diff --git a/inflammation-analysis.py b/inflammation-analysis.py index e1564317..4c612feb 100644 --- a/inflammation-analysis.py +++ b/inflammation-analysis.py @@ -27,7 +27,8 @@ def main(args): for filename in InFiles: inflammation_data = models.load_csv(filename) - view_data = {'average': models.daily_mean(inflammation_data), 'max': models.daily_max(inflammation_data), 'min': models.daily_min(inflammation_data)} + view_data = {'average': models.daily_mean(inflammation_data), 'max': models.daily_max(inflammation_data), 'min': models.daily_min(inflammation_data), **(models.s_dev(inflammation_data))} + views.visualize(view_data) diff --git a/inflammation/models.py b/inflammation/models.py index 94387ee3..ac91a5d4 100644 --- a/inflammation/models.py +++ b/inflammation/models.py @@ -54,3 +54,13 @@ def daily_min(data): """Calculate the daily min of a 2d inflammation data array.""" return np.min(data, axis=0) + +def s_dev(data): + """Computes and returns standard deviation for data.""" + data_mean = np.mean(data, axis=0) + devs = [] + for entry in data: + devs.append((entry - data_mean) * (entry - data_mean)) + + s_dev2 = sum(devs) / len(data) + return {'standard deviation': s_dev2} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..e497cf4c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +contourpy==1.2.1 +cycler==0.12.1 +fonttools==4.53.0 +kiwisolver==1.4.5 +matplotlib==3.9.0 +numpy==1.26.4 +packaging==24.0 +pillow==10.3.0 +pyparsing==3.1.2 +python-dateutil==2.9.0.post0 +six==1.16.0 diff --git a/tests/test_models.py b/tests/test_models.py index 292d00c4..b8adbfb0 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -3,7 +3,7 @@ import numpy as np import numpy.testing as npt import os - +import pytest def test_daily_mean_zeros(): """Test that mean function works for an array of zeros.""" @@ -37,3 +37,14 @@ def test_load_from_json(tmpdir): temp_json_file.write('[{"observations":[1, 2, 3]},{"observations":[4, 5, 6]}]') result = load_json(example_path) npt.assert_array_equal(result, [[1, 2, 3], [4, 5, 6]]) + + +@pytest.mark.parametrize('data, expected_standard_deviation', [ + ([0, 0, 0], 0.0), + ([1.0, 1.0, 1.0], 0), + ([0.0, 2.0], 1.0) +]) +def test_daily_standard_deviation(data, expected_standard_deviation): + from inflammation.models import s_dev + result_data = s_dev(data)['standard deviation'] + npt.assert_approx_equal(result_data, expected_standard_deviation) diff --git a/venv/bin/Activate.ps1 b/venv/bin/Activate.ps1 new file mode 100644 index 00000000..b49d77ba --- /dev/null +++ b/venv/bin/Activate.ps1 @@ -0,0 +1,247 @@ +<# +.Synopsis +Activate a Python virtual environment for the current PowerShell session. + +.Description +Pushes the python executable for a virtual environment to the front of the +$Env:PATH environment variable and sets the prompt to signify that you are +in a Python virtual environment. Makes use of the command line switches as +well as the `pyvenv.cfg` file values present in the virtual environment. + +.Parameter VenvDir +Path to the directory that contains the virtual environment to activate. The +default value for this is the parent of the directory that the Activate.ps1 +script is located within. + +.Parameter Prompt +The prompt prefix to display when this virtual environment is activated. By +default, this prompt is the name of the virtual environment folder (VenvDir) +surrounded by parentheses and followed by a single space (ie. '(.venv) '). + +.Example +Activate.ps1 +Activates the Python virtual environment that contains the Activate.ps1 script. + +.Example +Activate.ps1 -Verbose +Activates the Python virtual environment that contains the Activate.ps1 script, +and shows extra information about the activation as it executes. + +.Example +Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv +Activates the Python virtual environment located in the specified location. + +.Example +Activate.ps1 -Prompt "MyPython" +Activates the Python virtual environment that contains the Activate.ps1 script, +and prefixes the current prompt with the specified string (surrounded in +parentheses) while the virtual environment is active. + +.Notes +On Windows, it may be required to enable this Activate.ps1 script by setting the +execution policy for the user. You can do this by issuing the following PowerShell +command: + +PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +For more information on Execution Policies: +https://go.microsoft.com/fwlink/?LinkID=135170 + +#> +Param( + [Parameter(Mandatory = $false)] + [String] + $VenvDir, + [Parameter(Mandatory = $false)] + [String] + $Prompt +) + +<# Function declarations --------------------------------------------------- #> + +<# +.Synopsis +Remove all shell session elements added by the Activate script, including the +addition of the virtual environment's Python executable from the beginning of +the PATH variable. + +.Parameter NonDestructive +If present, do not remove this function from the global namespace for the +session. + +#> +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + + # The prior prompt: + if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { + Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT + } + + # The prior PYTHONHOME: + if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { + Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME + Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME + } + + # The prior PATH: + if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { + Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH + Remove-Item -Path Env:_OLD_VIRTUAL_PATH + } + + # Just remove the VIRTUAL_ENV altogether: + if (Test-Path -Path Env:VIRTUAL_ENV) { + Remove-Item -Path env:VIRTUAL_ENV + } + + # Just remove VIRTUAL_ENV_PROMPT altogether. + if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { + Remove-Item -Path env:VIRTUAL_ENV_PROMPT + } + + # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: + if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { + Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force + } + + # Leave deactivate function in the global namespace if requested: + if (-not $NonDestructive) { + Remove-Item -Path function:deactivate + } +} + +<# +.Description +Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the +given folder, and returns them in a map. + +For each line in the pyvenv.cfg file, if that line can be parsed into exactly +two strings separated by `=` (with any amount of whitespace surrounding the =) +then it is considered a `key = value` line. The left hand string is the key, +the right hand is the value. + +If the value starts with a `'` or a `"` then the first and last character is +stripped from the value before being captured. + +.Parameter ConfigDir +Path to the directory that contains the `pyvenv.cfg` file. +#> +function Get-PyVenvConfig( + [String] + $ConfigDir +) { + Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" + + # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). + $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue + + # An empty map will be returned if no config file is found. + $pyvenvConfig = @{ } + + if ($pyvenvConfigPath) { + + Write-Verbose "File exists, parse `key = value` lines" + $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath + + $pyvenvConfigContent | ForEach-Object { + $keyval = $PSItem -split "\s*=\s*", 2 + if ($keyval[0] -and $keyval[1]) { + $val = $keyval[1] + + # Remove extraneous quotations around a string value. + if ("'""".Contains($val.Substring(0, 1))) { + $val = $val.Substring(1, $val.Length - 2) + } + + $pyvenvConfig[$keyval[0]] = $val + Write-Verbose "Adding Key: '$($keyval[0])'='$val'" + } + } + } + return $pyvenvConfig +} + + +<# Begin Activate script --------------------------------------------------- #> + +# Determine the containing directory of this script +$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$VenvExecDir = Get-Item -Path $VenvExecPath + +Write-Verbose "Activation script is located in path: '$VenvExecPath'" +Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" +Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" + +# Set values required in priority: CmdLine, ConfigFile, Default +# First, get the location of the virtual environment, it might not be +# VenvExecDir if specified on the command line. +if ($VenvDir) { + Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" +} +else { + Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." + $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") + Write-Verbose "VenvDir=$VenvDir" +} + +# Next, read the `pyvenv.cfg` file to determine any required value such +# as `prompt`. +$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir + +# Next, set the prompt from the command line, or the config file, or +# just use the name of the virtual environment folder. +if ($Prompt) { + Write-Verbose "Prompt specified as argument, using '$Prompt'" +} +else { + Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" + if ($pyvenvCfg -and $pyvenvCfg['prompt']) { + Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" + $Prompt = $pyvenvCfg['prompt']; + } + else { + Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" + Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" + $Prompt = Split-Path -Path $venvDir -Leaf + } +} + +Write-Verbose "Prompt = '$Prompt'" +Write-Verbose "VenvDir='$VenvDir'" + +# Deactivate any currently active virtual environment, but leave the +# deactivate function in place. +deactivate -nondestructive + +# Now set the environment variable VIRTUAL_ENV, used by many tools to determine +# that there is an activated venv. +$env:VIRTUAL_ENV = $VenvDir + +if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { + + Write-Verbose "Setting prompt to '$Prompt'" + + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT { "" } + Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT + New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt + + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " + _OLD_VIRTUAL_PROMPT + } + $env:VIRTUAL_ENV_PROMPT = $Prompt +} + +# Clear PYTHONHOME +if (Test-Path -Path Env:PYTHONHOME) { + Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME + Remove-Item -Path Env:PYTHONHOME +} + +# Add the venv to the PATH +Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH +$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/venv/bin/activate b/venv/bin/activate new file mode 100644 index 00000000..3c25df7d --- /dev/null +++ b/venv/bin/activate @@ -0,0 +1,69 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + unset VIRTUAL_ENV_PROMPT + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/home/tgermany/python-intermediate-inflammation/venv" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(venv) ${PS1:-}" + export PS1 + VIRTUAL_ENV_PROMPT="(venv) " + export VIRTUAL_ENV_PROMPT +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null +fi diff --git a/venv/bin/activate.csh b/venv/bin/activate.csh new file mode 100644 index 00000000..9699e778 --- /dev/null +++ b/venv/bin/activate.csh @@ -0,0 +1,26 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . +# Ported to Python 3.3 venv by Andrew Svetlov + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/home/tgermany/python-intermediate-inflammation/venv" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + +set _OLD_VIRTUAL_PROMPT="$prompt" + +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "(venv) $prompt" + setenv VIRTUAL_ENV_PROMPT "(venv) " +endif + +alias pydoc python -m pydoc + +rehash diff --git a/venv/bin/activate.fish b/venv/bin/activate.fish new file mode 100644 index 00000000..891b5f19 --- /dev/null +++ b/venv/bin/activate.fish @@ -0,0 +1,69 @@ +# This file must be used with "source /bin/activate.fish" *from fish* +# (https://fishshell.com/); you cannot run it directly. + +function deactivate -d "Exit virtual environment and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + set -e _OLD_FISH_PROMPT_OVERRIDE + # prevents error when using nested fish instances (Issue #93858) + if functions -q _old_fish_prompt + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + end + end + + set -e VIRTUAL_ENV + set -e VIRTUAL_ENV_PROMPT + if test "$argv[1]" != "nondestructive" + # Self-destruct! + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/home/tgermany/python-intermediate-inflammation/venv" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset PYTHONHOME if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # Save the current fish_prompt function as the function _old_fish_prompt. + functions -c fish_prompt _old_fish_prompt + + # With the original prompt function renamed, we can override with our own. + function fish_prompt + # Save the return status of the last command. + set -l old_status $status + + # Output the venv prompt; color taken from the blue of the Python logo. + printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal) + + # Restore the return status of the previous command. + echo "exit $old_status" | . + # Output the original/"old" prompt. + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" + set -gx VIRTUAL_ENV_PROMPT "(venv) " +end diff --git a/venv/bin/f2py b/venv/bin/f2py new file mode 100755 index 00000000..d07ae78f --- /dev/null +++ b/venv/bin/f2py @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/fonttools b/venv/bin/fonttools new file mode 100755 index 00000000..dcb9d272 --- /dev/null +++ b/venv/bin/fonttools @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from fontTools.__main__ import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/pip b/venv/bin/pip new file mode 100755 index 00000000..33fb7d88 --- /dev/null +++ b/venv/bin/pip @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/pip3 b/venv/bin/pip3 new file mode 100755 index 00000000..33fb7d88 --- /dev/null +++ b/venv/bin/pip3 @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/pip3.10 b/venv/bin/pip3.10 new file mode 100755 index 00000000..33fb7d88 --- /dev/null +++ b/venv/bin/pip3.10 @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/pyftmerge b/venv/bin/pyftmerge new file mode 100755 index 00000000..45a39a4c --- /dev/null +++ b/venv/bin/pyftmerge @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from fontTools.merge import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/pyftsubset b/venv/bin/pyftsubset new file mode 100755 index 00000000..7d07e277 --- /dev/null +++ b/venv/bin/pyftsubset @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from fontTools.subset import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/bin/python b/venv/bin/python new file mode 120000 index 00000000..b8a0adbb --- /dev/null +++ b/venv/bin/python @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/venv/bin/python3 b/venv/bin/python3 new file mode 120000 index 00000000..ae65fdaa --- /dev/null +++ b/venv/bin/python3 @@ -0,0 +1 @@ +/usr/bin/python3 \ No newline at end of file diff --git a/venv/bin/python3.10 b/venv/bin/python3.10 new file mode 120000 index 00000000..b8a0adbb --- /dev/null +++ b/venv/bin/python3.10 @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/venv/bin/ttx b/venv/bin/ttx new file mode 100755 index 00000000..2121de51 --- /dev/null +++ b/venv/bin/ttx @@ -0,0 +1,8 @@ +#!/home/tgermany/python-intermediate-inflammation/venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from fontTools.ttx import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/venv/lib/python3.10/site-packages/PIL/BdfFontFile.py b/venv/lib/python3.10/site-packages/PIL/BdfFontFile.py new file mode 100644 index 00000000..e3eda4fe --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/BdfFontFile.py @@ -0,0 +1,133 @@ +# +# The Python Imaging Library +# $Id$ +# +# bitmap distribution font (bdf) file parser +# +# history: +# 1996-05-16 fl created (as bdf2pil) +# 1997-08-25 fl converted to FontFile driver +# 2001-05-25 fl removed bogus __init__ call +# 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev) +# 2003-04-22 fl more robustification (from Graham Dumpleton) +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1997-2003 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +""" +Parse X Bitmap Distribution Format (BDF) +""" +from __future__ import annotations + +from typing import BinaryIO + +from . import FontFile, Image + +bdf_slant = { + "R": "Roman", + "I": "Italic", + "O": "Oblique", + "RI": "Reverse Italic", + "RO": "Reverse Oblique", + "OT": "Other", +} + +bdf_spacing = {"P": "Proportional", "M": "Monospaced", "C": "Cell"} + + +def bdf_char( + f: BinaryIO, +) -> ( + tuple[ + str, + int, + tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int]], + Image.Image, + ] + | None +): + # skip to STARTCHAR + while True: + s = f.readline() + if not s: + return None + if s[:9] == b"STARTCHAR": + break + id = s[9:].strip().decode("ascii") + + # load symbol properties + props = {} + while True: + s = f.readline() + if not s or s[:6] == b"BITMAP": + break + i = s.find(b" ") + props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii") + + # load bitmap + bitmap = bytearray() + while True: + s = f.readline() + if not s or s[:7] == b"ENDCHAR": + break + bitmap += s[:-1] + + # The word BBX + # followed by the width in x (BBw), height in y (BBh), + # and x and y displacement (BBxoff0, BByoff0) + # of the lower left corner from the origin of the character. + width, height, x_disp, y_disp = (int(p) for p in props["BBX"].split()) + + # The word DWIDTH + # followed by the width in x and y of the character in device pixels. + dwx, dwy = (int(p) for p in props["DWIDTH"].split()) + + bbox = ( + (dwx, dwy), + (x_disp, -y_disp - height, width + x_disp, -y_disp), + (0, 0, width, height), + ) + + try: + im = Image.frombytes("1", (width, height), bitmap, "hex", "1") + except ValueError: + # deal with zero-width characters + im = Image.new("1", (width, height)) + + return id, int(props["ENCODING"]), bbox, im + + +class BdfFontFile(FontFile.FontFile): + """Font file plugin for the X11 BDF format.""" + + def __init__(self, fp: BinaryIO): + super().__init__() + + s = fp.readline() + if s[:13] != b"STARTFONT 2.1": + msg = "not a valid BDF file" + raise SyntaxError(msg) + + props = {} + comments = [] + + while True: + s = fp.readline() + if not s or s[:13] == b"ENDPROPERTIES": + break + i = s.find(b" ") + props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii") + if s[:i] in [b"COMMENT", b"COPYRIGHT"]: + if s.find(b"LogicalFontDescription") < 0: + comments.append(s[i + 1 : -1].decode("ascii")) + + while True: + c = bdf_char(fp) + if not c: + break + id, ch, (xy, dst, src), im = c + if 0 <= ch < len(self.glyph): + self.glyph[ch] = xy, dst, src, im diff --git a/venv/lib/python3.10/site-packages/PIL/BlpImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/BlpImagePlugin.py new file mode 100644 index 00000000..95e80778 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/BlpImagePlugin.py @@ -0,0 +1,476 @@ +""" +Blizzard Mipmap Format (.blp) +Jerome Leclanche + +The contents of this file are hereby released in the public domain (CC0) +Full text of the CC0 license: + https://creativecommons.org/publicdomain/zero/1.0/ + +BLP1 files, used mostly in Warcraft III, are not fully supported. +All types of BLP2 files used in World of Warcraft are supported. + +The BLP file structure consists of a header, up to 16 mipmaps of the +texture + +Texture sizes must be powers of two, though the two dimensions do +not have to be equal; 512x256 is valid, but 512x200 is not. +The first mipmap (mipmap #0) is the full size image; each subsequent +mipmap halves both dimensions. The final mipmap should be 1x1. + +BLP files come in many different flavours: +* JPEG-compressed (type == 0) - only supported for BLP1. +* RAW images (type == 1, encoding == 1). Each mipmap is stored as an + array of 8-bit values, one per pixel, left to right, top to bottom. + Each value is an index to the palette. +* DXT-compressed (type == 1, encoding == 2): +- DXT1 compression is used if alpha_encoding == 0. + - An additional alpha bit is used if alpha_depth == 1. + - DXT3 compression is used if alpha_encoding == 1. + - DXT5 compression is used if alpha_encoding == 7. +""" + +from __future__ import annotations + +import os +import struct +from enum import IntEnum +from io import BytesIO + +from . import Image, ImageFile + + +class Format(IntEnum): + JPEG = 0 + + +class Encoding(IntEnum): + UNCOMPRESSED = 1 + DXT = 2 + UNCOMPRESSED_RAW_BGRA = 3 + + +class AlphaEncoding(IntEnum): + DXT1 = 0 + DXT3 = 1 + DXT5 = 7 + + +def unpack_565(i): + return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3 + + +def decode_dxt1(data, alpha=False): + """ + input: one "row" of data (i.e. will produce 4*width pixels) + """ + + blocks = len(data) // 8 # number of blocks in row + ret = (bytearray(), bytearray(), bytearray(), bytearray()) + + for block in range(blocks): + # Decode next 8-byte block. + idx = block * 8 + color0, color1, bits = struct.unpack_from("> 2 + + a = 0xFF + if control == 0: + r, g, b = r0, g0, b0 + elif control == 1: + r, g, b = r1, g1, b1 + elif control == 2: + if color0 > color1: + r = (2 * r0 + r1) // 3 + g = (2 * g0 + g1) // 3 + b = (2 * b0 + b1) // 3 + else: + r = (r0 + r1) // 2 + g = (g0 + g1) // 2 + b = (b0 + b1) // 2 + elif control == 3: + if color0 > color1: + r = (2 * r1 + r0) // 3 + g = (2 * g1 + g0) // 3 + b = (2 * b1 + b0) // 3 + else: + r, g, b, a = 0, 0, 0, 0 + + if alpha: + ret[j].extend([r, g, b, a]) + else: + ret[j].extend([r, g, b]) + + return ret + + +def decode_dxt3(data): + """ + input: one "row" of data (i.e. will produce 4*width pixels) + """ + + blocks = len(data) // 16 # number of blocks in row + ret = (bytearray(), bytearray(), bytearray(), bytearray()) + + for block in range(blocks): + idx = block * 16 + block = data[idx : idx + 16] + # Decode next 16-byte block. + bits = struct.unpack_from("<8B", block) + color0, color1 = struct.unpack_from(">= 4 + else: + high = True + a &= 0xF + a *= 17 # We get a value between 0 and 15 + + color_code = (code >> 2 * (4 * j + i)) & 0x03 + + if color_code == 0: + r, g, b = r0, g0, b0 + elif color_code == 1: + r, g, b = r1, g1, b1 + elif color_code == 2: + r = (2 * r0 + r1) // 3 + g = (2 * g0 + g1) // 3 + b = (2 * b0 + b1) // 3 + elif color_code == 3: + r = (2 * r1 + r0) // 3 + g = (2 * g1 + g0) // 3 + b = (2 * b1 + b0) // 3 + + ret[j].extend([r, g, b, a]) + + return ret + + +def decode_dxt5(data): + """ + input: one "row" of data (i.e. will produce 4 * width pixels) + """ + + blocks = len(data) // 16 # number of blocks in row + ret = (bytearray(), bytearray(), bytearray(), bytearray()) + + for block in range(blocks): + idx = block * 16 + block = data[idx : idx + 16] + # Decode next 16-byte block. + a0, a1 = struct.unpack_from("> alphacode_index) & 0x07 + elif alphacode_index == 15: + alphacode = (alphacode2 >> 15) | ((alphacode1 << 1) & 0x06) + else: # alphacode_index >= 18 and alphacode_index <= 45 + alphacode = (alphacode1 >> (alphacode_index - 16)) & 0x07 + + if alphacode == 0: + a = a0 + elif alphacode == 1: + a = a1 + elif a0 > a1: + a = ((8 - alphacode) * a0 + (alphacode - 1) * a1) // 7 + elif alphacode == 6: + a = 0 + elif alphacode == 7: + a = 255 + else: + a = ((6 - alphacode) * a0 + (alphacode - 1) * a1) // 5 + + color_code = (code >> 2 * (4 * j + i)) & 0x03 + + if color_code == 0: + r, g, b = r0, g0, b0 + elif color_code == 1: + r, g, b = r1, g1, b1 + elif color_code == 2: + r = (2 * r0 + r1) // 3 + g = (2 * g0 + g1) // 3 + b = (2 * b0 + b1) // 3 + elif color_code == 3: + r = (2 * r1 + r0) // 3 + g = (2 * g1 + g0) // 3 + b = (2 * b1 + b0) // 3 + + ret[j].extend([r, g, b, a]) + + return ret + + +class BLPFormatError(NotImplementedError): + pass + + +def _accept(prefix): + return prefix[:4] in (b"BLP1", b"BLP2") + + +class BlpImageFile(ImageFile.ImageFile): + """ + Blizzard Mipmap Format + """ + + format = "BLP" + format_description = "Blizzard Mipmap Format" + + def _open(self): + self.magic = self.fp.read(4) + + self.fp.seek(5, os.SEEK_CUR) + (self._blp_alpha_depth,) = struct.unpack(" mode, rawmode + 1: ("P", "P;1"), + 4: ("P", "P;4"), + 8: ("P", "P"), + 16: ("RGB", "BGR;15"), + 24: ("RGB", "BGR"), + 32: ("RGB", "BGRX"), +} + + +def _accept(prefix): + return prefix[:2] == b"BM" + + +def _dib_accept(prefix): + return i32(prefix) in [12, 40, 64, 108, 124] + + +# ============================================================================= +# Image plugin for the Windows BMP format. +# ============================================================================= +class BmpImageFile(ImageFile.ImageFile): + """Image plugin for the Windows Bitmap format (BMP)""" + + # ------------------------------------------------------------- Description + format_description = "Windows Bitmap" + format = "BMP" + + # -------------------------------------------------- BMP Compression values + COMPRESSIONS = {"RAW": 0, "RLE8": 1, "RLE4": 2, "BITFIELDS": 3, "JPEG": 4, "PNG": 5} + for k, v in COMPRESSIONS.items(): + vars()[k] = v + + def _bitmap(self, header=0, offset=0): + """Read relevant info about the BMP""" + read, seek = self.fp.read, self.fp.seek + if header: + seek(header) + # read bmp header size @offset 14 (this is part of the header size) + file_info = {"header_size": i32(read(4)), "direction": -1} + + # -------------------- If requested, read header at a specific position + # read the rest of the bmp header, without its size + header_data = ImageFile._safe_read(self.fp, file_info["header_size"] - 4) + + # -------------------------------------------------- IBM OS/2 Bitmap v1 + # ----- This format has different offsets because of width/height types + if file_info["header_size"] == 12: + file_info["width"] = i16(header_data, 0) + file_info["height"] = i16(header_data, 2) + file_info["planes"] = i16(header_data, 4) + file_info["bits"] = i16(header_data, 6) + file_info["compression"] = self.RAW + file_info["palette_padding"] = 3 + + # --------------------------------------------- Windows Bitmap v2 to v5 + # v3, OS/2 v2, v4, v5 + elif file_info["header_size"] in (40, 64, 108, 124): + file_info["y_flip"] = header_data[7] == 0xFF + file_info["direction"] = 1 if file_info["y_flip"] else -1 + file_info["width"] = i32(header_data, 0) + file_info["height"] = ( + i32(header_data, 4) + if not file_info["y_flip"] + else 2**32 - i32(header_data, 4) + ) + file_info["planes"] = i16(header_data, 8) + file_info["bits"] = i16(header_data, 10) + file_info["compression"] = i32(header_data, 12) + # byte size of pixel data + file_info["data_size"] = i32(header_data, 16) + file_info["pixels_per_meter"] = ( + i32(header_data, 20), + i32(header_data, 24), + ) + file_info["colors"] = i32(header_data, 28) + file_info["palette_padding"] = 4 + self.info["dpi"] = tuple(x / 39.3701 for x in file_info["pixels_per_meter"]) + if file_info["compression"] == self.BITFIELDS: + if len(header_data) >= 52: + for idx, mask in enumerate( + ["r_mask", "g_mask", "b_mask", "a_mask"] + ): + file_info[mask] = i32(header_data, 36 + idx * 4) + else: + # 40 byte headers only have the three components in the + # bitfields masks, ref: + # https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx + # See also + # https://github.com/python-pillow/Pillow/issues/1293 + # There is a 4th component in the RGBQuad, in the alpha + # location, but it is listed as a reserved component, + # and it is not generally an alpha channel + file_info["a_mask"] = 0x0 + for mask in ["r_mask", "g_mask", "b_mask"]: + file_info[mask] = i32(read(4)) + file_info["rgb_mask"] = ( + file_info["r_mask"], + file_info["g_mask"], + file_info["b_mask"], + ) + file_info["rgba_mask"] = ( + file_info["r_mask"], + file_info["g_mask"], + file_info["b_mask"], + file_info["a_mask"], + ) + else: + msg = f"Unsupported BMP header type ({file_info['header_size']})" + raise OSError(msg) + + # ------------------ Special case : header is reported 40, which + # ---------------------- is shorter than real size for bpp >= 16 + self._size = file_info["width"], file_info["height"] + + # ------- If color count was not found in the header, compute from bits + file_info["colors"] = ( + file_info["colors"] + if file_info.get("colors", 0) + else (1 << file_info["bits"]) + ) + if offset == 14 + file_info["header_size"] and file_info["bits"] <= 8: + offset += 4 * file_info["colors"] + + # ---------------------- Check bit depth for unusual unsupported values + self._mode, raw_mode = BIT2MODE.get(file_info["bits"], (None, None)) + if self.mode is None: + msg = f"Unsupported BMP pixel depth ({file_info['bits']})" + raise OSError(msg) + + # ---------------- Process BMP with Bitfields compression (not palette) + decoder_name = "raw" + if file_info["compression"] == self.BITFIELDS: + SUPPORTED = { + 32: [ + (0xFF0000, 0xFF00, 0xFF, 0x0), + (0xFF000000, 0xFF0000, 0xFF00, 0x0), + (0xFF000000, 0xFF0000, 0xFF00, 0xFF), + (0xFF, 0xFF00, 0xFF0000, 0xFF000000), + (0xFF0000, 0xFF00, 0xFF, 0xFF000000), + (0x0, 0x0, 0x0, 0x0), + ], + 24: [(0xFF0000, 0xFF00, 0xFF)], + 16: [(0xF800, 0x7E0, 0x1F), (0x7C00, 0x3E0, 0x1F)], + } + MASK_MODES = { + (32, (0xFF0000, 0xFF00, 0xFF, 0x0)): "BGRX", + (32, (0xFF000000, 0xFF0000, 0xFF00, 0x0)): "XBGR", + (32, (0xFF000000, 0xFF0000, 0xFF00, 0xFF)): "ABGR", + (32, (0xFF, 0xFF00, 0xFF0000, 0xFF000000)): "RGBA", + (32, (0xFF0000, 0xFF00, 0xFF, 0xFF000000)): "BGRA", + (32, (0x0, 0x0, 0x0, 0x0)): "BGRA", + (24, (0xFF0000, 0xFF00, 0xFF)): "BGR", + (16, (0xF800, 0x7E0, 0x1F)): "BGR;16", + (16, (0x7C00, 0x3E0, 0x1F)): "BGR;15", + } + if file_info["bits"] in SUPPORTED: + if ( + file_info["bits"] == 32 + and file_info["rgba_mask"] in SUPPORTED[file_info["bits"]] + ): + raw_mode = MASK_MODES[(file_info["bits"], file_info["rgba_mask"])] + self._mode = "RGBA" if "A" in raw_mode else self.mode + elif ( + file_info["bits"] in (24, 16) + and file_info["rgb_mask"] in SUPPORTED[file_info["bits"]] + ): + raw_mode = MASK_MODES[(file_info["bits"], file_info["rgb_mask"])] + else: + msg = "Unsupported BMP bitfields layout" + raise OSError(msg) + else: + msg = "Unsupported BMP bitfields layout" + raise OSError(msg) + elif file_info["compression"] == self.RAW: + if file_info["bits"] == 32 and header == 22: # 32-bit .cur offset + raw_mode, self._mode = "BGRA", "RGBA" + elif file_info["compression"] in (self.RLE8, self.RLE4): + decoder_name = "bmp_rle" + else: + msg = f"Unsupported BMP compression ({file_info['compression']})" + raise OSError(msg) + + # --------------- Once the header is processed, process the palette/LUT + if self.mode == "P": # Paletted for 1, 4 and 8 bit images + # ---------------------------------------------------- 1-bit images + if not (0 < file_info["colors"] <= 65536): + msg = f"Unsupported BMP Palette size ({file_info['colors']})" + raise OSError(msg) + else: + padding = file_info["palette_padding"] + palette = read(padding * file_info["colors"]) + grayscale = True + indices = ( + (0, 255) + if file_info["colors"] == 2 + else list(range(file_info["colors"])) + ) + + # ----------------- Check if grayscale and ignore palette if so + for ind, val in enumerate(indices): + rgb = palette[ind * padding : ind * padding + 3] + if rgb != o8(val) * 3: + grayscale = False + + # ------- If all colors are gray, white or black, ditch palette + if grayscale: + self._mode = "1" if file_info["colors"] == 2 else "L" + raw_mode = self.mode + else: + self._mode = "P" + self.palette = ImagePalette.raw( + "BGRX" if padding == 4 else "BGR", palette + ) + + # ---------------------------- Finally set the tile data for the plugin + self.info["compression"] = file_info["compression"] + args = [raw_mode] + if decoder_name == "bmp_rle": + args.append(file_info["compression"] == self.RLE4) + else: + args.append(((file_info["width"] * file_info["bits"] + 31) >> 3) & (~3)) + args.append(file_info["direction"]) + self.tile = [ + ( + decoder_name, + (0, 0, file_info["width"], file_info["height"]), + offset or self.fp.tell(), + tuple(args), + ) + ] + + def _open(self): + """Open file, check magic number and read header""" + # read 14 bytes: magic number, filesize, reserved, header final offset + head_data = self.fp.read(14) + # choke if the file does not have the required magic bytes + if not _accept(head_data): + msg = "Not a BMP file" + raise SyntaxError(msg) + # read the start position of the BMP image data (u32) + offset = i32(head_data, 10) + # load bitmap information (offset=raster info) + self._bitmap(offset=offset) + + +class BmpRleDecoder(ImageFile.PyDecoder): + _pulls_fd = True + + def decode(self, buffer): + rle4 = self.args[1] + data = bytearray() + x = 0 + dest_length = self.state.xsize * self.state.ysize + while len(data) < dest_length: + pixels = self.fd.read(1) + byte = self.fd.read(1) + if not pixels or not byte: + break + num_pixels = pixels[0] + if num_pixels: + # encoded mode + if x + num_pixels > self.state.xsize: + # Too much data for row + num_pixels = max(0, self.state.xsize - x) + if rle4: + first_pixel = o8(byte[0] >> 4) + second_pixel = o8(byte[0] & 0x0F) + for index in range(num_pixels): + if index % 2 == 0: + data += first_pixel + else: + data += second_pixel + else: + data += byte * num_pixels + x += num_pixels + else: + if byte[0] == 0: + # end of line + while len(data) % self.state.xsize != 0: + data += b"\x00" + x = 0 + elif byte[0] == 1: + # end of bitmap + break + elif byte[0] == 2: + # delta + bytes_read = self.fd.read(2) + if len(bytes_read) < 2: + break + right, up = self.fd.read(2) + data += b"\x00" * (right + up * self.state.xsize) + x = len(data) % self.state.xsize + else: + # absolute mode + if rle4: + # 2 pixels per byte + byte_count = byte[0] // 2 + bytes_read = self.fd.read(byte_count) + for byte_read in bytes_read: + data += o8(byte_read >> 4) + data += o8(byte_read & 0x0F) + else: + byte_count = byte[0] + bytes_read = self.fd.read(byte_count) + data += bytes_read + if len(bytes_read) < byte_count: + break + x += byte[0] + + # align to 16-bit word boundary + if self.fd.tell() % 2 != 0: + self.fd.seek(1, os.SEEK_CUR) + rawmode = "L" if self.mode == "L" else "P" + self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1])) + return -1, 0 + + +# ============================================================================= +# Image plugin for the DIB format (BMP alias) +# ============================================================================= +class DibImageFile(BmpImageFile): + format = "DIB" + format_description = "Windows Bitmap" + + def _open(self): + self._bitmap() + + +# +# -------------------------------------------------------------------- +# Write BMP file + + +SAVE = { + "1": ("1", 1, 2), + "L": ("L", 8, 256), + "P": ("P", 8, 256), + "RGB": ("BGR", 24, 0), + "RGBA": ("BGRA", 32, 0), +} + + +def _dib_save(im, fp, filename): + _save(im, fp, filename, False) + + +def _save(im, fp, filename, bitmap_header=True): + try: + rawmode, bits, colors = SAVE[im.mode] + except KeyError as e: + msg = f"cannot write mode {im.mode} as BMP" + raise OSError(msg) from e + + info = im.encoderinfo + + dpi = info.get("dpi", (96, 96)) + + # 1 meter == 39.3701 inches + ppm = tuple(int(x * 39.3701 + 0.5) for x in dpi) + + stride = ((im.size[0] * bits + 7) // 8 + 3) & (~3) + header = 40 # or 64 for OS/2 version 2 + image = stride * im.size[1] + + if im.mode == "1": + palette = b"".join(o8(i) * 4 for i in (0, 255)) + elif im.mode == "L": + palette = b"".join(o8(i) * 4 for i in range(256)) + elif im.mode == "P": + palette = im.im.getpalette("RGB", "BGRX") + colors = len(palette) // 4 + else: + palette = None + + # bitmap header + if bitmap_header: + offset = 14 + header + colors * 4 + file_size = offset + image + if file_size > 2**32 - 1: + msg = "File size is too large for the BMP format" + raise ValueError(msg) + fp.write( + b"BM" # file type (magic) + + o32(file_size) # file size + + o32(0) # reserved + + o32(offset) # image data offset + ) + + # bitmap info header + fp.write( + o32(header) # info header size + + o32(im.size[0]) # width + + o32(im.size[1]) # height + + o16(1) # planes + + o16(bits) # depth + + o32(0) # compression (0=uncompressed) + + o32(image) # size of bitmap + + o32(ppm[0]) # resolution + + o32(ppm[1]) # resolution + + o32(colors) # colors used + + o32(colors) # colors important + ) + + fp.write(b"\0" * (header - 40)) # padding (for OS/2 format) + + if palette: + fp.write(palette) + + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, stride, -1))]) + + +# +# -------------------------------------------------------------------- +# Registry + + +Image.register_open(BmpImageFile.format, BmpImageFile, _accept) +Image.register_save(BmpImageFile.format, _save) + +Image.register_extension(BmpImageFile.format, ".bmp") + +Image.register_mime(BmpImageFile.format, "image/bmp") + +Image.register_decoder("bmp_rle", BmpRleDecoder) + +Image.register_open(DibImageFile.format, DibImageFile, _dib_accept) +Image.register_save(DibImageFile.format, _dib_save) + +Image.register_extension(DibImageFile.format, ".dib") + +Image.register_mime(DibImageFile.format, "image/bmp") diff --git a/venv/lib/python3.10/site-packages/PIL/BufrStubImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/BufrStubImagePlugin.py new file mode 100644 index 00000000..60f3ec25 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/BufrStubImagePlugin.py @@ -0,0 +1,74 @@ +# +# The Python Imaging Library +# $Id$ +# +# BUFR stub adapter +# +# Copyright (c) 1996-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile + +_handler = None + + +def register_handler(handler): + """ + Install application-specific BUFR image handler. + + :param handler: Handler object. + """ + global _handler + _handler = handler + + +# -------------------------------------------------------------------- +# Image adapter + + +def _accept(prefix): + return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC" + + +class BufrStubImageFile(ImageFile.StubImageFile): + format = "BUFR" + format_description = "BUFR" + + def _open(self): + offset = self.fp.tell() + + if not _accept(self.fp.read(4)): + msg = "Not a BUFR file" + raise SyntaxError(msg) + + self.fp.seek(offset) + + # make something up + self._mode = "F" + self._size = 1, 1 + + loader = self._load() + if loader: + loader.open(self) + + def _load(self): + return _handler + + +def _save(im, fp, filename): + if _handler is None or not hasattr(_handler, "save"): + msg = "BUFR save handler not installed" + raise OSError(msg) + _handler.save(im, fp, filename) + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(BufrStubImageFile.format, BufrStubImageFile, _accept) +Image.register_save(BufrStubImageFile.format, _save) + +Image.register_extension(BufrStubImageFile.format, ".bufr") diff --git a/venv/lib/python3.10/site-packages/PIL/ContainerIO.py b/venv/lib/python3.10/site-packages/PIL/ContainerIO.py new file mode 100644 index 00000000..0035296a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ContainerIO.py @@ -0,0 +1,121 @@ +# +# The Python Imaging Library. +# $Id$ +# +# a class to read from a container file +# +# History: +# 1995-06-18 fl Created +# 1995-09-07 fl Added readline(), readlines() +# +# Copyright (c) 1997-2001 by Secret Labs AB +# Copyright (c) 1995 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +from typing import IO, AnyStr, Generic, Literal + + +class ContainerIO(Generic[AnyStr]): + """ + A file object that provides read access to a part of an existing + file (for example a TAR file). + """ + + def __init__(self, file: IO[AnyStr], offset: int, length: int) -> None: + """ + Create file object. + + :param file: Existing file. + :param offset: Start of region, in bytes. + :param length: Size of region, in bytes. + """ + self.fh: IO[AnyStr] = file + self.pos = 0 + self.offset = offset + self.length = length + self.fh.seek(offset) + + ## + # Always false. + + def isatty(self) -> bool: + return False + + def seek(self, offset: int, mode: Literal[0, 1, 2] = io.SEEK_SET) -> None: + """ + Move file pointer. + + :param offset: Offset in bytes. + :param mode: Starting position. Use 0 for beginning of region, 1 + for current offset, and 2 for end of region. You cannot move + the pointer outside the defined region. + """ + if mode == 1: + self.pos = self.pos + offset + elif mode == 2: + self.pos = self.length + offset + else: + self.pos = offset + # clamp + self.pos = max(0, min(self.pos, self.length)) + self.fh.seek(self.offset + self.pos) + + def tell(self) -> int: + """ + Get current file pointer. + + :returns: Offset from start of region, in bytes. + """ + return self.pos + + def read(self, n: int = 0) -> AnyStr: + """ + Read data. + + :param n: Number of bytes to read. If omitted or zero, + read until end of region. + :returns: An 8-bit string. + """ + if n: + n = min(n, self.length - self.pos) + else: + n = self.length - self.pos + if not n: # EOF + return b"" if "b" in self.fh.mode else "" # type: ignore[return-value] + self.pos = self.pos + n + return self.fh.read(n) + + def readline(self) -> AnyStr: + """ + Read a line of text. + + :returns: An 8-bit string. + """ + s: AnyStr = b"" if "b" in self.fh.mode else "" # type: ignore[assignment] + newline_character = b"\n" if "b" in self.fh.mode else "\n" + while True: + c = self.read(1) + if not c: + break + s = s + c + if c == newline_character: + break + return s + + def readlines(self) -> list[AnyStr]: + """ + Read multiple lines of text. + + :returns: A list of 8-bit strings. + """ + lines = [] + while True: + s = self.readline() + if not s: + break + lines.append(s) + return lines diff --git a/venv/lib/python3.10/site-packages/PIL/CurImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/CurImagePlugin.py new file mode 100644 index 00000000..5fb2b019 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/CurImagePlugin.py @@ -0,0 +1,75 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Windows Cursor support for PIL +# +# notes: +# uses BmpImagePlugin.py to read the bitmap data. +# +# history: +# 96-05-27 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import BmpImagePlugin, Image +from ._binary import i16le as i16 +from ._binary import i32le as i32 + +# +# -------------------------------------------------------------------- + + +def _accept(prefix): + return prefix[:4] == b"\0\0\2\0" + + +## +# Image plugin for Windows Cursor files. + + +class CurImageFile(BmpImagePlugin.BmpImageFile): + format = "CUR" + format_description = "Windows Cursor" + + def _open(self): + offset = self.fp.tell() + + # check magic + s = self.fp.read(6) + if not _accept(s): + msg = "not a CUR file" + raise SyntaxError(msg) + + # pick the largest cursor in the file + m = b"" + for i in range(i16(s, 4)): + s = self.fp.read(16) + if not m: + m = s + elif s[0] > m[0] and s[1] > m[1]: + m = s + if not m: + msg = "No cursors were found" + raise TypeError(msg) + + # load as bitmap + self._bitmap(i32(m, 12) + offset) + + # patch up the bitmap height + self._size = self.size[0], self.size[1] // 2 + d, e, o, a = self.tile[0] + self.tile[0] = d, (0, 0) + self.size, o, a + + +# +# -------------------------------------------------------------------- + +Image.register_open(CurImageFile.format, CurImageFile, _accept) + +Image.register_extension(CurImageFile.format, ".cur") diff --git a/venv/lib/python3.10/site-packages/PIL/DcxImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/DcxImagePlugin.py new file mode 100644 index 00000000..f7344df4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/DcxImagePlugin.py @@ -0,0 +1,80 @@ +# +# The Python Imaging Library. +# $Id$ +# +# DCX file handling +# +# DCX is a container file format defined by Intel, commonly used +# for fax applications. Each DCX file consists of a directory +# (a list of file offsets) followed by a set of (usually 1-bit) +# PCX files. +# +# History: +# 1995-09-09 fl Created +# 1996-03-20 fl Properly derived from PcxImageFile. +# 1998-07-15 fl Renamed offset attribute to avoid name clash +# 2002-07-30 fl Fixed file handling +# +# Copyright (c) 1997-98 by Secret Labs AB. +# Copyright (c) 1995-96 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image +from ._binary import i32le as i32 +from .PcxImagePlugin import PcxImageFile + +MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? + + +def _accept(prefix): + return len(prefix) >= 4 and i32(prefix) == MAGIC + + +## +# Image plugin for the Intel DCX format. + + +class DcxImageFile(PcxImageFile): + format = "DCX" + format_description = "Intel DCX" + _close_exclusive_fp_after_loading = False + + def _open(self): + # Header + s = self.fp.read(4) + if not _accept(s): + msg = "not a DCX file" + raise SyntaxError(msg) + + # Component directory + self._offset = [] + for i in range(1024): + offset = i32(self.fp.read(4)) + if not offset: + break + self._offset.append(offset) + + self._fp = self.fp + self.frame = None + self.n_frames = len(self._offset) + self.is_animated = self.n_frames > 1 + self.seek(0) + + def seek(self, frame): + if not self._seek_check(frame): + return + self.frame = frame + self.fp = self._fp + self.fp.seek(self._offset[frame]) + PcxImageFile._open(self) + + def tell(self): + return self.frame + + +Image.register_open(DcxImageFile.format, DcxImageFile, _accept) + +Image.register_extension(DcxImageFile.format, ".dcx") diff --git a/venv/lib/python3.10/site-packages/PIL/DdsImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/DdsImagePlugin.py new file mode 100644 index 00000000..93c8e341 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/DdsImagePlugin.py @@ -0,0 +1,572 @@ +""" +A Pillow loader for .dds files (S3TC-compressed aka DXTC) +Jerome Leclanche + +Documentation: +https://web.archive.org/web/20170802060935/http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt + +The contents of this file are hereby released in the public domain (CC0) +Full text of the CC0 license: +https://creativecommons.org/publicdomain/zero/1.0/ +""" + +from __future__ import annotations + +import io +import struct +import sys +from enum import IntEnum, IntFlag + +from . import Image, ImageFile, ImagePalette +from ._binary import i32le as i32 +from ._binary import o8 +from ._binary import o32le as o32 + +# Magic ("DDS ") +DDS_MAGIC = 0x20534444 + + +# DDS flags +class DDSD(IntFlag): + CAPS = 0x1 + HEIGHT = 0x2 + WIDTH = 0x4 + PITCH = 0x8 + PIXELFORMAT = 0x1000 + MIPMAPCOUNT = 0x20000 + LINEARSIZE = 0x80000 + DEPTH = 0x800000 + + +# DDS caps +class DDSCAPS(IntFlag): + COMPLEX = 0x8 + TEXTURE = 0x1000 + MIPMAP = 0x400000 + + +class DDSCAPS2(IntFlag): + CUBEMAP = 0x200 + CUBEMAP_POSITIVEX = 0x400 + CUBEMAP_NEGATIVEX = 0x800 + CUBEMAP_POSITIVEY = 0x1000 + CUBEMAP_NEGATIVEY = 0x2000 + CUBEMAP_POSITIVEZ = 0x4000 + CUBEMAP_NEGATIVEZ = 0x8000 + VOLUME = 0x200000 + + +# Pixel Format +class DDPF(IntFlag): + ALPHAPIXELS = 0x1 + ALPHA = 0x2 + FOURCC = 0x4 + PALETTEINDEXED8 = 0x20 + RGB = 0x40 + LUMINANCE = 0x20000 + + +# dxgiformat.h +class DXGI_FORMAT(IntEnum): + UNKNOWN = 0 + R32G32B32A32_TYPELESS = 1 + R32G32B32A32_FLOAT = 2 + R32G32B32A32_UINT = 3 + R32G32B32A32_SINT = 4 + R32G32B32_TYPELESS = 5 + R32G32B32_FLOAT = 6 + R32G32B32_UINT = 7 + R32G32B32_SINT = 8 + R16G16B16A16_TYPELESS = 9 + R16G16B16A16_FLOAT = 10 + R16G16B16A16_UNORM = 11 + R16G16B16A16_UINT = 12 + R16G16B16A16_SNORM = 13 + R16G16B16A16_SINT = 14 + R32G32_TYPELESS = 15 + R32G32_FLOAT = 16 + R32G32_UINT = 17 + R32G32_SINT = 18 + R32G8X24_TYPELESS = 19 + D32_FLOAT_S8X24_UINT = 20 + R32_FLOAT_X8X24_TYPELESS = 21 + X32_TYPELESS_G8X24_UINT = 22 + R10G10B10A2_TYPELESS = 23 + R10G10B10A2_UNORM = 24 + R10G10B10A2_UINT = 25 + R11G11B10_FLOAT = 26 + R8G8B8A8_TYPELESS = 27 + R8G8B8A8_UNORM = 28 + R8G8B8A8_UNORM_SRGB = 29 + R8G8B8A8_UINT = 30 + R8G8B8A8_SNORM = 31 + R8G8B8A8_SINT = 32 + R16G16_TYPELESS = 33 + R16G16_FLOAT = 34 + R16G16_UNORM = 35 + R16G16_UINT = 36 + R16G16_SNORM = 37 + R16G16_SINT = 38 + R32_TYPELESS = 39 + D32_FLOAT = 40 + R32_FLOAT = 41 + R32_UINT = 42 + R32_SINT = 43 + R24G8_TYPELESS = 44 + D24_UNORM_S8_UINT = 45 + R24_UNORM_X8_TYPELESS = 46 + X24_TYPELESS_G8_UINT = 47 + R8G8_TYPELESS = 48 + R8G8_UNORM = 49 + R8G8_UINT = 50 + R8G8_SNORM = 51 + R8G8_SINT = 52 + R16_TYPELESS = 53 + R16_FLOAT = 54 + D16_UNORM = 55 + R16_UNORM = 56 + R16_UINT = 57 + R16_SNORM = 58 + R16_SINT = 59 + R8_TYPELESS = 60 + R8_UNORM = 61 + R8_UINT = 62 + R8_SNORM = 63 + R8_SINT = 64 + A8_UNORM = 65 + R1_UNORM = 66 + R9G9B9E5_SHAREDEXP = 67 + R8G8_B8G8_UNORM = 68 + G8R8_G8B8_UNORM = 69 + BC1_TYPELESS = 70 + BC1_UNORM = 71 + BC1_UNORM_SRGB = 72 + BC2_TYPELESS = 73 + BC2_UNORM = 74 + BC2_UNORM_SRGB = 75 + BC3_TYPELESS = 76 + BC3_UNORM = 77 + BC3_UNORM_SRGB = 78 + BC4_TYPELESS = 79 + BC4_UNORM = 80 + BC4_SNORM = 81 + BC5_TYPELESS = 82 + BC5_UNORM = 83 + BC5_SNORM = 84 + B5G6R5_UNORM = 85 + B5G5R5A1_UNORM = 86 + B8G8R8A8_UNORM = 87 + B8G8R8X8_UNORM = 88 + R10G10B10_XR_BIAS_A2_UNORM = 89 + B8G8R8A8_TYPELESS = 90 + B8G8R8A8_UNORM_SRGB = 91 + B8G8R8X8_TYPELESS = 92 + B8G8R8X8_UNORM_SRGB = 93 + BC6H_TYPELESS = 94 + BC6H_UF16 = 95 + BC6H_SF16 = 96 + BC7_TYPELESS = 97 + BC7_UNORM = 98 + BC7_UNORM_SRGB = 99 + AYUV = 100 + Y410 = 101 + Y416 = 102 + NV12 = 103 + P010 = 104 + P016 = 105 + OPAQUE_420 = 106 + YUY2 = 107 + Y210 = 108 + Y216 = 109 + NV11 = 110 + AI44 = 111 + IA44 = 112 + P8 = 113 + A8P8 = 114 + B4G4R4A4_UNORM = 115 + P208 = 130 + V208 = 131 + V408 = 132 + SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189 + SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190 + + +class D3DFMT(IntEnum): + UNKNOWN = 0 + R8G8B8 = 20 + A8R8G8B8 = 21 + X8R8G8B8 = 22 + R5G6B5 = 23 + X1R5G5B5 = 24 + A1R5G5B5 = 25 + A4R4G4B4 = 26 + R3G3B2 = 27 + A8 = 28 + A8R3G3B2 = 29 + X4R4G4B4 = 30 + A2B10G10R10 = 31 + A8B8G8R8 = 32 + X8B8G8R8 = 33 + G16R16 = 34 + A2R10G10B10 = 35 + A16B16G16R16 = 36 + A8P8 = 40 + P8 = 41 + L8 = 50 + A8L8 = 51 + A4L4 = 52 + V8U8 = 60 + L6V5U5 = 61 + X8L8V8U8 = 62 + Q8W8V8U8 = 63 + V16U16 = 64 + A2W10V10U10 = 67 + D16_LOCKABLE = 70 + D32 = 71 + D15S1 = 73 + D24S8 = 75 + D24X8 = 77 + D24X4S4 = 79 + D16 = 80 + D32F_LOCKABLE = 82 + D24FS8 = 83 + D32_LOCKABLE = 84 + S8_LOCKABLE = 85 + L16 = 81 + VERTEXDATA = 100 + INDEX16 = 101 + INDEX32 = 102 + Q16W16V16U16 = 110 + R16F = 111 + G16R16F = 112 + A16B16G16R16F = 113 + R32F = 114 + G32R32F = 115 + A32B32G32R32F = 116 + CxV8U8 = 117 + A1 = 118 + A2B10G10R10_XR_BIAS = 119 + BINARYBUFFER = 199 + + UYVY = i32(b"UYVY") + R8G8_B8G8 = i32(b"RGBG") + YUY2 = i32(b"YUY2") + G8R8_G8B8 = i32(b"GRGB") + DXT1 = i32(b"DXT1") + DXT2 = i32(b"DXT2") + DXT3 = i32(b"DXT3") + DXT4 = i32(b"DXT4") + DXT5 = i32(b"DXT5") + DX10 = i32(b"DX10") + BC4S = i32(b"BC4S") + BC4U = i32(b"BC4U") + BC5S = i32(b"BC5S") + BC5U = i32(b"BC5U") + ATI1 = i32(b"ATI1") + ATI2 = i32(b"ATI2") + MULTI2_ARGB8 = i32(b"MET1") + + +# Backward compatibility layer +module = sys.modules[__name__] +for item in DDSD: + assert item.name is not None + setattr(module, "DDSD_" + item.name, item.value) +for item1 in DDSCAPS: + assert item1.name is not None + setattr(module, "DDSCAPS_" + item1.name, item1.value) +for item2 in DDSCAPS2: + assert item2.name is not None + setattr(module, "DDSCAPS2_" + item2.name, item2.value) +for item3 in DDPF: + assert item3.name is not None + setattr(module, "DDPF_" + item3.name, item3.value) + +DDS_FOURCC = DDPF.FOURCC +DDS_RGB = DDPF.RGB +DDS_RGBA = DDPF.RGB | DDPF.ALPHAPIXELS +DDS_LUMINANCE = DDPF.LUMINANCE +DDS_LUMINANCEA = DDPF.LUMINANCE | DDPF.ALPHAPIXELS +DDS_ALPHA = DDPF.ALPHA +DDS_PAL8 = DDPF.PALETTEINDEXED8 + +DDS_HEADER_FLAGS_TEXTURE = DDSD.CAPS | DDSD.HEIGHT | DDSD.WIDTH | DDSD.PIXELFORMAT +DDS_HEADER_FLAGS_MIPMAP = DDSD.MIPMAPCOUNT +DDS_HEADER_FLAGS_VOLUME = DDSD.DEPTH +DDS_HEADER_FLAGS_PITCH = DDSD.PITCH +DDS_HEADER_FLAGS_LINEARSIZE = DDSD.LINEARSIZE + +DDS_HEIGHT = DDSD.HEIGHT +DDS_WIDTH = DDSD.WIDTH + +DDS_SURFACE_FLAGS_TEXTURE = DDSCAPS.TEXTURE +DDS_SURFACE_FLAGS_MIPMAP = DDSCAPS.COMPLEX | DDSCAPS.MIPMAP +DDS_SURFACE_FLAGS_CUBEMAP = DDSCAPS.COMPLEX + +DDS_CUBEMAP_POSITIVEX = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_POSITIVEX +DDS_CUBEMAP_NEGATIVEX = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_NEGATIVEX +DDS_CUBEMAP_POSITIVEY = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_POSITIVEY +DDS_CUBEMAP_NEGATIVEY = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_NEGATIVEY +DDS_CUBEMAP_POSITIVEZ = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_POSITIVEZ +DDS_CUBEMAP_NEGATIVEZ = DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_NEGATIVEZ + +DXT1_FOURCC = D3DFMT.DXT1 +DXT3_FOURCC = D3DFMT.DXT3 +DXT5_FOURCC = D3DFMT.DXT5 + +DXGI_FORMAT_R8G8B8A8_TYPELESS = DXGI_FORMAT.R8G8B8A8_TYPELESS +DXGI_FORMAT_R8G8B8A8_UNORM = DXGI_FORMAT.R8G8B8A8_UNORM +DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = DXGI_FORMAT.R8G8B8A8_UNORM_SRGB +DXGI_FORMAT_BC5_TYPELESS = DXGI_FORMAT.BC5_TYPELESS +DXGI_FORMAT_BC5_UNORM = DXGI_FORMAT.BC5_UNORM +DXGI_FORMAT_BC5_SNORM = DXGI_FORMAT.BC5_SNORM +DXGI_FORMAT_BC6H_UF16 = DXGI_FORMAT.BC6H_UF16 +DXGI_FORMAT_BC6H_SF16 = DXGI_FORMAT.BC6H_SF16 +DXGI_FORMAT_BC7_TYPELESS = DXGI_FORMAT.BC7_TYPELESS +DXGI_FORMAT_BC7_UNORM = DXGI_FORMAT.BC7_UNORM +DXGI_FORMAT_BC7_UNORM_SRGB = DXGI_FORMAT.BC7_UNORM_SRGB + + +class DdsImageFile(ImageFile.ImageFile): + format = "DDS" + format_description = "DirectDraw Surface" + + def _open(self): + if not _accept(self.fp.read(4)): + msg = "not a DDS file" + raise SyntaxError(msg) + (header_size,) = struct.unpack("> (offset + 1) << (offset + 1) == mask: + offset += 1 + mask_offsets.append(offset) + mask_totals.append(mask >> offset) + + data = bytearray() + bytecount = bitcount // 8 + dest_length = self.state.xsize * self.state.ysize * len(masks) + while len(data) < dest_length: + value = int.from_bytes(self.fd.read(bytecount), "little") + for i, mask in enumerate(masks): + masked_value = value & mask + # Remove the zero padding, and scale it to 8 bits + data += o8( + int(((masked_value >> mask_offsets[i]) / mask_totals[i]) * 255) + ) + self.set_as_raw(data) + return -1, 0 + + +def _save(im, fp, filename): + if im.mode not in ("RGB", "RGBA", "L", "LA"): + msg = f"cannot write mode {im.mode} as DDS" + raise OSError(msg) + + alpha = im.mode[-1] == "A" + if im.mode[0] == "L": + pixel_flags = DDPF.LUMINANCE + rawmode = im.mode + if alpha: + rgba_mask = [0x000000FF, 0x000000FF, 0x000000FF] + else: + rgba_mask = [0xFF000000, 0xFF000000, 0xFF000000] + else: + pixel_flags = DDPF.RGB + rawmode = im.mode[::-1] + rgba_mask = [0x00FF0000, 0x0000FF00, 0x000000FF] + + if alpha: + r, g, b, a = im.split() + im = Image.merge("RGBA", (a, r, g, b)) + if alpha: + pixel_flags |= DDPF.ALPHAPIXELS + rgba_mask.append(0xFF000000 if alpha else 0) + + flags = DDSD.CAPS | DDSD.HEIGHT | DDSD.WIDTH | DDSD.PITCH | DDSD.PIXELFORMAT + bitcount = len(im.getbands()) * 8 + pitch = (im.width * bitcount + 7) // 8 + + fp.write( + o32(DDS_MAGIC) + + struct.pack( + "<7I", + 124, # header size + flags, # flags + im.height, + im.width, + pitch, + 0, # depth + 0, # mipmaps + ) + + struct.pack("11I", *((0,) * 11)) # reserved + # pfsize, pfflags, fourcc, bitcount + + struct.pack("<4I", 32, pixel_flags, 0, bitcount) + + struct.pack("<4I", *rgba_mask) # dwRGBABitMask + + struct.pack("<5I", DDSCAPS.TEXTURE, 0, 0, 0, 0) + ) + ImageFile._save( + im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))] + ) + + +def _accept(prefix): + return prefix[:4] == b"DDS " + + +Image.register_open(DdsImageFile.format, DdsImageFile, _accept) +Image.register_decoder("dds_rgb", DdsRgbDecoder) +Image.register_save(DdsImageFile.format, _save) +Image.register_extension(DdsImageFile.format, ".dds") diff --git a/venv/lib/python3.10/site-packages/PIL/EpsImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/EpsImagePlugin.py new file mode 100644 index 00000000..523ffcbf --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/EpsImagePlugin.py @@ -0,0 +1,474 @@ +# +# The Python Imaging Library. +# $Id$ +# +# EPS file handling +# +# History: +# 1995-09-01 fl Created (0.1) +# 1996-05-18 fl Don't choke on "atend" fields, Ghostscript interface (0.2) +# 1996-08-22 fl Don't choke on floating point BoundingBox values +# 1996-08-23 fl Handle files from Macintosh (0.3) +# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.4) +# 2003-09-07 fl Check gs.close status (from Federico Di Gregorio) (0.5) +# 2014-05-07 e Handling of EPS with binary preview and fixed resolution +# resizing +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1995-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import os +import re +import subprocess +import sys +import tempfile + +from . import Image, ImageFile +from ._binary import i32le as i32 +from ._deprecate import deprecate + +# -------------------------------------------------------------------- + + +split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$") +field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$") + +gs_binary: str | bool | None = None +gs_windows_binary = None + + +def has_ghostscript(): + global gs_binary, gs_windows_binary + if gs_binary is None: + if sys.platform.startswith("win"): + if gs_windows_binary is None: + import shutil + + for binary in ("gswin32c", "gswin64c", "gs"): + if shutil.which(binary) is not None: + gs_windows_binary = binary + break + else: + gs_windows_binary = False + gs_binary = gs_windows_binary + else: + try: + subprocess.check_call(["gs", "--version"], stdout=subprocess.DEVNULL) + gs_binary = "gs" + except OSError: + gs_binary = False + return gs_binary is not False + + +def Ghostscript(tile, size, fp, scale=1, transparency=False): + """Render an image using Ghostscript""" + global gs_binary + if not has_ghostscript(): + msg = "Unable to locate Ghostscript on paths" + raise OSError(msg) + + # Unpack decoder tile + decoder, tile, offset, data = tile[0] + length, bbox = data + + # Hack to support hi-res rendering + scale = int(scale) or 1 + width = size[0] * scale + height = size[1] * scale + # resolution is dependent on bbox and size + res_x = 72.0 * width / (bbox[2] - bbox[0]) + res_y = 72.0 * height / (bbox[3] - bbox[1]) + + out_fd, outfile = tempfile.mkstemp() + os.close(out_fd) + + infile_temp = None + if hasattr(fp, "name") and os.path.exists(fp.name): + infile = fp.name + else: + in_fd, infile_temp = tempfile.mkstemp() + os.close(in_fd) + infile = infile_temp + + # Ignore length and offset! + # Ghostscript can read it + # Copy whole file to read in Ghostscript + with open(infile_temp, "wb") as f: + # fetch length of fp + fp.seek(0, io.SEEK_END) + fsize = fp.tell() + # ensure start position + # go back + fp.seek(0) + lengthfile = fsize + while lengthfile > 0: + s = fp.read(min(lengthfile, 100 * 1024)) + if not s: + break + lengthfile -= len(s) + f.write(s) + + device = "pngalpha" if transparency else "ppmraw" + + # Build Ghostscript command + command = [ + gs_binary, + "-q", # quiet mode + f"-g{width:d}x{height:d}", # set output geometry (pixels) + f"-r{res_x:f}x{res_y:f}", # set input DPI (dots per inch) + "-dBATCH", # exit after processing + "-dNOPAUSE", # don't pause between pages + "-dSAFER", # safe mode + f"-sDEVICE={device}", + f"-sOutputFile={outfile}", # output file + # adjust for image origin + "-c", + f"{-bbox[0]} {-bbox[1]} translate", + "-f", + infile, # input file + # showpage (see https://bugs.ghostscript.com/show_bug.cgi?id=698272) + "-c", + "showpage", + ] + + # push data through Ghostscript + try: + startupinfo = None + if sys.platform.startswith("win"): + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + subprocess.check_call(command, startupinfo=startupinfo) + out_im = Image.open(outfile) + out_im.load() + finally: + try: + os.unlink(outfile) + if infile_temp: + os.unlink(infile_temp) + except OSError: + pass + + im = out_im.im.copy() + out_im.close() + return im + + +class PSFile: + """ + Wrapper for bytesio object that treats either CR or LF as end of line. + This class is no longer used internally, but kept for backwards compatibility. + """ + + def __init__(self, fp): + deprecate( + "PSFile", + 11, + action="If you need the functionality of this class " + "you will need to implement it yourself.", + ) + self.fp = fp + self.char = None + + def seek(self, offset, whence=io.SEEK_SET): + self.char = None + self.fp.seek(offset, whence) + + def readline(self): + s = [self.char or b""] + self.char = None + + c = self.fp.read(1) + while (c not in b"\r\n") and len(c): + s.append(c) + c = self.fp.read(1) + + self.char = self.fp.read(1) + # line endings can be 1 or 2 of \r \n, in either order + if self.char in b"\r\n": + self.char = None + + return b"".join(s).decode("latin-1") + + +def _accept(prefix): + return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5) + + +## +# Image plugin for Encapsulated PostScript. This plugin supports only +# a few variants of this format. + + +class EpsImageFile(ImageFile.ImageFile): + """EPS File Parser for the Python Imaging Library""" + + format = "EPS" + format_description = "Encapsulated Postscript" + + mode_map = {1: "L", 2: "LAB", 3: "RGB", 4: "CMYK"} + + def _open(self): + (length, offset) = self._find_offset(self.fp) + + # go to offset - start of "%!PS" + self.fp.seek(offset) + + self._mode = "RGB" + self._size = None + + byte_arr = bytearray(255) + bytes_mv = memoryview(byte_arr) + bytes_read = 0 + reading_header_comments = True + reading_trailer_comments = False + trailer_reached = False + + def check_required_header_comments(): + if "PS-Adobe" not in self.info: + msg = 'EPS header missing "%!PS-Adobe" comment' + raise SyntaxError(msg) + if "BoundingBox" not in self.info: + msg = 'EPS header missing "%%BoundingBox" comment' + raise SyntaxError(msg) + + def _read_comment(s): + nonlocal reading_trailer_comments + try: + m = split.match(s) + except re.error as e: + msg = "not an EPS file" + raise SyntaxError(msg) from e + + if m: + k, v = m.group(1, 2) + self.info[k] = v + if k == "BoundingBox": + if v == "(atend)": + reading_trailer_comments = True + elif not self._size or ( + trailer_reached and reading_trailer_comments + ): + try: + # Note: The DSC spec says that BoundingBox + # fields should be integers, but some drivers + # put floating point values there anyway. + box = [int(float(i)) for i in v.split()] + self._size = box[2] - box[0], box[3] - box[1] + self.tile = [ + ("eps", (0, 0) + self.size, offset, (length, box)) + ] + except Exception: + pass + return True + + while True: + byte = self.fp.read(1) + if byte == b"": + # if we didn't read a byte we must be at the end of the file + if bytes_read == 0: + break + elif byte in b"\r\n": + # if we read a line ending character, ignore it and parse what + # we have already read. if we haven't read any other characters, + # continue reading + if bytes_read == 0: + continue + else: + # ASCII/hexadecimal lines in an EPS file must not exceed + # 255 characters, not including line ending characters + if bytes_read >= 255: + # only enforce this for lines starting with a "%", + # otherwise assume it's binary data + if byte_arr[0] == ord("%"): + msg = "not an EPS file" + raise SyntaxError(msg) + else: + if reading_header_comments: + check_required_header_comments() + reading_header_comments = False + # reset bytes_read so we can keep reading + # data until the end of the line + bytes_read = 0 + byte_arr[bytes_read] = byte[0] + bytes_read += 1 + continue + + if reading_header_comments: + # Load EPS header + + # if this line doesn't start with a "%", + # or does start with "%%EndComments", + # then we've reached the end of the header/comments + if byte_arr[0] != ord("%") or bytes_mv[:13] == b"%%EndComments": + check_required_header_comments() + reading_header_comments = False + continue + + s = str(bytes_mv[:bytes_read], "latin-1") + if not _read_comment(s): + m = field.match(s) + if m: + k = m.group(1) + if k[:8] == "PS-Adobe": + self.info["PS-Adobe"] = k[9:] + else: + self.info[k] = "" + elif s[0] == "%": + # handle non-DSC PostScript comments that some + # tools mistakenly put in the Comments section + pass + else: + msg = "bad EPS header" + raise OSError(msg) + elif bytes_mv[:11] == b"%ImageData:": + # Check for an "ImageData" descriptor + # https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096 + + # Values: + # columns + # rows + # bit depth (1 or 8) + # mode (1: L, 2: LAB, 3: RGB, 4: CMYK) + # number of padding channels + # block size (number of bytes per row per channel) + # binary/ascii (1: binary, 2: ascii) + # data start identifier (the image data follows after a single line + # consisting only of this quoted value) + image_data_values = byte_arr[11:bytes_read].split(None, 7) + columns, rows, bit_depth, mode_id = ( + int(value) for value in image_data_values[:4] + ) + + if bit_depth == 1: + self._mode = "1" + elif bit_depth == 8: + try: + self._mode = self.mode_map[mode_id] + except ValueError: + break + else: + break + + self._size = columns, rows + return + elif bytes_mv[:5] == b"%%EOF": + break + elif trailer_reached and reading_trailer_comments: + # Load EPS trailer + s = str(bytes_mv[:bytes_read], "latin-1") + _read_comment(s) + elif bytes_mv[:9] == b"%%Trailer": + trailer_reached = True + bytes_read = 0 + + check_required_header_comments() + + if not self._size: + msg = "cannot determine EPS bounding box" + raise OSError(msg) + + def _find_offset(self, fp): + s = fp.read(4) + + if s == b"%!PS": + # for HEAD without binary preview + fp.seek(0, io.SEEK_END) + length = fp.tell() + offset = 0 + elif i32(s) == 0xC6D3D0C5: + # FIX for: Some EPS file not handled correctly / issue #302 + # EPS can contain binary data + # or start directly with latin coding + # more info see: + # https://web.archive.org/web/20160528181353/http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf + s = fp.read(8) + offset = i32(s) + length = i32(s, 4) + else: + msg = "not an EPS file" + raise SyntaxError(msg) + + return length, offset + + def load(self, scale=1, transparency=False): + # Load EPS via Ghostscript + if self.tile: + self.im = Ghostscript(self.tile, self.size, self.fp, scale, transparency) + self._mode = self.im.mode + self._size = self.im.size + self.tile = [] + return Image.Image.load(self) + + def load_seek(self, pos): + # we can't incrementally load, so force ImageFile.parser to + # use our custom load method by defining this method. + pass + + +# -------------------------------------------------------------------- + + +def _save(im, fp, filename, eps=1): + """EPS Writer for the Python Imaging Library.""" + + # make sure image data is available + im.load() + + # determine PostScript image mode + if im.mode == "L": + operator = (8, 1, b"image") + elif im.mode == "RGB": + operator = (8, 3, b"false 3 colorimage") + elif im.mode == "CMYK": + operator = (8, 4, b"false 4 colorimage") + else: + msg = "image mode is not supported" + raise ValueError(msg) + + if eps: + # write EPS header + fp.write(b"%!PS-Adobe-3.0 EPSF-3.0\n") + fp.write(b"%%Creator: PIL 0.1 EpsEncode\n") + # fp.write("%%CreationDate: %s"...) + fp.write(b"%%%%BoundingBox: 0 0 %d %d\n" % im.size) + fp.write(b"%%Pages: 1\n") + fp.write(b"%%EndComments\n") + fp.write(b"%%Page: 1 1\n") + fp.write(b"%%ImageData: %d %d " % im.size) + fp.write(b'%d %d 0 1 1 "%s"\n' % operator) + + # image header + fp.write(b"gsave\n") + fp.write(b"10 dict begin\n") + fp.write(b"/buf %d string def\n" % (im.size[0] * operator[1])) + fp.write(b"%d %d scale\n" % im.size) + fp.write(b"%d %d 8\n" % im.size) # <= bits + fp.write(b"[%d 0 0 -%d 0 %d]\n" % (im.size[0], im.size[1], im.size[1])) + fp.write(b"{ currentfile buf readhexstring pop } bind\n") + fp.write(operator[2] + b"\n") + if hasattr(fp, "flush"): + fp.flush() + + ImageFile._save(im, fp, [("eps", (0, 0) + im.size, 0, None)]) + + fp.write(b"\n%%%%EndBinary\n") + fp.write(b"grestore end\n") + if hasattr(fp, "flush"): + fp.flush() + + +# -------------------------------------------------------------------- + + +Image.register_open(EpsImageFile.format, EpsImageFile, _accept) + +Image.register_save(EpsImageFile.format, _save) + +Image.register_extensions(EpsImageFile.format, [".ps", ".eps"]) + +Image.register_mime(EpsImageFile.format, "application/postscript") diff --git a/venv/lib/python3.10/site-packages/PIL/ExifTags.py b/venv/lib/python3.10/site-packages/PIL/ExifTags.py new file mode 100644 index 00000000..60a4d977 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ExifTags.py @@ -0,0 +1,381 @@ +# +# The Python Imaging Library. +# $Id$ +# +# EXIF tags +# +# Copyright (c) 2003 by Secret Labs AB +# +# See the README file for information on usage and redistribution. +# + +""" +This module provides constants and clear-text names for various +well-known EXIF tags. +""" +from __future__ import annotations + +from enum import IntEnum + + +class Base(IntEnum): + # possibly incomplete + InteropIndex = 0x0001 + ProcessingSoftware = 0x000B + NewSubfileType = 0x00FE + SubfileType = 0x00FF + ImageWidth = 0x0100 + ImageLength = 0x0101 + BitsPerSample = 0x0102 + Compression = 0x0103 + PhotometricInterpretation = 0x0106 + Thresholding = 0x0107 + CellWidth = 0x0108 + CellLength = 0x0109 + FillOrder = 0x010A + DocumentName = 0x010D + ImageDescription = 0x010E + Make = 0x010F + Model = 0x0110 + StripOffsets = 0x0111 + Orientation = 0x0112 + SamplesPerPixel = 0x0115 + RowsPerStrip = 0x0116 + StripByteCounts = 0x0117 + MinSampleValue = 0x0118 + MaxSampleValue = 0x0119 + XResolution = 0x011A + YResolution = 0x011B + PlanarConfiguration = 0x011C + PageName = 0x011D + FreeOffsets = 0x0120 + FreeByteCounts = 0x0121 + GrayResponseUnit = 0x0122 + GrayResponseCurve = 0x0123 + T4Options = 0x0124 + T6Options = 0x0125 + ResolutionUnit = 0x0128 + PageNumber = 0x0129 + TransferFunction = 0x012D + Software = 0x0131 + DateTime = 0x0132 + Artist = 0x013B + HostComputer = 0x013C + Predictor = 0x013D + WhitePoint = 0x013E + PrimaryChromaticities = 0x013F + ColorMap = 0x0140 + HalftoneHints = 0x0141 + TileWidth = 0x0142 + TileLength = 0x0143 + TileOffsets = 0x0144 + TileByteCounts = 0x0145 + SubIFDs = 0x014A + InkSet = 0x014C + InkNames = 0x014D + NumberOfInks = 0x014E + DotRange = 0x0150 + TargetPrinter = 0x0151 + ExtraSamples = 0x0152 + SampleFormat = 0x0153 + SMinSampleValue = 0x0154 + SMaxSampleValue = 0x0155 + TransferRange = 0x0156 + ClipPath = 0x0157 + XClipPathUnits = 0x0158 + YClipPathUnits = 0x0159 + Indexed = 0x015A + JPEGTables = 0x015B + OPIProxy = 0x015F + JPEGProc = 0x0200 + JpegIFOffset = 0x0201 + JpegIFByteCount = 0x0202 + JpegRestartInterval = 0x0203 + JpegLosslessPredictors = 0x0205 + JpegPointTransforms = 0x0206 + JpegQTables = 0x0207 + JpegDCTables = 0x0208 + JpegACTables = 0x0209 + YCbCrCoefficients = 0x0211 + YCbCrSubSampling = 0x0212 + YCbCrPositioning = 0x0213 + ReferenceBlackWhite = 0x0214 + XMLPacket = 0x02BC + RelatedImageFileFormat = 0x1000 + RelatedImageWidth = 0x1001 + RelatedImageLength = 0x1002 + Rating = 0x4746 + RatingPercent = 0x4749 + ImageID = 0x800D + CFARepeatPatternDim = 0x828D + BatteryLevel = 0x828F + Copyright = 0x8298 + ExposureTime = 0x829A + FNumber = 0x829D + IPTCNAA = 0x83BB + ImageResources = 0x8649 + ExifOffset = 0x8769 + InterColorProfile = 0x8773 + ExposureProgram = 0x8822 + SpectralSensitivity = 0x8824 + GPSInfo = 0x8825 + ISOSpeedRatings = 0x8827 + OECF = 0x8828 + Interlace = 0x8829 + TimeZoneOffset = 0x882A + SelfTimerMode = 0x882B + SensitivityType = 0x8830 + StandardOutputSensitivity = 0x8831 + RecommendedExposureIndex = 0x8832 + ISOSpeed = 0x8833 + ISOSpeedLatitudeyyy = 0x8834 + ISOSpeedLatitudezzz = 0x8835 + ExifVersion = 0x9000 + DateTimeOriginal = 0x9003 + DateTimeDigitized = 0x9004 + OffsetTime = 0x9010 + OffsetTimeOriginal = 0x9011 + OffsetTimeDigitized = 0x9012 + ComponentsConfiguration = 0x9101 + CompressedBitsPerPixel = 0x9102 + ShutterSpeedValue = 0x9201 + ApertureValue = 0x9202 + BrightnessValue = 0x9203 + ExposureBiasValue = 0x9204 + MaxApertureValue = 0x9205 + SubjectDistance = 0x9206 + MeteringMode = 0x9207 + LightSource = 0x9208 + Flash = 0x9209 + FocalLength = 0x920A + Noise = 0x920D + ImageNumber = 0x9211 + SecurityClassification = 0x9212 + ImageHistory = 0x9213 + TIFFEPStandardID = 0x9216 + MakerNote = 0x927C + UserComment = 0x9286 + SubsecTime = 0x9290 + SubsecTimeOriginal = 0x9291 + SubsecTimeDigitized = 0x9292 + AmbientTemperature = 0x9400 + Humidity = 0x9401 + Pressure = 0x9402 + WaterDepth = 0x9403 + Acceleration = 0x9404 + CameraElevationAngle = 0x9405 + XPTitle = 0x9C9B + XPComment = 0x9C9C + XPAuthor = 0x9C9D + XPKeywords = 0x9C9E + XPSubject = 0x9C9F + FlashPixVersion = 0xA000 + ColorSpace = 0xA001 + ExifImageWidth = 0xA002 + ExifImageHeight = 0xA003 + RelatedSoundFile = 0xA004 + ExifInteroperabilityOffset = 0xA005 + FlashEnergy = 0xA20B + SpatialFrequencyResponse = 0xA20C + FocalPlaneXResolution = 0xA20E + FocalPlaneYResolution = 0xA20F + FocalPlaneResolutionUnit = 0xA210 + SubjectLocation = 0xA214 + ExposureIndex = 0xA215 + SensingMethod = 0xA217 + FileSource = 0xA300 + SceneType = 0xA301 + CFAPattern = 0xA302 + CustomRendered = 0xA401 + ExposureMode = 0xA402 + WhiteBalance = 0xA403 + DigitalZoomRatio = 0xA404 + FocalLengthIn35mmFilm = 0xA405 + SceneCaptureType = 0xA406 + GainControl = 0xA407 + Contrast = 0xA408 + Saturation = 0xA409 + Sharpness = 0xA40A + DeviceSettingDescription = 0xA40B + SubjectDistanceRange = 0xA40C + ImageUniqueID = 0xA420 + CameraOwnerName = 0xA430 + BodySerialNumber = 0xA431 + LensSpecification = 0xA432 + LensMake = 0xA433 + LensModel = 0xA434 + LensSerialNumber = 0xA435 + CompositeImage = 0xA460 + CompositeImageCount = 0xA461 + CompositeImageExposureTimes = 0xA462 + Gamma = 0xA500 + PrintImageMatching = 0xC4A5 + DNGVersion = 0xC612 + DNGBackwardVersion = 0xC613 + UniqueCameraModel = 0xC614 + LocalizedCameraModel = 0xC615 + CFAPlaneColor = 0xC616 + CFALayout = 0xC617 + LinearizationTable = 0xC618 + BlackLevelRepeatDim = 0xC619 + BlackLevel = 0xC61A + BlackLevelDeltaH = 0xC61B + BlackLevelDeltaV = 0xC61C + WhiteLevel = 0xC61D + DefaultScale = 0xC61E + DefaultCropOrigin = 0xC61F + DefaultCropSize = 0xC620 + ColorMatrix1 = 0xC621 + ColorMatrix2 = 0xC622 + CameraCalibration1 = 0xC623 + CameraCalibration2 = 0xC624 + ReductionMatrix1 = 0xC625 + ReductionMatrix2 = 0xC626 + AnalogBalance = 0xC627 + AsShotNeutral = 0xC628 + AsShotWhiteXY = 0xC629 + BaselineExposure = 0xC62A + BaselineNoise = 0xC62B + BaselineSharpness = 0xC62C + BayerGreenSplit = 0xC62D + LinearResponseLimit = 0xC62E + CameraSerialNumber = 0xC62F + LensInfo = 0xC630 + ChromaBlurRadius = 0xC631 + AntiAliasStrength = 0xC632 + ShadowScale = 0xC633 + DNGPrivateData = 0xC634 + MakerNoteSafety = 0xC635 + CalibrationIlluminant1 = 0xC65A + CalibrationIlluminant2 = 0xC65B + BestQualityScale = 0xC65C + RawDataUniqueID = 0xC65D + OriginalRawFileName = 0xC68B + OriginalRawFileData = 0xC68C + ActiveArea = 0xC68D + MaskedAreas = 0xC68E + AsShotICCProfile = 0xC68F + AsShotPreProfileMatrix = 0xC690 + CurrentICCProfile = 0xC691 + CurrentPreProfileMatrix = 0xC692 + ColorimetricReference = 0xC6BF + CameraCalibrationSignature = 0xC6F3 + ProfileCalibrationSignature = 0xC6F4 + AsShotProfileName = 0xC6F6 + NoiseReductionApplied = 0xC6F7 + ProfileName = 0xC6F8 + ProfileHueSatMapDims = 0xC6F9 + ProfileHueSatMapData1 = 0xC6FA + ProfileHueSatMapData2 = 0xC6FB + ProfileToneCurve = 0xC6FC + ProfileEmbedPolicy = 0xC6FD + ProfileCopyright = 0xC6FE + ForwardMatrix1 = 0xC714 + ForwardMatrix2 = 0xC715 + PreviewApplicationName = 0xC716 + PreviewApplicationVersion = 0xC717 + PreviewSettingsName = 0xC718 + PreviewSettingsDigest = 0xC719 + PreviewColorSpace = 0xC71A + PreviewDateTime = 0xC71B + RawImageDigest = 0xC71C + OriginalRawFileDigest = 0xC71D + SubTileBlockSize = 0xC71E + RowInterleaveFactor = 0xC71F + ProfileLookTableDims = 0xC725 + ProfileLookTableData = 0xC726 + OpcodeList1 = 0xC740 + OpcodeList2 = 0xC741 + OpcodeList3 = 0xC74E + NoiseProfile = 0xC761 + + +"""Maps EXIF tags to tag names.""" +TAGS = { + **{i.value: i.name for i in Base}, + 0x920C: "SpatialFrequencyResponse", + 0x9214: "SubjectLocation", + 0x9215: "ExposureIndex", + 0x828E: "CFAPattern", + 0x920B: "FlashEnergy", + 0x9216: "TIFF/EPStandardID", +} + + +class GPS(IntEnum): + GPSVersionID = 0 + GPSLatitudeRef = 1 + GPSLatitude = 2 + GPSLongitudeRef = 3 + GPSLongitude = 4 + GPSAltitudeRef = 5 + GPSAltitude = 6 + GPSTimeStamp = 7 + GPSSatellites = 8 + GPSStatus = 9 + GPSMeasureMode = 10 + GPSDOP = 11 + GPSSpeedRef = 12 + GPSSpeed = 13 + GPSTrackRef = 14 + GPSTrack = 15 + GPSImgDirectionRef = 16 + GPSImgDirection = 17 + GPSMapDatum = 18 + GPSDestLatitudeRef = 19 + GPSDestLatitude = 20 + GPSDestLongitudeRef = 21 + GPSDestLongitude = 22 + GPSDestBearingRef = 23 + GPSDestBearing = 24 + GPSDestDistanceRef = 25 + GPSDestDistance = 26 + GPSProcessingMethod = 27 + GPSAreaInformation = 28 + GPSDateStamp = 29 + GPSDifferential = 30 + GPSHPositioningError = 31 + + +"""Maps EXIF GPS tags to tag names.""" +GPSTAGS = {i.value: i.name for i in GPS} + + +class Interop(IntEnum): + InteropIndex = 1 + InteropVersion = 2 + RelatedImageFileFormat = 4096 + RelatedImageWidth = 4097 + RleatedImageHeight = 4098 + + +class IFD(IntEnum): + Exif = 34665 + GPSInfo = 34853 + Makernote = 37500 + Interop = 40965 + IFD1 = -1 + + +class LightSource(IntEnum): + Unknown = 0 + Daylight = 1 + Fluorescent = 2 + Tungsten = 3 + Flash = 4 + Fine = 9 + Cloudy = 10 + Shade = 11 + DaylightFluorescent = 12 + DayWhiteFluorescent = 13 + CoolWhiteFluorescent = 14 + WhiteFluorescent = 15 + StandardLightA = 17 + StandardLightB = 18 + StandardLightC = 19 + D55 = 20 + D65 = 21 + D75 = 22 + D50 = 23 + ISO = 24 + Other = 255 diff --git a/venv/lib/python3.10/site-packages/PIL/FitsImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/FitsImagePlugin.py new file mode 100644 index 00000000..07191892 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/FitsImagePlugin.py @@ -0,0 +1,148 @@ +# +# The Python Imaging Library +# $Id$ +# +# FITS file handling +# +# Copyright (c) 1998-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import gzip +import math + +from . import Image, ImageFile + + +def _accept(prefix: bytes) -> bool: + return prefix[:6] == b"SIMPLE" + + +class FitsImageFile(ImageFile.ImageFile): + format = "FITS" + format_description = "FITS" + + def _open(self) -> None: + assert self.fp is not None + + headers: dict[bytes, bytes] = {} + header_in_progress = False + decoder_name = "" + while True: + header = self.fp.read(80) + if not header: + msg = "Truncated FITS file" + raise OSError(msg) + keyword = header[:8].strip() + if keyword in (b"SIMPLE", b"XTENSION"): + header_in_progress = True + elif headers and not header_in_progress: + # This is now a data unit + break + elif keyword == b"END": + # Seek to the end of the header unit + self.fp.seek(math.ceil(self.fp.tell() / 2880) * 2880) + if not decoder_name: + decoder_name, offset, args = self._parse_headers(headers) + + header_in_progress = False + continue + + if decoder_name: + # Keep going to read past the headers + continue + + value = header[8:].split(b"/")[0].strip() + if value.startswith(b"="): + value = value[1:].strip() + if not headers and (not _accept(keyword) or value != b"T"): + msg = "Not a FITS file" + raise SyntaxError(msg) + headers[keyword] = value + + if not decoder_name: + msg = "No image data" + raise ValueError(msg) + + offset += self.fp.tell() - 80 + self.tile = [(decoder_name, (0, 0) + self.size, offset, args)] + + def _get_size( + self, headers: dict[bytes, bytes], prefix: bytes + ) -> tuple[int, int] | None: + naxis = int(headers[prefix + b"NAXIS"]) + if naxis == 0: + return None + + if naxis == 1: + return 1, int(headers[prefix + b"NAXIS1"]) + else: + return int(headers[prefix + b"NAXIS1"]), int(headers[prefix + b"NAXIS2"]) + + def _parse_headers( + self, headers: dict[bytes, bytes] + ) -> tuple[str, int, tuple[str | int, ...]]: + prefix = b"" + decoder_name = "raw" + offset = 0 + if ( + headers.get(b"XTENSION") == b"'BINTABLE'" + and headers.get(b"ZIMAGE") == b"T" + and headers[b"ZCMPTYPE"] == b"'GZIP_1 '" + ): + no_prefix_size = self._get_size(headers, prefix) or (0, 0) + number_of_bits = int(headers[b"BITPIX"]) + offset = no_prefix_size[0] * no_prefix_size[1] * (number_of_bits // 8) + + prefix = b"Z" + decoder_name = "fits_gzip" + + size = self._get_size(headers, prefix) + if not size: + return "", 0, () + + self._size = size + + number_of_bits = int(headers[prefix + b"BITPIX"]) + if number_of_bits == 8: + self._mode = "L" + elif number_of_bits == 16: + self._mode = "I;16" + elif number_of_bits == 32: + self._mode = "I" + elif number_of_bits in (-32, -64): + self._mode = "F" + + args = (self.mode, 0, -1) if decoder_name == "raw" else (number_of_bits,) + return decoder_name, offset, args + + +class FitsGzipDecoder(ImageFile.PyDecoder): + _pulls_fd = True + + def decode(self, buffer): + assert self.fd is not None + value = gzip.decompress(self.fd.read()) + + rows = [] + offset = 0 + number_of_bits = min(self.args[0] // 8, 4) + for y in range(self.state.ysize): + row = bytearray() + for x in range(self.state.xsize): + row += value[offset + (4 - number_of_bits) : offset + 4] + offset += 4 + rows.append(row) + self.set_as_raw(bytes([pixel for row in rows[::-1] for pixel in row])) + return -1, 0 + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(FitsImageFile.format, FitsImageFile, _accept) +Image.register_decoder("fits_gzip", FitsGzipDecoder) + +Image.register_extensions(FitsImageFile.format, [".fit", ".fits"]) diff --git a/venv/lib/python3.10/site-packages/PIL/FliImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/FliImagePlugin.py new file mode 100644 index 00000000..f9e4c731 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/FliImagePlugin.py @@ -0,0 +1,174 @@ +# +# The Python Imaging Library. +# $Id$ +# +# FLI/FLC file handling. +# +# History: +# 95-09-01 fl Created +# 97-01-03 fl Fixed parser, setup decoder tile +# 98-07-15 fl Renamed offset attribute to avoid name clash +# +# Copyright (c) Secret Labs AB 1997-98. +# Copyright (c) Fredrik Lundh 1995-97. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import os + +from . import Image, ImageFile, ImagePalette +from ._binary import i16le as i16 +from ._binary import i32le as i32 +from ._binary import o8 + +# +# decoder + + +def _accept(prefix): + return ( + len(prefix) >= 6 + and i16(prefix, 4) in [0xAF11, 0xAF12] + and i16(prefix, 14) in [0, 3] # flags + ) + + +## +# Image plugin for the FLI/FLC animation format. Use the seek +# method to load individual frames. + + +class FliImageFile(ImageFile.ImageFile): + format = "FLI" + format_description = "Autodesk FLI/FLC Animation" + _close_exclusive_fp_after_loading = False + + def _open(self): + # HEAD + s = self.fp.read(128) + if not (_accept(s) and s[20:22] == b"\x00\x00"): + msg = "not an FLI/FLC file" + raise SyntaxError(msg) + + # frames + self.n_frames = i16(s, 6) + self.is_animated = self.n_frames > 1 + + # image characteristics + self._mode = "P" + self._size = i16(s, 8), i16(s, 10) + + # animation speed + duration = i32(s, 16) + magic = i16(s, 4) + if magic == 0xAF11: + duration = (duration * 1000) // 70 + self.info["duration"] = duration + + # look for palette + palette = [(a, a, a) for a in range(256)] + + s = self.fp.read(16) + + self.__offset = 128 + + if i16(s, 4) == 0xF100: + # prefix chunk; ignore it + self.__offset = self.__offset + i32(s) + self.fp.seek(self.__offset) + s = self.fp.read(16) + + if i16(s, 4) == 0xF1FA: + # look for palette chunk + number_of_subchunks = i16(s, 6) + chunk_size = None + for _ in range(number_of_subchunks): + if chunk_size is not None: + self.fp.seek(chunk_size - 6, os.SEEK_CUR) + s = self.fp.read(6) + chunk_type = i16(s, 4) + if chunk_type in (4, 11): + self._palette(palette, 2 if chunk_type == 11 else 0) + break + chunk_size = i32(s) + if not chunk_size: + break + + palette = [o8(r) + o8(g) + o8(b) for (r, g, b) in palette] + self.palette = ImagePalette.raw("RGB", b"".join(palette)) + + # set things up to decode first frame + self.__frame = -1 + self._fp = self.fp + self.__rewind = self.fp.tell() + self.seek(0) + + def _palette(self, palette, shift): + # load palette + + i = 0 + for e in range(i16(self.fp.read(2))): + s = self.fp.read(2) + i = i + s[0] + n = s[1] + if n == 0: + n = 256 + s = self.fp.read(n * 3) + for n in range(0, len(s), 3): + r = s[n] << shift + g = s[n + 1] << shift + b = s[n + 2] << shift + palette[i] = (r, g, b) + i += 1 + + def seek(self, frame): + if not self._seek_check(frame): + return + if frame < self.__frame: + self._seek(0) + + for f in range(self.__frame + 1, frame + 1): + self._seek(f) + + def _seek(self, frame): + if frame == 0: + self.__frame = -1 + self._fp.seek(self.__rewind) + self.__offset = 128 + else: + # ensure that the previous frame was loaded + self.load() + + if frame != self.__frame + 1: + msg = f"cannot seek to frame {frame}" + raise ValueError(msg) + self.__frame = frame + + # move to next frame + self.fp = self._fp + self.fp.seek(self.__offset) + + s = self.fp.read(4) + if not s: + msg = "missing frame size" + raise EOFError(msg) + + framesize = i32(s) + + self.decodermaxblock = framesize + self.tile = [("fli", (0, 0) + self.size, self.__offset, None)] + + self.__offset += framesize + + def tell(self): + return self.__frame + + +# +# registry + +Image.register_open(FliImageFile.format, FliImageFile, _accept) + +Image.register_extensions(FliImageFile.format, [".fli", ".flc"]) diff --git a/venv/lib/python3.10/site-packages/PIL/FontFile.py b/venv/lib/python3.10/site-packages/PIL/FontFile.py new file mode 100644 index 00000000..1e0c1c16 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/FontFile.py @@ -0,0 +1,134 @@ +# +# The Python Imaging Library +# $Id$ +# +# base class for raster font file parsers +# +# history: +# 1997-06-05 fl created +# 1997-08-19 fl restrict image width +# +# Copyright (c) 1997-1998 by Secret Labs AB +# Copyright (c) 1997-1998 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import os +from typing import BinaryIO + +from . import Image, _binary + +WIDTH = 800 + + +def puti16( + fp: BinaryIO, values: tuple[int, int, int, int, int, int, int, int, int, int] +) -> None: + """Write network order (big-endian) 16-bit sequence""" + for v in values: + if v < 0: + v += 65536 + fp.write(_binary.o16be(v)) + + +class FontFile: + """Base class for raster font file handlers.""" + + bitmap: Image.Image | None = None + + def __init__(self) -> None: + self.info: dict[bytes, bytes | int] = {} + self.glyph: list[ + tuple[ + tuple[int, int], + tuple[int, int, int, int], + tuple[int, int, int, int], + Image.Image, + ] + | None + ] = [None] * 256 + + def __getitem__(self, ix: int) -> ( + tuple[ + tuple[int, int], + tuple[int, int, int, int], + tuple[int, int, int, int], + Image.Image, + ] + | None + ): + return self.glyph[ix] + + def compile(self) -> None: + """Create metrics and bitmap""" + + if self.bitmap: + return + + # create bitmap large enough to hold all data + h = w = maxwidth = 0 + lines = 1 + for glyph in self.glyph: + if glyph: + d, dst, src, im = glyph + h = max(h, src[3] - src[1]) + w = w + (src[2] - src[0]) + if w > WIDTH: + lines += 1 + w = src[2] - src[0] + maxwidth = max(maxwidth, w) + + xsize = maxwidth + ysize = lines * h + + if xsize == 0 and ysize == 0: + return + + self.ysize = h + + # paste glyphs into bitmap + self.bitmap = Image.new("1", (xsize, ysize)) + self.metrics: list[ + tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int]] + | None + ] = [None] * 256 + x = y = 0 + for i in range(256): + glyph = self[i] + if glyph: + d, dst, src, im = glyph + xx = src[2] - src[0] + x0, y0 = x, y + x = x + xx + if x > WIDTH: + x, y = 0, y + h + x0, y0 = x, y + x = xx + s = src[0] + x0, src[1] + y0, src[2] + x0, src[3] + y0 + self.bitmap.paste(im.crop(src), s) + self.metrics[i] = d, dst, s + + def save(self, filename: str) -> None: + """Save font""" + + self.compile() + + # font data + if not self.bitmap: + msg = "No bitmap created" + raise ValueError(msg) + self.bitmap.save(os.path.splitext(filename)[0] + ".pbm", "PNG") + + # font metrics + with open(os.path.splitext(filename)[0] + ".pil", "wb") as fp: + fp.write(b"PILfont\n") + fp.write(f";;;;;;{self.ysize};\n".encode("ascii")) # HACK!!! + fp.write(b"DATA\n") + for id in range(256): + m = self.metrics[id] + if not m: + puti16(fp, (0,) * 10) + else: + puti16(fp, m[0] + m[1] + m[2]) diff --git a/venv/lib/python3.10/site-packages/PIL/FpxImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/FpxImagePlugin.py new file mode 100644 index 00000000..75680a94 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/FpxImagePlugin.py @@ -0,0 +1,255 @@ +# +# THIS IS WORK IN PROGRESS +# +# The Python Imaging Library. +# $Id$ +# +# FlashPix support for PIL +# +# History: +# 97-01-25 fl Created (reads uncompressed RGB images only) +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import olefile + +from . import Image, ImageFile +from ._binary import i32le as i32 + +# we map from colour field tuples to (mode, rawmode) descriptors +MODES = { + # opacity + (0x00007FFE,): ("A", "L"), + # monochrome + (0x00010000,): ("L", "L"), + (0x00018000, 0x00017FFE): ("RGBA", "LA"), + # photo YCC + (0x00020000, 0x00020001, 0x00020002): ("RGB", "YCC;P"), + (0x00028000, 0x00028001, 0x00028002, 0x00027FFE): ("RGBA", "YCCA;P"), + # standard RGB (NIFRGB) + (0x00030000, 0x00030001, 0x00030002): ("RGB", "RGB"), + (0x00038000, 0x00038001, 0x00038002, 0x00037FFE): ("RGBA", "RGBA"), +} + + +# +# -------------------------------------------------------------------- + + +def _accept(prefix): + return prefix[:8] == olefile.MAGIC + + +## +# Image plugin for the FlashPix images. + + +class FpxImageFile(ImageFile.ImageFile): + format = "FPX" + format_description = "FlashPix" + + def _open(self): + # + # read the OLE directory and see if this is a likely + # to be a FlashPix file + + try: + self.ole = olefile.OleFileIO(self.fp) + except OSError as e: + msg = "not an FPX file; invalid OLE file" + raise SyntaxError(msg) from e + + if self.ole.root.clsid != "56616700-C154-11CE-8553-00AA00A1F95B": + msg = "not an FPX file; bad root CLSID" + raise SyntaxError(msg) + + self._open_index(1) + + def _open_index(self, index=1): + # + # get the Image Contents Property Set + + prop = self.ole.getproperties( + [f"Data Object Store {index:06d}", "\005Image Contents"] + ) + + # size (highest resolution) + + self._size = prop[0x1000002], prop[0x1000003] + + size = max(self.size) + i = 1 + while size > 64: + size = size / 2 + i += 1 + self.maxid = i - 1 + + # mode. instead of using a single field for this, flashpix + # requires you to specify the mode for each channel in each + # resolution subimage, and leaves it to the decoder to make + # sure that they all match. for now, we'll cheat and assume + # that this is always the case. + + id = self.maxid << 16 + + s = prop[0x2000002 | id] + + bands = i32(s, 4) + if bands > 4: + msg = "Invalid number of bands" + raise OSError(msg) + + # note: for now, we ignore the "uncalibrated" flag + colors = tuple(i32(s, 8 + i * 4) & 0x7FFFFFFF for i in range(bands)) + + self._mode, self.rawmode = MODES[colors] + + # load JPEG tables, if any + self.jpeg = {} + for i in range(256): + id = 0x3000001 | (i << 16) + if id in prop: + self.jpeg[i] = prop[id] + + self._open_subimage(1, self.maxid) + + def _open_subimage(self, index=1, subimage=0): + # + # setup tile descriptors for a given subimage + + stream = [ + f"Data Object Store {index:06d}", + f"Resolution {subimage:04d}", + "Subimage 0000 Header", + ] + + fp = self.ole.openstream(stream) + + # skip prefix + fp.read(28) + + # header stream + s = fp.read(36) + + size = i32(s, 4), i32(s, 8) + # tilecount = i32(s, 12) + tilesize = i32(s, 16), i32(s, 20) + # channels = i32(s, 24) + offset = i32(s, 28) + length = i32(s, 32) + + if size != self.size: + msg = "subimage mismatch" + raise OSError(msg) + + # get tile descriptors + fp.seek(28 + offset) + s = fp.read(i32(s, 12) * length) + + x = y = 0 + xsize, ysize = size + xtile, ytile = tilesize + self.tile = [] + + for i in range(0, len(s), length): + x1 = min(xsize, x + xtile) + y1 = min(ysize, y + ytile) + + compression = i32(s, i + 8) + + if compression == 0: + self.tile.append( + ( + "raw", + (x, y, x1, y1), + i32(s, i) + 28, + (self.rawmode,), + ) + ) + + elif compression == 1: + # FIXME: the fill decoder is not implemented + self.tile.append( + ( + "fill", + (x, y, x1, y1), + i32(s, i) + 28, + (self.rawmode, s[12:16]), + ) + ) + + elif compression == 2: + internal_color_conversion = s[14] + jpeg_tables = s[15] + rawmode = self.rawmode + + if internal_color_conversion: + # The image is stored as usual (usually YCbCr). + if rawmode == "RGBA": + # For "RGBA", data is stored as YCbCrA based on + # negative RGB. The following trick works around + # this problem : + jpegmode, rawmode = "YCbCrK", "CMYK" + else: + jpegmode = None # let the decoder decide + + else: + # The image is stored as defined by rawmode + jpegmode = rawmode + + self.tile.append( + ( + "jpeg", + (x, y, x1, y1), + i32(s, i) + 28, + (rawmode, jpegmode), + ) + ) + + # FIXME: jpeg tables are tile dependent; the prefix + # data must be placed in the tile descriptor itself! + + if jpeg_tables: + self.tile_prefix = self.jpeg[jpeg_tables] + + else: + msg = "unknown/invalid compression" + raise OSError(msg) + + x = x + xtile + if x >= xsize: + x, y = 0, y + ytile + if y >= ysize: + break # isn't really required + + self.stream = stream + self._fp = self.fp + self.fp = None + + def load(self): + if not self.fp: + self.fp = self.ole.openstream(self.stream[:2] + ["Subimage 0000 Data"]) + + return ImageFile.ImageFile.load(self) + + def close(self): + self.ole.close() + super().close() + + def __exit__(self, *args): + self.ole.close() + super().__exit__() + + +# +# -------------------------------------------------------------------- + + +Image.register_open(FpxImageFile.format, FpxImageFile, _accept) + +Image.register_extension(FpxImageFile.format, ".fpx") diff --git a/venv/lib/python3.10/site-packages/PIL/FtexImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/FtexImagePlugin.py new file mode 100644 index 00000000..b4488e6e --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/FtexImagePlugin.py @@ -0,0 +1,115 @@ +""" +A Pillow loader for .ftc and .ftu files (FTEX) +Jerome Leclanche + +The contents of this file are hereby released in the public domain (CC0) +Full text of the CC0 license: + https://creativecommons.org/publicdomain/zero/1.0/ + +Independence War 2: Edge Of Chaos - Texture File Format - 16 October 2001 + +The textures used for 3D objects in Independence War 2: Edge Of Chaos are in a +packed custom format called FTEX. This file format uses file extensions FTC +and FTU. +* FTC files are compressed textures (using standard texture compression). +* FTU files are not compressed. +Texture File Format +The FTC and FTU texture files both use the same format. This +has the following structure: +{header} +{format_directory} +{data} +Where: +{header} = { + u32:magic, + u32:version, + u32:width, + u32:height, + u32:mipmap_count, + u32:format_count +} + +* The "magic" number is "FTEX". +* "width" and "height" are the dimensions of the texture. +* "mipmap_count" is the number of mipmaps in the texture. +* "format_count" is the number of texture formats (different versions of the +same texture) in this file. + +{format_directory} = format_count * { u32:format, u32:where } + +The format value is 0 for DXT1 compressed textures and 1 for 24-bit RGB +uncompressed textures. +The texture data for a format starts at the position "where" in the file. + +Each set of texture data in the file has the following structure: +{data} = format_count * { u32:mipmap_size, mipmap_size * { u8 } } +* "mipmap_size" is the number of bytes in that mip level. For compressed +textures this is the size of the texture data compressed with DXT1. For 24 bit +uncompressed textures, this is 3 * width * height. Following this are the image +bytes for that mipmap level. + +Note: All data is stored in little-Endian (Intel) byte order. +""" + +from __future__ import annotations + +import struct +from enum import IntEnum +from io import BytesIO + +from . import Image, ImageFile + +MAGIC = b"FTEX" + + +class Format(IntEnum): + DXT1 = 0 + UNCOMPRESSED = 1 + + +class FtexImageFile(ImageFile.ImageFile): + format = "FTEX" + format_description = "Texture File Format (IW2:EOC)" + + def _open(self): + if not _accept(self.fp.read(4)): + msg = "not an FTEX file" + raise SyntaxError(msg) + struct.unpack("= 8 and i32(prefix, 0) >= 20 and i32(prefix, 4) in (1, 2) + + +## +# Image plugin for the GIMP brush format. + + +class GbrImageFile(ImageFile.ImageFile): + format = "GBR" + format_description = "GIMP brush file" + + def _open(self): + header_size = i32(self.fp.read(4)) + if header_size < 20: + msg = "not a GIMP brush" + raise SyntaxError(msg) + version = i32(self.fp.read(4)) + if version not in (1, 2): + msg = f"Unsupported GIMP brush version: {version}" + raise SyntaxError(msg) + + width = i32(self.fp.read(4)) + height = i32(self.fp.read(4)) + color_depth = i32(self.fp.read(4)) + if width <= 0 or height <= 0: + msg = "not a GIMP brush" + raise SyntaxError(msg) + if color_depth not in (1, 4): + msg = f"Unsupported GIMP brush color depth: {color_depth}" + raise SyntaxError(msg) + + if version == 1: + comment_length = header_size - 20 + else: + comment_length = header_size - 28 + magic_number = self.fp.read(4) + if magic_number != b"GIMP": + msg = "not a GIMP brush, bad magic number" + raise SyntaxError(msg) + self.info["spacing"] = i32(self.fp.read(4)) + + comment = self.fp.read(comment_length)[:-1] + + if color_depth == 1: + self._mode = "L" + else: + self._mode = "RGBA" + + self._size = width, height + + self.info["comment"] = comment + + # Image might not be small + Image._decompression_bomb_check(self.size) + + # Data is an uncompressed block of w * h * bytes/pixel + self._data_size = width * height * color_depth + + def load(self): + if not self.im: + self.im = Image.core.new(self.mode, self.size) + self.frombytes(self.fp.read(self._data_size)) + return Image.Image.load(self) + + +# +# registry + + +Image.register_open(GbrImageFile.format, GbrImageFile, _accept) +Image.register_extension(GbrImageFile.format, ".gbr") diff --git a/venv/lib/python3.10/site-packages/PIL/GdImageFile.py b/venv/lib/python3.10/site-packages/PIL/GdImageFile.py new file mode 100644 index 00000000..88b87a22 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/GdImageFile.py @@ -0,0 +1,102 @@ +# +# The Python Imaging Library. +# $Id$ +# +# GD file handling +# +# History: +# 1996-04-12 fl Created +# +# Copyright (c) 1997 by Secret Labs AB. +# Copyright (c) 1996 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + + +""" +.. note:: + This format cannot be automatically recognized, so the + class is not registered for use with :py:func:`PIL.Image.open()`. To open a + gd file, use the :py:func:`PIL.GdImageFile.open()` function instead. + +.. warning:: + THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE. This + implementation is provided for convenience and demonstrational + purposes only. +""" +from __future__ import annotations + +from typing import IO + +from . import ImageFile, ImagePalette, UnidentifiedImageError +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._typing import StrOrBytesPath + + +class GdImageFile(ImageFile.ImageFile): + """ + Image plugin for the GD uncompressed format. Note that this format + is not supported by the standard :py:func:`PIL.Image.open()` function. To use + this plugin, you have to import the :py:mod:`PIL.GdImageFile` module and + use the :py:func:`PIL.GdImageFile.open()` function. + """ + + format = "GD" + format_description = "GD uncompressed images" + + def _open(self) -> None: + # Header + assert self.fp is not None + + s = self.fp.read(1037) + + if i16(s) not in [65534, 65535]: + msg = "Not a valid GD 2.x .gd file" + raise SyntaxError(msg) + + self._mode = "L" # FIXME: "P" + self._size = i16(s, 2), i16(s, 4) + + true_color = s[6] + true_color_offset = 2 if true_color else 0 + + # transparency index + tindex = i32(s, 7 + true_color_offset) + if tindex < 256: + self.info["transparency"] = tindex + + self.palette = ImagePalette.raw( + "XBGR", s[7 + true_color_offset + 4 : 7 + true_color_offset + 4 + 256 * 4] + ) + + self.tile = [ + ( + "raw", + (0, 0) + self.size, + 7 + true_color_offset + 4 + 256 * 4, + ("L", 0, 1), + ) + ] + + +def open(fp: StrOrBytesPath | IO[bytes], mode: str = "r") -> GdImageFile: + """ + Load texture from a GD image file. + + :param fp: GD file name, or an opened file handle. + :param mode: Optional mode. In this version, if the mode argument + is given, it must be "r". + :returns: An image instance. + :raises OSError: If the image could not be read. + """ + if mode != "r": + msg = "bad mode" + raise ValueError(msg) + + try: + return GdImageFile(fp) + except SyntaxError as e: + msg = "cannot identify this image file" + raise UnidentifiedImageError(msg) from e diff --git a/venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py new file mode 100644 index 00000000..6b415d23 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py @@ -0,0 +1,1107 @@ +# +# The Python Imaging Library. +# $Id$ +# +# GIF file handling +# +# History: +# 1995-09-01 fl Created +# 1996-12-14 fl Added interlace support +# 1996-12-30 fl Added animation support +# 1997-01-05 fl Added write support, fixed local colour map bug +# 1997-02-23 fl Make sure to load raster data in getdata() +# 1997-07-05 fl Support external decoder (0.4) +# 1998-07-09 fl Handle all modes when saving (0.5) +# 1998-07-15 fl Renamed offset attribute to avoid name clash +# 2001-04-16 fl Added rewind support (seek to frame 0) (0.6) +# 2001-04-17 fl Added palette optimization (0.7) +# 2002-06-06 fl Added transparency support for save (0.8) +# 2004-02-24 fl Disable interlacing for small images +# +# Copyright (c) 1997-2004 by Secret Labs AB +# Copyright (c) 1995-2004 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import itertools +import math +import os +import subprocess +from enum import IntEnum + +from . import ( + Image, + ImageChops, + ImageFile, + ImageMath, + ImageOps, + ImagePalette, + ImageSequence, +) +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 + + +class LoadingStrategy(IntEnum): + """.. versionadded:: 9.1.0""" + + RGB_AFTER_FIRST = 0 + RGB_AFTER_DIFFERENT_PALETTE_ONLY = 1 + RGB_ALWAYS = 2 + + +#: .. versionadded:: 9.1.0 +LOADING_STRATEGY = LoadingStrategy.RGB_AFTER_FIRST + +# -------------------------------------------------------------------- +# Identify/read GIF files + + +def _accept(prefix): + return prefix[:6] in [b"GIF87a", b"GIF89a"] + + +## +# Image plugin for GIF images. This plugin supports both GIF87 and +# GIF89 images. + + +class GifImageFile(ImageFile.ImageFile): + format = "GIF" + format_description = "Compuserve GIF" + _close_exclusive_fp_after_loading = False + + global_palette = None + + def data(self): + s = self.fp.read(1) + if s and s[0]: + return self.fp.read(s[0]) + return None + + def _is_palette_needed(self, p): + for i in range(0, len(p), 3): + if not (i // 3 == p[i] == p[i + 1] == p[i + 2]): + return True + return False + + def _open(self): + # Screen + s = self.fp.read(13) + if not _accept(s): + msg = "not a GIF file" + raise SyntaxError(msg) + + self.info["version"] = s[:6] + self._size = i16(s, 6), i16(s, 8) + self.tile = [] + flags = s[10] + bits = (flags & 7) + 1 + + if flags & 128: + # get global palette + self.info["background"] = s[11] + # check if palette contains colour indices + p = self.fp.read(3 << bits) + if self._is_palette_needed(p): + p = ImagePalette.raw("RGB", p) + self.global_palette = self.palette = p + + self._fp = self.fp # FIXME: hack + self.__rewind = self.fp.tell() + self._n_frames = None + self._is_animated = None + self._seek(0) # get ready to read first frame + + @property + def n_frames(self): + if self._n_frames is None: + current = self.tell() + try: + while True: + self._seek(self.tell() + 1, False) + except EOFError: + self._n_frames = self.tell() + 1 + self.seek(current) + return self._n_frames + + @property + def is_animated(self): + if self._is_animated is None: + if self._n_frames is not None: + self._is_animated = self._n_frames != 1 + else: + current = self.tell() + if current: + self._is_animated = True + else: + try: + self._seek(1, False) + self._is_animated = True + except EOFError: + self._is_animated = False + + self.seek(current) + return self._is_animated + + def seek(self, frame): + if not self._seek_check(frame): + return + if frame < self.__frame: + self.im = None + self._seek(0) + + last_frame = self.__frame + for f in range(self.__frame + 1, frame + 1): + try: + self._seek(f) + except EOFError as e: + self.seek(last_frame) + msg = "no more images in GIF file" + raise EOFError(msg) from e + + def _seek(self, frame, update_image=True): + if frame == 0: + # rewind + self.__offset = 0 + self.dispose = None + self.__frame = -1 + self._fp.seek(self.__rewind) + self.disposal_method = 0 + if "comment" in self.info: + del self.info["comment"] + else: + # ensure that the previous frame was loaded + if self.tile and update_image: + self.load() + + if frame != self.__frame + 1: + msg = f"cannot seek to frame {frame}" + raise ValueError(msg) + + self.fp = self._fp + if self.__offset: + # backup to last frame + self.fp.seek(self.__offset) + while self.data(): + pass + self.__offset = 0 + + s = self.fp.read(1) + if not s or s == b";": + msg = "no more images in GIF file" + raise EOFError(msg) + + palette = None + + info = {} + frame_transparency = None + interlace = None + frame_dispose_extent = None + while True: + if not s: + s = self.fp.read(1) + if not s or s == b";": + break + + elif s == b"!": + # + # extensions + # + s = self.fp.read(1) + block = self.data() + if s[0] == 249: + # + # graphic control extension + # + flags = block[0] + if flags & 1: + frame_transparency = block[3] + info["duration"] = i16(block, 1) * 10 + + # disposal method - find the value of bits 4 - 6 + dispose_bits = 0b00011100 & flags + dispose_bits = dispose_bits >> 2 + if dispose_bits: + # only set the dispose if it is not + # unspecified. I'm not sure if this is + # correct, but it seems to prevent the last + # frame from looking odd for some animations + self.disposal_method = dispose_bits + elif s[0] == 254: + # + # comment extension + # + comment = b"" + + # Read this comment block + while block: + comment += block + block = self.data() + + if "comment" in info: + # If multiple comment blocks in frame, separate with \n + info["comment"] += b"\n" + comment + else: + info["comment"] = comment + s = None + continue + elif s[0] == 255 and frame == 0: + # + # application extension + # + info["extension"] = block, self.fp.tell() + if block[:11] == b"NETSCAPE2.0": + block = self.data() + if len(block) >= 3 and block[0] == 1: + self.info["loop"] = i16(block, 1) + while self.data(): + pass + + elif s == b",": + # + # local image + # + s = self.fp.read(9) + + # extent + x0, y0 = i16(s, 0), i16(s, 2) + x1, y1 = x0 + i16(s, 4), y0 + i16(s, 6) + if (x1 > self.size[0] or y1 > self.size[1]) and update_image: + self._size = max(x1, self.size[0]), max(y1, self.size[1]) + Image._decompression_bomb_check(self._size) + frame_dispose_extent = x0, y0, x1, y1 + flags = s[8] + + interlace = (flags & 64) != 0 + + if flags & 128: + bits = (flags & 7) + 1 + p = self.fp.read(3 << bits) + if self._is_palette_needed(p): + palette = ImagePalette.raw("RGB", p) + else: + palette = False + + # image data + bits = self.fp.read(1)[0] + self.__offset = self.fp.tell() + break + s = None + + if interlace is None: + msg = "image not found in GIF frame" + raise EOFError(msg) + + self.__frame = frame + if not update_image: + return + + self.tile = [] + + if self.dispose: + self.im.paste(self.dispose, self.dispose_extent) + + self._frame_palette = palette if palette is not None else self.global_palette + self._frame_transparency = frame_transparency + if frame == 0: + if self._frame_palette: + if LOADING_STRATEGY == LoadingStrategy.RGB_ALWAYS: + self._mode = "RGBA" if frame_transparency is not None else "RGB" + else: + self._mode = "P" + else: + self._mode = "L" + + if not palette and self.global_palette: + from copy import copy + + palette = copy(self.global_palette) + self.palette = palette + else: + if self.mode == "P": + if ( + LOADING_STRATEGY != LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY + or palette + ): + self.pyaccess = None + if "transparency" in self.info: + self.im.putpalettealpha(self.info["transparency"], 0) + self.im = self.im.convert("RGBA", Image.Dither.FLOYDSTEINBERG) + self._mode = "RGBA" + del self.info["transparency"] + else: + self._mode = "RGB" + self.im = self.im.convert("RGB", Image.Dither.FLOYDSTEINBERG) + + def _rgb(color): + if self._frame_palette: + if color * 3 + 3 > len(self._frame_palette.palette): + color = 0 + color = tuple(self._frame_palette.palette[color * 3 : color * 3 + 3]) + else: + color = (color, color, color) + return color + + self.dispose_extent = frame_dispose_extent + try: + if self.disposal_method < 2: + # do not dispose or none specified + self.dispose = None + elif self.disposal_method == 2: + # replace with background colour + + # only dispose the extent in this frame + x0, y0, x1, y1 = self.dispose_extent + dispose_size = (x1 - x0, y1 - y0) + + Image._decompression_bomb_check(dispose_size) + + # by convention, attempt to use transparency first + dispose_mode = "P" + color = self.info.get("transparency", frame_transparency) + if color is not None: + if self.mode in ("RGB", "RGBA"): + dispose_mode = "RGBA" + color = _rgb(color) + (0,) + else: + color = self.info.get("background", 0) + if self.mode in ("RGB", "RGBA"): + dispose_mode = "RGB" + color = _rgb(color) + self.dispose = Image.core.fill(dispose_mode, dispose_size, color) + else: + # replace with previous contents + if self.im is not None: + # only dispose the extent in this frame + self.dispose = self._crop(self.im, self.dispose_extent) + elif frame_transparency is not None: + x0, y0, x1, y1 = self.dispose_extent + dispose_size = (x1 - x0, y1 - y0) + + Image._decompression_bomb_check(dispose_size) + dispose_mode = "P" + color = frame_transparency + if self.mode in ("RGB", "RGBA"): + dispose_mode = "RGBA" + color = _rgb(frame_transparency) + (0,) + self.dispose = Image.core.fill(dispose_mode, dispose_size, color) + except AttributeError: + pass + + if interlace is not None: + transparency = -1 + if frame_transparency is not None: + if frame == 0: + if LOADING_STRATEGY != LoadingStrategy.RGB_ALWAYS: + self.info["transparency"] = frame_transparency + elif self.mode not in ("RGB", "RGBA"): + transparency = frame_transparency + self.tile = [ + ( + "gif", + (x0, y0, x1, y1), + self.__offset, + (bits, interlace, transparency), + ) + ] + + if info.get("comment"): + self.info["comment"] = info["comment"] + for k in ["duration", "extension"]: + if k in info: + self.info[k] = info[k] + elif k in self.info: + del self.info[k] + + def load_prepare(self): + temp_mode = "P" if self._frame_palette else "L" + self._prev_im = None + if self.__frame == 0: + if self._frame_transparency is not None: + self.im = Image.core.fill( + temp_mode, self.size, self._frame_transparency + ) + elif self.mode in ("RGB", "RGBA"): + self._prev_im = self.im + if self._frame_palette: + self.im = Image.core.fill("P", self.size, self._frame_transparency or 0) + self.im.putpalette(*self._frame_palette.getdata()) + else: + self.im = None + self._mode = temp_mode + self._frame_palette = None + + super().load_prepare() + + def load_end(self): + if self.__frame == 0: + if self.mode == "P" and LOADING_STRATEGY == LoadingStrategy.RGB_ALWAYS: + if self._frame_transparency is not None: + self.im.putpalettealpha(self._frame_transparency, 0) + self._mode = "RGBA" + else: + self._mode = "RGB" + self.im = self.im.convert(self.mode, Image.Dither.FLOYDSTEINBERG) + return + if not self._prev_im: + return + if self._frame_transparency is not None: + self.im.putpalettealpha(self._frame_transparency, 0) + frame_im = self.im.convert("RGBA") + else: + frame_im = self.im.convert("RGB") + frame_im = self._crop(frame_im, self.dispose_extent) + + self.im = self._prev_im + self._mode = self.im.mode + if frame_im.mode == "RGBA": + self.im.paste(frame_im, self.dispose_extent, frame_im) + else: + self.im.paste(frame_im, self.dispose_extent) + + def tell(self): + return self.__frame + + +# -------------------------------------------------------------------- +# Write GIF files + + +RAWMODE = {"1": "L", "L": "L", "P": "P"} + + +def _normalize_mode(im): + """ + Takes an image (or frame), returns an image in a mode that is appropriate + for saving in a Gif. + + It may return the original image, or it may return an image converted to + palette or 'L' mode. + + :param im: Image object + :returns: Image object + """ + if im.mode in RAWMODE: + im.load() + return im + if Image.getmodebase(im.mode) == "RGB": + im = im.convert("P", palette=Image.Palette.ADAPTIVE) + if im.palette.mode == "RGBA": + for rgba in im.palette.colors: + if rgba[3] == 0: + im.info["transparency"] = im.palette.colors[rgba] + break + return im + return im.convert("L") + + +def _normalize_palette(im, palette, info): + """ + Normalizes the palette for image. + - Sets the palette to the incoming palette, if provided. + - Ensures that there's a palette for L mode images + - Optimizes the palette if necessary/desired. + + :param im: Image object + :param palette: bytes object containing the source palette, or .... + :param info: encoderinfo + :returns: Image object + """ + source_palette = None + if palette: + # a bytes palette + if isinstance(palette, (bytes, bytearray, list)): + source_palette = bytearray(palette[:768]) + if isinstance(palette, ImagePalette.ImagePalette): + source_palette = bytearray(palette.palette) + + if im.mode == "P": + if not source_palette: + source_palette = im.im.getpalette("RGB")[:768] + else: # L-mode + if not source_palette: + source_palette = bytearray(i // 3 for i in range(768)) + im.palette = ImagePalette.ImagePalette("RGB", palette=source_palette) + + if palette: + used_palette_colors = [] + for i in range(0, len(source_palette), 3): + source_color = tuple(source_palette[i : i + 3]) + index = im.palette.colors.get(source_color) + if index in used_palette_colors: + index = None + used_palette_colors.append(index) + for i, index in enumerate(used_palette_colors): + if index is None: + for j in range(len(used_palette_colors)): + if j not in used_palette_colors: + used_palette_colors[i] = j + break + im = im.remap_palette(used_palette_colors) + else: + used_palette_colors = _get_optimize(im, info) + if used_palette_colors is not None: + im = im.remap_palette(used_palette_colors, source_palette) + if "transparency" in info: + try: + info["transparency"] = used_palette_colors.index( + info["transparency"] + ) + except ValueError: + del info["transparency"] + return im + + im.palette.palette = source_palette + return im + + +def _write_single_frame(im, fp, palette): + im_out = _normalize_mode(im) + for k, v in im_out.info.items(): + im.encoderinfo.setdefault(k, v) + im_out = _normalize_palette(im_out, palette, im.encoderinfo) + + for s in _get_global_header(im_out, im.encoderinfo): + fp.write(s) + + # local image header + flags = 0 + if get_interlace(im): + flags = flags | 64 + _write_local_header(fp, im, (0, 0), flags) + + im_out.encoderconfig = (8, get_interlace(im)) + ImageFile._save(im_out, fp, [("gif", (0, 0) + im.size, 0, RAWMODE[im_out.mode])]) + + fp.write(b"\0") # end of image data + + +def _getbbox(base_im, im_frame): + if _get_palette_bytes(im_frame) != _get_palette_bytes(base_im): + im_frame = im_frame.convert("RGBA") + base_im = base_im.convert("RGBA") + delta = ImageChops.subtract_modulo(im_frame, base_im) + return delta, delta.getbbox(alpha_only=False) + + +def _write_multiple_frames(im, fp, palette): + duration = im.encoderinfo.get("duration") + disposal = im.encoderinfo.get("disposal", im.info.get("disposal")) + + im_frames = [] + previous_im = None + frame_count = 0 + background_im = None + for imSequence in itertools.chain([im], im.encoderinfo.get("append_images", [])): + for im_frame in ImageSequence.Iterator(imSequence): + # a copy is required here since seek can still mutate the image + im_frame = _normalize_mode(im_frame.copy()) + if frame_count == 0: + for k, v in im_frame.info.items(): + if k == "transparency": + continue + im.encoderinfo.setdefault(k, v) + + encoderinfo = im.encoderinfo.copy() + if "transparency" in im_frame.info: + encoderinfo.setdefault("transparency", im_frame.info["transparency"]) + im_frame = _normalize_palette(im_frame, palette, encoderinfo) + if isinstance(duration, (list, tuple)): + encoderinfo["duration"] = duration[frame_count] + elif duration is None and "duration" in im_frame.info: + encoderinfo["duration"] = im_frame.info["duration"] + if isinstance(disposal, (list, tuple)): + encoderinfo["disposal"] = disposal[frame_count] + frame_count += 1 + + diff_frame = None + if im_frames: + # delta frame + delta, bbox = _getbbox(previous_im, im_frame) + if not bbox: + # This frame is identical to the previous frame + if encoderinfo.get("duration"): + im_frames[-1]["encoderinfo"]["duration"] += encoderinfo[ + "duration" + ] + continue + if im_frames[-1]["encoderinfo"].get("disposal") == 2: + if background_im is None: + color = im.encoderinfo.get( + "transparency", im.info.get("transparency", (0, 0, 0)) + ) + background = _get_background(im_frame, color) + background_im = Image.new("P", im_frame.size, background) + background_im.putpalette(im_frames[0]["im"].palette) + bbox = _getbbox(background_im, im_frame)[1] + elif encoderinfo.get("optimize") and im_frame.mode != "1": + if "transparency" not in encoderinfo: + try: + encoderinfo["transparency"] = ( + im_frame.palette._new_color_index(im_frame) + ) + except ValueError: + pass + if "transparency" in encoderinfo: + # When the delta is zero, fill the image with transparency + diff_frame = im_frame.copy() + fill = Image.new("P", delta.size, encoderinfo["transparency"]) + if delta.mode == "RGBA": + r, g, b, a = delta.split() + mask = ImageMath.lambda_eval( + lambda args: args["convert"]( + args["max"]( + args["max"]( + args["max"](args["r"], args["g"]), args["b"] + ), + args["a"], + ) + * 255, + "1", + ), + r=r, + g=g, + b=b, + a=a, + ) + else: + if delta.mode == "P": + # Convert to L without considering palette + delta_l = Image.new("L", delta.size) + delta_l.putdata(delta.getdata()) + delta = delta_l + mask = ImageMath.lambda_eval( + lambda args: args["convert"](args["im"] * 255, "1"), + im=delta, + ) + diff_frame.paste(fill, mask=ImageOps.invert(mask)) + else: + bbox = None + previous_im = im_frame + im_frames.append( + {"im": diff_frame or im_frame, "bbox": bbox, "encoderinfo": encoderinfo} + ) + + if len(im_frames) == 1: + if "duration" in im.encoderinfo: + # Since multiple frames will not be written, use the combined duration + im.encoderinfo["duration"] = im_frames[0]["encoderinfo"]["duration"] + return + + for frame_data in im_frames: + im_frame = frame_data["im"] + if not frame_data["bbox"]: + # global header + for s in _get_global_header(im_frame, frame_data["encoderinfo"]): + fp.write(s) + offset = (0, 0) + else: + # compress difference + if not palette: + frame_data["encoderinfo"]["include_color_table"] = True + + im_frame = im_frame.crop(frame_data["bbox"]) + offset = frame_data["bbox"][:2] + _write_frame_data(fp, im_frame, offset, frame_data["encoderinfo"]) + return True + + +def _save_all(im, fp, filename): + _save(im, fp, filename, save_all=True) + + +def _save(im, fp, filename, save_all=False): + # header + if "palette" in im.encoderinfo or "palette" in im.info: + palette = im.encoderinfo.get("palette", im.info.get("palette")) + else: + palette = None + im.encoderinfo.setdefault("optimize", True) + + if not save_all or not _write_multiple_frames(im, fp, palette): + _write_single_frame(im, fp, palette) + + fp.write(b";") # end of file + + if hasattr(fp, "flush"): + fp.flush() + + +def get_interlace(im): + interlace = im.encoderinfo.get("interlace", 1) + + # workaround for @PIL153 + if min(im.size) < 16: + interlace = 0 + + return interlace + + +def _write_local_header(fp, im, offset, flags): + try: + transparency = im.encoderinfo["transparency"] + except KeyError: + transparency = None + + if "duration" in im.encoderinfo: + duration = int(im.encoderinfo["duration"] / 10) + else: + duration = 0 + + disposal = int(im.encoderinfo.get("disposal", 0)) + + if transparency is not None or duration != 0 or disposal: + packed_flag = 1 if transparency is not None else 0 + packed_flag |= disposal << 2 + + fp.write( + b"!" + + o8(249) # extension intro + + o8(4) # length + + o8(packed_flag) # packed fields + + o16(duration) # duration + + o8(transparency or 0) # transparency index + + o8(0) + ) + + include_color_table = im.encoderinfo.get("include_color_table") + if include_color_table: + palette_bytes = _get_palette_bytes(im) + color_table_size = _get_color_table_size(palette_bytes) + if color_table_size: + flags = flags | 128 # local color table flag + flags = flags | color_table_size + + fp.write( + b"," + + o16(offset[0]) # offset + + o16(offset[1]) + + o16(im.size[0]) # size + + o16(im.size[1]) + + o8(flags) # flags + ) + if include_color_table and color_table_size: + fp.write(_get_header_palette(palette_bytes)) + fp.write(o8(8)) # bits + + +def _save_netpbm(im, fp, filename): + # Unused by default. + # To use, uncomment the register_save call at the end of the file. + # + # If you need real GIF compression and/or RGB quantization, you + # can use the external NETPBM/PBMPLUS utilities. See comments + # below for information on how to enable this. + tempfile = im._dump() + + try: + with open(filename, "wb") as f: + if im.mode != "RGB": + subprocess.check_call( + ["ppmtogif", tempfile], stdout=f, stderr=subprocess.DEVNULL + ) + else: + # Pipe ppmquant output into ppmtogif + # "ppmquant 256 %s | ppmtogif > %s" % (tempfile, filename) + quant_cmd = ["ppmquant", "256", tempfile] + togif_cmd = ["ppmtogif"] + quant_proc = subprocess.Popen( + quant_cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL + ) + togif_proc = subprocess.Popen( + togif_cmd, + stdin=quant_proc.stdout, + stdout=f, + stderr=subprocess.DEVNULL, + ) + + # Allow ppmquant to receive SIGPIPE if ppmtogif exits + quant_proc.stdout.close() + + retcode = quant_proc.wait() + if retcode: + raise subprocess.CalledProcessError(retcode, quant_cmd) + + retcode = togif_proc.wait() + if retcode: + raise subprocess.CalledProcessError(retcode, togif_cmd) + finally: + try: + os.unlink(tempfile) + except OSError: + pass + + +# Force optimization so that we can test performance against +# cases where it took lots of memory and time previously. +_FORCE_OPTIMIZE = False + + +def _get_optimize(im, info): + """ + Palette optimization is a potentially expensive operation. + + This function determines if the palette should be optimized using + some heuristics, then returns the list of palette entries in use. + + :param im: Image object + :param info: encoderinfo + :returns: list of indexes of palette entries in use, or None + """ + if im.mode in ("P", "L") and info and info.get("optimize"): + # Potentially expensive operation. + + # The palette saves 3 bytes per color not used, but palette + # lengths are restricted to 3*(2**N) bytes. Max saving would + # be 768 -> 6 bytes if we went all the way down to 2 colors. + # * If we're over 128 colors, we can't save any space. + # * If there aren't any holes, it's not worth collapsing. + # * If we have a 'large' image, the palette is in the noise. + + # create the new palette if not every color is used + optimise = _FORCE_OPTIMIZE or im.mode == "L" + if optimise or im.width * im.height < 512 * 512: + # check which colors are used + used_palette_colors = [] + for i, count in enumerate(im.histogram()): + if count: + used_palette_colors.append(i) + + if optimise or max(used_palette_colors) >= len(used_palette_colors): + return used_palette_colors + + num_palette_colors = len(im.palette.palette) // Image.getmodebands( + im.palette.mode + ) + current_palette_size = 1 << (num_palette_colors - 1).bit_length() + if ( + # check that the palette would become smaller when saved + len(used_palette_colors) <= current_palette_size // 2 + # check that the palette is not already the smallest possible size + and current_palette_size > 2 + ): + return used_palette_colors + + +def _get_color_table_size(palette_bytes): + # calculate the palette size for the header + if not palette_bytes: + return 0 + elif len(palette_bytes) < 9: + return 1 + else: + return math.ceil(math.log(len(palette_bytes) // 3, 2)) - 1 + + +def _get_header_palette(palette_bytes): + """ + Returns the palette, null padded to the next power of 2 (*3) bytes + suitable for direct inclusion in the GIF header + + :param palette_bytes: Unpadded palette bytes, in RGBRGB form + :returns: Null padded palette + """ + color_table_size = _get_color_table_size(palette_bytes) + + # add the missing amount of bytes + # the palette has to be 2< 0: + palette_bytes += o8(0) * 3 * actual_target_size_diff + return palette_bytes + + +def _get_palette_bytes(im): + """ + Gets the palette for inclusion in the gif header + + :param im: Image object + :returns: Bytes, len<=768 suitable for inclusion in gif header + """ + return im.palette.palette if im.palette else b"" + + +def _get_background(im, info_background): + background = 0 + if info_background: + if isinstance(info_background, tuple): + # WebPImagePlugin stores an RGBA value in info["background"] + # So it must be converted to the same format as GifImagePlugin's + # info["background"] - a global color table index + try: + background = im.palette.getcolor(info_background, im) + except ValueError as e: + if str(e) not in ( + # If all 256 colors are in use, + # then there is no need for the background color + "cannot allocate more than 256 colors", + # Ignore non-opaque WebP background + "cannot add non-opaque RGBA color to RGB palette", + ): + raise + else: + background = info_background + return background + + +def _get_global_header(im, info): + """Return a list of strings representing a GIF header""" + + # Header Block + # https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp + + version = b"87a" + if im.info.get("version") == b"89a" or ( + info + and ( + "transparency" in info + or info.get("loop") is not None + or info.get("duration") + or info.get("comment") + ) + ): + version = b"89a" + + background = _get_background(im, info.get("background")) + + palette_bytes = _get_palette_bytes(im) + color_table_size = _get_color_table_size(palette_bytes) + + header = [ + b"GIF" # signature + + version # version + + o16(im.size[0]) # canvas width + + o16(im.size[1]), # canvas height + # Logical Screen Descriptor + # size of global color table + global color table flag + o8(color_table_size + 128), # packed fields + # background + reserved/aspect + o8(background) + o8(0), + # Global Color Table + _get_header_palette(palette_bytes), + ] + if info.get("loop") is not None: + header.append( + b"!" + + o8(255) # extension intro + + o8(11) + + b"NETSCAPE2.0" + + o8(3) + + o8(1) + + o16(info["loop"]) # number of loops + + o8(0) + ) + if info.get("comment"): + comment_block = b"!" + o8(254) # extension intro + + comment = info["comment"] + if isinstance(comment, str): + comment = comment.encode() + for i in range(0, len(comment), 255): + subblock = comment[i : i + 255] + comment_block += o8(len(subblock)) + subblock + + comment_block += o8(0) + header.append(comment_block) + return header + + +def _write_frame_data(fp, im_frame, offset, params): + try: + im_frame.encoderinfo = params + + # local image header + _write_local_header(fp, im_frame, offset, 0) + + ImageFile._save( + im_frame, fp, [("gif", (0, 0) + im_frame.size, 0, RAWMODE[im_frame.mode])] + ) + + fp.write(b"\0") # end of image data + finally: + del im_frame.encoderinfo + + +# -------------------------------------------------------------------- +# Legacy GIF utilities + + +def getheader(im, palette=None, info=None): + """ + Legacy Method to get Gif data from image. + + Warning:: May modify image data. + + :param im: Image object + :param palette: bytes object containing the source palette, or .... + :param info: encoderinfo + :returns: tuple of(list of header items, optimized palette) + + """ + used_palette_colors = _get_optimize(im, info) + + if info is None: + info = {} + + if "background" not in info and "background" in im.info: + info["background"] = im.info["background"] + + im_mod = _normalize_palette(im, palette, info) + im.palette = im_mod.palette + im.im = im_mod.im + header = _get_global_header(im, info) + + return header, used_palette_colors + + +def getdata(im, offset=(0, 0), **params): + """ + Legacy Method + + Return a list of strings representing this image. + The first string is a local image header, the rest contains + encoded image data. + + To specify duration, add the time in milliseconds, + e.g. ``getdata(im_frame, duration=1000)`` + + :param im: Image object + :param offset: Tuple of (x, y) pixels. Defaults to (0, 0) + :param \\**params: e.g. duration or other encoder info parameters + :returns: List of bytes containing GIF encoded frame data + + """ + + class Collector: + data = [] + + def write(self, data): + self.data.append(data) + + im.load() # make sure raster data is available + + fp = Collector() + + _write_frame_data(fp, im, offset, params) + + return fp.data + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(GifImageFile.format, GifImageFile, _accept) +Image.register_save(GifImageFile.format, _save) +Image.register_save_all(GifImageFile.format, _save_all) +Image.register_extension(GifImageFile.format, ".gif") +Image.register_mime(GifImageFile.format, "image/gif") + +# +# Uncomment the following line if you wish to use NETPBM/PBMPLUS +# instead of the built-in "uncompressed" GIF encoder + +# Image.register_save(GifImageFile.format, _save_netpbm) diff --git a/venv/lib/python3.10/site-packages/PIL/GimpGradientFile.py b/venv/lib/python3.10/site-packages/PIL/GimpGradientFile.py new file mode 100644 index 00000000..2d8c78ea --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/GimpGradientFile.py @@ -0,0 +1,137 @@ +# +# Python Imaging Library +# $Id$ +# +# stuff to read (and render) GIMP gradient files +# +# History: +# 97-08-23 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# + +""" +Stuff to translate curve segments to palette values (derived from +the corresponding code in GIMP, written by Federico Mena Quintero. +See the GIMP distribution for more information.) +""" +from __future__ import annotations + +from math import log, pi, sin, sqrt + +from ._binary import o8 + +EPSILON = 1e-10 +"""""" # Enable auto-doc for data member + + +def linear(middle, pos): + if pos <= middle: + if middle < EPSILON: + return 0.0 + else: + return 0.5 * pos / middle + else: + pos = pos - middle + middle = 1.0 - middle + if middle < EPSILON: + return 1.0 + else: + return 0.5 + 0.5 * pos / middle + + +def curved(middle, pos): + return pos ** (log(0.5) / log(max(middle, EPSILON))) + + +def sine(middle, pos): + return (sin((-pi / 2.0) + pi * linear(middle, pos)) + 1.0) / 2.0 + + +def sphere_increasing(middle, pos): + return sqrt(1.0 - (linear(middle, pos) - 1.0) ** 2) + + +def sphere_decreasing(middle, pos): + return 1.0 - sqrt(1.0 - linear(middle, pos) ** 2) + + +SEGMENTS = [linear, curved, sine, sphere_increasing, sphere_decreasing] +"""""" # Enable auto-doc for data member + + +class GradientFile: + gradient = None + + def getpalette(self, entries=256): + palette = [] + + ix = 0 + x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix] + + for i in range(entries): + x = i / (entries - 1) + + while x1 < x: + ix += 1 + x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix] + + w = x1 - x0 + + if w < EPSILON: + scale = segment(0.5, 0.5) + else: + scale = segment((xm - x0) / w, (x - x0) / w) + + # expand to RGBA + r = o8(int(255 * ((rgb1[0] - rgb0[0]) * scale + rgb0[0]) + 0.5)) + g = o8(int(255 * ((rgb1[1] - rgb0[1]) * scale + rgb0[1]) + 0.5)) + b = o8(int(255 * ((rgb1[2] - rgb0[2]) * scale + rgb0[2]) + 0.5)) + a = o8(int(255 * ((rgb1[3] - rgb0[3]) * scale + rgb0[3]) + 0.5)) + + # add to palette + palette.append(r + g + b + a) + + return b"".join(palette), "RGBA" + + +class GimpGradientFile(GradientFile): + """File handler for GIMP's gradient format.""" + + def __init__(self, fp): + if fp.readline()[:13] != b"GIMP Gradient": + msg = "not a GIMP gradient file" + raise SyntaxError(msg) + + line = fp.readline() + + # GIMP 1.2 gradient files don't contain a name, but GIMP 1.3 files do + if line.startswith(b"Name: "): + line = fp.readline().strip() + + count = int(line) + + gradient = [] + + for i in range(count): + s = fp.readline().split() + w = [float(x) for x in s[:11]] + + x0, x1 = w[0], w[2] + xm = w[1] + rgb0 = w[3:7] + rgb1 = w[7:11] + + segment = SEGMENTS[int(s[11])] + cspace = int(s[12]) + + if cspace != 0: + msg = "cannot handle HSV colour space" + raise OSError(msg) + + gradient.append((x0, x1, xm, rgb0, rgb1, segment)) + + self.gradient = gradient diff --git a/venv/lib/python3.10/site-packages/PIL/GimpPaletteFile.py b/venv/lib/python3.10/site-packages/PIL/GimpPaletteFile.py new file mode 100644 index 00000000..a3109eba --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/GimpPaletteFile.py @@ -0,0 +1,57 @@ +# +# Python Imaging Library +# $Id$ +# +# stuff to read GIMP palette files +# +# History: +# 1997-08-23 fl Created +# 2004-09-07 fl Support GIMP 2.0 palette files. +# +# Copyright (c) Secret Labs AB 1997-2004. All rights reserved. +# Copyright (c) Fredrik Lundh 1997-2004. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import re + +from ._binary import o8 + + +class GimpPaletteFile: + """File handler for GIMP's palette format.""" + + rawmode = "RGB" + + def __init__(self, fp): + self.palette = [o8(i) * 3 for i in range(256)] + + if fp.readline()[:12] != b"GIMP Palette": + msg = "not a GIMP palette file" + raise SyntaxError(msg) + + for i in range(256): + s = fp.readline() + if not s: + break + + # skip fields and comment lines + if re.match(rb"\w+:|#", s): + continue + if len(s) > 100: + msg = "bad palette file" + raise SyntaxError(msg) + + v = tuple(map(int, s.split()[:3])) + if len(v) != 3: + msg = "bad palette entry" + raise ValueError(msg) + + self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2]) + + self.palette = b"".join(self.palette) + + def getpalette(self): + return self.palette, self.rawmode diff --git a/venv/lib/python3.10/site-packages/PIL/GribStubImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/GribStubImagePlugin.py new file mode 100644 index 00000000..f8106800 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/GribStubImagePlugin.py @@ -0,0 +1,74 @@ +# +# The Python Imaging Library +# $Id$ +# +# GRIB stub adapter +# +# Copyright (c) 1996-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile + +_handler = None + + +def register_handler(handler): + """ + Install application-specific GRIB image handler. + + :param handler: Handler object. + """ + global _handler + _handler = handler + + +# -------------------------------------------------------------------- +# Image adapter + + +def _accept(prefix): + return prefix[:4] == b"GRIB" and prefix[7] == 1 + + +class GribStubImageFile(ImageFile.StubImageFile): + format = "GRIB" + format_description = "GRIB" + + def _open(self): + offset = self.fp.tell() + + if not _accept(self.fp.read(8)): + msg = "Not a GRIB file" + raise SyntaxError(msg) + + self.fp.seek(offset) + + # make something up + self._mode = "F" + self._size = 1, 1 + + loader = self._load() + if loader: + loader.open(self) + + def _load(self): + return _handler + + +def _save(im, fp, filename): + if _handler is None or not hasattr(_handler, "save"): + msg = "GRIB save handler not installed" + raise OSError(msg) + _handler.save(im, fp, filename) + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(GribStubImageFile.format, GribStubImageFile, _accept) +Image.register_save(GribStubImageFile.format, _save) + +Image.register_extension(GribStubImageFile.format, ".grib") diff --git a/venv/lib/python3.10/site-packages/PIL/Hdf5StubImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/Hdf5StubImagePlugin.py new file mode 100644 index 00000000..65409e26 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/Hdf5StubImagePlugin.py @@ -0,0 +1,74 @@ +# +# The Python Imaging Library +# $Id$ +# +# HDF5 stub adapter +# +# Copyright (c) 2000-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile + +_handler = None + + +def register_handler(handler): + """ + Install application-specific HDF5 image handler. + + :param handler: Handler object. + """ + global _handler + _handler = handler + + +# -------------------------------------------------------------------- +# Image adapter + + +def _accept(prefix): + return prefix[:8] == b"\x89HDF\r\n\x1a\n" + + +class HDF5StubImageFile(ImageFile.StubImageFile): + format = "HDF5" + format_description = "HDF5" + + def _open(self): + offset = self.fp.tell() + + if not _accept(self.fp.read(8)): + msg = "Not an HDF file" + raise SyntaxError(msg) + + self.fp.seek(offset) + + # make something up + self._mode = "F" + self._size = 1, 1 + + loader = self._load() + if loader: + loader.open(self) + + def _load(self): + return _handler + + +def _save(im, fp, filename): + if _handler is None or not hasattr(_handler, "save"): + msg = "HDF5 save handler not installed" + raise OSError(msg) + _handler.save(im, fp, filename) + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(HDF5StubImageFile.format, HDF5StubImageFile, _accept) +Image.register_save(HDF5StubImageFile.format, _save) + +Image.register_extensions(HDF5StubImageFile.format, [".h5", ".hdf"]) diff --git a/venv/lib/python3.10/site-packages/PIL/IcnsImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/IcnsImagePlugin.py new file mode 100644 index 00000000..d877b4ec --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/IcnsImagePlugin.py @@ -0,0 +1,400 @@ +# +# The Python Imaging Library. +# $Id$ +# +# macOS icns file decoder, based on icns.py by Bob Ippolito. +# +# history: +# 2004-10-09 fl Turned into a PIL plugin; removed 2.3 dependencies. +# 2020-04-04 Allow saving on all operating systems. +# +# Copyright (c) 2004 by Bob Ippolito. +# Copyright (c) 2004 by Secret Labs. +# Copyright (c) 2004 by Fredrik Lundh. +# Copyright (c) 2014 by Alastair Houghton. +# Copyright (c) 2020 by Pan Jing. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import os +import struct +import sys + +from . import Image, ImageFile, PngImagePlugin, features + +enable_jpeg2k = features.check_codec("jpg_2000") +if enable_jpeg2k: + from . import Jpeg2KImagePlugin + +MAGIC = b"icns" +HEADERSIZE = 8 + + +def nextheader(fobj): + return struct.unpack(">4sI", fobj.read(HEADERSIZE)) + + +def read_32t(fobj, start_length, size): + # The 128x128 icon seems to have an extra header for some reason. + (start, length) = start_length + fobj.seek(start) + sig = fobj.read(4) + if sig != b"\x00\x00\x00\x00": + msg = "Unknown signature, expecting 0x00000000" + raise SyntaxError(msg) + return read_32(fobj, (start + 4, length - 4), size) + + +def read_32(fobj, start_length, size): + """ + Read a 32bit RGB icon resource. Seems to be either uncompressed or + an RLE packbits-like scheme. + """ + (start, length) = start_length + fobj.seek(start) + pixel_size = (size[0] * size[2], size[1] * size[2]) + sizesq = pixel_size[0] * pixel_size[1] + if length == sizesq * 3: + # uncompressed ("RGBRGBGB") + indata = fobj.read(length) + im = Image.frombuffer("RGB", pixel_size, indata, "raw", "RGB", 0, 1) + else: + # decode image + im = Image.new("RGB", pixel_size, None) + for band_ix in range(3): + data = [] + bytesleft = sizesq + while bytesleft > 0: + byte = fobj.read(1) + if not byte: + break + byte = byte[0] + if byte & 0x80: + blocksize = byte - 125 + byte = fobj.read(1) + for i in range(blocksize): + data.append(byte) + else: + blocksize = byte + 1 + data.append(fobj.read(blocksize)) + bytesleft -= blocksize + if bytesleft <= 0: + break + if bytesleft != 0: + msg = f"Error reading channel [{repr(bytesleft)} left]" + raise SyntaxError(msg) + band = Image.frombuffer("L", pixel_size, b"".join(data), "raw", "L", 0, 1) + im.im.putband(band.im, band_ix) + return {"RGB": im} + + +def read_mk(fobj, start_length, size): + # Alpha masks seem to be uncompressed + start = start_length[0] + fobj.seek(start) + pixel_size = (size[0] * size[2], size[1] * size[2]) + sizesq = pixel_size[0] * pixel_size[1] + band = Image.frombuffer("L", pixel_size, fobj.read(sizesq), "raw", "L", 0, 1) + return {"A": band} + + +def read_png_or_jpeg2000(fobj, start_length, size): + (start, length) = start_length + fobj.seek(start) + sig = fobj.read(12) + if sig[:8] == b"\x89PNG\x0d\x0a\x1a\x0a": + fobj.seek(start) + im = PngImagePlugin.PngImageFile(fobj) + Image._decompression_bomb_check(im.size) + return {"RGBA": im} + elif ( + sig[:4] == b"\xff\x4f\xff\x51" + or sig[:4] == b"\x0d\x0a\x87\x0a" + or sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a" + ): + if not enable_jpeg2k: + msg = ( + "Unsupported icon subimage format (rebuild PIL " + "with JPEG 2000 support to fix this)" + ) + raise ValueError(msg) + # j2k, jpc or j2c + fobj.seek(start) + jp2kstream = fobj.read(length) + f = io.BytesIO(jp2kstream) + im = Jpeg2KImagePlugin.Jpeg2KImageFile(f) + Image._decompression_bomb_check(im.size) + if im.mode != "RGBA": + im = im.convert("RGBA") + return {"RGBA": im} + else: + msg = "Unsupported icon subimage format" + raise ValueError(msg) + + +class IcnsFile: + SIZES = { + (512, 512, 2): [(b"ic10", read_png_or_jpeg2000)], + (512, 512, 1): [(b"ic09", read_png_or_jpeg2000)], + (256, 256, 2): [(b"ic14", read_png_or_jpeg2000)], + (256, 256, 1): [(b"ic08", read_png_or_jpeg2000)], + (128, 128, 2): [(b"ic13", read_png_or_jpeg2000)], + (128, 128, 1): [ + (b"ic07", read_png_or_jpeg2000), + (b"it32", read_32t), + (b"t8mk", read_mk), + ], + (64, 64, 1): [(b"icp6", read_png_or_jpeg2000)], + (32, 32, 2): [(b"ic12", read_png_or_jpeg2000)], + (48, 48, 1): [(b"ih32", read_32), (b"h8mk", read_mk)], + (32, 32, 1): [ + (b"icp5", read_png_or_jpeg2000), + (b"il32", read_32), + (b"l8mk", read_mk), + ], + (16, 16, 2): [(b"ic11", read_png_or_jpeg2000)], + (16, 16, 1): [ + (b"icp4", read_png_or_jpeg2000), + (b"is32", read_32), + (b"s8mk", read_mk), + ], + } + + def __init__(self, fobj): + """ + fobj is a file-like object as an icns resource + """ + # signature : (start, length) + self.dct = dct = {} + self.fobj = fobj + sig, filesize = nextheader(fobj) + if not _accept(sig): + msg = "not an icns file" + raise SyntaxError(msg) + i = HEADERSIZE + while i < filesize: + sig, blocksize = nextheader(fobj) + if blocksize <= 0: + msg = "invalid block header" + raise SyntaxError(msg) + i += HEADERSIZE + blocksize -= HEADERSIZE + dct[sig] = (i, blocksize) + fobj.seek(blocksize, io.SEEK_CUR) + i += blocksize + + def itersizes(self): + sizes = [] + for size, fmts in self.SIZES.items(): + for fmt, reader in fmts: + if fmt in self.dct: + sizes.append(size) + break + return sizes + + def bestsize(self): + sizes = self.itersizes() + if not sizes: + msg = "No 32bit icon resources found" + raise SyntaxError(msg) + return max(sizes) + + def dataforsize(self, size): + """ + Get an icon resource as {channel: array}. Note that + the arrays are bottom-up like windows bitmaps and will likely + need to be flipped or transposed in some way. + """ + dct = {} + for code, reader in self.SIZES[size]: + desc = self.dct.get(code) + if desc is not None: + dct.update(reader(self.fobj, desc, size)) + return dct + + def getimage(self, size=None): + if size is None: + size = self.bestsize() + if len(size) == 2: + size = (size[0], size[1], 1) + channels = self.dataforsize(size) + + im = channels.get("RGBA", None) + if im: + return im + + im = channels.get("RGB").copy() + try: + im.putalpha(channels["A"]) + except KeyError: + pass + return im + + +## +# Image plugin for Mac OS icons. + + +class IcnsImageFile(ImageFile.ImageFile): + """ + PIL image support for Mac OS .icns files. + Chooses the best resolution, but will possibly load + a different size image if you mutate the size attribute + before calling 'load'. + + The info dictionary has a key 'sizes' that is a list + of sizes that the icns file has. + """ + + format = "ICNS" + format_description = "Mac OS icns resource" + + def _open(self): + self.icns = IcnsFile(self.fp) + self._mode = "RGBA" + self.info["sizes"] = self.icns.itersizes() + self.best_size = self.icns.bestsize() + self.size = ( + self.best_size[0] * self.best_size[2], + self.best_size[1] * self.best_size[2], + ) + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + info_size = value + if info_size not in self.info["sizes"] and len(info_size) == 2: + info_size = (info_size[0], info_size[1], 1) + if ( + info_size not in self.info["sizes"] + and len(info_size) == 3 + and info_size[2] == 1 + ): + simple_sizes = [ + (size[0] * size[2], size[1] * size[2]) for size in self.info["sizes"] + ] + if value in simple_sizes: + info_size = self.info["sizes"][simple_sizes.index(value)] + if info_size not in self.info["sizes"]: + msg = "This is not one of the allowed sizes of this image" + raise ValueError(msg) + self._size = value + + def load(self): + if len(self.size) == 3: + self.best_size = self.size + self.size = ( + self.best_size[0] * self.best_size[2], + self.best_size[1] * self.best_size[2], + ) + + px = Image.Image.load(self) + if self.im is not None and self.im.size == self.size: + # Already loaded + return px + self.load_prepare() + # This is likely NOT the best way to do it, but whatever. + im = self.icns.getimage(self.best_size) + + # If this is a PNG or JPEG 2000, it won't be loaded yet + px = im.load() + + self.im = im.im + self._mode = im.mode + self.size = im.size + + return px + + +def _save(im, fp, filename): + """ + Saves the image as a series of PNG files, + that are then combined into a .icns file. + """ + if hasattr(fp, "flush"): + fp.flush() + + sizes = { + b"ic07": 128, + b"ic08": 256, + b"ic09": 512, + b"ic10": 1024, + b"ic11": 32, + b"ic12": 64, + b"ic13": 256, + b"ic14": 512, + } + provided_images = {im.width: im for im in im.encoderinfo.get("append_images", [])} + size_streams = {} + for size in set(sizes.values()): + image = ( + provided_images[size] + if size in provided_images + else im.resize((size, size)) + ) + + temp = io.BytesIO() + image.save(temp, "png") + size_streams[size] = temp.getvalue() + + entries = [] + for type, size in sizes.items(): + stream = size_streams[size] + entries.append( + {"type": type, "size": HEADERSIZE + len(stream), "stream": stream} + ) + + # Header + fp.write(MAGIC) + file_length = HEADERSIZE # Header + file_length += HEADERSIZE + 8 * len(entries) # TOC + file_length += sum(entry["size"] for entry in entries) + fp.write(struct.pack(">i", file_length)) + + # TOC + fp.write(b"TOC ") + fp.write(struct.pack(">i", HEADERSIZE + len(entries) * HEADERSIZE)) + for entry in entries: + fp.write(entry["type"]) + fp.write(struct.pack(">i", entry["size"])) + + # Data + for entry in entries: + fp.write(entry["type"]) + fp.write(struct.pack(">i", entry["size"])) + fp.write(entry["stream"]) + + if hasattr(fp, "flush"): + fp.flush() + + +def _accept(prefix): + return prefix[:4] == MAGIC + + +Image.register_open(IcnsImageFile.format, IcnsImageFile, _accept) +Image.register_extension(IcnsImageFile.format, ".icns") + +Image.register_save(IcnsImageFile.format, _save) +Image.register_mime(IcnsImageFile.format, "image/icns") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Syntax: python3 IcnsImagePlugin.py [file]") + sys.exit() + + with open(sys.argv[1], "rb") as fp: + imf = IcnsImageFile(fp) + for size in imf.info["sizes"]: + width, height, scale = imf.size = size + imf.save(f"out-{width}-{height}-{scale}.png") + with Image.open(sys.argv[1]) as im: + im.save("out.png") + if sys.platform == "windows": + os.startfile("out.png") diff --git a/venv/lib/python3.10/site-packages/PIL/IcoImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/IcoImagePlugin.py new file mode 100644 index 00000000..d66fbc28 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/IcoImagePlugin.py @@ -0,0 +1,358 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Windows Icon support for PIL +# +# History: +# 96-05-27 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# + +# This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis +# . +# https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki +# +# Icon format references: +# * https://en.wikipedia.org/wiki/ICO_(file_format) +# * https://msdn.microsoft.com/en-us/library/ms997538.aspx +from __future__ import annotations + +import warnings +from io import BytesIO +from math import ceil, log + +from . import BmpImagePlugin, Image, ImageFile, PngImagePlugin +from ._binary import i16le as i16 +from ._binary import i32le as i32 +from ._binary import o8 +from ._binary import o16le as o16 +from ._binary import o32le as o32 + +# +# -------------------------------------------------------------------- + +_MAGIC = b"\0\0\1\0" + + +def _save(im, fp, filename): + fp.write(_MAGIC) # (2+2) + bmp = im.encoderinfo.get("bitmap_format") == "bmp" + sizes = im.encoderinfo.get( + "sizes", + [(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)], + ) + frames = [] + provided_ims = [im] + im.encoderinfo.get("append_images", []) + width, height = im.size + for size in sorted(set(sizes)): + if size[0] > width or size[1] > height or size[0] > 256 or size[1] > 256: + continue + + for provided_im in provided_ims: + if provided_im.size != size: + continue + frames.append(provided_im) + if bmp: + bits = BmpImagePlugin.SAVE[provided_im.mode][1] + bits_used = [bits] + for other_im in provided_ims: + if other_im.size != size: + continue + bits = BmpImagePlugin.SAVE[other_im.mode][1] + if bits not in bits_used: + # Another image has been supplied for this size + # with a different bit depth + frames.append(other_im) + bits_used.append(bits) + break + else: + # TODO: invent a more convenient method for proportional scalings + frame = provided_im.copy() + frame.thumbnail(size, Image.Resampling.LANCZOS, reducing_gap=None) + frames.append(frame) + fp.write(o16(len(frames))) # idCount(2) + offset = fp.tell() + len(frames) * 16 + for frame in frames: + width, height = frame.size + # 0 means 256 + fp.write(o8(width if width < 256 else 0)) # bWidth(1) + fp.write(o8(height if height < 256 else 0)) # bHeight(1) + + bits, colors = BmpImagePlugin.SAVE[frame.mode][1:] if bmp else (32, 0) + fp.write(o8(colors)) # bColorCount(1) + fp.write(b"\0") # bReserved(1) + fp.write(b"\0\0") # wPlanes(2) + fp.write(o16(bits)) # wBitCount(2) + + image_io = BytesIO() + if bmp: + frame.save(image_io, "dib") + + if bits != 32: + and_mask = Image.new("1", size) + ImageFile._save( + and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))] + ) + else: + frame.save(image_io, "png") + image_io.seek(0) + image_bytes = image_io.read() + if bmp: + image_bytes = image_bytes[:8] + o32(height * 2) + image_bytes[12:] + bytes_len = len(image_bytes) + fp.write(o32(bytes_len)) # dwBytesInRes(4) + fp.write(o32(offset)) # dwImageOffset(4) + current = fp.tell() + fp.seek(offset) + fp.write(image_bytes) + offset = offset + bytes_len + fp.seek(current) + + +def _accept(prefix): + return prefix[:4] == _MAGIC + + +class IcoFile: + def __init__(self, buf): + """ + Parse image from file-like object containing ico file data + """ + + # check magic + s = buf.read(6) + if not _accept(s): + msg = "not an ICO file" + raise SyntaxError(msg) + + self.buf = buf + self.entry = [] + + # Number of items in file + self.nb_items = i16(s, 4) + + # Get headers for each item + for i in range(self.nb_items): + s = buf.read(16) + + icon_header = { + "width": s[0], + "height": s[1], + "nb_color": s[2], # No. of colors in image (0 if >=8bpp) + "reserved": s[3], + "planes": i16(s, 4), + "bpp": i16(s, 6), + "size": i32(s, 8), + "offset": i32(s, 12), + } + + # See Wikipedia + for j in ("width", "height"): + if not icon_header[j]: + icon_header[j] = 256 + + # See Wikipedia notes about color depth. + # We need this just to differ images with equal sizes + icon_header["color_depth"] = ( + icon_header["bpp"] + or ( + icon_header["nb_color"] != 0 + and ceil(log(icon_header["nb_color"], 2)) + ) + or 256 + ) + + icon_header["dim"] = (icon_header["width"], icon_header["height"]) + icon_header["square"] = icon_header["width"] * icon_header["height"] + + self.entry.append(icon_header) + + self.entry = sorted(self.entry, key=lambda x: x["color_depth"]) + # ICO images are usually squares + self.entry = sorted(self.entry, key=lambda x: x["square"], reverse=True) + + def sizes(self): + """ + Get a list of all available icon sizes and color depths. + """ + return {(h["width"], h["height"]) for h in self.entry} + + def getentryindex(self, size, bpp=False): + for i, h in enumerate(self.entry): + if size == h["dim"] and (bpp is False or bpp == h["color_depth"]): + return i + return 0 + + def getimage(self, size, bpp=False): + """ + Get an image from the icon + """ + return self.frame(self.getentryindex(size, bpp)) + + def frame(self, idx): + """ + Get an image from frame idx + """ + + header = self.entry[idx] + + self.buf.seek(header["offset"]) + data = self.buf.read(8) + self.buf.seek(header["offset"]) + + if data[:8] == PngImagePlugin._MAGIC: + # png frame + im = PngImagePlugin.PngImageFile(self.buf) + Image._decompression_bomb_check(im.size) + else: + # XOR + AND mask bmp frame + im = BmpImagePlugin.DibImageFile(self.buf) + Image._decompression_bomb_check(im.size) + + # change tile dimension to only encompass XOR image + im._size = (im.size[0], int(im.size[1] / 2)) + d, e, o, a = im.tile[0] + im.tile[0] = d, (0, 0) + im.size, o, a + + # figure out where AND mask image starts + bpp = header["bpp"] + if 32 == bpp: + # 32-bit color depth icon image allows semitransparent areas + # PIL's DIB format ignores transparency bits, recover them. + # The DIB is packed in BGRX byte order where X is the alpha + # channel. + + # Back up to start of bmp data + self.buf.seek(o) + # extract every 4th byte (eg. 3,7,11,15,...) + alpha_bytes = self.buf.read(im.size[0] * im.size[1] * 4)[3::4] + + # convert to an 8bpp grayscale image + mask = Image.frombuffer( + "L", # 8bpp + im.size, # (w, h) + alpha_bytes, # source chars + "raw", # raw decoder + ("L", 0, -1), # 8bpp inverted, unpadded, reversed + ) + else: + # get AND image from end of bitmap + w = im.size[0] + if (w % 32) > 0: + # bitmap row data is aligned to word boundaries + w += 32 - (im.size[0] % 32) + + # the total mask data is + # padded row size * height / bits per char + + total_bytes = int((w * im.size[1]) / 8) + and_mask_offset = header["offset"] + header["size"] - total_bytes + + self.buf.seek(and_mask_offset) + mask_data = self.buf.read(total_bytes) + + # convert raw data to image + mask = Image.frombuffer( + "1", # 1 bpp + im.size, # (w, h) + mask_data, # source chars + "raw", # raw decoder + ("1;I", int(w / 8), -1), # 1bpp inverted, padded, reversed + ) + + # now we have two images, im is XOR image and mask is AND image + + # apply mask image as alpha channel + im = im.convert("RGBA") + im.putalpha(mask) + + return im + + +## +# Image plugin for Windows Icon files. + + +class IcoImageFile(ImageFile.ImageFile): + """ + PIL read-only image support for Microsoft Windows .ico files. + + By default the largest resolution image in the file will be loaded. This + can be changed by altering the 'size' attribute before calling 'load'. + + The info dictionary has a key 'sizes' that is a list of the sizes available + in the icon file. + + Handles classic, XP and Vista icon formats. + + When saving, PNG compression is used. Support for this was only added in + Windows Vista. If you are unable to view the icon in Windows, convert the + image to "RGBA" mode before saving. + + This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis + . + https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki + """ + + format = "ICO" + format_description = "Windows Icon" + + def _open(self): + self.ico = IcoFile(self.fp) + self.info["sizes"] = self.ico.sizes() + self.size = self.ico.entry[0]["dim"] + self.load() + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + if value not in self.info["sizes"]: + msg = "This is not one of the allowed sizes of this image" + raise ValueError(msg) + self._size = value + + def load(self): + if self.im is not None and self.im.size == self.size: + # Already loaded + return Image.Image.load(self) + im = self.ico.getimage(self.size) + # if tile is PNG, it won't really be loaded yet + im.load() + self.im = im.im + self.pyaccess = None + self._mode = im.mode + if im.palette: + self.palette = im.palette + if im.size != self.size: + warnings.warn("Image was not the expected size") + + index = self.ico.getentryindex(self.size) + sizes = list(self.info["sizes"]) + sizes[index] = im.size + self.info["sizes"] = set(sizes) + + self.size = im.size + + def load_seek(self, pos): + # Flag the ImageFile.Parser so that it + # just does all the decode at the end. + pass + + +# +# -------------------------------------------------------------------- + + +Image.register_open(IcoImageFile.format, IcoImageFile, _accept) +Image.register_save(IcoImageFile.format, _save) +Image.register_extension(IcoImageFile.format, ".ico") + +Image.register_mime(IcoImageFile.format, "image/x-icon") diff --git a/venv/lib/python3.10/site-packages/PIL/ImImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/ImImagePlugin.py new file mode 100644 index 00000000..4613e40b --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImImagePlugin.py @@ -0,0 +1,371 @@ +# +# The Python Imaging Library. +# $Id$ +# +# IFUNC IM file handling for PIL +# +# history: +# 1995-09-01 fl Created. +# 1997-01-03 fl Save palette images +# 1997-01-08 fl Added sequence support +# 1997-01-23 fl Added P and RGB save support +# 1997-05-31 fl Read floating point images +# 1997-06-22 fl Save floating point images +# 1997-08-27 fl Read and save 1-bit images +# 1998-06-25 fl Added support for RGB+LUT images +# 1998-07-02 fl Added support for YCC images +# 1998-07-15 fl Renamed offset attribute to avoid name clash +# 1998-12-29 fl Added I;16 support +# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.7) +# 2003-09-26 fl Added LA/PA support +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1995-2001 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import os +import re + +from . import Image, ImageFile, ImagePalette + +# -------------------------------------------------------------------- +# Standard tags + +COMMENT = "Comment" +DATE = "Date" +EQUIPMENT = "Digitalization equipment" +FRAMES = "File size (no of images)" +LUT = "Lut" +NAME = "Name" +SCALE = "Scale (x,y)" +SIZE = "Image size (x*y)" +MODE = "Image type" + +TAGS = { + COMMENT: 0, + DATE: 0, + EQUIPMENT: 0, + FRAMES: 0, + LUT: 0, + NAME: 0, + SCALE: 0, + SIZE: 0, + MODE: 0, +} + +OPEN = { + # ifunc93/p3cfunc formats + "0 1 image": ("1", "1"), + "L 1 image": ("1", "1"), + "Greyscale image": ("L", "L"), + "Grayscale image": ("L", "L"), + "RGB image": ("RGB", "RGB;L"), + "RLB image": ("RGB", "RLB"), + "RYB image": ("RGB", "RLB"), + "B1 image": ("1", "1"), + "B2 image": ("P", "P;2"), + "B4 image": ("P", "P;4"), + "X 24 image": ("RGB", "RGB"), + "L 32 S image": ("I", "I;32"), + "L 32 F image": ("F", "F;32"), + # old p3cfunc formats + "RGB3 image": ("RGB", "RGB;T"), + "RYB3 image": ("RGB", "RYB;T"), + # extensions + "LA image": ("LA", "LA;L"), + "PA image": ("LA", "PA;L"), + "RGBA image": ("RGBA", "RGBA;L"), + "RGBX image": ("RGBX", "RGBX;L"), + "CMYK image": ("CMYK", "CMYK;L"), + "YCC image": ("YCbCr", "YCbCr;L"), +} + +# ifunc95 extensions +for i in ["8", "8S", "16", "16S", "32", "32F"]: + OPEN[f"L {i} image"] = ("F", f"F;{i}") + OPEN[f"L*{i} image"] = ("F", f"F;{i}") +for i in ["16", "16L", "16B"]: + OPEN[f"L {i} image"] = (f"I;{i}", f"I;{i}") + OPEN[f"L*{i} image"] = (f"I;{i}", f"I;{i}") +for i in ["32S"]: + OPEN[f"L {i} image"] = ("I", f"I;{i}") + OPEN[f"L*{i} image"] = ("I", f"I;{i}") +for j in range(2, 33): + OPEN[f"L*{j} image"] = ("F", f"F;{j}") + + +# -------------------------------------------------------------------- +# Read IM directory + +split = re.compile(rb"^([A-Za-z][^:]*):[ \t]*(.*)[ \t]*$") + + +def number(s): + try: + return int(s) + except ValueError: + return float(s) + + +## +# Image plugin for the IFUNC IM file format. + + +class ImImageFile(ImageFile.ImageFile): + format = "IM" + format_description = "IFUNC Image Memory" + _close_exclusive_fp_after_loading = False + + def _open(self): + # Quick rejection: if there's not an LF among the first + # 100 bytes, this is (probably) not a text header. + + if b"\n" not in self.fp.read(100): + msg = "not an IM file" + raise SyntaxError(msg) + self.fp.seek(0) + + n = 0 + + # Default values + self.info[MODE] = "L" + self.info[SIZE] = (512, 512) + self.info[FRAMES] = 1 + + self.rawmode = "L" + + while True: + s = self.fp.read(1) + + # Some versions of IFUNC uses \n\r instead of \r\n... + if s == b"\r": + continue + + if not s or s == b"\0" or s == b"\x1A": + break + + # FIXME: this may read whole file if not a text file + s = s + self.fp.readline() + + if len(s) > 100: + msg = "not an IM file" + raise SyntaxError(msg) + + if s[-2:] == b"\r\n": + s = s[:-2] + elif s[-1:] == b"\n": + s = s[:-1] + + try: + m = split.match(s) + except re.error as e: + msg = "not an IM file" + raise SyntaxError(msg) from e + + if m: + k, v = m.group(1, 2) + + # Don't know if this is the correct encoding, + # but a decent guess (I guess) + k = k.decode("latin-1", "replace") + v = v.decode("latin-1", "replace") + + # Convert value as appropriate + if k in [FRAMES, SCALE, SIZE]: + v = v.replace("*", ",") + v = tuple(map(number, v.split(","))) + if len(v) == 1: + v = v[0] + elif k == MODE and v in OPEN: + v, self.rawmode = OPEN[v] + + # Add to dictionary. Note that COMMENT tags are + # combined into a list of strings. + if k == COMMENT: + if k in self.info: + self.info[k].append(v) + else: + self.info[k] = [v] + else: + self.info[k] = v + + if k in TAGS: + n += 1 + + else: + msg = "Syntax error in IM header: " + s.decode("ascii", "replace") + raise SyntaxError(msg) + + if not n: + msg = "Not an IM file" + raise SyntaxError(msg) + + # Basic attributes + self._size = self.info[SIZE] + self._mode = self.info[MODE] + + # Skip forward to start of image data + while s and s[:1] != b"\x1A": + s = self.fp.read(1) + if not s: + msg = "File truncated" + raise SyntaxError(msg) + + if LUT in self.info: + # convert lookup table to palette or lut attribute + palette = self.fp.read(768) + greyscale = 1 # greyscale palette + linear = 1 # linear greyscale palette + for i in range(256): + if palette[i] == palette[i + 256] == palette[i + 512]: + if palette[i] != i: + linear = 0 + else: + greyscale = 0 + if self.mode in ["L", "LA", "P", "PA"]: + if greyscale: + if not linear: + self.lut = list(palette[:256]) + else: + if self.mode in ["L", "P"]: + self._mode = self.rawmode = "P" + elif self.mode in ["LA", "PA"]: + self._mode = "PA" + self.rawmode = "PA;L" + self.palette = ImagePalette.raw("RGB;L", palette) + elif self.mode == "RGB": + if not greyscale or not linear: + self.lut = list(palette) + + self.frame = 0 + + self.__offset = offs = self.fp.tell() + + self._fp = self.fp # FIXME: hack + + if self.rawmode[:2] == "F;": + # ifunc95 formats + try: + # use bit decoder (if necessary) + bits = int(self.rawmode[2:]) + if bits not in [8, 16, 32]: + self.tile = [("bit", (0, 0) + self.size, offs, (bits, 8, 3, 0, -1))] + return + except ValueError: + pass + + if self.rawmode in ["RGB;T", "RYB;T"]: + # Old LabEye/3PC files. Would be very surprised if anyone + # ever stumbled upon such a file ;-) + size = self.size[0] * self.size[1] + self.tile = [ + ("raw", (0, 0) + self.size, offs, ("G", 0, -1)), + ("raw", (0, 0) + self.size, offs + size, ("R", 0, -1)), + ("raw", (0, 0) + self.size, offs + 2 * size, ("B", 0, -1)), + ] + else: + # LabEye/IFUNC files + self.tile = [("raw", (0, 0) + self.size, offs, (self.rawmode, 0, -1))] + + @property + def n_frames(self): + return self.info[FRAMES] + + @property + def is_animated(self): + return self.info[FRAMES] > 1 + + def seek(self, frame): + if not self._seek_check(frame): + return + + self.frame = frame + + if self.mode == "1": + bits = 1 + else: + bits = 8 * len(self.mode) + + size = ((self.size[0] * bits + 7) // 8) * self.size[1] + offs = self.__offset + frame * size + + self.fp = self._fp + + self.tile = [("raw", (0, 0) + self.size, offs, (self.rawmode, 0, -1))] + + def tell(self): + return self.frame + + +# +# -------------------------------------------------------------------- +# Save IM files + + +SAVE = { + # mode: (im type, raw mode) + "1": ("0 1", "1"), + "L": ("Greyscale", "L"), + "LA": ("LA", "LA;L"), + "P": ("Greyscale", "P"), + "PA": ("LA", "PA;L"), + "I": ("L 32S", "I;32S"), + "I;16": ("L 16", "I;16"), + "I;16L": ("L 16L", "I;16L"), + "I;16B": ("L 16B", "I;16B"), + "F": ("L 32F", "F;32F"), + "RGB": ("RGB", "RGB;L"), + "RGBA": ("RGBA", "RGBA;L"), + "RGBX": ("RGBX", "RGBX;L"), + "CMYK": ("CMYK", "CMYK;L"), + "YCbCr": ("YCC", "YCbCr;L"), +} + + +def _save(im, fp, filename): + try: + image_type, rawmode = SAVE[im.mode] + except KeyError as e: + msg = f"Cannot save {im.mode} images as IM" + raise ValueError(msg) from e + + frames = im.encoderinfo.get("frames", 1) + + fp.write(f"Image type: {image_type} image\r\n".encode("ascii")) + if filename: + # Each line must be 100 characters or less, + # or: SyntaxError("not an IM file") + # 8 characters are used for "Name: " and "\r\n" + # Keep just the filename, ditch the potentially overlong path + name, ext = os.path.splitext(os.path.basename(filename)) + name = "".join([name[: 92 - len(ext)], ext]) + + fp.write(f"Name: {name}\r\n".encode("ascii")) + fp.write(("Image size (x*y): %d*%d\r\n" % im.size).encode("ascii")) + fp.write(f"File size (no of images): {frames}\r\n".encode("ascii")) + if im.mode in ["P", "PA"]: + fp.write(b"Lut: 1\r\n") + fp.write(b"\000" * (511 - fp.tell()) + b"\032") + if im.mode in ["P", "PA"]: + im_palette = im.im.getpalette("RGB", "RGB;L") + colors = len(im_palette) // 3 + palette = b"" + for i in range(3): + palette += im_palette[colors * i : colors * (i + 1)] + palette += b"\x00" * (256 - colors) + fp.write(palette) # 768 bytes + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, -1))]) + + +# +# -------------------------------------------------------------------- +# Registry + + +Image.register_open(ImImageFile.format, ImImageFile) +Image.register_save(ImImageFile.format, _save) + +Image.register_extension(ImImageFile.format, ".im") diff --git a/venv/lib/python3.10/site-packages/PIL/Image.py b/venv/lib/python3.10/site-packages/PIL/Image.py new file mode 100644 index 00000000..baef0aa1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/Image.py @@ -0,0 +1,3983 @@ +# +# The Python Imaging Library. +# $Id$ +# +# the Image class wrapper +# +# partial release history: +# 1995-09-09 fl Created +# 1996-03-11 fl PIL release 0.0 (proof of concept) +# 1996-04-30 fl PIL release 0.1b1 +# 1999-07-28 fl PIL release 1.0 final +# 2000-06-07 fl PIL release 1.1 +# 2000-10-20 fl PIL release 1.1.1 +# 2001-05-07 fl PIL release 1.1.2 +# 2002-03-15 fl PIL release 1.1.3 +# 2003-05-10 fl PIL release 1.1.4 +# 2005-03-28 fl PIL release 1.1.5 +# 2006-12-02 fl PIL release 1.1.6 +# 2009-11-15 fl PIL release 1.1.7 +# +# Copyright (c) 1997-2009 by Secret Labs AB. All rights reserved. +# Copyright (c) 1995-2009 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +from __future__ import annotations + +import abc +import atexit +import builtins +import io +import logging +import math +import os +import re +import struct +import sys +import tempfile +import warnings +from collections.abc import Callable, MutableMapping +from enum import IntEnum +from types import ModuleType +from typing import IO, TYPE_CHECKING, Any + +# VERSION was removed in Pillow 6.0.0. +# PILLOW_VERSION was removed in Pillow 9.0.0. +# Use __version__ instead. +from . import ( + ExifTags, + ImageMode, + TiffTags, + UnidentifiedImageError, + __version__, + _plugins, +) +from ._binary import i32le, o32be, o32le +from ._typing import TypeGuard +from ._util import DeferredError, is_path + +ElementTree: ModuleType | None +try: + from defusedxml import ElementTree +except ImportError: + ElementTree = None + +logger = logging.getLogger(__name__) + + +class DecompressionBombWarning(RuntimeWarning): + pass + + +class DecompressionBombError(Exception): + pass + + +# Limit to around a quarter gigabyte for a 24-bit (3 bpp) image +MAX_IMAGE_PIXELS: int | None = int(1024 * 1024 * 1024 // 4 // 3) + + +try: + # If the _imaging C module is not present, Pillow will not load. + # Note that other modules should not refer to _imaging directly; + # import Image and use the Image.core variable instead. + # Also note that Image.core is not a publicly documented interface, + # and should be considered private and subject to change. + from . import _imaging as core + + if __version__ != getattr(core, "PILLOW_VERSION", None): + msg = ( + "The _imaging extension was built for another version of Pillow or PIL:\n" + f"Core version: {getattr(core, 'PILLOW_VERSION', None)}\n" + f"Pillow version: {__version__}" + ) + raise ImportError(msg) + +except ImportError as v: + core = DeferredError.new(ImportError("The _imaging C module is not installed.")) + # Explanations for ways that we know we might have an import error + if str(v).startswith("Module use of python"): + # The _imaging C module is present, but not compiled for + # the right version (windows only). Print a warning, if + # possible. + warnings.warn( + "The _imaging extension was built for another version of Python.", + RuntimeWarning, + ) + elif str(v).startswith("The _imaging extension"): + warnings.warn(str(v), RuntimeWarning) + # Fail here anyway. Don't let people run with a mostly broken Pillow. + # see docs/porting.rst + raise + + +USE_CFFI_ACCESS = False +cffi: ModuleType | None +try: + import cffi +except ImportError: + cffi = None + + +def isImageType(t: Any) -> TypeGuard[Image]: + """ + Checks if an object is an image object. + + .. warning:: + + This function is for internal use only. + + :param t: object to check if it's an image + :returns: True if the object is an image + """ + return hasattr(t, "im") + + +# +# Constants + + +# transpose +class Transpose(IntEnum): + FLIP_LEFT_RIGHT = 0 + FLIP_TOP_BOTTOM = 1 + ROTATE_90 = 2 + ROTATE_180 = 3 + ROTATE_270 = 4 + TRANSPOSE = 5 + TRANSVERSE = 6 + + +# transforms (also defined in Imaging.h) +class Transform(IntEnum): + AFFINE = 0 + EXTENT = 1 + PERSPECTIVE = 2 + QUAD = 3 + MESH = 4 + + +# resampling filters (also defined in Imaging.h) +class Resampling(IntEnum): + NEAREST = 0 + BOX = 4 + BILINEAR = 2 + HAMMING = 5 + BICUBIC = 3 + LANCZOS = 1 + + +_filters_support = { + Resampling.BOX: 0.5, + Resampling.BILINEAR: 1.0, + Resampling.HAMMING: 1.0, + Resampling.BICUBIC: 2.0, + Resampling.LANCZOS: 3.0, +} + + +# dithers +class Dither(IntEnum): + NONE = 0 + ORDERED = 1 # Not yet implemented + RASTERIZE = 2 # Not yet implemented + FLOYDSTEINBERG = 3 # default + + +# palettes/quantizers +class Palette(IntEnum): + WEB = 0 + ADAPTIVE = 1 + + +class Quantize(IntEnum): + MEDIANCUT = 0 + MAXCOVERAGE = 1 + FASTOCTREE = 2 + LIBIMAGEQUANT = 3 + + +module = sys.modules[__name__] +for enum in (Transpose, Transform, Resampling, Dither, Palette, Quantize): + for item in enum: + setattr(module, item.name, item.value) + + +if hasattr(core, "DEFAULT_STRATEGY"): + DEFAULT_STRATEGY = core.DEFAULT_STRATEGY + FILTERED = core.FILTERED + HUFFMAN_ONLY = core.HUFFMAN_ONLY + RLE = core.RLE + FIXED = core.FIXED + + +# -------------------------------------------------------------------- +# Registries + +if TYPE_CHECKING: + from . import ImageFile +ID: list[str] = [] +OPEN: dict[ + str, + tuple[ + Callable[[IO[bytes], str | bytes], ImageFile.ImageFile], + Callable[[bytes], bool] | None, + ], +] = {} +MIME: dict[str, str] = {} +SAVE: dict[str, Callable[[Image, IO[bytes], str | bytes], None]] = {} +SAVE_ALL: dict[str, Callable[[Image, IO[bytes], str | bytes], None]] = {} +EXTENSION: dict[str, str] = {} +DECODERS: dict[str, type[ImageFile.PyDecoder]] = {} +ENCODERS: dict[str, type[ImageFile.PyEncoder]] = {} + +# -------------------------------------------------------------------- +# Modes + +_ENDIAN = "<" if sys.byteorder == "little" else ">" + + +def _conv_type_shape(im): + m = ImageMode.getmode(im.mode) + shape = (im.height, im.width) + extra = len(m.bands) + if extra != 1: + shape += (extra,) + return shape, m.typestr + + +MODES = ["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"] + +# raw modes that may be memory mapped. NOTE: if you change this, you +# may have to modify the stride calculation in map.c too! +_MAPMODES = ("L", "P", "RGBX", "RGBA", "CMYK", "I;16", "I;16L", "I;16B") + + +def getmodebase(mode: str) -> str: + """ + Gets the "base" mode for given mode. This function returns "L" for + images that contain grayscale data, and "RGB" for images that + contain color data. + + :param mode: Input mode. + :returns: "L" or "RGB". + :exception KeyError: If the input mode was not a standard mode. + """ + return ImageMode.getmode(mode).basemode + + +def getmodetype(mode: str) -> str: + """ + Gets the storage type mode. Given a mode, this function returns a + single-layer mode suitable for storing individual bands. + + :param mode: Input mode. + :returns: "L", "I", or "F". + :exception KeyError: If the input mode was not a standard mode. + """ + return ImageMode.getmode(mode).basetype + + +def getmodebandnames(mode: str) -> tuple[str, ...]: + """ + Gets a list of individual band names. Given a mode, this function returns + a tuple containing the names of individual bands (use + :py:method:`~PIL.Image.getmodetype` to get the mode used to store each + individual band. + + :param mode: Input mode. + :returns: A tuple containing band names. The length of the tuple + gives the number of bands in an image of the given mode. + :exception KeyError: If the input mode was not a standard mode. + """ + return ImageMode.getmode(mode).bands + + +def getmodebands(mode: str) -> int: + """ + Gets the number of individual bands for this mode. + + :param mode: Input mode. + :returns: The number of bands in this mode. + :exception KeyError: If the input mode was not a standard mode. + """ + return len(ImageMode.getmode(mode).bands) + + +# -------------------------------------------------------------------- +# Helpers + +_initialized = 0 + + +def preinit() -> None: + """ + Explicitly loads BMP, GIF, JPEG, PPM and PPM file format drivers. + + It is called when opening or saving images. + """ + + global _initialized + if _initialized >= 1: + return + + try: + from . import BmpImagePlugin + + assert BmpImagePlugin + except ImportError: + pass + try: + from . import GifImagePlugin + + assert GifImagePlugin + except ImportError: + pass + try: + from . import JpegImagePlugin + + assert JpegImagePlugin + except ImportError: + pass + try: + from . import PpmImagePlugin + + assert PpmImagePlugin + except ImportError: + pass + try: + from . import PngImagePlugin + + assert PngImagePlugin + except ImportError: + pass + + _initialized = 1 + + +def init(): + """ + Explicitly initializes the Python Imaging Library. This function + loads all available file format drivers. + + It is called when opening or saving images if :py:meth:`~preinit()` is + insufficient, and by :py:meth:`~PIL.features.pilinfo`. + """ + + global _initialized + if _initialized >= 2: + return 0 + + parent_name = __name__.rpartition(".")[0] + for plugin in _plugins: + try: + logger.debug("Importing %s", plugin) + __import__(f"{parent_name}.{plugin}", globals(), locals(), []) + except ImportError as e: + logger.debug("Image: failed to import %s: %s", plugin, e) + + if OPEN or SAVE: + _initialized = 2 + return 1 + + +# -------------------------------------------------------------------- +# Codec factories (used by tobytes/frombytes and ImageFile.load) + + +def _getdecoder(mode, decoder_name, args, extra=()): + # tweak arguments + if args is None: + args = () + elif not isinstance(args, tuple): + args = (args,) + + try: + decoder = DECODERS[decoder_name] + except KeyError: + pass + else: + return decoder(mode, *args + extra) + + try: + # get decoder + decoder = getattr(core, decoder_name + "_decoder") + except AttributeError as e: + msg = f"decoder {decoder_name} not available" + raise OSError(msg) from e + return decoder(mode, *args + extra) + + +def _getencoder(mode, encoder_name, args, extra=()): + # tweak arguments + if args is None: + args = () + elif not isinstance(args, tuple): + args = (args,) + + try: + encoder = ENCODERS[encoder_name] + except KeyError: + pass + else: + return encoder(mode, *args + extra) + + try: + # get encoder + encoder = getattr(core, encoder_name + "_encoder") + except AttributeError as e: + msg = f"encoder {encoder_name} not available" + raise OSError(msg) from e + return encoder(mode, *args + extra) + + +# -------------------------------------------------------------------- +# Simple expression analyzer + + +class _E: + def __init__(self, scale, offset) -> None: + self.scale = scale + self.offset = offset + + def __neg__(self): + return _E(-self.scale, -self.offset) + + def __add__(self, other): + if isinstance(other, _E): + return _E(self.scale + other.scale, self.offset + other.offset) + return _E(self.scale, self.offset + other) + + __radd__ = __add__ + + def __sub__(self, other): + return self + -other + + def __rsub__(self, other): + return other + -self + + def __mul__(self, other): + if isinstance(other, _E): + return NotImplemented + return _E(self.scale * other, self.offset * other) + + __rmul__ = __mul__ + + def __truediv__(self, other): + if isinstance(other, _E): + return NotImplemented + return _E(self.scale / other, self.offset / other) + + +def _getscaleoffset(expr): + a = expr(_E(1, 0)) + return (a.scale, a.offset) if isinstance(a, _E) else (0, a) + + +# -------------------------------------------------------------------- +# Implementation wrapper + + +class Image: + """ + This class represents an image object. To create + :py:class:`~PIL.Image.Image` objects, use the appropriate factory + functions. There's hardly ever any reason to call the Image constructor + directly. + + * :py:func:`~PIL.Image.open` + * :py:func:`~PIL.Image.new` + * :py:func:`~PIL.Image.frombytes` + """ + + format: str | None = None + format_description: str | None = None + _close_exclusive_fp_after_loading = True + + def __init__(self): + # FIXME: take "new" parameters / other image? + # FIXME: turn mode and size into delegating properties? + self.im = None + self._mode = "" + self._size = (0, 0) + self.palette = None + self.info = {} + self.readonly = 0 + self.pyaccess = None + self._exif = None + + @property + def width(self) -> int: + return self.size[0] + + @property + def height(self) -> int: + return self.size[1] + + @property + def size(self) -> tuple[int, int]: + return self._size + + @property + def mode(self): + return self._mode + + def _new(self, im) -> Image: + new = Image() + new.im = im + new._mode = im.mode + new._size = im.size + if im.mode in ("P", "PA"): + if self.palette: + new.palette = self.palette.copy() + else: + from . import ImagePalette + + new.palette = ImagePalette.ImagePalette() + new.info = self.info.copy() + return new + + # Context manager support + def __enter__(self): + return self + + def _close_fp(self): + if getattr(self, "_fp", False): + if self._fp != self.fp: + self._fp.close() + self._fp = DeferredError(ValueError("Operation on closed image")) + if self.fp: + self.fp.close() + + def __exit__(self, *args): + if hasattr(self, "fp"): + if getattr(self, "_exclusive_fp", False): + self._close_fp() + self.fp = None + + def close(self) -> None: + """ + Closes the file pointer, if possible. + + This operation will destroy the image core and release its memory. + The image data will be unusable afterward. + + This function is required to close images that have multiple frames or + have not had their file read and closed by the + :py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for + more information. + """ + if hasattr(self, "fp"): + try: + self._close_fp() + self.fp = None + except Exception as msg: + logger.debug("Error closing: %s", msg) + + if getattr(self, "map", None): + self.map = None + + # Instead of simply setting to None, we're setting up a + # deferred error that will better explain that the core image + # object is gone. + self.im = DeferredError(ValueError("Operation on closed image")) + + def _copy(self) -> None: + self.load() + self.im = self.im.copy() + self.pyaccess = None + self.readonly = 0 + + def _ensure_mutable(self) -> None: + if self.readonly: + self._copy() + else: + self.load() + + def _dump( + self, file: str | None = None, format: str | None = None, **options + ) -> str: + suffix = "" + if format: + suffix = "." + format + + if not file: + f, filename = tempfile.mkstemp(suffix) + os.close(f) + else: + filename = file + if not filename.endswith(suffix): + filename = filename + suffix + + self.load() + + if not format or format == "PPM": + self.im.save_ppm(filename) + else: + self.save(filename, format, **options) + + return filename + + def __eq__(self, other): + return ( + self.__class__ is other.__class__ + and self.mode == other.mode + and self.size == other.size + and self.info == other.info + and self.getpalette() == other.getpalette() + and self.tobytes() == other.tobytes() + ) + + def __repr__(self) -> str: + return "<%s.%s image mode=%s size=%dx%d at 0x%X>" % ( + self.__class__.__module__, + self.__class__.__name__, + self.mode, + self.size[0], + self.size[1], + id(self), + ) + + def _repr_pretty_(self, p, cycle) -> None: + """IPython plain text display support""" + + # Same as __repr__ but without unpredictable id(self), + # to keep Jupyter notebook `text/plain` output stable. + p.text( + "<%s.%s image mode=%s size=%dx%d>" + % ( + self.__class__.__module__, + self.__class__.__name__, + self.mode, + self.size[0], + self.size[1], + ) + ) + + def _repr_image(self, image_format, **kwargs): + """Helper function for iPython display hook. + + :param image_format: Image format. + :returns: image as bytes, saved into the given format. + """ + b = io.BytesIO() + try: + self.save(b, image_format, **kwargs) + except Exception: + return None + return b.getvalue() + + def _repr_png_(self): + """iPython display hook support for PNG format. + + :returns: PNG version of the image as bytes + """ + return self._repr_image("PNG", compress_level=1) + + def _repr_jpeg_(self): + """iPython display hook support for JPEG format. + + :returns: JPEG version of the image as bytes + """ + return self._repr_image("JPEG") + + @property + def __array_interface__(self): + # numpy array interface support + new = {"version": 3} + try: + if self.mode == "1": + # Binary images need to be extended from bits to bytes + # See: https://github.com/python-pillow/Pillow/issues/350 + new["data"] = self.tobytes("raw", "L") + else: + new["data"] = self.tobytes() + except Exception as e: + if not isinstance(e, (MemoryError, RecursionError)): + try: + import numpy + from packaging.version import parse as parse_version + except ImportError: + pass + else: + if parse_version(numpy.__version__) < parse_version("1.23"): + warnings.warn(str(e)) + raise + new["shape"], new["typestr"] = _conv_type_shape(self) + return new + + def __getstate__(self): + im_data = self.tobytes() # load image first + return [self.info, self.mode, self.size, self.getpalette(), im_data] + + def __setstate__(self, state) -> None: + Image.__init__(self) + info, mode, size, palette, data = state + self.info = info + self._mode = mode + self._size = size + self.im = core.new(mode, size) + if mode in ("L", "LA", "P", "PA") and palette: + self.putpalette(palette) + self.frombytes(data) + + def tobytes(self, encoder_name: str = "raw", *args) -> bytes: + """ + Return image as a bytes object. + + .. warning:: + + This method returns the raw image data from the internal + storage. For compressed image data (e.g. PNG, JPEG) use + :meth:`~.save`, with a BytesIO parameter for in-memory + data. + + :param encoder_name: What encoder to use. The default is to + use the standard "raw" encoder. + + A list of C encoders can be seen under + codecs section of the function array in + :file:`_imaging.c`. Python encoders are + registered within the relevant plugins. + :param args: Extra arguments to the encoder. + :returns: A :py:class:`bytes` object. + """ + + # may pass tuple instead of argument list + if len(args) == 1 and isinstance(args[0], tuple): + args = args[0] + + if encoder_name == "raw" and args == (): + args = self.mode + + self.load() + + if self.width == 0 or self.height == 0: + return b"" + + # unpack data + e = _getencoder(self.mode, encoder_name, args) + e.setimage(self.im) + + bufsize = max(65536, self.size[0] * 4) # see RawEncode.c + + output = [] + while True: + bytes_consumed, errcode, data = e.encode(bufsize) + output.append(data) + if errcode: + break + if errcode < 0: + msg = f"encoder error {errcode} in tobytes" + raise RuntimeError(msg) + + return b"".join(output) + + def tobitmap(self, name: str = "image") -> bytes: + """ + Returns the image converted to an X11 bitmap. + + .. note:: This method only works for mode "1" images. + + :param name: The name prefix to use for the bitmap variables. + :returns: A string containing an X11 bitmap. + :raises ValueError: If the mode is not "1" + """ + + self.load() + if self.mode != "1": + msg = "not a bitmap" + raise ValueError(msg) + data = self.tobytes("xbm") + return b"".join( + [ + f"#define {name}_width {self.size[0]}\n".encode("ascii"), + f"#define {name}_height {self.size[1]}\n".encode("ascii"), + f"static char {name}_bits[] = {{\n".encode("ascii"), + data, + b"};", + ] + ) + + def frombytes(self, data: bytes, decoder_name: str = "raw", *args) -> None: + """ + Loads this image with pixel data from a bytes object. + + This method is similar to the :py:func:`~PIL.Image.frombytes` function, + but loads data into this image instead of creating a new image object. + """ + + if self.width == 0 or self.height == 0: + return + + # may pass tuple instead of argument list + if len(args) == 1 and isinstance(args[0], tuple): + args = args[0] + + # default format + if decoder_name == "raw" and args == (): + args = self.mode + + # unpack data + d = _getdecoder(self.mode, decoder_name, args) + d.setimage(self.im) + s = d.decode(data) + + if s[0] >= 0: + msg = "not enough image data" + raise ValueError(msg) + if s[1] != 0: + msg = "cannot decode image data" + raise ValueError(msg) + + def load(self): + """ + Allocates storage for the image and loads the pixel data. In + normal cases, you don't need to call this method, since the + Image class automatically loads an opened image when it is + accessed for the first time. + + If the file associated with the image was opened by Pillow, then this + method will close it. The exception to this is if the image has + multiple frames, in which case the file will be left open for seek + operations. See :ref:`file-handling` for more information. + + :returns: An image access object. + :rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess` + """ + if self.im is not None and self.palette and self.palette.dirty: + # realize palette + mode, arr = self.palette.getdata() + self.im.putpalette(mode, arr) + self.palette.dirty = 0 + self.palette.rawmode = None + if "transparency" in self.info and mode in ("LA", "PA"): + if isinstance(self.info["transparency"], int): + self.im.putpalettealpha(self.info["transparency"], 0) + else: + self.im.putpalettealphas(self.info["transparency"]) + self.palette.mode = "RGBA" + else: + palette_mode = "RGBA" if mode.startswith("RGBA") else "RGB" + self.palette.mode = palette_mode + self.palette.palette = self.im.getpalette(palette_mode, palette_mode) + + if self.im is not None: + if cffi and USE_CFFI_ACCESS: + if self.pyaccess: + return self.pyaccess + from . import PyAccess + + self.pyaccess = PyAccess.new(self, self.readonly) + if self.pyaccess: + return self.pyaccess + return self.im.pixel_access(self.readonly) + + def verify(self): + """ + Verifies the contents of a file. For data read from a file, this + method attempts to determine if the file is broken, without + actually decoding the image data. If this method finds any + problems, it raises suitable exceptions. If you need to load + the image after using this method, you must reopen the image + file. + """ + pass + + def convert( + self, + mode: str | None = None, + matrix: tuple[float, ...] | None = None, + dither: Dither | None = None, + palette: Palette = Palette.WEB, + colors: int = 256, + ) -> Image: + """ + Returns a converted copy of this image. For the "P" mode, this + method translates pixels through the palette. If mode is + omitted, a mode is chosen so that all information in the image + and the palette can be represented without a palette. + + This supports all possible conversions between "L", "RGB" and "CMYK". The + ``matrix`` argument only supports "L" and "RGB". + + When translating a color image to grayscale (mode "L"), + the library uses the ITU-R 601-2 luma transform:: + + L = R * 299/1000 + G * 587/1000 + B * 114/1000 + + The default method of converting a grayscale ("L") or "RGB" + image into a bilevel (mode "1") image uses Floyd-Steinberg + dither to approximate the original image luminosity levels. If + dither is ``None``, all values larger than 127 are set to 255 (white), + all other values to 0 (black). To use other thresholds, use the + :py:meth:`~PIL.Image.Image.point` method. + + When converting from "RGBA" to "P" without a ``matrix`` argument, + this passes the operation to :py:meth:`~PIL.Image.Image.quantize`, + and ``dither`` and ``palette`` are ignored. + + When converting from "PA", if an "RGBA" palette is present, the alpha + channel from the image will be used instead of the values from the palette. + + :param mode: The requested mode. See: :ref:`concept-modes`. + :param matrix: An optional conversion matrix. If given, this + should be 4- or 12-tuple containing floating point values. + :param dither: Dithering method, used when converting from + mode "RGB" to "P" or from "RGB" or "L" to "1". + Available methods are :data:`Dither.NONE` or :data:`Dither.FLOYDSTEINBERG` + (default). Note that this is not used when ``matrix`` is supplied. + :param palette: Palette to use when converting from mode "RGB" + to "P". Available palettes are :data:`Palette.WEB` or + :data:`Palette.ADAPTIVE`. + :param colors: Number of colors to use for the :data:`Palette.ADAPTIVE` + palette. Defaults to 256. + :rtype: :py:class:`~PIL.Image.Image` + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + self.load() + + has_transparency = "transparency" in self.info + if not mode and self.mode == "P": + # determine default mode + if self.palette: + mode = self.palette.mode + else: + mode = "RGB" + if mode == "RGB" and has_transparency: + mode = "RGBA" + if not mode or (mode == self.mode and not matrix): + return self.copy() + + if matrix: + # matrix conversion + if mode not in ("L", "RGB"): + msg = "illegal conversion" + raise ValueError(msg) + im = self.im.convert_matrix(mode, matrix) + new_im = self._new(im) + if has_transparency and self.im.bands == 3: + transparency = new_im.info["transparency"] + + def convert_transparency(m, v): + v = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * 0.5 + return max(0, min(255, int(v))) + + if mode == "L": + transparency = convert_transparency(matrix, transparency) + elif len(mode) == 3: + transparency = tuple( + convert_transparency(matrix[i * 4 : i * 4 + 4], transparency) + for i in range(0, len(transparency)) + ) + new_im.info["transparency"] = transparency + return new_im + + if mode == "P" and self.mode == "RGBA": + return self.quantize(colors) + + trns = None + delete_trns = False + # transparency handling + if has_transparency: + if (self.mode in ("1", "L", "I", "I;16") and mode in ("LA", "RGBA")) or ( + self.mode == "RGB" and mode in ("La", "LA", "RGBa", "RGBA") + ): + # Use transparent conversion to promote from transparent + # color to an alpha channel. + new_im = self._new( + self.im.convert_transparent(mode, self.info["transparency"]) + ) + del new_im.info["transparency"] + return new_im + elif self.mode in ("L", "RGB", "P") and mode in ("L", "RGB", "P"): + t = self.info["transparency"] + if isinstance(t, bytes): + # Dragons. This can't be represented by a single color + warnings.warn( + "Palette images with Transparency expressed in bytes should be " + "converted to RGBA images" + ) + delete_trns = True + else: + # get the new transparency color. + # use existing conversions + trns_im = new(self.mode, (1, 1)) + if self.mode == "P": + trns_im.putpalette(self.palette) + if isinstance(t, tuple): + err = "Couldn't allocate a palette color for transparency" + try: + t = trns_im.palette.getcolor(t, self) + except ValueError as e: + if str(e) == "cannot allocate more than 256 colors": + # If all 256 colors are in use, + # then there is no need for transparency + t = None + else: + raise ValueError(err) from e + if t is None: + trns = None + else: + trns_im.putpixel((0, 0), t) + + if mode in ("L", "RGB"): + trns_im = trns_im.convert(mode) + else: + # can't just retrieve the palette number, got to do it + # after quantization. + trns_im = trns_im.convert("RGB") + trns = trns_im.getpixel((0, 0)) + + elif self.mode == "P" and mode in ("LA", "PA", "RGBA"): + t = self.info["transparency"] + delete_trns = True + + if isinstance(t, bytes): + self.im.putpalettealphas(t) + elif isinstance(t, int): + self.im.putpalettealpha(t, 0) + else: + msg = "Transparency for P mode should be bytes or int" + raise ValueError(msg) + + if mode == "P" and palette == Palette.ADAPTIVE: + im = self.im.quantize(colors) + new_im = self._new(im) + from . import ImagePalette + + new_im.palette = ImagePalette.ImagePalette( + "RGB", new_im.im.getpalette("RGB") + ) + if delete_trns: + # This could possibly happen if we requantize to fewer colors. + # The transparency would be totally off in that case. + del new_im.info["transparency"] + if trns is not None: + try: + new_im.info["transparency"] = new_im.palette.getcolor(trns, new_im) + except Exception: + # if we can't make a transparent color, don't leave the old + # transparency hanging around to mess us up. + del new_im.info["transparency"] + warnings.warn("Couldn't allocate palette entry for transparency") + return new_im + + if "LAB" in (self.mode, mode): + other_mode = mode if self.mode == "LAB" else self.mode + if other_mode in ("RGB", "RGBA", "RGBX"): + from . import ImageCms + + srgb = ImageCms.createProfile("sRGB") + lab = ImageCms.createProfile("LAB") + profiles = [lab, srgb] if self.mode == "LAB" else [srgb, lab] + transform = ImageCms.buildTransform( + profiles[0], profiles[1], self.mode, mode + ) + return transform.apply(self) + + # colorspace conversion + if dither is None: + dither = Dither.FLOYDSTEINBERG + + try: + im = self.im.convert(mode, dither) + except ValueError: + try: + # normalize source image and try again + modebase = getmodebase(self.mode) + if modebase == self.mode: + raise + im = self.im.convert(modebase) + im = im.convert(mode, dither) + except KeyError as e: + msg = "illegal conversion" + raise ValueError(msg) from e + + new_im = self._new(im) + if mode == "P" and palette != Palette.ADAPTIVE: + from . import ImagePalette + + new_im.palette = ImagePalette.ImagePalette("RGB", im.getpalette("RGB")) + if delete_trns: + # crash fail if we leave a bytes transparency in an rgb/l mode. + del new_im.info["transparency"] + if trns is not None: + if new_im.mode == "P": + try: + new_im.info["transparency"] = new_im.palette.getcolor(trns, new_im) + except ValueError as e: + del new_im.info["transparency"] + if str(e) != "cannot allocate more than 256 colors": + # If all 256 colors are in use, + # then there is no need for transparency + warnings.warn( + "Couldn't allocate palette entry for transparency" + ) + else: + new_im.info["transparency"] = trns + return new_im + + def quantize( + self, + colors: int = 256, + method: Quantize | None = None, + kmeans: int = 0, + palette=None, + dither: Dither = Dither.FLOYDSTEINBERG, + ) -> Image: + """ + Convert the image to 'P' mode with the specified number + of colors. + + :param colors: The desired number of colors, <= 256 + :param method: :data:`Quantize.MEDIANCUT` (median cut), + :data:`Quantize.MAXCOVERAGE` (maximum coverage), + :data:`Quantize.FASTOCTREE` (fast octree), + :data:`Quantize.LIBIMAGEQUANT` (libimagequant; check support + using :py:func:`PIL.features.check_feature` with + ``feature="libimagequant"``). + + By default, :data:`Quantize.MEDIANCUT` will be used. + + The exception to this is RGBA images. :data:`Quantize.MEDIANCUT` + and :data:`Quantize.MAXCOVERAGE` do not support RGBA images, so + :data:`Quantize.FASTOCTREE` is used by default instead. + :param kmeans: Integer greater than or equal to zero. + :param palette: Quantize to the palette of given + :py:class:`PIL.Image.Image`. + :param dither: Dithering method, used when converting from + mode "RGB" to "P" or from "RGB" or "L" to "1". + Available methods are :data:`Dither.NONE` or :data:`Dither.FLOYDSTEINBERG` + (default). + :returns: A new image + """ + + self.load() + + if method is None: + # defaults: + method = Quantize.MEDIANCUT + if self.mode == "RGBA": + method = Quantize.FASTOCTREE + + if self.mode == "RGBA" and method not in ( + Quantize.FASTOCTREE, + Quantize.LIBIMAGEQUANT, + ): + # Caller specified an invalid mode. + msg = ( + "Fast Octree (method == 2) and libimagequant (method == 3) " + "are the only valid methods for quantizing RGBA images" + ) + raise ValueError(msg) + + if palette: + # use palette from reference image + palette.load() + if palette.mode != "P": + msg = "bad mode for palette image" + raise ValueError(msg) + if self.mode not in {"RGB", "L"}: + msg = "only RGB or L mode images can be quantized to a palette" + raise ValueError(msg) + im = self.im.convert("P", dither, palette.im) + new_im = self._new(im) + new_im.palette = palette.palette.copy() + return new_im + + if kmeans < 0: + msg = "kmeans must not be negative" + raise ValueError(msg) + + im = self._new(self.im.quantize(colors, method, kmeans)) + + from . import ImagePalette + + mode = im.im.getpalettemode() + palette = im.im.getpalette(mode, mode)[: colors * len(mode)] + im.palette = ImagePalette.ImagePalette(mode, palette) + + return im + + def copy(self) -> Image: + """ + Copies this image. Use this method if you wish to paste things + into an image, but still retain the original. + + :rtype: :py:class:`~PIL.Image.Image` + :returns: An :py:class:`~PIL.Image.Image` object. + """ + self.load() + return self._new(self.im.copy()) + + __copy__ = copy + + def crop(self, box: tuple[int, int, int, int] | None = None) -> Image: + """ + Returns a rectangular region from this image. The box is a + 4-tuple defining the left, upper, right, and lower pixel + coordinate. See :ref:`coordinate-system`. + + Note: Prior to Pillow 3.4.0, this was a lazy operation. + + :param box: The crop rectangle, as a (left, upper, right, lower)-tuple. + :rtype: :py:class:`~PIL.Image.Image` + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + if box is None: + return self.copy() + + if box[2] < box[0]: + msg = "Coordinate 'right' is less than 'left'" + raise ValueError(msg) + elif box[3] < box[1]: + msg = "Coordinate 'lower' is less than 'upper'" + raise ValueError(msg) + + self.load() + return self._new(self._crop(self.im, box)) + + def _crop(self, im, box): + """ + Returns a rectangular region from the core image object im. + + This is equivalent to calling im.crop((x0, y0, x1, y1)), but + includes additional sanity checks. + + :param im: a core image object + :param box: The crop rectangle, as a (left, upper, right, lower)-tuple. + :returns: A core image object. + """ + + x0, y0, x1, y1 = map(int, map(round, box)) + + absolute_values = (abs(x1 - x0), abs(y1 - y0)) + + _decompression_bomb_check(absolute_values) + + return im.crop((x0, y0, x1, y1)) + + def draft(self, mode, size): + """ + Configures the image file loader so it returns a version of the + image that as closely as possible matches the given mode and + size. For example, you can use this method to convert a color + JPEG to grayscale while loading it. + + If any changes are made, returns a tuple with the chosen ``mode`` and + ``box`` with coordinates of the original image within the altered one. + + Note that this method modifies the :py:class:`~PIL.Image.Image` object + in place. If the image has already been loaded, this method has no + effect. + + Note: This method is not implemented for most images. It is + currently implemented only for JPEG and MPO images. + + :param mode: The requested mode. + :param size: The requested size in pixels, as a 2-tuple: + (width, height). + """ + pass + + def _expand(self, xmargin, ymargin=None): + if ymargin is None: + ymargin = xmargin + self.load() + return self._new(self.im.expand(xmargin, ymargin)) + + def filter(self, filter): + """ + Filters this image using the given filter. For a list of + available filters, see the :py:mod:`~PIL.ImageFilter` module. + + :param filter: Filter kernel. + :returns: An :py:class:`~PIL.Image.Image` object.""" + + from . import ImageFilter + + self.load() + + if isinstance(filter, Callable): + filter = filter() + if not hasattr(filter, "filter"): + msg = "filter argument should be ImageFilter.Filter instance or class" + raise TypeError(msg) + + multiband = isinstance(filter, ImageFilter.MultibandFilter) + if self.im.bands == 1 or multiband: + return self._new(filter.filter(self.im)) + + ims = [ + self._new(filter.filter(self.im.getband(c))) for c in range(self.im.bands) + ] + return merge(self.mode, ims) + + def getbands(self) -> tuple[str, ...]: + """ + Returns a tuple containing the name of each band in this image. + For example, ``getbands`` on an RGB image returns ("R", "G", "B"). + + :returns: A tuple containing band names. + :rtype: tuple + """ + return ImageMode.getmode(self.mode).bands + + def getbbox(self, *, alpha_only: bool = True) -> tuple[int, int, int, int]: + """ + Calculates the bounding box of the non-zero regions in the + image. + + :param alpha_only: Optional flag, defaulting to ``True``. + If ``True`` and the image has an alpha channel, trim transparent pixels. + Otherwise, trim pixels when all channels are zero. + Keyword-only argument. + :returns: The bounding box is returned as a 4-tuple defining the + left, upper, right, and lower pixel coordinate. See + :ref:`coordinate-system`. If the image is completely empty, this + method returns None. + + """ + + self.load() + return self.im.getbbox(alpha_only) + + def getcolors(self, maxcolors: int = 256): + """ + Returns a list of colors used in this image. + + The colors will be in the image's mode. For example, an RGB image will + return a tuple of (red, green, blue) color values, and a P image will + return the index of the color in the palette. + + :param maxcolors: Maximum number of colors. If this number is + exceeded, this method returns None. The default limit is + 256 colors. + :returns: An unsorted list of (count, pixel) values. + """ + + self.load() + if self.mode in ("1", "L", "P"): + h = self.im.histogram() + out = [(h[i], i) for i in range(256) if h[i]] + if len(out) > maxcolors: + return None + return out + return self.im.getcolors(maxcolors) + + def getdata(self, band: int | None = None): + """ + Returns the contents of this image as a sequence object + containing pixel values. The sequence object is flattened, so + that values for line one follow directly after the values of + line zero, and so on. + + Note that the sequence object returned by this method is an + internal PIL data type, which only supports certain sequence + operations. To convert it to an ordinary sequence (e.g. for + printing), use ``list(im.getdata())``. + + :param band: What band to return. The default is to return + all bands. To return a single band, pass in the index + value (e.g. 0 to get the "R" band from an "RGB" image). + :returns: A sequence-like object. + """ + + self.load() + if band is not None: + return self.im.getband(band) + return self.im # could be abused + + def getextrema(self) -> tuple[float, float] | tuple[tuple[int, int], ...]: + """ + Gets the minimum and maximum pixel values for each band in + the image. + + :returns: For a single-band image, a 2-tuple containing the + minimum and maximum pixel value. For a multi-band image, + a tuple containing one 2-tuple for each band. + """ + + self.load() + if self.im.bands > 1: + return tuple(self.im.getband(i).getextrema() for i in range(self.im.bands)) + return self.im.getextrema() + + def _getxmp(self, xmp_tags): + def get_name(tag): + return re.sub("^{[^}]+}", "", tag) + + def get_value(element): + value = {get_name(k): v for k, v in element.attrib.items()} + children = list(element) + if children: + for child in children: + name = get_name(child.tag) + child_value = get_value(child) + if name in value: + if not isinstance(value[name], list): + value[name] = [value[name]] + value[name].append(child_value) + else: + value[name] = child_value + elif value: + if element.text: + value["text"] = element.text + else: + return element.text + return value + + if ElementTree is None: + warnings.warn("XMP data cannot be read without defusedxml dependency") + return {} + else: + root = ElementTree.fromstring(xmp_tags) + return {get_name(root.tag): get_value(root)} + + def getexif(self) -> Exif: + """ + Gets EXIF data from the image. + + :returns: an :py:class:`~PIL.Image.Exif` object. + """ + if self._exif is None: + self._exif = Exif() + elif self._exif._loaded: + return self._exif + self._exif._loaded = True + + exif_info = self.info.get("exif") + if exif_info is None: + if "Raw profile type exif" in self.info: + exif_info = bytes.fromhex( + "".join(self.info["Raw profile type exif"].split("\n")[3:]) + ) + elif hasattr(self, "tag_v2"): + self._exif.bigtiff = self.tag_v2._bigtiff + self._exif.endian = self.tag_v2._endian + self._exif.load_from_fp(self.fp, self.tag_v2._offset) + if exif_info is not None: + self._exif.load(exif_info) + + # XMP tags + if ExifTags.Base.Orientation not in self._exif: + xmp_tags = self.info.get("XML:com.adobe.xmp") + if xmp_tags: + match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags) + if match: + self._exif[ExifTags.Base.Orientation] = int(match[2]) + + return self._exif + + def _reload_exif(self) -> None: + if self._exif is None or not self._exif._loaded: + return + self._exif._loaded = False + self.getexif() + + def get_child_images(self): + child_images = [] + exif = self.getexif() + ifds = [] + if ExifTags.Base.SubIFDs in exif: + subifd_offsets = exif[ExifTags.Base.SubIFDs] + if subifd_offsets: + if not isinstance(subifd_offsets, tuple): + subifd_offsets = (subifd_offsets,) + for subifd_offset in subifd_offsets: + ifds.append((exif._get_ifd_dict(subifd_offset), subifd_offset)) + ifd1 = exif.get_ifd(ExifTags.IFD.IFD1) + if ifd1 and ifd1.get(513): + ifds.append((ifd1, exif._info.next)) + + offset = None + for ifd, ifd_offset in ifds: + current_offset = self.fp.tell() + if offset is None: + offset = current_offset + + fp = self.fp + thumbnail_offset = ifd.get(513) + if thumbnail_offset is not None: + try: + thumbnail_offset += self._exif_offset + except AttributeError: + pass + self.fp.seek(thumbnail_offset) + data = self.fp.read(ifd.get(514)) + fp = io.BytesIO(data) + + with open(fp) as im: + if thumbnail_offset is None: + im._frame_pos = [ifd_offset] + im._seek(0) + im.load() + child_images.append(im) + + if offset is not None: + self.fp.seek(offset) + return child_images + + def getim(self): + """ + Returns a capsule that points to the internal image memory. + + :returns: A capsule object. + """ + + self.load() + return self.im.ptr + + def getpalette(self, rawmode: str | None = "RGB") -> list[int] | None: + """ + Returns the image palette as a list. + + :param rawmode: The mode in which to return the palette. ``None`` will + return the palette in its current mode. + + .. versionadded:: 9.1.0 + + :returns: A list of color values [r, g, b, ...], or None if the + image has no palette. + """ + + self.load() + try: + mode = self.im.getpalettemode() + except ValueError: + return None # no palette + if rawmode is None: + rawmode = mode + return list(self.im.getpalette(mode, rawmode)) + + @property + def has_transparency_data(self) -> bool: + """ + Determine if an image has transparency data, whether in the form of an + alpha channel, a palette with an alpha channel, or a "transparency" key + in the info dictionary. + + Note the image might still appear solid, if all of the values shown + within are opaque. + + :returns: A boolean. + """ + return ( + self.mode in ("LA", "La", "PA", "RGBA", "RGBa") + or (self.mode == "P" and self.palette.mode.endswith("A")) + or "transparency" in self.info + ) + + def apply_transparency(self): + """ + If a P mode image has a "transparency" key in the info dictionary, + remove the key and instead apply the transparency to the palette. + Otherwise, the image is unchanged. + """ + if self.mode != "P" or "transparency" not in self.info: + return + + from . import ImagePalette + + palette = self.getpalette("RGBA") + transparency = self.info["transparency"] + if isinstance(transparency, bytes): + for i, alpha in enumerate(transparency): + palette[i * 4 + 3] = alpha + else: + palette[transparency * 4 + 3] = 0 + self.palette = ImagePalette.ImagePalette("RGBA", bytes(palette)) + self.palette.dirty = 1 + + del self.info["transparency"] + + def getpixel(self, xy): + """ + Returns the pixel value at a given position. + + :param xy: The coordinate, given as (x, y). See + :ref:`coordinate-system`. + :returns: The pixel value. If the image is a multi-layer image, + this method returns a tuple. + """ + + self.load() + if self.pyaccess: + return self.pyaccess.getpixel(xy) + return self.im.getpixel(tuple(xy)) + + def getprojection(self) -> tuple[list[int], list[int]]: + """ + Get projection to x and y axes + + :returns: Two sequences, indicating where there are non-zero + pixels along the X-axis and the Y-axis, respectively. + """ + + self.load() + x, y = self.im.getprojection() + return list(x), list(y) + + def histogram(self, mask: Image | None = None, extrema=None) -> list[int]: + """ + Returns a histogram for the image. The histogram is returned as a + list of pixel counts, one for each pixel value in the source + image. Counts are grouped into 256 bins for each band, even if + the image has more than 8 bits per band. If the image has more + than one band, the histograms for all bands are concatenated (for + example, the histogram for an "RGB" image contains 768 values). + + A bilevel image (mode "1") is treated as a grayscale ("L") image + by this method. + + If a mask is provided, the method returns a histogram for those + parts of the image where the mask image is non-zero. The mask + image must have the same size as the image, and be either a + bi-level image (mode "1") or a grayscale image ("L"). + + :param mask: An optional mask. + :param extrema: An optional tuple of manually-specified extrema. + :returns: A list containing pixel counts. + """ + self.load() + if mask: + mask.load() + return self.im.histogram((0, 0), mask.im) + if self.mode in ("I", "F"): + if extrema is None: + extrema = self.getextrema() + return self.im.histogram(extrema) + return self.im.histogram() + + def entropy(self, mask=None, extrema=None): + """ + Calculates and returns the entropy for the image. + + A bilevel image (mode "1") is treated as a grayscale ("L") + image by this method. + + If a mask is provided, the method employs the histogram for + those parts of the image where the mask image is non-zero. + The mask image must have the same size as the image, and be + either a bi-level image (mode "1") or a grayscale image ("L"). + + :param mask: An optional mask. + :param extrema: An optional tuple of manually-specified extrema. + :returns: A float value representing the image entropy + """ + self.load() + if mask: + mask.load() + return self.im.entropy((0, 0), mask.im) + if self.mode in ("I", "F"): + if extrema is None: + extrema = self.getextrema() + return self.im.entropy(extrema) + return self.im.entropy() + + def paste(self, im, box=None, mask=None) -> None: + """ + Pastes another image into this image. The box argument is either + a 2-tuple giving the upper left corner, a 4-tuple defining the + left, upper, right, and lower pixel coordinate, or None (same as + (0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size + of the pasted image must match the size of the region. + + If the modes don't match, the pasted image is converted to the mode of + this image (see the :py:meth:`~PIL.Image.Image.convert` method for + details). + + Instead of an image, the source can be a integer or tuple + containing pixel values. The method then fills the region + with the given color. When creating RGB images, you can + also use color strings as supported by the ImageColor module. + + If a mask is given, this method updates only the regions + indicated by the mask. You can use either "1", "L", "LA", "RGBA" + or "RGBa" images (if present, the alpha band is used as mask). + Where the mask is 255, the given image is copied as is. Where + the mask is 0, the current value is preserved. Intermediate + values will mix the two images together, including their alpha + channels if they have them. + + See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to + combine images with respect to their alpha channels. + + :param im: Source image or pixel value (integer or tuple). + :param box: An optional 4-tuple giving the region to paste into. + If a 2-tuple is used instead, it's treated as the upper left + corner. If omitted or None, the source is pasted into the + upper left corner. + + If an image is given as the second argument and there is no + third, the box defaults to (0, 0), and the second argument + is interpreted as a mask image. + :param mask: An optional mask image. + """ + + if isImageType(box) and mask is None: + # abbreviated paste(im, mask) syntax + mask = box + box = None + + if box is None: + box = (0, 0) + + if len(box) == 2: + # upper left corner given; get size from image or mask + if isImageType(im): + size = im.size + elif isImageType(mask): + size = mask.size + else: + # FIXME: use self.size here? + msg = "cannot determine region size; use 4-item box" + raise ValueError(msg) + box += (box[0] + size[0], box[1] + size[1]) + + if isinstance(im, str): + from . import ImageColor + + im = ImageColor.getcolor(im, self.mode) + + elif isImageType(im): + im.load() + if self.mode != im.mode: + if self.mode != "RGB" or im.mode not in ("LA", "RGBA", "RGBa"): + # should use an adapter for this! + im = im.convert(self.mode) + im = im.im + + self._ensure_mutable() + + if mask: + mask.load() + self.im.paste(im, box, mask.im) + else: + self.im.paste(im, box) + + def alpha_composite(self, im, dest=(0, 0), source=(0, 0)): + """'In-place' analog of Image.alpha_composite. Composites an image + onto this image. + + :param im: image to composite over this one + :param dest: Optional 2 tuple (left, top) specifying the upper + left corner in this (destination) image. + :param source: Optional 2 (left, top) tuple for the upper left + corner in the overlay source image, or 4 tuple (left, top, right, + bottom) for the bounds of the source rectangle + + Performance Note: Not currently implemented in-place in the core layer. + """ + + if not isinstance(source, (list, tuple)): + msg = "Source must be a tuple" + raise ValueError(msg) + if not isinstance(dest, (list, tuple)): + msg = "Destination must be a tuple" + raise ValueError(msg) + if len(source) not in (2, 4): + msg = "Source must be a 2 or 4-tuple" + raise ValueError(msg) + if not len(dest) == 2: + msg = "Destination must be a 2-tuple" + raise ValueError(msg) + if min(source) < 0: + msg = "Source must be non-negative" + raise ValueError(msg) + + if len(source) == 2: + source = source + im.size + + # over image, crop if it's not the whole thing. + if source == (0, 0) + im.size: + overlay = im + else: + overlay = im.crop(source) + + # target for the paste + box = dest + (dest[0] + overlay.width, dest[1] + overlay.height) + + # destination image. don't copy if we're using the whole image. + if box == (0, 0) + self.size: + background = self + else: + background = self.crop(box) + + result = alpha_composite(background, overlay) + self.paste(result, box) + + def point(self, lut, mode: str | None = None) -> Image: + """ + Maps this image through a lookup table or function. + + :param lut: A lookup table, containing 256 (or 65536 if + self.mode=="I" and mode == "L") values per band in the + image. A function can be used instead, it should take a + single argument. The function is called once for each + possible pixel value, and the resulting table is applied to + all bands of the image. + + It may also be an :py:class:`~PIL.Image.ImagePointHandler` + object:: + + class Example(Image.ImagePointHandler): + def point(self, data): + # Return result + :param mode: Output mode (default is same as input). This can only be used if + the source image has mode "L" or "P", and the output has mode "1" or the + source image mode is "I" and the output mode is "L". + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + self.load() + + if isinstance(lut, ImagePointHandler): + return lut.point(self) + + if callable(lut): + # if it isn't a list, it should be a function + if self.mode in ("I", "I;16", "F"): + # check if the function can be used with point_transform + # UNDONE wiredfool -- I think this prevents us from ever doing + # a gamma function point transform on > 8bit images. + scale, offset = _getscaleoffset(lut) + return self._new(self.im.point_transform(scale, offset)) + # for other modes, convert the function to a table + lut = [lut(i) for i in range(256)] * self.im.bands + + if self.mode == "F": + # FIXME: _imaging returns a confusing error message for this case + msg = "point operation not supported for this mode" + raise ValueError(msg) + + if mode != "F": + lut = [round(i) for i in lut] + return self._new(self.im.point(lut, mode)) + + def putalpha(self, alpha): + """ + Adds or replaces the alpha layer in this image. If the image + does not have an alpha layer, it's converted to "LA" or "RGBA". + The new layer must be either "L" or "1". + + :param alpha: The new alpha layer. This can either be an "L" or "1" + image having the same size as this image, or an integer or + other color value. + """ + + self._ensure_mutable() + + if self.mode not in ("LA", "PA", "RGBA"): + # attempt to promote self to a matching alpha mode + try: + mode = getmodebase(self.mode) + "A" + try: + self.im.setmode(mode) + except (AttributeError, ValueError) as e: + # do things the hard way + im = self.im.convert(mode) + if im.mode not in ("LA", "PA", "RGBA"): + msg = "alpha channel could not be added" + raise ValueError(msg) from e # sanity check + self.im = im + self.pyaccess = None + self._mode = self.im.mode + except KeyError as e: + msg = "illegal image mode" + raise ValueError(msg) from e + + if self.mode in ("LA", "PA"): + band = 1 + else: + band = 3 + + if isImageType(alpha): + # alpha layer + if alpha.mode not in ("1", "L"): + msg = "illegal image mode" + raise ValueError(msg) + alpha.load() + if alpha.mode == "1": + alpha = alpha.convert("L") + else: + # constant alpha + try: + self.im.fillband(band, alpha) + except (AttributeError, ValueError): + # do things the hard way + alpha = new("L", self.size, alpha) + else: + return + + self.im.putband(alpha.im, band) + + def putdata(self, data, scale=1.0, offset=0.0): + """ + Copies pixel data from a flattened sequence object into the image. The + values should start at the upper left corner (0, 0), continue to the + end of the line, followed directly by the first value of the second + line, and so on. Data will be read until either the image or the + sequence ends. The scale and offset values are used to adjust the + sequence values: **pixel = value*scale + offset**. + + :param data: A flattened sequence object. + :param scale: An optional scale value. The default is 1.0. + :param offset: An optional offset value. The default is 0.0. + """ + + self._ensure_mutable() + + self.im.putdata(data, scale, offset) + + def putpalette(self, data, rawmode="RGB") -> None: + """ + Attaches a palette to this image. The image must be a "P", "PA", "L" + or "LA" image. + + The palette sequence must contain at most 256 colors, made up of one + integer value for each channel in the raw mode. + For example, if the raw mode is "RGB", then it can contain at most 768 + values, made up of red, green and blue values for the corresponding pixel + index in the 256 colors. + If the raw mode is "RGBA", then it can contain at most 1024 values, + containing red, green, blue and alpha values. + + Alternatively, an 8-bit string may be used instead of an integer sequence. + + :param data: A palette sequence (either a list or a string). + :param rawmode: The raw mode of the palette. Either "RGB", "RGBA", or a mode + that can be transformed to "RGB" or "RGBA" (e.g. "R", "BGR;15", "RGBA;L"). + """ + from . import ImagePalette + + if self.mode not in ("L", "LA", "P", "PA"): + msg = "illegal image mode" + raise ValueError(msg) + if isinstance(data, ImagePalette.ImagePalette): + palette = ImagePalette.raw(data.rawmode, data.palette) + else: + if not isinstance(data, bytes): + data = bytes(data) + palette = ImagePalette.raw(rawmode, data) + self._mode = "PA" if "A" in self.mode else "P" + self.palette = palette + self.palette.mode = "RGB" + self.load() # install new palette + + def putpixel(self, xy, value): + """ + Modifies the pixel at the given position. The color is given as + a single numerical value for single-band images, and a tuple for + multi-band images. In addition to this, RGB and RGBA tuples are + accepted for P and PA images. + + Note that this method is relatively slow. For more extensive changes, + use :py:meth:`~PIL.Image.Image.paste` or the :py:mod:`~PIL.ImageDraw` + module instead. + + See: + + * :py:meth:`~PIL.Image.Image.paste` + * :py:meth:`~PIL.Image.Image.putdata` + * :py:mod:`~PIL.ImageDraw` + + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. + :param value: The pixel value. + """ + + if self.readonly: + self._copy() + self.load() + + if self.pyaccess: + return self.pyaccess.putpixel(xy, value) + + if ( + self.mode in ("P", "PA") + and isinstance(value, (list, tuple)) + and len(value) in [3, 4] + ): + # RGB or RGBA value for a P or PA image + if self.mode == "PA": + alpha = value[3] if len(value) == 4 else 255 + value = value[:3] + value = self.palette.getcolor(value, self) + if self.mode == "PA": + value = (value, alpha) + return self.im.putpixel(xy, value) + + def remap_palette(self, dest_map, source_palette=None): + """ + Rewrites the image to reorder the palette. + + :param dest_map: A list of indexes into the original palette. + e.g. ``[1,0]`` would swap a two item palette, and ``list(range(256))`` + is the identity transform. + :param source_palette: Bytes or None. + :returns: An :py:class:`~PIL.Image.Image` object. + + """ + from . import ImagePalette + + if self.mode not in ("L", "P"): + msg = "illegal image mode" + raise ValueError(msg) + + bands = 3 + palette_mode = "RGB" + if source_palette is None: + if self.mode == "P": + self.load() + palette_mode = self.im.getpalettemode() + if palette_mode == "RGBA": + bands = 4 + source_palette = self.im.getpalette(palette_mode, palette_mode) + else: # L-mode + source_palette = bytearray(i // 3 for i in range(768)) + + palette_bytes = b"" + new_positions = [0] * 256 + + # pick only the used colors from the palette + for i, oldPosition in enumerate(dest_map): + palette_bytes += source_palette[ + oldPosition * bands : oldPosition * bands + bands + ] + new_positions[oldPosition] = i + + # replace the palette color id of all pixel with the new id + + # Palette images are [0..255], mapped through a 1 or 3 + # byte/color map. We need to remap the whole image + # from palette 1 to palette 2. New_positions is + # an array of indexes into palette 1. Palette 2 is + # palette 1 with any holes removed. + + # We're going to leverage the convert mechanism to use the + # C code to remap the image from palette 1 to palette 2, + # by forcing the source image into 'L' mode and adding a + # mapping 'L' mode palette, then converting back to 'L' + # sans palette thus converting the image bytes, then + # assigning the optimized RGB palette. + + # perf reference, 9500x4000 gif, w/~135 colors + # 14 sec prepatch, 1 sec postpatch with optimization forced. + + mapping_palette = bytearray(new_positions) + + m_im = self.copy() + m_im._mode = "P" + + m_im.palette = ImagePalette.ImagePalette( + palette_mode, palette=mapping_palette * bands + ) + # possibly set palette dirty, then + # m_im.putpalette(mapping_palette, 'L') # converts to 'P' + # or just force it. + # UNDONE -- this is part of the general issue with palettes + m_im.im.putpalette(palette_mode + ";L", m_im.palette.tobytes()) + + m_im = m_im.convert("L") + + m_im.putpalette(palette_bytes, palette_mode) + m_im.palette = ImagePalette.ImagePalette(palette_mode, palette=palette_bytes) + + if "transparency" in self.info: + try: + m_im.info["transparency"] = dest_map.index(self.info["transparency"]) + except ValueError: + if "transparency" in m_im.info: + del m_im.info["transparency"] + + return m_im + + def _get_safe_box(self, size, resample, box): + """Expands the box so it includes adjacent pixels + that may be used by resampling with the given resampling filter. + """ + filter_support = _filters_support[resample] - 0.5 + scale_x = (box[2] - box[0]) / size[0] + scale_y = (box[3] - box[1]) / size[1] + support_x = filter_support * scale_x + support_y = filter_support * scale_y + + return ( + max(0, int(box[0] - support_x)), + max(0, int(box[1] - support_y)), + min(self.size[0], math.ceil(box[2] + support_x)), + min(self.size[1], math.ceil(box[3] + support_y)), + ) + + def resize(self, size, resample=None, box=None, reducing_gap=None) -> Image: + """ + Returns a resized copy of this image. + + :param size: The requested size in pixels, as a 2-tuple: + (width, height). + :param resample: An optional resampling filter. This can be + one of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`, + :py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`, + :py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`. + If the image has mode "1" or "P", it is always set to + :py:data:`Resampling.NEAREST`. If the image mode specifies a number + of bits, such as "I;16", then the default filter is + :py:data:`Resampling.NEAREST`. Otherwise, the default filter is + :py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`. + :param box: An optional 4-tuple of floats providing + the source image region to be scaled. + The values must be within (0, 0, width, height) rectangle. + If omitted or None, the entire source is used. + :param reducing_gap: Apply optimization by resizing the image + in two steps. First, reducing the image by integer times + using :py:meth:`~PIL.Image.Image.reduce`. + Second, resizing using regular resampling. The last step + changes size no less than by ``reducing_gap`` times. + ``reducing_gap`` may be None (no first step is performed) + or should be greater than 1.0. The bigger ``reducing_gap``, + the closer the result to the fair resampling. + The smaller ``reducing_gap``, the faster resizing. + With ``reducing_gap`` greater or equal to 3.0, the result is + indistinguishable from fair resampling in most cases. + The default value is None (no optimization). + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + if resample is None: + type_special = ";" in self.mode + resample = Resampling.NEAREST if type_special else Resampling.BICUBIC + elif resample not in ( + Resampling.NEAREST, + Resampling.BILINEAR, + Resampling.BICUBIC, + Resampling.LANCZOS, + Resampling.BOX, + Resampling.HAMMING, + ): + msg = f"Unknown resampling filter ({resample})." + + filters = [ + f"{filter[1]} ({filter[0]})" + for filter in ( + (Resampling.NEAREST, "Image.Resampling.NEAREST"), + (Resampling.LANCZOS, "Image.Resampling.LANCZOS"), + (Resampling.BILINEAR, "Image.Resampling.BILINEAR"), + (Resampling.BICUBIC, "Image.Resampling.BICUBIC"), + (Resampling.BOX, "Image.Resampling.BOX"), + (Resampling.HAMMING, "Image.Resampling.HAMMING"), + ) + ] + msg += " Use " + ", ".join(filters[:-1]) + " or " + filters[-1] + raise ValueError(msg) + + if reducing_gap is not None and reducing_gap < 1.0: + msg = "reducing_gap must be 1.0 or greater" + raise ValueError(msg) + + size = tuple(size) + + self.load() + if box is None: + box = (0, 0) + self.size + else: + box = tuple(box) + + if self.size == size and box == (0, 0) + self.size: + return self.copy() + + if self.mode in ("1", "P"): + resample = Resampling.NEAREST + + if self.mode in ["LA", "RGBA"] and resample != Resampling.NEAREST: + im = self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode]) + im = im.resize(size, resample, box) + return im.convert(self.mode) + + self.load() + + if reducing_gap is not None and resample != Resampling.NEAREST: + factor_x = int((box[2] - box[0]) / size[0] / reducing_gap) or 1 + factor_y = int((box[3] - box[1]) / size[1] / reducing_gap) or 1 + if factor_x > 1 or factor_y > 1: + reduce_box = self._get_safe_box(size, resample, box) + factor = (factor_x, factor_y) + self = ( + self.reduce(factor, box=reduce_box) + if callable(self.reduce) + else Image.reduce(self, factor, box=reduce_box) + ) + box = ( + (box[0] - reduce_box[0]) / factor_x, + (box[1] - reduce_box[1]) / factor_y, + (box[2] - reduce_box[0]) / factor_x, + (box[3] - reduce_box[1]) / factor_y, + ) + + return self._new(self.im.resize(size, resample, box)) + + def reduce(self, factor, box=None): + """ + Returns a copy of the image reduced ``factor`` times. + If the size of the image is not dividable by ``factor``, + the resulting size will be rounded up. + + :param factor: A greater than 0 integer or tuple of two integers + for width and height separately. + :param box: An optional 4-tuple of ints providing + the source image region to be reduced. + The values must be within ``(0, 0, width, height)`` rectangle. + If omitted or ``None``, the entire source is used. + """ + if not isinstance(factor, (list, tuple)): + factor = (factor, factor) + + if box is None: + box = (0, 0) + self.size + else: + box = tuple(box) + + if factor == (1, 1) and box == (0, 0) + self.size: + return self.copy() + + if self.mode in ["LA", "RGBA"]: + im = self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode]) + im = im.reduce(factor, box) + return im.convert(self.mode) + + self.load() + + return self._new(self.im.reduce(factor, box)) + + def rotate( + self, + angle, + resample=Resampling.NEAREST, + expand=0, + center=None, + translate=None, + fillcolor=None, + ): + """ + Returns a rotated copy of this image. This method returns a + copy of this image, rotated the given number of degrees counter + clockwise around its centre. + + :param angle: In degrees counter clockwise. + :param resample: An optional resampling filter. This can be + one of :py:data:`Resampling.NEAREST` (use nearest neighbour), + :py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2 + environment), or :py:data:`Resampling.BICUBIC` (cubic spline + interpolation in a 4x4 environment). If omitted, or if the image has + mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`. + See :ref:`concept-filters`. + :param expand: Optional expansion flag. If true, expands the output + image to make it large enough to hold the entire rotated image. + If false or omitted, make the output image the same size as the + input image. Note that the expand flag assumes rotation around + the center and no translation. + :param center: Optional center of rotation (a 2-tuple). Origin is + the upper left corner. Default is the center of the image. + :param translate: An optional post-rotate translation (a 2-tuple). + :param fillcolor: An optional color for area outside the rotated image. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + angle = angle % 360.0 + + # Fast paths regardless of filter, as long as we're not + # translating or changing the center. + if not (center or translate): + if angle == 0: + return self.copy() + if angle == 180: + return self.transpose(Transpose.ROTATE_180) + if angle in (90, 270) and (expand or self.width == self.height): + return self.transpose( + Transpose.ROTATE_90 if angle == 90 else Transpose.ROTATE_270 + ) + + # Calculate the affine matrix. Note that this is the reverse + # transformation (from destination image to source) because we + # want to interpolate the (discrete) destination pixel from + # the local area around the (floating) source pixel. + + # The matrix we actually want (note that it operates from the right): + # (1, 0, tx) (1, 0, cx) ( cos a, sin a, 0) (1, 0, -cx) + # (0, 1, ty) * (0, 1, cy) * (-sin a, cos a, 0) * (0, 1, -cy) + # (0, 0, 1) (0, 0, 1) ( 0, 0, 1) (0, 0, 1) + + # The reverse matrix is thus: + # (1, 0, cx) ( cos -a, sin -a, 0) (1, 0, -cx) (1, 0, -tx) + # (0, 1, cy) * (-sin -a, cos -a, 0) * (0, 1, -cy) * (0, 1, -ty) + # (0, 0, 1) ( 0, 0, 1) (0, 0, 1) (0, 0, 1) + + # In any case, the final translation may be updated at the end to + # compensate for the expand flag. + + w, h = self.size + + if translate is None: + post_trans = (0, 0) + else: + post_trans = translate + if center is None: + # FIXME These should be rounded to ints? + rotn_center = (w / 2.0, h / 2.0) + else: + rotn_center = center + + angle = -math.radians(angle) + matrix = [ + round(math.cos(angle), 15), + round(math.sin(angle), 15), + 0.0, + round(-math.sin(angle), 15), + round(math.cos(angle), 15), + 0.0, + ] + + def transform(x, y, matrix): + (a, b, c, d, e, f) = matrix + return a * x + b * y + c, d * x + e * y + f + + matrix[2], matrix[5] = transform( + -rotn_center[0] - post_trans[0], -rotn_center[1] - post_trans[1], matrix + ) + matrix[2] += rotn_center[0] + matrix[5] += rotn_center[1] + + if expand: + # calculate output size + xx = [] + yy = [] + for x, y in ((0, 0), (w, 0), (w, h), (0, h)): + x, y = transform(x, y, matrix) + xx.append(x) + yy.append(y) + nw = math.ceil(max(xx)) - math.floor(min(xx)) + nh = math.ceil(max(yy)) - math.floor(min(yy)) + + # We multiply a translation matrix from the right. Because of its + # special form, this is the same as taking the image of the + # translation vector as new translation vector. + matrix[2], matrix[5] = transform(-(nw - w) / 2.0, -(nh - h) / 2.0, matrix) + w, h = nw, nh + + return self.transform( + (w, h), Transform.AFFINE, matrix, resample, fillcolor=fillcolor + ) + + def save(self, fp, format=None, **params) -> None: + """ + Saves this image under the given filename. If no format is + specified, the format to use is determined from the filename + extension, if possible. + + Keyword options can be used to provide additional instructions + to the writer. If a writer doesn't recognise an option, it is + silently ignored. The available options are described in the + :doc:`image format documentation + <../handbook/image-file-formats>` for each writer. + + You can use a file object instead of a filename. In this case, + you must always specify the format. The file object must + implement the ``seek``, ``tell``, and ``write`` + methods, and be opened in binary mode. + + :param fp: A filename (string), os.PathLike object or file object. + :param format: Optional format override. If omitted, the + format to use is determined from the filename extension. + If a file object was used instead of a filename, this + parameter should always be used. + :param params: Extra parameters to the image writer. + :returns: None + :exception ValueError: If the output format could not be determined + from the file name. Use the format option to solve this. + :exception OSError: If the file could not be written. The file + may have been created, and may contain partial data. + """ + + filename: str | bytes = "" + open_fp = False + if is_path(fp): + filename = os.path.realpath(os.fspath(fp)) + open_fp = True + elif fp == sys.stdout: + try: + fp = sys.stdout.buffer + except AttributeError: + pass + if not filename and hasattr(fp, "name") and is_path(fp.name): + # only set the name for metadata purposes + filename = os.path.realpath(os.fspath(fp.name)) + + # may mutate self! + self._ensure_mutable() + + save_all = params.pop("save_all", False) + self.encoderinfo = params + self.encoderconfig = () + + preinit() + + filename_ext = os.path.splitext(filename)[1].lower() + ext = filename_ext.decode() if isinstance(filename_ext, bytes) else filename_ext + + if not format: + if ext not in EXTENSION: + init() + try: + format = EXTENSION[ext] + except KeyError as e: + msg = f"unknown file extension: {ext}" + raise ValueError(msg) from e + + if format.upper() not in SAVE: + init() + if save_all: + save_handler = SAVE_ALL[format.upper()] + else: + save_handler = SAVE[format.upper()] + + created = False + if open_fp: + created = not os.path.exists(filename) + if params.get("append", False): + # Open also for reading ("+"), because TIFF save_all + # writer needs to go back and edit the written data. + fp = builtins.open(filename, "r+b") + else: + fp = builtins.open(filename, "w+b") + + try: + save_handler(self, fp, filename) + except Exception: + if open_fp: + fp.close() + if created: + try: + os.remove(filename) + except PermissionError: + pass + raise + if open_fp: + fp.close() + + def seek(self, frame: int) -> None: + """ + Seeks to the given frame in this sequence file. If you seek + beyond the end of the sequence, the method raises an + ``EOFError`` exception. When a sequence file is opened, the + library automatically seeks to frame 0. + + See :py:meth:`~PIL.Image.Image.tell`. + + If defined, :attr:`~PIL.Image.Image.n_frames` refers to the + number of available frames. + + :param frame: Frame number, starting at 0. + :exception EOFError: If the call attempts to seek beyond the end + of the sequence. + """ + + # overridden by file handlers + if frame != 0: + msg = "no more images in file" + raise EOFError(msg) + + def show(self, title: str | None = None) -> None: + """ + Displays this image. This method is mainly intended for debugging purposes. + + This method calls :py:func:`PIL.ImageShow.show` internally. You can use + :py:func:`PIL.ImageShow.register` to override its default behaviour. + + The image is first saved to a temporary file. By default, it will be in + PNG format. + + On Unix, the image is then opened using the **xdg-open**, **display**, + **gm**, **eog** or **xv** utility, depending on which one can be found. + + On macOS, the image is opened with the native Preview application. + + On Windows, the image is opened with the standard PNG display utility. + + :param title: Optional title to use for the image window, where possible. + """ + + _show(self, title=title) + + def split(self) -> tuple[Image, ...]: + """ + Split this image into individual bands. This method returns a + tuple of individual image bands from an image. For example, + splitting an "RGB" image creates three new images each + containing a copy of one of the original bands (red, green, + blue). + + If you need only one band, :py:meth:`~PIL.Image.Image.getchannel` + method can be more convenient and faster. + + :returns: A tuple containing bands. + """ + + self.load() + if self.im.bands == 1: + return (self.copy(),) + return tuple(map(self._new, self.im.split())) + + def getchannel(self, channel: int | str) -> Image: + """ + Returns an image containing a single channel of the source image. + + :param channel: What channel to return. Could be index + (0 for "R" channel of "RGB") or channel name + ("A" for alpha channel of "RGBA"). + :returns: An image in "L" mode. + + .. versionadded:: 4.3.0 + """ + self.load() + + if isinstance(channel, str): + try: + channel = self.getbands().index(channel) + except ValueError as e: + msg = f'The image has no channel "{channel}"' + raise ValueError(msg) from e + + return self._new(self.im.getband(channel)) + + def tell(self) -> int: + """ + Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`. + + If defined, :attr:`~PIL.Image.Image.n_frames` refers to the + number of available frames. + + :returns: Frame number, starting with 0. + """ + return 0 + + def thumbnail(self, size, resample=Resampling.BICUBIC, reducing_gap=2.0): + """ + Make this image into a thumbnail. This method modifies the + image to contain a thumbnail version of itself, no larger than + the given size. This method calculates an appropriate thumbnail + size to preserve the aspect of the image, calls the + :py:meth:`~PIL.Image.Image.draft` method to configure the file reader + (where applicable), and finally resizes the image. + + Note that this function modifies the :py:class:`~PIL.Image.Image` + object in place. If you need to use the full resolution image as well, + apply this method to a :py:meth:`~PIL.Image.Image.copy` of the original + image. + + :param size: The requested size in pixels, as a 2-tuple: + (width, height). + :param resample: Optional resampling filter. This can be one + of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`, + :py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`, + :py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`. + If omitted, it defaults to :py:data:`Resampling.BICUBIC`. + (was :py:data:`Resampling.NEAREST` prior to version 2.5.0). + See: :ref:`concept-filters`. + :param reducing_gap: Apply optimization by resizing the image + in two steps. First, reducing the image by integer times + using :py:meth:`~PIL.Image.Image.reduce` or + :py:meth:`~PIL.Image.Image.draft` for JPEG images. + Second, resizing using regular resampling. The last step + changes size no less than by ``reducing_gap`` times. + ``reducing_gap`` may be None (no first step is performed) + or should be greater than 1.0. The bigger ``reducing_gap``, + the closer the result to the fair resampling. + The smaller ``reducing_gap``, the faster resizing. + With ``reducing_gap`` greater or equal to 3.0, the result is + indistinguishable from fair resampling in most cases. + The default value is 2.0 (very close to fair resampling + while still being faster in many cases). + :returns: None + """ + + provided_size = tuple(map(math.floor, size)) + + def preserve_aspect_ratio() -> tuple[int, int] | None: + def round_aspect(number, key): + return max(min(math.floor(number), math.ceil(number), key=key), 1) + + x, y = provided_size + if x >= self.width and y >= self.height: + return None + + aspect = self.width / self.height + if x / y >= aspect: + x = round_aspect(y * aspect, key=lambda n: abs(aspect - n / y)) + else: + y = round_aspect( + x / aspect, key=lambda n: 0 if n == 0 else abs(aspect - x / n) + ) + return x, y + + box = None + if reducing_gap is not None: + size = preserve_aspect_ratio() + if size is None: + return + + res = self.draft(None, (size[0] * reducing_gap, size[1] * reducing_gap)) + if res is not None: + box = res[1] + if box is None: + self.load() + + # load() may have changed the size of the image + size = preserve_aspect_ratio() + if size is None: + return + + if self.size != size: + im = self.resize(size, resample, box=box, reducing_gap=reducing_gap) + + self.im = im.im + self._size = size + self._mode = self.im.mode + + self.readonly = 0 + self.pyaccess = None + + # FIXME: the different transform methods need further explanation + # instead of bloating the method docs, add a separate chapter. + def transform( + self, + size, + method, + data=None, + resample=Resampling.NEAREST, + fill=1, + fillcolor=None, + ) -> Image: + """ + Transforms this image. This method creates a new image with the + given size, and the same mode as the original, and copies data + to the new image using the given transform. + + :param size: The output size in pixels, as a 2-tuple: + (width, height). + :param method: The transformation method. This is one of + :py:data:`Transform.EXTENT` (cut out a rectangular subregion), + :py:data:`Transform.AFFINE` (affine transform), + :py:data:`Transform.PERSPECTIVE` (perspective transform), + :py:data:`Transform.QUAD` (map a quadrilateral to a rectangle), or + :py:data:`Transform.MESH` (map a number of source quadrilaterals + in one operation). + + It may also be an :py:class:`~PIL.Image.ImageTransformHandler` + object:: + + class Example(Image.ImageTransformHandler): + def transform(self, size, data, resample, fill=1): + # Return result + + Implementations of :py:class:`~PIL.Image.ImageTransformHandler` + for some of the :py:class:`Transform` methods are provided + in :py:mod:`~PIL.ImageTransform`. + + It may also be an object with a ``method.getdata`` method + that returns a tuple supplying new ``method`` and ``data`` values:: + + class Example: + def getdata(self): + method = Image.Transform.EXTENT + data = (0, 0, 100, 100) + return method, data + :param data: Extra data to the transformation method. + :param resample: Optional resampling filter. It can be one of + :py:data:`Resampling.NEAREST` (use nearest neighbour), + :py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2 + environment), or :py:data:`Resampling.BICUBIC` (cubic spline + interpolation in a 4x4 environment). If omitted, or if the image + has mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`. + See: :ref:`concept-filters`. + :param fill: If ``method`` is an + :py:class:`~PIL.Image.ImageTransformHandler` object, this is one of + the arguments passed to it. Otherwise, it is unused. + :param fillcolor: Optional fill color for the area outside the + transform in the output image. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + if self.mode in ("LA", "RGBA") and resample != Resampling.NEAREST: + return ( + self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode]) + .transform(size, method, data, resample, fill, fillcolor) + .convert(self.mode) + ) + + if isinstance(method, ImageTransformHandler): + return method.transform(size, self, resample=resample, fill=fill) + + if hasattr(method, "getdata"): + # compatibility w. old-style transform objects + method, data = method.getdata() + + if data is None: + msg = "missing method data" + raise ValueError(msg) + + im = new(self.mode, size, fillcolor) + if self.mode == "P" and self.palette: + im.palette = self.palette.copy() + im.info = self.info.copy() + if method == Transform.MESH: + # list of quads + for box, quad in data: + im.__transformer( + box, self, Transform.QUAD, quad, resample, fillcolor is None + ) + else: + im.__transformer( + (0, 0) + size, self, method, data, resample, fillcolor is None + ) + + return im + + def __transformer( + self, box, image, method, data, resample=Resampling.NEAREST, fill=1 + ): + w = box[2] - box[0] + h = box[3] - box[1] + + if method == Transform.AFFINE: + data = data[:6] + + elif method == Transform.EXTENT: + # convert extent to an affine transform + x0, y0, x1, y1 = data + xs = (x1 - x0) / w + ys = (y1 - y0) / h + method = Transform.AFFINE + data = (xs, 0, x0, 0, ys, y0) + + elif method == Transform.PERSPECTIVE: + data = data[:8] + + elif method == Transform.QUAD: + # quadrilateral warp. data specifies the four corners + # given as NW, SW, SE, and NE. + nw = data[:2] + sw = data[2:4] + se = data[4:6] + ne = data[6:8] + x0, y0 = nw + As = 1.0 / w + At = 1.0 / h + data = ( + x0, + (ne[0] - x0) * As, + (sw[0] - x0) * At, + (se[0] - sw[0] - ne[0] + x0) * As * At, + y0, + (ne[1] - y0) * As, + (sw[1] - y0) * At, + (se[1] - sw[1] - ne[1] + y0) * As * At, + ) + + else: + msg = "unknown transformation method" + raise ValueError(msg) + + if resample not in ( + Resampling.NEAREST, + Resampling.BILINEAR, + Resampling.BICUBIC, + ): + if resample in (Resampling.BOX, Resampling.HAMMING, Resampling.LANCZOS): + msg = { + Resampling.BOX: "Image.Resampling.BOX", + Resampling.HAMMING: "Image.Resampling.HAMMING", + Resampling.LANCZOS: "Image.Resampling.LANCZOS", + }[resample] + f" ({resample}) cannot be used." + else: + msg = f"Unknown resampling filter ({resample})." + + filters = [ + f"{filter[1]} ({filter[0]})" + for filter in ( + (Resampling.NEAREST, "Image.Resampling.NEAREST"), + (Resampling.BILINEAR, "Image.Resampling.BILINEAR"), + (Resampling.BICUBIC, "Image.Resampling.BICUBIC"), + ) + ] + msg += " Use " + ", ".join(filters[:-1]) + " or " + filters[-1] + raise ValueError(msg) + + image.load() + + self.load() + + if image.mode in ("1", "P"): + resample = Resampling.NEAREST + + self.im.transform2(box, image.im, method, data, resample, fill) + + def transpose(self, method: Transpose) -> Image: + """ + Transpose image (flip or rotate in 90 degree steps) + + :param method: One of :py:data:`Transpose.FLIP_LEFT_RIGHT`, + :py:data:`Transpose.FLIP_TOP_BOTTOM`, :py:data:`Transpose.ROTATE_90`, + :py:data:`Transpose.ROTATE_180`, :py:data:`Transpose.ROTATE_270`, + :py:data:`Transpose.TRANSPOSE` or :py:data:`Transpose.TRANSVERSE`. + :returns: Returns a flipped or rotated copy of this image. + """ + + self.load() + return self._new(self.im.transpose(method)) + + def effect_spread(self, distance): + """ + Randomly spread pixels in an image. + + :param distance: Distance to spread pixels. + """ + self.load() + return self._new(self.im.effect_spread(distance)) + + def toqimage(self): + """Returns a QImage copy of this image""" + from . import ImageQt + + if not ImageQt.qt_is_installed: + msg = "Qt bindings are not installed" + raise ImportError(msg) + return ImageQt.toqimage(self) + + def toqpixmap(self): + """Returns a QPixmap copy of this image""" + from . import ImageQt + + if not ImageQt.qt_is_installed: + msg = "Qt bindings are not installed" + raise ImportError(msg) + return ImageQt.toqpixmap(self) + + +# -------------------------------------------------------------------- +# Abstract handlers. + + +class ImagePointHandler: + """ + Used as a mixin by point transforms + (for use with :py:meth:`~PIL.Image.Image.point`) + """ + + @abc.abstractmethod + def point(self, im: Image) -> Image: + pass + + +class ImageTransformHandler: + """ + Used as a mixin by geometry transforms + (for use with :py:meth:`~PIL.Image.Image.transform`) + """ + + @abc.abstractmethod + def transform( + self, + size: tuple[int, int], + image: Image, + **options: dict[str, str | int | tuple[int, ...] | list[int]], + ) -> Image: + pass + + +# -------------------------------------------------------------------- +# Factories + +# +# Debugging + + +def _wedge(): + """Create grayscale wedge (for debugging only)""" + + return Image()._new(core.wedge("L")) + + +def _check_size(size): + """ + Common check to enforce type and sanity check on size tuples + + :param size: Should be a 2 tuple of (width, height) + :returns: True, or raises a ValueError + """ + + if not isinstance(size, (list, tuple)): + msg = "Size must be a tuple" + raise ValueError(msg) + if len(size) != 2: + msg = "Size must be a tuple of length 2" + raise ValueError(msg) + if size[0] < 0 or size[1] < 0: + msg = "Width and height must be >= 0" + raise ValueError(msg) + + return True + + +def new( + mode: str, size: tuple[int, int], color: float | tuple[float, ...] | str | None = 0 +) -> Image: + """ + Creates a new image with the given mode and size. + + :param mode: The mode to use for the new image. See: + :ref:`concept-modes`. + :param size: A 2-tuple, containing (width, height) in pixels. + :param color: What color to use for the image. Default is black. + If given, this should be a single integer or floating point value + for single-band modes, and a tuple for multi-band modes (one value + per band). When creating RGB or HSV images, you can also use color + strings as supported by the ImageColor module. If the color is + None, the image is not initialised. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + _check_size(size) + + if color is None: + # don't initialize + return Image()._new(core.new(mode, size)) + + if isinstance(color, str): + # css3-style specifier + + from . import ImageColor + + color = ImageColor.getcolor(color, mode) + + im = Image() + if mode == "P" and isinstance(color, (list, tuple)) and len(color) in [3, 4]: + # RGB or RGBA value for a P image + from . import ImagePalette + + im.palette = ImagePalette.ImagePalette() + color = im.palette.getcolor(color) + return im._new(core.fill(mode, size, color)) + + +def frombytes(mode, size, data, decoder_name="raw", *args) -> Image: + """ + Creates a copy of an image memory from pixel data in a buffer. + + In its simplest form, this function takes three arguments + (mode, size, and unpacked pixel data). + + You can also use any pixel decoder supported by PIL. For more + information on available decoders, see the section + :ref:`Writing Your Own File Codec `. + + Note that this function decodes pixel data only, not entire images. + If you have an entire image in a string, wrap it in a + :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load + it. + + :param mode: The image mode. See: :ref:`concept-modes`. + :param size: The image size. + :param data: A byte buffer containing raw data for the given mode. + :param decoder_name: What decoder to use. + :param args: Additional parameters for the given decoder. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + _check_size(size) + + im = new(mode, size) + if im.width != 0 and im.height != 0: + # may pass tuple instead of argument list + if len(args) == 1 and isinstance(args[0], tuple): + args = args[0] + + if decoder_name == "raw" and args == (): + args = mode + + im.frombytes(data, decoder_name, args) + return im + + +def frombuffer(mode, size, data, decoder_name="raw", *args): + """ + Creates an image memory referencing pixel data in a byte buffer. + + This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data + in the byte buffer, where possible. This means that changes to the + original buffer object are reflected in this image). Not all modes can + share memory; supported modes include "L", "RGBX", "RGBA", and "CMYK". + + Note that this function decodes pixel data only, not entire images. + If you have an entire image file in a string, wrap it in a + :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load it. + + The default parameters used for the "raw" decoder differs from that used for + :py:func:`~PIL.Image.frombytes`. This is a bug, and will probably be fixed in a + future release. The current release issues a warning if you do this; to disable + the warning, you should provide the full set of parameters. See below for details. + + :param mode: The image mode. See: :ref:`concept-modes`. + :param size: The image size. + :param data: A bytes or other buffer object containing raw + data for the given mode. + :param decoder_name: What decoder to use. + :param args: Additional parameters for the given decoder. For the + default encoder ("raw"), it's recommended that you provide the + full set of parameters:: + + frombuffer(mode, size, data, "raw", mode, 0, 1) + + :returns: An :py:class:`~PIL.Image.Image` object. + + .. versionadded:: 1.1.4 + """ + + _check_size(size) + + # may pass tuple instead of argument list + if len(args) == 1 and isinstance(args[0], tuple): + args = args[0] + + if decoder_name == "raw": + if args == (): + args = mode, 0, 1 + if args[0] in _MAPMODES: + im = new(mode, (0, 0)) + im = im._new(core.map_buffer(data, size, decoder_name, 0, args)) + if mode == "P": + from . import ImagePalette + + im.palette = ImagePalette.ImagePalette("RGB", im.im.getpalette("RGB")) + im.readonly = 1 + return im + + return frombytes(mode, size, data, decoder_name, args) + + +def fromarray(obj, mode=None): + """ + Creates an image memory from an object exporting the array interface + (using the buffer protocol):: + + from PIL import Image + import numpy as np + a = np.zeros((5, 5)) + im = Image.fromarray(a) + + If ``obj`` is not contiguous, then the ``tobytes`` method is called + and :py:func:`~PIL.Image.frombuffer` is used. + + In the case of NumPy, be aware that Pillow modes do not always correspond + to NumPy dtypes. Pillow modes only offer 1-bit pixels, 8-bit pixels, + 32-bit signed integer pixels, and 32-bit floating point pixels. + + Pillow images can also be converted to arrays:: + + from PIL import Image + import numpy as np + im = Image.open("hopper.jpg") + a = np.asarray(im) + + When converting Pillow images to arrays however, only pixel values are + transferred. This means that P and PA mode images will lose their palette. + + :param obj: Object with array interface + :param mode: Optional mode to use when reading ``obj``. Will be determined from + type if ``None``. + + This will not be used to convert the data after reading, but will be used to + change how the data is read:: + + from PIL import Image + import numpy as np + a = np.full((1, 1), 300) + im = Image.fromarray(a, mode="L") + im.getpixel((0, 0)) # 44 + im = Image.fromarray(a, mode="RGB") + im.getpixel((0, 0)) # (44, 1, 0) + + See: :ref:`concept-modes` for general information about modes. + :returns: An image object. + + .. versionadded:: 1.1.6 + """ + arr = obj.__array_interface__ + shape = arr["shape"] + ndim = len(shape) + strides = arr.get("strides", None) + if mode is None: + try: + typekey = (1, 1) + shape[2:], arr["typestr"] + except KeyError as e: + msg = "Cannot handle this data type" + raise TypeError(msg) from e + try: + mode, rawmode = _fromarray_typemap[typekey] + except KeyError as e: + typekey_shape, typestr = typekey + msg = f"Cannot handle this data type: {typekey_shape}, {typestr}" + raise TypeError(msg) from e + else: + rawmode = mode + if mode in ["1", "L", "I", "P", "F"]: + ndmax = 2 + elif mode == "RGB": + ndmax = 3 + else: + ndmax = 4 + if ndim > ndmax: + msg = f"Too many dimensions: {ndim} > {ndmax}." + raise ValueError(msg) + + size = 1 if ndim == 1 else shape[1], shape[0] + if strides is not None: + if hasattr(obj, "tobytes"): + obj = obj.tobytes() + else: + obj = obj.tostring() + + return frombuffer(mode, size, obj, "raw", rawmode, 0, 1) + + +def fromqimage(im): + """Creates an image instance from a QImage image""" + from . import ImageQt + + if not ImageQt.qt_is_installed: + msg = "Qt bindings are not installed" + raise ImportError(msg) + return ImageQt.fromqimage(im) + + +def fromqpixmap(im): + """Creates an image instance from a QPixmap image""" + from . import ImageQt + + if not ImageQt.qt_is_installed: + msg = "Qt bindings are not installed" + raise ImportError(msg) + return ImageQt.fromqpixmap(im) + + +_fromarray_typemap = { + # (shape, typestr) => mode, rawmode + # first two members of shape are set to one + ((1, 1), "|b1"): ("1", "1;8"), + ((1, 1), "|u1"): ("L", "L"), + ((1, 1), "|i1"): ("I", "I;8"), + ((1, 1), "u2"): ("I", "I;16B"), + ((1, 1), "i2"): ("I", "I;16BS"), + ((1, 1), "u4"): ("I", "I;32B"), + ((1, 1), "i4"): ("I", "I;32BS"), + ((1, 1), "f4"): ("F", "F;32BF"), + ((1, 1), "f8"): ("F", "F;64BF"), + ((1, 1, 2), "|u1"): ("LA", "LA"), + ((1, 1, 3), "|u1"): ("RGB", "RGB"), + ((1, 1, 4), "|u1"): ("RGBA", "RGBA"), + # shortcuts: + ((1, 1), _ENDIAN + "i4"): ("I", "I"), + ((1, 1), _ENDIAN + "f4"): ("F", "F"), +} + + +def _decompression_bomb_check(size: tuple[int, int]) -> None: + if MAX_IMAGE_PIXELS is None: + return + + pixels = max(1, size[0]) * max(1, size[1]) + + if pixels > 2 * MAX_IMAGE_PIXELS: + msg = ( + f"Image size ({pixels} pixels) exceeds limit of {2 * MAX_IMAGE_PIXELS} " + "pixels, could be decompression bomb DOS attack." + ) + raise DecompressionBombError(msg) + + if pixels > MAX_IMAGE_PIXELS: + warnings.warn( + f"Image size ({pixels} pixels) exceeds limit of {MAX_IMAGE_PIXELS} pixels, " + "could be decompression bomb DOS attack.", + DecompressionBombWarning, + ) + + +def open(fp, mode="r", formats=None) -> Image: + """ + Opens and identifies the given image file. + + This is a lazy operation; this function identifies the file, but + the file remains open and the actual image data is not read from + the file until you try to process the data (or call the + :py:meth:`~PIL.Image.Image.load` method). See + :py:func:`~PIL.Image.new`. See :ref:`file-handling`. + + :param fp: A filename (string), os.PathLike object or a file object. + The file object must implement ``file.read``, + ``file.seek``, and ``file.tell`` methods, + and be opened in binary mode. The file object will also seek to zero + before reading. + :param mode: The mode. If given, this argument must be "r". + :param formats: A list or tuple of formats to attempt to load the file in. + This can be used to restrict the set of formats checked. + Pass ``None`` to try all supported formats. You can print the set of + available formats by running ``python3 -m PIL`` or using + the :py:func:`PIL.features.pilinfo` function. + :returns: An :py:class:`~PIL.Image.Image` object. + :exception FileNotFoundError: If the file cannot be found. + :exception PIL.UnidentifiedImageError: If the image cannot be opened and + identified. + :exception ValueError: If the ``mode`` is not "r", or if a ``StringIO`` + instance is used for ``fp``. + :exception TypeError: If ``formats`` is not ``None``, a list or a tuple. + """ + + if mode != "r": + msg = f"bad mode {repr(mode)}" + raise ValueError(msg) + elif isinstance(fp, io.StringIO): + msg = ( + "StringIO cannot be used to open an image. " + "Binary data must be used instead." + ) + raise ValueError(msg) + + if formats is None: + formats = ID + elif not isinstance(formats, (list, tuple)): + msg = "formats must be a list or tuple" + raise TypeError(msg) + + exclusive_fp = False + filename: str | bytes = "" + if is_path(fp): + filename = os.path.realpath(os.fspath(fp)) + + if filename: + fp = builtins.open(filename, "rb") + exclusive_fp = True + + try: + fp.seek(0) + except (AttributeError, io.UnsupportedOperation): + fp = io.BytesIO(fp.read()) + exclusive_fp = True + + prefix = fp.read(16) + + preinit() + + accept_warnings = [] + + def _open_core(fp, filename, prefix, formats): + for i in formats: + i = i.upper() + if i not in OPEN: + init() + try: + factory, accept = OPEN[i] + result = not accept or accept(prefix) + if type(result) in [str, bytes]: + accept_warnings.append(result) + elif result: + fp.seek(0) + im = factory(fp, filename) + _decompression_bomb_check(im.size) + return im + except (SyntaxError, IndexError, TypeError, struct.error): + # Leave disabled by default, spams the logs with image + # opening failures that are entirely expected. + # logger.debug("", exc_info=True) + continue + except BaseException: + if exclusive_fp: + fp.close() + raise + return None + + im = _open_core(fp, filename, prefix, formats) + + if im is None and formats is ID: + checked_formats = formats.copy() + if init(): + im = _open_core( + fp, + filename, + prefix, + tuple(format for format in formats if format not in checked_formats), + ) + + if im: + im._exclusive_fp = exclusive_fp + return im + + if exclusive_fp: + fp.close() + for message in accept_warnings: + warnings.warn(message) + msg = "cannot identify image file %r" % (filename if filename else fp) + raise UnidentifiedImageError(msg) + + +# +# Image processing. + + +def alpha_composite(im1: Image, im2: Image) -> Image: + """ + Alpha composite im2 over im1. + + :param im1: The first image. Must have mode RGBA. + :param im2: The second image. Must have mode RGBA, and the same size as + the first image. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + im1.load() + im2.load() + return im1._new(core.alpha_composite(im1.im, im2.im)) + + +def blend(im1: Image, im2: Image, alpha: float) -> Image: + """ + Creates a new image by interpolating between two input images, using + a constant alpha:: + + out = image1 * (1.0 - alpha) + image2 * alpha + + :param im1: The first image. + :param im2: The second image. Must have the same mode and size as + the first image. + :param alpha: The interpolation alpha factor. If alpha is 0.0, a + copy of the first image is returned. If alpha is 1.0, a copy of + the second image is returned. There are no restrictions on the + alpha value. If necessary, the result is clipped to fit into + the allowed output range. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + im1.load() + im2.load() + return im1._new(core.blend(im1.im, im2.im, alpha)) + + +def composite(image1: Image, image2: Image, mask: Image) -> Image: + """ + Create composite image by blending images using a transparency mask. + + :param image1: The first image. + :param image2: The second image. Must have the same mode and + size as the first image. + :param mask: A mask image. This image can have mode + "1", "L", or "RGBA", and must have the same size as the + other two images. + """ + + image = image2.copy() + image.paste(image1, None, mask) + return image + + +def eval(image, *args): + """ + Applies the function (which should take one argument) to each pixel + in the given image. If the image has more than one band, the same + function is applied to each band. Note that the function is + evaluated once for each possible pixel value, so you cannot use + random components or other generators. + + :param image: The input image. + :param function: A function object, taking one integer argument. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + return image.point(args[0]) + + +def merge(mode, bands): + """ + Merge a set of single band images into a new multiband image. + + :param mode: The mode to use for the output image. See: + :ref:`concept-modes`. + :param bands: A sequence containing one single-band image for + each band in the output image. All bands must have the + same size. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + + if getmodebands(mode) != len(bands) or "*" in mode: + msg = "wrong number of bands" + raise ValueError(msg) + for band in bands[1:]: + if band.mode != getmodetype(mode): + msg = "mode mismatch" + raise ValueError(msg) + if band.size != bands[0].size: + msg = "size mismatch" + raise ValueError(msg) + for band in bands: + band.load() + return bands[0]._new(core.merge(mode, *[b.im for b in bands])) + + +# -------------------------------------------------------------------- +# Plugin registry + + +def register_open( + id, + factory: Callable[[IO[bytes], str | bytes], ImageFile.ImageFile], + accept: Callable[[bytes], bool] | None = None, +) -> None: + """ + Register an image file plugin. This function should not be used + in application code. + + :param id: An image format identifier. + :param factory: An image file factory method. + :param accept: An optional function that can be used to quickly + reject images having another format. + """ + id = id.upper() + if id not in ID: + ID.append(id) + OPEN[id] = factory, accept + + +def register_mime(id: str, mimetype: str) -> None: + """ + Registers an image MIME type by populating ``Image.MIME``. This function + should not be used in application code. + + ``Image.MIME`` provides a mapping from image format identifiers to mime + formats, but :py:meth:`~PIL.ImageFile.ImageFile.get_format_mimetype` can + provide a different result for specific images. + + :param id: An image format identifier. + :param mimetype: The image MIME type for this format. + """ + MIME[id.upper()] = mimetype + + +def register_save(id: str, driver) -> None: + """ + Registers an image save function. This function should not be + used in application code. + + :param id: An image format identifier. + :param driver: A function to save images in this format. + """ + SAVE[id.upper()] = driver + + +def register_save_all(id, driver) -> None: + """ + Registers an image function to save all the frames + of a multiframe format. This function should not be + used in application code. + + :param id: An image format identifier. + :param driver: A function to save images in this format. + """ + SAVE_ALL[id.upper()] = driver + + +def register_extension(id, extension) -> None: + """ + Registers an image extension. This function should not be + used in application code. + + :param id: An image format identifier. + :param extension: An extension used for this format. + """ + EXTENSION[extension.lower()] = id.upper() + + +def register_extensions(id, extensions) -> None: + """ + Registers image extensions. This function should not be + used in application code. + + :param id: An image format identifier. + :param extensions: A list of extensions used for this format. + """ + for extension in extensions: + register_extension(id, extension) + + +def registered_extensions(): + """ + Returns a dictionary containing all file extensions belonging + to registered plugins + """ + init() + return EXTENSION + + +def register_decoder(name: str, decoder: type[ImageFile.PyDecoder]) -> None: + """ + Registers an image decoder. This function should not be + used in application code. + + :param name: The name of the decoder + :param decoder: An ImageFile.PyDecoder object + + .. versionadded:: 4.1.0 + """ + DECODERS[name] = decoder + + +def register_encoder(name: str, encoder: type[ImageFile.PyEncoder]) -> None: + """ + Registers an image encoder. This function should not be + used in application code. + + :param name: The name of the encoder + :param encoder: An ImageFile.PyEncoder object + + .. versionadded:: 4.1.0 + """ + ENCODERS[name] = encoder + + +# -------------------------------------------------------------------- +# Simple display support. + + +def _show(image, **options) -> None: + from . import ImageShow + + ImageShow.show(image, **options) + + +# -------------------------------------------------------------------- +# Effects + + +def effect_mandelbrot(size, extent, quality): + """ + Generate a Mandelbrot set covering the given extent. + + :param size: The requested size in pixels, as a 2-tuple: + (width, height). + :param extent: The extent to cover, as a 4-tuple: + (x0, y0, x1, y1). + :param quality: Quality. + """ + return Image()._new(core.effect_mandelbrot(size, extent, quality)) + + +def effect_noise(size, sigma): + """ + Generate Gaussian noise centered around 128. + + :param size: The requested size in pixels, as a 2-tuple: + (width, height). + :param sigma: Standard deviation of noise. + """ + return Image()._new(core.effect_noise(size, sigma)) + + +def linear_gradient(mode): + """ + Generate 256x256 linear gradient from black to white, top to bottom. + + :param mode: Input mode. + """ + return Image()._new(core.linear_gradient(mode)) + + +def radial_gradient(mode): + """ + Generate 256x256 radial gradient from black to white, centre to edge. + + :param mode: Input mode. + """ + return Image()._new(core.radial_gradient(mode)) + + +# -------------------------------------------------------------------- +# Resources + + +def _apply_env_variables(env=None) -> None: + if env is None: + env = os.environ + + for var_name, setter in [ + ("PILLOW_ALIGNMENT", core.set_alignment), + ("PILLOW_BLOCK_SIZE", core.set_block_size), + ("PILLOW_BLOCKS_MAX", core.set_blocks_max), + ]: + if var_name not in env: + continue + + var = env[var_name].lower() + + units = 1 + for postfix, mul in [("k", 1024), ("m", 1024 * 1024)]: + if var.endswith(postfix): + units = mul + var = var[: -len(postfix)] + + try: + var = int(var) * units + except ValueError: + warnings.warn(f"{var_name} is not int") + continue + + try: + setter(var) + except ValueError as e: + warnings.warn(f"{var_name}: {e}") + + +_apply_env_variables() +atexit.register(core.clear_cache) + + +if TYPE_CHECKING: + _ExifBase = MutableMapping[int, Any] +else: + _ExifBase = MutableMapping + + +class Exif(_ExifBase): + """ + This class provides read and write access to EXIF image data:: + + from PIL import Image + im = Image.open("exif.png") + exif = im.getexif() # Returns an instance of this class + + Information can be read and written, iterated over or deleted:: + + print(exif[274]) # 1 + exif[274] = 2 + for k, v in exif.items(): + print("Tag", k, "Value", v) # Tag 274 Value 2 + del exif[274] + + To access information beyond IFD0, :py:meth:`~PIL.Image.Exif.get_ifd` + returns a dictionary:: + + from PIL import ExifTags + im = Image.open("exif_gps.jpg") + exif = im.getexif() + gps_ifd = exif.get_ifd(ExifTags.IFD.GPSInfo) + print(gps_ifd) + + Other IFDs include ``ExifTags.IFD.Exif``, ``ExifTags.IFD.Makernote``, + ``ExifTags.IFD.Interop`` and ``ExifTags.IFD.IFD1``. + + :py:mod:`~PIL.ExifTags` also has enum classes to provide names for data:: + + print(exif[ExifTags.Base.Software]) # PIL + print(gps_ifd[ExifTags.GPS.GPSDateStamp]) # 1999:99:99 99:99:99 + """ + + endian = None + bigtiff = False + _loaded = False + + def __init__(self): + self._data = {} + self._hidden_data = {} + self._ifds = {} + self._info = None + self._loaded_exif = None + + def _fixup(self, value): + try: + if len(value) == 1 and isinstance(value, tuple): + return value[0] + except Exception: + pass + return value + + def _fixup_dict(self, src_dict): + # Helper function + # returns a dict with any single item tuples/lists as individual values + return {k: self._fixup(v) for k, v in src_dict.items()} + + def _get_ifd_dict(self, offset, group=None): + try: + # an offset pointer to the location of the nested embedded IFD. + # It should be a long, but may be corrupted. + self.fp.seek(offset) + except (KeyError, TypeError): + pass + else: + from . import TiffImagePlugin + + info = TiffImagePlugin.ImageFileDirectory_v2(self.head, group=group) + info.load(self.fp) + return self._fixup_dict(info) + + def _get_head(self): + version = b"\x2B" if self.bigtiff else b"\x2A" + if self.endian == "<": + head = b"II" + version + b"\x00" + o32le(8) + else: + head = b"MM\x00" + version + o32be(8) + if self.bigtiff: + head += o32le(8) if self.endian == "<" else o32be(8) + head += b"\x00\x00\x00\x00" + return head + + def load(self, data): + # Extract EXIF information. This is highly experimental, + # and is likely to be replaced with something better in a future + # version. + + # The EXIF record consists of a TIFF file embedded in a JPEG + # application marker (!). + if data == self._loaded_exif: + return + self._loaded_exif = data + self._data.clear() + self._hidden_data.clear() + self._ifds.clear() + if data and data.startswith(b"Exif\x00\x00"): + data = data[6:] + if not data: + self._info = None + return + + self.fp = io.BytesIO(data) + self.head = self.fp.read(8) + # process dictionary + from . import TiffImagePlugin + + self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head) + self.endian = self._info._endian + self.fp.seek(self._info.next) + self._info.load(self.fp) + + def load_from_fp(self, fp, offset=None): + self._loaded_exif = None + self._data.clear() + self._hidden_data.clear() + self._ifds.clear() + + # process dictionary + from . import TiffImagePlugin + + self.fp = fp + if offset is not None: + self.head = self._get_head() + else: + self.head = self.fp.read(8) + self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head) + if self.endian is None: + self.endian = self._info._endian + if offset is None: + offset = self._info.next + self.fp.tell() + self.fp.seek(offset) + self._info.load(self.fp) + + def _get_merged_dict(self): + merged_dict = dict(self) + + # get EXIF extension + if ExifTags.IFD.Exif in self: + ifd = self._get_ifd_dict(self[ExifTags.IFD.Exif], ExifTags.IFD.Exif) + if ifd: + merged_dict.update(ifd) + + # GPS + if ExifTags.IFD.GPSInfo in self: + merged_dict[ExifTags.IFD.GPSInfo] = self._get_ifd_dict( + self[ExifTags.IFD.GPSInfo], ExifTags.IFD.GPSInfo + ) + + return merged_dict + + def tobytes(self, offset: int = 8) -> bytes: + from . import TiffImagePlugin + + head = self._get_head() + ifd = TiffImagePlugin.ImageFileDirectory_v2(ifh=head) + for tag, value in self.items(): + if tag in [ + ExifTags.IFD.Exif, + ExifTags.IFD.GPSInfo, + ] and not isinstance(value, dict): + value = self.get_ifd(tag) + if ( + tag == ExifTags.IFD.Exif + and ExifTags.IFD.Interop in value + and not isinstance(value[ExifTags.IFD.Interop], dict) + ): + value = value.copy() + value[ExifTags.IFD.Interop] = self.get_ifd(ExifTags.IFD.Interop) + ifd[tag] = value + return b"Exif\x00\x00" + head + ifd.tobytes(offset) + + def get_ifd(self, tag): + if tag not in self._ifds: + if tag == ExifTags.IFD.IFD1: + if self._info is not None and self._info.next != 0: + self._ifds[tag] = self._get_ifd_dict(self._info.next) + elif tag in [ExifTags.IFD.Exif, ExifTags.IFD.GPSInfo]: + offset = self._hidden_data.get(tag, self.get(tag)) + if offset is not None: + self._ifds[tag] = self._get_ifd_dict(offset, tag) + elif tag in [ExifTags.IFD.Interop, ExifTags.IFD.Makernote]: + if ExifTags.IFD.Exif not in self._ifds: + self.get_ifd(ExifTags.IFD.Exif) + tag_data = self._ifds[ExifTags.IFD.Exif][tag] + if tag == ExifTags.IFD.Makernote: + from .TiffImagePlugin import ImageFileDirectory_v2 + + if tag_data[:8] == b"FUJIFILM": + ifd_offset = i32le(tag_data, 8) + ifd_data = tag_data[ifd_offset:] + + makernote = {} + for i in range(0, struct.unpack(" 4: + (offset,) = struct.unpack("H", tag_data[:2])[0]): + ifd_tag, typ, count, data = struct.unpack( + ">HHL4s", tag_data[i * 12 + 2 : (i + 1) * 12 + 2] + ) + if ifd_tag == 0x1101: + # CameraInfo + (offset,) = struct.unpack(">L", data) + self.fp.seek(offset) + + camerainfo = {"ModelID": self.fp.read(4)} + + self.fp.read(4) + # Seconds since 2000 + camerainfo["TimeStamp"] = i32le(self.fp.read(12)) + + self.fp.read(4) + camerainfo["InternalSerialNumber"] = self.fp.read(4) + + self.fp.read(12) + parallax = self.fp.read(4) + handler = ImageFileDirectory_v2._load_dispatch[ + TiffTags.FLOAT + ][1] + camerainfo["Parallax"] = handler( + ImageFileDirectory_v2(), parallax, False + ) + + self.fp.read(4) + camerainfo["Category"] = self.fp.read(2) + + makernote = {0x1101: dict(self._fixup_dict(camerainfo))} + self._ifds[tag] = makernote + else: + # Interop + self._ifds[tag] = self._get_ifd_dict(tag_data, tag) + ifd = self._ifds.get(tag, {}) + if tag == ExifTags.IFD.Exif and self._hidden_data: + ifd = { + k: v + for (k, v) in ifd.items() + if k not in (ExifTags.IFD.Interop, ExifTags.IFD.Makernote) + } + return ifd + + def hide_offsets(self) -> None: + for tag in (ExifTags.IFD.Exif, ExifTags.IFD.GPSInfo): + if tag in self: + self._hidden_data[tag] = self[tag] + del self[tag] + + def __str__(self) -> str: + if self._info is not None: + # Load all keys into self._data + for tag in self._info: + self[tag] + + return str(self._data) + + def __len__(self) -> int: + keys = set(self._data) + if self._info is not None: + keys.update(self._info) + return len(keys) + + def __getitem__(self, tag): + if self._info is not None and tag not in self._data and tag in self._info: + self._data[tag] = self._fixup(self._info[tag]) + del self._info[tag] + return self._data[tag] + + def __contains__(self, tag) -> bool: + return tag in self._data or (self._info is not None and tag in self._info) + + def __setitem__(self, tag, value) -> None: + if self._info is not None and tag in self._info: + del self._info[tag] + self._data[tag] = value + + def __delitem__(self, tag: int) -> None: + if self._info is not None and tag in self._info: + del self._info[tag] + else: + del self._data[tag] + + def __iter__(self): + keys = set(self._data) + if self._info is not None: + keys.update(self._info) + return iter(keys) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageChops.py b/venv/lib/python3.10/site-packages/PIL/ImageChops.py new file mode 100644 index 00000000..29a5c995 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageChops.py @@ -0,0 +1,311 @@ +# +# The Python Imaging Library. +# $Id$ +# +# standard channel operations +# +# History: +# 1996-03-24 fl Created +# 1996-08-13 fl Added logical operations (for "1" images) +# 2000-10-12 fl Added offset method (from Image.py) +# +# Copyright (c) 1997-2000 by Secret Labs AB +# Copyright (c) 1996-2000 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# + +from __future__ import annotations + +from . import Image + + +def constant(image: Image.Image, value: int) -> Image.Image: + """Fill a channel with a given gray level. + + :rtype: :py:class:`~PIL.Image.Image` + """ + + return Image.new("L", image.size, value) + + +def duplicate(image: Image.Image) -> Image.Image: + """Copy a channel. Alias for :py:meth:`PIL.Image.Image.copy`. + + :rtype: :py:class:`~PIL.Image.Image` + """ + + return image.copy() + + +def invert(image: Image.Image) -> Image.Image: + """ + Invert an image (channel). :: + + out = MAX - image + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image.load() + return image._new(image.im.chop_invert()) + + +def lighter(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Compares the two images, pixel by pixel, and returns a new image containing + the lighter values. :: + + out = max(image1, image2) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_lighter(image2.im)) + + +def darker(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Compares the two images, pixel by pixel, and returns a new image containing + the darker values. :: + + out = min(image1, image2) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_darker(image2.im)) + + +def difference(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Returns the absolute value of the pixel-by-pixel difference between the two + images. :: + + out = abs(image1 - image2) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_difference(image2.im)) + + +def multiply(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Superimposes two images on top of each other. + + If you multiply an image with a solid black image, the result is black. If + you multiply with a solid white image, the image is unaffected. :: + + out = image1 * image2 / MAX + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_multiply(image2.im)) + + +def screen(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Superimposes two inverted images on top of each other. :: + + out = MAX - ((MAX - image1) * (MAX - image2) / MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_screen(image2.im)) + + +def soft_light(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Superimposes two images on top of each other using the Soft Light algorithm + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_soft_light(image2.im)) + + +def hard_light(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Superimposes two images on top of each other using the Hard Light algorithm + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_hard_light(image2.im)) + + +def overlay(image1: Image.Image, image2: Image.Image) -> Image.Image: + """ + Superimposes two images on top of each other using the Overlay algorithm + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_overlay(image2.im)) + + +def add( + image1: Image.Image, image2: Image.Image, scale: float = 1.0, offset: float = 0 +) -> Image.Image: + """ + Adds two images, dividing the result by scale and adding the + offset. If omitted, scale defaults to 1.0, and offset to 0.0. :: + + out = ((image1 + image2) / scale + offset) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_add(image2.im, scale, offset)) + + +def subtract( + image1: Image.Image, image2: Image.Image, scale: float = 1.0, offset: float = 0 +) -> Image.Image: + """ + Subtracts two images, dividing the result by scale and adding the offset. + If omitted, scale defaults to 1.0, and offset to 0.0. :: + + out = ((image1 - image2) / scale + offset) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_subtract(image2.im, scale, offset)) + + +def add_modulo(image1: Image.Image, image2: Image.Image) -> Image.Image: + """Add two images, without clipping the result. :: + + out = ((image1 + image2) % MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_add_modulo(image2.im)) + + +def subtract_modulo(image1: Image.Image, image2: Image.Image) -> Image.Image: + """Subtract two images, without clipping the result. :: + + out = ((image1 - image2) % MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_subtract_modulo(image2.im)) + + +def logical_and(image1: Image.Image, image2: Image.Image) -> Image.Image: + """Logical AND between two images. + + Both of the images must have mode "1". If you would like to perform a + logical AND on an image with a mode other than "1", try + :py:meth:`~PIL.ImageChops.multiply` instead, using a black-and-white mask + as the second image. :: + + out = ((image1 and image2) % MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_and(image2.im)) + + +def logical_or(image1: Image.Image, image2: Image.Image) -> Image.Image: + """Logical OR between two images. + + Both of the images must have mode "1". :: + + out = ((image1 or image2) % MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_or(image2.im)) + + +def logical_xor(image1: Image.Image, image2: Image.Image) -> Image.Image: + """Logical XOR between two images. + + Both of the images must have mode "1". :: + + out = ((bool(image1) != bool(image2)) % MAX) + + :rtype: :py:class:`~PIL.Image.Image` + """ + + image1.load() + image2.load() + return image1._new(image1.im.chop_xor(image2.im)) + + +def blend(image1: Image.Image, image2: Image.Image, alpha: float) -> Image.Image: + """Blend images using constant transparency weight. Alias for + :py:func:`PIL.Image.blend`. + + :rtype: :py:class:`~PIL.Image.Image` + """ + + return Image.blend(image1, image2, alpha) + + +def composite( + image1: Image.Image, image2: Image.Image, mask: Image.Image +) -> Image.Image: + """Create composite using transparency mask. Alias for + :py:func:`PIL.Image.composite`. + + :rtype: :py:class:`~PIL.Image.Image` + """ + + return Image.composite(image1, image2, mask) + + +def offset(image: Image.Image, xoffset: int, yoffset: int | None = None) -> Image.Image: + """Returns a copy of the image where data has been offset by the given + distances. Data wraps around the edges. If ``yoffset`` is omitted, it + is assumed to be equal to ``xoffset``. + + :param image: Input image. + :param xoffset: The horizontal distance. + :param yoffset: The vertical distance. If omitted, both + distances are set to the same value. + :rtype: :py:class:`~PIL.Image.Image` + """ + + if yoffset is None: + yoffset = xoffset + image.load() + return image._new(image.im.offset(xoffset, yoffset)) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageCms.py b/venv/lib/python3.10/site-packages/PIL/ImageCms.py new file mode 100644 index 00000000..3a45572a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageCms.py @@ -0,0 +1,1102 @@ +# The Python Imaging Library. +# $Id$ + +# Optional color management support, based on Kevin Cazabon's PyCMS +# library. + +# Originally released under LGPL. Graciously donated to PIL in +# March 2009, for distribution under the standard PIL license + +# History: + +# 2009-03-08 fl Added to PIL. + +# Copyright (C) 2002-2003 Kevin Cazabon +# Copyright (c) 2009 by Fredrik Lundh +# Copyright (c) 2013 by Eric Soroos + +# See the README file for information on usage and redistribution. See +# below for the original description. +from __future__ import annotations + +import operator +import sys +from enum import IntEnum, IntFlag +from functools import reduce +from typing import Any, Literal, SupportsFloat, SupportsInt, Union + +from . import Image, __version__ +from ._deprecate import deprecate +from ._typing import SupportsRead + +try: + from . import _imagingcms as core +except ImportError as ex: + # Allow error import for doc purposes, but error out when accessing + # anything in core. + from ._util import DeferredError + + core = DeferredError.new(ex) + +_DESCRIPTION = """ +pyCMS + + a Python / PIL interface to the littleCMS ICC Color Management System + Copyright (C) 2002-2003 Kevin Cazabon + kevin@cazabon.com + https://www.cazabon.com + + pyCMS home page: https://www.cazabon.com/pyCMS + littleCMS home page: https://www.littlecms.com + (littleCMS is Copyright (C) 1998-2001 Marti Maria) + + Originally released under LGPL. Graciously donated to PIL in + March 2009, for distribution under the standard PIL license + + The pyCMS.py module provides a "clean" interface between Python/PIL and + pyCMSdll, taking care of some of the more complex handling of the direct + pyCMSdll functions, as well as error-checking and making sure that all + relevant data is kept together. + + While it is possible to call pyCMSdll functions directly, it's not highly + recommended. + + Version History: + + 1.0.0 pil Oct 2013 Port to LCMS 2. + + 0.1.0 pil mod March 10, 2009 + + Renamed display profile to proof profile. The proof + profile is the profile of the device that is being + simulated, not the profile of the device which is + actually used to display/print the final simulation + (that'd be the output profile) - also see LCMSAPI.txt + input colorspace -> using 'renderingIntent' -> proof + colorspace -> using 'proofRenderingIntent' -> output + colorspace + + Added LCMS FLAGS support. + Added FLAGS["SOFTPROOFING"] as default flag for + buildProofTransform (otherwise the proof profile/intent + would be ignored). + + 0.1.0 pil March 2009 - added to PIL, as PIL.ImageCms + + 0.0.2 alpha Jan 6, 2002 + + Added try/except statements around type() checks of + potential CObjects... Python won't let you use type() + on them, and raises a TypeError (stupid, if you ask + me!) + + Added buildProofTransformFromOpenProfiles() function. + Additional fixes in DLL, see DLL code for details. + + 0.0.1 alpha first public release, Dec. 26, 2002 + + Known to-do list with current version (of Python interface, not pyCMSdll): + + none + +""" + +_VERSION = "1.0.0 pil" + + +def __getattr__(name: str) -> Any: + if name == "DESCRIPTION": + deprecate("PIL.ImageCms.DESCRIPTION", 12) + return _DESCRIPTION + elif name == "VERSION": + deprecate("PIL.ImageCms.VERSION", 12) + return _VERSION + elif name == "FLAGS": + deprecate("PIL.ImageCms.FLAGS", 12, "PIL.ImageCms.Flags") + return _FLAGS + msg = f"module '{__name__}' has no attribute '{name}'" + raise AttributeError(msg) + + +# --------------------------------------------------------------------. + + +# +# intent/direction values + + +class Intent(IntEnum): + PERCEPTUAL = 0 + RELATIVE_COLORIMETRIC = 1 + SATURATION = 2 + ABSOLUTE_COLORIMETRIC = 3 + + +class Direction(IntEnum): + INPUT = 0 + OUTPUT = 1 + PROOF = 2 + + +# +# flags + + +class Flags(IntFlag): + """Flags and documentation are taken from ``lcms2.h``.""" + + NONE = 0 + NOCACHE = 0x0040 + """Inhibit 1-pixel cache""" + NOOPTIMIZE = 0x0100 + """Inhibit optimizations""" + NULLTRANSFORM = 0x0200 + """Don't transform anyway""" + GAMUTCHECK = 0x1000 + """Out of Gamut alarm""" + SOFTPROOFING = 0x4000 + """Do softproofing""" + BLACKPOINTCOMPENSATION = 0x2000 + NOWHITEONWHITEFIXUP = 0x0004 + """Don't fix scum dot""" + HIGHRESPRECALC = 0x0400 + """Use more memory to give better accuracy""" + LOWRESPRECALC = 0x0800 + """Use less memory to minimize resources""" + # this should be 8BITS_DEVICELINK, but that is not a valid name in Python: + USE_8BITS_DEVICELINK = 0x0008 + """Create 8 bits devicelinks""" + GUESSDEVICECLASS = 0x0020 + """Guess device class (for ``transform2devicelink``)""" + KEEP_SEQUENCE = 0x0080 + """Keep profile sequence for devicelink creation""" + FORCE_CLUT = 0x0002 + """Force CLUT optimization""" + CLUT_POST_LINEARIZATION = 0x0001 + """create postlinearization tables if possible""" + CLUT_PRE_LINEARIZATION = 0x0010 + """create prelinearization tables if possible""" + NONEGATIVES = 0x8000 + """Prevent negative numbers in floating point transforms""" + COPY_ALPHA = 0x04000000 + """Alpha channels are copied on ``cmsDoTransform()``""" + NODEFAULTRESOURCEDEF = 0x01000000 + + _GRIDPOINTS_1 = 1 << 16 + _GRIDPOINTS_2 = 2 << 16 + _GRIDPOINTS_4 = 4 << 16 + _GRIDPOINTS_8 = 8 << 16 + _GRIDPOINTS_16 = 16 << 16 + _GRIDPOINTS_32 = 32 << 16 + _GRIDPOINTS_64 = 64 << 16 + _GRIDPOINTS_128 = 128 << 16 + + @staticmethod + def GRIDPOINTS(n: int) -> Flags: + """ + Fine-tune control over number of gridpoints + + :param n: :py:class:`int` in range ``0 <= n <= 255`` + """ + return Flags.NONE | ((n & 0xFF) << 16) + + +_MAX_FLAG = reduce(operator.or_, Flags) + + +_FLAGS = { + "MATRIXINPUT": 1, + "MATRIXOUTPUT": 2, + "MATRIXONLY": (1 | 2), + "NOWHITEONWHITEFIXUP": 4, # Don't hot fix scum dot + # Don't create prelinearization tables on precalculated transforms + # (internal use): + "NOPRELINEARIZATION": 16, + "GUESSDEVICECLASS": 32, # Guess device class (for transform2devicelink) + "NOTCACHE": 64, # Inhibit 1-pixel cache + "NOTPRECALC": 256, + "NULLTRANSFORM": 512, # Don't transform anyway + "HIGHRESPRECALC": 1024, # Use more memory to give better accuracy + "LOWRESPRECALC": 2048, # Use less memory to minimize resources + "WHITEBLACKCOMPENSATION": 8192, + "BLACKPOINTCOMPENSATION": 8192, + "GAMUTCHECK": 4096, # Out of Gamut alarm + "SOFTPROOFING": 16384, # Do softproofing + "PRESERVEBLACK": 32768, # Black preservation + "NODEFAULTRESOURCEDEF": 16777216, # CRD special + "GRIDPOINTS": lambda n: (n & 0xFF) << 16, # Gridpoints +} + + +# --------------------------------------------------------------------. +# Experimental PIL-level API +# --------------------------------------------------------------------. + +## +# Profile. + + +class ImageCmsProfile: + def __init__(self, profile: str | SupportsRead[bytes] | core.CmsProfile) -> None: + """ + :param profile: Either a string representing a filename, + a file like object containing a profile or a + low-level profile object + + """ + + if isinstance(profile, str): + if sys.platform == "win32": + profile_bytes_path = profile.encode() + try: + profile_bytes_path.decode("ascii") + except UnicodeDecodeError: + with open(profile, "rb") as f: + self._set(core.profile_frombytes(f.read())) + return + self._set(core.profile_open(profile), profile) + elif hasattr(profile, "read"): + self._set(core.profile_frombytes(profile.read())) + elif isinstance(profile, core.CmsProfile): + self._set(profile) + else: + msg = "Invalid type for Profile" # type: ignore[unreachable] + raise TypeError(msg) + + def _set(self, profile: core.CmsProfile, filename: str | None = None) -> None: + self.profile = profile + self.filename = filename + self.product_name = None # profile.product_name + self.product_info = None # profile.product_info + + def tobytes(self) -> bytes: + """ + Returns the profile in a format suitable for embedding in + saved images. + + :returns: a bytes object containing the ICC profile. + """ + + return core.profile_tobytes(self.profile) + + +class ImageCmsTransform(Image.ImagePointHandler): + """ + Transform. This can be used with the procedural API, or with the standard + :py:func:`~PIL.Image.Image.point` method. + + Will return the output profile in the ``output.info['icc_profile']``. + """ + + def __init__( + self, + input: ImageCmsProfile, + output: ImageCmsProfile, + input_mode: str, + output_mode: str, + intent: Intent = Intent.PERCEPTUAL, + proof: ImageCmsProfile | None = None, + proof_intent: Intent = Intent.ABSOLUTE_COLORIMETRIC, + flags: Flags = Flags.NONE, + ): + if proof is None: + self.transform = core.buildTransform( + input.profile, output.profile, input_mode, output_mode, intent, flags + ) + else: + self.transform = core.buildProofTransform( + input.profile, + output.profile, + proof.profile, + input_mode, + output_mode, + intent, + proof_intent, + flags, + ) + # Note: inputMode and outputMode are for pyCMS compatibility only + self.input_mode = self.inputMode = input_mode + self.output_mode = self.outputMode = output_mode + + self.output_profile = output + + def point(self, im: Image.Image) -> Image.Image: + return self.apply(im) + + def apply(self, im: Image.Image, imOut: Image.Image | None = None) -> Image.Image: + im.load() + if imOut is None: + imOut = Image.new(self.output_mode, im.size, None) + self.transform.apply(im.im.id, imOut.im.id) + imOut.info["icc_profile"] = self.output_profile.tobytes() + return imOut + + def apply_in_place(self, im: Image.Image) -> Image.Image: + im.load() + if im.mode != self.output_mode: + msg = "mode mismatch" + raise ValueError(msg) # wrong output mode + self.transform.apply(im.im.id, im.im.id) + im.info["icc_profile"] = self.output_profile.tobytes() + return im + + +def get_display_profile(handle: SupportsInt | None = None) -> ImageCmsProfile | None: + """ + (experimental) Fetches the profile for the current display device. + + :returns: ``None`` if the profile is not known. + """ + + if sys.platform != "win32": + return None + + from . import ImageWin # type: ignore[unused-ignore, unreachable] + + if isinstance(handle, ImageWin.HDC): + profile = core.get_display_profile_win32(int(handle), 1) + else: + profile = core.get_display_profile_win32(int(handle or 0)) + if profile is None: + return None + return ImageCmsProfile(profile) + + +# --------------------------------------------------------------------. +# pyCMS compatible layer +# --------------------------------------------------------------------. + +_CmsProfileCompatible = Union[ + str, SupportsRead[bytes], core.CmsProfile, ImageCmsProfile +] + + +class PyCMSError(Exception): + """(pyCMS) Exception class. + This is used for all errors in the pyCMS API.""" + + pass + + +def profileToProfile( + im: Image.Image, + inputProfile: _CmsProfileCompatible, + outputProfile: _CmsProfileCompatible, + renderingIntent: Intent = Intent.PERCEPTUAL, + outputMode: str | None = None, + inPlace: bool = False, + flags: Flags = Flags.NONE, +) -> Image.Image | None: + """ + (pyCMS) Applies an ICC transformation to a given image, mapping from + ``inputProfile`` to ``outputProfile``. + + If the input or output profiles specified are not valid filenames, a + :exc:`PyCMSError` will be raised. If ``inPlace`` is ``True`` and + ``outputMode != im.mode``, a :exc:`PyCMSError` will be raised. + If an error occurs during application of the profiles, + a :exc:`PyCMSError` will be raised. + If ``outputMode`` is not a mode supported by the ``outputProfile`` (or by pyCMS), + a :exc:`PyCMSError` will be raised. + + This function applies an ICC transformation to im from ``inputProfile``'s + color space to ``outputProfile``'s color space using the specified rendering + intent to decide how to handle out-of-gamut colors. + + ``outputMode`` can be used to specify that a color mode conversion is to + be done using these profiles, but the specified profiles must be able + to handle that mode. I.e., if converting im from RGB to CMYK using + profiles, the input profile must handle RGB data, and the output + profile must handle CMYK data. + + :param im: An open :py:class:`~PIL.Image.Image` object (i.e. Image.new(...) + or Image.open(...), etc.) + :param inputProfile: String, as a valid filename path to the ICC input + profile you wish to use for this image, or a profile object + :param outputProfile: String, as a valid filename path to the ICC output + profile you wish to use for this image, or a profile object + :param renderingIntent: Integer (0-3) specifying the rendering intent you + wish to use for the transform + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :param outputMode: A valid PIL mode for the output image (i.e. "RGB", + "CMYK", etc.). Note: if rendering the image "inPlace", outputMode + MUST be the same mode as the input, or omitted completely. If + omitted, the outputMode will be the same as the mode of the input + image (im.mode) + :param inPlace: Boolean. If ``True``, the original image is modified in-place, + and ``None`` is returned. If ``False`` (default), a new + :py:class:`~PIL.Image.Image` object is returned with the transform applied. + :param flags: Integer (0-...) specifying additional flags + :returns: Either None or a new :py:class:`~PIL.Image.Image` object, depending on + the value of ``inPlace`` + :exception PyCMSError: + """ + + if outputMode is None: + outputMode = im.mode + + if not isinstance(renderingIntent, int) or not (0 <= renderingIntent <= 3): + msg = "renderingIntent must be an integer between 0 and 3" + raise PyCMSError(msg) + + if not isinstance(flags, int) or not (0 <= flags <= _MAX_FLAG): + msg = f"flags must be an integer between 0 and {_MAX_FLAG}" + raise PyCMSError(msg) + + try: + if not isinstance(inputProfile, ImageCmsProfile): + inputProfile = ImageCmsProfile(inputProfile) + if not isinstance(outputProfile, ImageCmsProfile): + outputProfile = ImageCmsProfile(outputProfile) + transform = ImageCmsTransform( + inputProfile, + outputProfile, + im.mode, + outputMode, + renderingIntent, + flags=flags, + ) + if inPlace: + transform.apply_in_place(im) + imOut = None + else: + imOut = transform.apply(im) + except (OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + return imOut + + +def getOpenProfile( + profileFilename: str | SupportsRead[bytes] | core.CmsProfile, +) -> ImageCmsProfile: + """ + (pyCMS) Opens an ICC profile file. + + The PyCMSProfile object can be passed back into pyCMS for use in creating + transforms and such (as in ImageCms.buildTransformFromOpenProfiles()). + + If ``profileFilename`` is not a valid filename for an ICC profile, + a :exc:`PyCMSError` will be raised. + + :param profileFilename: String, as a valid filename path to the ICC profile + you wish to open, or a file-like object. + :returns: A CmsProfile class object. + :exception PyCMSError: + """ + + try: + return ImageCmsProfile(profileFilename) + except (OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def buildTransform( + inputProfile: _CmsProfileCompatible, + outputProfile: _CmsProfileCompatible, + inMode: str, + outMode: str, + renderingIntent: Intent = Intent.PERCEPTUAL, + flags: Flags = Flags.NONE, +) -> ImageCmsTransform: + """ + (pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the + ``outputProfile``. Use applyTransform to apply the transform to a given + image. + + If the input or output profiles specified are not valid filenames, a + :exc:`PyCMSError` will be raised. If an error occurs during creation + of the transform, a :exc:`PyCMSError` will be raised. + + If ``inMode`` or ``outMode`` are not a mode supported by the ``outputProfile`` + (or by pyCMS), a :exc:`PyCMSError` will be raised. + + This function builds and returns an ICC transform from the ``inputProfile`` + to the ``outputProfile`` using the ``renderingIntent`` to determine what to do + with out-of-gamut colors. It will ONLY work for converting images that + are in ``inMode`` to images that are in ``outMode`` color format (PIL mode, + i.e. "RGB", "RGBA", "CMYK", etc.). + + Building the transform is a fair part of the overhead in + ImageCms.profileToProfile(), so if you're planning on converting multiple + images using the same input/output settings, this can save you time. + Once you have a transform object, it can be used with + ImageCms.applyProfile() to convert images without the need to re-compute + the lookup table for the transform. + + The reason pyCMS returns a class object rather than a handle directly + to the transform is that it needs to keep track of the PIL input/output + modes that the transform is meant for. These attributes are stored in + the ``inMode`` and ``outMode`` attributes of the object (which can be + manually overridden if you really want to, but I don't know of any + time that would be of use, or would even work). + + :param inputProfile: String, as a valid filename path to the ICC input + profile you wish to use for this transform, or a profile object + :param outputProfile: String, as a valid filename path to the ICC output + profile you wish to use for this transform, or a profile object + :param inMode: String, as a valid PIL mode that the appropriate profile + also supports (i.e. "RGB", "RGBA", "CMYK", etc.) + :param outMode: String, as a valid PIL mode that the appropriate profile + also supports (i.e. "RGB", "RGBA", "CMYK", etc.) + :param renderingIntent: Integer (0-3) specifying the rendering intent you + wish to use for the transform + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :param flags: Integer (0-...) specifying additional flags + :returns: A CmsTransform class object. + :exception PyCMSError: + """ + + if not isinstance(renderingIntent, int) or not (0 <= renderingIntent <= 3): + msg = "renderingIntent must be an integer between 0 and 3" + raise PyCMSError(msg) + + if not isinstance(flags, int) or not (0 <= flags <= _MAX_FLAG): + msg = f"flags must be an integer between 0 and {_MAX_FLAG}" + raise PyCMSError(msg) + + try: + if not isinstance(inputProfile, ImageCmsProfile): + inputProfile = ImageCmsProfile(inputProfile) + if not isinstance(outputProfile, ImageCmsProfile): + outputProfile = ImageCmsProfile(outputProfile) + return ImageCmsTransform( + inputProfile, outputProfile, inMode, outMode, renderingIntent, flags=flags + ) + except (OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def buildProofTransform( + inputProfile: _CmsProfileCompatible, + outputProfile: _CmsProfileCompatible, + proofProfile: _CmsProfileCompatible, + inMode: str, + outMode: str, + renderingIntent: Intent = Intent.PERCEPTUAL, + proofRenderingIntent: Intent = Intent.ABSOLUTE_COLORIMETRIC, + flags: Flags = Flags.SOFTPROOFING, +) -> ImageCmsTransform: + """ + (pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the + ``outputProfile``, but tries to simulate the result that would be + obtained on the ``proofProfile`` device. + + If the input, output, or proof profiles specified are not valid + filenames, a :exc:`PyCMSError` will be raised. + + If an error occurs during creation of the transform, + a :exc:`PyCMSError` will be raised. + + If ``inMode`` or ``outMode`` are not a mode supported by the ``outputProfile`` + (or by pyCMS), a :exc:`PyCMSError` will be raised. + + This function builds and returns an ICC transform from the ``inputProfile`` + to the ``outputProfile``, but tries to simulate the result that would be + obtained on the ``proofProfile`` device using ``renderingIntent`` and + ``proofRenderingIntent`` to determine what to do with out-of-gamut + colors. This is known as "soft-proofing". It will ONLY work for + converting images that are in ``inMode`` to images that are in outMode + color format (PIL mode, i.e. "RGB", "RGBA", "CMYK", etc.). + + Usage of the resulting transform object is exactly the same as with + ImageCms.buildTransform(). + + Proof profiling is generally used when using an output device to get a + good idea of what the final printed/displayed image would look like on + the ``proofProfile`` device when it's quicker and easier to use the + output device for judging color. Generally, this means that the + output device is a monitor, or a dye-sub printer (etc.), and the simulated + device is something more expensive, complicated, or time consuming + (making it difficult to make a real print for color judgement purposes). + + Soft-proofing basically functions by adjusting the colors on the + output device to match the colors of the device being simulated. However, + when the simulated device has a much wider gamut than the output + device, you may obtain marginal results. + + :param inputProfile: String, as a valid filename path to the ICC input + profile you wish to use for this transform, or a profile object + :param outputProfile: String, as a valid filename path to the ICC output + (monitor, usually) profile you wish to use for this transform, or a + profile object + :param proofProfile: String, as a valid filename path to the ICC proof + profile you wish to use for this transform, or a profile object + :param inMode: String, as a valid PIL mode that the appropriate profile + also supports (i.e. "RGB", "RGBA", "CMYK", etc.) + :param outMode: String, as a valid PIL mode that the appropriate profile + also supports (i.e. "RGB", "RGBA", "CMYK", etc.) + :param renderingIntent: Integer (0-3) specifying the rendering intent you + wish to use for the input->proof (simulated) transform + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :param proofRenderingIntent: Integer (0-3) specifying the rendering intent + you wish to use for proof->output transform + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :param flags: Integer (0-...) specifying additional flags + :returns: A CmsTransform class object. + :exception PyCMSError: + """ + + if not isinstance(renderingIntent, int) or not (0 <= renderingIntent <= 3): + msg = "renderingIntent must be an integer between 0 and 3" + raise PyCMSError(msg) + + if not isinstance(flags, int) or not (0 <= flags <= _MAX_FLAG): + msg = f"flags must be an integer between 0 and {_MAX_FLAG}" + raise PyCMSError(msg) + + try: + if not isinstance(inputProfile, ImageCmsProfile): + inputProfile = ImageCmsProfile(inputProfile) + if not isinstance(outputProfile, ImageCmsProfile): + outputProfile = ImageCmsProfile(outputProfile) + if not isinstance(proofProfile, ImageCmsProfile): + proofProfile = ImageCmsProfile(proofProfile) + return ImageCmsTransform( + inputProfile, + outputProfile, + inMode, + outMode, + renderingIntent, + proofProfile, + proofRenderingIntent, + flags, + ) + except (OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +buildTransformFromOpenProfiles = buildTransform +buildProofTransformFromOpenProfiles = buildProofTransform + + +def applyTransform( + im: Image.Image, transform: ImageCmsTransform, inPlace: bool = False +) -> Image.Image | None: + """ + (pyCMS) Applies a transform to a given image. + + If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised. + + If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a + :exc:`PyCMSError` is raised. + + If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not + supported by pyCMSdll or the profiles you used for the transform, a + :exc:`PyCMSError` is raised. + + If an error occurs while the transform is being applied, + a :exc:`PyCMSError` is raised. + + This function applies a pre-calculated transform (from + ImageCms.buildTransform() or ImageCms.buildTransformFromOpenProfiles()) + to an image. The transform can be used for multiple images, saving + considerable calculation time if doing the same conversion multiple times. + + If you want to modify im in-place instead of receiving a new image as + the return value, set ``inPlace`` to ``True``. This can only be done if + ``transform.inMode`` and ``transform.outMode`` are the same, because we can't + change the mode in-place (the buffer sizes for some modes are + different). The default behavior is to return a new :py:class:`~PIL.Image.Image` + object of the same dimensions in mode ``transform.outMode``. + + :param im: An :py:class:`~PIL.Image.Image` object, and im.mode must be the same + as the ``inMode`` supported by the transform. + :param transform: A valid CmsTransform class object + :param inPlace: Bool. If ``True``, ``im`` is modified in place and ``None`` is + returned, if ``False``, a new :py:class:`~PIL.Image.Image` object with the + transform applied is returned (and ``im`` is not changed). The default is + ``False``. + :returns: Either ``None``, or a new :py:class:`~PIL.Image.Image` object, + depending on the value of ``inPlace``. The profile will be returned in + the image's ``info['icc_profile']``. + :exception PyCMSError: + """ + + try: + if inPlace: + transform.apply_in_place(im) + imOut = None + else: + imOut = transform.apply(im) + except (TypeError, ValueError) as v: + raise PyCMSError(v) from v + + return imOut + + +def createProfile( + colorSpace: Literal["LAB", "XYZ", "sRGB"], colorTemp: SupportsFloat = -1 +) -> core.CmsProfile: + """ + (pyCMS) Creates a profile. + + If colorSpace not in ``["LAB", "XYZ", "sRGB"]``, + a :exc:`PyCMSError` is raised. + + If using LAB and ``colorTemp`` is not a positive integer, + a :exc:`PyCMSError` is raised. + + If an error occurs while creating the profile, + a :exc:`PyCMSError` is raised. + + Use this function to create common profiles on-the-fly instead of + having to supply a profile on disk and knowing the path to it. It + returns a normal CmsProfile object that can be passed to + ImageCms.buildTransformFromOpenProfiles() to create a transform to apply + to images. + + :param colorSpace: String, the color space of the profile you wish to + create. + Currently only "LAB", "XYZ", and "sRGB" are supported. + :param colorTemp: Positive integer for the white point for the profile, in + degrees Kelvin (i.e. 5000, 6500, 9600, etc.). The default is for D50 + illuminant if omitted (5000k). colorTemp is ONLY applied to LAB + profiles, and is ignored for XYZ and sRGB. + :returns: A CmsProfile class object + :exception PyCMSError: + """ + + if colorSpace not in ["LAB", "XYZ", "sRGB"]: + msg = ( + f"Color space not supported for on-the-fly profile creation ({colorSpace})" + ) + raise PyCMSError(msg) + + if colorSpace == "LAB": + try: + colorTemp = float(colorTemp) + except (TypeError, ValueError) as e: + msg = f'Color temperature must be numeric, "{colorTemp}" not valid' + raise PyCMSError(msg) from e + + try: + return core.createProfile(colorSpace, colorTemp) + except (TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileName(profile: _CmsProfileCompatible) -> str: + """ + + (pyCMS) Gets the internal product name for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, + a :exc:`PyCMSError` is raised If an error occurs while trying + to obtain the name tag, a :exc:`PyCMSError` is raised. + + Use this function to obtain the INTERNAL name of the profile (stored + in an ICC tag in the profile itself), usually the one used when the + profile was originally created. Sometimes this tag also contains + additional information supplied by the creator. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal name of the profile as stored + in an ICC tag. + :exception PyCMSError: + """ + + try: + # add an extra newline to preserve pyCMS compatibility + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + # do it in python, not c. + # // name was "%s - %s" (model, manufacturer) || Description , + # // but if the Model and Manufacturer were the same or the model + # // was long, Just the model, in 1.x + model = profile.profile.model + manufacturer = profile.profile.manufacturer + + if not (model or manufacturer): + return (profile.profile.profile_description or "") + "\n" + if not manufacturer or len(model) > 30: # type: ignore[arg-type] + return model + "\n" # type: ignore[operator] + return f"{model} - {manufacturer}\n" + + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileInfo(profile: _CmsProfileCompatible) -> str: + """ + (pyCMS) Gets the internal product information for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, + a :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the info tag, + a :exc:`PyCMSError` is raised. + + Use this function to obtain the information stored in the profile's + info tag. This often contains details about the profile, and how it + was created, as supplied by the creator. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal profile information stored in + an ICC tag. + :exception PyCMSError: + """ + + try: + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + # add an extra newline to preserve pyCMS compatibility + # Python, not C. the white point bits weren't working well, + # so skipping. + # info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint + description = profile.profile.profile_description + cpright = profile.profile.copyright + elements = [element for element in (description, cpright) if element] + return "\r\n\r\n".join(elements) + "\r\n\r\n" + + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileCopyright(profile: _CmsProfileCompatible) -> str: + """ + (pyCMS) Gets the copyright for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, a + :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the copyright tag, + a :exc:`PyCMSError` is raised. + + Use this function to obtain the information stored in the profile's + copyright tag. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal profile information stored in + an ICC tag. + :exception PyCMSError: + """ + try: + # add an extra newline to preserve pyCMS compatibility + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + return (profile.profile.copyright or "") + "\n" + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileManufacturer(profile: _CmsProfileCompatible) -> str: + """ + (pyCMS) Gets the manufacturer for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, a + :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the manufacturer tag, a + :exc:`PyCMSError` is raised. + + Use this function to obtain the information stored in the profile's + manufacturer tag. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal profile information stored in + an ICC tag. + :exception PyCMSError: + """ + try: + # add an extra newline to preserve pyCMS compatibility + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + return (profile.profile.manufacturer or "") + "\n" + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileModel(profile: _CmsProfileCompatible) -> str: + """ + (pyCMS) Gets the model for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, a + :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the model tag, + a :exc:`PyCMSError` is raised. + + Use this function to obtain the information stored in the profile's + model tag. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal profile information stored in + an ICC tag. + :exception PyCMSError: + """ + + try: + # add an extra newline to preserve pyCMS compatibility + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + return (profile.profile.model or "") + "\n" + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getProfileDescription(profile: _CmsProfileCompatible) -> str: + """ + (pyCMS) Gets the description for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, a + :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the description tag, + a :exc:`PyCMSError` is raised. + + Use this function to obtain the information stored in the profile's + description tag. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: A string containing the internal profile information stored in an + ICC tag. + :exception PyCMSError: + """ + + try: + # add an extra newline to preserve pyCMS compatibility + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + return (profile.profile.profile_description or "") + "\n" + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def getDefaultIntent(profile: _CmsProfileCompatible) -> int: + """ + (pyCMS) Gets the default intent name for the given profile. + + If ``profile`` isn't a valid CmsProfile object or filename to a profile, a + :exc:`PyCMSError` is raised. + + If an error occurs while trying to obtain the default intent, a + :exc:`PyCMSError` is raised. + + Use this function to determine the default (and usually best optimized) + rendering intent for this profile. Most profiles support multiple + rendering intents, but are intended mostly for one type of conversion. + If you wish to use a different intent than returned, use + ImageCms.isIntentSupported() to verify it will work first. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :returns: Integer 0-3 specifying the default rendering intent for this + profile. + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :exception PyCMSError: + """ + + try: + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + return profile.profile.rendering_intent + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def isIntentSupported( + profile: _CmsProfileCompatible, intent: Intent, direction: Direction +) -> Literal[-1, 1]: + """ + (pyCMS) Checks if a given intent is supported. + + Use this function to verify that you can use your desired + ``intent`` with ``profile``, and that ``profile`` can be used for the + input/output/proof profile as you desire. + + Some profiles are created specifically for one "direction", can cannot + be used for others. Some profiles can only be used for certain + rendering intents, so it's best to either verify this before trying + to create a transform with them (using this function), or catch the + potential :exc:`PyCMSError` that will occur if they don't + support the modes you select. + + :param profile: EITHER a valid CmsProfile object, OR a string of the + filename of an ICC profile. + :param intent: Integer (0-3) specifying the rendering intent you wish to + use with this profile + + ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) + ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 + ImageCms.Intent.SATURATION = 2 + ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 + + see the pyCMS documentation for details on rendering intents and what + they do. + :param direction: Integer specifying if the profile is to be used for + input, output, or proof + + INPUT = 0 (or use ImageCms.Direction.INPUT) + OUTPUT = 1 (or use ImageCms.Direction.OUTPUT) + PROOF = 2 (or use ImageCms.Direction.PROOF) + + :returns: 1 if the intent/direction are supported, -1 if they are not. + :exception PyCMSError: + """ + + try: + if not isinstance(profile, ImageCmsProfile): + profile = ImageCmsProfile(profile) + # FIXME: I get different results for the same data w. different + # compilers. Bug in LittleCMS or in the binding? + if profile.profile.is_intent_supported(intent, direction): + return 1 + else: + return -1 + except (AttributeError, OSError, TypeError, ValueError) as v: + raise PyCMSError(v) from v + + +def versions() -> tuple[str, str, str, str]: + """ + (pyCMS) Fetches versions. + """ + + deprecate( + "PIL.ImageCms.versions()", + 12, + '(PIL.features.version("littlecms2"), sys.version, PIL.__version__)', + ) + return _VERSION, core.littlecms_version, sys.version.split()[0], __version__ diff --git a/venv/lib/python3.10/site-packages/PIL/ImageColor.py b/venv/lib/python3.10/site-packages/PIL/ImageColor.py new file mode 100644 index 00000000..5fb80b75 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageColor.py @@ -0,0 +1,317 @@ +# +# The Python Imaging Library +# $Id$ +# +# map CSS3-style colour description strings to RGB +# +# History: +# 2002-10-24 fl Added support for CSS-style color strings +# 2002-12-15 fl Added RGBA support +# 2004-03-27 fl Fixed remaining int() problems for Python 1.5.2 +# 2004-07-19 fl Fixed gray/grey spelling issues +# 2009-03-05 fl Fixed rounding error in grayscale calculation +# +# Copyright (c) 2002-2004 by Secret Labs AB +# Copyright (c) 2002-2004 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import re +from functools import lru_cache + +from . import Image + + +@lru_cache +def getrgb(color): + """ + Convert a color string to an RGB or RGBA tuple. If the string cannot be + parsed, this function raises a :py:exc:`ValueError` exception. + + .. versionadded:: 1.1.4 + + :param color: A color string + :return: ``(red, green, blue[, alpha])`` + """ + if len(color) > 100: + msg = "color specifier is too long" + raise ValueError(msg) + color = color.lower() + + rgb = colormap.get(color, None) + if rgb: + if isinstance(rgb, tuple): + return rgb + colormap[color] = rgb = getrgb(rgb) + return rgb + + # check for known string formats + if re.match("#[a-f0-9]{3}$", color): + return int(color[1] * 2, 16), int(color[2] * 2, 16), int(color[3] * 2, 16) + + if re.match("#[a-f0-9]{4}$", color): + return ( + int(color[1] * 2, 16), + int(color[2] * 2, 16), + int(color[3] * 2, 16), + int(color[4] * 2, 16), + ) + + if re.match("#[a-f0-9]{6}$", color): + return int(color[1:3], 16), int(color[3:5], 16), int(color[5:7], 16) + + if re.match("#[a-f0-9]{8}$", color): + return ( + int(color[1:3], 16), + int(color[3:5], 16), + int(color[5:7], 16), + int(color[7:9], 16), + ) + + m = re.match(r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color) + if m: + return int(m.group(1)), int(m.group(2)), int(m.group(3)) + + m = re.match(r"rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color) + if m: + return ( + int((int(m.group(1)) * 255) / 100.0 + 0.5), + int((int(m.group(2)) * 255) / 100.0 + 0.5), + int((int(m.group(3)) * 255) / 100.0 + 0.5), + ) + + m = re.match( + r"hsl\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color + ) + if m: + from colorsys import hls_to_rgb + + rgb = hls_to_rgb( + float(m.group(1)) / 360.0, + float(m.group(3)) / 100.0, + float(m.group(2)) / 100.0, + ) + return ( + int(rgb[0] * 255 + 0.5), + int(rgb[1] * 255 + 0.5), + int(rgb[2] * 255 + 0.5), + ) + + m = re.match( + r"hs[bv]\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color + ) + if m: + from colorsys import hsv_to_rgb + + rgb = hsv_to_rgb( + float(m.group(1)) / 360.0, + float(m.group(2)) / 100.0, + float(m.group(3)) / 100.0, + ) + return ( + int(rgb[0] * 255 + 0.5), + int(rgb[1] * 255 + 0.5), + int(rgb[2] * 255 + 0.5), + ) + + m = re.match(r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color) + if m: + return int(m.group(1)), int(m.group(2)), int(m.group(3)), int(m.group(4)) + msg = f"unknown color specifier: {repr(color)}" + raise ValueError(msg) + + +@lru_cache +def getcolor(color, mode: str) -> tuple[int, ...]: + """ + Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if + ``mode`` is HSV, converts the RGB value to a HSV value, or if ``mode`` is + not color or a palette image, converts the RGB value to a grayscale value. + If the string cannot be parsed, this function raises a :py:exc:`ValueError` + exception. + + .. versionadded:: 1.1.4 + + :param color: A color string + :param mode: Convert result to this mode + :return: ``(graylevel[, alpha]) or (red, green, blue[, alpha])`` + """ + # same as getrgb, but converts the result to the given mode + color, alpha = getrgb(color), 255 + if len(color) == 4: + color, alpha = color[:3], color[3] + + if mode == "HSV": + from colorsys import rgb_to_hsv + + r, g, b = color + h, s, v = rgb_to_hsv(r / 255, g / 255, b / 255) + return int(h * 255), int(s * 255), int(v * 255) + elif Image.getmodebase(mode) == "L": + r, g, b = color + # ITU-R Recommendation 601-2 for nonlinear RGB + # scaled to 24 bits to match the convert's implementation. + color = (r * 19595 + g * 38470 + b * 7471 + 0x8000) >> 16 + if mode[-1] == "A": + return color, alpha + else: + if mode[-1] == "A": + return color + (alpha,) + return color + + +colormap = { + # X11 colour table from https://drafts.csswg.org/css-color-4/, with + # gray/grey spelling issues fixed. This is a superset of HTML 4.0 + # colour names used in CSS 1. + "aliceblue": "#f0f8ff", + "antiquewhite": "#faebd7", + "aqua": "#00ffff", + "aquamarine": "#7fffd4", + "azure": "#f0ffff", + "beige": "#f5f5dc", + "bisque": "#ffe4c4", + "black": "#000000", + "blanchedalmond": "#ffebcd", + "blue": "#0000ff", + "blueviolet": "#8a2be2", + "brown": "#a52a2a", + "burlywood": "#deb887", + "cadetblue": "#5f9ea0", + "chartreuse": "#7fff00", + "chocolate": "#d2691e", + "coral": "#ff7f50", + "cornflowerblue": "#6495ed", + "cornsilk": "#fff8dc", + "crimson": "#dc143c", + "cyan": "#00ffff", + "darkblue": "#00008b", + "darkcyan": "#008b8b", + "darkgoldenrod": "#b8860b", + "darkgray": "#a9a9a9", + "darkgrey": "#a9a9a9", + "darkgreen": "#006400", + "darkkhaki": "#bdb76b", + "darkmagenta": "#8b008b", + "darkolivegreen": "#556b2f", + "darkorange": "#ff8c00", + "darkorchid": "#9932cc", + "darkred": "#8b0000", + "darksalmon": "#e9967a", + "darkseagreen": "#8fbc8f", + "darkslateblue": "#483d8b", + "darkslategray": "#2f4f4f", + "darkslategrey": "#2f4f4f", + "darkturquoise": "#00ced1", + "darkviolet": "#9400d3", + "deeppink": "#ff1493", + "deepskyblue": "#00bfff", + "dimgray": "#696969", + "dimgrey": "#696969", + "dodgerblue": "#1e90ff", + "firebrick": "#b22222", + "floralwhite": "#fffaf0", + "forestgreen": "#228b22", + "fuchsia": "#ff00ff", + "gainsboro": "#dcdcdc", + "ghostwhite": "#f8f8ff", + "gold": "#ffd700", + "goldenrod": "#daa520", + "gray": "#808080", + "grey": "#808080", + "green": "#008000", + "greenyellow": "#adff2f", + "honeydew": "#f0fff0", + "hotpink": "#ff69b4", + "indianred": "#cd5c5c", + "indigo": "#4b0082", + "ivory": "#fffff0", + "khaki": "#f0e68c", + "lavender": "#e6e6fa", + "lavenderblush": "#fff0f5", + "lawngreen": "#7cfc00", + "lemonchiffon": "#fffacd", + "lightblue": "#add8e6", + "lightcoral": "#f08080", + "lightcyan": "#e0ffff", + "lightgoldenrodyellow": "#fafad2", + "lightgreen": "#90ee90", + "lightgray": "#d3d3d3", + "lightgrey": "#d3d3d3", + "lightpink": "#ffb6c1", + "lightsalmon": "#ffa07a", + "lightseagreen": "#20b2aa", + "lightskyblue": "#87cefa", + "lightslategray": "#778899", + "lightslategrey": "#778899", + "lightsteelblue": "#b0c4de", + "lightyellow": "#ffffe0", + "lime": "#00ff00", + "limegreen": "#32cd32", + "linen": "#faf0e6", + "magenta": "#ff00ff", + "maroon": "#800000", + "mediumaquamarine": "#66cdaa", + "mediumblue": "#0000cd", + "mediumorchid": "#ba55d3", + "mediumpurple": "#9370db", + "mediumseagreen": "#3cb371", + "mediumslateblue": "#7b68ee", + "mediumspringgreen": "#00fa9a", + "mediumturquoise": "#48d1cc", + "mediumvioletred": "#c71585", + "midnightblue": "#191970", + "mintcream": "#f5fffa", + "mistyrose": "#ffe4e1", + "moccasin": "#ffe4b5", + "navajowhite": "#ffdead", + "navy": "#000080", + "oldlace": "#fdf5e6", + "olive": "#808000", + "olivedrab": "#6b8e23", + "orange": "#ffa500", + "orangered": "#ff4500", + "orchid": "#da70d6", + "palegoldenrod": "#eee8aa", + "palegreen": "#98fb98", + "paleturquoise": "#afeeee", + "palevioletred": "#db7093", + "papayawhip": "#ffefd5", + "peachpuff": "#ffdab9", + "peru": "#cd853f", + "pink": "#ffc0cb", + "plum": "#dda0dd", + "powderblue": "#b0e0e6", + "purple": "#800080", + "rebeccapurple": "#663399", + "red": "#ff0000", + "rosybrown": "#bc8f8f", + "royalblue": "#4169e1", + "saddlebrown": "#8b4513", + "salmon": "#fa8072", + "sandybrown": "#f4a460", + "seagreen": "#2e8b57", + "seashell": "#fff5ee", + "sienna": "#a0522d", + "silver": "#c0c0c0", + "skyblue": "#87ceeb", + "slateblue": "#6a5acd", + "slategray": "#708090", + "slategrey": "#708090", + "snow": "#fffafa", + "springgreen": "#00ff7f", + "steelblue": "#4682b4", + "tan": "#d2b48c", + "teal": "#008080", + "thistle": "#d8bfd8", + "tomato": "#ff6347", + "turquoise": "#40e0d0", + "violet": "#ee82ee", + "wheat": "#f5deb3", + "white": "#ffffff", + "whitesmoke": "#f5f5f5", + "yellow": "#ffff00", + "yellowgreen": "#9acd32", +} diff --git a/venv/lib/python3.10/site-packages/PIL/ImageDraw.py b/venv/lib/python3.10/site-packages/PIL/ImageDraw.py new file mode 100644 index 00000000..d3efe648 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageDraw.py @@ -0,0 +1,1087 @@ +# +# The Python Imaging Library +# $Id$ +# +# drawing interface operations +# +# History: +# 1996-04-13 fl Created (experimental) +# 1996-08-07 fl Filled polygons, ellipses. +# 1996-08-13 fl Added text support +# 1998-06-28 fl Handle I and F images +# 1998-12-29 fl Added arc; use arc primitive to draw ellipses +# 1999-01-10 fl Added shape stuff (experimental) +# 1999-02-06 fl Added bitmap support +# 1999-02-11 fl Changed all primitives to take options +# 1999-02-20 fl Fixed backwards compatibility +# 2000-10-12 fl Copy on write, when necessary +# 2001-02-18 fl Use default ink for bitmap/text also in fill mode +# 2002-10-24 fl Added support for CSS-style color strings +# 2002-12-10 fl Added experimental support for RGBA-on-RGB drawing +# 2002-12-11 fl Refactored low-level drawing API (work in progress) +# 2004-08-26 fl Made Draw() a factory function, added getdraw() support +# 2004-09-04 fl Added width support to line primitive +# 2004-09-10 fl Added font mode handling +# 2006-06-19 fl Added font bearing support (getmask2) +# +# Copyright (c) 1997-2006 by Secret Labs AB +# Copyright (c) 1996-2006 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import math +import numbers +import struct +from typing import Sequence, cast + +from . import Image, ImageColor +from ._typing import Coords + +""" +A simple 2D drawing interface for PIL images. +

+Application code should use the Draw factory, instead of +directly. +""" + + +class ImageDraw: + font = None + + def __init__(self, im: Image.Image, mode: str | None = None) -> None: + """ + Create a drawing instance. + + :param im: The image to draw in. + :param mode: Optional mode to use for color values. For RGB + images, this argument can be RGB or RGBA (to blend the + drawing into the image). For all other modes, this argument + must be the same as the image mode. If omitted, the mode + defaults to the mode of the image. + """ + im.load() + if im.readonly: + im._copy() # make it writeable + blend = 0 + if mode is None: + mode = im.mode + if mode != im.mode: + if mode == "RGBA" and im.mode == "RGB": + blend = 1 + else: + msg = "mode mismatch" + raise ValueError(msg) + if mode == "P": + self.palette = im.palette + else: + self.palette = None + self._image = im + self.im = im.im + self.draw = Image.core.draw(self.im, blend) + self.mode = mode + if mode in ("I", "F"): + self.ink = self.draw.draw_ink(1) + else: + self.ink = self.draw.draw_ink(-1) + if mode in ("1", "P", "I", "F"): + # FIXME: fix Fill2 to properly support matte for I+F images + self.fontmode = "1" + else: + self.fontmode = "L" # aliasing is okay for other modes + self.fill = False + + def getfont(self): + """ + Get the current default font. + + To set the default font for this ImageDraw instance:: + + from PIL import ImageDraw, ImageFont + draw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + + To set the default font for all future ImageDraw instances:: + + from PIL import ImageDraw, ImageFont + ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + + If the current default font is ``None``, + it is initialized with ``ImageFont.load_default()``. + + :returns: An image font.""" + if not self.font: + # FIXME: should add a font repository + from . import ImageFont + + self.font = ImageFont.load_default() + return self.font + + def _getfont(self, font_size: float | None): + if font_size is not None: + from . import ImageFont + + font = ImageFont.load_default(font_size) + else: + font = self.getfont() + return font + + def _getink(self, ink, fill=None) -> tuple[int | None, int | None]: + if ink is None and fill is None: + if self.fill: + fill = self.ink + else: + ink = self.ink + else: + if ink is not None: + if isinstance(ink, str): + ink = ImageColor.getcolor(ink, self.mode) + if self.palette and not isinstance(ink, numbers.Number): + ink = self.palette.getcolor(ink, self._image) + ink = self.draw.draw_ink(ink) + if fill is not None: + if isinstance(fill, str): + fill = ImageColor.getcolor(fill, self.mode) + if self.palette and not isinstance(fill, numbers.Number): + fill = self.palette.getcolor(fill, self._image) + fill = self.draw.draw_ink(fill) + return ink, fill + + def arc(self, xy: Coords, start, end, fill=None, width=1) -> None: + """Draw an arc.""" + ink, fill = self._getink(fill) + if ink is not None: + self.draw.draw_arc(xy, start, end, ink, width) + + def bitmap(self, xy: Sequence[int], bitmap, fill=None) -> None: + """Draw a bitmap.""" + bitmap.load() + ink, fill = self._getink(fill) + if ink is None: + ink = fill + if ink is not None: + self.draw.draw_bitmap(xy, bitmap.im, ink) + + def chord(self, xy: Coords, start, end, fill=None, outline=None, width=1) -> None: + """Draw a chord.""" + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_chord(xy, start, end, fill, 1) + if ink is not None and ink != fill and width != 0: + self.draw.draw_chord(xy, start, end, ink, 0, width) + + def ellipse(self, xy: Coords, fill=None, outline=None, width=1) -> None: + """Draw an ellipse.""" + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_ellipse(xy, fill, 1) + if ink is not None and ink != fill and width != 0: + self.draw.draw_ellipse(xy, ink, 0, width) + + def line(self, xy: Coords, fill=None, width=0, joint=None) -> None: + """Draw a line, or a connected sequence of line segments.""" + ink = self._getink(fill)[0] + if ink is not None: + self.draw.draw_lines(xy, ink, width) + if joint == "curve" and width > 4: + points: Sequence[Sequence[float]] + if isinstance(xy[0], (list, tuple)): + points = cast(Sequence[Sequence[float]], xy) + else: + points = [ + cast(Sequence[float], tuple(xy[i : i + 2])) + for i in range(0, len(xy), 2) + ] + for i in range(1, len(points) - 1): + point = points[i] + angles = [ + math.degrees(math.atan2(end[0] - start[0], start[1] - end[1])) + % 360 + for start, end in ( + (points[i - 1], point), + (point, points[i + 1]), + ) + ] + if angles[0] == angles[1]: + # This is a straight line, so no joint is required + continue + + def coord_at_angle(coord, angle): + x, y = coord + angle -= 90 + distance = width / 2 - 1 + return tuple( + p + (math.floor(p_d) if p_d > 0 else math.ceil(p_d)) + for p, p_d in ( + (x, distance * math.cos(math.radians(angle))), + (y, distance * math.sin(math.radians(angle))), + ) + ) + + flipped = ( + angles[1] > angles[0] and angles[1] - 180 > angles[0] + ) or (angles[1] < angles[0] and angles[1] + 180 > angles[0]) + coords = [ + (point[0] - width / 2 + 1, point[1] - width / 2 + 1), + (point[0] + width / 2 - 1, point[1] + width / 2 - 1), + ] + if flipped: + start, end = (angles[1] + 90, angles[0] + 90) + else: + start, end = (angles[0] - 90, angles[1] - 90) + self.pieslice(coords, start - 90, end - 90, fill) + + if width > 8: + # Cover potential gaps between the line and the joint + if flipped: + gap_coords = [ + coord_at_angle(point, angles[0] + 90), + point, + coord_at_angle(point, angles[1] + 90), + ] + else: + gap_coords = [ + coord_at_angle(point, angles[0] - 90), + point, + coord_at_angle(point, angles[1] - 90), + ] + self.line(gap_coords, fill, width=3) + + def shape(self, shape, fill=None, outline=None) -> None: + """(Experimental) Draw a shape.""" + shape.close() + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_outline(shape, fill, 1) + if ink is not None and ink != fill: + self.draw.draw_outline(shape, ink, 0) + + def pieslice( + self, xy: Coords, start, end, fill=None, outline=None, width=1 + ) -> None: + """Draw a pieslice.""" + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_pieslice(xy, start, end, fill, 1) + if ink is not None and ink != fill and width != 0: + self.draw.draw_pieslice(xy, start, end, ink, 0, width) + + def point(self, xy: Coords, fill=None) -> None: + """Draw one or more individual pixels.""" + ink, fill = self._getink(fill) + if ink is not None: + self.draw.draw_points(xy, ink) + + def polygon(self, xy: Coords, fill=None, outline=None, width=1) -> None: + """Draw a polygon.""" + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_polygon(xy, fill, 1) + if ink is not None and ink != fill and width != 0: + if width == 1: + self.draw.draw_polygon(xy, ink, 0, width) + elif self.im is not None: + # To avoid expanding the polygon outwards, + # use the fill as a mask + mask = Image.new("1", self.im.size) + mask_ink = self._getink(1)[0] + + fill_im = mask.copy() + draw = Draw(fill_im) + draw.draw.draw_polygon(xy, mask_ink, 1) + + ink_im = mask.copy() + draw = Draw(ink_im) + width = width * 2 - 1 + draw.draw.draw_polygon(xy, mask_ink, 0, width) + + mask.paste(ink_im, mask=fill_im) + + im = Image.new(self.mode, self.im.size) + draw = Draw(im) + draw.draw.draw_polygon(xy, ink, 0, width) + self.im.paste(im.im, (0, 0) + im.size, mask.im) + + def regular_polygon( + self, bounding_circle, n_sides, rotation=0, fill=None, outline=None, width=1 + ) -> None: + """Draw a regular polygon.""" + xy = _compute_regular_polygon_vertices(bounding_circle, n_sides, rotation) + self.polygon(xy, fill, outline, width) + + def rectangle(self, xy: Coords, fill=None, outline=None, width=1) -> None: + """Draw a rectangle.""" + ink, fill = self._getink(outline, fill) + if fill is not None: + self.draw.draw_rectangle(xy, fill, 1) + if ink is not None and ink != fill and width != 0: + self.draw.draw_rectangle(xy, ink, 0, width) + + def rounded_rectangle( + self, xy: Coords, radius=0, fill=None, outline=None, width=1, *, corners=None + ) -> None: + """Draw a rounded rectangle.""" + if isinstance(xy[0], (list, tuple)): + (x0, y0), (x1, y1) = cast(Sequence[Sequence[float]], xy) + else: + x0, y0, x1, y1 = cast(Sequence[float], xy) + if x1 < x0: + msg = "x1 must be greater than or equal to x0" + raise ValueError(msg) + if y1 < y0: + msg = "y1 must be greater than or equal to y0" + raise ValueError(msg) + if corners is None: + corners = (True, True, True, True) + + d = radius * 2 + + x0 = round(x0) + y0 = round(y0) + x1 = round(x1) + y1 = round(y1) + full_x, full_y = False, False + if all(corners): + full_x = d >= x1 - x0 - 1 + if full_x: + # The two left and two right corners are joined + d = x1 - x0 + full_y = d >= y1 - y0 - 1 + if full_y: + # The two top and two bottom corners are joined + d = y1 - y0 + if full_x and full_y: + # If all corners are joined, that is a circle + return self.ellipse(xy, fill, outline, width) + + if d == 0 or not any(corners): + # If the corners have no curve, + # or there are no corners, + # that is a rectangle + return self.rectangle(xy, fill, outline, width) + + r = d // 2 + ink, fill = self._getink(outline, fill) + + def draw_corners(pieslice) -> None: + parts: tuple[tuple[tuple[float, float, float, float], int, int], ...] + if full_x: + # Draw top and bottom halves + parts = ( + ((x0, y0, x0 + d, y0 + d), 180, 360), + ((x0, y1 - d, x0 + d, y1), 0, 180), + ) + elif full_y: + # Draw left and right halves + parts = ( + ((x0, y0, x0 + d, y0 + d), 90, 270), + ((x1 - d, y0, x1, y0 + d), 270, 90), + ) + else: + # Draw four separate corners + parts = tuple( + part + for i, part in enumerate( + ( + ((x0, y0, x0 + d, y0 + d), 180, 270), + ((x1 - d, y0, x1, y0 + d), 270, 360), + ((x1 - d, y1 - d, x1, y1), 0, 90), + ((x0, y1 - d, x0 + d, y1), 90, 180), + ) + ) + if corners[i] + ) + for part in parts: + if pieslice: + self.draw.draw_pieslice(*(part + (fill, 1))) + else: + self.draw.draw_arc(*(part + (ink, width))) + + if fill is not None: + draw_corners(True) + + if full_x: + self.draw.draw_rectangle((x0, y0 + r + 1, x1, y1 - r - 1), fill, 1) + else: + self.draw.draw_rectangle((x0 + r + 1, y0, x1 - r - 1, y1), fill, 1) + if not full_x and not full_y: + left = [x0, y0, x0 + r, y1] + if corners[0]: + left[1] += r + 1 + if corners[3]: + left[3] -= r + 1 + self.draw.draw_rectangle(left, fill, 1) + + right = [x1 - r, y0, x1, y1] + if corners[1]: + right[1] += r + 1 + if corners[2]: + right[3] -= r + 1 + self.draw.draw_rectangle(right, fill, 1) + if ink is not None and ink != fill and width != 0: + draw_corners(False) + + if not full_x: + top = [x0, y0, x1, y0 + width - 1] + if corners[0]: + top[0] += r + 1 + if corners[1]: + top[2] -= r + 1 + self.draw.draw_rectangle(top, ink, 1) + + bottom = [x0, y1 - width + 1, x1, y1] + if corners[3]: + bottom[0] += r + 1 + if corners[2]: + bottom[2] -= r + 1 + self.draw.draw_rectangle(bottom, ink, 1) + if not full_y: + left = [x0, y0, x0 + width - 1, y1] + if corners[0]: + left[1] += r + 1 + if corners[3]: + left[3] -= r + 1 + self.draw.draw_rectangle(left, ink, 1) + + right = [x1 - width + 1, y0, x1, y1] + if corners[1]: + right[1] += r + 1 + if corners[2]: + right[3] -= r + 1 + self.draw.draw_rectangle(right, ink, 1) + + def _multiline_check(self, text) -> bool: + split_character = "\n" if isinstance(text, str) else b"\n" + + return split_character in text + + def _multiline_split(self, text) -> list[str | bytes]: + split_character = "\n" if isinstance(text, str) else b"\n" + + return text.split(split_character) + + def _multiline_spacing(self, font, spacing, stroke_width): + return ( + self.textbbox((0, 0), "A", font, stroke_width=stroke_width)[3] + + stroke_width + + spacing + ) + + def text( + self, + xy, + text, + fill=None, + font=None, + anchor=None, + spacing=4, + align="left", + direction=None, + features=None, + language=None, + stroke_width=0, + stroke_fill=None, + embedded_color=False, + *args, + **kwargs, + ) -> None: + """Draw text.""" + if embedded_color and self.mode not in ("RGB", "RGBA"): + msg = "Embedded color supported only in RGB and RGBA modes" + raise ValueError(msg) + + if font is None: + font = self._getfont(kwargs.get("font_size")) + + if self._multiline_check(text): + return self.multiline_text( + xy, + text, + fill, + font, + anchor, + spacing, + align, + direction, + features, + language, + stroke_width, + stroke_fill, + embedded_color, + ) + + def getink(fill): + ink, fill = self._getink(fill) + if ink is None: + return fill + return ink + + def draw_text(ink, stroke_width=0, stroke_offset=None) -> None: + mode = self.fontmode + if stroke_width == 0 and embedded_color: + mode = "RGBA" + coord = [] + start = [] + for i in range(2): + coord.append(int(xy[i])) + start.append(math.modf(xy[i])[0]) + try: + mask, offset = font.getmask2( + text, + mode, + direction=direction, + features=features, + language=language, + stroke_width=stroke_width, + anchor=anchor, + ink=ink, + start=start, + *args, + **kwargs, + ) + coord = [coord[0] + offset[0], coord[1] + offset[1]] + except AttributeError: + try: + mask = font.getmask( + text, + mode, + direction, + features, + language, + stroke_width, + anchor, + ink, + start=start, + *args, + **kwargs, + ) + except TypeError: + mask = font.getmask(text) + if stroke_offset: + coord = [coord[0] + stroke_offset[0], coord[1] + stroke_offset[1]] + if mode == "RGBA": + # font.getmask2(mode="RGBA") returns color in RGB bands and mask in A + # extract mask and set text alpha + color, mask = mask, mask.getband(3) + ink_alpha = struct.pack("i", ink)[3] + color.fillband(3, ink_alpha) + x, y = coord + if self.im is not None: + self.im.paste( + color, (x, y, x + mask.size[0], y + mask.size[1]), mask + ) + else: + self.draw.draw_bitmap(coord, mask, ink) + + ink = getink(fill) + if ink is not None: + stroke_ink = None + if stroke_width: + stroke_ink = getink(stroke_fill) if stroke_fill is not None else ink + + if stroke_ink is not None: + # Draw stroked text + draw_text(stroke_ink, stroke_width) + + # Draw normal text + draw_text(ink, 0) + else: + # Only draw normal text + draw_text(ink) + + def multiline_text( + self, + xy, + text, + fill=None, + font=None, + anchor=None, + spacing=4, + align="left", + direction=None, + features=None, + language=None, + stroke_width=0, + stroke_fill=None, + embedded_color=False, + *, + font_size=None, + ) -> None: + if direction == "ttb": + msg = "ttb direction is unsupported for multiline text" + raise ValueError(msg) + + if anchor is None: + anchor = "la" + elif len(anchor) != 2: + msg = "anchor must be a 2 character string" + raise ValueError(msg) + elif anchor[1] in "tb": + msg = "anchor not supported for multiline text" + raise ValueError(msg) + + if font is None: + font = self._getfont(font_size) + + widths = [] + max_width = 0 + lines = self._multiline_split(text) + line_spacing = self._multiline_spacing(font, spacing, stroke_width) + for line in lines: + line_width = self.textlength( + line, font, direction=direction, features=features, language=language + ) + widths.append(line_width) + max_width = max(max_width, line_width) + + top = xy[1] + if anchor[1] == "m": + top -= (len(lines) - 1) * line_spacing / 2.0 + elif anchor[1] == "d": + top -= (len(lines) - 1) * line_spacing + + for idx, line in enumerate(lines): + left = xy[0] + width_difference = max_width - widths[idx] + + # first align left by anchor + if anchor[0] == "m": + left -= width_difference / 2.0 + elif anchor[0] == "r": + left -= width_difference + + # then align by align parameter + if align == "left": + pass + elif align == "center": + left += width_difference / 2.0 + elif align == "right": + left += width_difference + else: + msg = 'align must be "left", "center" or "right"' + raise ValueError(msg) + + self.text( + (left, top), + line, + fill, + font, + anchor, + direction=direction, + features=features, + language=language, + stroke_width=stroke_width, + stroke_fill=stroke_fill, + embedded_color=embedded_color, + ) + top += line_spacing + + def textlength( + self, + text, + font=None, + direction=None, + features=None, + language=None, + embedded_color=False, + *, + font_size=None, + ): + """Get the length of a given string, in pixels with 1/64 precision.""" + if self._multiline_check(text): + msg = "can't measure length of multiline text" + raise ValueError(msg) + if embedded_color and self.mode not in ("RGB", "RGBA"): + msg = "Embedded color supported only in RGB and RGBA modes" + raise ValueError(msg) + + if font is None: + font = self._getfont(font_size) + mode = "RGBA" if embedded_color else self.fontmode + return font.getlength(text, mode, direction, features, language) + + def textbbox( + self, + xy, + text, + font=None, + anchor=None, + spacing=4, + align="left", + direction=None, + features=None, + language=None, + stroke_width=0, + embedded_color=False, + *, + font_size=None, + ) -> tuple[int, int, int, int]: + """Get the bounding box of a given string, in pixels.""" + if embedded_color and self.mode not in ("RGB", "RGBA"): + msg = "Embedded color supported only in RGB and RGBA modes" + raise ValueError(msg) + + if font is None: + font = self._getfont(font_size) + + if self._multiline_check(text): + return self.multiline_textbbox( + xy, + text, + font, + anchor, + spacing, + align, + direction, + features, + language, + stroke_width, + embedded_color, + ) + + mode = "RGBA" if embedded_color else self.fontmode + bbox = font.getbbox( + text, mode, direction, features, language, stroke_width, anchor + ) + return bbox[0] + xy[0], bbox[1] + xy[1], bbox[2] + xy[0], bbox[3] + xy[1] + + def multiline_textbbox( + self, + xy, + text, + font=None, + anchor=None, + spacing=4, + align="left", + direction=None, + features=None, + language=None, + stroke_width=0, + embedded_color=False, + *, + font_size=None, + ) -> tuple[int, int, int, int]: + if direction == "ttb": + msg = "ttb direction is unsupported for multiline text" + raise ValueError(msg) + + if anchor is None: + anchor = "la" + elif len(anchor) != 2: + msg = "anchor must be a 2 character string" + raise ValueError(msg) + elif anchor[1] in "tb": + msg = "anchor not supported for multiline text" + raise ValueError(msg) + + if font is None: + font = self._getfont(font_size) + + widths = [] + max_width = 0 + lines = self._multiline_split(text) + line_spacing = self._multiline_spacing(font, spacing, stroke_width) + for line in lines: + line_width = self.textlength( + line, + font, + direction=direction, + features=features, + language=language, + embedded_color=embedded_color, + ) + widths.append(line_width) + max_width = max(max_width, line_width) + + top = xy[1] + if anchor[1] == "m": + top -= (len(lines) - 1) * line_spacing / 2.0 + elif anchor[1] == "d": + top -= (len(lines) - 1) * line_spacing + + bbox: tuple[int, int, int, int] | None = None + + for idx, line in enumerate(lines): + left = xy[0] + width_difference = max_width - widths[idx] + + # first align left by anchor + if anchor[0] == "m": + left -= width_difference / 2.0 + elif anchor[0] == "r": + left -= width_difference + + # then align by align parameter + if align == "left": + pass + elif align == "center": + left += width_difference / 2.0 + elif align == "right": + left += width_difference + else: + msg = 'align must be "left", "center" or "right"' + raise ValueError(msg) + + bbox_line = self.textbbox( + (left, top), + line, + font, + anchor, + direction=direction, + features=features, + language=language, + stroke_width=stroke_width, + embedded_color=embedded_color, + ) + if bbox is None: + bbox = bbox_line + else: + bbox = ( + min(bbox[0], bbox_line[0]), + min(bbox[1], bbox_line[1]), + max(bbox[2], bbox_line[2]), + max(bbox[3], bbox_line[3]), + ) + + top += line_spacing + + if bbox is None: + return xy[0], xy[1], xy[0], xy[1] + return bbox + + +def Draw(im, mode: str | None = None) -> ImageDraw: + """ + A simple 2D drawing interface for PIL images. + + :param im: The image to draw in. + :param mode: Optional mode to use for color values. For RGB + images, this argument can be RGB or RGBA (to blend the + drawing into the image). For all other modes, this argument + must be the same as the image mode. If omitted, the mode + defaults to the mode of the image. + """ + try: + return im.getdraw(mode) + except AttributeError: + return ImageDraw(im, mode) + + +# experimental access to the outline API +try: + Outline = Image.core.outline +except AttributeError: + Outline = None + + +def getdraw(im=None, hints=None): + """ + (Experimental) A more advanced 2D drawing interface for PIL images, + based on the WCK interface. + + :param im: The image to draw in. + :param hints: An optional list of hints. + :returns: A (drawing context, drawing resource factory) tuple. + """ + # FIXME: this needs more work! + # FIXME: come up with a better 'hints' scheme. + handler = None + if not hints or "nicest" in hints: + try: + from . import _imagingagg as handler + except ImportError: + pass + if handler is None: + from . import ImageDraw2 as handler + if im: + im = handler.Draw(im) + return im, handler + + +def floodfill(image: Image.Image, xy, value, border=None, thresh=0) -> None: + """ + (experimental) Fills a bounded region with a given color. + + :param image: Target image. + :param xy: Seed position (a 2-item coordinate tuple). See + :ref:`coordinate-system`. + :param value: Fill color. + :param border: Optional border value. If given, the region consists of + pixels with a color different from the border color. If not given, + the region consists of pixels having the same color as the seed + pixel. + :param thresh: Optional threshold value which specifies a maximum + tolerable difference of a pixel value from the 'background' in + order for it to be replaced. Useful for filling regions of + non-homogeneous, but similar, colors. + """ + # based on an implementation by Eric S. Raymond + # amended by yo1995 @20180806 + pixel = image.load() + x, y = xy + try: + background = pixel[x, y] + if _color_diff(value, background) <= thresh: + return # seed point already has fill color + pixel[x, y] = value + except (ValueError, IndexError): + return # seed point outside image + edge = {(x, y)} + # use a set to keep record of current and previous edge pixels + # to reduce memory consumption + full_edge = set() + while edge: + new_edge = set() + for x, y in edge: # 4 adjacent method + for s, t in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)): + # If already processed, or if a coordinate is negative, skip + if (s, t) in full_edge or s < 0 or t < 0: + continue + try: + p = pixel[s, t] + except (ValueError, IndexError): + pass + else: + full_edge.add((s, t)) + if border is None: + fill = _color_diff(p, background) <= thresh + else: + fill = p not in (value, border) + if fill: + pixel[s, t] = value + new_edge.add((s, t)) + full_edge = edge # discard pixels processed + edge = new_edge + + +def _compute_regular_polygon_vertices( + bounding_circle, n_sides, rotation +) -> list[tuple[float, float]]: + """ + Generate a list of vertices for a 2D regular polygon. + + :param bounding_circle: The bounding circle is a tuple defined + by a point and radius. The polygon is inscribed in this circle. + (e.g. ``bounding_circle=(x, y, r)`` or ``((x, y), r)``) + :param n_sides: Number of sides + (e.g. ``n_sides=3`` for a triangle, ``6`` for a hexagon) + :param rotation: Apply an arbitrary rotation to the polygon + (e.g. ``rotation=90``, applies a 90 degree rotation) + :return: List of regular polygon vertices + (e.g. ``[(25, 50), (50, 50), (50, 25), (25, 25)]``) + + How are the vertices computed? + 1. Compute the following variables + - theta: Angle between the apothem & the nearest polygon vertex + - side_length: Length of each polygon edge + - centroid: Center of bounding circle (1st, 2nd elements of bounding_circle) + - polygon_radius: Polygon radius (last element of bounding_circle) + - angles: Location of each polygon vertex in polar grid + (e.g. A square with 0 degree rotation => [225.0, 315.0, 45.0, 135.0]) + + 2. For each angle in angles, get the polygon vertex at that angle + The vertex is computed using the equation below. + X= xcos(φ) + ysin(φ) + Y= −xsin(φ) + ycos(φ) + + Note: + φ = angle in degrees + x = 0 + y = polygon_radius + + The formula above assumes rotation around the origin. + In our case, we are rotating around the centroid. + To account for this, we use the formula below + X = xcos(φ) + ysin(φ) + centroid_x + Y = −xsin(φ) + ycos(φ) + centroid_y + """ + # 1. Error Handling + # 1.1 Check `n_sides` has an appropriate value + if not isinstance(n_sides, int): + msg = "n_sides should be an int" + raise TypeError(msg) + if n_sides < 3: + msg = "n_sides should be an int > 2" + raise ValueError(msg) + + # 1.2 Check `bounding_circle` has an appropriate value + if not isinstance(bounding_circle, (list, tuple)): + msg = "bounding_circle should be a sequence" + raise TypeError(msg) + + if len(bounding_circle) == 3: + *centroid, polygon_radius = bounding_circle + elif len(bounding_circle) == 2: + centroid, polygon_radius = bounding_circle + else: + msg = ( + "bounding_circle should contain 2D coordinates " + "and a radius (e.g. (x, y, r) or ((x, y), r) )" + ) + raise ValueError(msg) + + if not all(isinstance(i, (int, float)) for i in (*centroid, polygon_radius)): + msg = "bounding_circle should only contain numeric data" + raise ValueError(msg) + + if not len(centroid) == 2: + msg = "bounding_circle centre should contain 2D coordinates (e.g. (x, y))" + raise ValueError(msg) + + if polygon_radius <= 0: + msg = "bounding_circle radius should be > 0" + raise ValueError(msg) + + # 1.3 Check `rotation` has an appropriate value + if not isinstance(rotation, (int, float)): + msg = "rotation should be an int or float" + raise ValueError(msg) + + # 2. Define Helper Functions + def _apply_rotation(point: list[float], degrees: float) -> tuple[int, int]: + return ( + round( + point[0] * math.cos(math.radians(360 - degrees)) + - point[1] * math.sin(math.radians(360 - degrees)) + + centroid[0], + 2, + ), + round( + point[1] * math.cos(math.radians(360 - degrees)) + + point[0] * math.sin(math.radians(360 - degrees)) + + centroid[1], + 2, + ), + ) + + def _compute_polygon_vertex(angle: float) -> tuple[int, int]: + start_point = [polygon_radius, 0] + return _apply_rotation(start_point, angle) + + def _get_angles(n_sides: int, rotation: float) -> list[float]: + angles = [] + degrees = 360 / n_sides + # Start with the bottom left polygon vertex + current_angle = (270 - 0.5 * degrees) + rotation + for _ in range(0, n_sides): + angles.append(current_angle) + current_angle += degrees + if current_angle > 360: + current_angle -= 360 + return angles + + # 3. Variable Declarations + angles = _get_angles(n_sides, rotation) + + # 4. Compute Vertices + return [_compute_polygon_vertex(angle) for angle in angles] + + +def _color_diff(color1, color2: float | tuple[int, ...]) -> float: + """ + Uses 1-norm distance to calculate difference between two values. + """ + if isinstance(color2, tuple): + return sum(abs(color1[i] - color2[i]) for i in range(0, len(color2))) + else: + return abs(color1 - color2) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageDraw2.py b/venv/lib/python3.10/site-packages/PIL/ImageDraw2.py new file mode 100644 index 00000000..35ee5834 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageDraw2.py @@ -0,0 +1,193 @@ +# +# The Python Imaging Library +# $Id$ +# +# WCK-style drawing interface operations +# +# History: +# 2003-12-07 fl created +# 2005-05-15 fl updated; added to PIL as ImageDraw2 +# 2005-05-15 fl added text support +# 2005-05-20 fl added arc/chord/pieslice support +# +# Copyright (c) 2003-2005 by Secret Labs AB +# Copyright (c) 2003-2005 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# + + +""" +(Experimental) WCK-style drawing interface operations + +.. seealso:: :py:mod:`PIL.ImageDraw` +""" +from __future__ import annotations + +from . import Image, ImageColor, ImageDraw, ImageFont, ImagePath + + +class Pen: + """Stores an outline color and width.""" + + def __init__(self, color, width=1, opacity=255): + self.color = ImageColor.getrgb(color) + self.width = width + + +class Brush: + """Stores a fill color""" + + def __init__(self, color, opacity=255): + self.color = ImageColor.getrgb(color) + + +class Font: + """Stores a TrueType font and color""" + + def __init__(self, color, file, size=12): + # FIXME: add support for bitmap fonts + self.color = ImageColor.getrgb(color) + self.font = ImageFont.truetype(file, size) + + +class Draw: + """ + (Experimental) WCK-style drawing interface + """ + + def __init__(self, image, size=None, color=None): + if not hasattr(image, "im"): + image = Image.new(image, size, color) + self.draw = ImageDraw.Draw(image) + self.image = image + self.transform = None + + def flush(self): + return self.image + + def render(self, op, xy, pen, brush=None): + # handle color arguments + outline = fill = None + width = 1 + if isinstance(pen, Pen): + outline = pen.color + width = pen.width + elif isinstance(brush, Pen): + outline = brush.color + width = brush.width + if isinstance(brush, Brush): + fill = brush.color + elif isinstance(pen, Brush): + fill = pen.color + # handle transformation + if self.transform: + xy = ImagePath.Path(xy) + xy.transform(self.transform) + # render the item + if op == "line": + self.draw.line(xy, fill=outline, width=width) + else: + getattr(self.draw, op)(xy, fill=fill, outline=outline) + + def settransform(self, offset): + """Sets a transformation offset.""" + (xoffset, yoffset) = offset + self.transform = (1, 0, xoffset, 0, 1, yoffset) + + def arc(self, xy, start, end, *options): + """ + Draws an arc (a portion of a circle outline) between the start and end + angles, inside the given bounding box. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.arc` + """ + self.render("arc", xy, start, end, *options) + + def chord(self, xy, start, end, *options): + """ + Same as :py:meth:`~PIL.ImageDraw2.Draw.arc`, but connects the end points + with a straight line. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.chord` + """ + self.render("chord", xy, start, end, *options) + + def ellipse(self, xy, *options): + """ + Draws an ellipse inside the given bounding box. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse` + """ + self.render("ellipse", xy, *options) + + def line(self, xy, *options): + """ + Draws a line between the coordinates in the ``xy`` list. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line` + """ + self.render("line", xy, *options) + + def pieslice(self, xy, start, end, *options): + """ + Same as arc, but also draws straight lines between the end points and the + center of the bounding box. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice` + """ + self.render("pieslice", xy, start, end, *options) + + def polygon(self, xy, *options): + """ + Draws a polygon. + + The polygon outline consists of straight lines between the given + coordinates, plus a straight line between the last and the first + coordinate. + + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon` + """ + self.render("polygon", xy, *options) + + def rectangle(self, xy, *options): + """ + Draws a rectangle. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle` + """ + self.render("rectangle", xy, *options) + + def text(self, xy, text, font): + """ + Draws the string at the given position. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text` + """ + if self.transform: + xy = ImagePath.Path(xy) + xy.transform(self.transform) + self.draw.text(xy, text, font=font.font, fill=font.color) + + def textbbox(self, xy, text, font): + """ + Returns bounding box (in pixels) of given text. + + :return: ``(left, top, right, bottom)`` bounding box + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textbbox` + """ + if self.transform: + xy = ImagePath.Path(xy) + xy.transform(self.transform) + return self.draw.textbbox(xy, text, font=font.font) + + def textlength(self, text, font): + """ + Returns length (in pixels) of given text. + This is the amount by which following text should be offset. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textlength` + """ + return self.draw.textlength(text, font=font.font) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageEnhance.py b/venv/lib/python3.10/site-packages/PIL/ImageEnhance.py new file mode 100644 index 00000000..93a50d2a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageEnhance.py @@ -0,0 +1,104 @@ +# +# The Python Imaging Library. +# $Id$ +# +# image enhancement classes +# +# For a background, see "Image Processing By Interpolation and +# Extrapolation", Paul Haeberli and Douglas Voorhies. Available +# at http://www.graficaobscura.com/interp/index.html +# +# History: +# 1996-03-23 fl Created +# 2009-06-16 fl Fixed mean calculation +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFilter, ImageStat + + +class _Enhance: + def enhance(self, factor): + """ + Returns an enhanced image. + + :param factor: A floating point value controlling the enhancement. + Factor 1.0 always returns a copy of the original image, + lower factors mean less color (brightness, contrast, + etc), and higher values more. There are no restrictions + on this value. + :rtype: :py:class:`~PIL.Image.Image` + """ + return Image.blend(self.degenerate, self.image, factor) + + +class Color(_Enhance): + """Adjust image color balance. + + This class can be used to adjust the colour balance of an image, in + a manner similar to the controls on a colour TV set. An enhancement + factor of 0.0 gives a black and white image. A factor of 1.0 gives + the original image. + """ + + def __init__(self, image): + self.image = image + self.intermediate_mode = "L" + if "A" in image.getbands(): + self.intermediate_mode = "LA" + + self.degenerate = image.convert(self.intermediate_mode).convert(image.mode) + + +class Contrast(_Enhance): + """Adjust image contrast. + + This class can be used to control the contrast of an image, similar + to the contrast control on a TV set. An enhancement factor of 0.0 + gives a solid gray image. A factor of 1.0 gives the original image. + """ + + def __init__(self, image): + self.image = image + mean = int(ImageStat.Stat(image.convert("L")).mean[0] + 0.5) + self.degenerate = Image.new("L", image.size, mean).convert(image.mode) + + if "A" in image.getbands(): + self.degenerate.putalpha(image.getchannel("A")) + + +class Brightness(_Enhance): + """Adjust image brightness. + + This class can be used to control the brightness of an image. An + enhancement factor of 0.0 gives a black image. A factor of 1.0 gives the + original image. + """ + + def __init__(self, image): + self.image = image + self.degenerate = Image.new(image.mode, image.size, 0) + + if "A" in image.getbands(): + self.degenerate.putalpha(image.getchannel("A")) + + +class Sharpness(_Enhance): + """Adjust image sharpness. + + This class can be used to adjust the sharpness of an image. An + enhancement factor of 0.0 gives a blurred image, a factor of 1.0 gives the + original image, and a factor of 2.0 gives a sharpened image. + """ + + def __init__(self, image): + self.image = image + self.degenerate = image.filter(ImageFilter.SMOOTH) + + if "A" in image.getbands(): + self.degenerate.putalpha(image.getchannel("A")) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageFile.py b/venv/lib/python3.10/site-packages/PIL/ImageFile.py new file mode 100644 index 00000000..0283fa2f --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageFile.py @@ -0,0 +1,797 @@ +# +# The Python Imaging Library. +# $Id$ +# +# base class for image file handlers +# +# history: +# 1995-09-09 fl Created +# 1996-03-11 fl Fixed load mechanism. +# 1996-04-15 fl Added pcx/xbm decoders. +# 1996-04-30 fl Added encoders. +# 1996-12-14 fl Added load helpers +# 1997-01-11 fl Use encode_to_file where possible +# 1997-08-27 fl Flush output in _save +# 1998-03-05 fl Use memory mapping for some modes +# 1999-02-04 fl Use memory mapping also for "I;16" and "I;16B" +# 1999-05-31 fl Added image parser +# 2000-10-12 fl Set readonly flag on memory-mapped images +# 2002-03-20 fl Use better messages for common decoder errors +# 2003-04-21 fl Fall back on mmap/map_buffer if map is not available +# 2003-10-30 fl Added StubImageFile class +# 2004-02-25 fl Made incremental parser more robust +# +# Copyright (c) 1997-2004 by Secret Labs AB +# Copyright (c) 1995-2004 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import itertools +import struct +import sys +from typing import IO, Any, NamedTuple + +from . import Image +from ._deprecate import deprecate +from ._util import is_path + +MAXBLOCK = 65536 + +SAFEBLOCK = 1024 * 1024 + +LOAD_TRUNCATED_IMAGES = False +"""Whether or not to load truncated image files. User code may change this.""" + +ERRORS = { + -1: "image buffer overrun error", + -2: "decoding error", + -3: "unknown error", + -8: "bad configuration", + -9: "out of memory error", +} +""" +Dict of known error codes returned from :meth:`.PyDecoder.decode`, +:meth:`.PyEncoder.encode` :meth:`.PyEncoder.encode_to_pyfd` and +:meth:`.PyEncoder.encode_to_file`. +""" + + +# +# -------------------------------------------------------------------- +# Helpers + + +def _get_oserror(error, *, encoder): + try: + msg = Image.core.getcodecstatus(error) + except AttributeError: + msg = ERRORS.get(error) + if not msg: + msg = f"{'encoder' if encoder else 'decoder'} error {error}" + msg += f" when {'writing' if encoder else 'reading'} image file" + return OSError(msg) + + +def raise_oserror(error): + deprecate( + "raise_oserror", + 12, + action="It is only useful for translating error codes returned by a codec's " + "decode() method, which ImageFile already does automatically.", + ) + raise _get_oserror(error, encoder=False) + + +def _tilesort(t): + # sort on offset + return t[2] + + +class _Tile(NamedTuple): + codec_name: str + extents: tuple[int, int, int, int] + offset: int + args: tuple[Any, ...] | str | None + + +# +# -------------------------------------------------------------------- +# ImageFile base class + + +class ImageFile(Image.Image): + """Base class for image file format handlers.""" + + def __init__(self, fp=None, filename=None): + super().__init__() + + self._min_frame = 0 + + self.custom_mimetype = None + + self.tile = None + """ A list of tile descriptors, or ``None`` """ + + self.readonly = 1 # until we know better + + self.decoderconfig = () + self.decodermaxblock = MAXBLOCK + + if is_path(fp): + # filename + self.fp = open(fp, "rb") + self.filename = fp + self._exclusive_fp = True + else: + # stream + self.fp = fp + self.filename = filename + # can be overridden + self._exclusive_fp = None + + try: + try: + self._open() + except ( + IndexError, # end of data + TypeError, # end of data (ord) + KeyError, # unsupported mode + EOFError, # got header but not the first frame + struct.error, + ) as v: + raise SyntaxError(v) from v + + if not self.mode or self.size[0] <= 0 or self.size[1] <= 0: + msg = "not identified by this driver" + raise SyntaxError(msg) + except BaseException: + # close the file only if we have opened it this constructor + if self._exclusive_fp: + self.fp.close() + raise + + def get_format_mimetype(self): + if self.custom_mimetype: + return self.custom_mimetype + if self.format is not None: + return Image.MIME.get(self.format.upper()) + + def __setstate__(self, state): + self.tile = [] + super().__setstate__(state) + + def verify(self): + """Check file integrity""" + + # raise exception if something's wrong. must be called + # directly after open, and closes file when finished. + if self._exclusive_fp: + self.fp.close() + self.fp = None + + def load(self): + """Load image data based on tile list""" + + if self.tile is None: + msg = "cannot load this image" + raise OSError(msg) + + pixel = Image.Image.load(self) + if not self.tile: + return pixel + + self.map = None + use_mmap = self.filename and len(self.tile) == 1 + # As of pypy 2.1.0, memory mapping was failing here. + use_mmap = use_mmap and not hasattr(sys, "pypy_version_info") + + readonly = 0 + + # look for read/seek overrides + try: + read = self.load_read + # don't use mmap if there are custom read/seek functions + use_mmap = False + except AttributeError: + read = self.fp.read + + try: + seek = self.load_seek + use_mmap = False + except AttributeError: + seek = self.fp.seek + + if use_mmap: + # try memory mapping + decoder_name, extents, offset, args = self.tile[0] + if isinstance(args, str): + args = (args, 0, 1) + if ( + decoder_name == "raw" + and len(args) >= 3 + and args[0] == self.mode + and args[0] in Image._MAPMODES + ): + try: + # use mmap, if possible + import mmap + + with open(self.filename) as fp: + self.map = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ) + if offset + self.size[1] * args[1] > self.map.size(): + msg = "buffer is not large enough" + raise OSError(msg) + self.im = Image.core.map_buffer( + self.map, self.size, decoder_name, offset, args + ) + readonly = 1 + # After trashing self.im, + # we might need to reload the palette data. + if self.palette: + self.palette.dirty = 1 + except (AttributeError, OSError, ImportError): + self.map = None + + self.load_prepare() + err_code = -3 # initialize to unknown error + if not self.map: + # sort tiles in file order + self.tile.sort(key=_tilesort) + + try: + # FIXME: This is a hack to handle TIFF's JpegTables tag. + prefix = self.tile_prefix + except AttributeError: + prefix = b"" + + # Remove consecutive duplicates that only differ by their offset + self.tile = [ + list(tiles)[-1] + for _, tiles in itertools.groupby( + self.tile, lambda tile: (tile[0], tile[1], tile[3]) + ) + ] + for decoder_name, extents, offset, args in self.tile: + seek(offset) + decoder = Image._getdecoder( + self.mode, decoder_name, args, self.decoderconfig + ) + try: + decoder.setimage(self.im, extents) + if decoder.pulls_fd: + decoder.setfd(self.fp) + err_code = decoder.decode(b"")[1] + else: + b = prefix + while True: + try: + s = read(self.decodermaxblock) + except (IndexError, struct.error) as e: + # truncated png/gif + if LOAD_TRUNCATED_IMAGES: + break + else: + msg = "image file is truncated" + raise OSError(msg) from e + + if not s: # truncated jpeg + if LOAD_TRUNCATED_IMAGES: + break + else: + msg = ( + "image file is truncated " + f"({len(b)} bytes not processed)" + ) + raise OSError(msg) + + b = b + s + n, err_code = decoder.decode(b) + if n < 0: + break + b = b[n:] + finally: + # Need to cleanup here to prevent leaks + decoder.cleanup() + + self.tile = [] + self.readonly = readonly + + self.load_end() + + if self._exclusive_fp and self._close_exclusive_fp_after_loading: + self.fp.close() + self.fp = None + + if not self.map and not LOAD_TRUNCATED_IMAGES and err_code < 0: + # still raised if decoder fails to return anything + raise _get_oserror(err_code, encoder=False) + + return Image.Image.load(self) + + def load_prepare(self): + # create image memory if necessary + if not self.im or self.im.mode != self.mode or self.im.size != self.size: + self.im = Image.core.new(self.mode, self.size) + # create palette (optional) + if self.mode == "P": + Image.Image.load(self) + + def load_end(self): + # may be overridden + pass + + # may be defined for contained formats + # def load_seek(self, pos): + # pass + + # may be defined for blocked formats (e.g. PNG) + # def load_read(self, read_bytes): + # pass + + def _seek_check(self, frame): + if ( + frame < self._min_frame + # Only check upper limit on frames if additional seek operations + # are not required to do so + or ( + not (hasattr(self, "_n_frames") and self._n_frames is None) + and frame >= self.n_frames + self._min_frame + ) + ): + msg = "attempt to seek outside sequence" + raise EOFError(msg) + + return self.tell() != frame + + +class StubImageFile(ImageFile): + """ + Base class for stub image loaders. + + A stub loader is an image loader that can identify files of a + certain format, but relies on external code to load the file. + """ + + def _open(self): + msg = "StubImageFile subclass must implement _open" + raise NotImplementedError(msg) + + def load(self): + loader = self._load() + if loader is None: + msg = f"cannot find loader for this {self.format} file" + raise OSError(msg) + image = loader.load(self) + assert image is not None + # become the other object (!) + self.__class__ = image.__class__ + self.__dict__ = image.__dict__ + return image.load() + + def _load(self): + """(Hook) Find actual image loader.""" + msg = "StubImageFile subclass must implement _load" + raise NotImplementedError(msg) + + +class Parser: + """ + Incremental image parser. This class implements the standard + feed/close consumer interface. + """ + + incremental = None + image: Image.Image | None = None + data = None + decoder = None + offset = 0 + finished = 0 + + def reset(self): + """ + (Consumer) Reset the parser. Note that you can only call this + method immediately after you've created a parser; parser + instances cannot be reused. + """ + assert self.data is None, "cannot reuse parsers" + + def feed(self, data): + """ + (Consumer) Feed data to the parser. + + :param data: A string buffer. + :exception OSError: If the parser failed to parse the image file. + """ + # collect data + + if self.finished: + return + + if self.data is None: + self.data = data + else: + self.data = self.data + data + + # parse what we have + if self.decoder: + if self.offset > 0: + # skip header + skip = min(len(self.data), self.offset) + self.data = self.data[skip:] + self.offset = self.offset - skip + if self.offset > 0 or not self.data: + return + + n, e = self.decoder.decode(self.data) + + if n < 0: + # end of stream + self.data = None + self.finished = 1 + if e < 0: + # decoding error + self.image = None + raise _get_oserror(e, encoder=False) + else: + # end of image + return + self.data = self.data[n:] + + elif self.image: + # if we end up here with no decoder, this file cannot + # be incrementally parsed. wait until we've gotten all + # available data + pass + + else: + # attempt to open this file + try: + with io.BytesIO(self.data) as fp: + im = Image.open(fp) + except OSError: + pass # not enough data + else: + flag = hasattr(im, "load_seek") or hasattr(im, "load_read") + if flag or len(im.tile) != 1: + # custom load code, or multiple tiles + self.decode = None + else: + # initialize decoder + im.load_prepare() + d, e, o, a = im.tile[0] + im.tile = [] + self.decoder = Image._getdecoder(im.mode, d, a, im.decoderconfig) + self.decoder.setimage(im.im, e) + + # calculate decoder offset + self.offset = o + if self.offset <= len(self.data): + self.data = self.data[self.offset :] + self.offset = 0 + + self.image = im + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def close(self): + """ + (Consumer) Close the stream. + + :returns: An image object. + :exception OSError: If the parser failed to parse the image file either + because it cannot be identified or cannot be + decoded. + """ + # finish decoding + if self.decoder: + # get rid of what's left in the buffers + self.feed(b"") + self.data = self.decoder = None + if not self.finished: + msg = "image was incomplete" + raise OSError(msg) + if not self.image: + msg = "cannot parse this image" + raise OSError(msg) + if self.data: + # incremental parsing not possible; reopen the file + # not that we have all data + with io.BytesIO(self.data) as fp: + try: + self.image = Image.open(fp) + finally: + self.image.load() + return self.image + + +# -------------------------------------------------------------------- + + +def _save(im, fp, tile, bufsize=0) -> None: + """Helper to save image based on tile list + + :param im: Image object. + :param fp: File object. + :param tile: Tile list. + :param bufsize: Optional buffer size + """ + + im.load() + if not hasattr(im, "encoderconfig"): + im.encoderconfig = () + tile.sort(key=_tilesort) + # FIXME: make MAXBLOCK a configuration parameter + # It would be great if we could have the encoder specify what it needs + # But, it would need at least the image size in most cases. RawEncode is + # a tricky case. + bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4) # see RawEncode.c + try: + fh = fp.fileno() + fp.flush() + _encode_tile(im, fp, tile, bufsize, fh) + except (AttributeError, io.UnsupportedOperation) as exc: + _encode_tile(im, fp, tile, bufsize, None, exc) + if hasattr(fp, "flush"): + fp.flush() + + +def _encode_tile(im, fp, tile: list[_Tile], bufsize, fh, exc=None): + for encoder_name, extents, offset, args in tile: + if offset > 0: + fp.seek(offset) + encoder = Image._getencoder(im.mode, encoder_name, args, im.encoderconfig) + try: + encoder.setimage(im.im, extents) + if encoder.pushes_fd: + encoder.setfd(fp) + errcode = encoder.encode_to_pyfd()[1] + else: + if exc: + # compress to Python file-compatible object + while True: + errcode, data = encoder.encode(bufsize)[1:] + fp.write(data) + if errcode: + break + else: + # slight speedup: compress to real file object + errcode = encoder.encode_to_file(fh, bufsize) + if errcode < 0: + raise _get_oserror(errcode, encoder=True) from exc + finally: + encoder.cleanup() + + +def _safe_read(fp, size): + """ + Reads large blocks in a safe way. Unlike fp.read(n), this function + doesn't trust the user. If the requested size is larger than + SAFEBLOCK, the file is read block by block. + + :param fp: File handle. Must implement a read method. + :param size: Number of bytes to read. + :returns: A string containing size bytes of data. + + Raises an OSError if the file is truncated and the read cannot be completed + + """ + if size <= 0: + return b"" + if size <= SAFEBLOCK: + data = fp.read(size) + if len(data) < size: + msg = "Truncated File Read" + raise OSError(msg) + return data + data = [] + remaining_size = size + while remaining_size > 0: + block = fp.read(min(remaining_size, SAFEBLOCK)) + if not block: + break + data.append(block) + remaining_size -= len(block) + if sum(len(d) for d in data) < size: + msg = "Truncated File Read" + raise OSError(msg) + return b"".join(data) + + +class PyCodecState: + def __init__(self): + self.xsize = 0 + self.ysize = 0 + self.xoff = 0 + self.yoff = 0 + + def extents(self): + return self.xoff, self.yoff, self.xoff + self.xsize, self.yoff + self.ysize + + +class PyCodec: + fd: IO[bytes] | None + + def __init__(self, mode, *args): + self.im = None + self.state = PyCodecState() + self.fd = None + self.mode = mode + self.init(args) + + def init(self, args): + """ + Override to perform codec specific initialization + + :param args: Array of args items from the tile entry + :returns: None + """ + self.args = args + + def cleanup(self): + """ + Override to perform codec specific cleanup + + :returns: None + """ + pass + + def setfd(self, fd): + """ + Called from ImageFile to set the Python file-like object + + :param fd: A Python file-like object + :returns: None + """ + self.fd = fd + + def setimage(self, im, extents=None): + """ + Called from ImageFile to set the core output image for the codec + + :param im: A core image object + :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle + for this tile + :returns: None + """ + + # following c code + self.im = im + + if extents: + (x0, y0, x1, y1) = extents + else: + (x0, y0, x1, y1) = (0, 0, 0, 0) + + if x0 == 0 and x1 == 0: + self.state.xsize, self.state.ysize = self.im.size + else: + self.state.xoff = x0 + self.state.yoff = y0 + self.state.xsize = x1 - x0 + self.state.ysize = y1 - y0 + + if self.state.xsize <= 0 or self.state.ysize <= 0: + msg = "Size cannot be negative" + raise ValueError(msg) + + if ( + self.state.xsize + self.state.xoff > self.im.size[0] + or self.state.ysize + self.state.yoff > self.im.size[1] + ): + msg = "Tile cannot extend outside image" + raise ValueError(msg) + + +class PyDecoder(PyCodec): + """ + Python implementation of a format decoder. Override this class and + add the decoding logic in the :meth:`decode` method. + + See :ref:`Writing Your Own File Codec in Python` + """ + + _pulls_fd = False + + @property + def pulls_fd(self): + return self._pulls_fd + + def decode(self, buffer): + """ + Override to perform the decoding process. + + :param buffer: A bytes object with the data to be decoded. + :returns: A tuple of ``(bytes consumed, errcode)``. + If finished with decoding return -1 for the bytes consumed. + Err codes are from :data:`.ImageFile.ERRORS`. + """ + msg = "unavailable in base decoder" + raise NotImplementedError(msg) + + def set_as_raw(self, data: bytes, rawmode=None) -> None: + """ + Convenience method to set the internal image from a stream of raw data + + :param data: Bytes to be set + :param rawmode: The rawmode to be used for the decoder. + If not specified, it will default to the mode of the image + :returns: None + """ + + if not rawmode: + rawmode = self.mode + d = Image._getdecoder(self.mode, "raw", rawmode) + d.setimage(self.im, self.state.extents()) + s = d.decode(data) + + if s[0] >= 0: + msg = "not enough image data" + raise ValueError(msg) + if s[1] != 0: + msg = "cannot decode image data" + raise ValueError(msg) + + +class PyEncoder(PyCodec): + """ + Python implementation of a format encoder. Override this class and + add the decoding logic in the :meth:`encode` method. + + See :ref:`Writing Your Own File Codec in Python` + """ + + _pushes_fd = False + + @property + def pushes_fd(self): + return self._pushes_fd + + def encode(self, bufsize): + """ + Override to perform the encoding process. + + :param bufsize: Buffer size. + :returns: A tuple of ``(bytes encoded, errcode, bytes)``. + If finished with encoding return 1 for the error code. + Err codes are from :data:`.ImageFile.ERRORS`. + """ + msg = "unavailable in base encoder" + raise NotImplementedError(msg) + + def encode_to_pyfd(self): + """ + If ``pushes_fd`` is ``True``, then this method will be used, + and ``encode()`` will only be called once. + + :returns: A tuple of ``(bytes consumed, errcode)``. + Err codes are from :data:`.ImageFile.ERRORS`. + """ + if not self.pushes_fd: + return 0, -8 # bad configuration + bytes_consumed, errcode, data = self.encode(0) + if data: + self.fd.write(data) + return bytes_consumed, errcode + + def encode_to_file(self, fh, bufsize): + """ + :param fh: File handle. + :param bufsize: Buffer size. + + :returns: If finished successfully, return 0. + Otherwise, return an error code. Err codes are from + :data:`.ImageFile.ERRORS`. + """ + errcode = 0 + while errcode == 0: + status, errcode, buf = self.encode(bufsize) + if status > 0: + fh.write(buf[status:]) + return errcode diff --git a/venv/lib/python3.10/site-packages/PIL/ImageFilter.py b/venv/lib/python3.10/site-packages/PIL/ImageFilter.py new file mode 100644 index 00000000..b2c4950d --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageFilter.py @@ -0,0 +1,565 @@ +# +# The Python Imaging Library. +# $Id$ +# +# standard filters +# +# History: +# 1995-11-27 fl Created +# 2002-06-08 fl Added rank and mode filters +# 2003-09-15 fl Fixed rank calculation in rank filter; added expand call +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1995-2002 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import functools + + +class Filter: + pass + + +class MultibandFilter(Filter): + pass + + +class BuiltinFilter(MultibandFilter): + def filter(self, image): + if image.mode == "P": + msg = "cannot filter palette images" + raise ValueError(msg) + return image.filter(*self.filterargs) + + +class Kernel(BuiltinFilter): + """ + Create a convolution kernel. This only supports 3x3 and 5x5 integer and floating + point kernels. + + Kernels can only be applied to "L" and "RGB" images. + + :param size: Kernel size, given as (width, height). This must be (3,3) or (5,5). + :param kernel: A sequence containing kernel weights. The kernel will be flipped + vertically before being applied to the image. + :param scale: Scale factor. If given, the result for each pixel is divided by this + value. The default is the sum of the kernel weights. + :param offset: Offset. If given, this value is added to the result, after it has + been divided by the scale factor. + """ + + name = "Kernel" + + def __init__(self, size, kernel, scale=None, offset=0): + if scale is None: + # default scale is sum of kernel + scale = functools.reduce(lambda a, b: a + b, kernel) + if size[0] * size[1] != len(kernel): + msg = "not enough coefficients in kernel" + raise ValueError(msg) + self.filterargs = size, scale, offset, kernel + + +class RankFilter(Filter): + """ + Create a rank filter. The rank filter sorts all pixels in + a window of the given size, and returns the ``rank``'th value. + + :param size: The kernel size, in pixels. + :param rank: What pixel value to pick. Use 0 for a min filter, + ``size * size / 2`` for a median filter, ``size * size - 1`` + for a max filter, etc. + """ + + name = "Rank" + + def __init__(self, size, rank): + self.size = size + self.rank = rank + + def filter(self, image): + if image.mode == "P": + msg = "cannot filter palette images" + raise ValueError(msg) + image = image.expand(self.size // 2, self.size // 2) + return image.rankfilter(self.size, self.rank) + + +class MedianFilter(RankFilter): + """ + Create a median filter. Picks the median pixel value in a window with the + given size. + + :param size: The kernel size, in pixels. + """ + + name = "Median" + + def __init__(self, size=3): + self.size = size + self.rank = size * size // 2 + + +class MinFilter(RankFilter): + """ + Create a min filter. Picks the lowest pixel value in a window with the + given size. + + :param size: The kernel size, in pixels. + """ + + name = "Min" + + def __init__(self, size=3): + self.size = size + self.rank = 0 + + +class MaxFilter(RankFilter): + """ + Create a max filter. Picks the largest pixel value in a window with the + given size. + + :param size: The kernel size, in pixels. + """ + + name = "Max" + + def __init__(self, size=3): + self.size = size + self.rank = size * size - 1 + + +class ModeFilter(Filter): + """ + Create a mode filter. Picks the most frequent pixel value in a box with the + given size. Pixel values that occur only once or twice are ignored; if no + pixel value occurs more than twice, the original pixel value is preserved. + + :param size: The kernel size, in pixels. + """ + + name = "Mode" + + def __init__(self, size=3): + self.size = size + + def filter(self, image): + return image.modefilter(self.size) + + +class GaussianBlur(MultibandFilter): + """Blurs the image with a sequence of extended box filters, which + approximates a Gaussian kernel. For details on accuracy see + + + :param radius: Standard deviation of the Gaussian kernel. Either a sequence of two + numbers for x and y, or a single number for both. + """ + + name = "GaussianBlur" + + def __init__(self, radius=2): + self.radius = radius + + def filter(self, image): + xy = self.radius + if not isinstance(xy, (tuple, list)): + xy = (xy, xy) + if xy == (0, 0): + return image.copy() + return image.gaussian_blur(xy) + + +class BoxBlur(MultibandFilter): + """Blurs the image by setting each pixel to the average value of the pixels + in a square box extending radius pixels in each direction. + Supports float radius of arbitrary size. Uses an optimized implementation + which runs in linear time relative to the size of the image + for any radius value. + + :param radius: Size of the box in a direction. Either a sequence of two numbers for + x and y, or a single number for both. + + Radius 0 does not blur, returns an identical image. + Radius 1 takes 1 pixel in each direction, i.e. 9 pixels in total. + """ + + name = "BoxBlur" + + def __init__(self, radius): + xy = radius + if not isinstance(xy, (tuple, list)): + xy = (xy, xy) + if xy[0] < 0 or xy[1] < 0: + msg = "radius must be >= 0" + raise ValueError(msg) + self.radius = radius + + def filter(self, image): + xy = self.radius + if not isinstance(xy, (tuple, list)): + xy = (xy, xy) + if xy == (0, 0): + return image.copy() + return image.box_blur(xy) + + +class UnsharpMask(MultibandFilter): + """Unsharp mask filter. + + See Wikipedia's entry on `digital unsharp masking`_ for an explanation of + the parameters. + + :param radius: Blur Radius + :param percent: Unsharp strength, in percent + :param threshold: Threshold controls the minimum brightness change that + will be sharpened + + .. _digital unsharp masking: https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking + + """ + + name = "UnsharpMask" + + def __init__(self, radius=2, percent=150, threshold=3): + self.radius = radius + self.percent = percent + self.threshold = threshold + + def filter(self, image): + return image.unsharp_mask(self.radius, self.percent, self.threshold) + + +class BLUR(BuiltinFilter): + name = "Blur" + # fmt: off + filterargs = (5, 5), 16, 0, ( + 1, 1, 1, 1, 1, + 1, 0, 0, 0, 1, + 1, 0, 0, 0, 1, + 1, 0, 0, 0, 1, + 1, 1, 1, 1, 1, + ) + # fmt: on + + +class CONTOUR(BuiltinFilter): + name = "Contour" + # fmt: off + filterargs = (3, 3), 1, 255, ( + -1, -1, -1, + -1, 8, -1, + -1, -1, -1, + ) + # fmt: on + + +class DETAIL(BuiltinFilter): + name = "Detail" + # fmt: off + filterargs = (3, 3), 6, 0, ( + 0, -1, 0, + -1, 10, -1, + 0, -1, 0, + ) + # fmt: on + + +class EDGE_ENHANCE(BuiltinFilter): + name = "Edge-enhance" + # fmt: off + filterargs = (3, 3), 2, 0, ( + -1, -1, -1, + -1, 10, -1, + -1, -1, -1, + ) + # fmt: on + + +class EDGE_ENHANCE_MORE(BuiltinFilter): + name = "Edge-enhance More" + # fmt: off + filterargs = (3, 3), 1, 0, ( + -1, -1, -1, + -1, 9, -1, + -1, -1, -1, + ) + # fmt: on + + +class EMBOSS(BuiltinFilter): + name = "Emboss" + # fmt: off + filterargs = (3, 3), 1, 128, ( + -1, 0, 0, + 0, 1, 0, + 0, 0, 0, + ) + # fmt: on + + +class FIND_EDGES(BuiltinFilter): + name = "Find Edges" + # fmt: off + filterargs = (3, 3), 1, 0, ( + -1, -1, -1, + -1, 8, -1, + -1, -1, -1, + ) + # fmt: on + + +class SHARPEN(BuiltinFilter): + name = "Sharpen" + # fmt: off + filterargs = (3, 3), 16, 0, ( + -2, -2, -2, + -2, 32, -2, + -2, -2, -2, + ) + # fmt: on + + +class SMOOTH(BuiltinFilter): + name = "Smooth" + # fmt: off + filterargs = (3, 3), 13, 0, ( + 1, 1, 1, + 1, 5, 1, + 1, 1, 1, + ) + # fmt: on + + +class SMOOTH_MORE(BuiltinFilter): + name = "Smooth More" + # fmt: off + filterargs = (5, 5), 100, 0, ( + 1, 1, 1, 1, 1, + 1, 5, 5, 5, 1, + 1, 5, 44, 5, 1, + 1, 5, 5, 5, 1, + 1, 1, 1, 1, 1, + ) + # fmt: on + + +class Color3DLUT(MultibandFilter): + """Three-dimensional color lookup table. + + Transforms 3-channel pixels using the values of the channels as coordinates + in the 3D lookup table and interpolating the nearest elements. + + This method allows you to apply almost any color transformation + in constant time by using pre-calculated decimated tables. + + .. versionadded:: 5.2.0 + + :param size: Size of the table. One int or tuple of (int, int, int). + Minimal size in any dimension is 2, maximum is 65. + :param table: Flat lookup table. A list of ``channels * size**3`` + float elements or a list of ``size**3`` channels-sized + tuples with floats. Channels are changed first, + then first dimension, then second, then third. + Value 0.0 corresponds lowest value of output, 1.0 highest. + :param channels: Number of channels in the table. Could be 3 or 4. + Default is 3. + :param target_mode: A mode for the result image. Should have not less + than ``channels`` channels. Default is ``None``, + which means that mode wouldn't be changed. + """ + + name = "Color 3D LUT" + + def __init__(self, size, table, channels=3, target_mode=None, **kwargs): + if channels not in (3, 4): + msg = "Only 3 or 4 output channels are supported" + raise ValueError(msg) + self.size = size = self._check_size(size) + self.channels = channels + self.mode = target_mode + + # Hidden flag `_copy_table=False` could be used to avoid extra copying + # of the table if the table is specially made for the constructor. + copy_table = kwargs.get("_copy_table", True) + items = size[0] * size[1] * size[2] + wrong_size = False + + numpy = None + if hasattr(table, "shape"): + try: + import numpy + except ImportError: + pass + + if numpy and isinstance(table, numpy.ndarray): + if copy_table: + table = table.copy() + + if table.shape in [ + (items * channels,), + (items, channels), + (size[2], size[1], size[0], channels), + ]: + table = table.reshape(items * channels) + else: + wrong_size = True + + else: + if copy_table: + table = list(table) + + # Convert to a flat list + if table and isinstance(table[0], (list, tuple)): + table, raw_table = [], table + for pixel in raw_table: + if len(pixel) != channels: + msg = ( + "The elements of the table should " + f"have a length of {channels}." + ) + raise ValueError(msg) + table.extend(pixel) + + if wrong_size or len(table) != items * channels: + msg = ( + "The table should have either channels * size**3 float items " + "or size**3 items of channels-sized tuples with floats. " + f"Table should be: {channels}x{size[0]}x{size[1]}x{size[2]}. " + f"Actual length: {len(table)}" + ) + raise ValueError(msg) + self.table = table + + @staticmethod + def _check_size(size): + try: + _, _, _ = size + except ValueError as e: + msg = "Size should be either an integer or a tuple of three integers." + raise ValueError(msg) from e + except TypeError: + size = (size, size, size) + size = [int(x) for x in size] + for size_1d in size: + if not 2 <= size_1d <= 65: + msg = "Size should be in [2, 65] range." + raise ValueError(msg) + return size + + @classmethod + def generate(cls, size, callback, channels=3, target_mode=None): + """Generates new LUT using provided callback. + + :param size: Size of the table. Passed to the constructor. + :param callback: Function with three parameters which correspond + three color channels. Will be called ``size**3`` + times with values from 0.0 to 1.0 and should return + a tuple with ``channels`` elements. + :param channels: The number of channels which should return callback. + :param target_mode: Passed to the constructor of the resulting + lookup table. + """ + size_1d, size_2d, size_3d = cls._check_size(size) + if channels not in (3, 4): + msg = "Only 3 or 4 output channels are supported" + raise ValueError(msg) + + table = [0] * (size_1d * size_2d * size_3d * channels) + idx_out = 0 + for b in range(size_3d): + for g in range(size_2d): + for r in range(size_1d): + table[idx_out : idx_out + channels] = callback( + r / (size_1d - 1), g / (size_2d - 1), b / (size_3d - 1) + ) + idx_out += channels + + return cls( + (size_1d, size_2d, size_3d), + table, + channels=channels, + target_mode=target_mode, + _copy_table=False, + ) + + def transform(self, callback, with_normals=False, channels=None, target_mode=None): + """Transforms the table values using provided callback and returns + a new LUT with altered values. + + :param callback: A function which takes old lookup table values + and returns a new set of values. The number + of arguments which function should take is + ``self.channels`` or ``3 + self.channels`` + if ``with_normals`` flag is set. + Should return a tuple of ``self.channels`` or + ``channels`` elements if it is set. + :param with_normals: If true, ``callback`` will be called with + coordinates in the color cube as the first + three arguments. Otherwise, ``callback`` + will be called only with actual color values. + :param channels: The number of channels in the resulting lookup table. + :param target_mode: Passed to the constructor of the resulting + lookup table. + """ + if channels not in (None, 3, 4): + msg = "Only 3 or 4 output channels are supported" + raise ValueError(msg) + ch_in = self.channels + ch_out = channels or ch_in + size_1d, size_2d, size_3d = self.size + + table = [0] * (size_1d * size_2d * size_3d * ch_out) + idx_in = 0 + idx_out = 0 + for b in range(size_3d): + for g in range(size_2d): + for r in range(size_1d): + values = self.table[idx_in : idx_in + ch_in] + if with_normals: + values = callback( + r / (size_1d - 1), + g / (size_2d - 1), + b / (size_3d - 1), + *values, + ) + else: + values = callback(*values) + table[idx_out : idx_out + ch_out] = values + idx_in += ch_in + idx_out += ch_out + + return type(self)( + self.size, + table, + channels=ch_out, + target_mode=target_mode or self.mode, + _copy_table=False, + ) + + def __repr__(self): + r = [ + f"{self.__class__.__name__} from {self.table.__class__.__name__}", + "size={:d}x{:d}x{:d}".format(*self.size), + f"channels={self.channels:d}", + ] + if self.mode: + r.append(f"target_mode={self.mode}") + return "<{}>".format(" ".join(r)) + + def filter(self, image): + from . import Image + + return image.color_lut_3d( + self.mode or image.mode, + Image.Resampling.BILINEAR, + self.channels, + self.size[0], + self.size[1], + self.size[2], + self.table, + ) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageFont.py b/venv/lib/python3.10/site-packages/PIL/ImageFont.py new file mode 100644 index 00000000..256c581d --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageFont.py @@ -0,0 +1,1252 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PIL raster font management +# +# History: +# 1996-08-07 fl created (experimental) +# 1997-08-25 fl minor adjustments to handle fonts from pilfont 0.3 +# 1999-02-06 fl rewrote most font management stuff in C +# 1999-03-17 fl take pth files into account in load_path (from Richard Jones) +# 2001-02-17 fl added freetype support +# 2001-05-09 fl added TransposedFont wrapper class +# 2002-03-04 fl make sure we have a "L" or "1" font +# 2002-12-04 fl skip non-directory entries in the system path +# 2003-04-29 fl add embedded default font +# 2003-09-27 fl added support for truetype charmap encodings +# +# Todo: +# Adapt to PILFONT2 format (16-bit fonts, compressed, single file) +# +# Copyright (c) 1997-2003 by Secret Labs AB +# Copyright (c) 1996-2003 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# + +from __future__ import annotations + +import base64 +import os +import sys +import warnings +from enum import IntEnum +from io import BytesIO +from typing import BinaryIO + +from . import Image +from ._typing import StrOrBytesPath +from ._util import is_directory, is_path + + +class Layout(IntEnum): + BASIC = 0 + RAQM = 1 + + +MAX_STRING_LENGTH = 1_000_000 + + +try: + from . import _imagingft as core +except ImportError as ex: + from ._util import DeferredError + + core = DeferredError.new(ex) + + +def _string_length_check(text): + if MAX_STRING_LENGTH is not None and len(text) > MAX_STRING_LENGTH: + msg = "too many characters in string" + raise ValueError(msg) + + +# FIXME: add support for pilfont2 format (see FontFile.py) + +# -------------------------------------------------------------------- +# Font metrics format: +# "PILfont" LF +# fontdescriptor LF +# (optional) key=value... LF +# "DATA" LF +# binary data: 256*10*2 bytes (dx, dy, dstbox, srcbox) +# +# To place a character, cut out srcbox and paste at dstbox, +# relative to the character position. Then move the character +# position according to dx, dy. +# -------------------------------------------------------------------- + + +class ImageFont: + """PIL font wrapper""" + + def _load_pilfont(self, filename): + with open(filename, "rb") as fp: + image = None + for ext in (".png", ".gif", ".pbm"): + if image: + image.close() + try: + fullname = os.path.splitext(filename)[0] + ext + image = Image.open(fullname) + except Exception: + pass + else: + if image and image.mode in ("1", "L"): + break + else: + if image: + image.close() + msg = "cannot find glyph data file" + raise OSError(msg) + + self.file = fullname + + self._load_pilfont_data(fp, image) + image.close() + + def _load_pilfont_data(self, file, image): + # read PILfont header + if file.readline() != b"PILfont\n": + msg = "Not a PILfont file" + raise SyntaxError(msg) + file.readline().split(b";") + self.info = [] # FIXME: should be a dictionary + while True: + s = file.readline() + if not s or s == b"DATA\n": + break + self.info.append(s) + + # read PILfont metrics + data = file.read(256 * 20) + + # check image + if image.mode not in ("1", "L"): + msg = "invalid font image mode" + raise TypeError(msg) + + image.load() + + self.font = Image.core.font(image.im, data) + + def getmask(self, text, mode="", *args, **kwargs): + """ + Create a bitmap for the text. + + If the font uses antialiasing, the bitmap should have mode ``L`` and use a + maximum value of 255. Otherwise, it should have mode ``1``. + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + .. versionadded:: 1.1.5 + + :return: An internal PIL storage memory instance as defined by the + :py:mod:`PIL.Image.core` interface module. + """ + _string_length_check(text) + Image._decompression_bomb_check(self.font.getsize(text)) + return self.font.getmask(text, mode) + + def getbbox(self, text, *args, **kwargs): + """ + Returns bounding box (in pixels) of given text. + + .. versionadded:: 9.2.0 + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + :return: ``(left, top, right, bottom)`` bounding box + """ + _string_length_check(text) + width, height = self.font.getsize(text) + return 0, 0, width, height + + def getlength(self, text, *args, **kwargs): + """ + Returns length (in pixels) of given text. + This is the amount by which following text should be offset. + + .. versionadded:: 9.2.0 + """ + _string_length_check(text) + width, height = self.font.getsize(text) + return width + + +## +# Wrapper for FreeType fonts. Application code should use the +# truetype factory function to create font objects. + + +class FreeTypeFont: + """FreeType font wrapper (requires _imagingft service)""" + + def __init__( + self, + font: StrOrBytesPath | BinaryIO | None = None, + size: float = 10, + index: int = 0, + encoding: str = "", + layout_engine: Layout | None = None, + ) -> None: + # FIXME: use service provider instead + + if size <= 0: + msg = "font size must be greater than 0" + raise ValueError(msg) + + self.path = font + self.size = size + self.index = index + self.encoding = encoding + + if layout_engine not in (Layout.BASIC, Layout.RAQM): + layout_engine = Layout.BASIC + if core.HAVE_RAQM: + layout_engine = Layout.RAQM + elif layout_engine == Layout.RAQM and not core.HAVE_RAQM: + warnings.warn( + "Raqm layout was requested, but Raqm is not available. " + "Falling back to basic layout." + ) + layout_engine = Layout.BASIC + + self.layout_engine = layout_engine + + def load_from_bytes(f): + self.font_bytes = f.read() + self.font = core.getfont( + "", size, index, encoding, self.font_bytes, layout_engine + ) + + if is_path(font): + font = os.path.realpath(os.fspath(font)) + if sys.platform == "win32": + font_bytes_path = font if isinstance(font, bytes) else font.encode() + try: + font_bytes_path.decode("ascii") + except UnicodeDecodeError: + # FreeType cannot load fonts with non-ASCII characters on Windows + # So load it into memory first + with open(font, "rb") as f: + load_from_bytes(f) + return + self.font = core.getfont( + font, size, index, encoding, layout_engine=layout_engine + ) + else: + load_from_bytes(font) + + def __getstate__(self): + return [self.path, self.size, self.index, self.encoding, self.layout_engine] + + def __setstate__(self, state): + path, size, index, encoding, layout_engine = state + self.__init__(path, size, index, encoding, layout_engine) + + def getname(self): + """ + :return: A tuple of the font family (e.g. Helvetica) and the font style + (e.g. Bold) + """ + return self.font.family, self.font.style + + def getmetrics(self): + """ + :return: A tuple of the font ascent (the distance from the baseline to + the highest outline point) and descent (the distance from the + baseline to the lowest outline point, a negative value) + """ + return self.font.ascent, self.font.descent + + def getlength(self, text, mode="", direction=None, features=None, language=None): + """ + Returns length (in pixels with 1/64 precision) of given text when rendered + in font with provided direction, features, and language. + + This is the amount by which following text should be offset. + Text bounding box may extend past the length in some fonts, + e.g. when using italics or accents. + + The result is returned as a float; it is a whole number if using basic layout. + + Note that the sum of two lengths may not equal the length of a concatenated + string due to kerning. If you need to adjust for kerning, include the following + character and subtract its length. + + For example, instead of :: + + hello = font.getlength("Hello") + world = font.getlength("World") + hello_world = hello + world # not adjusted for kerning + assert hello_world == font.getlength("HelloWorld") # may fail + + use :: + + hello = font.getlength("HelloW") - font.getlength("W") # adjusted for kerning + world = font.getlength("World") + hello_world = hello + world # adjusted for kerning + assert hello_world == font.getlength("HelloWorld") # True + + or disable kerning with (requires libraqm) :: + + hello = draw.textlength("Hello", font, features=["-kern"]) + world = draw.textlength("World", font, features=["-kern"]) + hello_world = hello + world # kerning is disabled, no need to adjust + assert hello_world == draw.textlength("HelloWorld", font, features=["-kern"]) + + .. versionadded:: 8.0.0 + + :param text: Text to measure. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + :param direction: Direction of the text. It can be 'rtl' (right to + left), 'ltr' (left to right) or 'ttb' (top to bottom). + Requires libraqm. + + :param features: A list of OpenType font features to be used during text + layout. This is usually used to turn on optional + font features that are not enabled by default, + for example 'dlig' or 'ss01', but can be also + used to turn off default font features for + example '-liga' to disable ligatures or '-kern' + to disable kerning. To get all supported + features, see + https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist + Requires libraqm. + + :param language: Language of the text. Different languages may use + different glyph shapes or ligatures. This parameter tells + the font which language the text is in, and to apply the + correct substitutions as appropriate, if available. + It should be a `BCP 47 language code + `_ + Requires libraqm. + + :return: Either width for horizontal text, or height for vertical text. + """ + _string_length_check(text) + return self.font.getlength(text, mode, direction, features, language) / 64 + + def getbbox( + self, + text, + mode="", + direction=None, + features=None, + language=None, + stroke_width=0, + anchor=None, + ): + """ + Returns bounding box (in pixels) of given text relative to given anchor + when rendered in font with provided direction, features, and language. + + Use :py:meth:`getlength()` to get the offset of following text with + 1/64 pixel precision. The bounding box includes extra margins for + some fonts, e.g. italics or accents. + + .. versionadded:: 8.0.0 + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + :param direction: Direction of the text. It can be 'rtl' (right to + left), 'ltr' (left to right) or 'ttb' (top to bottom). + Requires libraqm. + + :param features: A list of OpenType font features to be used during text + layout. This is usually used to turn on optional + font features that are not enabled by default, + for example 'dlig' or 'ss01', but can be also + used to turn off default font features for + example '-liga' to disable ligatures or '-kern' + to disable kerning. To get all supported + features, see + https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist + Requires libraqm. + + :param language: Language of the text. Different languages may use + different glyph shapes or ligatures. This parameter tells + the font which language the text is in, and to apply the + correct substitutions as appropriate, if available. + It should be a `BCP 47 language code + `_ + Requires libraqm. + + :param stroke_width: The width of the text stroke. + + :param anchor: The text anchor alignment. Determines the relative location of + the anchor to the text. The default alignment is top left, + specifically ``la`` for horizontal text and ``lt`` for + vertical text. See :ref:`text-anchors` for details. + + :return: ``(left, top, right, bottom)`` bounding box + """ + _string_length_check(text) + size, offset = self.font.getsize( + text, mode, direction, features, language, anchor + ) + left, top = offset[0] - stroke_width, offset[1] - stroke_width + width, height = size[0] + 2 * stroke_width, size[1] + 2 * stroke_width + return left, top, left + width, top + height + + def getmask( + self, + text, + mode="", + direction=None, + features=None, + language=None, + stroke_width=0, + anchor=None, + ink=0, + start=None, + ): + """ + Create a bitmap for the text. + + If the font uses antialiasing, the bitmap should have mode ``L`` and use a + maximum value of 255. If the font has embedded color data, the bitmap + should have mode ``RGBA``. Otherwise, it should have mode ``1``. + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + .. versionadded:: 1.1.5 + + :param direction: Direction of the text. It can be 'rtl' (right to + left), 'ltr' (left to right) or 'ttb' (top to bottom). + Requires libraqm. + + .. versionadded:: 4.2.0 + + :param features: A list of OpenType font features to be used during text + layout. This is usually used to turn on optional + font features that are not enabled by default, + for example 'dlig' or 'ss01', but can be also + used to turn off default font features for + example '-liga' to disable ligatures or '-kern' + to disable kerning. To get all supported + features, see + https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist + Requires libraqm. + + .. versionadded:: 4.2.0 + + :param language: Language of the text. Different languages may use + different glyph shapes or ligatures. This parameter tells + the font which language the text is in, and to apply the + correct substitutions as appropriate, if available. + It should be a `BCP 47 language code + `_ + Requires libraqm. + + .. versionadded:: 6.0.0 + + :param stroke_width: The width of the text stroke. + + .. versionadded:: 6.2.0 + + :param anchor: The text anchor alignment. Determines the relative location of + the anchor to the text. The default alignment is top left, + specifically ``la`` for horizontal text and ``lt`` for + vertical text. See :ref:`text-anchors` for details. + + .. versionadded:: 8.0.0 + + :param ink: Foreground ink for rendering in RGBA mode. + + .. versionadded:: 8.0.0 + + :param start: Tuple of horizontal and vertical offset, as text may render + differently when starting at fractional coordinates. + + .. versionadded:: 9.4.0 + + :return: An internal PIL storage memory instance as defined by the + :py:mod:`PIL.Image.core` interface module. + """ + return self.getmask2( + text, + mode, + direction=direction, + features=features, + language=language, + stroke_width=stroke_width, + anchor=anchor, + ink=ink, + start=start, + )[0] + + def getmask2( + self, + text, + mode="", + direction=None, + features=None, + language=None, + stroke_width=0, + anchor=None, + ink=0, + start=None, + *args, + **kwargs, + ): + """ + Create a bitmap for the text. + + If the font uses antialiasing, the bitmap should have mode ``L`` and use a + maximum value of 255. If the font has embedded color data, the bitmap + should have mode ``RGBA``. Otherwise, it should have mode ``1``. + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + .. versionadded:: 1.1.5 + + :param direction: Direction of the text. It can be 'rtl' (right to + left), 'ltr' (left to right) or 'ttb' (top to bottom). + Requires libraqm. + + .. versionadded:: 4.2.0 + + :param features: A list of OpenType font features to be used during text + layout. This is usually used to turn on optional + font features that are not enabled by default, + for example 'dlig' or 'ss01', but can be also + used to turn off default font features for + example '-liga' to disable ligatures or '-kern' + to disable kerning. To get all supported + features, see + https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist + Requires libraqm. + + .. versionadded:: 4.2.0 + + :param language: Language of the text. Different languages may use + different glyph shapes or ligatures. This parameter tells + the font which language the text is in, and to apply the + correct substitutions as appropriate, if available. + It should be a `BCP 47 language code + `_ + Requires libraqm. + + .. versionadded:: 6.0.0 + + :param stroke_width: The width of the text stroke. + + .. versionadded:: 6.2.0 + + :param anchor: The text anchor alignment. Determines the relative location of + the anchor to the text. The default alignment is top left, + specifically ``la`` for horizontal text and ``lt`` for + vertical text. See :ref:`text-anchors` for details. + + .. versionadded:: 8.0.0 + + :param ink: Foreground ink for rendering in RGBA mode. + + .. versionadded:: 8.0.0 + + :param start: Tuple of horizontal and vertical offset, as text may render + differently when starting at fractional coordinates. + + .. versionadded:: 9.4.0 + + :return: A tuple of an internal PIL storage memory instance as defined by the + :py:mod:`PIL.Image.core` interface module, and the text offset, the + gap between the starting coordinate and the first marking + """ + _string_length_check(text) + if start is None: + start = (0, 0) + + def fill(width, height): + size = (width, height) + Image._decompression_bomb_check(size) + return Image.core.fill("RGBA" if mode == "RGBA" else "L", size) + + return self.font.render( + text, + fill, + mode, + direction, + features, + language, + stroke_width, + anchor, + ink, + start[0], + start[1], + ) + + def font_variant( + self, font=None, size=None, index=None, encoding=None, layout_engine=None + ): + """ + Create a copy of this FreeTypeFont object, + using any specified arguments to override the settings. + + Parameters are identical to the parameters used to initialize this + object. + + :return: A FreeTypeFont object. + """ + if font is None: + try: + font = BytesIO(self.font_bytes) + except AttributeError: + font = self.path + return FreeTypeFont( + font=font, + size=self.size if size is None else size, + index=self.index if index is None else index, + encoding=self.encoding if encoding is None else encoding, + layout_engine=layout_engine or self.layout_engine, + ) + + def get_variation_names(self): + """ + :returns: A list of the named styles in a variation font. + :exception OSError: If the font is not a variation font. + """ + try: + names = self.font.getvarnames() + except AttributeError as e: + msg = "FreeType 2.9.1 or greater is required" + raise NotImplementedError(msg) from e + return [name.replace(b"\x00", b"") for name in names] + + def set_variation_by_name(self, name): + """ + :param name: The name of the style. + :exception OSError: If the font is not a variation font. + """ + names = self.get_variation_names() + if not isinstance(name, bytes): + name = name.encode() + index = names.index(name) + 1 + + if index == getattr(self, "_last_variation_index", None): + # When the same name is set twice in a row, + # there is an 'unknown freetype error' + # https://savannah.nongnu.org/bugs/?56186 + return + self._last_variation_index = index + + self.font.setvarname(index) + + def get_variation_axes(self): + """ + :returns: A list of the axes in a variation font. + :exception OSError: If the font is not a variation font. + """ + try: + axes = self.font.getvaraxes() + except AttributeError as e: + msg = "FreeType 2.9.1 or greater is required" + raise NotImplementedError(msg) from e + for axis in axes: + axis["name"] = axis["name"].replace(b"\x00", b"") + return axes + + def set_variation_by_axes(self, axes): + """ + :param axes: A list of values for each axis. + :exception OSError: If the font is not a variation font. + """ + try: + self.font.setvaraxes(axes) + except AttributeError as e: + msg = "FreeType 2.9.1 or greater is required" + raise NotImplementedError(msg) from e + + +class TransposedFont: + """Wrapper for writing rotated or mirrored text""" + + def __init__(self, font, orientation=None): + """ + Wrapper that creates a transposed font from any existing font + object. + + :param font: A font object. + :param orientation: An optional orientation. If given, this should + be one of Image.Transpose.FLIP_LEFT_RIGHT, Image.Transpose.FLIP_TOP_BOTTOM, + Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_180, or + Image.Transpose.ROTATE_270. + """ + self.font = font + self.orientation = orientation # any 'transpose' argument, or None + + def getmask(self, text, mode="", *args, **kwargs): + im = self.font.getmask(text, mode, *args, **kwargs) + if self.orientation is not None: + return im.transpose(self.orientation) + return im + + def getbbox(self, text, *args, **kwargs): + # TransposedFont doesn't support getmask2, move top-left point to (0, 0) + # this has no effect on ImageFont and simulates anchor="lt" for FreeTypeFont + left, top, right, bottom = self.font.getbbox(text, *args, **kwargs) + width = right - left + height = bottom - top + if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270): + return 0, 0, height, width + return 0, 0, width, height + + def getlength(self, text, *args, **kwargs): + if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270): + msg = "text length is undefined for text rotated by 90 or 270 degrees" + raise ValueError(msg) + return self.font.getlength(text, *args, **kwargs) + + +def load(filename): + """ + Load a font file. This function loads a font object from the given + bitmap font file, and returns the corresponding font object. + + :param filename: Name of font file. + :return: A font object. + :exception OSError: If the file could not be read. + """ + f = ImageFont() + f._load_pilfont(filename) + return f + + +def truetype(font=None, size=10, index=0, encoding="", layout_engine=None): + """ + Load a TrueType or OpenType font from a file or file-like object, + and create a font object. + This function loads a font object from the given file or file-like + object, and creates a font object for a font of the given size. + + Pillow uses FreeType to open font files. On Windows, be aware that FreeType + will keep the file open as long as the FreeTypeFont object exists. Windows + limits the number of files that can be open in C at once to 512, so if many + fonts are opened simultaneously and that limit is approached, an + ``OSError`` may be thrown, reporting that FreeType "cannot open resource". + A workaround would be to copy the file(s) into memory, and open that instead. + + This function requires the _imagingft service. + + :param font: A filename or file-like object containing a TrueType font. + If the file is not found in this filename, the loader may also + search in other directories, such as the :file:`fonts/` + directory on Windows or :file:`/Library/Fonts/`, + :file:`/System/Library/Fonts/` and :file:`~/Library/Fonts/` on + macOS. + + :param size: The requested size, in pixels. + :param index: Which font face to load (default is first available face). + :param encoding: Which font encoding to use (default is Unicode). Possible + encodings include (see the FreeType documentation for more + information): + + * "unic" (Unicode) + * "symb" (Microsoft Symbol) + * "ADOB" (Adobe Standard) + * "ADBE" (Adobe Expert) + * "ADBC" (Adobe Custom) + * "armn" (Apple Roman) + * "sjis" (Shift JIS) + * "gb " (PRC) + * "big5" + * "wans" (Extended Wansung) + * "joha" (Johab) + * "lat1" (Latin-1) + + This specifies the character set to use. It does not alter the + encoding of any text provided in subsequent operations. + :param layout_engine: Which layout engine to use, if available: + :attr:`.ImageFont.Layout.BASIC` or :attr:`.ImageFont.Layout.RAQM`. + If it is available, Raqm layout will be used by default. + Otherwise, basic layout will be used. + + Raqm layout is recommended for all non-English text. If Raqm layout + is not required, basic layout will have better performance. + + You can check support for Raqm layout using + :py:func:`PIL.features.check_feature` with ``feature="raqm"``. + + .. versionadded:: 4.2.0 + :return: A font object. + :exception OSError: If the file could not be read. + :exception ValueError: If the font size is not greater than zero. + """ + + def freetype(font): + return FreeTypeFont(font, size, index, encoding, layout_engine) + + try: + return freetype(font) + except OSError: + if not is_path(font): + raise + ttf_filename = os.path.basename(font) + + dirs = [] + if sys.platform == "win32": + # check the windows font repository + # NOTE: must use uppercase WINDIR, to work around bugs in + # 1.5.2's os.environ.get() + windir = os.environ.get("WINDIR") + if windir: + dirs.append(os.path.join(windir, "fonts")) + elif sys.platform in ("linux", "linux2"): + lindirs = os.environ.get("XDG_DATA_DIRS") + if not lindirs: + # According to the freedesktop spec, XDG_DATA_DIRS should + # default to /usr/share + lindirs = "/usr/share" + dirs += [os.path.join(lindir, "fonts") for lindir in lindirs.split(":")] + elif sys.platform == "darwin": + dirs += [ + "/Library/Fonts", + "/System/Library/Fonts", + os.path.expanduser("~/Library/Fonts"), + ] + + ext = os.path.splitext(ttf_filename)[1] + first_font_with_a_different_extension = None + for directory in dirs: + for walkroot, walkdir, walkfilenames in os.walk(directory): + for walkfilename in walkfilenames: + if ext and walkfilename == ttf_filename: + return freetype(os.path.join(walkroot, walkfilename)) + elif not ext and os.path.splitext(walkfilename)[0] == ttf_filename: + fontpath = os.path.join(walkroot, walkfilename) + if os.path.splitext(fontpath)[1] == ".ttf": + return freetype(fontpath) + if not ext and first_font_with_a_different_extension is None: + first_font_with_a_different_extension = fontpath + if first_font_with_a_different_extension: + return freetype(first_font_with_a_different_extension) + raise + + +def load_path(filename): + """ + Load font file. Same as :py:func:`~PIL.ImageFont.load`, but searches for a + bitmap font along the Python path. + + :param filename: Name of font file. + :return: A font object. + :exception OSError: If the file could not be read. + """ + for directory in sys.path: + if is_directory(directory): + if not isinstance(filename, str): + filename = filename.decode("utf-8") + try: + return load(os.path.join(directory, filename)) + except OSError: + pass + msg = "cannot find font file" + raise OSError(msg) + + +def load_default(size: float | None = None) -> FreeTypeFont | ImageFont: + """If FreeType support is available, load a version of Aileron Regular, + https://dotcolon.net/font/aileron, with a more limited character set. + + Otherwise, load a "better than nothing" font. + + .. versionadded:: 1.1.4 + + :param size: The font size of Aileron Regular. + + .. versionadded:: 10.1.0 + + :return: A font object. + """ + if core.__class__.__name__ == "module" or size is not None: + f = truetype( + BytesIO( + base64.b64decode( + b""" +AAEAAAAPAIAAAwBwRkZUTYwDlUAAADFoAAAAHEdERUYAqADnAAAo8AAAACRHUE9ThhmITwAAKfgAA +AduR1NVQnHxefoAACkUAAAA4k9TLzJovoHLAAABeAAAAGBjbWFw5lFQMQAAA6gAAAGqZ2FzcP//AA +MAACjoAAAACGdseWYmRXoPAAAGQAAAHfhoZWFkE18ayQAAAPwAAAA2aGhlYQboArEAAAE0AAAAJGh +tdHjjERZ8AAAB2AAAAdBsb2NhuOexrgAABVQAAADqbWF4cAC7AEYAAAFYAAAAIG5hbWUr+h5lAAAk +OAAAA6Jwb3N0D3oPTQAAJ9wAAAEKAAEAAAABGhxJDqIhXw889QALA+gAAAAA0Bqf2QAAAADhCh2h/ +2r/LgOxAyAAAAAIAAIAAAAAAAAAAQAAA8r/GgAAA7j/av9qA7EAAQAAAAAAAAAAAAAAAAAAAHQAAQ +AAAHQAQwAFAAAAAAACAAAAAQABAAAAQAAAAAAAAAADAfoBkAAFAAgCigJYAAAASwKKAlgAAAFeADI +BPgAAAAAFAAAAAAAAAAAAAAcAAAAAAAAAAAAAAABVS1dOAEAAIPsCAwL/GgDIA8oA5iAAAJMAAAAA +AhICsgAAACAAAwH0AAAAAAAAAU0AAADYAAAA8gA5AVMAVgJEAEYCRAA1AuQAKQKOAEAAsAArATsAZ +AE7AB4CMABVAkQAUADc/+EBEgAgANwAJQEv//sCRAApAkQAggJEADwCRAAtAkQAIQJEADkCRAArAk +QAMgJEACwCRAAxANwAJQDc/+ECRABnAkQAUAJEAEQB8wAjA1QANgJ/AB0CcwBkArsALwLFAGQCSwB +kAjcAZALGAC8C2gBkAQgAZAIgADcCYQBkAj8AZANiAGQCzgBkAuEALwJWAGQC3QAvAmsAZAJJADQC +ZAAiAqoAXgJuACADuAAaAnEAGQJFABMCTwAuATMAYgEv//sBJwAiAkQAUAH0ADIBLAApAhMAJAJjA +EoCEQAeAmcAHgIlAB4BIgAVAmcAHgJRAEoA7gA+AOn/8wIKAEoA9wBGA1cASgJRAEoCSgAeAmMASg +JnAB4BSgBKAcsAGAE5ABQCUABCAgIAAQMRAAEB4v/6AgEAAQHOABQBLwBAAPoAYAEvACECRABNA0Y +AJAItAHgBKgAcAkQAUAEsAHQAygAgAi0AOQD3ADYA9wAWAaEANgGhABYCbAAlAYMAeAGDADkA6/9q +AhsAFAIKABUB/QAVAAAAAwAAAAMAAAAcAAEAAAAAAKQAAwABAAAAHAAEAIgAAAAeABAAAwAOAH4Aq +QCrALEAtAC3ALsgGSAdICYgOiBEISL7Av//AAAAIACpAKsAsAC0ALcAuyAYIBwgJiA5IEQhIvsB// +//4/+5/7j/tP+y/7D/reBR4E/gR+A14CzfTwVxAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAEGAAABAAAAAAAAAAECAAAAAgAAAAAAAAAAAAAAAAAAAAEAAAMEBQYHCAkKCwwNDg8QERIT +FBUWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMT +U5PUFFSU1RVVldYWVpbXF1eX2BhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQAAA +AAAAAAYnFmAAAAAABlAAAAAAAAAAAAAAAAAAAAAAAAAAAAY2htAAAAAAAAAABrbGlqAAAAAHAAbm9 +ycwBnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmACYAJgAmAD4AUgCCAMoBCgFO +AVwBcgGIAaYBvAHKAdYB6AH2AgwCIAJKAogCpgLWAw4DIgNkA5wDugPUA+gD/AQQBEYEogS8BPoFJ +gVSBWoFgAWwBcoF1gX6BhQGJAZMBmgGiga0BuIHGgdUB2YHkAeiB8AH3AfyCAoIHAgqCDoITghcCG +oIogjSCPoJKglYCXwJwgnqCgIKKApACl4Klgq8CtwLDAs8C1YLjAuyC9oL7gwMDCYMSAxgDKAMrAz +qDQoNTA1mDYQNoA2uDcAN2g3oDfYODA4iDkoOXA5sDnoOnA7EDvwAAAAFAAAAAAH0ArwAAwAGAAkA +DAAPAAAxESERAxMhExcRASELARETAfT6qv6syKr+jgFUqsiqArz9RAGLAP/+1P8B/v3VAP8BLP4CA +P8AAgA5//IAuQKyAAMACwAANyMDMwIyFhQGIiY0oE4MZk84JCQ4JLQB/v3AJDgkJDgAAgBWAeUBPA +LfAAMABwAAEyMnMxcjJzOmRgpagkYKWgHl+vr6AAAAAAIARgAAAf4CsgAbAB8AAAEHMxUjByM3Iwc +jNyM1MzcjNTM3MwczNzMHMxUrAQczAZgdZXEvOi9bLzovWmYdZXEvOi9bLzovWp9bHlsBn4w429vb +2ziMONvb29s4jAAAAAMANf+mAg4DDAAfACYALAAAJRQGBxUjNS4BJzMeARcRLgE0Njc1MxUeARcjJ +icVHgEBFBYXNQ4BExU+ATU0Ag5xWDpgcgRcBz41Xl9oVTpVYwpcC1ttXP6cLTQuM5szOrVRZwlOTQ +ZqVzZECAEAGlukZAlOTQdrUG8O7iNlAQgxNhDlCDj+8/YGOjReAAAAAAUAKf/yArsCvAAHAAsAFQA +dACcAABIyFhQGIiY0EyMBMwQiBhUUFjI2NTQSMhYUBiImNDYiBhUUFjI2NTR5iFBQiFCVVwHAV/5c +OiMjOiPmiFBQiFCxOiMjOiMCvFaSVlaS/ZoCsjIzMC80NC8w/uNWklZWkhozMC80NC8wAAAAAgBA/ +/ICbgLAACIALgAAARUjEQYjIiY1NDY3LgE1NDYzMhcVJiMiBhUUFhcWOwE1MxUFFBYzMjc1IyIHDg +ECbmBcYYOOVkg7R4hsQjY4Q0RNRD4SLDxW/pJUXzksPCkUUk0BgUb+zBVUZ0BkDw5RO1huCkULQzp +COAMBcHDHRz0J/AIHRQAAAAEAKwHlAIUC3wADAAATIycze0YKWgHl+gAAAAABAGT/sAEXAwwACQAA +EzMGEBcjLgE0Nt06dXU6OUBAAwzG/jDGVePs4wAAAAEAHv+wANEDDAAJAAATMx4BFAYHIzYQHjo5Q +EA5OnUDDFXj7ONVxgHQAAAAAQBVAFIB2wHbAA4AAAE3FwcXBycHJzcnNxcnMwEtmxOfcTJjYzJxnx +ObCj4BKD07KYolmZkliik7PbMAAQBQAFUB9AIlAAsAAAEjFSM1IzUzNTMVMwH0tTq1tTq1AR/Kyjj +OzgAAAAAB/+H/iACMAGQABAAANwcjNzOMWlFOXVrS3AAAAQAgAP8A8gE3AAMAABMjNTPy0tIA/zgA +AQAl//IApQByAAcAADYyFhQGIiY0STgkJDgkciQ4JCQ4AAAAAf/7/+IBNALQAAMAABcjEzM5Pvs+H +gLuAAAAAAIAKf/yAhsCwAADAAcAABIgECA2IBAgKQHy/g5gATL+zgLA/TJEAkYAAAAAAQCCAAABlg +KyAAgAAAERIxEHNTc2MwGWVr6SIygCsv1OAldxW1sWAAEAPAAAAg4CwAAZAAA3IRUhNRM+ATU0JiM +iDwEjNz4BMzIWFRQGB7kBUv4x+kI2QTt+EAFWAQp8aGVtSl5GRjEA/0RVLzlLmAoKa3FsUkNxXQAA +AAEALf/yAhYCwAAqAAABHgEVFAYjIi8BMxceATMyNjU0KwE1MzI2NTQmIyIGDwEjNz4BMzIWFRQGA +YxBSZJo2RUBVgEHV0JBUaQREUBUQzc5TQcBVgEKfGhfcEMBbxJbQl1x0AoKRkZHPn9GSD80QUVCCg +pfbGBPOlgAAAACACEAAAIkArIACgAPAAAlIxUjNSE1ATMRMyMRBg8BAiRXVv6qAVZWV60dHLCurq4 +rAdn+QgFLMibzAAABADn/8gIZArIAHQAAATIWFRQGIyIvATMXFjMyNjU0JiMiByMTIRUhBzc2ATNv +d5Fl1RQBVgIad0VSTkVhL1IwAYj+vh8rMAHHgGdtgcUKCoFXTU5bYgGRRvAuHQAAAAACACv/8gITA +sAAFwAjAAABMhYVFAYjIhE0NjMyFh8BIycmIyIDNzYTMjY1NCYjIgYVFBYBLmp7imr0l3RZdAgBXA +IYZ5wKJzU6QVNJSz5SUAHSgWltiQFGxcNlVQoKdv7sPiz+ZF1LTmJbU0lhAAAAAQAyAAACGgKyAAY +AAAEVASMBITUCGv6oXAFL/oECsij9dgJsRgAAAAMALP/xAhgCwAAWACAALAAAAR4BFRQGIyImNTQ2 +Ny4BNTQ2MhYVFAYmIgYVFBYyNjU0AzI2NTQmIyIGFRQWAZQ5S5BmbIpPOjA7ecp5P2F8Q0J8RIVJS +0pLTEtOAW0TXTxpZ2ZqPF0SE1A3VWVlVTdQ/UU0N0RENzT9/ko+Ok1NOj1LAAIAMf/yAhkCwAAXAC +MAAAEyERQGIyImLwEzFxYzMhMHBiMiJjU0NhMyNjU0JiMiBhUUFgEl9Jd0WXQIAVwCGGecCic1SWp +7imo+UlBAQVNJAsD+usXDZVUKCnYBFD4sgWltif5kW1NJYV1LTmIAAAACACX/8gClAiAABwAPAAAS +MhYUBiImNBIyFhQGIiY0STgkJDgkJDgkJDgkAiAkOCQkOP52JDgkJDgAAAAC/+H/iAClAiAABwAMA +AASMhYUBiImNBMHIzczSTgkJDgkaFpSTl4CICQ4JCQ4/mba5gAAAQBnAB4B+AH0AAYAAAENARUlNS +UB+P6qAVb+bwGRAbCmpkbJRMkAAAIAUAC7AfQBuwADAAcAAAEhNSERITUhAfT+XAGk/lwBpAGDOP8 +AOAABAEQAHgHVAfQABgAAARUFNS0BNQHV/m8BVv6qAStEyUSmpkYAAAAAAgAj//IB1ALAABgAIAAA +ATIWFRQHDgEHIz4BNz4BNTQmIyIGByM+ARIyFhQGIiY0AQRibmktIAJWBSEqNig+NTlHBFoDezQ4J +CQ4JALAZ1BjaS03JS1DMD5LLDQ/SUVgcv2yJDgkJDgAAAAAAgA2/5gDFgKYADYAQgAAAQMGFRQzMj +Y1NCYjIg4CFRQWMzI2NxcGIyImNTQ+AjMyFhUUBiMiJwcGIyImNTQ2MzIfATcHNzYmIyIGFRQzMjY +Cej8EJjJJlnBAfGQ+oHtAhjUYg5OPx0h2k06Os3xRWQsVLjY5VHtdPBwJETcJDyUoOkZEJz8B0f74 +EQ8kZl6EkTFZjVOLlyknMVm1pmCiaTq4lX6CSCknTVRmmR8wPdYnQzxuSWVGAAIAHQAAAncCsgAHA +AoAACUjByMTMxMjATMDAcj+UVz4dO5d/sjPZPT0ArL9TgE6ATQAAAADAGQAAAJMArIAEAAbACcAAA +EeARUUBgcGKwERMzIXFhUUJRUzMjc2NTQnJiMTPgE1NCcmKwEVMzIBvkdHZkwiNt7LOSGq/oeFHBt +hahIlSTM+cB8Yj5UWAW8QT0VYYgwFArIEF5Fv1eMED2NfDAL93AU+N24PBP0AAAAAAQAv//ICjwLA +ABsAAAEyFh8BIycmIyIGFRQWMzI/ATMHDgEjIiY1NDYBdX+PCwFWAiKiaHx5ZaIiAlYBCpWBk6a0A +sCAagoKpqN/gaOmCgplhcicn8sAAAIAZAAAAp8CsgAMABkAAAEeARUUBgcGKwERMzITPgE1NCYnJi +sBETMyAY59lJp8IzXN0jUVWmdjWRs5d3I4Aq4QqJWUug8EArL9mQ+PeHGHDgX92gAAAAABAGQAAAI +vArIACwAAJRUhESEVIRUhFSEVAi/+NQHB/pUBTf6zRkYCskbwRvAAAAABAGQAAAIlArIACQAAExUh +FSERIxEhFboBQ/69VgHBAmzwRv7KArJGAAAAAAEAL//yAo8CwAAfAAABMxEjNQcGIyImNTQ2MzIWH +wEjJyYjIgYVFBYzMjY1IwGP90wfPnWTprSSf48LAVYCIqJofHllVG+hAU3+s3hARsicn8uAagoKpq +N/gaN1XAAAAAEAZAAAAowCsgALAAABESMRIREjETMRIRECjFb+hFZWAXwCsv1OAS7+0gKy/sQBPAA +AAAABAGQAAAC6ArIAAwAAMyMRM7pWVgKyAAABADf/8gHoArIAEwAAAREUBw4BIyImLwEzFxYzMjc2 +NREB6AIFcGpgbQIBVgIHfXQKAQKy/lYxIltob2EpKYyEFD0BpwAAAAABAGQAAAJ0ArIACwAACQEjA +wcVIxEzEQEzATsBJ3ntQlZWAVVlAWH+nwEnR+ACsv6RAW8AAQBkAAACLwKyAAUAACUVIREzEQIv/j +VWRkYCsv2UAAABAGQAAAMUArIAFAAAAREjETQ3BgcDIwMmJxYVESMRMxsBAxRWAiMxemx8NxsCVo7 +MywKy/U4BY7ZLco7+nAFmoFxLtP6dArL9lwJpAAAAAAEAZAAAAoACsgANAAAhIwEWFREjETMBJjUR +MwKAhP67A1aEAUUDVAJeeov+pwKy/aJ5jAFZAAAAAgAv//ICuwLAAAkAEwAAEiAWFRQGICY1NBIyN +jU0JiIGFRTbATSsrP7MrNrYenrYegLAxaKhxsahov47nIeIm5uIhwACAGQAAAJHArIADgAYAAABHg +EVFAYHBisBESMRMzITNjQnJisBETMyAZRUX2VOHzuAVtY7GlxcGDWIiDUCrgtnVlVpCgT+5gKy/rU +V1BUF/vgAAAACAC//zAK9AsAAEgAcAAAlFhcHJiMiBwYjIiY1NDYgFhUUJRQWMjY1NCYiBgI9PUMx +UDcfKh8omqysATSs/dR62Hp62HpICTg7NgkHxqGixcWitbWHnJyHiJubAAIAZAAAAlgCsgAXACMAA +CUWFyMmJyYnJisBESMRMzIXHgEVFAYHFiUzMjc+ATU0JyYrAQIqDCJfGQwNWhAhglbiOx9QXEY1Tv +6bhDATMj1lGSyMtYgtOXR0BwH+1wKyBApbU0BSESRAAgVAOGoQBAABADT/8gIoAsAAJQAAATIWFyM +uASMiBhUUFhceARUUBiMiJiczHgEzMjY1NCYnLgE1NDYBOmd2ClwGS0E6SUNRdW+HZnKKC1wPWkQ9 +Uk1cZGuEAsBwXUJHNjQ3OhIbZVZZbm5kREo+NT5DFRdYUFdrAAAAAAEAIgAAAmQCsgAHAAABIxEjE +SM1IQJk9lb2AkICbP2UAmxGAAEAXv/yAmQCsgAXAAABERQHDgEiJicmNREzERQXHgEyNjc2NRECZA +IIgfCBCAJWAgZYmlgGAgKy/k0qFFxzc1wUKgGz/lUrEkRQUEQSKwGrAAAAAAEAIAAAAnoCsgAGAAA +hIwMzGwEzAYJ07l3N1FwCsv2PAnEAAAEAGgAAA7ECsgAMAAABAyMLASMDMxsBMxsBA7HAcZyicrZi +kaB0nJkCsv1OAlP9rQKy/ZsCW/2kAmYAAAEAGQAAAm8CsgALAAAhCwEjEwMzGwEzAxMCCsrEY/bkY +re+Y/D6AST+3AFcAVb+5gEa/q3+oQAAAQATAAACUQKyAAgAAAERIxEDMxsBMwFdVvRjwLphARD+8A +EQAaL+sQFPAAABAC4AAAI5ArIACQAAJRUhNQEhNSEVAQI5/fUBof57Aen+YUZGQgIqRkX92QAAAAA +BAGL/sAEFAwwABwAAARUjETMVIxEBBWlpowMMOP0UOANcAAAB//v/4gE0AtAAAwAABSMDMwE0Pvs+ +HgLuAAAAAQAi/7AAxQMMAAcAABcjNTMRIzUzxaNpaaNQOALsOAABAFAA1wH0AmgABgAAJQsBIxMzE +wGwjY1GsESw1wFZ/qcBkf5vAAAAAQAy/6oBwv/iAAMAAAUhNSEBwv5wAZBWOAAAAAEAKQJEALYCsg +ADAAATIycztjhVUAJEbgAAAAACACT/8gHQAiAAHQAlAAAhJwcGIyImNTQ2OwE1NCcmIyIHIz4BMzI +XFh0BFBcnMjY9ASYVFAF6CR0wVUtgkJoiAgdgaQlaBm1Zrg4DCuQ9R+5MOSFQR1tbDiwUUXBUXowf +J8c9SjRORzYSgVwAAAAAAgBK//ICRQLfABEAHgAAATIWFRQGIyImLwEVIxEzETc2EzI2NTQmIyIGH +QEUFgFUcYCVbiNJEyNWVigySElcU01JXmECIJd4i5QTEDRJAt/+3jkq/hRuZV55ZWsdX14AAQAe// +IB9wIgABgAAAEyFhcjJiMiBhUUFjMyNjczDgEjIiY1NDYBF152DFocbEJXU0A1Rw1aE3pbaoKQAiB +oWH5qZm1tPDlaXYuLgZcAAAACAB7/8gIZAt8AEQAeAAABESM1BwYjIiY1NDYzMhYfAREDMjY9ATQm +IyIGFRQWAhlWKDJacYCVbiNJEyOnSV5hQUlcUwLf/SFVOSqXeIuUExA0ARb9VWVrHV9ebmVeeQACA +B7/8gH9AiAAFQAbAAABFAchHgEzMjY3Mw4BIyImNTQ2MzIWJyIGByEmAf0C/oAGUkA1SwlaD4FXbI +WObmt45UBVBwEqDQEYFhNjWD84W16Oh3+akU9aU60AAAEAFQAAARoC8gAWAAATBh0BMxUjESMRIzU +zNTQ3PgEzMhcVJqcDbW1WOTkDB0k8Hx5oAngVITRC/jQBzEIsJRs5PwVHEwAAAAIAHv8uAhkCIAAi +AC8AAAERFAcOASMiLwEzFx4BMzI2NzY9AQcGIyImNTQ2MzIWHwE1AzI2PQE0JiMiBhUUFgIZAQSEd +NwRAVcBBU5DTlUDASgyWnGAlW4jSRMjp0leYUFJXFMCEv5wSh1zeq8KCTI8VU0ZIQk5Kpd4i5QTED +RJ/iJlax1fXm5lXnkAAQBKAAACCgLkABcAAAEWFREjETQnLgEHDgEdASMRMxE3NjMyFgIIAlYCBDs +6RVRWViE5UVViAYUbQP7WASQxGzI7AQJyf+kC5P7TPSxUAAACAD4AAACsAsAABwALAAASMhYUBiIm +NBMjETNeLiAgLiBiVlYCwCAuICAu/WACEgAC//P/LgCnAsAABwAVAAASMhYUBiImNBcRFAcGIyInN +RY3NjURWS4gIC4gYgMLcRwNSgYCAsAgLiAgLo79wCUbZAJGBzMOHgJEAAAAAQBKAAACCALfAAsAAC +EnBxUjETMREzMHEwGTwTJWVvdu9/rgN6kC3/4oAQv6/ugAAQBG//wA3gLfAA8AABMRFBceATcVBiM +iJicmNRGcAQIcIxkkKi4CAQLf/bkhERoSBD4EJC8SNAJKAAAAAQBKAAADEAIgACQAAAEWFREjETQn +JiMiFREjETQnJiMiFREjETMVNzYzMhYXNzYzMhYDCwVWBAxedFYEDF50VlYiJko7ThAvJkpEVAGfI +jn+vAEcQyRZ1v76ARxDJFnW/voCEk08HzYtRB9HAAAAAAEASgAAAgoCIAAWAAABFhURIxE0JyYjIg +YdASMRMxU3NjMyFgIIAlYCCXBEVVZWITlRVWIBhRtA/tYBJDEbbHR/6QISWz0sVAAAAAACAB7/8gI +sAiAABwARAAASIBYUBiAmNBIyNjU0JiIGFRSlAQCHh/8Ah7ieWlqeWgIgn/Cfn/D+s3ZfYHV1YF8A +AgBK/zwCRQIgABEAHgAAATIWFRQGIyImLwERIxEzFTc2EzI2NTQmIyIGHQEUFgFUcYCVbiNJEyNWV +igySElcU01JXmECIJd4i5QTEDT+8wLWVTkq/hRuZV55ZWsdX14AAgAe/zwCGQIgABEAHgAAAREjEQ +cGIyImNTQ2MzIWHwE1AzI2PQE0JiMiBhUUFgIZVigyWnGAlW4jSRMjp0leYUFJXFMCEv0qARk5Kpd +4i5QTEDRJ/iJlax1fXm5lXnkAAQBKAAABPgIeAA0AAAEyFxUmBhURIxEzFTc2ARoWDkdXVlYwIwIe +B0EFVlf+0gISU0cYAAEAGP/yAa0CIAAjAAATMhYXIyYjIgYVFBYXHgEVFAYjIiYnMxYzMjY1NCYnL +gE1NDbkV2MJWhNdKy04PF1XbVhWbgxaE2ktOjlEUllkAiBaS2MrJCUoEBlPQkhOVFZoKCUmLhIWSE +BIUwAAAAEAFP/4ARQCiQAXAAATERQXHgE3FQYjIiYnJjURIzUzNTMVMxWxAQMmMx8qMjMEAUdHVmM +BzP7PGw4mFgY/BSwxDjQBNUJ7e0IAAAABAEL/8gICAhIAFwAAAREjNQcGIyImJyY1ETMRFBceATMy +Nj0BAgJWITlRT2EKBVYEBkA1RFECEv3uWj4qTToiOQE+/tIlJC43c4DpAAAAAAEAAQAAAfwCEgAGA +AABAyMDMxsBAfzJaclfop8CEv3uAhL+LQHTAAABAAEAAAMLAhIADAAAAQMjCwEjAzMbATMbAQMLqW +Z2dmapY3t0a3Z7AhL97gG+/kICEv5AAcD+QwG9AAAB//oAAAHWAhIACwAAARMjJwcjEwMzFzczARq +8ZIuKY763ZoWFYwEO/vLV1QEMAQbNzQAAAQAB/y4B+wISABEAAAEDDgEjIic1FjMyNj8BAzMbAQH7 +2iFZQB8NDRIpNhQH02GenQIS/cFVUAJGASozEwIt/i4B0gABABQAAAGxAg4ACQAAJRUhNQEhNSEVA +QGx/mMBNP7iAYL+zkREQgGIREX+ewAAAAABAED/sAEOAwwALAAAASMiBhUUFxYVFAYHHgEVFAcGFR +QWOwEVIyImNTQ3NjU0JzU2NTQnJjU0NjsBAQ4MKiMLDS4pKS4NCyMqDAtERAwLUlILDERECwLUGBk +WTlsgKzUFBTcrIFtOFhkYOC87GFVMIkUIOAhFIkxVGDsvAAAAAAEAYP84AJoDIAADAAAXIxEzmjo6 +yAPoAAEAIf+wAO8DDAAsAAATFQYVFBcWFRQGKwE1MzI2NTQnJjU0NjcuATU0NzY1NCYrATUzMhYVF +AcGFRTvUgsMREQLDCojCw0uKSkuDQsjKgwLREQMCwF6OAhFIkxVGDsvOBgZFk5bICs1BQU3KyBbTh +YZGDgvOxhVTCJFAAABAE0A3wH2AWQAEwAAATMUIyImJyYjIhUjNDMyFhcWMzIBvjhuGywtQR0xOG4 +bLC1BHTEBZIURGCNMhREYIwAAAwAk/94DIgLoAAcAEQApAAAAIBYQBiAmECQgBhUUFiA2NTQlMhYX +IyYjIgYUFjMyNjczDgEjIiY1NDYBAQFE3d3+vN0CB/7wubkBELn+xVBnD1wSWDo+QTcqOQZcEmZWX +HN2Aujg/rbg4AFKpr+Mjb6+jYxbWEldV5ZZNShLVn5na34AAgB4AFIB9AGeAAUACwAAAQcXIyc3Mw +cXIyc3AUqJiUmJifOJiUmJiQGepqampqampqYAAAIAHAHSAQ4CwAAHAA8AABIyFhQGIiY0NiIGFBY +yNjRgakREakSTNCEhNCECwEJqQkJqCiM4IyM4AAAAAAIAUAAAAfQCCwALAA8AAAEzFSMVIzUjNTM1 +MxMhNSEBP7W1OrW1OrX+XAGkAVs4tLQ4sP31OAAAAQB0AkQBAQKyAAMAABMjNzOsOD1QAkRuAAAAA +AEAIADsAKoBdgAHAAASMhYUBiImNEg6KCg6KAF2KDooKDoAAAIAOQBSAbUBngAFAAsAACUHIzcnMw +UHIzcnMwELiUmJiUkBM4lJiYlJ+KampqampqYAAAABADYB5QDhAt8ABAAAEzczByM2Xk1OXQHv8Po +AAQAWAeUAwQLfAAQAABMHIzczwV5NTl0C1fD6AAIANgHlAYsC3wAEAAkAABM3MwcjPwEzByM2Xk1O +XapeTU5dAe/w+grw+gAAAgAWAeUBawLfAAQACQAAEwcjNzMXByM3M8FeTU5dql5NTl0C1fD6CvD6A +AADACX/8gI1AHIABwAPABcAADYyFhQGIiY0NjIWFAYiJjQ2MhYUBiImNEk4JCQ4JOw4JCQ4JOw4JC +Q4JHIkOCQkOCQkOCQkOCQkOCQkOAAAAAEAeABSAUoBngAFAAABBxcjJzcBSomJSYmJAZ6mpqamAAA +AAAEAOQBSAQsBngAFAAAlByM3JzMBC4lJiYlJ+KampgAAAf9qAAABgQKyAAMAACsBATM/VwHAVwKy +AAAAAAIAFAHIAdwClAAHABQAABMVIxUjNSM1BRUjNwcjJxcjNTMXN9pKMkoByDICKzQqATJLKysCl +CmjoykBy46KiY3Lm5sAAQAVAAABvALyABgAAAERIxEjESMRIzUzNTQ3NjMyFxUmBgcGHQEBvFbCVj +k5AxHHHx5iVgcDAg798gHM/jQBzEIOJRuWBUcIJDAVIRYAAAABABX//AHkAvIAJQAAJR4BNxUGIyI +mJyY1ESYjIgcGHQEzFSMRIxEjNTM1NDc2MzIXERQBowIcIxkkKi4CAR4nXgwDbW1WLy8DEbNdOmYa +EQQ/BCQvEjQCFQZWFSEWQv40AcxCDiUblhP9uSEAAAAAAAAWAQ4AAQAAAAAAAAATACgAAQAAAAAAA +QAHAEwAAQAAAAAAAgAHAGQAAQAAAAAAAwAaAKIAAQAAAAAABAAHAM0AAQAAAAAABQA8AU8AAQAAAA +AABgAPAawAAQAAAAAACAALAdQAAQAAAAAACQALAfgAAQAAAAAACwAXAjQAAQAAAAAADAAXAnwAAwA +BBAkAAAAmAAAAAwABBAkAAQAOADwAAwABBAkAAgAOAFQAAwABBAkAAwA0AGwAAwABBAkABAAOAL0A +AwABBAkABQB4ANUAAwABBAkABgAeAYwAAwABBAkACAAWAbwAAwABBAkACQAWAeAAAwABBAkACwAuA +gQAAwABBAkADAAuAkwATgBvACAAUgBpAGcAaAB0AHMAIABSAGUAcwBlAHIAdgBlAGQALgAATm8gUm +lnaHRzIFJlc2VydmVkLgAAQQBpAGwAZQByAG8AbgAAQWlsZXJvbgAAUgBlAGcAdQBsAGEAcgAAUmV +ndWxhcgAAMQAuADEAMAAyADsAVQBLAFcATgA7AEEAaQBsAGUAcgBvAG4ALQBSAGUAZwB1AGwAYQBy +AAAxLjEwMjtVS1dOO0FpbGVyb24tUmVndWxhcgAAQQBpAGwAZQByAG8AbgAAQWlsZXJvbgAAVgBlA +HIAcwBpAG8AbgAgADEALgAxADAAMgA7AFAAUwAgADAAMAAxAC4AMQAwADIAOwBoAG8AdABjAG8Abg +B2ACAAMQAuADAALgA3ADAAOwBtAGEAawBlAG8AdABmAC4AbABpAGIAMgAuADUALgA1ADgAMwAyADk +AAFZlcnNpb24gMS4xMDI7UFMgMDAxLjEwMjtob3Rjb252IDEuMC43MDttYWtlb3RmLmxpYjIuNS41 +ODMyOQAAQQBpAGwAZQByAG8AbgAtAFIAZQBnAHUAbABhAHIAAEFpbGVyb24tUmVndWxhcgAAUwBvA +HIAYQAgAFMAYQBnAGEAbgBvAABTb3JhIFNhZ2FubwAAUwBvAHIAYQAgAFMAYQBnAGEAbgBvAABTb3 +JhIFNhZ2FubwAAaAB0AHQAcAA6AC8ALwB3AHcAdwAuAGQAbwB0AGMAbwBsAG8AbgAuAG4AZQB0AAB +odHRwOi8vd3d3LmRvdGNvbG9uLm5ldAAAaAB0AHQAcAA6AC8ALwB3AHcAdwAuAGQAbwB0AGMAbwBs +AG8AbgAuAG4AZQB0AABodHRwOi8vd3d3LmRvdGNvbG9uLm5ldAAAAAACAAAAAAAA/4MAMgAAAAAAA +AAAAAAAAAAAAAAAAAAAAHQAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAEgATAB +QAFQAWABcAGAAZABoAGwAcAB0AHgAfACAAIQAiACMAJAAlACYAJwAoACkAKgArACwALQAuAC8AMAA +xADIAMwA0ADUANgA3ADgAOQA6ADsAPAA9AD4APwBAAEEAQgBDAEQARQBGAEcASABJAEoASwBMAE0A +TgBPAFAAUQBSAFMAVABVAFYAVwBYAFkAWgBbAFwAXQBeAF8AYABhAIsAqQCDAJMAjQDDAKoAtgC3A +LQAtQCrAL4AvwC8AIwAwADBAAAAAAAB//8AAgABAAAADAAAABwAAAACAAIAAwBxAAEAcgBzAAIABA +AAAAIAAAABAAAACgBMAGYAAkRGTFQADmxhdG4AGgAEAAAAAP//AAEAAAAWAANDQVQgAB5NT0wgABZ +ST00gABYAAP//AAEAAAAA//8AAgAAAAEAAmxpZ2EADmxvY2wAFAAAAAEAAQAAAAEAAAACAAYAEAAG +AAAAAgASADQABAAAAAEATAADAAAAAgAQABYAAQAcAAAAAQABAE8AAQABAGcAAQABAE8AAwAAAAIAE +AAWAAEAHAAAAAEAAQAvAAEAAQBnAAEAAQAvAAEAGgABAAgAAgAGAAwAcwACAE8AcgACAEwAAQABAE +kAAAABAAAACgBGAGAAAkRGTFQADmxhdG4AHAAEAAAAAP//AAIAAAABABYAA0NBVCAAFk1PTCAAFlJ +PTSAAFgAA//8AAgAAAAEAAmNwc3AADmtlcm4AFAAAAAEAAAAAAAEAAQACAAYADgABAAAAAQASAAIA +AAACAB4ANgABAAoABQAFAAoAAgABACQAPQAAAAEAEgAEAAAAAQAMAAEAOP/nAAEAAQAkAAIGigAEA +AAFJAXKABoAGQAA//gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAD/sv+4/+z/7v/MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAD/xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/9T/6AAAAAD/8QAA +ABD/vQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/7gAAAAAAAAAAAAAAAAAA//MAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAP/5AAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gAAD/4AAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//L/9AAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAA/+gAAAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/zAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/mAAAAAAAAAAAAAAAAAAD +/4gAA//AAAAAA//YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+AAAAAAAAP/OAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/zv/qAAAAAP/0AAAACAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/ZAAD/egAA/1kAAAAA/5D/rgAAAAAAAAAAAA +AAAAAAAAAAAAAAAAD/9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAD/8AAA/7b/8P+wAAD/8P/E/98AAAAA/8P/+P/0//oAAAAAAAAAAAAA//gA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+AAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/w//C/9MAAP/SAAD/9wAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAD/yAAA/+kAAAAA//QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/9wAAAAD//QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAP/2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAP/cAAAAAAAAAAAAAAAA/7YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAP/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/6AAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAkAFAAEAAAAAQACwAAABcA +BgAAAAAAAAAIAA4AAAAAAAsAEgAAAAAAAAATABkAAwANAAAAAQAJAAAAAAAAAAAAAAAAAAAAGAAAA +AAABwAAAAAAAAAAAAAAFQAFAAAAAAAYABgAAAAUAAAACgAAAAwAAgAPABEAFgAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAEAEQBdAAYAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAcAAAAAAAAABwAAAAAACAAAAAAAAAAAAAcAAAAHAAAAEwAJ +ABUADgAPAAAACwAQAAAAAAAAAAAAAAAAAAUAGAACAAIAAgAAAAIAGAAXAAAAGAAAABYAFgACABYAA +gAWAAAAEQADAAoAFAAMAA0ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAAAAEgAGAAEAHgAkAC +YAJwApACoALQAuAC8AMgAzADcAOAA5ADoAPAA9AEUASABOAE8AUgBTAFUAVwBZAFoAWwBcAF0AcwA +AAAAAAQAAAADa3tfFAAAAANAan9kAAAAA4QodoQ== +""" + ) + ), + 10 if size is None else size, + layout_engine=Layout.BASIC, + ) + else: + f = ImageFont() + f._load_pilfont_data( + # courB08 + BytesIO( + base64.b64decode( + b""" +UElMZm9udAo7Ozs7OzsxMDsKREFUQQoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAA//8AAQAAAAAAAAABAAEA +BgAAAAH/+gADAAAAAQAAAAMABgAGAAAAAf/6AAT//QADAAAABgADAAYAAAAA//kABQABAAYAAAAL +AAgABgAAAAD/+AAFAAEACwAAABAACQAGAAAAAP/5AAUAAAAQAAAAFQAHAAYAAP////oABQAAABUA +AAAbAAYABgAAAAH/+QAE//wAGwAAAB4AAwAGAAAAAf/5AAQAAQAeAAAAIQAIAAYAAAAB//kABAAB +ACEAAAAkAAgABgAAAAD/+QAE//0AJAAAACgABAAGAAAAAP/6AAX//wAoAAAALQAFAAYAAAAB//8A +BAACAC0AAAAwAAMABgAAAAD//AAF//0AMAAAADUAAQAGAAAAAf//AAMAAAA1AAAANwABAAYAAAAB +//kABQABADcAAAA7AAgABgAAAAD/+QAFAAAAOwAAAEAABwAGAAAAAP/5AAYAAABAAAAARgAHAAYA +AAAA//kABQAAAEYAAABLAAcABgAAAAD/+QAFAAAASwAAAFAABwAGAAAAAP/5AAYAAABQAAAAVgAH +AAYAAAAA//kABQAAAFYAAABbAAcABgAAAAD/+QAFAAAAWwAAAGAABwAGAAAAAP/5AAUAAABgAAAA +ZQAHAAYAAAAA//kABQAAAGUAAABqAAcABgAAAAD/+QAFAAAAagAAAG8ABwAGAAAAAf/8AAMAAABv +AAAAcQAEAAYAAAAA//wAAwACAHEAAAB0AAYABgAAAAD/+gAE//8AdAAAAHgABQAGAAAAAP/7AAT/ +/gB4AAAAfAADAAYAAAAB//oABf//AHwAAACAAAUABgAAAAD/+gAFAAAAgAAAAIUABgAGAAAAAP/5 +AAYAAQCFAAAAiwAIAAYAAP////oABgAAAIsAAACSAAYABgAA////+gAFAAAAkgAAAJgABgAGAAAA +AP/6AAUAAACYAAAAnQAGAAYAAP////oABQAAAJ0AAACjAAYABgAA////+gAFAAAAowAAAKkABgAG +AAD////6AAUAAACpAAAArwAGAAYAAAAA//oABQAAAK8AAAC0AAYABgAA////+gAGAAAAtAAAALsA +BgAGAAAAAP/6AAQAAAC7AAAAvwAGAAYAAP////oABQAAAL8AAADFAAYABgAA////+gAGAAAAxQAA +AMwABgAGAAD////6AAUAAADMAAAA0gAGAAYAAP////oABQAAANIAAADYAAYABgAA////+gAGAAAA +2AAAAN8ABgAGAAAAAP/6AAUAAADfAAAA5AAGAAYAAP////oABQAAAOQAAADqAAYABgAAAAD/+gAF +AAEA6gAAAO8ABwAGAAD////6AAYAAADvAAAA9gAGAAYAAAAA//oABQAAAPYAAAD7AAYABgAA//// ++gAFAAAA+wAAAQEABgAGAAD////6AAYAAAEBAAABCAAGAAYAAP////oABgAAAQgAAAEPAAYABgAA +////+gAGAAABDwAAARYABgAGAAAAAP/6AAYAAAEWAAABHAAGAAYAAP////oABgAAARwAAAEjAAYA +BgAAAAD/+gAFAAABIwAAASgABgAGAAAAAf/5AAQAAQEoAAABKwAIAAYAAAAA//kABAABASsAAAEv +AAgABgAAAAH/+QAEAAEBLwAAATIACAAGAAAAAP/5AAX//AEyAAABNwADAAYAAAAAAAEABgACATcA +AAE9AAEABgAAAAH/+QAE//wBPQAAAUAAAwAGAAAAAP/7AAYAAAFAAAABRgAFAAYAAP////kABQAA +AUYAAAFMAAcABgAAAAD/+wAFAAABTAAAAVEABQAGAAAAAP/5AAYAAAFRAAABVwAHAAYAAAAA//sA +BQAAAVcAAAFcAAUABgAAAAD/+QAFAAABXAAAAWEABwAGAAAAAP/7AAYAAgFhAAABZwAHAAYAAP// +//kABQAAAWcAAAFtAAcABgAAAAD/+QAGAAABbQAAAXMABwAGAAAAAP/5AAQAAgFzAAABdwAJAAYA +AP////kABgAAAXcAAAF+AAcABgAAAAD/+QAGAAABfgAAAYQABwAGAAD////7AAUAAAGEAAABigAF +AAYAAP////sABQAAAYoAAAGQAAUABgAAAAD/+wAFAAABkAAAAZUABQAGAAD////7AAUAAgGVAAAB +mwAHAAYAAAAA//sABgACAZsAAAGhAAcABgAAAAD/+wAGAAABoQAAAacABQAGAAAAAP/7AAYAAAGn +AAABrQAFAAYAAAAA//kABgAAAa0AAAGzAAcABgAA////+wAGAAABswAAAboABQAGAAD////7AAUA +AAG6AAABwAAFAAYAAP////sABgAAAcAAAAHHAAUABgAAAAD/+wAGAAABxwAAAc0ABQAGAAD////7 +AAYAAgHNAAAB1AAHAAYAAAAA//sABQAAAdQAAAHZAAUABgAAAAH/+QAFAAEB2QAAAd0ACAAGAAAA +Av/6AAMAAQHdAAAB3gAHAAYAAAAA//kABAABAd4AAAHiAAgABgAAAAD/+wAF//0B4gAAAecAAgAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAB +//sAAwACAecAAAHpAAcABgAAAAD/+QAFAAEB6QAAAe4ACAAGAAAAAP/5AAYAAAHuAAAB9AAHAAYA +AAAA//oABf//AfQAAAH5AAUABgAAAAD/+QAGAAAB+QAAAf8ABwAGAAAAAv/5AAMAAgH/AAACAAAJ +AAYAAAAA//kABQABAgAAAAIFAAgABgAAAAH/+gAE//sCBQAAAggAAQAGAAAAAP/5AAYAAAIIAAAC +DgAHAAYAAAAB//kABf/+Ag4AAAISAAUABgAA////+wAGAAACEgAAAhkABQAGAAAAAP/7AAX//gIZ +AAACHgADAAYAAAAA//wABf/9Ah4AAAIjAAEABgAAAAD/+QAHAAACIwAAAioABwAGAAAAAP/6AAT/ ++wIqAAACLgABAAYAAAAA//kABP/8Ai4AAAIyAAMABgAAAAD/+gAFAAACMgAAAjcABgAGAAAAAf/5 +AAT//QI3AAACOgAEAAYAAAAB//kABP/9AjoAAAI9AAQABgAAAAL/+QAE//sCPQAAAj8AAgAGAAD/ +///7AAYAAgI/AAACRgAHAAYAAAAA//kABgABAkYAAAJMAAgABgAAAAH//AAD//0CTAAAAk4AAQAG +AAAAAf//AAQAAgJOAAACUQADAAYAAAAB//kABP/9AlEAAAJUAAQABgAAAAH/+QAF//4CVAAAAlgA +BQAGAAD////7AAYAAAJYAAACXwAFAAYAAP////kABgAAAl8AAAJmAAcABgAA////+QAGAAACZgAA +Am0ABwAGAAD////5AAYAAAJtAAACdAAHAAYAAAAA//sABQACAnQAAAJ5AAcABgAA////9wAGAAAC +eQAAAoAACQAGAAD////3AAYAAAKAAAAChwAJAAYAAP////cABgAAAocAAAKOAAkABgAA////9wAG +AAACjgAAApUACQAGAAD////4AAYAAAKVAAACnAAIAAYAAP////cABgAAApwAAAKjAAkABgAA//// ++gAGAAACowAAAqoABgAGAAAAAP/6AAUAAgKqAAACrwAIAAYAAP////cABQAAAq8AAAK1AAkABgAA +////9wAFAAACtQAAArsACQAGAAD////3AAUAAAK7AAACwQAJAAYAAP////gABQAAAsEAAALHAAgA +BgAAAAD/9wAEAAACxwAAAssACQAGAAAAAP/3AAQAAALLAAACzwAJAAYAAAAA//cABAAAAs8AAALT +AAkABgAAAAD/+AAEAAAC0wAAAtcACAAGAAD////6AAUAAALXAAAC3QAGAAYAAP////cABgAAAt0A +AALkAAkABgAAAAD/9wAFAAAC5AAAAukACQAGAAAAAP/3AAUAAALpAAAC7gAJAAYAAAAA//cABQAA +Au4AAALzAAkABgAAAAD/9wAFAAAC8wAAAvgACQAGAAAAAP/4AAUAAAL4AAAC/QAIAAYAAAAA//oA +Bf//Av0AAAMCAAUABgAA////+gAGAAADAgAAAwkABgAGAAD////3AAYAAAMJAAADEAAJAAYAAP// +//cABgAAAxAAAAMXAAkABgAA////9wAGAAADFwAAAx4ACQAGAAD////4AAYAAAAAAAoABwASAAYA +AP////cABgAAAAcACgAOABMABgAA////+gAFAAAADgAKABQAEAAGAAD////6AAYAAAAUAAoAGwAQ +AAYAAAAA//gABgAAABsACgAhABIABgAAAAD/+AAGAAAAIQAKACcAEgAGAAAAAP/4AAYAAAAnAAoA +LQASAAYAAAAA//gABgAAAC0ACgAzABIABgAAAAD/+QAGAAAAMwAKADkAEQAGAAAAAP/3AAYAAAA5 +AAoAPwATAAYAAP////sABQAAAD8ACgBFAA8ABgAAAAD/+wAFAAIARQAKAEoAEQAGAAAAAP/4AAUA +AABKAAoATwASAAYAAAAA//gABQAAAE8ACgBUABIABgAAAAD/+AAFAAAAVAAKAFkAEgAGAAAAAP/5 +AAUAAABZAAoAXgARAAYAAAAA//gABgAAAF4ACgBkABIABgAAAAD/+AAGAAAAZAAKAGoAEgAGAAAA +AP/4AAYAAABqAAoAcAASAAYAAAAA//kABgAAAHAACgB2ABEABgAAAAD/+AAFAAAAdgAKAHsAEgAG +AAD////4AAYAAAB7AAoAggASAAYAAAAA//gABQAAAIIACgCHABIABgAAAAD/+AAFAAAAhwAKAIwA +EgAGAAAAAP/4AAUAAACMAAoAkQASAAYAAAAA//gABQAAAJEACgCWABIABgAAAAD/+QAFAAAAlgAK +AJsAEQAGAAAAAP/6AAX//wCbAAoAoAAPAAYAAAAA//oABQABAKAACgClABEABgAA////+AAGAAAA +pQAKAKwAEgAGAAD////4AAYAAACsAAoAswASAAYAAP////gABgAAALMACgC6ABIABgAA////+QAG +AAAAugAKAMEAEQAGAAD////4AAYAAgDBAAoAyAAUAAYAAP////kABQACAMgACgDOABMABgAA//// ++QAGAAIAzgAKANUAEw== +""" + ) + ), + Image.open( + BytesIO( + base64.b64decode( + b""" +iVBORw0KGgoAAAANSUhEUgAAAx4AAAAUAQAAAAArMtZoAAAEwElEQVR4nABlAJr/AHVE4czCI/4u +Mc4b7vuds/xzjz5/3/7u/n9vMe7vnfH/9++vPn/xyf5zhxzjt8GHw8+2d83u8x27199/nxuQ6Od9 +M43/5z2I+9n9ZtmDBwMQECDRQw/eQIQohJXxpBCNVE6QCCAAAAD//wBlAJr/AgALyj1t/wINwq0g +LeNZUworuN1cjTPIzrTX6ofHWeo3v336qPzfEwRmBnHTtf95/fglZK5N0PDgfRTslpGBvz7LFc4F +IUXBWQGjQ5MGCx34EDFPwXiY4YbYxavpnhHFrk14CDAAAAD//wBlAJr/AgKqRooH2gAgPeggvUAA +Bu2WfgPoAwzRAABAAAAAAACQgLz/3Uv4Gv+gX7BJgDeeGP6AAAD1NMDzKHD7ANWr3loYbxsAD791 +NAADfcoIDyP44K/jv4Y63/Z+t98Ovt+ub4T48LAAAAD//wBlAJr/AuplMlADJAAAAGuAphWpqhMx +in0A/fRvAYBABPgBwBUgABBQ/sYAyv9g0bCHgOLoGAAAAAAAREAAwI7nr0ArYpow7aX8//9LaP/9 +SjdavWA8ePHeBIKB//81/83ndznOaXx379wAAAD//wBlAJr/AqDxW+D3AABAAbUh/QMnbQag/gAY +AYDAAACgtgD/gOqAAAB5IA/8AAAk+n9w0AAA8AAAmFRJuPo27ciC0cD5oeW4E7KA/wD3ECMAn2tt +y8PgwH8AfAxFzC0JzeAMtratAsC/ffwAAAD//wBlAJr/BGKAyCAA4AAAAvgeYTAwHd1kmQF5chkG +ABoMIHcL5xVpTfQbUqzlAAAErwAQBgAAEOClA5D9il08AEh/tUzdCBsXkbgACED+woQg8Si9VeqY +lODCn7lmF6NhnAEYgAAA/NMIAAAAAAD//2JgjLZgVGBg5Pv/Tvpc8hwGBjYGJADjHDrAwPzAjv/H +/Wf3PzCwtzcwHmBgYGcwbZz8wHaCAQMDOwMDQ8MCBgYOC3W7mp+f0w+wHOYxO3OG+e376hsMZjk3 +AAAAAP//YmCMY2A4wMAIN5e5gQETPD6AZisDAwMDgzSDAAPjByiHcQMDAwMDg1nOze1lByRu5/47 +c4859311AYNZzg0AAAAA//9iYGDBYihOIIMuwIjGL39/fwffA8b//xv/P2BPtzzHwCBjUQAAAAD/ +/yLFBrIBAAAA//9i1HhcwdhizX7u8NZNzyLbvT97bfrMf/QHI8evOwcSqGUJAAAA//9iYBB81iSw +pEE170Qrg5MIYydHqwdDQRMrAwcVrQAAAAD//2J4x7j9AAMDn8Q/BgYLBoaiAwwMjPdvMDBYM1Tv +oJodAAAAAP//Yqo/83+dxePWlxl3npsel9lvLfPcqlE9725C+acfVLMEAAAA//9i+s9gwCoaaGMR +evta/58PTEWzr21hufPjA8N+qlnBwAAAAAD//2JiWLci5v1+HmFXDqcnULE/MxgYGBj+f6CaJQAA +AAD//2Ji2FrkY3iYpYC5qDeGgeEMAwPDvwQBBoYvcTwOVLMEAAAA//9isDBgkP///0EOg9z35v// +Gc/eeW7BwPj5+QGZhANUswMAAAD//2JgqGBgYGBgqEMXlvhMPUsAAAAA//8iYDd1AAAAAP//AwDR +w7IkEbzhVQAAAABJRU5ErkJggg== +""" + ) + ) + ), + ) + return f diff --git a/venv/lib/python3.10/site-packages/PIL/ImageGrab.py b/venv/lib/python3.10/site-packages/PIL/ImageGrab.py new file mode 100644 index 00000000..3f3be706 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageGrab.py @@ -0,0 +1,186 @@ +# +# The Python Imaging Library +# $Id$ +# +# screen grabber +# +# History: +# 2001-04-26 fl created +# 2001-09-17 fl use builtin driver, if present +# 2002-11-19 fl added grabclipboard support +# +# Copyright (c) 2001-2002 by Secret Labs AB +# Copyright (c) 2001-2002 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import os +import shutil +import subprocess +import sys +import tempfile + +from . import Image + + +def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=None): + if xdisplay is None: + if sys.platform == "darwin": + fh, filepath = tempfile.mkstemp(".png") + os.close(fh) + args = ["screencapture"] + if bbox: + left, top, right, bottom = bbox + args += ["-R", f"{left},{top},{right-left},{bottom-top}"] + subprocess.call(args + ["-x", filepath]) + im = Image.open(filepath) + im.load() + os.unlink(filepath) + if bbox: + im_resized = im.resize((right - left, bottom - top)) + im.close() + return im_resized + return im + elif sys.platform == "win32": + offset, size, data = Image.core.grabscreen_win32( + include_layered_windows, all_screens + ) + im = Image.frombytes( + "RGB", + size, + data, + # RGB, 32-bit line padding, origin lower left corner + "raw", + "BGR", + (size[0] * 3 + 3) & -4, + -1, + ) + if bbox: + x0, y0 = offset + left, top, right, bottom = bbox + im = im.crop((left - x0, top - y0, right - x0, bottom - y0)) + return im + try: + if not Image.core.HAVE_XCB: + msg = "Pillow was built without XCB support" + raise OSError(msg) + size, data = Image.core.grabscreen_x11(xdisplay) + except OSError: + if ( + xdisplay is None + and sys.platform not in ("darwin", "win32") + and shutil.which("gnome-screenshot") + ): + fh, filepath = tempfile.mkstemp(".png") + os.close(fh) + subprocess.call(["gnome-screenshot", "-f", filepath]) + im = Image.open(filepath) + im.load() + os.unlink(filepath) + if bbox: + im_cropped = im.crop(bbox) + im.close() + return im_cropped + return im + else: + raise + else: + im = Image.frombytes("RGB", size, data, "raw", "BGRX", size[0] * 4, 1) + if bbox: + im = im.crop(bbox) + return im + + +def grabclipboard(): + if sys.platform == "darwin": + fh, filepath = tempfile.mkstemp(".png") + os.close(fh) + commands = [ + 'set theFile to (open for access POSIX file "' + + filepath + + '" with write permission)', + "try", + " write (the clipboard as «class PNGf») to theFile", + "end try", + "close access theFile", + ] + script = ["osascript"] + for command in commands: + script += ["-e", command] + subprocess.call(script) + + im = None + if os.stat(filepath).st_size != 0: + im = Image.open(filepath) + im.load() + os.unlink(filepath) + return im + elif sys.platform == "win32": + fmt, data = Image.core.grabclipboard_win32() + if fmt == "file": # CF_HDROP + import struct + + o = struct.unpack_from("I", data)[0] + if data[16] != 0: + files = data[o:].decode("utf-16le").split("\0") + else: + files = data[o:].decode("mbcs").split("\0") + return files[: files.index("")] + if isinstance(data, bytes): + data = io.BytesIO(data) + if fmt == "png": + from . import PngImagePlugin + + return PngImagePlugin.PngImageFile(data) + elif fmt == "DIB": + from . import BmpImagePlugin + + return BmpImagePlugin.DibImageFile(data) + return None + else: + if os.getenv("WAYLAND_DISPLAY"): + session_type = "wayland" + elif os.getenv("DISPLAY"): + session_type = "x11" + else: # Session type check failed + session_type = None + + if shutil.which("wl-paste") and session_type in ("wayland", None): + args = ["wl-paste", "-t", "image"] + elif shutil.which("xclip") and session_type in ("x11", None): + args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"] + else: + msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux" + raise NotImplementedError(msg) + + p = subprocess.run(args, capture_output=True) + if p.returncode != 0: + err = p.stderr + for silent_error in [ + # wl-paste, when the clipboard is empty + b"Nothing is copied", + # Ubuntu/Debian wl-paste, when the clipboard is empty + b"No selection", + # Ubuntu/Debian wl-paste, when an image isn't available + b"No suitable type of content copied", + # wl-paste or Ubuntu/Debian xclip, when an image isn't available + b" not available", + # xclip, when an image isn't available + b"cannot convert ", + # xclip, when the clipboard isn't initialized + b"xclip: Error: There is no owner for the ", + ]: + if silent_error in err: + return None + msg = f"{args[0]} error" + if err: + msg += f": {err.strip().decode()}" + raise ChildProcessError(msg) + + data = io.BytesIO(p.stdout) + im = Image.open(data) + im.load() + return im diff --git a/venv/lib/python3.10/site-packages/PIL/ImageMath.py b/venv/lib/python3.10/site-packages/PIL/ImageMath.py new file mode 100644 index 00000000..77472a24 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageMath.py @@ -0,0 +1,357 @@ +# +# The Python Imaging Library +# $Id$ +# +# a simple math add-on for the Python Imaging Library +# +# History: +# 1999-02-15 fl Original PIL Plus release +# 2005-05-05 fl Simplified and cleaned up for PIL 1.1.6 +# 2005-09-12 fl Fixed int() and float() for Python 2.4.1 +# +# Copyright (c) 1999-2005 by Secret Labs AB +# Copyright (c) 2005 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import builtins +from types import CodeType +from typing import Any, Callable + +from . import Image, _imagingmath +from ._deprecate import deprecate + + +class _Operand: + """Wraps an image operand, providing standard operators""" + + def __init__(self, im: Image.Image): + self.im = im + + def __fixup(self, im1: _Operand | float) -> Image.Image: + # convert image to suitable mode + if isinstance(im1, _Operand): + # argument was an image. + if im1.im.mode in ("1", "L"): + return im1.im.convert("I") + elif im1.im.mode in ("I", "F"): + return im1.im + else: + msg = f"unsupported mode: {im1.im.mode}" + raise ValueError(msg) + else: + # argument was a constant + if isinstance(im1, (int, float)) and self.im.mode in ("1", "L", "I"): + return Image.new("I", self.im.size, im1) + else: + return Image.new("F", self.im.size, im1) + + def apply( + self, + op: str, + im1: _Operand | float, + im2: _Operand | float | None = None, + mode: str | None = None, + ) -> _Operand: + im_1 = self.__fixup(im1) + if im2 is None: + # unary operation + out = Image.new(mode or im_1.mode, im_1.size, None) + im_1.load() + try: + op = getattr(_imagingmath, op + "_" + im_1.mode) + except AttributeError as e: + msg = f"bad operand type for '{op}'" + raise TypeError(msg) from e + _imagingmath.unop(op, out.im.id, im_1.im.id) + else: + # binary operation + im_2 = self.__fixup(im2) + if im_1.mode != im_2.mode: + # convert both arguments to floating point + if im_1.mode != "F": + im_1 = im_1.convert("F") + if im_2.mode != "F": + im_2 = im_2.convert("F") + if im_1.size != im_2.size: + # crop both arguments to a common size + size = ( + min(im_1.size[0], im_2.size[0]), + min(im_1.size[1], im_2.size[1]), + ) + if im_1.size != size: + im_1 = im_1.crop((0, 0) + size) + if im_2.size != size: + im_2 = im_2.crop((0, 0) + size) + out = Image.new(mode or im_1.mode, im_1.size, None) + im_1.load() + im_2.load() + try: + op = getattr(_imagingmath, op + "_" + im_1.mode) + except AttributeError as e: + msg = f"bad operand type for '{op}'" + raise TypeError(msg) from e + _imagingmath.binop(op, out.im.id, im_1.im.id, im_2.im.id) + return _Operand(out) + + # unary operators + def __bool__(self) -> bool: + # an image is "true" if it contains at least one non-zero pixel + return self.im.getbbox() is not None + + def __abs__(self) -> _Operand: + return self.apply("abs", self) + + def __pos__(self) -> _Operand: + return self + + def __neg__(self) -> _Operand: + return self.apply("neg", self) + + # binary operators + def __add__(self, other: _Operand | float) -> _Operand: + return self.apply("add", self, other) + + def __radd__(self, other: _Operand | float) -> _Operand: + return self.apply("add", other, self) + + def __sub__(self, other: _Operand | float) -> _Operand: + return self.apply("sub", self, other) + + def __rsub__(self, other: _Operand | float) -> _Operand: + return self.apply("sub", other, self) + + def __mul__(self, other: _Operand | float) -> _Operand: + return self.apply("mul", self, other) + + def __rmul__(self, other: _Operand | float) -> _Operand: + return self.apply("mul", other, self) + + def __truediv__(self, other: _Operand | float) -> _Operand: + return self.apply("div", self, other) + + def __rtruediv__(self, other: _Operand | float) -> _Operand: + return self.apply("div", other, self) + + def __mod__(self, other: _Operand | float) -> _Operand: + return self.apply("mod", self, other) + + def __rmod__(self, other: _Operand | float) -> _Operand: + return self.apply("mod", other, self) + + def __pow__(self, other: _Operand | float) -> _Operand: + return self.apply("pow", self, other) + + def __rpow__(self, other: _Operand | float) -> _Operand: + return self.apply("pow", other, self) + + # bitwise + def __invert__(self) -> _Operand: + return self.apply("invert", self) + + def __and__(self, other: _Operand | float) -> _Operand: + return self.apply("and", self, other) + + def __rand__(self, other: _Operand | float) -> _Operand: + return self.apply("and", other, self) + + def __or__(self, other: _Operand | float) -> _Operand: + return self.apply("or", self, other) + + def __ror__(self, other: _Operand | float) -> _Operand: + return self.apply("or", other, self) + + def __xor__(self, other: _Operand | float) -> _Operand: + return self.apply("xor", self, other) + + def __rxor__(self, other: _Operand | float) -> _Operand: + return self.apply("xor", other, self) + + def __lshift__(self, other: _Operand | float) -> _Operand: + return self.apply("lshift", self, other) + + def __rshift__(self, other: _Operand | float) -> _Operand: + return self.apply("rshift", self, other) + + # logical + def __eq__(self, other): + return self.apply("eq", self, other) + + def __ne__(self, other): + return self.apply("ne", self, other) + + def __lt__(self, other: _Operand | float) -> _Operand: + return self.apply("lt", self, other) + + def __le__(self, other: _Operand | float) -> _Operand: + return self.apply("le", self, other) + + def __gt__(self, other: _Operand | float) -> _Operand: + return self.apply("gt", self, other) + + def __ge__(self, other: _Operand | float) -> _Operand: + return self.apply("ge", self, other) + + +# conversions +def imagemath_int(self: _Operand) -> _Operand: + return _Operand(self.im.convert("I")) + + +def imagemath_float(self: _Operand) -> _Operand: + return _Operand(self.im.convert("F")) + + +# logical +def imagemath_equal(self: _Operand, other: _Operand | float | None) -> _Operand: + return self.apply("eq", self, other, mode="I") + + +def imagemath_notequal(self: _Operand, other: _Operand | float | None) -> _Operand: + return self.apply("ne", self, other, mode="I") + + +def imagemath_min(self: _Operand, other: _Operand | float | None) -> _Operand: + return self.apply("min", self, other) + + +def imagemath_max(self: _Operand, other: _Operand | float | None) -> _Operand: + return self.apply("max", self, other) + + +def imagemath_convert(self: _Operand, mode: str) -> _Operand: + return _Operand(self.im.convert(mode)) + + +ops = { + "int": imagemath_int, + "float": imagemath_float, + "equal": imagemath_equal, + "notequal": imagemath_notequal, + "min": imagemath_min, + "max": imagemath_max, + "convert": imagemath_convert, +} + + +def lambda_eval( + expression: Callable[[dict[str, Any]], Any], + options: dict[str, Any] = {}, + **kw: Any, +) -> Any: + """ + Returns the result of an image function. + + :py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band + images, use the :py:meth:`~PIL.Image.Image.split` method or + :py:func:`~PIL.Image.merge` function. + + :param expression: A function that receives a dictionary. + :param options: Values to add to the function's dictionary. You + can either use a dictionary, or one or more keyword + arguments. + :return: The expression result. This is usually an image object, but can + also be an integer, a floating point value, or a pixel tuple, + depending on the expression. + """ + + args: dict[str, Any] = ops.copy() + args.update(options) + args.update(kw) + for k, v in args.items(): + if hasattr(v, "im"): + args[k] = _Operand(v) + + out = expression(args) + try: + return out.im + except AttributeError: + return out + + +def unsafe_eval( + expression: str, + options: dict[str, Any] = {}, + **kw: Any, +) -> Any: + """ + Evaluates an image expression. This uses Python's ``eval()`` function to process + the expression string, and carries the security risks of doing so. It is not + recommended to process expressions without considering this. + :py:meth:`~lambda_eval` is a more secure alternative. + + :py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band + images, use the :py:meth:`~PIL.Image.Image.split` method or + :py:func:`~PIL.Image.merge` function. + + :param expression: A string containing a Python-style expression. + :param options: Values to add to the evaluation context. You + can either use a dictionary, or one or more keyword + arguments. + :return: The evaluated expression. This is usually an image object, but can + also be an integer, a floating point value, or a pixel tuple, + depending on the expression. + """ + + # build execution namespace + args: dict[str, Any] = ops.copy() + for k in list(options.keys()) + list(kw.keys()): + if "__" in k or hasattr(builtins, k): + msg = f"'{k}' not allowed" + raise ValueError(msg) + + args.update(options) + args.update(kw) + for k, v in args.items(): + if hasattr(v, "im"): + args[k] = _Operand(v) + + compiled_code = compile(expression, "", "eval") + + def scan(code: CodeType) -> None: + for const in code.co_consts: + if type(const) is type(compiled_code): + scan(const) + + for name in code.co_names: + if name not in args and name != "abs": + msg = f"'{name}' not allowed" + raise ValueError(msg) + + scan(compiled_code) + out = builtins.eval(expression, {"__builtins": {"abs": abs}}, args) + try: + return out.im + except AttributeError: + return out + + +def eval( + expression: str, + _dict: dict[str, Any] = {}, + **kw: Any, +) -> Any: + """ + Evaluates an image expression. + + Deprecated. Use lambda_eval() or unsafe_eval() instead. + + :param expression: A string containing a Python-style expression. + :param _dict: Values to add to the evaluation context. You + can either use a dictionary, or one or more keyword + arguments. + :return: The evaluated expression. This is usually an image object, but can + also be an integer, a floating point value, or a pixel tuple, + depending on the expression. + + .. deprecated:: 10.3.0 + """ + + deprecate( + "ImageMath.eval", + 12, + "ImageMath.lambda_eval or ImageMath.unsafe_eval", + ) + return unsafe_eval(expression, _dict, **kw) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageMode.py b/venv/lib/python3.10/site-packages/PIL/ImageMode.py new file mode 100644 index 00000000..0b31f608 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageMode.py @@ -0,0 +1,96 @@ +# +# The Python Imaging Library. +# $Id$ +# +# standard mode descriptors +# +# History: +# 2006-03-20 fl Added +# +# Copyright (c) 2006 by Secret Labs AB. +# Copyright (c) 2006 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import sys +from functools import lru_cache + + +class ModeDescriptor: + """Wrapper for mode strings.""" + + def __init__( + self, + mode: str, + bands: tuple[str, ...], + basemode: str, + basetype: str, + typestr: str, + ) -> None: + self.mode = mode + self.bands = bands + self.basemode = basemode + self.basetype = basetype + self.typestr = typestr + + def __str__(self) -> str: + return self.mode + + +@lru_cache +def getmode(mode: str) -> ModeDescriptor: + """Gets a mode descriptor for the given mode.""" + # initialize mode cache + endian = "<" if sys.byteorder == "little" else ">" + + modes = { + # core modes + # Bits need to be extended to bytes + "1": ("L", "L", ("1",), "|b1"), + "L": ("L", "L", ("L",), "|u1"), + "I": ("L", "I", ("I",), endian + "i4"), + "F": ("L", "F", ("F",), endian + "f4"), + "P": ("P", "L", ("P",), "|u1"), + "RGB": ("RGB", "L", ("R", "G", "B"), "|u1"), + "RGBX": ("RGB", "L", ("R", "G", "B", "X"), "|u1"), + "RGBA": ("RGB", "L", ("R", "G", "B", "A"), "|u1"), + "CMYK": ("RGB", "L", ("C", "M", "Y", "K"), "|u1"), + "YCbCr": ("RGB", "L", ("Y", "Cb", "Cr"), "|u1"), + # UNDONE - unsigned |u1i1i1 + "LAB": ("RGB", "L", ("L", "A", "B"), "|u1"), + "HSV": ("RGB", "L", ("H", "S", "V"), "|u1"), + # extra experimental modes + "RGBa": ("RGB", "L", ("R", "G", "B", "a"), "|u1"), + "BGR;15": ("RGB", "L", ("B", "G", "R"), "|u1"), + "BGR;16": ("RGB", "L", ("B", "G", "R"), "|u1"), + "BGR;24": ("RGB", "L", ("B", "G", "R"), "|u1"), + "LA": ("L", "L", ("L", "A"), "|u1"), + "La": ("L", "L", ("L", "a"), "|u1"), + "PA": ("RGB", "L", ("P", "A"), "|u1"), + } + if mode in modes: + base_mode, base_type, bands, type_str = modes[mode] + return ModeDescriptor(mode, bands, base_mode, base_type, type_str) + + mapping_modes = { + # I;16 == I;16L, and I;32 == I;32L + "I;16": "u2", + "I;16BS": ">i2", + "I;16N": endian + "u2", + "I;16NS": endian + "i2", + "I;32": "u4", + "I;32L": "i4", + "I;32LS": " +from __future__ import annotations + +import re + +from . import Image, _imagingmorph + +LUT_SIZE = 1 << 9 + +# fmt: off +ROTATION_MATRIX = [ + 6, 3, 0, + 7, 4, 1, + 8, 5, 2, +] +MIRROR_MATRIX = [ + 2, 1, 0, + 5, 4, 3, + 8, 7, 6, +] +# fmt: on + + +class LutBuilder: + """A class for building a MorphLut from a descriptive language + + The input patterns is a list of a strings sequences like these:: + + 4:(... + .1. + 111)->1 + + (whitespaces including linebreaks are ignored). The option 4 + describes a series of symmetry operations (in this case a + 4-rotation), the pattern is described by: + + - . or X - Ignore + - 1 - Pixel is on + - 0 - Pixel is off + + The result of the operation is described after "->" string. + + The default is to return the current pixel value, which is + returned if no other match is found. + + Operations: + + - 4 - 4 way rotation + - N - Negate + - 1 - Dummy op for no other operation (an op must always be given) + - M - Mirroring + + Example:: + + lb = LutBuilder(patterns = ["4:(... .1. 111)->1"]) + lut = lb.build_lut() + + """ + + def __init__( + self, patterns: list[str] | None = None, op_name: str | None = None + ) -> None: + if patterns is not None: + self.patterns = patterns + else: + self.patterns = [] + self.lut: bytearray | None = None + if op_name is not None: + known_patterns = { + "corner": ["1:(... ... ...)->0", "4:(00. 01. ...)->1"], + "dilation4": ["4:(... .0. .1.)->1"], + "dilation8": ["4:(... .0. .1.)->1", "4:(... .0. ..1)->1"], + "erosion4": ["4:(... .1. .0.)->0"], + "erosion8": ["4:(... .1. .0.)->0", "4:(... .1. ..0)->0"], + "edge": [ + "1:(... ... ...)->0", + "4:(.0. .1. ...)->1", + "4:(01. .1. ...)->1", + ], + } + if op_name not in known_patterns: + msg = "Unknown pattern " + op_name + "!" + raise Exception(msg) + + self.patterns = known_patterns[op_name] + + def add_patterns(self, patterns: list[str]) -> None: + self.patterns += patterns + + def build_default_lut(self) -> None: + symbols = [0, 1] + m = 1 << 4 # pos of current pixel + self.lut = bytearray(symbols[(i & m) > 0] for i in range(LUT_SIZE)) + + def get_lut(self) -> bytearray | None: + return self.lut + + def _string_permute(self, pattern: str, permutation: list[int]) -> str: + """string_permute takes a pattern and a permutation and returns the + string permuted according to the permutation list. + """ + assert len(permutation) == 9 + return "".join(pattern[p] for p in permutation) + + def _pattern_permute( + self, basic_pattern: str, options: str, basic_result: int + ) -> list[tuple[str, int]]: + """pattern_permute takes a basic pattern and its result and clones + the pattern according to the modifications described in the $options + parameter. It returns a list of all cloned patterns.""" + patterns = [(basic_pattern, basic_result)] + + # rotations + if "4" in options: + res = patterns[-1][1] + for i in range(4): + patterns.append( + (self._string_permute(patterns[-1][0], ROTATION_MATRIX), res) + ) + # mirror + if "M" in options: + n = len(patterns) + for pattern, res in patterns[:n]: + patterns.append((self._string_permute(pattern, MIRROR_MATRIX), res)) + + # negate + if "N" in options: + n = len(patterns) + for pattern, res in patterns[:n]: + # Swap 0 and 1 + pattern = pattern.replace("0", "Z").replace("1", "0").replace("Z", "1") + res = 1 - int(res) + patterns.append((pattern, res)) + + return patterns + + def build_lut(self) -> bytearray: + """Compile all patterns into a morphology lut. + + TBD :Build based on (file) morphlut:modify_lut + """ + self.build_default_lut() + assert self.lut is not None + patterns = [] + + # Parse and create symmetries of the patterns strings + for p in self.patterns: + m = re.search(r"(\w*):?\s*\((.+?)\)\s*->\s*(\d)", p.replace("\n", "")) + if not m: + msg = 'Syntax error in pattern "' + p + '"' + raise Exception(msg) + options = m.group(1) + pattern = m.group(2) + result = int(m.group(3)) + + # Get rid of spaces + pattern = pattern.replace(" ", "").replace("\n", "") + + patterns += self._pattern_permute(pattern, options, result) + + # compile the patterns into regular expressions for speed + compiled_patterns = [] + for pattern in patterns: + p = pattern[0].replace(".", "X").replace("X", "[01]") + compiled_patterns.append((re.compile(p), pattern[1])) + + # Step through table and find patterns that match. + # Note that all the patterns are searched. The last one + # caught overrides + for i in range(LUT_SIZE): + # Build the bit pattern + bitpattern = bin(i)[2:] + bitpattern = ("0" * (9 - len(bitpattern)) + bitpattern)[::-1] + + for pattern, r in compiled_patterns: + if pattern.match(bitpattern): + self.lut[i] = [0, 1][r] + + return self.lut + + +class MorphOp: + """A class for binary morphological operators""" + + def __init__( + self, + lut: bytearray | None = None, + op_name: str | None = None, + patterns: list[str] | None = None, + ) -> None: + """Create a binary morphological operator""" + self.lut = lut + if op_name is not None: + self.lut = LutBuilder(op_name=op_name).build_lut() + elif patterns is not None: + self.lut = LutBuilder(patterns=patterns).build_lut() + + def apply(self, image: Image.Image): + """Run a single morphological operation on an image + + Returns a tuple of the number of changed pixels and the + morphed image""" + if self.lut is None: + msg = "No operator loaded" + raise Exception(msg) + + if image.mode != "L": + msg = "Image mode must be L" + raise ValueError(msg) + outimage = Image.new(image.mode, image.size, None) + count = _imagingmorph.apply(bytes(self.lut), image.im.id, outimage.im.id) + return count, outimage + + def match(self, image: Image.Image): + """Get a list of coordinates matching the morphological operation on + an image. + + Returns a list of tuples of (x,y) coordinates + of all matching pixels. See :ref:`coordinate-system`.""" + if self.lut is None: + msg = "No operator loaded" + raise Exception(msg) + + if image.mode != "L": + msg = "Image mode must be L" + raise ValueError(msg) + return _imagingmorph.match(bytes(self.lut), image.im.id) + + def get_on_pixels(self, image: Image.Image): + """Get a list of all turned on pixels in a binary image + + Returns a list of tuples of (x,y) coordinates + of all matching pixels. See :ref:`coordinate-system`.""" + + if image.mode != "L": + msg = "Image mode must be L" + raise ValueError(msg) + return _imagingmorph.get_on_pixels(image.im.id) + + def load_lut(self, filename: str) -> None: + """Load an operator from an mrl file""" + with open(filename, "rb") as f: + self.lut = bytearray(f.read()) + + if len(self.lut) != LUT_SIZE: + self.lut = None + msg = "Wrong size operator file!" + raise Exception(msg) + + def save_lut(self, filename: str) -> None: + """Save an operator to an mrl file""" + if self.lut is None: + msg = "No operator loaded" + raise Exception(msg) + with open(filename, "wb") as f: + f.write(self.lut) + + def set_lut(self, lut: bytearray | None) -> None: + """Set the lut from an external source""" + self.lut = lut diff --git a/venv/lib/python3.10/site-packages/PIL/ImageOps.py b/venv/lib/python3.10/site-packages/PIL/ImageOps.py new file mode 100644 index 00000000..33db8fa5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageOps.py @@ -0,0 +1,724 @@ +# +# The Python Imaging Library. +# $Id$ +# +# standard image operations +# +# History: +# 2001-10-20 fl Created +# 2001-10-23 fl Added autocontrast operator +# 2001-12-18 fl Added Kevin's fit operator +# 2004-03-14 fl Fixed potential division by zero in equalize +# 2005-05-05 fl Fixed equalize for low number of values +# +# Copyright (c) 2001-2004 by Secret Labs AB +# Copyright (c) 2001-2004 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import functools +import operator +import re +from typing import Protocol, Sequence, cast + +from . import ExifTags, Image, ImagePalette + +# +# helpers + + +def _border(border: int | tuple[int, ...]) -> tuple[int, int, int, int]: + if isinstance(border, tuple): + if len(border) == 2: + left, top = right, bottom = border + elif len(border) == 4: + left, top, right, bottom = border + else: + left = top = right = bottom = border + return left, top, right, bottom + + +def _color(color: str | int | tuple[int, ...], mode: str) -> int | tuple[int, ...]: + if isinstance(color, str): + from . import ImageColor + + color = ImageColor.getcolor(color, mode) + return color + + +def _lut(image: Image.Image, lut: list[int]) -> Image.Image: + if image.mode == "P": + # FIXME: apply to lookup table, not image data + msg = "mode P support coming soon" + raise NotImplementedError(msg) + elif image.mode in ("L", "RGB"): + if image.mode == "RGB" and len(lut) == 256: + lut = lut + lut + lut + return image.point(lut) + else: + msg = f"not supported for mode {image.mode}" + raise OSError(msg) + + +# +# actions + + +def autocontrast( + image: Image.Image, + cutoff: float | tuple[float, float] = 0, + ignore: int | Sequence[int] | None = None, + mask: Image.Image | None = None, + preserve_tone: bool = False, +) -> Image.Image: + """ + Maximize (normalize) image contrast. This function calculates a + histogram of the input image (or mask region), removes ``cutoff`` percent of the + lightest and darkest pixels from the histogram, and remaps the image + so that the darkest pixel becomes black (0), and the lightest + becomes white (255). + + :param image: The image to process. + :param cutoff: The percent to cut off from the histogram on the low and + high ends. Either a tuple of (low, high), or a single + number for both. + :param ignore: The background pixel value (use None for no background). + :param mask: Histogram used in contrast operation is computed using pixels + within the mask. If no mask is given the entire image is used + for histogram computation. + :param preserve_tone: Preserve image tone in Photoshop-like style autocontrast. + + .. versionadded:: 8.2.0 + + :return: An image. + """ + if preserve_tone: + histogram = image.convert("L").histogram(mask) + else: + histogram = image.histogram(mask) + + lut = [] + for layer in range(0, len(histogram), 256): + h = histogram[layer : layer + 256] + if ignore is not None: + # get rid of outliers + if isinstance(ignore, int): + h[ignore] = 0 + else: + for ix in ignore: + h[ix] = 0 + if cutoff: + # cut off pixels from both ends of the histogram + if not isinstance(cutoff, tuple): + cutoff = (cutoff, cutoff) + # get number of pixels + n = 0 + for ix in range(256): + n = n + h[ix] + # remove cutoff% pixels from the low end + cut = int(n * cutoff[0] // 100) + for lo in range(256): + if cut > h[lo]: + cut = cut - h[lo] + h[lo] = 0 + else: + h[lo] -= cut + cut = 0 + if cut <= 0: + break + # remove cutoff% samples from the high end + cut = int(n * cutoff[1] // 100) + for hi in range(255, -1, -1): + if cut > h[hi]: + cut = cut - h[hi] + h[hi] = 0 + else: + h[hi] -= cut + cut = 0 + if cut <= 0: + break + # find lowest/highest samples after preprocessing + for lo in range(256): + if h[lo]: + break + for hi in range(255, -1, -1): + if h[hi]: + break + if hi <= lo: + # don't bother + lut.extend(list(range(256))) + else: + scale = 255.0 / (hi - lo) + offset = -lo * scale + for ix in range(256): + ix = int(ix * scale + offset) + if ix < 0: + ix = 0 + elif ix > 255: + ix = 255 + lut.append(ix) + return _lut(image, lut) + + +def colorize( + image: Image.Image, + black: str | tuple[int, ...], + white: str | tuple[int, ...], + mid: str | int | tuple[int, ...] | None = None, + blackpoint: int = 0, + whitepoint: int = 255, + midpoint: int = 127, +) -> Image.Image: + """ + Colorize grayscale image. + This function calculates a color wedge which maps all black pixels in + the source image to the first color and all white pixels to the + second color. If ``mid`` is specified, it uses three-color mapping. + The ``black`` and ``white`` arguments should be RGB tuples or color names; + optionally you can use three-color mapping by also specifying ``mid``. + Mapping positions for any of the colors can be specified + (e.g. ``blackpoint``), where these parameters are the integer + value corresponding to where the corresponding color should be mapped. + These parameters must have logical order, such that + ``blackpoint <= midpoint <= whitepoint`` (if ``mid`` is specified). + + :param image: The image to colorize. + :param black: The color to use for black input pixels. + :param white: The color to use for white input pixels. + :param mid: The color to use for midtone input pixels. + :param blackpoint: an int value [0, 255] for the black mapping. + :param whitepoint: an int value [0, 255] for the white mapping. + :param midpoint: an int value [0, 255] for the midtone mapping. + :return: An image. + """ + + # Initial asserts + assert image.mode == "L" + if mid is None: + assert 0 <= blackpoint <= whitepoint <= 255 + else: + assert 0 <= blackpoint <= midpoint <= whitepoint <= 255 + + # Define colors from arguments + rgb_black = cast(Sequence[int], _color(black, "RGB")) + rgb_white = cast(Sequence[int], _color(white, "RGB")) + rgb_mid = cast(Sequence[int], _color(mid, "RGB")) if mid is not None else None + + # Empty lists for the mapping + red = [] + green = [] + blue = [] + + # Create the low-end values + for i in range(0, blackpoint): + red.append(rgb_black[0]) + green.append(rgb_black[1]) + blue.append(rgb_black[2]) + + # Create the mapping (2-color) + if rgb_mid is None: + range_map = range(0, whitepoint - blackpoint) + + for i in range_map: + red.append( + rgb_black[0] + i * (rgb_white[0] - rgb_black[0]) // len(range_map) + ) + green.append( + rgb_black[1] + i * (rgb_white[1] - rgb_black[1]) // len(range_map) + ) + blue.append( + rgb_black[2] + i * (rgb_white[2] - rgb_black[2]) // len(range_map) + ) + + # Create the mapping (3-color) + else: + range_map1 = range(0, midpoint - blackpoint) + range_map2 = range(0, whitepoint - midpoint) + + for i in range_map1: + red.append( + rgb_black[0] + i * (rgb_mid[0] - rgb_black[0]) // len(range_map1) + ) + green.append( + rgb_black[1] + i * (rgb_mid[1] - rgb_black[1]) // len(range_map1) + ) + blue.append( + rgb_black[2] + i * (rgb_mid[2] - rgb_black[2]) // len(range_map1) + ) + for i in range_map2: + red.append(rgb_mid[0] + i * (rgb_white[0] - rgb_mid[0]) // len(range_map2)) + green.append( + rgb_mid[1] + i * (rgb_white[1] - rgb_mid[1]) // len(range_map2) + ) + blue.append(rgb_mid[2] + i * (rgb_white[2] - rgb_mid[2]) // len(range_map2)) + + # Create the high-end values + for i in range(0, 256 - whitepoint): + red.append(rgb_white[0]) + green.append(rgb_white[1]) + blue.append(rgb_white[2]) + + # Return converted image + image = image.convert("RGB") + return _lut(image, red + green + blue) + + +def contain( + image: Image.Image, size: tuple[int, int], method: int = Image.Resampling.BICUBIC +) -> Image.Image: + """ + Returns a resized version of the image, set to the maximum width and height + within the requested size, while maintaining the original aspect ratio. + + :param image: The image to resize. + :param size: The requested output size in pixels, given as a + (width, height) tuple. + :param method: Resampling method to use. Default is + :py:attr:`~PIL.Image.Resampling.BICUBIC`. + See :ref:`concept-filters`. + :return: An image. + """ + + im_ratio = image.width / image.height + dest_ratio = size[0] / size[1] + + if im_ratio != dest_ratio: + if im_ratio > dest_ratio: + new_height = round(image.height / image.width * size[0]) + if new_height != size[1]: + size = (size[0], new_height) + else: + new_width = round(image.width / image.height * size[1]) + if new_width != size[0]: + size = (new_width, size[1]) + return image.resize(size, resample=method) + + +def cover( + image: Image.Image, size: tuple[int, int], method: int = Image.Resampling.BICUBIC +) -> Image.Image: + """ + Returns a resized version of the image, so that the requested size is + covered, while maintaining the original aspect ratio. + + :param image: The image to resize. + :param size: The requested output size in pixels, given as a + (width, height) tuple. + :param method: Resampling method to use. Default is + :py:attr:`~PIL.Image.Resampling.BICUBIC`. + See :ref:`concept-filters`. + :return: An image. + """ + + im_ratio = image.width / image.height + dest_ratio = size[0] / size[1] + + if im_ratio != dest_ratio: + if im_ratio < dest_ratio: + new_height = round(image.height / image.width * size[0]) + if new_height != size[1]: + size = (size[0], new_height) + else: + new_width = round(image.width / image.height * size[1]) + if new_width != size[0]: + size = (new_width, size[1]) + return image.resize(size, resample=method) + + +def pad( + image: Image.Image, + size: tuple[int, int], + method: int = Image.Resampling.BICUBIC, + color: str | int | tuple[int, ...] | None = None, + centering: tuple[float, float] = (0.5, 0.5), +) -> Image.Image: + """ + Returns a resized and padded version of the image, expanded to fill the + requested aspect ratio and size. + + :param image: The image to resize and crop. + :param size: The requested output size in pixels, given as a + (width, height) tuple. + :param method: Resampling method to use. Default is + :py:attr:`~PIL.Image.Resampling.BICUBIC`. + See :ref:`concept-filters`. + :param color: The background color of the padded image. + :param centering: Control the position of the original image within the + padded version. + + (0.5, 0.5) will keep the image centered + (0, 0) will keep the image aligned to the top left + (1, 1) will keep the image aligned to the bottom + right + :return: An image. + """ + + resized = contain(image, size, method) + if resized.size == size: + out = resized + else: + out = Image.new(image.mode, size, color) + if resized.palette: + out.putpalette(resized.getpalette()) + if resized.width != size[0]: + x = round((size[0] - resized.width) * max(0, min(centering[0], 1))) + out.paste(resized, (x, 0)) + else: + y = round((size[1] - resized.height) * max(0, min(centering[1], 1))) + out.paste(resized, (0, y)) + return out + + +def crop(image: Image.Image, border: int = 0) -> Image.Image: + """ + Remove border from image. The same amount of pixels are removed + from all four sides. This function works on all image modes. + + .. seealso:: :py:meth:`~PIL.Image.Image.crop` + + :param image: The image to crop. + :param border: The number of pixels to remove. + :return: An image. + """ + left, top, right, bottom = _border(border) + return image.crop((left, top, image.size[0] - right, image.size[1] - bottom)) + + +def scale( + image: Image.Image, factor: float, resample: int = Image.Resampling.BICUBIC +) -> Image.Image: + """ + Returns a rescaled image by a specific factor given in parameter. + A factor greater than 1 expands the image, between 0 and 1 contracts the + image. + + :param image: The image to rescale. + :param factor: The expansion factor, as a float. + :param resample: Resampling method to use. Default is + :py:attr:`~PIL.Image.Resampling.BICUBIC`. + See :ref:`concept-filters`. + :returns: An :py:class:`~PIL.Image.Image` object. + """ + if factor == 1: + return image.copy() + elif factor <= 0: + msg = "the factor must be greater than 0" + raise ValueError(msg) + else: + size = (round(factor * image.width), round(factor * image.height)) + return image.resize(size, resample) + + +class SupportsGetMesh(Protocol): + """ + An object that supports the ``getmesh`` method, taking an image as an + argument, and returning a list of tuples. Each tuple contains two tuples, + the source box as a tuple of 4 integers, and a tuple of 8 integers for the + final quadrilateral, in order of top left, bottom left, bottom right, top + right. + """ + + def getmesh( + self, image: Image.Image + ) -> list[ + tuple[tuple[int, int, int, int], tuple[int, int, int, int, int, int, int, int]] + ]: ... + + +def deform( + image: Image.Image, + deformer: SupportsGetMesh, + resample: int = Image.Resampling.BILINEAR, +) -> Image.Image: + """ + Deform the image. + + :param image: The image to deform. + :param deformer: A deformer object. Any object that implements a + ``getmesh`` method can be used. + :param resample: An optional resampling filter. Same values possible as + in the PIL.Image.transform function. + :return: An image. + """ + return image.transform( + image.size, Image.Transform.MESH, deformer.getmesh(image), resample + ) + + +def equalize(image: Image.Image, mask: Image.Image | None = None) -> Image.Image: + """ + Equalize the image histogram. This function applies a non-linear + mapping to the input image, in order to create a uniform + distribution of grayscale values in the output image. + + :param image: The image to equalize. + :param mask: An optional mask. If given, only the pixels selected by + the mask are included in the analysis. + :return: An image. + """ + if image.mode == "P": + image = image.convert("RGB") + h = image.histogram(mask) + lut = [] + for b in range(0, len(h), 256): + histo = [_f for _f in h[b : b + 256] if _f] + if len(histo) <= 1: + lut.extend(list(range(256))) + else: + step = (functools.reduce(operator.add, histo) - histo[-1]) // 255 + if not step: + lut.extend(list(range(256))) + else: + n = step // 2 + for i in range(256): + lut.append(n // step) + n = n + h[i + b] + return _lut(image, lut) + + +def expand( + image: Image.Image, + border: int | tuple[int, ...] = 0, + fill: str | int | tuple[int, ...] = 0, +) -> Image.Image: + """ + Add border to the image + + :param image: The image to expand. + :param border: Border width, in pixels. + :param fill: Pixel fill value (a color value). Default is 0 (black). + :return: An image. + """ + left, top, right, bottom = _border(border) + width = left + image.size[0] + right + height = top + image.size[1] + bottom + color = _color(fill, image.mode) + if image.palette: + palette = ImagePalette.ImagePalette(palette=image.getpalette()) + if isinstance(color, tuple): + color = palette.getcolor(color) + else: + palette = None + out = Image.new(image.mode, (width, height), color) + if palette: + out.putpalette(palette.palette) + out.paste(image, (left, top)) + return out + + +def fit( + image: Image.Image, + size: tuple[int, int], + method: int = Image.Resampling.BICUBIC, + bleed: float = 0.0, + centering: tuple[float, float] = (0.5, 0.5), +) -> Image.Image: + """ + Returns a resized and cropped version of the image, cropped to the + requested aspect ratio and size. + + This function was contributed by Kevin Cazabon. + + :param image: The image to resize and crop. + :param size: The requested output size in pixels, given as a + (width, height) tuple. + :param method: Resampling method to use. Default is + :py:attr:`~PIL.Image.Resampling.BICUBIC`. + See :ref:`concept-filters`. + :param bleed: Remove a border around the outside of the image from all + four edges. The value is a decimal percentage (use 0.01 for + one percent). The default value is 0 (no border). + Cannot be greater than or equal to 0.5. + :param centering: Control the cropping position. Use (0.5, 0.5) for + center cropping (e.g. if cropping the width, take 50% off + of the left side, and therefore 50% off the right side). + (0.0, 0.0) will crop from the top left corner (i.e. if + cropping the width, take all of the crop off of the right + side, and if cropping the height, take all of it off the + bottom). (1.0, 0.0) will crop from the bottom left + corner, etc. (i.e. if cropping the width, take all of the + crop off the left side, and if cropping the height take + none from the top, and therefore all off the bottom). + :return: An image. + """ + + # by Kevin Cazabon, Feb 17/2000 + # kevin@cazabon.com + # https://www.cazabon.com + + centering_x, centering_y = centering + + if not 0.0 <= centering_x <= 1.0: + centering_x = 0.5 + if not 0.0 <= centering_y <= 1.0: + centering_y = 0.5 + + if not 0.0 <= bleed < 0.5: + bleed = 0.0 + + # calculate the area to use for resizing and cropping, subtracting + # the 'bleed' around the edges + + # number of pixels to trim off on Top and Bottom, Left and Right + bleed_pixels = (bleed * image.size[0], bleed * image.size[1]) + + live_size = ( + image.size[0] - bleed_pixels[0] * 2, + image.size[1] - bleed_pixels[1] * 2, + ) + + # calculate the aspect ratio of the live_size + live_size_ratio = live_size[0] / live_size[1] + + # calculate the aspect ratio of the output image + output_ratio = size[0] / size[1] + + # figure out if the sides or top/bottom will be cropped off + if live_size_ratio == output_ratio: + # live_size is already the needed ratio + crop_width = live_size[0] + crop_height = live_size[1] + elif live_size_ratio >= output_ratio: + # live_size is wider than what's needed, crop the sides + crop_width = output_ratio * live_size[1] + crop_height = live_size[1] + else: + # live_size is taller than what's needed, crop the top and bottom + crop_width = live_size[0] + crop_height = live_size[0] / output_ratio + + # make the crop + crop_left = bleed_pixels[0] + (live_size[0] - crop_width) * centering_x + crop_top = bleed_pixels[1] + (live_size[1] - crop_height) * centering_y + + crop = (crop_left, crop_top, crop_left + crop_width, crop_top + crop_height) + + # resize the image and return it + return image.resize(size, method, box=crop) + + +def flip(image: Image.Image) -> Image.Image: + """ + Flip the image vertically (top to bottom). + + :param image: The image to flip. + :return: An image. + """ + return image.transpose(Image.Transpose.FLIP_TOP_BOTTOM) + + +def grayscale(image: Image.Image) -> Image.Image: + """ + Convert the image to grayscale. + + :param image: The image to convert. + :return: An image. + """ + return image.convert("L") + + +def invert(image: Image.Image) -> Image.Image: + """ + Invert (negate) the image. + + :param image: The image to invert. + :return: An image. + """ + lut = list(range(255, -1, -1)) + return image.point(lut) if image.mode == "1" else _lut(image, lut) + + +def mirror(image: Image.Image) -> Image.Image: + """ + Flip image horizontally (left to right). + + :param image: The image to mirror. + :return: An image. + """ + return image.transpose(Image.Transpose.FLIP_LEFT_RIGHT) + + +def posterize(image: Image.Image, bits: int) -> Image.Image: + """ + Reduce the number of bits for each color channel. + + :param image: The image to posterize. + :param bits: The number of bits to keep for each channel (1-8). + :return: An image. + """ + mask = ~(2 ** (8 - bits) - 1) + lut = [i & mask for i in range(256)] + return _lut(image, lut) + + +def solarize(image: Image.Image, threshold: int = 128) -> Image.Image: + """ + Invert all pixel values above a threshold. + + :param image: The image to solarize. + :param threshold: All pixels above this grayscale level are inverted. + :return: An image. + """ + lut = [] + for i in range(256): + if i < threshold: + lut.append(i) + else: + lut.append(255 - i) + return _lut(image, lut) + + +def exif_transpose(image: Image.Image, *, in_place: bool = False) -> Image.Image | None: + """ + If an image has an EXIF Orientation tag, other than 1, transpose the image + accordingly, and remove the orientation data. + + :param image: The image to transpose. + :param in_place: Boolean. Keyword-only argument. + If ``True``, the original image is modified in-place, and ``None`` is returned. + If ``False`` (default), a new :py:class:`~PIL.Image.Image` object is returned + with the transposition applied. If there is no transposition, a copy of the + image will be returned. + """ + image.load() + image_exif = image.getexif() + orientation = image_exif.get(ExifTags.Base.Orientation, 1) + method = { + 2: Image.Transpose.FLIP_LEFT_RIGHT, + 3: Image.Transpose.ROTATE_180, + 4: Image.Transpose.FLIP_TOP_BOTTOM, + 5: Image.Transpose.TRANSPOSE, + 6: Image.Transpose.ROTATE_270, + 7: Image.Transpose.TRANSVERSE, + 8: Image.Transpose.ROTATE_90, + }.get(orientation) + if method is not None: + transposed_image = image.transpose(method) + if in_place: + image.im = transposed_image.im + image.pyaccess = None + image._size = transposed_image._size + exif_image = image if in_place else transposed_image + + exif = exif_image.getexif() + if ExifTags.Base.Orientation in exif: + del exif[ExifTags.Base.Orientation] + if "exif" in exif_image.info: + exif_image.info["exif"] = exif.tobytes() + elif "Raw profile type exif" in exif_image.info: + exif_image.info["Raw profile type exif"] = exif.tobytes().hex() + elif "XML:com.adobe.xmp" in exif_image.info: + for pattern in ( + r'tiff:Orientation="([0-9])"', + r"([0-9])", + ): + exif_image.info["XML:com.adobe.xmp"] = re.sub( + pattern, "", exif_image.info["XML:com.adobe.xmp"] + ) + if not in_place: + return transposed_image + elif not in_place: + return image.copy() + return None diff --git a/venv/lib/python3.10/site-packages/PIL/ImagePalette.py b/venv/lib/python3.10/site-packages/PIL/ImagePalette.py new file mode 100644 index 00000000..770d1002 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImagePalette.py @@ -0,0 +1,263 @@ +# +# The Python Imaging Library. +# $Id$ +# +# image palette object +# +# History: +# 1996-03-11 fl Rewritten. +# 1997-01-03 fl Up and running. +# 1997-08-23 fl Added load hack +# 2001-04-16 fl Fixed randint shadow bug in random() +# +# Copyright (c) 1997-2001 by Secret Labs AB +# Copyright (c) 1996-1997 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import array +from typing import Sequence + +from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile + + +class ImagePalette: + """ + Color palette for palette mapped images + + :param mode: The mode to use for the palette. See: + :ref:`concept-modes`. Defaults to "RGB" + :param palette: An optional palette. If given, it must be a bytearray, + an array or a list of ints between 0-255. The list must consist of + all channels for one color followed by the next color (e.g. RGBRGBRGB). + Defaults to an empty palette. + """ + + def __init__(self, mode: str = "RGB", palette: Sequence[int] | None = None) -> None: + self.mode = mode + self.rawmode = None # if set, palette contains raw data + self.palette = palette or bytearray() + self.dirty: int | None = None + + @property + def palette(self): + return self._palette + + @palette.setter + def palette(self, palette): + self._colors = None + self._palette = palette + + @property + def colors(self): + if self._colors is None: + mode_len = len(self.mode) + self._colors = {} + for i in range(0, len(self.palette), mode_len): + color = tuple(self.palette[i : i + mode_len]) + if color in self._colors: + continue + self._colors[color] = i // mode_len + return self._colors + + @colors.setter + def colors(self, colors): + self._colors = colors + + def copy(self): + new = ImagePalette() + + new.mode = self.mode + new.rawmode = self.rawmode + if self.palette is not None: + new.palette = self.palette[:] + new.dirty = self.dirty + + return new + + def getdata(self): + """ + Get palette contents in format suitable for the low-level + ``im.putpalette`` primitive. + + .. warning:: This method is experimental. + """ + if self.rawmode: + return self.rawmode, self.palette + return self.mode, self.tobytes() + + def tobytes(self): + """Convert palette to bytes. + + .. warning:: This method is experimental. + """ + if self.rawmode: + msg = "palette contains raw palette data" + raise ValueError(msg) + if isinstance(self.palette, bytes): + return self.palette + arr = array.array("B", self.palette) + return arr.tobytes() + + # Declare tostring as an alias for tobytes + tostring = tobytes + + def _new_color_index(self, image=None, e=None): + if not isinstance(self.palette, bytearray): + self._palette = bytearray(self.palette) + index = len(self.palette) // 3 + special_colors = () + if image: + special_colors = ( + image.info.get("background"), + image.info.get("transparency"), + ) + while index in special_colors: + index += 1 + if index >= 256: + if image: + # Search for an unused index + for i, count in reversed(list(enumerate(image.histogram()))): + if count == 0 and i not in special_colors: + index = i + break + if index >= 256: + msg = "cannot allocate more than 256 colors" + raise ValueError(msg) from e + return index + + def getcolor(self, color, image=None) -> int: + """Given an rgb tuple, allocate palette entry. + + .. warning:: This method is experimental. + """ + if self.rawmode: + msg = "palette contains raw palette data" + raise ValueError(msg) + if isinstance(color, tuple): + if self.mode == "RGB": + if len(color) == 4: + if color[3] != 255: + msg = "cannot add non-opaque RGBA color to RGB palette" + raise ValueError(msg) + color = color[:3] + elif self.mode == "RGBA": + if len(color) == 3: + color += (255,) + try: + return self.colors[color] + except KeyError as e: + # allocate new color slot + index = self._new_color_index(image, e) + self.colors[color] = index + if index * 3 < len(self.palette): + self._palette = ( + self.palette[: index * 3] + + bytes(color) + + self.palette[index * 3 + 3 :] + ) + else: + self._palette += bytes(color) + self.dirty = 1 + return index + else: + msg = f"unknown color specifier: {repr(color)}" + raise ValueError(msg) + + def save(self, fp): + """Save palette to text file. + + .. warning:: This method is experimental. + """ + if self.rawmode: + msg = "palette contains raw palette data" + raise ValueError(msg) + if isinstance(fp, str): + fp = open(fp, "w") + fp.write("# Palette\n") + fp.write(f"# Mode: {self.mode}\n") + for i in range(256): + fp.write(f"{i}") + for j in range(i * len(self.mode), (i + 1) * len(self.mode)): + try: + fp.write(f" {self.palette[j]}") + except IndexError: + fp.write(" 0") + fp.write("\n") + fp.close() + + +# -------------------------------------------------------------------- +# Internal + + +def raw(rawmode, data) -> ImagePalette: + palette = ImagePalette() + palette.rawmode = rawmode + palette.palette = data + palette.dirty = 1 + return palette + + +# -------------------------------------------------------------------- +# Factories + + +def make_linear_lut(black, white): + if black == 0: + return [white * i // 255 for i in range(256)] + + msg = "unavailable when black is non-zero" + raise NotImplementedError(msg) # FIXME + + +def make_gamma_lut(exp): + return [int(((i / 255.0) ** exp) * 255.0 + 0.5) for i in range(256)] + + +def negative(mode="RGB"): + palette = list(range(256 * len(mode))) + palette.reverse() + return ImagePalette(mode, [i // len(mode) for i in palette]) + + +def random(mode="RGB"): + from random import randint + + palette = [randint(0, 255) for _ in range(256 * len(mode))] + return ImagePalette(mode, palette) + + +def sepia(white="#fff0c0"): + bands = [make_linear_lut(0, band) for band in ImageColor.getrgb(white)] + return ImagePalette("RGB", [bands[i % 3][i // 3] for i in range(256 * 3)]) + + +def wedge(mode="RGB"): + palette = list(range(256 * len(mode))) + return ImagePalette(mode, [i // len(mode) for i in palette]) + + +def load(filename): + # FIXME: supports GIMP gradients only + + with open(filename, "rb") as fp: + for paletteHandler in [ + GimpPaletteFile.GimpPaletteFile, + GimpGradientFile.GimpGradientFile, + PaletteFile.PaletteFile, + ]: + try: + fp.seek(0) + lut = paletteHandler(fp).getpalette() + if lut: + break + except (SyntaxError, ValueError): + pass + else: + msg = "cannot load palette" + raise OSError(msg) + + return lut # data, rawmode diff --git a/venv/lib/python3.10/site-packages/PIL/ImagePath.py b/venv/lib/python3.10/site-packages/PIL/ImagePath.py new file mode 100644 index 00000000..77e8a609 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImagePath.py @@ -0,0 +1,20 @@ +# +# The Python Imaging Library +# $Id$ +# +# path interface +# +# History: +# 1996-11-04 fl Created +# 2002-04-14 fl Added documentation stub class +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image + +Path = Image.core.path diff --git a/venv/lib/python3.10/site-packages/PIL/ImageQt.py b/venv/lib/python3.10/site-packages/PIL/ImageQt.py new file mode 100644 index 00000000..293ba494 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageQt.py @@ -0,0 +1,205 @@ +# +# The Python Imaging Library. +# $Id$ +# +# a simple Qt image interface. +# +# history: +# 2006-06-03 fl: created +# 2006-06-04 fl: inherit from QImage instead of wrapping it +# 2006-06-05 fl: removed toimage helper; move string support to ImageQt +# 2013-11-13 fl: add support for Qt5 (aurelien.ballier@cyclonit.com) +# +# Copyright (c) 2006 by Secret Labs AB +# Copyright (c) 2006 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import sys +from io import BytesIO +from typing import Callable + +from . import Image +from ._util import is_path + +qt_version: str | None +qt_versions = [ + ["6", "PyQt6"], + ["side6", "PySide6"], +] + +# If a version has already been imported, attempt it first +qt_versions.sort(key=lambda version: version[1] in sys.modules, reverse=True) +for version, qt_module in qt_versions: + try: + QBuffer: type + QIODevice: type + QImage: type + QPixmap: type + qRgba: Callable[[int, int, int, int], int] + if qt_module == "PyQt6": + from PyQt6.QtCore import QBuffer, QIODevice + from PyQt6.QtGui import QImage, QPixmap, qRgba + elif qt_module == "PySide6": + from PySide6.QtCore import QBuffer, QIODevice + from PySide6.QtGui import QImage, QPixmap, qRgba + except (ImportError, RuntimeError): + continue + qt_is_installed = True + qt_version = version + break +else: + qt_is_installed = False + qt_version = None + + +def rgb(r, g, b, a=255): + """(Internal) Turns an RGB color into a Qt compatible color integer.""" + # use qRgb to pack the colors, and then turn the resulting long + # into a negative integer with the same bitpattern. + return qRgba(r, g, b, a) & 0xFFFFFFFF + + +def fromqimage(im): + """ + :param im: QImage or PIL ImageQt object + """ + buffer = QBuffer() + if qt_version == "6": + try: + qt_openmode = QIODevice.OpenModeFlag + except AttributeError: + qt_openmode = QIODevice.OpenMode + else: + qt_openmode = QIODevice + buffer.open(qt_openmode.ReadWrite) + # preserve alpha channel with png + # otherwise ppm is more friendly with Image.open + if im.hasAlphaChannel(): + im.save(buffer, "png") + else: + im.save(buffer, "ppm") + + b = BytesIO() + b.write(buffer.data()) + buffer.close() + b.seek(0) + + return Image.open(b) + + +def fromqpixmap(im): + return fromqimage(im) + + +def align8to32(bytes, width, mode): + """ + converts each scanline of data from 8 bit to 32 bit aligned + """ + + bits_per_pixel = {"1": 1, "L": 8, "P": 8, "I;16": 16}[mode] + + # calculate bytes per line and the extra padding if needed + bits_per_line = bits_per_pixel * width + full_bytes_per_line, remaining_bits_per_line = divmod(bits_per_line, 8) + bytes_per_line = full_bytes_per_line + (1 if remaining_bits_per_line else 0) + + extra_padding = -bytes_per_line % 4 + + # already 32 bit aligned by luck + if not extra_padding: + return bytes + + new_data = [ + bytes[i * bytes_per_line : (i + 1) * bytes_per_line] + b"\x00" * extra_padding + for i in range(len(bytes) // bytes_per_line) + ] + + return b"".join(new_data) + + +def _toqclass_helper(im): + data = None + colortable = None + exclusive_fp = False + + # handle filename, if given instead of image name + if hasattr(im, "toUtf8"): + # FIXME - is this really the best way to do this? + im = str(im.toUtf8(), "utf-8") + if is_path(im): + im = Image.open(im) + exclusive_fp = True + + qt_format = QImage.Format if qt_version == "6" else QImage + if im.mode == "1": + format = qt_format.Format_Mono + elif im.mode == "L": + format = qt_format.Format_Indexed8 + colortable = [rgb(i, i, i) for i in range(256)] + elif im.mode == "P": + format = qt_format.Format_Indexed8 + palette = im.getpalette() + colortable = [rgb(*palette[i : i + 3]) for i in range(0, len(palette), 3)] + elif im.mode == "RGB": + # Populate the 4th channel with 255 + im = im.convert("RGBA") + + data = im.tobytes("raw", "BGRA") + format = qt_format.Format_RGB32 + elif im.mode == "RGBA": + data = im.tobytes("raw", "BGRA") + format = qt_format.Format_ARGB32 + elif im.mode == "I;16" and hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+ + im = im.point(lambda i: i * 256) + + format = qt_format.Format_Grayscale16 + else: + if exclusive_fp: + im.close() + msg = f"unsupported image mode {repr(im.mode)}" + raise ValueError(msg) + + size = im.size + __data = data or align8to32(im.tobytes(), size[0], im.mode) + if exclusive_fp: + im.close() + return {"data": __data, "size": size, "format": format, "colortable": colortable} + + +if qt_is_installed: + + class ImageQt(QImage): + def __init__(self, im): + """ + An PIL image wrapper for Qt. This is a subclass of PyQt's QImage + class. + + :param im: A PIL Image object, or a file name (given either as + Python string or a PyQt string object). + """ + im_data = _toqclass_helper(im) + # must keep a reference, or Qt will crash! + # All QImage constructors that take data operate on an existing + # buffer, so this buffer has to hang on for the life of the image. + # Fixes https://github.com/python-pillow/Pillow/issues/1370 + self.__data = im_data["data"] + super().__init__( + self.__data, + im_data["size"][0], + im_data["size"][1], + im_data["format"], + ) + if im_data["colortable"]: + self.setColorTable(im_data["colortable"]) + + +def toqimage(im): + return ImageQt(im) + + +def toqpixmap(im): + qimage = toqimage(im) + return QPixmap.fromImage(qimage) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageSequence.py b/venv/lib/python3.10/site-packages/PIL/ImageSequence.py new file mode 100644 index 00000000..2c185027 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageSequence.py @@ -0,0 +1,86 @@ +# +# The Python Imaging Library. +# $Id$ +# +# sequence support classes +# +# history: +# 1997-02-20 fl Created +# +# Copyright (c) 1997 by Secret Labs AB. +# Copyright (c) 1997 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +## +from __future__ import annotations + +from typing import Callable + +from . import Image + + +class Iterator: + """ + This class implements an iterator object that can be used to loop + over an image sequence. + + You can use the ``[]`` operator to access elements by index. This operator + will raise an :py:exc:`IndexError` if you try to access a nonexistent + frame. + + :param im: An image object. + """ + + def __init__(self, im: Image.Image): + if not hasattr(im, "seek"): + msg = "im must have seek method" + raise AttributeError(msg) + self.im = im + self.position = getattr(self.im, "_min_frame", 0) + + def __getitem__(self, ix: int) -> Image.Image: + try: + self.im.seek(ix) + return self.im + except EOFError as e: + msg = "end of sequence" + raise IndexError(msg) from e + + def __iter__(self) -> Iterator: + return self + + def __next__(self) -> Image.Image: + try: + self.im.seek(self.position) + self.position += 1 + return self.im + except EOFError as e: + msg = "end of sequence" + raise StopIteration(msg) from e + + +def all_frames( + im: Image.Image | list[Image.Image], + func: Callable[[Image.Image], Image.Image] | None = None, +) -> list[Image.Image]: + """ + Applies a given function to all frames in an image or a list of images. + The frames are returned as a list of separate images. + + :param im: An image, or a list of images. + :param func: The function to apply to all of the image frames. + :returns: A list of images. + """ + if not isinstance(im, list): + im = [im] + + ims = [] + for imSequence in im: + current = imSequence.tell() + + ims += [im_frame.copy() for im_frame in Iterator(imSequence)] + + imSequence.seek(current) + return [func(im) for im in ims] if func else ims diff --git a/venv/lib/python3.10/site-packages/PIL/ImageShow.py b/venv/lib/python3.10/site-packages/PIL/ImageShow.py new file mode 100644 index 00000000..4e505f2e --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageShow.py @@ -0,0 +1,347 @@ +# +# The Python Imaging Library. +# $Id$ +# +# im.show() drivers +# +# History: +# 2008-04-06 fl Created +# +# Copyright (c) Secret Labs AB 2008. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import abc +import os +import shutil +import subprocess +import sys +from shlex import quote +from typing import Any + +from . import Image + +_viewers = [] + + +def register(viewer, order: int = 1) -> None: + """ + The :py:func:`register` function is used to register additional viewers:: + + from PIL import ImageShow + ImageShow.register(MyViewer()) # MyViewer will be used as a last resort + ImageShow.register(MySecondViewer(), 0) # MySecondViewer will be prioritised + ImageShow.register(ImageShow.XVViewer(), 0) # XVViewer will be prioritised + + :param viewer: The viewer to be registered. + :param order: + Zero or a negative integer to prepend this viewer to the list, + a positive integer to append it. + """ + try: + if issubclass(viewer, Viewer): + viewer = viewer() + except TypeError: + pass # raised if viewer wasn't a class + if order > 0: + _viewers.append(viewer) + else: + _viewers.insert(0, viewer) + + +def show(image: Image.Image, title: str | None = None, **options: Any) -> bool: + r""" + Display a given image. + + :param image: An image object. + :param title: Optional title. Not all viewers can display the title. + :param \**options: Additional viewer options. + :returns: ``True`` if a suitable viewer was found, ``False`` otherwise. + """ + for viewer in _viewers: + if viewer.show(image, title=title, **options): + return True + return False + + +class Viewer: + """Base class for viewers.""" + + # main api + + def show(self, image: Image.Image, **options: Any) -> int: + """ + The main function for displaying an image. + Converts the given image to the target format and displays it. + """ + + if not ( + image.mode in ("1", "RGBA") + or (self.format == "PNG" and image.mode in ("I;16", "LA")) + ): + base = Image.getmodebase(image.mode) + if image.mode != base: + image = image.convert(base) + + return self.show_image(image, **options) + + # hook methods + + format: str | None = None + """The format to convert the image into.""" + options: dict[str, Any] = {} + """Additional options used to convert the image.""" + + def get_format(self, image: Image.Image) -> str | None: + """Return format name, or ``None`` to save as PGM/PPM.""" + return self.format + + def get_command(self, file: str, **options: Any) -> str: + """ + Returns the command used to display the file. + Not implemented in the base class. + """ + msg = "unavailable in base viewer" + raise NotImplementedError(msg) + + def save_image(self, image: Image.Image) -> str: + """Save to temporary file and return filename.""" + return image._dump(format=self.get_format(image), **self.options) + + def show_image(self, image: Image.Image, **options: Any) -> int: + """Display the given image.""" + return self.show_file(self.save_image(image), **options) + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + os.system(self.get_command(path, **options)) # nosec + return 1 + + +# -------------------------------------------------------------------- + + +class WindowsViewer(Viewer): + """The default viewer on Windows is the default system application for PNG files.""" + + format = "PNG" + options = {"compress_level": 1, "save_all": True} + + def get_command(self, file: str, **options: Any) -> str: + return ( + f'start "Pillow" /WAIT "{file}" ' + "&& ping -n 4 127.0.0.1 >NUL " + f'&& del /f "{file}"' + ) + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + subprocess.Popen( + self.get_command(path, **options), + shell=True, + creationflags=getattr(subprocess, "CREATE_NO_WINDOW"), + ) # nosec + return 1 + + +if sys.platform == "win32": + register(WindowsViewer) + + +class MacViewer(Viewer): + """The default viewer on macOS using ``Preview.app``.""" + + format = "PNG" + options = {"compress_level": 1, "save_all": True} + + def get_command(self, file: str, **options: Any) -> str: + # on darwin open returns immediately resulting in the temp + # file removal while app is opening + command = "open -a Preview.app" + command = f"({command} {quote(file)}; sleep 20; rm -f {quote(file)})&" + return command + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + subprocess.call(["open", "-a", "Preview.app", path]) + executable = sys.executable or shutil.which("python3") + if executable: + subprocess.Popen( + [ + executable, + "-c", + "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", + path, + ] + ) + return 1 + + +if sys.platform == "darwin": + register(MacViewer) + + +class UnixViewer(Viewer): + format = "PNG" + options = {"compress_level": 1, "save_all": True} + + @abc.abstractmethod + def get_command_ex(self, file: str, **options: Any) -> tuple[str, str]: + pass + + def get_command(self, file: str, **options: Any) -> str: + command = self.get_command_ex(file, **options)[0] + return f"({command} {quote(file)}" + + +class XDGViewer(UnixViewer): + """ + The freedesktop.org ``xdg-open`` command. + """ + + def get_command_ex(self, file: str, **options: Any) -> tuple[str, str]: + command = executable = "xdg-open" + return command, executable + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + subprocess.Popen(["xdg-open", path]) + return 1 + + +class DisplayViewer(UnixViewer): + """ + The ImageMagick ``display`` command. + This viewer supports the ``title`` parameter. + """ + + def get_command_ex( + self, file: str, title: str | None = None, **options: Any + ) -> tuple[str, str]: + command = executable = "display" + if title: + command += f" -title {quote(title)}" + return command, executable + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + args = ["display"] + title = options.get("title") + if title: + args += ["-title", title] + args.append(path) + + subprocess.Popen(args) + return 1 + + +class GmDisplayViewer(UnixViewer): + """The GraphicsMagick ``gm display`` command.""" + + def get_command_ex(self, file: str, **options: Any) -> tuple[str, str]: + executable = "gm" + command = "gm display" + return command, executable + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + subprocess.Popen(["gm", "display", path]) + return 1 + + +class EogViewer(UnixViewer): + """The GNOME Image Viewer ``eog`` command.""" + + def get_command_ex(self, file: str, **options: Any) -> tuple[str, str]: + executable = "eog" + command = "eog -n" + return command, executable + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + subprocess.Popen(["eog", "-n", path]) + return 1 + + +class XVViewer(UnixViewer): + """ + The X Viewer ``xv`` command. + This viewer supports the ``title`` parameter. + """ + + def get_command_ex( + self, file: str, title: str | None = None, **options: Any + ) -> tuple[str, str]: + # note: xv is pretty outdated. most modern systems have + # imagemagick's display command instead. + command = executable = "xv" + if title: + command += f" -name {quote(title)}" + return command, executable + + def show_file(self, path: str, **options: Any) -> int: + """ + Display given file. + """ + args = ["xv"] + title = options.get("title") + if title: + args += ["-name", title] + args.append(path) + + subprocess.Popen(args) + return 1 + + +if sys.platform not in ("win32", "darwin"): # unixoids + if shutil.which("xdg-open"): + register(XDGViewer) + if shutil.which("display"): + register(DisplayViewer) + if shutil.which("gm"): + register(GmDisplayViewer) + if shutil.which("eog"): + register(EogViewer) + if shutil.which("xv"): + register(XVViewer) + + +class IPythonViewer(Viewer): + """The viewer for IPython frontends.""" + + def show_image(self, image: Image.Image, **options: Any) -> int: + ipython_display(image) + return 1 + + +try: + from IPython.display import display as ipython_display +except ImportError: + pass +else: + register(IPythonViewer) + + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Syntax: python3 ImageShow.py imagefile [title]") + sys.exit() + + with Image.open(sys.argv[1]) as im: + print(show(im, *sys.argv[2:])) diff --git a/venv/lib/python3.10/site-packages/PIL/ImageStat.py b/venv/lib/python3.10/site-packages/PIL/ImageStat.py new file mode 100644 index 00000000..13864e59 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageStat.py @@ -0,0 +1,129 @@ +# +# The Python Imaging Library. +# $Id$ +# +# global image statistics +# +# History: +# 1996-04-05 fl Created +# 1997-05-21 fl Added mask; added rms, var, stddev attributes +# 1997-08-05 fl Added median +# 1998-07-05 hk Fixed integer overflow error +# +# Notes: +# This class shows how to implement delayed evaluation of attributes. +# To get a certain value, simply access the corresponding attribute. +# The __getattr__ dispatcher takes care of the rest. +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996-97. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import math + + +class Stat: + def __init__(self, image_or_list, mask=None): + try: + if mask: + self.h = image_or_list.histogram(mask) + else: + self.h = image_or_list.histogram() + except AttributeError: + self.h = image_or_list # assume it to be a histogram list + if not isinstance(self.h, list): + msg = "first argument must be image or list" + raise TypeError(msg) + self.bands = list(range(len(self.h) // 256)) + + def __getattr__(self, id): + """Calculate missing attribute""" + if id[:4] == "_get": + raise AttributeError(id) + # calculate missing attribute + v = getattr(self, "_get" + id)() + setattr(self, id, v) + return v + + def _getextrema(self): + """Get min/max values for each band in the image""" + + def minmax(histogram): + res_min, res_max = 255, 0 + for i in range(256): + if histogram[i]: + res_min = i + break + for i in range(255, -1, -1): + if histogram[i]: + res_max = i + break + return res_min, res_max + + return [minmax(self.h[i:]) for i in range(0, len(self.h), 256)] + + def _getcount(self): + """Get total number of pixels in each layer""" + return [sum(self.h[i : i + 256]) for i in range(0, len(self.h), 256)] + + def _getsum(self): + """Get sum of all pixels in each layer""" + + v = [] + for i in range(0, len(self.h), 256): + layer_sum = 0.0 + for j in range(256): + layer_sum += j * self.h[i + j] + v.append(layer_sum) + return v + + def _getsum2(self): + """Get squared sum of all pixels in each layer""" + + v = [] + for i in range(0, len(self.h), 256): + sum2 = 0.0 + for j in range(256): + sum2 += (j**2) * float(self.h[i + j]) + v.append(sum2) + return v + + def _getmean(self): + """Get average pixel level for each layer""" + return [self.sum[i] / self.count[i] for i in self.bands] + + def _getmedian(self): + """Get median pixel level for each layer""" + + v = [] + for i in self.bands: + s = 0 + half = self.count[i] // 2 + b = i * 256 + for j in range(256): + s = s + self.h[b + j] + if s > half: + break + v.append(j) + return v + + def _getrms(self): + """Get RMS for each layer""" + return [math.sqrt(self.sum2[i] / self.count[i]) for i in self.bands] + + def _getvar(self): + """Get variance for each layer""" + return [ + (self.sum2[i] - (self.sum[i] ** 2.0) / self.count[i]) / self.count[i] + for i in self.bands + ] + + def _getstddev(self): + """Get standard deviation for each layer""" + return [math.sqrt(self.var[i]) for i in self.bands] + + +Global = Stat # compatibility diff --git a/venv/lib/python3.10/site-packages/PIL/ImageTk.py b/venv/lib/python3.10/site-packages/PIL/ImageTk.py new file mode 100644 index 00000000..10b2cc69 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageTk.py @@ -0,0 +1,284 @@ +# +# The Python Imaging Library. +# $Id$ +# +# a Tk display interface +# +# History: +# 96-04-08 fl Created +# 96-09-06 fl Added getimage method +# 96-11-01 fl Rewritten, removed image attribute and crop method +# 97-05-09 fl Use PyImagingPaste method instead of image type +# 97-05-12 fl Minor tweaks to match the IFUNC95 interface +# 97-05-17 fl Support the "pilbitmap" booster patch +# 97-06-05 fl Added file= and data= argument to image constructors +# 98-03-09 fl Added width and height methods to Image classes +# 98-07-02 fl Use default mode for "P" images without palette attribute +# 98-07-02 fl Explicitly destroy Tkinter image objects +# 99-07-24 fl Support multiple Tk interpreters (from Greg Couch) +# 99-07-26 fl Automatically hook into Tkinter (if possible) +# 99-08-15 fl Hook uses _imagingtk instead of _imaging +# +# Copyright (c) 1997-1999 by Secret Labs AB +# Copyright (c) 1996-1997 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import tkinter +from io import BytesIO + +from . import Image + +# -------------------------------------------------------------------- +# Check for Tkinter interface hooks + +_pilbitmap_ok = None + + +def _pilbitmap_check(): + global _pilbitmap_ok + if _pilbitmap_ok is None: + try: + im = Image.new("1", (1, 1)) + tkinter.BitmapImage(data=f"PIL:{im.im.id}") + _pilbitmap_ok = 1 + except tkinter.TclError: + _pilbitmap_ok = 0 + return _pilbitmap_ok + + +def _get_image_from_kw(kw): + source = None + if "file" in kw: + source = kw.pop("file") + elif "data" in kw: + source = BytesIO(kw.pop("data")) + if source: + return Image.open(source) + + +def _pyimagingtkcall(command, photo, id): + tk = photo.tk + try: + tk.call(command, photo, id) + except tkinter.TclError: + # activate Tkinter hook + # may raise an error if it cannot attach to Tkinter + from . import _imagingtk + + _imagingtk.tkinit(tk.interpaddr()) + tk.call(command, photo, id) + + +# -------------------------------------------------------------------- +# PhotoImage + + +class PhotoImage: + """ + A Tkinter-compatible photo image. This can be used + everywhere Tkinter expects an image object. If the image is an RGBA + image, pixels having alpha 0 are treated as transparent. + + The constructor takes either a PIL image, or a mode and a size. + Alternatively, you can use the ``file`` or ``data`` options to initialize + the photo image object. + + :param image: Either a PIL image, or a mode string. If a mode string is + used, a size must also be given. + :param size: If the first argument is a mode string, this defines the size + of the image. + :keyword file: A filename to load the image from (using + ``Image.open(file)``). + :keyword data: An 8-bit string containing image data (as loaded from an + image file). + """ + + def __init__(self, image=None, size=None, **kw): + # Tk compatibility: file or data + if image is None: + image = _get_image_from_kw(kw) + + if hasattr(image, "mode") and hasattr(image, "size"): + # got an image instead of a mode + mode = image.mode + if mode == "P": + # palette mapped data + image.apply_transparency() + image.load() + try: + mode = image.palette.mode + except AttributeError: + mode = "RGB" # default + size = image.size + kw["width"], kw["height"] = size + else: + mode = image + image = None + + if mode not in ["1", "L", "RGB", "RGBA"]: + mode = Image.getmodebase(mode) + + self.__mode = mode + self.__size = size + self.__photo = tkinter.PhotoImage(**kw) + self.tk = self.__photo.tk + if image: + self.paste(image) + + def __del__(self): + name = self.__photo.name + self.__photo.name = None + try: + self.__photo.tk.call("image", "delete", name) + except Exception: + pass # ignore internal errors + + def __str__(self): + """ + Get the Tkinter photo image identifier. This method is automatically + called by Tkinter whenever a PhotoImage object is passed to a Tkinter + method. + + :return: A Tkinter photo image identifier (a string). + """ + return str(self.__photo) + + def width(self): + """ + Get the width of the image. + + :return: The width, in pixels. + """ + return self.__size[0] + + def height(self): + """ + Get the height of the image. + + :return: The height, in pixels. + """ + return self.__size[1] + + def paste(self, im): + """ + Paste a PIL image into the photo image. Note that this can + be very slow if the photo image is displayed. + + :param im: A PIL image. The size must match the target region. If the + mode does not match, the image is converted to the mode of + the bitmap image. + """ + # convert to blittable + im.load() + image = im.im + if image.isblock() and im.mode == self.__mode: + block = image + else: + block = image.new_block(self.__mode, im.size) + image.convert2(block, image) # convert directly between buffers + + _pyimagingtkcall("PyImagingPhoto", self.__photo, block.id) + + +# -------------------------------------------------------------------- +# BitmapImage + + +class BitmapImage: + """ + A Tkinter-compatible bitmap image. This can be used everywhere Tkinter + expects an image object. + + The given image must have mode "1". Pixels having value 0 are treated as + transparent. Options, if any, are passed on to Tkinter. The most commonly + used option is ``foreground``, which is used to specify the color for the + non-transparent parts. See the Tkinter documentation for information on + how to specify colours. + + :param image: A PIL image. + """ + + def __init__(self, image=None, **kw): + # Tk compatibility: file or data + if image is None: + image = _get_image_from_kw(kw) + + self.__mode = image.mode + self.__size = image.size + + if _pilbitmap_check(): + # fast way (requires the pilbitmap booster patch) + image.load() + kw["data"] = f"PIL:{image.im.id}" + self.__im = image # must keep a reference + else: + # slow but safe way + kw["data"] = image.tobitmap() + self.__photo = tkinter.BitmapImage(**kw) + + def __del__(self): + name = self.__photo.name + self.__photo.name = None + try: + self.__photo.tk.call("image", "delete", name) + except Exception: + pass # ignore internal errors + + def width(self): + """ + Get the width of the image. + + :return: The width, in pixels. + """ + return self.__size[0] + + def height(self): + """ + Get the height of the image. + + :return: The height, in pixels. + """ + return self.__size[1] + + def __str__(self): + """ + Get the Tkinter bitmap image identifier. This method is automatically + called by Tkinter whenever a BitmapImage object is passed to a Tkinter + method. + + :return: A Tkinter bitmap image identifier (a string). + """ + return str(self.__photo) + + +def getimage(photo): + """Copies the contents of a PhotoImage to a PIL image memory.""" + im = Image.new("RGBA", (photo.width(), photo.height())) + block = im.im + + _pyimagingtkcall("PyImagingPhotoGet", photo, block.id) + + return im + + +def _show(image, title): + """Helper for the Image.show method.""" + + class UI(tkinter.Label): + def __init__(self, master, im): + if im.mode == "1": + self.image = BitmapImage(im, foreground="white", master=master) + else: + self.image = PhotoImage(im, master=master) + super().__init__(master, image=self.image, bg="black", bd=0) + + if not tkinter._default_root: + msg = "tkinter not initialized" + raise OSError(msg) + top = tkinter.Toplevel() + if title: + top.title(title) + UI(top, image).pack() diff --git a/venv/lib/python3.10/site-packages/PIL/ImageTransform.py b/venv/lib/python3.10/site-packages/PIL/ImageTransform.py new file mode 100644 index 00000000..6aa82dad --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageTransform.py @@ -0,0 +1,135 @@ +# +# The Python Imaging Library. +# $Id$ +# +# transform wrappers +# +# History: +# 2002-04-08 fl Created +# +# Copyright (c) 2002 by Secret Labs AB +# Copyright (c) 2002 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from typing import Sequence + +from . import Image + + +class Transform(Image.ImageTransformHandler): + """Base class for other transforms defined in :py:mod:`~PIL.ImageTransform`.""" + + method: Image.Transform + + def __init__(self, data: Sequence[int]) -> None: + self.data = data + + def getdata(self) -> tuple[Image.Transform, Sequence[int]]: + return self.method, self.data + + def transform( + self, + size: tuple[int, int], + image: Image.Image, + **options: dict[str, str | int | tuple[int, ...] | list[int]], + ) -> Image.Image: + """Perform the transform. Called from :py:meth:`.Image.transform`.""" + # can be overridden + method, data = self.getdata() + return image.transform(size, method, data, **options) + + +class AffineTransform(Transform): + """ + Define an affine image transform. + + This function takes a 6-tuple (a, b, c, d, e, f) which contain the first + two rows from an affine transform matrix. For each pixel (x, y) in the + output image, the new value is taken from a position (a x + b y + c, + d x + e y + f) in the input image, rounded to nearest pixel. + + This function can be used to scale, translate, rotate, and shear the + original image. + + See :py:meth:`.Image.transform` + + :param matrix: A 6-tuple (a, b, c, d, e, f) containing the first two rows + from an affine transform matrix. + """ + + method = Image.Transform.AFFINE + + +class PerspectiveTransform(Transform): + """ + Define a perspective image transform. + + This function takes an 8-tuple (a, b, c, d, e, f, g, h). For each pixel + (x, y) in the output image, the new value is taken from a position + ((a x + b y + c) / (g x + h y + 1), (d x + e y + f) / (g x + h y + 1)) in + the input image, rounded to nearest pixel. + + This function can be used to scale, translate, rotate, and shear the + original image. + + See :py:meth:`.Image.transform` + + :param matrix: An 8-tuple (a, b, c, d, e, f, g, h). + """ + + method = Image.Transform.PERSPECTIVE + + +class ExtentTransform(Transform): + """ + Define a transform to extract a subregion from an image. + + Maps a rectangle (defined by two corners) from the image to a rectangle of + the given size. The resulting image will contain data sampled from between + the corners, such that (x0, y0) in the input image will end up at (0,0) in + the output image, and (x1, y1) at size. + + This method can be used to crop, stretch, shrink, or mirror an arbitrary + rectangle in the current image. It is slightly slower than crop, but about + as fast as a corresponding resize operation. + + See :py:meth:`.Image.transform` + + :param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the + input image's coordinate system. See :ref:`coordinate-system`. + """ + + method = Image.Transform.EXTENT + + +class QuadTransform(Transform): + """ + Define a quad image transform. + + Maps a quadrilateral (a region defined by four corners) from the image to a + rectangle of the given size. + + See :py:meth:`.Image.transform` + + :param xy: An 8-tuple (x0, y0, x1, y1, x2, y2, x3, y3) which contain the + upper left, lower left, lower right, and upper right corner of the + source quadrilateral. + """ + + method = Image.Transform.QUAD + + +class MeshTransform(Transform): + """ + Define a mesh image transform. A mesh transform consists of one or more + individual quad transforms. + + See :py:meth:`.Image.transform` + + :param data: A list of (bbox, quad) tuples. + """ + + method = Image.Transform.MESH diff --git a/venv/lib/python3.10/site-packages/PIL/ImageWin.py b/venv/lib/python3.10/site-packages/PIL/ImageWin.py new file mode 100644 index 00000000..75910d2d --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImageWin.py @@ -0,0 +1,231 @@ +# +# The Python Imaging Library. +# $Id$ +# +# a Windows DIB display interface +# +# History: +# 1996-05-20 fl Created +# 1996-09-20 fl Fixed subregion exposure +# 1997-09-21 fl Added draw primitive (for tzPrint) +# 2003-05-21 fl Added experimental Window/ImageWindow classes +# 2003-09-05 fl Added fromstring/tostring methods +# +# Copyright (c) Secret Labs AB 1997-2003. +# Copyright (c) Fredrik Lundh 1996-2003. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image + + +class HDC: + """ + Wraps an HDC integer. The resulting object can be passed to the + :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose` + methods. + """ + + def __init__(self, dc): + self.dc = dc + + def __int__(self): + return self.dc + + +class HWND: + """ + Wraps an HWND integer. The resulting object can be passed to the + :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose` + methods, instead of a DC. + """ + + def __init__(self, wnd): + self.wnd = wnd + + def __int__(self): + return self.wnd + + +class Dib: + """ + A Windows bitmap with the given mode and size. The mode can be one of "1", + "L", "P", or "RGB". + + If the display requires a palette, this constructor creates a suitable + palette and associates it with the image. For an "L" image, 128 graylevels + are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together + with 20 graylevels. + + To make sure that palettes work properly under Windows, you must call the + ``palette`` method upon certain events from Windows. + + :param image: Either a PIL image, or a mode string. If a mode string is + used, a size must also be given. The mode can be one of "1", + "L", "P", or "RGB". + :param size: If the first argument is a mode string, this + defines the size of the image. + """ + + def __init__(self, image, size=None): + if hasattr(image, "mode") and hasattr(image, "size"): + mode = image.mode + size = image.size + else: + mode = image + image = None + if mode not in ["1", "L", "P", "RGB"]: + mode = Image.getmodebase(mode) + self.image = Image.core.display(mode, size) + self.mode = mode + self.size = size + if image: + self.paste(image) + + def expose(self, handle): + """ + Copy the bitmap contents to a device context. + + :param handle: Device context (HDC), cast to a Python integer, or an + HDC or HWND instance. In PythonWin, you can use + ``CDC.GetHandleAttrib()`` to get a suitable handle. + """ + if isinstance(handle, HWND): + dc = self.image.getdc(handle) + try: + result = self.image.expose(dc) + finally: + self.image.releasedc(handle, dc) + else: + result = self.image.expose(handle) + return result + + def draw(self, handle, dst, src=None): + """ + Same as expose, but allows you to specify where to draw the image, and + what part of it to draw. + + The destination and source areas are given as 4-tuple rectangles. If + the source is omitted, the entire image is copied. If the source and + the destination have different sizes, the image is resized as + necessary. + """ + if not src: + src = (0, 0) + self.size + if isinstance(handle, HWND): + dc = self.image.getdc(handle) + try: + result = self.image.draw(dc, dst, src) + finally: + self.image.releasedc(handle, dc) + else: + result = self.image.draw(handle, dst, src) + return result + + def query_palette(self, handle): + """ + Installs the palette associated with the image in the given device + context. + + This method should be called upon **QUERYNEWPALETTE** and + **PALETTECHANGED** events from Windows. If this method returns a + non-zero value, one or more display palette entries were changed, and + the image should be redrawn. + + :param handle: Device context (HDC), cast to a Python integer, or an + HDC or HWND instance. + :return: A true value if one or more entries were changed (this + indicates that the image should be redrawn). + """ + if isinstance(handle, HWND): + handle = self.image.getdc(handle) + try: + result = self.image.query_palette(handle) + finally: + self.image.releasedc(handle, handle) + else: + result = self.image.query_palette(handle) + return result + + def paste(self, im, box=None): + """ + Paste a PIL image into the bitmap image. + + :param im: A PIL image. The size must match the target region. + If the mode does not match, the image is converted to the + mode of the bitmap image. + :param box: A 4-tuple defining the left, upper, right, and + lower pixel coordinate. See :ref:`coordinate-system`. If + None is given instead of a tuple, all of the image is + assumed. + """ + im.load() + if self.mode != im.mode: + im = im.convert(self.mode) + if box: + self.image.paste(im.im, box) + else: + self.image.paste(im.im) + + def frombytes(self, buffer): + """ + Load display memory contents from byte data. + + :param buffer: A buffer containing display data (usually + data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`) + """ + return self.image.frombytes(buffer) + + def tobytes(self): + """ + Copy display memory contents to bytes object. + + :return: A bytes object containing display data. + """ + return self.image.tobytes() + + +class Window: + """Create a Window with the given title size.""" + + def __init__(self, title="PIL", width=None, height=None): + self.hwnd = Image.core.createwindow( + title, self.__dispatcher, width or 0, height or 0 + ) + + def __dispatcher(self, action, *args): + return getattr(self, "ui_handle_" + action)(*args) + + def ui_handle_clear(self, dc, x0, y0, x1, y1): + pass + + def ui_handle_damage(self, x0, y0, x1, y1): + pass + + def ui_handle_destroy(self): + pass + + def ui_handle_repair(self, dc, x0, y0, x1, y1): + pass + + def ui_handle_resize(self, width, height): + pass + + def mainloop(self): + Image.core.eventloop() + + +class ImageWindow(Window): + """Create an image window which displays the given image.""" + + def __init__(self, image, title="PIL"): + if not isinstance(image, Dib): + image = Dib(image) + self.image = image + width, height = image.size + super().__init__(title, width=width, height=height) + + def ui_handle_repair(self, dc, x0, y0, x1, y1): + self.image.draw(dc, (x0, y0, x1, y1)) diff --git a/venv/lib/python3.10/site-packages/PIL/ImtImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/ImtImagePlugin.py new file mode 100644 index 00000000..abb3fb76 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/ImtImagePlugin.py @@ -0,0 +1,103 @@ +# +# The Python Imaging Library. +# $Id$ +# +# IM Tools support for PIL +# +# history: +# 1996-05-27 fl Created (read 8-bit images only) +# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.2) +# +# Copyright (c) Secret Labs AB 1997-2001. +# Copyright (c) Fredrik Lundh 1996-2001. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import re + +from . import Image, ImageFile + +# +# -------------------------------------------------------------------- + +field = re.compile(rb"([a-z]*) ([^ \r\n]*)") + + +## +# Image plugin for IM Tools images. + + +class ImtImageFile(ImageFile.ImageFile): + format = "IMT" + format_description = "IM Tools" + + def _open(self) -> None: + # Quick rejection: if there's not a LF among the first + # 100 bytes, this is (probably) not a text header. + + assert self.fp is not None + + buffer = self.fp.read(100) + if b"\n" not in buffer: + msg = "not an IM file" + raise SyntaxError(msg) + + xsize = ysize = 0 + + while True: + if buffer: + s = buffer[:1] + buffer = buffer[1:] + else: + s = self.fp.read(1) + if not s: + break + + if s == b"\x0C": + # image data begins + self.tile = [ + ( + "raw", + (0, 0) + self.size, + self.fp.tell() - len(buffer), + (self.mode, 0, 1), + ) + ] + + break + + else: + # read key/value pair + if b"\n" not in buffer: + buffer += self.fp.read(100) + lines = buffer.split(b"\n") + s += lines.pop(0) + buffer = b"\n".join(lines) + if len(s) == 1 or len(s) > 100: + break + if s[0] == ord(b"*"): + continue # comment + + m = field.match(s) + if not m: + break + k, v = m.group(1, 2) + if k == b"width": + xsize = int(v) + self._size = xsize, ysize + elif k == b"height": + ysize = int(v) + self._size = xsize, ysize + elif k == b"pixel" and v == b"n8": + self._mode = "L" + + +# +# -------------------------------------------------------------------- + +Image.register_open(ImtImageFile.format, ImtImageFile) + +# +# no extension registered (".im" is simply too common) diff --git a/venv/lib/python3.10/site-packages/PIL/IptcImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/IptcImagePlugin.py new file mode 100644 index 00000000..40960943 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/IptcImagePlugin.py @@ -0,0 +1,235 @@ +# +# The Python Imaging Library. +# $Id$ +# +# IPTC/NAA file handling +# +# history: +# 1995-10-01 fl Created +# 1998-03-09 fl Cleaned up and added to PIL +# 2002-06-18 fl Added getiptcinfo helper +# +# Copyright (c) Secret Labs AB 1997-2002. +# Copyright (c) Fredrik Lundh 1995. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from io import BytesIO +from typing import Sequence + +from . import Image, ImageFile +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._deprecate import deprecate + +COMPRESSION = {1: "raw", 5: "jpeg"} + + +def __getattr__(name: str) -> bytes: + if name == "PAD": + deprecate("IptcImagePlugin.PAD", 12) + return b"\0\0\0\0" + msg = f"module '{__name__}' has no attribute '{name}'" + raise AttributeError(msg) + + +# +# Helpers + + +def _i(c: bytes) -> int: + return i32((b"\0\0\0\0" + c)[-4:]) + + +def _i8(c: int | bytes) -> int: + return c if isinstance(c, int) else c[0] + + +def i(c: bytes) -> int: + """.. deprecated:: 10.2.0""" + deprecate("IptcImagePlugin.i", 12) + return _i(c) + + +def dump(c: Sequence[int | bytes]) -> None: + """.. deprecated:: 10.2.0""" + deprecate("IptcImagePlugin.dump", 12) + for i in c: + print("%02x" % _i8(i), end=" ") + print() + + +## +# Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields +# from TIFF and JPEG files, use the getiptcinfo function. + + +class IptcImageFile(ImageFile.ImageFile): + format = "IPTC" + format_description = "IPTC/NAA" + + def getint(self, key: tuple[int, int]) -> int: + return _i(self.info[key]) + + def field(self) -> tuple[tuple[int, int] | None, int]: + # + # get a IPTC field header + s = self.fp.read(5) + if not s.strip(b"\x00"): + return None, 0 + + tag = s[1], s[2] + + # syntax + if s[0] != 0x1C or tag[0] not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 240]: + msg = "invalid IPTC/NAA file" + raise SyntaxError(msg) + + # field size + size = s[3] + if size > 132: + msg = "illegal field length in IPTC/NAA file" + raise OSError(msg) + elif size == 128: + size = 0 + elif size > 128: + size = _i(self.fp.read(size - 128)) + else: + size = i16(s, 3) + + return tag, size + + def _open(self) -> None: + # load descriptive fields + while True: + offset = self.fp.tell() + tag, size = self.field() + if not tag or tag == (8, 10): + break + if size: + tagdata = self.fp.read(size) + else: + tagdata = None + if tag in self.info: + if isinstance(self.info[tag], list): + self.info[tag].append(tagdata) + else: + self.info[tag] = [self.info[tag], tagdata] + else: + self.info[tag] = tagdata + + # mode + layers = self.info[(3, 60)][0] + component = self.info[(3, 60)][1] + if (3, 65) in self.info: + id = self.info[(3, 65)][0] - 1 + else: + id = 0 + if layers == 1 and not component: + self._mode = "L" + elif layers == 3 and component: + self._mode = "RGB"[id] + elif layers == 4 and component: + self._mode = "CMYK"[id] + + # size + self._size = self.getint((3, 20)), self.getint((3, 30)) + + # compression + try: + compression = COMPRESSION[self.getint((3, 120))] + except KeyError as e: + msg = "Unknown IPTC image compression" + raise OSError(msg) from e + + # tile + if tag == (8, 10): + self.tile = [("iptc", (0, 0) + self.size, offset, compression)] + + def load(self): + if len(self.tile) != 1 or self.tile[0][0] != "iptc": + return ImageFile.ImageFile.load(self) + + offset, compression = self.tile[0][2:] + + self.fp.seek(offset) + + # Copy image data to temporary file + o = BytesIO() + if compression == "raw": + # To simplify access to the extracted file, + # prepend a PPM header + o.write(b"P5\n%d %d\n255\n" % self.size) + while True: + type, size = self.field() + if type != (8, 10): + break + while size > 0: + s = self.fp.read(min(size, 8192)) + if not s: + break + o.write(s) + size -= len(s) + + with Image.open(o) as _im: + _im.load() + self.im = _im.im + + +Image.register_open(IptcImageFile.format, IptcImageFile) + +Image.register_extension(IptcImageFile.format, ".iim") + + +def getiptcinfo(im): + """ + Get IPTC information from TIFF, JPEG, or IPTC file. + + :param im: An image containing IPTC data. + :returns: A dictionary containing IPTC information, or None if + no IPTC information block was found. + """ + from . import JpegImagePlugin, TiffImagePlugin + + data = None + + if isinstance(im, IptcImageFile): + # return info dictionary right away + return im.info + + elif isinstance(im, JpegImagePlugin.JpegImageFile): + # extract the IPTC/NAA resource + photoshop = im.info.get("photoshop") + if photoshop: + data = photoshop.get(0x0404) + + elif isinstance(im, TiffImagePlugin.TiffImageFile): + # get raw data from the IPTC/NAA tag (PhotoShop tags the data + # as 4-byte integers, so we cannot use the get method...) + try: + data = im.tag.tagdata[TiffImagePlugin.IPTC_NAA_CHUNK] + except (AttributeError, KeyError): + pass + + if data is None: + return None # no properties + + # create an IptcImagePlugin object without initializing it + class FakeImage: + pass + + im = FakeImage() + im.__class__ = IptcImageFile + + # parse the IPTC information chunk + im.info = {} + im.fp = BytesIO(data) + + try: + im._open() + except (IndexError, KeyError): + pass # expected failure + + return im.info diff --git a/venv/lib/python3.10/site-packages/PIL/Jpeg2KImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/Jpeg2KImagePlugin.py new file mode 100644 index 00000000..be000c35 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/Jpeg2KImagePlugin.py @@ -0,0 +1,403 @@ +# +# The Python Imaging Library +# $Id$ +# +# JPEG2000 file handling +# +# History: +# 2014-03-12 ajh Created +# 2021-06-30 rogermb Extract dpi information from the 'resc' header box +# +# Copyright (c) 2014 Coriolis Systems Limited +# Copyright (c) 2014 Alastair Houghton +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import os +import struct + +from . import Image, ImageFile, ImagePalette, _binary + + +class BoxReader: + """ + A small helper class to read fields stored in JPEG2000 header boxes + and to easily step into and read sub-boxes. + """ + + def __init__(self, fp, length=-1): + self.fp = fp + self.has_length = length >= 0 + self.length = length + self.remaining_in_box = -1 + + def _can_read(self, num_bytes): + if self.has_length and self.fp.tell() + num_bytes > self.length: + # Outside box: ensure we don't read past the known file length + return False + if self.remaining_in_box >= 0: + # Inside box contents: ensure read does not go past box boundaries + return num_bytes <= self.remaining_in_box + else: + return True # No length known, just read + + def _read_bytes(self, num_bytes): + if not self._can_read(num_bytes): + msg = "Not enough data in header" + raise SyntaxError(msg) + + data = self.fp.read(num_bytes) + if len(data) < num_bytes: + msg = f"Expected to read {num_bytes} bytes but only got {len(data)}." + raise OSError(msg) + + if self.remaining_in_box > 0: + self.remaining_in_box -= num_bytes + return data + + def read_fields(self, field_format): + size = struct.calcsize(field_format) + data = self._read_bytes(size) + return struct.unpack(field_format, data) + + def read_boxes(self): + size = self.remaining_in_box + data = self._read_bytes(size) + return BoxReader(io.BytesIO(data), size) + + def has_next_box(self): + if self.has_length: + return self.fp.tell() + self.remaining_in_box < self.length + else: + return True + + def next_box_type(self): + # Skip the rest of the box if it has not been read + if self.remaining_in_box > 0: + self.fp.seek(self.remaining_in_box, os.SEEK_CUR) + self.remaining_in_box = -1 + + # Read the length and type of the next box + lbox, tbox = self.read_fields(">I4s") + if lbox == 1: + lbox = self.read_fields(">Q")[0] + hlen = 16 + else: + hlen = 8 + + if lbox < hlen or not self._can_read(lbox - hlen): + msg = "Invalid header length" + raise SyntaxError(msg) + + self.remaining_in_box = lbox - hlen + return tbox + + +def _parse_codestream(fp): + """Parse the JPEG 2000 codestream to extract the size and component + count from the SIZ marker segment, returning a PIL (size, mode) tuple.""" + + hdr = fp.read(2) + lsiz = _binary.i16be(hdr) + siz = hdr + fp.read(lsiz - 2) + lsiz, rsiz, xsiz, ysiz, xosiz, yosiz, _, _, _, _, csiz = struct.unpack_from( + ">HHIIIIIIIIH", siz + ) + + size = (xsiz - xosiz, ysiz - yosiz) + if csiz == 1: + ssiz = struct.unpack_from(">B", siz, 38) + if (ssiz[0] & 0x7F) + 1 > 8: + mode = "I;16" + else: + mode = "L" + elif csiz == 2: + mode = "LA" + elif csiz == 3: + mode = "RGB" + elif csiz == 4: + mode = "RGBA" + else: + mode = None + + return size, mode + + +def _res_to_dpi(num, denom, exp): + """Convert JPEG2000's (numerator, denominator, exponent-base-10) resolution, + calculated as (num / denom) * 10^exp and stored in dots per meter, + to floating-point dots per inch.""" + if denom != 0: + return (254 * num * (10**exp)) / (10000 * denom) + + +def _parse_jp2_header(fp): + """Parse the JP2 header box to extract size, component count, + color space information, and optionally DPI information, + returning a (size, mode, mimetype, dpi) tuple.""" + + # Find the JP2 header box + reader = BoxReader(fp) + header = None + mimetype = None + while reader.has_next_box(): + tbox = reader.next_box_type() + + if tbox == b"jp2h": + header = reader.read_boxes() + break + elif tbox == b"ftyp": + if reader.read_fields(">4s")[0] == b"jpx ": + mimetype = "image/jpx" + + size = None + mode = None + bpc = None + nc = None + dpi = None # 2-tuple of DPI info, or None + palette = None + + while header.has_next_box(): + tbox = header.next_box_type() + + if tbox == b"ihdr": + height, width, nc, bpc = header.read_fields(">IIHB") + size = (width, height) + if nc == 1 and (bpc & 0x7F) > 8: + mode = "I;16" + elif nc == 1: + mode = "L" + elif nc == 2: + mode = "LA" + elif nc == 3: + mode = "RGB" + elif nc == 4: + mode = "RGBA" + elif tbox == b"pclr" and mode in ("L", "LA"): + ne, npc = header.read_fields(">HB") + bitdepths = header.read_fields(">" + ("B" * npc)) + if max(bitdepths) <= 8: + palette = ImagePalette.ImagePalette() + for i in range(ne): + palette.getcolor(header.read_fields(">" + ("B" * npc))) + mode = "P" if mode == "L" else "PA" + elif tbox == b"res ": + res = header.read_boxes() + while res.has_next_box(): + tres = res.next_box_type() + if tres == b"resc": + vrcn, vrcd, hrcn, hrcd, vrce, hrce = res.read_fields(">HHHHBB") + hres = _res_to_dpi(hrcn, hrcd, hrce) + vres = _res_to_dpi(vrcn, vrcd, vrce) + if hres is not None and vres is not None: + dpi = (hres, vres) + break + + if size is None or mode is None: + msg = "Malformed JP2 header" + raise SyntaxError(msg) + + return size, mode, mimetype, dpi, palette + + +## +# Image plugin for JPEG2000 images. + + +class Jpeg2KImageFile(ImageFile.ImageFile): + format = "JPEG2000" + format_description = "JPEG 2000 (ISO 15444)" + + def _open(self): + sig = self.fp.read(4) + if sig == b"\xff\x4f\xff\x51": + self.codec = "j2k" + self._size, self._mode = _parse_codestream(self.fp) + else: + sig = sig + self.fp.read(8) + + if sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a": + self.codec = "jp2" + header = _parse_jp2_header(self.fp) + self._size, self._mode, self.custom_mimetype, dpi, self.palette = header + if dpi is not None: + self.info["dpi"] = dpi + if self.fp.read(12).endswith(b"jp2c\xff\x4f\xff\x51"): + self._parse_comment() + else: + msg = "not a JPEG 2000 file" + raise SyntaxError(msg) + + if self.size is None or self.mode is None: + msg = "unable to determine size/mode" + raise SyntaxError(msg) + + self._reduce = 0 + self.layers = 0 + + fd = -1 + length = -1 + + try: + fd = self.fp.fileno() + length = os.fstat(fd).st_size + except Exception: + fd = -1 + try: + pos = self.fp.tell() + self.fp.seek(0, io.SEEK_END) + length = self.fp.tell() + self.fp.seek(pos) + except Exception: + length = -1 + + self.tile = [ + ( + "jpeg2k", + (0, 0) + self.size, + 0, + (self.codec, self._reduce, self.layers, fd, length), + ) + ] + + def _parse_comment(self): + hdr = self.fp.read(2) + length = _binary.i16be(hdr) + self.fp.seek(length - 2, os.SEEK_CUR) + + while True: + marker = self.fp.read(2) + if not marker: + break + typ = marker[1] + if typ in (0x90, 0xD9): + # Start of tile or end of codestream + break + hdr = self.fp.read(2) + length = _binary.i16be(hdr) + if typ == 0x64: + # Comment + self.info["comment"] = self.fp.read(length - 2)[2:] + break + else: + self.fp.seek(length - 2, os.SEEK_CUR) + + @property + def reduce(self): + # https://github.com/python-pillow/Pillow/issues/4343 found that the + # new Image 'reduce' method was shadowed by this plugin's 'reduce' + # property. This attempts to allow for both scenarios + return self._reduce or super().reduce + + @reduce.setter + def reduce(self, value): + self._reduce = value + + def load(self): + if self.tile and self._reduce: + power = 1 << self._reduce + adjust = power >> 1 + self._size = ( + int((self.size[0] + adjust) / power), + int((self.size[1] + adjust) / power), + ) + + # Update the reduce and layers settings + t = self.tile[0] + t3 = (t[3][0], self._reduce, self.layers, t[3][3], t[3][4]) + self.tile = [(t[0], (0, 0) + self.size, t[2], t3)] + + return ImageFile.ImageFile.load(self) + + +def _accept(prefix): + return ( + prefix[:4] == b"\xff\x4f\xff\x51" + or prefix[:12] == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a" + ) + + +# ------------------------------------------------------------ +# Save support + + +def _save(im, fp, filename): + # Get the keyword arguments + info = im.encoderinfo + + if filename.endswith(".j2k") or info.get("no_jp2", False): + kind = "j2k" + else: + kind = "jp2" + + offset = info.get("offset", None) + tile_offset = info.get("tile_offset", None) + tile_size = info.get("tile_size", None) + quality_mode = info.get("quality_mode", "rates") + quality_layers = info.get("quality_layers", None) + if quality_layers is not None and not ( + isinstance(quality_layers, (list, tuple)) + and all( + isinstance(quality_layer, (int, float)) for quality_layer in quality_layers + ) + ): + msg = "quality_layers must be a sequence of numbers" + raise ValueError(msg) + + num_resolutions = info.get("num_resolutions", 0) + cblk_size = info.get("codeblock_size", None) + precinct_size = info.get("precinct_size", None) + irreversible = info.get("irreversible", False) + progression = info.get("progression", "LRCP") + cinema_mode = info.get("cinema_mode", "no") + mct = info.get("mct", 0) + signed = info.get("signed", False) + comment = info.get("comment") + if isinstance(comment, str): + comment = comment.encode() + plt = info.get("plt", False) + + fd = -1 + if hasattr(fp, "fileno"): + try: + fd = fp.fileno() + except Exception: + fd = -1 + + im.encoderconfig = ( + offset, + tile_offset, + tile_size, + quality_mode, + quality_layers, + num_resolutions, + cblk_size, + precinct_size, + irreversible, + progression, + cinema_mode, + mct, + signed, + fd, + comment, + plt, + ) + + ImageFile._save(im, fp, [("jpeg2k", (0, 0) + im.size, 0, kind)]) + + +# ------------------------------------------------------------ +# Registry stuff + + +Image.register_open(Jpeg2KImageFile.format, Jpeg2KImageFile, _accept) +Image.register_save(Jpeg2KImageFile.format, _save) + +Image.register_extensions( + Jpeg2KImageFile.format, [".jp2", ".j2k", ".jpc", ".jpf", ".jpx", ".j2c"] +) + +Image.register_mime(Jpeg2KImageFile.format, "image/jp2") diff --git a/venv/lib/python3.10/site-packages/PIL/JpegImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/JpegImagePlugin.py new file mode 100644 index 00000000..81b8749a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/JpegImagePlugin.py @@ -0,0 +1,868 @@ +# +# The Python Imaging Library. +# $Id$ +# +# JPEG (JFIF) file handling +# +# See "Digital Compression and Coding of Continuous-Tone Still Images, +# Part 1, Requirements and Guidelines" (CCITT T.81 / ISO 10918-1) +# +# History: +# 1995-09-09 fl Created +# 1995-09-13 fl Added full parser +# 1996-03-25 fl Added hack to use the IJG command line utilities +# 1996-05-05 fl Workaround Photoshop 2.5 CMYK polarity bug +# 1996-05-28 fl Added draft support, JFIF version (0.1) +# 1996-12-30 fl Added encoder options, added progression property (0.2) +# 1997-08-27 fl Save mode 1 images as BW (0.3) +# 1998-07-12 fl Added YCbCr to draft and save methods (0.4) +# 1998-10-19 fl Don't hang on files using 16-bit DQT's (0.4.1) +# 2001-04-16 fl Extract DPI settings from JFIF files (0.4.2) +# 2002-07-01 fl Skip pad bytes before markers; identify Exif files (0.4.3) +# 2003-04-25 fl Added experimental EXIF decoder (0.5) +# 2003-06-06 fl Added experimental EXIF GPSinfo decoder +# 2003-09-13 fl Extract COM markers +# 2009-09-06 fl Added icc_profile support (from Florian Hoech) +# 2009-03-06 fl Changed CMYK handling; always use Adobe polarity (0.6) +# 2009-03-08 fl Added subsampling support (from Justin Huff). +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1995-1996 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import array +import io +import math +import os +import struct +import subprocess +import sys +import tempfile +import warnings + +from . import Image, ImageFile +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 +from ._binary import o16be as o16 +from .JpegPresets import presets + +# +# Parser + + +def Skip(self, marker): + n = i16(self.fp.read(2)) - 2 + ImageFile._safe_read(self.fp, n) + + +def APP(self, marker): + # + # Application marker. Store these in the APP dictionary. + # Also look for well-known application markers. + + n = i16(self.fp.read(2)) - 2 + s = ImageFile._safe_read(self.fp, n) + + app = "APP%d" % (marker & 15) + + self.app[app] = s # compatibility + self.applist.append((app, s)) + + if marker == 0xFFE0 and s[:4] == b"JFIF": + # extract JFIF information + self.info["jfif"] = version = i16(s, 5) # version + self.info["jfif_version"] = divmod(version, 256) + # extract JFIF properties + try: + jfif_unit = s[7] + jfif_density = i16(s, 8), i16(s, 10) + except Exception: + pass + else: + if jfif_unit == 1: + self.info["dpi"] = jfif_density + self.info["jfif_unit"] = jfif_unit + self.info["jfif_density"] = jfif_density + elif marker == 0xFFE1 and s[:6] == b"Exif\0\0": + # extract EXIF information + if "exif" in self.info: + self.info["exif"] += s[6:] + else: + self.info["exif"] = s + self._exif_offset = self.fp.tell() - n + 6 + elif marker == 0xFFE2 and s[:5] == b"FPXR\0": + # extract FlashPix information (incomplete) + self.info["flashpix"] = s # FIXME: value will change + elif marker == 0xFFE2 and s[:12] == b"ICC_PROFILE\0": + # Since an ICC profile can be larger than the maximum size of + # a JPEG marker (64K), we need provisions to split it into + # multiple markers. The format defined by the ICC specifies + # one or more APP2 markers containing the following data: + # Identifying string ASCII "ICC_PROFILE\0" (12 bytes) + # Marker sequence number 1, 2, etc (1 byte) + # Number of markers Total of APP2's used (1 byte) + # Profile data (remainder of APP2 data) + # Decoders should use the marker sequence numbers to + # reassemble the profile, rather than assuming that the APP2 + # markers appear in the correct sequence. + self.icclist.append(s) + elif marker == 0xFFED and s[:14] == b"Photoshop 3.0\x00": + # parse the image resource block + offset = 14 + photoshop = self.info.setdefault("photoshop", {}) + while s[offset : offset + 4] == b"8BIM": + try: + offset += 4 + # resource code + code = i16(s, offset) + offset += 2 + # resource name (usually empty) + name_len = s[offset] + # name = s[offset+1:offset+1+name_len] + offset += 1 + name_len + offset += offset & 1 # align + # resource data block + size = i32(s, offset) + offset += 4 + data = s[offset : offset + size] + if code == 0x03ED: # ResolutionInfo + data = { + "XResolution": i32(data, 0) / 65536, + "DisplayedUnitsX": i16(data, 4), + "YResolution": i32(data, 8) / 65536, + "DisplayedUnitsY": i16(data, 12), + } + photoshop[code] = data + offset += size + offset += offset & 1 # align + except struct.error: + break # insufficient data + + elif marker == 0xFFEE and s[:5] == b"Adobe": + self.info["adobe"] = i16(s, 5) + # extract Adobe custom properties + try: + adobe_transform = s[11] + except IndexError: + pass + else: + self.info["adobe_transform"] = adobe_transform + elif marker == 0xFFE2 and s[:4] == b"MPF\0": + # extract MPO information + self.info["mp"] = s[4:] + # offset is current location minus buffer size + # plus constant header size + self.info["mpoffset"] = self.fp.tell() - n + 4 + + # If DPI isn't in JPEG header, fetch from EXIF + if "dpi" not in self.info and "exif" in self.info: + try: + exif = self.getexif() + resolution_unit = exif[0x0128] + x_resolution = exif[0x011A] + try: + dpi = float(x_resolution[0]) / x_resolution[1] + except TypeError: + dpi = x_resolution + if math.isnan(dpi): + msg = "DPI is not a number" + raise ValueError(msg) + if resolution_unit == 3: # cm + # 1 dpcm = 2.54 dpi + dpi *= 2.54 + self.info["dpi"] = dpi, dpi + except ( + struct.error, + KeyError, + SyntaxError, + TypeError, + ValueError, + ZeroDivisionError, + ): + # struct.error for truncated EXIF + # KeyError for dpi not included + # SyntaxError for invalid/unreadable EXIF + # ValueError or TypeError for dpi being an invalid float + # ZeroDivisionError for invalid dpi rational value + self.info["dpi"] = 72, 72 + + +def COM(self, marker): + # + # Comment marker. Store these in the APP dictionary. + n = i16(self.fp.read(2)) - 2 + s = ImageFile._safe_read(self.fp, n) + + self.info["comment"] = s + self.app["COM"] = s # compatibility + self.applist.append(("COM", s)) + + +def SOF(self, marker): + # + # Start of frame marker. Defines the size and mode of the + # image. JPEG is colour blind, so we use some simple + # heuristics to map the number of layers to an appropriate + # mode. Note that this could be made a bit brighter, by + # looking for JFIF and Adobe APP markers. + + n = i16(self.fp.read(2)) - 2 + s = ImageFile._safe_read(self.fp, n) + self._size = i16(s, 3), i16(s, 1) + + self.bits = s[0] + if self.bits != 8: + msg = f"cannot handle {self.bits}-bit layers" + raise SyntaxError(msg) + + self.layers = s[5] + if self.layers == 1: + self._mode = "L" + elif self.layers == 3: + self._mode = "RGB" + elif self.layers == 4: + self._mode = "CMYK" + else: + msg = f"cannot handle {self.layers}-layer images" + raise SyntaxError(msg) + + if marker in [0xFFC2, 0xFFC6, 0xFFCA, 0xFFCE]: + self.info["progressive"] = self.info["progression"] = 1 + + if self.icclist: + # fixup icc profile + self.icclist.sort() # sort by sequence number + if self.icclist[0][13] == len(self.icclist): + profile = [p[14:] for p in self.icclist] + icc_profile = b"".join(profile) + else: + icc_profile = None # wrong number of fragments + self.info["icc_profile"] = icc_profile + self.icclist = [] + + for i in range(6, len(s), 3): + t = s[i : i + 3] + # 4-tuples: id, vsamp, hsamp, qtable + self.layer.append((t[0], t[1] // 16, t[1] & 15, t[2])) + + +def DQT(self, marker): + # + # Define quantization table. Note that there might be more + # than one table in each marker. + + # FIXME: The quantization tables can be used to estimate the + # compression quality. + + n = i16(self.fp.read(2)) - 2 + s = ImageFile._safe_read(self.fp, n) + while len(s): + v = s[0] + precision = 1 if (v // 16 == 0) else 2 # in bytes + qt_length = 1 + precision * 64 + if len(s) < qt_length: + msg = "bad quantization table marker" + raise SyntaxError(msg) + data = array.array("B" if precision == 1 else "H", s[1:qt_length]) + if sys.byteorder == "little" and precision > 1: + data.byteswap() # the values are always big-endian + self.quantization[v & 15] = [data[i] for i in zigzag_index] + s = s[qt_length:] + + +# +# JPEG marker table + +MARKER = { + 0xFFC0: ("SOF0", "Baseline DCT", SOF), + 0xFFC1: ("SOF1", "Extended Sequential DCT", SOF), + 0xFFC2: ("SOF2", "Progressive DCT", SOF), + 0xFFC3: ("SOF3", "Spatial lossless", SOF), + 0xFFC4: ("DHT", "Define Huffman table", Skip), + 0xFFC5: ("SOF5", "Differential sequential DCT", SOF), + 0xFFC6: ("SOF6", "Differential progressive DCT", SOF), + 0xFFC7: ("SOF7", "Differential spatial", SOF), + 0xFFC8: ("JPG", "Extension", None), + 0xFFC9: ("SOF9", "Extended sequential DCT (AC)", SOF), + 0xFFCA: ("SOF10", "Progressive DCT (AC)", SOF), + 0xFFCB: ("SOF11", "Spatial lossless DCT (AC)", SOF), + 0xFFCC: ("DAC", "Define arithmetic coding conditioning", Skip), + 0xFFCD: ("SOF13", "Differential sequential DCT (AC)", SOF), + 0xFFCE: ("SOF14", "Differential progressive DCT (AC)", SOF), + 0xFFCF: ("SOF15", "Differential spatial (AC)", SOF), + 0xFFD0: ("RST0", "Restart 0", None), + 0xFFD1: ("RST1", "Restart 1", None), + 0xFFD2: ("RST2", "Restart 2", None), + 0xFFD3: ("RST3", "Restart 3", None), + 0xFFD4: ("RST4", "Restart 4", None), + 0xFFD5: ("RST5", "Restart 5", None), + 0xFFD6: ("RST6", "Restart 6", None), + 0xFFD7: ("RST7", "Restart 7", None), + 0xFFD8: ("SOI", "Start of image", None), + 0xFFD9: ("EOI", "End of image", None), + 0xFFDA: ("SOS", "Start of scan", Skip), + 0xFFDB: ("DQT", "Define quantization table", DQT), + 0xFFDC: ("DNL", "Define number of lines", Skip), + 0xFFDD: ("DRI", "Define restart interval", Skip), + 0xFFDE: ("DHP", "Define hierarchical progression", SOF), + 0xFFDF: ("EXP", "Expand reference component", Skip), + 0xFFE0: ("APP0", "Application segment 0", APP), + 0xFFE1: ("APP1", "Application segment 1", APP), + 0xFFE2: ("APP2", "Application segment 2", APP), + 0xFFE3: ("APP3", "Application segment 3", APP), + 0xFFE4: ("APP4", "Application segment 4", APP), + 0xFFE5: ("APP5", "Application segment 5", APP), + 0xFFE6: ("APP6", "Application segment 6", APP), + 0xFFE7: ("APP7", "Application segment 7", APP), + 0xFFE8: ("APP8", "Application segment 8", APP), + 0xFFE9: ("APP9", "Application segment 9", APP), + 0xFFEA: ("APP10", "Application segment 10", APP), + 0xFFEB: ("APP11", "Application segment 11", APP), + 0xFFEC: ("APP12", "Application segment 12", APP), + 0xFFED: ("APP13", "Application segment 13", APP), + 0xFFEE: ("APP14", "Application segment 14", APP), + 0xFFEF: ("APP15", "Application segment 15", APP), + 0xFFF0: ("JPG0", "Extension 0", None), + 0xFFF1: ("JPG1", "Extension 1", None), + 0xFFF2: ("JPG2", "Extension 2", None), + 0xFFF3: ("JPG3", "Extension 3", None), + 0xFFF4: ("JPG4", "Extension 4", None), + 0xFFF5: ("JPG5", "Extension 5", None), + 0xFFF6: ("JPG6", "Extension 6", None), + 0xFFF7: ("JPG7", "Extension 7", None), + 0xFFF8: ("JPG8", "Extension 8", None), + 0xFFF9: ("JPG9", "Extension 9", None), + 0xFFFA: ("JPG10", "Extension 10", None), + 0xFFFB: ("JPG11", "Extension 11", None), + 0xFFFC: ("JPG12", "Extension 12", None), + 0xFFFD: ("JPG13", "Extension 13", None), + 0xFFFE: ("COM", "Comment", COM), +} + + +def _accept(prefix): + # Magic number was taken from https://en.wikipedia.org/wiki/JPEG + return prefix[:3] == b"\xFF\xD8\xFF" + + +## +# Image plugin for JPEG and JFIF images. + + +class JpegImageFile(ImageFile.ImageFile): + format = "JPEG" + format_description = "JPEG (ISO 10918)" + + def _open(self): + s = self.fp.read(3) + + if not _accept(s): + msg = "not a JPEG file" + raise SyntaxError(msg) + s = b"\xFF" + + # Create attributes + self.bits = self.layers = 0 + + # JPEG specifics (internal) + self.layer = [] + self.huffman_dc = {} + self.huffman_ac = {} + self.quantization = {} + self.app = {} # compatibility + self.applist = [] + self.icclist = [] + + while True: + i = s[0] + if i == 0xFF: + s = s + self.fp.read(1) + i = i16(s) + else: + # Skip non-0xFF junk + s = self.fp.read(1) + continue + + if i in MARKER: + name, description, handler = MARKER[i] + if handler is not None: + handler(self, i) + if i == 0xFFDA: # start of scan + rawmode = self.mode + if self.mode == "CMYK": + rawmode = "CMYK;I" # assume adobe conventions + self.tile = [("jpeg", (0, 0) + self.size, 0, (rawmode, ""))] + # self.__offset = self.fp.tell() + break + s = self.fp.read(1) + elif i in {0, 0xFFFF}: + # padded marker or junk; move on + s = b"\xff" + elif i == 0xFF00: # Skip extraneous data (escaped 0xFF) + s = self.fp.read(1) + else: + msg = "no marker found" + raise SyntaxError(msg) + + def load_read(self, read_bytes): + """ + internal: read more image data + For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker + so libjpeg can finish decoding + """ + s = self.fp.read(read_bytes) + + if not s and ImageFile.LOAD_TRUNCATED_IMAGES and not hasattr(self, "_ended"): + # Premature EOF. + # Pretend file is finished adding EOI marker + self._ended = True + return b"\xFF\xD9" + + return s + + def draft(self, mode, size): + if len(self.tile) != 1: + return + + # Protect from second call + if self.decoderconfig: + return + + d, e, o, a = self.tile[0] + scale = 1 + original_size = self.size + + if a[0] == "RGB" and mode in ["L", "YCbCr"]: + self._mode = mode + a = mode, "" + + if size: + scale = min(self.size[0] // size[0], self.size[1] // size[1]) + for s in [8, 4, 2, 1]: + if scale >= s: + break + e = ( + e[0], + e[1], + (e[2] - e[0] + s - 1) // s + e[0], + (e[3] - e[1] + s - 1) // s + e[1], + ) + self._size = ((self.size[0] + s - 1) // s, (self.size[1] + s - 1) // s) + scale = s + + self.tile = [(d, e, o, a)] + self.decoderconfig = (scale, 0) + + box = (0, 0, original_size[0] / scale, original_size[1] / scale) + return self.mode, box + + def load_djpeg(self): + # ALTERNATIVE: handle JPEGs via the IJG command line utilities + + f, path = tempfile.mkstemp() + os.close(f) + if os.path.exists(self.filename): + subprocess.check_call(["djpeg", "-outfile", path, self.filename]) + else: + try: + os.unlink(path) + except OSError: + pass + + msg = "Invalid Filename" + raise ValueError(msg) + + try: + with Image.open(path) as _im: + _im.load() + self.im = _im.im + finally: + try: + os.unlink(path) + except OSError: + pass + + self._mode = self.im.mode + self._size = self.im.size + + self.tile = [] + + def _getexif(self): + return _getexif(self) + + def _getmp(self): + return _getmp(self) + + def getxmp(self): + """ + Returns a dictionary containing the XMP tags. + Requires defusedxml to be installed. + + :returns: XMP tags in a dictionary. + """ + + for segment, content in self.applist: + if segment == "APP1": + marker, xmp_tags = content.split(b"\x00")[:2] + if marker == b"http://ns.adobe.com/xap/1.0/": + return self._getxmp(xmp_tags) + return {} + + +def _getexif(self): + if "exif" not in self.info: + return None + return self.getexif()._get_merged_dict() + + +def _getmp(self): + # Extract MP information. This method was inspired by the "highly + # experimental" _getexif version that's been in use for years now, + # itself based on the ImageFileDirectory class in the TIFF plugin. + + # The MP record essentially consists of a TIFF file embedded in a JPEG + # application marker. + try: + data = self.info["mp"] + except KeyError: + return None + file_contents = io.BytesIO(data) + head = file_contents.read(8) + endianness = ">" if head[:4] == b"\x4d\x4d\x00\x2a" else "<" + # process dictionary + from . import TiffImagePlugin + + try: + info = TiffImagePlugin.ImageFileDirectory_v2(head) + file_contents.seek(info.next) + info.load(file_contents) + mp = dict(info) + except Exception as e: + msg = "malformed MP Index (unreadable directory)" + raise SyntaxError(msg) from e + # it's an error not to have a number of images + try: + quant = mp[0xB001] + except KeyError as e: + msg = "malformed MP Index (no number of images)" + raise SyntaxError(msg) from e + # get MP entries + mpentries = [] + try: + rawmpentries = mp[0xB002] + for entrynum in range(0, quant): + unpackedentry = struct.unpack_from( + f"{endianness}LLLHH", rawmpentries, entrynum * 16 + ) + labels = ("Attribute", "Size", "DataOffset", "EntryNo1", "EntryNo2") + mpentry = dict(zip(labels, unpackedentry)) + mpentryattr = { + "DependentParentImageFlag": bool(mpentry["Attribute"] & (1 << 31)), + "DependentChildImageFlag": bool(mpentry["Attribute"] & (1 << 30)), + "RepresentativeImageFlag": bool(mpentry["Attribute"] & (1 << 29)), + "Reserved": (mpentry["Attribute"] & (3 << 27)) >> 27, + "ImageDataFormat": (mpentry["Attribute"] & (7 << 24)) >> 24, + "MPType": mpentry["Attribute"] & 0x00FFFFFF, + } + if mpentryattr["ImageDataFormat"] == 0: + mpentryattr["ImageDataFormat"] = "JPEG" + else: + msg = "unsupported picture format in MPO" + raise SyntaxError(msg) + mptypemap = { + 0x000000: "Undefined", + 0x010001: "Large Thumbnail (VGA Equivalent)", + 0x010002: "Large Thumbnail (Full HD Equivalent)", + 0x020001: "Multi-Frame Image (Panorama)", + 0x020002: "Multi-Frame Image: (Disparity)", + 0x020003: "Multi-Frame Image: (Multi-Angle)", + 0x030000: "Baseline MP Primary Image", + } + mpentryattr["MPType"] = mptypemap.get(mpentryattr["MPType"], "Unknown") + mpentry["Attribute"] = mpentryattr + mpentries.append(mpentry) + mp[0xB002] = mpentries + except KeyError as e: + msg = "malformed MP Index (bad MP Entry)" + raise SyntaxError(msg) from e + # Next we should try and parse the individual image unique ID list; + # we don't because I've never seen this actually used in a real MPO + # file and so can't test it. + return mp + + +# -------------------------------------------------------------------- +# stuff to save JPEG files + +RAWMODE = { + "1": "L", + "L": "L", + "RGB": "RGB", + "RGBX": "RGB", + "CMYK": "CMYK;I", # assume adobe conventions + "YCbCr": "YCbCr", +} + +# fmt: off +zigzag_index = ( + 0, 1, 5, 6, 14, 15, 27, 28, + 2, 4, 7, 13, 16, 26, 29, 42, + 3, 8, 12, 17, 25, 30, 41, 43, + 9, 11, 18, 24, 31, 40, 44, 53, + 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, + 21, 34, 37, 47, 50, 56, 59, 61, + 35, 36, 48, 49, 57, 58, 62, 63, +) + +samplings = { + (1, 1, 1, 1, 1, 1): 0, + (2, 1, 1, 1, 1, 1): 1, + (2, 2, 1, 1, 1, 1): 2, +} +# fmt: on + + +def get_sampling(im): + # There's no subsampling when images have only 1 layer + # (grayscale images) or when they are CMYK (4 layers), + # so set subsampling to the default value. + # + # NOTE: currently Pillow can't encode JPEG to YCCK format. + # If YCCK support is added in the future, subsampling code will have + # to be updated (here and in JpegEncode.c) to deal with 4 layers. + if not hasattr(im, "layers") or im.layers in (1, 4): + return -1 + sampling = im.layer[0][1:3] + im.layer[1][1:3] + im.layer[2][1:3] + return samplings.get(sampling, -1) + + +def _save(im, fp, filename): + if im.width == 0 or im.height == 0: + msg = "cannot write empty image as JPEG" + raise ValueError(msg) + + try: + rawmode = RAWMODE[im.mode] + except KeyError as e: + msg = f"cannot write mode {im.mode} as JPEG" + raise OSError(msg) from e + + info = im.encoderinfo + + dpi = [round(x) for x in info.get("dpi", (0, 0))] + + quality = info.get("quality", -1) + subsampling = info.get("subsampling", -1) + qtables = info.get("qtables") + + if quality == "keep": + quality = -1 + subsampling = "keep" + qtables = "keep" + elif quality in presets: + preset = presets[quality] + quality = -1 + subsampling = preset.get("subsampling", -1) + qtables = preset.get("quantization") + elif not isinstance(quality, int): + msg = "Invalid quality setting" + raise ValueError(msg) + else: + if subsampling in presets: + subsampling = presets[subsampling].get("subsampling", -1) + if isinstance(qtables, str) and qtables in presets: + qtables = presets[qtables].get("quantization") + + if subsampling == "4:4:4": + subsampling = 0 + elif subsampling == "4:2:2": + subsampling = 1 + elif subsampling == "4:2:0": + subsampling = 2 + elif subsampling == "4:1:1": + # For compatibility. Before Pillow 4.3, 4:1:1 actually meant 4:2:0. + # Set 4:2:0 if someone is still using that value. + subsampling = 2 + elif subsampling == "keep": + if im.format != "JPEG": + msg = "Cannot use 'keep' when original image is not a JPEG" + raise ValueError(msg) + subsampling = get_sampling(im) + + def validate_qtables(qtables): + if qtables is None: + return qtables + if isinstance(qtables, str): + try: + lines = [ + int(num) + for line in qtables.splitlines() + for num in line.split("#", 1)[0].split() + ] + except ValueError as e: + msg = "Invalid quantization table" + raise ValueError(msg) from e + else: + qtables = [lines[s : s + 64] for s in range(0, len(lines), 64)] + if isinstance(qtables, (tuple, list, dict)): + if isinstance(qtables, dict): + qtables = [ + qtables[key] for key in range(len(qtables)) if key in qtables + ] + elif isinstance(qtables, tuple): + qtables = list(qtables) + if not (0 < len(qtables) < 5): + msg = "None or too many quantization tables" + raise ValueError(msg) + for idx, table in enumerate(qtables): + try: + if len(table) != 64: + msg = "Invalid quantization table" + raise TypeError(msg) + table = array.array("H", table) + except TypeError as e: + msg = "Invalid quantization table" + raise ValueError(msg) from e + else: + qtables[idx] = list(table) + return qtables + + if qtables == "keep": + if im.format != "JPEG": + msg = "Cannot use 'keep' when original image is not a JPEG" + raise ValueError(msg) + qtables = getattr(im, "quantization", None) + qtables = validate_qtables(qtables) + + extra = info.get("extra", b"") + + MAX_BYTES_IN_MARKER = 65533 + icc_profile = info.get("icc_profile") + if icc_profile: + ICC_OVERHEAD_LEN = 14 + MAX_DATA_BYTES_IN_MARKER = MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN + markers = [] + while icc_profile: + markers.append(icc_profile[:MAX_DATA_BYTES_IN_MARKER]) + icc_profile = icc_profile[MAX_DATA_BYTES_IN_MARKER:] + i = 1 + for marker in markers: + size = o16(2 + ICC_OVERHEAD_LEN + len(marker)) + extra += ( + b"\xFF\xE2" + + size + + b"ICC_PROFILE\0" + + o8(i) + + o8(len(markers)) + + marker + ) + i += 1 + + comment = info.get("comment", im.info.get("comment")) + + # "progressive" is the official name, but older documentation + # says "progression" + # FIXME: issue a warning if the wrong form is used (post-1.1.7) + progressive = info.get("progressive", False) or info.get("progression", False) + + optimize = info.get("optimize", False) + + exif = info.get("exif", b"") + if isinstance(exif, Image.Exif): + exif = exif.tobytes() + if len(exif) > MAX_BYTES_IN_MARKER: + msg = "EXIF data is too long" + raise ValueError(msg) + + # get keyword arguments + im.encoderconfig = ( + quality, + progressive, + info.get("smooth", 0), + optimize, + info.get("keep_rgb", False), + info.get("streamtype", 0), + dpi[0], + dpi[1], + subsampling, + info.get("restart_marker_blocks", 0), + info.get("restart_marker_rows", 0), + qtables, + comment, + extra, + exif, + ) + + # if we optimize, libjpeg needs a buffer big enough to hold the whole image + # in a shot. Guessing on the size, at im.size bytes. (raw pixel size is + # channels*size, this is a value that's been used in a django patch. + # https://github.com/matthewwithanm/django-imagekit/issues/50 + bufsize = 0 + if optimize or progressive: + # CMYK can be bigger + if im.mode == "CMYK": + bufsize = 4 * im.size[0] * im.size[1] + # keep sets quality to -1, but the actual value may be high. + elif quality >= 95 or quality == -1: + bufsize = 2 * im.size[0] * im.size[1] + else: + bufsize = im.size[0] * im.size[1] + if exif: + bufsize += len(exif) + 5 + if extra: + bufsize += len(extra) + 1 + else: + # The EXIF info needs to be written as one block, + APP1, + one spare byte. + # Ensure that our buffer is big enough. Same with the icc_profile block. + bufsize = max(bufsize, len(exif) + 5, len(extra) + 1) + + ImageFile._save(im, fp, [("jpeg", (0, 0) + im.size, 0, rawmode)], bufsize) + + +def _save_cjpeg(im, fp, filename): + # ALTERNATIVE: handle JPEGs via the IJG command line utilities. + tempfile = im._dump() + subprocess.check_call(["cjpeg", "-outfile", filename, tempfile]) + try: + os.unlink(tempfile) + except OSError: + pass + + +## +# Factory for making JPEG and MPO instances +def jpeg_factory(fp=None, filename=None): + im = JpegImageFile(fp, filename) + try: + mpheader = im._getmp() + if mpheader[45057] > 1: + # It's actually an MPO + from .MpoImagePlugin import MpoImageFile + + # Don't reload everything, just convert it. + im = MpoImageFile.adopt(im, mpheader) + except (TypeError, IndexError): + # It is really a JPEG + pass + except SyntaxError: + warnings.warn( + "Image appears to be a malformed MPO file, it will be " + "interpreted as a base JPEG file" + ) + return im + + +# --------------------------------------------------------------------- +# Registry stuff + +Image.register_open(JpegImageFile.format, jpeg_factory, _accept) +Image.register_save(JpegImageFile.format, _save) + +Image.register_extensions(JpegImageFile.format, [".jfif", ".jpe", ".jpg", ".jpeg"]) + +Image.register_mime(JpegImageFile.format, "image/jpeg") diff --git a/venv/lib/python3.10/site-packages/PIL/JpegPresets.py b/venv/lib/python3.10/site-packages/PIL/JpegPresets.py new file mode 100644 index 00000000..3aefa073 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/JpegPresets.py @@ -0,0 +1,242 @@ +""" +JPEG quality settings equivalent to the Photoshop settings. +Can be used when saving JPEG files. + +The following presets are available by default: +``web_low``, ``web_medium``, ``web_high``, ``web_very_high``, ``web_maximum``, +``low``, ``medium``, ``high``, ``maximum``. +More presets can be added to the :py:data:`presets` dict if needed. + +To apply the preset, specify:: + + quality="preset_name" + +To apply only the quantization table:: + + qtables="preset_name" + +To apply only the subsampling setting:: + + subsampling="preset_name" + +Example:: + + im.save("image_name.jpg", quality="web_high") + +Subsampling +----------- + +Subsampling is the practice of encoding images by implementing less resolution +for chroma information than for luma information. +(ref.: https://en.wikipedia.org/wiki/Chroma_subsampling) + +Possible subsampling values are 0, 1 and 2 that correspond to 4:4:4, 4:2:2 and +4:2:0. + +You can get the subsampling of a JPEG with the +:func:`.JpegImagePlugin.get_sampling` function. + +In JPEG compressed data a JPEG marker is used instead of an EXIF tag. +(ref.: https://web.archive.org/web/20240227115053/https://exiv2.org/tags.html) + + +Quantization tables +------------------- + +They are values use by the DCT (Discrete cosine transform) to remove +*unnecessary* information from the image (the lossy part of the compression). +(ref.: https://en.wikipedia.org/wiki/Quantization_matrix#Quantization_matrices, +https://en.wikipedia.org/wiki/JPEG#Quantization) + +You can get the quantization tables of a JPEG with:: + + im.quantization + +This will return a dict with a number of lists. You can pass this dict +directly as the qtables argument when saving a JPEG. + +The quantization table format in presets is a list with sublists. These formats +are interchangeable. + +Libjpeg ref.: +https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html + +""" + +from __future__ import annotations + +# fmt: off +presets = { + 'web_low': {'subsampling': 2, # "4:2:0" + 'quantization': [ + [20, 16, 25, 39, 50, 46, 62, 68, + 16, 18, 23, 38, 38, 53, 65, 68, + 25, 23, 31, 38, 53, 65, 68, 68, + 39, 38, 38, 53, 65, 68, 68, 68, + 50, 38, 53, 65, 68, 68, 68, 68, + 46, 53, 65, 68, 68, 68, 68, 68, + 62, 65, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68], + [21, 25, 32, 38, 54, 68, 68, 68, + 25, 28, 24, 38, 54, 68, 68, 68, + 32, 24, 32, 43, 66, 68, 68, 68, + 38, 38, 43, 53, 68, 68, 68, 68, + 54, 54, 66, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68] + ]}, + 'web_medium': {'subsampling': 2, # "4:2:0" + 'quantization': [ + [16, 11, 11, 16, 23, 27, 31, 30, + 11, 12, 12, 15, 20, 23, 23, 30, + 11, 12, 13, 16, 23, 26, 35, 47, + 16, 15, 16, 23, 26, 37, 47, 64, + 23, 20, 23, 26, 39, 51, 64, 64, + 27, 23, 26, 37, 51, 64, 64, 64, + 31, 23, 35, 47, 64, 64, 64, 64, + 30, 30, 47, 64, 64, 64, 64, 64], + [17, 15, 17, 21, 20, 26, 38, 48, + 15, 19, 18, 17, 20, 26, 35, 43, + 17, 18, 20, 22, 26, 30, 46, 53, + 21, 17, 22, 28, 30, 39, 53, 64, + 20, 20, 26, 30, 39, 48, 64, 64, + 26, 26, 30, 39, 48, 63, 64, 64, + 38, 35, 46, 53, 64, 64, 64, 64, + 48, 43, 53, 64, 64, 64, 64, 64] + ]}, + 'web_high': {'subsampling': 0, # "4:4:4" + 'quantization': [ + [6, 4, 4, 6, 9, 11, 12, 16, + 4, 5, 5, 6, 8, 10, 12, 12, + 4, 5, 5, 6, 10, 12, 14, 19, + 6, 6, 6, 11, 12, 15, 19, 28, + 9, 8, 10, 12, 16, 20, 27, 31, + 11, 10, 12, 15, 20, 27, 31, 31, + 12, 12, 14, 19, 27, 31, 31, 31, + 16, 12, 19, 28, 31, 31, 31, 31], + [7, 7, 13, 24, 26, 31, 31, 31, + 7, 12, 16, 21, 31, 31, 31, 31, + 13, 16, 17, 31, 31, 31, 31, 31, + 24, 21, 31, 31, 31, 31, 31, 31, + 26, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31] + ]}, + 'web_very_high': {'subsampling': 0, # "4:4:4" + 'quantization': [ + [2, 2, 2, 2, 3, 4, 5, 6, + 2, 2, 2, 2, 3, 4, 5, 6, + 2, 2, 2, 2, 4, 5, 7, 9, + 2, 2, 2, 4, 5, 7, 9, 12, + 3, 3, 4, 5, 8, 10, 12, 12, + 4, 4, 5, 7, 10, 12, 12, 12, + 5, 5, 7, 9, 12, 12, 12, 12, + 6, 6, 9, 12, 12, 12, 12, 12], + [3, 3, 5, 9, 13, 15, 15, 15, + 3, 4, 6, 11, 14, 12, 12, 12, + 5, 6, 9, 14, 12, 12, 12, 12, + 9, 11, 14, 12, 12, 12, 12, 12, + 13, 14, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12] + ]}, + 'web_maximum': {'subsampling': 0, # "4:4:4" + 'quantization': [ + [1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 2, 2, + 1, 1, 1, 1, 1, 2, 2, 3, + 1, 1, 1, 1, 2, 2, 3, 3, + 1, 1, 1, 2, 2, 3, 3, 3, + 1, 1, 2, 2, 3, 3, 3, 3], + [1, 1, 1, 2, 2, 3, 3, 3, + 1, 1, 1, 2, 3, 3, 3, 3, + 1, 1, 1, 3, 3, 3, 3, 3, + 2, 2, 3, 3, 3, 3, 3, 3, + 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3] + ]}, + 'low': {'subsampling': 2, # "4:2:0" + 'quantization': [ + [18, 14, 14, 21, 30, 35, 34, 17, + 14, 16, 16, 19, 26, 23, 12, 12, + 14, 16, 17, 21, 23, 12, 12, 12, + 21, 19, 21, 23, 12, 12, 12, 12, + 30, 26, 23, 12, 12, 12, 12, 12, + 35, 23, 12, 12, 12, 12, 12, 12, + 34, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12], + [20, 19, 22, 27, 20, 20, 17, 17, + 19, 25, 23, 14, 14, 12, 12, 12, + 22, 23, 14, 14, 12, 12, 12, 12, + 27, 14, 14, 12, 12, 12, 12, 12, + 20, 14, 12, 12, 12, 12, 12, 12, + 20, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12] + ]}, + 'medium': {'subsampling': 2, # "4:2:0" + 'quantization': [ + [12, 8, 8, 12, 17, 21, 24, 17, + 8, 9, 9, 11, 15, 19, 12, 12, + 8, 9, 10, 12, 19, 12, 12, 12, + 12, 11, 12, 21, 12, 12, 12, 12, + 17, 15, 19, 12, 12, 12, 12, 12, + 21, 19, 12, 12, 12, 12, 12, 12, + 24, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12], + [13, 11, 13, 16, 20, 20, 17, 17, + 11, 14, 14, 14, 14, 12, 12, 12, + 13, 14, 14, 14, 12, 12, 12, 12, + 16, 14, 14, 12, 12, 12, 12, 12, + 20, 14, 12, 12, 12, 12, 12, 12, + 20, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12] + ]}, + 'high': {'subsampling': 0, # "4:4:4" + 'quantization': [ + [6, 4, 4, 6, 9, 11, 12, 16, + 4, 5, 5, 6, 8, 10, 12, 12, + 4, 5, 5, 6, 10, 12, 12, 12, + 6, 6, 6, 11, 12, 12, 12, 12, + 9, 8, 10, 12, 12, 12, 12, 12, + 11, 10, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 16, 12, 12, 12, 12, 12, 12, 12], + [7, 7, 13, 24, 20, 20, 17, 17, + 7, 12, 16, 14, 14, 12, 12, 12, + 13, 16, 14, 14, 12, 12, 12, 12, + 24, 14, 14, 12, 12, 12, 12, 12, + 20, 14, 12, 12, 12, 12, 12, 12, + 20, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12, + 17, 12, 12, 12, 12, 12, 12, 12] + ]}, + 'maximum': {'subsampling': 0, # "4:4:4" + 'quantization': [ + [2, 2, 2, 2, 3, 4, 5, 6, + 2, 2, 2, 2, 3, 4, 5, 6, + 2, 2, 2, 2, 4, 5, 7, 9, + 2, 2, 2, 4, 5, 7, 9, 12, + 3, 3, 4, 5, 8, 10, 12, 12, + 4, 4, 5, 7, 10, 12, 12, 12, + 5, 5, 7, 9, 12, 12, 12, 12, + 6, 6, 9, 12, 12, 12, 12, 12], + [3, 3, 5, 9, 13, 15, 15, 15, + 3, 4, 6, 10, 14, 12, 12, 12, + 5, 6, 9, 14, 12, 12, 12, 12, + 9, 10, 14, 12, 12, 12, 12, 12, + 13, 14, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12, + 15, 12, 12, 12, 12, 12, 12, 12] + ]}, +} +# fmt: on diff --git a/venv/lib/python3.10/site-packages/PIL/McIdasImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/McIdasImagePlugin.py new file mode 100644 index 00000000..27972236 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/McIdasImagePlugin.py @@ -0,0 +1,78 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Basic McIdas support for PIL +# +# History: +# 1997-05-05 fl Created (8-bit images only) +# 2009-03-08 fl Added 16/32-bit support. +# +# Thanks to Richard Jones and Craig Swank for specs and samples. +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import struct + +from . import Image, ImageFile + + +def _accept(prefix: bytes) -> bool: + return prefix[:8] == b"\x00\x00\x00\x00\x00\x00\x00\x04" + + +## +# Image plugin for McIdas area images. + + +class McIdasImageFile(ImageFile.ImageFile): + format = "MCIDAS" + format_description = "McIdas area file" + + def _open(self) -> None: + # parse area file directory + assert self.fp is not None + + s = self.fp.read(256) + if not _accept(s) or len(s) != 256: + msg = "not an McIdas area file" + raise SyntaxError(msg) + + self.area_descriptor_raw = s + self.area_descriptor = w = [0] + list(struct.unpack("!64i", s)) + + # get mode + if w[11] == 1: + mode = rawmode = "L" + elif w[11] == 2: + # FIXME: add memory map support + mode = "I" + rawmode = "I;16B" + elif w[11] == 4: + # FIXME: add memory map support + mode = "I" + rawmode = "I;32B" + else: + msg = "unsupported McIdas format" + raise SyntaxError(msg) + + self._mode = mode + self._size = w[10], w[9] + + offset = w[34] + w[15] + stride = w[15] + w[10] * w[11] * w[14] + + self.tile = [("raw", (0, 0) + self.size, offset, (rawmode, stride, 1))] + + +# -------------------------------------------------------------------- +# registry + +Image.register_open(McIdasImageFile.format, McIdasImageFile, _accept) + +# no default extension diff --git a/venv/lib/python3.10/site-packages/PIL/MicImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/MicImagePlugin.py new file mode 100644 index 00000000..f4529d9a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/MicImagePlugin.py @@ -0,0 +1,107 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Microsoft Image Composer support for PIL +# +# Notes: +# uses TiffImagePlugin.py to read the actual image streams +# +# History: +# 97-01-20 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import olefile + +from . import Image, TiffImagePlugin + +# +# -------------------------------------------------------------------- + + +def _accept(prefix): + return prefix[:8] == olefile.MAGIC + + +## +# Image plugin for Microsoft's Image Composer file format. + + +class MicImageFile(TiffImagePlugin.TiffImageFile): + format = "MIC" + format_description = "Microsoft Image Composer" + _close_exclusive_fp_after_loading = False + + def _open(self): + # read the OLE directory and see if this is a likely + # to be a Microsoft Image Composer file + + try: + self.ole = olefile.OleFileIO(self.fp) + except OSError as e: + msg = "not an MIC file; invalid OLE file" + raise SyntaxError(msg) from e + + # find ACI subfiles with Image members (maybe not the + # best way to identify MIC files, but what the... ;-) + + self.images = [ + path + for path in self.ole.listdir() + if path[1:] and path[0][-4:] == ".ACI" and path[1] == "Image" + ] + + # if we didn't find any images, this is probably not + # an MIC file. + if not self.images: + msg = "not an MIC file; no image entries" + raise SyntaxError(msg) + + self.frame = None + self._n_frames = len(self.images) + self.is_animated = self._n_frames > 1 + + self.__fp = self.fp + self.seek(0) + + def seek(self, frame): + if not self._seek_check(frame): + return + try: + filename = self.images[frame] + except IndexError as e: + msg = "no such frame" + raise EOFError(msg) from e + + self.fp = self.ole.openstream(filename) + + TiffImagePlugin.TiffImageFile._open(self) + + self.frame = frame + + def tell(self): + return self.frame + + def close(self): + self.__fp.close() + self.ole.close() + super().close() + + def __exit__(self, *args): + self.__fp.close() + self.ole.close() + super().__exit__() + + +# +# -------------------------------------------------------------------- + +Image.register_open(MicImageFile.format, MicImageFile, _accept) + +Image.register_extension(MicImageFile.format, ".mic") diff --git a/venv/lib/python3.10/site-packages/PIL/MpegImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/MpegImagePlugin.py new file mode 100644 index 00000000..1565612f --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/MpegImagePlugin.py @@ -0,0 +1,84 @@ +# +# The Python Imaging Library. +# $Id$ +# +# MPEG file handling +# +# History: +# 95-09-09 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1995. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile +from ._binary import i8 +from ._typing import SupportsRead + +# +# Bitstream parser + + +class BitStream: + def __init__(self, fp: SupportsRead[bytes]) -> None: + self.fp = fp + self.bits = 0 + self.bitbuffer = 0 + + def next(self) -> int: + return i8(self.fp.read(1)) + + def peek(self, bits: int) -> int: + while self.bits < bits: + c = self.next() + if c < 0: + self.bits = 0 + continue + self.bitbuffer = (self.bitbuffer << 8) + c + self.bits += 8 + return self.bitbuffer >> (self.bits - bits) & (1 << bits) - 1 + + def skip(self, bits: int) -> None: + while self.bits < bits: + self.bitbuffer = (self.bitbuffer << 8) + i8(self.fp.read(1)) + self.bits += 8 + self.bits = self.bits - bits + + def read(self, bits: int) -> int: + v = self.peek(bits) + self.bits = self.bits - bits + return v + + +## +# Image plugin for MPEG streams. This plugin can identify a stream, +# but it cannot read it. + + +class MpegImageFile(ImageFile.ImageFile): + format = "MPEG" + format_description = "MPEG" + + def _open(self) -> None: + assert self.fp is not None + + s = BitStream(self.fp) + if s.read(32) != 0x1B3: + msg = "not an MPEG file" + raise SyntaxError(msg) + + self._mode = "RGB" + self._size = s.read(12), s.read(12) + + +# -------------------------------------------------------------------- +# Registry stuff + +Image.register_open(MpegImageFile.format, MpegImageFile) + +Image.register_extensions(MpegImageFile.format, [".mpg", ".mpeg"]) + +Image.register_mime(MpegImageFile.format, "video/mpeg") diff --git a/venv/lib/python3.10/site-packages/PIL/MpoImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/MpoImagePlugin.py new file mode 100644 index 00000000..ac9820bb --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/MpoImagePlugin.py @@ -0,0 +1,184 @@ +# +# The Python Imaging Library. +# $Id$ +# +# MPO file handling +# +# See "Multi-Picture Format" (CIPA DC-007-Translation 2009, Standard of the +# Camera & Imaging Products Association) +# +# The multi-picture object combines multiple JPEG images (with a modified EXIF +# data format) into a single file. While it can theoretically be used much like +# a GIF animation, it is commonly used to represent 3D photographs and is (as +# of this writing) the most commonly used format by 3D cameras. +# +# History: +# 2014-03-13 Feneric Created +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import itertools +import os +import struct + +from . import ( + Image, + ImageSequence, + JpegImagePlugin, + TiffImagePlugin, +) +from ._binary import o32le + + +def _save(im, fp, filename): + JpegImagePlugin._save(im, fp, filename) + + +def _save_all(im, fp, filename): + append_images = im.encoderinfo.get("append_images", []) + if not append_images: + try: + animated = im.is_animated + except AttributeError: + animated = False + if not animated: + _save(im, fp, filename) + return + + mpf_offset = 28 + offsets = [] + for imSequence in itertools.chain([im], append_images): + for im_frame in ImageSequence.Iterator(imSequence): + if not offsets: + # APP2 marker + im_frame.encoderinfo["extra"] = ( + b"\xFF\xE2" + struct.pack(">H", 6 + 82) + b"MPF\0" + b" " * 82 + ) + exif = im_frame.encoderinfo.get("exif") + if isinstance(exif, Image.Exif): + exif = exif.tobytes() + im_frame.encoderinfo["exif"] = exif + if exif: + mpf_offset += 4 + len(exif) + + JpegImagePlugin._save(im_frame, fp, filename) + offsets.append(fp.tell()) + else: + im_frame.save(fp, "JPEG") + offsets.append(fp.tell() - offsets[-1]) + + ifd = TiffImagePlugin.ImageFileDirectory_v2() + ifd[0xB000] = b"0100" + ifd[0xB001] = len(offsets) + + mpentries = b"" + data_offset = 0 + for i, size in enumerate(offsets): + if i == 0: + mptype = 0x030000 # Baseline MP Primary Image + else: + mptype = 0x000000 # Undefined + mpentries += struct.pack(" 1 + self._fp = self.fp # FIXME: hack + self._fp.seek(self.__mpoffsets[0]) # get ready to read first frame + self.__frame = 0 + self.offset = 0 + # for now we can only handle reading and individual frame extraction + self.readonly = 1 + + def load_seek(self, pos): + self._fp.seek(pos) + + def seek(self, frame): + if not self._seek_check(frame): + return + self.fp = self._fp + self.offset = self.__mpoffsets[frame] + + original_exif = self.info.get("exif") + if "exif" in self.info: + del self.info["exif"] + + self.fp.seek(self.offset + 2) # skip SOI marker + if not self.fp.read(2): + msg = "No data found for frame" + raise ValueError(msg) + self.fp.seek(self.offset) + JpegImagePlugin.JpegImageFile._open(self) + if self.info.get("exif") != original_exif: + self._reload_exif() + + self.tile = [("jpeg", (0, 0) + self.size, self.offset, self.tile[0][-1])] + self.__frame = frame + + def tell(self): + return self.__frame + + @staticmethod + def adopt(jpeg_instance, mpheader=None): + """ + Transform the instance of JpegImageFile into + an instance of MpoImageFile. + After the call, the JpegImageFile is extended + to be an MpoImageFile. + + This is essentially useful when opening a JPEG + file that reveals itself as an MPO, to avoid + double call to _open. + """ + jpeg_instance.__class__ = MpoImageFile + jpeg_instance._after_jpeg_open(mpheader) + return jpeg_instance + + +# --------------------------------------------------------------------- +# Registry stuff + +# Note that since MPO shares a factory with JPEG, we do not need to do a +# separate registration for it here. +# Image.register_open(MpoImageFile.format, +# JpegImagePlugin.jpeg_factory, _accept) +Image.register_save(MpoImageFile.format, _save) +Image.register_save_all(MpoImageFile.format, _save_all) + +Image.register_extension(MpoImageFile.format, ".mpo") + +Image.register_mime(MpoImageFile.format, "image/mpo") diff --git a/venv/lib/python3.10/site-packages/PIL/MspImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/MspImagePlugin.py new file mode 100644 index 00000000..65cc7062 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/MspImagePlugin.py @@ -0,0 +1,200 @@ +# +# The Python Imaging Library. +# +# MSP file handling +# +# This is the format used by the Paint program in Windows 1 and 2. +# +# History: +# 95-09-05 fl Created +# 97-01-03 fl Read/write MSP images +# 17-02-21 es Fixed RLE interpretation +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1995-97. +# Copyright (c) Eric Soroos 2017. +# +# See the README file for information on usage and redistribution. +# +# More info on this format: https://archive.org/details/gg243631 +# Page 313: +# Figure 205. Windows Paint Version 1: "DanM" Format +# Figure 206. Windows Paint Version 2: "LinS" Format. Used in Windows V2.03 +# +# See also: https://www.fileformat.info/format/mspaint/egff.htm +from __future__ import annotations + +import io +import struct +from typing import IO + +from . import Image, ImageFile +from ._binary import i16le as i16 +from ._binary import o16le as o16 + +# +# read MSP files + + +def _accept(prefix: bytes) -> bool: + return prefix[:4] in [b"DanM", b"LinS"] + + +## +# Image plugin for Windows MSP images. This plugin supports both +# uncompressed (Windows 1.0). + + +class MspImageFile(ImageFile.ImageFile): + format = "MSP" + format_description = "Windows Paint" + + def _open(self) -> None: + # Header + assert self.fp is not None + + s = self.fp.read(32) + if not _accept(s): + msg = "not an MSP file" + raise SyntaxError(msg) + + # Header checksum + checksum = 0 + for i in range(0, 32, 2): + checksum = checksum ^ i16(s, i) + if checksum != 0: + msg = "bad MSP checksum" + raise SyntaxError(msg) + + self._mode = "1" + self._size = i16(s, 4), i16(s, 6) + + if s[:4] == b"DanM": + self.tile = [("raw", (0, 0) + self.size, 32, ("1", 0, 1))] + else: + self.tile = [("MSP", (0, 0) + self.size, 32, None)] + + +class MspDecoder(ImageFile.PyDecoder): + # The algo for the MSP decoder is from + # https://www.fileformat.info/format/mspaint/egff.htm + # cc-by-attribution -- That page references is taken from the + # Encyclopedia of Graphics File Formats and is licensed by + # O'Reilly under the Creative Common/Attribution license + # + # For RLE encoded files, the 32byte header is followed by a scan + # line map, encoded as one 16bit word of encoded byte length per + # line. + # + # NOTE: the encoded length of the line can be 0. This was not + # handled in the previous version of this encoder, and there's no + # mention of how to handle it in the documentation. From the few + # examples I've seen, I've assumed that it is a fill of the + # background color, in this case, white. + # + # + # Pseudocode of the decoder: + # Read a BYTE value as the RunType + # If the RunType value is zero + # Read next byte as the RunCount + # Read the next byte as the RunValue + # Write the RunValue byte RunCount times + # If the RunType value is non-zero + # Use this value as the RunCount + # Read and write the next RunCount bytes literally + # + # e.g.: + # 0x00 03 ff 05 00 01 02 03 04 + # would yield the bytes: + # 0xff ff ff 00 01 02 03 04 + # + # which are then interpreted as a bit packed mode '1' image + + _pulls_fd = True + + def decode(self, buffer: bytes) -> tuple[int, int]: + assert self.fd is not None + + img = io.BytesIO() + blank_line = bytearray((0xFF,) * ((self.state.xsize + 7) // 8)) + try: + self.fd.seek(32) + rowmap = struct.unpack_from( + f"<{self.state.ysize}H", self.fd.read(self.state.ysize * 2) + ) + except struct.error as e: + msg = "Truncated MSP file in row map" + raise OSError(msg) from e + + for x, rowlen in enumerate(rowmap): + try: + if rowlen == 0: + img.write(blank_line) + continue + row = self.fd.read(rowlen) + if len(row) != rowlen: + msg = f"Truncated MSP file, expected {rowlen} bytes on row {x}" + raise OSError(msg) + idx = 0 + while idx < rowlen: + runtype = row[idx] + idx += 1 + if runtype == 0: + (runcount, runval) = struct.unpack_from("Bc", row, idx) + img.write(runval * runcount) + idx += 2 + else: + runcount = runtype + img.write(row[idx : idx + runcount]) + idx += runcount + + except struct.error as e: + msg = f"Corrupted MSP file in row {x}" + raise OSError(msg) from e + + self.set_as_raw(img.getvalue(), ("1", 0, 1)) + + return -1, 0 + + +Image.register_decoder("MSP", MspDecoder) + + +# +# write MSP files (uncompressed only) + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + if im.mode != "1": + msg = f"cannot write mode {im.mode} as MSP" + raise OSError(msg) + + # create MSP header + header = [0] * 16 + + header[0], header[1] = i16(b"Da"), i16(b"nM") # version 1 + header[2], header[3] = im.size + header[4], header[5] = 1, 1 + header[6], header[7] = 1, 1 + header[8], header[9] = im.size + + checksum = 0 + for h in header: + checksum = checksum ^ h + header[12] = checksum # FIXME: is this the right field? + + # header + for h in header: + fp.write(o16(h)) + + # image body + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 32, ("1", 0, 1))]) + + +# +# registry + +Image.register_open(MspImageFile.format, MspImageFile, _accept) +Image.register_save(MspImageFile.format, _save) + +Image.register_extension(MspImageFile.format, ".msp") diff --git a/venv/lib/python3.10/site-packages/PIL/PSDraw.py b/venv/lib/python3.10/site-packages/PIL/PSDraw.py new file mode 100644 index 00000000..848fc2f7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PSDraw.py @@ -0,0 +1,230 @@ +# +# The Python Imaging Library +# $Id$ +# +# Simple PostScript graphics interface +# +# History: +# 1996-04-20 fl Created +# 1999-01-10 fl Added gsave/grestore to image method +# 2005-05-04 fl Fixed floating point issue in image (from Eric Etheridge) +# +# Copyright (c) 1997-2005 by Secret Labs AB. All rights reserved. +# Copyright (c) 1996 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import sys + +from . import EpsImagePlugin + +## +# Simple PostScript graphics interface. + + +class PSDraw: + """ + Sets up printing to the given file. If ``fp`` is omitted, + ``sys.stdout.buffer`` or ``sys.stdout`` is assumed. + """ + + def __init__(self, fp=None): + if not fp: + try: + fp = sys.stdout.buffer + except AttributeError: + fp = sys.stdout + self.fp = fp + + def begin_document(self, id=None): + """Set up printing of a document. (Write PostScript DSC header.)""" + # FIXME: incomplete + self.fp.write( + b"%!PS-Adobe-3.0\n" + b"save\n" + b"/showpage { } def\n" + b"%%EndComments\n" + b"%%BeginDocument\n" + ) + # self.fp.write(ERROR_PS) # debugging! + self.fp.write(EDROFF_PS) + self.fp.write(VDI_PS) + self.fp.write(b"%%EndProlog\n") + self.isofont = {} + + def end_document(self): + """Ends printing. (Write PostScript DSC footer.)""" + self.fp.write(b"%%EndDocument\nrestore showpage\n%%End\n") + if hasattr(self.fp, "flush"): + self.fp.flush() + + def setfont(self, font, size): + """ + Selects which font to use. + + :param font: A PostScript font name + :param size: Size in points. + """ + font = bytes(font, "UTF-8") + if font not in self.isofont: + # reencode font + self.fp.write(b"/PSDraw-%s ISOLatin1Encoding /%s E\n" % (font, font)) + self.isofont[font] = 1 + # rough + self.fp.write(b"/F0 %d /PSDraw-%s F\n" % (size, font)) + + def line(self, xy0, xy1): + """ + Draws a line between the two points. Coordinates are given in + PostScript point coordinates (72 points per inch, (0, 0) is the lower + left corner of the page). + """ + self.fp.write(b"%d %d %d %d Vl\n" % (*xy0, *xy1)) + + def rectangle(self, box): + """ + Draws a rectangle. + + :param box: A tuple of four integers, specifying left, bottom, width and + height. + """ + self.fp.write(b"%d %d M 0 %d %d Vr\n" % box) + + def text(self, xy, text): + """ + Draws text at the given position. You must use + :py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method. + """ + text = bytes(text, "UTF-8") + text = b"\\(".join(text.split(b"(")) + text = b"\\)".join(text.split(b")")) + xy += (text,) + self.fp.write(b"%d %d M (%s) S\n" % xy) + + def image(self, box, im, dpi=None): + """Draw a PIL image, centered in the given box.""" + # default resolution depends on mode + if not dpi: + if im.mode == "1": + dpi = 200 # fax + else: + dpi = 100 # grayscale + # image size (on paper) + x = im.size[0] * 72 / dpi + y = im.size[1] * 72 / dpi + # max allowed size + xmax = float(box[2] - box[0]) + ymax = float(box[3] - box[1]) + if x > xmax: + y = y * xmax / x + x = xmax + if y > ymax: + x = x * ymax / y + y = ymax + dx = (xmax - x) / 2 + box[0] + dy = (ymax - y) / 2 + box[1] + self.fp.write(b"gsave\n%f %f translate\n" % (dx, dy)) + if (x, y) != im.size: + # EpsImagePlugin._save prints the image at (0,0,xsize,ysize) + sx = x / im.size[0] + sy = y / im.size[1] + self.fp.write(b"%f %f scale\n" % (sx, sy)) + EpsImagePlugin._save(im, self.fp, None, 0) + self.fp.write(b"\ngrestore\n") + + +# -------------------------------------------------------------------- +# PostScript driver + +# +# EDROFF.PS -- PostScript driver for Edroff 2 +# +# History: +# 94-01-25 fl: created (edroff 2.04) +# +# Copyright (c) Fredrik Lundh 1994. +# + + +EDROFF_PS = b"""\ +/S { show } bind def +/P { moveto show } bind def +/M { moveto } bind def +/X { 0 rmoveto } bind def +/Y { 0 exch rmoveto } bind def +/E { findfont + dup maxlength dict begin + { + 1 index /FID ne { def } { pop pop } ifelse + } forall + /Encoding exch def + dup /FontName exch def + currentdict end definefont pop +} bind def +/F { findfont exch scalefont dup setfont + [ exch /setfont cvx ] cvx bind def +} bind def +""" + +# +# VDI.PS -- PostScript driver for VDI meta commands +# +# History: +# 94-01-25 fl: created (edroff 2.04) +# +# Copyright (c) Fredrik Lundh 1994. +# + +VDI_PS = b"""\ +/Vm { moveto } bind def +/Va { newpath arcn stroke } bind def +/Vl { moveto lineto stroke } bind def +/Vc { newpath 0 360 arc closepath } bind def +/Vr { exch dup 0 rlineto + exch dup 0 exch rlineto + exch neg 0 rlineto + 0 exch neg rlineto + setgray fill } bind def +/Tm matrix def +/Ve { Tm currentmatrix pop + translate scale newpath 0 0 .5 0 360 arc closepath + Tm setmatrix +} bind def +/Vf { currentgray exch setgray fill setgray } bind def +""" + +# +# ERROR.PS -- Error handler +# +# History: +# 89-11-21 fl: created (pslist 1.10) +# + +ERROR_PS = b"""\ +/landscape false def +/errorBUF 200 string def +/errorNL { currentpoint 10 sub exch pop 72 exch moveto } def +errordict begin /handleerror { + initmatrix /Courier findfont 10 scalefont setfont + newpath 72 720 moveto $error begin /newerror false def + (PostScript Error) show errorNL errorNL + (Error: ) show + /errorname load errorBUF cvs show errorNL errorNL + (Command: ) show + /command load dup type /stringtype ne { errorBUF cvs } if show + errorNL errorNL + (VMstatus: ) show + vmstatus errorBUF cvs show ( bytes available, ) show + errorBUF cvs show ( bytes used at level ) show + errorBUF cvs show errorNL errorNL + (Operand stargck: ) show errorNL /ostargck load { + dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL + } forall errorNL + (Execution stargck: ) show errorNL /estargck load { + dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL + } forall + end showpage +} def end +""" diff --git a/venv/lib/python3.10/site-packages/PIL/PaletteFile.py b/venv/lib/python3.10/site-packages/PIL/PaletteFile.py new file mode 100644 index 00000000..dc317540 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PaletteFile.py @@ -0,0 +1,52 @@ +# +# Python Imaging Library +# $Id$ +# +# stuff to read simple, teragon-style palette files +# +# History: +# 97-08-23 fl Created +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from ._binary import o8 + + +class PaletteFile: + """File handler for Teragon-style palette files.""" + + rawmode = "RGB" + + def __init__(self, fp): + self.palette = [(i, i, i) for i in range(256)] + + while True: + s = fp.readline() + + if not s: + break + if s[:1] == b"#": + continue + if len(s) > 100: + msg = "bad palette file" + raise SyntaxError(msg) + + v = [int(x) for x in s.split()] + try: + [i, r, g, b] = v + except ValueError: + [i, r] = v + g = b = r + + if 0 <= i <= 255: + self.palette[i] = o8(r) + o8(g) + o8(b) + + self.palette = b"".join(self.palette) + + def getpalette(self): + return self.palette, self.rawmode diff --git a/venv/lib/python3.10/site-packages/PIL/PalmImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PalmImagePlugin.py new file mode 100644 index 00000000..65be7fef --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PalmImagePlugin.py @@ -0,0 +1,226 @@ +# +# The Python Imaging Library. +# $Id$ +# + +## +# Image plugin for Palm pixmap images (output only). +## +from __future__ import annotations + +from . import Image, ImageFile +from ._binary import o8 +from ._binary import o16be as o16b + +# fmt: off +_Palm8BitColormapValues = ( + (255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255), + (255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204), + (255, 153, 204), (255, 102, 204), (255, 51, 204), (255, 0, 204), + (255, 255, 153), (255, 204, 153), (255, 153, 153), (255, 102, 153), + (255, 51, 153), (255, 0, 153), (204, 255, 255), (204, 204, 255), + (204, 153, 255), (204, 102, 255), (204, 51, 255), (204, 0, 255), + (204, 255, 204), (204, 204, 204), (204, 153, 204), (204, 102, 204), + (204, 51, 204), (204, 0, 204), (204, 255, 153), (204, 204, 153), + (204, 153, 153), (204, 102, 153), (204, 51, 153), (204, 0, 153), + (153, 255, 255), (153, 204, 255), (153, 153, 255), (153, 102, 255), + (153, 51, 255), (153, 0, 255), (153, 255, 204), (153, 204, 204), + (153, 153, 204), (153, 102, 204), (153, 51, 204), (153, 0, 204), + (153, 255, 153), (153, 204, 153), (153, 153, 153), (153, 102, 153), + (153, 51, 153), (153, 0, 153), (102, 255, 255), (102, 204, 255), + (102, 153, 255), (102, 102, 255), (102, 51, 255), (102, 0, 255), + (102, 255, 204), (102, 204, 204), (102, 153, 204), (102, 102, 204), + (102, 51, 204), (102, 0, 204), (102, 255, 153), (102, 204, 153), + (102, 153, 153), (102, 102, 153), (102, 51, 153), (102, 0, 153), + (51, 255, 255), (51, 204, 255), (51, 153, 255), (51, 102, 255), + (51, 51, 255), (51, 0, 255), (51, 255, 204), (51, 204, 204), + (51, 153, 204), (51, 102, 204), (51, 51, 204), (51, 0, 204), + (51, 255, 153), (51, 204, 153), (51, 153, 153), (51, 102, 153), + (51, 51, 153), (51, 0, 153), (0, 255, 255), (0, 204, 255), + (0, 153, 255), (0, 102, 255), (0, 51, 255), (0, 0, 255), + (0, 255, 204), (0, 204, 204), (0, 153, 204), (0, 102, 204), + (0, 51, 204), (0, 0, 204), (0, 255, 153), (0, 204, 153), + (0, 153, 153), (0, 102, 153), (0, 51, 153), (0, 0, 153), + (255, 255, 102), (255, 204, 102), (255, 153, 102), (255, 102, 102), + (255, 51, 102), (255, 0, 102), (255, 255, 51), (255, 204, 51), + (255, 153, 51), (255, 102, 51), (255, 51, 51), (255, 0, 51), + (255, 255, 0), (255, 204, 0), (255, 153, 0), (255, 102, 0), + (255, 51, 0), (255, 0, 0), (204, 255, 102), (204, 204, 102), + (204, 153, 102), (204, 102, 102), (204, 51, 102), (204, 0, 102), + (204, 255, 51), (204, 204, 51), (204, 153, 51), (204, 102, 51), + (204, 51, 51), (204, 0, 51), (204, 255, 0), (204, 204, 0), + (204, 153, 0), (204, 102, 0), (204, 51, 0), (204, 0, 0), + (153, 255, 102), (153, 204, 102), (153, 153, 102), (153, 102, 102), + (153, 51, 102), (153, 0, 102), (153, 255, 51), (153, 204, 51), + (153, 153, 51), (153, 102, 51), (153, 51, 51), (153, 0, 51), + (153, 255, 0), (153, 204, 0), (153, 153, 0), (153, 102, 0), + (153, 51, 0), (153, 0, 0), (102, 255, 102), (102, 204, 102), + (102, 153, 102), (102, 102, 102), (102, 51, 102), (102, 0, 102), + (102, 255, 51), (102, 204, 51), (102, 153, 51), (102, 102, 51), + (102, 51, 51), (102, 0, 51), (102, 255, 0), (102, 204, 0), + (102, 153, 0), (102, 102, 0), (102, 51, 0), (102, 0, 0), + (51, 255, 102), (51, 204, 102), (51, 153, 102), (51, 102, 102), + (51, 51, 102), (51, 0, 102), (51, 255, 51), (51, 204, 51), + (51, 153, 51), (51, 102, 51), (51, 51, 51), (51, 0, 51), + (51, 255, 0), (51, 204, 0), (51, 153, 0), (51, 102, 0), + (51, 51, 0), (51, 0, 0), (0, 255, 102), (0, 204, 102), + (0, 153, 102), (0, 102, 102), (0, 51, 102), (0, 0, 102), + (0, 255, 51), (0, 204, 51), (0, 153, 51), (0, 102, 51), + (0, 51, 51), (0, 0, 51), (0, 255, 0), (0, 204, 0), + (0, 153, 0), (0, 102, 0), (0, 51, 0), (17, 17, 17), + (34, 34, 34), (68, 68, 68), (85, 85, 85), (119, 119, 119), + (136, 136, 136), (170, 170, 170), (187, 187, 187), (221, 221, 221), + (238, 238, 238), (192, 192, 192), (128, 0, 0), (128, 0, 128), + (0, 128, 0), (0, 128, 128), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)) +# fmt: on + + +# so build a prototype image to be used for palette resampling +def build_prototype_image(): + image = Image.new("L", (1, len(_Palm8BitColormapValues))) + image.putdata(list(range(len(_Palm8BitColormapValues)))) + palettedata = () + for colormapValue in _Palm8BitColormapValues: + palettedata += colormapValue + palettedata += (0, 0, 0) * (256 - len(_Palm8BitColormapValues)) + image.putpalette(palettedata) + return image + + +Palm8BitColormapImage = build_prototype_image() + +# OK, we now have in Palm8BitColormapImage, +# a "P"-mode image with the right palette +# +# -------------------------------------------------------------------- + +_FLAGS = {"custom-colormap": 0x4000, "is-compressed": 0x8000, "has-transparent": 0x2000} + +_COMPRESSION_TYPES = {"none": 0xFF, "rle": 0x01, "scanline": 0x00} + + +# +# -------------------------------------------------------------------- + +## +# (Internal) Image save plugin for the Palm format. + + +def _save(im, fp, filename): + if im.mode == "P": + # we assume this is a color Palm image with the standard colormap, + # unless the "info" dict has a "custom-colormap" field + + rawmode = "P" + bpp = 8 + version = 1 + + elif im.mode == "L": + if im.encoderinfo.get("bpp") in (1, 2, 4): + # this is 8-bit grayscale, so we shift it to get the high-order bits, + # and invert it because + # Palm does grayscale from white (0) to black (1) + bpp = im.encoderinfo["bpp"] + im = im.point( + lambda x, shift=8 - bpp, maxval=(1 << bpp) - 1: maxval - (x >> shift) + ) + elif im.info.get("bpp") in (1, 2, 4): + # here we assume that even though the inherent mode is 8-bit grayscale, + # only the lower bpp bits are significant. + # We invert them to match the Palm. + bpp = im.info["bpp"] + im = im.point(lambda x, maxval=(1 << bpp) - 1: maxval - (x & maxval)) + else: + msg = f"cannot write mode {im.mode} as Palm" + raise OSError(msg) + + # we ignore the palette here + im.mode = "P" + rawmode = "P;" + str(bpp) + version = 1 + + elif im.mode == "1": + # monochrome -- write it inverted, as is the Palm standard + rawmode = "1;I" + bpp = 1 + version = 0 + + else: + msg = f"cannot write mode {im.mode} as Palm" + raise OSError(msg) + + # + # make sure image data is available + im.load() + + # write header + + cols = im.size[0] + rows = im.size[1] + + rowbytes = int((cols + (16 // bpp - 1)) / (16 // bpp)) * 2 + transparent_index = 0 + compression_type = _COMPRESSION_TYPES["none"] + + flags = 0 + if im.mode == "P" and "custom-colormap" in im.info: + flags = flags & _FLAGS["custom-colormap"] + colormapsize = 4 * 256 + 2 + colormapmode = im.palette.mode + colormap = im.getdata().getpalette() + else: + colormapsize = 0 + + if "offset" in im.info: + offset = (rowbytes * rows + 16 + 3 + colormapsize) // 4 + else: + offset = 0 + + fp.write(o16b(cols) + o16b(rows) + o16b(rowbytes) + o16b(flags)) + fp.write(o8(bpp)) + fp.write(o8(version)) + fp.write(o16b(offset)) + fp.write(o8(transparent_index)) + fp.write(o8(compression_type)) + fp.write(o16b(0)) # reserved by Palm + + # now write colormap if necessary + + if colormapsize > 0: + fp.write(o16b(256)) + for i in range(256): + fp.write(o8(i)) + if colormapmode == "RGB": + fp.write( + o8(colormap[3 * i]) + + o8(colormap[3 * i + 1]) + + o8(colormap[3 * i + 2]) + ) + elif colormapmode == "RGBA": + fp.write( + o8(colormap[4 * i]) + + o8(colormap[4 * i + 1]) + + o8(colormap[4 * i + 2]) + ) + + # now convert data to raw form + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, rowbytes, 1))]) + + if hasattr(fp, "flush"): + fp.flush() + + +# +# -------------------------------------------------------------------- + +Image.register_save("Palm", _save) + +Image.register_extension("Palm", ".palm") + +Image.register_mime("Palm", "image/palm") diff --git a/venv/lib/python3.10/site-packages/PIL/PcdImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PcdImagePlugin.py new file mode 100644 index 00000000..1cd5c4a9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PcdImagePlugin.py @@ -0,0 +1,66 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PCD file handling +# +# History: +# 96-05-10 fl Created +# 96-05-27 fl Added draft mode (128x192, 256x384) +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile + +## +# Image plugin for PhotoCD images. This plugin only reads the 768x512 +# image from the file; higher resolutions are encoded in a proprietary +# encoding. + + +class PcdImageFile(ImageFile.ImageFile): + format = "PCD" + format_description = "Kodak PhotoCD" + + def _open(self) -> None: + # rough + assert self.fp is not None + + self.fp.seek(2048) + s = self.fp.read(2048) + + if s[:4] != b"PCD_": + msg = "not a PCD file" + raise SyntaxError(msg) + + orientation = s[1538] & 3 + self.tile_post_rotate = None + if orientation == 1: + self.tile_post_rotate = 90 + elif orientation == 3: + self.tile_post_rotate = -90 + + self._mode = "RGB" + self._size = 768, 512 # FIXME: not correct for rotated images! + self.tile = [("pcd", (0, 0) + self.size, 96 * 2048, None)] + + def load_end(self) -> None: + if self.tile_post_rotate: + # Handle rotated PCDs + assert self.im is not None + + self.im = self.im.rotate(self.tile_post_rotate) + self._size = self.im.size + + +# +# registry + +Image.register_open(PcdImageFile.format, PcdImageFile) + +Image.register_extension(PcdImageFile.format, ".pcd") diff --git a/venv/lib/python3.10/site-packages/PIL/PcfFontFile.py b/venv/lib/python3.10/site-packages/PIL/PcfFontFile.py new file mode 100644 index 00000000..0d1968b1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PcfFontFile.py @@ -0,0 +1,254 @@ +# +# THIS IS WORK IN PROGRESS +# +# The Python Imaging Library +# $Id$ +# +# portable compiled font file parser +# +# history: +# 1997-08-19 fl created +# 2003-09-13 fl fixed loading of unicode fonts +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1997-2003 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +from typing import BinaryIO, Callable + +from . import FontFile, Image +from ._binary import i8 +from ._binary import i16be as b16 +from ._binary import i16le as l16 +from ._binary import i32be as b32 +from ._binary import i32le as l32 + +# -------------------------------------------------------------------- +# declarations + +PCF_MAGIC = 0x70636601 # "\x01fcp" + +PCF_PROPERTIES = 1 << 0 +PCF_ACCELERATORS = 1 << 1 +PCF_METRICS = 1 << 2 +PCF_BITMAPS = 1 << 3 +PCF_INK_METRICS = 1 << 4 +PCF_BDF_ENCODINGS = 1 << 5 +PCF_SWIDTHS = 1 << 6 +PCF_GLYPH_NAMES = 1 << 7 +PCF_BDF_ACCELERATORS = 1 << 8 + +BYTES_PER_ROW: list[Callable[[int], int]] = [ + lambda bits: ((bits + 7) >> 3), + lambda bits: ((bits + 15) >> 3) & ~1, + lambda bits: ((bits + 31) >> 3) & ~3, + lambda bits: ((bits + 63) >> 3) & ~7, +] + + +def sz(s: bytes, o: int) -> bytes: + return s[o : s.index(b"\0", o)] + + +class PcfFontFile(FontFile.FontFile): + """Font file plugin for the X11 PCF format.""" + + name = "name" + + def __init__(self, fp: BinaryIO, charset_encoding: str = "iso8859-1"): + self.charset_encoding = charset_encoding + + magic = l32(fp.read(4)) + if magic != PCF_MAGIC: + msg = "not a PCF file" + raise SyntaxError(msg) + + super().__init__() + + count = l32(fp.read(4)) + self.toc = {} + for i in range(count): + type = l32(fp.read(4)) + self.toc[type] = l32(fp.read(4)), l32(fp.read(4)), l32(fp.read(4)) + + self.fp = fp + + self.info = self._load_properties() + + metrics = self._load_metrics() + bitmaps = self._load_bitmaps(metrics) + encoding = self._load_encoding() + + # + # create glyph structure + + for ch, ix in enumerate(encoding): + if ix is not None: + ( + xsize, + ysize, + left, + right, + width, + ascent, + descent, + attributes, + ) = metrics[ix] + self.glyph[ch] = ( + (width, 0), + (left, descent - ysize, xsize + left, descent), + (0, 0, xsize, ysize), + bitmaps[ix], + ) + + def _getformat( + self, tag: int + ) -> tuple[BinaryIO, int, Callable[[bytes], int], Callable[[bytes], int]]: + format, size, offset = self.toc[tag] + + fp = self.fp + fp.seek(offset) + + format = l32(fp.read(4)) + + if format & 4: + i16, i32 = b16, b32 + else: + i16, i32 = l16, l32 + + return fp, format, i16, i32 + + def _load_properties(self) -> dict[bytes, bytes | int]: + # + # font properties + + properties = {} + + fp, format, i16, i32 = self._getformat(PCF_PROPERTIES) + + nprops = i32(fp.read(4)) + + # read property description + p = [(i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))) for _ in range(nprops)] + + if nprops & 3: + fp.seek(4 - (nprops & 3), io.SEEK_CUR) # pad + + data = fp.read(i32(fp.read(4))) + + for k, s, v in p: + property_value: bytes | int = sz(data, v) if s else v + properties[sz(data, k)] = property_value + + return properties + + def _load_metrics(self) -> list[tuple[int, int, int, int, int, int, int, int]]: + # + # font metrics + + metrics: list[tuple[int, int, int, int, int, int, int, int]] = [] + + fp, format, i16, i32 = self._getformat(PCF_METRICS) + + append = metrics.append + + if (format & 0xFF00) == 0x100: + # "compressed" metrics + for i in range(i16(fp.read(2))): + left = i8(fp.read(1)) - 128 + right = i8(fp.read(1)) - 128 + width = i8(fp.read(1)) - 128 + ascent = i8(fp.read(1)) - 128 + descent = i8(fp.read(1)) - 128 + xsize = right - left + ysize = ascent + descent + append((xsize, ysize, left, right, width, ascent, descent, 0)) + + else: + # "jumbo" metrics + for i in range(i32(fp.read(4))): + left = i16(fp.read(2)) + right = i16(fp.read(2)) + width = i16(fp.read(2)) + ascent = i16(fp.read(2)) + descent = i16(fp.read(2)) + attributes = i16(fp.read(2)) + xsize = right - left + ysize = ascent + descent + append((xsize, ysize, left, right, width, ascent, descent, attributes)) + + return metrics + + def _load_bitmaps( + self, metrics: list[tuple[int, int, int, int, int, int, int, int]] + ) -> list[Image.Image]: + # + # bitmap data + + fp, format, i16, i32 = self._getformat(PCF_BITMAPS) + + nbitmaps = i32(fp.read(4)) + + if nbitmaps != len(metrics): + msg = "Wrong number of bitmaps" + raise OSError(msg) + + offsets = [i32(fp.read(4)) for _ in range(nbitmaps)] + + bitmap_sizes = [i32(fp.read(4)) for _ in range(4)] + + # byteorder = format & 4 # non-zero => MSB + bitorder = format & 8 # non-zero => MSB + padindex = format & 3 + + bitmapsize = bitmap_sizes[padindex] + offsets.append(bitmapsize) + + data = fp.read(bitmapsize) + + pad = BYTES_PER_ROW[padindex] + mode = "1;R" + if bitorder: + mode = "1" + + bitmaps = [] + for i in range(nbitmaps): + xsize, ysize = metrics[i][:2] + b, e = offsets[i : i + 2] + bitmaps.append( + Image.frombytes("1", (xsize, ysize), data[b:e], "raw", mode, pad(xsize)) + ) + + return bitmaps + + def _load_encoding(self) -> list[int | None]: + fp, format, i16, i32 = self._getformat(PCF_BDF_ENCODINGS) + + first_col, last_col = i16(fp.read(2)), i16(fp.read(2)) + first_row, last_row = i16(fp.read(2)), i16(fp.read(2)) + + i16(fp.read(2)) # default + + nencoding = (last_col - first_col + 1) * (last_row - first_row + 1) + + # map character code to bitmap index + encoding: list[int | None] = [None] * min(256, nencoding) + + encoding_offsets = [i16(fp.read(2)) for _ in range(nencoding)] + + for i in range(first_col, len(encoding)): + try: + encoding_offset = encoding_offsets[ + ord(bytearray([i]).decode(self.charset_encoding)) + ] + if encoding_offset != 0xFFFF: + encoding[i] = encoding_offset + except UnicodeDecodeError: + # character is not supported in selected encoding + pass + + return encoding diff --git a/venv/lib/python3.10/site-packages/PIL/PcxImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PcxImagePlugin.py new file mode 100644 index 00000000..026bfd9a --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PcxImagePlugin.py @@ -0,0 +1,227 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PCX file handling +# +# This format was originally used by ZSoft's popular PaintBrush +# program for the IBM PC. It is also supported by many MS-DOS and +# Windows applications, including the Windows PaintBrush program in +# Windows 3. +# +# history: +# 1995-09-01 fl Created +# 1996-05-20 fl Fixed RGB support +# 1997-01-03 fl Fixed 2-bit and 4-bit support +# 1999-02-03 fl Fixed 8-bit support (broken in 1.0b1) +# 1999-02-07 fl Added write support +# 2002-06-09 fl Made 2-bit and 4-bit support a bit more robust +# 2002-07-30 fl Seek from to current position, not beginning of file +# 2003-06-03 fl Extract DPI settings (info["dpi"]) +# +# Copyright (c) 1997-2003 by Secret Labs AB. +# Copyright (c) 1995-2003 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import logging +from typing import IO + +from . import Image, ImageFile, ImagePalette +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 + +logger = logging.getLogger(__name__) + + +def _accept(prefix: bytes) -> bool: + return prefix[0] == 10 and prefix[1] in [0, 2, 3, 5] + + +## +# Image plugin for Paintbrush images. + + +class PcxImageFile(ImageFile.ImageFile): + format = "PCX" + format_description = "Paintbrush" + + def _open(self) -> None: + # header + assert self.fp is not None + + s = self.fp.read(128) + if not _accept(s): + msg = "not a PCX file" + raise SyntaxError(msg) + + # image + bbox = i16(s, 4), i16(s, 6), i16(s, 8) + 1, i16(s, 10) + 1 + if bbox[2] <= bbox[0] or bbox[3] <= bbox[1]: + msg = "bad PCX image size" + raise SyntaxError(msg) + logger.debug("BBox: %s %s %s %s", *bbox) + + # format + version = s[1] + bits = s[3] + planes = s[65] + provided_stride = i16(s, 66) + logger.debug( + "PCX version %s, bits %s, planes %s, stride %s", + version, + bits, + planes, + provided_stride, + ) + + self.info["dpi"] = i16(s, 12), i16(s, 14) + + if bits == 1 and planes == 1: + mode = rawmode = "1" + + elif bits == 1 and planes in (2, 4): + mode = "P" + rawmode = "P;%dL" % planes + self.palette = ImagePalette.raw("RGB", s[16:64]) + + elif version == 5 and bits == 8 and planes == 1: + mode = rawmode = "L" + # FIXME: hey, this doesn't work with the incremental loader !!! + self.fp.seek(-769, io.SEEK_END) + s = self.fp.read(769) + if len(s) == 769 and s[0] == 12: + # check if the palette is linear grayscale + for i in range(256): + if s[i * 3 + 1 : i * 3 + 4] != o8(i) * 3: + mode = rawmode = "P" + break + if mode == "P": + self.palette = ImagePalette.raw("RGB", s[1:]) + self.fp.seek(128) + + elif version == 5 and bits == 8 and planes == 3: + mode = "RGB" + rawmode = "RGB;L" + + else: + msg = "unknown PCX mode" + raise OSError(msg) + + self._mode = mode + self._size = bbox[2] - bbox[0], bbox[3] - bbox[1] + + # Don't trust the passed in stride. + # Calculate the approximate position for ourselves. + # CVE-2020-35653 + stride = (self._size[0] * bits + 7) // 8 + + # While the specification states that this must be even, + # not all images follow this + if provided_stride != stride: + stride += stride % 2 + + bbox = (0, 0) + self.size + logger.debug("size: %sx%s", *self.size) + + self.tile = [("pcx", bbox, self.fp.tell(), (rawmode, planes * stride))] + + +# -------------------------------------------------------------------- +# save PCX files + + +SAVE = { + # mode: (version, bits, planes, raw mode) + "1": (2, 1, 1, "1"), + "L": (5, 8, 1, "L"), + "P": (5, 8, 1, "P"), + "RGB": (5, 8, 3, "RGB;L"), +} + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + try: + version, bits, planes, rawmode = SAVE[im.mode] + except KeyError as e: + msg = f"Cannot save {im.mode} images as PCX" + raise ValueError(msg) from e + + # bytes per plane + stride = (im.size[0] * bits + 7) // 8 + # stride should be even + stride += stride % 2 + # Stride needs to be kept in sync with the PcxEncode.c version. + # Ideally it should be passed in in the state, but the bytes value + # gets overwritten. + + logger.debug( + "PcxImagePlugin._save: xwidth: %d, bits: %d, stride: %d", + im.size[0], + bits, + stride, + ) + + # under windows, we could determine the current screen size with + # "Image.core.display_mode()[1]", but I think that's overkill... + + screen = im.size + + dpi = 100, 100 + + # PCX header + fp.write( + o8(10) + + o8(version) + + o8(1) + + o8(bits) + + o16(0) + + o16(0) + + o16(im.size[0] - 1) + + o16(im.size[1] - 1) + + o16(dpi[0]) + + o16(dpi[1]) + + b"\0" * 24 + + b"\xFF" * 24 + + b"\0" + + o8(planes) + + o16(stride) + + o16(1) + + o16(screen[0]) + + o16(screen[1]) + + b"\0" * 54 + ) + + assert fp.tell() == 128 + + ImageFile._save(im, fp, [("pcx", (0, 0) + im.size, 0, (rawmode, bits * planes))]) + + if im.mode == "P": + # colour palette + assert im.im is not None + + fp.write(o8(12)) + palette = im.im.getpalette("RGB", "RGB") + palette += b"\x00" * (768 - len(palette)) + fp.write(palette) # 768 bytes + elif im.mode == "L": + # grayscale palette + fp.write(o8(12)) + for i in range(256): + fp.write(o8(i) * 3) + + +# -------------------------------------------------------------------- +# registry + + +Image.register_open(PcxImageFile.format, PcxImageFile, _accept) +Image.register_save(PcxImageFile.format, _save) + +Image.register_extension(PcxImageFile.format, ".pcx") + +Image.register_mime(PcxImageFile.format, "image/x-pcx") diff --git a/venv/lib/python3.10/site-packages/PIL/PdfImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PdfImagePlugin.py new file mode 100644 index 00000000..1777f1f2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PdfImagePlugin.py @@ -0,0 +1,303 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PDF (Acrobat) file handling +# +# History: +# 1996-07-16 fl Created +# 1997-01-18 fl Fixed header +# 2004-02-21 fl Fixes for 1/L/CMYK images, etc. +# 2004-02-24 fl Fixes for 1 and P images. +# +# Copyright (c) 1997-2004 by Secret Labs AB. All rights reserved. +# Copyright (c) 1996-1997 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +## +# Image plugin for PDF images (output only). +## +from __future__ import annotations + +import io +import math +import os +import time + +from . import Image, ImageFile, ImageSequence, PdfParser, __version__, features + +# +# -------------------------------------------------------------------- + +# object ids: +# 1. catalogue +# 2. pages +# 3. image +# 4. page +# 5. page contents + + +def _save_all(im, fp, filename): + _save(im, fp, filename, save_all=True) + + +## +# (Internal) Image save plugin for the PDF format. + + +def _write_image(im, filename, existing_pdf, image_refs): + # FIXME: Should replace ASCIIHexDecode with RunLengthDecode + # (packbits) or LZWDecode (tiff/lzw compression). Note that + # PDF 1.2 also supports Flatedecode (zip compression). + + params = None + decode = None + + # + # Get image characteristics + + width, height = im.size + + dict_obj = {"BitsPerComponent": 8} + if im.mode == "1": + if features.check("libtiff"): + filter = "CCITTFaxDecode" + dict_obj["BitsPerComponent"] = 1 + params = PdfParser.PdfArray( + [ + PdfParser.PdfDict( + { + "K": -1, + "BlackIs1": True, + "Columns": width, + "Rows": height, + } + ) + ] + ) + else: + filter = "DCTDecode" + dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceGray") + procset = "ImageB" # grayscale + elif im.mode == "L": + filter = "DCTDecode" + # params = f"<< /Predictor 15 /Columns {width-2} >>" + dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceGray") + procset = "ImageB" # grayscale + elif im.mode == "LA": + filter = "JPXDecode" + # params = f"<< /Predictor 15 /Columns {width-2} >>" + procset = "ImageB" # grayscale + dict_obj["SMaskInData"] = 1 + elif im.mode == "P": + filter = "ASCIIHexDecode" + palette = im.getpalette() + dict_obj["ColorSpace"] = [ + PdfParser.PdfName("Indexed"), + PdfParser.PdfName("DeviceRGB"), + len(palette) // 3 - 1, + PdfParser.PdfBinary(palette), + ] + procset = "ImageI" # indexed color + + if "transparency" in im.info: + smask = im.convert("LA").getchannel("A") + smask.encoderinfo = {} + + image_ref = _write_image(smask, filename, existing_pdf, image_refs)[0] + dict_obj["SMask"] = image_ref + elif im.mode == "RGB": + filter = "DCTDecode" + dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceRGB") + procset = "ImageC" # color images + elif im.mode == "RGBA": + filter = "JPXDecode" + procset = "ImageC" # color images + dict_obj["SMaskInData"] = 1 + elif im.mode == "CMYK": + filter = "DCTDecode" + dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceCMYK") + procset = "ImageC" # color images + decode = [1, 0, 1, 0, 1, 0, 1, 0] + else: + msg = f"cannot save mode {im.mode}" + raise ValueError(msg) + + # + # image + + op = io.BytesIO() + + if filter == "ASCIIHexDecode": + ImageFile._save(im, op, [("hex", (0, 0) + im.size, 0, im.mode)]) + elif filter == "CCITTFaxDecode": + im.save( + op, + "TIFF", + compression="group4", + # use a single strip + strip_size=math.ceil(width / 8) * height, + ) + elif filter == "DCTDecode": + Image.SAVE["JPEG"](im, op, filename) + elif filter == "JPXDecode": + del dict_obj["BitsPerComponent"] + Image.SAVE["JPEG2000"](im, op, filename) + else: + msg = f"unsupported PDF filter ({filter})" + raise ValueError(msg) + + stream = op.getvalue() + if filter == "CCITTFaxDecode": + stream = stream[8:] + filter = PdfParser.PdfArray([PdfParser.PdfName(filter)]) + else: + filter = PdfParser.PdfName(filter) + + image_ref = image_refs.pop(0) + existing_pdf.write_obj( + image_ref, + stream=stream, + Type=PdfParser.PdfName("XObject"), + Subtype=PdfParser.PdfName("Image"), + Width=width, # * 72.0 / x_resolution, + Height=height, # * 72.0 / y_resolution, + Filter=filter, + Decode=decode, + DecodeParms=params, + **dict_obj, + ) + + return image_ref, procset + + +def _save(im, fp, filename, save_all=False): + is_appending = im.encoderinfo.get("append", False) + if is_appending: + existing_pdf = PdfParser.PdfParser(f=fp, filename=filename, mode="r+b") + else: + existing_pdf = PdfParser.PdfParser(f=fp, filename=filename, mode="w+b") + + dpi = im.encoderinfo.get("dpi") + if dpi: + x_resolution = dpi[0] + y_resolution = dpi[1] + else: + x_resolution = y_resolution = im.encoderinfo.get("resolution", 72.0) + + info = { + "title": ( + None if is_appending else os.path.splitext(os.path.basename(filename))[0] + ), + "author": None, + "subject": None, + "keywords": None, + "creator": None, + "producer": None, + "creationDate": None if is_appending else time.gmtime(), + "modDate": None if is_appending else time.gmtime(), + } + for k, default in info.items(): + v = im.encoderinfo.get(k) if k in im.encoderinfo else default + if v: + existing_pdf.info[k[0].upper() + k[1:]] = v + + # + # make sure image data is available + im.load() + + existing_pdf.start_writing() + existing_pdf.write_header() + existing_pdf.write_comment(f"created by Pillow {__version__} PDF driver") + + # + # pages + ims = [im] + if save_all: + append_images = im.encoderinfo.get("append_images", []) + for append_im in append_images: + append_im.encoderinfo = im.encoderinfo.copy() + ims.append(append_im) + number_of_pages = 0 + image_refs = [] + page_refs = [] + contents_refs = [] + for im in ims: + im_number_of_pages = 1 + if save_all: + try: + im_number_of_pages = im.n_frames + except AttributeError: + # Image format does not have n_frames. + # It is a single frame image + pass + number_of_pages += im_number_of_pages + for i in range(im_number_of_pages): + image_refs.append(existing_pdf.next_object_id(0)) + if im.mode == "P" and "transparency" in im.info: + image_refs.append(existing_pdf.next_object_id(0)) + + page_refs.append(existing_pdf.next_object_id(0)) + contents_refs.append(existing_pdf.next_object_id(0)) + existing_pdf.pages.append(page_refs[-1]) + + # + # catalog and list of pages + existing_pdf.write_catalog() + + page_number = 0 + for im_sequence in ims: + im_pages = ImageSequence.Iterator(im_sequence) if save_all else [im_sequence] + for im in im_pages: + image_ref, procset = _write_image(im, filename, existing_pdf, image_refs) + + # + # page + + existing_pdf.write_page( + page_refs[page_number], + Resources=PdfParser.PdfDict( + ProcSet=[PdfParser.PdfName("PDF"), PdfParser.PdfName(procset)], + XObject=PdfParser.PdfDict(image=image_ref), + ), + MediaBox=[ + 0, + 0, + im.width * 72.0 / x_resolution, + im.height * 72.0 / y_resolution, + ], + Contents=contents_refs[page_number], + ) + + # + # page contents + + page_contents = b"q %f 0 0 %f 0 0 cm /image Do Q\n" % ( + im.width * 72.0 / x_resolution, + im.height * 72.0 / y_resolution, + ) + + existing_pdf.write_obj(contents_refs[page_number], stream=page_contents) + + page_number += 1 + + # + # trailer + existing_pdf.write_xref_and_trailer() + if hasattr(fp, "flush"): + fp.flush() + existing_pdf.close() + + +# +# -------------------------------------------------------------------- + + +Image.register_save("PDF", _save) +Image.register_save_all("PDF", _save_all) + +Image.register_extension("PDF", ".pdf") + +Image.register_mime("PDF", "application/pdf") diff --git a/venv/lib/python3.10/site-packages/PIL/PdfParser.py b/venv/lib/python3.10/site-packages/PIL/PdfParser.py new file mode 100644 index 00000000..2542d4e9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PdfParser.py @@ -0,0 +1,1008 @@ +from __future__ import annotations + +import calendar +import codecs +import collections +import mmap +import os +import re +import time +import zlib +from typing import TYPE_CHECKING, Any, List, NamedTuple, Union + + +# see 7.9.2.2 Text String Type on page 86 and D.3 PDFDocEncoding Character Set +# on page 656 +def encode_text(s): + return codecs.BOM_UTF16_BE + s.encode("utf_16_be") + + +PDFDocEncoding = { + 0x16: "\u0017", + 0x18: "\u02D8", + 0x19: "\u02C7", + 0x1A: "\u02C6", + 0x1B: "\u02D9", + 0x1C: "\u02DD", + 0x1D: "\u02DB", + 0x1E: "\u02DA", + 0x1F: "\u02DC", + 0x80: "\u2022", + 0x81: "\u2020", + 0x82: "\u2021", + 0x83: "\u2026", + 0x84: "\u2014", + 0x85: "\u2013", + 0x86: "\u0192", + 0x87: "\u2044", + 0x88: "\u2039", + 0x89: "\u203A", + 0x8A: "\u2212", + 0x8B: "\u2030", + 0x8C: "\u201E", + 0x8D: "\u201C", + 0x8E: "\u201D", + 0x8F: "\u2018", + 0x90: "\u2019", + 0x91: "\u201A", + 0x92: "\u2122", + 0x93: "\uFB01", + 0x94: "\uFB02", + 0x95: "\u0141", + 0x96: "\u0152", + 0x97: "\u0160", + 0x98: "\u0178", + 0x99: "\u017D", + 0x9A: "\u0131", + 0x9B: "\u0142", + 0x9C: "\u0153", + 0x9D: "\u0161", + 0x9E: "\u017E", + 0xA0: "\u20AC", +} + + +def decode_text(b): + if b[: len(codecs.BOM_UTF16_BE)] == codecs.BOM_UTF16_BE: + return b[len(codecs.BOM_UTF16_BE) :].decode("utf_16_be") + else: + return "".join(PDFDocEncoding.get(byte, chr(byte)) for byte in b) + + +class PdfFormatError(RuntimeError): + """An error that probably indicates a syntactic or semantic error in the + PDF file structure""" + + pass + + +def check_format_condition(condition, error_message): + if not condition: + raise PdfFormatError(error_message) + + +class IndirectReferenceTuple(NamedTuple): + object_id: int + generation: int + + +class IndirectReference(IndirectReferenceTuple): + def __str__(self): + return f"{self.object_id} {self.generation} R" + + def __bytes__(self): + return self.__str__().encode("us-ascii") + + def __eq__(self, other): + return ( + other.__class__ is self.__class__ + and other.object_id == self.object_id + and other.generation == self.generation + ) + + def __ne__(self, other): + return not (self == other) + + def __hash__(self): + return hash((self.object_id, self.generation)) + + +class IndirectObjectDef(IndirectReference): + def __str__(self): + return f"{self.object_id} {self.generation} obj" + + +class XrefTable: + def __init__(self): + self.existing_entries = {} # object ID => (offset, generation) + self.new_entries = {} # object ID => (offset, generation) + self.deleted_entries = {0: 65536} # object ID => generation + self.reading_finished = False + + def __setitem__(self, key, value): + if self.reading_finished: + self.new_entries[key] = value + else: + self.existing_entries[key] = value + if key in self.deleted_entries: + del self.deleted_entries[key] + + def __getitem__(self, key): + try: + return self.new_entries[key] + except KeyError: + return self.existing_entries[key] + + def __delitem__(self, key): + if key in self.new_entries: + generation = self.new_entries[key][1] + 1 + del self.new_entries[key] + self.deleted_entries[key] = generation + elif key in self.existing_entries: + generation = self.existing_entries[key][1] + 1 + self.deleted_entries[key] = generation + elif key in self.deleted_entries: + generation = self.deleted_entries[key] + else: + msg = ( + "object ID " + str(key) + " cannot be deleted because it doesn't exist" + ) + raise IndexError(msg) + + def __contains__(self, key): + return key in self.existing_entries or key in self.new_entries + + def __len__(self): + return len( + set(self.existing_entries.keys()) + | set(self.new_entries.keys()) + | set(self.deleted_entries.keys()) + ) + + def keys(self): + return ( + set(self.existing_entries.keys()) - set(self.deleted_entries.keys()) + ) | set(self.new_entries.keys()) + + def write(self, f): + keys = sorted(set(self.new_entries.keys()) | set(self.deleted_entries.keys())) + deleted_keys = sorted(set(self.deleted_entries.keys())) + startxref = f.tell() + f.write(b"xref\n") + while keys: + # find a contiguous sequence of object IDs + prev = None + for index, key in enumerate(keys): + if prev is None or prev + 1 == key: + prev = key + else: + contiguous_keys = keys[:index] + keys = keys[index:] + break + else: + contiguous_keys = keys + keys = None + f.write(b"%d %d\n" % (contiguous_keys[0], len(contiguous_keys))) + for object_id in contiguous_keys: + if object_id in self.new_entries: + f.write(b"%010d %05d n \n" % self.new_entries[object_id]) + else: + this_deleted_object_id = deleted_keys.pop(0) + check_format_condition( + object_id == this_deleted_object_id, + f"expected the next deleted object ID to be {object_id}, " + f"instead found {this_deleted_object_id}", + ) + try: + next_in_linked_list = deleted_keys[0] + except IndexError: + next_in_linked_list = 0 + f.write( + b"%010d %05d f \n" + % (next_in_linked_list, self.deleted_entries[object_id]) + ) + return startxref + + +class PdfName: + def __init__(self, name): + if isinstance(name, PdfName): + self.name = name.name + elif isinstance(name, bytes): + self.name = name + else: + self.name = name.encode("us-ascii") + + def name_as_str(self): + return self.name.decode("us-ascii") + + def __eq__(self, other): + return ( + isinstance(other, PdfName) and other.name == self.name + ) or other == self.name + + def __hash__(self): + return hash(self.name) + + def __repr__(self): + return f"PdfName({repr(self.name)})" + + @classmethod + def from_pdf_stream(cls, data): + return cls(PdfParser.interpret_name(data)) + + allowed_chars = set(range(33, 127)) - {ord(c) for c in "#%/()<>[]{}"} + + def __bytes__(self): + result = bytearray(b"/") + for b in self.name: + if b in self.allowed_chars: + result.append(b) + else: + result.extend(b"#%02X" % b) + return bytes(result) + + +class PdfArray(List[Any]): + def __bytes__(self): + return b"[ " + b" ".join(pdf_repr(x) for x in self) + b" ]" + + +if TYPE_CHECKING: + _DictBase = collections.UserDict[Union[str, bytes], Any] +else: + _DictBase = collections.UserDict + + +class PdfDict(_DictBase): + def __setattr__(self, key, value): + if key == "data": + collections.UserDict.__setattr__(self, key, value) + else: + self[key.encode("us-ascii")] = value + + def __getattr__(self, key): + try: + value = self[key.encode("us-ascii")] + except KeyError as e: + raise AttributeError(key) from e + if isinstance(value, bytes): + value = decode_text(value) + if key.endswith("Date"): + if value.startswith("D:"): + value = value[2:] + + relationship = "Z" + if len(value) > 17: + relationship = value[14] + offset = int(value[15:17]) * 60 + if len(value) > 20: + offset += int(value[18:20]) + + format = "%Y%m%d%H%M%S"[: len(value) - 2] + value = time.strptime(value[: len(format) + 2], format) + if relationship in ["+", "-"]: + offset *= 60 + if relationship == "+": + offset *= -1 + value = time.gmtime(calendar.timegm(value) + offset) + return value + + def __bytes__(self): + out = bytearray(b"<<") + for key, value in self.items(): + if value is None: + continue + value = pdf_repr(value) + out.extend(b"\n") + out.extend(bytes(PdfName(key))) + out.extend(b" ") + out.extend(value) + out.extend(b"\n>>") + return bytes(out) + + +class PdfBinary: + def __init__(self, data): + self.data = data + + def __bytes__(self): + return b"<%s>" % b"".join(b"%02X" % b for b in self.data) + + +class PdfStream: + def __init__(self, dictionary, buf): + self.dictionary = dictionary + self.buf = buf + + def decode(self): + try: + filter = self.dictionary.Filter + except AttributeError: + return self.buf + if filter == b"FlateDecode": + try: + expected_length = self.dictionary.DL + except AttributeError: + expected_length = self.dictionary.Length + return zlib.decompress(self.buf, bufsize=int(expected_length)) + else: + msg = f"stream filter {repr(self.dictionary.Filter)} unknown/unsupported" + raise NotImplementedError(msg) + + +def pdf_repr(x): + if x is True: + return b"true" + elif x is False: + return b"false" + elif x is None: + return b"null" + elif isinstance(x, (PdfName, PdfDict, PdfArray, PdfBinary)): + return bytes(x) + elif isinstance(x, (int, float)): + return str(x).encode("us-ascii") + elif isinstance(x, time.struct_time): + return b"(D:" + time.strftime("%Y%m%d%H%M%SZ", x).encode("us-ascii") + b")" + elif isinstance(x, dict): + return bytes(PdfDict(x)) + elif isinstance(x, list): + return bytes(PdfArray(x)) + elif isinstance(x, str): + return pdf_repr(encode_text(x)) + elif isinstance(x, bytes): + # XXX escape more chars? handle binary garbage + x = x.replace(b"\\", b"\\\\") + x = x.replace(b"(", b"\\(") + x = x.replace(b")", b"\\)") + return b"(" + x + b")" + else: + return bytes(x) + + +class PdfParser: + """Based on + https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf + Supports PDF up to 1.4 + """ + + def __init__(self, filename=None, f=None, buf=None, start_offset=0, mode="rb"): + if buf and f: + msg = "specify buf or f or filename, but not both buf and f" + raise RuntimeError(msg) + self.filename = filename + self.buf = buf + self.f = f + self.start_offset = start_offset + self.should_close_buf = False + self.should_close_file = False + if filename is not None and f is None: + self.f = f = open(filename, mode) + self.should_close_file = True + if f is not None: + self.buf = buf = self.get_buf_from_file(f) + self.should_close_buf = True + if not filename and hasattr(f, "name"): + self.filename = f.name + self.cached_objects = {} + if buf: + self.read_pdf_info() + else: + self.file_size_total = self.file_size_this = 0 + self.root = PdfDict() + self.root_ref = None + self.info = PdfDict() + self.info_ref = None + self.page_tree_root = {} + self.pages = [] + self.orig_pages = [] + self.pages_ref = None + self.last_xref_section_offset = None + self.trailer_dict = {} + self.xref_table = XrefTable() + self.xref_table.reading_finished = True + if f: + self.seek_end() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + return False # do not suppress exceptions + + def start_writing(self): + self.close_buf() + self.seek_end() + + def close_buf(self): + try: + self.buf.close() + except AttributeError: + pass + self.buf = None + + def close(self): + if self.should_close_buf: + self.close_buf() + if self.f is not None and self.should_close_file: + self.f.close() + self.f = None + + def seek_end(self): + self.f.seek(0, os.SEEK_END) + + def write_header(self): + self.f.write(b"%PDF-1.4\n") + + def write_comment(self, s): + self.f.write(f"% {s}\n".encode()) + + def write_catalog(self): + self.del_root() + self.root_ref = self.next_object_id(self.f.tell()) + self.pages_ref = self.next_object_id(0) + self.rewrite_pages() + self.write_obj(self.root_ref, Type=PdfName(b"Catalog"), Pages=self.pages_ref) + self.write_obj( + self.pages_ref, + Type=PdfName(b"Pages"), + Count=len(self.pages), + Kids=self.pages, + ) + return self.root_ref + + def rewrite_pages(self): + pages_tree_nodes_to_delete = [] + for i, page_ref in enumerate(self.orig_pages): + page_info = self.cached_objects[page_ref] + del self.xref_table[page_ref.object_id] + pages_tree_nodes_to_delete.append(page_info[PdfName(b"Parent")]) + if page_ref not in self.pages: + # the page has been deleted + continue + # make dict keys into strings for passing to write_page + stringified_page_info = {} + for key, value in page_info.items(): + # key should be a PdfName + stringified_page_info[key.name_as_str()] = value + stringified_page_info["Parent"] = self.pages_ref + new_page_ref = self.write_page(None, **stringified_page_info) + for j, cur_page_ref in enumerate(self.pages): + if cur_page_ref == page_ref: + # replace the page reference with the new one + self.pages[j] = new_page_ref + # delete redundant Pages tree nodes from xref table + for pages_tree_node_ref in pages_tree_nodes_to_delete: + while pages_tree_node_ref: + pages_tree_node = self.cached_objects[pages_tree_node_ref] + if pages_tree_node_ref.object_id in self.xref_table: + del self.xref_table[pages_tree_node_ref.object_id] + pages_tree_node_ref = pages_tree_node.get(b"Parent", None) + self.orig_pages = [] + + def write_xref_and_trailer(self, new_root_ref=None): + if new_root_ref: + self.del_root() + self.root_ref = new_root_ref + if self.info: + self.info_ref = self.write_obj(None, self.info) + start_xref = self.xref_table.write(self.f) + num_entries = len(self.xref_table) + trailer_dict = {b"Root": self.root_ref, b"Size": num_entries} + if self.last_xref_section_offset is not None: + trailer_dict[b"Prev"] = self.last_xref_section_offset + if self.info: + trailer_dict[b"Info"] = self.info_ref + self.last_xref_section_offset = start_xref + self.f.write( + b"trailer\n" + + bytes(PdfDict(trailer_dict)) + + b"\nstartxref\n%d\n%%%%EOF" % start_xref + ) + + def write_page(self, ref, *objs, **dict_obj): + if isinstance(ref, int): + ref = self.pages[ref] + if "Type" not in dict_obj: + dict_obj["Type"] = PdfName(b"Page") + if "Parent" not in dict_obj: + dict_obj["Parent"] = self.pages_ref + return self.write_obj(ref, *objs, **dict_obj) + + def write_obj(self, ref, *objs, **dict_obj): + f = self.f + if ref is None: + ref = self.next_object_id(f.tell()) + else: + self.xref_table[ref.object_id] = (f.tell(), ref.generation) + f.write(bytes(IndirectObjectDef(*ref))) + stream = dict_obj.pop("stream", None) + if stream is not None: + dict_obj["Length"] = len(stream) + if dict_obj: + f.write(pdf_repr(dict_obj)) + for obj in objs: + f.write(pdf_repr(obj)) + if stream is not None: + f.write(b"stream\n") + f.write(stream) + f.write(b"\nendstream\n") + f.write(b"endobj\n") + return ref + + def del_root(self): + if self.root_ref is None: + return + del self.xref_table[self.root_ref.object_id] + del self.xref_table[self.root[b"Pages"].object_id] + + @staticmethod + def get_buf_from_file(f): + if hasattr(f, "getbuffer"): + return f.getbuffer() + elif hasattr(f, "getvalue"): + return f.getvalue() + else: + try: + return mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) + except ValueError: # cannot mmap an empty file + return b"" + + def read_pdf_info(self): + self.file_size_total = len(self.buf) + self.file_size_this = self.file_size_total - self.start_offset + self.read_trailer() + self.root_ref = self.trailer_dict[b"Root"] + self.info_ref = self.trailer_dict.get(b"Info", None) + self.root = PdfDict(self.read_indirect(self.root_ref)) + if self.info_ref is None: + self.info = PdfDict() + else: + self.info = PdfDict(self.read_indirect(self.info_ref)) + check_format_condition(b"Type" in self.root, "/Type missing in Root") + check_format_condition( + self.root[b"Type"] == b"Catalog", "/Type in Root is not /Catalog" + ) + check_format_condition(b"Pages" in self.root, "/Pages missing in Root") + check_format_condition( + isinstance(self.root[b"Pages"], IndirectReference), + "/Pages in Root is not an indirect reference", + ) + self.pages_ref = self.root[b"Pages"] + self.page_tree_root = self.read_indirect(self.pages_ref) + self.pages = self.linearize_page_tree(self.page_tree_root) + # save the original list of page references + # in case the user modifies, adds or deletes some pages + # and we need to rewrite the pages and their list + self.orig_pages = self.pages[:] + + def next_object_id(self, offset=None): + try: + # TODO: support reuse of deleted objects + reference = IndirectReference(max(self.xref_table.keys()) + 1, 0) + except ValueError: + reference = IndirectReference(1, 0) + if offset is not None: + self.xref_table[reference.object_id] = (offset, 0) + return reference + + delimiter = rb"[][()<>{}/%]" + delimiter_or_ws = rb"[][()<>{}/%\000\011\012\014\015\040]" + whitespace = rb"[\000\011\012\014\015\040]" + whitespace_or_hex = rb"[\000\011\012\014\015\0400-9a-fA-F]" + whitespace_optional = whitespace + b"*" + whitespace_mandatory = whitespace + b"+" + # No "\012" aka "\n" or "\015" aka "\r": + whitespace_optional_no_nl = rb"[\000\011\014\040]*" + newline_only = rb"[\r\n]+" + newline = whitespace_optional_no_nl + newline_only + whitespace_optional_no_nl + re_trailer_end = re.compile( + whitespace_mandatory + + rb"trailer" + + whitespace_optional + + rb"<<(.*>>)" + + newline + + rb"startxref" + + newline + + rb"([0-9]+)" + + newline + + rb"%%EOF" + + whitespace_optional + + rb"$", + re.DOTALL, + ) + re_trailer_prev = re.compile( + whitespace_optional + + rb"trailer" + + whitespace_optional + + rb"<<(.*?>>)" + + newline + + rb"startxref" + + newline + + rb"([0-9]+)" + + newline + + rb"%%EOF" + + whitespace_optional, + re.DOTALL, + ) + + def read_trailer(self): + search_start_offset = len(self.buf) - 16384 + if search_start_offset < self.start_offset: + search_start_offset = self.start_offset + m = self.re_trailer_end.search(self.buf, search_start_offset) + check_format_condition(m, "trailer end not found") + # make sure we found the LAST trailer + last_match = m + while m: + last_match = m + m = self.re_trailer_end.search(self.buf, m.start() + 16) + if not m: + m = last_match + trailer_data = m.group(1) + self.last_xref_section_offset = int(m.group(2)) + self.trailer_dict = self.interpret_trailer(trailer_data) + self.xref_table = XrefTable() + self.read_xref_table(xref_section_offset=self.last_xref_section_offset) + if b"Prev" in self.trailer_dict: + self.read_prev_trailer(self.trailer_dict[b"Prev"]) + + def read_prev_trailer(self, xref_section_offset): + trailer_offset = self.read_xref_table(xref_section_offset=xref_section_offset) + m = self.re_trailer_prev.search( + self.buf[trailer_offset : trailer_offset + 16384] + ) + check_format_condition(m, "previous trailer not found") + trailer_data = m.group(1) + check_format_condition( + int(m.group(2)) == xref_section_offset, + "xref section offset in previous trailer doesn't match what was expected", + ) + trailer_dict = self.interpret_trailer(trailer_data) + if b"Prev" in trailer_dict: + self.read_prev_trailer(trailer_dict[b"Prev"]) + + re_whitespace_optional = re.compile(whitespace_optional) + re_name = re.compile( + whitespace_optional + + rb"/([!-$&'*-.0-;=?-Z\\^-z|~]+)(?=" + + delimiter_or_ws + + rb")" + ) + re_dict_start = re.compile(whitespace_optional + rb"<<") + re_dict_end = re.compile(whitespace_optional + rb">>" + whitespace_optional) + + @classmethod + def interpret_trailer(cls, trailer_data): + trailer = {} + offset = 0 + while True: + m = cls.re_name.match(trailer_data, offset) + if not m: + m = cls.re_dict_end.match(trailer_data, offset) + check_format_condition( + m and m.end() == len(trailer_data), + "name not found in trailer, remaining data: " + + repr(trailer_data[offset:]), + ) + break + key = cls.interpret_name(m.group(1)) + value, offset = cls.get_value(trailer_data, m.end()) + trailer[key] = value + check_format_condition( + b"Size" in trailer and isinstance(trailer[b"Size"], int), + "/Size not in trailer or not an integer", + ) + check_format_condition( + b"Root" in trailer and isinstance(trailer[b"Root"], IndirectReference), + "/Root not in trailer or not an indirect reference", + ) + return trailer + + re_hashes_in_name = re.compile(rb"([^#]*)(#([0-9a-fA-F]{2}))?") + + @classmethod + def interpret_name(cls, raw, as_text=False): + name = b"" + for m in cls.re_hashes_in_name.finditer(raw): + if m.group(3): + name += m.group(1) + bytearray.fromhex(m.group(3).decode("us-ascii")) + else: + name += m.group(1) + if as_text: + return name.decode("utf-8") + else: + return bytes(name) + + re_null = re.compile(whitespace_optional + rb"null(?=" + delimiter_or_ws + rb")") + re_true = re.compile(whitespace_optional + rb"true(?=" + delimiter_or_ws + rb")") + re_false = re.compile(whitespace_optional + rb"false(?=" + delimiter_or_ws + rb")") + re_int = re.compile( + whitespace_optional + rb"([-+]?[0-9]+)(?=" + delimiter_or_ws + rb")" + ) + re_real = re.compile( + whitespace_optional + + rb"([-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+))(?=" + + delimiter_or_ws + + rb")" + ) + re_array_start = re.compile(whitespace_optional + rb"\[") + re_array_end = re.compile(whitespace_optional + rb"]") + re_string_hex = re.compile( + whitespace_optional + rb"<(" + whitespace_or_hex + rb"*)>" + ) + re_string_lit = re.compile(whitespace_optional + rb"\(") + re_indirect_reference = re.compile( + whitespace_optional + + rb"([-+]?[0-9]+)" + + whitespace_mandatory + + rb"([-+]?[0-9]+)" + + whitespace_mandatory + + rb"R(?=" + + delimiter_or_ws + + rb")" + ) + re_indirect_def_start = re.compile( + whitespace_optional + + rb"([-+]?[0-9]+)" + + whitespace_mandatory + + rb"([-+]?[0-9]+)" + + whitespace_mandatory + + rb"obj(?=" + + delimiter_or_ws + + rb")" + ) + re_indirect_def_end = re.compile( + whitespace_optional + rb"endobj(?=" + delimiter_or_ws + rb")" + ) + re_comment = re.compile( + rb"(" + whitespace_optional + rb"%[^\r\n]*" + newline + rb")*" + ) + re_stream_start = re.compile(whitespace_optional + rb"stream\r?\n") + re_stream_end = re.compile( + whitespace_optional + rb"endstream(?=" + delimiter_or_ws + rb")" + ) + + @classmethod + def get_value(cls, data, offset, expect_indirect=None, max_nesting=-1): + if max_nesting == 0: + return None, None + m = cls.re_comment.match(data, offset) + if m: + offset = m.end() + m = cls.re_indirect_def_start.match(data, offset) + if m: + check_format_condition( + int(m.group(1)) > 0, + "indirect object definition: object ID must be greater than 0", + ) + check_format_condition( + int(m.group(2)) >= 0, + "indirect object definition: generation must be non-negative", + ) + check_format_condition( + expect_indirect is None + or expect_indirect + == IndirectReference(int(m.group(1)), int(m.group(2))), + "indirect object definition different than expected", + ) + object, offset = cls.get_value(data, m.end(), max_nesting=max_nesting - 1) + if offset is None: + return object, None + m = cls.re_indirect_def_end.match(data, offset) + check_format_condition(m, "indirect object definition end not found") + return object, m.end() + check_format_condition( + not expect_indirect, "indirect object definition not found" + ) + m = cls.re_indirect_reference.match(data, offset) + if m: + check_format_condition( + int(m.group(1)) > 0, + "indirect object reference: object ID must be greater than 0", + ) + check_format_condition( + int(m.group(2)) >= 0, + "indirect object reference: generation must be non-negative", + ) + return IndirectReference(int(m.group(1)), int(m.group(2))), m.end() + m = cls.re_dict_start.match(data, offset) + if m: + offset = m.end() + result = {} + m = cls.re_dict_end.match(data, offset) + while not m: + key, offset = cls.get_value(data, offset, max_nesting=max_nesting - 1) + if offset is None: + return result, None + value, offset = cls.get_value(data, offset, max_nesting=max_nesting - 1) + result[key] = value + if offset is None: + return result, None + m = cls.re_dict_end.match(data, offset) + offset = m.end() + m = cls.re_stream_start.match(data, offset) + if m: + try: + stream_len = int(result[b"Length"]) + except (TypeError, KeyError, ValueError) as e: + msg = "bad or missing Length in stream dict (%r)" % result.get( + b"Length", None + ) + raise PdfFormatError(msg) from e + stream_data = data[m.end() : m.end() + stream_len] + m = cls.re_stream_end.match(data, m.end() + stream_len) + check_format_condition(m, "stream end not found") + offset = m.end() + result = PdfStream(PdfDict(result), stream_data) + else: + result = PdfDict(result) + return result, offset + m = cls.re_array_start.match(data, offset) + if m: + offset = m.end() + result = [] + m = cls.re_array_end.match(data, offset) + while not m: + value, offset = cls.get_value(data, offset, max_nesting=max_nesting - 1) + result.append(value) + if offset is None: + return result, None + m = cls.re_array_end.match(data, offset) + return result, m.end() + m = cls.re_null.match(data, offset) + if m: + return None, m.end() + m = cls.re_true.match(data, offset) + if m: + return True, m.end() + m = cls.re_false.match(data, offset) + if m: + return False, m.end() + m = cls.re_name.match(data, offset) + if m: + return PdfName(cls.interpret_name(m.group(1))), m.end() + m = cls.re_int.match(data, offset) + if m: + return int(m.group(1)), m.end() + m = cls.re_real.match(data, offset) + if m: + # XXX Decimal instead of float??? + return float(m.group(1)), m.end() + m = cls.re_string_hex.match(data, offset) + if m: + # filter out whitespace + hex_string = bytearray( + b for b in m.group(1) if b in b"0123456789abcdefABCDEF" + ) + if len(hex_string) % 2 == 1: + # append a 0 if the length is not even - yes, at the end + hex_string.append(ord(b"0")) + return bytearray.fromhex(hex_string.decode("us-ascii")), m.end() + m = cls.re_string_lit.match(data, offset) + if m: + return cls.get_literal_string(data, m.end()) + # return None, offset # fallback (only for debugging) + msg = "unrecognized object: " + repr(data[offset : offset + 32]) + raise PdfFormatError(msg) + + re_lit_str_token = re.compile( + rb"(\\[nrtbf()\\])|(\\[0-9]{1,3})|(\\(\r\n|\r|\n))|(\r\n|\r|\n)|(\()|(\))" + ) + escaped_chars = { + b"n": b"\n", + b"r": b"\r", + b"t": b"\t", + b"b": b"\b", + b"f": b"\f", + b"(": b"(", + b")": b")", + b"\\": b"\\", + ord(b"n"): b"\n", + ord(b"r"): b"\r", + ord(b"t"): b"\t", + ord(b"b"): b"\b", + ord(b"f"): b"\f", + ord(b"("): b"(", + ord(b")"): b")", + ord(b"\\"): b"\\", + } + + @classmethod + def get_literal_string(cls, data, offset): + nesting_depth = 0 + result = bytearray() + for m in cls.re_lit_str_token.finditer(data, offset): + result.extend(data[offset : m.start()]) + if m.group(1): + result.extend(cls.escaped_chars[m.group(1)[1]]) + elif m.group(2): + result.append(int(m.group(2)[1:], 8)) + elif m.group(3): + pass + elif m.group(5): + result.extend(b"\n") + elif m.group(6): + result.extend(b"(") + nesting_depth += 1 + elif m.group(7): + if nesting_depth == 0: + return bytes(result), m.end() + result.extend(b")") + nesting_depth -= 1 + offset = m.end() + msg = "unfinished literal string" + raise PdfFormatError(msg) + + re_xref_section_start = re.compile(whitespace_optional + rb"xref" + newline) + re_xref_subsection_start = re.compile( + whitespace_optional + + rb"([0-9]+)" + + whitespace_mandatory + + rb"([0-9]+)" + + whitespace_optional + + newline_only + ) + re_xref_entry = re.compile(rb"([0-9]{10}) ([0-9]{5}) ([fn])( \r| \n|\r\n)") + + def read_xref_table(self, xref_section_offset): + subsection_found = False + m = self.re_xref_section_start.match( + self.buf, xref_section_offset + self.start_offset + ) + check_format_condition(m, "xref section start not found") + offset = m.end() + while True: + m = self.re_xref_subsection_start.match(self.buf, offset) + if not m: + check_format_condition( + subsection_found, "xref subsection start not found" + ) + break + subsection_found = True + offset = m.end() + first_object = int(m.group(1)) + num_objects = int(m.group(2)) + for i in range(first_object, first_object + num_objects): + m = self.re_xref_entry.match(self.buf, offset) + check_format_condition(m, "xref entry not found") + offset = m.end() + is_free = m.group(3) == b"f" + if not is_free: + generation = int(m.group(2)) + new_entry = (int(m.group(1)), generation) + if i not in self.xref_table: + self.xref_table[i] = new_entry + return offset + + def read_indirect(self, ref, max_nesting=-1): + offset, generation = self.xref_table[ref[0]] + check_format_condition( + generation == ref[1], + f"expected to find generation {ref[1]} for object ID {ref[0]} in xref " + f"table, instead found generation {generation} at offset {offset}", + ) + value = self.get_value( + self.buf, + offset + self.start_offset, + expect_indirect=IndirectReference(*ref), + max_nesting=max_nesting, + )[0] + self.cached_objects[ref] = value + return value + + def linearize_page_tree(self, node=None): + if node is None: + node = self.page_tree_root + check_format_condition( + node[b"Type"] == b"Pages", "/Type of page tree node is not /Pages" + ) + pages = [] + for kid in node[b"Kids"]: + kid_object = self.read_indirect(kid) + if kid_object[b"Type"] == b"Page": + pages.append(kid) + else: + pages.extend(self.linearize_page_tree(node=kid_object)) + return pages diff --git a/venv/lib/python3.10/site-packages/PIL/PixarImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PixarImagePlugin.py new file mode 100644 index 00000000..887b6568 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PixarImagePlugin.py @@ -0,0 +1,72 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PIXAR raster support for PIL +# +# history: +# 97-01-29 fl Created +# +# notes: +# This is incomplete; it is based on a few samples created with +# Photoshop 2.5 and 3.0, and a summary description provided by +# Greg Coats . Hopefully, "L" and +# "RGBA" support will be added in future versions. +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1997. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile +from ._binary import i16le as i16 + +# +# helpers + + +def _accept(prefix: bytes) -> bool: + return prefix[:4] == b"\200\350\000\000" + + +## +# Image plugin for PIXAR raster images. + + +class PixarImageFile(ImageFile.ImageFile): + format = "PIXAR" + format_description = "PIXAR raster image" + + def _open(self) -> None: + # assuming a 4-byte magic label + assert self.fp is not None + + s = self.fp.read(4) + if not _accept(s): + msg = "not a PIXAR file" + raise SyntaxError(msg) + + # read rest of header + s = s + self.fp.read(508) + + self._size = i16(s, 418), i16(s, 416) + + # get channel/depth descriptions + mode = i16(s, 424), i16(s, 426) + + if mode == (14, 2): + self._mode = "RGB" + # FIXME: to be continued... + + # create tile descriptor (assuming "dumped") + self.tile = [("raw", (0, 0) + self.size, 1024, (self.mode, 0, 1))] + + +# +# -------------------------------------------------------------------- + +Image.register_open(PixarImageFile.format, PixarImageFile, _accept) + +Image.register_extension(PixarImageFile.format, ".pxr") diff --git a/venv/lib/python3.10/site-packages/PIL/PngImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PngImagePlugin.py new file mode 100644 index 00000000..d922bacf --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PngImagePlugin.py @@ -0,0 +1,1470 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PNG support code +# +# See "PNG (Portable Network Graphics) Specification, version 1.0; +# W3C Recommendation", 1996-10-01, Thomas Boutell (ed.). +# +# history: +# 1996-05-06 fl Created (couldn't resist it) +# 1996-12-14 fl Upgraded, added read and verify support (0.2) +# 1996-12-15 fl Separate PNG stream parser +# 1996-12-29 fl Added write support, added getchunks +# 1996-12-30 fl Eliminated circular references in decoder (0.3) +# 1998-07-12 fl Read/write 16-bit images as mode I (0.4) +# 2001-02-08 fl Added transparency support (from Zircon) (0.5) +# 2001-04-16 fl Don't close data source in "open" method (0.6) +# 2004-02-24 fl Don't even pretend to support interlaced files (0.7) +# 2004-08-31 fl Do basic sanity check on chunk identifiers (0.8) +# 2004-09-20 fl Added PngInfo chunk container +# 2004-12-18 fl Added DPI read support (based on code by Niki Spahiev) +# 2008-08-13 fl Added tRNS support for RGB images +# 2009-03-06 fl Support for preserving ICC profiles (by Florian Hoech) +# 2009-03-08 fl Added zTXT support (from Lowell Alleman) +# 2009-03-29 fl Read interlaced PNG files (from Conrado Porto Lopes Gouvua) +# +# Copyright (c) 1997-2009 by Secret Labs AB +# Copyright (c) 1996 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import itertools +import logging +import re +import struct +import warnings +import zlib +from enum import IntEnum + +from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 +from ._binary import o16be as o16 +from ._binary import o32be as o32 + +logger = logging.getLogger(__name__) + +is_cid = re.compile(rb"\w\w\w\w").match + + +_MAGIC = b"\211PNG\r\n\032\n" + + +_MODES = { + # supported bits/color combinations, and corresponding modes/rawmodes + # Grayscale + (1, 0): ("1", "1"), + (2, 0): ("L", "L;2"), + (4, 0): ("L", "L;4"), + (8, 0): ("L", "L"), + (16, 0): ("I;16", "I;16B"), + # Truecolour + (8, 2): ("RGB", "RGB"), + (16, 2): ("RGB", "RGB;16B"), + # Indexed-colour + (1, 3): ("P", "P;1"), + (2, 3): ("P", "P;2"), + (4, 3): ("P", "P;4"), + (8, 3): ("P", "P"), + # Grayscale with alpha + (8, 4): ("LA", "LA"), + (16, 4): ("RGBA", "LA;16B"), # LA;16B->LA not yet available + # Truecolour with alpha + (8, 6): ("RGBA", "RGBA"), + (16, 6): ("RGBA", "RGBA;16B"), +} + + +_simple_palette = re.compile(b"^\xff*\x00\xff*$") + +MAX_TEXT_CHUNK = ImageFile.SAFEBLOCK +""" +Maximum decompressed size for a iTXt or zTXt chunk. +Eliminates decompression bombs where compressed chunks can expand 1000x. +See :ref:`Text in PNG File Format`. +""" +MAX_TEXT_MEMORY = 64 * MAX_TEXT_CHUNK +""" +Set the maximum total text chunk size. +See :ref:`Text in PNG File Format`. +""" + + +# APNG frame disposal modes +class Disposal(IntEnum): + OP_NONE = 0 + """ + No disposal is done on this frame before rendering the next frame. + See :ref:`Saving APNG sequences`. + """ + OP_BACKGROUND = 1 + """ + This frame’s modified region is cleared to fully transparent black before rendering + the next frame. + See :ref:`Saving APNG sequences`. + """ + OP_PREVIOUS = 2 + """ + This frame’s modified region is reverted to the previous frame’s contents before + rendering the next frame. + See :ref:`Saving APNG sequences`. + """ + + +# APNG frame blend modes +class Blend(IntEnum): + OP_SOURCE = 0 + """ + All color components of this frame, including alpha, overwrite the previous output + image contents. + See :ref:`Saving APNG sequences`. + """ + OP_OVER = 1 + """ + This frame should be alpha composited with the previous output image contents. + See :ref:`Saving APNG sequences`. + """ + + +def _safe_zlib_decompress(s): + dobj = zlib.decompressobj() + plaintext = dobj.decompress(s, MAX_TEXT_CHUNK) + if dobj.unconsumed_tail: + msg = "Decompressed Data Too Large" + raise ValueError(msg) + return plaintext + + +def _crc32(data, seed=0): + return zlib.crc32(data, seed) & 0xFFFFFFFF + + +# -------------------------------------------------------------------- +# Support classes. Suitable for PNG and related formats like MNG etc. + + +class ChunkStream: + def __init__(self, fp): + self.fp = fp + self.queue = [] + + def read(self): + """Fetch a new chunk. Returns header information.""" + cid = None + + if self.queue: + cid, pos, length = self.queue.pop() + self.fp.seek(pos) + else: + s = self.fp.read(8) + cid = s[4:] + pos = self.fp.tell() + length = i32(s) + + if not is_cid(cid): + if not ImageFile.LOAD_TRUNCATED_IMAGES: + msg = f"broken PNG file (chunk {repr(cid)})" + raise SyntaxError(msg) + + return cid, pos, length + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def close(self): + self.queue = self.fp = None + + def push(self, cid, pos, length): + self.queue.append((cid, pos, length)) + + def call(self, cid, pos, length): + """Call the appropriate chunk handler""" + + logger.debug("STREAM %r %s %s", cid, pos, length) + return getattr(self, "chunk_" + cid.decode("ascii"))(pos, length) + + def crc(self, cid, data): + """Read and verify checksum""" + + # Skip CRC checks for ancillary chunks if allowed to load truncated + # images + # 5th byte of first char is 1 [specs, section 5.4] + if ImageFile.LOAD_TRUNCATED_IMAGES and (cid[0] >> 5 & 1): + self.crc_skip(cid, data) + return + + try: + crc1 = _crc32(data, _crc32(cid)) + crc2 = i32(self.fp.read(4)) + if crc1 != crc2: + msg = f"broken PNG file (bad header checksum in {repr(cid)})" + raise SyntaxError(msg) + except struct.error as e: + msg = f"broken PNG file (incomplete checksum in {repr(cid)})" + raise SyntaxError(msg) from e + + def crc_skip(self, cid, data): + """Read checksum""" + + self.fp.read(4) + + def verify(self, endchunk=b"IEND"): + # Simple approach; just calculate checksum for all remaining + # blocks. Must be called directly after open. + + cids = [] + + while True: + try: + cid, pos, length = self.read() + except struct.error as e: + msg = "truncated PNG file" + raise OSError(msg) from e + + if cid == endchunk: + break + self.crc(cid, ImageFile._safe_read(self.fp, length)) + cids.append(cid) + + return cids + + +class iTXt(str): + """ + Subclass of string to allow iTXt chunks to look like strings while + keeping their extra information + + """ + + @staticmethod + def __new__(cls, text, lang=None, tkey=None): + """ + :param cls: the class to use when creating the instance + :param text: value for this key + :param lang: language code + :param tkey: UTF-8 version of the key name + """ + + self = str.__new__(cls, text) + self.lang = lang + self.tkey = tkey + return self + + +class PngInfo: + """ + PNG chunk container (for use with save(pnginfo=)) + + """ + + def __init__(self): + self.chunks = [] + + def add(self, cid, data, after_idat=False): + """Appends an arbitrary chunk. Use with caution. + + :param cid: a byte string, 4 bytes long. + :param data: a byte string of the encoded data + :param after_idat: for use with private chunks. Whether the chunk + should be written after IDAT + + """ + + chunk = [cid, data] + if after_idat: + chunk.append(True) + self.chunks.append(tuple(chunk)) + + def add_itxt(self, key, value, lang="", tkey="", zip=False): + """Appends an iTXt chunk. + + :param key: latin-1 encodable text key name + :param value: value for this key + :param lang: language code + :param tkey: UTF-8 version of the key name + :param zip: compression flag + + """ + + if not isinstance(key, bytes): + key = key.encode("latin-1", "strict") + if not isinstance(value, bytes): + value = value.encode("utf-8", "strict") + if not isinstance(lang, bytes): + lang = lang.encode("utf-8", "strict") + if not isinstance(tkey, bytes): + tkey = tkey.encode("utf-8", "strict") + + if zip: + self.add( + b"iTXt", + key + b"\0\x01\0" + lang + b"\0" + tkey + b"\0" + zlib.compress(value), + ) + else: + self.add(b"iTXt", key + b"\0\0\0" + lang + b"\0" + tkey + b"\0" + value) + + def add_text(self, key, value, zip=False): + """Appends a text chunk. + + :param key: latin-1 encodable text key name + :param value: value for this key, text or an + :py:class:`PIL.PngImagePlugin.iTXt` instance + :param zip: compression flag + + """ + if isinstance(value, iTXt): + return self.add_itxt(key, value, value.lang, value.tkey, zip=zip) + + # The tEXt chunk stores latin-1 text + if not isinstance(value, bytes): + try: + value = value.encode("latin-1", "strict") + except UnicodeError: + return self.add_itxt(key, value, zip=zip) + + if not isinstance(key, bytes): + key = key.encode("latin-1", "strict") + + if zip: + self.add(b"zTXt", key + b"\0\0" + zlib.compress(value)) + else: + self.add(b"tEXt", key + b"\0" + value) + + +# -------------------------------------------------------------------- +# PNG image stream (IHDR/IEND) + + +class PngStream(ChunkStream): + def __init__(self, fp): + super().__init__(fp) + + # local copies of Image attributes + self.im_info = {} + self.im_text = {} + self.im_size = (0, 0) + self.im_mode = None + self.im_tile = None + self.im_palette = None + self.im_custom_mimetype = None + self.im_n_frames = None + self._seq_num = None + self.rewind_state = None + + self.text_memory = 0 + + def check_text_memory(self, chunklen): + self.text_memory += chunklen + if self.text_memory > MAX_TEXT_MEMORY: + msg = ( + "Too much memory used in text chunks: " + f"{self.text_memory}>MAX_TEXT_MEMORY" + ) + raise ValueError(msg) + + def save_rewind(self): + self.rewind_state = { + "info": self.im_info.copy(), + "tile": self.im_tile, + "seq_num": self._seq_num, + } + + def rewind(self): + self.im_info = self.rewind_state["info"].copy() + self.im_tile = self.rewind_state["tile"] + self._seq_num = self.rewind_state["seq_num"] + + def chunk_iCCP(self, pos, length): + # ICC profile + s = ImageFile._safe_read(self.fp, length) + # according to PNG spec, the iCCP chunk contains: + # Profile name 1-79 bytes (character string) + # Null separator 1 byte (null character) + # Compression method 1 byte (0) + # Compressed profile n bytes (zlib with deflate compression) + i = s.find(b"\0") + logger.debug("iCCP profile name %r", s[:i]) + comp_method = s[i + 1] + logger.debug("Compression method %s", comp_method) + if comp_method != 0: + msg = f"Unknown compression method {comp_method} in iCCP chunk" + raise SyntaxError(msg) + try: + icc_profile = _safe_zlib_decompress(s[i + 2 :]) + except ValueError: + if ImageFile.LOAD_TRUNCATED_IMAGES: + icc_profile = None + else: + raise + except zlib.error: + icc_profile = None # FIXME + self.im_info["icc_profile"] = icc_profile + return s + + def chunk_IHDR(self, pos, length): + # image header + s = ImageFile._safe_read(self.fp, length) + if length < 13: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + msg = "Truncated IHDR chunk" + raise ValueError(msg) + self.im_size = i32(s, 0), i32(s, 4) + try: + self.im_mode, self.im_rawmode = _MODES[(s[8], s[9])] + except Exception: + pass + if s[12]: + self.im_info["interlace"] = 1 + if s[11]: + msg = "unknown filter category" + raise SyntaxError(msg) + return s + + def chunk_IDAT(self, pos, length): + # image data + if "bbox" in self.im_info: + tile = [("zip", self.im_info["bbox"], pos, self.im_rawmode)] + else: + if self.im_n_frames is not None: + self.im_info["default_image"] = True + tile = [("zip", (0, 0) + self.im_size, pos, self.im_rawmode)] + self.im_tile = tile + self.im_idat = length + msg = "image data found" + raise EOFError(msg) + + def chunk_IEND(self, pos, length): + msg = "end of PNG image" + raise EOFError(msg) + + def chunk_PLTE(self, pos, length): + # palette + s = ImageFile._safe_read(self.fp, length) + if self.im_mode == "P": + self.im_palette = "RGB", s + return s + + def chunk_tRNS(self, pos, length): + # transparency + s = ImageFile._safe_read(self.fp, length) + if self.im_mode == "P": + if _simple_palette.match(s): + # tRNS contains only one full-transparent entry, + # other entries are full opaque + i = s.find(b"\0") + if i >= 0: + self.im_info["transparency"] = i + else: + # otherwise, we have a byte string with one alpha value + # for each palette entry + self.im_info["transparency"] = s + elif self.im_mode in ("1", "L", "I;16"): + self.im_info["transparency"] = i16(s) + elif self.im_mode == "RGB": + self.im_info["transparency"] = i16(s), i16(s, 2), i16(s, 4) + return s + + def chunk_gAMA(self, pos, length): + # gamma setting + s = ImageFile._safe_read(self.fp, length) + self.im_info["gamma"] = i32(s) / 100000.0 + return s + + def chunk_cHRM(self, pos, length): + # chromaticity, 8 unsigned ints, actual value is scaled by 100,000 + # WP x,y, Red x,y, Green x,y Blue x,y + + s = ImageFile._safe_read(self.fp, length) + raw_vals = struct.unpack(">%dI" % (len(s) // 4), s) + self.im_info["chromaticity"] = tuple(elt / 100000.0 for elt in raw_vals) + return s + + def chunk_sRGB(self, pos, length): + # srgb rendering intent, 1 byte + # 0 perceptual + # 1 relative colorimetric + # 2 saturation + # 3 absolute colorimetric + + s = ImageFile._safe_read(self.fp, length) + if length < 1: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + msg = "Truncated sRGB chunk" + raise ValueError(msg) + self.im_info["srgb"] = s[0] + return s + + def chunk_pHYs(self, pos, length): + # pixels per unit + s = ImageFile._safe_read(self.fp, length) + if length < 9: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + msg = "Truncated pHYs chunk" + raise ValueError(msg) + px, py = i32(s, 0), i32(s, 4) + unit = s[8] + if unit == 1: # meter + dpi = px * 0.0254, py * 0.0254 + self.im_info["dpi"] = dpi + elif unit == 0: + self.im_info["aspect"] = px, py + return s + + def chunk_tEXt(self, pos, length): + # text + s = ImageFile._safe_read(self.fp, length) + try: + k, v = s.split(b"\0", 1) + except ValueError: + # fallback for broken tEXt tags + k = s + v = b"" + if k: + k = k.decode("latin-1", "strict") + v_str = v.decode("latin-1", "replace") + + self.im_info[k] = v if k == "exif" else v_str + self.im_text[k] = v_str + self.check_text_memory(len(v_str)) + + return s + + def chunk_zTXt(self, pos, length): + # compressed text + s = ImageFile._safe_read(self.fp, length) + try: + k, v = s.split(b"\0", 1) + except ValueError: + k = s + v = b"" + if v: + comp_method = v[0] + else: + comp_method = 0 + if comp_method != 0: + msg = f"Unknown compression method {comp_method} in zTXt chunk" + raise SyntaxError(msg) + try: + v = _safe_zlib_decompress(v[1:]) + except ValueError: + if ImageFile.LOAD_TRUNCATED_IMAGES: + v = b"" + else: + raise + except zlib.error: + v = b"" + + if k: + k = k.decode("latin-1", "strict") + v = v.decode("latin-1", "replace") + + self.im_info[k] = self.im_text[k] = v + self.check_text_memory(len(v)) + + return s + + def chunk_iTXt(self, pos, length): + # international text + r = s = ImageFile._safe_read(self.fp, length) + try: + k, r = r.split(b"\0", 1) + except ValueError: + return s + if len(r) < 2: + return s + cf, cm, r = r[0], r[1], r[2:] + try: + lang, tk, v = r.split(b"\0", 2) + except ValueError: + return s + if cf != 0: + if cm == 0: + try: + v = _safe_zlib_decompress(v) + except ValueError: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + else: + raise + except zlib.error: + return s + else: + return s + try: + k = k.decode("latin-1", "strict") + lang = lang.decode("utf-8", "strict") + tk = tk.decode("utf-8", "strict") + v = v.decode("utf-8", "strict") + except UnicodeError: + return s + + self.im_info[k] = self.im_text[k] = iTXt(v, lang, tk) + self.check_text_memory(len(v)) + + return s + + def chunk_eXIf(self, pos, length): + s = ImageFile._safe_read(self.fp, length) + self.im_info["exif"] = b"Exif\x00\x00" + s + return s + + # APNG chunks + def chunk_acTL(self, pos, length): + s = ImageFile._safe_read(self.fp, length) + if length < 8: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + msg = "APNG contains truncated acTL chunk" + raise ValueError(msg) + if self.im_n_frames is not None: + self.im_n_frames = None + warnings.warn("Invalid APNG, will use default PNG image if possible") + return s + n_frames = i32(s) + if n_frames == 0 or n_frames > 0x80000000: + warnings.warn("Invalid APNG, will use default PNG image if possible") + return s + self.im_n_frames = n_frames + self.im_info["loop"] = i32(s, 4) + self.im_custom_mimetype = "image/apng" + return s + + def chunk_fcTL(self, pos, length): + s = ImageFile._safe_read(self.fp, length) + if length < 26: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + msg = "APNG contains truncated fcTL chunk" + raise ValueError(msg) + seq = i32(s) + if (self._seq_num is None and seq != 0) or ( + self._seq_num is not None and self._seq_num != seq - 1 + ): + msg = "APNG contains frame sequence errors" + raise SyntaxError(msg) + self._seq_num = seq + width, height = i32(s, 4), i32(s, 8) + px, py = i32(s, 12), i32(s, 16) + im_w, im_h = self.im_size + if px + width > im_w or py + height > im_h: + msg = "APNG contains invalid frames" + raise SyntaxError(msg) + self.im_info["bbox"] = (px, py, px + width, py + height) + delay_num, delay_den = i16(s, 20), i16(s, 22) + if delay_den == 0: + delay_den = 100 + self.im_info["duration"] = float(delay_num) / float(delay_den) * 1000 + self.im_info["disposal"] = s[24] + self.im_info["blend"] = s[25] + return s + + def chunk_fdAT(self, pos, length): + if length < 4: + if ImageFile.LOAD_TRUNCATED_IMAGES: + s = ImageFile._safe_read(self.fp, length) + return s + msg = "APNG contains truncated fDAT chunk" + raise ValueError(msg) + s = ImageFile._safe_read(self.fp, 4) + seq = i32(s) + if self._seq_num != seq - 1: + msg = "APNG contains frame sequence errors" + raise SyntaxError(msg) + self._seq_num = seq + return self.chunk_IDAT(pos + 4, length - 4) + + +# -------------------------------------------------------------------- +# PNG reader + + +def _accept(prefix): + return prefix[:8] == _MAGIC + + +## +# Image plugin for PNG images. + + +class PngImageFile(ImageFile.ImageFile): + format = "PNG" + format_description = "Portable network graphics" + + def _open(self): + if not _accept(self.fp.read(8)): + msg = "not a PNG file" + raise SyntaxError(msg) + self._fp = self.fp + self.__frame = 0 + + # + # Parse headers up to the first IDAT or fDAT chunk + + self.private_chunks = [] + self.png = PngStream(self.fp) + + while True: + # + # get next chunk + + cid, pos, length = self.png.read() + + try: + s = self.png.call(cid, pos, length) + except EOFError: + break + except AttributeError: + logger.debug("%r %s %s (unknown)", cid, pos, length) + s = ImageFile._safe_read(self.fp, length) + if cid[1:2].islower(): + self.private_chunks.append((cid, s)) + + self.png.crc(cid, s) + + # + # Copy relevant attributes from the PngStream. An alternative + # would be to let the PngStream class modify these attributes + # directly, but that introduces circular references which are + # difficult to break if things go wrong in the decoder... + # (believe me, I've tried ;-) + + self._mode = self.png.im_mode + self._size = self.png.im_size + self.info = self.png.im_info + self._text = None + self.tile = self.png.im_tile + self.custom_mimetype = self.png.im_custom_mimetype + self.n_frames = self.png.im_n_frames or 1 + self.default_image = self.info.get("default_image", False) + + if self.png.im_palette: + rawmode, data = self.png.im_palette + self.palette = ImagePalette.raw(rawmode, data) + + if cid == b"fdAT": + self.__prepare_idat = length - 4 + else: + self.__prepare_idat = length # used by load_prepare() + + if self.png.im_n_frames is not None: + self._close_exclusive_fp_after_loading = False + self.png.save_rewind() + self.__rewind_idat = self.__prepare_idat + self.__rewind = self._fp.tell() + if self.default_image: + # IDAT chunk contains default image and not first animation frame + self.n_frames += 1 + self._seek(0) + self.is_animated = self.n_frames > 1 + + @property + def text(self): + # experimental + if self._text is None: + # iTxt, tEXt and zTXt chunks may appear at the end of the file + # So load the file to ensure that they are read + if self.is_animated: + frame = self.__frame + # for APNG, seek to the final frame before loading + self.seek(self.n_frames - 1) + self.load() + if self.is_animated: + self.seek(frame) + return self._text + + def verify(self): + """Verify PNG file""" + + if self.fp is None: + msg = "verify must be called directly after open" + raise RuntimeError(msg) + + # back up to beginning of IDAT block + self.fp.seek(self.tile[0][2] - 8) + + self.png.verify() + self.png.close() + + if self._exclusive_fp: + self.fp.close() + self.fp = None + + def seek(self, frame): + if not self._seek_check(frame): + return + if frame < self.__frame: + self._seek(0, True) + + last_frame = self.__frame + for f in range(self.__frame + 1, frame + 1): + try: + self._seek(f) + except EOFError as e: + self.seek(last_frame) + msg = "no more images in APNG file" + raise EOFError(msg) from e + + def _seek(self, frame, rewind=False): + if frame == 0: + if rewind: + self._fp.seek(self.__rewind) + self.png.rewind() + self.__prepare_idat = self.__rewind_idat + self.im = None + if self.pyaccess: + self.pyaccess = None + self.info = self.png.im_info + self.tile = self.png.im_tile + self.fp = self._fp + self._prev_im = None + self.dispose = None + self.default_image = self.info.get("default_image", False) + self.dispose_op = self.info.get("disposal") + self.blend_op = self.info.get("blend") + self.dispose_extent = self.info.get("bbox") + self.__frame = 0 + else: + if frame != self.__frame + 1: + msg = f"cannot seek to frame {frame}" + raise ValueError(msg) + + # ensure previous frame was loaded + self.load() + + if self.dispose: + self.im.paste(self.dispose, self.dispose_extent) + self._prev_im = self.im.copy() + + self.fp = self._fp + + # advance to the next frame + if self.__prepare_idat: + ImageFile._safe_read(self.fp, self.__prepare_idat) + self.__prepare_idat = 0 + frame_start = False + while True: + self.fp.read(4) # CRC + + try: + cid, pos, length = self.png.read() + except (struct.error, SyntaxError): + break + + if cid == b"IEND": + msg = "No more images in APNG file" + raise EOFError(msg) + if cid == b"fcTL": + if frame_start: + # there must be at least one fdAT chunk between fcTL chunks + msg = "APNG missing frame data" + raise SyntaxError(msg) + frame_start = True + + try: + self.png.call(cid, pos, length) + except UnicodeDecodeError: + break + except EOFError: + if cid == b"fdAT": + length -= 4 + if frame_start: + self.__prepare_idat = length + break + ImageFile._safe_read(self.fp, length) + except AttributeError: + logger.debug("%r %s %s (unknown)", cid, pos, length) + ImageFile._safe_read(self.fp, length) + + self.__frame = frame + self.tile = self.png.im_tile + self.dispose_op = self.info.get("disposal") + self.blend_op = self.info.get("blend") + self.dispose_extent = self.info.get("bbox") + + if not self.tile: + msg = "image not found in APNG frame" + raise EOFError(msg) + + # setup frame disposal (actual disposal done when needed in the next _seek()) + if self._prev_im is None and self.dispose_op == Disposal.OP_PREVIOUS: + self.dispose_op = Disposal.OP_BACKGROUND + + if self.dispose_op == Disposal.OP_PREVIOUS: + self.dispose = self._prev_im.copy() + self.dispose = self._crop(self.dispose, self.dispose_extent) + elif self.dispose_op == Disposal.OP_BACKGROUND: + self.dispose = Image.core.fill(self.mode, self.size) + self.dispose = self._crop(self.dispose, self.dispose_extent) + else: + self.dispose = None + + def tell(self): + return self.__frame + + def load_prepare(self): + """internal: prepare to read PNG file""" + + if self.info.get("interlace"): + self.decoderconfig = self.decoderconfig + (1,) + + self.__idat = self.__prepare_idat # used by load_read() + ImageFile.ImageFile.load_prepare(self) + + def load_read(self, read_bytes): + """internal: read more image data""" + + while self.__idat == 0: + # end of chunk, skip forward to next one + + self.fp.read(4) # CRC + + cid, pos, length = self.png.read() + + if cid not in [b"IDAT", b"DDAT", b"fdAT"]: + self.png.push(cid, pos, length) + return b"" + + if cid == b"fdAT": + try: + self.png.call(cid, pos, length) + except EOFError: + pass + self.__idat = length - 4 # sequence_num has already been read + else: + self.__idat = length # empty chunks are allowed + + # read more data from this chunk + if read_bytes <= 0: + read_bytes = self.__idat + else: + read_bytes = min(read_bytes, self.__idat) + + self.__idat = self.__idat - read_bytes + + return self.fp.read(read_bytes) + + def load_end(self): + """internal: finished reading image data""" + if self.__idat != 0: + self.fp.read(self.__idat) + while True: + self.fp.read(4) # CRC + + try: + cid, pos, length = self.png.read() + except (struct.error, SyntaxError): + break + + if cid == b"IEND": + break + elif cid == b"fcTL" and self.is_animated: + # start of the next frame, stop reading + self.__prepare_idat = 0 + self.png.push(cid, pos, length) + break + + try: + self.png.call(cid, pos, length) + except UnicodeDecodeError: + break + except EOFError: + if cid == b"fdAT": + length -= 4 + try: + ImageFile._safe_read(self.fp, length) + except OSError as e: + if ImageFile.LOAD_TRUNCATED_IMAGES: + break + else: + raise e + except AttributeError: + logger.debug("%r %s %s (unknown)", cid, pos, length) + s = ImageFile._safe_read(self.fp, length) + if cid[1:2].islower(): + self.private_chunks.append((cid, s, True)) + self._text = self.png.im_text + if not self.is_animated: + self.png.close() + self.png = None + else: + if self._prev_im and self.blend_op == Blend.OP_OVER: + updated = self._crop(self.im, self.dispose_extent) + if self.im.mode == "RGB" and "transparency" in self.info: + mask = updated.convert_transparent( + "RGBA", self.info["transparency"] + ) + else: + mask = updated.convert("RGBA") + self._prev_im.paste(updated, self.dispose_extent, mask) + self.im = self._prev_im + if self.pyaccess: + self.pyaccess = None + + def _getexif(self): + if "exif" not in self.info: + self.load() + if "exif" not in self.info and "Raw profile type exif" not in self.info: + return None + return self.getexif()._get_merged_dict() + + def getexif(self): + if "exif" not in self.info: + self.load() + + return super().getexif() + + def getxmp(self): + """ + Returns a dictionary containing the XMP tags. + Requires defusedxml to be installed. + + :returns: XMP tags in a dictionary. + """ + return ( + self._getxmp(self.info["XML:com.adobe.xmp"]) + if "XML:com.adobe.xmp" in self.info + else {} + ) + + +# -------------------------------------------------------------------- +# PNG writer + +_OUTMODES = { + # supported PIL modes, and corresponding rawmodes/bits/color combinations + "1": ("1", b"\x01\x00"), + "L;1": ("L;1", b"\x01\x00"), + "L;2": ("L;2", b"\x02\x00"), + "L;4": ("L;4", b"\x04\x00"), + "L": ("L", b"\x08\x00"), + "LA": ("LA", b"\x08\x04"), + "I": ("I;16B", b"\x10\x00"), + "I;16": ("I;16B", b"\x10\x00"), + "I;16B": ("I;16B", b"\x10\x00"), + "P;1": ("P;1", b"\x01\x03"), + "P;2": ("P;2", b"\x02\x03"), + "P;4": ("P;4", b"\x04\x03"), + "P": ("P", b"\x08\x03"), + "RGB": ("RGB", b"\x08\x02"), + "RGBA": ("RGBA", b"\x08\x06"), +} + + +def putchunk(fp, cid, *data): + """Write a PNG chunk (including CRC field)""" + + data = b"".join(data) + + fp.write(o32(len(data)) + cid) + fp.write(data) + crc = _crc32(data, _crc32(cid)) + fp.write(o32(crc)) + + +class _idat: + # wrap output from the encoder in IDAT chunks + + def __init__(self, fp, chunk): + self.fp = fp + self.chunk = chunk + + def write(self, data): + self.chunk(self.fp, b"IDAT", data) + + +class _fdat: + # wrap encoder output in fdAT chunks + + def __init__(self, fp, chunk, seq_num): + self.fp = fp + self.chunk = chunk + self.seq_num = seq_num + + def write(self, data): + self.chunk(self.fp, b"fdAT", o32(self.seq_num), data) + self.seq_num += 1 + + +def _write_multiple_frames(im, fp, chunk, rawmode, default_image, append_images): + duration = im.encoderinfo.get("duration", im.info.get("duration", 0)) + loop = im.encoderinfo.get("loop", im.info.get("loop", 0)) + disposal = im.encoderinfo.get("disposal", im.info.get("disposal", Disposal.OP_NONE)) + blend = im.encoderinfo.get("blend", im.info.get("blend", Blend.OP_SOURCE)) + + if default_image: + chain = itertools.chain(append_images) + else: + chain = itertools.chain([im], append_images) + + im_frames = [] + frame_count = 0 + for im_seq in chain: + for im_frame in ImageSequence.Iterator(im_seq): + if im_frame.mode == rawmode: + im_frame = im_frame.copy() + else: + im_frame = im_frame.convert(rawmode) + encoderinfo = im.encoderinfo.copy() + if isinstance(duration, (list, tuple)): + encoderinfo["duration"] = duration[frame_count] + if isinstance(disposal, (list, tuple)): + encoderinfo["disposal"] = disposal[frame_count] + if isinstance(blend, (list, tuple)): + encoderinfo["blend"] = blend[frame_count] + frame_count += 1 + + if im_frames: + previous = im_frames[-1] + prev_disposal = previous["encoderinfo"].get("disposal") + prev_blend = previous["encoderinfo"].get("blend") + if prev_disposal == Disposal.OP_PREVIOUS and len(im_frames) < 2: + prev_disposal = Disposal.OP_BACKGROUND + + if prev_disposal == Disposal.OP_BACKGROUND: + base_im = previous["im"].copy() + dispose = Image.core.fill("RGBA", im.size, (0, 0, 0, 0)) + bbox = previous["bbox"] + if bbox: + dispose = dispose.crop(bbox) + else: + bbox = (0, 0) + im.size + base_im.paste(dispose, bbox) + elif prev_disposal == Disposal.OP_PREVIOUS: + base_im = im_frames[-2]["im"] + else: + base_im = previous["im"] + delta = ImageChops.subtract_modulo( + im_frame.convert("RGBA"), base_im.convert("RGBA") + ) + bbox = delta.getbbox(alpha_only=False) + if ( + not bbox + and prev_disposal == encoderinfo.get("disposal") + and prev_blend == encoderinfo.get("blend") + ): + previous["encoderinfo"]["duration"] += encoderinfo.get( + "duration", duration + ) + continue + else: + bbox = None + if "duration" not in encoderinfo: + encoderinfo["duration"] = duration + im_frames.append({"im": im_frame, "bbox": bbox, "encoderinfo": encoderinfo}) + + if len(im_frames) == 1 and not default_image: + return im_frames[0]["im"] + + # animation control + chunk( + fp, + b"acTL", + o32(len(im_frames)), # 0: num_frames + o32(loop), # 4: num_plays + ) + + # default image IDAT (if it exists) + if default_image: + if im.mode != rawmode: + im = im.convert(rawmode) + ImageFile._save(im, _idat(fp, chunk), [("zip", (0, 0) + im.size, 0, rawmode)]) + + seq_num = 0 + for frame, frame_data in enumerate(im_frames): + im_frame = frame_data["im"] + if not frame_data["bbox"]: + bbox = (0, 0) + im_frame.size + else: + bbox = frame_data["bbox"] + im_frame = im_frame.crop(bbox) + size = im_frame.size + encoderinfo = frame_data["encoderinfo"] + frame_duration = int(round(encoderinfo["duration"])) + frame_disposal = encoderinfo.get("disposal", disposal) + frame_blend = encoderinfo.get("blend", blend) + # frame control + chunk( + fp, + b"fcTL", + o32(seq_num), # sequence_number + o32(size[0]), # width + o32(size[1]), # height + o32(bbox[0]), # x_offset + o32(bbox[1]), # y_offset + o16(frame_duration), # delay_numerator + o16(1000), # delay_denominator + o8(frame_disposal), # dispose_op + o8(frame_blend), # blend_op + ) + seq_num += 1 + # frame data + if frame == 0 and not default_image: + # first frame must be in IDAT chunks for backwards compatibility + ImageFile._save( + im_frame, + _idat(fp, chunk), + [("zip", (0, 0) + im_frame.size, 0, rawmode)], + ) + else: + fdat_chunks = _fdat(fp, chunk, seq_num) + ImageFile._save( + im_frame, + fdat_chunks, + [("zip", (0, 0) + im_frame.size, 0, rawmode)], + ) + seq_num = fdat_chunks.seq_num + + +def _save_all(im, fp, filename): + _save(im, fp, filename, save_all=True) + + +def _save(im, fp, filename, chunk=putchunk, save_all=False): + # save an image to disk (called by the save method) + + if save_all: + default_image = im.encoderinfo.get( + "default_image", im.info.get("default_image") + ) + modes = set() + sizes = set() + append_images = im.encoderinfo.get("append_images", []) + for im_seq in itertools.chain([im], append_images): + for im_frame in ImageSequence.Iterator(im_seq): + modes.add(im_frame.mode) + sizes.add(im_frame.size) + for mode in ("RGBA", "RGB", "P"): + if mode in modes: + break + else: + mode = modes.pop() + size = tuple(max(frame_size[i] for frame_size in sizes) for i in range(2)) + else: + size = im.size + mode = im.mode + + if mode == "P": + # + # attempt to minimize storage requirements for palette images + if "bits" in im.encoderinfo: + # number of bits specified by user + colors = min(1 << im.encoderinfo["bits"], 256) + else: + # check palette contents + if im.palette: + colors = max(min(len(im.palette.getdata()[1]) // 3, 256), 1) + else: + colors = 256 + + if colors <= 16: + if colors <= 2: + bits = 1 + elif colors <= 4: + bits = 2 + else: + bits = 4 + mode = f"{mode};{bits}" + + # encoder options + im.encoderconfig = ( + im.encoderinfo.get("optimize", False), + im.encoderinfo.get("compress_level", -1), + im.encoderinfo.get("compress_type", -1), + im.encoderinfo.get("dictionary", b""), + ) + + # get the corresponding PNG mode + try: + rawmode, mode = _OUTMODES[mode] + except KeyError as e: + msg = f"cannot write mode {mode} as PNG" + raise OSError(msg) from e + + # + # write minimal PNG file + + fp.write(_MAGIC) + + chunk( + fp, + b"IHDR", + o32(size[0]), # 0: size + o32(size[1]), + mode, # 8: depth/type + b"\0", # 10: compression + b"\0", # 11: filter category + b"\0", # 12: interlace flag + ) + + chunks = [b"cHRM", b"gAMA", b"sBIT", b"sRGB", b"tIME"] + + icc = im.encoderinfo.get("icc_profile", im.info.get("icc_profile")) + if icc: + # ICC profile + # according to PNG spec, the iCCP chunk contains: + # Profile name 1-79 bytes (character string) + # Null separator 1 byte (null character) + # Compression method 1 byte (0) + # Compressed profile n bytes (zlib with deflate compression) + name = b"ICC Profile" + data = name + b"\0\0" + zlib.compress(icc) + chunk(fp, b"iCCP", data) + + # You must either have sRGB or iCCP. + # Disallow sRGB chunks when an iCCP-chunk has been emitted. + chunks.remove(b"sRGB") + + info = im.encoderinfo.get("pnginfo") + if info: + chunks_multiple_allowed = [b"sPLT", b"iTXt", b"tEXt", b"zTXt"] + for info_chunk in info.chunks: + cid, data = info_chunk[:2] + if cid in chunks: + chunks.remove(cid) + chunk(fp, cid, data) + elif cid in chunks_multiple_allowed: + chunk(fp, cid, data) + elif cid[1:2].islower(): + # Private chunk + after_idat = info_chunk[2:3] + if not after_idat: + chunk(fp, cid, data) + + if im.mode == "P": + palette_byte_number = colors * 3 + palette_bytes = im.im.getpalette("RGB")[:palette_byte_number] + while len(palette_bytes) < palette_byte_number: + palette_bytes += b"\0" + chunk(fp, b"PLTE", palette_bytes) + + transparency = im.encoderinfo.get("transparency", im.info.get("transparency", None)) + + if transparency or transparency == 0: + if im.mode == "P": + # limit to actual palette size + alpha_bytes = colors + if isinstance(transparency, bytes): + chunk(fp, b"tRNS", transparency[:alpha_bytes]) + else: + transparency = max(0, min(255, transparency)) + alpha = b"\xFF" * transparency + b"\0" + chunk(fp, b"tRNS", alpha[:alpha_bytes]) + elif im.mode in ("1", "L", "I", "I;16"): + transparency = max(0, min(65535, transparency)) + chunk(fp, b"tRNS", o16(transparency)) + elif im.mode == "RGB": + red, green, blue = transparency + chunk(fp, b"tRNS", o16(red) + o16(green) + o16(blue)) + else: + if "transparency" in im.encoderinfo: + # don't bother with transparency if it's an RGBA + # and it's in the info dict. It's probably just stale. + msg = "cannot use transparency for this mode" + raise OSError(msg) + else: + if im.mode == "P" and im.im.getpalettemode() == "RGBA": + alpha = im.im.getpalette("RGBA", "A") + alpha_bytes = colors + chunk(fp, b"tRNS", alpha[:alpha_bytes]) + + dpi = im.encoderinfo.get("dpi") + if dpi: + chunk( + fp, + b"pHYs", + o32(int(dpi[0] / 0.0254 + 0.5)), + o32(int(dpi[1] / 0.0254 + 0.5)), + b"\x01", + ) + + if info: + chunks = [b"bKGD", b"hIST"] + for info_chunk in info.chunks: + cid, data = info_chunk[:2] + if cid in chunks: + chunks.remove(cid) + chunk(fp, cid, data) + + exif = im.encoderinfo.get("exif") + if exif: + if isinstance(exif, Image.Exif): + exif = exif.tobytes(8) + if exif.startswith(b"Exif\x00\x00"): + exif = exif[6:] + chunk(fp, b"eXIf", exif) + + if save_all: + im = _write_multiple_frames( + im, fp, chunk, rawmode, default_image, append_images + ) + if im: + ImageFile._save(im, _idat(fp, chunk), [("zip", (0, 0) + im.size, 0, rawmode)]) + + if info: + for info_chunk in info.chunks: + cid, data = info_chunk[:2] + if cid[1:2].islower(): + # Private chunk + after_idat = info_chunk[2:3] + if after_idat: + chunk(fp, cid, data) + + chunk(fp, b"IEND", b"") + + if hasattr(fp, "flush"): + fp.flush() + + +# -------------------------------------------------------------------- +# PNG chunk converter + + +def getchunks(im, **params): + """Return a list of PNG chunks representing this image.""" + + class collector: + data = [] + + def write(self, data): + pass + + def append(self, chunk): + self.data.append(chunk) + + def append(fp, cid, *data): + data = b"".join(data) + crc = o32(_crc32(data, _crc32(cid))) + fp.append((cid, data, crc)) + + fp = collector() + + try: + im.encoderinfo = params + _save(im, fp, None, append) + finally: + del im.encoderinfo + + return fp.data + + +# -------------------------------------------------------------------- +# Registry + +Image.register_open(PngImageFile.format, PngImageFile, _accept) +Image.register_save(PngImageFile.format, _save) +Image.register_save_all(PngImageFile.format, _save_all) + +Image.register_extensions(PngImageFile.format, [".png", ".apng"]) + +Image.register_mime(PngImageFile.format, "image/png") diff --git a/venv/lib/python3.10/site-packages/PIL/PpmImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PpmImagePlugin.py new file mode 100644 index 00000000..94bf430b --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PpmImagePlugin.py @@ -0,0 +1,371 @@ +# +# The Python Imaging Library. +# $Id$ +# +# PPM support for PIL +# +# History: +# 96-03-24 fl Created +# 98-03-06 fl Write RGBA images (as RGB, that is) +# +# Copyright (c) Secret Labs AB 1997-98. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import math +from typing import IO + +from . import Image, ImageFile +from ._binary import i16be as i16 +from ._binary import o8 +from ._binary import o32le as o32 + +# +# -------------------------------------------------------------------- + +b_whitespace = b"\x20\x09\x0a\x0b\x0c\x0d" + +MODES = { + # standard + b"P1": "1", + b"P2": "L", + b"P3": "RGB", + b"P4": "1", + b"P5": "L", + b"P6": "RGB", + # extensions + b"P0CMYK": "CMYK", + b"Pf": "F", + # PIL extensions (for test purposes only) + b"PyP": "P", + b"PyRGBA": "RGBA", + b"PyCMYK": "CMYK", +} + + +def _accept(prefix: bytes) -> bool: + return prefix[0:1] == b"P" and prefix[1] in b"0123456fy" + + +## +# Image plugin for PBM, PGM, and PPM images. + + +class PpmImageFile(ImageFile.ImageFile): + format = "PPM" + format_description = "Pbmplus image" + + def _read_magic(self) -> bytes: + assert self.fp is not None + + magic = b"" + # read until whitespace or longest available magic number + for _ in range(6): + c = self.fp.read(1) + if not c or c in b_whitespace: + break + magic += c + return magic + + def _read_token(self) -> bytes: + assert self.fp is not None + + token = b"" + while len(token) <= 10: # read until next whitespace or limit of 10 characters + c = self.fp.read(1) + if not c: + break + elif c in b_whitespace: # token ended + if not token: + # skip whitespace at start + continue + break + elif c == b"#": + # ignores rest of the line; stops at CR, LF or EOF + while self.fp.read(1) not in b"\r\n": + pass + continue + token += c + if not token: + # Token was not even 1 byte + msg = "Reached EOF while reading header" + raise ValueError(msg) + elif len(token) > 10: + msg = f"Token too long in file header: {token.decode()}" + raise ValueError(msg) + return token + + def _open(self) -> None: + assert self.fp is not None + + magic_number = self._read_magic() + try: + mode = MODES[magic_number] + except KeyError: + msg = "not a PPM file" + raise SyntaxError(msg) + self._mode = mode + + if magic_number in (b"P1", b"P4"): + self.custom_mimetype = "image/x-portable-bitmap" + elif magic_number in (b"P2", b"P5"): + self.custom_mimetype = "image/x-portable-graymap" + elif magic_number in (b"P3", b"P6"): + self.custom_mimetype = "image/x-portable-pixmap" + + self._size = int(self._read_token()), int(self._read_token()) + + decoder_name = "raw" + if magic_number in (b"P1", b"P2", b"P3"): + decoder_name = "ppm_plain" + + args: str | tuple[str | int, ...] + if mode == "1": + args = "1;I" + elif mode == "F": + scale = float(self._read_token()) + if scale == 0.0 or not math.isfinite(scale): + msg = "scale must be finite and non-zero" + raise ValueError(msg) + self.info["scale"] = abs(scale) + + rawmode = "F;32F" if scale < 0 else "F;32BF" + args = (rawmode, 0, -1) + else: + maxval = int(self._read_token()) + if not 0 < maxval < 65536: + msg = "maxval must be greater than 0 and less than 65536" + raise ValueError(msg) + if maxval > 255 and mode == "L": + self._mode = "I" + + rawmode = mode + if decoder_name != "ppm_plain": + # If maxval matches a bit depth, use the raw decoder directly + if maxval == 65535 and mode == "L": + rawmode = "I;16B" + elif maxval != 255: + decoder_name = "ppm" + + args = rawmode if decoder_name == "raw" else (rawmode, maxval) + self.tile = [(decoder_name, (0, 0) + self.size, self.fp.tell(), args)] + + +# +# -------------------------------------------------------------------- + + +class PpmPlainDecoder(ImageFile.PyDecoder): + _pulls_fd = True + _comment_spans: bool + + def _read_block(self) -> bytes: + assert self.fd is not None + + return self.fd.read(ImageFile.SAFEBLOCK) + + def _find_comment_end(self, block: bytes, start: int = 0) -> int: + a = block.find(b"\n", start) + b = block.find(b"\r", start) + return min(a, b) if a * b > 0 else max(a, b) # lowest nonnegative index (or -1) + + def _ignore_comments(self, block: bytes) -> bytes: + if self._comment_spans: + # Finish current comment + while block: + comment_end = self._find_comment_end(block) + if comment_end != -1: + # Comment ends in this block + # Delete tail of comment + block = block[comment_end + 1 :] + break + else: + # Comment spans whole block + # So read the next block, looking for the end + block = self._read_block() + + # Search for any further comments + self._comment_spans = False + while True: + comment_start = block.find(b"#") + if comment_start == -1: + # No comment found + break + comment_end = self._find_comment_end(block, comment_start) + if comment_end != -1: + # Comment ends in this block + # Delete comment + block = block[:comment_start] + block[comment_end + 1 :] + else: + # Comment continues to next block(s) + block = block[:comment_start] + self._comment_spans = True + break + return block + + def _decode_bitonal(self) -> bytearray: + """ + This is a separate method because in the plain PBM format, all data tokens are + exactly one byte, so the inter-token whitespace is optional. + """ + data = bytearray() + total_bytes = self.state.xsize * self.state.ysize + + while len(data) != total_bytes: + block = self._read_block() # read next block + if not block: + # eof + break + + block = self._ignore_comments(block) + + tokens = b"".join(block.split()) + for token in tokens: + if token not in (48, 49): + msg = b"Invalid token for this mode: %s" % bytes([token]) + raise ValueError(msg) + data = (data + tokens)[:total_bytes] + invert = bytes.maketrans(b"01", b"\xFF\x00") + return data.translate(invert) + + def _decode_blocks(self, maxval: int) -> bytearray: + data = bytearray() + max_len = 10 + out_byte_count = 4 if self.mode == "I" else 1 + out_max = 65535 if self.mode == "I" else 255 + bands = Image.getmodebands(self.mode) + total_bytes = self.state.xsize * self.state.ysize * bands * out_byte_count + + half_token = b"" + while len(data) != total_bytes: + block = self._read_block() # read next block + if not block: + if half_token: + block = bytearray(b" ") # flush half_token + else: + # eof + break + + block = self._ignore_comments(block) + + if half_token: + block = half_token + block # stitch half_token to new block + half_token = b"" + + tokens = block.split() + + if block and not block[-1:].isspace(): # block might split token + half_token = tokens.pop() # save half token for later + if len(half_token) > max_len: # prevent buildup of half_token + msg = ( + b"Token too long found in data: %s" % half_token[: max_len + 1] + ) + raise ValueError(msg) + + for token in tokens: + if len(token) > max_len: + msg = b"Token too long found in data: %s" % token[: max_len + 1] + raise ValueError(msg) + value = int(token) + if value < 0: + msg_str = f"Channel value is negative: {value}" + raise ValueError(msg_str) + if value > maxval: + msg_str = f"Channel value too large for this mode: {value}" + raise ValueError(msg_str) + value = round(value / maxval * out_max) + data += o32(value) if self.mode == "I" else o8(value) + if len(data) == total_bytes: # finished! + break + return data + + def decode(self, buffer: bytes) -> tuple[int, int]: + self._comment_spans = False + if self.mode == "1": + data = self._decode_bitonal() + rawmode = "1;8" + else: + maxval = self.args[-1] + data = self._decode_blocks(maxval) + rawmode = "I;32" if self.mode == "I" else self.mode + self.set_as_raw(bytes(data), rawmode) + return -1, 0 + + +class PpmDecoder(ImageFile.PyDecoder): + _pulls_fd = True + + def decode(self, buffer: bytes) -> tuple[int, int]: + assert self.fd is not None + + data = bytearray() + maxval = self.args[-1] + in_byte_count = 1 if maxval < 256 else 2 + out_byte_count = 4 if self.mode == "I" else 1 + out_max = 65535 if self.mode == "I" else 255 + bands = Image.getmodebands(self.mode) + dest_length = self.state.xsize * self.state.ysize * bands * out_byte_count + while len(data) < dest_length: + pixels = self.fd.read(in_byte_count * bands) + if len(pixels) < in_byte_count * bands: + # eof + break + for b in range(bands): + value = ( + pixels[b] if in_byte_count == 1 else i16(pixels, b * in_byte_count) + ) + value = min(out_max, round(value / maxval * out_max)) + data += o32(value) if self.mode == "I" else o8(value) + rawmode = "I;32" if self.mode == "I" else self.mode + self.set_as_raw(bytes(data), rawmode) + return -1, 0 + + +# +# -------------------------------------------------------------------- + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + if im.mode == "1": + rawmode, head = "1;I", b"P4" + elif im.mode == "L": + rawmode, head = "L", b"P5" + elif im.mode == "I": + rawmode, head = "I;16B", b"P5" + elif im.mode in ("RGB", "RGBA"): + rawmode, head = "RGB", b"P6" + elif im.mode == "F": + rawmode, head = "F;32F", b"Pf" + else: + msg = f"cannot write mode {im.mode} as PPM" + raise OSError(msg) + fp.write(head + b"\n%d %d\n" % im.size) + if head == b"P6": + fp.write(b"255\n") + elif head == b"P5": + if rawmode == "L": + fp.write(b"255\n") + else: + fp.write(b"65535\n") + elif head == b"Pf": + fp.write(b"-1.0\n") + row_order = -1 if im.mode == "F" else 1 + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, row_order))]) + + +# +# -------------------------------------------------------------------- + + +Image.register_open(PpmImageFile.format, PpmImageFile, _accept) +Image.register_save(PpmImageFile.format, _save) + +Image.register_decoder("ppm", PpmDecoder) +Image.register_decoder("ppm_plain", PpmPlainDecoder) + +Image.register_extensions(PpmImageFile.format, [".pbm", ".pgm", ".ppm", ".pnm", ".pfm"]) + +Image.register_mime(PpmImageFile.format, "image/x-portable-anymap") diff --git a/venv/lib/python3.10/site-packages/PIL/PsdImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/PsdImagePlugin.py new file mode 100644 index 00000000..d29bcf99 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PsdImagePlugin.py @@ -0,0 +1,307 @@ +# +# The Python Imaging Library +# $Id$ +# +# Adobe PSD 2.5/3.0 file handling +# +# History: +# 1995-09-01 fl Created +# 1997-01-03 fl Read most PSD images +# 1997-01-18 fl Fixed P and CMYK support +# 2001-10-21 fl Added seek/tell support (for layers) +# +# Copyright (c) 1997-2001 by Secret Labs AB. +# Copyright (c) 1995-2001 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io + +from . import Image, ImageFile, ImagePalette +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import si16be as si16 +from ._binary import si32be as si32 + +MODES = { + # (photoshop mode, bits) -> (pil mode, required channels) + (0, 1): ("1", 1), + (0, 8): ("L", 1), + (1, 8): ("L", 1), + (2, 8): ("P", 1), + (3, 8): ("RGB", 3), + (4, 8): ("CMYK", 4), + (7, 8): ("L", 1), # FIXME: multilayer + (8, 8): ("L", 1), # duotone + (9, 8): ("LAB", 3), +} + + +# --------------------------------------------------------------------. +# read PSD images + + +def _accept(prefix): + return prefix[:4] == b"8BPS" + + +## +# Image plugin for Photoshop images. + + +class PsdImageFile(ImageFile.ImageFile): + format = "PSD" + format_description = "Adobe Photoshop" + _close_exclusive_fp_after_loading = False + + def _open(self): + read = self.fp.read + + # + # header + + s = read(26) + if not _accept(s) or i16(s, 4) != 1: + msg = "not a PSD file" + raise SyntaxError(msg) + + psd_bits = i16(s, 22) + psd_channels = i16(s, 12) + psd_mode = i16(s, 24) + + mode, channels = MODES[(psd_mode, psd_bits)] + + if channels > psd_channels: + msg = "not enough channels" + raise OSError(msg) + if mode == "RGB" and psd_channels == 4: + mode = "RGBA" + channels = 4 + + self._mode = mode + self._size = i32(s, 18), i32(s, 14) + + # + # color mode data + + size = i32(read(4)) + if size: + data = read(size) + if mode == "P" and size == 768: + self.palette = ImagePalette.raw("RGB;L", data) + + # + # image resources + + self.resources = [] + + size = i32(read(4)) + if size: + # load resources + end = self.fp.tell() + size + while self.fp.tell() < end: + read(4) # signature + id = i16(read(2)) + name = read(i8(read(1))) + if not (len(name) & 1): + read(1) # padding + data = read(i32(read(4))) + if len(data) & 1: + read(1) # padding + self.resources.append((id, name, data)) + if id == 1039: # ICC profile + self.info["icc_profile"] = data + + # + # layer and mask information + + self.layers = [] + + size = i32(read(4)) + if size: + end = self.fp.tell() + size + size = i32(read(4)) + if size: + _layer_data = io.BytesIO(ImageFile._safe_read(self.fp, size)) + self.layers = _layerinfo(_layer_data, size) + self.fp.seek(end) + self.n_frames = len(self.layers) + self.is_animated = self.n_frames > 1 + + # + # image descriptor + + self.tile = _maketile(self.fp, mode, (0, 0) + self.size, channels) + + # keep the file open + self._fp = self.fp + self.frame = 1 + self._min_frame = 1 + + def seek(self, layer): + if not self._seek_check(layer): + return + + # seek to given layer (1..max) + try: + name, mode, bbox, tile = self.layers[layer - 1] + self._mode = mode + self.tile = tile + self.frame = layer + self.fp = self._fp + return name, bbox + except IndexError as e: + msg = "no such layer" + raise EOFError(msg) from e + + def tell(self): + # return layer number (0=image, 1..max=layers) + return self.frame + + +def _layerinfo(fp, ct_bytes): + # read layerinfo block + layers = [] + + def read(size): + return ImageFile._safe_read(fp, size) + + ct = si16(read(2)) + + # sanity check + if ct_bytes < (abs(ct) * 20): + msg = "Layer block too short for number of layers requested" + raise SyntaxError(msg) + + for _ in range(abs(ct)): + # bounding box + y0 = si32(read(4)) + x0 = si32(read(4)) + y1 = si32(read(4)) + x1 = si32(read(4)) + + # image info + mode = [] + ct_types = i16(read(2)) + if ct_types > 4: + fp.seek(ct_types * 6 + 12, io.SEEK_CUR) + size = i32(read(4)) + fp.seek(size, io.SEEK_CUR) + continue + + for _ in range(ct_types): + type = i16(read(2)) + + if type == 65535: + m = "A" + else: + m = "RGBA"[type] + + mode.append(m) + read(4) # size + + # figure out the image mode + mode.sort() + if mode == ["R"]: + mode = "L" + elif mode == ["B", "G", "R"]: + mode = "RGB" + elif mode == ["A", "B", "G", "R"]: + mode = "RGBA" + else: + mode = None # unknown + + # skip over blend flags and extra information + read(12) # filler + name = "" + size = i32(read(4)) # length of the extra data field + if size: + data_end = fp.tell() + size + + length = i32(read(4)) + if length: + fp.seek(length - 16, io.SEEK_CUR) + + length = i32(read(4)) + if length: + fp.seek(length, io.SEEK_CUR) + + length = i8(read(1)) + if length: + # Don't know the proper encoding, + # Latin-1 should be a good guess + name = read(length).decode("latin-1", "replace") + + fp.seek(data_end) + layers.append((name, mode, (x0, y0, x1, y1))) + + # get tiles + for i, (name, mode, bbox) in enumerate(layers): + tile = [] + for m in mode: + t = _maketile(fp, m, bbox, 1) + if t: + tile.extend(t) + layers[i] = name, mode, bbox, tile + + return layers + + +def _maketile(file, mode, bbox, channels): + tile = None + read = file.read + + compression = i16(read(2)) + + xsize = bbox[2] - bbox[0] + ysize = bbox[3] - bbox[1] + + offset = file.tell() + + if compression == 0: + # + # raw compression + tile = [] + for channel in range(channels): + layer = mode[channel] + if mode == "CMYK": + layer += ";I" + tile.append(("raw", bbox, offset, layer)) + offset = offset + xsize * ysize + + elif compression == 1: + # + # packbits compression + i = 0 + tile = [] + bytecount = read(channels * ysize * 2) + offset = file.tell() + for channel in range(channels): + layer = mode[channel] + if mode == "CMYK": + layer += ";I" + tile.append(("packbits", bbox, offset, layer)) + for y in range(ysize): + offset = offset + i16(bytecount, i) + i += 2 + + file.seek(offset) + + if offset & 1: + read(1) # padding + + return tile + + +# -------------------------------------------------------------------- +# registry + + +Image.register_open(PsdImageFile.format, PsdImageFile, _accept) + +Image.register_extension(PsdImageFile.format, ".psd") + +Image.register_mime(PsdImageFile.format, "image/vnd.adobe.photoshop") diff --git a/venv/lib/python3.10/site-packages/PIL/PyAccess.py b/venv/lib/python3.10/site-packages/PIL/PyAccess.py new file mode 100644 index 00000000..2c831913 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/PyAccess.py @@ -0,0 +1,365 @@ +# +# The Python Imaging Library +# Pillow fork +# +# Python implementation of the PixelAccess Object +# +# Copyright (c) 1997-2009 by Secret Labs AB. All rights reserved. +# Copyright (c) 1995-2009 by Fredrik Lundh. +# Copyright (c) 2013 Eric Soroos +# +# See the README file for information on usage and redistribution +# + +# Notes: +# +# * Implements the pixel access object following Access.c +# * Taking only the tuple form, which is used from python. +# * Fill.c uses the integer form, but it's still going to use the old +# Access.c implementation. +# +from __future__ import annotations + +import logging +import sys + +from ._deprecate import deprecate + +FFI: type +try: + from cffi import FFI + + defs = """ + struct Pixel_RGBA { + unsigned char r,g,b,a; + }; + struct Pixel_I16 { + unsigned char l,r; + }; + """ + ffi = FFI() + ffi.cdef(defs) +except ImportError as ex: + # Allow error import for doc purposes, but error out when accessing + # anything in core. + from ._util import DeferredError + + FFI = ffi = DeferredError.new(ex) + +logger = logging.getLogger(__name__) + + +class PyAccess: + def __init__(self, img, readonly=False): + deprecate("PyAccess", 11) + vals = dict(img.im.unsafe_ptrs) + self.readonly = readonly + self.image8 = ffi.cast("unsigned char **", vals["image8"]) + self.image32 = ffi.cast("int **", vals["image32"]) + self.image = ffi.cast("unsigned char **", vals["image"]) + self.xsize, self.ysize = img.im.size + self._img = img + + # Keep pointer to im object to prevent dereferencing. + self._im = img.im + if self._im.mode in ("P", "PA"): + self._palette = img.palette + + # Debugging is polluting test traces, only useful here + # when hacking on PyAccess + # logger.debug("%s", vals) + self._post_init() + + def _post_init(self): + pass + + def __setitem__(self, xy, color): + """ + Modifies the pixel at x,y. The color is given as a single + numerical value for single band images, and a tuple for + multi-band images + + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. + :param color: The pixel value. + """ + if self.readonly: + msg = "Attempt to putpixel a read only image" + raise ValueError(msg) + (x, y) = xy + if x < 0: + x = self.xsize + x + if y < 0: + y = self.ysize + y + (x, y) = self.check_xy((x, y)) + + if ( + self._im.mode in ("P", "PA") + and isinstance(color, (list, tuple)) + and len(color) in [3, 4] + ): + # RGB or RGBA value for a P or PA image + if self._im.mode == "PA": + alpha = color[3] if len(color) == 4 else 255 + color = color[:3] + color = self._palette.getcolor(color, self._img) + if self._im.mode == "PA": + color = (color, alpha) + + return self.set_pixel(x, y, color) + + def __getitem__(self, xy): + """ + Returns the pixel at x,y. The pixel is returned as a single + value for single band images or a tuple for multiple band + images + + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. + :returns: a pixel value for single band images, a tuple of + pixel values for multiband images. + """ + (x, y) = xy + if x < 0: + x = self.xsize + x + if y < 0: + y = self.ysize + y + (x, y) = self.check_xy((x, y)) + return self.get_pixel(x, y) + + putpixel = __setitem__ + getpixel = __getitem__ + + def check_xy(self, xy): + (x, y) = xy + if not (0 <= x < self.xsize and 0 <= y < self.ysize): + msg = "pixel location out of range" + raise ValueError(msg) + return xy + + +class _PyAccess32_2(PyAccess): + """PA, LA, stored in first and last bytes of a 32 bit word""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("struct Pixel_RGBA **", self.image32) + + def get_pixel(self, x, y): + pixel = self.pixels[y][x] + return pixel.r, pixel.a + + def set_pixel(self, x, y, color): + pixel = self.pixels[y][x] + # tuple + pixel.r = min(color[0], 255) + pixel.a = min(color[1], 255) + + +class _PyAccess32_3(PyAccess): + """RGB and friends, stored in the first three bytes of a 32 bit word""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("struct Pixel_RGBA **", self.image32) + + def get_pixel(self, x, y): + pixel = self.pixels[y][x] + return pixel.r, pixel.g, pixel.b + + def set_pixel(self, x, y, color): + pixel = self.pixels[y][x] + # tuple + pixel.r = min(color[0], 255) + pixel.g = min(color[1], 255) + pixel.b = min(color[2], 255) + pixel.a = 255 + + +class _PyAccess32_4(PyAccess): + """RGBA etc, all 4 bytes of a 32 bit word""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("struct Pixel_RGBA **", self.image32) + + def get_pixel(self, x, y): + pixel = self.pixels[y][x] + return pixel.r, pixel.g, pixel.b, pixel.a + + def set_pixel(self, x, y, color): + pixel = self.pixels[y][x] + # tuple + pixel.r = min(color[0], 255) + pixel.g = min(color[1], 255) + pixel.b = min(color[2], 255) + pixel.a = min(color[3], 255) + + +class _PyAccess8(PyAccess): + """1, L, P, 8 bit images stored as uint8""" + + def _post_init(self, *args, **kwargs): + self.pixels = self.image8 + + def get_pixel(self, x, y): + return self.pixels[y][x] + + def set_pixel(self, x, y, color): + try: + # integer + self.pixels[y][x] = min(color, 255) + except TypeError: + # tuple + self.pixels[y][x] = min(color[0], 255) + + +class _PyAccessI16_N(PyAccess): + """I;16 access, native bitendian without conversion""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("unsigned short **", self.image) + + def get_pixel(self, x, y): + return self.pixels[y][x] + + def set_pixel(self, x, y, color): + try: + # integer + self.pixels[y][x] = min(color, 65535) + except TypeError: + # tuple + self.pixels[y][x] = min(color[0], 65535) + + +class _PyAccessI16_L(PyAccess): + """I;16L access, with conversion""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("struct Pixel_I16 **", self.image) + + def get_pixel(self, x, y): + pixel = self.pixels[y][x] + return pixel.l + pixel.r * 256 + + def set_pixel(self, x, y, color): + pixel = self.pixels[y][x] + try: + color = min(color, 65535) + except TypeError: + color = min(color[0], 65535) + + pixel.l = color & 0xFF + pixel.r = color >> 8 + + +class _PyAccessI16_B(PyAccess): + """I;16B access, with conversion""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("struct Pixel_I16 **", self.image) + + def get_pixel(self, x, y): + pixel = self.pixels[y][x] + return pixel.l * 256 + pixel.r + + def set_pixel(self, x, y, color): + pixel = self.pixels[y][x] + try: + color = min(color, 65535) + except Exception: + color = min(color[0], 65535) + + pixel.l = color >> 8 + pixel.r = color & 0xFF + + +class _PyAccessI32_N(PyAccess): + """Signed Int32 access, native endian""" + + def _post_init(self, *args, **kwargs): + self.pixels = self.image32 + + def get_pixel(self, x, y): + return self.pixels[y][x] + + def set_pixel(self, x, y, color): + self.pixels[y][x] = color + + +class _PyAccessI32_Swap(PyAccess): + """I;32L/B access, with byteswapping conversion""" + + def _post_init(self, *args, **kwargs): + self.pixels = self.image32 + + def reverse(self, i): + orig = ffi.new("int *", i) + chars = ffi.cast("unsigned char *", orig) + chars[0], chars[1], chars[2], chars[3] = chars[3], chars[2], chars[1], chars[0] + return ffi.cast("int *", chars)[0] + + def get_pixel(self, x, y): + return self.reverse(self.pixels[y][x]) + + def set_pixel(self, x, y, color): + self.pixels[y][x] = self.reverse(color) + + +class _PyAccessF(PyAccess): + """32 bit float access""" + + def _post_init(self, *args, **kwargs): + self.pixels = ffi.cast("float **", self.image32) + + def get_pixel(self, x, y): + return self.pixels[y][x] + + def set_pixel(self, x, y, color): + try: + # not a tuple + self.pixels[y][x] = color + except TypeError: + # tuple + self.pixels[y][x] = color[0] + + +mode_map = { + "1": _PyAccess8, + "L": _PyAccess8, + "P": _PyAccess8, + "I;16N": _PyAccessI16_N, + "LA": _PyAccess32_2, + "La": _PyAccess32_2, + "PA": _PyAccess32_2, + "RGB": _PyAccess32_3, + "LAB": _PyAccess32_3, + "HSV": _PyAccess32_3, + "YCbCr": _PyAccess32_3, + "RGBA": _PyAccess32_4, + "RGBa": _PyAccess32_4, + "RGBX": _PyAccess32_4, + "CMYK": _PyAccess32_4, + "F": _PyAccessF, + "I": _PyAccessI32_N, +} + +if sys.byteorder == "little": + mode_map["I;16"] = _PyAccessI16_N + mode_map["I;16L"] = _PyAccessI16_N + mode_map["I;16B"] = _PyAccessI16_B + + mode_map["I;32L"] = _PyAccessI32_N + mode_map["I;32B"] = _PyAccessI32_Swap +else: + mode_map["I;16"] = _PyAccessI16_L + mode_map["I;16L"] = _PyAccessI16_L + mode_map["I;16B"] = _PyAccessI16_N + + mode_map["I;32L"] = _PyAccessI32_Swap + mode_map["I;32B"] = _PyAccessI32_N + + +def new(img, readonly=False): + access_type = mode_map.get(img.mode, None) + if not access_type: + logger.debug("PyAccess Not Implemented: %s", img.mode) + return None + return access_type(img, readonly) diff --git a/venv/lib/python3.10/site-packages/PIL/QoiImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/QoiImagePlugin.py new file mode 100644 index 00000000..f8aa720c --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/QoiImagePlugin.py @@ -0,0 +1,111 @@ +# +# The Python Imaging Library. +# +# QOI support for PIL +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import os + +from . import Image, ImageFile +from ._binary import i32be as i32 + + +def _accept(prefix): + return prefix[:4] == b"qoif" + + +class QoiImageFile(ImageFile.ImageFile): + format = "QOI" + format_description = "Quite OK Image" + + def _open(self): + if not _accept(self.fp.read(4)): + msg = "not a QOI file" + raise SyntaxError(msg) + + self._size = tuple(i32(self.fp.read(4)) for i in range(2)) + + channels = self.fp.read(1)[0] + self._mode = "RGB" if channels == 3 else "RGBA" + + self.fp.seek(1, os.SEEK_CUR) # colorspace + self.tile = [("qoi", (0, 0) + self._size, self.fp.tell(), None)] + + +class QoiDecoder(ImageFile.PyDecoder): + _pulls_fd = True + + def _add_to_previous_pixels(self, value): + self._previous_pixel = value + + r, g, b, a = value + hash_value = (r * 3 + g * 5 + b * 7 + a * 11) % 64 + self._previously_seen_pixels[hash_value] = value + + def decode(self, buffer): + self._previously_seen_pixels = {} + self._previous_pixel = None + self._add_to_previous_pixels(bytearray((0, 0, 0, 255))) + + data = bytearray() + bands = Image.getmodebands(self.mode) + dest_length = self.state.xsize * self.state.ysize * bands + while len(data) < dest_length: + byte = self.fd.read(1)[0] + if byte == 0b11111110: # QOI_OP_RGB + value = bytearray(self.fd.read(3)) + self._previous_pixel[3:] + elif byte == 0b11111111: # QOI_OP_RGBA + value = self.fd.read(4) + else: + op = byte >> 6 + if op == 0: # QOI_OP_INDEX + op_index = byte & 0b00111111 + value = self._previously_seen_pixels.get( + op_index, bytearray((0, 0, 0, 0)) + ) + elif op == 1: # QOI_OP_DIFF + value = bytearray( + ( + (self._previous_pixel[0] + ((byte & 0b00110000) >> 4) - 2) + % 256, + (self._previous_pixel[1] + ((byte & 0b00001100) >> 2) - 2) + % 256, + (self._previous_pixel[2] + (byte & 0b00000011) - 2) % 256, + self._previous_pixel[3], + ) + ) + elif op == 2: # QOI_OP_LUMA + second_byte = self.fd.read(1)[0] + diff_green = (byte & 0b00111111) - 32 + diff_red = ((second_byte & 0b11110000) >> 4) - 8 + diff_blue = (second_byte & 0b00001111) - 8 + + value = bytearray( + tuple( + (self._previous_pixel[i] + diff_green + diff) % 256 + for i, diff in enumerate((diff_red, 0, diff_blue)) + ) + ) + value += self._previous_pixel[3:] + elif op == 3: # QOI_OP_RUN + run_length = (byte & 0b00111111) + 1 + value = self._previous_pixel + if bands == 3: + value = value[:3] + data += value * run_length + continue + self._add_to_previous_pixels(value) + + if bands == 3: + value = value[:3] + data += value + self.set_as_raw(data) + return -1, 0 + + +Image.register_open(QoiImageFile.format, QoiImageFile, _accept) +Image.register_decoder("qoi", QoiDecoder) +Image.register_extension(QoiImageFile.format, ".qoi") diff --git a/venv/lib/python3.10/site-packages/PIL/SgiImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/SgiImagePlugin.py new file mode 100644 index 00000000..7bd84ebd --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/SgiImagePlugin.py @@ -0,0 +1,237 @@ +# +# The Python Imaging Library. +# $Id$ +# +# SGI image file handling +# +# See "The SGI Image File Format (Draft version 0.97)", Paul Haeberli. +# +# +# +# History: +# 2017-22-07 mb Add RLE decompression +# 2016-16-10 mb Add save method without compression +# 1995-09-10 fl Created +# +# Copyright (c) 2016 by Mickael Bonfill. +# Copyright (c) 2008 by Karsten Hiddemann. +# Copyright (c) 1997 by Secret Labs AB. +# Copyright (c) 1995 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import os +import struct +from typing import IO + +from . import Image, ImageFile +from ._binary import i16be as i16 +from ._binary import o8 + + +def _accept(prefix: bytes) -> bool: + return len(prefix) >= 2 and i16(prefix) == 474 + + +MODES = { + (1, 1, 1): "L", + (1, 2, 1): "L", + (2, 1, 1): "L;16B", + (2, 2, 1): "L;16B", + (1, 3, 3): "RGB", + (2, 3, 3): "RGB;16B", + (1, 3, 4): "RGBA", + (2, 3, 4): "RGBA;16B", +} + + +## +# Image plugin for SGI images. +class SgiImageFile(ImageFile.ImageFile): + format = "SGI" + format_description = "SGI Image File Format" + + def _open(self) -> None: + # HEAD + assert self.fp is not None + + headlen = 512 + s = self.fp.read(headlen) + + if not _accept(s): + msg = "Not an SGI image file" + raise ValueError(msg) + + # compression : verbatim or RLE + compression = s[2] + + # bpc : 1 or 2 bytes (8bits or 16bits) + bpc = s[3] + + # dimension : 1, 2 or 3 (depending on xsize, ysize and zsize) + dimension = i16(s, 4) + + # xsize : width + xsize = i16(s, 6) + + # ysize : height + ysize = i16(s, 8) + + # zsize : channels count + zsize = i16(s, 10) + + # layout + layout = bpc, dimension, zsize + + # determine mode from bits/zsize + rawmode = "" + try: + rawmode = MODES[layout] + except KeyError: + pass + + if rawmode == "": + msg = "Unsupported SGI image mode" + raise ValueError(msg) + + self._size = xsize, ysize + self._mode = rawmode.split(";")[0] + if self.mode == "RGB": + self.custom_mimetype = "image/rgb" + + # orientation -1 : scanlines begins at the bottom-left corner + orientation = -1 + + # decoder info + if compression == 0: + pagesize = xsize * ysize * bpc + if bpc == 2: + self.tile = [ + ("SGI16", (0, 0) + self.size, headlen, (self.mode, 0, orientation)) + ] + else: + self.tile = [] + offset = headlen + for layer in self.mode: + self.tile.append( + ("raw", (0, 0) + self.size, offset, (layer, 0, orientation)) + ) + offset += pagesize + elif compression == 1: + self.tile = [ + ("sgi_rle", (0, 0) + self.size, headlen, (rawmode, orientation, bpc)) + ] + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + if im.mode not in {"RGB", "RGBA", "L"}: + msg = "Unsupported SGI image mode" + raise ValueError(msg) + + # Get the keyword arguments + info = im.encoderinfo + + # Byte-per-pixel precision, 1 = 8bits per pixel + bpc = info.get("bpc", 1) + + if bpc not in (1, 2): + msg = "Unsupported number of bytes per pixel" + raise ValueError(msg) + + # Flip the image, since the origin of SGI file is the bottom-left corner + orientation = -1 + # Define the file as SGI File Format + magic_number = 474 + # Run-Length Encoding Compression - Unsupported at this time + rle = 0 + + # Number of dimensions (x,y,z) + dim = 3 + # X Dimension = width / Y Dimension = height + x, y = im.size + if im.mode == "L" and y == 1: + dim = 1 + elif im.mode == "L": + dim = 2 + # Z Dimension: Number of channels + z = len(im.mode) + + if dim in {1, 2}: + z = 1 + + # assert we've got the right number of bands. + if len(im.getbands()) != z: + msg = f"incorrect number of bands in SGI write: {z} vs {len(im.getbands())}" + raise ValueError(msg) + + # Minimum Byte value + pinmin = 0 + # Maximum Byte value (255 = 8bits per pixel) + pinmax = 255 + # Image name (79 characters max, truncated below in write) + filename = os.path.basename(filename) + img_name = os.path.splitext(filename)[0].encode("ascii", "ignore") + # Standard representation of pixel in the file + colormap = 0 + fp.write(struct.pack(">h", magic_number)) + fp.write(o8(rle)) + fp.write(o8(bpc)) + fp.write(struct.pack(">H", dim)) + fp.write(struct.pack(">H", x)) + fp.write(struct.pack(">H", y)) + fp.write(struct.pack(">H", z)) + fp.write(struct.pack(">l", pinmin)) + fp.write(struct.pack(">l", pinmax)) + fp.write(struct.pack("4s", b"")) # dummy + fp.write(struct.pack("79s", img_name)) # truncates to 79 chars + fp.write(struct.pack("s", b"")) # force null byte after img_name + fp.write(struct.pack(">l", colormap)) + fp.write(struct.pack("404s", b"")) # dummy + + rawmode = "L" + if bpc == 2: + rawmode = "L;16B" + + for channel in im.split(): + fp.write(channel.tobytes("raw", rawmode, 0, orientation)) + + if hasattr(fp, "flush"): + fp.flush() + + +class SGI16Decoder(ImageFile.PyDecoder): + _pulls_fd = True + + def decode(self, buffer: bytes) -> tuple[int, int]: + assert self.fd is not None + assert self.im is not None + + rawmode, stride, orientation = self.args + pagesize = self.state.xsize * self.state.ysize + zsize = len(self.mode) + self.fd.seek(512) + + for band in range(zsize): + channel = Image.new("L", (self.state.xsize, self.state.ysize)) + channel.frombytes( + self.fd.read(2 * pagesize), "raw", "L;16B", stride, orientation + ) + self.im.putband(channel.im, band) + + return -1, 0 + + +# +# registry + + +Image.register_decoder("SGI16", SGI16Decoder) +Image.register_open(SgiImageFile.format, SgiImageFile, _accept) +Image.register_save(SgiImageFile.format, _save) +Image.register_mime(SgiImageFile.format, "image/sgi") + +Image.register_extensions(SgiImageFile.format, [".bw", ".rgb", ".rgba", ".sgi"]) + +# End of file diff --git a/venv/lib/python3.10/site-packages/PIL/SpiderImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/SpiderImagePlugin.py new file mode 100644 index 00000000..86582fb1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/SpiderImagePlugin.py @@ -0,0 +1,318 @@ +# +# The Python Imaging Library. +# +# SPIDER image file handling +# +# History: +# 2004-08-02 Created BB +# 2006-03-02 added save method +# 2006-03-13 added support for stack images +# +# Copyright (c) 2004 by Health Research Inc. (HRI) RENSSELAER, NY 12144. +# Copyright (c) 2004 by William Baxter. +# Copyright (c) 2004 by Secret Labs AB. +# Copyright (c) 2004 by Fredrik Lundh. +# + +## +# Image plugin for the Spider image format. This format is used +# by the SPIDER software, in processing image data from electron +# microscopy and tomography. +## + +# +# SpiderImagePlugin.py +# +# The Spider image format is used by SPIDER software, in processing +# image data from electron microscopy and tomography. +# +# Spider home page: +# https://spider.wadsworth.org/spider_doc/spider/docs/spider.html +# +# Details about the Spider image format: +# https://spider.wadsworth.org/spider_doc/spider/docs/image_doc.html +# +from __future__ import annotations + +import os +import struct +import sys + +from . import Image, ImageFile + + +def isInt(f): + try: + i = int(f) + if f - i == 0: + return 1 + else: + return 0 + except (ValueError, OverflowError): + return 0 + + +iforms = [1, 3, -11, -12, -21, -22] + + +# There is no magic number to identify Spider files, so just check a +# series of header locations to see if they have reasonable values. +# Returns no. of bytes in the header, if it is a valid Spider header, +# otherwise returns 0 + + +def isSpiderHeader(t): + h = (99,) + t # add 1 value so can use spider header index start=1 + # header values 1,2,5,12,13,22,23 should be integers + for i in [1, 2, 5, 12, 13, 22, 23]: + if not isInt(h[i]): + return 0 + # check iform + iform = int(h[5]) + if iform not in iforms: + return 0 + # check other header values + labrec = int(h[13]) # no. records in file header + labbyt = int(h[22]) # total no. of bytes in header + lenbyt = int(h[23]) # record length in bytes + if labbyt != (labrec * lenbyt): + return 0 + # looks like a valid header + return labbyt + + +def isSpiderImage(filename): + with open(filename, "rb") as fp: + f = fp.read(92) # read 23 * 4 bytes + t = struct.unpack(">23f", f) # try big-endian first + hdrlen = isSpiderHeader(t) + if hdrlen == 0: + t = struct.unpack("<23f", f) # little-endian + hdrlen = isSpiderHeader(t) + return hdrlen + + +class SpiderImageFile(ImageFile.ImageFile): + format = "SPIDER" + format_description = "Spider 2D image" + _close_exclusive_fp_after_loading = False + + def _open(self): + # check header + n = 27 * 4 # read 27 float values + f = self.fp.read(n) + + try: + self.bigendian = 1 + t = struct.unpack(">27f", f) # try big-endian first + hdrlen = isSpiderHeader(t) + if hdrlen == 0: + self.bigendian = 0 + t = struct.unpack("<27f", f) # little-endian + hdrlen = isSpiderHeader(t) + if hdrlen == 0: + msg = "not a valid Spider file" + raise SyntaxError(msg) + except struct.error as e: + msg = "not a valid Spider file" + raise SyntaxError(msg) from e + + h = (99,) + t # add 1 value : spider header index starts at 1 + iform = int(h[5]) + if iform != 1: + msg = "not a Spider 2D image" + raise SyntaxError(msg) + + self._size = int(h[12]), int(h[2]) # size in pixels (width, height) + self.istack = int(h[24]) + self.imgnumber = int(h[27]) + + if self.istack == 0 and self.imgnumber == 0: + # stk=0, img=0: a regular 2D image + offset = hdrlen + self._nimages = 1 + elif self.istack > 0 and self.imgnumber == 0: + # stk>0, img=0: Opening the stack for the first time + self.imgbytes = int(h[12]) * int(h[2]) * 4 + self.hdrlen = hdrlen + self._nimages = int(h[26]) + # Point to the first image in the stack + offset = hdrlen * 2 + self.imgnumber = 1 + elif self.istack == 0 and self.imgnumber > 0: + # stk=0, img>0: an image within the stack + offset = hdrlen + self.stkoffset + self.istack = 2 # So Image knows it's still a stack + else: + msg = "inconsistent stack header values" + raise SyntaxError(msg) + + if self.bigendian: + self.rawmode = "F;32BF" + else: + self.rawmode = "F;32F" + self._mode = "F" + + self.tile = [("raw", (0, 0) + self.size, offset, (self.rawmode, 0, 1))] + self._fp = self.fp # FIXME: hack + + @property + def n_frames(self): + return self._nimages + + @property + def is_animated(self): + return self._nimages > 1 + + # 1st image index is zero (although SPIDER imgnumber starts at 1) + def tell(self): + if self.imgnumber < 1: + return 0 + else: + return self.imgnumber - 1 + + def seek(self, frame): + if self.istack == 0: + msg = "attempt to seek in a non-stack file" + raise EOFError(msg) + if not self._seek_check(frame): + return + self.stkoffset = self.hdrlen + frame * (self.hdrlen + self.imgbytes) + self.fp = self._fp + self.fp.seek(self.stkoffset) + self._open() + + # returns a byte image after rescaling to 0..255 + def convert2byte(self, depth=255): + (minimum, maximum) = self.getextrema() + m = 1 + if maximum != minimum: + m = depth / (maximum - minimum) + b = -m * minimum + return self.point(lambda i, m=m, b=b: i * m + b).convert("L") + + # returns a ImageTk.PhotoImage object, after rescaling to 0..255 + def tkPhotoImage(self): + from . import ImageTk + + return ImageTk.PhotoImage(self.convert2byte(), palette=256) + + +# -------------------------------------------------------------------- +# Image series + + +# given a list of filenames, return a list of images +def loadImageSeries(filelist=None): + """create a list of :py:class:`~PIL.Image.Image` objects for use in a montage""" + if filelist is None or len(filelist) < 1: + return + + imglist = [] + for img in filelist: + if not os.path.exists(img): + print(f"unable to find {img}") + continue + try: + with Image.open(img) as im: + im = im.convert2byte() + except Exception: + if not isSpiderImage(img): + print(img + " is not a Spider image file") + continue + im.info["filename"] = img + imglist.append(im) + return imglist + + +# -------------------------------------------------------------------- +# For saving images in Spider format + + +def makeSpiderHeader(im): + nsam, nrow = im.size + lenbyt = nsam * 4 # There are labrec records in the header + labrec = int(1024 / lenbyt) + if 1024 % lenbyt != 0: + labrec += 1 + labbyt = labrec * lenbyt + nvalues = int(labbyt / 4) + if nvalues < 23: + return [] + + hdr = [0.0] * nvalues + + # NB these are Fortran indices + hdr[1] = 1.0 # nslice (=1 for an image) + hdr[2] = float(nrow) # number of rows per slice + hdr[3] = float(nrow) # number of records in the image + hdr[5] = 1.0 # iform for 2D image + hdr[12] = float(nsam) # number of pixels per line + hdr[13] = float(labrec) # number of records in file header + hdr[22] = float(labbyt) # total number of bytes in header + hdr[23] = float(lenbyt) # record length in bytes + + # adjust for Fortran indexing + hdr = hdr[1:] + hdr.append(0.0) + # pack binary data into a string + return [struct.pack("f", v) for v in hdr] + + +def _save(im, fp, filename): + if im.mode[0] != "F": + im = im.convert("F") + + hdr = makeSpiderHeader(im) + if len(hdr) < 256: + msg = "Error creating Spider header" + raise OSError(msg) + + # write the SPIDER header + fp.writelines(hdr) + + rawmode = "F;32NF" # 32-bit native floating point + ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]) + + +def _save_spider(im, fp, filename): + # get the filename extension and register it with Image + ext = os.path.splitext(filename)[1] + Image.register_extension(SpiderImageFile.format, ext) + _save(im, fp, filename) + + +# -------------------------------------------------------------------- + + +Image.register_open(SpiderImageFile.format, SpiderImageFile) +Image.register_save(SpiderImageFile.format, _save_spider) + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Syntax: python3 SpiderImagePlugin.py [infile] [outfile]") + sys.exit() + + filename = sys.argv[1] + if not isSpiderImage(filename): + print("input image must be in Spider format") + sys.exit() + + with Image.open(filename) as im: + print("image: " + str(im)) + print("format: " + str(im.format)) + print("size: " + str(im.size)) + print("mode: " + str(im.mode)) + print("max, min: ", end=" ") + print(im.getextrema()) + + if len(sys.argv) > 2: + outfile = sys.argv[2] + + # perform some image operation + im = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT) + print( + f"saving a flipped version of {os.path.basename(filename)} " + f"as {outfile} " + ) + im.save(outfile, SpiderImageFile.format) diff --git a/venv/lib/python3.10/site-packages/PIL/SunImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/SunImagePlugin.py new file mode 100644 index 00000000..4e098474 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/SunImagePlugin.py @@ -0,0 +1,141 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Sun image file handling +# +# History: +# 1995-09-10 fl Created +# 1996-05-28 fl Fixed 32-bit alignment +# 1998-12-29 fl Import ImagePalette module +# 2001-12-18 fl Fixed palette loading (from Jean-Claude Rimbault) +# +# Copyright (c) 1997-2001 by Secret Labs AB +# Copyright (c) 1995-1996 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +from . import Image, ImageFile, ImagePalette +from ._binary import i32be as i32 + + +def _accept(prefix: bytes) -> bool: + return len(prefix) >= 4 and i32(prefix) == 0x59A66A95 + + +## +# Image plugin for Sun raster files. + + +class SunImageFile(ImageFile.ImageFile): + format = "SUN" + format_description = "Sun Raster File" + + def _open(self) -> None: + # The Sun Raster file header is 32 bytes in length + # and has the following format: + + # typedef struct _SunRaster + # { + # DWORD MagicNumber; /* Magic (identification) number */ + # DWORD Width; /* Width of image in pixels */ + # DWORD Height; /* Height of image in pixels */ + # DWORD Depth; /* Number of bits per pixel */ + # DWORD Length; /* Size of image data in bytes */ + # DWORD Type; /* Type of raster file */ + # DWORD ColorMapType; /* Type of color map */ + # DWORD ColorMapLength; /* Size of the color map in bytes */ + # } SUNRASTER; + + assert self.fp is not None + + # HEAD + s = self.fp.read(32) + if not _accept(s): + msg = "not an SUN raster file" + raise SyntaxError(msg) + + offset = 32 + + self._size = i32(s, 4), i32(s, 8) + + depth = i32(s, 12) + # data_length = i32(s, 16) # unreliable, ignore. + file_type = i32(s, 20) + palette_type = i32(s, 24) # 0: None, 1: RGB, 2: Raw/arbitrary + palette_length = i32(s, 28) + + if depth == 1: + self._mode, rawmode = "1", "1;I" + elif depth == 4: + self._mode, rawmode = "L", "L;4" + elif depth == 8: + self._mode = rawmode = "L" + elif depth == 24: + if file_type == 3: + self._mode, rawmode = "RGB", "RGB" + else: + self._mode, rawmode = "RGB", "BGR" + elif depth == 32: + if file_type == 3: + self._mode, rawmode = "RGB", "RGBX" + else: + self._mode, rawmode = "RGB", "BGRX" + else: + msg = "Unsupported Mode/Bit Depth" + raise SyntaxError(msg) + + if palette_length: + if palette_length > 1024: + msg = "Unsupported Color Palette Length" + raise SyntaxError(msg) + + if palette_type != 1: + msg = "Unsupported Palette Type" + raise SyntaxError(msg) + + offset = offset + palette_length + self.palette = ImagePalette.raw("RGB;L", self.fp.read(palette_length)) + if self.mode == "L": + self._mode = "P" + rawmode = rawmode.replace("L", "P") + + # 16 bit boundaries on stride + stride = ((self.size[0] * depth + 15) // 16) * 2 + + # file type: Type is the version (or flavor) of the bitmap + # file. The following values are typically found in the Type + # field: + # 0000h Old + # 0001h Standard + # 0002h Byte-encoded + # 0003h RGB format + # 0004h TIFF format + # 0005h IFF format + # FFFFh Experimental + + # Old and standard are the same, except for the length tag. + # byte-encoded is run-length-encoded + # RGB looks similar to standard, but RGB byte order + # TIFF and IFF mean that they were converted from T/IFF + # Experimental means that it's something else. + # (https://www.fileformat.info/format/sunraster/egff.htm) + + if file_type in (0, 1, 3, 4, 5): + self.tile = [("raw", (0, 0) + self.size, offset, (rawmode, stride))] + elif file_type == 2: + self.tile = [("sun_rle", (0, 0) + self.size, offset, rawmode)] + else: + msg = "Unsupported Sun Raster file type" + raise SyntaxError(msg) + + +# +# registry + + +Image.register_open(SunImageFile.format, SunImageFile, _accept) + +Image.register_extension(SunImageFile.format, ".ras") diff --git a/venv/lib/python3.10/site-packages/PIL/TarIO.py b/venv/lib/python3.10/site-packages/PIL/TarIO.py new file mode 100644 index 00000000..7470663b --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/TarIO.py @@ -0,0 +1,73 @@ +# +# The Python Imaging Library. +# $Id$ +# +# read files from within a tar file +# +# History: +# 95-06-18 fl Created +# 96-05-28 fl Open files in binary mode +# +# Copyright (c) Secret Labs AB 1997. +# Copyright (c) Fredrik Lundh 1995-96. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +from types import TracebackType + +from . import ContainerIO + + +class TarIO(ContainerIO.ContainerIO[bytes]): + """A file object that provides read access to a given member of a TAR file.""" + + def __init__(self, tarfile: str, file: str) -> None: + """ + Create file object. + + :param tarfile: Name of TAR file. + :param file: Name of member file. + """ + self.fh = open(tarfile, "rb") + + while True: + s = self.fh.read(512) + if len(s) != 512: + msg = "unexpected end of tar file" + raise OSError(msg) + + name = s[:100].decode("utf-8") + i = name.find("\0") + if i == 0: + msg = "cannot find subfile" + raise OSError(msg) + if i > 0: + name = name[:i] + + size = int(s[124:135], 8) + + if file == name: + break + + self.fh.seek((size + 511) & (~511), io.SEEK_CUR) + + # Open region + super().__init__(self.fh, self.fh.tell(), size) + + # Context manager support + def __enter__(self) -> TarIO: + return self + + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: TracebackType | None, + ) -> None: + self.close() + + def close(self) -> None: + self.fh.close() diff --git a/venv/lib/python3.10/site-packages/PIL/TgaImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/TgaImagePlugin.py new file mode 100644 index 00000000..401a83f9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/TgaImagePlugin.py @@ -0,0 +1,263 @@ +# +# The Python Imaging Library. +# $Id$ +# +# TGA file handling +# +# History: +# 95-09-01 fl created (reads 24-bit files only) +# 97-01-04 fl support more TGA versions, including compressed images +# 98-07-04 fl fixed orientation and alpha layer bugs +# 98-09-11 fl fixed orientation for runlength decoder +# +# Copyright (c) Secret Labs AB 1997-98. +# Copyright (c) Fredrik Lundh 1995-97. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import warnings +from typing import IO + +from . import Image, ImageFile, ImagePalette +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 + +# +# -------------------------------------------------------------------- +# Read RGA file + + +MODES = { + # map imagetype/depth to rawmode + (1, 8): "P", + (3, 1): "1", + (3, 8): "L", + (3, 16): "LA", + (2, 16): "BGR;5", + (2, 24): "BGR", + (2, 32): "BGRA", +} + + +## +# Image plugin for Targa files. + + +class TgaImageFile(ImageFile.ImageFile): + format = "TGA" + format_description = "Targa" + + def _open(self) -> None: + # process header + assert self.fp is not None + + s = self.fp.read(18) + + id_len = s[0] + + colormaptype = s[1] + imagetype = s[2] + + depth = s[16] + + flags = s[17] + + self._size = i16(s, 12), i16(s, 14) + + # validate header fields + if ( + colormaptype not in (0, 1) + or self.size[0] <= 0 + or self.size[1] <= 0 + or depth not in (1, 8, 16, 24, 32) + ): + msg = "not a TGA file" + raise SyntaxError(msg) + + # image mode + if imagetype in (3, 11): + self._mode = "L" + if depth == 1: + self._mode = "1" # ??? + elif depth == 16: + self._mode = "LA" + elif imagetype in (1, 9): + self._mode = "P" if colormaptype else "L" + elif imagetype in (2, 10): + self._mode = "RGB" + if depth == 32: + self._mode = "RGBA" + else: + msg = "unknown TGA mode" + raise SyntaxError(msg) + + # orientation + orientation = flags & 0x30 + self._flip_horizontally = orientation in [0x10, 0x30] + if orientation in [0x20, 0x30]: + orientation = 1 + elif orientation in [0, 0x10]: + orientation = -1 + else: + msg = "unknown TGA orientation" + raise SyntaxError(msg) + + self.info["orientation"] = orientation + + if imagetype & 8: + self.info["compression"] = "tga_rle" + + if id_len: + self.info["id_section"] = self.fp.read(id_len) + + if colormaptype: + # read palette + start, size, mapdepth = i16(s, 3), i16(s, 5), s[7] + if mapdepth == 16: + self.palette = ImagePalette.raw( + "BGR;15", b"\0" * 2 * start + self.fp.read(2 * size) + ) + elif mapdepth == 24: + self.palette = ImagePalette.raw( + "BGR", b"\0" * 3 * start + self.fp.read(3 * size) + ) + elif mapdepth == 32: + self.palette = ImagePalette.raw( + "BGRA", b"\0" * 4 * start + self.fp.read(4 * size) + ) + else: + msg = "unknown TGA map depth" + raise SyntaxError(msg) + + # setup tile descriptor + try: + rawmode = MODES[(imagetype & 7, depth)] + if imagetype & 8: + # compressed + self.tile = [ + ( + "tga_rle", + (0, 0) + self.size, + self.fp.tell(), + (rawmode, orientation, depth), + ) + ] + else: + self.tile = [ + ( + "raw", + (0, 0) + self.size, + self.fp.tell(), + (rawmode, 0, orientation), + ) + ] + except KeyError: + pass # cannot decode + + def load_end(self) -> None: + if self._flip_horizontally: + assert self.im is not None + self.im = self.im.transpose(Image.Transpose.FLIP_LEFT_RIGHT) + + +# +# -------------------------------------------------------------------- +# Write TGA file + + +SAVE = { + "1": ("1", 1, 0, 3), + "L": ("L", 8, 0, 3), + "LA": ("LA", 16, 0, 3), + "P": ("P", 8, 1, 1), + "RGB": ("BGR", 24, 0, 2), + "RGBA": ("BGRA", 32, 0, 2), +} + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + try: + rawmode, bits, colormaptype, imagetype = SAVE[im.mode] + except KeyError as e: + msg = f"cannot write mode {im.mode} as TGA" + raise OSError(msg) from e + + if "rle" in im.encoderinfo: + rle = im.encoderinfo["rle"] + else: + compression = im.encoderinfo.get("compression", im.info.get("compression")) + rle = compression == "tga_rle" + if rle: + imagetype += 8 + + id_section = im.encoderinfo.get("id_section", im.info.get("id_section", "")) + id_len = len(id_section) + if id_len > 255: + id_len = 255 + id_section = id_section[:255] + warnings.warn("id_section has been trimmed to 255 characters") + + if colormaptype: + assert im.im is not None + palette = im.im.getpalette("RGB", "BGR") + colormaplength, colormapentry = len(palette) // 3, 24 + else: + colormaplength, colormapentry = 0, 0 + + if im.mode in ("LA", "RGBA"): + flags = 8 + else: + flags = 0 + + orientation = im.encoderinfo.get("orientation", im.info.get("orientation", -1)) + if orientation > 0: + flags = flags | 0x20 + + fp.write( + o8(id_len) + + o8(colormaptype) + + o8(imagetype) + + o16(0) # colormapfirst + + o16(colormaplength) + + o8(colormapentry) + + o16(0) + + o16(0) + + o16(im.size[0]) + + o16(im.size[1]) + + o8(bits) + + o8(flags) + ) + + if id_section: + fp.write(id_section) + + if colormaptype: + fp.write(palette) + + if rle: + ImageFile._save( + im, fp, [("tga_rle", (0, 0) + im.size, 0, (rawmode, orientation))] + ) + else: + ImageFile._save( + im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, orientation))] + ) + + # write targa version 2 footer + fp.write(b"\000" * 8 + b"TRUEVISION-XFILE." + b"\000") + + +# +# -------------------------------------------------------------------- +# Registry + + +Image.register_open(TgaImageFile.format, TgaImageFile) +Image.register_save(TgaImageFile.format, _save) + +Image.register_extensions(TgaImageFile.format, [".tga", ".icb", ".vda", ".vst"]) + +Image.register_mime(TgaImageFile.format, "image/x-tga") diff --git a/venv/lib/python3.10/site-packages/PIL/TiffImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/TiffImagePlugin.py new file mode 100644 index 00000000..8bfcd290 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/TiffImagePlugin.py @@ -0,0 +1,2184 @@ +# +# The Python Imaging Library. +# $Id$ +# +# TIFF file handling +# +# TIFF is a flexible, if somewhat aged, image file format originally +# defined by Aldus. Although TIFF supports a wide variety of pixel +# layouts and compression methods, the name doesn't really stand for +# "thousands of incompatible file formats," it just feels that way. +# +# To read TIFF data from a stream, the stream must be seekable. For +# progressive decoding, make sure to use TIFF files where the tag +# directory is placed first in the file. +# +# History: +# 1995-09-01 fl Created +# 1996-05-04 fl Handle JPEGTABLES tag +# 1996-05-18 fl Fixed COLORMAP support +# 1997-01-05 fl Fixed PREDICTOR support +# 1997-08-27 fl Added support for rational tags (from Perry Stoll) +# 1998-01-10 fl Fixed seek/tell (from Jan Blom) +# 1998-07-15 fl Use private names for internal variables +# 1999-06-13 fl Rewritten for PIL 1.0 (1.0) +# 2000-10-11 fl Additional fixes for Python 2.0 (1.1) +# 2001-04-17 fl Fixed rewind support (seek to frame 0) (1.2) +# 2001-05-12 fl Added write support for more tags (from Greg Couch) (1.3) +# 2001-12-18 fl Added workaround for broken Matrox library +# 2002-01-18 fl Don't mess up if photometric tag is missing (D. Alan Stewart) +# 2003-05-19 fl Check FILLORDER tag +# 2003-09-26 fl Added RGBa support +# 2004-02-24 fl Added DPI support; fixed rational write support +# 2005-02-07 fl Added workaround for broken Corel Draw 10 files +# 2006-01-09 fl Added support for float/double tags (from Russell Nelson) +# +# Copyright (c) 1997-2006 by Secret Labs AB. All rights reserved. +# Copyright (c) 1995-1997 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import io +import itertools +import logging +import math +import os +import struct +import warnings +from collections.abc import MutableMapping +from fractions import Fraction +from numbers import Number, Rational +from typing import TYPE_CHECKING, Any, Callable + +from . import ExifTags, Image, ImageFile, ImageOps, ImagePalette, TiffTags +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 +from .TiffTags import TYPES + +logger = logging.getLogger(__name__) + +# Set these to true to force use of libtiff for reading or writing. +READ_LIBTIFF = False +WRITE_LIBTIFF = False +IFD_LEGACY_API = True +STRIP_SIZE = 65536 + +II = b"II" # little-endian (Intel style) +MM = b"MM" # big-endian (Motorola style) + +# +# -------------------------------------------------------------------- +# Read TIFF files + +# a few tag names, just to make the code below a bit more readable +OSUBFILETYPE = 255 +IMAGEWIDTH = 256 +IMAGELENGTH = 257 +BITSPERSAMPLE = 258 +COMPRESSION = 259 +PHOTOMETRIC_INTERPRETATION = 262 +FILLORDER = 266 +IMAGEDESCRIPTION = 270 +STRIPOFFSETS = 273 +SAMPLESPERPIXEL = 277 +ROWSPERSTRIP = 278 +STRIPBYTECOUNTS = 279 +X_RESOLUTION = 282 +Y_RESOLUTION = 283 +PLANAR_CONFIGURATION = 284 +RESOLUTION_UNIT = 296 +TRANSFERFUNCTION = 301 +SOFTWARE = 305 +DATE_TIME = 306 +ARTIST = 315 +PREDICTOR = 317 +COLORMAP = 320 +TILEWIDTH = 322 +TILELENGTH = 323 +TILEOFFSETS = 324 +TILEBYTECOUNTS = 325 +SUBIFD = 330 +EXTRASAMPLES = 338 +SAMPLEFORMAT = 339 +JPEGTABLES = 347 +YCBCRSUBSAMPLING = 530 +REFERENCEBLACKWHITE = 532 +COPYRIGHT = 33432 +IPTC_NAA_CHUNK = 33723 # newsphoto properties +PHOTOSHOP_CHUNK = 34377 # photoshop properties +ICCPROFILE = 34675 +EXIFIFD = 34665 +XMP = 700 +JPEGQUALITY = 65537 # pseudo-tag by libtiff + +# https://github.com/imagej/ImageJA/blob/master/src/main/java/ij/io/TiffDecoder.java +IMAGEJ_META_DATA_BYTE_COUNTS = 50838 +IMAGEJ_META_DATA = 50839 + +COMPRESSION_INFO = { + # Compression => pil compression name + 1: "raw", + 2: "tiff_ccitt", + 3: "group3", + 4: "group4", + 5: "tiff_lzw", + 6: "tiff_jpeg", # obsolete + 7: "jpeg", + 8: "tiff_adobe_deflate", + 32771: "tiff_raw_16", # 16-bit padding + 32773: "packbits", + 32809: "tiff_thunderscan", + 32946: "tiff_deflate", + 34676: "tiff_sgilog", + 34677: "tiff_sgilog24", + 34925: "lzma", + 50000: "zstd", + 50001: "webp", +} + +COMPRESSION_INFO_REV = {v: k for k, v in COMPRESSION_INFO.items()} + +OPEN_INFO = { + # (ByteOrder, PhotoInterpretation, SampleFormat, FillOrder, BitsPerSample, + # ExtraSamples) => mode, rawmode + (II, 0, (1,), 1, (1,), ()): ("1", "1;I"), + (MM, 0, (1,), 1, (1,), ()): ("1", "1;I"), + (II, 0, (1,), 2, (1,), ()): ("1", "1;IR"), + (MM, 0, (1,), 2, (1,), ()): ("1", "1;IR"), + (II, 1, (1,), 1, (1,), ()): ("1", "1"), + (MM, 1, (1,), 1, (1,), ()): ("1", "1"), + (II, 1, (1,), 2, (1,), ()): ("1", "1;R"), + (MM, 1, (1,), 2, (1,), ()): ("1", "1;R"), + (II, 0, (1,), 1, (2,), ()): ("L", "L;2I"), + (MM, 0, (1,), 1, (2,), ()): ("L", "L;2I"), + (II, 0, (1,), 2, (2,), ()): ("L", "L;2IR"), + (MM, 0, (1,), 2, (2,), ()): ("L", "L;2IR"), + (II, 1, (1,), 1, (2,), ()): ("L", "L;2"), + (MM, 1, (1,), 1, (2,), ()): ("L", "L;2"), + (II, 1, (1,), 2, (2,), ()): ("L", "L;2R"), + (MM, 1, (1,), 2, (2,), ()): ("L", "L;2R"), + (II, 0, (1,), 1, (4,), ()): ("L", "L;4I"), + (MM, 0, (1,), 1, (4,), ()): ("L", "L;4I"), + (II, 0, (1,), 2, (4,), ()): ("L", "L;4IR"), + (MM, 0, (1,), 2, (4,), ()): ("L", "L;4IR"), + (II, 1, (1,), 1, (4,), ()): ("L", "L;4"), + (MM, 1, (1,), 1, (4,), ()): ("L", "L;4"), + (II, 1, (1,), 2, (4,), ()): ("L", "L;4R"), + (MM, 1, (1,), 2, (4,), ()): ("L", "L;4R"), + (II, 0, (1,), 1, (8,), ()): ("L", "L;I"), + (MM, 0, (1,), 1, (8,), ()): ("L", "L;I"), + (II, 0, (1,), 2, (8,), ()): ("L", "L;IR"), + (MM, 0, (1,), 2, (8,), ()): ("L", "L;IR"), + (II, 1, (1,), 1, (8,), ()): ("L", "L"), + (MM, 1, (1,), 1, (8,), ()): ("L", "L"), + (II, 1, (2,), 1, (8,), ()): ("L", "L"), + (MM, 1, (2,), 1, (8,), ()): ("L", "L"), + (II, 1, (1,), 2, (8,), ()): ("L", "L;R"), + (MM, 1, (1,), 2, (8,), ()): ("L", "L;R"), + (II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"), + (II, 0, (1,), 1, (16,), ()): ("I;16", "I;16"), + (II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"), + (MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"), + (II, 1, (1,), 2, (16,), ()): ("I;16", "I;16R"), + (II, 1, (2,), 1, (16,), ()): ("I", "I;16S"), + (MM, 1, (2,), 1, (16,), ()): ("I", "I;16BS"), + (II, 0, (3,), 1, (32,), ()): ("F", "F;32F"), + (MM, 0, (3,), 1, (32,), ()): ("F", "F;32BF"), + (II, 1, (1,), 1, (32,), ()): ("I", "I;32N"), + (II, 1, (2,), 1, (32,), ()): ("I", "I;32S"), + (MM, 1, (2,), 1, (32,), ()): ("I", "I;32BS"), + (II, 1, (3,), 1, (32,), ()): ("F", "F;32F"), + (MM, 1, (3,), 1, (32,), ()): ("F", "F;32BF"), + (II, 1, (1,), 1, (8, 8), (2,)): ("LA", "LA"), + (MM, 1, (1,), 1, (8, 8), (2,)): ("LA", "LA"), + (II, 2, (1,), 1, (8, 8, 8), ()): ("RGB", "RGB"), + (MM, 2, (1,), 1, (8, 8, 8), ()): ("RGB", "RGB"), + (II, 2, (1,), 2, (8, 8, 8), ()): ("RGB", "RGB;R"), + (MM, 2, (1,), 2, (8, 8, 8), ()): ("RGB", "RGB;R"), + (II, 2, (1,), 1, (8, 8, 8, 8), ()): ("RGBA", "RGBA"), # missing ExtraSamples + (MM, 2, (1,), 1, (8, 8, 8, 8), ()): ("RGBA", "RGBA"), # missing ExtraSamples + (II, 2, (1,), 1, (8, 8, 8, 8), (0,)): ("RGBX", "RGBX"), + (MM, 2, (1,), 1, (8, 8, 8, 8), (0,)): ("RGBX", "RGBX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("RGBX", "RGBXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("RGBX", "RGBXX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("RGBX", "RGBXXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("RGBX", "RGBXXX"), + (II, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), + (MM, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8), (1, 0)): ("RGBA", "RGBaX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (1, 0)): ("RGBA", "RGBaX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0, 0)): ("RGBA", "RGBaXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0, 0)): ("RGBA", "RGBaXX"), + (II, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), + (MM, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0, 0)): ("RGBA", "RGBAXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0, 0)): ("RGBA", "RGBAXX"), + (II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 + (MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 + (II, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16L"), + (MM, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16B"), + (II, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16L"), + (MM, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16B"), + (II, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16L"), + (MM, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16B"), + (II, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16L"), + (MM, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16B"), + (II, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16L"), + (MM, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16B"), + (II, 3, (1,), 1, (1,), ()): ("P", "P;1"), + (MM, 3, (1,), 1, (1,), ()): ("P", "P;1"), + (II, 3, (1,), 2, (1,), ()): ("P", "P;1R"), + (MM, 3, (1,), 2, (1,), ()): ("P", "P;1R"), + (II, 3, (1,), 1, (2,), ()): ("P", "P;2"), + (MM, 3, (1,), 1, (2,), ()): ("P", "P;2"), + (II, 3, (1,), 2, (2,), ()): ("P", "P;2R"), + (MM, 3, (1,), 2, (2,), ()): ("P", "P;2R"), + (II, 3, (1,), 1, (4,), ()): ("P", "P;4"), + (MM, 3, (1,), 1, (4,), ()): ("P", "P;4"), + (II, 3, (1,), 2, (4,), ()): ("P", "P;4R"), + (MM, 3, (1,), 2, (4,), ()): ("P", "P;4R"), + (II, 3, (1,), 1, (8,), ()): ("P", "P"), + (MM, 3, (1,), 1, (8,), ()): ("P", "P"), + (II, 3, (1,), 1, (8, 8), (2,)): ("PA", "PA"), + (MM, 3, (1,), 1, (8, 8), (2,)): ("PA", "PA"), + (II, 3, (1,), 2, (8,), ()): ("P", "P;R"), + (MM, 3, (1,), 2, (8,), ()): ("P", "P;R"), + (II, 5, (1,), 1, (8, 8, 8, 8), ()): ("CMYK", "CMYK"), + (MM, 5, (1,), 1, (8, 8, 8, 8), ()): ("CMYK", "CMYK"), + (II, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX"), + (MM, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX"), + (II, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"), + (MM, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"), + (II, 5, (1,), 1, (16, 16, 16, 16), ()): ("CMYK", "CMYK;16L"), + (II, 6, (1,), 1, (8,), ()): ("L", "L"), + (MM, 6, (1,), 1, (8,), ()): ("L", "L"), + # JPEG compressed images handled by LibTiff and auto-converted to RGBX + # Minimal Baseline TIFF requires YCbCr images to have 3 SamplesPerPixel + (II, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"), + (MM, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"), + (II, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), + (MM, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), +} + +MAX_SAMPLESPERPIXEL = max(len(key_tp[4]) for key_tp in OPEN_INFO) + +PREFIXES = [ + b"MM\x00\x2A", # Valid TIFF header with big-endian byte order + b"II\x2A\x00", # Valid TIFF header with little-endian byte order + b"MM\x2A\x00", # Invalid TIFF header, assume big-endian + b"II\x00\x2A", # Invalid TIFF header, assume little-endian + b"MM\x00\x2B", # BigTIFF with big-endian byte order + b"II\x2B\x00", # BigTIFF with little-endian byte order +] + + +def _accept(prefix): + return prefix[:4] in PREFIXES + + +def _limit_rational(val, max_val): + inv = abs(val) > 1 + n_d = IFDRational(1 / val if inv else val).limit_rational(max_val) + return n_d[::-1] if inv else n_d + + +def _limit_signed_rational(val, max_val, min_val): + frac = Fraction(val) + n_d = frac.numerator, frac.denominator + + if min(n_d) < min_val: + n_d = _limit_rational(val, abs(min_val)) + + if max(n_d) > max_val: + val = Fraction(*n_d) + n_d = _limit_rational(val, max_val) + + return n_d + + +## +# Wrapper for TIFF IFDs. + +_load_dispatch = {} +_write_dispatch = {} + + +def _delegate(op): + def delegate(self, *args): + return getattr(self._val, op)(*args) + + return delegate + + +class IFDRational(Rational): + """Implements a rational class where 0/0 is a legal value to match + the in the wild use of exif rationals. + + e.g., DigitalZoomRatio - 0.00/0.00 indicates that no digital zoom was used + """ + + """ If the denominator is 0, store this as a float('nan'), otherwise store + as a fractions.Fraction(). Delegate as appropriate + + """ + + __slots__ = ("_numerator", "_denominator", "_val") + + def __init__(self, value, denominator=1): + """ + :param value: either an integer numerator, a + float/rational/other number, or an IFDRational + :param denominator: Optional integer denominator + """ + if isinstance(value, IFDRational): + self._numerator = value.numerator + self._denominator = value.denominator + self._val = value._val + return + + if isinstance(value, Fraction): + self._numerator = value.numerator + self._denominator = value.denominator + else: + self._numerator = value + self._denominator = denominator + + if denominator == 0: + self._val = float("nan") + elif denominator == 1: + self._val = Fraction(value) + else: + self._val = Fraction(value, denominator) + + @property + def numerator(self): + return self._numerator + + @property + def denominator(self): + return self._denominator + + def limit_rational(self, max_denominator): + """ + + :param max_denominator: Integer, the maximum denominator value + :returns: Tuple of (numerator, denominator) + """ + + if self.denominator == 0: + return self.numerator, self.denominator + + f = self._val.limit_denominator(max_denominator) + return f.numerator, f.denominator + + def __repr__(self): + return str(float(self._val)) + + def __hash__(self): + return self._val.__hash__() + + def __eq__(self, other): + val = self._val + if isinstance(other, IFDRational): + other = other._val + if isinstance(other, float): + val = float(val) + return val == other + + def __getstate__(self): + return [self._val, self._numerator, self._denominator] + + def __setstate__(self, state): + IFDRational.__init__(self, 0) + _val, _numerator, _denominator = state + self._val = _val + self._numerator = _numerator + self._denominator = _denominator + + """ a = ['add','radd', 'sub', 'rsub', 'mul', 'rmul', + 'truediv', 'rtruediv', 'floordiv', 'rfloordiv', + 'mod','rmod', 'pow','rpow', 'pos', 'neg', + 'abs', 'trunc', 'lt', 'gt', 'le', 'ge', 'bool', + 'ceil', 'floor', 'round'] + print("\n".join("__%s__ = _delegate('__%s__')" % (s,s) for s in a)) + """ + + __add__ = _delegate("__add__") + __radd__ = _delegate("__radd__") + __sub__ = _delegate("__sub__") + __rsub__ = _delegate("__rsub__") + __mul__ = _delegate("__mul__") + __rmul__ = _delegate("__rmul__") + __truediv__ = _delegate("__truediv__") + __rtruediv__ = _delegate("__rtruediv__") + __floordiv__ = _delegate("__floordiv__") + __rfloordiv__ = _delegate("__rfloordiv__") + __mod__ = _delegate("__mod__") + __rmod__ = _delegate("__rmod__") + __pow__ = _delegate("__pow__") + __rpow__ = _delegate("__rpow__") + __pos__ = _delegate("__pos__") + __neg__ = _delegate("__neg__") + __abs__ = _delegate("__abs__") + __trunc__ = _delegate("__trunc__") + __lt__ = _delegate("__lt__") + __gt__ = _delegate("__gt__") + __le__ = _delegate("__le__") + __ge__ = _delegate("__ge__") + __bool__ = _delegate("__bool__") + __ceil__ = _delegate("__ceil__") + __floor__ = _delegate("__floor__") + __round__ = _delegate("__round__") + # Python >= 3.11 + if hasattr(Fraction, "__int__"): + __int__ = _delegate("__int__") + + +def _register_loader(idx, size): + def decorator(func): + from .TiffTags import TYPES + + if func.__name__.startswith("load_"): + TYPES[idx] = func.__name__[5:].replace("_", " ") + _load_dispatch[idx] = size, func # noqa: F821 + return func + + return decorator + + +def _register_writer(idx): + def decorator(func): + _write_dispatch[idx] = func # noqa: F821 + return func + + return decorator + + +def _register_basic(idx_fmt_name): + from .TiffTags import TYPES + + idx, fmt, name = idx_fmt_name + TYPES[idx] = name + size = struct.calcsize("=" + fmt) + _load_dispatch[idx] = ( # noqa: F821 + size, + lambda self, data, legacy_api=True: ( + self._unpack(f"{len(data) // size}{fmt}", data) + ), + ) + _write_dispatch[idx] = lambda self, *values: ( # noqa: F821 + b"".join(self._pack(fmt, value) for value in values) + ) + + +if TYPE_CHECKING: + _IFDv2Base = MutableMapping[int, Any] +else: + _IFDv2Base = MutableMapping + + +class ImageFileDirectory_v2(_IFDv2Base): + """This class represents a TIFF tag directory. To speed things up, we + don't decode tags unless they're asked for. + + Exposes a dictionary interface of the tags in the directory:: + + ifd = ImageFileDirectory_v2() + ifd[key] = 'Some Data' + ifd.tagtype[key] = TiffTags.ASCII + print(ifd[key]) + 'Some Data' + + Individual values are returned as the strings or numbers, sequences are + returned as tuples of the values. + + The tiff metadata type of each item is stored in a dictionary of + tag types in + :attr:`~PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype`. The types + are read from a tiff file, guessed from the type added, or added + manually. + + Data Structures: + + * ``self.tagtype = {}`` + + * Key: numerical TIFF tag number + * Value: integer corresponding to the data type from + :py:data:`.TiffTags.TYPES` + + .. versionadded:: 3.0.0 + + 'Internal' data structures: + + * ``self._tags_v2 = {}`` + + * Key: numerical TIFF tag number + * Value: decoded data, as tuple for multiple values + + * ``self._tagdata = {}`` + + * Key: numerical TIFF tag number + * Value: undecoded byte string from file + + * ``self._tags_v1 = {}`` + + * Key: numerical TIFF tag number + * Value: decoded data in the v1 format + + Tags will be found in the private attributes ``self._tagdata``, and in + ``self._tags_v2`` once decoded. + + ``self.legacy_api`` is a value for internal use, and shouldn't be changed + from outside code. In cooperation with + :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1`, if ``legacy_api`` + is true, then decoded tags will be populated into both ``_tags_v1`` and + ``_tags_v2``. ``_tags_v2`` will be used if this IFD is used in the TIFF + save routine. Tags should be read from ``_tags_v1`` if + ``legacy_api == true``. + + """ + + _load_dispatch: dict[int, Callable[[ImageFileDirectory_v2, bytes, bool], Any]] = {} + _write_dispatch: dict[int, Callable[..., Any]] = {} + + def __init__(self, ifh=b"II\052\0\0\0\0\0", prefix=None, group=None): + """Initialize an ImageFileDirectory. + + To construct an ImageFileDirectory from a real file, pass the 8-byte + magic header to the constructor. To only set the endianness, pass it + as the 'prefix' keyword argument. + + :param ifh: One of the accepted magic headers (cf. PREFIXES); also sets + endianness. + :param prefix: Override the endianness of the file. + """ + if not _accept(ifh): + msg = f"not a TIFF file (header {repr(ifh)} not valid)" + raise SyntaxError(msg) + self._prefix = prefix if prefix is not None else ifh[:2] + if self._prefix == MM: + self._endian = ">" + elif self._prefix == II: + self._endian = "<" + else: + msg = "not a TIFF IFD" + raise SyntaxError(msg) + self._bigtiff = ifh[2] == 43 + self.group = group + self.tagtype = {} + """ Dictionary of tag types """ + self.reset() + (self.next,) = ( + self._unpack("Q", ifh[8:]) if self._bigtiff else self._unpack("L", ifh[4:]) + ) + self._legacy_api = False + + prefix = property(lambda self: self._prefix) + offset = property(lambda self: self._offset) + + @property + def legacy_api(self): + return self._legacy_api + + @legacy_api.setter + def legacy_api(self, value): + msg = "Not allowing setting of legacy api" + raise Exception(msg) + + def reset(self): + self._tags_v1 = {} # will remain empty if legacy_api is false + self._tags_v2 = {} # main tag storage + self._tagdata = {} + self.tagtype = {} # added 2008-06-05 by Florian Hoech + self._next = None + self._offset = None + + def __str__(self): + return str(dict(self)) + + def named(self): + """ + :returns: dict of name|key: value + + Returns the complete tag dictionary, with named tags where possible. + """ + return { + TiffTags.lookup(code, self.group).name: value + for code, value in self.items() + } + + def __len__(self): + return len(set(self._tagdata) | set(self._tags_v2)) + + def __getitem__(self, tag): + if tag not in self._tags_v2: # unpack on the fly + data = self._tagdata[tag] + typ = self.tagtype[tag] + size, handler = self._load_dispatch[typ] + self[tag] = handler(self, data, self.legacy_api) # check type + val = self._tags_v2[tag] + if self.legacy_api and not isinstance(val, (tuple, bytes)): + val = (val,) + return val + + def __contains__(self, tag): + return tag in self._tags_v2 or tag in self._tagdata + + def __setitem__(self, tag, value): + self._setitem(tag, value, self.legacy_api) + + def _setitem(self, tag, value, legacy_api): + basetypes = (Number, bytes, str) + + info = TiffTags.lookup(tag, self.group) + values = [value] if isinstance(value, basetypes) else value + + if tag not in self.tagtype: + if info.type: + self.tagtype[tag] = info.type + else: + self.tagtype[tag] = TiffTags.UNDEFINED + if all(isinstance(v, IFDRational) for v in values): + self.tagtype[tag] = ( + TiffTags.RATIONAL + if all(v >= 0 for v in values) + else TiffTags.SIGNED_RATIONAL + ) + elif all(isinstance(v, int) for v in values): + if all(0 <= v < 2**16 for v in values): + self.tagtype[tag] = TiffTags.SHORT + elif all(-(2**15) < v < 2**15 for v in values): + self.tagtype[tag] = TiffTags.SIGNED_SHORT + else: + self.tagtype[tag] = ( + TiffTags.LONG + if all(v >= 0 for v in values) + else TiffTags.SIGNED_LONG + ) + elif all(isinstance(v, float) for v in values): + self.tagtype[tag] = TiffTags.DOUBLE + elif all(isinstance(v, str) for v in values): + self.tagtype[tag] = TiffTags.ASCII + elif all(isinstance(v, bytes) for v in values): + self.tagtype[tag] = TiffTags.BYTE + + if self.tagtype[tag] == TiffTags.UNDEFINED: + values = [ + v.encode("ascii", "replace") if isinstance(v, str) else v + for v in values + ] + elif self.tagtype[tag] == TiffTags.RATIONAL: + values = [float(v) if isinstance(v, int) else v for v in values] + + is_ifd = self.tagtype[tag] == TiffTags.LONG and isinstance(values, dict) + if not is_ifd: + values = tuple(info.cvt_enum(value) for value in values) + + dest = self._tags_v1 if legacy_api else self._tags_v2 + + # Three branches: + # Spec'd length == 1, Actual length 1, store as element + # Spec'd length == 1, Actual > 1, Warn and truncate. Formerly barfed. + # No Spec, Actual length 1, Formerly (<4.2) returned a 1 element tuple. + # Don't mess with the legacy api, since it's frozen. + if not is_ifd and ( + (info.length == 1) + or self.tagtype[tag] == TiffTags.BYTE + or (info.length is None and len(values) == 1 and not legacy_api) + ): + # Don't mess with the legacy api, since it's frozen. + if legacy_api and self.tagtype[tag] in [ + TiffTags.RATIONAL, + TiffTags.SIGNED_RATIONAL, + ]: # rationals + values = (values,) + try: + (dest[tag],) = values + except ValueError: + # We've got a builtin tag with 1 expected entry + warnings.warn( + f"Metadata Warning, tag {tag} had too many entries: " + f"{len(values)}, expected 1" + ) + dest[tag] = values[0] + + else: + # Spec'd length > 1 or undefined + # Unspec'd, and length > 1 + dest[tag] = values + + def __delitem__(self, tag): + self._tags_v2.pop(tag, None) + self._tags_v1.pop(tag, None) + self._tagdata.pop(tag, None) + + def __iter__(self): + return iter(set(self._tagdata) | set(self._tags_v2)) + + def _unpack(self, fmt, data): + return struct.unpack(self._endian + fmt, data) + + def _pack(self, fmt, *values): + return struct.pack(self._endian + fmt, *values) + + list( + map( + _register_basic, + [ + (TiffTags.SHORT, "H", "short"), + (TiffTags.LONG, "L", "long"), + (TiffTags.SIGNED_BYTE, "b", "signed byte"), + (TiffTags.SIGNED_SHORT, "h", "signed short"), + (TiffTags.SIGNED_LONG, "l", "signed long"), + (TiffTags.FLOAT, "f", "float"), + (TiffTags.DOUBLE, "d", "double"), + (TiffTags.IFD, "L", "long"), + (TiffTags.LONG8, "Q", "long8"), + ], + ) + ) + + @_register_loader(1, 1) # Basic type, except for the legacy API. + def load_byte(self, data, legacy_api=True): + return data + + @_register_writer(1) # Basic type, except for the legacy API. + def write_byte(self, data): + if isinstance(data, IFDRational): + data = int(data) + if isinstance(data, int): + data = bytes((data,)) + return data + + @_register_loader(2, 1) + def load_string(self, data, legacy_api=True): + if data.endswith(b"\0"): + data = data[:-1] + return data.decode("latin-1", "replace") + + @_register_writer(2) + def write_string(self, value): + # remerge of https://github.com/python-pillow/Pillow/pull/1416 + if isinstance(value, int): + value = str(value) + if not isinstance(value, bytes): + value = value.encode("ascii", "replace") + return value + b"\0" + + @_register_loader(5, 8) + def load_rational(self, data, legacy_api=True): + vals = self._unpack(f"{len(data) // 4}L", data) + + def combine(a, b): + return (a, b) if legacy_api else IFDRational(a, b) + + return tuple(combine(num, denom) for num, denom in zip(vals[::2], vals[1::2])) + + @_register_writer(5) + def write_rational(self, *values): + return b"".join( + self._pack("2L", *_limit_rational(frac, 2**32 - 1)) for frac in values + ) + + @_register_loader(7, 1) + def load_undefined(self, data, legacy_api=True): + return data + + @_register_writer(7) + def write_undefined(self, value): + if isinstance(value, IFDRational): + value = int(value) + if isinstance(value, int): + value = str(value).encode("ascii", "replace") + return value + + @_register_loader(10, 8) + def load_signed_rational(self, data, legacy_api=True): + vals = self._unpack(f"{len(data) // 4}l", data) + + def combine(a, b): + return (a, b) if legacy_api else IFDRational(a, b) + + return tuple(combine(num, denom) for num, denom in zip(vals[::2], vals[1::2])) + + @_register_writer(10) + def write_signed_rational(self, *values): + return b"".join( + self._pack("2l", *_limit_signed_rational(frac, 2**31 - 1, -(2**31))) + for frac in values + ) + + def _ensure_read(self, fp, size): + ret = fp.read(size) + if len(ret) != size: + msg = ( + "Corrupt EXIF data. " + f"Expecting to read {size} bytes but only got {len(ret)}. " + ) + raise OSError(msg) + return ret + + def load(self, fp): + self.reset() + self._offset = fp.tell() + + try: + tag_count = ( + self._unpack("Q", self._ensure_read(fp, 8)) + if self._bigtiff + else self._unpack("H", self._ensure_read(fp, 2)) + )[0] + for i in range(tag_count): + tag, typ, count, data = ( + self._unpack("HHQ8s", self._ensure_read(fp, 20)) + if self._bigtiff + else self._unpack("HHL4s", self._ensure_read(fp, 12)) + ) + + tagname = TiffTags.lookup(tag, self.group).name + typname = TYPES.get(typ, "unknown") + msg = f"tag: {tagname} ({tag}) - type: {typname} ({typ})" + + try: + unit_size, handler = self._load_dispatch[typ] + except KeyError: + logger.debug("%s - unsupported type %s", msg, typ) + continue # ignore unsupported type + size = count * unit_size + if size > (8 if self._bigtiff else 4): + here = fp.tell() + (offset,) = self._unpack("Q" if self._bigtiff else "L", data) + msg += f" Tag Location: {here} - Data Location: {offset}" + fp.seek(offset) + data = ImageFile._safe_read(fp, size) + fp.seek(here) + else: + data = data[:size] + + if len(data) != size: + warnings.warn( + "Possibly corrupt EXIF data. " + f"Expecting to read {size} bytes but only got {len(data)}." + f" Skipping tag {tag}" + ) + logger.debug(msg) + continue + + if not data: + logger.debug(msg) + continue + + self._tagdata[tag] = data + self.tagtype[tag] = typ + + msg += " - value: " + ( + "" % size if size > 32 else repr(data) + ) + logger.debug(msg) + + (self.next,) = ( + self._unpack("Q", self._ensure_read(fp, 8)) + if self._bigtiff + else self._unpack("L", self._ensure_read(fp, 4)) + ) + except OSError as msg: + warnings.warn(str(msg)) + return + + def tobytes(self, offset=0): + # FIXME What about tagdata? + result = self._pack("H", len(self._tags_v2)) + + entries = [] + offset = offset + len(result) + len(self._tags_v2) * 12 + 4 + stripoffsets = None + + # pass 1: convert tags to binary format + # always write tags in ascending order + for tag, value in sorted(self._tags_v2.items()): + if tag == STRIPOFFSETS: + stripoffsets = len(entries) + typ = self.tagtype.get(tag) + logger.debug("Tag %s, Type: %s, Value: %s", tag, typ, repr(value)) + is_ifd = typ == TiffTags.LONG and isinstance(value, dict) + if is_ifd: + if self._endian == "<": + ifh = b"II\x2A\x00\x08\x00\x00\x00" + else: + ifh = b"MM\x00\x2A\x00\x00\x00\x08" + ifd = ImageFileDirectory_v2(ifh, group=tag) + values = self._tags_v2[tag] + for ifd_tag, ifd_value in values.items(): + ifd[ifd_tag] = ifd_value + data = ifd.tobytes(offset) + else: + values = value if isinstance(value, tuple) else (value,) + data = self._write_dispatch[typ](self, *values) + + tagname = TiffTags.lookup(tag, self.group).name + typname = "ifd" if is_ifd else TYPES.get(typ, "unknown") + msg = f"save: {tagname} ({tag}) - type: {typname} ({typ})" + msg += " - value: " + ( + "" % len(data) if len(data) >= 16 else str(values) + ) + logger.debug(msg) + + # count is sum of lengths for string and arbitrary data + if is_ifd: + count = 1 + elif typ in [TiffTags.BYTE, TiffTags.ASCII, TiffTags.UNDEFINED]: + count = len(data) + else: + count = len(values) + # figure out if data fits into the entry + if len(data) <= 4: + entries.append((tag, typ, count, data.ljust(4, b"\0"), b"")) + else: + entries.append((tag, typ, count, self._pack("L", offset), data)) + offset += (len(data) + 1) // 2 * 2 # pad to word + + # update strip offset data to point beyond auxiliary data + if stripoffsets is not None: + tag, typ, count, value, data = entries[stripoffsets] + if data: + msg = "multistrip support not yet implemented" + raise NotImplementedError(msg) + value = self._pack("L", self._unpack("L", value)[0] + offset) + entries[stripoffsets] = tag, typ, count, value, data + + # pass 2: write entries to file + for tag, typ, count, value, data in entries: + logger.debug("%s %s %s %s %s", tag, typ, count, repr(value), repr(data)) + result += self._pack("HHL4s", tag, typ, count, value) + + # -- overwrite here for multi-page -- + result += b"\0\0\0\0" # end of entries + + # pass 3: write auxiliary data to file + for tag, typ, count, value, data in entries: + result += data + if len(data) & 1: + result += b"\0" + + return result + + def save(self, fp): + if fp.tell() == 0: # skip TIFF header on subsequent pages + # tiff header -- PIL always starts the first IFD at offset 8 + fp.write(self._prefix + self._pack("HL", 42, 8)) + + offset = fp.tell() + result = self.tobytes(offset) + fp.write(result) + return offset + len(result) + + +ImageFileDirectory_v2._load_dispatch = _load_dispatch +ImageFileDirectory_v2._write_dispatch = _write_dispatch +for idx, name in TYPES.items(): + name = name.replace(" ", "_") + setattr(ImageFileDirectory_v2, "load_" + name, _load_dispatch[idx][1]) + setattr(ImageFileDirectory_v2, "write_" + name, _write_dispatch[idx]) +del _load_dispatch, _write_dispatch, idx, name + + +# Legacy ImageFileDirectory support. +class ImageFileDirectory_v1(ImageFileDirectory_v2): + """This class represents the **legacy** interface to a TIFF tag directory. + + Exposes a dictionary interface of the tags in the directory:: + + ifd = ImageFileDirectory_v1() + ifd[key] = 'Some Data' + ifd.tagtype[key] = TiffTags.ASCII + print(ifd[key]) + ('Some Data',) + + Also contains a dictionary of tag types as read from the tiff image file, + :attr:`~PIL.TiffImagePlugin.ImageFileDirectory_v1.tagtype`. + + Values are returned as a tuple. + + .. deprecated:: 3.0.0 + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._legacy_api = True + + tags = property(lambda self: self._tags_v1) + tagdata = property(lambda self: self._tagdata) + + # defined in ImageFileDirectory_v2 + tagtype: dict[int, int] + """Dictionary of tag types""" + + @classmethod + def from_v2(cls, original): + """Returns an + :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` + instance with the same data as is contained in the original + :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` + instance. + + :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` + + """ + + ifd = cls(prefix=original.prefix) + ifd._tagdata = original._tagdata + ifd.tagtype = original.tagtype + ifd.next = original.next # an indicator for multipage tiffs + return ifd + + def to_v2(self): + """Returns an + :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` + instance with the same data as is contained in the original + :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` + instance. + + :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` + + """ + + ifd = ImageFileDirectory_v2(prefix=self.prefix) + ifd._tagdata = dict(self._tagdata) + ifd.tagtype = dict(self.tagtype) + ifd._tags_v2 = dict(self._tags_v2) + return ifd + + def __contains__(self, tag): + return tag in self._tags_v1 or tag in self._tagdata + + def __len__(self): + return len(set(self._tagdata) | set(self._tags_v1)) + + def __iter__(self): + return iter(set(self._tagdata) | set(self._tags_v1)) + + def __setitem__(self, tag, value): + for legacy_api in (False, True): + self._setitem(tag, value, legacy_api) + + def __getitem__(self, tag): + if tag not in self._tags_v1: # unpack on the fly + data = self._tagdata[tag] + typ = self.tagtype[tag] + size, handler = self._load_dispatch[typ] + for legacy in (False, True): + self._setitem(tag, handler(self, data, legacy), legacy) + val = self._tags_v1[tag] + if not isinstance(val, (tuple, bytes)): + val = (val,) + return val + + +# undone -- switch this pointer when IFD_LEGACY_API == False +ImageFileDirectory = ImageFileDirectory_v1 + + +## +# Image plugin for TIFF files. + + +class TiffImageFile(ImageFile.ImageFile): + format = "TIFF" + format_description = "Adobe TIFF" + _close_exclusive_fp_after_loading = False + + def __init__(self, fp=None, filename=None): + self.tag_v2 = None + """ Image file directory (tag dictionary) """ + + self.tag = None + """ Legacy tag entries """ + + super().__init__(fp, filename) + + def _open(self): + """Open the first image in a TIFF file""" + + # Header + ifh = self.fp.read(8) + if ifh[2] == 43: + ifh += self.fp.read(8) + + self.tag_v2 = ImageFileDirectory_v2(ifh) + + # legacy IFD entries will be filled in later + self.ifd = None + + # setup frame pointers + self.__first = self.__next = self.tag_v2.next + self.__frame = -1 + self._fp = self.fp + self._frame_pos = [] + self._n_frames = None + + logger.debug("*** TiffImageFile._open ***") + logger.debug("- __first: %s", self.__first) + logger.debug("- ifh: %s", repr(ifh)) # Use repr to avoid str(bytes) + + # and load the first frame + self._seek(0) + + @property + def n_frames(self): + if self._n_frames is None: + current = self.tell() + self._seek(len(self._frame_pos)) + while self._n_frames is None: + self._seek(self.tell() + 1) + self.seek(current) + return self._n_frames + + def seek(self, frame): + """Select a given frame as current image""" + if not self._seek_check(frame): + return + self._seek(frame) + # Create a new core image object on second and + # subsequent frames in the image. Image may be + # different size/mode. + Image._decompression_bomb_check(self.size) + self.im = Image.core.new(self.mode, self.size) + + def _seek(self, frame): + self.fp = self._fp + + # reset buffered io handle in case fp + # was passed to libtiff, invalidating the buffer + self.fp.tell() + + while len(self._frame_pos) <= frame: + if not self.__next: + msg = "no more images in TIFF file" + raise EOFError(msg) + logger.debug( + "Seeking to frame %s, on frame %s, __next %s, location: %s", + frame, + self.__frame, + self.__next, + self.fp.tell(), + ) + if self.__next >= 2**63: + msg = "Unable to seek to frame" + raise ValueError(msg) + self.fp.seek(self.__next) + self._frame_pos.append(self.__next) + logger.debug("Loading tags, location: %s", self.fp.tell()) + self.tag_v2.load(self.fp) + if self.tag_v2.next in self._frame_pos: + # This IFD has already been processed + # Declare this to be the end of the image + self.__next = 0 + else: + self.__next = self.tag_v2.next + if self.__next == 0: + self._n_frames = frame + 1 + if len(self._frame_pos) == 1: + self.is_animated = self.__next != 0 + self.__frame += 1 + self.fp.seek(self._frame_pos[frame]) + self.tag_v2.load(self.fp) + self._reload_exif() + # fill the legacy tag/ifd entries + self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2) + self.__frame = frame + self._setup() + + def tell(self): + """Return the current frame number""" + return self.__frame + + def getxmp(self): + """ + Returns a dictionary containing the XMP tags. + Requires defusedxml to be installed. + + :returns: XMP tags in a dictionary. + """ + return self._getxmp(self.tag_v2[XMP]) if XMP in self.tag_v2 else {} + + def get_photoshop_blocks(self): + """ + Returns a dictionary of Photoshop "Image Resource Blocks". + The keys are the image resource ID. For more information, see + https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1037727 + + :returns: Photoshop "Image Resource Blocks" in a dictionary. + """ + blocks = {} + val = self.tag_v2.get(ExifTags.Base.ImageResources) + if val: + while val[:4] == b"8BIM": + id = i16(val[4:6]) + n = math.ceil((val[6] + 1) / 2) * 2 + size = i32(val[6 + n : 10 + n]) + data = val[10 + n : 10 + n + size] + blocks[id] = {"data": data} + + val = val[math.ceil((10 + n + size) / 2) * 2 :] + return blocks + + def load(self): + if self.tile and self.use_load_libtiff: + return self._load_libtiff() + return super().load() + + def load_end(self): + # allow closing if we're on the first frame, there's no next + # This is the ImageFile.load path only, libtiff specific below. + if not self.is_animated: + self._close_exclusive_fp_after_loading = True + + # reset buffered io handle in case fp + # was passed to libtiff, invalidating the buffer + self.fp.tell() + + # load IFD data from fp before it is closed + exif = self.getexif() + for key in TiffTags.TAGS_V2_GROUPS: + if key not in exif: + continue + exif.get_ifd(key) + + ImageOps.exif_transpose(self, in_place=True) + if ExifTags.Base.Orientation in self.tag_v2: + del self.tag_v2[ExifTags.Base.Orientation] + + def _load_libtiff(self): + """Overload method triggered when we detect a compressed tiff + Calls out to libtiff""" + + Image.Image.load(self) + + self.load_prepare() + + if not len(self.tile) == 1: + msg = "Not exactly one tile" + raise OSError(msg) + + # (self._compression, (extents tuple), + # 0, (rawmode, self._compression, fp)) + extents = self.tile[0][1] + args = list(self.tile[0][3]) + + # To be nice on memory footprint, if there's a + # file descriptor, use that instead of reading + # into a string in python. + try: + fp = hasattr(self.fp, "fileno") and self.fp.fileno() + # flush the file descriptor, prevents error on pypy 2.4+ + # should also eliminate the need for fp.tell + # in _seek + if hasattr(self.fp, "flush"): + self.fp.flush() + except OSError: + # io.BytesIO have a fileno, but returns an OSError if + # it doesn't use a file descriptor. + fp = False + + if fp: + args[2] = fp + + decoder = Image._getdecoder( + self.mode, "libtiff", tuple(args), self.decoderconfig + ) + try: + decoder.setimage(self.im, extents) + except ValueError as e: + msg = "Couldn't set the image" + raise OSError(msg) from e + + close_self_fp = self._exclusive_fp and not self.is_animated + if hasattr(self.fp, "getvalue"): + # We've got a stringio like thing passed in. Yay for all in memory. + # The decoder needs the entire file in one shot, so there's not + # a lot we can do here other than give it the entire file. + # unless we could do something like get the address of the + # underlying string for stringio. + # + # Rearranging for supporting byteio items, since they have a fileno + # that returns an OSError if there's no underlying fp. Easier to + # deal with here by reordering. + logger.debug("have getvalue. just sending in a string from getvalue") + n, err = decoder.decode(self.fp.getvalue()) + elif fp: + # we've got a actual file on disk, pass in the fp. + logger.debug("have fileno, calling fileno version of the decoder.") + if not close_self_fp: + self.fp.seek(0) + # 4 bytes, otherwise the trace might error out + n, err = decoder.decode(b"fpfp") + else: + # we have something else. + logger.debug("don't have fileno or getvalue. just reading") + self.fp.seek(0) + # UNDONE -- so much for that buffer size thing. + n, err = decoder.decode(self.fp.read()) + + self.tile = [] + self.readonly = 0 + + self.load_end() + + if close_self_fp: + self.fp.close() + self.fp = None # might be shared + + if err < 0: + raise OSError(err) + + return Image.Image.load(self) + + def _setup(self): + """Setup this image object based on current tags""" + + if 0xBC01 in self.tag_v2: + msg = "Windows Media Photo files not yet supported" + raise OSError(msg) + + # extract relevant tags + self._compression = COMPRESSION_INFO[self.tag_v2.get(COMPRESSION, 1)] + self._planar_configuration = self.tag_v2.get(PLANAR_CONFIGURATION, 1) + + # photometric is a required tag, but not everyone is reading + # the specification + photo = self.tag_v2.get(PHOTOMETRIC_INTERPRETATION, 0) + + # old style jpeg compression images most certainly are YCbCr + if self._compression == "tiff_jpeg": + photo = 6 + + fillorder = self.tag_v2.get(FILLORDER, 1) + + logger.debug("*** Summary ***") + logger.debug("- compression: %s", self._compression) + logger.debug("- photometric_interpretation: %s", photo) + logger.debug("- planar_configuration: %s", self._planar_configuration) + logger.debug("- fill_order: %s", fillorder) + logger.debug("- YCbCr subsampling: %s", self.tag.get(YCBCRSUBSAMPLING)) + + # size + xsize = int(self.tag_v2.get(IMAGEWIDTH)) + ysize = int(self.tag_v2.get(IMAGELENGTH)) + self._size = xsize, ysize + + logger.debug("- size: %s", self.size) + + sample_format = self.tag_v2.get(SAMPLEFORMAT, (1,)) + if len(sample_format) > 1 and max(sample_format) == min(sample_format) == 1: + # SAMPLEFORMAT is properly per band, so an RGB image will + # be (1,1,1). But, we don't support per band pixel types, + # and anything more than one band is a uint8. So, just + # take the first element. Revisit this if adding support + # for more exotic images. + sample_format = (1,) + + bps_tuple = self.tag_v2.get(BITSPERSAMPLE, (1,)) + extra_tuple = self.tag_v2.get(EXTRASAMPLES, ()) + if photo in (2, 6, 8): # RGB, YCbCr, LAB + bps_count = 3 + elif photo == 5: # CMYK + bps_count = 4 + else: + bps_count = 1 + bps_count += len(extra_tuple) + bps_actual_count = len(bps_tuple) + samples_per_pixel = self.tag_v2.get( + SAMPLESPERPIXEL, + 3 if self._compression == "tiff_jpeg" and photo in (2, 6) else 1, + ) + + if samples_per_pixel > MAX_SAMPLESPERPIXEL: + # DOS check, samples_per_pixel can be a Long, and we extend the tuple below + logger.error( + "More samples per pixel than can be decoded: %s", samples_per_pixel + ) + msg = "Invalid value for samples per pixel" + raise SyntaxError(msg) + + if samples_per_pixel < bps_actual_count: + # If a file has more values in bps_tuple than expected, + # remove the excess. + bps_tuple = bps_tuple[:samples_per_pixel] + elif samples_per_pixel > bps_actual_count and bps_actual_count == 1: + # If a file has only one value in bps_tuple, when it should have more, + # presume it is the same number of bits for all of the samples. + bps_tuple = bps_tuple * samples_per_pixel + + if len(bps_tuple) != samples_per_pixel: + msg = "unknown data organization" + raise SyntaxError(msg) + + # mode: check photometric interpretation and bits per pixel + key = ( + self.tag_v2.prefix, + photo, + sample_format, + fillorder, + bps_tuple, + extra_tuple, + ) + logger.debug("format key: %s", key) + try: + self._mode, rawmode = OPEN_INFO[key] + except KeyError as e: + logger.debug("- unsupported format") + msg = "unknown pixel mode" + raise SyntaxError(msg) from e + + logger.debug("- raw mode: %s", rawmode) + logger.debug("- pil mode: %s", self.mode) + + self.info["compression"] = self._compression + + xres = self.tag_v2.get(X_RESOLUTION, 1) + yres = self.tag_v2.get(Y_RESOLUTION, 1) + + if xres and yres: + resunit = self.tag_v2.get(RESOLUTION_UNIT) + if resunit == 2: # dots per inch + self.info["dpi"] = (xres, yres) + elif resunit == 3: # dots per centimeter. convert to dpi + self.info["dpi"] = (xres * 2.54, yres * 2.54) + elif resunit is None: # used to default to 1, but now 2) + self.info["dpi"] = (xres, yres) + # For backward compatibility, + # we also preserve the old behavior + self.info["resolution"] = xres, yres + else: # No absolute unit of measurement + self.info["resolution"] = xres, yres + + # build tile descriptors + x = y = layer = 0 + self.tile = [] + self.use_load_libtiff = READ_LIBTIFF or self._compression != "raw" + if self.use_load_libtiff: + # Decoder expects entire file as one tile. + # There's a buffer size limit in load (64k) + # so large g4 images will fail if we use that + # function. + # + # Setup the one tile for the whole image, then + # use the _load_libtiff function. + + # libtiff handles the fillmode for us, so 1;IR should + # actually be 1;I. Including the R double reverses the + # bits, so stripes of the image are reversed. See + # https://github.com/python-pillow/Pillow/issues/279 + if fillorder == 2: + # Replace fillorder with fillorder=1 + key = key[:3] + (1,) + key[4:] + logger.debug("format key: %s", key) + # this should always work, since all the + # fillorder==2 modes have a corresponding + # fillorder=1 mode + self._mode, rawmode = OPEN_INFO[key] + # libtiff always returns the bytes in native order. + # we're expecting image byte order. So, if the rawmode + # contains I;16, we need to convert from native to image + # byte order. + if rawmode == "I;16": + rawmode = "I;16N" + if ";16B" in rawmode: + rawmode = rawmode.replace(";16B", ";16N") + if ";16L" in rawmode: + rawmode = rawmode.replace(";16L", ";16N") + + # YCbCr images with new jpeg compression with pixels in one plane + # unpacked straight into RGB values + if ( + photo == 6 + and self._compression == "jpeg" + and self._planar_configuration == 1 + ): + rawmode = "RGB" + + # Offset in the tile tuple is 0, we go from 0,0 to + # w,h, and we only do this once -- eds + a = (rawmode, self._compression, False, self.tag_v2.offset) + self.tile.append(("libtiff", (0, 0, xsize, ysize), 0, a)) + + elif STRIPOFFSETS in self.tag_v2 or TILEOFFSETS in self.tag_v2: + # striped image + if STRIPOFFSETS in self.tag_v2: + offsets = self.tag_v2[STRIPOFFSETS] + h = self.tag_v2.get(ROWSPERSTRIP, ysize) + w = self.size[0] + else: + # tiled image + offsets = self.tag_v2[TILEOFFSETS] + w = self.tag_v2.get(TILEWIDTH) + h = self.tag_v2.get(TILELENGTH) + + for offset in offsets: + if x + w > xsize: + stride = w * sum(bps_tuple) / 8 # bytes per line + else: + stride = 0 + + tile_rawmode = rawmode + if self._planar_configuration == 2: + # each band on it's own layer + tile_rawmode = rawmode[layer] + # adjust stride width accordingly + stride /= bps_count + + a = (tile_rawmode, int(stride), 1) + self.tile.append( + ( + self._compression, + (x, y, min(x + w, xsize), min(y + h, ysize)), + offset, + a, + ) + ) + x = x + w + if x >= self.size[0]: + x, y = 0, y + h + if y >= self.size[1]: + x = y = 0 + layer += 1 + else: + logger.debug("- unsupported data organization") + msg = "unknown data organization" + raise SyntaxError(msg) + + # Fix up info. + if ICCPROFILE in self.tag_v2: + self.info["icc_profile"] = self.tag_v2[ICCPROFILE] + + # fixup palette descriptor + + if self.mode in ["P", "PA"]: + palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]] + self.palette = ImagePalette.raw("RGB;L", b"".join(palette)) + + +# +# -------------------------------------------------------------------- +# Write TIFF files + +# little endian is default except for image modes with +# explicit big endian byte-order + +SAVE_INFO = { + # mode => rawmode, byteorder, photometrics, + # sampleformat, bitspersample, extra + "1": ("1", II, 1, 1, (1,), None), + "L": ("L", II, 1, 1, (8,), None), + "LA": ("LA", II, 1, 1, (8, 8), 2), + "P": ("P", II, 3, 1, (8,), None), + "PA": ("PA", II, 3, 1, (8, 8), 2), + "I": ("I;32S", II, 1, 2, (32,), None), + "I;16": ("I;16", II, 1, 1, (16,), None), + "I;16S": ("I;16S", II, 1, 2, (16,), None), + "F": ("F;32F", II, 1, 3, (32,), None), + "RGB": ("RGB", II, 2, 1, (8, 8, 8), None), + "RGBX": ("RGBX", II, 2, 1, (8, 8, 8, 8), 0), + "RGBA": ("RGBA", II, 2, 1, (8, 8, 8, 8), 2), + "CMYK": ("CMYK", II, 5, 1, (8, 8, 8, 8), None), + "YCbCr": ("YCbCr", II, 6, 1, (8, 8, 8), None), + "LAB": ("LAB", II, 8, 1, (8, 8, 8), None), + "I;32BS": ("I;32BS", MM, 1, 2, (32,), None), + "I;16B": ("I;16B", MM, 1, 1, (16,), None), + "I;16BS": ("I;16BS", MM, 1, 2, (16,), None), + "F;32BF": ("F;32BF", MM, 1, 3, (32,), None), +} + + +def _save(im, fp, filename): + try: + rawmode, prefix, photo, format, bits, extra = SAVE_INFO[im.mode] + except KeyError as e: + msg = f"cannot write mode {im.mode} as TIFF" + raise OSError(msg) from e + + ifd = ImageFileDirectory_v2(prefix=prefix) + + encoderinfo = im.encoderinfo + encoderconfig = im.encoderconfig + try: + compression = encoderinfo["compression"] + except KeyError: + compression = im.info.get("compression") + if isinstance(compression, int): + # compression value may be from BMP. Ignore it + compression = None + if compression is None: + compression = "raw" + elif compression == "tiff_jpeg": + # OJPEG is obsolete, so use new-style JPEG compression instead + compression = "jpeg" + elif compression == "tiff_deflate": + compression = "tiff_adobe_deflate" + + libtiff = WRITE_LIBTIFF or compression != "raw" + + # required for color libtiff images + ifd[PLANAR_CONFIGURATION] = 1 + + ifd[IMAGEWIDTH] = im.size[0] + ifd[IMAGELENGTH] = im.size[1] + + # write any arbitrary tags passed in as an ImageFileDirectory + if "tiffinfo" in encoderinfo: + info = encoderinfo["tiffinfo"] + elif "exif" in encoderinfo: + info = encoderinfo["exif"] + if isinstance(info, bytes): + exif = Image.Exif() + exif.load(info) + info = exif + else: + info = {} + logger.debug("Tiffinfo Keys: %s", list(info)) + if isinstance(info, ImageFileDirectory_v1): + info = info.to_v2() + for key in info: + if isinstance(info, Image.Exif) and key in TiffTags.TAGS_V2_GROUPS: + ifd[key] = info.get_ifd(key) + else: + ifd[key] = info.get(key) + try: + ifd.tagtype[key] = info.tagtype[key] + except Exception: + pass # might not be an IFD. Might not have populated type + + # additions written by Greg Couch, gregc@cgl.ucsf.edu + # inspired by image-sig posting from Kevin Cazabon, kcazabon@home.com + if hasattr(im, "tag_v2"): + # preserve tags from original TIFF image file + for key in ( + RESOLUTION_UNIT, + X_RESOLUTION, + Y_RESOLUTION, + IPTC_NAA_CHUNK, + PHOTOSHOP_CHUNK, + XMP, + ): + if key in im.tag_v2: + ifd[key] = im.tag_v2[key] + ifd.tagtype[key] = im.tag_v2.tagtype[key] + + # preserve ICC profile (should also work when saving other formats + # which support profiles as TIFF) -- 2008-06-06 Florian Hoech + icc = encoderinfo.get("icc_profile", im.info.get("icc_profile")) + if icc: + ifd[ICCPROFILE] = icc + + for key, name in [ + (IMAGEDESCRIPTION, "description"), + (X_RESOLUTION, "resolution"), + (Y_RESOLUTION, "resolution"), + (X_RESOLUTION, "x_resolution"), + (Y_RESOLUTION, "y_resolution"), + (RESOLUTION_UNIT, "resolution_unit"), + (SOFTWARE, "software"), + (DATE_TIME, "date_time"), + (ARTIST, "artist"), + (COPYRIGHT, "copyright"), + ]: + if name in encoderinfo: + ifd[key] = encoderinfo[name] + + dpi = encoderinfo.get("dpi") + if dpi: + ifd[RESOLUTION_UNIT] = 2 + ifd[X_RESOLUTION] = dpi[0] + ifd[Y_RESOLUTION] = dpi[1] + + if bits != (1,): + ifd[BITSPERSAMPLE] = bits + if len(bits) != 1: + ifd[SAMPLESPERPIXEL] = len(bits) + if extra is not None: + ifd[EXTRASAMPLES] = extra + if format != 1: + ifd[SAMPLEFORMAT] = format + + if PHOTOMETRIC_INTERPRETATION not in ifd: + ifd[PHOTOMETRIC_INTERPRETATION] = photo + elif im.mode in ("1", "L") and ifd[PHOTOMETRIC_INTERPRETATION] == 0: + if im.mode == "1": + inverted_im = im.copy() + px = inverted_im.load() + for y in range(inverted_im.height): + for x in range(inverted_im.width): + px[x, y] = 0 if px[x, y] == 255 else 255 + im = inverted_im + else: + im = ImageOps.invert(im) + + if im.mode in ["P", "PA"]: + lut = im.im.getpalette("RGB", "RGB;L") + colormap = [] + colors = len(lut) // 3 + for i in range(3): + colormap += [v * 256 for v in lut[colors * i : colors * (i + 1)]] + colormap += [0] * (256 - colors) + ifd[COLORMAP] = colormap + # data orientation + w, h = ifd[IMAGEWIDTH], ifd[IMAGELENGTH] + stride = len(bits) * ((w * bits[0] + 7) // 8) + if ROWSPERSTRIP not in ifd: + # aim for given strip size (64 KB by default) when using libtiff writer + if libtiff: + im_strip_size = encoderinfo.get("strip_size", STRIP_SIZE) + rows_per_strip = 1 if stride == 0 else min(im_strip_size // stride, h) + # JPEG encoder expects multiple of 8 rows + if compression == "jpeg": + rows_per_strip = min(((rows_per_strip + 7) // 8) * 8, h) + else: + rows_per_strip = h + if rows_per_strip == 0: + rows_per_strip = 1 + ifd[ROWSPERSTRIP] = rows_per_strip + strip_byte_counts = 1 if stride == 0 else stride * ifd[ROWSPERSTRIP] + strips_per_image = (h + ifd[ROWSPERSTRIP] - 1) // ifd[ROWSPERSTRIP] + if strip_byte_counts >= 2**16: + ifd.tagtype[STRIPBYTECOUNTS] = TiffTags.LONG + ifd[STRIPBYTECOUNTS] = (strip_byte_counts,) * (strips_per_image - 1) + ( + stride * h - strip_byte_counts * (strips_per_image - 1), + ) + ifd[STRIPOFFSETS] = tuple( + range(0, strip_byte_counts * strips_per_image, strip_byte_counts) + ) # this is adjusted by IFD writer + # no compression by default: + ifd[COMPRESSION] = COMPRESSION_INFO_REV.get(compression, 1) + + if im.mode == "YCbCr": + for tag, value in { + YCBCRSUBSAMPLING: (1, 1), + REFERENCEBLACKWHITE: (0, 255, 128, 255, 128, 255), + }.items(): + ifd.setdefault(tag, value) + + blocklist = [TILEWIDTH, TILELENGTH, TILEOFFSETS, TILEBYTECOUNTS] + if libtiff: + if "quality" in encoderinfo: + quality = encoderinfo["quality"] + if not isinstance(quality, int) or quality < 0 or quality > 100: + msg = "Invalid quality setting" + raise ValueError(msg) + if compression != "jpeg": + msg = "quality setting only supported for 'jpeg' compression" + raise ValueError(msg) + ifd[JPEGQUALITY] = quality + + logger.debug("Saving using libtiff encoder") + logger.debug("Items: %s", sorted(ifd.items())) + _fp = 0 + if hasattr(fp, "fileno"): + try: + fp.seek(0) + _fp = os.dup(fp.fileno()) + except io.UnsupportedOperation: + pass + + # optional types for non core tags + types = {} + # STRIPOFFSETS and STRIPBYTECOUNTS are added by the library + # based on the data in the strip. + # OSUBFILETYPE is deprecated. + # The other tags expect arrays with a certain length (fixed or depending on + # BITSPERSAMPLE, etc), passing arrays with a different length will result in + # segfaults. Block these tags until we add extra validation. + # SUBIFD may also cause a segfault. + blocklist += [ + OSUBFILETYPE, + REFERENCEBLACKWHITE, + STRIPBYTECOUNTS, + STRIPOFFSETS, + TRANSFERFUNCTION, + SUBIFD, + ] + + # bits per sample is a single short in the tiff directory, not a list. + atts = {BITSPERSAMPLE: bits[0]} + # Merge the ones that we have with (optional) more bits from + # the original file, e.g x,y resolution so that we can + # save(load('')) == original file. + legacy_ifd = {} + if hasattr(im, "tag"): + legacy_ifd = im.tag.to_v2() + + # SAMPLEFORMAT is determined by the image format and should not be copied + # from legacy_ifd. + supplied_tags = {**getattr(im, "tag_v2", {}), **legacy_ifd} + if SAMPLEFORMAT in supplied_tags: + del supplied_tags[SAMPLEFORMAT] + + for tag, value in itertools.chain(ifd.items(), supplied_tags.items()): + # Libtiff can only process certain core items without adding + # them to the custom dictionary. + # Custom items are supported for int, float, unicode, string and byte + # values. Other types and tuples require a tagtype. + if tag not in TiffTags.LIBTIFF_CORE: + if not getattr(Image.core, "libtiff_support_custom_tags", False): + continue + + if tag in ifd.tagtype: + types[tag] = ifd.tagtype[tag] + elif not (isinstance(value, (int, float, str, bytes))): + continue + else: + type = TiffTags.lookup(tag).type + if type: + types[tag] = type + if tag not in atts and tag not in blocklist: + if isinstance(value, str): + atts[tag] = value.encode("ascii", "replace") + b"\0" + elif isinstance(value, IFDRational): + atts[tag] = float(value) + else: + atts[tag] = value + + if SAMPLEFORMAT in atts and len(atts[SAMPLEFORMAT]) == 1: + atts[SAMPLEFORMAT] = atts[SAMPLEFORMAT][0] + + logger.debug("Converted items: %s", sorted(atts.items())) + + # libtiff always expects the bytes in native order. + # we're storing image byte order. So, if the rawmode + # contains I;16, we need to convert from native to image + # byte order. + if im.mode in ("I;16B", "I;16"): + rawmode = "I;16N" + + # Pass tags as sorted list so that the tags are set in a fixed order. + # This is required by libtiff for some tags. For example, the JPEGQUALITY + # pseudo tag requires that the COMPRESS tag was already set. + tags = list(atts.items()) + tags.sort() + a = (rawmode, compression, _fp, filename, tags, types) + encoder = Image._getencoder(im.mode, "libtiff", a, encoderconfig) + encoder.setimage(im.im, (0, 0) + im.size) + while True: + # undone, change to self.decodermaxblock: + errcode, data = encoder.encode(16 * 1024)[1:] + if not _fp: + fp.write(data) + if errcode: + break + if _fp: + try: + os.close(_fp) + except OSError: + pass + if errcode < 0: + msg = f"encoder error {errcode} when writing image file" + raise OSError(msg) + + else: + for tag in blocklist: + del ifd[tag] + offset = ifd.save(fp) + + ImageFile._save( + im, fp, [("raw", (0, 0) + im.size, offset, (rawmode, stride, 1))] + ) + + # -- helper for multi-page save -- + if "_debug_multipage" in encoderinfo: + # just to access o32 and o16 (using correct byte order) + im._debug_multipage = ifd + + +class AppendingTiffWriter: + fieldSizes = [ + 0, # None + 1, # byte + 1, # ascii + 2, # short + 4, # long + 8, # rational + 1, # sbyte + 1, # undefined + 2, # sshort + 4, # slong + 8, # srational + 4, # float + 8, # double + 4, # ifd + 2, # unicode + 4, # complex + 8, # long8 + ] + + Tags = { + 273, # StripOffsets + 288, # FreeOffsets + 324, # TileOffsets + 519, # JPEGQTables + 520, # JPEGDCTables + 521, # JPEGACTables + } + + def __init__(self, fn, new=False): + if hasattr(fn, "read"): + self.f = fn + self.close_fp = False + else: + self.name = fn + self.close_fp = True + try: + self.f = open(fn, "w+b" if new else "r+b") + except OSError: + self.f = open(fn, "w+b") + self.beginning = self.f.tell() + self.setup() + + def setup(self): + # Reset everything. + self.f.seek(self.beginning, os.SEEK_SET) + + self.whereToWriteNewIFDOffset = None + self.offsetOfNewPage = 0 + + self.IIMM = iimm = self.f.read(4) + if not iimm: + # empty file - first page + self.isFirst = True + return + + self.isFirst = False + if iimm == b"II\x2a\x00": + self.setEndian("<") + elif iimm == b"MM\x00\x2a": + self.setEndian(">") + else: + msg = "Invalid TIFF file header" + raise RuntimeError(msg) + + self.skipIFDs() + self.goToEnd() + + def finalize(self): + if self.isFirst: + return + + # fix offsets + self.f.seek(self.offsetOfNewPage) + + iimm = self.f.read(4) + if not iimm: + # Make it easy to finish a frame without committing to a new one. + return + + if iimm != self.IIMM: + msg = "IIMM of new page doesn't match IIMM of first page" + raise RuntimeError(msg) + + ifd_offset = self.readLong() + ifd_offset += self.offsetOfNewPage + self.f.seek(self.whereToWriteNewIFDOffset) + self.writeLong(ifd_offset) + self.f.seek(ifd_offset) + self.fixIFD() + + def newFrame(self): + # Call this to finish a frame. + self.finalize() + self.setup() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + if self.close_fp: + self.close() + return False + + def tell(self): + return self.f.tell() - self.offsetOfNewPage + + def seek(self, offset, whence=io.SEEK_SET): + if whence == os.SEEK_SET: + offset += self.offsetOfNewPage + + self.f.seek(offset, whence) + return self.tell() + + def goToEnd(self): + self.f.seek(0, os.SEEK_END) + pos = self.f.tell() + + # pad to 16 byte boundary + pad_bytes = 16 - pos % 16 + if 0 < pad_bytes < 16: + self.f.write(bytes(pad_bytes)) + self.offsetOfNewPage = self.f.tell() + + def setEndian(self, endian): + self.endian = endian + self.longFmt = self.endian + "L" + self.shortFmt = self.endian + "H" + self.tagFormat = self.endian + "HHL" + + def skipIFDs(self): + while True: + ifd_offset = self.readLong() + if ifd_offset == 0: + self.whereToWriteNewIFDOffset = self.f.tell() - 4 + break + + self.f.seek(ifd_offset) + num_tags = self.readShort() + self.f.seek(num_tags * 12, os.SEEK_CUR) + + def write(self, data): + return self.f.write(data) + + def readShort(self): + (value,) = struct.unpack(self.shortFmt, self.f.read(2)) + return value + + def readLong(self): + (value,) = struct.unpack(self.longFmt, self.f.read(4)) + return value + + def rewriteLastShortToLong(self, value): + self.f.seek(-2, os.SEEK_CUR) + bytes_written = self.f.write(struct.pack(self.longFmt, value)) + if bytes_written is not None and bytes_written != 4: + msg = f"wrote only {bytes_written} bytes but wanted 4" + raise RuntimeError(msg) + + def rewriteLastShort(self, value): + self.f.seek(-2, os.SEEK_CUR) + bytes_written = self.f.write(struct.pack(self.shortFmt, value)) + if bytes_written is not None and bytes_written != 2: + msg = f"wrote only {bytes_written} bytes but wanted 2" + raise RuntimeError(msg) + + def rewriteLastLong(self, value): + self.f.seek(-4, os.SEEK_CUR) + bytes_written = self.f.write(struct.pack(self.longFmt, value)) + if bytes_written is not None and bytes_written != 4: + msg = f"wrote only {bytes_written} bytes but wanted 4" + raise RuntimeError(msg) + + def writeShort(self, value): + bytes_written = self.f.write(struct.pack(self.shortFmt, value)) + if bytes_written is not None and bytes_written != 2: + msg = f"wrote only {bytes_written} bytes but wanted 2" + raise RuntimeError(msg) + + def writeLong(self, value): + bytes_written = self.f.write(struct.pack(self.longFmt, value)) + if bytes_written is not None and bytes_written != 4: + msg = f"wrote only {bytes_written} bytes but wanted 4" + raise RuntimeError(msg) + + def close(self): + self.finalize() + self.f.close() + + def fixIFD(self): + num_tags = self.readShort() + + for i in range(num_tags): + tag, field_type, count = struct.unpack(self.tagFormat, self.f.read(8)) + + field_size = self.fieldSizes[field_type] + total_size = field_size * count + is_local = total_size <= 4 + if not is_local: + offset = self.readLong() + offset += self.offsetOfNewPage + self.rewriteLastLong(offset) + + if tag in self.Tags: + cur_pos = self.f.tell() + + if is_local: + self.fixOffsets( + count, isShort=(field_size == 2), isLong=(field_size == 4) + ) + self.f.seek(cur_pos + 4) + else: + self.f.seek(offset) + self.fixOffsets( + count, isShort=(field_size == 2), isLong=(field_size == 4) + ) + self.f.seek(cur_pos) + + offset = cur_pos = None + + elif is_local: + # skip the locally stored value that is not an offset + self.f.seek(4, os.SEEK_CUR) + + def fixOffsets(self, count, isShort=False, isLong=False): + if not isShort and not isLong: + msg = "offset is neither short nor long" + raise RuntimeError(msg) + + for i in range(count): + offset = self.readShort() if isShort else self.readLong() + offset += self.offsetOfNewPage + if isShort and offset >= 65536: + # offset is now too large - we must convert shorts to longs + if count != 1: + msg = "not implemented" + raise RuntimeError(msg) # XXX TODO + + # simple case - the offset is just one and therefore it is + # local (not referenced with another offset) + self.rewriteLastShortToLong(offset) + self.f.seek(-10, os.SEEK_CUR) + self.writeShort(TiffTags.LONG) # rewrite the type to LONG + self.f.seek(8, os.SEEK_CUR) + elif isShort: + self.rewriteLastShort(offset) + else: + self.rewriteLastLong(offset) + + +def _save_all(im, fp, filename): + encoderinfo = im.encoderinfo.copy() + encoderconfig = im.encoderconfig + append_images = list(encoderinfo.get("append_images", [])) + if not hasattr(im, "n_frames") and not append_images: + return _save(im, fp, filename) + + cur_idx = im.tell() + try: + with AppendingTiffWriter(fp) as tf: + for ims in [im] + append_images: + ims.encoderinfo = encoderinfo + ims.encoderconfig = encoderconfig + if not hasattr(ims, "n_frames"): + nfr = 1 + else: + nfr = ims.n_frames + + for idx in range(nfr): + ims.seek(idx) + ims.load() + _save(ims, tf, filename) + tf.newFrame() + finally: + im.seek(cur_idx) + + +# +# -------------------------------------------------------------------- +# Register + +Image.register_open(TiffImageFile.format, TiffImageFile, _accept) +Image.register_save(TiffImageFile.format, _save) +Image.register_save_all(TiffImageFile.format, _save_all) + +Image.register_extensions(TiffImageFile.format, [".tif", ".tiff"]) + +Image.register_mime(TiffImageFile.format, "image/tiff") diff --git a/venv/lib/python3.10/site-packages/PIL/TiffTags.py b/venv/lib/python3.10/site-packages/PIL/TiffTags.py new file mode 100644 index 00000000..89fad703 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/TiffTags.py @@ -0,0 +1,553 @@ +# +# The Python Imaging Library. +# $Id$ +# +# TIFF tags +# +# This module provides clear-text names for various well-known +# TIFF tags. the TIFF codec works just fine without it. +# +# Copyright (c) Secret Labs AB 1999. +# +# See the README file for information on usage and redistribution. +# + +## +# This module provides constants and clear-text names for various +# well-known TIFF tags. +## +from __future__ import annotations + +from typing import NamedTuple + + +class _TagInfo(NamedTuple): + value: int | None + name: str + type: int | None + length: int | None + enum: dict[str, int] + + +class TagInfo(_TagInfo): + __slots__: list[str] = [] + + def __new__(cls, value=None, name="unknown", type=None, length=None, enum=None): + return super().__new__(cls, value, name, type, length, enum or {}) + + def cvt_enum(self, value): + # Using get will call hash(value), which can be expensive + # for some types (e.g. Fraction). Since self.enum is rarely + # used, it's usually better to test it first. + return self.enum.get(value, value) if self.enum else value + + +def lookup(tag, group=None): + """ + :param tag: Integer tag number + :param group: Which :py:data:`~PIL.TiffTags.TAGS_V2_GROUPS` to look in + + .. versionadded:: 8.3.0 + + :returns: Taginfo namedtuple, From the ``TAGS_V2`` info if possible, + otherwise just populating the value and name from ``TAGS``. + If the tag is not recognized, "unknown" is returned for the name + + """ + + if group is not None: + info = TAGS_V2_GROUPS[group].get(tag) if group in TAGS_V2_GROUPS else None + else: + info = TAGS_V2.get(tag) + return info or TagInfo(tag, TAGS.get(tag, "unknown")) + + +## +# Map tag numbers to tag info. +# +# id: (Name, Type, Length[, enum_values]) +# +# The length here differs from the length in the tiff spec. For +# numbers, the tiff spec is for the number of fields returned. We +# agree here. For string-like types, the tiff spec uses the length of +# field in bytes. In Pillow, we are using the number of expected +# fields, in general 1 for string-like types. + + +BYTE = 1 +ASCII = 2 +SHORT = 3 +LONG = 4 +RATIONAL = 5 +SIGNED_BYTE = 6 +UNDEFINED = 7 +SIGNED_SHORT = 8 +SIGNED_LONG = 9 +SIGNED_RATIONAL = 10 +FLOAT = 11 +DOUBLE = 12 +IFD = 13 +LONG8 = 16 + +TAGS_V2 = { + 254: ("NewSubfileType", LONG, 1), + 255: ("SubfileType", SHORT, 1), + 256: ("ImageWidth", LONG, 1), + 257: ("ImageLength", LONG, 1), + 258: ("BitsPerSample", SHORT, 0), + 259: ( + "Compression", + SHORT, + 1, + { + "Uncompressed": 1, + "CCITT 1d": 2, + "Group 3 Fax": 3, + "Group 4 Fax": 4, + "LZW": 5, + "JPEG": 6, + "PackBits": 32773, + }, + ), + 262: ( + "PhotometricInterpretation", + SHORT, + 1, + { + "WhiteIsZero": 0, + "BlackIsZero": 1, + "RGB": 2, + "RGB Palette": 3, + "Transparency Mask": 4, + "CMYK": 5, + "YCbCr": 6, + "CieLAB": 8, + "CFA": 32803, # TIFF/EP, Adobe DNG + "LinearRaw": 32892, # Adobe DNG + }, + ), + 263: ("Threshholding", SHORT, 1), + 264: ("CellWidth", SHORT, 1), + 265: ("CellLength", SHORT, 1), + 266: ("FillOrder", SHORT, 1), + 269: ("DocumentName", ASCII, 1), + 270: ("ImageDescription", ASCII, 1), + 271: ("Make", ASCII, 1), + 272: ("Model", ASCII, 1), + 273: ("StripOffsets", LONG, 0), + 274: ("Orientation", SHORT, 1), + 277: ("SamplesPerPixel", SHORT, 1), + 278: ("RowsPerStrip", LONG, 1), + 279: ("StripByteCounts", LONG, 0), + 280: ("MinSampleValue", SHORT, 0), + 281: ("MaxSampleValue", SHORT, 0), + 282: ("XResolution", RATIONAL, 1), + 283: ("YResolution", RATIONAL, 1), + 284: ("PlanarConfiguration", SHORT, 1, {"Contiguous": 1, "Separate": 2}), + 285: ("PageName", ASCII, 1), + 286: ("XPosition", RATIONAL, 1), + 287: ("YPosition", RATIONAL, 1), + 288: ("FreeOffsets", LONG, 1), + 289: ("FreeByteCounts", LONG, 1), + 290: ("GrayResponseUnit", SHORT, 1), + 291: ("GrayResponseCurve", SHORT, 0), + 292: ("T4Options", LONG, 1), + 293: ("T6Options", LONG, 1), + 296: ("ResolutionUnit", SHORT, 1, {"none": 1, "inch": 2, "cm": 3}), + 297: ("PageNumber", SHORT, 2), + 301: ("TransferFunction", SHORT, 0), + 305: ("Software", ASCII, 1), + 306: ("DateTime", ASCII, 1), + 315: ("Artist", ASCII, 1), + 316: ("HostComputer", ASCII, 1), + 317: ("Predictor", SHORT, 1, {"none": 1, "Horizontal Differencing": 2}), + 318: ("WhitePoint", RATIONAL, 2), + 319: ("PrimaryChromaticities", RATIONAL, 6), + 320: ("ColorMap", SHORT, 0), + 321: ("HalftoneHints", SHORT, 2), + 322: ("TileWidth", LONG, 1), + 323: ("TileLength", LONG, 1), + 324: ("TileOffsets", LONG, 0), + 325: ("TileByteCounts", LONG, 0), + 330: ("SubIFDs", LONG, 0), + 332: ("InkSet", SHORT, 1), + 333: ("InkNames", ASCII, 1), + 334: ("NumberOfInks", SHORT, 1), + 336: ("DotRange", SHORT, 0), + 337: ("TargetPrinter", ASCII, 1), + 338: ("ExtraSamples", SHORT, 0), + 339: ("SampleFormat", SHORT, 0), + 340: ("SMinSampleValue", DOUBLE, 0), + 341: ("SMaxSampleValue", DOUBLE, 0), + 342: ("TransferRange", SHORT, 6), + 347: ("JPEGTables", UNDEFINED, 1), + # obsolete JPEG tags + 512: ("JPEGProc", SHORT, 1), + 513: ("JPEGInterchangeFormat", LONG, 1), + 514: ("JPEGInterchangeFormatLength", LONG, 1), + 515: ("JPEGRestartInterval", SHORT, 1), + 517: ("JPEGLosslessPredictors", SHORT, 0), + 518: ("JPEGPointTransforms", SHORT, 0), + 519: ("JPEGQTables", LONG, 0), + 520: ("JPEGDCTables", LONG, 0), + 521: ("JPEGACTables", LONG, 0), + 529: ("YCbCrCoefficients", RATIONAL, 3), + 530: ("YCbCrSubSampling", SHORT, 2), + 531: ("YCbCrPositioning", SHORT, 1), + 532: ("ReferenceBlackWhite", RATIONAL, 6), + 700: ("XMP", BYTE, 0), + 33432: ("Copyright", ASCII, 1), + 33723: ("IptcNaaInfo", UNDEFINED, 1), + 34377: ("PhotoshopInfo", BYTE, 0), + # FIXME add more tags here + 34665: ("ExifIFD", LONG, 1), + 34675: ("ICCProfile", UNDEFINED, 1), + 34853: ("GPSInfoIFD", LONG, 1), + 36864: ("ExifVersion", UNDEFINED, 1), + 37724: ("ImageSourceData", UNDEFINED, 1), + 40965: ("InteroperabilityIFD", LONG, 1), + 41730: ("CFAPattern", UNDEFINED, 1), + # MPInfo + 45056: ("MPFVersion", UNDEFINED, 1), + 45057: ("NumberOfImages", LONG, 1), + 45058: ("MPEntry", UNDEFINED, 1), + 45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check + 45060: ("TotalFrames", LONG, 1), + 45313: ("MPIndividualNum", LONG, 1), + 45569: ("PanOrientation", LONG, 1), + 45570: ("PanOverlap_H", RATIONAL, 1), + 45571: ("PanOverlap_V", RATIONAL, 1), + 45572: ("BaseViewpointNum", LONG, 1), + 45573: ("ConvergenceAngle", SIGNED_RATIONAL, 1), + 45574: ("BaselineLength", RATIONAL, 1), + 45575: ("VerticalDivergence", SIGNED_RATIONAL, 1), + 45576: ("AxisDistance_X", SIGNED_RATIONAL, 1), + 45577: ("AxisDistance_Y", SIGNED_RATIONAL, 1), + 45578: ("AxisDistance_Z", SIGNED_RATIONAL, 1), + 45579: ("YawAngle", SIGNED_RATIONAL, 1), + 45580: ("PitchAngle", SIGNED_RATIONAL, 1), + 45581: ("RollAngle", SIGNED_RATIONAL, 1), + 40960: ("FlashPixVersion", UNDEFINED, 1), + 50741: ("MakerNoteSafety", SHORT, 1, {"Unsafe": 0, "Safe": 1}), + 50780: ("BestQualityScale", RATIONAL, 1), + 50838: ("ImageJMetaDataByteCounts", LONG, 0), # Can be more than one + 50839: ("ImageJMetaData", UNDEFINED, 1), # see Issue #2006 +} +TAGS_V2_GROUPS = { + # ExifIFD + 34665: { + 36864: ("ExifVersion", UNDEFINED, 1), + 40960: ("FlashPixVersion", UNDEFINED, 1), + 40965: ("InteroperabilityIFD", LONG, 1), + 41730: ("CFAPattern", UNDEFINED, 1), + }, + # GPSInfoIFD + 34853: { + 0: ("GPSVersionID", BYTE, 4), + 1: ("GPSLatitudeRef", ASCII, 2), + 2: ("GPSLatitude", RATIONAL, 3), + 3: ("GPSLongitudeRef", ASCII, 2), + 4: ("GPSLongitude", RATIONAL, 3), + 5: ("GPSAltitudeRef", BYTE, 1), + 6: ("GPSAltitude", RATIONAL, 1), + 7: ("GPSTimeStamp", RATIONAL, 3), + 8: ("GPSSatellites", ASCII, 0), + 9: ("GPSStatus", ASCII, 2), + 10: ("GPSMeasureMode", ASCII, 2), + 11: ("GPSDOP", RATIONAL, 1), + 12: ("GPSSpeedRef", ASCII, 2), + 13: ("GPSSpeed", RATIONAL, 1), + 14: ("GPSTrackRef", ASCII, 2), + 15: ("GPSTrack", RATIONAL, 1), + 16: ("GPSImgDirectionRef", ASCII, 2), + 17: ("GPSImgDirection", RATIONAL, 1), + 18: ("GPSMapDatum", ASCII, 0), + 19: ("GPSDestLatitudeRef", ASCII, 2), + 20: ("GPSDestLatitude", RATIONAL, 3), + 21: ("GPSDestLongitudeRef", ASCII, 2), + 22: ("GPSDestLongitude", RATIONAL, 3), + 23: ("GPSDestBearingRef", ASCII, 2), + 24: ("GPSDestBearing", RATIONAL, 1), + 25: ("GPSDestDistanceRef", ASCII, 2), + 26: ("GPSDestDistance", RATIONAL, 1), + 27: ("GPSProcessingMethod", UNDEFINED, 0), + 28: ("GPSAreaInformation", UNDEFINED, 0), + 29: ("GPSDateStamp", ASCII, 11), + 30: ("GPSDifferential", SHORT, 1), + }, + # InteroperabilityIFD + 40965: {1: ("InteropIndex", ASCII, 1), 2: ("InteropVersion", UNDEFINED, 1)}, +} + +# Legacy Tags structure +# these tags aren't included above, but were in the previous versions +TAGS = { + 347: "JPEGTables", + 700: "XMP", + # Additional Exif Info + 32932: "Wang Annotation", + 33434: "ExposureTime", + 33437: "FNumber", + 33445: "MD FileTag", + 33446: "MD ScalePixel", + 33447: "MD ColorTable", + 33448: "MD LabName", + 33449: "MD SampleInfo", + 33450: "MD PrepDate", + 33451: "MD PrepTime", + 33452: "MD FileUnits", + 33550: "ModelPixelScaleTag", + 33723: "IptcNaaInfo", + 33918: "INGR Packet Data Tag", + 33919: "INGR Flag Registers", + 33920: "IrasB Transformation Matrix", + 33922: "ModelTiepointTag", + 34264: "ModelTransformationTag", + 34377: "PhotoshopInfo", + 34735: "GeoKeyDirectoryTag", + 34736: "GeoDoubleParamsTag", + 34737: "GeoAsciiParamsTag", + 34850: "ExposureProgram", + 34852: "SpectralSensitivity", + 34855: "ISOSpeedRatings", + 34856: "OECF", + 34864: "SensitivityType", + 34865: "StandardOutputSensitivity", + 34866: "RecommendedExposureIndex", + 34867: "ISOSpeed", + 34868: "ISOSpeedLatitudeyyy", + 34869: "ISOSpeedLatitudezzz", + 34908: "HylaFAX FaxRecvParams", + 34909: "HylaFAX FaxSubAddress", + 34910: "HylaFAX FaxRecvTime", + 36864: "ExifVersion", + 36867: "DateTimeOriginal", + 36868: "DateTimeDigitized", + 37121: "ComponentsConfiguration", + 37122: "CompressedBitsPerPixel", + 37724: "ImageSourceData", + 37377: "ShutterSpeedValue", + 37378: "ApertureValue", + 37379: "BrightnessValue", + 37380: "ExposureBiasValue", + 37381: "MaxApertureValue", + 37382: "SubjectDistance", + 37383: "MeteringMode", + 37384: "LightSource", + 37385: "Flash", + 37386: "FocalLength", + 37396: "SubjectArea", + 37500: "MakerNote", + 37510: "UserComment", + 37520: "SubSec", + 37521: "SubSecTimeOriginal", + 37522: "SubsecTimeDigitized", + 40960: "FlashPixVersion", + 40961: "ColorSpace", + 40962: "PixelXDimension", + 40963: "PixelYDimension", + 40964: "RelatedSoundFile", + 40965: "InteroperabilityIFD", + 41483: "FlashEnergy", + 41484: "SpatialFrequencyResponse", + 41486: "FocalPlaneXResolution", + 41487: "FocalPlaneYResolution", + 41488: "FocalPlaneResolutionUnit", + 41492: "SubjectLocation", + 41493: "ExposureIndex", + 41495: "SensingMethod", + 41728: "FileSource", + 41729: "SceneType", + 41730: "CFAPattern", + 41985: "CustomRendered", + 41986: "ExposureMode", + 41987: "WhiteBalance", + 41988: "DigitalZoomRatio", + 41989: "FocalLengthIn35mmFilm", + 41990: "SceneCaptureType", + 41991: "GainControl", + 41992: "Contrast", + 41993: "Saturation", + 41994: "Sharpness", + 41995: "DeviceSettingDescription", + 41996: "SubjectDistanceRange", + 42016: "ImageUniqueID", + 42032: "CameraOwnerName", + 42033: "BodySerialNumber", + 42034: "LensSpecification", + 42035: "LensMake", + 42036: "LensModel", + 42037: "LensSerialNumber", + 42112: "GDAL_METADATA", + 42113: "GDAL_NODATA", + 42240: "Gamma", + 50215: "Oce Scanjob Description", + 50216: "Oce Application Selector", + 50217: "Oce Identification Number", + 50218: "Oce ImageLogic Characteristics", + # Adobe DNG + 50706: "DNGVersion", + 50707: "DNGBackwardVersion", + 50708: "UniqueCameraModel", + 50709: "LocalizedCameraModel", + 50710: "CFAPlaneColor", + 50711: "CFALayout", + 50712: "LinearizationTable", + 50713: "BlackLevelRepeatDim", + 50714: "BlackLevel", + 50715: "BlackLevelDeltaH", + 50716: "BlackLevelDeltaV", + 50717: "WhiteLevel", + 50718: "DefaultScale", + 50719: "DefaultCropOrigin", + 50720: "DefaultCropSize", + 50721: "ColorMatrix1", + 50722: "ColorMatrix2", + 50723: "CameraCalibration1", + 50724: "CameraCalibration2", + 50725: "ReductionMatrix1", + 50726: "ReductionMatrix2", + 50727: "AnalogBalance", + 50728: "AsShotNeutral", + 50729: "AsShotWhiteXY", + 50730: "BaselineExposure", + 50731: "BaselineNoise", + 50732: "BaselineSharpness", + 50733: "BayerGreenSplit", + 50734: "LinearResponseLimit", + 50735: "CameraSerialNumber", + 50736: "LensInfo", + 50737: "ChromaBlurRadius", + 50738: "AntiAliasStrength", + 50740: "DNGPrivateData", + 50778: "CalibrationIlluminant1", + 50779: "CalibrationIlluminant2", + 50784: "Alias Layer Metadata", +} + + +def _populate(): + for k, v in TAGS_V2.items(): + # Populate legacy structure. + TAGS[k] = v[0] + if len(v) == 4: + for sk, sv in v[3].items(): + TAGS[(k, sv)] = sk + + TAGS_V2[k] = TagInfo(k, *v) + + for tags in TAGS_V2_GROUPS.values(): + for k, v in tags.items(): + tags[k] = TagInfo(k, *v) + + +_populate() +## +# Map type numbers to type names -- defined in ImageFileDirectory. + +TYPES: dict[int, str] = {} + +# +# These tags are handled by default in libtiff, without +# adding to the custom dictionary. From tif_dir.c, searching for +# case TIFFTAG in the _TIFFVSetField function: +# Line: item. +# 148: case TIFFTAG_SUBFILETYPE: +# 151: case TIFFTAG_IMAGEWIDTH: +# 154: case TIFFTAG_IMAGELENGTH: +# 157: case TIFFTAG_BITSPERSAMPLE: +# 181: case TIFFTAG_COMPRESSION: +# 202: case TIFFTAG_PHOTOMETRIC: +# 205: case TIFFTAG_THRESHHOLDING: +# 208: case TIFFTAG_FILLORDER: +# 214: case TIFFTAG_ORIENTATION: +# 221: case TIFFTAG_SAMPLESPERPIXEL: +# 228: case TIFFTAG_ROWSPERSTRIP: +# 238: case TIFFTAG_MINSAMPLEVALUE: +# 241: case TIFFTAG_MAXSAMPLEVALUE: +# 244: case TIFFTAG_SMINSAMPLEVALUE: +# 247: case TIFFTAG_SMAXSAMPLEVALUE: +# 250: case TIFFTAG_XRESOLUTION: +# 256: case TIFFTAG_YRESOLUTION: +# 262: case TIFFTAG_PLANARCONFIG: +# 268: case TIFFTAG_XPOSITION: +# 271: case TIFFTAG_YPOSITION: +# 274: case TIFFTAG_RESOLUTIONUNIT: +# 280: case TIFFTAG_PAGENUMBER: +# 284: case TIFFTAG_HALFTONEHINTS: +# 288: case TIFFTAG_COLORMAP: +# 294: case TIFFTAG_EXTRASAMPLES: +# 298: case TIFFTAG_MATTEING: +# 305: case TIFFTAG_TILEWIDTH: +# 316: case TIFFTAG_TILELENGTH: +# 327: case TIFFTAG_TILEDEPTH: +# 333: case TIFFTAG_DATATYPE: +# 344: case TIFFTAG_SAMPLEFORMAT: +# 361: case TIFFTAG_IMAGEDEPTH: +# 364: case TIFFTAG_SUBIFD: +# 376: case TIFFTAG_YCBCRPOSITIONING: +# 379: case TIFFTAG_YCBCRSUBSAMPLING: +# 383: case TIFFTAG_TRANSFERFUNCTION: +# 389: case TIFFTAG_REFERENCEBLACKWHITE: +# 393: case TIFFTAG_INKNAMES: + +# Following pseudo-tags are also handled by default in libtiff: +# TIFFTAG_JPEGQUALITY 65537 + +# some of these are not in our TAGS_V2 dict and were included from tiff.h + +# This list also exists in encode.c +LIBTIFF_CORE = { + 255, + 256, + 257, + 258, + 259, + 262, + 263, + 266, + 274, + 277, + 278, + 280, + 281, + 340, + 341, + 282, + 283, + 284, + 286, + 287, + 296, + 297, + 321, + 320, + 338, + 32995, + 322, + 323, + 32998, + 32996, + 339, + 32997, + 330, + 531, + 530, + 301, + 532, + 333, + # as above + 269, # this has been in our tests forever, and works + 65537, +} + +LIBTIFF_CORE.remove(255) # We don't have support for subfiletypes +LIBTIFF_CORE.remove(322) # We don't have support for writing tiled images with libtiff +LIBTIFF_CORE.remove(323) # Tiled images +LIBTIFF_CORE.remove(333) # Ink Names either + +# Note to advanced users: There may be combinations of these +# parameters and values that when added properly, will work and +# produce valid tiff images that may work in your application. +# It is safe to add and remove tags from this set from Pillow's point +# of view so long as you test against libtiff. diff --git a/venv/lib/python3.10/site-packages/PIL/WalImageFile.py b/venv/lib/python3.10/site-packages/PIL/WalImageFile.py new file mode 100644 index 00000000..c5bf3e04 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/WalImageFile.py @@ -0,0 +1,124 @@ +# +# The Python Imaging Library. +# $Id$ +# +# WAL file handling +# +# History: +# 2003-04-23 fl created +# +# Copyright (c) 2003 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +""" +This reader is based on the specification available from: +https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml +and has been tested with a few sample files found using google. + +.. note:: + This format cannot be automatically recognized, so the reader + is not registered for use with :py:func:`PIL.Image.open()`. + To open a WAL file, use the :py:func:`PIL.WalImageFile.open()` function instead. +""" +from __future__ import annotations + +from . import Image, ImageFile +from ._binary import i32le as i32 + + +class WalImageFile(ImageFile.ImageFile): + format = "WAL" + format_description = "Quake2 Texture" + + def _open(self): + self._mode = "P" + + # read header fields + header = self.fp.read(32 + 24 + 32 + 12) + self._size = i32(header, 32), i32(header, 36) + Image._decompression_bomb_check(self.size) + + # load pixel data + offset = i32(header, 40) + self.fp.seek(offset) + + # strings are null-terminated + self.info["name"] = header[:32].split(b"\0", 1)[0] + next_name = header[56 : 56 + 32].split(b"\0", 1)[0] + if next_name: + self.info["next_name"] = next_name + + def load(self): + if not self.im: + self.im = Image.core.new(self.mode, self.size) + self.frombytes(self.fp.read(self.size[0] * self.size[1])) + self.putpalette(quake2palette) + return Image.Image.load(self) + + +def open(filename): + """ + Load texture from a Quake2 WAL texture file. + + By default, a Quake2 standard palette is attached to the texture. + To override the palette, use the :py:func:`PIL.Image.Image.putpalette()` method. + + :param filename: WAL file name, or an opened file handle. + :returns: An image instance. + """ + return WalImageFile(filename) + + +quake2palette = ( + # default palette taken from piffo 0.93 by Hans Häggström + b"\x01\x01\x01\x0b\x0b\x0b\x12\x12\x12\x17\x17\x17\x1b\x1b\x1b\x1e" + b"\x1e\x1e\x22\x22\x22\x26\x26\x26\x29\x29\x29\x2c\x2c\x2c\x2f\x2f" + b"\x2f\x32\x32\x32\x35\x35\x35\x37\x37\x37\x3a\x3a\x3a\x3c\x3c\x3c" + b"\x24\x1e\x13\x22\x1c\x12\x20\x1b\x12\x1f\x1a\x10\x1d\x19\x10\x1b" + b"\x17\x0f\x1a\x16\x0f\x18\x14\x0d\x17\x13\x0d\x16\x12\x0d\x14\x10" + b"\x0b\x13\x0f\x0b\x10\x0d\x0a\x0f\x0b\x0a\x0d\x0b\x07\x0b\x0a\x07" + b"\x23\x23\x26\x22\x22\x25\x22\x20\x23\x21\x1f\x22\x20\x1e\x20\x1f" + b"\x1d\x1e\x1d\x1b\x1c\x1b\x1a\x1a\x1a\x19\x19\x18\x17\x17\x17\x16" + b"\x16\x14\x14\x14\x13\x13\x13\x10\x10\x10\x0f\x0f\x0f\x0d\x0d\x0d" + b"\x2d\x28\x20\x29\x24\x1c\x27\x22\x1a\x25\x1f\x17\x38\x2e\x1e\x31" + b"\x29\x1a\x2c\x25\x17\x26\x20\x14\x3c\x30\x14\x37\x2c\x13\x33\x28" + b"\x12\x2d\x24\x10\x28\x1f\x0f\x22\x1a\x0b\x1b\x14\x0a\x13\x0f\x07" + b"\x31\x1a\x16\x30\x17\x13\x2e\x16\x10\x2c\x14\x0d\x2a\x12\x0b\x27" + b"\x0f\x0a\x25\x0f\x07\x21\x0d\x01\x1e\x0b\x01\x1c\x0b\x01\x1a\x0b" + b"\x01\x18\x0a\x01\x16\x0a\x01\x13\x0a\x01\x10\x07\x01\x0d\x07\x01" + b"\x29\x23\x1e\x27\x21\x1c\x26\x20\x1b\x25\x1f\x1a\x23\x1d\x19\x21" + b"\x1c\x18\x20\x1b\x17\x1e\x19\x16\x1c\x18\x14\x1b\x17\x13\x19\x14" + b"\x10\x17\x13\x0f\x14\x10\x0d\x12\x0f\x0b\x0f\x0b\x0a\x0b\x0a\x07" + b"\x26\x1a\x0f\x23\x19\x0f\x20\x17\x0f\x1c\x16\x0f\x19\x13\x0d\x14" + b"\x10\x0b\x10\x0d\x0a\x0b\x0a\x07\x33\x22\x1f\x35\x29\x26\x37\x2f" + b"\x2d\x39\x35\x34\x37\x39\x3a\x33\x37\x39\x30\x34\x36\x2b\x31\x34" + b"\x27\x2e\x31\x22\x2b\x2f\x1d\x28\x2c\x17\x25\x2a\x0f\x20\x26\x0d" + b"\x1e\x25\x0b\x1c\x22\x0a\x1b\x20\x07\x19\x1e\x07\x17\x1b\x07\x14" + b"\x18\x01\x12\x16\x01\x0f\x12\x01\x0b\x0d\x01\x07\x0a\x01\x01\x01" + b"\x2c\x21\x21\x2a\x1f\x1f\x29\x1d\x1d\x27\x1c\x1c\x26\x1a\x1a\x24" + b"\x18\x18\x22\x17\x17\x21\x16\x16\x1e\x13\x13\x1b\x12\x12\x18\x10" + b"\x10\x16\x0d\x0d\x12\x0b\x0b\x0d\x0a\x0a\x0a\x07\x07\x01\x01\x01" + b"\x2e\x30\x29\x2d\x2e\x27\x2b\x2c\x26\x2a\x2a\x24\x28\x29\x23\x27" + b"\x27\x21\x26\x26\x1f\x24\x24\x1d\x22\x22\x1c\x1f\x1f\x1a\x1c\x1c" + b"\x18\x19\x19\x16\x17\x17\x13\x13\x13\x10\x0f\x0f\x0d\x0b\x0b\x0a" + b"\x30\x1e\x1b\x2d\x1c\x19\x2c\x1a\x17\x2a\x19\x14\x28\x17\x13\x26" + b"\x16\x10\x24\x13\x0f\x21\x12\x0d\x1f\x10\x0b\x1c\x0f\x0a\x19\x0d" + b"\x0a\x16\x0b\x07\x12\x0a\x07\x0f\x07\x01\x0a\x01\x01\x01\x01\x01" + b"\x28\x29\x38\x26\x27\x36\x25\x26\x34\x24\x24\x31\x22\x22\x2f\x20" + b"\x21\x2d\x1e\x1f\x2a\x1d\x1d\x27\x1b\x1b\x25\x19\x19\x21\x17\x17" + b"\x1e\x14\x14\x1b\x13\x12\x17\x10\x0f\x13\x0d\x0b\x0f\x0a\x07\x07" + b"\x2f\x32\x29\x2d\x30\x26\x2b\x2e\x24\x29\x2c\x21\x27\x2a\x1e\x25" + b"\x28\x1c\x23\x26\x1a\x21\x25\x18\x1e\x22\x14\x1b\x1f\x10\x19\x1c" + b"\x0d\x17\x1a\x0a\x13\x17\x07\x10\x13\x01\x0d\x0f\x01\x0a\x0b\x01" + b"\x01\x3f\x01\x13\x3c\x0b\x1b\x39\x10\x20\x35\x14\x23\x31\x17\x23" + b"\x2d\x18\x23\x29\x18\x3f\x3f\x3f\x3f\x3f\x39\x3f\x3f\x31\x3f\x3f" + b"\x2a\x3f\x3f\x20\x3f\x3f\x14\x3f\x3c\x12\x3f\x39\x0f\x3f\x35\x0b" + b"\x3f\x32\x07\x3f\x2d\x01\x3d\x2a\x01\x3b\x26\x01\x39\x21\x01\x37" + b"\x1d\x01\x34\x1a\x01\x32\x16\x01\x2f\x12\x01\x2d\x0f\x01\x2a\x0b" + b"\x01\x27\x07\x01\x23\x01\x01\x1d\x01\x01\x17\x01\x01\x10\x01\x01" + b"\x3d\x01\x01\x19\x19\x3f\x3f\x01\x01\x01\x01\x3f\x16\x16\x13\x10" + b"\x10\x0f\x0d\x0d\x0b\x3c\x2e\x2a\x36\x27\x20\x30\x21\x18\x29\x1b" + b"\x10\x3c\x39\x37\x37\x32\x2f\x31\x2c\x28\x2b\x26\x21\x30\x22\x20" +) diff --git a/venv/lib/python3.10/site-packages/PIL/WebPImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/WebPImagePlugin.py new file mode 100644 index 00000000..c07abcaf --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/WebPImagePlugin.py @@ -0,0 +1,370 @@ +from __future__ import annotations + +from io import BytesIO + +from . import Image, ImageFile + +try: + from . import _webp + + SUPPORTED = True +except ImportError: + SUPPORTED = False + + +_VALID_WEBP_MODES = {"RGBX": True, "RGBA": True, "RGB": True} + +_VALID_WEBP_LEGACY_MODES = {"RGB": True, "RGBA": True} + +_VP8_MODES_BY_IDENTIFIER = { + b"VP8 ": "RGB", + b"VP8X": "RGBA", + b"VP8L": "RGBA", # lossless +} + + +def _accept(prefix): + is_riff_file_format = prefix[:4] == b"RIFF" + is_webp_file = prefix[8:12] == b"WEBP" + is_valid_vp8_mode = prefix[12:16] in _VP8_MODES_BY_IDENTIFIER + + if is_riff_file_format and is_webp_file and is_valid_vp8_mode: + if not SUPPORTED: + return ( + "image file could not be identified because WEBP support not installed" + ) + return True + + +class WebPImageFile(ImageFile.ImageFile): + format = "WEBP" + format_description = "WebP image" + __loaded = 0 + __logical_frame = 0 + + def _open(self): + if not _webp.HAVE_WEBPANIM: + # Legacy mode + data, width, height, self._mode, icc_profile, exif = _webp.WebPDecode( + self.fp.read() + ) + if icc_profile: + self.info["icc_profile"] = icc_profile + if exif: + self.info["exif"] = exif + self._size = width, height + self.fp = BytesIO(data) + self.tile = [("raw", (0, 0) + self.size, 0, self.mode)] + self.n_frames = 1 + self.is_animated = False + return + + # Use the newer AnimDecoder API to parse the (possibly) animated file, + # and access muxed chunks like ICC/EXIF/XMP. + self._decoder = _webp.WebPAnimDecoder(self.fp.read()) + + # Get info from decoder + width, height, loop_count, bgcolor, frame_count, mode = self._decoder.get_info() + self._size = width, height + self.info["loop"] = loop_count + bg_a, bg_r, bg_g, bg_b = ( + (bgcolor >> 24) & 0xFF, + (bgcolor >> 16) & 0xFF, + (bgcolor >> 8) & 0xFF, + bgcolor & 0xFF, + ) + self.info["background"] = (bg_r, bg_g, bg_b, bg_a) + self.n_frames = frame_count + self.is_animated = self.n_frames > 1 + self._mode = "RGB" if mode == "RGBX" else mode + self.rawmode = mode + self.tile = [] + + # Attempt to read ICC / EXIF / XMP chunks from file + icc_profile = self._decoder.get_chunk("ICCP") + exif = self._decoder.get_chunk("EXIF") + xmp = self._decoder.get_chunk("XMP ") + if icc_profile: + self.info["icc_profile"] = icc_profile + if exif: + self.info["exif"] = exif + if xmp: + self.info["xmp"] = xmp + + # Initialize seek state + self._reset(reset=False) + + def _getexif(self): + if "exif" not in self.info: + return None + return self.getexif()._get_merged_dict() + + def getxmp(self): + """ + Returns a dictionary containing the XMP tags. + Requires defusedxml to be installed. + + :returns: XMP tags in a dictionary. + """ + return self._getxmp(self.info["xmp"]) if "xmp" in self.info else {} + + def seek(self, frame): + if not self._seek_check(frame): + return + + # Set logical frame to requested position + self.__logical_frame = frame + + def _reset(self, reset=True): + if reset: + self._decoder.reset() + self.__physical_frame = 0 + self.__loaded = -1 + self.__timestamp = 0 + + def _get_next(self): + # Get next frame + ret = self._decoder.get_next() + self.__physical_frame += 1 + + # Check if an error occurred + if ret is None: + self._reset() # Reset just to be safe + self.seek(0) + msg = "failed to decode next frame in WebP file" + raise EOFError(msg) + + # Compute duration + data, timestamp = ret + duration = timestamp - self.__timestamp + self.__timestamp = timestamp + + # libwebp gives frame end, adjust to start of frame + timestamp -= duration + return data, timestamp, duration + + def _seek(self, frame): + if self.__physical_frame == frame: + return # Nothing to do + if frame < self.__physical_frame: + self._reset() # Rewind to beginning + while self.__physical_frame < frame: + self._get_next() # Advance to the requested frame + + def load(self): + if _webp.HAVE_WEBPANIM: + if self.__loaded != self.__logical_frame: + self._seek(self.__logical_frame) + + # We need to load the image data for this frame + data, timestamp, duration = self._get_next() + self.info["timestamp"] = timestamp + self.info["duration"] = duration + self.__loaded = self.__logical_frame + + # Set tile + if self.fp and self._exclusive_fp: + self.fp.close() + self.fp = BytesIO(data) + self.tile = [("raw", (0, 0) + self.size, 0, self.rawmode)] + + return super().load() + + def load_seek(self, pos): + pass + + def tell(self): + if not _webp.HAVE_WEBPANIM: + return super().tell() + + return self.__logical_frame + + +def _save_all(im, fp, filename): + encoderinfo = im.encoderinfo.copy() + append_images = list(encoderinfo.get("append_images", [])) + + # If total frame count is 1, then save using the legacy API, which + # will preserve non-alpha modes + total = 0 + for ims in [im] + append_images: + total += getattr(ims, "n_frames", 1) + if total == 1: + _save(im, fp, filename) + return + + background = (0, 0, 0, 0) + if "background" in encoderinfo: + background = encoderinfo["background"] + elif "background" in im.info: + background = im.info["background"] + if isinstance(background, int): + # GifImagePlugin stores a global color table index in + # info["background"]. So it must be converted to an RGBA value + palette = im.getpalette() + if palette: + r, g, b = palette[background * 3 : (background + 1) * 3] + background = (r, g, b, 255) + else: + background = (background, background, background, 255) + + duration = im.encoderinfo.get("duration", im.info.get("duration", 0)) + loop = im.encoderinfo.get("loop", 0) + minimize_size = im.encoderinfo.get("minimize_size", False) + kmin = im.encoderinfo.get("kmin", None) + kmax = im.encoderinfo.get("kmax", None) + allow_mixed = im.encoderinfo.get("allow_mixed", False) + verbose = False + lossless = im.encoderinfo.get("lossless", False) + quality = im.encoderinfo.get("quality", 80) + alpha_quality = im.encoderinfo.get("alpha_quality", 100) + method = im.encoderinfo.get("method", 0) + icc_profile = im.encoderinfo.get("icc_profile") or "" + exif = im.encoderinfo.get("exif", "") + if isinstance(exif, Image.Exif): + exif = exif.tobytes() + xmp = im.encoderinfo.get("xmp", "") + if allow_mixed: + lossless = False + + # Sensible keyframe defaults are from gif2webp.c script + if kmin is None: + kmin = 9 if lossless else 3 + if kmax is None: + kmax = 17 if lossless else 5 + + # Validate background color + if ( + not isinstance(background, (list, tuple)) + or len(background) != 4 + or not all(0 <= v < 256 for v in background) + ): + msg = f"Background color is not an RGBA tuple clamped to (0-255): {background}" + raise OSError(msg) + + # Convert to packed uint + bg_r, bg_g, bg_b, bg_a = background + background = (bg_a << 24) | (bg_r << 16) | (bg_g << 8) | (bg_b << 0) + + # Setup the WebP animation encoder + enc = _webp.WebPAnimEncoder( + im.size[0], + im.size[1], + background, + loop, + minimize_size, + kmin, + kmax, + allow_mixed, + verbose, + ) + + # Add each frame + frame_idx = 0 + timestamp = 0 + cur_idx = im.tell() + try: + for ims in [im] + append_images: + # Get # of frames in this image + nfr = getattr(ims, "n_frames", 1) + + for idx in range(nfr): + ims.seek(idx) + ims.load() + + # Make sure image mode is supported + frame = ims + rawmode = ims.mode + if ims.mode not in _VALID_WEBP_MODES: + alpha = ( + "A" in ims.mode + or "a" in ims.mode + or (ims.mode == "P" and "A" in ims.im.getpalettemode()) + ) + rawmode = "RGBA" if alpha else "RGB" + frame = ims.convert(rawmode) + + if rawmode == "RGB": + # For faster conversion, use RGBX + rawmode = "RGBX" + + # Append the frame to the animation encoder + enc.add( + frame.tobytes("raw", rawmode), + round(timestamp), + frame.size[0], + frame.size[1], + rawmode, + lossless, + quality, + alpha_quality, + method, + ) + + # Update timestamp and frame index + if isinstance(duration, (list, tuple)): + timestamp += duration[frame_idx] + else: + timestamp += duration + frame_idx += 1 + + finally: + im.seek(cur_idx) + + # Force encoder to flush frames + enc.add(None, round(timestamp), 0, 0, "", lossless, quality, alpha_quality, 0) + + # Get the final output from the encoder + data = enc.assemble(icc_profile, exif, xmp) + if data is None: + msg = "cannot write file as WebP (encoder returned None)" + raise OSError(msg) + + fp.write(data) + + +def _save(im, fp, filename): + lossless = im.encoderinfo.get("lossless", False) + quality = im.encoderinfo.get("quality", 80) + alpha_quality = im.encoderinfo.get("alpha_quality", 100) + icc_profile = im.encoderinfo.get("icc_profile") or "" + exif = im.encoderinfo.get("exif", b"") + if isinstance(exif, Image.Exif): + exif = exif.tobytes() + if exif.startswith(b"Exif\x00\x00"): + exif = exif[6:] + xmp = im.encoderinfo.get("xmp", "") + method = im.encoderinfo.get("method", 4) + exact = 1 if im.encoderinfo.get("exact") else 0 + + if im.mode not in _VALID_WEBP_LEGACY_MODES: + im = im.convert("RGBA" if im.has_transparency_data else "RGB") + + data = _webp.WebPEncode( + im.tobytes(), + im.size[0], + im.size[1], + lossless, + float(quality), + float(alpha_quality), + im.mode, + icc_profile, + method, + exact, + exif, + xmp, + ) + if data is None: + msg = "cannot write file as WebP (encoder returned None)" + raise OSError(msg) + + fp.write(data) + + +Image.register_open(WebPImageFile.format, WebPImageFile, _accept) +if SUPPORTED: + Image.register_save(WebPImageFile.format, _save) + if _webp.HAVE_WEBPANIM: + Image.register_save_all(WebPImageFile.format, _save_all) + Image.register_extension(WebPImageFile.format, ".webp") + Image.register_mime(WebPImageFile.format, "image/webp") diff --git a/venv/lib/python3.10/site-packages/PIL/WmfImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/WmfImagePlugin.py new file mode 100644 index 00000000..b5b8c69b --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/WmfImagePlugin.py @@ -0,0 +1,179 @@ +# +# The Python Imaging Library +# $Id$ +# +# WMF stub codec +# +# history: +# 1996-12-14 fl Created +# 2004-02-22 fl Turned into a stub driver +# 2004-02-23 fl Added EMF support +# +# Copyright (c) Secret Labs AB 1997-2004. All rights reserved. +# Copyright (c) Fredrik Lundh 1996. +# +# See the README file for information on usage and redistribution. +# +# WMF/EMF reference documentation: +# https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-WMF/[MS-WMF].pdf +# http://wvware.sourceforge.net/caolan/index.html +# http://wvware.sourceforge.net/caolan/ora-wmf.html +from __future__ import annotations + +from . import Image, ImageFile +from ._binary import i16le as word +from ._binary import si16le as short +from ._binary import si32le as _long + +_handler = None + + +def register_handler(handler): + """ + Install application-specific WMF image handler. + + :param handler: Handler object. + """ + global _handler + _handler = handler + + +if hasattr(Image.core, "drawwmf"): + # install default handler (windows only) + + class WmfHandler: + def open(self, im): + im._mode = "RGB" + self.bbox = im.info["wmf_bbox"] + + def load(self, im): + im.fp.seek(0) # rewind + return Image.frombytes( + "RGB", + im.size, + Image.core.drawwmf(im.fp.read(), im.size, self.bbox), + "raw", + "BGR", + (im.size[0] * 3 + 3) & -4, + -1, + ) + + register_handler(WmfHandler()) + +# +# -------------------------------------------------------------------- +# Read WMF file + + +def _accept(prefix): + return ( + prefix[:6] == b"\xd7\xcd\xc6\x9a\x00\x00" or prefix[:4] == b"\x01\x00\x00\x00" + ) + + +## +# Image plugin for Windows metafiles. + + +class WmfStubImageFile(ImageFile.StubImageFile): + format = "WMF" + format_description = "Windows Metafile" + + def _open(self): + self._inch = None + + # check placable header + s = self.fp.read(80) + + if s[:6] == b"\xd7\xcd\xc6\x9a\x00\x00": + # placeable windows metafile + + # get units per inch + self._inch = word(s, 14) + + # get bounding box + x0 = short(s, 6) + y0 = short(s, 8) + x1 = short(s, 10) + y1 = short(s, 12) + + # normalize size to 72 dots per inch + self.info["dpi"] = 72 + size = ( + (x1 - x0) * self.info["dpi"] // self._inch, + (y1 - y0) * self.info["dpi"] // self._inch, + ) + + self.info["wmf_bbox"] = x0, y0, x1, y1 + + # sanity check (standard metafile header) + if s[22:26] != b"\x01\x00\t\x00": + msg = "Unsupported WMF file format" + raise SyntaxError(msg) + + elif s[:4] == b"\x01\x00\x00\x00" and s[40:44] == b" EMF": + # enhanced metafile + + # get bounding box + x0 = _long(s, 8) + y0 = _long(s, 12) + x1 = _long(s, 16) + y1 = _long(s, 20) + + # get frame (in 0.01 millimeter units) + frame = _long(s, 24), _long(s, 28), _long(s, 32), _long(s, 36) + + size = x1 - x0, y1 - y0 + + # calculate dots per inch from bbox and frame + xdpi = 2540.0 * (x1 - y0) / (frame[2] - frame[0]) + ydpi = 2540.0 * (y1 - y0) / (frame[3] - frame[1]) + + self.info["wmf_bbox"] = x0, y0, x1, y1 + + if xdpi == ydpi: + self.info["dpi"] = xdpi + else: + self.info["dpi"] = xdpi, ydpi + + else: + msg = "Unsupported file format" + raise SyntaxError(msg) + + self._mode = "RGB" + self._size = size + + loader = self._load() + if loader: + loader.open(self) + + def _load(self): + return _handler + + def load(self, dpi=None): + if dpi is not None and self._inch is not None: + self.info["dpi"] = dpi + x0, y0, x1, y1 = self.info["wmf_bbox"] + self._size = ( + (x1 - x0) * self.info["dpi"] // self._inch, + (y1 - y0) * self.info["dpi"] // self._inch, + ) + return super().load() + + +def _save(im, fp, filename): + if _handler is None or not hasattr(_handler, "save"): + msg = "WMF save handler not installed" + raise OSError(msg) + _handler.save(im, fp, filename) + + +# +# -------------------------------------------------------------------- +# Registry stuff + + +Image.register_open(WmfStubImageFile.format, WmfStubImageFile, _accept) +Image.register_save(WmfStubImageFile.format, _save) + +Image.register_extensions(WmfStubImageFile.format, [".wmf", ".emf"]) diff --git a/venv/lib/python3.10/site-packages/PIL/XVThumbImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/XVThumbImagePlugin.py new file mode 100644 index 00000000..c84adaca --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/XVThumbImagePlugin.py @@ -0,0 +1,81 @@ +# +# The Python Imaging Library. +# $Id$ +# +# XV Thumbnail file handler by Charles E. "Gene" Cash +# (gcash@magicnet.net) +# +# see xvcolor.c and xvbrowse.c in the sources to John Bradley's XV, +# available from ftp://ftp.cis.upenn.edu/pub/xv/ +# +# history: +# 98-08-15 cec created (b/w only) +# 98-12-09 cec added color palette +# 98-12-28 fl added to PIL (with only a few very minor modifications) +# +# To do: +# FIXME: make save work (this requires quantization support) +# +from __future__ import annotations + +from . import Image, ImageFile, ImagePalette +from ._binary import o8 + +_MAGIC = b"P7 332" + +# standard color palette for thumbnails (RGB332) +PALETTE = b"" +for r in range(8): + for g in range(8): + for b in range(4): + PALETTE = PALETTE + ( + o8((r * 255) // 7) + o8((g * 255) // 7) + o8((b * 255) // 3) + ) + + +def _accept(prefix: bytes) -> bool: + return prefix[:6] == _MAGIC + + +## +# Image plugin for XV thumbnail images. + + +class XVThumbImageFile(ImageFile.ImageFile): + format = "XVThumb" + format_description = "XV thumbnail image" + + def _open(self) -> None: + # check magic + assert self.fp is not None + + if not _accept(self.fp.read(6)): + msg = "not an XV thumbnail file" + raise SyntaxError(msg) + + # Skip to beginning of next line + self.fp.readline() + + # skip info comments + while True: + s = self.fp.readline() + if not s: + msg = "Unexpected EOF reading XV thumbnail file" + raise SyntaxError(msg) + if s[0] != 35: # ie. when not a comment: '#' + break + + # parse header line (already read) + s = s.strip().split() + + self._mode = "P" + self._size = int(s[0]), int(s[1]) + + self.palette = ImagePalette.raw("RGB", PALETTE) + + self.tile = [("raw", (0, 0) + self.size, self.fp.tell(), (self.mode, 0, 1))] + + +# -------------------------------------------------------------------- + +Image.register_open(XVThumbImageFile.format, XVThumbImageFile, _accept) diff --git a/venv/lib/python3.10/site-packages/PIL/XbmImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/XbmImagePlugin.py new file mode 100644 index 00000000..eee72743 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/XbmImagePlugin.py @@ -0,0 +1,98 @@ +# +# The Python Imaging Library. +# $Id$ +# +# XBM File handling +# +# History: +# 1995-09-08 fl Created +# 1996-11-01 fl Added save support +# 1997-07-07 fl Made header parser more tolerant +# 1997-07-22 fl Fixed yet another parser bug +# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.4) +# 2001-05-13 fl Added hotspot handling (based on code from Bernhard Herzog) +# 2004-02-24 fl Allow some whitespace before first #define +# +# Copyright (c) 1997-2004 by Secret Labs AB +# Copyright (c) 1996-1997 by Fredrik Lundh +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import re +from typing import IO + +from . import Image, ImageFile + +# XBM header +xbm_head = re.compile( + rb"\s*#define[ \t]+.*_width[ \t]+(?P[0-9]+)[\r\n]+" + b"#define[ \t]+.*_height[ \t]+(?P[0-9]+)[\r\n]+" + b"(?P" + b"#define[ \t]+[^_]*_x_hot[ \t]+(?P[0-9]+)[\r\n]+" + b"#define[ \t]+[^_]*_y_hot[ \t]+(?P[0-9]+)[\r\n]+" + b")?" + rb"[\000-\377]*_bits\[]" +) + + +def _accept(prefix: bytes) -> bool: + return prefix.lstrip()[:7] == b"#define" + + +## +# Image plugin for X11 bitmaps. + + +class XbmImageFile(ImageFile.ImageFile): + format = "XBM" + format_description = "X11 Bitmap" + + def _open(self) -> None: + assert self.fp is not None + + m = xbm_head.match(self.fp.read(512)) + + if not m: + msg = "not a XBM file" + raise SyntaxError(msg) + + xsize = int(m.group("width")) + ysize = int(m.group("height")) + + if m.group("hotspot"): + self.info["hotspot"] = (int(m.group("xhot")), int(m.group("yhot"))) + + self._mode = "1" + self._size = xsize, ysize + + self.tile = [("xbm", (0, 0) + self.size, m.end(), None)] + + +def _save(im: Image.Image, fp: IO[bytes], filename: str) -> None: + if im.mode != "1": + msg = f"cannot write mode {im.mode} as XBM" + raise OSError(msg) + + fp.write(f"#define im_width {im.size[0]}\n".encode("ascii")) + fp.write(f"#define im_height {im.size[1]}\n".encode("ascii")) + + hotspot = im.encoderinfo.get("hotspot") + if hotspot: + fp.write(f"#define im_x_hot {hotspot[0]}\n".encode("ascii")) + fp.write(f"#define im_y_hot {hotspot[1]}\n".encode("ascii")) + + fp.write(b"static char im_bits[] = {\n") + + ImageFile._save(im, fp, [("xbm", (0, 0) + im.size, 0, None)]) + + fp.write(b"};\n") + + +Image.register_open(XbmImageFile.format, XbmImageFile, _accept) +Image.register_save(XbmImageFile.format, _save) + +Image.register_extension(XbmImageFile.format, ".xbm") + +Image.register_mime(XbmImageFile.format, "image/xbm") diff --git a/venv/lib/python3.10/site-packages/PIL/XpmImagePlugin.py b/venv/lib/python3.10/site-packages/PIL/XpmImagePlugin.py new file mode 100644 index 00000000..3125f8d5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/XpmImagePlugin.py @@ -0,0 +1,128 @@ +# +# The Python Imaging Library. +# $Id$ +# +# XPM File handling +# +# History: +# 1996-12-29 fl Created +# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.7) +# +# Copyright (c) Secret Labs AB 1997-2001. +# Copyright (c) Fredrik Lundh 1996-2001. +# +# See the README file for information on usage and redistribution. +# +from __future__ import annotations + +import re + +from . import Image, ImageFile, ImagePalette +from ._binary import o8 + +# XPM header +xpm_head = re.compile(b'"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)') + + +def _accept(prefix): + return prefix[:9] == b"/* XPM */" + + +## +# Image plugin for X11 pixel maps. + + +class XpmImageFile(ImageFile.ImageFile): + format = "XPM" + format_description = "X11 Pixel Map" + + def _open(self): + if not _accept(self.fp.read(9)): + msg = "not an XPM file" + raise SyntaxError(msg) + + # skip forward to next string + while True: + s = self.fp.readline() + if not s: + msg = "broken XPM file" + raise SyntaxError(msg) + m = xpm_head.match(s) + if m: + break + + self._size = int(m.group(1)), int(m.group(2)) + + pal = int(m.group(3)) + bpp = int(m.group(4)) + + if pal > 256 or bpp != 1: + msg = "cannot read this XPM file" + raise ValueError(msg) + + # + # load palette description + + palette = [b"\0\0\0"] * 256 + + for _ in range(pal): + s = self.fp.readline() + if s[-2:] == b"\r\n": + s = s[:-2] + elif s[-1:] in b"\r\n": + s = s[:-1] + + c = s[1] + s = s[2:-2].split() + + for i in range(0, len(s), 2): + if s[i] == b"c": + # process colour key + rgb = s[i + 1] + if rgb == b"None": + self.info["transparency"] = c + elif rgb[:1] == b"#": + # FIXME: handle colour names (see ImagePalette.py) + rgb = int(rgb[1:], 16) + palette[c] = ( + o8((rgb >> 16) & 255) + o8((rgb >> 8) & 255) + o8(rgb & 255) + ) + else: + # unknown colour + msg = "cannot read this XPM file" + raise ValueError(msg) + break + + else: + # missing colour key + msg = "cannot read this XPM file" + raise ValueError(msg) + + self._mode = "P" + self.palette = ImagePalette.raw("RGB", b"".join(palette)) + + self.tile = [("raw", (0, 0) + self.size, self.fp.tell(), ("P", 0, 1))] + + def load_read(self, read_bytes): + # + # load all image data in one chunk + + xsize, ysize = self.size + + s = [None] * ysize + + for i in range(ysize): + s[i] = self.fp.readline()[1 : xsize + 1].ljust(xsize) + + return b"".join(s) + + +# +# Registry + + +Image.register_open(XpmImageFile.format, XpmImageFile, _accept) + +Image.register_extension(XpmImageFile.format, ".xpm") + +Image.register_mime(XpmImageFile.format, "image/xpm") diff --git a/venv/lib/python3.10/site-packages/PIL/__init__.py b/venv/lib/python3.10/site-packages/PIL/__init__.py new file mode 100644 index 00000000..09546fe6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/__init__.py @@ -0,0 +1,86 @@ +"""Pillow (Fork of the Python Imaging Library) + +Pillow is the friendly PIL fork by Jeffrey A. Clark and contributors. + https://github.com/python-pillow/Pillow/ + +Pillow is forked from PIL 1.1.7. + +PIL is the Python Imaging Library by Fredrik Lundh and contributors. +Copyright (c) 1999 by Secret Labs AB. + +Use PIL.__version__ for this Pillow version. + +;-) +""" + +from __future__ import annotations + +from . import _version + +# VERSION was removed in Pillow 6.0.0. +# PILLOW_VERSION was removed in Pillow 9.0.0. +# Use __version__ instead. +__version__ = _version.__version__ +del _version + + +_plugins = [ + "BlpImagePlugin", + "BmpImagePlugin", + "BufrStubImagePlugin", + "CurImagePlugin", + "DcxImagePlugin", + "DdsImagePlugin", + "EpsImagePlugin", + "FitsImagePlugin", + "FliImagePlugin", + "FpxImagePlugin", + "FtexImagePlugin", + "GbrImagePlugin", + "GifImagePlugin", + "GribStubImagePlugin", + "Hdf5StubImagePlugin", + "IcnsImagePlugin", + "IcoImagePlugin", + "ImImagePlugin", + "ImtImagePlugin", + "IptcImagePlugin", + "JpegImagePlugin", + "Jpeg2KImagePlugin", + "McIdasImagePlugin", + "MicImagePlugin", + "MpegImagePlugin", + "MpoImagePlugin", + "MspImagePlugin", + "PalmImagePlugin", + "PcdImagePlugin", + "PcxImagePlugin", + "PdfImagePlugin", + "PixarImagePlugin", + "PngImagePlugin", + "PpmImagePlugin", + "PsdImagePlugin", + "QoiImagePlugin", + "SgiImagePlugin", + "SpiderImagePlugin", + "SunImagePlugin", + "TgaImagePlugin", + "TiffImagePlugin", + "WebPImagePlugin", + "WmfImagePlugin", + "XbmImagePlugin", + "XpmImagePlugin", + "XVThumbImagePlugin", +] + + +class UnidentifiedImageError(OSError): + """ + Raised in :py:meth:`PIL.Image.open` if an image cannot be opened and identified. + + If a PNG image raises this error, setting :data:`.ImageFile.LOAD_TRUNCATED_IMAGES` + to true may allow the image to be opened after all. The setting will ignore missing + data and checksum failures. + """ + + pass diff --git a/venv/lib/python3.10/site-packages/PIL/__main__.py b/venv/lib/python3.10/site-packages/PIL/__main__.py new file mode 100644 index 00000000..043156e8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/__main__.py @@ -0,0 +1,7 @@ +from __future__ import annotations + +import sys + +from .features import pilinfo + +pilinfo(supported_formats="--report" not in sys.argv) diff --git a/venv/lib/python3.10/site-packages/PIL/_binary.py b/venv/lib/python3.10/site-packages/PIL/_binary.py new file mode 100644 index 00000000..4594ccce --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_binary.py @@ -0,0 +1,112 @@ +# +# The Python Imaging Library. +# $Id$ +# +# Binary input/output support routines. +# +# Copyright (c) 1997-2003 by Secret Labs AB +# Copyright (c) 1995-2003 by Fredrik Lundh +# Copyright (c) 2012 by Brian Crowell +# +# See the README file for information on usage and redistribution. +# + + +"""Binary input/output support routines.""" +from __future__ import annotations + +from struct import pack, unpack_from + + +def i8(c: bytes) -> int: + return c[0] + + +def o8(i: int) -> bytes: + return bytes((i & 255,)) + + +# Input, le = little endian, be = big endian +def i16le(c: bytes, o: int = 0) -> int: + """ + Converts a 2-bytes (16 bits) string to an unsigned integer. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(" int: + """ + Converts a 2-bytes (16 bits) string to a signed integer. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(" int: + """ + Converts a 2-bytes (16 bits) string to a signed integer, big endian. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(">h", c, o)[0] + + +def i32le(c: bytes, o: int = 0) -> int: + """ + Converts a 4-bytes (32 bits) string to an unsigned integer. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(" int: + """ + Converts a 4-bytes (32 bits) string to a signed integer. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(" int: + """ + Converts a 4-bytes (32 bits) string to a signed integer, big endian. + + :param c: string containing bytes to convert + :param o: offset of bytes to convert in string + """ + return unpack_from(">i", c, o)[0] + + +def i16be(c: bytes, o: int = 0) -> int: + return unpack_from(">H", c, o)[0] + + +def i32be(c: bytes, o: int = 0) -> int: + return unpack_from(">I", c, o)[0] + + +# Output, le = little endian, be = big endian +def o16le(i: int) -> bytes: + return pack(" bytes: + return pack(" bytes: + return pack(">H", i) + + +def o32be(i: int) -> bytes: + return pack(">I", i) diff --git a/venv/lib/python3.10/site-packages/PIL/_deprecate.py b/venv/lib/python3.10/site-packages/PIL/_deprecate.py new file mode 100644 index 00000000..33a0e07b --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_deprecate.py @@ -0,0 +1,71 @@ +from __future__ import annotations + +import warnings + +from . import __version__ + + +def deprecate( + deprecated: str, + when: int | None, + replacement: str | None = None, + *, + action: str | None = None, + plural: bool = False, +) -> None: + """ + Deprecations helper. + + :param deprecated: Name of thing to be deprecated. + :param when: Pillow major version to be removed in. + :param replacement: Name of replacement. + :param action: Instead of "replacement", give a custom call to action + e.g. "Upgrade to new thing". + :param plural: if the deprecated thing is plural, needing "are" instead of "is". + + Usually of the form: + + "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd). + Use [replacement] instead." + + You can leave out the replacement sentence: + + "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd)" + + Or with another call to action: + + "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd). + [action]." + """ + + is_ = "are" if plural else "is" + + if when is None: + removed = "a future version" + elif when <= int(__version__.split(".")[0]): + msg = f"{deprecated} {is_} deprecated and should be removed." + raise RuntimeError(msg) + elif when == 11: + removed = "Pillow 11 (2024-10-15)" + elif when == 12: + removed = "Pillow 12 (2025-10-15)" + else: + msg = f"Unknown removal version: {when}. Update {__name__}?" + raise ValueError(msg) + + if replacement and action: + msg = "Use only one of 'replacement' and 'action'" + raise ValueError(msg) + + if replacement: + action = f". Use {replacement} instead." + elif action: + action = f". {action.rstrip('.')}." + else: + action = "" + + warnings.warn( + f"{deprecated} {is_} deprecated and will be removed in {removed}{action}", + DeprecationWarning, + stacklevel=3, + ) diff --git a/venv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..a72af842 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_imaging.pyi b/venv/lib/python3.10/site-packages/PIL/_imaging.pyi new file mode 100644 index 00000000..e27843e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_imaging.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingcms.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imagingcms.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..b50b7aa5 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imagingcms.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingcms.pyi b/venv/lib/python3.10/site-packages/PIL/_imagingcms.pyi new file mode 100644 index 00000000..036521b0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_imagingcms.pyi @@ -0,0 +1,145 @@ +import datetime +import sys +from typing import Literal, SupportsFloat, TypedDict + +littlecms_version: str + +_Tuple3f = tuple[float, float, float] +_Tuple2x3f = tuple[_Tuple3f, _Tuple3f] +_Tuple3x3f = tuple[_Tuple3f, _Tuple3f, _Tuple3f] + +class _IccMeasurementCondition(TypedDict): + observer: int + backing: _Tuple3f + geo: str + flare: float + illuminant_type: str + +class _IccViewingCondition(TypedDict): + illuminant: _Tuple3f + surround: _Tuple3f + illuminant_type: str + +class CmsProfile: + @property + def rendering_intent(self) -> int: ... + @property + def creation_date(self) -> datetime.datetime | None: ... + @property + def copyright(self) -> str | None: ... + @property + def target(self) -> str | None: ... + @property + def manufacturer(self) -> str | None: ... + @property + def model(self) -> str | None: ... + @property + def profile_description(self) -> str | None: ... + @property + def screening_description(self) -> str | None: ... + @property + def viewing_condition(self) -> str | None: ... + @property + def version(self) -> float: ... + @property + def icc_version(self) -> int: ... + @property + def attributes(self) -> int: ... + @property + def header_flags(self) -> int: ... + @property + def header_manufacturer(self) -> str: ... + @property + def header_model(self) -> str: ... + @property + def device_class(self) -> str: ... + @property + def connection_space(self) -> str: ... + @property + def xcolor_space(self) -> str: ... + @property + def profile_id(self) -> bytes: ... + @property + def is_matrix_shaper(self) -> bool: ... + @property + def technology(self) -> str | None: ... + @property + def colorimetric_intent(self) -> str | None: ... + @property + def perceptual_rendering_intent_gamut(self) -> str | None: ... + @property + def saturation_rendering_intent_gamut(self) -> str | None: ... + @property + def red_colorant(self) -> _Tuple2x3f | None: ... + @property + def green_colorant(self) -> _Tuple2x3f | None: ... + @property + def blue_colorant(self) -> _Tuple2x3f | None: ... + @property + def red_primary(self) -> _Tuple2x3f | None: ... + @property + def green_primary(self) -> _Tuple2x3f | None: ... + @property + def blue_primary(self) -> _Tuple2x3f | None: ... + @property + def media_white_point_temperature(self) -> float | None: ... + @property + def media_white_point(self) -> _Tuple2x3f | None: ... + @property + def media_black_point(self) -> _Tuple2x3f | None: ... + @property + def luminance(self) -> _Tuple2x3f | None: ... + @property + def chromatic_adaptation(self) -> tuple[_Tuple3x3f, _Tuple3x3f] | None: ... + @property + def chromaticity(self) -> _Tuple3x3f | None: ... + @property + def colorant_table(self) -> list[str] | None: ... + @property + def colorant_table_out(self) -> list[str] | None: ... + @property + def intent_supported(self) -> dict[int, tuple[bool, bool, bool]] | None: ... + @property + def clut(self) -> dict[int, tuple[bool, bool, bool]] | None: ... + @property + def icc_measurement_condition(self) -> _IccMeasurementCondition | None: ... + @property + def icc_viewing_condition(self) -> _IccViewingCondition | None: ... + def is_intent_supported(self, intent: int, direction: int, /) -> int: ... + +class CmsTransform: + @property + def inputMode(self) -> str: ... + @property + def outputMode(self) -> str: ... + def apply(self, id_in: int, id_out: int) -> int: ... + +def profile_open(profile: str, /) -> CmsProfile: ... +def profile_frombytes(profile: bytes, /) -> CmsProfile: ... +def profile_tobytes(profile: CmsProfile, /) -> bytes: ... +def buildTransform( + input_profile: CmsProfile, + output_profile: CmsProfile, + in_mode: str, + out_mode: str, + rendering_intent: int = 0, + cms_flags: int = 0, + /, +) -> CmsTransform: ... +def buildProofTransform( + input_profile: CmsProfile, + output_profile: CmsProfile, + proof_profile: CmsProfile, + in_mode: str, + out_mode: str, + rendering_intent: int = 0, + proof_intent: int = 0, + cms_flags: int = 0, + /, +) -> CmsTransform: ... +def createProfile( + color_space: Literal["LAB", "XYZ", "sRGB"], color_temp: SupportsFloat = 0.0, / +) -> CmsProfile: ... + +if sys.platform == "win32": + def get_display_profile_win32(handle: int = 0, is_dc: int = 0, /) -> str | None: ... diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingft.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imagingft.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..66fcedb0 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imagingft.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingft.pyi b/venv/lib/python3.10/site-packages/PIL/_imagingft.pyi new file mode 100644 index 00000000..e27843e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_imagingft.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingmath.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imagingmath.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..fe92cf1d Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imagingmath.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingmath.pyi b/venv/lib/python3.10/site-packages/PIL/_imagingmath.pyi new file mode 100644 index 00000000..e27843e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_imagingmath.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingmorph.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imagingmorph.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..5974fcf6 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imagingmorph.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingmorph.pyi b/venv/lib/python3.10/site-packages/PIL/_imagingmorph.pyi new file mode 100644 index 00000000..e27843e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_imagingmorph.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/venv/lib/python3.10/site-packages/PIL/_imagingtk.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_imagingtk.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..fdf4c6c8 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_imagingtk.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_tkinter_finder.py b/venv/lib/python3.10/site-packages/PIL/_tkinter_finder.py new file mode 100644 index 00000000..beddfb06 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_tkinter_finder.py @@ -0,0 +1,21 @@ +""" Find compiled module linking to Tcl / Tk libraries +""" + +from __future__ import annotations + +import sys +import tkinter + +tk = getattr(tkinter, "_tkinter") + +try: + if hasattr(sys, "pypy_find_executable"): + TKINTER_LIB = tk.tklib_cffi.__file__ + else: + TKINTER_LIB = tk.__file__ +except AttributeError: + # _tkinter may be compiled directly into Python, in which case __file__ is + # not available. load_tkinter_funcs will check the binary first in any case. + TKINTER_LIB = None + +tk_version = str(tkinter.TkVersion) diff --git a/venv/lib/python3.10/site-packages/PIL/_typing.py b/venv/lib/python3.10/site-packages/PIL/_typing.py new file mode 100644 index 00000000..7075e867 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_typing.py @@ -0,0 +1,33 @@ +from __future__ import annotations + +import os +import sys +from typing import Protocol, Sequence, TypeVar, Union + +if sys.version_info >= (3, 10): + from typing import TypeGuard +else: + try: + from typing_extensions import TypeGuard + except ImportError: + from typing import Any + + class TypeGuard: # type: ignore[no-redef] + def __class_getitem__(cls, item: Any) -> type[bool]: + return bool + + +Coords = Union[Sequence[float], Sequence[Sequence[float]]] + + +_T_co = TypeVar("_T_co", covariant=True) + + +class SupportsRead(Protocol[_T_co]): + def read(self, __length: int = ...) -> _T_co: ... + + +StrOrBytesPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"] + + +__all__ = ["TypeGuard", "StrOrBytesPath", "SupportsRead"] diff --git a/venv/lib/python3.10/site-packages/PIL/_util.py b/venv/lib/python3.10/site-packages/PIL/_util.py new file mode 100644 index 00000000..6bc76281 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_util.py @@ -0,0 +1,31 @@ +from __future__ import annotations + +import os +from typing import Any, NoReturn + +from ._typing import StrOrBytesPath, TypeGuard + + +def is_path(f: Any) -> TypeGuard[StrOrBytesPath]: + return isinstance(f, (bytes, str, os.PathLike)) + + +def is_directory(f: Any) -> TypeGuard[StrOrBytesPath]: + """Checks if an object is a string, and that it points to a directory.""" + return is_path(f) and os.path.isdir(f) + + +class DeferredError: + def __init__(self, ex: BaseException): + self.ex = ex + + def __getattr__(self, elt: str) -> NoReturn: + raise self.ex + + @staticmethod + def new(ex: BaseException) -> Any: + """ + Creates an object that raises the wrapped exception ``ex`` when used, + and casts it to :py:obj:`~typing.Any` type. + """ + return DeferredError(ex) diff --git a/venv/lib/python3.10/site-packages/PIL/_version.py b/venv/lib/python3.10/site-packages/PIL/_version.py new file mode 100644 index 00000000..dbed769e --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_version.py @@ -0,0 +1,4 @@ +# Master version for Pillow +from __future__ import annotations + +__version__ = "10.3.0" diff --git a/venv/lib/python3.10/site-packages/PIL/_webp.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/PIL/_webp.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..7e413100 Binary files /dev/null and b/venv/lib/python3.10/site-packages/PIL/_webp.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/PIL/_webp.pyi b/venv/lib/python3.10/site-packages/PIL/_webp.pyi new file mode 100644 index 00000000..e27843e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/_webp.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/venv/lib/python3.10/site-packages/PIL/features.py b/venv/lib/python3.10/site-packages/PIL/features.py new file mode 100644 index 00000000..8a0b1400 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/features.py @@ -0,0 +1,339 @@ +from __future__ import annotations + +import collections +import os +import sys +import warnings + +import PIL + +from . import Image + +modules = { + "pil": ("PIL._imaging", "PILLOW_VERSION"), + "tkinter": ("PIL._tkinter_finder", "tk_version"), + "freetype2": ("PIL._imagingft", "freetype2_version"), + "littlecms2": ("PIL._imagingcms", "littlecms_version"), + "webp": ("PIL._webp", "webpdecoder_version"), +} + + +def check_module(feature): + """ + Checks if a module is available. + + :param feature: The module to check for. + :returns: ``True`` if available, ``False`` otherwise. + :raises ValueError: If the module is not defined in this version of Pillow. + """ + if feature not in modules: + msg = f"Unknown module {feature}" + raise ValueError(msg) + + module, ver = modules[feature] + + try: + __import__(module) + return True + except ModuleNotFoundError: + return False + except ImportError as ex: + warnings.warn(str(ex)) + return False + + +def version_module(feature): + """ + :param feature: The module to check for. + :returns: + The loaded version number as a string, or ``None`` if unknown or not available. + :raises ValueError: If the module is not defined in this version of Pillow. + """ + if not check_module(feature): + return None + + module, ver = modules[feature] + + if ver is None: + return None + + return getattr(__import__(module, fromlist=[ver]), ver) + + +def get_supported_modules(): + """ + :returns: A list of all supported modules. + """ + return [f for f in modules if check_module(f)] + + +codecs = { + "jpg": ("jpeg", "jpeglib"), + "jpg_2000": ("jpeg2k", "jp2klib"), + "zlib": ("zip", "zlib"), + "libtiff": ("libtiff", "libtiff"), +} + + +def check_codec(feature): + """ + Checks if a codec is available. + + :param feature: The codec to check for. + :returns: ``True`` if available, ``False`` otherwise. + :raises ValueError: If the codec is not defined in this version of Pillow. + """ + if feature not in codecs: + msg = f"Unknown codec {feature}" + raise ValueError(msg) + + codec, lib = codecs[feature] + + return codec + "_encoder" in dir(Image.core) + + +def version_codec(feature): + """ + :param feature: The codec to check for. + :returns: + The version number as a string, or ``None`` if not available. + Checked at compile time for ``jpg``, run-time otherwise. + :raises ValueError: If the codec is not defined in this version of Pillow. + """ + if not check_codec(feature): + return None + + codec, lib = codecs[feature] + + version = getattr(Image.core, lib + "_version") + + if feature == "libtiff": + return version.split("\n")[0].split("Version ")[1] + + return version + + +def get_supported_codecs(): + """ + :returns: A list of all supported codecs. + """ + return [f for f in codecs if check_codec(f)] + + +features = { + "webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None), + "webp_mux": ("PIL._webp", "HAVE_WEBPMUX", None), + "transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY", None), + "raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"), + "fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"), + "harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"), + "libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO", "libjpeg_turbo_version"), + "libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT", "imagequant_version"), + "xcb": ("PIL._imaging", "HAVE_XCB", None), +} + + +def check_feature(feature): + """ + Checks if a feature is available. + + :param feature: The feature to check for. + :returns: ``True`` if available, ``False`` if unavailable, ``None`` if unknown. + :raises ValueError: If the feature is not defined in this version of Pillow. + """ + if feature not in features: + msg = f"Unknown feature {feature}" + raise ValueError(msg) + + module, flag, ver = features[feature] + + try: + imported_module = __import__(module, fromlist=["PIL"]) + return getattr(imported_module, flag) + except ModuleNotFoundError: + return None + except ImportError as ex: + warnings.warn(str(ex)) + return None + + +def version_feature(feature): + """ + :param feature: The feature to check for. + :returns: The version number as a string, or ``None`` if not available. + :raises ValueError: If the feature is not defined in this version of Pillow. + """ + if not check_feature(feature): + return None + + module, flag, ver = features[feature] + + if ver is None: + return None + + return getattr(__import__(module, fromlist=[ver]), ver) + + +def get_supported_features(): + """ + :returns: A list of all supported features. + """ + return [f for f in features if check_feature(f)] + + +def check(feature): + """ + :param feature: A module, codec, or feature name. + :returns: + ``True`` if the module, codec, or feature is available, + ``False`` or ``None`` otherwise. + """ + + if feature in modules: + return check_module(feature) + if feature in codecs: + return check_codec(feature) + if feature in features: + return check_feature(feature) + warnings.warn(f"Unknown feature '{feature}'.", stacklevel=2) + return False + + +def version(feature): + """ + :param feature: + The module, codec, or feature to check for. + :returns: + The version number as a string, or ``None`` if unknown or not available. + """ + if feature in modules: + return version_module(feature) + if feature in codecs: + return version_codec(feature) + if feature in features: + return version_feature(feature) + return None + + +def get_supported(): + """ + :returns: A list of all supported modules, features, and codecs. + """ + + ret = get_supported_modules() + ret.extend(get_supported_features()) + ret.extend(get_supported_codecs()) + return ret + + +def pilinfo(out=None, supported_formats=True): + """ + Prints information about this installation of Pillow. + This function can be called with ``python3 -m PIL``. + It can also be called with ``python3 -m PIL.report`` or ``python3 -m PIL --report`` + to have "supported_formats" set to ``False``, omitting the list of all supported + image file formats. + + :param out: + The output stream to print to. Defaults to ``sys.stdout`` if ``None``. + :param supported_formats: + If ``True``, a list of all supported image file formats will be printed. + """ + + if out is None: + out = sys.stdout + + Image.init() + + print("-" * 68, file=out) + print(f"Pillow {PIL.__version__}", file=out) + py_version = sys.version.splitlines() + print(f"Python {py_version[0].strip()}", file=out) + for py_version in py_version[1:]: + print(f" {py_version.strip()}", file=out) + print("-" * 68, file=out) + print(f"Python executable is {sys.executable or 'unknown'}", file=out) + if sys.prefix != sys.base_prefix: + print(f"Environment Python files loaded from {sys.prefix}", file=out) + print(f"System Python files loaded from {sys.base_prefix}", file=out) + print("-" * 68, file=out) + print( + f"Python Pillow modules loaded from {os.path.dirname(Image.__file__)}", + file=out, + ) + print( + f"Binary Pillow modules loaded from {os.path.dirname(Image.core.__file__)}", + file=out, + ) + print("-" * 68, file=out) + + for name, feature in [ + ("pil", "PIL CORE"), + ("tkinter", "TKINTER"), + ("freetype2", "FREETYPE2"), + ("littlecms2", "LITTLECMS2"), + ("webp", "WEBP"), + ("transp_webp", "WEBP Transparency"), + ("webp_mux", "WEBPMUX"), + ("webp_anim", "WEBP Animation"), + ("jpg", "JPEG"), + ("jpg_2000", "OPENJPEG (JPEG2000)"), + ("zlib", "ZLIB (PNG/ZIP)"), + ("libtiff", "LIBTIFF"), + ("raqm", "RAQM (Bidirectional Text)"), + ("libimagequant", "LIBIMAGEQUANT (Quantization method)"), + ("xcb", "XCB (X protocol)"), + ]: + if check(name): + if name == "jpg" and check_feature("libjpeg_turbo"): + v = "libjpeg-turbo " + version_feature("libjpeg_turbo") + else: + v = version(name) + if v is not None: + version_static = name in ("pil", "jpg") + if name == "littlecms2": + # this check is also in src/_imagingcms.c:setup_module() + version_static = tuple(int(x) for x in v.split(".")) < (2, 7) + t = "compiled for" if version_static else "loaded" + if name == "raqm": + for f in ("fribidi", "harfbuzz"): + v2 = version_feature(f) + if v2 is not None: + v += f", {f} {v2}" + print("---", feature, "support ok,", t, v, file=out) + else: + print("---", feature, "support ok", file=out) + else: + print("***", feature, "support not installed", file=out) + print("-" * 68, file=out) + + if supported_formats: + extensions = collections.defaultdict(list) + for ext, i in Image.EXTENSION.items(): + extensions[i].append(ext) + + for i in sorted(Image.ID): + line = f"{i}" + if i in Image.MIME: + line = f"{line} {Image.MIME[i]}" + print(line, file=out) + + if i in extensions: + print( + "Extensions: {}".format(", ".join(sorted(extensions[i]))), file=out + ) + + features = [] + if i in Image.OPEN: + features.append("open") + if i in Image.SAVE: + features.append("save") + if i in Image.SAVE_ALL: + features.append("save_all") + if i in Image.DECODERS: + features.append("decode") + if i in Image.ENCODERS: + features.append("encode") + + print("Features: {}".format(", ".join(features)), file=out) + print("-" * 68, file=out) diff --git a/venv/lib/python3.10/site-packages/PIL/py.typed b/venv/lib/python3.10/site-packages/PIL/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/PIL/report.py b/venv/lib/python3.10/site-packages/PIL/report.py new file mode 100644 index 00000000..d2815e84 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PIL/report.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from .features import pilinfo + +pilinfo(supported_formats=False) diff --git a/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py b/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py new file mode 100644 index 00000000..f7074162 --- /dev/null +++ b/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py @@ -0,0 +1,132 @@ +import sys +import os +import re +import importlib +import warnings + + +is_pypy = '__pypy__' in sys.builtin_module_names + + +warnings.filterwarnings('ignore', + r'.+ distutils\b.+ deprecated', + DeprecationWarning) + + +def warn_distutils_present(): + if 'distutils' not in sys.modules: + return + if is_pypy and sys.version_info < (3, 7): + # PyPy for 3.6 unconditionally imports distutils, so bypass the warning + # https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250 + return + warnings.warn( + "Distutils was imported before Setuptools, but importing Setuptools " + "also replaces the `distutils` module in `sys.modules`. This may lead " + "to undesirable behaviors or errors. To avoid these issues, avoid " + "using distutils directly, ensure that setuptools is installed in the " + "traditional way (e.g. not an editable install), and/or make sure " + "that setuptools is always imported before distutils.") + + +def clear_distutils(): + if 'distutils' not in sys.modules: + return + warnings.warn("Setuptools is replacing distutils.") + mods = [name for name in sys.modules if re.match(r'distutils\b', name)] + for name in mods: + del sys.modules[name] + + +def enabled(): + """ + Allow selection of distutils by environment variable. + """ + which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib') + return which == 'local' + + +def ensure_local_distutils(): + clear_distutils() + + # With the DistutilsMetaFinder in place, + # perform an import to cause distutils to be + # loaded from setuptools._distutils. Ref #2906. + add_shim() + importlib.import_module('distutils') + remove_shim() + + # check that submodules load as expected + core = importlib.import_module('distutils.core') + assert '_distutils' in core.__file__, core.__file__ + + +def do_override(): + """ + Ensure that the local copy of distutils is preferred over stdlib. + + See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401 + for more motivation. + """ + if enabled(): + warn_distutils_present() + ensure_local_distutils() + + +class DistutilsMetaFinder: + def find_spec(self, fullname, path, target=None): + if path is not None: + return + + method_name = 'spec_for_{fullname}'.format(**locals()) + method = getattr(self, method_name, lambda: None) + return method() + + def spec_for_distutils(self): + import importlib.abc + import importlib.util + + class DistutilsLoader(importlib.abc.Loader): + + def create_module(self, spec): + return importlib.import_module('setuptools._distutils') + + def exec_module(self, module): + pass + + return importlib.util.spec_from_loader('distutils', DistutilsLoader()) + + def spec_for_pip(self): + """ + Ensure stdlib distutils when running under pip. + See pypa/pip#8761 for rationale. + """ + if self.pip_imported_during_build(): + return + clear_distutils() + self.spec_for_distutils = lambda: None + + @staticmethod + def pip_imported_during_build(): + """ + Detect if pip is being imported in a build script. Ref #2355. + """ + import traceback + return any( + frame.f_globals['__file__'].endswith('setup.py') + for frame, line in traceback.walk_stack(None) + ) + + +DISTUTILS_FINDER = DistutilsMetaFinder() + + +def add_shim(): + sys.meta_path.insert(0, DISTUTILS_FINDER) + + +def remove_shim(): + try: + sys.meta_path.remove(DISTUTILS_FINDER) + except ValueError: + pass diff --git a/venv/lib/python3.10/site-packages/_distutils_hack/override.py b/venv/lib/python3.10/site-packages/_distutils_hack/override.py new file mode 100644 index 00000000..2cc433a4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/_distutils_hack/override.py @@ -0,0 +1 @@ +__import__('_distutils_hack').do_override() diff --git a/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/INSTALLER b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/INSTALLER new file mode 100644 index 00000000..a1b589e3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/LICENSE b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/LICENSE new file mode 100644 index 00000000..96837bd9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2021-2024, ContourPy Developers. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/METADATA b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/METADATA new file mode 100644 index 00000000..7078d824 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/METADATA @@ -0,0 +1,91 @@ +Metadata-Version: 2.1 +Name: contourpy +Version: 1.2.1 +Summary: Python library for calculating contours of 2D quadrilateral grids +Author-Email: Ian Thomas +License: BSD 3-Clause License + + Copyright (c) 2021-2024, ContourPy Developers. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: BSD License +Classifier: Programming Language :: C++ +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 +Classifier: Topic :: Scientific/Engineering :: Information Analysis +Classifier: Topic :: Scientific/Engineering :: Mathematics +Classifier: Topic :: Scientific/Engineering :: Visualization +Project-URL: Homepage, https://github.com/contourpy/contourpy +Project-URL: Changelog, https://contourpy.readthedocs.io/en/latest/changelog.html +Project-URL: Documentation, https://contourpy.readthedocs.io +Project-URL: Repository, https://github.com/contourpy/contourpy +Requires-Python: >=3.9 +Requires-Dist: numpy>=1.20 +Requires-Dist: furo; extra == "docs" +Requires-Dist: sphinx>=7.2; extra == "docs" +Requires-Dist: sphinx-copybutton; extra == "docs" +Requires-Dist: bokeh; extra == "bokeh" +Requires-Dist: selenium; extra == "bokeh" +Requires-Dist: contourpy[bokeh,docs]; extra == "mypy" +Requires-Dist: docutils-stubs; extra == "mypy" +Requires-Dist: mypy==1.8.0; extra == "mypy" +Requires-Dist: types-Pillow; extra == "mypy" +Requires-Dist: contourpy[test-no-images]; extra == "test" +Requires-Dist: matplotlib; extra == "test" +Requires-Dist: Pillow; extra == "test" +Requires-Dist: pytest; extra == "test-no-images" +Requires-Dist: pytest-cov; extra == "test-no-images" +Requires-Dist: pytest-xdist; extra == "test-no-images" +Requires-Dist: wurlitzer; extra == "test-no-images" +Provides-Extra: docs +Provides-Extra: bokeh +Provides-Extra: mypy +Provides-Extra: test +Provides-Extra: test-no-images +Description-Content-Type: text/markdown + +ContourPy + +ContourPy is a Python library for calculating contours of 2D quadrilateral grids. It is written in C++11 and wrapped using pybind11. + +It contains the 2005 and 2014 algorithms used in Matplotlib as well as a newer algorithm that includes more features and is available in both serial and multithreaded versions. It provides an easy way for Python libraries to use contouring algorithms without having to include Matplotlib as a dependency. + + * **Documentation**: https://contourpy.readthedocs.io + * **Source code**: https://github.com/contourpy/contourpy + +| | | +| --- | --- | +| Latest release | [![PyPI version](https://img.shields.io/pypi/v/contourpy.svg?label=pypi&color=fdae61)](https://pypi.python.org/pypi/contourpy) [![conda-forge version](https://img.shields.io/conda/v/conda-forge/contourpy.svg?label=conda-forge&color=a6d96a)](https://anaconda.org/conda-forge/contourpy) [![anaconda version](https://img.shields.io/conda/v/anaconda/contourpy.svg?label=anaconda&color=1a9641)](https://anaconda.org/anaconda/contourpy) | +| Downloads | [![PyPi downloads](https://img.shields.io/pypi/dm/contourpy?label=pypi&style=flat&color=fdae61)](https://pepy.tech/project/contourpy) [![conda-forge downloads](https://raw.githubusercontent.com/contourpy/condabadges/main/cache/contourpy_conda-forge_monthly.svg)](https://anaconda.org/conda-forge/contourpy) [![anaconda downloads](https://raw.githubusercontent.com/contourpy/condabadges/main/cache/contourpy_anaconda_monthly.svg)](https://anaconda.org/anaconda/contourpy) | +| Python version | [![Platforms](https://img.shields.io/pypi/pyversions/contourpy?color=fdae61)](https://pypi.org/project/contourpy/) | +| Coverage | [![Codecov](https://img.shields.io/codecov/c/gh/contourpy/contourpy?color=fdae61&label=codecov)](https://app.codecov.io/gh/contourpy/contourpy) | diff --git a/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/RECORD b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/RECORD new file mode 100644 index 00000000..c8a2237f --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/RECORD @@ -0,0 +1,42 @@ +contourpy-1.2.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +contourpy-1.2.1.dist-info/LICENSE,sha256=x9ChU7_6oQQERGPrxjN5PUUXIu_TE4tf_SUntA8VBaI,1534 +contourpy-1.2.1.dist-info/METADATA,sha256=2P2_nKjGaPLSnVIu_O4EdfAkPhic9smE2DwyQuB7emE,5802 +contourpy-1.2.1.dist-info/RECORD,, +contourpy-1.2.1.dist-info/WHEEL,sha256=sZM_NeUMz2G4fDenMf11eikcCxcLaQWiYRmjwQBavQs,137 +contourpy/__init__.py,sha256=sAgP3LY7-PTMH96gQeA65OZrP1ZgNo9Bcw3h0BnpOI0,11330 +contourpy/__pycache__/__init__.cpython-310.pyc,, +contourpy/__pycache__/_version.cpython-310.pyc,, +contourpy/__pycache__/array.cpython-310.pyc,, +contourpy/__pycache__/chunk.cpython-310.pyc,, +contourpy/__pycache__/convert.cpython-310.pyc,, +contourpy/__pycache__/dechunk.cpython-310.pyc,, +contourpy/__pycache__/enum_util.cpython-310.pyc,, +contourpy/__pycache__/typecheck.cpython-310.pyc,, +contourpy/__pycache__/types.cpython-310.pyc,, +contourpy/_contourpy.cpython-310-x86_64-linux-gnu.so,sha256=dJnNEGFdSZtM-CBDEPtgok0HgkpeyaXbgywdSGqABtM,839768 +contourpy/_contourpy.pyi,sha256=zQ4pIKuHmBBPJgLZdctJJH99BYSlGfKRc8A-j4HeNoM,6970 +contourpy/_version.py,sha256=Mlm4Gvmb_6yQxwUbv2Ksc-BJFXLPg9H1Vt2iV7wXrA4,22 +contourpy/array.py,sha256=fNp-o8odWzqANFoT2J5ueMW7q7y1vSJkjzkEUYN4B-Q,9012 +contourpy/chunk.py,sha256=8njDQqlpuD22RjaaCyA75FXQsSQDY5hZGJSrxFpvGGU,3279 +contourpy/convert.py,sha256=AuHThR7s-VJIvUBydcwYiRs2WrlDvxY_5eQnHSlI7v8,23398 +contourpy/dechunk.py,sha256=1J6QWQCkwYl87fhmQfXncPRvMhMauuYDmlVxZBoG2pg,5498 +contourpy/enum_util.py,sha256=o8MItJRs08oqzwPP3IwC75BBAY9Qq95saIzjkXBXwqA,1519 +contourpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +contourpy/typecheck.py,sha256=t1nvvCuKMYva1Zx4fc30EpdKFcO0Enz3n_UFfXBsq9o,10747 +contourpy/types.py,sha256=2K4T5tJpMIjYrkkg1Lqh3C2ZKlnOhnMtYmtwz92l_y8,247 +contourpy/util/__init__.py,sha256=eVhJ_crOHL7nkG4Kb0dOo7NL4WHMy_Px665aAN_3d-8,118 +contourpy/util/__pycache__/__init__.cpython-310.pyc,, +contourpy/util/__pycache__/_build_config.cpython-310.pyc,, +contourpy/util/__pycache__/bokeh_renderer.cpython-310.pyc,, +contourpy/util/__pycache__/bokeh_util.cpython-310.pyc,, +contourpy/util/__pycache__/data.cpython-310.pyc,, +contourpy/util/__pycache__/mpl_renderer.cpython-310.pyc,, +contourpy/util/__pycache__/mpl_util.cpython-310.pyc,, +contourpy/util/__pycache__/renderer.cpython-310.pyc,, +contourpy/util/_build_config.py,sha256=b0ZmaX2i3zVZlB0UmFPBwZZYeVFDn86diriF2k5t8Yk,1848 +contourpy/util/bokeh_renderer.py,sha256=pGPyK1tN-lCR4S8ETY4KdTRFs_Qdm4Wy9H8wd8ZVqtY,13771 +contourpy/util/bokeh_util.py,sha256=wc-S3ewBUYWyIkEv9jkhFySIergjLQl4Z0UEVnE0HhA,2804 +contourpy/util/data.py,sha256=cPSAk3pUlg1N4uTp4chzXZLjR5uXnFa2h3adXn-_DJg,2566 +contourpy/util/mpl_renderer.py,sha256=UONy5efwxAlr0RSS3ecpcmUCexAXrbpnSXhXC6ynUdc,20061 +contourpy/util/mpl_util.py,sha256=q2OO2gGSO7bYgpNj3DCJtRUC8BjuBSrQClrZ92trT0U,3438 +contourpy/util/renderer.py,sha256=scRiAvbLo6jrDxT3AJ9cO-5PTtpL5BXRfGNt1Vxv7QI,2367 diff --git a/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/WHEEL b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/WHEEL new file mode 100644 index 00000000..4e4c38ae --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy-1.2.1.dist-info/WHEEL @@ -0,0 +1,6 @@ +Wheel-Version: 1.0 +Generator: meson +Root-Is-Purelib: false +Tag: cp310-cp310-manylinux_2_17_x86_64 +Tag: cp310-cp310-manylinux2014_x86_64 + diff --git a/venv/lib/python3.10/site-packages/contourpy/__init__.py b/venv/lib/python3.10/site-packages/contourpy/__init__.py new file mode 100644 index 00000000..aa6baf93 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/__init__.py @@ -0,0 +1,267 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + +import numpy as np + +from contourpy._contourpy import ( + ContourGenerator, + FillType, + LineType, + Mpl2005ContourGenerator, + Mpl2014ContourGenerator, + SerialContourGenerator, + ThreadedContourGenerator, + ZInterp, + max_threads, +) +from contourpy._version import __version__ +from contourpy.chunk import calc_chunk_sizes +from contourpy.convert import convert_filled, convert_lines +from contourpy.dechunk import dechunk_filled, dechunk_lines +from contourpy.enum_util import as_fill_type, as_line_type, as_z_interp + +if TYPE_CHECKING: + from typing import Any + + from numpy.typing import ArrayLike + + from ._contourpy import CoordinateArray, MaskArray + +__all__ = [ + "__version__", + "contour_generator", + "convert_filled", + "convert_lines", + "dechunk_filled", + "dechunk_lines", + "max_threads", + "FillType", + "LineType", + "ContourGenerator", + "Mpl2005ContourGenerator", + "Mpl2014ContourGenerator", + "SerialContourGenerator", + "ThreadedContourGenerator", + "ZInterp", +] + + +# Simple mapping of algorithm name to class name. +_class_lookup: dict[str, type[ContourGenerator]] = { + "mpl2005": Mpl2005ContourGenerator, + "mpl2014": Mpl2014ContourGenerator, + "serial": SerialContourGenerator, + "threaded": ThreadedContourGenerator, +} + + +def _remove_z_mask( + z: ArrayLike | np.ma.MaskedArray[Any, Any] | None, +) -> tuple[CoordinateArray, MaskArray | None]: + # Preserve mask if present. + z_array = np.ma.asarray(z, dtype=np.float64) # type: ignore[no-untyped-call] + z_masked = np.ma.masked_invalid(z_array, copy=False) # type: ignore[no-untyped-call] + + if np.ma.is_masked(z_masked): # type: ignore[no-untyped-call] + mask = np.ma.getmask(z_masked) # type: ignore[no-untyped-call] + else: + mask = None + + return np.ma.getdata(z_masked), mask # type: ignore[no-untyped-call] + + +def contour_generator( + x: ArrayLike | None = None, + y: ArrayLike | None = None, + z: ArrayLike | np.ma.MaskedArray[Any, Any] | None = None, + *, + name: str = "serial", + corner_mask: bool | None = None, + line_type: LineType | str | None = None, + fill_type: FillType | str | None = None, + chunk_size: int | tuple[int, int] | None = None, + chunk_count: int | tuple[int, int] | None = None, + total_chunk_count: int | None = None, + quad_as_tri: bool = False, + z_interp: ZInterp | str | None = ZInterp.Linear, + thread_count: int = 0, +) -> ContourGenerator: + """Create and return a :class:`~contourpy._contourpy.ContourGenerator` object. + + The class and properties of the returned :class:`~contourpy._contourpy.ContourGenerator` are + determined by the function arguments, with sensible defaults. + + Args: + x (array-like of shape (ny, nx) or (nx,), optional): The x-coordinates of the ``z`` values. + May be 2D with the same shape as ``z.shape``, or 1D with length ``nx = z.shape[1]``. + If not specified are assumed to be ``np.arange(nx)``. Must be ordered monotonically. + y (array-like of shape (ny, nx) or (ny,), optional): The y-coordinates of the ``z`` values. + May be 2D with the same shape as ``z.shape``, or 1D with length ``ny = z.shape[0]``. + If not specified are assumed to be ``np.arange(ny)``. Must be ordered monotonically. + z (array-like of shape (ny, nx), may be a masked array): The 2D gridded values to calculate + the contours of. May be a masked array, and any invalid values (``np.inf`` or + ``np.nan``) will also be masked out. + name (str): Algorithm name, one of ``"serial"``, ``"threaded"``, ``"mpl2005"`` or + ``"mpl2014"``, default ``"serial"``. + corner_mask (bool, optional): Enable/disable corner masking, which only has an effect if + ``z`` is a masked array. If ``False``, any quad touching a masked point is masked out. + If ``True``, only the triangular corners of quads nearest these points are always masked + out, other triangular corners comprising three unmasked points are contoured as usual. + If not specified, uses the default provided by the algorithm ``name``. + line_type (LineType or str, optional): The format of contour line data returned from calls + to :meth:`~contourpy.ContourGenerator.lines`, specified either as a + :class:`~contourpy.LineType` or its string equivalent such as ``"SeparateCode"``. + If not specified, uses the default provided by the algorithm ``name``. + fill_type (FillType or str, optional): The format of filled contour data returned from calls + to :meth:`~contourpy.ContourGenerator.filled`, specified either as a + :class:`~contourpy.FillType` or its string equivalent such as ``"OuterOffset"``. + If not specified, uses the default provided by the algorithm ``name``. + chunk_size (int or tuple(int, int), optional): Chunk size in (y, x) directions, or the same + size in both directions if only one value is specified. + chunk_count (int or tuple(int, int), optional): Chunk count in (y, x) directions, or the + same count in both directions if only one value is specified. + total_chunk_count (int, optional): Total number of chunks. + quad_as_tri (bool): Enable/disable treating quads as 4 triangles, default ``False``. + If ``False``, a contour line within a quad is a straight line between points on two of + its edges. If ``True``, each full quad is divided into 4 triangles using a virtual point + at the centre (mean x, y of the corner points) and a contour line is piecewise linear + within those triangles. Corner-masked triangles are not affected by this setting, only + full unmasked quads. + z_interp (ZInterp or str, optional): How to interpolate ``z`` values when determining where + contour lines intersect the edges of quads and the ``z`` values of the central points of + quads, specified either as a :class:`~contourpy.ZInterp` or its string equivalent such + as ``"Log"``. Default is ``ZInterp.Linear``. + thread_count (int): Number of threads to use for contour calculation, default 0. Threads can + only be used with an algorithm ``name`` that supports threads (currently only + ``name="threaded"``) and there must be at least the same number of chunks as threads. + If ``thread_count=0`` and ``name="threaded"`` then it uses the maximum number of threads + as determined by the C++11 call ``std::thread::hardware_concurrency()``. If ``name`` is + something other than ``"threaded"`` then the ``thread_count`` will be set to ``1``. + + Return: + :class:`~contourpy._contourpy.ContourGenerator`. + + Note: + A maximum of one of ``chunk_size``, ``chunk_count`` and ``total_chunk_count`` may be + specified. + + Warning: + The ``name="mpl2005"`` algorithm does not implement chunking for contour lines. + """ + x = np.asarray(x, dtype=np.float64) + y = np.asarray(y, dtype=np.float64) + z, mask = _remove_z_mask(z) + + # Check arguments: z. + if z.ndim != 2: + raise TypeError(f"Input z must be 2D, not {z.ndim}D") + + if z.shape[0] < 2 or z.shape[1] < 2: + raise TypeError(f"Input z must be at least a (2, 2) shaped array, but has shape {z.shape}") + + ny, nx = z.shape + + # Check arguments: x and y. + if x.ndim != y.ndim: + raise TypeError(f"Number of dimensions of x ({x.ndim}) and y ({y.ndim}) do not match") + + if x.ndim == 0: + x = np.arange(nx, dtype=np.float64) + y = np.arange(ny, dtype=np.float64) + x, y = np.meshgrid(x, y) + elif x.ndim == 1: + if len(x) != nx: + raise TypeError(f"Length of x ({len(x)}) must match number of columns in z ({nx})") + if len(y) != ny: + raise TypeError(f"Length of y ({len(y)}) must match number of rows in z ({ny})") + x, y = np.meshgrid(x, y) + elif x.ndim == 2: + if x.shape != z.shape: + raise TypeError(f"Shapes of x {x.shape} and z {z.shape} do not match") + if y.shape != z.shape: + raise TypeError(f"Shapes of y {y.shape} and z {z.shape} do not match") + else: + raise TypeError(f"Inputs x and y must be None, 1D or 2D, not {x.ndim}D") + + # Check mask shape just in case. + if mask is not None and mask.shape != z.shape: + raise ValueError("If mask is set it must be a 2D array with the same shape as z") + + # Check arguments: name. + if name not in _class_lookup: + raise ValueError(f"Unrecognised contour generator name: {name}") + + # Check arguments: chunk_size, chunk_count and total_chunk_count. + y_chunk_size, x_chunk_size = calc_chunk_sizes( + chunk_size, chunk_count, total_chunk_count, ny, nx) + + cls = _class_lookup[name] + + # Check arguments: corner_mask. + if corner_mask is None: + # Set it to default, which is True if the algorithm supports it. + corner_mask = cls.supports_corner_mask() + elif corner_mask and not cls.supports_corner_mask(): + raise ValueError(f"{name} contour generator does not support corner_mask=True") + + # Check arguments: line_type. + if line_type is None: + line_type = cls.default_line_type + else: + line_type = as_line_type(line_type) + + if not cls.supports_line_type(line_type): + raise ValueError(f"{name} contour generator does not support line_type {line_type}") + + # Check arguments: fill_type. + if fill_type is None: + fill_type = cls.default_fill_type + else: + fill_type = as_fill_type(fill_type) + + if not cls.supports_fill_type(fill_type): + raise ValueError(f"{name} contour generator does not support fill_type {fill_type}") + + # Check arguments: quad_as_tri. + if quad_as_tri and not cls.supports_quad_as_tri(): + raise ValueError(f"{name} contour generator does not support quad_as_tri=True") + + # Check arguments: z_interp. + if z_interp is None: + z_interp = ZInterp.Linear + else: + z_interp = as_z_interp(z_interp) + + if z_interp != ZInterp.Linear and not cls.supports_z_interp(): + raise ValueError(f"{name} contour generator does not support z_interp {z_interp}") + + # Check arguments: thread_count. + if thread_count not in (0, 1) and not cls.supports_threads(): + raise ValueError(f"{name} contour generator does not support thread_count {thread_count}") + + # Prepare args and kwargs for contour generator constructor. + args = [x, y, z, mask] + kwargs: dict[str, int | bool | LineType | FillType | ZInterp] = { + "x_chunk_size": x_chunk_size, + "y_chunk_size": y_chunk_size, + } + + if name not in ("mpl2005", "mpl2014"): + kwargs["line_type"] = line_type + kwargs["fill_type"] = fill_type + + if cls.supports_corner_mask(): + kwargs["corner_mask"] = corner_mask + + if cls.supports_quad_as_tri(): + kwargs["quad_as_tri"] = quad_as_tri + + if cls.supports_z_interp(): + kwargs["z_interp"] = z_interp + + if cls.supports_threads(): + kwargs["thread_count"] = thread_count + + # Create contour generator. + return cls(*args, **kwargs) diff --git a/venv/lib/python3.10/site-packages/contourpy/_contourpy.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/contourpy/_contourpy.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..6cd697e1 Binary files /dev/null and b/venv/lib/python3.10/site-packages/contourpy/_contourpy.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/contourpy/_contourpy.pyi b/venv/lib/python3.10/site-packages/contourpy/_contourpy.pyi new file mode 100644 index 00000000..077f5f9b --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/_contourpy.pyi @@ -0,0 +1,197 @@ +from typing import ClassVar, NoReturn + +import numpy as np +import numpy.typing as npt +from typing_extensions import TypeAlias + +import contourpy._contourpy as cpy + +# Input numpy array types, the same as in common.h +CoordinateArray: TypeAlias = npt.NDArray[np.float64] +MaskArray: TypeAlias = npt.NDArray[np.bool_] + +# Output numpy array types, the same as in common.h +PointArray: TypeAlias = npt.NDArray[np.float64] +CodeArray: TypeAlias = npt.NDArray[np.uint8] +OffsetArray: TypeAlias = npt.NDArray[np.uint32] + +# Types returned from filled() +FillReturn_OuterCode: TypeAlias = tuple[list[PointArray], list[CodeArray]] +FillReturn_OuterOffset: TypeAlias = tuple[list[PointArray], list[OffsetArray]] +FillReturn_ChunkCombinedCode: TypeAlias = tuple[list[PointArray | None], list[CodeArray | None]] +FillReturn_ChunkCombinedOffset: TypeAlias = tuple[list[PointArray | None], list[OffsetArray | None]] +FillReturn_ChunkCombinedCodeOffset: TypeAlias = tuple[list[PointArray | None], list[CodeArray | None], list[OffsetArray | None]] +FillReturn_ChunkCombinedOffsetOffset: TypeAlias = tuple[list[PointArray | None], list[OffsetArray | None], list[OffsetArray | None]] +FillReturn_Chunk: TypeAlias = FillReturn_ChunkCombinedCode | FillReturn_ChunkCombinedOffset | FillReturn_ChunkCombinedCodeOffset | FillReturn_ChunkCombinedOffsetOffset +FillReturn: TypeAlias = FillReturn_OuterCode | FillReturn_OuterOffset | FillReturn_Chunk + +# Types returned from lines() +LineReturn_Separate: TypeAlias = list[PointArray] +LineReturn_SeparateCode: TypeAlias = tuple[list[PointArray], list[CodeArray]] +LineReturn_ChunkCombinedCode: TypeAlias = tuple[list[PointArray | None], list[CodeArray | None]] +LineReturn_ChunkCombinedOffset: TypeAlias = tuple[list[PointArray | None], list[OffsetArray | None]] +LineReturn_ChunkCombinedNan: TypeAlias = tuple[list[PointArray | None]] +LineReturn_Chunk: TypeAlias = LineReturn_ChunkCombinedCode | LineReturn_ChunkCombinedOffset | LineReturn_ChunkCombinedNan +LineReturn: TypeAlias = LineReturn_Separate | LineReturn_SeparateCode | LineReturn_Chunk + + +NDEBUG: int +__version__: str + +class FillType: + ChunkCombinedCode: ClassVar[cpy.FillType] + ChunkCombinedCodeOffset: ClassVar[cpy.FillType] + ChunkCombinedOffset: ClassVar[cpy.FillType] + ChunkCombinedOffsetOffset: ClassVar[cpy.FillType] + OuterCode: ClassVar[cpy.FillType] + OuterOffset: ClassVar[cpy.FillType] + __members__: ClassVar[dict[str, cpy.FillType]] + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> NoReturn: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class LineType: + ChunkCombinedCode: ClassVar[cpy.LineType] + ChunkCombinedNan: ClassVar[cpy.LineType] + ChunkCombinedOffset: ClassVar[cpy.LineType] + Separate: ClassVar[cpy.LineType] + SeparateCode: ClassVar[cpy.LineType] + __members__: ClassVar[dict[str, cpy.LineType]] + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> NoReturn: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class ZInterp: + Linear: ClassVar[cpy.ZInterp] + Log: ClassVar[cpy.ZInterp] + __members__: ClassVar[dict[str, cpy.ZInterp]] + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> NoReturn: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +def max_threads() -> int: ... + +class ContourGenerator: + def create_contour(self, level: float) -> LineReturn: ... + def create_filled_contour(self, lower_level: float, upper_level: float) -> FillReturn: ... + def filled(self, lower_level: float, upper_level: float) -> FillReturn: ... + def lines(self, level: float) -> LineReturn: ... + @staticmethod + def supports_corner_mask() -> bool: ... + @staticmethod + def supports_fill_type(fill_type: FillType) -> bool: ... + @staticmethod + def supports_line_type(line_type: LineType) -> bool: ... + @staticmethod + def supports_quad_as_tri() -> bool: ... + @staticmethod + def supports_threads() -> bool: ... + @staticmethod + def supports_z_interp() -> bool: ... + @property + def chunk_count(self) -> tuple[int, int]: ... + @property + def chunk_size(self) -> tuple[int, int]: ... + @property + def corner_mask(self) -> bool: ... + @property + def fill_type(self) -> FillType: ... + @property + def line_type(self) -> LineType: ... + @property + def quad_as_tri(self) -> bool: ... + @property + def thread_count(self) -> int: ... + @property + def z_interp(self) -> ZInterp: ... + default_fill_type: cpy.FillType + default_line_type: cpy.LineType + +class Mpl2005ContourGenerator(ContourGenerator): + def __init__( + self, + x: CoordinateArray, + y: CoordinateArray, + z: CoordinateArray, + mask: MaskArray, + *, + x_chunk_size: int = 0, + y_chunk_size: int = 0, + ) -> None: ... + +class Mpl2014ContourGenerator(ContourGenerator): + def __init__( + self, + x: CoordinateArray, + y: CoordinateArray, + z: CoordinateArray, + mask: MaskArray, + *, + corner_mask: bool, + x_chunk_size: int = 0, + y_chunk_size: int = 0, + ) -> None: ... + +class SerialContourGenerator(ContourGenerator): + def __init__( + self, + x: CoordinateArray, + y: CoordinateArray, + z: CoordinateArray, + mask: MaskArray, + *, + corner_mask: bool, + line_type: LineType, + fill_type: FillType, + quad_as_tri: bool, + z_interp: ZInterp, + x_chunk_size: int = 0, + y_chunk_size: int = 0, + ) -> None: ... + def _write_cache(self) -> NoReturn: ... + +class ThreadedContourGenerator(ContourGenerator): + def __init__( + self, + x: CoordinateArray, + y: CoordinateArray, + z: CoordinateArray, + mask: MaskArray, + *, + corner_mask: bool, + line_type: LineType, + fill_type: FillType, + quad_as_tri: bool, + z_interp: ZInterp, + x_chunk_size: int = 0, + y_chunk_size: int = 0, + thread_count: int = 0, + ) -> None: ... + def _write_cache(self) -> None: ... diff --git a/venv/lib/python3.10/site-packages/contourpy/_version.py b/venv/lib/python3.10/site-packages/contourpy/_version.py new file mode 100644 index 00000000..a955fdae --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/_version.py @@ -0,0 +1 @@ +__version__ = "1.2.1" diff --git a/venv/lib/python3.10/site-packages/contourpy/array.py b/venv/lib/python3.10/site-packages/contourpy/array.py new file mode 100644 index 00000000..fbc53d6c --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/array.py @@ -0,0 +1,261 @@ +from __future__ import annotations + +from itertools import chain +from typing import TYPE_CHECKING + +import numpy as np + +from contourpy.typecheck import check_code_array, check_offset_array, check_point_array +from contourpy.types import CLOSEPOLY, LINETO, MOVETO, code_dtype, offset_dtype, point_dtype + +if TYPE_CHECKING: + import contourpy._contourpy as cpy + + +def codes_from_offsets(offsets: cpy.OffsetArray) -> cpy.CodeArray: + """Determine codes from offsets, assuming they all correspond to closed polygons. + """ + check_offset_array(offsets) + + n = offsets[-1] + codes = np.full(n, LINETO, dtype=code_dtype) + codes[offsets[:-1]] = MOVETO + codes[offsets[1:] - 1] = CLOSEPOLY + return codes + + +def codes_from_offsets_and_points( + offsets: cpy.OffsetArray, + points: cpy.PointArray, +) -> cpy.CodeArray: + """Determine codes from offsets and points, using the equality of the start and end points of + each line to determine if lines are closed or not. + """ + check_offset_array(offsets) + check_point_array(points) + + codes = np.full(len(points), LINETO, dtype=code_dtype) + codes[offsets[:-1]] = MOVETO + + end_offsets = offsets[1:] - 1 + closed = np.all(points[offsets[:-1]] == points[end_offsets], axis=1) + codes[end_offsets[closed]] = CLOSEPOLY + + return codes + + +def codes_from_points(points: cpy.PointArray) -> cpy.CodeArray: + """Determine codes for a single line, using the equality of the start and end points to + determine if the line is closed or not. + """ + check_point_array(points) + + n = len(points) + codes = np.full(n, LINETO, dtype=code_dtype) + codes[0] = MOVETO + if np.all(points[0] == points[-1]): + codes[-1] = CLOSEPOLY + return codes + + +def concat_codes(list_of_codes: list[cpy.CodeArray]) -> cpy.CodeArray: + """Concatenate a list of codes arrays into a single code array. + """ + if not list_of_codes: + raise ValueError("Empty list passed to concat_codes") + + return np.concatenate(list_of_codes, dtype=code_dtype) + + +def concat_codes_or_none(list_of_codes_or_none: list[cpy.CodeArray | None]) -> cpy.CodeArray | None: + """Concatenate a list of codes arrays or None into a single code array or None. + """ + list_of_codes = [codes for codes in list_of_codes_or_none if codes is not None] + if list_of_codes: + return concat_codes(list_of_codes) + else: + return None + + +def concat_offsets(list_of_offsets: list[cpy.OffsetArray]) -> cpy.OffsetArray: + """Concatenate a list of offsets arrays into a single offset array. + """ + if not list_of_offsets: + raise ValueError("Empty list passed to concat_offsets") + + n = len(list_of_offsets) + cumulative = np.cumsum([offsets[-1] for offsets in list_of_offsets], dtype=offset_dtype) + ret: cpy.OffsetArray = np.concatenate( + (list_of_offsets[0], *(list_of_offsets[i+1][1:] + cumulative[i] for i in range(n-1))), + dtype=offset_dtype, + ) + return ret + + +def concat_offsets_or_none( + list_of_offsets_or_none: list[cpy.OffsetArray | None], +) -> cpy.OffsetArray | None: + """Concatenate a list of offsets arrays or None into a single offset array or None. + """ + list_of_offsets = [offsets for offsets in list_of_offsets_or_none if offsets is not None] + if list_of_offsets: + return concat_offsets(list_of_offsets) + else: + return None + + +def concat_points(list_of_points: list[cpy.PointArray]) -> cpy.PointArray: + """Concatenate a list of point arrays into a single point array. + """ + if not list_of_points: + raise ValueError("Empty list passed to concat_points") + + return np.concatenate(list_of_points, dtype=point_dtype) + + +def concat_points_or_none( + list_of_points_or_none: list[cpy.PointArray | None], +) -> cpy.PointArray | None: + """Concatenate a list of point arrays or None into a single point array or None. + """ + list_of_points = [points for points in list_of_points_or_none if points is not None] + if list_of_points: + return concat_points(list_of_points) + else: + return None + + +def concat_points_or_none_with_nan( + list_of_points_or_none: list[cpy.PointArray | None], +) -> cpy.PointArray | None: + """Concatenate a list of points or None into a single point array or None, with NaNs used to + separate each line. + """ + list_of_points = [points for points in list_of_points_or_none if points is not None] + if list_of_points: + return concat_points_with_nan(list_of_points) + else: + return None + + +def concat_points_with_nan(list_of_points: list[cpy.PointArray]) -> cpy.PointArray: + """Concatenate a list of points into a single point array with NaNs used to separate each line. + """ + if not list_of_points: + raise ValueError("Empty list passed to concat_points_with_nan") + + if len(list_of_points) == 1: + return list_of_points[0] + else: + nan_spacer = np.full((1, 2), np.nan, dtype=point_dtype) + list_of_points = [list_of_points[0], + *list(chain(*((nan_spacer, x) for x in list_of_points[1:])))] + return concat_points(list_of_points) + + +def insert_nan_at_offsets(points: cpy.PointArray, offsets: cpy.OffsetArray) -> cpy.PointArray: + """Insert NaNs into a point array at locations specified by an offset array. + """ + check_point_array(points) + check_offset_array(offsets) + + if len(offsets) <= 2: + return points + else: + nan_spacer = np.array([np.nan, np.nan], dtype=point_dtype) + # Convert offsets to int64 to avoid numpy error when mixing signed and unsigned ints. + return np.insert(points, offsets[1:-1].astype(np.int64), nan_spacer, axis=0) + + +def offsets_from_codes(codes: cpy.CodeArray) -> cpy.OffsetArray: + """Determine offsets from codes using locations of MOVETO codes. + """ + check_code_array(codes) + + return np.append(np.nonzero(codes == MOVETO)[0], len(codes)).astype(offset_dtype) + + +def offsets_from_lengths(list_of_points: list[cpy.PointArray]) -> cpy.OffsetArray: + """Determine offsets from lengths of point arrays. + """ + if not list_of_points: + raise ValueError("Empty list passed to offsets_from_lengths") + + return np.cumsum([0] + [len(line) for line in list_of_points], dtype=offset_dtype) + + +def outer_offsets_from_list_of_codes(list_of_codes: list[cpy.CodeArray]) -> cpy.OffsetArray: + """Determine outer offsets from codes using locations of MOVETO codes. + """ + if not list_of_codes: + raise ValueError("Empty list passed to outer_offsets_from_list_of_codes") + + return np.cumsum([0] + [np.count_nonzero(codes == MOVETO) for codes in list_of_codes], + dtype=offset_dtype) + + +def outer_offsets_from_list_of_offsets(list_of_offsets: list[cpy.OffsetArray]) -> cpy.OffsetArray: + """Determine outer offsets from a list of offsets. + """ + if not list_of_offsets: + raise ValueError("Empty list passed to outer_offsets_from_list_of_offsets") + + return np.cumsum([0] + [len(offsets)-1 for offsets in list_of_offsets], dtype=offset_dtype) + + +def remove_nan(points: cpy.PointArray) -> tuple[cpy.PointArray, cpy.OffsetArray]: + """Remove NaN from a points array, also return the offsets corresponding to the NaN removed. + """ + check_point_array(points) + + nan_offsets = np.nonzero(np.isnan(points[:, 0]))[0] + if len(nan_offsets) == 0: + return points, np.array([0, len(points)], dtype=offset_dtype) + else: + points = np.delete(points, nan_offsets, axis=0) + nan_offsets -= np.arange(len(nan_offsets)) + offsets: cpy.OffsetArray = np.empty(len(nan_offsets)+2, dtype=offset_dtype) + offsets[0] = 0 + offsets[1:-1] = nan_offsets + offsets[-1] = len(points) + return points, offsets + + +def split_codes_by_offsets(codes: cpy.CodeArray, offsets: cpy.OffsetArray) -> list[cpy.CodeArray]: + """Split a code array at locations specified by an offset array into a list of code arrays. + """ + check_code_array(codes) + check_offset_array(offsets) + + if len(offsets) > 2: + return np.split(codes, offsets[1:-1]) + else: + return [codes] + + +def split_points_by_offsets( + points: cpy.PointArray, + offsets: cpy.OffsetArray, +) -> list[cpy.PointArray]: + """Split a point array at locations specified by an offset array into a list of point arrays. + """ + check_point_array(points) + check_offset_array(offsets) + + if len(offsets) > 2: + return np.split(points, offsets[1:-1]) + else: + return [points] + + +def split_points_at_nan(points: cpy.PointArray) -> list[cpy.PointArray]: + """Split a points array at NaNs into a list of point arrays. + """ + check_point_array(points) + + nan_offsets = np.nonzero(np.isnan(points[:, 0]))[0] + if len(nan_offsets) == 0: + return [points] + else: + nan_offsets = np.concatenate(([-1], nan_offsets, [len(points)])) # type: ignore[arg-type] + return [points[s+1:e] for s, e in zip(nan_offsets[:-1], nan_offsets[1:])] diff --git a/venv/lib/python3.10/site-packages/contourpy/chunk.py b/venv/lib/python3.10/site-packages/contourpy/chunk.py new file mode 100644 index 00000000..94fded1b --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/chunk.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +import math + + +def calc_chunk_sizes( + chunk_size: int | tuple[int, int] | None, + chunk_count: int | tuple[int, int] | None, + total_chunk_count: int | None, + ny: int, + nx: int, +) -> tuple[int, int]: + """Calculate chunk sizes. + + Args: + chunk_size (int or tuple(int, int), optional): Chunk size in (y, x) directions, or the same + size in both directions if only one is specified. Cannot be negative. + chunk_count (int or tuple(int, int), optional): Chunk count in (y, x) directions, or the + same count in both directions if only one is specified. If less than 1, set to 1. + total_chunk_count (int, optional): Total number of chunks. If less than 1, set to 1. + ny (int): Number of grid points in y-direction. + nx (int): Number of grid points in x-direction. + + Return: + tuple(int, int): Chunk sizes (y_chunk_size, x_chunk_size). + + Note: + Zero or one of ``chunk_size``, ``chunk_count`` and ``total_chunk_count`` should be + specified. + """ + if sum([chunk_size is not None, chunk_count is not None, total_chunk_count is not None]) > 1: + raise ValueError("Only one of chunk_size, chunk_count and total_chunk_count should be set") + + if nx < 2 or ny < 2: + raise ValueError(f"(ny, nx) must be at least (2, 2), not ({ny}, {nx})") + + if total_chunk_count is not None: + max_chunk_count = (nx-1)*(ny-1) + total_chunk_count = min(max(total_chunk_count, 1), max_chunk_count) + if total_chunk_count == 1: + chunk_size = 0 + elif total_chunk_count == max_chunk_count: + chunk_size = (1, 1) + else: + factors = two_factors(total_chunk_count) + if ny > nx: + chunk_count = factors + else: + chunk_count = (factors[1], factors[0]) + + if chunk_count is not None: + if isinstance(chunk_count, tuple): + y_chunk_count, x_chunk_count = chunk_count + else: + y_chunk_count = x_chunk_count = chunk_count + x_chunk_count = min(max(x_chunk_count, 1), nx-1) + y_chunk_count = min(max(y_chunk_count, 1), ny-1) + chunk_size = (math.ceil((ny-1) / y_chunk_count), math.ceil((nx-1) / x_chunk_count)) + + if chunk_size is None: + y_chunk_size = x_chunk_size = 0 + elif isinstance(chunk_size, tuple): + y_chunk_size, x_chunk_size = chunk_size + else: + y_chunk_size = x_chunk_size = chunk_size + + if x_chunk_size < 0 or y_chunk_size < 0: + raise ValueError("chunk_size cannot be negative") + + return y_chunk_size, x_chunk_size + + +def two_factors(n: int) -> tuple[int, int]: + """Split an integer into two integer factors. + + The two factors will be as close as possible to the sqrt of n, and are returned in decreasing + order. Worst case returns (n, 1). + + Args: + n (int): The integer to factorize, must be positive. + + Return: + tuple(int, int): The two factors of n, in decreasing order. + """ + if n < 0: + raise ValueError(f"two_factors expects positive integer not {n}") + + i = math.ceil(math.sqrt(n)) + while n % i != 0: + i -= 1 + j = n // i + if i > j: + return i, j + else: + return j, i diff --git a/venv/lib/python3.10/site-packages/contourpy/convert.py b/venv/lib/python3.10/site-packages/contourpy/convert.py new file mode 100644 index 00000000..75a54b08 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/convert.py @@ -0,0 +1,555 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, cast + +import numpy as np + +from contourpy._contourpy import FillType, LineType +import contourpy.array as arr +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.typecheck import check_filled, check_lines +from contourpy.types import MOVETO, offset_dtype + +if TYPE_CHECKING: + import contourpy._contourpy as cpy + + +def _convert_filled_from_OuterCode( + filled: cpy.FillReturn_OuterCode, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.OuterCode: + return filled + elif fill_type_to == FillType.OuterOffset: + return (filled[0], [arr.offsets_from_codes(codes) for codes in filled[1]]) + + if len(filled[0]) > 0: + points = arr.concat_points(filled[0]) + codes = arr.concat_codes(filled[1]) + else: + points = None + codes = None + + if fill_type_to == FillType.ChunkCombinedCode: + return ([points], [codes]) + elif fill_type_to == FillType.ChunkCombinedOffset: + return ([points], [None if codes is None else arr.offsets_from_codes(codes)]) + elif fill_type_to == FillType.ChunkCombinedCodeOffset: + outer_offsets = None if points is None else arr.offsets_from_lengths(filled[0]) + ret1: cpy.FillReturn_ChunkCombinedCodeOffset = ([points], [codes], [outer_offsets]) + return ret1 + elif fill_type_to == FillType.ChunkCombinedOffsetOffset: + if codes is None: + ret2: cpy.FillReturn_ChunkCombinedOffsetOffset = ([None], [None], [None]) + else: + offsets = arr.offsets_from_codes(codes) + outer_offsets = arr.outer_offsets_from_list_of_codes(filled[1]) + ret2 = ([points], [offsets], [outer_offsets]) + return ret2 + else: + raise ValueError(f"Invalid FillType {fill_type_to}") + + +def _convert_filled_from_OuterOffset( + filled: cpy.FillReturn_OuterOffset, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.OuterCode: + separate_codes = [arr.codes_from_offsets(offsets) for offsets in filled[1]] + return (filled[0], separate_codes) + elif fill_type_to == FillType.OuterOffset: + return filled + + if len(filled[0]) > 0: + points = arr.concat_points(filled[0]) + offsets = arr.concat_offsets(filled[1]) + else: + points = None + offsets = None + + if fill_type_to == FillType.ChunkCombinedCode: + return ([points], [None if offsets is None else arr.codes_from_offsets(offsets)]) + elif fill_type_to == FillType.ChunkCombinedOffset: + return ([points], [offsets]) + elif fill_type_to == FillType.ChunkCombinedCodeOffset: + if offsets is None: + ret1: cpy.FillReturn_ChunkCombinedCodeOffset = ([None], [None], [None]) + else: + codes = arr.codes_from_offsets(offsets) + outer_offsets = arr.offsets_from_lengths(filled[0]) + ret1 = ([points], [codes], [outer_offsets]) + return ret1 + elif fill_type_to == FillType.ChunkCombinedOffsetOffset: + if points is None: + ret2: cpy.FillReturn_ChunkCombinedOffsetOffset = ([None], [None], [None]) + else: + outer_offsets = arr.outer_offsets_from_list_of_offsets(filled[1]) + ret2 = ([points], [offsets], [outer_offsets]) + return ret2 + else: + raise ValueError(f"Invalid FillType {fill_type_to}") + + +def _convert_filled_from_ChunkCombinedCode( + filled: cpy.FillReturn_ChunkCombinedCode, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.ChunkCombinedCode: + return filled + elif fill_type_to == FillType.ChunkCombinedOffset: + codes = [None if codes is None else arr.offsets_from_codes(codes) for codes in filled[1]] + return (filled[0], codes) + else: + raise ValueError( + f"Conversion from {FillType.ChunkCombinedCode} to {fill_type_to} not supported") + + +def _convert_filled_from_ChunkCombinedOffset( + filled: cpy.FillReturn_ChunkCombinedOffset, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.ChunkCombinedCode: + chunk_codes: list[cpy.CodeArray | None] = [] + for points, offsets in zip(*filled): + if points is None: + chunk_codes.append(None) + else: + if TYPE_CHECKING: + assert offsets is not None + chunk_codes.append(arr.codes_from_offsets_and_points(offsets, points)) + return (filled[0], chunk_codes) + elif fill_type_to == FillType.ChunkCombinedOffset: + return filled + else: + raise ValueError( + f"Conversion from {FillType.ChunkCombinedOffset} to {fill_type_to} not supported") + + +def _convert_filled_from_ChunkCombinedCodeOffset( + filled: cpy.FillReturn_ChunkCombinedCodeOffset, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.OuterCode: + separate_points = [] + separate_codes = [] + for points, codes, outer_offsets in zip(*filled): + if points is not None: + if TYPE_CHECKING: + assert codes is not None + assert outer_offsets is not None + separate_points += arr.split_points_by_offsets(points, outer_offsets) + separate_codes += arr.split_codes_by_offsets(codes, outer_offsets) + return (separate_points, separate_codes) + elif fill_type_to == FillType.OuterOffset: + separate_points = [] + separate_offsets = [] + for points, codes, outer_offsets in zip(*filled): + if points is not None: + if TYPE_CHECKING: + assert codes is not None + assert outer_offsets is not None + separate_points += arr.split_points_by_offsets(points, outer_offsets) + separate_codes = arr.split_codes_by_offsets(codes, outer_offsets) + separate_offsets += [arr.offsets_from_codes(codes) for codes in separate_codes] + return (separate_points, separate_offsets) + elif fill_type_to == FillType.ChunkCombinedCode: + ret1: cpy.FillReturn_ChunkCombinedCode = (filled[0], filled[1]) + return ret1 + elif fill_type_to == FillType.ChunkCombinedOffset: + all_offsets = [None if codes is None else arr.offsets_from_codes(codes) + for codes in filled[1]] + ret2: cpy.FillReturn_ChunkCombinedOffset = (filled[0], all_offsets) + return ret2 + elif fill_type_to == FillType.ChunkCombinedCodeOffset: + return filled + elif fill_type_to == FillType.ChunkCombinedOffsetOffset: + chunk_offsets: list[cpy.OffsetArray | None] = [] + chunk_outer_offsets: list[cpy.OffsetArray | None] = [] + for codes, outer_offsets in zip(*filled[1:]): + if codes is None: + chunk_offsets.append(None) + chunk_outer_offsets.append(None) + else: + if TYPE_CHECKING: + assert outer_offsets is not None + offsets = arr.offsets_from_codes(codes) + outer_offsets = np.array([np.nonzero(offsets == oo)[0][0] for oo in outer_offsets], + dtype=offset_dtype) + chunk_offsets.append(offsets) + chunk_outer_offsets.append(outer_offsets) + ret3: cpy.FillReturn_ChunkCombinedOffsetOffset = ( + filled[0], chunk_offsets, chunk_outer_offsets, + ) + return ret3 + else: + raise ValueError(f"Invalid FillType {fill_type_to}") + + +def _convert_filled_from_ChunkCombinedOffsetOffset( + filled: cpy.FillReturn_ChunkCombinedOffsetOffset, + fill_type_to: FillType, +) -> cpy.FillReturn: + if fill_type_to == FillType.OuterCode: + separate_points = [] + separate_codes = [] + for points, offsets, outer_offsets in zip(*filled): + if points is not None: + if TYPE_CHECKING: + assert offsets is not None + assert outer_offsets is not None + codes = arr.codes_from_offsets_and_points(offsets, points) + outer_offsets = offsets[outer_offsets] + separate_points += arr.split_points_by_offsets(points, outer_offsets) + separate_codes += arr.split_codes_by_offsets(codes, outer_offsets) + return (separate_points, separate_codes) + elif fill_type_to == FillType.OuterOffset: + separate_points = [] + separate_offsets = [] + for points, offsets, outer_offsets in zip(*filled): + if points is not None: + if TYPE_CHECKING: + assert offsets is not None + assert outer_offsets is not None + if len(outer_offsets) > 2: + separate_offsets += [offsets[s:e+1] - offsets[s] for s, e in + zip(outer_offsets[:-1], outer_offsets[1:])] + else: + separate_offsets.append(offsets) + separate_points += arr.split_points_by_offsets(points, offsets[outer_offsets]) + return (separate_points, separate_offsets) + elif fill_type_to == FillType.ChunkCombinedCode: + chunk_codes: list[cpy.CodeArray | None] = [] + for points, offsets, outer_offsets in zip(*filled): + if points is None: + chunk_codes.append(None) + else: + if TYPE_CHECKING: + assert offsets is not None + assert outer_offsets is not None + chunk_codes.append(arr.codes_from_offsets_and_points(offsets, points)) + ret1: cpy.FillReturn_ChunkCombinedCode = (filled[0], chunk_codes) + return ret1 + elif fill_type_to == FillType.ChunkCombinedOffset: + return (filled[0], filled[1]) + elif fill_type_to == FillType.ChunkCombinedCodeOffset: + chunk_codes = [] + chunk_outer_offsets: list[cpy.OffsetArray | None] = [] + for points, offsets, outer_offsets in zip(*filled): + if points is None: + chunk_codes.append(None) + chunk_outer_offsets.append(None) + else: + if TYPE_CHECKING: + assert offsets is not None + assert outer_offsets is not None + chunk_codes.append(arr.codes_from_offsets_and_points(offsets, points)) + chunk_outer_offsets.append(offsets[outer_offsets]) + ret2: cpy.FillReturn_ChunkCombinedCodeOffset = (filled[0], chunk_codes, chunk_outer_offsets) + return ret2 + elif fill_type_to == FillType.ChunkCombinedOffsetOffset: + return filled + else: + raise ValueError(f"Invalid FillType {fill_type_to}") + + +def convert_filled( + filled: cpy.FillReturn, + fill_type_from: FillType | str, + fill_type_to: FillType | str, +) -> cpy.FillReturn: + """Return the specified filled contours converted to a different :class:`~contourpy.FillType`. + + Args: + filled (sequence of arrays): Filled contour polygons to convert. + fill_type_from (FillType or str): :class:`~contourpy.FillType` to convert from as enum or + string equivalent. + fill_type_to (FillType or str): :class:`~contourpy.FillType` to convert to as enum or string + equivalent. + + Return: + Converted filled contour polygons. + + When converting non-chunked fill types (``FillType.OuterCode`` or ``FillType.OuterOffset``) to + chunked ones, all polygons are placed in the first chunk. When converting in the other + direction, all chunk information is discarded. Converting a fill type that is not aware of the + relationship between outer boundaries and contained holes (``FillType.ChunkCombinedCode`` or) + ``FillType.ChunkCombinedOffset``) to one that is will raise a ``ValueError``. + + .. versionadded:: 1.2.0 + """ + fill_type_from = as_fill_type(fill_type_from) + fill_type_to = as_fill_type(fill_type_to) + + check_filled(filled, fill_type_from) + + if fill_type_from == FillType.OuterCode: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_OuterCode, filled) + return _convert_filled_from_OuterCode(filled, fill_type_to) + elif fill_type_from == FillType.OuterOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_OuterOffset, filled) + return _convert_filled_from_OuterOffset(filled, fill_type_to) + elif fill_type_from == FillType.ChunkCombinedCode: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCode, filled) + return _convert_filled_from_ChunkCombinedCode(filled, fill_type_to) + elif fill_type_from == FillType.ChunkCombinedOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffset, filled) + return _convert_filled_from_ChunkCombinedOffset(filled, fill_type_to) + elif fill_type_from == FillType.ChunkCombinedCodeOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCodeOffset, filled) + return _convert_filled_from_ChunkCombinedCodeOffset(filled, fill_type_to) + elif fill_type_from == FillType.ChunkCombinedOffsetOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffsetOffset, filled) + return _convert_filled_from_ChunkCombinedOffsetOffset(filled, fill_type_to) + else: + raise ValueError(f"Invalid FillType {fill_type_from}") + + +def _convert_lines_from_Separate( + lines: cpy.LineReturn_Separate, + line_type_to: LineType, +) -> cpy.LineReturn: + if line_type_to == LineType.Separate: + return lines + elif line_type_to == LineType.SeparateCode: + separate_codes = [arr.codes_from_points(line) for line in lines] + return (lines, separate_codes) + elif line_type_to == LineType.ChunkCombinedCode: + if not lines: + ret1: cpy.LineReturn_ChunkCombinedCode = ([None], [None]) + else: + points = arr.concat_points(lines) + offsets = arr.offsets_from_lengths(lines) + codes = arr.codes_from_offsets_and_points(offsets, points) + ret1 = ([points], [codes]) + return ret1 + elif line_type_to == LineType.ChunkCombinedOffset: + if not lines: + ret2: cpy.LineReturn_ChunkCombinedOffset = ([None], [None]) + else: + ret2 = ([arr.concat_points(lines)], [arr.offsets_from_lengths(lines)]) + return ret2 + elif line_type_to == LineType.ChunkCombinedNan: + if not lines: + ret3: cpy.LineReturn_ChunkCombinedNan = ([None],) + else: + ret3 = ([arr.concat_points_with_nan(lines)],) + return ret3 + else: + raise ValueError(f"Invalid LineType {line_type_to}") + + +def _convert_lines_from_SeparateCode( + lines: cpy.LineReturn_SeparateCode, + line_type_to: LineType, +) -> cpy.LineReturn: + if line_type_to == LineType.Separate: + # Drop codes. + return lines[0] + elif line_type_to == LineType.SeparateCode: + return lines + elif line_type_to == LineType.ChunkCombinedCode: + if not lines[0]: + ret1: cpy.LineReturn_ChunkCombinedCode = ([None], [None]) + else: + ret1 = ([arr.concat_points(lines[0])], [arr.concat_codes(lines[1])]) + return ret1 + elif line_type_to == LineType.ChunkCombinedOffset: + if not lines[0]: + ret2: cpy.LineReturn_ChunkCombinedOffset = ([None], [None]) + else: + ret2 = ([arr.concat_points(lines[0])], [arr.offsets_from_lengths(lines[0])]) + return ret2 + elif line_type_to == LineType.ChunkCombinedNan: + if not lines[0]: + ret3: cpy.LineReturn_ChunkCombinedNan = ([None],) + else: + ret3 = ([arr.concat_points_with_nan(lines[0])],) + return ret3 + else: + raise ValueError(f"Invalid LineType {line_type_to}") + + +def _convert_lines_from_ChunkCombinedCode( + lines: cpy.LineReturn_ChunkCombinedCode, + line_type_to: LineType, +) -> cpy.LineReturn: + if line_type_to in (LineType.Separate, LineType.SeparateCode): + separate_lines = [] + for points, codes in zip(*lines): + if points is not None: + if TYPE_CHECKING: + assert codes is not None + split_at = np.nonzero(codes == MOVETO)[0] + if len(split_at) > 1: + separate_lines += np.split(points, split_at[1:]) + else: + separate_lines.append(points) + if line_type_to == LineType.Separate: + return separate_lines + else: + separate_codes = [arr.codes_from_points(line) for line in separate_lines] + return (separate_lines, separate_codes) + elif line_type_to == LineType.ChunkCombinedCode: + return lines + elif line_type_to == LineType.ChunkCombinedOffset: + chunk_offsets = [None if codes is None else arr.offsets_from_codes(codes) + for codes in lines[1]] + return (lines[0], chunk_offsets) + elif line_type_to == LineType.ChunkCombinedNan: + points_nan: list[cpy.PointArray | None] = [] + for points, codes in zip(*lines): + if points is None: + points_nan.append(None) + else: + if TYPE_CHECKING: + assert codes is not None + offsets = arr.offsets_from_codes(codes) + points_nan.append(arr.insert_nan_at_offsets(points, offsets)) + return (points_nan,) + else: + raise ValueError(f"Invalid LineType {line_type_to}") + + +def _convert_lines_from_ChunkCombinedOffset( + lines: cpy.LineReturn_ChunkCombinedOffset, + line_type_to: LineType, +) -> cpy.LineReturn: + if line_type_to in (LineType.Separate, LineType.SeparateCode): + separate_lines = [] + for points, offsets in zip(*lines): + if points is not None: + if TYPE_CHECKING: + assert offsets is not None + separate_lines += arr.split_points_by_offsets(points, offsets) + if line_type_to == LineType.Separate: + return separate_lines + else: + separate_codes = [arr.codes_from_points(line) for line in separate_lines] + return (separate_lines, separate_codes) + elif line_type_to == LineType.ChunkCombinedCode: + chunk_codes: list[cpy.CodeArray | None] = [] + for points, offsets in zip(*lines): + if points is None: + chunk_codes.append(None) + else: + if TYPE_CHECKING: + assert offsets is not None + chunk_codes.append(arr.codes_from_offsets_and_points(offsets, points)) + return (lines[0], chunk_codes) + elif line_type_to == LineType.ChunkCombinedOffset: + return lines + elif line_type_to == LineType.ChunkCombinedNan: + points_nan: list[cpy.PointArray | None] = [] + for points, offsets in zip(*lines): + if points is None: + points_nan.append(None) + else: + if TYPE_CHECKING: + assert offsets is not None + points_nan.append(arr.insert_nan_at_offsets(points, offsets)) + return (points_nan,) + else: + raise ValueError(f"Invalid LineType {line_type_to}") + + +def _convert_lines_from_ChunkCombinedNan( + lines: cpy.LineReturn_ChunkCombinedNan, + line_type_to: LineType, +) -> cpy.LineReturn: + if line_type_to in (LineType.Separate, LineType.SeparateCode): + separate_lines = [] + for points in lines[0]: + if points is not None: + separate_lines += arr.split_points_at_nan(points) + if line_type_to == LineType.Separate: + return separate_lines + else: + separate_codes = [arr.codes_from_points(points) for points in separate_lines] + return (separate_lines, separate_codes) + elif line_type_to == LineType.ChunkCombinedCode: + chunk_points: list[cpy.PointArray | None] = [] + chunk_codes: list[cpy.CodeArray | None] = [] + for points in lines[0]: + if points is None: + chunk_points.append(None) + chunk_codes.append(None) + else: + points, offsets = arr.remove_nan(points) + chunk_points.append(points) + chunk_codes.append(arr.codes_from_offsets_and_points(offsets, points)) + return (chunk_points, chunk_codes) + elif line_type_to == LineType.ChunkCombinedOffset: + chunk_points = [] + chunk_offsets: list[cpy.OffsetArray | None] = [] + for points in lines[0]: + if points is None: + chunk_points.append(None) + chunk_offsets.append(None) + else: + points, offsets = arr.remove_nan(points) + chunk_points.append(points) + chunk_offsets.append(offsets) + return (chunk_points, chunk_offsets) + elif line_type_to == LineType.ChunkCombinedNan: + return lines + else: + raise ValueError(f"Invalid LineType {line_type_to}") + + +def convert_lines( + lines: cpy.LineReturn, + line_type_from: LineType | str, + line_type_to: LineType | str, +) -> cpy.LineReturn: + """Return the specified contour lines converted to a different :class:`~contourpy.LineType`. + + Args: + lines (sequence of arrays): Contour lines to convert. + line_type_from (LineType or str): :class:`~contourpy.LineType` to convert from as enum or + string equivalent. + line_type_to (LineType or str): :class:`~contourpy.LineType` to convert to as enum or string + equivalent. + + Return: + Converted contour lines. + + When converting non-chunked line types (``LineType.Separate`` or ``LineType.SeparateCode``) to + chunked ones (``LineType.ChunkCombinedCode``, ``LineType.ChunkCombinedOffset`` or + ``LineType.ChunkCombinedNan``), all lines are placed in the first chunk. When converting in the + other direction, all chunk information is discarded. + + .. versionadded:: 1.2.0 + """ + line_type_from = as_line_type(line_type_from) + line_type_to = as_line_type(line_type_to) + + check_lines(lines, line_type_from) + + if line_type_from == LineType.Separate: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_Separate, lines) + return _convert_lines_from_Separate(lines, line_type_to) + elif line_type_from == LineType.SeparateCode: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_SeparateCode, lines) + return _convert_lines_from_SeparateCode(lines, line_type_to) + elif line_type_from == LineType.ChunkCombinedCode: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedCode, lines) + return _convert_lines_from_ChunkCombinedCode(lines, line_type_to) + elif line_type_from == LineType.ChunkCombinedOffset: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedOffset, lines) + return _convert_lines_from_ChunkCombinedOffset(lines, line_type_to) + elif line_type_from == LineType.ChunkCombinedNan: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedNan, lines) + return _convert_lines_from_ChunkCombinedNan(lines, line_type_to) + else: + raise ValueError(f"Invalid LineType {line_type_from}") diff --git a/venv/lib/python3.10/site-packages/contourpy/dechunk.py b/venv/lib/python3.10/site-packages/contourpy/dechunk.py new file mode 100644 index 00000000..622a1ceb --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/dechunk.py @@ -0,0 +1,144 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, cast + +from contourpy._contourpy import FillType, LineType +from contourpy.array import ( + concat_codes_or_none, + concat_offsets_or_none, + concat_points_or_none, + concat_points_or_none_with_nan, +) +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.typecheck import check_filled, check_lines + +if TYPE_CHECKING: + import contourpy._contourpy as cpy + + +def dechunk_filled(filled: cpy.FillReturn, fill_type: FillType | str) -> cpy.FillReturn: + """Return the specified filled contours with all chunked data moved into the first chunk. + + Filled contours that are not chunked (``FillType.OuterCode`` and ``FillType.OuterOffset``) and + those that are but only contain a single chunk are returned unmodified. Individual polygons are + unchanged, they are not geometrically combined. + + Args: + filled (sequence of arrays): Filled contour data as returned by + :func:`~contourpy.ContourGenerator.filled`. + fill_type (FillType or str): Type of ``filled`` as enum or string equivalent. + + Return: + Filled contours in a single chunk. + + .. versionadded:: 1.2.0 + """ + fill_type = as_fill_type(fill_type) + + if fill_type in (FillType.OuterCode, FillType.OuterOffset): + # No-op if fill_type is not chunked. + return filled + + check_filled(filled, fill_type) + if len(filled[0]) < 2: + # No-op if just one chunk. + return filled + + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_Chunk, filled) + points = concat_points_or_none(filled[0]) + + if fill_type == FillType.ChunkCombinedCode: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCode, filled) + if points is None: + ret1: cpy.FillReturn_ChunkCombinedCode = ([None], [None]) + else: + ret1 = ([points], [concat_codes_or_none(filled[1])]) + return ret1 + elif fill_type == FillType.ChunkCombinedOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffset, filled) + if points is None: + ret2: cpy.FillReturn_ChunkCombinedOffset = ([None], [None]) + else: + ret2 = ([points], [concat_offsets_or_none(filled[1])]) + return ret2 + elif fill_type == FillType.ChunkCombinedCodeOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCodeOffset, filled) + if points is None: + ret3: cpy.FillReturn_ChunkCombinedCodeOffset = ([None], [None], [None]) + else: + outer_offsets = concat_offsets_or_none(filled[2]) + ret3 = ([points], [concat_codes_or_none(filled[1])], [outer_offsets]) + return ret3 + elif fill_type == FillType.ChunkCombinedOffsetOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffsetOffset, filled) + if points is None: + ret4: cpy.FillReturn_ChunkCombinedOffsetOffset = ([None], [None], [None]) + else: + outer_offsets = concat_offsets_or_none(filled[2]) + ret4 = ([points], [concat_offsets_or_none(filled[1])], [outer_offsets]) + return ret4 + else: + raise ValueError(f"Invalid FillType {fill_type}") + + +def dechunk_lines(lines: cpy.LineReturn, line_type: LineType | str) -> cpy.LineReturn: + """Return the specified contour lines with all chunked data moved into the first chunk. + + Contour lines that are not chunked (``LineType.Separate`` and ``LineType.SeparateCode``) and + those that are but only contain a single chunk are returned unmodified. Individual lines are + unchanged, they are not geometrically combined. + + Args: + lines (sequence of arrays): Contour line data as returned by + :func:`~contourpy.ContourGenerator.lines`. + line_type (LineType or str): Type of ``lines`` as enum or string equivalent. + + Return: + Contour lines in a single chunk. + + .. versionadded:: 1.2.0 + """ + line_type = as_line_type(line_type) + if line_type in (LineType.Separate, LineType.SeparateCode): + # No-op if line_type is not chunked. + return lines + + check_lines(lines, line_type) + if len(lines[0]) < 2: + # No-op if just one chunk. + return lines + + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_Chunk, lines) + + if line_type == LineType.ChunkCombinedCode: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedCode, lines) + points = concat_points_or_none(lines[0]) + if points is None: + ret1: cpy.LineReturn_ChunkCombinedCode = ([None], [None]) + else: + ret1 = ([points], [concat_codes_or_none(lines[1])]) + return ret1 + elif line_type == LineType.ChunkCombinedOffset: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedOffset, lines) + points = concat_points_or_none(lines[0]) + if points is None: + ret2: cpy.LineReturn_ChunkCombinedOffset = ([None], [None]) + else: + ret2 = ([points], [concat_offsets_or_none(lines[1])]) + return ret2 + elif line_type == LineType.ChunkCombinedNan: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedNan, lines) + points = concat_points_or_none_with_nan(lines[0]) + ret3: cpy.LineReturn_ChunkCombinedNan = ([points],) + return ret3 + else: + raise ValueError(f"Invalid LineType {line_type}") diff --git a/venv/lib/python3.10/site-packages/contourpy/enum_util.py b/venv/lib/python3.10/site-packages/contourpy/enum_util.py new file mode 100644 index 00000000..14229abe --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/enum_util.py @@ -0,0 +1,57 @@ +from __future__ import annotations + +from contourpy._contourpy import FillType, LineType, ZInterp + + +def as_fill_type(fill_type: FillType | str) -> FillType: + """Coerce a FillType or string value to a FillType. + + Args: + fill_type (FillType or str): Value to convert. + + Return: + FillType: Converted value. + """ + if isinstance(fill_type, str): + try: + return FillType.__members__[fill_type] + except KeyError as e: + raise ValueError(f"'{fill_type}' is not a valid FillType") from e + else: + return fill_type + + +def as_line_type(line_type: LineType | str) -> LineType: + """Coerce a LineType or string value to a LineType. + + Args: + line_type (LineType or str): Value to convert. + + Return: + LineType: Converted value. + """ + if isinstance(line_type, str): + try: + return LineType.__members__[line_type] + except KeyError as e: + raise ValueError(f"'{line_type}' is not a valid LineType") from e + else: + return line_type + + +def as_z_interp(z_interp: ZInterp | str) -> ZInterp: + """Coerce a ZInterp or string value to a ZInterp. + + Args: + z_interp (ZInterp or str): Value to convert. + + Return: + ZInterp: Converted value. + """ + if isinstance(z_interp, str): + try: + return ZInterp.__members__[z_interp] + except KeyError as e: + raise ValueError(f"'{z_interp}' is not a valid ZInterp") from e + else: + return z_interp diff --git a/venv/lib/python3.10/site-packages/contourpy/py.typed b/venv/lib/python3.10/site-packages/contourpy/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/contourpy/typecheck.py b/venv/lib/python3.10/site-packages/contourpy/typecheck.py new file mode 100644 index 00000000..23fbd548 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/typecheck.py @@ -0,0 +1,203 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, cast + +import numpy as np + +from contourpy import FillType, LineType +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.types import MOVETO, code_dtype, offset_dtype, point_dtype + +if TYPE_CHECKING: + import contourpy._contourpy as cpy + + +# Minimalist array-checking functions that check dtype, ndims and shape only. +# They do not walk the arrays to check the contents for performance reasons. +def check_code_array(codes: Any) -> None: + if not isinstance(codes, np.ndarray): + raise TypeError(f"Expected numpy array not {type(codes)}") + if codes.dtype != code_dtype: + raise ValueError(f"Expected numpy array of dtype {code_dtype} not {codes.dtype}") + if not (codes.ndim == 1 and len(codes) > 1): + raise ValueError(f"Expected numpy array of shape (?,) not {codes.shape}") + if codes[0] != MOVETO: + raise ValueError(f"First element of code array must be {MOVETO}, not {codes[0]}") + + +def check_offset_array(offsets: Any) -> None: + if not isinstance(offsets, np.ndarray): + raise TypeError(f"Expected numpy array not {type(offsets)}") + if offsets.dtype != offset_dtype: + raise ValueError(f"Expected numpy array of dtype {offset_dtype} not {offsets.dtype}") + if not (offsets.ndim == 1 and len(offsets) > 1): + raise ValueError(f"Expected numpy array of shape (?,) not {offsets.shape}") + if offsets[0] != 0: + raise ValueError(f"First element of offset array must be 0, not {offsets[0]}") + + +def check_point_array(points: Any) -> None: + if not isinstance(points, np.ndarray): + raise TypeError(f"Expected numpy array not {type(points)}") + if points.dtype != point_dtype: + raise ValueError(f"Expected numpy array of dtype {point_dtype} not {points.dtype}") + if not (points.ndim == 2 and points.shape[1] ==2 and points.shape[0] > 1): + raise ValueError(f"Expected numpy array of shape (?, 2) not {points.shape}") + + +def _check_tuple_of_lists_with_same_length( + maybe_tuple: Any, + tuple_length: int, + allow_empty_lists: bool = True, +) -> None: + if not isinstance(maybe_tuple, tuple): + raise TypeError(f"Expected tuple not {type(maybe_tuple)}") + if len(maybe_tuple) != tuple_length: + raise ValueError(f"Expected tuple of length {tuple_length} not {len(maybe_tuple)}") + for maybe_list in maybe_tuple: + if not isinstance(maybe_list, list): + msg = f"Expected tuple to contain {tuple_length} lists but found a {type(maybe_list)}" + raise TypeError(msg) + lengths = [len(item) for item in maybe_tuple] + if len(set(lengths)) != 1: + msg = f"Expected {tuple_length} lists with same length but lengths are {lengths}" + raise ValueError(msg) + if not allow_empty_lists and lengths[0] == 0: + raise ValueError(f"Expected {tuple_length} non-empty lists") + + +def check_filled(filled: cpy.FillReturn, fill_type: FillType | str) -> None: + fill_type = as_fill_type(fill_type) + + if fill_type == FillType.OuterCode: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_OuterCode, filled) + _check_tuple_of_lists_with_same_length(filled, 2) + for i, (points, codes) in enumerate(zip(*filled)): + check_point_array(points) + check_code_array(codes) + if len(points) != len(codes): + raise ValueError(f"Points and codes have different lengths in polygon {i}") + elif fill_type == FillType.OuterOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_OuterOffset, filled) + _check_tuple_of_lists_with_same_length(filled, 2) + for i, (points, offsets) in enumerate(zip(*filled)): + check_point_array(points) + check_offset_array(offsets) + if offsets[-1] != len(points): + raise ValueError(f"Inconsistent points and offsets in polygon {i}") + elif fill_type == FillType.ChunkCombinedCode: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCode, filled) + _check_tuple_of_lists_with_same_length(filled, 2, allow_empty_lists=False) + for chunk, (points_or_none, codes_or_none) in enumerate(zip(*filled)): + if points_or_none is not None and codes_or_none is not None: + check_point_array(points_or_none) + check_code_array(codes_or_none) + if len(points_or_none) != len(codes_or_none): + raise ValueError(f"Points and codes have different lengths in chunk {chunk}") + elif not (points_or_none is None and codes_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {chunk}") + elif fill_type == FillType.ChunkCombinedOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffset, filled) + _check_tuple_of_lists_with_same_length(filled, 2, allow_empty_lists=False) + for chunk, (points_or_none, offsets_or_none) in enumerate(zip(*filled)): + if points_or_none is not None and offsets_or_none is not None: + check_point_array(points_or_none) + check_offset_array(offsets_or_none) + if offsets_or_none[-1] != len(points_or_none): + raise ValueError(f"Inconsistent points and offsets in chunk {chunk}") + elif not (points_or_none is None and offsets_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {chunk}") + elif fill_type == FillType.ChunkCombinedCodeOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedCodeOffset, filled) + _check_tuple_of_lists_with_same_length(filled, 3, allow_empty_lists=False) + for i, (points_or_none, codes_or_none, outer_offsets_or_none) in enumerate(zip(*filled)): + if (points_or_none is not None and codes_or_none is not None and + outer_offsets_or_none is not None): + check_point_array(points_or_none) + check_code_array(codes_or_none) + check_offset_array(outer_offsets_or_none) + if len(codes_or_none) != len(points_or_none): + raise ValueError(f"Points and codes have different lengths in chunk {i}") + if outer_offsets_or_none[-1] != len(codes_or_none): + raise ValueError(f"Inconsistent codes and outer_offsets in chunk {i}") + elif not (points_or_none is None and codes_or_none is None and + outer_offsets_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {i}") + elif fill_type == FillType.ChunkCombinedOffsetOffset: + if TYPE_CHECKING: + filled = cast(cpy.FillReturn_ChunkCombinedOffsetOffset, filled) + _check_tuple_of_lists_with_same_length(filled, 3, allow_empty_lists=False) + for i, (points_or_none, offsets_or_none, outer_offsets_or_none) in enumerate(zip(*filled)): + if (points_or_none is not None and offsets_or_none is not None and + outer_offsets_or_none is not None): + check_point_array(points_or_none) + check_offset_array(offsets_or_none) + check_offset_array(outer_offsets_or_none) + if offsets_or_none[-1] != len(points_or_none): + raise ValueError(f"Inconsistent points and offsets in chunk {i}") + if outer_offsets_or_none[-1] != len(offsets_or_none) - 1: + raise ValueError(f"Inconsistent offsets and outer_offsets in chunk {i}") + elif not (points_or_none is None and offsets_or_none is None and + outer_offsets_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {i}") + else: + raise ValueError(f"Invalid FillType {fill_type}") + + +def check_lines(lines: cpy.LineReturn, line_type: LineType | str) -> None: + line_type = as_line_type(line_type) + + if line_type == LineType.Separate: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_Separate, lines) + if not isinstance(lines, list): + raise TypeError(f"Expected list not {type(lines)}") + for points in lines: + check_point_array(points) + elif line_type == LineType.SeparateCode: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_SeparateCode, lines) + _check_tuple_of_lists_with_same_length(lines, 2) + for i, (points, codes) in enumerate(zip(*lines)): + check_point_array(points) + check_code_array(codes) + if len(points) != len(codes): + raise ValueError(f"Points and codes have different lengths in line {i}") + elif line_type == LineType.ChunkCombinedCode: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedCode, lines) + _check_tuple_of_lists_with_same_length(lines, 2, allow_empty_lists=False) + for chunk, (points_or_none, codes_or_none) in enumerate(zip(*lines)): + if points_or_none is not None and codes_or_none is not None: + check_point_array(points_or_none) + check_code_array(codes_or_none) + if len(points_or_none) != len(codes_or_none): + raise ValueError(f"Points and codes have different lengths in chunk {chunk}") + elif not (points_or_none is None and codes_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {chunk}") + elif line_type == LineType.ChunkCombinedOffset: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedOffset, lines) + _check_tuple_of_lists_with_same_length(lines, 2, allow_empty_lists=False) + for chunk, (points_or_none, offsets_or_none) in enumerate(zip(*lines)): + if points_or_none is not None and offsets_or_none is not None: + check_point_array(points_or_none) + check_offset_array(offsets_or_none) + if offsets_or_none[-1] != len(points_or_none): + raise ValueError(f"Inconsistent points and offsets in chunk {chunk}") + elif not (points_or_none is None and offsets_or_none is None): + raise ValueError(f"Inconsistent Nones in chunk {chunk}") + elif line_type == LineType.ChunkCombinedNan: + if TYPE_CHECKING: + lines = cast(cpy.LineReturn_ChunkCombinedNan, lines) + _check_tuple_of_lists_with_same_length(lines, 1, allow_empty_lists=False) + for _chunk, points_or_none in enumerate(lines[0]): + if points_or_none is not None: + check_point_array(points_or_none) + else: + raise ValueError(f"Invalid LineType {line_type}") diff --git a/venv/lib/python3.10/site-packages/contourpy/types.py b/venv/lib/python3.10/site-packages/contourpy/types.py new file mode 100644 index 00000000..e704b98e --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/types.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +import numpy as np + +# dtypes of arrays returned by ContourPy. +point_dtype = np.float64 +code_dtype = np.uint8 +offset_dtype = np.uint32 + +# Kind codes used in Matplotlib Paths. +MOVETO = 1 +LINETO = 2 +CLOSEPOLY = 79 diff --git a/venv/lib/python3.10/site-packages/contourpy/util/__init__.py b/venv/lib/python3.10/site-packages/contourpy/util/__init__.py new file mode 100644 index 00000000..fe33fcef --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/__init__.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from contourpy.util._build_config import build_config + +__all__ = ["build_config"] diff --git a/venv/lib/python3.10/site-packages/contourpy/util/_build_config.py b/venv/lib/python3.10/site-packages/contourpy/util/_build_config.py new file mode 100644 index 00000000..f9d45b5b --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/_build_config.py @@ -0,0 +1,60 @@ +# _build_config.py.in is converted into _build_config.py during the meson build process. + +from __future__ import annotations + + +def build_config() -> dict[str, str]: + """ + Return a dictionary containing build configuration settings. + + All dictionary keys and values are strings, for example ``False`` is + returned as ``"False"``. + + .. versionadded:: 1.1.0 + """ + return dict( + # Python settings + python_version="3.10", + python_install_dir=r"/usr/local/lib/python3.10/site-packages/", + python_path=r"/tmp/build-env-dr3nnjcd/bin/python", + + # Package versions + contourpy_version="1.2.1", + meson_version="1.4.0", + mesonpy_version="0.15.0", + pybind11_version="2.12.0", + + # Misc meson settings + meson_backend="ninja", + build_dir=r"/project/.mesonpy-f0ezjjlb/lib/contourpy/util", + source_dir=r"/project/lib/contourpy/util", + cross_build="False", + + # Build options + build_options=r"-Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dvsenv=True --native-file=/project/.mesonpy-f0ezjjlb/meson-python-native-file.ini", + buildtype="release", + cpp_std="c++17", + debug="False", + optimization="3", + vsenv="True", + b_ndebug="if-release", + b_vscrt="from_buildtype", + + # C++ compiler + compiler_name="gcc", + compiler_version="10.2.1", + linker_id="ld.bfd", + compile_command="c++", + + # Host machine + host_cpu="x86_64", + host_cpu_family="x86_64", + host_cpu_endian="little", + host_cpu_system="linux", + + # Build machine, same as host machine if not a cross_build + build_cpu="x86_64", + build_cpu_family="x86_64", + build_cpu_endian="little", + build_cpu_system="linux", + ) diff --git a/venv/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py b/venv/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py new file mode 100644 index 00000000..85b0f8c4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py @@ -0,0 +1,336 @@ +from __future__ import annotations + +import io +from typing import TYPE_CHECKING, Any + +from bokeh.io import export_png, export_svg, show +from bokeh.io.export import get_screenshot_as_png +from bokeh.layouts import gridplot +from bokeh.models.annotations.labels import Label +from bokeh.palettes import Category10 +from bokeh.plotting import figure +import numpy as np + +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.util.bokeh_util import filled_to_bokeh, lines_to_bokeh +from contourpy.util.renderer import Renderer + +if TYPE_CHECKING: + from bokeh.models import GridPlot + from bokeh.palettes import Palette + from numpy.typing import ArrayLike + from selenium.webdriver.remote.webdriver import WebDriver + + from contourpy import FillType, LineType + from contourpy._contourpy import FillReturn, LineReturn + + +class BokehRenderer(Renderer): + """Utility renderer using Bokeh to render a grid of plots over the same (x, y) range. + + Args: + nrows (int, optional): Number of rows of plots, default ``1``. + ncols (int, optional): Number of columns of plots, default ``1``. + figsize (tuple(float, float), optional): Figure size in inches (assuming 100 dpi), default + ``(9, 9)``. + show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``. + want_svg (bool, optional): Whether output is required in SVG format or not, default + ``False``. + + Warning: + :class:`~contourpy.util.bokeh_renderer.BokehRenderer`, unlike + :class:`~contourpy.util.mpl_renderer.MplRenderer`, needs to be told in advance if output to + SVG format will be required later, otherwise it will assume PNG output. + """ + _figures: list[figure] + _layout: GridPlot + _palette: Palette + _want_svg: bool + + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + want_svg: bool = False, + ) -> None: + self._want_svg = want_svg + self._palette = Category10[10] + + total_size = 100*np.asarray(figsize, dtype=int) # Assuming 100 dpi. + + nfigures = nrows*ncols + self._figures = [] + backend = "svg" if self._want_svg else "canvas" + for _ in range(nfigures): + fig = figure(output_backend=backend) + fig.xgrid.visible = False + fig.ygrid.visible = False + self._figures.append(fig) + if not show_frame: + fig.outline_line_color = None # type: ignore[assignment] + fig.axis.visible = False + + self._layout = gridplot( + self._figures, ncols=ncols, toolbar_location=None, # type: ignore[arg-type] + width=total_size[0] // ncols, height=total_size[1] // nrows) + + def _convert_color(self, color: str) -> str: + if isinstance(color, str) and color[0] == "C": + index = int(color[1:]) + color = self._palette[index] + return color + + def _get_figure(self, ax: figure | int) -> figure: + if isinstance(ax, int): + ax = self._figures[ax] + return ax + + def filled( + self, + filled: FillReturn, + fill_type: FillType | str, + ax: figure | int = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + """Plot filled contours on a single plot. + + Args: + filled (sequence of arrays): Filled contour data as returned by + :func:`~contourpy.ContourGenerator.filled`. + fill_type (FillType or str): Type of ``filled`` data as returned by + :attr:`~contourpy.ContourGenerator.fill_type`, or a string equivalent. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot with. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"C0"``. + alpha (float, optional): Opacity to plot with, default ``0.7``. + """ + fill_type = as_fill_type(fill_type) + fig = self._get_figure(ax) + color = self._convert_color(color) + xs, ys = filled_to_bokeh(filled, fill_type) + if len(xs) > 0: + fig.multi_polygons(xs=[xs], ys=[ys], color=color, fill_alpha=alpha, line_width=0) + + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: figure | int = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + """Plot quad grid lines on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot grid lines, default ``"black"``. + alpha (float, optional): Opacity to plot lines with, default ``0.1``. + point_color (str, optional): Color to plot grid points or ``None`` if grid points + should not be plotted, default ``None``. + quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default + ``0``. + + Colors may be a string color or the letter ``"C"`` followed by an integer in the range + ``"C0"`` to ``"C9"`` to use a color from the ``Category10`` palette. + + Warning: + ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked. + """ + fig = self._get_figure(ax) + x, y = self._grid_as_2d(x, y) + xs = list(x) + list(x.T) + ys = list(y) + list(y.T) + kwargs = {"line_color": color, "alpha": alpha} + fig.multi_line(xs, ys, **kwargs) + if quad_as_tri_alpha > 0: + # Assumes no quad mask. + xmid = (0.25*(x[:-1, :-1] + x[1:, :-1] + x[:-1, 1:] + x[1:, 1:])).ravel() + ymid = (0.25*(y[:-1, :-1] + y[1:, :-1] + y[:-1, 1:] + y[1:, 1:])).ravel() + fig.multi_line( + list(np.stack((x[:-1, :-1].ravel(), xmid, x[1:, 1:].ravel()), axis=1)), + list(np.stack((y[:-1, :-1].ravel(), ymid, y[1:, 1:].ravel()), axis=1)), + **kwargs) + fig.multi_line( + list(np.stack((x[:-1, 1:].ravel(), xmid, x[1:, :-1].ravel()), axis=1)), + list(np.stack((y[:-1, 1:].ravel(), ymid, y[1:, :-1].ravel()), axis=1)), + **kwargs) + if point_color is not None: + fig.circle( + x=x.ravel(), y=y.ravel(), fill_color=color, line_color=None, alpha=alpha, size=8) + + def lines( + self, + lines: LineReturn, + line_type: LineType | str, + ax: figure | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + """Plot contour lines on a single plot. + + Args: + lines (sequence of arrays): Contour line data as returned by + :func:`~contourpy.ContourGenerator.lines`. + line_type (LineType or str): Type of ``lines`` data as returned by + :attr:`~contourpy.ContourGenerator.line_type`, or a string equivalent. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot lines. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"C0"``. + alpha (float, optional): Opacity to plot lines with, default ``1.0``. + linewidth (float, optional): Width of lines, default ``1``. + + Note: + Assumes all lines are open line strips not closed line loops. + """ + line_type = as_line_type(line_type) + fig = self._get_figure(ax) + color = self._convert_color(color) + xs, ys = lines_to_bokeh(lines, line_type) + if xs is not None: + fig.line(xs, ys, line_color=color, line_alpha=alpha, line_width=linewidth) + + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: figure | int = 0, + color: str = "black", + ) -> None: + """Plot masked out grid points as circles on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (masked array of shape (ny, nx): z-values. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Circle color, default ``"black"``. + """ + mask = np.ma.getmask(z) # type: ignore[no-untyped-call] + if mask is np.ma.nomask: + return + fig = self._get_figure(ax) + color = self._convert_color(color) + x, y = self._grid_as_2d(x, y) + fig.circle(x[mask], y[mask], fill_color=color, size=10) + + def save( + self, + filename: str, + transparent: bool = False, + *, + webdriver: WebDriver | None = None, + ) -> None: + """Save plots to SVG or PNG file. + + Args: + filename (str): Filename to save to. + transparent (bool, optional): Whether background should be transparent, default + ``False``. + webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image. + + .. versionadded:: 1.1.1 + + Warning: + To output to SVG file, ``want_svg=True`` must have been passed to the constructor. + """ + if transparent: + for fig in self._figures: + fig.background_fill_color = None # type: ignore[assignment] + fig.border_fill_color = None # type: ignore[assignment] + + if self._want_svg: + export_svg(self._layout, filename=filename, webdriver=webdriver) + else: + export_png(self._layout, filename=filename, webdriver=webdriver) + + def save_to_buffer(self, *, webdriver: WebDriver | None = None) -> io.BytesIO: + """Save plots to an ``io.BytesIO`` buffer. + + Args: + webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image. + + .. versionadded:: 1.1.1 + + Return: + BytesIO: PNG image buffer. + """ + image = get_screenshot_as_png(self._layout, driver=webdriver) + buffer = io.BytesIO() + image.save(buffer, "png") + return buffer + + def show(self) -> None: + """Show plots in web browser, in usual Bokeh manner. + """ + show(self._layout) + + def title(self, title: str, ax: figure | int = 0, color: str | None = None) -> None: + """Set the title of a single plot. + + Args: + title (str): Title text. + ax (int or Bokeh Figure, optional): Which plot to set the title of, default ``0``. + color (str, optional): Color to set title. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``None`` which is ``black``. + """ + fig = self._get_figure(ax) + fig.title = title # type: ignore[assignment] + fig.title.align = "center" # type: ignore[attr-defined] + if color is not None: + fig.title.text_color = self._convert_color(color) # type: ignore[attr-defined] + + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: figure | int = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + """Show ``z`` values on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (array-like of shape (ny, nx): z-values. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color of added text. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"green"``. + fmt (str, optional): Format to display z-values, default ``".1f"``. + quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centres + of quads. + + Warning: + ``quad_as_tri=True`` shows z-values for all quads, even if masked. + """ + fig = self._get_figure(ax) + color = self._convert_color(color) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + kwargs = {"text_color": color, "text_align": "center", "text_baseline": "middle"} + for j in range(ny): + for i in range(nx): + fig.add_layout(Label(x=x[j, i], y=y[j, i], text=f"{z[j, i]:{fmt}}", **kwargs)) + if quad_as_tri: + for j in range(ny-1): + for i in range(nx-1): + xx = np.mean(x[j:j+2, i:i+2]) + yy = np.mean(y[j:j+2, i:i+2]) + zz = np.mean(z[j:j+2, i:i+2]) + fig.add_layout(Label(x=xx, y=yy, text=f"{zz:{fmt}}", **kwargs)) diff --git a/venv/lib/python3.10/site-packages/contourpy/util/bokeh_util.py b/venv/lib/python3.10/site-packages/contourpy/util/bokeh_util.py new file mode 100644 index 00000000..e75eb844 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/bokeh_util.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, cast + +from contourpy import FillType, LineType +from contourpy.array import offsets_from_codes +from contourpy.convert import convert_lines +from contourpy.dechunk import dechunk_lines + +if TYPE_CHECKING: + from contourpy._contourpy import ( + CoordinateArray, + FillReturn, + LineReturn, + LineReturn_ChunkCombinedNan, + ) + + +def filled_to_bokeh( + filled: FillReturn, + fill_type: FillType, +) -> tuple[list[list[CoordinateArray]], list[list[CoordinateArray]]]: + xs: list[list[CoordinateArray]] = [] + ys: list[list[CoordinateArray]] = [] + if fill_type in (FillType.OuterOffset, FillType.ChunkCombinedOffset, + FillType.OuterCode, FillType.ChunkCombinedCode): + have_codes = fill_type in (FillType.OuterCode, FillType.ChunkCombinedCode) + + for points, offsets in zip(*filled): + if points is None: + continue + if have_codes: + offsets = offsets_from_codes(offsets) + xs.append([]) # New outer with zero or more holes. + ys.append([]) + for i in range(len(offsets)-1): + xys = points[offsets[i]:offsets[i+1]] + xs[-1].append(xys[:, 0]) + ys[-1].append(xys[:, 1]) + elif fill_type in (FillType.ChunkCombinedCodeOffset, FillType.ChunkCombinedOffsetOffset): + for points, codes_or_offsets, outer_offsets in zip(*filled): + if points is None: + continue + for j in range(len(outer_offsets)-1): + if fill_type == FillType.ChunkCombinedCodeOffset: + codes = codes_or_offsets[outer_offsets[j]:outer_offsets[j+1]] + offsets = offsets_from_codes(codes) + outer_offsets[j] + else: + offsets = codes_or_offsets[outer_offsets[j]:outer_offsets[j+1]+1] + xs.append([]) # New outer with zero or more holes. + ys.append([]) + for k in range(len(offsets)-1): + xys = points[offsets[k]:offsets[k+1]] + xs[-1].append(xys[:, 0]) + ys[-1].append(xys[:, 1]) + else: + raise RuntimeError(f"Conversion of FillType {fill_type} to Bokeh is not implemented") + + return xs, ys + + +def lines_to_bokeh( + lines: LineReturn, + line_type: LineType, +) -> tuple[CoordinateArray | None, CoordinateArray | None]: + lines = convert_lines(lines, line_type, LineType.ChunkCombinedNan) + lines = dechunk_lines(lines, LineType.ChunkCombinedNan) + if TYPE_CHECKING: + lines = cast(LineReturn_ChunkCombinedNan, lines) + points = lines[0][0] + if points is None: + return None, None + else: + return points[:, 0], points[:, 1] diff --git a/venv/lib/python3.10/site-packages/contourpy/util/data.py b/venv/lib/python3.10/site-packages/contourpy/util/data.py new file mode 100644 index 00000000..5ab26172 --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/data.py @@ -0,0 +1,78 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import numpy as np + +if TYPE_CHECKING: + from contourpy._contourpy import CoordinateArray + + +def simple( + shape: tuple[int, int], want_mask: bool = False, +) -> tuple[CoordinateArray, CoordinateArray, CoordinateArray | np.ma.MaskedArray[Any, Any]]: + """Return simple test data consisting of the sum of two gaussians. + + Args: + shape (tuple(int, int)): 2D shape of data to return. + want_mask (bool, optional): Whether test data should be masked or not, default ``False``. + + Return: + Tuple of 3 arrays: ``x``, ``y``, ``z`` test data, ``z`` will be masked if + ``want_mask=True``. + """ + ny, nx = shape + x = np.arange(nx, dtype=np.float64) + y = np.arange(ny, dtype=np.float64) + x, y = np.meshgrid(x, y) + + xscale = nx - 1.0 + yscale = ny - 1.0 + + # z is sum of 2D gaussians. + amp = np.asarray([1.0, -1.0, 0.8, -0.9, 0.7]) + mid = np.asarray([[0.4, 0.2], [0.3, 0.8], [0.9, 0.75], [0.7, 0.3], [0.05, 0.7]]) + width = np.asarray([0.4, 0.2, 0.2, 0.2, 0.1]) + + z = np.zeros_like(x) + for i in range(len(amp)): + z += amp[i]*np.exp(-((x/xscale - mid[i, 0])**2 + (y/yscale - mid[i, 1])**2) / width[i]**2) + + if want_mask: + mask = np.logical_or( + ((x/xscale - 1.0)**2 / 0.2 + (y/yscale - 0.0)**2 / 0.1) < 1.0, + ((x/xscale - 0.2)**2 / 0.02 + (y/yscale - 0.45)**2 / 0.08) < 1.0, + ) + z = np.ma.array(z, mask=mask) # type: ignore[no-untyped-call] + + return x, y, z + + +def random( + shape: tuple[int, int], seed: int = 2187, mask_fraction: float = 0.0, +) -> tuple[CoordinateArray, CoordinateArray, CoordinateArray | np.ma.MaskedArray[Any, Any]]: + """Return random test data. + + Args: + shape (tuple(int, int)): 2D shape of data to return. + seed (int, optional): Seed for random number generator, default 2187. + mask_fraction (float, optional): Fraction of elements to mask, default 0. + + Return: + Tuple of 3 arrays: ``x``, ``y``, ``z`` test data, ``z`` will be masked if + ``mask_fraction`` is greater than zero. + """ + ny, nx = shape + x = np.arange(nx, dtype=np.float64) + y = np.arange(ny, dtype=np.float64) + x, y = np.meshgrid(x, y) + + rng = np.random.default_rng(seed) + z = rng.uniform(size=shape) + + if mask_fraction > 0.0: + mask_fraction = min(mask_fraction, 0.99) + mask = rng.uniform(size=shape) < mask_fraction + z = np.ma.array(z, mask=mask) # type: ignore[no-untyped-call] + + return x, y, z diff --git a/venv/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py b/venv/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py new file mode 100644 index 00000000..c459e02a --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py @@ -0,0 +1,534 @@ +from __future__ import annotations + +import io +from typing import TYPE_CHECKING, Any, cast + +import matplotlib.collections as mcollections +import matplotlib.pyplot as plt +import numpy as np + +from contourpy import FillType, LineType +from contourpy.convert import convert_filled, convert_lines +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.util.mpl_util import filled_to_mpl_paths, lines_to_mpl_paths +from contourpy.util.renderer import Renderer + +if TYPE_CHECKING: + from collections.abc import Sequence + + from matplotlib.axes import Axes + from matplotlib.figure import Figure + from numpy.typing import ArrayLike + + import contourpy._contourpy as cpy + + +class MplRenderer(Renderer): + """Utility renderer using Matplotlib to render a grid of plots over the same (x, y) range. + + Args: + nrows (int, optional): Number of rows of plots, default ``1``. + ncols (int, optional): Number of columns of plots, default ``1``. + figsize (tuple(float, float), optional): Figure size in inches, default ``(9, 9)``. + show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``. + backend (str, optional): Matplotlib backend to use or ``None`` for default backend. + Default ``None``. + gridspec_kw (dict, optional): Gridspec keyword arguments to pass to ``plt.subplots``, + default None. + """ + _axes: Sequence[Axes] + _fig: Figure + _want_tight: bool + + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + backend: str | None = None, + gridspec_kw: dict[str, Any] | None = None, + ) -> None: + if backend is not None: + import matplotlib as mpl + mpl.use(backend) + + kwargs: dict[str, Any] = {"figsize": figsize, "squeeze": False, + "sharex": True, "sharey": True} + if gridspec_kw is not None: + kwargs["gridspec_kw"] = gridspec_kw + else: + kwargs["subplot_kw"] = {"aspect": "equal"} + + self._fig, axes = plt.subplots(nrows, ncols, **kwargs) + self._axes = axes.flatten() + if not show_frame: + for ax in self._axes: + ax.axis("off") + + self._want_tight = True + + def __del__(self) -> None: + if hasattr(self, "_fig"): + plt.close(self._fig) + + def _autoscale(self) -> None: + # Using axes._need_autoscale attribute if need to autoscale before rendering after adding + # lines/filled. Only want to autoscale once per axes regardless of how many lines/filled + # added. + for ax in self._axes: + if getattr(ax, "_need_autoscale", False): + ax.autoscale_view(tight=True) + ax._need_autoscale = False # type: ignore[attr-defined] + if self._want_tight and len(self._axes) > 1: + self._fig.tight_layout() + + def _get_ax(self, ax: Axes | int) -> Axes: + if isinstance(ax, int): + ax = self._axes[ax] + return ax + + def filled( + self, + filled: cpy.FillReturn, + fill_type: FillType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + """Plot filled contours on a single Axes. + + Args: + filled (sequence of arrays): Filled contour data as returned by + :func:`~contourpy.ContourGenerator.filled`. + fill_type (FillType or str): Type of ``filled`` data as returned by + :attr:`~contourpy.ContourGenerator.fill_type`, or string equivalent + ax (int or Maplotlib Axes, optional): Which axes to plot on, default ``0``. + color (str, optional): Color to plot with. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"C0"``. + alpha (float, optional): Opacity to plot with, default ``0.7``. + """ + fill_type = as_fill_type(fill_type) + ax = self._get_ax(ax) + paths = filled_to_mpl_paths(filled, fill_type) + collection = mcollections.PathCollection( + paths, facecolors=color, edgecolors="none", lw=0, alpha=alpha) + ax.add_collection(collection) + ax._need_autoscale = True # type: ignore[attr-defined] + + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: Axes | int = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + """Plot quad grid lines on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color to plot grid lines, default ``"black"``. + alpha (float, optional): Opacity to plot lines with, default ``0.1``. + point_color (str, optional): Color to plot grid points or ``None`` if grid points + should not be plotted, default ``None``. + quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default 0. + + Colors may be a string color or the letter ``"C"`` followed by an integer in the range + ``"C0"`` to ``"C9"`` to use a color from the ``tab10`` colormap. + + Warning: + ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked. + """ + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + kwargs: dict[str, Any] = {"color": color, "alpha": alpha} + ax.plot(x, y, x.T, y.T, **kwargs) + if quad_as_tri_alpha > 0: + # Assumes no quad mask. + xmid = 0.25*(x[:-1, :-1] + x[1:, :-1] + x[:-1, 1:] + x[1:, 1:]) + ymid = 0.25*(y[:-1, :-1] + y[1:, :-1] + y[:-1, 1:] + y[1:, 1:]) + kwargs["alpha"] = quad_as_tri_alpha + ax.plot( + np.stack((x[:-1, :-1], xmid, x[1:, 1:])).reshape((3, -1)), + np.stack((y[:-1, :-1], ymid, y[1:, 1:])).reshape((3, -1)), + np.stack((x[1:, :-1], xmid, x[:-1, 1:])).reshape((3, -1)), + np.stack((y[1:, :-1], ymid, y[:-1, 1:])).reshape((3, -1)), + **kwargs) + if point_color is not None: + ax.plot(x, y, color=point_color, alpha=alpha, marker="o", lw=0) + ax._need_autoscale = True # type: ignore[attr-defined] + + def lines( + self, + lines: cpy.LineReturn, + line_type: LineType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + """Plot contour lines on a single Axes. + + Args: + lines (sequence of arrays): Contour line data as returned by + :func:`~contourpy.ContourGenerator.lines`. + line_type (LineType or str): Type of ``lines`` data as returned by + :attr:`~contourpy.ContourGenerator.line_type`, or string equivalent. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color to plot lines. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"C0"``. + alpha (float, optional): Opacity to plot lines with, default ``1.0``. + linewidth (float, optional): Width of lines, default ``1``. + """ + line_type = as_line_type(line_type) + ax = self._get_ax(ax) + paths = lines_to_mpl_paths(lines, line_type) + collection = mcollections.PathCollection( + paths, facecolors="none", edgecolors=color, lw=linewidth, alpha=alpha) + ax.add_collection(collection) + ax._need_autoscale = True # type: ignore[attr-defined] + + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: Axes | int = 0, + color: str = "black", + ) -> None: + """Plot masked out grid points as circles on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (masked array of shape (ny, nx): z-values. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Circle color, default ``"black"``. + """ + mask = np.ma.getmask(z) # type: ignore[no-untyped-call] + if mask is np.ma.nomask: + return + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + ax.plot(x[mask], y[mask], "o", c=color) + + def save(self, filename: str, transparent: bool = False) -> None: + """Save plots to SVG or PNG file. + + Args: + filename (str): Filename to save to. + transparent (bool, optional): Whether background should be transparent, default + ``False``. + """ + self._autoscale() + self._fig.savefig(filename, transparent=transparent) + + def save_to_buffer(self) -> io.BytesIO: + """Save plots to an ``io.BytesIO`` buffer. + + Return: + BytesIO: PNG image buffer. + """ + self._autoscale() + buf = io.BytesIO() + self._fig.savefig(buf, format="png") + buf.seek(0) + return buf + + def show(self) -> None: + """Show plots in an interactive window, in the usual Matplotlib manner. + """ + self._autoscale() + plt.show() + + def title(self, title: str, ax: Axes | int = 0, color: str | None = None) -> None: + """Set the title of a single Axes. + + Args: + title (str): Title text. + ax (int or Matplotlib Axes, optional): Which Axes to set the title of, default ``0``. + color (str, optional): Color to set title. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default is ``None`` which uses Matplotlib's default title color + that depends on the stylesheet in use. + """ + if color: + self._get_ax(ax).set_title(title, color=color) + else: + self._get_ax(ax).set_title(title) + + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + """Show ``z`` values on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (array-like of shape (ny, nx): z-values. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color of added text. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"green"``. + fmt (str, optional): Format to display z-values, default ``".1f"``. + quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centers + of quads. + + Warning: + ``quad_as_tri=True`` shows z-values for all quads, even if masked. + """ + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + ax.text(x[j, i], y[j, i], f"{z[j, i]:{fmt}}", ha="center", va="center", + color=color, clip_on=True) + if quad_as_tri: + for j in range(ny-1): + for i in range(nx-1): + xx = np.mean(x[j:j+2, i:i+2]) + yy = np.mean(y[j:j+2, i:i+2]) + zz = np.mean(z[j:j+2, i:i+2]) + ax.text(xx, yy, f"{zz:{fmt}}", ha="center", va="center", color=color, + clip_on=True) + + +class MplTestRenderer(MplRenderer): + """Test renderer implemented using Matplotlib. + + No whitespace around plots and no spines/ticks displayed. + Uses Agg backend, so can only save to file/buffer, cannot call ``show()``. + """ + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + ) -> None: + gridspec = { + "left": 0.01, + "right": 0.99, + "top": 0.99, + "bottom": 0.01, + "wspace": 0.01, + "hspace": 0.01, + } + super().__init__( + nrows, ncols, figsize, show_frame=True, backend="Agg", gridspec_kw=gridspec, + ) + + for ax in self._axes: + ax.set_xmargin(0.0) + ax.set_ymargin(0.0) + ax.set_xticks([]) + ax.set_yticks([]) + + self._want_tight = False + + +class MplDebugRenderer(MplRenderer): + """Debug renderer implemented using Matplotlib. + + Extends ``MplRenderer`` to add extra information to help in debugging such as markers, arrows, + text, etc. + """ + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + ) -> None: + super().__init__(nrows, ncols, figsize, show_frame) + + def _arrow( + self, + ax: Axes, + line_start: cpy.CoordinateArray, + line_end: cpy.CoordinateArray, + color: str, + alpha: float, + arrow_size: float, + ) -> None: + mid = 0.5*(line_start + line_end) + along = line_end - line_start + along /= np.sqrt(np.dot(along, along)) # Unit vector. + right = np.asarray((along[1], -along[0])) + arrow = np.stack(( + mid - (along*0.5 - right)*arrow_size, + mid + along*0.5*arrow_size, + mid - (along*0.5 + right)*arrow_size, + )) + ax.plot(arrow[:, 0], arrow[:, 1], "-", c=color, alpha=alpha) + + def filled( + self, + filled: cpy.FillReturn, + fill_type: FillType | str, + ax: Axes | int = 0, + color: str = "C1", + alpha: float = 0.7, + line_color: str = "C0", + line_alpha: float = 0.7, + point_color: str = "C0", + start_point_color: str = "red", + arrow_size: float = 0.1, + ) -> None: + fill_type = as_fill_type(fill_type) + super().filled(filled, fill_type, ax, color, alpha) + + if line_color is None and point_color is None: + return + + ax = self._get_ax(ax) + filled = convert_filled(filled, fill_type, FillType.ChunkCombinedOffset) + + # Lines. + if line_color is not None: + for points, offsets in zip(*filled): + if points is None: + continue + for start, end in zip(offsets[:-1], offsets[1:]): + xys = points[start:end] + ax.plot(xys[:, 0], xys[:, 1], c=line_color, alpha=line_alpha) + + if arrow_size > 0.0: + n = len(xys) + for i in range(n-1): + self._arrow(ax, xys[i], xys[i+1], line_color, line_alpha, arrow_size) + + # Points. + if point_color is not None: + for points, offsets in zip(*filled): + if points is None: + continue + mask = np.ones(offsets[-1], dtype=bool) + mask[offsets[1:]-1] = False # Exclude end points. + if start_point_color is not None: + start_indices = offsets[:-1] + mask[start_indices] = False # Exclude start points. + ax.plot( + points[:, 0][mask], points[:, 1][mask], "o", c=point_color, alpha=line_alpha) + + if start_point_color is not None: + ax.plot(points[:, 0][start_indices], points[:, 1][start_indices], "o", + c=start_point_color, alpha=line_alpha) + + def lines( + self, + lines: cpy.LineReturn, + line_type: LineType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + point_color: str = "C0", + start_point_color: str = "red", + arrow_size: float = 0.1, + ) -> None: + line_type = as_line_type(line_type) + super().lines(lines, line_type, ax, color, alpha, linewidth) + + if arrow_size == 0.0 and point_color is None: + return + + ax = self._get_ax(ax) + separate_lines = convert_lines(lines, line_type, LineType.Separate) + if TYPE_CHECKING: + separate_lines = cast(cpy.LineReturn_Separate, separate_lines) + + if arrow_size > 0.0: + for line in separate_lines: + for i in range(len(line)-1): + self._arrow(ax, line[i], line[i+1], color, alpha, arrow_size) + + if point_color is not None: + for line in separate_lines: + start_index = 0 + end_index = len(line) + if start_point_color is not None: + ax.plot(line[0, 0], line[0, 1], "o", c=start_point_color, alpha=alpha) + start_index = 1 + if line[0][0] == line[-1][0] and line[0][1] == line[-1][1]: + end_index -= 1 + ax.plot(line[start_index:end_index, 0], line[start_index:end_index, 1], "o", + c=color, alpha=alpha) + + def point_numbers( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "red", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + quad = i + j*nx + ax.text(x[j, i], y[j, i], str(quad), ha="right", va="top", color=color, + clip_on=True) + + def quad_numbers( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "blue", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(1, ny): + for i in range(1, nx): + quad = i + j*nx + xmid = x[j-1:j+1, i-1:i+1].mean() + ymid = y[j-1:j+1, i-1:i+1].mean() + ax.text(xmid, ymid, str(quad), ha="center", va="center", color=color, clip_on=True) + + def z_levels( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + lower_level: float, + upper_level: float | None = None, + ax: Axes | int = 0, + color: str = "green", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + zz = z[j, i] + if upper_level is not None and zz > upper_level: + z_level = 2 + elif zz > lower_level: + z_level = 1 + else: + z_level = 0 + ax.text(x[j, i], y[j, i], str(z_level), ha="left", va="bottom", color=color, + clip_on=True) diff --git a/venv/lib/python3.10/site-packages/contourpy/util/mpl_util.py b/venv/lib/python3.10/site-packages/contourpy/util/mpl_util.py new file mode 100644 index 00000000..10a2ccdb --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/mpl_util.py @@ -0,0 +1,76 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, cast + +import matplotlib.path as mpath +import numpy as np + +from contourpy import FillType, LineType +from contourpy.array import codes_from_offsets + +if TYPE_CHECKING: + from contourpy._contourpy import FillReturn, LineReturn, LineReturn_Separate + + +def filled_to_mpl_paths(filled: FillReturn, fill_type: FillType) -> list[mpath.Path]: + if fill_type in (FillType.OuterCode, FillType.ChunkCombinedCode): + paths = [mpath.Path(points, codes) for points, codes in zip(*filled) if points is not None] + elif fill_type in (FillType.OuterOffset, FillType.ChunkCombinedOffset): + paths = [mpath.Path(points, codes_from_offsets(offsets)) + for points, offsets in zip(*filled) if points is not None] + elif fill_type == FillType.ChunkCombinedCodeOffset: + paths = [] + for points, codes, outer_offsets in zip(*filled): + if points is None: + continue + points = np.split(points, outer_offsets[1:-1]) + codes = np.split(codes, outer_offsets[1:-1]) + paths += [mpath.Path(p, c) for p, c in zip(points, codes)] + elif fill_type == FillType.ChunkCombinedOffsetOffset: + paths = [] + for points, offsets, outer_offsets in zip(*filled): + if points is None: + continue + for i in range(len(outer_offsets)-1): + offs = offsets[outer_offsets[i]:outer_offsets[i+1]+1] + pts = points[offs[0]:offs[-1]] + paths += [mpath.Path(pts, codes_from_offsets(offs - offs[0]))] + else: + raise RuntimeError(f"Conversion of FillType {fill_type} to MPL Paths is not implemented") + return paths + + +def lines_to_mpl_paths(lines: LineReturn, line_type: LineType) -> list[mpath.Path]: + if line_type == LineType.Separate: + if TYPE_CHECKING: + lines = cast(LineReturn_Separate, lines) + paths = [] + for line in lines: + # Drawing as Paths so that they can be closed correctly. + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + elif line_type in (LineType.SeparateCode, LineType.ChunkCombinedCode): + paths = [mpath.Path(points, codes) for points, codes in zip(*lines) if points is not None] + elif line_type == LineType.ChunkCombinedOffset: + paths = [] + for points, offsets in zip(*lines): + if points is None: + continue + for i in range(len(offsets)-1): + line = points[offsets[i]:offsets[i+1]] + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + elif line_type == LineType.ChunkCombinedNan: + paths = [] + for points in lines[0]: + if points is None: + continue + nan_offsets = np.nonzero(np.isnan(points[:, 0]))[0] + nan_offsets = np.concatenate([[-1], nan_offsets, [len(points)]]) + for s, e in zip(nan_offsets[:-1], nan_offsets[1:]): + line = points[s+1:e] + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + else: + raise RuntimeError(f"Conversion of LineType {line_type} to MPL Paths is not implemented") + return paths diff --git a/venv/lib/python3.10/site-packages/contourpy/util/renderer.py b/venv/lib/python3.10/site-packages/contourpy/util/renderer.py new file mode 100644 index 00000000..f4bdfdff --- /dev/null +++ b/venv/lib/python3.10/site-packages/contourpy/util/renderer.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import TYPE_CHECKING, Any + +import numpy as np + +if TYPE_CHECKING: + import io + + from numpy.typing import ArrayLike + + from contourpy._contourpy import CoordinateArray, FillReturn, FillType, LineReturn, LineType + + +class Renderer(ABC): + """Abstract base class for renderers, defining the interface that they must implement.""" + + def _grid_as_2d(self, x: ArrayLike, y: ArrayLike) -> tuple[CoordinateArray, CoordinateArray]: + x = np.asarray(x) + y = np.asarray(y) + if x.ndim == 1: + x, y = np.meshgrid(x, y) + return x, y + + x = np.asarray(x) + y = np.asarray(y) + if x.ndim == 1: + x, y = np.meshgrid(x, y) + return x, y + + @abstractmethod + def filled( + self, + filled: FillReturn, + fill_type: FillType | str, + ax: Any = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + pass + + @abstractmethod + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: Any = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + pass + + @abstractmethod + def lines( + self, + lines: LineReturn, + line_type: LineType | str, + ax: Any = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + pass + + @abstractmethod + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: Any = 0, + color: str = "black", + ) -> None: + pass + + @abstractmethod + def save(self, filename: str, transparent: bool = False) -> None: + pass + + @abstractmethod + def save_to_buffer(self) -> io.BytesIO: + pass + + @abstractmethod + def show(self) -> None: + pass + + @abstractmethod + def title(self, title: str, ax: Any = 0, color: str | None = None) -> None: + pass + + @abstractmethod + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Any = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + pass diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/INSTALLER b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/INSTALLER new file mode 100644 index 00000000..a1b589e3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/LICENSE b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/LICENSE new file mode 100644 index 00000000..d41d8089 --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2015, matplotlib project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the matplotlib project nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/METADATA b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/METADATA new file mode 100644 index 00000000..e81ab4fa --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/METADATA @@ -0,0 +1,78 @@ +Metadata-Version: 2.1 +Name: cycler +Version: 0.12.1 +Summary: Composable style cycles +Author-email: Thomas A Caswell +License: Copyright (c) 2015, matplotlib project + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the matplotlib project nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Project-URL: homepage, https://matplotlib.org/cycler/ +Project-URL: repository, https://github.com/matplotlib/cycler +Keywords: cycle kwargs +Classifier: License :: OSI Approved :: BSD License +Classifier: Development Status :: 4 - Beta +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 +Classifier: Programming Language :: Python :: 3 :: Only +Requires-Python: >=3.8 +Description-Content-Type: text/x-rst +License-File: LICENSE +Provides-Extra: docs +Requires-Dist: ipython ; extra == 'docs' +Requires-Dist: matplotlib ; extra == 'docs' +Requires-Dist: numpydoc ; extra == 'docs' +Requires-Dist: sphinx ; extra == 'docs' +Provides-Extra: tests +Requires-Dist: pytest ; extra == 'tests' +Requires-Dist: pytest-cov ; extra == 'tests' +Requires-Dist: pytest-xdist ; extra == 'tests' + +|PyPi|_ |Conda|_ |Supported Python versions|_ |GitHub Actions|_ |Codecov|_ + +.. |PyPi| image:: https://img.shields.io/pypi/v/cycler.svg?style=flat +.. _PyPi: https://pypi.python.org/pypi/cycler + +.. |Conda| image:: https://img.shields.io/conda/v/conda-forge/cycler +.. _Conda: https://anaconda.org/conda-forge/cycler + +.. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/cycler.svg +.. _Supported Python versions: https://pypi.python.org/pypi/cycler + +.. |GitHub Actions| image:: https://github.com/matplotlib/cycler/actions/workflows/tests.yml/badge.svg +.. _GitHub Actions: https://github.com/matplotlib/cycler/actions + +.. |Codecov| image:: https://codecov.io/github/matplotlib/cycler/badge.svg?branch=main&service=github +.. _Codecov: https://codecov.io/github/matplotlib/cycler?branch=main + +cycler: composable cycles +========================= + +Docs: https://matplotlib.org/cycler/ diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/RECORD b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/RECORD new file mode 100644 index 00000000..c286b78e --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/RECORD @@ -0,0 +1,9 @@ +cycler-0.12.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +cycler-0.12.1.dist-info/LICENSE,sha256=8SGBQ9dm2j_qZvEzlrfxXfRqgzA_Kb-Wum6Y601C9Ag,1497 +cycler-0.12.1.dist-info/METADATA,sha256=IyieGbdvHgE5Qidpbmryts0c556JcxIJv5GVFIsY7TY,3779 +cycler-0.12.1.dist-info/RECORD,, +cycler-0.12.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92 +cycler-0.12.1.dist-info/top_level.txt,sha256=D8BVVDdAAelLb2FOEz7lDpc6-AL21ylKPrMhtG6yzyE,7 +cycler/__init__.py,sha256=1JdRgv5Zzxo-W1ev7B_LWquysWP6LZH6CHk_COtIaXE,16709 +cycler/__pycache__/__init__.cpython-310.pyc,, +cycler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/WHEEL b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/WHEEL new file mode 100644 index 00000000..7e688737 --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/WHEEL @@ -0,0 +1,5 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.41.2) +Root-Is-Purelib: true +Tag: py3-none-any + diff --git a/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/top_level.txt b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/top_level.txt new file mode 100644 index 00000000..22546440 --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler-0.12.1.dist-info/top_level.txt @@ -0,0 +1 @@ +cycler diff --git a/venv/lib/python3.10/site-packages/cycler/__init__.py b/venv/lib/python3.10/site-packages/cycler/__init__.py new file mode 100644 index 00000000..97949547 --- /dev/null +++ b/venv/lib/python3.10/site-packages/cycler/__init__.py @@ -0,0 +1,573 @@ +""" +Cycler +====== + +Cycling through combinations of values, producing dictionaries. + +You can add cyclers:: + + from cycler import cycler + cc = (cycler(color=list('rgb')) + + cycler(linestyle=['-', '--', '-.'])) + for d in cc: + print(d) + +Results in:: + + {'color': 'r', 'linestyle': '-'} + {'color': 'g', 'linestyle': '--'} + {'color': 'b', 'linestyle': '-.'} + + +You can multiply cyclers:: + + from cycler import cycler + cc = (cycler(color=list('rgb')) * + cycler(linestyle=['-', '--', '-.'])) + for d in cc: + print(d) + +Results in:: + + {'color': 'r', 'linestyle': '-'} + {'color': 'r', 'linestyle': '--'} + {'color': 'r', 'linestyle': '-.'} + {'color': 'g', 'linestyle': '-'} + {'color': 'g', 'linestyle': '--'} + {'color': 'g', 'linestyle': '-.'} + {'color': 'b', 'linestyle': '-'} + {'color': 'b', 'linestyle': '--'} + {'color': 'b', 'linestyle': '-.'} +""" + + +from __future__ import annotations + +from collections.abc import Hashable, Iterable, Generator +import copy +from functools import reduce +from itertools import product, cycle +from operator import mul, add +# Dict, List, Union required for runtime cast calls +from typing import TypeVar, Generic, Callable, Union, Dict, List, Any, overload, cast + +__version__ = "0.12.1" + +K = TypeVar("K", bound=Hashable) +L = TypeVar("L", bound=Hashable) +V = TypeVar("V") +U = TypeVar("U") + + +def _process_keys( + left: Cycler[K, V] | Iterable[dict[K, V]], + right: Cycler[K, V] | Iterable[dict[K, V]] | None, +) -> set[K]: + """ + Helper function to compose cycler keys. + + Parameters + ---------- + left, right : iterable of dictionaries or None + The cyclers to be composed. + + Returns + ------- + keys : set + The keys in the composition of the two cyclers. + """ + l_peek: dict[K, V] = next(iter(left)) if left != [] else {} + r_peek: dict[K, V] = next(iter(right)) if right is not None else {} + l_key: set[K] = set(l_peek.keys()) + r_key: set[K] = set(r_peek.keys()) + if l_key & r_key: + raise ValueError("Can not compose overlapping cycles") + return l_key | r_key + + +def concat(left: Cycler[K, V], right: Cycler[K, U]) -> Cycler[K, V | U]: + r""" + Concatenate `Cycler`\s, as if chained using `itertools.chain`. + + The keys must match exactly. + + Examples + -------- + >>> num = cycler('a', range(3)) + >>> let = cycler('a', 'abc') + >>> num.concat(let) + cycler('a', [0, 1, 2, 'a', 'b', 'c']) + + Returns + ------- + `Cycler` + The concatenated cycler. + """ + if left.keys != right.keys: + raise ValueError( + "Keys do not match:\n" + "\tIntersection: {both!r}\n" + "\tDisjoint: {just_one!r}".format( + both=left.keys & right.keys, just_one=left.keys ^ right.keys + ) + ) + _l = cast(Dict[K, List[Union[V, U]]], left.by_key()) + _r = cast(Dict[K, List[Union[V, U]]], right.by_key()) + return reduce(add, (_cycler(k, _l[k] + _r[k]) for k in left.keys)) + + +class Cycler(Generic[K, V]): + """ + Composable cycles. + + This class has compositions methods: + + ``+`` + for 'inner' products (zip) + + ``+=`` + in-place ``+`` + + ``*`` + for outer products (`itertools.product`) and integer multiplication + + ``*=`` + in-place ``*`` + + and supports basic slicing via ``[]``. + + Parameters + ---------- + left, right : Cycler or None + The 'left' and 'right' cyclers. + op : func or None + Function which composes the 'left' and 'right' cyclers. + """ + + def __call__(self): + return cycle(self) + + def __init__( + self, + left: Cycler[K, V] | Iterable[dict[K, V]] | None, + right: Cycler[K, V] | None = None, + op: Any = None, + ): + """ + Semi-private init. + + Do not use this directly, use `cycler` function instead. + """ + if isinstance(left, Cycler): + self._left: Cycler[K, V] | list[dict[K, V]] = Cycler( + left._left, left._right, left._op + ) + elif left is not None: + # Need to copy the dictionary or else that will be a residual + # mutable that could lead to strange errors + self._left = [copy.copy(v) for v in left] + else: + self._left = [] + + if isinstance(right, Cycler): + self._right: Cycler[K, V] | None = Cycler( + right._left, right._right, right._op + ) + else: + self._right = None + + self._keys: set[K] = _process_keys(self._left, self._right) + self._op: Any = op + + def __contains__(self, k): + return k in self._keys + + @property + def keys(self) -> set[K]: + """The keys this Cycler knows about.""" + return set(self._keys) + + def change_key(self, old: K, new: K) -> None: + """ + Change a key in this cycler to a new name. + Modification is performed in-place. + + Does nothing if the old key is the same as the new key. + Raises a ValueError if the new key is already a key. + Raises a KeyError if the old key isn't a key. + """ + if old == new: + return + if new in self._keys: + raise ValueError( + f"Can't replace {old} with {new}, {new} is already a key" + ) + if old not in self._keys: + raise KeyError( + f"Can't replace {old} with {new}, {old} is not a key" + ) + + self._keys.remove(old) + self._keys.add(new) + + if self._right is not None and old in self._right.keys: + self._right.change_key(old, new) + + # self._left should always be non-None + # if self._keys is non-empty. + elif isinstance(self._left, Cycler): + self._left.change_key(old, new) + else: + # It should be completely safe at this point to + # assume that the old key can be found in each + # iteration. + self._left = [{new: entry[old]} for entry in self._left] + + @classmethod + def _from_iter(cls, label: K, itr: Iterable[V]) -> Cycler[K, V]: + """ + Class method to create 'base' Cycler objects + that do not have a 'right' or 'op' and for which + the 'left' object is not another Cycler. + + Parameters + ---------- + label : hashable + The property key. + + itr : iterable + Finite length iterable of the property values. + + Returns + ------- + `Cycler` + New 'base' cycler. + """ + ret: Cycler[K, V] = cls(None) + ret._left = list({label: v} for v in itr) + ret._keys = {label} + return ret + + def __getitem__(self, key: slice) -> Cycler[K, V]: + # TODO : maybe add numpy style fancy slicing + if isinstance(key, slice): + trans = self.by_key() + return reduce(add, (_cycler(k, v[key]) for k, v in trans.items())) + else: + raise ValueError("Can only use slices with Cycler.__getitem__") + + def __iter__(self) -> Generator[dict[K, V], None, None]: + if self._right is None: + for left in self._left: + yield dict(left) + else: + if self._op is None: + raise TypeError( + "Operation cannot be None when both left and right are defined" + ) + for a, b in self._op(self._left, self._right): + out = {} + out.update(a) + out.update(b) + yield out + + def __add__(self, other: Cycler[L, U]) -> Cycler[K | L, V | U]: + """ + Pair-wise combine two equal length cyclers (zip). + + Parameters + ---------- + other : Cycler + """ + if len(self) != len(other): + raise ValueError( + f"Can only add equal length cycles, not {len(self)} and {len(other)}" + ) + return Cycler( + cast(Cycler[Union[K, L], Union[V, U]], self), + cast(Cycler[Union[K, L], Union[V, U]], other), + zip + ) + + @overload + def __mul__(self, other: Cycler[L, U]) -> Cycler[K | L, V | U]: + ... + + @overload + def __mul__(self, other: int) -> Cycler[K, V]: + ... + + def __mul__(self, other): + """ + Outer product of two cyclers (`itertools.product`) or integer + multiplication. + + Parameters + ---------- + other : Cycler or int + """ + if isinstance(other, Cycler): + return Cycler( + cast(Cycler[Union[K, L], Union[V, U]], self), + cast(Cycler[Union[K, L], Union[V, U]], other), + product + ) + elif isinstance(other, int): + trans = self.by_key() + return reduce( + add, (_cycler(k, v * other) for k, v in trans.items()) + ) + else: + return NotImplemented + + @overload + def __rmul__(self, other: Cycler[L, U]) -> Cycler[K | L, V | U]: + ... + + @overload + def __rmul__(self, other: int) -> Cycler[K, V]: + ... + + def __rmul__(self, other): + return self * other + + def __len__(self) -> int: + op_dict: dict[Callable, Callable[[int, int], int]] = {zip: min, product: mul} + if self._right is None: + return len(self._left) + l_len = len(self._left) + r_len = len(self._right) + return op_dict[self._op](l_len, r_len) + + # iadd and imul do not exapand the the type as the returns must be consistent with + # self, thus they flag as inconsistent with add/mul + def __iadd__(self, other: Cycler[K, V]) -> Cycler[K, V]: # type: ignore[misc] + """ + In-place pair-wise combine two equal length cyclers (zip). + + Parameters + ---------- + other : Cycler + """ + if not isinstance(other, Cycler): + raise TypeError("Cannot += with a non-Cycler object") + # True shallow copy of self is fine since this is in-place + old_self = copy.copy(self) + self._keys = _process_keys(old_self, other) + self._left = old_self + self._op = zip + self._right = Cycler(other._left, other._right, other._op) + return self + + def __imul__(self, other: Cycler[K, V] | int) -> Cycler[K, V]: # type: ignore[misc] + """ + In-place outer product of two cyclers (`itertools.product`). + + Parameters + ---------- + other : Cycler + """ + if not isinstance(other, Cycler): + raise TypeError("Cannot *= with a non-Cycler object") + # True shallow copy of self is fine since this is in-place + old_self = copy.copy(self) + self._keys = _process_keys(old_self, other) + self._left = old_self + self._op = product + self._right = Cycler(other._left, other._right, other._op) + return self + + def __eq__(self, other: object) -> bool: + if not isinstance(other, Cycler): + return False + if len(self) != len(other): + return False + if self.keys ^ other.keys: + return False + return all(a == b for a, b in zip(self, other)) + + __hash__ = None # type: ignore + + def __repr__(self) -> str: + op_map = {zip: "+", product: "*"} + if self._right is None: + lab = self.keys.pop() + itr = list(v[lab] for v in self) + return f"cycler({lab!r}, {itr!r})" + else: + op = op_map.get(self._op, "?") + msg = "({left!r} {op} {right!r})" + return msg.format(left=self._left, op=op, right=self._right) + + def _repr_html_(self) -> str: + # an table showing the value of each key through a full cycle + output = "" + sorted_keys = sorted(self.keys, key=repr) + for key in sorted_keys: + output += f"" + for d in iter(self): + output += "" + for k in sorted_keys: + output += f"" + output += "" + output += "
{key!r}
{d[k]!r}
" + return output + + def by_key(self) -> dict[K, list[V]]: + """ + Values by key. + + This returns the transposed values of the cycler. Iterating + over a `Cycler` yields dicts with a single value for each key, + this method returns a `dict` of `list` which are the values + for the given key. + + The returned value can be used to create an equivalent `Cycler` + using only `+`. + + Returns + ------- + transpose : dict + dict of lists of the values for each key. + """ + + # TODO : sort out if this is a bottle neck, if there is a better way + # and if we care. + + keys = self.keys + out: dict[K, list[V]] = {k: list() for k in keys} + + for d in self: + for k in keys: + out[k].append(d[k]) + return out + + # for back compatibility + _transpose = by_key + + def simplify(self) -> Cycler[K, V]: + """ + Simplify the cycler into a sum (but no products) of cyclers. + + Returns + ------- + simple : Cycler + """ + # TODO: sort out if it is worth the effort to make sure this is + # balanced. Currently it is is + # (((a + b) + c) + d) vs + # ((a + b) + (c + d)) + # I would believe that there is some performance implications + trans = self.by_key() + return reduce(add, (_cycler(k, v) for k, v in trans.items())) + + concat = concat + + +@overload +def cycler(arg: Cycler[K, V]) -> Cycler[K, V]: + ... + + +@overload +def cycler(**kwargs: Iterable[V]) -> Cycler[str, V]: + ... + + +@overload +def cycler(label: K, itr: Iterable[V]) -> Cycler[K, V]: + ... + + +def cycler(*args, **kwargs): + """ + Create a new `Cycler` object from a single positional argument, + a pair of positional arguments, or the combination of keyword arguments. + + cycler(arg) + cycler(label1=itr1[, label2=iter2[, ...]]) + cycler(label, itr) + + Form 1 simply copies a given `Cycler` object. + + Form 2 composes a `Cycler` as an inner product of the + pairs of keyword arguments. In other words, all of the + iterables are cycled simultaneously, as if through zip(). + + Form 3 creates a `Cycler` from a label and an iterable. + This is useful for when the label cannot be a keyword argument + (e.g., an integer or a name that has a space in it). + + Parameters + ---------- + arg : Cycler + Copy constructor for Cycler (does a shallow copy of iterables). + label : name + The property key. In the 2-arg form of the function, + the label can be any hashable object. In the keyword argument + form of the function, it must be a valid python identifier. + itr : iterable + Finite length iterable of the property values. + Can be a single-property `Cycler` that would + be like a key change, but as a shallow copy. + + Returns + ------- + cycler : Cycler + New `Cycler` for the given property + + """ + if args and kwargs: + raise TypeError( + "cycler() can only accept positional OR keyword arguments -- not both." + ) + + if len(args) == 1: + if not isinstance(args[0], Cycler): + raise TypeError( + "If only one positional argument given, it must " + "be a Cycler instance." + ) + return Cycler(args[0]) + elif len(args) == 2: + return _cycler(*args) + elif len(args) > 2: + raise TypeError( + "Only a single Cycler can be accepted as the lone " + "positional argument. Use keyword arguments instead." + ) + + if kwargs: + return reduce(add, (_cycler(k, v) for k, v in kwargs.items())) + + raise TypeError("Must have at least a positional OR keyword arguments") + + +def _cycler(label: K, itr: Iterable[V]) -> Cycler[K, V]: + """ + Create a new `Cycler` object from a property name and iterable of values. + + Parameters + ---------- + label : hashable + The property key. + itr : iterable + Finite length iterable of the property values. + + Returns + ------- + cycler : Cycler + New `Cycler` for the given property + """ + if isinstance(itr, Cycler): + keys = itr.keys + if len(keys) != 1: + msg = "Can not create Cycler from a multi-property Cycler" + raise ValueError(msg) + + lab = keys.pop() + # Doesn't need to be a new list because + # _from_iter() will be creating that new list anyway. + itr = (v[lab] for v in itr) + + return Cycler._from_iter(label, itr) diff --git a/venv/lib/python3.10/site-packages/cycler/py.typed b/venv/lib/python3.10/site-packages/cycler/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/dateutil/__init__.py b/venv/lib/python3.10/site-packages/dateutil/__init__.py new file mode 100644 index 00000000..a2c19c06 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +import sys + +try: + from ._version import version as __version__ +except ImportError: + __version__ = 'unknown' + +__all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz', + 'utils', 'zoneinfo'] + +def __getattr__(name): + import importlib + + if name in __all__: + return importlib.import_module("." + name, __name__) + raise AttributeError( + "module {!r} has not attribute {!r}".format(__name__, name) + ) + + +def __dir__(): + # __dir__ should include all the lazy-importable modules as well. + return [x for x in globals() if x not in sys.modules] + __all__ diff --git a/venv/lib/python3.10/site-packages/dateutil/_common.py b/venv/lib/python3.10/site-packages/dateutil/_common.py new file mode 100644 index 00000000..4eb2659b --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/_common.py @@ -0,0 +1,43 @@ +""" +Common code used in multiple modules. +""" + + +class weekday(object): + __slots__ = ["weekday", "n"] + + def __init__(self, weekday, n=None): + self.weekday = weekday + self.n = n + + def __call__(self, n): + if n == self.n: + return self + else: + return self.__class__(self.weekday, n) + + def __eq__(self, other): + try: + if self.weekday != other.weekday or self.n != other.n: + return False + except AttributeError: + return False + return True + + def __hash__(self): + return hash(( + self.weekday, + self.n, + )) + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday] + if not self.n: + return s + else: + return "%s(%+d)" % (s, self.n) + +# vim:ts=4:sw=4:et diff --git a/venv/lib/python3.10/site-packages/dateutil/_version.py b/venv/lib/python3.10/site-packages/dateutil/_version.py new file mode 100644 index 00000000..ddda9809 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/_version.py @@ -0,0 +1,4 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '2.9.0.post0' +__version_tuple__ = version_tuple = (2, 9, 0) diff --git a/venv/lib/python3.10/site-packages/dateutil/easter.py b/venv/lib/python3.10/site-packages/dateutil/easter.py new file mode 100644 index 00000000..f74d1f74 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/easter.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +""" +This module offers a generic Easter computing method for any given year, using +Western, Orthodox or Julian algorithms. +""" + +import datetime + +__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"] + +EASTER_JULIAN = 1 +EASTER_ORTHODOX = 2 +EASTER_WESTERN = 3 + + +def easter(year, method=EASTER_WESTERN): + """ + This method was ported from the work done by GM Arts, + on top of the algorithm by Claus Tondering, which was + based in part on the algorithm of Ouding (1940), as + quoted in "Explanatory Supplement to the Astronomical + Almanac", P. Kenneth Seidelmann, editor. + + This algorithm implements three different Easter + calculation methods: + + 1. Original calculation in Julian calendar, valid in + dates after 326 AD + 2. Original method, with date converted to Gregorian + calendar, valid in years 1583 to 4099 + 3. Revised method, in Gregorian calendar, valid in + years 1583 to 4099 as well + + These methods are represented by the constants: + + * ``EASTER_JULIAN = 1`` + * ``EASTER_ORTHODOX = 2`` + * ``EASTER_WESTERN = 3`` + + The default method is method 3. + + More about the algorithm may be found at: + + `GM Arts: Easter Algorithms `_ + + and + + `The Calendar FAQ: Easter `_ + + """ + + if not (1 <= method <= 3): + raise ValueError("invalid method") + + # g - Golden year - 1 + # c - Century + # h - (23 - Epact) mod 30 + # i - Number of days from March 21 to Paschal Full Moon + # j - Weekday for PFM (0=Sunday, etc) + # p - Number of days from March 21 to Sunday on or before PFM + # (-6 to 28 methods 1 & 3, to 56 for method 2) + # e - Extra days to add for method 2 (converting Julian + # date to Gregorian date) + + y = year + g = y % 19 + e = 0 + if method < 3: + # Old method + i = (19*g + 15) % 30 + j = (y + y//4 + i) % 7 + if method == 2: + # Extra dates to convert Julian to Gregorian date + e = 10 + if y > 1600: + e = e + y//100 - 16 - (y//100 - 16)//4 + else: + # New method + c = y//100 + h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 30 + i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11)) + j = (y + y//4 + i + 2 - c + c//4) % 7 + + # p can be from -6 to 56 corresponding to dates 22 March to 23 May + # (later dates apply to method 2, although 23 May never actually occurs) + p = i - j + e + d = 1 + (p + 27 + (p + 6)//40) % 31 + m = 3 + (p + 26)//30 + return datetime.date(int(y), int(m), int(d)) diff --git a/venv/lib/python3.10/site-packages/dateutil/parser/__init__.py b/venv/lib/python3.10/site-packages/dateutil/parser/__init__.py new file mode 100644 index 00000000..d174b0e4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/parser/__init__.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +from ._parser import parse, parser, parserinfo, ParserError +from ._parser import DEFAULTPARSER, DEFAULTTZPARSER +from ._parser import UnknownTimezoneWarning + +from ._parser import __doc__ + +from .isoparser import isoparser, isoparse + +__all__ = ['parse', 'parser', 'parserinfo', + 'isoparse', 'isoparser', + 'ParserError', + 'UnknownTimezoneWarning'] + + +### +# Deprecate portions of the private interface so that downstream code that +# is improperly relying on it is given *some* notice. + + +def __deprecated_private_func(f): + from functools import wraps + import warnings + + msg = ('{name} is a private function and may break without warning, ' + 'it will be moved and or renamed in future versions.') + msg = msg.format(name=f.__name__) + + @wraps(f) + def deprecated_func(*args, **kwargs): + warnings.warn(msg, DeprecationWarning) + return f(*args, **kwargs) + + return deprecated_func + +def __deprecate_private_class(c): + import warnings + + msg = ('{name} is a private class and may break without warning, ' + 'it will be moved and or renamed in future versions.') + msg = msg.format(name=c.__name__) + + class private_class(c): + __doc__ = c.__doc__ + + def __init__(self, *args, **kwargs): + warnings.warn(msg, DeprecationWarning) + super(private_class, self).__init__(*args, **kwargs) + + private_class.__name__ = c.__name__ + + return private_class + + +from ._parser import _timelex, _resultbase +from ._parser import _tzparser, _parsetz + +_timelex = __deprecate_private_class(_timelex) +_tzparser = __deprecate_private_class(_tzparser) +_resultbase = __deprecate_private_class(_resultbase) +_parsetz = __deprecated_private_func(_parsetz) diff --git a/venv/lib/python3.10/site-packages/dateutil/parser/_parser.py b/venv/lib/python3.10/site-packages/dateutil/parser/_parser.py new file mode 100644 index 00000000..37d1663b --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/parser/_parser.py @@ -0,0 +1,1613 @@ +# -*- coding: utf-8 -*- +""" +This module offers a generic date/time string parser which is able to parse +most known formats to represent a date and/or time. + +This module attempts to be forgiving with regards to unlikely input formats, +returning a datetime object even for dates which are ambiguous. If an element +of a date/time stamp is omitted, the following rules are applied: + +- If AM or PM is left unspecified, a 24-hour clock is assumed, however, an hour + on a 12-hour clock (``0 <= hour <= 12``) *must* be specified if AM or PM is + specified. +- If a time zone is omitted, a timezone-naive datetime is returned. + +If any other elements are missing, they are taken from the +:class:`datetime.datetime` object passed to the parameter ``default``. If this +results in a day number exceeding the valid number of days per month, the +value falls back to the end of the month. + +Additional resources about date/time string formats can be found below: + +- `A summary of the international standard date and time notation + `_ +- `W3C Date and Time Formats `_ +- `Time Formats (Planetary Rings Node) `_ +- `CPAN ParseDate module + `_ +- `Java SimpleDateFormat Class + `_ +""" +from __future__ import unicode_literals + +import datetime +import re +import string +import time +import warnings + +from calendar import monthrange +from io import StringIO + +import six +from six import integer_types, text_type + +from decimal import Decimal + +from warnings import warn + +from .. import relativedelta +from .. import tz + +__all__ = ["parse", "parserinfo", "ParserError"] + + +# TODO: pandas.core.tools.datetimes imports this explicitly. Might be worth +# making public and/or figuring out if there is something we can +# take off their plate. +class _timelex(object): + # Fractional seconds are sometimes split by a comma + _split_decimal = re.compile("([.,])") + + def __init__(self, instream): + if isinstance(instream, (bytes, bytearray)): + instream = instream.decode() + + if isinstance(instream, text_type): + instream = StringIO(instream) + elif getattr(instream, 'read', None) is None: + raise TypeError('Parser must be a string or character stream, not ' + '{itype}'.format(itype=instream.__class__.__name__)) + + self.instream = instream + self.charstack = [] + self.tokenstack = [] + self.eof = False + + def get_token(self): + """ + This function breaks the time string into lexical units (tokens), which + can be parsed by the parser. Lexical units are demarcated by changes in + the character set, so any continuous string of letters is considered + one unit, any continuous string of numbers is considered one unit. + + The main complication arises from the fact that dots ('.') can be used + both as separators (e.g. "Sep.20.2009") or decimal points (e.g. + "4:30:21.447"). As such, it is necessary to read the full context of + any dot-separated strings before breaking it into tokens; as such, this + function maintains a "token stack", for when the ambiguous context + demands that multiple tokens be parsed at once. + """ + if self.tokenstack: + return self.tokenstack.pop(0) + + seenletters = False + token = None + state = None + + while not self.eof: + # We only realize that we've reached the end of a token when we + # find a character that's not part of the current token - since + # that character may be part of the next token, it's stored in the + # charstack. + if self.charstack: + nextchar = self.charstack.pop(0) + else: + nextchar = self.instream.read(1) + while nextchar == '\x00': + nextchar = self.instream.read(1) + + if not nextchar: + self.eof = True + break + elif not state: + # First character of the token - determines if we're starting + # to parse a word, a number or something else. + token = nextchar + if self.isword(nextchar): + state = 'a' + elif self.isnum(nextchar): + state = '0' + elif self.isspace(nextchar): + token = ' ' + break # emit token + else: + break # emit token + elif state == 'a': + # If we've already started reading a word, we keep reading + # letters until we find something that's not part of a word. + seenletters = True + if self.isword(nextchar): + token += nextchar + elif nextchar == '.': + token += nextchar + state = 'a.' + else: + self.charstack.append(nextchar) + break # emit token + elif state == '0': + # If we've already started reading a number, we keep reading + # numbers until we find something that doesn't fit. + if self.isnum(nextchar): + token += nextchar + elif nextchar == '.' or (nextchar == ',' and len(token) >= 2): + token += nextchar + state = '0.' + else: + self.charstack.append(nextchar) + break # emit token + elif state == 'a.': + # If we've seen some letters and a dot separator, continue + # parsing, and the tokens will be broken up later. + seenletters = True + if nextchar == '.' or self.isword(nextchar): + token += nextchar + elif self.isnum(nextchar) and token[-1] == '.': + token += nextchar + state = '0.' + else: + self.charstack.append(nextchar) + break # emit token + elif state == '0.': + # If we've seen at least one dot separator, keep going, we'll + # break up the tokens later. + if nextchar == '.' or self.isnum(nextchar): + token += nextchar + elif self.isword(nextchar) and token[-1] == '.': + token += nextchar + state = 'a.' + else: + self.charstack.append(nextchar) + break # emit token + + if (state in ('a.', '0.') and (seenletters or token.count('.') > 1 or + token[-1] in '.,')): + l = self._split_decimal.split(token) + token = l[0] + for tok in l[1:]: + if tok: + self.tokenstack.append(tok) + + if state == '0.' and token.count('.') == 0: + token = token.replace(',', '.') + + return token + + def __iter__(self): + return self + + def __next__(self): + token = self.get_token() + if token is None: + raise StopIteration + + return token + + def next(self): + return self.__next__() # Python 2.x support + + @classmethod + def split(cls, s): + return list(cls(s)) + + @classmethod + def isword(cls, nextchar): + """ Whether or not the next character is part of a word """ + return nextchar.isalpha() + + @classmethod + def isnum(cls, nextchar): + """ Whether the next character is part of a number """ + return nextchar.isdigit() + + @classmethod + def isspace(cls, nextchar): + """ Whether the next character is whitespace """ + return nextchar.isspace() + + +class _resultbase(object): + + def __init__(self): + for attr in self.__slots__: + setattr(self, attr, None) + + def _repr(self, classname): + l = [] + for attr in self.__slots__: + value = getattr(self, attr) + if value is not None: + l.append("%s=%s" % (attr, repr(value))) + return "%s(%s)" % (classname, ", ".join(l)) + + def __len__(self): + return (sum(getattr(self, attr) is not None + for attr in self.__slots__)) + + def __repr__(self): + return self._repr(self.__class__.__name__) + + +class parserinfo(object): + """ + Class which handles what inputs are accepted. Subclass this to customize + the language and acceptable values for each parameter. + + :param dayfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the day (``True``) or month (``False``). If + ``yearfirst`` is set to ``True``, this distinguishes between YDM + and YMD. Default is ``False``. + + :param yearfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the year. If ``True``, the first number is taken + to be the year, otherwise the last number is taken to be the year. + Default is ``False``. + """ + + # m from a.m/p.m, t from ISO T separator + JUMP = [" ", ".", ",", ";", "-", "/", "'", + "at", "on", "and", "ad", "m", "t", "of", + "st", "nd", "rd", "th"] + + WEEKDAYS = [("Mon", "Monday"), + ("Tue", "Tuesday"), # TODO: "Tues" + ("Wed", "Wednesday"), + ("Thu", "Thursday"), # TODO: "Thurs" + ("Fri", "Friday"), + ("Sat", "Saturday"), + ("Sun", "Sunday")] + MONTHS = [("Jan", "January"), + ("Feb", "February"), # TODO: "Febr" + ("Mar", "March"), + ("Apr", "April"), + ("May", "May"), + ("Jun", "June"), + ("Jul", "July"), + ("Aug", "August"), + ("Sep", "Sept", "September"), + ("Oct", "October"), + ("Nov", "November"), + ("Dec", "December")] + HMS = [("h", "hour", "hours"), + ("m", "minute", "minutes"), + ("s", "second", "seconds")] + AMPM = [("am", "a"), + ("pm", "p")] + UTCZONE = ["UTC", "GMT", "Z", "z"] + PERTAIN = ["of"] + TZOFFSET = {} + # TODO: ERA = ["AD", "BC", "CE", "BCE", "Stardate", + # "Anno Domini", "Year of Our Lord"] + + def __init__(self, dayfirst=False, yearfirst=False): + self._jump = self._convert(self.JUMP) + self._weekdays = self._convert(self.WEEKDAYS) + self._months = self._convert(self.MONTHS) + self._hms = self._convert(self.HMS) + self._ampm = self._convert(self.AMPM) + self._utczone = self._convert(self.UTCZONE) + self._pertain = self._convert(self.PERTAIN) + + self.dayfirst = dayfirst + self.yearfirst = yearfirst + + self._year = time.localtime().tm_year + self._century = self._year // 100 * 100 + + def _convert(self, lst): + dct = {} + for i, v in enumerate(lst): + if isinstance(v, tuple): + for v in v: + dct[v.lower()] = i + else: + dct[v.lower()] = i + return dct + + def jump(self, name): + return name.lower() in self._jump + + def weekday(self, name): + try: + return self._weekdays[name.lower()] + except KeyError: + pass + return None + + def month(self, name): + try: + return self._months[name.lower()] + 1 + except KeyError: + pass + return None + + def hms(self, name): + try: + return self._hms[name.lower()] + except KeyError: + return None + + def ampm(self, name): + try: + return self._ampm[name.lower()] + except KeyError: + return None + + def pertain(self, name): + return name.lower() in self._pertain + + def utczone(self, name): + return name.lower() in self._utczone + + def tzoffset(self, name): + if name in self._utczone: + return 0 + + return self.TZOFFSET.get(name) + + def convertyear(self, year, century_specified=False): + """ + Converts two-digit years to year within [-50, 49] + range of self._year (current local time) + """ + + # Function contract is that the year is always positive + assert year >= 0 + + if year < 100 and not century_specified: + # assume current century to start + year += self._century + + if year >= self._year + 50: # if too far in future + year -= 100 + elif year < self._year - 50: # if too far in past + year += 100 + + return year + + def validate(self, res): + # move to info + if res.year is not None: + res.year = self.convertyear(res.year, res.century_specified) + + if ((res.tzoffset == 0 and not res.tzname) or + (res.tzname == 'Z' or res.tzname == 'z')): + res.tzname = "UTC" + res.tzoffset = 0 + elif res.tzoffset != 0 and res.tzname and self.utczone(res.tzname): + res.tzoffset = 0 + return True + + +class _ymd(list): + def __init__(self, *args, **kwargs): + super(self.__class__, self).__init__(*args, **kwargs) + self.century_specified = False + self.dstridx = None + self.mstridx = None + self.ystridx = None + + @property + def has_year(self): + return self.ystridx is not None + + @property + def has_month(self): + return self.mstridx is not None + + @property + def has_day(self): + return self.dstridx is not None + + def could_be_day(self, value): + if self.has_day: + return False + elif not self.has_month: + return 1 <= value <= 31 + elif not self.has_year: + # Be permissive, assume leap year + month = self[self.mstridx] + return 1 <= value <= monthrange(2000, month)[1] + else: + month = self[self.mstridx] + year = self[self.ystridx] + return 1 <= value <= monthrange(year, month)[1] + + def append(self, val, label=None): + if hasattr(val, '__len__'): + if val.isdigit() and len(val) > 2: + self.century_specified = True + if label not in [None, 'Y']: # pragma: no cover + raise ValueError(label) + label = 'Y' + elif val > 100: + self.century_specified = True + if label not in [None, 'Y']: # pragma: no cover + raise ValueError(label) + label = 'Y' + + super(self.__class__, self).append(int(val)) + + if label == 'M': + if self.has_month: + raise ValueError('Month is already set') + self.mstridx = len(self) - 1 + elif label == 'D': + if self.has_day: + raise ValueError('Day is already set') + self.dstridx = len(self) - 1 + elif label == 'Y': + if self.has_year: + raise ValueError('Year is already set') + self.ystridx = len(self) - 1 + + def _resolve_from_stridxs(self, strids): + """ + Try to resolve the identities of year/month/day elements using + ystridx, mstridx, and dstridx, if enough of these are specified. + """ + if len(self) == 3 and len(strids) == 2: + # we can back out the remaining stridx value + missing = [x for x in range(3) if x not in strids.values()] + key = [x for x in ['y', 'm', 'd'] if x not in strids] + assert len(missing) == len(key) == 1 + key = key[0] + val = missing[0] + strids[key] = val + + assert len(self) == len(strids) # otherwise this should not be called + out = {key: self[strids[key]] for key in strids} + return (out.get('y'), out.get('m'), out.get('d')) + + def resolve_ymd(self, yearfirst, dayfirst): + len_ymd = len(self) + year, month, day = (None, None, None) + + strids = (('y', self.ystridx), + ('m', self.mstridx), + ('d', self.dstridx)) + + strids = {key: val for key, val in strids if val is not None} + if (len(self) == len(strids) > 0 or + (len(self) == 3 and len(strids) == 2)): + return self._resolve_from_stridxs(strids) + + mstridx = self.mstridx + + if len_ymd > 3: + raise ValueError("More than three YMD values") + elif len_ymd == 1 or (mstridx is not None and len_ymd == 2): + # One member, or two members with a month string + if mstridx is not None: + month = self[mstridx] + # since mstridx is 0 or 1, self[mstridx-1] always + # looks up the other element + other = self[mstridx - 1] + else: + other = self[0] + + if len_ymd > 1 or mstridx is None: + if other > 31: + year = other + else: + day = other + + elif len_ymd == 2: + # Two members with numbers + if self[0] > 31: + # 99-01 + year, month = self + elif self[1] > 31: + # 01-99 + month, year = self + elif dayfirst and self[1] <= 12: + # 13-01 + day, month = self + else: + # 01-13 + month, day = self + + elif len_ymd == 3: + # Three members + if mstridx == 0: + if self[1] > 31: + # Apr-2003-25 + month, year, day = self + else: + month, day, year = self + elif mstridx == 1: + if self[0] > 31 or (yearfirst and self[2] <= 31): + # 99-Jan-01 + year, month, day = self + else: + # 01-Jan-01 + # Give precedence to day-first, since + # two-digit years is usually hand-written. + day, month, year = self + + elif mstridx == 2: + # WTF!? + if self[1] > 31: + # 01-99-Jan + day, year, month = self + else: + # 99-01-Jan + year, day, month = self + + else: + if (self[0] > 31 or + self.ystridx == 0 or + (yearfirst and self[1] <= 12 and self[2] <= 31)): + # 99-01-01 + if dayfirst and self[2] <= 12: + year, day, month = self + else: + year, month, day = self + elif self[0] > 12 or (dayfirst and self[1] <= 12): + # 13-01-01 + day, month, year = self + else: + # 01-13-01 + month, day, year = self + + return year, month, day + + +class parser(object): + def __init__(self, info=None): + self.info = info or parserinfo() + + def parse(self, timestr, default=None, + ignoretz=False, tzinfos=None, **kwargs): + """ + Parse the date/time string into a :class:`datetime.datetime` object. + + :param timestr: + Any date/time string using the supported formats. + + :param default: + The default datetime object, if this is a datetime object and not + ``None``, elements specified in ``timestr`` replace elements in the + default object. + + :param ignoretz: + If set ``True``, time zones in parsed strings are ignored and a + naive :class:`datetime.datetime` object is returned. + + :param tzinfos: + Additional time zone names / aliases which may be present in the + string. This argument maps time zone names (and optionally offsets + from those time zones) to time zones. This parameter can be a + dictionary with timezone aliases mapping time zone names to time + zones or a function taking two parameters (``tzname`` and + ``tzoffset``) and returning a time zone. + + The timezones to which the names are mapped can be an integer + offset from UTC in seconds or a :class:`tzinfo` object. + + .. doctest:: + :options: +NORMALIZE_WHITESPACE + + >>> from dateutil.parser import parse + >>> from dateutil.tz import gettz + >>> tzinfos = {"BRST": -7200, "CST": gettz("America/Chicago")} + >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos) + datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -7200)) + >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos) + datetime.datetime(2012, 1, 19, 17, 21, + tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago')) + + This parameter is ignored if ``ignoretz`` is set. + + :param \\*\\*kwargs: + Keyword arguments as passed to ``_parse()``. + + :return: + Returns a :class:`datetime.datetime` object or, if the + ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the + first element being a :class:`datetime.datetime` object, the second + a tuple containing the fuzzy tokens. + + :raises ParserError: + Raised for invalid or unknown string format, if the provided + :class:`tzinfo` is not in a valid format, or if an invalid date + would be created. + + :raises TypeError: + Raised for non-string or character stream input. + + :raises OverflowError: + Raised if the parsed date exceeds the largest valid C integer on + your system. + """ + + if default is None: + default = datetime.datetime.now().replace(hour=0, minute=0, + second=0, microsecond=0) + + res, skipped_tokens = self._parse(timestr, **kwargs) + + if res is None: + raise ParserError("Unknown string format: %s", timestr) + + if len(res) == 0: + raise ParserError("String does not contain a date: %s", timestr) + + try: + ret = self._build_naive(res, default) + except ValueError as e: + six.raise_from(ParserError(str(e) + ": %s", timestr), e) + + if not ignoretz: + ret = self._build_tzaware(ret, res, tzinfos) + + if kwargs.get('fuzzy_with_tokens', False): + return ret, skipped_tokens + else: + return ret + + class _result(_resultbase): + __slots__ = ["year", "month", "day", "weekday", + "hour", "minute", "second", "microsecond", + "tzname", "tzoffset", "ampm","any_unused_tokens"] + + def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False, + fuzzy_with_tokens=False): + """ + Private method which performs the heavy lifting of parsing, called from + ``parse()``, which passes on its ``kwargs`` to this function. + + :param timestr: + The string to parse. + + :param dayfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the day (``True``) or month (``False``). If + ``yearfirst`` is set to ``True``, this distinguishes between YDM + and YMD. If set to ``None``, this value is retrieved from the + current :class:`parserinfo` object (which itself defaults to + ``False``). + + :param yearfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the year. If ``True``, the first number is taken + to be the year, otherwise the last number is taken to be the year. + If this is set to ``None``, the value is retrieved from the current + :class:`parserinfo` object (which itself defaults to ``False``). + + :param fuzzy: + Whether to allow fuzzy parsing, allowing for string like "Today is + January 1, 2047 at 8:21:00AM". + + :param fuzzy_with_tokens: + If ``True``, ``fuzzy`` is automatically set to True, and the parser + will return a tuple where the first element is the parsed + :class:`datetime.datetime` datetimestamp and the second element is + a tuple containing the portions of the string which were ignored: + + .. doctest:: + + >>> from dateutil.parser import parse + >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True) + (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at ')) + + """ + if fuzzy_with_tokens: + fuzzy = True + + info = self.info + + if dayfirst is None: + dayfirst = info.dayfirst + + if yearfirst is None: + yearfirst = info.yearfirst + + res = self._result() + l = _timelex.split(timestr) # Splits the timestr into tokens + + skipped_idxs = [] + + # year/month/day list + ymd = _ymd() + + len_l = len(l) + i = 0 + try: + while i < len_l: + + # Check if it's a number + value_repr = l[i] + try: + value = float(value_repr) + except ValueError: + value = None + + if value is not None: + # Numeric token + i = self._parse_numeric_token(l, i, info, ymd, res, fuzzy) + + # Check weekday + elif info.weekday(l[i]) is not None: + value = info.weekday(l[i]) + res.weekday = value + + # Check month name + elif info.month(l[i]) is not None: + value = info.month(l[i]) + ymd.append(value, 'M') + + if i + 1 < len_l: + if l[i + 1] in ('-', '/'): + # Jan-01[-99] + sep = l[i + 1] + ymd.append(l[i + 2]) + + if i + 3 < len_l and l[i + 3] == sep: + # Jan-01-99 + ymd.append(l[i + 4]) + i += 2 + + i += 2 + + elif (i + 4 < len_l and l[i + 1] == l[i + 3] == ' ' and + info.pertain(l[i + 2])): + # Jan of 01 + # In this case, 01 is clearly year + if l[i + 4].isdigit(): + # Convert it here to become unambiguous + value = int(l[i + 4]) + year = str(info.convertyear(value)) + ymd.append(year, 'Y') + else: + # Wrong guess + pass + # TODO: not hit in tests + i += 4 + + # Check am/pm + elif info.ampm(l[i]) is not None: + value = info.ampm(l[i]) + val_is_ampm = self._ampm_valid(res.hour, res.ampm, fuzzy) + + if val_is_ampm: + res.hour = self._adjust_ampm(res.hour, value) + res.ampm = value + + elif fuzzy: + skipped_idxs.append(i) + + # Check for a timezone name + elif self._could_be_tzname(res.hour, res.tzname, res.tzoffset, l[i]): + res.tzname = l[i] + res.tzoffset = info.tzoffset(res.tzname) + + # Check for something like GMT+3, or BRST+3. Notice + # that it doesn't mean "I am 3 hours after GMT", but + # "my time +3 is GMT". If found, we reverse the + # logic so that timezone parsing code will get it + # right. + if i + 1 < len_l and l[i + 1] in ('+', '-'): + l[i + 1] = ('+', '-')[l[i + 1] == '+'] + res.tzoffset = None + if info.utczone(res.tzname): + # With something like GMT+3, the timezone + # is *not* GMT. + res.tzname = None + + # Check for a numbered timezone + elif res.hour is not None and l[i] in ('+', '-'): + signal = (-1, 1)[l[i] == '+'] + len_li = len(l[i + 1]) + + # TODO: check that l[i + 1] is integer? + if len_li == 4: + # -0300 + hour_offset = int(l[i + 1][:2]) + min_offset = int(l[i + 1][2:]) + elif i + 2 < len_l and l[i + 2] == ':': + # -03:00 + hour_offset = int(l[i + 1]) + min_offset = int(l[i + 3]) # TODO: Check that l[i+3] is minute-like? + i += 2 + elif len_li <= 2: + # -[0]3 + hour_offset = int(l[i + 1][:2]) + min_offset = 0 + else: + raise ValueError(timestr) + + res.tzoffset = signal * (hour_offset * 3600 + min_offset * 60) + + # Look for a timezone name between parenthesis + if (i + 5 < len_l and + info.jump(l[i + 2]) and l[i + 3] == '(' and + l[i + 5] == ')' and + 3 <= len(l[i + 4]) and + self._could_be_tzname(res.hour, res.tzname, + None, l[i + 4])): + # -0300 (BRST) + res.tzname = l[i + 4] + i += 4 + + i += 1 + + # Check jumps + elif not (info.jump(l[i]) or fuzzy): + raise ValueError(timestr) + + else: + skipped_idxs.append(i) + i += 1 + + # Process year/month/day + year, month, day = ymd.resolve_ymd(yearfirst, dayfirst) + + res.century_specified = ymd.century_specified + res.year = year + res.month = month + res.day = day + + except (IndexError, ValueError): + return None, None + + if not info.validate(res): + return None, None + + if fuzzy_with_tokens: + skipped_tokens = self._recombine_skipped(l, skipped_idxs) + return res, tuple(skipped_tokens) + else: + return res, None + + def _parse_numeric_token(self, tokens, idx, info, ymd, res, fuzzy): + # Token is a number + value_repr = tokens[idx] + try: + value = self._to_decimal(value_repr) + except Exception as e: + six.raise_from(ValueError('Unknown numeric token'), e) + + len_li = len(value_repr) + + len_l = len(tokens) + + if (len(ymd) == 3 and len_li in (2, 4) and + res.hour is None and + (idx + 1 >= len_l or + (tokens[idx + 1] != ':' and + info.hms(tokens[idx + 1]) is None))): + # 19990101T23[59] + s = tokens[idx] + res.hour = int(s[:2]) + + if len_li == 4: + res.minute = int(s[2:]) + + elif len_li == 6 or (len_li > 6 and tokens[idx].find('.') == 6): + # YYMMDD or HHMMSS[.ss] + s = tokens[idx] + + if not ymd and '.' not in tokens[idx]: + ymd.append(s[:2]) + ymd.append(s[2:4]) + ymd.append(s[4:]) + else: + # 19990101T235959[.59] + + # TODO: Check if res attributes already set. + res.hour = int(s[:2]) + res.minute = int(s[2:4]) + res.second, res.microsecond = self._parsems(s[4:]) + + elif len_li in (8, 12, 14): + # YYYYMMDD + s = tokens[idx] + ymd.append(s[:4], 'Y') + ymd.append(s[4:6]) + ymd.append(s[6:8]) + + if len_li > 8: + res.hour = int(s[8:10]) + res.minute = int(s[10:12]) + + if len_li > 12: + res.second = int(s[12:]) + + elif self._find_hms_idx(idx, tokens, info, allow_jump=True) is not None: + # HH[ ]h or MM[ ]m or SS[.ss][ ]s + hms_idx = self._find_hms_idx(idx, tokens, info, allow_jump=True) + (idx, hms) = self._parse_hms(idx, tokens, info, hms_idx) + if hms is not None: + # TODO: checking that hour/minute/second are not + # already set? + self._assign_hms(res, value_repr, hms) + + elif idx + 2 < len_l and tokens[idx + 1] == ':': + # HH:MM[:SS[.ss]] + res.hour = int(value) + value = self._to_decimal(tokens[idx + 2]) # TODO: try/except for this? + (res.minute, res.second) = self._parse_min_sec(value) + + if idx + 4 < len_l and tokens[idx + 3] == ':': + res.second, res.microsecond = self._parsems(tokens[idx + 4]) + + idx += 2 + + idx += 2 + + elif idx + 1 < len_l and tokens[idx + 1] in ('-', '/', '.'): + sep = tokens[idx + 1] + ymd.append(value_repr) + + if idx + 2 < len_l and not info.jump(tokens[idx + 2]): + if tokens[idx + 2].isdigit(): + # 01-01[-01] + ymd.append(tokens[idx + 2]) + else: + # 01-Jan[-01] + value = info.month(tokens[idx + 2]) + + if value is not None: + ymd.append(value, 'M') + else: + raise ValueError() + + if idx + 3 < len_l and tokens[idx + 3] == sep: + # We have three members + value = info.month(tokens[idx + 4]) + + if value is not None: + ymd.append(value, 'M') + else: + ymd.append(tokens[idx + 4]) + idx += 2 + + idx += 1 + idx += 1 + + elif idx + 1 >= len_l or info.jump(tokens[idx + 1]): + if idx + 2 < len_l and info.ampm(tokens[idx + 2]) is not None: + # 12 am + hour = int(value) + res.hour = self._adjust_ampm(hour, info.ampm(tokens[idx + 2])) + idx += 1 + else: + # Year, month or day + ymd.append(value) + idx += 1 + + elif info.ampm(tokens[idx + 1]) is not None and (0 <= value < 24): + # 12am + hour = int(value) + res.hour = self._adjust_ampm(hour, info.ampm(tokens[idx + 1])) + idx += 1 + + elif ymd.could_be_day(value): + ymd.append(value) + + elif not fuzzy: + raise ValueError() + + return idx + + def _find_hms_idx(self, idx, tokens, info, allow_jump): + len_l = len(tokens) + + if idx+1 < len_l and info.hms(tokens[idx+1]) is not None: + # There is an "h", "m", or "s" label following this token. We take + # assign the upcoming label to the current token. + # e.g. the "12" in 12h" + hms_idx = idx + 1 + + elif (allow_jump and idx+2 < len_l and tokens[idx+1] == ' ' and + info.hms(tokens[idx+2]) is not None): + # There is a space and then an "h", "m", or "s" label. + # e.g. the "12" in "12 h" + hms_idx = idx + 2 + + elif idx > 0 and info.hms(tokens[idx-1]) is not None: + # There is a "h", "m", or "s" preceding this token. Since neither + # of the previous cases was hit, there is no label following this + # token, so we use the previous label. + # e.g. the "04" in "12h04" + hms_idx = idx-1 + + elif (1 < idx == len_l-1 and tokens[idx-1] == ' ' and + info.hms(tokens[idx-2]) is not None): + # If we are looking at the final token, we allow for a + # backward-looking check to skip over a space. + # TODO: Are we sure this is the right condition here? + hms_idx = idx - 2 + + else: + hms_idx = None + + return hms_idx + + def _assign_hms(self, res, value_repr, hms): + # See GH issue #427, fixing float rounding + value = self._to_decimal(value_repr) + + if hms == 0: + # Hour + res.hour = int(value) + if value % 1: + res.minute = int(60*(value % 1)) + + elif hms == 1: + (res.minute, res.second) = self._parse_min_sec(value) + + elif hms == 2: + (res.second, res.microsecond) = self._parsems(value_repr) + + def _could_be_tzname(self, hour, tzname, tzoffset, token): + return (hour is not None and + tzname is None and + tzoffset is None and + len(token) <= 5 and + (all(x in string.ascii_uppercase for x in token) + or token in self.info.UTCZONE)) + + def _ampm_valid(self, hour, ampm, fuzzy): + """ + For fuzzy parsing, 'a' or 'am' (both valid English words) + may erroneously trigger the AM/PM flag. Deal with that + here. + """ + val_is_ampm = True + + # If there's already an AM/PM flag, this one isn't one. + if fuzzy and ampm is not None: + val_is_ampm = False + + # If AM/PM is found and hour is not, raise a ValueError + if hour is None: + if fuzzy: + val_is_ampm = False + else: + raise ValueError('No hour specified with AM or PM flag.') + elif not 0 <= hour <= 12: + # If AM/PM is found, it's a 12 hour clock, so raise + # an error for invalid range + if fuzzy: + val_is_ampm = False + else: + raise ValueError('Invalid hour specified for 12-hour clock.') + + return val_is_ampm + + def _adjust_ampm(self, hour, ampm): + if hour < 12 and ampm == 1: + hour += 12 + elif hour == 12 and ampm == 0: + hour = 0 + return hour + + def _parse_min_sec(self, value): + # TODO: Every usage of this function sets res.second to the return + # value. Are there any cases where second will be returned as None and + # we *don't* want to set res.second = None? + minute = int(value) + second = None + + sec_remainder = value % 1 + if sec_remainder: + second = int(60 * sec_remainder) + return (minute, second) + + def _parse_hms(self, idx, tokens, info, hms_idx): + # TODO: Is this going to admit a lot of false-positives for when we + # just happen to have digits and "h", "m" or "s" characters in non-date + # text? I guess hex hashes won't have that problem, but there's plenty + # of random junk out there. + if hms_idx is None: + hms = None + new_idx = idx + elif hms_idx > idx: + hms = info.hms(tokens[hms_idx]) + new_idx = hms_idx + else: + # Looking backwards, increment one. + hms = info.hms(tokens[hms_idx]) + 1 + new_idx = idx + + return (new_idx, hms) + + # ------------------------------------------------------------------ + # Handling for individual tokens. These are kept as methods instead + # of functions for the sake of customizability via subclassing. + + def _parsems(self, value): + """Parse a I[.F] seconds value into (seconds, microseconds).""" + if "." not in value: + return int(value), 0 + else: + i, f = value.split(".") + return int(i), int(f.ljust(6, "0")[:6]) + + def _to_decimal(self, val): + try: + decimal_value = Decimal(val) + # See GH 662, edge case, infinite value should not be converted + # via `_to_decimal` + if not decimal_value.is_finite(): + raise ValueError("Converted decimal value is infinite or NaN") + except Exception as e: + msg = "Could not convert %s to decimal" % val + six.raise_from(ValueError(msg), e) + else: + return decimal_value + + # ------------------------------------------------------------------ + # Post-Parsing construction of datetime output. These are kept as + # methods instead of functions for the sake of customizability via + # subclassing. + + def _build_tzinfo(self, tzinfos, tzname, tzoffset): + if callable(tzinfos): + tzdata = tzinfos(tzname, tzoffset) + else: + tzdata = tzinfos.get(tzname) + # handle case where tzinfo is paased an options that returns None + # eg tzinfos = {'BRST' : None} + if isinstance(tzdata, datetime.tzinfo) or tzdata is None: + tzinfo = tzdata + elif isinstance(tzdata, text_type): + tzinfo = tz.tzstr(tzdata) + elif isinstance(tzdata, integer_types): + tzinfo = tz.tzoffset(tzname, tzdata) + else: + raise TypeError("Offset must be tzinfo subclass, tz string, " + "or int offset.") + return tzinfo + + def _build_tzaware(self, naive, res, tzinfos): + if (callable(tzinfos) or (tzinfos and res.tzname in tzinfos)): + tzinfo = self._build_tzinfo(tzinfos, res.tzname, res.tzoffset) + aware = naive.replace(tzinfo=tzinfo) + aware = self._assign_tzname(aware, res.tzname) + + elif res.tzname and res.tzname in time.tzname: + aware = naive.replace(tzinfo=tz.tzlocal()) + + # Handle ambiguous local datetime + aware = self._assign_tzname(aware, res.tzname) + + # This is mostly relevant for winter GMT zones parsed in the UK + if (aware.tzname() != res.tzname and + res.tzname in self.info.UTCZONE): + aware = aware.replace(tzinfo=tz.UTC) + + elif res.tzoffset == 0: + aware = naive.replace(tzinfo=tz.UTC) + + elif res.tzoffset: + aware = naive.replace(tzinfo=tz.tzoffset(res.tzname, res.tzoffset)) + + elif not res.tzname and not res.tzoffset: + # i.e. no timezone information was found. + aware = naive + + elif res.tzname: + # tz-like string was parsed but we don't know what to do + # with it + warnings.warn("tzname {tzname} identified but not understood. " + "Pass `tzinfos` argument in order to correctly " + "return a timezone-aware datetime. In a future " + "version, this will raise an " + "exception.".format(tzname=res.tzname), + category=UnknownTimezoneWarning) + aware = naive + + return aware + + def _build_naive(self, res, default): + repl = {} + for attr in ("year", "month", "day", "hour", + "minute", "second", "microsecond"): + value = getattr(res, attr) + if value is not None: + repl[attr] = value + + if 'day' not in repl: + # If the default day exceeds the last day of the month, fall back + # to the end of the month. + cyear = default.year if res.year is None else res.year + cmonth = default.month if res.month is None else res.month + cday = default.day if res.day is None else res.day + + if cday > monthrange(cyear, cmonth)[1]: + repl['day'] = monthrange(cyear, cmonth)[1] + + naive = default.replace(**repl) + + if res.weekday is not None and not res.day: + naive = naive + relativedelta.relativedelta(weekday=res.weekday) + + return naive + + def _assign_tzname(self, dt, tzname): + if dt.tzname() != tzname: + new_dt = tz.enfold(dt, fold=1) + if new_dt.tzname() == tzname: + return new_dt + + return dt + + def _recombine_skipped(self, tokens, skipped_idxs): + """ + >>> tokens = ["foo", " ", "bar", " ", "19June2000", "baz"] + >>> skipped_idxs = [0, 1, 2, 5] + >>> _recombine_skipped(tokens, skipped_idxs) + ["foo bar", "baz"] + """ + skipped_tokens = [] + for i, idx in enumerate(sorted(skipped_idxs)): + if i > 0 and idx - 1 == skipped_idxs[i - 1]: + skipped_tokens[-1] = skipped_tokens[-1] + tokens[idx] + else: + skipped_tokens.append(tokens[idx]) + + return skipped_tokens + + +DEFAULTPARSER = parser() + + +def parse(timestr, parserinfo=None, **kwargs): + """ + + Parse a string in one of the supported formats, using the + ``parserinfo`` parameters. + + :param timestr: + A string containing a date/time stamp. + + :param parserinfo: + A :class:`parserinfo` object containing parameters for the parser. + If ``None``, the default arguments to the :class:`parserinfo` + constructor are used. + + The ``**kwargs`` parameter takes the following keyword arguments: + + :param default: + The default datetime object, if this is a datetime object and not + ``None``, elements specified in ``timestr`` replace elements in the + default object. + + :param ignoretz: + If set ``True``, time zones in parsed strings are ignored and a naive + :class:`datetime` object is returned. + + :param tzinfos: + Additional time zone names / aliases which may be present in the + string. This argument maps time zone names (and optionally offsets + from those time zones) to time zones. This parameter can be a + dictionary with timezone aliases mapping time zone names to time + zones or a function taking two parameters (``tzname`` and + ``tzoffset``) and returning a time zone. + + The timezones to which the names are mapped can be an integer + offset from UTC in seconds or a :class:`tzinfo` object. + + .. doctest:: + :options: +NORMALIZE_WHITESPACE + + >>> from dateutil.parser import parse + >>> from dateutil.tz import gettz + >>> tzinfos = {"BRST": -7200, "CST": gettz("America/Chicago")} + >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos) + datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -7200)) + >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos) + datetime.datetime(2012, 1, 19, 17, 21, + tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago')) + + This parameter is ignored if ``ignoretz`` is set. + + :param dayfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the day (``True``) or month (``False``). If + ``yearfirst`` is set to ``True``, this distinguishes between YDM and + YMD. If set to ``None``, this value is retrieved from the current + :class:`parserinfo` object (which itself defaults to ``False``). + + :param yearfirst: + Whether to interpret the first value in an ambiguous 3-integer date + (e.g. 01/05/09) as the year. If ``True``, the first number is taken to + be the year, otherwise the last number is taken to be the year. If + this is set to ``None``, the value is retrieved from the current + :class:`parserinfo` object (which itself defaults to ``False``). + + :param fuzzy: + Whether to allow fuzzy parsing, allowing for string like "Today is + January 1, 2047 at 8:21:00AM". + + :param fuzzy_with_tokens: + If ``True``, ``fuzzy`` is automatically set to True, and the parser + will return a tuple where the first element is the parsed + :class:`datetime.datetime` datetimestamp and the second element is + a tuple containing the portions of the string which were ignored: + + .. doctest:: + + >>> from dateutil.parser import parse + >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True) + (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at ')) + + :return: + Returns a :class:`datetime.datetime` object or, if the + ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the + first element being a :class:`datetime.datetime` object, the second + a tuple containing the fuzzy tokens. + + :raises ParserError: + Raised for invalid or unknown string formats, if the provided + :class:`tzinfo` is not in a valid format, or if an invalid date would + be created. + + :raises OverflowError: + Raised if the parsed date exceeds the largest valid C integer on + your system. + """ + if parserinfo: + return parser(parserinfo).parse(timestr, **kwargs) + else: + return DEFAULTPARSER.parse(timestr, **kwargs) + + +class _tzparser(object): + + class _result(_resultbase): + + __slots__ = ["stdabbr", "stdoffset", "dstabbr", "dstoffset", + "start", "end"] + + class _attr(_resultbase): + __slots__ = ["month", "week", "weekday", + "yday", "jyday", "day", "time"] + + def __repr__(self): + return self._repr("") + + def __init__(self): + _resultbase.__init__(self) + self.start = self._attr() + self.end = self._attr() + + def parse(self, tzstr): + res = self._result() + l = [x for x in re.split(r'([,:.]|[a-zA-Z]+|[0-9]+)',tzstr) if x] + used_idxs = list() + try: + + len_l = len(l) + + i = 0 + while i < len_l: + # BRST+3[BRDT[+2]] + j = i + while j < len_l and not [x for x in l[j] + if x in "0123456789:,-+"]: + j += 1 + if j != i: + if not res.stdabbr: + offattr = "stdoffset" + res.stdabbr = "".join(l[i:j]) + else: + offattr = "dstoffset" + res.dstabbr = "".join(l[i:j]) + + for ii in range(j): + used_idxs.append(ii) + i = j + if (i < len_l and (l[i] in ('+', '-') or l[i][0] in + "0123456789")): + if l[i] in ('+', '-'): + # Yes, that's right. See the TZ variable + # documentation. + signal = (1, -1)[l[i] == '+'] + used_idxs.append(i) + i += 1 + else: + signal = -1 + len_li = len(l[i]) + if len_li == 4: + # -0300 + setattr(res, offattr, (int(l[i][:2]) * 3600 + + int(l[i][2:]) * 60) * signal) + elif i + 1 < len_l and l[i + 1] == ':': + # -03:00 + setattr(res, offattr, + (int(l[i]) * 3600 + + int(l[i + 2]) * 60) * signal) + used_idxs.append(i) + i += 2 + elif len_li <= 2: + # -[0]3 + setattr(res, offattr, + int(l[i][:2]) * 3600 * signal) + else: + return None + used_idxs.append(i) + i += 1 + if res.dstabbr: + break + else: + break + + + if i < len_l: + for j in range(i, len_l): + if l[j] == ';': + l[j] = ',' + + assert l[i] == ',' + + i += 1 + + if i >= len_l: + pass + elif (8 <= l.count(',') <= 9 and + not [y for x in l[i:] if x != ',' + for y in x if y not in "0123456789+-"]): + # GMT0BST,3,0,30,3600,10,0,26,7200[,3600] + for x in (res.start, res.end): + x.month = int(l[i]) + used_idxs.append(i) + i += 2 + if l[i] == '-': + value = int(l[i + 1]) * -1 + used_idxs.append(i) + i += 1 + else: + value = int(l[i]) + used_idxs.append(i) + i += 2 + if value: + x.week = value + x.weekday = (int(l[i]) - 1) % 7 + else: + x.day = int(l[i]) + used_idxs.append(i) + i += 2 + x.time = int(l[i]) + used_idxs.append(i) + i += 2 + if i < len_l: + if l[i] in ('-', '+'): + signal = (-1, 1)[l[i] == "+"] + used_idxs.append(i) + i += 1 + else: + signal = 1 + used_idxs.append(i) + res.dstoffset = (res.stdoffset + int(l[i]) * signal) + + # This was a made-up format that is not in normal use + warn(('Parsed time zone "%s"' % tzstr) + + 'is in a non-standard dateutil-specific format, which ' + + 'is now deprecated; support for parsing this format ' + + 'will be removed in future versions. It is recommended ' + + 'that you switch to a standard format like the GNU ' + + 'TZ variable format.', tz.DeprecatedTzFormatWarning) + elif (l.count(',') == 2 and l[i:].count('/') <= 2 and + not [y for x in l[i:] if x not in (',', '/', 'J', 'M', + '.', '-', ':') + for y in x if y not in "0123456789"]): + for x in (res.start, res.end): + if l[i] == 'J': + # non-leap year day (1 based) + used_idxs.append(i) + i += 1 + x.jyday = int(l[i]) + elif l[i] == 'M': + # month[-.]week[-.]weekday + used_idxs.append(i) + i += 1 + x.month = int(l[i]) + used_idxs.append(i) + i += 1 + assert l[i] in ('-', '.') + used_idxs.append(i) + i += 1 + x.week = int(l[i]) + if x.week == 5: + x.week = -1 + used_idxs.append(i) + i += 1 + assert l[i] in ('-', '.') + used_idxs.append(i) + i += 1 + x.weekday = (int(l[i]) - 1) % 7 + else: + # year day (zero based) + x.yday = int(l[i]) + 1 + + used_idxs.append(i) + i += 1 + + if i < len_l and l[i] == '/': + used_idxs.append(i) + i += 1 + # start time + len_li = len(l[i]) + if len_li == 4: + # -0300 + x.time = (int(l[i][:2]) * 3600 + + int(l[i][2:]) * 60) + elif i + 1 < len_l and l[i + 1] == ':': + # -03:00 + x.time = int(l[i]) * 3600 + int(l[i + 2]) * 60 + used_idxs.append(i) + i += 2 + if i + 1 < len_l and l[i + 1] == ':': + used_idxs.append(i) + i += 2 + x.time += int(l[i]) + elif len_li <= 2: + # -[0]3 + x.time = (int(l[i][:2]) * 3600) + else: + return None + used_idxs.append(i) + i += 1 + + assert i == len_l or l[i] == ',' + + i += 1 + + assert i >= len_l + + except (IndexError, ValueError, AssertionError): + return None + + unused_idxs = set(range(len_l)).difference(used_idxs) + res.any_unused_tokens = not {l[n] for n in unused_idxs}.issubset({",",":"}) + return res + + +DEFAULTTZPARSER = _tzparser() + + +def _parsetz(tzstr): + return DEFAULTTZPARSER.parse(tzstr) + + +class ParserError(ValueError): + """Exception subclass used for any failure to parse a datetime string. + + This is a subclass of :py:exc:`ValueError`, and should be raised any time + earlier versions of ``dateutil`` would have raised ``ValueError``. + + .. versionadded:: 2.8.1 + """ + def __str__(self): + try: + return self.args[0] % self.args[1:] + except (TypeError, IndexError): + return super(ParserError, self).__str__() + + def __repr__(self): + args = ", ".join("'%s'" % arg for arg in self.args) + return "%s(%s)" % (self.__class__.__name__, args) + + +class UnknownTimezoneWarning(RuntimeWarning): + """Raised when the parser finds a timezone it cannot parse into a tzinfo. + + .. versionadded:: 2.7.0 + """ +# vim:ts=4:sw=4:et diff --git a/venv/lib/python3.10/site-packages/dateutil/parser/isoparser.py b/venv/lib/python3.10/site-packages/dateutil/parser/isoparser.py new file mode 100644 index 00000000..7060087d --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/parser/isoparser.py @@ -0,0 +1,416 @@ +# -*- coding: utf-8 -*- +""" +This module offers a parser for ISO-8601 strings + +It is intended to support all valid date, time and datetime formats per the +ISO-8601 specification. + +..versionadded:: 2.7.0 +""" +from datetime import datetime, timedelta, time, date +import calendar +from dateutil import tz + +from functools import wraps + +import re +import six + +__all__ = ["isoparse", "isoparser"] + + +def _takes_ascii(f): + @wraps(f) + def func(self, str_in, *args, **kwargs): + # If it's a stream, read the whole thing + str_in = getattr(str_in, 'read', lambda: str_in)() + + # If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII + if isinstance(str_in, six.text_type): + # ASCII is the same in UTF-8 + try: + str_in = str_in.encode('ascii') + except UnicodeEncodeError as e: + msg = 'ISO-8601 strings should contain only ASCII characters' + six.raise_from(ValueError(msg), e) + + return f(self, str_in, *args, **kwargs) + + return func + + +class isoparser(object): + def __init__(self, sep=None): + """ + :param sep: + A single character that separates date and time portions. If + ``None``, the parser will accept any single character. + For strict ISO-8601 adherence, pass ``'T'``. + """ + if sep is not None: + if (len(sep) != 1 or ord(sep) >= 128 or sep in '0123456789'): + raise ValueError('Separator must be a single, non-numeric ' + + 'ASCII character') + + sep = sep.encode('ascii') + + self._sep = sep + + @_takes_ascii + def isoparse(self, dt_str): + """ + Parse an ISO-8601 datetime string into a :class:`datetime.datetime`. + + An ISO-8601 datetime string consists of a date portion, followed + optionally by a time portion - the date and time portions are separated + by a single character separator, which is ``T`` in the official + standard. Incomplete date formats (such as ``YYYY-MM``) may *not* be + combined with a time portion. + + Supported date formats are: + + Common: + + - ``YYYY`` + - ``YYYY-MM`` + - ``YYYY-MM-DD`` or ``YYYYMMDD`` + + Uncommon: + + - ``YYYY-Www`` or ``YYYYWww`` - ISO week (day defaults to 0) + - ``YYYY-Www-D`` or ``YYYYWwwD`` - ISO week and day + + The ISO week and day numbering follows the same logic as + :func:`datetime.date.isocalendar`. + + Supported time formats are: + + - ``hh`` + - ``hh:mm`` or ``hhmm`` + - ``hh:mm:ss`` or ``hhmmss`` + - ``hh:mm:ss.ssssss`` (Up to 6 sub-second digits) + + Midnight is a special case for `hh`, as the standard supports both + 00:00 and 24:00 as a representation. The decimal separator can be + either a dot or a comma. + + + .. caution:: + + Support for fractional components other than seconds is part of the + ISO-8601 standard, but is not currently implemented in this parser. + + Supported time zone offset formats are: + + - `Z` (UTC) + - `±HH:MM` + - `±HHMM` + - `±HH` + + Offsets will be represented as :class:`dateutil.tz.tzoffset` objects, + with the exception of UTC, which will be represented as + :class:`dateutil.tz.tzutc`. Time zone offsets equivalent to UTC (such + as `+00:00`) will also be represented as :class:`dateutil.tz.tzutc`. + + :param dt_str: + A string or stream containing only an ISO-8601 datetime string + + :return: + Returns a :class:`datetime.datetime` representing the string. + Unspecified components default to their lowest value. + + .. warning:: + + As of version 2.7.0, the strictness of the parser should not be + considered a stable part of the contract. Any valid ISO-8601 string + that parses correctly with the default settings will continue to + parse correctly in future versions, but invalid strings that + currently fail (e.g. ``2017-01-01T00:00+00:00:00``) are not + guaranteed to continue failing in future versions if they encode + a valid date. + + .. versionadded:: 2.7.0 + """ + components, pos = self._parse_isodate(dt_str) + + if len(dt_str) > pos: + if self._sep is None or dt_str[pos:pos + 1] == self._sep: + components += self._parse_isotime(dt_str[pos + 1:]) + else: + raise ValueError('String contains unknown ISO components') + + if len(components) > 3 and components[3] == 24: + components[3] = 0 + return datetime(*components) + timedelta(days=1) + + return datetime(*components) + + @_takes_ascii + def parse_isodate(self, datestr): + """ + Parse the date portion of an ISO string. + + :param datestr: + The string portion of an ISO string, without a separator + + :return: + Returns a :class:`datetime.date` object + """ + components, pos = self._parse_isodate(datestr) + if pos < len(datestr): + raise ValueError('String contains unknown ISO ' + + 'components: {!r}'.format(datestr.decode('ascii'))) + return date(*components) + + @_takes_ascii + def parse_isotime(self, timestr): + """ + Parse the time portion of an ISO string. + + :param timestr: + The time portion of an ISO string, without a separator + + :return: + Returns a :class:`datetime.time` object + """ + components = self._parse_isotime(timestr) + if components[0] == 24: + components[0] = 0 + return time(*components) + + @_takes_ascii + def parse_tzstr(self, tzstr, zero_as_utc=True): + """ + Parse a valid ISO time zone string. + + See :func:`isoparser.isoparse` for details on supported formats. + + :param tzstr: + A string representing an ISO time zone offset + + :param zero_as_utc: + Whether to return :class:`dateutil.tz.tzutc` for zero-offset zones + + :return: + Returns :class:`dateutil.tz.tzoffset` for offsets and + :class:`dateutil.tz.tzutc` for ``Z`` and (if ``zero_as_utc`` is + specified) offsets equivalent to UTC. + """ + return self._parse_tzstr(tzstr, zero_as_utc=zero_as_utc) + + # Constants + _DATE_SEP = b'-' + _TIME_SEP = b':' + _FRACTION_REGEX = re.compile(b'[\\.,]([0-9]+)') + + def _parse_isodate(self, dt_str): + try: + return self._parse_isodate_common(dt_str) + except ValueError: + return self._parse_isodate_uncommon(dt_str) + + def _parse_isodate_common(self, dt_str): + len_str = len(dt_str) + components = [1, 1, 1] + + if len_str < 4: + raise ValueError('ISO string too short') + + # Year + components[0] = int(dt_str[0:4]) + pos = 4 + if pos >= len_str: + return components, pos + + has_sep = dt_str[pos:pos + 1] == self._DATE_SEP + if has_sep: + pos += 1 + + # Month + if len_str - pos < 2: + raise ValueError('Invalid common month') + + components[1] = int(dt_str[pos:pos + 2]) + pos += 2 + + if pos >= len_str: + if has_sep: + return components, pos + else: + raise ValueError('Invalid ISO format') + + if has_sep: + if dt_str[pos:pos + 1] != self._DATE_SEP: + raise ValueError('Invalid separator in ISO string') + pos += 1 + + # Day + if len_str - pos < 2: + raise ValueError('Invalid common day') + components[2] = int(dt_str[pos:pos + 2]) + return components, pos + 2 + + def _parse_isodate_uncommon(self, dt_str): + if len(dt_str) < 4: + raise ValueError('ISO string too short') + + # All ISO formats start with the year + year = int(dt_str[0:4]) + + has_sep = dt_str[4:5] == self._DATE_SEP + + pos = 4 + has_sep # Skip '-' if it's there + if dt_str[pos:pos + 1] == b'W': + # YYYY-?Www-?D? + pos += 1 + weekno = int(dt_str[pos:pos + 2]) + pos += 2 + + dayno = 1 + if len(dt_str) > pos: + if (dt_str[pos:pos + 1] == self._DATE_SEP) != has_sep: + raise ValueError('Inconsistent use of dash separator') + + pos += has_sep + + dayno = int(dt_str[pos:pos + 1]) + pos += 1 + + base_date = self._calculate_weekdate(year, weekno, dayno) + else: + # YYYYDDD or YYYY-DDD + if len(dt_str) - pos < 3: + raise ValueError('Invalid ordinal day') + + ordinal_day = int(dt_str[pos:pos + 3]) + pos += 3 + + if ordinal_day < 1 or ordinal_day > (365 + calendar.isleap(year)): + raise ValueError('Invalid ordinal day' + + ' {} for year {}'.format(ordinal_day, year)) + + base_date = date(year, 1, 1) + timedelta(days=ordinal_day - 1) + + components = [base_date.year, base_date.month, base_date.day] + return components, pos + + def _calculate_weekdate(self, year, week, day): + """ + Calculate the day of corresponding to the ISO year-week-day calendar. + + This function is effectively the inverse of + :func:`datetime.date.isocalendar`. + + :param year: + The year in the ISO calendar + + :param week: + The week in the ISO calendar - range is [1, 53] + + :param day: + The day in the ISO calendar - range is [1 (MON), 7 (SUN)] + + :return: + Returns a :class:`datetime.date` + """ + if not 0 < week < 54: + raise ValueError('Invalid week: {}'.format(week)) + + if not 0 < day < 8: # Range is 1-7 + raise ValueError('Invalid weekday: {}'.format(day)) + + # Get week 1 for the specific year: + jan_4 = date(year, 1, 4) # Week 1 always has January 4th in it + week_1 = jan_4 - timedelta(days=jan_4.isocalendar()[2] - 1) + + # Now add the specific number of weeks and days to get what we want + week_offset = (week - 1) * 7 + (day - 1) + return week_1 + timedelta(days=week_offset) + + def _parse_isotime(self, timestr): + len_str = len(timestr) + components = [0, 0, 0, 0, None] + pos = 0 + comp = -1 + + if len_str < 2: + raise ValueError('ISO time too short') + + has_sep = False + + while pos < len_str and comp < 5: + comp += 1 + + if timestr[pos:pos + 1] in b'-+Zz': + # Detect time zone boundary + components[-1] = self._parse_tzstr(timestr[pos:]) + pos = len_str + break + + if comp == 1 and timestr[pos:pos+1] == self._TIME_SEP: + has_sep = True + pos += 1 + elif comp == 2 and has_sep: + if timestr[pos:pos+1] != self._TIME_SEP: + raise ValueError('Inconsistent use of colon separator') + pos += 1 + + if comp < 3: + # Hour, minute, second + components[comp] = int(timestr[pos:pos + 2]) + pos += 2 + + if comp == 3: + # Fraction of a second + frac = self._FRACTION_REGEX.match(timestr[pos:]) + if not frac: + continue + + us_str = frac.group(1)[:6] # Truncate to microseconds + components[comp] = int(us_str) * 10**(6 - len(us_str)) + pos += len(frac.group()) + + if pos < len_str: + raise ValueError('Unused components in ISO string') + + if components[0] == 24: + # Standard supports 00:00 and 24:00 as representations of midnight + if any(component != 0 for component in components[1:4]): + raise ValueError('Hour may only be 24 at 24:00:00.000') + + return components + + def _parse_tzstr(self, tzstr, zero_as_utc=True): + if tzstr == b'Z' or tzstr == b'z': + return tz.UTC + + if len(tzstr) not in {3, 5, 6}: + raise ValueError('Time zone offset must be 1, 3, 5 or 6 characters') + + if tzstr[0:1] == b'-': + mult = -1 + elif tzstr[0:1] == b'+': + mult = 1 + else: + raise ValueError('Time zone offset requires sign') + + hours = int(tzstr[1:3]) + if len(tzstr) == 3: + minutes = 0 + else: + minutes = int(tzstr[(4 if tzstr[3:4] == self._TIME_SEP else 3):]) + + if zero_as_utc and hours == 0 and minutes == 0: + return tz.UTC + else: + if minutes > 59: + raise ValueError('Invalid minutes in time zone offset') + + if hours > 23: + raise ValueError('Invalid hours in time zone offset') + + return tz.tzoffset(None, mult * (hours * 60 + minutes) * 60) + + +DEFAULT_ISOPARSER = isoparser() +isoparse = DEFAULT_ISOPARSER.isoparse diff --git a/venv/lib/python3.10/site-packages/dateutil/relativedelta.py b/venv/lib/python3.10/site-packages/dateutil/relativedelta.py new file mode 100644 index 00000000..cd323a54 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/relativedelta.py @@ -0,0 +1,599 @@ +# -*- coding: utf-8 -*- +import datetime +import calendar + +import operator +from math import copysign + +from six import integer_types +from warnings import warn + +from ._common import weekday + +MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7)) + +__all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"] + + +class relativedelta(object): + """ + The relativedelta type is designed to be applied to an existing datetime and + can replace specific components of that datetime, or represents an interval + of time. + + It is based on the specification of the excellent work done by M.-A. Lemburg + in his + `mx.DateTime `_ extension. + However, notice that this type does *NOT* implement the same algorithm as + his work. Do *NOT* expect it to behave like mx.DateTime's counterpart. + + There are two different ways to build a relativedelta instance. The + first one is passing it two date/datetime classes:: + + relativedelta(datetime1, datetime2) + + The second one is passing it any number of the following keyword arguments:: + + relativedelta(arg1=x,arg2=y,arg3=z...) + + year, month, day, hour, minute, second, microsecond: + Absolute information (argument is singular); adding or subtracting a + relativedelta with absolute information does not perform an arithmetic + operation, but rather REPLACES the corresponding value in the + original datetime with the value(s) in relativedelta. + + years, months, weeks, days, hours, minutes, seconds, microseconds: + Relative information, may be negative (argument is plural); adding + or subtracting a relativedelta with relative information performs + the corresponding arithmetic operation on the original datetime value + with the information in the relativedelta. + + weekday: + One of the weekday instances (MO, TU, etc) available in the + relativedelta module. These instances may receive a parameter N, + specifying the Nth weekday, which could be positive or negative + (like MO(+1) or MO(-2)). Not specifying it is the same as specifying + +1. You can also use an integer, where 0=MO. This argument is always + relative e.g. if the calculated date is already Monday, using MO(1) + or MO(-1) won't change the day. To effectively make it absolute, use + it in combination with the day argument (e.g. day=1, MO(1) for first + Monday of the month). + + leapdays: + Will add given days to the date found, if year is a leap + year, and the date found is post 28 of february. + + yearday, nlyearday: + Set the yearday or the non-leap year day (jump leap days). + These are converted to day/month/leapdays information. + + There are relative and absolute forms of the keyword + arguments. The plural is relative, and the singular is + absolute. For each argument in the order below, the absolute form + is applied first (by setting each attribute to that value) and + then the relative form (by adding the value to the attribute). + + The order of attributes considered when this relativedelta is + added to a datetime is: + + 1. Year + 2. Month + 3. Day + 4. Hours + 5. Minutes + 6. Seconds + 7. Microseconds + + Finally, weekday is applied, using the rule described above. + + For example + + >>> from datetime import datetime + >>> from dateutil.relativedelta import relativedelta, MO + >>> dt = datetime(2018, 4, 9, 13, 37, 0) + >>> delta = relativedelta(hours=25, day=1, weekday=MO(1)) + >>> dt + delta + datetime.datetime(2018, 4, 2, 14, 37) + + First, the day is set to 1 (the first of the month), then 25 hours + are added, to get to the 2nd day and 14th hour, finally the + weekday is applied, but since the 2nd is already a Monday there is + no effect. + + """ + + def __init__(self, dt1=None, dt2=None, + years=0, months=0, days=0, leapdays=0, weeks=0, + hours=0, minutes=0, seconds=0, microseconds=0, + year=None, month=None, day=None, weekday=None, + yearday=None, nlyearday=None, + hour=None, minute=None, second=None, microsecond=None): + + if dt1 and dt2: + # datetime is a subclass of date. So both must be date + if not (isinstance(dt1, datetime.date) and + isinstance(dt2, datetime.date)): + raise TypeError("relativedelta only diffs datetime/date") + + # We allow two dates, or two datetimes, so we coerce them to be + # of the same type + if (isinstance(dt1, datetime.datetime) != + isinstance(dt2, datetime.datetime)): + if not isinstance(dt1, datetime.datetime): + dt1 = datetime.datetime.fromordinal(dt1.toordinal()) + elif not isinstance(dt2, datetime.datetime): + dt2 = datetime.datetime.fromordinal(dt2.toordinal()) + + self.years = 0 + self.months = 0 + self.days = 0 + self.leapdays = 0 + self.hours = 0 + self.minutes = 0 + self.seconds = 0 + self.microseconds = 0 + self.year = None + self.month = None + self.day = None + self.weekday = None + self.hour = None + self.minute = None + self.second = None + self.microsecond = None + self._has_time = 0 + + # Get year / month delta between the two + months = (dt1.year - dt2.year) * 12 + (dt1.month - dt2.month) + self._set_months(months) + + # Remove the year/month delta so the timedelta is just well-defined + # time units (seconds, days and microseconds) + dtm = self.__radd__(dt2) + + # If we've overshot our target, make an adjustment + if dt1 < dt2: + compare = operator.gt + increment = 1 + else: + compare = operator.lt + increment = -1 + + while compare(dt1, dtm): + months += increment + self._set_months(months) + dtm = self.__radd__(dt2) + + # Get the timedelta between the "months-adjusted" date and dt1 + delta = dt1 - dtm + self.seconds = delta.seconds + delta.days * 86400 + self.microseconds = delta.microseconds + else: + # Check for non-integer values in integer-only quantities + if any(x is not None and x != int(x) for x in (years, months)): + raise ValueError("Non-integer years and months are " + "ambiguous and not currently supported.") + + # Relative information + self.years = int(years) + self.months = int(months) + self.days = days + weeks * 7 + self.leapdays = leapdays + self.hours = hours + self.minutes = minutes + self.seconds = seconds + self.microseconds = microseconds + + # Absolute information + self.year = year + self.month = month + self.day = day + self.hour = hour + self.minute = minute + self.second = second + self.microsecond = microsecond + + if any(x is not None and int(x) != x + for x in (year, month, day, hour, + minute, second, microsecond)): + # For now we'll deprecate floats - later it'll be an error. + warn("Non-integer value passed as absolute information. " + + "This is not a well-defined condition and will raise " + + "errors in future versions.", DeprecationWarning) + + if isinstance(weekday, integer_types): + self.weekday = weekdays[weekday] + else: + self.weekday = weekday + + yday = 0 + if nlyearday: + yday = nlyearday + elif yearday: + yday = yearday + if yearday > 59: + self.leapdays = -1 + if yday: + ydayidx = [31, 59, 90, 120, 151, 181, 212, + 243, 273, 304, 334, 366] + for idx, ydays in enumerate(ydayidx): + if yday <= ydays: + self.month = idx+1 + if idx == 0: + self.day = yday + else: + self.day = yday-ydayidx[idx-1] + break + else: + raise ValueError("invalid year day (%d)" % yday) + + self._fix() + + def _fix(self): + if abs(self.microseconds) > 999999: + s = _sign(self.microseconds) + div, mod = divmod(self.microseconds * s, 1000000) + self.microseconds = mod * s + self.seconds += div * s + if abs(self.seconds) > 59: + s = _sign(self.seconds) + div, mod = divmod(self.seconds * s, 60) + self.seconds = mod * s + self.minutes += div * s + if abs(self.minutes) > 59: + s = _sign(self.minutes) + div, mod = divmod(self.minutes * s, 60) + self.minutes = mod * s + self.hours += div * s + if abs(self.hours) > 23: + s = _sign(self.hours) + div, mod = divmod(self.hours * s, 24) + self.hours = mod * s + self.days += div * s + if abs(self.months) > 11: + s = _sign(self.months) + div, mod = divmod(self.months * s, 12) + self.months = mod * s + self.years += div * s + if (self.hours or self.minutes or self.seconds or self.microseconds + or self.hour is not None or self.minute is not None or + self.second is not None or self.microsecond is not None): + self._has_time = 1 + else: + self._has_time = 0 + + @property + def weeks(self): + return int(self.days / 7.0) + + @weeks.setter + def weeks(self, value): + self.days = self.days - (self.weeks * 7) + value * 7 + + def _set_months(self, months): + self.months = months + if abs(self.months) > 11: + s = _sign(self.months) + div, mod = divmod(self.months * s, 12) + self.months = mod * s + self.years = div * s + else: + self.years = 0 + + def normalized(self): + """ + Return a version of this object represented entirely using integer + values for the relative attributes. + + >>> relativedelta(days=1.5, hours=2).normalized() + relativedelta(days=+1, hours=+14) + + :return: + Returns a :class:`dateutil.relativedelta.relativedelta` object. + """ + # Cascade remainders down (rounding each to roughly nearest microsecond) + days = int(self.days) + + hours_f = round(self.hours + 24 * (self.days - days), 11) + hours = int(hours_f) + + minutes_f = round(self.minutes + 60 * (hours_f - hours), 10) + minutes = int(minutes_f) + + seconds_f = round(self.seconds + 60 * (minutes_f - minutes), 8) + seconds = int(seconds_f) + + microseconds = round(self.microseconds + 1e6 * (seconds_f - seconds)) + + # Constructor carries overflow back up with call to _fix() + return self.__class__(years=self.years, months=self.months, + days=days, hours=hours, minutes=minutes, + seconds=seconds, microseconds=microseconds, + leapdays=self.leapdays, year=self.year, + month=self.month, day=self.day, + weekday=self.weekday, hour=self.hour, + minute=self.minute, second=self.second, + microsecond=self.microsecond) + + def __add__(self, other): + if isinstance(other, relativedelta): + return self.__class__(years=other.years + self.years, + months=other.months + self.months, + days=other.days + self.days, + hours=other.hours + self.hours, + minutes=other.minutes + self.minutes, + seconds=other.seconds + self.seconds, + microseconds=(other.microseconds + + self.microseconds), + leapdays=other.leapdays or self.leapdays, + year=(other.year if other.year is not None + else self.year), + month=(other.month if other.month is not None + else self.month), + day=(other.day if other.day is not None + else self.day), + weekday=(other.weekday if other.weekday is not None + else self.weekday), + hour=(other.hour if other.hour is not None + else self.hour), + minute=(other.minute if other.minute is not None + else self.minute), + second=(other.second if other.second is not None + else self.second), + microsecond=(other.microsecond if other.microsecond + is not None else + self.microsecond)) + if isinstance(other, datetime.timedelta): + return self.__class__(years=self.years, + months=self.months, + days=self.days + other.days, + hours=self.hours, + minutes=self.minutes, + seconds=self.seconds + other.seconds, + microseconds=self.microseconds + other.microseconds, + leapdays=self.leapdays, + year=self.year, + month=self.month, + day=self.day, + weekday=self.weekday, + hour=self.hour, + minute=self.minute, + second=self.second, + microsecond=self.microsecond) + if not isinstance(other, datetime.date): + return NotImplemented + elif self._has_time and not isinstance(other, datetime.datetime): + other = datetime.datetime.fromordinal(other.toordinal()) + year = (self.year or other.year)+self.years + month = self.month or other.month + if self.months: + assert 1 <= abs(self.months) <= 12 + month += self.months + if month > 12: + year += 1 + month -= 12 + elif month < 1: + year -= 1 + month += 12 + day = min(calendar.monthrange(year, month)[1], + self.day or other.day) + repl = {"year": year, "month": month, "day": day} + for attr in ["hour", "minute", "second", "microsecond"]: + value = getattr(self, attr) + if value is not None: + repl[attr] = value + days = self.days + if self.leapdays and month > 2 and calendar.isleap(year): + days += self.leapdays + ret = (other.replace(**repl) + + datetime.timedelta(days=days, + hours=self.hours, + minutes=self.minutes, + seconds=self.seconds, + microseconds=self.microseconds)) + if self.weekday: + weekday, nth = self.weekday.weekday, self.weekday.n or 1 + jumpdays = (abs(nth) - 1) * 7 + if nth > 0: + jumpdays += (7 - ret.weekday() + weekday) % 7 + else: + jumpdays += (ret.weekday() - weekday) % 7 + jumpdays *= -1 + ret += datetime.timedelta(days=jumpdays) + return ret + + def __radd__(self, other): + return self.__add__(other) + + def __rsub__(self, other): + return self.__neg__().__radd__(other) + + def __sub__(self, other): + if not isinstance(other, relativedelta): + return NotImplemented # In case the other object defines __rsub__ + return self.__class__(years=self.years - other.years, + months=self.months - other.months, + days=self.days - other.days, + hours=self.hours - other.hours, + minutes=self.minutes - other.minutes, + seconds=self.seconds - other.seconds, + microseconds=self.microseconds - other.microseconds, + leapdays=self.leapdays or other.leapdays, + year=(self.year if self.year is not None + else other.year), + month=(self.month if self.month is not None else + other.month), + day=(self.day if self.day is not None else + other.day), + weekday=(self.weekday if self.weekday is not None else + other.weekday), + hour=(self.hour if self.hour is not None else + other.hour), + minute=(self.minute if self.minute is not None else + other.minute), + second=(self.second if self.second is not None else + other.second), + microsecond=(self.microsecond if self.microsecond + is not None else + other.microsecond)) + + def __abs__(self): + return self.__class__(years=abs(self.years), + months=abs(self.months), + days=abs(self.days), + hours=abs(self.hours), + minutes=abs(self.minutes), + seconds=abs(self.seconds), + microseconds=abs(self.microseconds), + leapdays=self.leapdays, + year=self.year, + month=self.month, + day=self.day, + weekday=self.weekday, + hour=self.hour, + minute=self.minute, + second=self.second, + microsecond=self.microsecond) + + def __neg__(self): + return self.__class__(years=-self.years, + months=-self.months, + days=-self.days, + hours=-self.hours, + minutes=-self.minutes, + seconds=-self.seconds, + microseconds=-self.microseconds, + leapdays=self.leapdays, + year=self.year, + month=self.month, + day=self.day, + weekday=self.weekday, + hour=self.hour, + minute=self.minute, + second=self.second, + microsecond=self.microsecond) + + def __bool__(self): + return not (not self.years and + not self.months and + not self.days and + not self.hours and + not self.minutes and + not self.seconds and + not self.microseconds and + not self.leapdays and + self.year is None and + self.month is None and + self.day is None and + self.weekday is None and + self.hour is None and + self.minute is None and + self.second is None and + self.microsecond is None) + # Compatibility with Python 2.x + __nonzero__ = __bool__ + + def __mul__(self, other): + try: + f = float(other) + except TypeError: + return NotImplemented + + return self.__class__(years=int(self.years * f), + months=int(self.months * f), + days=int(self.days * f), + hours=int(self.hours * f), + minutes=int(self.minutes * f), + seconds=int(self.seconds * f), + microseconds=int(self.microseconds * f), + leapdays=self.leapdays, + year=self.year, + month=self.month, + day=self.day, + weekday=self.weekday, + hour=self.hour, + minute=self.minute, + second=self.second, + microsecond=self.microsecond) + + __rmul__ = __mul__ + + def __eq__(self, other): + if not isinstance(other, relativedelta): + return NotImplemented + if self.weekday or other.weekday: + if not self.weekday or not other.weekday: + return False + if self.weekday.weekday != other.weekday.weekday: + return False + n1, n2 = self.weekday.n, other.weekday.n + if n1 != n2 and not ((not n1 or n1 == 1) and (not n2 or n2 == 1)): + return False + return (self.years == other.years and + self.months == other.months and + self.days == other.days and + self.hours == other.hours and + self.minutes == other.minutes and + self.seconds == other.seconds and + self.microseconds == other.microseconds and + self.leapdays == other.leapdays and + self.year == other.year and + self.month == other.month and + self.day == other.day and + self.hour == other.hour and + self.minute == other.minute and + self.second == other.second and + self.microsecond == other.microsecond) + + def __hash__(self): + return hash(( + self.weekday, + self.years, + self.months, + self.days, + self.hours, + self.minutes, + self.seconds, + self.microseconds, + self.leapdays, + self.year, + self.month, + self.day, + self.hour, + self.minute, + self.second, + self.microsecond, + )) + + def __ne__(self, other): + return not self.__eq__(other) + + def __div__(self, other): + try: + reciprocal = 1 / float(other) + except TypeError: + return NotImplemented + + return self.__mul__(reciprocal) + + __truediv__ = __div__ + + def __repr__(self): + l = [] + for attr in ["years", "months", "days", "leapdays", + "hours", "minutes", "seconds", "microseconds"]: + value = getattr(self, attr) + if value: + l.append("{attr}={value:+g}".format(attr=attr, value=value)) + for attr in ["year", "month", "day", "weekday", + "hour", "minute", "second", "microsecond"]: + value = getattr(self, attr) + if value is not None: + l.append("{attr}={value}".format(attr=attr, value=repr(value))) + return "{classname}({attrs})".format(classname=self.__class__.__name__, + attrs=", ".join(l)) + + +def _sign(x): + return int(copysign(1, x)) + +# vim:ts=4:sw=4:et diff --git a/venv/lib/python3.10/site-packages/dateutil/rrule.py b/venv/lib/python3.10/site-packages/dateutil/rrule.py new file mode 100644 index 00000000..571a0d2b --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/rrule.py @@ -0,0 +1,1737 @@ +# -*- coding: utf-8 -*- +""" +The rrule module offers a small, complete, and very fast, implementation of +the recurrence rules documented in the +`iCalendar RFC `_, +including support for caching of results. +""" +import calendar +import datetime +import heapq +import itertools +import re +import sys +from functools import wraps +# For warning about deprecation of until and count +from warnings import warn + +from six import advance_iterator, integer_types + +from six.moves import _thread, range + +from ._common import weekday as weekdaybase + +try: + from math import gcd +except ImportError: + from fractions import gcd + +__all__ = ["rrule", "rruleset", "rrulestr", + "YEARLY", "MONTHLY", "WEEKLY", "DAILY", + "HOURLY", "MINUTELY", "SECONDLY", + "MO", "TU", "WE", "TH", "FR", "SA", "SU"] + +# Every mask is 7 days longer to handle cross-year weekly periods. +M366MASK = tuple([1]*31+[2]*29+[3]*31+[4]*30+[5]*31+[6]*30 + + [7]*31+[8]*31+[9]*30+[10]*31+[11]*30+[12]*31+[1]*7) +M365MASK = list(M366MASK) +M29, M30, M31 = list(range(1, 30)), list(range(1, 31)), list(range(1, 32)) +MDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7]) +MDAY365MASK = list(MDAY366MASK) +M29, M30, M31 = list(range(-29, 0)), list(range(-30, 0)), list(range(-31, 0)) +NMDAY366MASK = tuple(M31+M29+M31+M30+M31+M30+M31+M31+M30+M31+M30+M31+M31[:7]) +NMDAY365MASK = list(NMDAY366MASK) +M366RANGE = (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366) +M365RANGE = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365) +WDAYMASK = [0, 1, 2, 3, 4, 5, 6]*55 +del M29, M30, M31, M365MASK[59], MDAY365MASK[59], NMDAY365MASK[31] +MDAY365MASK = tuple(MDAY365MASK) +M365MASK = tuple(M365MASK) + +FREQNAMES = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY'] + +(YEARLY, + MONTHLY, + WEEKLY, + DAILY, + HOURLY, + MINUTELY, + SECONDLY) = list(range(7)) + +# Imported on demand. +easter = None +parser = None + + +class weekday(weekdaybase): + """ + This version of weekday does not allow n = 0. + """ + def __init__(self, wkday, n=None): + if n == 0: + raise ValueError("Can't create weekday with n==0") + + super(weekday, self).__init__(wkday, n) + + +MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7)) + + +def _invalidates_cache(f): + """ + Decorator for rruleset methods which may invalidate the + cached length. + """ + @wraps(f) + def inner_func(self, *args, **kwargs): + rv = f(self, *args, **kwargs) + self._invalidate_cache() + return rv + + return inner_func + + +class rrulebase(object): + def __init__(self, cache=False): + if cache: + self._cache = [] + self._cache_lock = _thread.allocate_lock() + self._invalidate_cache() + else: + self._cache = None + self._cache_complete = False + self._len = None + + def __iter__(self): + if self._cache_complete: + return iter(self._cache) + elif self._cache is None: + return self._iter() + else: + return self._iter_cached() + + def _invalidate_cache(self): + if self._cache is not None: + self._cache = [] + self._cache_complete = False + self._cache_gen = self._iter() + + if self._cache_lock.locked(): + self._cache_lock.release() + + self._len = None + + def _iter_cached(self): + i = 0 + gen = self._cache_gen + cache = self._cache + acquire = self._cache_lock.acquire + release = self._cache_lock.release + while gen: + if i == len(cache): + acquire() + if self._cache_complete: + break + try: + for j in range(10): + cache.append(advance_iterator(gen)) + except StopIteration: + self._cache_gen = gen = None + self._cache_complete = True + break + release() + yield cache[i] + i += 1 + while i < self._len: + yield cache[i] + i += 1 + + def __getitem__(self, item): + if self._cache_complete: + return self._cache[item] + elif isinstance(item, slice): + if item.step and item.step < 0: + return list(iter(self))[item] + else: + return list(itertools.islice(self, + item.start or 0, + item.stop or sys.maxsize, + item.step or 1)) + elif item >= 0: + gen = iter(self) + try: + for i in range(item+1): + res = advance_iterator(gen) + except StopIteration: + raise IndexError + return res + else: + return list(iter(self))[item] + + def __contains__(self, item): + if self._cache_complete: + return item in self._cache + else: + for i in self: + if i == item: + return True + elif i > item: + return False + return False + + # __len__() introduces a large performance penalty. + def count(self): + """ Returns the number of recurrences in this set. It will have go + through the whole recurrence, if this hasn't been done before. """ + if self._len is None: + for x in self: + pass + return self._len + + def before(self, dt, inc=False): + """ Returns the last recurrence before the given datetime instance. The + inc keyword defines what happens if dt is an occurrence. With + inc=True, if dt itself is an occurrence, it will be returned. """ + if self._cache_complete: + gen = self._cache + else: + gen = self + last = None + if inc: + for i in gen: + if i > dt: + break + last = i + else: + for i in gen: + if i >= dt: + break + last = i + return last + + def after(self, dt, inc=False): + """ Returns the first recurrence after the given datetime instance. The + inc keyword defines what happens if dt is an occurrence. With + inc=True, if dt itself is an occurrence, it will be returned. """ + if self._cache_complete: + gen = self._cache + else: + gen = self + if inc: + for i in gen: + if i >= dt: + return i + else: + for i in gen: + if i > dt: + return i + return None + + def xafter(self, dt, count=None, inc=False): + """ + Generator which yields up to `count` recurrences after the given + datetime instance, equivalent to `after`. + + :param dt: + The datetime at which to start generating recurrences. + + :param count: + The maximum number of recurrences to generate. If `None` (default), + dates are generated until the recurrence rule is exhausted. + + :param inc: + If `dt` is an instance of the rule and `inc` is `True`, it is + included in the output. + + :yields: Yields a sequence of `datetime` objects. + """ + + if self._cache_complete: + gen = self._cache + else: + gen = self + + # Select the comparison function + if inc: + comp = lambda dc, dtc: dc >= dtc + else: + comp = lambda dc, dtc: dc > dtc + + # Generate dates + n = 0 + for d in gen: + if comp(d, dt): + if count is not None: + n += 1 + if n > count: + break + + yield d + + def between(self, after, before, inc=False, count=1): + """ Returns all the occurrences of the rrule between after and before. + The inc keyword defines what happens if after and/or before are + themselves occurrences. With inc=True, they will be included in the + list, if they are found in the recurrence set. """ + if self._cache_complete: + gen = self._cache + else: + gen = self + started = False + l = [] + if inc: + for i in gen: + if i > before: + break + elif not started: + if i >= after: + started = True + l.append(i) + else: + l.append(i) + else: + for i in gen: + if i >= before: + break + elif not started: + if i > after: + started = True + l.append(i) + else: + l.append(i) + return l + + +class rrule(rrulebase): + """ + That's the base of the rrule operation. It accepts all the keywords + defined in the RFC as its constructor parameters (except byday, + which was renamed to byweekday) and more. The constructor prototype is:: + + rrule(freq) + + Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, + or SECONDLY. + + .. note:: + Per RFC section 3.3.10, recurrence instances falling on invalid dates + and times are ignored rather than coerced: + + Recurrence rules may generate recurrence instances with an invalid + date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM + on a day where the local time is moved forward by an hour at 1:00 + AM). Such recurrence instances MUST be ignored and MUST NOT be + counted as part of the recurrence set. + + This can lead to possibly surprising behavior when, for example, the + start date occurs at the end of the month: + + >>> from dateutil.rrule import rrule, MONTHLY + >>> from datetime import datetime + >>> start_date = datetime(2014, 12, 31) + >>> list(rrule(freq=MONTHLY, count=4, dtstart=start_date)) + ... # doctest: +NORMALIZE_WHITESPACE + [datetime.datetime(2014, 12, 31, 0, 0), + datetime.datetime(2015, 1, 31, 0, 0), + datetime.datetime(2015, 3, 31, 0, 0), + datetime.datetime(2015, 5, 31, 0, 0)] + + Additionally, it supports the following keyword arguments: + + :param dtstart: + The recurrence start. Besides being the base for the recurrence, + missing parameters in the final recurrence instances will also be + extracted from this date. If not given, datetime.now() will be used + instead. + :param interval: + The interval between each freq iteration. For example, when using + YEARLY, an interval of 2 means once every two years, but with HOURLY, + it means once every two hours. The default interval is 1. + :param wkst: + The week start day. Must be one of the MO, TU, WE constants, or an + integer, specifying the first day of the week. This will affect + recurrences based on weekly periods. The default week start is got + from calendar.firstweekday(), and may be modified by + calendar.setfirstweekday(). + :param count: + If given, this determines how many occurrences will be generated. + + .. note:: + As of version 2.5.0, the use of the keyword ``until`` in conjunction + with ``count`` is deprecated, to make sure ``dateutil`` is fully + compliant with `RFC-5545 Sec. 3.3.10 `_. Therefore, ``until`` and ``count`` + **must not** occur in the same call to ``rrule``. + :param until: + If given, this must be a datetime instance specifying the upper-bound + limit of the recurrence. The last recurrence in the rule is the greatest + datetime that is less than or equal to the value specified in the + ``until`` parameter. + + .. note:: + As of version 2.5.0, the use of the keyword ``until`` in conjunction + with ``count`` is deprecated, to make sure ``dateutil`` is fully + compliant with `RFC-5545 Sec. 3.3.10 `_. Therefore, ``until`` and ``count`` + **must not** occur in the same call to ``rrule``. + :param bysetpos: + If given, it must be either an integer, or a sequence of integers, + positive or negative. Each given integer will specify an occurrence + number, corresponding to the nth occurrence of the rule inside the + frequency period. For example, a bysetpos of -1 if combined with a + MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will + result in the last work day of every month. + :param bymonth: + If given, it must be either an integer, or a sequence of integers, + meaning the months to apply the recurrence to. + :param bymonthday: + If given, it must be either an integer, or a sequence of integers, + meaning the month days to apply the recurrence to. + :param byyearday: + If given, it must be either an integer, or a sequence of integers, + meaning the year days to apply the recurrence to. + :param byeaster: + If given, it must be either an integer, or a sequence of integers, + positive or negative. Each integer will define an offset from the + Easter Sunday. Passing the offset 0 to byeaster will yield the Easter + Sunday itself. This is an extension to the RFC specification. + :param byweekno: + If given, it must be either an integer, or a sequence of integers, + meaning the week numbers to apply the recurrence to. Week numbers + have the meaning described in ISO8601, that is, the first week of + the year is that containing at least four days of the new year. + :param byweekday: + If given, it must be either an integer (0 == MO), a sequence of + integers, one of the weekday constants (MO, TU, etc), or a sequence + of these constants. When given, these variables will define the + weekdays where the recurrence will be applied. It's also possible to + use an argument n for the weekday instances, which will mean the nth + occurrence of this weekday in the period. For example, with MONTHLY, + or with YEARLY and BYMONTH, using FR(+1) in byweekday will specify the + first friday of the month where the recurrence happens. Notice that in + the RFC documentation, this is specified as BYDAY, but was renamed to + avoid the ambiguity of that keyword. + :param byhour: + If given, it must be either an integer, or a sequence of integers, + meaning the hours to apply the recurrence to. + :param byminute: + If given, it must be either an integer, or a sequence of integers, + meaning the minutes to apply the recurrence to. + :param bysecond: + If given, it must be either an integer, or a sequence of integers, + meaning the seconds to apply the recurrence to. + :param cache: + If given, it must be a boolean value specifying to enable or disable + caching of results. If you will use the same rrule instance multiple + times, enabling caching will improve the performance considerably. + """ + def __init__(self, freq, dtstart=None, + interval=1, wkst=None, count=None, until=None, bysetpos=None, + bymonth=None, bymonthday=None, byyearday=None, byeaster=None, + byweekno=None, byweekday=None, + byhour=None, byminute=None, bysecond=None, + cache=False): + super(rrule, self).__init__(cache) + global easter + if not dtstart: + if until and until.tzinfo: + dtstart = datetime.datetime.now(tz=until.tzinfo).replace(microsecond=0) + else: + dtstart = datetime.datetime.now().replace(microsecond=0) + elif not isinstance(dtstart, datetime.datetime): + dtstart = datetime.datetime.fromordinal(dtstart.toordinal()) + else: + dtstart = dtstart.replace(microsecond=0) + self._dtstart = dtstart + self._tzinfo = dtstart.tzinfo + self._freq = freq + self._interval = interval + self._count = count + + # Cache the original byxxx rules, if they are provided, as the _byxxx + # attributes do not necessarily map to the inputs, and this can be + # a problem in generating the strings. Only store things if they've + # been supplied (the string retrieval will just use .get()) + self._original_rule = {} + + if until and not isinstance(until, datetime.datetime): + until = datetime.datetime.fromordinal(until.toordinal()) + self._until = until + + if self._dtstart and self._until: + if (self._dtstart.tzinfo is not None) != (self._until.tzinfo is not None): + # According to RFC5545 Section 3.3.10: + # https://tools.ietf.org/html/rfc5545#section-3.3.10 + # + # > If the "DTSTART" property is specified as a date with UTC + # > time or a date with local time and time zone reference, + # > then the UNTIL rule part MUST be specified as a date with + # > UTC time. + raise ValueError( + 'RRULE UNTIL values must be specified in UTC when DTSTART ' + 'is timezone-aware' + ) + + if count is not None and until: + warn("Using both 'count' and 'until' is inconsistent with RFC 5545" + " and has been deprecated in dateutil. Future versions will " + "raise an error.", DeprecationWarning) + + if wkst is None: + self._wkst = calendar.firstweekday() + elif isinstance(wkst, integer_types): + self._wkst = wkst + else: + self._wkst = wkst.weekday + + if bysetpos is None: + self._bysetpos = None + elif isinstance(bysetpos, integer_types): + if bysetpos == 0 or not (-366 <= bysetpos <= 366): + raise ValueError("bysetpos must be between 1 and 366, " + "or between -366 and -1") + self._bysetpos = (bysetpos,) + else: + self._bysetpos = tuple(bysetpos) + for pos in self._bysetpos: + if pos == 0 or not (-366 <= pos <= 366): + raise ValueError("bysetpos must be between 1 and 366, " + "or between -366 and -1") + + if self._bysetpos: + self._original_rule['bysetpos'] = self._bysetpos + + if (byweekno is None and byyearday is None and bymonthday is None and + byweekday is None and byeaster is None): + if freq == YEARLY: + if bymonth is None: + bymonth = dtstart.month + self._original_rule['bymonth'] = None + bymonthday = dtstart.day + self._original_rule['bymonthday'] = None + elif freq == MONTHLY: + bymonthday = dtstart.day + self._original_rule['bymonthday'] = None + elif freq == WEEKLY: + byweekday = dtstart.weekday() + self._original_rule['byweekday'] = None + + # bymonth + if bymonth is None: + self._bymonth = None + else: + if isinstance(bymonth, integer_types): + bymonth = (bymonth,) + + self._bymonth = tuple(sorted(set(bymonth))) + + if 'bymonth' not in self._original_rule: + self._original_rule['bymonth'] = self._bymonth + + # byyearday + if byyearday is None: + self._byyearday = None + else: + if isinstance(byyearday, integer_types): + byyearday = (byyearday,) + + self._byyearday = tuple(sorted(set(byyearday))) + self._original_rule['byyearday'] = self._byyearday + + # byeaster + if byeaster is not None: + if not easter: + from dateutil import easter + if isinstance(byeaster, integer_types): + self._byeaster = (byeaster,) + else: + self._byeaster = tuple(sorted(byeaster)) + + self._original_rule['byeaster'] = self._byeaster + else: + self._byeaster = None + + # bymonthday + if bymonthday is None: + self._bymonthday = () + self._bynmonthday = () + else: + if isinstance(bymonthday, integer_types): + bymonthday = (bymonthday,) + + bymonthday = set(bymonthday) # Ensure it's unique + + self._bymonthday = tuple(sorted(x for x in bymonthday if x > 0)) + self._bynmonthday = tuple(sorted(x for x in bymonthday if x < 0)) + + # Storing positive numbers first, then negative numbers + if 'bymonthday' not in self._original_rule: + self._original_rule['bymonthday'] = tuple( + itertools.chain(self._bymonthday, self._bynmonthday)) + + # byweekno + if byweekno is None: + self._byweekno = None + else: + if isinstance(byweekno, integer_types): + byweekno = (byweekno,) + + self._byweekno = tuple(sorted(set(byweekno))) + + self._original_rule['byweekno'] = self._byweekno + + # byweekday / bynweekday + if byweekday is None: + self._byweekday = None + self._bynweekday = None + else: + # If it's one of the valid non-sequence types, convert to a + # single-element sequence before the iterator that builds the + # byweekday set. + if isinstance(byweekday, integer_types) or hasattr(byweekday, "n"): + byweekday = (byweekday,) + + self._byweekday = set() + self._bynweekday = set() + for wday in byweekday: + if isinstance(wday, integer_types): + self._byweekday.add(wday) + elif not wday.n or freq > MONTHLY: + self._byweekday.add(wday.weekday) + else: + self._bynweekday.add((wday.weekday, wday.n)) + + if not self._byweekday: + self._byweekday = None + elif not self._bynweekday: + self._bynweekday = None + + if self._byweekday is not None: + self._byweekday = tuple(sorted(self._byweekday)) + orig_byweekday = [weekday(x) for x in self._byweekday] + else: + orig_byweekday = () + + if self._bynweekday is not None: + self._bynweekday = tuple(sorted(self._bynweekday)) + orig_bynweekday = [weekday(*x) for x in self._bynweekday] + else: + orig_bynweekday = () + + if 'byweekday' not in self._original_rule: + self._original_rule['byweekday'] = tuple(itertools.chain( + orig_byweekday, orig_bynweekday)) + + # byhour + if byhour is None: + if freq < HOURLY: + self._byhour = {dtstart.hour} + else: + self._byhour = None + else: + if isinstance(byhour, integer_types): + byhour = (byhour,) + + if freq == HOURLY: + self._byhour = self.__construct_byset(start=dtstart.hour, + byxxx=byhour, + base=24) + else: + self._byhour = set(byhour) + + self._byhour = tuple(sorted(self._byhour)) + self._original_rule['byhour'] = self._byhour + + # byminute + if byminute is None: + if freq < MINUTELY: + self._byminute = {dtstart.minute} + else: + self._byminute = None + else: + if isinstance(byminute, integer_types): + byminute = (byminute,) + + if freq == MINUTELY: + self._byminute = self.__construct_byset(start=dtstart.minute, + byxxx=byminute, + base=60) + else: + self._byminute = set(byminute) + + self._byminute = tuple(sorted(self._byminute)) + self._original_rule['byminute'] = self._byminute + + # bysecond + if bysecond is None: + if freq < SECONDLY: + self._bysecond = ((dtstart.second,)) + else: + self._bysecond = None + else: + if isinstance(bysecond, integer_types): + bysecond = (bysecond,) + + self._bysecond = set(bysecond) + + if freq == SECONDLY: + self._bysecond = self.__construct_byset(start=dtstart.second, + byxxx=bysecond, + base=60) + else: + self._bysecond = set(bysecond) + + self._bysecond = tuple(sorted(self._bysecond)) + self._original_rule['bysecond'] = self._bysecond + + if self._freq >= HOURLY: + self._timeset = None + else: + self._timeset = [] + for hour in self._byhour: + for minute in self._byminute: + for second in self._bysecond: + self._timeset.append( + datetime.time(hour, minute, second, + tzinfo=self._tzinfo)) + self._timeset.sort() + self._timeset = tuple(self._timeset) + + def __str__(self): + """ + Output a string that would generate this RRULE if passed to rrulestr. + This is mostly compatible with RFC5545, except for the + dateutil-specific extension BYEASTER. + """ + + output = [] + h, m, s = [None] * 3 + if self._dtstart: + output.append(self._dtstart.strftime('DTSTART:%Y%m%dT%H%M%S')) + h, m, s = self._dtstart.timetuple()[3:6] + + parts = ['FREQ=' + FREQNAMES[self._freq]] + if self._interval != 1: + parts.append('INTERVAL=' + str(self._interval)) + + if self._wkst: + parts.append('WKST=' + repr(weekday(self._wkst))[0:2]) + + if self._count is not None: + parts.append('COUNT=' + str(self._count)) + + if self._until: + parts.append(self._until.strftime('UNTIL=%Y%m%dT%H%M%S')) + + if self._original_rule.get('byweekday') is not None: + # The str() method on weekday objects doesn't generate + # RFC5545-compliant strings, so we should modify that. + original_rule = dict(self._original_rule) + wday_strings = [] + for wday in original_rule['byweekday']: + if wday.n: + wday_strings.append('{n:+d}{wday}'.format( + n=wday.n, + wday=repr(wday)[0:2])) + else: + wday_strings.append(repr(wday)) + + original_rule['byweekday'] = wday_strings + else: + original_rule = self._original_rule + + partfmt = '{name}={vals}' + for name, key in [('BYSETPOS', 'bysetpos'), + ('BYMONTH', 'bymonth'), + ('BYMONTHDAY', 'bymonthday'), + ('BYYEARDAY', 'byyearday'), + ('BYWEEKNO', 'byweekno'), + ('BYDAY', 'byweekday'), + ('BYHOUR', 'byhour'), + ('BYMINUTE', 'byminute'), + ('BYSECOND', 'bysecond'), + ('BYEASTER', 'byeaster')]: + value = original_rule.get(key) + if value: + parts.append(partfmt.format(name=name, vals=(','.join(str(v) + for v in value)))) + + output.append('RRULE:' + ';'.join(parts)) + return '\n'.join(output) + + def replace(self, **kwargs): + """Return new rrule with same attributes except for those attributes given new + values by whichever keyword arguments are specified.""" + new_kwargs = {"interval": self._interval, + "count": self._count, + "dtstart": self._dtstart, + "freq": self._freq, + "until": self._until, + "wkst": self._wkst, + "cache": False if self._cache is None else True } + new_kwargs.update(self._original_rule) + new_kwargs.update(kwargs) + return rrule(**new_kwargs) + + def _iter(self): + year, month, day, hour, minute, second, weekday, yearday, _ = \ + self._dtstart.timetuple() + + # Some local variables to speed things up a bit + freq = self._freq + interval = self._interval + wkst = self._wkst + until = self._until + bymonth = self._bymonth + byweekno = self._byweekno + byyearday = self._byyearday + byweekday = self._byweekday + byeaster = self._byeaster + bymonthday = self._bymonthday + bynmonthday = self._bynmonthday + bysetpos = self._bysetpos + byhour = self._byhour + byminute = self._byminute + bysecond = self._bysecond + + ii = _iterinfo(self) + ii.rebuild(year, month) + + getdayset = {YEARLY: ii.ydayset, + MONTHLY: ii.mdayset, + WEEKLY: ii.wdayset, + DAILY: ii.ddayset, + HOURLY: ii.ddayset, + MINUTELY: ii.ddayset, + SECONDLY: ii.ddayset}[freq] + + if freq < HOURLY: + timeset = self._timeset + else: + gettimeset = {HOURLY: ii.htimeset, + MINUTELY: ii.mtimeset, + SECONDLY: ii.stimeset}[freq] + if ((freq >= HOURLY and + self._byhour and hour not in self._byhour) or + (freq >= MINUTELY and + self._byminute and minute not in self._byminute) or + (freq >= SECONDLY and + self._bysecond and second not in self._bysecond)): + timeset = () + else: + timeset = gettimeset(hour, minute, second) + + total = 0 + count = self._count + while True: + # Get dayset with the right frequency + dayset, start, end = getdayset(year, month, day) + + # Do the "hard" work ;-) + filtered = False + for i in dayset[start:end]: + if ((bymonth and ii.mmask[i] not in bymonth) or + (byweekno and not ii.wnomask[i]) or + (byweekday and ii.wdaymask[i] not in byweekday) or + (ii.nwdaymask and not ii.nwdaymask[i]) or + (byeaster and not ii.eastermask[i]) or + ((bymonthday or bynmonthday) and + ii.mdaymask[i] not in bymonthday and + ii.nmdaymask[i] not in bynmonthday) or + (byyearday and + ((i < ii.yearlen and i+1 not in byyearday and + -ii.yearlen+i not in byyearday) or + (i >= ii.yearlen and i+1-ii.yearlen not in byyearday and + -ii.nextyearlen+i-ii.yearlen not in byyearday)))): + dayset[i] = None + filtered = True + + # Output results + if bysetpos and timeset: + poslist = [] + for pos in bysetpos: + if pos < 0: + daypos, timepos = divmod(pos, len(timeset)) + else: + daypos, timepos = divmod(pos-1, len(timeset)) + try: + i = [x for x in dayset[start:end] + if x is not None][daypos] + time = timeset[timepos] + except IndexError: + pass + else: + date = datetime.date.fromordinal(ii.yearordinal+i) + res = datetime.datetime.combine(date, time) + if res not in poslist: + poslist.append(res) + poslist.sort() + for res in poslist: + if until and res > until: + self._len = total + return + elif res >= self._dtstart: + if count is not None: + count -= 1 + if count < 0: + self._len = total + return + total += 1 + yield res + else: + for i in dayset[start:end]: + if i is not None: + date = datetime.date.fromordinal(ii.yearordinal + i) + for time in timeset: + res = datetime.datetime.combine(date, time) + if until and res > until: + self._len = total + return + elif res >= self._dtstart: + if count is not None: + count -= 1 + if count < 0: + self._len = total + return + + total += 1 + yield res + + # Handle frequency and interval + fixday = False + if freq == YEARLY: + year += interval + if year > datetime.MAXYEAR: + self._len = total + return + ii.rebuild(year, month) + elif freq == MONTHLY: + month += interval + if month > 12: + div, mod = divmod(month, 12) + month = mod + year += div + if month == 0: + month = 12 + year -= 1 + if year > datetime.MAXYEAR: + self._len = total + return + ii.rebuild(year, month) + elif freq == WEEKLY: + if wkst > weekday: + day += -(weekday+1+(6-wkst))+self._interval*7 + else: + day += -(weekday-wkst)+self._interval*7 + weekday = wkst + fixday = True + elif freq == DAILY: + day += interval + fixday = True + elif freq == HOURLY: + if filtered: + # Jump to one iteration before next day + hour += ((23-hour)//interval)*interval + + if byhour: + ndays, hour = self.__mod_distance(value=hour, + byxxx=self._byhour, + base=24) + else: + ndays, hour = divmod(hour+interval, 24) + + if ndays: + day += ndays + fixday = True + + timeset = gettimeset(hour, minute, second) + elif freq == MINUTELY: + if filtered: + # Jump to one iteration before next day + minute += ((1439-(hour*60+minute))//interval)*interval + + valid = False + rep_rate = (24*60) + for j in range(rep_rate // gcd(interval, rep_rate)): + if byminute: + nhours, minute = \ + self.__mod_distance(value=minute, + byxxx=self._byminute, + base=60) + else: + nhours, minute = divmod(minute+interval, 60) + + div, hour = divmod(hour+nhours, 24) + if div: + day += div + fixday = True + filtered = False + + if not byhour or hour in byhour: + valid = True + break + + if not valid: + raise ValueError('Invalid combination of interval and ' + + 'byhour resulting in empty rule.') + + timeset = gettimeset(hour, minute, second) + elif freq == SECONDLY: + if filtered: + # Jump to one iteration before next day + second += (((86399 - (hour * 3600 + minute * 60 + second)) + // interval) * interval) + + rep_rate = (24 * 3600) + valid = False + for j in range(0, rep_rate // gcd(interval, rep_rate)): + if bysecond: + nminutes, second = \ + self.__mod_distance(value=second, + byxxx=self._bysecond, + base=60) + else: + nminutes, second = divmod(second+interval, 60) + + div, minute = divmod(minute+nminutes, 60) + if div: + hour += div + div, hour = divmod(hour, 24) + if div: + day += div + fixday = True + + if ((not byhour or hour in byhour) and + (not byminute or minute in byminute) and + (not bysecond or second in bysecond)): + valid = True + break + + if not valid: + raise ValueError('Invalid combination of interval, ' + + 'byhour and byminute resulting in empty' + + ' rule.') + + timeset = gettimeset(hour, minute, second) + + if fixday and day > 28: + daysinmonth = calendar.monthrange(year, month)[1] + if day > daysinmonth: + while day > daysinmonth: + day -= daysinmonth + month += 1 + if month == 13: + month = 1 + year += 1 + if year > datetime.MAXYEAR: + self._len = total + return + daysinmonth = calendar.monthrange(year, month)[1] + ii.rebuild(year, month) + + def __construct_byset(self, start, byxxx, base): + """ + If a `BYXXX` sequence is passed to the constructor at the same level as + `FREQ` (e.g. `FREQ=HOURLY,BYHOUR={2,4,7},INTERVAL=3`), there are some + specifications which cannot be reached given some starting conditions. + + This occurs whenever the interval is not coprime with the base of a + given unit and the difference between the starting position and the + ending position is not coprime with the greatest common denominator + between the interval and the base. For example, with a FREQ of hourly + starting at 17:00 and an interval of 4, the only valid values for + BYHOUR would be {21, 1, 5, 9, 13, 17}, because 4 and 24 are not + coprime. + + :param start: + Specifies the starting position. + :param byxxx: + An iterable containing the list of allowed values. + :param base: + The largest allowable value for the specified frequency (e.g. + 24 hours, 60 minutes). + + This does not preserve the type of the iterable, returning a set, since + the values should be unique and the order is irrelevant, this will + speed up later lookups. + + In the event of an empty set, raises a :exception:`ValueError`, as this + results in an empty rrule. + """ + + cset = set() + + # Support a single byxxx value. + if isinstance(byxxx, integer_types): + byxxx = (byxxx, ) + + for num in byxxx: + i_gcd = gcd(self._interval, base) + # Use divmod rather than % because we need to wrap negative nums. + if i_gcd == 1 or divmod(num - start, i_gcd)[1] == 0: + cset.add(num) + + if len(cset) == 0: + raise ValueError("Invalid rrule byxxx generates an empty set.") + + return cset + + def __mod_distance(self, value, byxxx, base): + """ + Calculates the next value in a sequence where the `FREQ` parameter is + specified along with a `BYXXX` parameter at the same "level" + (e.g. `HOURLY` specified with `BYHOUR`). + + :param value: + The old value of the component. + :param byxxx: + The `BYXXX` set, which should have been generated by + `rrule._construct_byset`, or something else which checks that a + valid rule is present. + :param base: + The largest allowable value for the specified frequency (e.g. + 24 hours, 60 minutes). + + If a valid value is not found after `base` iterations (the maximum + number before the sequence would start to repeat), this raises a + :exception:`ValueError`, as no valid values were found. + + This returns a tuple of `divmod(n*interval, base)`, where `n` is the + smallest number of `interval` repetitions until the next specified + value in `byxxx` is found. + """ + accumulator = 0 + for ii in range(1, base + 1): + # Using divmod() over % to account for negative intervals + div, value = divmod(value + self._interval, base) + accumulator += div + if value in byxxx: + return (accumulator, value) + + +class _iterinfo(object): + __slots__ = ["rrule", "lastyear", "lastmonth", + "yearlen", "nextyearlen", "yearordinal", "yearweekday", + "mmask", "mrange", "mdaymask", "nmdaymask", + "wdaymask", "wnomask", "nwdaymask", "eastermask"] + + def __init__(self, rrule): + for attr in self.__slots__: + setattr(self, attr, None) + self.rrule = rrule + + def rebuild(self, year, month): + # Every mask is 7 days longer to handle cross-year weekly periods. + rr = self.rrule + if year != self.lastyear: + self.yearlen = 365 + calendar.isleap(year) + self.nextyearlen = 365 + calendar.isleap(year + 1) + firstyday = datetime.date(year, 1, 1) + self.yearordinal = firstyday.toordinal() + self.yearweekday = firstyday.weekday() + + wday = datetime.date(year, 1, 1).weekday() + if self.yearlen == 365: + self.mmask = M365MASK + self.mdaymask = MDAY365MASK + self.nmdaymask = NMDAY365MASK + self.wdaymask = WDAYMASK[wday:] + self.mrange = M365RANGE + else: + self.mmask = M366MASK + self.mdaymask = MDAY366MASK + self.nmdaymask = NMDAY366MASK + self.wdaymask = WDAYMASK[wday:] + self.mrange = M366RANGE + + if not rr._byweekno: + self.wnomask = None + else: + self.wnomask = [0]*(self.yearlen+7) + # no1wkst = firstwkst = self.wdaymask.index(rr._wkst) + no1wkst = firstwkst = (7-self.yearweekday+rr._wkst) % 7 + if no1wkst >= 4: + no1wkst = 0 + # Number of days in the year, plus the days we got + # from last year. + wyearlen = self.yearlen+(self.yearweekday-rr._wkst) % 7 + else: + # Number of days in the year, minus the days we + # left in last year. + wyearlen = self.yearlen-no1wkst + div, mod = divmod(wyearlen, 7) + numweeks = div+mod//4 + for n in rr._byweekno: + if n < 0: + n += numweeks+1 + if not (0 < n <= numweeks): + continue + if n > 1: + i = no1wkst+(n-1)*7 + if no1wkst != firstwkst: + i -= 7-firstwkst + else: + i = no1wkst + for j in range(7): + self.wnomask[i] = 1 + i += 1 + if self.wdaymask[i] == rr._wkst: + break + if 1 in rr._byweekno: + # Check week number 1 of next year as well + # TODO: Check -numweeks for next year. + i = no1wkst+numweeks*7 + if no1wkst != firstwkst: + i -= 7-firstwkst + if i < self.yearlen: + # If week starts in next year, we + # don't care about it. + for j in range(7): + self.wnomask[i] = 1 + i += 1 + if self.wdaymask[i] == rr._wkst: + break + if no1wkst: + # Check last week number of last year as + # well. If no1wkst is 0, either the year + # started on week start, or week number 1 + # got days from last year, so there are no + # days from last year's last week number in + # this year. + if -1 not in rr._byweekno: + lyearweekday = datetime.date(year-1, 1, 1).weekday() + lno1wkst = (7-lyearweekday+rr._wkst) % 7 + lyearlen = 365+calendar.isleap(year-1) + if lno1wkst >= 4: + lno1wkst = 0 + lnumweeks = 52+(lyearlen + + (lyearweekday-rr._wkst) % 7) % 7//4 + else: + lnumweeks = 52+(self.yearlen-no1wkst) % 7//4 + else: + lnumweeks = -1 + if lnumweeks in rr._byweekno: + for i in range(no1wkst): + self.wnomask[i] = 1 + + if (rr._bynweekday and (month != self.lastmonth or + year != self.lastyear)): + ranges = [] + if rr._freq == YEARLY: + if rr._bymonth: + for month in rr._bymonth: + ranges.append(self.mrange[month-1:month+1]) + else: + ranges = [(0, self.yearlen)] + elif rr._freq == MONTHLY: + ranges = [self.mrange[month-1:month+1]] + if ranges: + # Weekly frequency won't get here, so we may not + # care about cross-year weekly periods. + self.nwdaymask = [0]*self.yearlen + for first, last in ranges: + last -= 1 + for wday, n in rr._bynweekday: + if n < 0: + i = last+(n+1)*7 + i -= (self.wdaymask[i]-wday) % 7 + else: + i = first+(n-1)*7 + i += (7-self.wdaymask[i]+wday) % 7 + if first <= i <= last: + self.nwdaymask[i] = 1 + + if rr._byeaster: + self.eastermask = [0]*(self.yearlen+7) + eyday = easter.easter(year).toordinal()-self.yearordinal + for offset in rr._byeaster: + self.eastermask[eyday+offset] = 1 + + self.lastyear = year + self.lastmonth = month + + def ydayset(self, year, month, day): + return list(range(self.yearlen)), 0, self.yearlen + + def mdayset(self, year, month, day): + dset = [None]*self.yearlen + start, end = self.mrange[month-1:month+1] + for i in range(start, end): + dset[i] = i + return dset, start, end + + def wdayset(self, year, month, day): + # We need to handle cross-year weeks here. + dset = [None]*(self.yearlen+7) + i = datetime.date(year, month, day).toordinal()-self.yearordinal + start = i + for j in range(7): + dset[i] = i + i += 1 + # if (not (0 <= i < self.yearlen) or + # self.wdaymask[i] == self.rrule._wkst): + # This will cross the year boundary, if necessary. + if self.wdaymask[i] == self.rrule._wkst: + break + return dset, start, i + + def ddayset(self, year, month, day): + dset = [None] * self.yearlen + i = datetime.date(year, month, day).toordinal() - self.yearordinal + dset[i] = i + return dset, i, i + 1 + + def htimeset(self, hour, minute, second): + tset = [] + rr = self.rrule + for minute in rr._byminute: + for second in rr._bysecond: + tset.append(datetime.time(hour, minute, second, + tzinfo=rr._tzinfo)) + tset.sort() + return tset + + def mtimeset(self, hour, minute, second): + tset = [] + rr = self.rrule + for second in rr._bysecond: + tset.append(datetime.time(hour, minute, second, tzinfo=rr._tzinfo)) + tset.sort() + return tset + + def stimeset(self, hour, minute, second): + return (datetime.time(hour, minute, second, + tzinfo=self.rrule._tzinfo),) + + +class rruleset(rrulebase): + """ The rruleset type allows more complex recurrence setups, mixing + multiple rules, dates, exclusion rules, and exclusion dates. The type + constructor takes the following keyword arguments: + + :param cache: If True, caching of results will be enabled, improving + performance of multiple queries considerably. """ + + class _genitem(object): + def __init__(self, genlist, gen): + try: + self.dt = advance_iterator(gen) + genlist.append(self) + except StopIteration: + pass + self.genlist = genlist + self.gen = gen + + def __next__(self): + try: + self.dt = advance_iterator(self.gen) + except StopIteration: + if self.genlist[0] is self: + heapq.heappop(self.genlist) + else: + self.genlist.remove(self) + heapq.heapify(self.genlist) + + next = __next__ + + def __lt__(self, other): + return self.dt < other.dt + + def __gt__(self, other): + return self.dt > other.dt + + def __eq__(self, other): + return self.dt == other.dt + + def __ne__(self, other): + return self.dt != other.dt + + def __init__(self, cache=False): + super(rruleset, self).__init__(cache) + self._rrule = [] + self._rdate = [] + self._exrule = [] + self._exdate = [] + + @_invalidates_cache + def rrule(self, rrule): + """ Include the given :py:class:`rrule` instance in the recurrence set + generation. """ + self._rrule.append(rrule) + + @_invalidates_cache + def rdate(self, rdate): + """ Include the given :py:class:`datetime` instance in the recurrence + set generation. """ + self._rdate.append(rdate) + + @_invalidates_cache + def exrule(self, exrule): + """ Include the given rrule instance in the recurrence set exclusion + list. Dates which are part of the given recurrence rules will not + be generated, even if some inclusive rrule or rdate matches them. + """ + self._exrule.append(exrule) + + @_invalidates_cache + def exdate(self, exdate): + """ Include the given datetime instance in the recurrence set + exclusion list. Dates included that way will not be generated, + even if some inclusive rrule or rdate matches them. """ + self._exdate.append(exdate) + + def _iter(self): + rlist = [] + self._rdate.sort() + self._genitem(rlist, iter(self._rdate)) + for gen in [iter(x) for x in self._rrule]: + self._genitem(rlist, gen) + exlist = [] + self._exdate.sort() + self._genitem(exlist, iter(self._exdate)) + for gen in [iter(x) for x in self._exrule]: + self._genitem(exlist, gen) + lastdt = None + total = 0 + heapq.heapify(rlist) + heapq.heapify(exlist) + while rlist: + ritem = rlist[0] + if not lastdt or lastdt != ritem.dt: + while exlist and exlist[0] < ritem: + exitem = exlist[0] + advance_iterator(exitem) + if exlist and exlist[0] is exitem: + heapq.heapreplace(exlist, exitem) + if not exlist or ritem != exlist[0]: + total += 1 + yield ritem.dt + lastdt = ritem.dt + advance_iterator(ritem) + if rlist and rlist[0] is ritem: + heapq.heapreplace(rlist, ritem) + self._len = total + + + + +class _rrulestr(object): + """ Parses a string representation of a recurrence rule or set of + recurrence rules. + + :param s: + Required, a string defining one or more recurrence rules. + + :param dtstart: + If given, used as the default recurrence start if not specified in the + rule string. + + :param cache: + If set ``True`` caching of results will be enabled, improving + performance of multiple queries considerably. + + :param unfold: + If set ``True`` indicates that a rule string is split over more + than one line and should be joined before processing. + + :param forceset: + If set ``True`` forces a :class:`dateutil.rrule.rruleset` to + be returned. + + :param compatible: + If set ``True`` forces ``unfold`` and ``forceset`` to be ``True``. + + :param ignoretz: + If set ``True``, time zones in parsed strings are ignored and a naive + :class:`datetime.datetime` object is returned. + + :param tzids: + If given, a callable or mapping used to retrieve a + :class:`datetime.tzinfo` from a string representation. + Defaults to :func:`dateutil.tz.gettz`. + + :param tzinfos: + Additional time zone names / aliases which may be present in a string + representation. See :func:`dateutil.parser.parse` for more + information. + + :return: + Returns a :class:`dateutil.rrule.rruleset` or + :class:`dateutil.rrule.rrule` + """ + + _freq_map = {"YEARLY": YEARLY, + "MONTHLY": MONTHLY, + "WEEKLY": WEEKLY, + "DAILY": DAILY, + "HOURLY": HOURLY, + "MINUTELY": MINUTELY, + "SECONDLY": SECONDLY} + + _weekday_map = {"MO": 0, "TU": 1, "WE": 2, "TH": 3, + "FR": 4, "SA": 5, "SU": 6} + + def _handle_int(self, rrkwargs, name, value, **kwargs): + rrkwargs[name.lower()] = int(value) + + def _handle_int_list(self, rrkwargs, name, value, **kwargs): + rrkwargs[name.lower()] = [int(x) for x in value.split(',')] + + _handle_INTERVAL = _handle_int + _handle_COUNT = _handle_int + _handle_BYSETPOS = _handle_int_list + _handle_BYMONTH = _handle_int_list + _handle_BYMONTHDAY = _handle_int_list + _handle_BYYEARDAY = _handle_int_list + _handle_BYEASTER = _handle_int_list + _handle_BYWEEKNO = _handle_int_list + _handle_BYHOUR = _handle_int_list + _handle_BYMINUTE = _handle_int_list + _handle_BYSECOND = _handle_int_list + + def _handle_FREQ(self, rrkwargs, name, value, **kwargs): + rrkwargs["freq"] = self._freq_map[value] + + def _handle_UNTIL(self, rrkwargs, name, value, **kwargs): + global parser + if not parser: + from dateutil import parser + try: + rrkwargs["until"] = parser.parse(value, + ignoretz=kwargs.get("ignoretz"), + tzinfos=kwargs.get("tzinfos")) + except ValueError: + raise ValueError("invalid until date") + + def _handle_WKST(self, rrkwargs, name, value, **kwargs): + rrkwargs["wkst"] = self._weekday_map[value] + + def _handle_BYWEEKDAY(self, rrkwargs, name, value, **kwargs): + """ + Two ways to specify this: +1MO or MO(+1) + """ + l = [] + for wday in value.split(','): + if '(' in wday: + # If it's of the form TH(+1), etc. + splt = wday.split('(') + w = splt[0] + n = int(splt[1][:-1]) + elif len(wday): + # If it's of the form +1MO + for i in range(len(wday)): + if wday[i] not in '+-0123456789': + break + n = wday[:i] or None + w = wday[i:] + if n: + n = int(n) + else: + raise ValueError("Invalid (empty) BYDAY specification.") + + l.append(weekdays[self._weekday_map[w]](n)) + rrkwargs["byweekday"] = l + + _handle_BYDAY = _handle_BYWEEKDAY + + def _parse_rfc_rrule(self, line, + dtstart=None, + cache=False, + ignoretz=False, + tzinfos=None): + if line.find(':') != -1: + name, value = line.split(':') + if name != "RRULE": + raise ValueError("unknown parameter name") + else: + value = line + rrkwargs = {} + for pair in value.split(';'): + name, value = pair.split('=') + name = name.upper() + value = value.upper() + try: + getattr(self, "_handle_"+name)(rrkwargs, name, value, + ignoretz=ignoretz, + tzinfos=tzinfos) + except AttributeError: + raise ValueError("unknown parameter '%s'" % name) + except (KeyError, ValueError): + raise ValueError("invalid '%s': %s" % (name, value)) + return rrule(dtstart=dtstart, cache=cache, **rrkwargs) + + def _parse_date_value(self, date_value, parms, rule_tzids, + ignoretz, tzids, tzinfos): + global parser + if not parser: + from dateutil import parser + + datevals = [] + value_found = False + TZID = None + + for parm in parms: + if parm.startswith("TZID="): + try: + tzkey = rule_tzids[parm.split('TZID=')[-1]] + except KeyError: + continue + if tzids is None: + from . import tz + tzlookup = tz.gettz + elif callable(tzids): + tzlookup = tzids + else: + tzlookup = getattr(tzids, 'get', None) + if tzlookup is None: + msg = ('tzids must be a callable, mapping, or None, ' + 'not %s' % tzids) + raise ValueError(msg) + + TZID = tzlookup(tzkey) + continue + + # RFC 5445 3.8.2.4: The VALUE parameter is optional, but may be found + # only once. + if parm not in {"VALUE=DATE-TIME", "VALUE=DATE"}: + raise ValueError("unsupported parm: " + parm) + else: + if value_found: + msg = ("Duplicate value parameter found in: " + parm) + raise ValueError(msg) + value_found = True + + for datestr in date_value.split(','): + date = parser.parse(datestr, ignoretz=ignoretz, tzinfos=tzinfos) + if TZID is not None: + if date.tzinfo is None: + date = date.replace(tzinfo=TZID) + else: + raise ValueError('DTSTART/EXDATE specifies multiple timezone') + datevals.append(date) + + return datevals + + def _parse_rfc(self, s, + dtstart=None, + cache=False, + unfold=False, + forceset=False, + compatible=False, + ignoretz=False, + tzids=None, + tzinfos=None): + global parser + if compatible: + forceset = True + unfold = True + + TZID_NAMES = dict(map( + lambda x: (x.upper(), x), + re.findall('TZID=(?P[^:]+):', s) + )) + s = s.upper() + if not s.strip(): + raise ValueError("empty string") + if unfold: + lines = s.splitlines() + i = 0 + while i < len(lines): + line = lines[i].rstrip() + if not line: + del lines[i] + elif i > 0 and line[0] == " ": + lines[i-1] += line[1:] + del lines[i] + else: + i += 1 + else: + lines = s.split() + if (not forceset and len(lines) == 1 and (s.find(':') == -1 or + s.startswith('RRULE:'))): + return self._parse_rfc_rrule(lines[0], cache=cache, + dtstart=dtstart, ignoretz=ignoretz, + tzinfos=tzinfos) + else: + rrulevals = [] + rdatevals = [] + exrulevals = [] + exdatevals = [] + for line in lines: + if not line: + continue + if line.find(':') == -1: + name = "RRULE" + value = line + else: + name, value = line.split(':', 1) + parms = name.split(';') + if not parms: + raise ValueError("empty property name") + name = parms[0] + parms = parms[1:] + if name == "RRULE": + for parm in parms: + raise ValueError("unsupported RRULE parm: "+parm) + rrulevals.append(value) + elif name == "RDATE": + for parm in parms: + if parm != "VALUE=DATE-TIME": + raise ValueError("unsupported RDATE parm: "+parm) + rdatevals.append(value) + elif name == "EXRULE": + for parm in parms: + raise ValueError("unsupported EXRULE parm: "+parm) + exrulevals.append(value) + elif name == "EXDATE": + exdatevals.extend( + self._parse_date_value(value, parms, + TZID_NAMES, ignoretz, + tzids, tzinfos) + ) + elif name == "DTSTART": + dtvals = self._parse_date_value(value, parms, TZID_NAMES, + ignoretz, tzids, tzinfos) + if len(dtvals) != 1: + raise ValueError("Multiple DTSTART values specified:" + + value) + dtstart = dtvals[0] + else: + raise ValueError("unsupported property: "+name) + if (forceset or len(rrulevals) > 1 or rdatevals + or exrulevals or exdatevals): + if not parser and (rdatevals or exdatevals): + from dateutil import parser + rset = rruleset(cache=cache) + for value in rrulevals: + rset.rrule(self._parse_rfc_rrule(value, dtstart=dtstart, + ignoretz=ignoretz, + tzinfos=tzinfos)) + for value in rdatevals: + for datestr in value.split(','): + rset.rdate(parser.parse(datestr, + ignoretz=ignoretz, + tzinfos=tzinfos)) + for value in exrulevals: + rset.exrule(self._parse_rfc_rrule(value, dtstart=dtstart, + ignoretz=ignoretz, + tzinfos=tzinfos)) + for value in exdatevals: + rset.exdate(value) + if compatible and dtstart: + rset.rdate(dtstart) + return rset + else: + return self._parse_rfc_rrule(rrulevals[0], + dtstart=dtstart, + cache=cache, + ignoretz=ignoretz, + tzinfos=tzinfos) + + def __call__(self, s, **kwargs): + return self._parse_rfc(s, **kwargs) + + +rrulestr = _rrulestr() + +# vim:ts=4:sw=4:et diff --git a/venv/lib/python3.10/site-packages/dateutil/tz/__init__.py b/venv/lib/python3.10/site-packages/dateutil/tz/__init__.py new file mode 100644 index 00000000..af1352c4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tz/__init__.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from .tz import * +from .tz import __doc__ + +__all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange", + "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz", + "enfold", "datetime_ambiguous", "datetime_exists", + "resolve_imaginary", "UTC", "DeprecatedTzFormatWarning"] + + +class DeprecatedTzFormatWarning(Warning): + """Warning raised when time zones are parsed from deprecated formats.""" diff --git a/venv/lib/python3.10/site-packages/dateutil/tz/_common.py b/venv/lib/python3.10/site-packages/dateutil/tz/_common.py new file mode 100644 index 00000000..e6ac1183 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tz/_common.py @@ -0,0 +1,419 @@ +from six import PY2 + +from functools import wraps + +from datetime import datetime, timedelta, tzinfo + + +ZERO = timedelta(0) + +__all__ = ['tzname_in_python2', 'enfold'] + + +def tzname_in_python2(namefunc): + """Change unicode output into bytestrings in Python 2 + + tzname() API changed in Python 3. It used to return bytes, but was changed + to unicode strings + """ + if PY2: + @wraps(namefunc) + def adjust_encoding(*args, **kwargs): + name = namefunc(*args, **kwargs) + if name is not None: + name = name.encode() + + return name + + return adjust_encoding + else: + return namefunc + + +# The following is adapted from Alexander Belopolsky's tz library +# https://github.com/abalkin/tz +if hasattr(datetime, 'fold'): + # This is the pre-python 3.6 fold situation + def enfold(dt, fold=1): + """ + Provides a unified interface for assigning the ``fold`` attribute to + datetimes both before and after the implementation of PEP-495. + + :param fold: + The value for the ``fold`` attribute in the returned datetime. This + should be either 0 or 1. + + :return: + Returns an object for which ``getattr(dt, 'fold', 0)`` returns + ``fold`` for all versions of Python. In versions prior to + Python 3.6, this is a ``_DatetimeWithFold`` object, which is a + subclass of :py:class:`datetime.datetime` with the ``fold`` + attribute added, if ``fold`` is 1. + + .. versionadded:: 2.6.0 + """ + return dt.replace(fold=fold) + +else: + class _DatetimeWithFold(datetime): + """ + This is a class designed to provide a PEP 495-compliant interface for + Python versions before 3.6. It is used only for dates in a fold, so + the ``fold`` attribute is fixed at ``1``. + + .. versionadded:: 2.6.0 + """ + __slots__ = () + + def replace(self, *args, **kwargs): + """ + Return a datetime with the same attributes, except for those + attributes given new values by whichever keyword arguments are + specified. Note that tzinfo=None can be specified to create a naive + datetime from an aware datetime with no conversion of date and time + data. + + This is reimplemented in ``_DatetimeWithFold`` because pypy3 will + return a ``datetime.datetime`` even if ``fold`` is unchanged. + """ + argnames = ( + 'year', 'month', 'day', 'hour', 'minute', 'second', + 'microsecond', 'tzinfo' + ) + + for arg, argname in zip(args, argnames): + if argname in kwargs: + raise TypeError('Duplicate argument: {}'.format(argname)) + + kwargs[argname] = arg + + for argname in argnames: + if argname not in kwargs: + kwargs[argname] = getattr(self, argname) + + dt_class = self.__class__ if kwargs.get('fold', 1) else datetime + + return dt_class(**kwargs) + + @property + def fold(self): + return 1 + + def enfold(dt, fold=1): + """ + Provides a unified interface for assigning the ``fold`` attribute to + datetimes both before and after the implementation of PEP-495. + + :param fold: + The value for the ``fold`` attribute in the returned datetime. This + should be either 0 or 1. + + :return: + Returns an object for which ``getattr(dt, 'fold', 0)`` returns + ``fold`` for all versions of Python. In versions prior to + Python 3.6, this is a ``_DatetimeWithFold`` object, which is a + subclass of :py:class:`datetime.datetime` with the ``fold`` + attribute added, if ``fold`` is 1. + + .. versionadded:: 2.6.0 + """ + if getattr(dt, 'fold', 0) == fold: + return dt + + args = dt.timetuple()[:6] + args += (dt.microsecond, dt.tzinfo) + + if fold: + return _DatetimeWithFold(*args) + else: + return datetime(*args) + + +def _validate_fromutc_inputs(f): + """ + The CPython version of ``fromutc`` checks that the input is a ``datetime`` + object and that ``self`` is attached as its ``tzinfo``. + """ + @wraps(f) + def fromutc(self, dt): + if not isinstance(dt, datetime): + raise TypeError("fromutc() requires a datetime argument") + if dt.tzinfo is not self: + raise ValueError("dt.tzinfo is not self") + + return f(self, dt) + + return fromutc + + +class _tzinfo(tzinfo): + """ + Base class for all ``dateutil`` ``tzinfo`` objects. + """ + + def is_ambiguous(self, dt): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + + + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + + dt = dt.replace(tzinfo=self) + + wall_0 = enfold(dt, fold=0) + wall_1 = enfold(dt, fold=1) + + same_offset = wall_0.utcoffset() == wall_1.utcoffset() + same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None) + + return same_dt and not same_offset + + def _fold_status(self, dt_utc, dt_wall): + """ + Determine the fold status of a "wall" datetime, given a representation + of the same datetime as a (naive) UTC datetime. This is calculated based + on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all + datetimes, and that this offset is the actual number of hours separating + ``dt_utc`` and ``dt_wall``. + + :param dt_utc: + Representation of the datetime as UTC + + :param dt_wall: + Representation of the datetime as "wall time". This parameter must + either have a `fold` attribute or have a fold-naive + :class:`datetime.tzinfo` attached, otherwise the calculation may + fail. + """ + if self.is_ambiguous(dt_wall): + delta_wall = dt_wall - dt_utc + _fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst())) + else: + _fold = 0 + + return _fold + + def _fold(self, dt): + return getattr(dt, 'fold', 0) + + def _fromutc(self, dt): + """ + Given a timezone-aware datetime in a given timezone, calculates a + timezone-aware datetime in a new timezone. + + Since this is the one time that we *know* we have an unambiguous + datetime object, we take this opportunity to determine whether the + datetime is ambiguous and in a "fold" state (e.g. if it's the first + occurrence, chronologically, of the ambiguous datetime). + + :param dt: + A timezone-aware :class:`datetime.datetime` object. + """ + + # Re-implement the algorithm from Python's datetime.py + dtoff = dt.utcoffset() + if dtoff is None: + raise ValueError("fromutc() requires a non-None utcoffset() " + "result") + + # The original datetime.py code assumes that `dst()` defaults to + # zero during ambiguous times. PEP 495 inverts this presumption, so + # for pre-PEP 495 versions of python, we need to tweak the algorithm. + dtdst = dt.dst() + if dtdst is None: + raise ValueError("fromutc() requires a non-None dst() result") + delta = dtoff - dtdst + + dt += delta + # Set fold=1 so we can default to being in the fold for + # ambiguous dates. + dtdst = enfold(dt, fold=1).dst() + if dtdst is None: + raise ValueError("fromutc(): dt.dst gave inconsistent " + "results; cannot convert") + return dt + dtdst + + @_validate_fromutc_inputs + def fromutc(self, dt): + """ + Given a timezone-aware datetime in a given timezone, calculates a + timezone-aware datetime in a new timezone. + + Since this is the one time that we *know* we have an unambiguous + datetime object, we take this opportunity to determine whether the + datetime is ambiguous and in a "fold" state (e.g. if it's the first + occurrence, chronologically, of the ambiguous datetime). + + :param dt: + A timezone-aware :class:`datetime.datetime` object. + """ + dt_wall = self._fromutc(dt) + + # Calculate the fold status given the two datetimes. + _fold = self._fold_status(dt, dt_wall) + + # Set the default fold value for ambiguous dates + return enfold(dt_wall, fold=_fold) + + +class tzrangebase(_tzinfo): + """ + This is an abstract base class for time zones represented by an annual + transition into and out of DST. Child classes should implement the following + methods: + + * ``__init__(self, *args, **kwargs)`` + * ``transitions(self, year)`` - this is expected to return a tuple of + datetimes representing the DST on and off transitions in standard + time. + + A fully initialized ``tzrangebase`` subclass should also provide the + following attributes: + * ``hasdst``: Boolean whether or not the zone uses DST. + * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects + representing the respective UTC offsets. + * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short + abbreviations in DST and STD, respectively. + * ``_hasdst``: Whether or not the zone has DST. + + .. versionadded:: 2.6.0 + """ + def __init__(self): + raise NotImplementedError('tzrangebase is an abstract base class') + + def utcoffset(self, dt): + isdst = self._isdst(dt) + + if isdst is None: + return None + elif isdst: + return self._dst_offset + else: + return self._std_offset + + def dst(self, dt): + isdst = self._isdst(dt) + + if isdst is None: + return None + elif isdst: + return self._dst_base_offset + else: + return ZERO + + @tzname_in_python2 + def tzname(self, dt): + if self._isdst(dt): + return self._dst_abbr + else: + return self._std_abbr + + def fromutc(self, dt): + """ Given a datetime in UTC, return local time """ + if not isinstance(dt, datetime): + raise TypeError("fromutc() requires a datetime argument") + + if dt.tzinfo is not self: + raise ValueError("dt.tzinfo is not self") + + # Get transitions - if there are none, fixed offset + transitions = self.transitions(dt.year) + if transitions is None: + return dt + self.utcoffset(dt) + + # Get the transition times in UTC + dston, dstoff = transitions + + dston -= self._std_offset + dstoff -= self._std_offset + + utc_transitions = (dston, dstoff) + dt_utc = dt.replace(tzinfo=None) + + isdst = self._naive_isdst(dt_utc, utc_transitions) + + if isdst: + dt_wall = dt + self._dst_offset + else: + dt_wall = dt + self._std_offset + + _fold = int(not isdst and self.is_ambiguous(dt_wall)) + + return enfold(dt_wall, fold=_fold) + + def is_ambiguous(self, dt): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + + + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + if not self.hasdst: + return False + + start, end = self.transitions(dt.year) + + dt = dt.replace(tzinfo=None) + return (end <= dt < end + self._dst_base_offset) + + def _isdst(self, dt): + if not self.hasdst: + return False + elif dt is None: + return None + + transitions = self.transitions(dt.year) + + if transitions is None: + return False + + dt = dt.replace(tzinfo=None) + + isdst = self._naive_isdst(dt, transitions) + + # Handle ambiguous dates + if not isdst and self.is_ambiguous(dt): + return not self._fold(dt) + else: + return isdst + + def _naive_isdst(self, dt, transitions): + dston, dstoff = transitions + + dt = dt.replace(tzinfo=None) + + if dston < dstoff: + isdst = dston <= dt < dstoff + else: + isdst = not dstoff <= dt < dston + + return isdst + + @property + def _dst_base_offset(self): + return self._dst_offset - self._std_offset + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "%s(...)" % self.__class__.__name__ + + __reduce__ = object.__reduce__ diff --git a/venv/lib/python3.10/site-packages/dateutil/tz/_factories.py b/venv/lib/python3.10/site-packages/dateutil/tz/_factories.py new file mode 100644 index 00000000..f8a65891 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tz/_factories.py @@ -0,0 +1,80 @@ +from datetime import timedelta +import weakref +from collections import OrderedDict + +from six.moves import _thread + + +class _TzSingleton(type): + def __init__(cls, *args, **kwargs): + cls.__instance = None + super(_TzSingleton, cls).__init__(*args, **kwargs) + + def __call__(cls): + if cls.__instance is None: + cls.__instance = super(_TzSingleton, cls).__call__() + return cls.__instance + + +class _TzFactory(type): + def instance(cls, *args, **kwargs): + """Alternate constructor that returns a fresh instance""" + return type.__call__(cls, *args, **kwargs) + + +class _TzOffsetFactory(_TzFactory): + def __init__(cls, *args, **kwargs): + cls.__instances = weakref.WeakValueDictionary() + cls.__strong_cache = OrderedDict() + cls.__strong_cache_size = 8 + + cls._cache_lock = _thread.allocate_lock() + + def __call__(cls, name, offset): + if isinstance(offset, timedelta): + key = (name, offset.total_seconds()) + else: + key = (name, offset) + + instance = cls.__instances.get(key, None) + if instance is None: + instance = cls.__instances.setdefault(key, + cls.instance(name, offset)) + + # This lock may not be necessary in Python 3. See GH issue #901 + with cls._cache_lock: + cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance) + + # Remove an item if the strong cache is overpopulated + if len(cls.__strong_cache) > cls.__strong_cache_size: + cls.__strong_cache.popitem(last=False) + + return instance + + +class _TzStrFactory(_TzFactory): + def __init__(cls, *args, **kwargs): + cls.__instances = weakref.WeakValueDictionary() + cls.__strong_cache = OrderedDict() + cls.__strong_cache_size = 8 + + cls.__cache_lock = _thread.allocate_lock() + + def __call__(cls, s, posix_offset=False): + key = (s, posix_offset) + instance = cls.__instances.get(key, None) + + if instance is None: + instance = cls.__instances.setdefault(key, + cls.instance(s, posix_offset)) + + # This lock may not be necessary in Python 3. See GH issue #901 + with cls.__cache_lock: + cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance) + + # Remove an item if the strong cache is overpopulated + if len(cls.__strong_cache) > cls.__strong_cache_size: + cls.__strong_cache.popitem(last=False) + + return instance + diff --git a/venv/lib/python3.10/site-packages/dateutil/tz/tz.py b/venv/lib/python3.10/site-packages/dateutil/tz/tz.py new file mode 100644 index 00000000..61759144 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tz/tz.py @@ -0,0 +1,1849 @@ +# -*- coding: utf-8 -*- +""" +This module offers timezone implementations subclassing the abstract +:py:class:`datetime.tzinfo` type. There are classes to handle tzfile format +files (usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, +etc), TZ environment string (in all known formats), given ranges (with help +from relative deltas), local machine timezone, fixed offset timezone, and UTC +timezone. +""" +import datetime +import struct +import time +import sys +import os +import bisect +import weakref +from collections import OrderedDict + +import six +from six import string_types +from six.moves import _thread +from ._common import tzname_in_python2, _tzinfo +from ._common import tzrangebase, enfold +from ._common import _validate_fromutc_inputs + +from ._factories import _TzSingleton, _TzOffsetFactory +from ._factories import _TzStrFactory +try: + from .win import tzwin, tzwinlocal +except ImportError: + tzwin = tzwinlocal = None + +# For warning about rounding tzinfo +from warnings import warn + +ZERO = datetime.timedelta(0) +EPOCH = datetime.datetime(1970, 1, 1, 0, 0) +EPOCHORDINAL = EPOCH.toordinal() + + +@six.add_metaclass(_TzSingleton) +class tzutc(datetime.tzinfo): + """ + This is a tzinfo object that represents the UTC time zone. + + **Examples:** + + .. doctest:: + + >>> from datetime import * + >>> from dateutil.tz import * + + >>> datetime.now() + datetime.datetime(2003, 9, 27, 9, 40, 1, 521290) + + >>> datetime.now(tzutc()) + datetime.datetime(2003, 9, 27, 12, 40, 12, 156379, tzinfo=tzutc()) + + >>> datetime.now(tzutc()).tzname() + 'UTC' + + .. versionchanged:: 2.7.0 + ``tzutc()`` is now a singleton, so the result of ``tzutc()`` will + always return the same object. + + .. doctest:: + + >>> from dateutil.tz import tzutc, UTC + >>> tzutc() is tzutc() + True + >>> tzutc() is UTC + True + """ + def utcoffset(self, dt): + return ZERO + + def dst(self, dt): + return ZERO + + @tzname_in_python2 + def tzname(self, dt): + return "UTC" + + def is_ambiguous(self, dt): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + + + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + return False + + @_validate_fromutc_inputs + def fromutc(self, dt): + """ + Fast track version of fromutc() returns the original ``dt`` object for + any valid :py:class:`datetime.datetime` object. + """ + return dt + + def __eq__(self, other): + if not isinstance(other, (tzutc, tzoffset)): + return NotImplemented + + return (isinstance(other, tzutc) or + (isinstance(other, tzoffset) and other._offset == ZERO)) + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "%s()" % self.__class__.__name__ + + __reduce__ = object.__reduce__ + + +#: Convenience constant providing a :class:`tzutc()` instance +#: +#: .. versionadded:: 2.7.0 +UTC = tzutc() + + +@six.add_metaclass(_TzOffsetFactory) +class tzoffset(datetime.tzinfo): + """ + A simple class for representing a fixed offset from UTC. + + :param name: + The timezone name, to be returned when ``tzname()`` is called. + :param offset: + The time zone offset in seconds, or (since version 2.6.0, represented + as a :py:class:`datetime.timedelta` object). + """ + def __init__(self, name, offset): + self._name = name + + try: + # Allow a timedelta + offset = offset.total_seconds() + except (TypeError, AttributeError): + pass + + self._offset = datetime.timedelta(seconds=_get_supported_offset(offset)) + + def utcoffset(self, dt): + return self._offset + + def dst(self, dt): + return ZERO + + @tzname_in_python2 + def tzname(self, dt): + return self._name + + @_validate_fromutc_inputs + def fromutc(self, dt): + return dt + self._offset + + def is_ambiguous(self, dt): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + return False + + def __eq__(self, other): + if not isinstance(other, tzoffset): + return NotImplemented + + return self._offset == other._offset + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "%s(%s, %s)" % (self.__class__.__name__, + repr(self._name), + int(self._offset.total_seconds())) + + __reduce__ = object.__reduce__ + + +class tzlocal(_tzinfo): + """ + A :class:`tzinfo` subclass built around the ``time`` timezone functions. + """ + def __init__(self): + super(tzlocal, self).__init__() + + self._std_offset = datetime.timedelta(seconds=-time.timezone) + if time.daylight: + self._dst_offset = datetime.timedelta(seconds=-time.altzone) + else: + self._dst_offset = self._std_offset + + self._dst_saved = self._dst_offset - self._std_offset + self._hasdst = bool(self._dst_saved) + self._tznames = tuple(time.tzname) + + def utcoffset(self, dt): + if dt is None and self._hasdst: + return None + + if self._isdst(dt): + return self._dst_offset + else: + return self._std_offset + + def dst(self, dt): + if dt is None and self._hasdst: + return None + + if self._isdst(dt): + return self._dst_offset - self._std_offset + else: + return ZERO + + @tzname_in_python2 + def tzname(self, dt): + return self._tznames[self._isdst(dt)] + + def is_ambiguous(self, dt): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + + + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + naive_dst = self._naive_is_dst(dt) + return (not naive_dst and + (naive_dst != self._naive_is_dst(dt - self._dst_saved))) + + def _naive_is_dst(self, dt): + timestamp = _datetime_to_timestamp(dt) + return time.localtime(timestamp + time.timezone).tm_isdst + + def _isdst(self, dt, fold_naive=True): + # We can't use mktime here. It is unstable when deciding if + # the hour near to a change is DST or not. + # + # timestamp = time.mktime((dt.year, dt.month, dt.day, dt.hour, + # dt.minute, dt.second, dt.weekday(), 0, -1)) + # return time.localtime(timestamp).tm_isdst + # + # The code above yields the following result: + # + # >>> import tz, datetime + # >>> t = tz.tzlocal() + # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname() + # 'BRDT' + # >>> datetime.datetime(2003,2,16,0,tzinfo=t).tzname() + # 'BRST' + # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname() + # 'BRST' + # >>> datetime.datetime(2003,2,15,22,tzinfo=t).tzname() + # 'BRDT' + # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname() + # 'BRDT' + # + # Here is a more stable implementation: + # + if not self._hasdst: + return False + + # Check for ambiguous times: + dstval = self._naive_is_dst(dt) + fold = getattr(dt, 'fold', None) + + if self.is_ambiguous(dt): + if fold is not None: + return not self._fold(dt) + else: + return True + + return dstval + + def __eq__(self, other): + if isinstance(other, tzlocal): + return (self._std_offset == other._std_offset and + self._dst_offset == other._dst_offset) + elif isinstance(other, tzutc): + return (not self._hasdst and + self._tznames[0] in {'UTC', 'GMT'} and + self._std_offset == ZERO) + elif isinstance(other, tzoffset): + return (not self._hasdst and + self._tznames[0] == other._name and + self._std_offset == other._offset) + else: + return NotImplemented + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "%s()" % self.__class__.__name__ + + __reduce__ = object.__reduce__ + + +class _ttinfo(object): + __slots__ = ["offset", "delta", "isdst", "abbr", + "isstd", "isgmt", "dstoffset"] + + def __init__(self): + for attr in self.__slots__: + setattr(self, attr, None) + + def __repr__(self): + l = [] + for attr in self.__slots__: + value = getattr(self, attr) + if value is not None: + l.append("%s=%s" % (attr, repr(value))) + return "%s(%s)" % (self.__class__.__name__, ", ".join(l)) + + def __eq__(self, other): + if not isinstance(other, _ttinfo): + return NotImplemented + + return (self.offset == other.offset and + self.delta == other.delta and + self.isdst == other.isdst and + self.abbr == other.abbr and + self.isstd == other.isstd and + self.isgmt == other.isgmt and + self.dstoffset == other.dstoffset) + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __getstate__(self): + state = {} + for name in self.__slots__: + state[name] = getattr(self, name, None) + return state + + def __setstate__(self, state): + for name in self.__slots__: + if name in state: + setattr(self, name, state[name]) + + +class _tzfile(object): + """ + Lightweight class for holding the relevant transition and time zone + information read from binary tzfiles. + """ + attrs = ['trans_list', 'trans_list_utc', 'trans_idx', 'ttinfo_list', + 'ttinfo_std', 'ttinfo_dst', 'ttinfo_before', 'ttinfo_first'] + + def __init__(self, **kwargs): + for attr in self.attrs: + setattr(self, attr, kwargs.get(attr, None)) + + +class tzfile(_tzinfo): + """ + This is a ``tzinfo`` subclass that allows one to use the ``tzfile(5)`` + format timezone files to extract current and historical zone information. + + :param fileobj: + This can be an opened file stream or a file name that the time zone + information can be read from. + + :param filename: + This is an optional parameter specifying the source of the time zone + information in the event that ``fileobj`` is a file object. If omitted + and ``fileobj`` is a file stream, this parameter will be set either to + ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``. + + See `Sources for Time Zone and Daylight Saving Time Data + `_ for more information. + Time zone files can be compiled from the `IANA Time Zone database files + `_ with the `zic time zone compiler + `_ + + .. note:: + + Only construct a ``tzfile`` directly if you have a specific timezone + file on disk that you want to read into a Python ``tzinfo`` object. + If you want to get a ``tzfile`` representing a specific IANA zone, + (e.g. ``'America/New_York'``), you should call + :func:`dateutil.tz.gettz` with the zone identifier. + + + **Examples:** + + Using the US Eastern time zone as an example, we can see that a ``tzfile`` + provides time zone information for the standard Daylight Saving offsets: + + .. testsetup:: tzfile + + from dateutil.tz import gettz + from datetime import datetime + + .. doctest:: tzfile + + >>> NYC = gettz('America/New_York') + >>> NYC + tzfile('/usr/share/zoneinfo/America/New_York') + + >>> print(datetime(2016, 1, 3, tzinfo=NYC)) # EST + 2016-01-03 00:00:00-05:00 + + >>> print(datetime(2016, 7, 7, tzinfo=NYC)) # EDT + 2016-07-07 00:00:00-04:00 + + + The ``tzfile`` structure contains a fully history of the time zone, + so historical dates will also have the right offsets. For example, before + the adoption of the UTC standards, New York used local solar mean time: + + .. doctest:: tzfile + + >>> print(datetime(1901, 4, 12, tzinfo=NYC)) # LMT + 1901-04-12 00:00:00-04:56 + + And during World War II, New York was on "Eastern War Time", which was a + state of permanent daylight saving time: + + .. doctest:: tzfile + + >>> print(datetime(1944, 2, 7, tzinfo=NYC)) # EWT + 1944-02-07 00:00:00-04:00 + + """ + + def __init__(self, fileobj, filename=None): + super(tzfile, self).__init__() + + file_opened_here = False + if isinstance(fileobj, string_types): + self._filename = fileobj + fileobj = open(fileobj, 'rb') + file_opened_here = True + elif filename is not None: + self._filename = filename + elif hasattr(fileobj, "name"): + self._filename = fileobj.name + else: + self._filename = repr(fileobj) + + if fileobj is not None: + if not file_opened_here: + fileobj = _nullcontext(fileobj) + + with fileobj as file_stream: + tzobj = self._read_tzfile(file_stream) + + self._set_tzdata(tzobj) + + def _set_tzdata(self, tzobj): + """ Set the time zone data of this object from a _tzfile object """ + # Copy the relevant attributes over as private attributes + for attr in _tzfile.attrs: + setattr(self, '_' + attr, getattr(tzobj, attr)) + + def _read_tzfile(self, fileobj): + out = _tzfile() + + # From tzfile(5): + # + # The time zone information files used by tzset(3) + # begin with the magic characters "TZif" to identify + # them as time zone information files, followed by + # sixteen bytes reserved for future use, followed by + # six four-byte values of type long, written in a + # ``standard'' byte order (the high-order byte + # of the value is written first). + if fileobj.read(4).decode() != "TZif": + raise ValueError("magic not found") + + fileobj.read(16) + + ( + # The number of UTC/local indicators stored in the file. + ttisgmtcnt, + + # The number of standard/wall indicators stored in the file. + ttisstdcnt, + + # The number of leap seconds for which data is + # stored in the file. + leapcnt, + + # The number of "transition times" for which data + # is stored in the file. + timecnt, + + # The number of "local time types" for which data + # is stored in the file (must not be zero). + typecnt, + + # The number of characters of "time zone + # abbreviation strings" stored in the file. + charcnt, + + ) = struct.unpack(">6l", fileobj.read(24)) + + # The above header is followed by tzh_timecnt four-byte + # values of type long, sorted in ascending order. + # These values are written in ``standard'' byte order. + # Each is used as a transition time (as returned by + # time(2)) at which the rules for computing local time + # change. + + if timecnt: + out.trans_list_utc = list(struct.unpack(">%dl" % timecnt, + fileobj.read(timecnt*4))) + else: + out.trans_list_utc = [] + + # Next come tzh_timecnt one-byte values of type unsigned + # char; each one tells which of the different types of + # ``local time'' types described in the file is associated + # with the same-indexed transition time. These values + # serve as indices into an array of ttinfo structures that + # appears next in the file. + + if timecnt: + out.trans_idx = struct.unpack(">%dB" % timecnt, + fileobj.read(timecnt)) + else: + out.trans_idx = [] + + # Each ttinfo structure is written as a four-byte value + # for tt_gmtoff of type long, in a standard byte + # order, followed by a one-byte value for tt_isdst + # and a one-byte value for tt_abbrind. In each + # structure, tt_gmtoff gives the number of + # seconds to be added to UTC, tt_isdst tells whether + # tm_isdst should be set by localtime(3), and + # tt_abbrind serves as an index into the array of + # time zone abbreviation characters that follow the + # ttinfo structure(s) in the file. + + ttinfo = [] + + for i in range(typecnt): + ttinfo.append(struct.unpack(">lbb", fileobj.read(6))) + + abbr = fileobj.read(charcnt).decode() + + # Then there are tzh_leapcnt pairs of four-byte + # values, written in standard byte order; the + # first value of each pair gives the time (as + # returned by time(2)) at which a leap second + # occurs; the second gives the total number of + # leap seconds to be applied after the given time. + # The pairs of values are sorted in ascending order + # by time. + + # Not used, for now (but seek for correct file position) + if leapcnt: + fileobj.seek(leapcnt * 8, os.SEEK_CUR) + + # Then there are tzh_ttisstdcnt standard/wall + # indicators, each stored as a one-byte value; + # they tell whether the transition times associated + # with local time types were specified as standard + # time or wall clock time, and are used when + # a time zone file is used in handling POSIX-style + # time zone environment variables. + + if ttisstdcnt: + isstd = struct.unpack(">%db" % ttisstdcnt, + fileobj.read(ttisstdcnt)) + + # Finally, there are tzh_ttisgmtcnt UTC/local + # indicators, each stored as a one-byte value; + # they tell whether the transition times associated + # with local time types were specified as UTC or + # local time, and are used when a time zone file + # is used in handling POSIX-style time zone envi- + # ronment variables. + + if ttisgmtcnt: + isgmt = struct.unpack(">%db" % ttisgmtcnt, + fileobj.read(ttisgmtcnt)) + + # Build ttinfo list + out.ttinfo_list = [] + for i in range(typecnt): + gmtoff, isdst, abbrind = ttinfo[i] + gmtoff = _get_supported_offset(gmtoff) + tti = _ttinfo() + tti.offset = gmtoff + tti.dstoffset = datetime.timedelta(0) + tti.delta = datetime.timedelta(seconds=gmtoff) + tti.isdst = isdst + tti.abbr = abbr[abbrind:abbr.find('\x00', abbrind)] + tti.isstd = (ttisstdcnt > i and isstd[i] != 0) + tti.isgmt = (ttisgmtcnt > i and isgmt[i] != 0) + out.ttinfo_list.append(tti) + + # Replace ttinfo indexes for ttinfo objects. + out.trans_idx = [out.ttinfo_list[idx] for idx in out.trans_idx] + + # Set standard, dst, and before ttinfos. before will be + # used when a given time is before any transitions, + # and will be set to the first non-dst ttinfo, or to + # the first dst, if all of them are dst. + out.ttinfo_std = None + out.ttinfo_dst = None + out.ttinfo_before = None + if out.ttinfo_list: + if not out.trans_list_utc: + out.ttinfo_std = out.ttinfo_first = out.ttinfo_list[0] + else: + for i in range(timecnt-1, -1, -1): + tti = out.trans_idx[i] + if not out.ttinfo_std and not tti.isdst: + out.ttinfo_std = tti + elif not out.ttinfo_dst and tti.isdst: + out.ttinfo_dst = tti + + if out.ttinfo_std and out.ttinfo_dst: + break + else: + if out.ttinfo_dst and not out.ttinfo_std: + out.ttinfo_std = out.ttinfo_dst + + for tti in out.ttinfo_list: + if not tti.isdst: + out.ttinfo_before = tti + break + else: + out.ttinfo_before = out.ttinfo_list[0] + + # Now fix transition times to become relative to wall time. + # + # I'm not sure about this. In my tests, the tz source file + # is setup to wall time, and in the binary file isstd and + # isgmt are off, so it should be in wall time. OTOH, it's + # always in gmt time. Let me know if you have comments + # about this. + lastdst = None + lastoffset = None + lastdstoffset = None + lastbaseoffset = None + out.trans_list = [] + + for i, tti in enumerate(out.trans_idx): + offset = tti.offset + dstoffset = 0 + + if lastdst is not None: + if tti.isdst: + if not lastdst: + dstoffset = offset - lastoffset + + if not dstoffset and lastdstoffset: + dstoffset = lastdstoffset + + tti.dstoffset = datetime.timedelta(seconds=dstoffset) + lastdstoffset = dstoffset + + # If a time zone changes its base offset during a DST transition, + # then you need to adjust by the previous base offset to get the + # transition time in local time. Otherwise you use the current + # base offset. Ideally, I would have some mathematical proof of + # why this is true, but I haven't really thought about it enough. + baseoffset = offset - dstoffset + adjustment = baseoffset + if (lastbaseoffset is not None and baseoffset != lastbaseoffset + and tti.isdst != lastdst): + # The base DST has changed + adjustment = lastbaseoffset + + lastdst = tti.isdst + lastoffset = offset + lastbaseoffset = baseoffset + + out.trans_list.append(out.trans_list_utc[i] + adjustment) + + out.trans_idx = tuple(out.trans_idx) + out.trans_list = tuple(out.trans_list) + out.trans_list_utc = tuple(out.trans_list_utc) + + return out + + def _find_last_transition(self, dt, in_utc=False): + # If there's no list, there are no transitions to find + if not self._trans_list: + return None + + timestamp = _datetime_to_timestamp(dt) + + # Find where the timestamp fits in the transition list - if the + # timestamp is a transition time, it's part of the "after" period. + trans_list = self._trans_list_utc if in_utc else self._trans_list + idx = bisect.bisect_right(trans_list, timestamp) + + # We want to know when the previous transition was, so subtract off 1 + return idx - 1 + + def _get_ttinfo(self, idx): + # For no list or after the last transition, default to _ttinfo_std + if idx is None or (idx + 1) >= len(self._trans_list): + return self._ttinfo_std + + # If there is a list and the time is before it, return _ttinfo_before + if idx < 0: + return self._ttinfo_before + + return self._trans_idx[idx] + + def _find_ttinfo(self, dt): + idx = self._resolve_ambiguous_time(dt) + + return self._get_ttinfo(idx) + + def fromutc(self, dt): + """ + The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`. + + :param dt: + A :py:class:`datetime.datetime` object. + + :raises TypeError: + Raised if ``dt`` is not a :py:class:`datetime.datetime` object. + + :raises ValueError: + Raised if this is called with a ``dt`` which does not have this + ``tzinfo`` attached. + + :return: + Returns a :py:class:`datetime.datetime` object representing the + wall time in ``self``'s time zone. + """ + # These isinstance checks are in datetime.tzinfo, so we'll preserve + # them, even if we don't care about duck typing. + if not isinstance(dt, datetime.datetime): + raise TypeError("fromutc() requires a datetime argument") + + if dt.tzinfo is not self: + raise ValueError("dt.tzinfo is not self") + + # First treat UTC as wall time and get the transition we're in. + idx = self._find_last_transition(dt, in_utc=True) + tti = self._get_ttinfo(idx) + + dt_out = dt + datetime.timedelta(seconds=tti.offset) + + fold = self.is_ambiguous(dt_out, idx=idx) + + return enfold(dt_out, fold=int(fold)) + + def is_ambiguous(self, dt, idx=None): + """ + Whether or not the "wall time" of a given datetime is ambiguous in this + zone. + + :param dt: + A :py:class:`datetime.datetime`, naive or time zone aware. + + + :return: + Returns ``True`` if ambiguous, ``False`` otherwise. + + .. versionadded:: 2.6.0 + """ + if idx is None: + idx = self._find_last_transition(dt) + + # Calculate the difference in offsets from current to previous + timestamp = _datetime_to_timestamp(dt) + tti = self._get_ttinfo(idx) + + if idx is None or idx <= 0: + return False + + od = self._get_ttinfo(idx - 1).offset - tti.offset + tt = self._trans_list[idx] # Transition time + + return timestamp < tt + od + + def _resolve_ambiguous_time(self, dt): + idx = self._find_last_transition(dt) + + # If we have no transitions, return the index + _fold = self._fold(dt) + if idx is None or idx == 0: + return idx + + # If it's ambiguous and we're in a fold, shift to a different index. + idx_offset = int(not _fold and self.is_ambiguous(dt, idx)) + + return idx - idx_offset + + def utcoffset(self, dt): + if dt is None: + return None + + if not self._ttinfo_std: + return ZERO + + return self._find_ttinfo(dt).delta + + def dst(self, dt): + if dt is None: + return None + + if not self._ttinfo_dst: + return ZERO + + tti = self._find_ttinfo(dt) + + if not tti.isdst: + return ZERO + + # The documentation says that utcoffset()-dst() must + # be constant for every dt. + return tti.dstoffset + + @tzname_in_python2 + def tzname(self, dt): + if not self._ttinfo_std or dt is None: + return None + return self._find_ttinfo(dt).abbr + + def __eq__(self, other): + if not isinstance(other, tzfile): + return NotImplemented + return (self._trans_list == other._trans_list and + self._trans_idx == other._trans_idx and + self._ttinfo_list == other._ttinfo_list) + + __hash__ = None + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "%s(%s)" % (self.__class__.__name__, repr(self._filename)) + + def __reduce__(self): + return self.__reduce_ex__(None) + + def __reduce_ex__(self, protocol): + return (self.__class__, (None, self._filename), self.__dict__) + + +class tzrange(tzrangebase): + """ + The ``tzrange`` object is a time zone specified by a set of offsets and + abbreviations, equivalent to the way the ``TZ`` variable can be specified + in POSIX-like systems, but using Python delta objects to specify DST + start, end and offsets. + + :param stdabbr: + The abbreviation for standard time (e.g. ``'EST'``). + + :param stdoffset: + An integer or :class:`datetime.timedelta` object or equivalent + specifying the base offset from UTC. + + If unspecified, +00:00 is used. + + :param dstabbr: + The abbreviation for DST / "Summer" time (e.g. ``'EDT'``). + + If specified, with no other DST information, DST is assumed to occur + and the default behavior or ``dstoffset``, ``start`` and ``end`` is + used. If unspecified and no other DST information is specified, it + is assumed that this zone has no DST. + + If this is unspecified and other DST information is *is* specified, + DST occurs in the zone but the time zone abbreviation is left + unchanged. + + :param dstoffset: + A an integer or :class:`datetime.timedelta` object or equivalent + specifying the UTC offset during DST. If unspecified and any other DST + information is specified, it is assumed to be the STD offset +1 hour. + + :param start: + A :class:`relativedelta.relativedelta` object or equivalent specifying + the time and time of year that daylight savings time starts. To + specify, for example, that DST starts at 2AM on the 2nd Sunday in + March, pass: + + ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))`` + + If unspecified and any other DST information is specified, the default + value is 2 AM on the first Sunday in April. + + :param end: + A :class:`relativedelta.relativedelta` object or equivalent + representing the time and time of year that daylight savings time + ends, with the same specification method as in ``start``. One note is + that this should point to the first time in the *standard* zone, so if + a transition occurs at 2AM in the DST zone and the clocks are set back + 1 hour to 1AM, set the ``hours`` parameter to +1. + + + **Examples:** + + .. testsetup:: tzrange + + from dateutil.tz import tzrange, tzstr + + .. doctest:: tzrange + + >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT") + True + + >>> from dateutil.relativedelta import * + >>> range1 = tzrange("EST", -18000, "EDT") + >>> range2 = tzrange("EST", -18000, "EDT", -14400, + ... relativedelta(hours=+2, month=4, day=1, + ... weekday=SU(+1)), + ... relativedelta(hours=+1, month=10, day=31, + ... weekday=SU(-1))) + >>> tzstr('EST5EDT') == range1 == range2 + True + + """ + def __init__(self, stdabbr, stdoffset=None, + dstabbr=None, dstoffset=None, + start=None, end=None): + + global relativedelta + from dateutil import relativedelta + + self._std_abbr = stdabbr + self._dst_abbr = dstabbr + + try: + stdoffset = stdoffset.total_seconds() + except (TypeError, AttributeError): + pass + + try: + dstoffset = dstoffset.total_seconds() + except (TypeError, AttributeError): + pass + + if stdoffset is not None: + self._std_offset = datetime.timedelta(seconds=stdoffset) + else: + self._std_offset = ZERO + + if dstoffset is not None: + self._dst_offset = datetime.timedelta(seconds=dstoffset) + elif dstabbr and stdoffset is not None: + self._dst_offset = self._std_offset + datetime.timedelta(hours=+1) + else: + self._dst_offset = ZERO + + if dstabbr and start is None: + self._start_delta = relativedelta.relativedelta( + hours=+2, month=4, day=1, weekday=relativedelta.SU(+1)) + else: + self._start_delta = start + + if dstabbr and end is None: + self._end_delta = relativedelta.relativedelta( + hours=+1, month=10, day=31, weekday=relativedelta.SU(-1)) + else: + self._end_delta = end + + self._dst_base_offset_ = self._dst_offset - self._std_offset + self.hasdst = bool(self._start_delta) + + def transitions(self, year): + """ + For a given year, get the DST on and off transition times, expressed + always on the standard time side. For zones with no transitions, this + function returns ``None``. + + :param year: + The year whose transitions you would like to query. + + :return: + Returns a :class:`tuple` of :class:`datetime.datetime` objects, + ``(dston, dstoff)`` for zones with an annual DST transition, or + ``None`` for fixed offset zones. + """ + if not self.hasdst: + return None + + base_year = datetime.datetime(year, 1, 1) + + start = base_year + self._start_delta + end = base_year + self._end_delta + + return (start, end) + + def __eq__(self, other): + if not isinstance(other, tzrange): + return NotImplemented + + return (self._std_abbr == other._std_abbr and + self._dst_abbr == other._dst_abbr and + self._std_offset == other._std_offset and + self._dst_offset == other._dst_offset and + self._start_delta == other._start_delta and + self._end_delta == other._end_delta) + + @property + def _dst_base_offset(self): + return self._dst_base_offset_ + + +@six.add_metaclass(_TzStrFactory) +class tzstr(tzrange): + """ + ``tzstr`` objects are time zone objects specified by a time-zone string as + it would be passed to a ``TZ`` variable on POSIX-style systems (see + the `GNU C Library: TZ Variable`_ for more details). + + There is one notable exception, which is that POSIX-style time zones use an + inverted offset format, so normally ``GMT+3`` would be parsed as an offset + 3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an + offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX + behavior, pass a ``True`` value to ``posix_offset``. + + The :class:`tzrange` object provides the same functionality, but is + specified using :class:`relativedelta.relativedelta` objects. rather than + strings. + + :param s: + A time zone string in ``TZ`` variable format. This can be a + :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: + :class:`unicode`) or a stream emitting unicode characters + (e.g. :class:`StringIO`). + + :param posix_offset: + Optional. If set to ``True``, interpret strings such as ``GMT+3`` or + ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the + POSIX standard. + + .. caution:: + + Prior to version 2.7.0, this function also supported time zones + in the format: + + * ``EST5EDT,4,0,6,7200,10,0,26,7200,3600`` + * ``EST5EDT,4,1,0,7200,10,-1,0,7200,3600`` + + This format is non-standard and has been deprecated; this function + will raise a :class:`DeprecatedTZFormatWarning` until + support is removed in a future version. + + .. _`GNU C Library: TZ Variable`: + https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + """ + def __init__(self, s, posix_offset=False): + global parser + from dateutil.parser import _parser as parser + + self._s = s + + res = parser._parsetz(s) + if res is None or res.any_unused_tokens: + raise ValueError("unknown string format") + + # Here we break the compatibility with the TZ variable handling. + # GMT-3 actually *means* the timezone -3. + if res.stdabbr in ("GMT", "UTC") and not posix_offset: + res.stdoffset *= -1 + + # We must initialize it first, since _delta() needs + # _std_offset and _dst_offset set. Use False in start/end + # to avoid building it two times. + tzrange.__init__(self, res.stdabbr, res.stdoffset, + res.dstabbr, res.dstoffset, + start=False, end=False) + + if not res.dstabbr: + self._start_delta = None + self._end_delta = None + else: + self._start_delta = self._delta(res.start) + if self._start_delta: + self._end_delta = self._delta(res.end, isend=1) + + self.hasdst = bool(self._start_delta) + + def _delta(self, x, isend=0): + from dateutil import relativedelta + kwargs = {} + if x.month is not None: + kwargs["month"] = x.month + if x.weekday is not None: + kwargs["weekday"] = relativedelta.weekday(x.weekday, x.week) + if x.week > 0: + kwargs["day"] = 1 + else: + kwargs["day"] = 31 + elif x.day: + kwargs["day"] = x.day + elif x.yday is not None: + kwargs["yearday"] = x.yday + elif x.jyday is not None: + kwargs["nlyearday"] = x.jyday + if not kwargs: + # Default is to start on first sunday of april, and end + # on last sunday of october. + if not isend: + kwargs["month"] = 4 + kwargs["day"] = 1 + kwargs["weekday"] = relativedelta.SU(+1) + else: + kwargs["month"] = 10 + kwargs["day"] = 31 + kwargs["weekday"] = relativedelta.SU(-1) + if x.time is not None: + kwargs["seconds"] = x.time + else: + # Default is 2AM. + kwargs["seconds"] = 7200 + if isend: + # Convert to standard time, to follow the documented way + # of working with the extra hour. See the documentation + # of the tzinfo class. + delta = self._dst_offset - self._std_offset + kwargs["seconds"] -= delta.seconds + delta.days * 86400 + return relativedelta.relativedelta(**kwargs) + + def __repr__(self): + return "%s(%s)" % (self.__class__.__name__, repr(self._s)) + + +class _tzicalvtzcomp(object): + def __init__(self, tzoffsetfrom, tzoffsetto, isdst, + tzname=None, rrule=None): + self.tzoffsetfrom = datetime.timedelta(seconds=tzoffsetfrom) + self.tzoffsetto = datetime.timedelta(seconds=tzoffsetto) + self.tzoffsetdiff = self.tzoffsetto - self.tzoffsetfrom + self.isdst = isdst + self.tzname = tzname + self.rrule = rrule + + +class _tzicalvtz(_tzinfo): + def __init__(self, tzid, comps=[]): + super(_tzicalvtz, self).__init__() + + self._tzid = tzid + self._comps = comps + self._cachedate = [] + self._cachecomp = [] + self._cache_lock = _thread.allocate_lock() + + def _find_comp(self, dt): + if len(self._comps) == 1: + return self._comps[0] + + dt = dt.replace(tzinfo=None) + + try: + with self._cache_lock: + return self._cachecomp[self._cachedate.index( + (dt, self._fold(dt)))] + except ValueError: + pass + + lastcompdt = None + lastcomp = None + + for comp in self._comps: + compdt = self._find_compdt(comp, dt) + + if compdt and (not lastcompdt or lastcompdt < compdt): + lastcompdt = compdt + lastcomp = comp + + if not lastcomp: + # RFC says nothing about what to do when a given + # time is before the first onset date. We'll look for the + # first standard component, or the first component, if + # none is found. + for comp in self._comps: + if not comp.isdst: + lastcomp = comp + break + else: + lastcomp = comp[0] + + with self._cache_lock: + self._cachedate.insert(0, (dt, self._fold(dt))) + self._cachecomp.insert(0, lastcomp) + + if len(self._cachedate) > 10: + self._cachedate.pop() + self._cachecomp.pop() + + return lastcomp + + def _find_compdt(self, comp, dt): + if comp.tzoffsetdiff < ZERO and self._fold(dt): + dt -= comp.tzoffsetdiff + + compdt = comp.rrule.before(dt, inc=True) + + return compdt + + def utcoffset(self, dt): + if dt is None: + return None + + return self._find_comp(dt).tzoffsetto + + def dst(self, dt): + comp = self._find_comp(dt) + if comp.isdst: + return comp.tzoffsetdiff + else: + return ZERO + + @tzname_in_python2 + def tzname(self, dt): + return self._find_comp(dt).tzname + + def __repr__(self): + return "" % repr(self._tzid) + + __reduce__ = object.__reduce__ + + +class tzical(object): + """ + This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure + as set out in `RFC 5545`_ Section 4.6.5 into one or more `tzinfo` objects. + + :param `fileobj`: + A file or stream in iCalendar format, which should be UTF-8 encoded + with CRLF endings. + + .. _`RFC 5545`: https://tools.ietf.org/html/rfc5545 + """ + def __init__(self, fileobj): + global rrule + from dateutil import rrule + + if isinstance(fileobj, string_types): + self._s = fileobj + # ical should be encoded in UTF-8 with CRLF + fileobj = open(fileobj, 'r') + else: + self._s = getattr(fileobj, 'name', repr(fileobj)) + fileobj = _nullcontext(fileobj) + + self._vtz = {} + + with fileobj as fobj: + self._parse_rfc(fobj.read()) + + def keys(self): + """ + Retrieves the available time zones as a list. + """ + return list(self._vtz.keys()) + + def get(self, tzid=None): + """ + Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``. + + :param tzid: + If there is exactly one time zone available, omitting ``tzid`` + or passing :py:const:`None` value returns it. Otherwise a valid + key (which can be retrieved from :func:`keys`) is required. + + :raises ValueError: + Raised if ``tzid`` is not specified but there are either more + or fewer than 1 zone defined. + + :returns: + Returns either a :py:class:`datetime.tzinfo` object representing + the relevant time zone or :py:const:`None` if the ``tzid`` was + not found. + """ + if tzid is None: + if len(self._vtz) == 0: + raise ValueError("no timezones defined") + elif len(self._vtz) > 1: + raise ValueError("more than one timezone available") + tzid = next(iter(self._vtz)) + + return self._vtz.get(tzid) + + def _parse_offset(self, s): + s = s.strip() + if not s: + raise ValueError("empty offset") + if s[0] in ('+', '-'): + signal = (-1, +1)[s[0] == '+'] + s = s[1:] + else: + signal = +1 + if len(s) == 4: + return (int(s[:2]) * 3600 + int(s[2:]) * 60) * signal + elif len(s) == 6: + return (int(s[:2]) * 3600 + int(s[2:4]) * 60 + int(s[4:])) * signal + else: + raise ValueError("invalid offset: " + s) + + def _parse_rfc(self, s): + lines = s.splitlines() + if not lines: + raise ValueError("empty string") + + # Unfold + i = 0 + while i < len(lines): + line = lines[i].rstrip() + if not line: + del lines[i] + elif i > 0 and line[0] == " ": + lines[i-1] += line[1:] + del lines[i] + else: + i += 1 + + tzid = None + comps = [] + invtz = False + comptype = None + for line in lines: + if not line: + continue + name, value = line.split(':', 1) + parms = name.split(';') + if not parms: + raise ValueError("empty property name") + name = parms[0].upper() + parms = parms[1:] + if invtz: + if name == "BEGIN": + if value in ("STANDARD", "DAYLIGHT"): + # Process component + pass + else: + raise ValueError("unknown component: "+value) + comptype = value + founddtstart = False + tzoffsetfrom = None + tzoffsetto = None + rrulelines = [] + tzname = None + elif name == "END": + if value == "VTIMEZONE": + if comptype: + raise ValueError("component not closed: "+comptype) + if not tzid: + raise ValueError("mandatory TZID not found") + if not comps: + raise ValueError( + "at least one component is needed") + # Process vtimezone + self._vtz[tzid] = _tzicalvtz(tzid, comps) + invtz = False + elif value == comptype: + if not founddtstart: + raise ValueError("mandatory DTSTART not found") + if tzoffsetfrom is None: + raise ValueError( + "mandatory TZOFFSETFROM not found") + if tzoffsetto is None: + raise ValueError( + "mandatory TZOFFSETFROM not found") + # Process component + rr = None + if rrulelines: + rr = rrule.rrulestr("\n".join(rrulelines), + compatible=True, + ignoretz=True, + cache=True) + comp = _tzicalvtzcomp(tzoffsetfrom, tzoffsetto, + (comptype == "DAYLIGHT"), + tzname, rr) + comps.append(comp) + comptype = None + else: + raise ValueError("invalid component end: "+value) + elif comptype: + if name == "DTSTART": + # DTSTART in VTIMEZONE takes a subset of valid RRULE + # values under RFC 5545. + for parm in parms: + if parm != 'VALUE=DATE-TIME': + msg = ('Unsupported DTSTART param in ' + + 'VTIMEZONE: ' + parm) + raise ValueError(msg) + rrulelines.append(line) + founddtstart = True + elif name in ("RRULE", "RDATE", "EXRULE", "EXDATE"): + rrulelines.append(line) + elif name == "TZOFFSETFROM": + if parms: + raise ValueError( + "unsupported %s parm: %s " % (name, parms[0])) + tzoffsetfrom = self._parse_offset(value) + elif name == "TZOFFSETTO": + if parms: + raise ValueError( + "unsupported TZOFFSETTO parm: "+parms[0]) + tzoffsetto = self._parse_offset(value) + elif name == "TZNAME": + if parms: + raise ValueError( + "unsupported TZNAME parm: "+parms[0]) + tzname = value + elif name == "COMMENT": + pass + else: + raise ValueError("unsupported property: "+name) + else: + if name == "TZID": + if parms: + raise ValueError( + "unsupported TZID parm: "+parms[0]) + tzid = value + elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"): + pass + else: + raise ValueError("unsupported property: "+name) + elif name == "BEGIN" and value == "VTIMEZONE": + tzid = None + comps = [] + invtz = True + + def __repr__(self): + return "%s(%s)" % (self.__class__.__name__, repr(self._s)) + + +if sys.platform != "win32": + TZFILES = ["/etc/localtime", "localtime"] + TZPATHS = ["/usr/share/zoneinfo", + "/usr/lib/zoneinfo", + "/usr/share/lib/zoneinfo", + "/etc/zoneinfo"] +else: + TZFILES = [] + TZPATHS = [] + + +def __get_gettz(): + tzlocal_classes = (tzlocal,) + if tzwinlocal is not None: + tzlocal_classes += (tzwinlocal,) + + class GettzFunc(object): + """ + Retrieve a time zone object from a string representation + + This function is intended to retrieve the :py:class:`tzinfo` subclass + that best represents the time zone that would be used if a POSIX + `TZ variable`_ were set to the same value. + + If no argument or an empty string is passed to ``gettz``, local time + is returned: + + .. code-block:: python3 + + >>> gettz() + tzfile('/etc/localtime') + + This function is also the preferred way to map IANA tz database keys + to :class:`tzfile` objects: + + .. code-block:: python3 + + >>> gettz('Pacific/Kiritimati') + tzfile('/usr/share/zoneinfo/Pacific/Kiritimati') + + On Windows, the standard is extended to include the Windows-specific + zone names provided by the operating system: + + .. code-block:: python3 + + >>> gettz('Egypt Standard Time') + tzwin('Egypt Standard Time') + + Passing a GNU ``TZ`` style string time zone specification returns a + :class:`tzstr` object: + + .. code-block:: python3 + + >>> gettz('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3') + tzstr('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3') + + :param name: + A time zone name (IANA, or, on Windows, Windows keys), location of + a ``tzfile(5)`` zoneinfo file or ``TZ`` variable style time zone + specifier. An empty string, no argument or ``None`` is interpreted + as local time. + + :return: + Returns an instance of one of ``dateutil``'s :py:class:`tzinfo` + subclasses. + + .. versionchanged:: 2.7.0 + + After version 2.7.0, any two calls to ``gettz`` using the same + input strings will return the same object: + + .. code-block:: python3 + + >>> tz.gettz('America/Chicago') is tz.gettz('America/Chicago') + True + + In addition to improving performance, this ensures that + `"same zone" semantics`_ are used for datetimes in the same zone. + + + .. _`TZ variable`: + https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + + .. _`"same zone" semantics`: + https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html + """ + def __init__(self): + + self.__instances = weakref.WeakValueDictionary() + self.__strong_cache_size = 8 + self.__strong_cache = OrderedDict() + self._cache_lock = _thread.allocate_lock() + + def __call__(self, name=None): + with self._cache_lock: + rv = self.__instances.get(name, None) + + if rv is None: + rv = self.nocache(name=name) + if not (name is None + or isinstance(rv, tzlocal_classes) + or rv is None): + # tzlocal is slightly more complicated than the other + # time zone providers because it depends on environment + # at construction time, so don't cache that. + # + # We also cannot store weak references to None, so we + # will also not store that. + self.__instances[name] = rv + else: + # No need for strong caching, return immediately + return rv + + self.__strong_cache[name] = self.__strong_cache.pop(name, rv) + + if len(self.__strong_cache) > self.__strong_cache_size: + self.__strong_cache.popitem(last=False) + + return rv + + def set_cache_size(self, size): + with self._cache_lock: + self.__strong_cache_size = size + while len(self.__strong_cache) > size: + self.__strong_cache.popitem(last=False) + + def cache_clear(self): + with self._cache_lock: + self.__instances = weakref.WeakValueDictionary() + self.__strong_cache.clear() + + @staticmethod + def nocache(name=None): + """A non-cached version of gettz""" + tz = None + if not name: + try: + name = os.environ["TZ"] + except KeyError: + pass + if name is None or name in ("", ":"): + for filepath in TZFILES: + if not os.path.isabs(filepath): + filename = filepath + for path in TZPATHS: + filepath = os.path.join(path, filename) + if os.path.isfile(filepath): + break + else: + continue + if os.path.isfile(filepath): + try: + tz = tzfile(filepath) + break + except (IOError, OSError, ValueError): + pass + else: + tz = tzlocal() + else: + try: + if name.startswith(":"): + name = name[1:] + except TypeError as e: + if isinstance(name, bytes): + new_msg = "gettz argument should be str, not bytes" + six.raise_from(TypeError(new_msg), e) + else: + raise + if os.path.isabs(name): + if os.path.isfile(name): + tz = tzfile(name) + else: + tz = None + else: + for path in TZPATHS: + filepath = os.path.join(path, name) + if not os.path.isfile(filepath): + filepath = filepath.replace(' ', '_') + if not os.path.isfile(filepath): + continue + try: + tz = tzfile(filepath) + break + except (IOError, OSError, ValueError): + pass + else: + tz = None + if tzwin is not None: + try: + tz = tzwin(name) + except (WindowsError, UnicodeEncodeError): + # UnicodeEncodeError is for Python 2.7 compat + tz = None + + if not tz: + from dateutil.zoneinfo import get_zonefile_instance + tz = get_zonefile_instance().get(name) + + if not tz: + for c in name: + # name is not a tzstr unless it has at least + # one offset. For short values of "name", an + # explicit for loop seems to be the fastest way + # To determine if a string contains a digit + if c in "0123456789": + try: + tz = tzstr(name) + except ValueError: + pass + break + else: + if name in ("GMT", "UTC"): + tz = UTC + elif name in time.tzname: + tz = tzlocal() + return tz + + return GettzFunc() + + +gettz = __get_gettz() +del __get_gettz + + +def datetime_exists(dt, tz=None): + """ + Given a datetime and a time zone, determine whether or not a given datetime + would fall in a gap. + + :param dt: + A :class:`datetime.datetime` (whose time zone will be ignored if ``tz`` + is provided.) + + :param tz: + A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If + ``None`` or not provided, the datetime's own time zone will be used. + + :return: + Returns a boolean value whether or not the "wall time" exists in + ``tz``. + + .. versionadded:: 2.7.0 + """ + if tz is None: + if dt.tzinfo is None: + raise ValueError('Datetime is naive and no time zone provided.') + tz = dt.tzinfo + + dt = dt.replace(tzinfo=None) + + # This is essentially a test of whether or not the datetime can survive + # a round trip to UTC. + dt_rt = dt.replace(tzinfo=tz).astimezone(UTC).astimezone(tz) + dt_rt = dt_rt.replace(tzinfo=None) + + return dt == dt_rt + + +def datetime_ambiguous(dt, tz=None): + """ + Given a datetime and a time zone, determine whether or not a given datetime + is ambiguous (i.e if there are two times differentiated only by their DST + status). + + :param dt: + A :class:`datetime.datetime` (whose time zone will be ignored if ``tz`` + is provided.) + + :param tz: + A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If + ``None`` or not provided, the datetime's own time zone will be used. + + :return: + Returns a boolean value whether or not the "wall time" is ambiguous in + ``tz``. + + .. versionadded:: 2.6.0 + """ + if tz is None: + if dt.tzinfo is None: + raise ValueError('Datetime is naive and no time zone provided.') + + tz = dt.tzinfo + + # If a time zone defines its own "is_ambiguous" function, we'll use that. + is_ambiguous_fn = getattr(tz, 'is_ambiguous', None) + if is_ambiguous_fn is not None: + try: + return tz.is_ambiguous(dt) + except Exception: + pass + + # If it doesn't come out and tell us it's ambiguous, we'll just check if + # the fold attribute has any effect on this particular date and time. + dt = dt.replace(tzinfo=tz) + wall_0 = enfold(dt, fold=0) + wall_1 = enfold(dt, fold=1) + + same_offset = wall_0.utcoffset() == wall_1.utcoffset() + same_dst = wall_0.dst() == wall_1.dst() + + return not (same_offset and same_dst) + + +def resolve_imaginary(dt): + """ + Given a datetime that may be imaginary, return an existing datetime. + + This function assumes that an imaginary datetime represents what the + wall time would be in a zone had the offset transition not occurred, so + it will always fall forward by the transition's change in offset. + + .. doctest:: + + >>> from dateutil import tz + >>> from datetime import datetime + >>> NYC = tz.gettz('America/New_York') + >>> print(tz.resolve_imaginary(datetime(2017, 3, 12, 2, 30, tzinfo=NYC))) + 2017-03-12 03:30:00-04:00 + + >>> KIR = tz.gettz('Pacific/Kiritimati') + >>> print(tz.resolve_imaginary(datetime(1995, 1, 1, 12, 30, tzinfo=KIR))) + 1995-01-02 12:30:00+14:00 + + As a note, :func:`datetime.astimezone` is guaranteed to produce a valid, + existing datetime, so a round-trip to and from UTC is sufficient to get + an extant datetime, however, this generally "falls back" to an earlier time + rather than falling forward to the STD side (though no guarantees are made + about this behavior). + + :param dt: + A :class:`datetime.datetime` which may or may not exist. + + :return: + Returns an existing :class:`datetime.datetime`. If ``dt`` was not + imaginary, the datetime returned is guaranteed to be the same object + passed to the function. + + .. versionadded:: 2.7.0 + """ + if dt.tzinfo is not None and not datetime_exists(dt): + + curr_offset = (dt + datetime.timedelta(hours=24)).utcoffset() + old_offset = (dt - datetime.timedelta(hours=24)).utcoffset() + + dt += curr_offset - old_offset + + return dt + + +def _datetime_to_timestamp(dt): + """ + Convert a :class:`datetime.datetime` object to an epoch timestamp in + seconds since January 1, 1970, ignoring the time zone. + """ + return (dt.replace(tzinfo=None) - EPOCH).total_seconds() + + +if sys.version_info >= (3, 6): + def _get_supported_offset(second_offset): + return second_offset +else: + def _get_supported_offset(second_offset): + # For python pre-3.6, round to full-minutes if that's not the case. + # Python's datetime doesn't accept sub-minute timezones. Check + # http://python.org/sf/1447945 or https://bugs.python.org/issue5288 + # for some information. + old_offset = second_offset + calculated_offset = 60 * ((second_offset + 30) // 60) + return calculated_offset + + +try: + # Python 3.7 feature + from contextlib import nullcontext as _nullcontext +except ImportError: + class _nullcontext(object): + """ + Class for wrapping contexts so that they are passed through in a + with statement. + """ + def __init__(self, context): + self.context = context + + def __enter__(self): + return self.context + + def __exit__(*args, **kwargs): + pass + +# vim:ts=4:sw=4:et diff --git a/venv/lib/python3.10/site-packages/dateutil/tz/win.py b/venv/lib/python3.10/site-packages/dateutil/tz/win.py new file mode 100644 index 00000000..cde07ba7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tz/win.py @@ -0,0 +1,370 @@ +# -*- coding: utf-8 -*- +""" +This module provides an interface to the native time zone data on Windows, +including :py:class:`datetime.tzinfo` implementations. + +Attempting to import this module on a non-Windows platform will raise an +:py:obj:`ImportError`. +""" +# This code was originally contributed by Jeffrey Harris. +import datetime +import struct + +from six.moves import winreg +from six import text_type + +try: + import ctypes + from ctypes import wintypes +except ValueError: + # ValueError is raised on non-Windows systems for some horrible reason. + raise ImportError("Running tzwin on non-Windows system") + +from ._common import tzrangebase + +__all__ = ["tzwin", "tzwinlocal", "tzres"] + +ONEWEEK = datetime.timedelta(7) + +TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" +TZKEYNAME9X = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones" +TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation" + + +def _settzkeyname(): + handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) + try: + winreg.OpenKey(handle, TZKEYNAMENT).Close() + TZKEYNAME = TZKEYNAMENT + except WindowsError: + TZKEYNAME = TZKEYNAME9X + handle.Close() + return TZKEYNAME + + +TZKEYNAME = _settzkeyname() + + +class tzres(object): + """ + Class for accessing ``tzres.dll``, which contains timezone name related + resources. + + .. versionadded:: 2.5.0 + """ + p_wchar = ctypes.POINTER(wintypes.WCHAR) # Pointer to a wide char + + def __init__(self, tzres_loc='tzres.dll'): + # Load the user32 DLL so we can load strings from tzres + user32 = ctypes.WinDLL('user32') + + # Specify the LoadStringW function + user32.LoadStringW.argtypes = (wintypes.HINSTANCE, + wintypes.UINT, + wintypes.LPWSTR, + ctypes.c_int) + + self.LoadStringW = user32.LoadStringW + self._tzres = ctypes.WinDLL(tzres_loc) + self.tzres_loc = tzres_loc + + def load_name(self, offset): + """ + Load a timezone name from a DLL offset (integer). + + >>> from dateutil.tzwin import tzres + >>> tzr = tzres() + >>> print(tzr.load_name(112)) + 'Eastern Standard Time' + + :param offset: + A positive integer value referring to a string from the tzres dll. + + .. note:: + + Offsets found in the registry are generally of the form + ``@tzres.dll,-114``. The offset in this case is 114, not -114. + + """ + resource = self.p_wchar() + lpBuffer = ctypes.cast(ctypes.byref(resource), wintypes.LPWSTR) + nchar = self.LoadStringW(self._tzres._handle, offset, lpBuffer, 0) + return resource[:nchar] + + def name_from_string(self, tzname_str): + """ + Parse strings as returned from the Windows registry into the time zone + name as defined in the registry. + + >>> from dateutil.tzwin import tzres + >>> tzr = tzres() + >>> print(tzr.name_from_string('@tzres.dll,-251')) + 'Dateline Daylight Time' + >>> print(tzr.name_from_string('Eastern Standard Time')) + 'Eastern Standard Time' + + :param tzname_str: + A timezone name string as returned from a Windows registry key. + + :return: + Returns the localized timezone string from tzres.dll if the string + is of the form `@tzres.dll,-offset`, else returns the input string. + """ + if not tzname_str.startswith('@'): + return tzname_str + + name_splt = tzname_str.split(',-') + try: + offset = int(name_splt[1]) + except: + raise ValueError("Malformed timezone string.") + + return self.load_name(offset) + + +class tzwinbase(tzrangebase): + """tzinfo class based on win32's timezones available in the registry.""" + def __init__(self): + raise NotImplementedError('tzwinbase is an abstract base class') + + def __eq__(self, other): + # Compare on all relevant dimensions, including name. + if not isinstance(other, tzwinbase): + return NotImplemented + + return (self._std_offset == other._std_offset and + self._dst_offset == other._dst_offset and + self._stddayofweek == other._stddayofweek and + self._dstdayofweek == other._dstdayofweek and + self._stdweeknumber == other._stdweeknumber and + self._dstweeknumber == other._dstweeknumber and + self._stdhour == other._stdhour and + self._dsthour == other._dsthour and + self._stdminute == other._stdminute and + self._dstminute == other._dstminute and + self._std_abbr == other._std_abbr and + self._dst_abbr == other._dst_abbr) + + @staticmethod + def list(): + """Return a list of all time zones known to the system.""" + with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle: + with winreg.OpenKey(handle, TZKEYNAME) as tzkey: + result = [winreg.EnumKey(tzkey, i) + for i in range(winreg.QueryInfoKey(tzkey)[0])] + return result + + def display(self): + """ + Return the display name of the time zone. + """ + return self._display + + def transitions(self, year): + """ + For a given year, get the DST on and off transition times, expressed + always on the standard time side. For zones with no transitions, this + function returns ``None``. + + :param year: + The year whose transitions you would like to query. + + :return: + Returns a :class:`tuple` of :class:`datetime.datetime` objects, + ``(dston, dstoff)`` for zones with an annual DST transition, or + ``None`` for fixed offset zones. + """ + + if not self.hasdst: + return None + + dston = picknthweekday(year, self._dstmonth, self._dstdayofweek, + self._dsthour, self._dstminute, + self._dstweeknumber) + + dstoff = picknthweekday(year, self._stdmonth, self._stddayofweek, + self._stdhour, self._stdminute, + self._stdweeknumber) + + # Ambiguous dates default to the STD side + dstoff -= self._dst_base_offset + + return dston, dstoff + + def _get_hasdst(self): + return self._dstmonth != 0 + + @property + def _dst_base_offset(self): + return self._dst_base_offset_ + + +class tzwin(tzwinbase): + """ + Time zone object created from the zone info in the Windows registry + + These are similar to :py:class:`dateutil.tz.tzrange` objects in that + the time zone data is provided in the format of a single offset rule + for either 0 or 2 time zone transitions per year. + + :param: name + The name of a Windows time zone key, e.g. "Eastern Standard Time". + The full list of keys can be retrieved with :func:`tzwin.list`. + """ + + def __init__(self, name): + self._name = name + + with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle: + tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name) + with winreg.OpenKey(handle, tzkeyname) as tzkey: + keydict = valuestodict(tzkey) + + self._std_abbr = keydict["Std"] + self._dst_abbr = keydict["Dlt"] + + self._display = keydict["Display"] + + # See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm + tup = struct.unpack("=3l16h", keydict["TZI"]) + stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1 + dstoffset = stdoffset-tup[2] # + DaylightBias * -1 + self._std_offset = datetime.timedelta(minutes=stdoffset) + self._dst_offset = datetime.timedelta(minutes=dstoffset) + + # for the meaning see the win32 TIME_ZONE_INFORMATION structure docs + # http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx + (self._stdmonth, + self._stddayofweek, # Sunday = 0 + self._stdweeknumber, # Last = 5 + self._stdhour, + self._stdminute) = tup[4:9] + + (self._dstmonth, + self._dstdayofweek, # Sunday = 0 + self._dstweeknumber, # Last = 5 + self._dsthour, + self._dstminute) = tup[12:17] + + self._dst_base_offset_ = self._dst_offset - self._std_offset + self.hasdst = self._get_hasdst() + + def __repr__(self): + return "tzwin(%s)" % repr(self._name) + + def __reduce__(self): + return (self.__class__, (self._name,)) + + +class tzwinlocal(tzwinbase): + """ + Class representing the local time zone information in the Windows registry + + While :class:`dateutil.tz.tzlocal` makes system calls (via the :mod:`time` + module) to retrieve time zone information, ``tzwinlocal`` retrieves the + rules directly from the Windows registry and creates an object like + :class:`dateutil.tz.tzwin`. + + Because Windows does not have an equivalent of :func:`time.tzset`, on + Windows, :class:`dateutil.tz.tzlocal` instances will always reflect the + time zone settings *at the time that the process was started*, meaning + changes to the machine's time zone settings during the run of a program + on Windows will **not** be reflected by :class:`dateutil.tz.tzlocal`. + Because ``tzwinlocal`` reads the registry directly, it is unaffected by + this issue. + """ + def __init__(self): + with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle: + with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey: + keydict = valuestodict(tzlocalkey) + + self._std_abbr = keydict["StandardName"] + self._dst_abbr = keydict["DaylightName"] + + try: + tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME, + sn=self._std_abbr) + with winreg.OpenKey(handle, tzkeyname) as tzkey: + _keydict = valuestodict(tzkey) + self._display = _keydict["Display"] + except OSError: + self._display = None + + stdoffset = -keydict["Bias"]-keydict["StandardBias"] + dstoffset = stdoffset-keydict["DaylightBias"] + + self._std_offset = datetime.timedelta(minutes=stdoffset) + self._dst_offset = datetime.timedelta(minutes=dstoffset) + + # For reasons unclear, in this particular key, the day of week has been + # moved to the END of the SYSTEMTIME structure. + tup = struct.unpack("=8h", keydict["StandardStart"]) + + (self._stdmonth, + self._stdweeknumber, # Last = 5 + self._stdhour, + self._stdminute) = tup[1:5] + + self._stddayofweek = tup[7] + + tup = struct.unpack("=8h", keydict["DaylightStart"]) + + (self._dstmonth, + self._dstweeknumber, # Last = 5 + self._dsthour, + self._dstminute) = tup[1:5] + + self._dstdayofweek = tup[7] + + self._dst_base_offset_ = self._dst_offset - self._std_offset + self.hasdst = self._get_hasdst() + + def __repr__(self): + return "tzwinlocal()" + + def __str__(self): + # str will return the standard name, not the daylight name. + return "tzwinlocal(%s)" % repr(self._std_abbr) + + def __reduce__(self): + return (self.__class__, ()) + + +def picknthweekday(year, month, dayofweek, hour, minute, whichweek): + """ dayofweek == 0 means Sunday, whichweek 5 means last instance """ + first = datetime.datetime(year, month, 1, hour, minute) + + # This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6), + # Because 7 % 7 = 0 + weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1) + wd = weekdayone + ((whichweek - 1) * ONEWEEK) + if (wd.month != month): + wd -= ONEWEEK + + return wd + + +def valuestodict(key): + """Convert a registry key's values to a dictionary.""" + dout = {} + size = winreg.QueryInfoKey(key)[1] + tz_res = None + + for i in range(size): + key_name, value, dtype = winreg.EnumValue(key, i) + if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN: + # If it's a DWORD (32-bit integer), it's stored as unsigned - convert + # that to a proper signed integer + if value & (1 << 31): + value = value - (1 << 32) + elif dtype == winreg.REG_SZ: + # If it's a reference to the tzres DLL, load the actual string + if value.startswith('@tzres'): + tz_res = tz_res or tzres() + value = tz_res.name_from_string(value) + + value = value.rstrip('\x00') # Remove trailing nulls + + dout[key_name] = value + + return dout diff --git a/venv/lib/python3.10/site-packages/dateutil/tzwin.py b/venv/lib/python3.10/site-packages/dateutil/tzwin.py new file mode 100644 index 00000000..cebc673e --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/tzwin.py @@ -0,0 +1,2 @@ +# tzwin has moved to dateutil.tz.win +from .tz.win import * diff --git a/venv/lib/python3.10/site-packages/dateutil/utils.py b/venv/lib/python3.10/site-packages/dateutil/utils.py new file mode 100644 index 00000000..dd2d245a --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/utils.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +""" +This module offers general convenience and utility functions for dealing with +datetimes. + +.. versionadded:: 2.7.0 +""" +from __future__ import unicode_literals + +from datetime import datetime, time + + +def today(tzinfo=None): + """ + Returns a :py:class:`datetime` representing the current day at midnight + + :param tzinfo: + The time zone to attach (also used to determine the current day). + + :return: + A :py:class:`datetime.datetime` object representing the current day + at midnight. + """ + + dt = datetime.now(tzinfo) + return datetime.combine(dt.date(), time(0, tzinfo=tzinfo)) + + +def default_tzinfo(dt, tzinfo): + """ + Sets the ``tzinfo`` parameter on naive datetimes only + + This is useful for example when you are provided a datetime that may have + either an implicit or explicit time zone, such as when parsing a time zone + string. + + .. doctest:: + + >>> from dateutil.tz import tzoffset + >>> from dateutil.parser import parse + >>> from dateutil.utils import default_tzinfo + >>> dflt_tz = tzoffset("EST", -18000) + >>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz)) + 2014-01-01 12:30:00+00:00 + >>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz)) + 2014-01-01 12:30:00-05:00 + + :param dt: + The datetime on which to replace the time zone + + :param tzinfo: + The :py:class:`datetime.tzinfo` subclass instance to assign to + ``dt`` if (and only if) it is naive. + + :return: + Returns an aware :py:class:`datetime.datetime`. + """ + if dt.tzinfo is not None: + return dt + else: + return dt.replace(tzinfo=tzinfo) + + +def within_delta(dt1, dt2, delta): + """ + Useful for comparing two datetimes that may have a negligible difference + to be considered equal. + """ + delta = abs(delta) + difference = dt1 - dt2 + return -delta <= difference <= delta diff --git a/venv/lib/python3.10/site-packages/dateutil/zoneinfo/__init__.py b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/__init__.py new file mode 100644 index 00000000..34f11ad6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/__init__.py @@ -0,0 +1,167 @@ +# -*- coding: utf-8 -*- +import warnings +import json + +from tarfile import TarFile +from pkgutil import get_data +from io import BytesIO + +from dateutil.tz import tzfile as _tzfile + +__all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"] + +ZONEFILENAME = "dateutil-zoneinfo.tar.gz" +METADATA_FN = 'METADATA' + + +class tzfile(_tzfile): + def __reduce__(self): + return (gettz, (self._filename,)) + + +def getzoneinfofile_stream(): + try: + return BytesIO(get_data(__name__, ZONEFILENAME)) + except IOError as e: # TODO switch to FileNotFoundError? + warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) + return None + + +class ZoneInfoFile(object): + def __init__(self, zonefile_stream=None): + if zonefile_stream is not None: + with TarFile.open(fileobj=zonefile_stream) as tf: + self.zones = {zf.name: tzfile(tf.extractfile(zf), filename=zf.name) + for zf in tf.getmembers() + if zf.isfile() and zf.name != METADATA_FN} + # deal with links: They'll point to their parent object. Less + # waste of memory + links = {zl.name: self.zones[zl.linkname] + for zl in tf.getmembers() if + zl.islnk() or zl.issym()} + self.zones.update(links) + try: + metadata_json = tf.extractfile(tf.getmember(METADATA_FN)) + metadata_str = metadata_json.read().decode('UTF-8') + self.metadata = json.loads(metadata_str) + except KeyError: + # no metadata in tar file + self.metadata = None + else: + self.zones = {} + self.metadata = None + + def get(self, name, default=None): + """ + Wrapper for :func:`ZoneInfoFile.zones.get`. This is a convenience method + for retrieving zones from the zone dictionary. + + :param name: + The name of the zone to retrieve. (Generally IANA zone names) + + :param default: + The value to return in the event of a missing key. + + .. versionadded:: 2.6.0 + + """ + return self.zones.get(name, default) + + +# The current API has gettz as a module function, although in fact it taps into +# a stateful class. So as a workaround for now, without changing the API, we +# will create a new "global" class instance the first time a user requests a +# timezone. Ugly, but adheres to the api. +# +# TODO: Remove after deprecation period. +_CLASS_ZONE_INSTANCE = [] + + +def get_zonefile_instance(new_instance=False): + """ + This is a convenience function which provides a :class:`ZoneInfoFile` + instance using the data provided by the ``dateutil`` package. By default, it + caches a single instance of the ZoneInfoFile object and returns that. + + :param new_instance: + If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and + used as the cached instance for the next call. Otherwise, new instances + are created only as necessary. + + :return: + Returns a :class:`ZoneInfoFile` object. + + .. versionadded:: 2.6 + """ + if new_instance: + zif = None + else: + zif = getattr(get_zonefile_instance, '_cached_instance', None) + + if zif is None: + zif = ZoneInfoFile(getzoneinfofile_stream()) + + get_zonefile_instance._cached_instance = zif + + return zif + + +def gettz(name): + """ + This retrieves a time zone from the local zoneinfo tarball that is packaged + with dateutil. + + :param name: + An IANA-style time zone name, as found in the zoneinfo file. + + :return: + Returns a :class:`dateutil.tz.tzfile` time zone object. + + .. warning:: + It is generally inadvisable to use this function, and it is only + provided for API compatibility with earlier versions. This is *not* + equivalent to ``dateutil.tz.gettz()``, which selects an appropriate + time zone based on the inputs, favoring system zoneinfo. This is ONLY + for accessing the dateutil-specific zoneinfo (which may be out of + date compared to the system zoneinfo). + + .. deprecated:: 2.6 + If you need to use a specific zoneinfofile over the system zoneinfo, + instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call + :func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead. + + Use :func:`get_zonefile_instance` to retrieve an instance of the + dateutil-provided zoneinfo. + """ + warnings.warn("zoneinfo.gettz() will be removed in future versions, " + "to use the dateutil-provided zoneinfo files, instantiate a " + "ZoneInfoFile object and use ZoneInfoFile.zones.get() " + "instead. See the documentation for details.", + DeprecationWarning) + + if len(_CLASS_ZONE_INSTANCE) == 0: + _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream())) + return _CLASS_ZONE_INSTANCE[0].zones.get(name) + + +def gettz_db_metadata(): + """ Get the zonefile metadata + + See `zonefile_metadata`_ + + :returns: + A dictionary with the database metadata + + .. deprecated:: 2.6 + See deprecation warning in :func:`zoneinfo.gettz`. To get metadata, + query the attribute ``zoneinfo.ZoneInfoFile.metadata``. + """ + warnings.warn("zoneinfo.gettz_db_metadata() will be removed in future " + "versions, to use the dateutil-provided zoneinfo files, " + "ZoneInfoFile object and query the 'metadata' attribute " + "instead. See the documentation for details.", + DeprecationWarning) + + if len(_CLASS_ZONE_INSTANCE) == 0: + _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream())) + return _CLASS_ZONE_INSTANCE[0].metadata diff --git a/venv/lib/python3.10/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz new file mode 100644 index 00000000..1461f8c8 Binary files /dev/null and b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz differ diff --git a/venv/lib/python3.10/site-packages/dateutil/zoneinfo/rebuild.py b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/rebuild.py new file mode 100644 index 00000000..684c6586 --- /dev/null +++ b/venv/lib/python3.10/site-packages/dateutil/zoneinfo/rebuild.py @@ -0,0 +1,75 @@ +import logging +import os +import tempfile +import shutil +import json +from subprocess import check_call, check_output +from tarfile import TarFile + +from dateutil.zoneinfo import METADATA_FN, ZONEFILENAME + + +def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None): + """Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar* + + filename is the timezone tarball from ``ftp.iana.org/tz``. + + """ + tmpdir = tempfile.mkdtemp() + zonedir = os.path.join(tmpdir, "zoneinfo") + moduledir = os.path.dirname(__file__) + try: + with TarFile.open(filename) as tf: + for name in zonegroups: + tf.extract(name, tmpdir) + filepaths = [os.path.join(tmpdir, n) for n in zonegroups] + + _run_zic(zonedir, filepaths) + + # write metadata file + with open(os.path.join(zonedir, METADATA_FN), 'w') as f: + json.dump(metadata, f, indent=4, sort_keys=True) + target = os.path.join(moduledir, ZONEFILENAME) + with TarFile.open(target, "w:%s" % format) as tf: + for entry in os.listdir(zonedir): + entrypath = os.path.join(zonedir, entry) + tf.add(entrypath, entry) + finally: + shutil.rmtree(tmpdir) + + +def _run_zic(zonedir, filepaths): + """Calls the ``zic`` compiler in a compatible way to get a "fat" binary. + + Recent versions of ``zic`` default to ``-b slim``, while older versions + don't even have the ``-b`` option (but default to "fat" binaries). The + current version of dateutil does not support Version 2+ TZif files, which + causes problems when used in conjunction with "slim" binaries, so this + function is used to ensure that we always get a "fat" binary. + """ + + try: + help_text = check_output(["zic", "--help"]) + except OSError as e: + _print_on_nosuchfile(e) + raise + + if b"-b " in help_text: + bloat_args = ["-b", "fat"] + else: + bloat_args = [] + + check_call(["zic"] + bloat_args + ["-d", zonedir] + filepaths) + + +def _print_on_nosuchfile(e): + """Print helpful troubleshooting message + + e is an exception raised by subprocess.check_call() + + """ + if e.errno == 2: + logging.error( + "Could not find zic. Perhaps you need to install " + "libc-bin or some other package that provides it, " + "or it's not in your PATH?") diff --git a/venv/lib/python3.10/site-packages/distutils-precedence.pth b/venv/lib/python3.10/site-packages/distutils-precedence.pth new file mode 100644 index 00000000..6de4198f --- /dev/null +++ b/venv/lib/python3.10/site-packages/distutils-precedence.pth @@ -0,0 +1 @@ +import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'stdlib') == 'local'; enabled and __import__('_distutils_hack').add_shim(); diff --git a/venv/lib/python3.10/site-packages/fontTools/__init__.py b/venv/lib/python3.10/site-packages/fontTools/__init__.py new file mode 100644 index 00000000..0de5c155 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/__init__.py @@ -0,0 +1,8 @@ +import logging +from fontTools.misc.loggingTools import configLogger + +log = logging.getLogger(__name__) + +version = __version__ = "4.53.0" + +__all__ = ["version", "log", "configLogger"] diff --git a/venv/lib/python3.10/site-packages/fontTools/__main__.py b/venv/lib/python3.10/site-packages/fontTools/__main__.py new file mode 100644 index 00000000..7c74ad3c --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/__main__.py @@ -0,0 +1,35 @@ +import sys + + +def main(args=None): + if args is None: + args = sys.argv[1:] + + # TODO Handle library-wide options. Eg.: + # --unicodedata + # --verbose / other logging stuff + + # TODO Allow a way to run arbitrary modules? Useful for setting + # library-wide options and calling another library. Eg.: + # + # $ fonttools --unicodedata=... fontmake ... + # + # This allows for a git-like command where thirdparty commands + # can be added. Should we just try importing the fonttools + # module first and try without if it fails? + + if len(sys.argv) < 2: + sys.argv.append("help") + if sys.argv[1] == "-h" or sys.argv[1] == "--help": + sys.argv[1] = "help" + mod = "fontTools." + sys.argv[1] + sys.argv[1] = sys.argv[0] + " " + sys.argv[1] + del sys.argv[0] + + import runpy + + runpy.run_module(mod, run_name="__main__") + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/venv/lib/python3.10/site-packages/fontTools/afmLib.py b/venv/lib/python3.10/site-packages/fontTools/afmLib.py new file mode 100644 index 00000000..0aabf7f6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/afmLib.py @@ -0,0 +1,439 @@ +"""Module for reading and writing AFM (Adobe Font Metrics) files. + +Note that this has been designed to read in AFM files generated by Fontographer +and has not been tested on many other files. In particular, it does not +implement the whole Adobe AFM specification [#f1]_ but, it should read most +"common" AFM files. + +Here is an example of using `afmLib` to read, modify and write an AFM file: + + >>> from fontTools.afmLib import AFM + >>> f = AFM("Tests/afmLib/data/TestAFM.afm") + >>> + >>> # Accessing a pair gets you the kern value + >>> f[("V","A")] + -60 + >>> + >>> # Accessing a glyph name gets you metrics + >>> f["A"] + (65, 668, (8, -25, 660, 666)) + >>> # (charnum, width, bounding box) + >>> + >>> # Accessing an attribute gets you metadata + >>> f.FontName + 'TestFont-Regular' + >>> f.FamilyName + 'TestFont' + >>> f.Weight + 'Regular' + >>> f.XHeight + 500 + >>> f.Ascender + 750 + >>> + >>> # Attributes and items can also be set + >>> f[("A","V")] = -150 # Tighten kerning + >>> f.FontName = "TestFont Squished" + >>> + >>> # And the font written out again (remove the # in front) + >>> #f.write("testfont-squished.afm") + +.. rubric:: Footnotes + +.. [#f1] `Adobe Technote 5004 `_, + Adobe Font Metrics File Format Specification. + +""" + +import re + +# every single line starts with a "word" +identifierRE = re.compile(r"^([A-Za-z]+).*") + +# regular expression to parse char lines +charRE = re.compile( + r"(-?\d+)" # charnum + r"\s*;\s*WX\s+" # ; WX + r"(-?\d+)" # width + r"\s*;\s*N\s+" # ; N + r"([.A-Za-z0-9_]+)" # charname + r"\s*;\s*B\s+" # ; B + r"(-?\d+)" # left + r"\s+" + r"(-?\d+)" # bottom + r"\s+" + r"(-?\d+)" # right + r"\s+" + r"(-?\d+)" # top + r"\s*;\s*" # ; +) + +# regular expression to parse kerning lines +kernRE = re.compile( + r"([.A-Za-z0-9_]+)" # leftchar + r"\s+" + r"([.A-Za-z0-9_]+)" # rightchar + r"\s+" + r"(-?\d+)" # value + r"\s*" +) + +# regular expressions to parse composite info lines of the form: +# Aacute 2 ; PCC A 0 0 ; PCC acute 182 211 ; +compositeRE = re.compile( + r"([.A-Za-z0-9_]+)" # char name + r"\s+" + r"(\d+)" # number of parts + r"\s*;\s*" +) +componentRE = re.compile( + r"PCC\s+" # PPC + r"([.A-Za-z0-9_]+)" # base char name + r"\s+" + r"(-?\d+)" # x offset + r"\s+" + r"(-?\d+)" # y offset + r"\s*;\s*" +) + +preferredAttributeOrder = [ + "FontName", + "FullName", + "FamilyName", + "Weight", + "ItalicAngle", + "IsFixedPitch", + "FontBBox", + "UnderlinePosition", + "UnderlineThickness", + "Version", + "Notice", + "EncodingScheme", + "CapHeight", + "XHeight", + "Ascender", + "Descender", +] + + +class error(Exception): + pass + + +class AFM(object): + _attrs = None + + _keywords = [ + "StartFontMetrics", + "EndFontMetrics", + "StartCharMetrics", + "EndCharMetrics", + "StartKernData", + "StartKernPairs", + "EndKernPairs", + "EndKernData", + "StartComposites", + "EndComposites", + ] + + def __init__(self, path=None): + """AFM file reader. + + Instantiating an object with a path name will cause the file to be opened, + read, and parsed. Alternatively the path can be left unspecified, and a + file can be parsed later with the :meth:`read` method.""" + self._attrs = {} + self._chars = {} + self._kerning = {} + self._index = {} + self._comments = [] + self._composites = {} + if path is not None: + self.read(path) + + def read(self, path): + """Opens, reads and parses a file.""" + lines = readlines(path) + for line in lines: + if not line.strip(): + continue + m = identifierRE.match(line) + if m is None: + raise error("syntax error in AFM file: " + repr(line)) + + pos = m.regs[1][1] + word = line[:pos] + rest = line[pos:].strip() + if word in self._keywords: + continue + if word == "C": + self.parsechar(rest) + elif word == "KPX": + self.parsekernpair(rest) + elif word == "CC": + self.parsecomposite(rest) + else: + self.parseattr(word, rest) + + def parsechar(self, rest): + m = charRE.match(rest) + if m is None: + raise error("syntax error in AFM file: " + repr(rest)) + things = [] + for fr, to in m.regs[1:]: + things.append(rest[fr:to]) + charname = things[2] + del things[2] + charnum, width, l, b, r, t = (int(thing) for thing in things) + self._chars[charname] = charnum, width, (l, b, r, t) + + def parsekernpair(self, rest): + m = kernRE.match(rest) + if m is None: + raise error("syntax error in AFM file: " + repr(rest)) + things = [] + for fr, to in m.regs[1:]: + things.append(rest[fr:to]) + leftchar, rightchar, value = things + value = int(value) + self._kerning[(leftchar, rightchar)] = value + + def parseattr(self, word, rest): + if word == "FontBBox": + l, b, r, t = [int(thing) for thing in rest.split()] + self._attrs[word] = l, b, r, t + elif word == "Comment": + self._comments.append(rest) + else: + try: + value = int(rest) + except (ValueError, OverflowError): + self._attrs[word] = rest + else: + self._attrs[word] = value + + def parsecomposite(self, rest): + m = compositeRE.match(rest) + if m is None: + raise error("syntax error in AFM file: " + repr(rest)) + charname = m.group(1) + ncomponents = int(m.group(2)) + rest = rest[m.regs[0][1] :] + components = [] + while True: + m = componentRE.match(rest) + if m is None: + raise error("syntax error in AFM file: " + repr(rest)) + basechar = m.group(1) + xoffset = int(m.group(2)) + yoffset = int(m.group(3)) + components.append((basechar, xoffset, yoffset)) + rest = rest[m.regs[0][1] :] + if not rest: + break + assert len(components) == ncomponents + self._composites[charname] = components + + def write(self, path, sep="\r"): + """Writes out an AFM font to the given path.""" + import time + + lines = [ + "StartFontMetrics 2.0", + "Comment Generated by afmLib; at %s" + % (time.strftime("%m/%d/%Y %H:%M:%S", time.localtime(time.time()))), + ] + + # write comments, assuming (possibly wrongly!) they should + # all appear at the top + for comment in self._comments: + lines.append("Comment " + comment) + + # write attributes, first the ones we know about, in + # a preferred order + attrs = self._attrs + for attr in preferredAttributeOrder: + if attr in attrs: + value = attrs[attr] + if attr == "FontBBox": + value = "%s %s %s %s" % value + lines.append(attr + " " + str(value)) + # then write the attributes we don't know about, + # in alphabetical order + items = sorted(attrs.items()) + for attr, value in items: + if attr in preferredAttributeOrder: + continue + lines.append(attr + " " + str(value)) + + # write char metrics + lines.append("StartCharMetrics " + repr(len(self._chars))) + items = [ + (charnum, (charname, width, box)) + for charname, (charnum, width, box) in self._chars.items() + ] + + def myKey(a): + """Custom key function to make sure unencoded chars (-1) + end up at the end of the list after sorting.""" + if a[0] == -1: + a = (0xFFFF,) + a[1:] # 0xffff is an arbitrary large number + return a + + items.sort(key=myKey) + + for charnum, (charname, width, (l, b, r, t)) in items: + lines.append( + "C %d ; WX %d ; N %s ; B %d %d %d %d ;" + % (charnum, width, charname, l, b, r, t) + ) + lines.append("EndCharMetrics") + + # write kerning info + lines.append("StartKernData") + lines.append("StartKernPairs " + repr(len(self._kerning))) + items = sorted(self._kerning.items()) + for (leftchar, rightchar), value in items: + lines.append("KPX %s %s %d" % (leftchar, rightchar, value)) + lines.append("EndKernPairs") + lines.append("EndKernData") + + if self._composites: + composites = sorted(self._composites.items()) + lines.append("StartComposites %s" % len(self._composites)) + for charname, components in composites: + line = "CC %s %s ;" % (charname, len(components)) + for basechar, xoffset, yoffset in components: + line = line + " PCC %s %s %s ;" % (basechar, xoffset, yoffset) + lines.append(line) + lines.append("EndComposites") + + lines.append("EndFontMetrics") + + writelines(path, lines, sep) + + def has_kernpair(self, pair): + """Returns `True` if the given glyph pair (specified as a tuple) exists + in the kerning dictionary.""" + return pair in self._kerning + + def kernpairs(self): + """Returns a list of all kern pairs in the kerning dictionary.""" + return list(self._kerning.keys()) + + def has_char(self, char): + """Returns `True` if the given glyph exists in the font.""" + return char in self._chars + + def chars(self): + """Returns a list of all glyph names in the font.""" + return list(self._chars.keys()) + + def comments(self): + """Returns all comments from the file.""" + return self._comments + + def addComment(self, comment): + """Adds a new comment to the file.""" + self._comments.append(comment) + + def addComposite(self, glyphName, components): + """Specifies that the glyph `glyphName` is made up of the given components. + The components list should be of the following form:: + + [ + (glyphname, xOffset, yOffset), + ... + ] + + """ + self._composites[glyphName] = components + + def __getattr__(self, attr): + if attr in self._attrs: + return self._attrs[attr] + else: + raise AttributeError(attr) + + def __setattr__(self, attr, value): + # all attrs *not* starting with "_" are consider to be AFM keywords + if attr[:1] == "_": + self.__dict__[attr] = value + else: + self._attrs[attr] = value + + def __delattr__(self, attr): + # all attrs *not* starting with "_" are consider to be AFM keywords + if attr[:1] == "_": + try: + del self.__dict__[attr] + except KeyError: + raise AttributeError(attr) + else: + try: + del self._attrs[attr] + except KeyError: + raise AttributeError(attr) + + def __getitem__(self, key): + if isinstance(key, tuple): + # key is a tuple, return the kernpair + return self._kerning[key] + else: + # return the metrics instead + return self._chars[key] + + def __setitem__(self, key, value): + if isinstance(key, tuple): + # key is a tuple, set kernpair + self._kerning[key] = value + else: + # set char metrics + self._chars[key] = value + + def __delitem__(self, key): + if isinstance(key, tuple): + # key is a tuple, del kernpair + del self._kerning[key] + else: + # del char metrics + del self._chars[key] + + def __repr__(self): + if hasattr(self, "FullName"): + return "" % self.FullName + else: + return "" % id(self) + + +def readlines(path): + with open(path, "r", encoding="ascii") as f: + data = f.read() + return data.splitlines() + + +def writelines(path, lines, sep="\r"): + with open(path, "w", encoding="ascii", newline=sep) as f: + f.write("\n".join(lines) + "\n") + + +if __name__ == "__main__": + import EasyDialogs + + path = EasyDialogs.AskFileForOpen() + if path: + afm = AFM(path) + char = "A" + if afm.has_char(char): + print(afm[char]) # print charnum, width and boundingbox + pair = ("A", "V") + if afm.has_kernpair(pair): + print(afm[pair]) # print kerning value for pair + print(afm.Version) # various other afm entries have become attributes + print(afm.Weight) + # afm.comments() returns a list of all Comment lines found in the AFM + print(afm.comments()) + # print afm.chars() + # print afm.kernpairs() + print(afm) + afm.write(path + ".muck") diff --git a/venv/lib/python3.10/site-packages/fontTools/agl.py b/venv/lib/python3.10/site-packages/fontTools/agl.py new file mode 100644 index 00000000..d6994628 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/agl.py @@ -0,0 +1,5233 @@ +# -*- coding: utf-8 -*- +# The tables below are taken from +# https://github.com/adobe-type-tools/agl-aglfn/raw/4036a9ca80a62f64f9de4f7321a9a045ad0ecfd6/glyphlist.txt +# and +# https://github.com/adobe-type-tools/agl-aglfn/raw/4036a9ca80a62f64f9de4f7321a9a045ad0ecfd6/aglfn.txt +""" +Interface to the Adobe Glyph List + +This module exists to convert glyph names from the Adobe Glyph List +to their Unicode equivalents. Example usage: + + >>> from fontTools.agl import toUnicode + >>> toUnicode("nahiragana") + 'な' + +It also contains two dictionaries, ``UV2AGL`` and ``AGL2UV``, which map from +Unicode codepoints to AGL names and vice versa: + + >>> import fontTools + >>> fontTools.agl.UV2AGL[ord("?")] + 'question' + >>> fontTools.agl.AGL2UV["wcircumflex"] + 373 + +This is used by fontTools when it has to construct glyph names for a font which +doesn't include any (e.g. format 3.0 post tables). +""" + +from fontTools.misc.textTools import tostr +import re + + +_aglText = """\ +# ----------------------------------------------------------- +# Copyright 2002-2019 Adobe (http://www.adobe.com/). +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the +# following conditions are met: +# +# Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# Neither the name of Adobe nor the names of its contributors +# may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------- +# Name: Adobe Glyph List +# Table version: 2.0 +# Date: September 20, 2002 +# URL: https://github.com/adobe-type-tools/agl-aglfn +# +# Format: two semicolon-delimited fields: +# (1) glyph name--upper/lowercase letters and digits +# (2) Unicode scalar value--four uppercase hexadecimal digits +# +A;0041 +AE;00C6 +AEacute;01FC +AEmacron;01E2 +AEsmall;F7E6 +Aacute;00C1 +Aacutesmall;F7E1 +Abreve;0102 +Abreveacute;1EAE +Abrevecyrillic;04D0 +Abrevedotbelow;1EB6 +Abrevegrave;1EB0 +Abrevehookabove;1EB2 +Abrevetilde;1EB4 +Acaron;01CD +Acircle;24B6 +Acircumflex;00C2 +Acircumflexacute;1EA4 +Acircumflexdotbelow;1EAC +Acircumflexgrave;1EA6 +Acircumflexhookabove;1EA8 +Acircumflexsmall;F7E2 +Acircumflextilde;1EAA +Acute;F6C9 +Acutesmall;F7B4 +Acyrillic;0410 +Adblgrave;0200 +Adieresis;00C4 +Adieresiscyrillic;04D2 +Adieresismacron;01DE +Adieresissmall;F7E4 +Adotbelow;1EA0 +Adotmacron;01E0 +Agrave;00C0 +Agravesmall;F7E0 +Ahookabove;1EA2 +Aiecyrillic;04D4 +Ainvertedbreve;0202 +Alpha;0391 +Alphatonos;0386 +Amacron;0100 +Amonospace;FF21 +Aogonek;0104 +Aring;00C5 +Aringacute;01FA +Aringbelow;1E00 +Aringsmall;F7E5 +Asmall;F761 +Atilde;00C3 +Atildesmall;F7E3 +Aybarmenian;0531 +B;0042 +Bcircle;24B7 +Bdotaccent;1E02 +Bdotbelow;1E04 +Becyrillic;0411 +Benarmenian;0532 +Beta;0392 +Bhook;0181 +Blinebelow;1E06 +Bmonospace;FF22 +Brevesmall;F6F4 +Bsmall;F762 +Btopbar;0182 +C;0043 +Caarmenian;053E +Cacute;0106 +Caron;F6CA +Caronsmall;F6F5 +Ccaron;010C +Ccedilla;00C7 +Ccedillaacute;1E08 +Ccedillasmall;F7E7 +Ccircle;24B8 +Ccircumflex;0108 +Cdot;010A +Cdotaccent;010A +Cedillasmall;F7B8 +Chaarmenian;0549 +Cheabkhasiancyrillic;04BC +Checyrillic;0427 +Chedescenderabkhasiancyrillic;04BE +Chedescendercyrillic;04B6 +Chedieresiscyrillic;04F4 +Cheharmenian;0543 +Chekhakassiancyrillic;04CB +Cheverticalstrokecyrillic;04B8 +Chi;03A7 +Chook;0187 +Circumflexsmall;F6F6 +Cmonospace;FF23 +Coarmenian;0551 +Csmall;F763 +D;0044 +DZ;01F1 +DZcaron;01C4 +Daarmenian;0534 +Dafrican;0189 +Dcaron;010E +Dcedilla;1E10 +Dcircle;24B9 +Dcircumflexbelow;1E12 +Dcroat;0110 +Ddotaccent;1E0A +Ddotbelow;1E0C +Decyrillic;0414 +Deicoptic;03EE +Delta;2206 +Deltagreek;0394 +Dhook;018A +Dieresis;F6CB +DieresisAcute;F6CC +DieresisGrave;F6CD +Dieresissmall;F7A8 +Digammagreek;03DC +Djecyrillic;0402 +Dlinebelow;1E0E +Dmonospace;FF24 +Dotaccentsmall;F6F7 +Dslash;0110 +Dsmall;F764 +Dtopbar;018B +Dz;01F2 +Dzcaron;01C5 +Dzeabkhasiancyrillic;04E0 +Dzecyrillic;0405 +Dzhecyrillic;040F +E;0045 +Eacute;00C9 +Eacutesmall;F7E9 +Ebreve;0114 +Ecaron;011A +Ecedillabreve;1E1C +Echarmenian;0535 +Ecircle;24BA +Ecircumflex;00CA +Ecircumflexacute;1EBE +Ecircumflexbelow;1E18 +Ecircumflexdotbelow;1EC6 +Ecircumflexgrave;1EC0 +Ecircumflexhookabove;1EC2 +Ecircumflexsmall;F7EA +Ecircumflextilde;1EC4 +Ecyrillic;0404 +Edblgrave;0204 +Edieresis;00CB +Edieresissmall;F7EB +Edot;0116 +Edotaccent;0116 +Edotbelow;1EB8 +Efcyrillic;0424 +Egrave;00C8 +Egravesmall;F7E8 +Eharmenian;0537 +Ehookabove;1EBA +Eightroman;2167 +Einvertedbreve;0206 +Eiotifiedcyrillic;0464 +Elcyrillic;041B +Elevenroman;216A +Emacron;0112 +Emacronacute;1E16 +Emacrongrave;1E14 +Emcyrillic;041C +Emonospace;FF25 +Encyrillic;041D +Endescendercyrillic;04A2 +Eng;014A +Enghecyrillic;04A4 +Enhookcyrillic;04C7 +Eogonek;0118 +Eopen;0190 +Epsilon;0395 +Epsilontonos;0388 +Ercyrillic;0420 +Ereversed;018E +Ereversedcyrillic;042D +Escyrillic;0421 +Esdescendercyrillic;04AA +Esh;01A9 +Esmall;F765 +Eta;0397 +Etarmenian;0538 +Etatonos;0389 +Eth;00D0 +Ethsmall;F7F0 +Etilde;1EBC +Etildebelow;1E1A +Euro;20AC +Ezh;01B7 +Ezhcaron;01EE +Ezhreversed;01B8 +F;0046 +Fcircle;24BB +Fdotaccent;1E1E +Feharmenian;0556 +Feicoptic;03E4 +Fhook;0191 +Fitacyrillic;0472 +Fiveroman;2164 +Fmonospace;FF26 +Fourroman;2163 +Fsmall;F766 +G;0047 +GBsquare;3387 +Gacute;01F4 +Gamma;0393 +Gammaafrican;0194 +Gangiacoptic;03EA +Gbreve;011E +Gcaron;01E6 +Gcedilla;0122 +Gcircle;24BC +Gcircumflex;011C +Gcommaaccent;0122 +Gdot;0120 +Gdotaccent;0120 +Gecyrillic;0413 +Ghadarmenian;0542 +Ghemiddlehookcyrillic;0494 +Ghestrokecyrillic;0492 +Gheupturncyrillic;0490 +Ghook;0193 +Gimarmenian;0533 +Gjecyrillic;0403 +Gmacron;1E20 +Gmonospace;FF27 +Grave;F6CE +Gravesmall;F760 +Gsmall;F767 +Gsmallhook;029B +Gstroke;01E4 +H;0048 +H18533;25CF +H18543;25AA +H18551;25AB +H22073;25A1 +HPsquare;33CB +Haabkhasiancyrillic;04A8 +Hadescendercyrillic;04B2 +Hardsigncyrillic;042A +Hbar;0126 +Hbrevebelow;1E2A +Hcedilla;1E28 +Hcircle;24BD +Hcircumflex;0124 +Hdieresis;1E26 +Hdotaccent;1E22 +Hdotbelow;1E24 +Hmonospace;FF28 +Hoarmenian;0540 +Horicoptic;03E8 +Hsmall;F768 +Hungarumlaut;F6CF +Hungarumlautsmall;F6F8 +Hzsquare;3390 +I;0049 +IAcyrillic;042F +IJ;0132 +IUcyrillic;042E +Iacute;00CD +Iacutesmall;F7ED +Ibreve;012C +Icaron;01CF +Icircle;24BE +Icircumflex;00CE +Icircumflexsmall;F7EE +Icyrillic;0406 +Idblgrave;0208 +Idieresis;00CF +Idieresisacute;1E2E +Idieresiscyrillic;04E4 +Idieresissmall;F7EF +Idot;0130 +Idotaccent;0130 +Idotbelow;1ECA +Iebrevecyrillic;04D6 +Iecyrillic;0415 +Ifraktur;2111 +Igrave;00CC +Igravesmall;F7EC +Ihookabove;1EC8 +Iicyrillic;0418 +Iinvertedbreve;020A +Iishortcyrillic;0419 +Imacron;012A +Imacroncyrillic;04E2 +Imonospace;FF29 +Iniarmenian;053B +Iocyrillic;0401 +Iogonek;012E +Iota;0399 +Iotaafrican;0196 +Iotadieresis;03AA +Iotatonos;038A +Ismall;F769 +Istroke;0197 +Itilde;0128 +Itildebelow;1E2C +Izhitsacyrillic;0474 +Izhitsadblgravecyrillic;0476 +J;004A +Jaarmenian;0541 +Jcircle;24BF +Jcircumflex;0134 +Jecyrillic;0408 +Jheharmenian;054B +Jmonospace;FF2A +Jsmall;F76A +K;004B +KBsquare;3385 +KKsquare;33CD +Kabashkircyrillic;04A0 +Kacute;1E30 +Kacyrillic;041A +Kadescendercyrillic;049A +Kahookcyrillic;04C3 +Kappa;039A +Kastrokecyrillic;049E +Kaverticalstrokecyrillic;049C +Kcaron;01E8 +Kcedilla;0136 +Kcircle;24C0 +Kcommaaccent;0136 +Kdotbelow;1E32 +Keharmenian;0554 +Kenarmenian;053F +Khacyrillic;0425 +Kheicoptic;03E6 +Khook;0198 +Kjecyrillic;040C +Klinebelow;1E34 +Kmonospace;FF2B +Koppacyrillic;0480 +Koppagreek;03DE +Ksicyrillic;046E +Ksmall;F76B +L;004C +LJ;01C7 +LL;F6BF +Lacute;0139 +Lambda;039B +Lcaron;013D +Lcedilla;013B +Lcircle;24C1 +Lcircumflexbelow;1E3C +Lcommaaccent;013B +Ldot;013F +Ldotaccent;013F +Ldotbelow;1E36 +Ldotbelowmacron;1E38 +Liwnarmenian;053C +Lj;01C8 +Ljecyrillic;0409 +Llinebelow;1E3A +Lmonospace;FF2C +Lslash;0141 +Lslashsmall;F6F9 +Lsmall;F76C +M;004D +MBsquare;3386 +Macron;F6D0 +Macronsmall;F7AF +Macute;1E3E +Mcircle;24C2 +Mdotaccent;1E40 +Mdotbelow;1E42 +Menarmenian;0544 +Mmonospace;FF2D +Msmall;F76D +Mturned;019C +Mu;039C +N;004E +NJ;01CA +Nacute;0143 +Ncaron;0147 +Ncedilla;0145 +Ncircle;24C3 +Ncircumflexbelow;1E4A +Ncommaaccent;0145 +Ndotaccent;1E44 +Ndotbelow;1E46 +Nhookleft;019D +Nineroman;2168 +Nj;01CB +Njecyrillic;040A +Nlinebelow;1E48 +Nmonospace;FF2E +Nowarmenian;0546 +Nsmall;F76E +Ntilde;00D1 +Ntildesmall;F7F1 +Nu;039D +O;004F +OE;0152 +OEsmall;F6FA +Oacute;00D3 +Oacutesmall;F7F3 +Obarredcyrillic;04E8 +Obarreddieresiscyrillic;04EA +Obreve;014E +Ocaron;01D1 +Ocenteredtilde;019F +Ocircle;24C4 +Ocircumflex;00D4 +Ocircumflexacute;1ED0 +Ocircumflexdotbelow;1ED8 +Ocircumflexgrave;1ED2 +Ocircumflexhookabove;1ED4 +Ocircumflexsmall;F7F4 +Ocircumflextilde;1ED6 +Ocyrillic;041E +Odblacute;0150 +Odblgrave;020C +Odieresis;00D6 +Odieresiscyrillic;04E6 +Odieresissmall;F7F6 +Odotbelow;1ECC +Ogoneksmall;F6FB +Ograve;00D2 +Ogravesmall;F7F2 +Oharmenian;0555 +Ohm;2126 +Ohookabove;1ECE +Ohorn;01A0 +Ohornacute;1EDA +Ohorndotbelow;1EE2 +Ohorngrave;1EDC +Ohornhookabove;1EDE +Ohorntilde;1EE0 +Ohungarumlaut;0150 +Oi;01A2 +Oinvertedbreve;020E +Omacron;014C +Omacronacute;1E52 +Omacrongrave;1E50 +Omega;2126 +Omegacyrillic;0460 +Omegagreek;03A9 +Omegaroundcyrillic;047A +Omegatitlocyrillic;047C +Omegatonos;038F +Omicron;039F +Omicrontonos;038C +Omonospace;FF2F +Oneroman;2160 +Oogonek;01EA +Oogonekmacron;01EC +Oopen;0186 +Oslash;00D8 +Oslashacute;01FE +Oslashsmall;F7F8 +Osmall;F76F +Ostrokeacute;01FE +Otcyrillic;047E +Otilde;00D5 +Otildeacute;1E4C +Otildedieresis;1E4E +Otildesmall;F7F5 +P;0050 +Pacute;1E54 +Pcircle;24C5 +Pdotaccent;1E56 +Pecyrillic;041F +Peharmenian;054A +Pemiddlehookcyrillic;04A6 +Phi;03A6 +Phook;01A4 +Pi;03A0 +Piwrarmenian;0553 +Pmonospace;FF30 +Psi;03A8 +Psicyrillic;0470 +Psmall;F770 +Q;0051 +Qcircle;24C6 +Qmonospace;FF31 +Qsmall;F771 +R;0052 +Raarmenian;054C +Racute;0154 +Rcaron;0158 +Rcedilla;0156 +Rcircle;24C7 +Rcommaaccent;0156 +Rdblgrave;0210 +Rdotaccent;1E58 +Rdotbelow;1E5A +Rdotbelowmacron;1E5C +Reharmenian;0550 +Rfraktur;211C +Rho;03A1 +Ringsmall;F6FC +Rinvertedbreve;0212 +Rlinebelow;1E5E +Rmonospace;FF32 +Rsmall;F772 +Rsmallinverted;0281 +Rsmallinvertedsuperior;02B6 +S;0053 +SF010000;250C +SF020000;2514 +SF030000;2510 +SF040000;2518 +SF050000;253C +SF060000;252C +SF070000;2534 +SF080000;251C +SF090000;2524 +SF100000;2500 +SF110000;2502 +SF190000;2561 +SF200000;2562 +SF210000;2556 +SF220000;2555 +SF230000;2563 +SF240000;2551 +SF250000;2557 +SF260000;255D +SF270000;255C +SF280000;255B +SF360000;255E +SF370000;255F +SF380000;255A +SF390000;2554 +SF400000;2569 +SF410000;2566 +SF420000;2560 +SF430000;2550 +SF440000;256C +SF450000;2567 +SF460000;2568 +SF470000;2564 +SF480000;2565 +SF490000;2559 +SF500000;2558 +SF510000;2552 +SF520000;2553 +SF530000;256B +SF540000;256A +Sacute;015A +Sacutedotaccent;1E64 +Sampigreek;03E0 +Scaron;0160 +Scarondotaccent;1E66 +Scaronsmall;F6FD +Scedilla;015E +Schwa;018F +Schwacyrillic;04D8 +Schwadieresiscyrillic;04DA +Scircle;24C8 +Scircumflex;015C +Scommaaccent;0218 +Sdotaccent;1E60 +Sdotbelow;1E62 +Sdotbelowdotaccent;1E68 +Seharmenian;054D +Sevenroman;2166 +Shaarmenian;0547 +Shacyrillic;0428 +Shchacyrillic;0429 +Sheicoptic;03E2 +Shhacyrillic;04BA +Shimacoptic;03EC +Sigma;03A3 +Sixroman;2165 +Smonospace;FF33 +Softsigncyrillic;042C +Ssmall;F773 +Stigmagreek;03DA +T;0054 +Tau;03A4 +Tbar;0166 +Tcaron;0164 +Tcedilla;0162 +Tcircle;24C9 +Tcircumflexbelow;1E70 +Tcommaaccent;0162 +Tdotaccent;1E6A +Tdotbelow;1E6C +Tecyrillic;0422 +Tedescendercyrillic;04AC +Tenroman;2169 +Tetsecyrillic;04B4 +Theta;0398 +Thook;01AC +Thorn;00DE +Thornsmall;F7FE +Threeroman;2162 +Tildesmall;F6FE +Tiwnarmenian;054F +Tlinebelow;1E6E +Tmonospace;FF34 +Toarmenian;0539 +Tonefive;01BC +Tonesix;0184 +Tonetwo;01A7 +Tretroflexhook;01AE +Tsecyrillic;0426 +Tshecyrillic;040B +Tsmall;F774 +Twelveroman;216B +Tworoman;2161 +U;0055 +Uacute;00DA +Uacutesmall;F7FA +Ubreve;016C +Ucaron;01D3 +Ucircle;24CA +Ucircumflex;00DB +Ucircumflexbelow;1E76 +Ucircumflexsmall;F7FB +Ucyrillic;0423 +Udblacute;0170 +Udblgrave;0214 +Udieresis;00DC +Udieresisacute;01D7 +Udieresisbelow;1E72 +Udieresiscaron;01D9 +Udieresiscyrillic;04F0 +Udieresisgrave;01DB +Udieresismacron;01D5 +Udieresissmall;F7FC +Udotbelow;1EE4 +Ugrave;00D9 +Ugravesmall;F7F9 +Uhookabove;1EE6 +Uhorn;01AF +Uhornacute;1EE8 +Uhorndotbelow;1EF0 +Uhorngrave;1EEA +Uhornhookabove;1EEC +Uhorntilde;1EEE +Uhungarumlaut;0170 +Uhungarumlautcyrillic;04F2 +Uinvertedbreve;0216 +Ukcyrillic;0478 +Umacron;016A +Umacroncyrillic;04EE +Umacrondieresis;1E7A +Umonospace;FF35 +Uogonek;0172 +Upsilon;03A5 +Upsilon1;03D2 +Upsilonacutehooksymbolgreek;03D3 +Upsilonafrican;01B1 +Upsilondieresis;03AB +Upsilondieresishooksymbolgreek;03D4 +Upsilonhooksymbol;03D2 +Upsilontonos;038E +Uring;016E +Ushortcyrillic;040E +Usmall;F775 +Ustraightcyrillic;04AE +Ustraightstrokecyrillic;04B0 +Utilde;0168 +Utildeacute;1E78 +Utildebelow;1E74 +V;0056 +Vcircle;24CB +Vdotbelow;1E7E +Vecyrillic;0412 +Vewarmenian;054E +Vhook;01B2 +Vmonospace;FF36 +Voarmenian;0548 +Vsmall;F776 +Vtilde;1E7C +W;0057 +Wacute;1E82 +Wcircle;24CC +Wcircumflex;0174 +Wdieresis;1E84 +Wdotaccent;1E86 +Wdotbelow;1E88 +Wgrave;1E80 +Wmonospace;FF37 +Wsmall;F777 +X;0058 +Xcircle;24CD +Xdieresis;1E8C +Xdotaccent;1E8A +Xeharmenian;053D +Xi;039E +Xmonospace;FF38 +Xsmall;F778 +Y;0059 +Yacute;00DD +Yacutesmall;F7FD +Yatcyrillic;0462 +Ycircle;24CE +Ycircumflex;0176 +Ydieresis;0178 +Ydieresissmall;F7FF +Ydotaccent;1E8E +Ydotbelow;1EF4 +Yericyrillic;042B +Yerudieresiscyrillic;04F8 +Ygrave;1EF2 +Yhook;01B3 +Yhookabove;1EF6 +Yiarmenian;0545 +Yicyrillic;0407 +Yiwnarmenian;0552 +Ymonospace;FF39 +Ysmall;F779 +Ytilde;1EF8 +Yusbigcyrillic;046A +Yusbigiotifiedcyrillic;046C +Yuslittlecyrillic;0466 +Yuslittleiotifiedcyrillic;0468 +Z;005A +Zaarmenian;0536 +Zacute;0179 +Zcaron;017D +Zcaronsmall;F6FF +Zcircle;24CF +Zcircumflex;1E90 +Zdot;017B +Zdotaccent;017B +Zdotbelow;1E92 +Zecyrillic;0417 +Zedescendercyrillic;0498 +Zedieresiscyrillic;04DE +Zeta;0396 +Zhearmenian;053A +Zhebrevecyrillic;04C1 +Zhecyrillic;0416 +Zhedescendercyrillic;0496 +Zhedieresiscyrillic;04DC +Zlinebelow;1E94 +Zmonospace;FF3A +Zsmall;F77A +Zstroke;01B5 +a;0061 +aabengali;0986 +aacute;00E1 +aadeva;0906 +aagujarati;0A86 +aagurmukhi;0A06 +aamatragurmukhi;0A3E +aarusquare;3303 +aavowelsignbengali;09BE +aavowelsigndeva;093E +aavowelsigngujarati;0ABE +abbreviationmarkarmenian;055F +abbreviationsigndeva;0970 +abengali;0985 +abopomofo;311A +abreve;0103 +abreveacute;1EAF +abrevecyrillic;04D1 +abrevedotbelow;1EB7 +abrevegrave;1EB1 +abrevehookabove;1EB3 +abrevetilde;1EB5 +acaron;01CE +acircle;24D0 +acircumflex;00E2 +acircumflexacute;1EA5 +acircumflexdotbelow;1EAD +acircumflexgrave;1EA7 +acircumflexhookabove;1EA9 +acircumflextilde;1EAB +acute;00B4 +acutebelowcmb;0317 +acutecmb;0301 +acutecomb;0301 +acutedeva;0954 +acutelowmod;02CF +acutetonecmb;0341 +acyrillic;0430 +adblgrave;0201 +addakgurmukhi;0A71 +adeva;0905 +adieresis;00E4 +adieresiscyrillic;04D3 +adieresismacron;01DF +adotbelow;1EA1 +adotmacron;01E1 +ae;00E6 +aeacute;01FD +aekorean;3150 +aemacron;01E3 +afii00208;2015 +afii08941;20A4 +afii10017;0410 +afii10018;0411 +afii10019;0412 +afii10020;0413 +afii10021;0414 +afii10022;0415 +afii10023;0401 +afii10024;0416 +afii10025;0417 +afii10026;0418 +afii10027;0419 +afii10028;041A +afii10029;041B +afii10030;041C +afii10031;041D +afii10032;041E +afii10033;041F +afii10034;0420 +afii10035;0421 +afii10036;0422 +afii10037;0423 +afii10038;0424 +afii10039;0425 +afii10040;0426 +afii10041;0427 +afii10042;0428 +afii10043;0429 +afii10044;042A +afii10045;042B +afii10046;042C +afii10047;042D +afii10048;042E +afii10049;042F +afii10050;0490 +afii10051;0402 +afii10052;0403 +afii10053;0404 +afii10054;0405 +afii10055;0406 +afii10056;0407 +afii10057;0408 +afii10058;0409 +afii10059;040A +afii10060;040B +afii10061;040C +afii10062;040E +afii10063;F6C4 +afii10064;F6C5 +afii10065;0430 +afii10066;0431 +afii10067;0432 +afii10068;0433 +afii10069;0434 +afii10070;0435 +afii10071;0451 +afii10072;0436 +afii10073;0437 +afii10074;0438 +afii10075;0439 +afii10076;043A +afii10077;043B +afii10078;043C +afii10079;043D +afii10080;043E +afii10081;043F +afii10082;0440 +afii10083;0441 +afii10084;0442 +afii10085;0443 +afii10086;0444 +afii10087;0445 +afii10088;0446 +afii10089;0447 +afii10090;0448 +afii10091;0449 +afii10092;044A +afii10093;044B +afii10094;044C +afii10095;044D +afii10096;044E +afii10097;044F +afii10098;0491 +afii10099;0452 +afii10100;0453 +afii10101;0454 +afii10102;0455 +afii10103;0456 +afii10104;0457 +afii10105;0458 +afii10106;0459 +afii10107;045A +afii10108;045B +afii10109;045C +afii10110;045E +afii10145;040F +afii10146;0462 +afii10147;0472 +afii10148;0474 +afii10192;F6C6 +afii10193;045F +afii10194;0463 +afii10195;0473 +afii10196;0475 +afii10831;F6C7 +afii10832;F6C8 +afii10846;04D9 +afii299;200E +afii300;200F +afii301;200D +afii57381;066A +afii57388;060C +afii57392;0660 +afii57393;0661 +afii57394;0662 +afii57395;0663 +afii57396;0664 +afii57397;0665 +afii57398;0666 +afii57399;0667 +afii57400;0668 +afii57401;0669 +afii57403;061B +afii57407;061F +afii57409;0621 +afii57410;0622 +afii57411;0623 +afii57412;0624 +afii57413;0625 +afii57414;0626 +afii57415;0627 +afii57416;0628 +afii57417;0629 +afii57418;062A +afii57419;062B +afii57420;062C +afii57421;062D +afii57422;062E +afii57423;062F +afii57424;0630 +afii57425;0631 +afii57426;0632 +afii57427;0633 +afii57428;0634 +afii57429;0635 +afii57430;0636 +afii57431;0637 +afii57432;0638 +afii57433;0639 +afii57434;063A +afii57440;0640 +afii57441;0641 +afii57442;0642 +afii57443;0643 +afii57444;0644 +afii57445;0645 +afii57446;0646 +afii57448;0648 +afii57449;0649 +afii57450;064A +afii57451;064B +afii57452;064C +afii57453;064D +afii57454;064E +afii57455;064F +afii57456;0650 +afii57457;0651 +afii57458;0652 +afii57470;0647 +afii57505;06A4 +afii57506;067E +afii57507;0686 +afii57508;0698 +afii57509;06AF +afii57511;0679 +afii57512;0688 +afii57513;0691 +afii57514;06BA +afii57519;06D2 +afii57534;06D5 +afii57636;20AA +afii57645;05BE +afii57658;05C3 +afii57664;05D0 +afii57665;05D1 +afii57666;05D2 +afii57667;05D3 +afii57668;05D4 +afii57669;05D5 +afii57670;05D6 +afii57671;05D7 +afii57672;05D8 +afii57673;05D9 +afii57674;05DA +afii57675;05DB +afii57676;05DC +afii57677;05DD +afii57678;05DE +afii57679;05DF +afii57680;05E0 +afii57681;05E1 +afii57682;05E2 +afii57683;05E3 +afii57684;05E4 +afii57685;05E5 +afii57686;05E6 +afii57687;05E7 +afii57688;05E8 +afii57689;05E9 +afii57690;05EA +afii57694;FB2A +afii57695;FB2B +afii57700;FB4B +afii57705;FB1F +afii57716;05F0 +afii57717;05F1 +afii57718;05F2 +afii57723;FB35 +afii57793;05B4 +afii57794;05B5 +afii57795;05B6 +afii57796;05BB +afii57797;05B8 +afii57798;05B7 +afii57799;05B0 +afii57800;05B2 +afii57801;05B1 +afii57802;05B3 +afii57803;05C2 +afii57804;05C1 +afii57806;05B9 +afii57807;05BC +afii57839;05BD +afii57841;05BF +afii57842;05C0 +afii57929;02BC +afii61248;2105 +afii61289;2113 +afii61352;2116 +afii61573;202C +afii61574;202D +afii61575;202E +afii61664;200C +afii63167;066D +afii64937;02BD +agrave;00E0 +agujarati;0A85 +agurmukhi;0A05 +ahiragana;3042 +ahookabove;1EA3 +aibengali;0990 +aibopomofo;311E +aideva;0910 +aiecyrillic;04D5 +aigujarati;0A90 +aigurmukhi;0A10 +aimatragurmukhi;0A48 +ainarabic;0639 +ainfinalarabic;FECA +aininitialarabic;FECB +ainmedialarabic;FECC +ainvertedbreve;0203 +aivowelsignbengali;09C8 +aivowelsigndeva;0948 +aivowelsigngujarati;0AC8 +akatakana;30A2 +akatakanahalfwidth;FF71 +akorean;314F +alef;05D0 +alefarabic;0627 +alefdageshhebrew;FB30 +aleffinalarabic;FE8E +alefhamzaabovearabic;0623 +alefhamzaabovefinalarabic;FE84 +alefhamzabelowarabic;0625 +alefhamzabelowfinalarabic;FE88 +alefhebrew;05D0 +aleflamedhebrew;FB4F +alefmaddaabovearabic;0622 +alefmaddaabovefinalarabic;FE82 +alefmaksuraarabic;0649 +alefmaksurafinalarabic;FEF0 +alefmaksurainitialarabic;FEF3 +alefmaksuramedialarabic;FEF4 +alefpatahhebrew;FB2E +alefqamatshebrew;FB2F +aleph;2135 +allequal;224C +alpha;03B1 +alphatonos;03AC +amacron;0101 +amonospace;FF41 +ampersand;0026 +ampersandmonospace;FF06 +ampersandsmall;F726 +amsquare;33C2 +anbopomofo;3122 +angbopomofo;3124 +angkhankhuthai;0E5A +angle;2220 +anglebracketleft;3008 +anglebracketleftvertical;FE3F +anglebracketright;3009 +anglebracketrightvertical;FE40 +angleleft;2329 +angleright;232A +angstrom;212B +anoteleia;0387 +anudattadeva;0952 +anusvarabengali;0982 +anusvaradeva;0902 +anusvaragujarati;0A82 +aogonek;0105 +apaatosquare;3300 +aparen;249C +apostrophearmenian;055A +apostrophemod;02BC +apple;F8FF +approaches;2250 +approxequal;2248 +approxequalorimage;2252 +approximatelyequal;2245 +araeaekorean;318E +araeakorean;318D +arc;2312 +arighthalfring;1E9A +aring;00E5 +aringacute;01FB +aringbelow;1E01 +arrowboth;2194 +arrowdashdown;21E3 +arrowdashleft;21E0 +arrowdashright;21E2 +arrowdashup;21E1 +arrowdblboth;21D4 +arrowdbldown;21D3 +arrowdblleft;21D0 +arrowdblright;21D2 +arrowdblup;21D1 +arrowdown;2193 +arrowdownleft;2199 +arrowdownright;2198 +arrowdownwhite;21E9 +arrowheaddownmod;02C5 +arrowheadleftmod;02C2 +arrowheadrightmod;02C3 +arrowheadupmod;02C4 +arrowhorizex;F8E7 +arrowleft;2190 +arrowleftdbl;21D0 +arrowleftdblstroke;21CD +arrowleftoverright;21C6 +arrowleftwhite;21E6 +arrowright;2192 +arrowrightdblstroke;21CF +arrowrightheavy;279E +arrowrightoverleft;21C4 +arrowrightwhite;21E8 +arrowtableft;21E4 +arrowtabright;21E5 +arrowup;2191 +arrowupdn;2195 +arrowupdnbse;21A8 +arrowupdownbase;21A8 +arrowupleft;2196 +arrowupleftofdown;21C5 +arrowupright;2197 +arrowupwhite;21E7 +arrowvertex;F8E6 +asciicircum;005E +asciicircummonospace;FF3E +asciitilde;007E +asciitildemonospace;FF5E +ascript;0251 +ascriptturned;0252 +asmallhiragana;3041 +asmallkatakana;30A1 +asmallkatakanahalfwidth;FF67 +asterisk;002A +asteriskaltonearabic;066D +asteriskarabic;066D +asteriskmath;2217 +asteriskmonospace;FF0A +asterisksmall;FE61 +asterism;2042 +asuperior;F6E9 +asymptoticallyequal;2243 +at;0040 +atilde;00E3 +atmonospace;FF20 +atsmall;FE6B +aturned;0250 +aubengali;0994 +aubopomofo;3120 +audeva;0914 +augujarati;0A94 +augurmukhi;0A14 +aulengthmarkbengali;09D7 +aumatragurmukhi;0A4C +auvowelsignbengali;09CC +auvowelsigndeva;094C +auvowelsigngujarati;0ACC +avagrahadeva;093D +aybarmenian;0561 +ayin;05E2 +ayinaltonehebrew;FB20 +ayinhebrew;05E2 +b;0062 +babengali;09AC +backslash;005C +backslashmonospace;FF3C +badeva;092C +bagujarati;0AAC +bagurmukhi;0A2C +bahiragana;3070 +bahtthai;0E3F +bakatakana;30D0 +bar;007C +barmonospace;FF5C +bbopomofo;3105 +bcircle;24D1 +bdotaccent;1E03 +bdotbelow;1E05 +beamedsixteenthnotes;266C +because;2235 +becyrillic;0431 +beharabic;0628 +behfinalarabic;FE90 +behinitialarabic;FE91 +behiragana;3079 +behmedialarabic;FE92 +behmeeminitialarabic;FC9F +behmeemisolatedarabic;FC08 +behnoonfinalarabic;FC6D +bekatakana;30D9 +benarmenian;0562 +bet;05D1 +beta;03B2 +betasymbolgreek;03D0 +betdagesh;FB31 +betdageshhebrew;FB31 +bethebrew;05D1 +betrafehebrew;FB4C +bhabengali;09AD +bhadeva;092D +bhagujarati;0AAD +bhagurmukhi;0A2D +bhook;0253 +bihiragana;3073 +bikatakana;30D3 +bilabialclick;0298 +bindigurmukhi;0A02 +birusquare;3331 +blackcircle;25CF +blackdiamond;25C6 +blackdownpointingtriangle;25BC +blackleftpointingpointer;25C4 +blackleftpointingtriangle;25C0 +blacklenticularbracketleft;3010 +blacklenticularbracketleftvertical;FE3B +blacklenticularbracketright;3011 +blacklenticularbracketrightvertical;FE3C +blacklowerlefttriangle;25E3 +blacklowerrighttriangle;25E2 +blackrectangle;25AC +blackrightpointingpointer;25BA +blackrightpointingtriangle;25B6 +blacksmallsquare;25AA +blacksmilingface;263B +blacksquare;25A0 +blackstar;2605 +blackupperlefttriangle;25E4 +blackupperrighttriangle;25E5 +blackuppointingsmalltriangle;25B4 +blackuppointingtriangle;25B2 +blank;2423 +blinebelow;1E07 +block;2588 +bmonospace;FF42 +bobaimaithai;0E1A +bohiragana;307C +bokatakana;30DC +bparen;249D +bqsquare;33C3 +braceex;F8F4 +braceleft;007B +braceleftbt;F8F3 +braceleftmid;F8F2 +braceleftmonospace;FF5B +braceleftsmall;FE5B +bracelefttp;F8F1 +braceleftvertical;FE37 +braceright;007D +bracerightbt;F8FE +bracerightmid;F8FD +bracerightmonospace;FF5D +bracerightsmall;FE5C +bracerighttp;F8FC +bracerightvertical;FE38 +bracketleft;005B +bracketleftbt;F8F0 +bracketleftex;F8EF +bracketleftmonospace;FF3B +bracketlefttp;F8EE +bracketright;005D +bracketrightbt;F8FB +bracketrightex;F8FA +bracketrightmonospace;FF3D +bracketrighttp;F8F9 +breve;02D8 +brevebelowcmb;032E +brevecmb;0306 +breveinvertedbelowcmb;032F +breveinvertedcmb;0311 +breveinverteddoublecmb;0361 +bridgebelowcmb;032A +bridgeinvertedbelowcmb;033A +brokenbar;00A6 +bstroke;0180 +bsuperior;F6EA +btopbar;0183 +buhiragana;3076 +bukatakana;30D6 +bullet;2022 +bulletinverse;25D8 +bulletoperator;2219 +bullseye;25CE +c;0063 +caarmenian;056E +cabengali;099A +cacute;0107 +cadeva;091A +cagujarati;0A9A +cagurmukhi;0A1A +calsquare;3388 +candrabindubengali;0981 +candrabinducmb;0310 +candrabindudeva;0901 +candrabindugujarati;0A81 +capslock;21EA +careof;2105 +caron;02C7 +caronbelowcmb;032C +caroncmb;030C +carriagereturn;21B5 +cbopomofo;3118 +ccaron;010D +ccedilla;00E7 +ccedillaacute;1E09 +ccircle;24D2 +ccircumflex;0109 +ccurl;0255 +cdot;010B +cdotaccent;010B +cdsquare;33C5 +cedilla;00B8 +cedillacmb;0327 +cent;00A2 +centigrade;2103 +centinferior;F6DF +centmonospace;FFE0 +centoldstyle;F7A2 +centsuperior;F6E0 +chaarmenian;0579 +chabengali;099B +chadeva;091B +chagujarati;0A9B +chagurmukhi;0A1B +chbopomofo;3114 +cheabkhasiancyrillic;04BD +checkmark;2713 +checyrillic;0447 +chedescenderabkhasiancyrillic;04BF +chedescendercyrillic;04B7 +chedieresiscyrillic;04F5 +cheharmenian;0573 +chekhakassiancyrillic;04CC +cheverticalstrokecyrillic;04B9 +chi;03C7 +chieuchacirclekorean;3277 +chieuchaparenkorean;3217 +chieuchcirclekorean;3269 +chieuchkorean;314A +chieuchparenkorean;3209 +chochangthai;0E0A +chochanthai;0E08 +chochingthai;0E09 +chochoethai;0E0C +chook;0188 +cieucacirclekorean;3276 +cieucaparenkorean;3216 +cieuccirclekorean;3268 +cieuckorean;3148 +cieucparenkorean;3208 +cieucuparenkorean;321C +circle;25CB +circlemultiply;2297 +circleot;2299 +circleplus;2295 +circlepostalmark;3036 +circlewithlefthalfblack;25D0 +circlewithrighthalfblack;25D1 +circumflex;02C6 +circumflexbelowcmb;032D +circumflexcmb;0302 +clear;2327 +clickalveolar;01C2 +clickdental;01C0 +clicklateral;01C1 +clickretroflex;01C3 +club;2663 +clubsuitblack;2663 +clubsuitwhite;2667 +cmcubedsquare;33A4 +cmonospace;FF43 +cmsquaredsquare;33A0 +coarmenian;0581 +colon;003A +colonmonetary;20A1 +colonmonospace;FF1A +colonsign;20A1 +colonsmall;FE55 +colontriangularhalfmod;02D1 +colontriangularmod;02D0 +comma;002C +commaabovecmb;0313 +commaaboverightcmb;0315 +commaaccent;F6C3 +commaarabic;060C +commaarmenian;055D +commainferior;F6E1 +commamonospace;FF0C +commareversedabovecmb;0314 +commareversedmod;02BD +commasmall;FE50 +commasuperior;F6E2 +commaturnedabovecmb;0312 +commaturnedmod;02BB +compass;263C +congruent;2245 +contourintegral;222E +control;2303 +controlACK;0006 +controlBEL;0007 +controlBS;0008 +controlCAN;0018 +controlCR;000D +controlDC1;0011 +controlDC2;0012 +controlDC3;0013 +controlDC4;0014 +controlDEL;007F +controlDLE;0010 +controlEM;0019 +controlENQ;0005 +controlEOT;0004 +controlESC;001B +controlETB;0017 +controlETX;0003 +controlFF;000C +controlFS;001C +controlGS;001D +controlHT;0009 +controlLF;000A +controlNAK;0015 +controlRS;001E +controlSI;000F +controlSO;000E +controlSOT;0002 +controlSTX;0001 +controlSUB;001A +controlSYN;0016 +controlUS;001F +controlVT;000B +copyright;00A9 +copyrightsans;F8E9 +copyrightserif;F6D9 +cornerbracketleft;300C +cornerbracketlefthalfwidth;FF62 +cornerbracketleftvertical;FE41 +cornerbracketright;300D +cornerbracketrighthalfwidth;FF63 +cornerbracketrightvertical;FE42 +corporationsquare;337F +cosquare;33C7 +coverkgsquare;33C6 +cparen;249E +cruzeiro;20A2 +cstretched;0297 +curlyand;22CF +curlyor;22CE +currency;00A4 +cyrBreve;F6D1 +cyrFlex;F6D2 +cyrbreve;F6D4 +cyrflex;F6D5 +d;0064 +daarmenian;0564 +dabengali;09A6 +dadarabic;0636 +dadeva;0926 +dadfinalarabic;FEBE +dadinitialarabic;FEBF +dadmedialarabic;FEC0 +dagesh;05BC +dageshhebrew;05BC +dagger;2020 +daggerdbl;2021 +dagujarati;0AA6 +dagurmukhi;0A26 +dahiragana;3060 +dakatakana;30C0 +dalarabic;062F +dalet;05D3 +daletdagesh;FB33 +daletdageshhebrew;FB33 +dalethatafpatah;05D3 05B2 +dalethatafpatahhebrew;05D3 05B2 +dalethatafsegol;05D3 05B1 +dalethatafsegolhebrew;05D3 05B1 +dalethebrew;05D3 +dalethiriq;05D3 05B4 +dalethiriqhebrew;05D3 05B4 +daletholam;05D3 05B9 +daletholamhebrew;05D3 05B9 +daletpatah;05D3 05B7 +daletpatahhebrew;05D3 05B7 +daletqamats;05D3 05B8 +daletqamatshebrew;05D3 05B8 +daletqubuts;05D3 05BB +daletqubutshebrew;05D3 05BB +daletsegol;05D3 05B6 +daletsegolhebrew;05D3 05B6 +daletsheva;05D3 05B0 +daletshevahebrew;05D3 05B0 +dalettsere;05D3 05B5 +dalettserehebrew;05D3 05B5 +dalfinalarabic;FEAA +dammaarabic;064F +dammalowarabic;064F +dammatanaltonearabic;064C +dammatanarabic;064C +danda;0964 +dargahebrew;05A7 +dargalefthebrew;05A7 +dasiapneumatacyrilliccmb;0485 +dblGrave;F6D3 +dblanglebracketleft;300A +dblanglebracketleftvertical;FE3D +dblanglebracketright;300B +dblanglebracketrightvertical;FE3E +dblarchinvertedbelowcmb;032B +dblarrowleft;21D4 +dblarrowright;21D2 +dbldanda;0965 +dblgrave;F6D6 +dblgravecmb;030F +dblintegral;222C +dbllowline;2017 +dbllowlinecmb;0333 +dbloverlinecmb;033F +dblprimemod;02BA +dblverticalbar;2016 +dblverticallineabovecmb;030E +dbopomofo;3109 +dbsquare;33C8 +dcaron;010F +dcedilla;1E11 +dcircle;24D3 +dcircumflexbelow;1E13 +dcroat;0111 +ddabengali;09A1 +ddadeva;0921 +ddagujarati;0AA1 +ddagurmukhi;0A21 +ddalarabic;0688 +ddalfinalarabic;FB89 +dddhadeva;095C +ddhabengali;09A2 +ddhadeva;0922 +ddhagujarati;0AA2 +ddhagurmukhi;0A22 +ddotaccent;1E0B +ddotbelow;1E0D +decimalseparatorarabic;066B +decimalseparatorpersian;066B +decyrillic;0434 +degree;00B0 +dehihebrew;05AD +dehiragana;3067 +deicoptic;03EF +dekatakana;30C7 +deleteleft;232B +deleteright;2326 +delta;03B4 +deltaturned;018D +denominatorminusonenumeratorbengali;09F8 +dezh;02A4 +dhabengali;09A7 +dhadeva;0927 +dhagujarati;0AA7 +dhagurmukhi;0A27 +dhook;0257 +dialytikatonos;0385 +dialytikatonoscmb;0344 +diamond;2666 +diamondsuitwhite;2662 +dieresis;00A8 +dieresisacute;F6D7 +dieresisbelowcmb;0324 +dieresiscmb;0308 +dieresisgrave;F6D8 +dieresistonos;0385 +dihiragana;3062 +dikatakana;30C2 +dittomark;3003 +divide;00F7 +divides;2223 +divisionslash;2215 +djecyrillic;0452 +dkshade;2593 +dlinebelow;1E0F +dlsquare;3397 +dmacron;0111 +dmonospace;FF44 +dnblock;2584 +dochadathai;0E0E +dodekthai;0E14 +dohiragana;3069 +dokatakana;30C9 +dollar;0024 +dollarinferior;F6E3 +dollarmonospace;FF04 +dollaroldstyle;F724 +dollarsmall;FE69 +dollarsuperior;F6E4 +dong;20AB +dorusquare;3326 +dotaccent;02D9 +dotaccentcmb;0307 +dotbelowcmb;0323 +dotbelowcomb;0323 +dotkatakana;30FB +dotlessi;0131 +dotlessj;F6BE +dotlessjstrokehook;0284 +dotmath;22C5 +dottedcircle;25CC +doubleyodpatah;FB1F +doubleyodpatahhebrew;FB1F +downtackbelowcmb;031E +downtackmod;02D5 +dparen;249F +dsuperior;F6EB +dtail;0256 +dtopbar;018C +duhiragana;3065 +dukatakana;30C5 +dz;01F3 +dzaltone;02A3 +dzcaron;01C6 +dzcurl;02A5 +dzeabkhasiancyrillic;04E1 +dzecyrillic;0455 +dzhecyrillic;045F +e;0065 +eacute;00E9 +earth;2641 +ebengali;098F +ebopomofo;311C +ebreve;0115 +ecandradeva;090D +ecandragujarati;0A8D +ecandravowelsigndeva;0945 +ecandravowelsigngujarati;0AC5 +ecaron;011B +ecedillabreve;1E1D +echarmenian;0565 +echyiwnarmenian;0587 +ecircle;24D4 +ecircumflex;00EA +ecircumflexacute;1EBF +ecircumflexbelow;1E19 +ecircumflexdotbelow;1EC7 +ecircumflexgrave;1EC1 +ecircumflexhookabove;1EC3 +ecircumflextilde;1EC5 +ecyrillic;0454 +edblgrave;0205 +edeva;090F +edieresis;00EB +edot;0117 +edotaccent;0117 +edotbelow;1EB9 +eegurmukhi;0A0F +eematragurmukhi;0A47 +efcyrillic;0444 +egrave;00E8 +egujarati;0A8F +eharmenian;0567 +ehbopomofo;311D +ehiragana;3048 +ehookabove;1EBB +eibopomofo;311F +eight;0038 +eightarabic;0668 +eightbengali;09EE +eightcircle;2467 +eightcircleinversesansserif;2791 +eightdeva;096E +eighteencircle;2471 +eighteenparen;2485 +eighteenperiod;2499 +eightgujarati;0AEE +eightgurmukhi;0A6E +eighthackarabic;0668 +eighthangzhou;3028 +eighthnotebeamed;266B +eightideographicparen;3227 +eightinferior;2088 +eightmonospace;FF18 +eightoldstyle;F738 +eightparen;247B +eightperiod;248F +eightpersian;06F8 +eightroman;2177 +eightsuperior;2078 +eightthai;0E58 +einvertedbreve;0207 +eiotifiedcyrillic;0465 +ekatakana;30A8 +ekatakanahalfwidth;FF74 +ekonkargurmukhi;0A74 +ekorean;3154 +elcyrillic;043B +element;2208 +elevencircle;246A +elevenparen;247E +elevenperiod;2492 +elevenroman;217A +ellipsis;2026 +ellipsisvertical;22EE +emacron;0113 +emacronacute;1E17 +emacrongrave;1E15 +emcyrillic;043C +emdash;2014 +emdashvertical;FE31 +emonospace;FF45 +emphasismarkarmenian;055B +emptyset;2205 +enbopomofo;3123 +encyrillic;043D +endash;2013 +endashvertical;FE32 +endescendercyrillic;04A3 +eng;014B +engbopomofo;3125 +enghecyrillic;04A5 +enhookcyrillic;04C8 +enspace;2002 +eogonek;0119 +eokorean;3153 +eopen;025B +eopenclosed;029A +eopenreversed;025C +eopenreversedclosed;025E +eopenreversedhook;025D +eparen;24A0 +epsilon;03B5 +epsilontonos;03AD +equal;003D +equalmonospace;FF1D +equalsmall;FE66 +equalsuperior;207C +equivalence;2261 +erbopomofo;3126 +ercyrillic;0440 +ereversed;0258 +ereversedcyrillic;044D +escyrillic;0441 +esdescendercyrillic;04AB +esh;0283 +eshcurl;0286 +eshortdeva;090E +eshortvowelsigndeva;0946 +eshreversedloop;01AA +eshsquatreversed;0285 +esmallhiragana;3047 +esmallkatakana;30A7 +esmallkatakanahalfwidth;FF6A +estimated;212E +esuperior;F6EC +eta;03B7 +etarmenian;0568 +etatonos;03AE +eth;00F0 +etilde;1EBD +etildebelow;1E1B +etnahtafoukhhebrew;0591 +etnahtafoukhlefthebrew;0591 +etnahtahebrew;0591 +etnahtalefthebrew;0591 +eturned;01DD +eukorean;3161 +euro;20AC +evowelsignbengali;09C7 +evowelsigndeva;0947 +evowelsigngujarati;0AC7 +exclam;0021 +exclamarmenian;055C +exclamdbl;203C +exclamdown;00A1 +exclamdownsmall;F7A1 +exclammonospace;FF01 +exclamsmall;F721 +existential;2203 +ezh;0292 +ezhcaron;01EF +ezhcurl;0293 +ezhreversed;01B9 +ezhtail;01BA +f;0066 +fadeva;095E +fagurmukhi;0A5E +fahrenheit;2109 +fathaarabic;064E +fathalowarabic;064E +fathatanarabic;064B +fbopomofo;3108 +fcircle;24D5 +fdotaccent;1E1F +feharabic;0641 +feharmenian;0586 +fehfinalarabic;FED2 +fehinitialarabic;FED3 +fehmedialarabic;FED4 +feicoptic;03E5 +female;2640 +ff;FB00 +ffi;FB03 +ffl;FB04 +fi;FB01 +fifteencircle;246E +fifteenparen;2482 +fifteenperiod;2496 +figuredash;2012 +filledbox;25A0 +filledrect;25AC +finalkaf;05DA +finalkafdagesh;FB3A +finalkafdageshhebrew;FB3A +finalkafhebrew;05DA +finalkafqamats;05DA 05B8 +finalkafqamatshebrew;05DA 05B8 +finalkafsheva;05DA 05B0 +finalkafshevahebrew;05DA 05B0 +finalmem;05DD +finalmemhebrew;05DD +finalnun;05DF +finalnunhebrew;05DF +finalpe;05E3 +finalpehebrew;05E3 +finaltsadi;05E5 +finaltsadihebrew;05E5 +firsttonechinese;02C9 +fisheye;25C9 +fitacyrillic;0473 +five;0035 +fivearabic;0665 +fivebengali;09EB +fivecircle;2464 +fivecircleinversesansserif;278E +fivedeva;096B +fiveeighths;215D +fivegujarati;0AEB +fivegurmukhi;0A6B +fivehackarabic;0665 +fivehangzhou;3025 +fiveideographicparen;3224 +fiveinferior;2085 +fivemonospace;FF15 +fiveoldstyle;F735 +fiveparen;2478 +fiveperiod;248C +fivepersian;06F5 +fiveroman;2174 +fivesuperior;2075 +fivethai;0E55 +fl;FB02 +florin;0192 +fmonospace;FF46 +fmsquare;3399 +fofanthai;0E1F +fofathai;0E1D +fongmanthai;0E4F +forall;2200 +four;0034 +fourarabic;0664 +fourbengali;09EA +fourcircle;2463 +fourcircleinversesansserif;278D +fourdeva;096A +fourgujarati;0AEA +fourgurmukhi;0A6A +fourhackarabic;0664 +fourhangzhou;3024 +fourideographicparen;3223 +fourinferior;2084 +fourmonospace;FF14 +fournumeratorbengali;09F7 +fouroldstyle;F734 +fourparen;2477 +fourperiod;248B +fourpersian;06F4 +fourroman;2173 +foursuperior;2074 +fourteencircle;246D +fourteenparen;2481 +fourteenperiod;2495 +fourthai;0E54 +fourthtonechinese;02CB +fparen;24A1 +fraction;2044 +franc;20A3 +g;0067 +gabengali;0997 +gacute;01F5 +gadeva;0917 +gafarabic;06AF +gaffinalarabic;FB93 +gafinitialarabic;FB94 +gafmedialarabic;FB95 +gagujarati;0A97 +gagurmukhi;0A17 +gahiragana;304C +gakatakana;30AC +gamma;03B3 +gammalatinsmall;0263 +gammasuperior;02E0 +gangiacoptic;03EB +gbopomofo;310D +gbreve;011F +gcaron;01E7 +gcedilla;0123 +gcircle;24D6 +gcircumflex;011D +gcommaaccent;0123 +gdot;0121 +gdotaccent;0121 +gecyrillic;0433 +gehiragana;3052 +gekatakana;30B2 +geometricallyequal;2251 +gereshaccenthebrew;059C +gereshhebrew;05F3 +gereshmuqdamhebrew;059D +germandbls;00DF +gershayimaccenthebrew;059E +gershayimhebrew;05F4 +getamark;3013 +ghabengali;0998 +ghadarmenian;0572 +ghadeva;0918 +ghagujarati;0A98 +ghagurmukhi;0A18 +ghainarabic;063A +ghainfinalarabic;FECE +ghaininitialarabic;FECF +ghainmedialarabic;FED0 +ghemiddlehookcyrillic;0495 +ghestrokecyrillic;0493 +gheupturncyrillic;0491 +ghhadeva;095A +ghhagurmukhi;0A5A +ghook;0260 +ghzsquare;3393 +gihiragana;304E +gikatakana;30AE +gimarmenian;0563 +gimel;05D2 +gimeldagesh;FB32 +gimeldageshhebrew;FB32 +gimelhebrew;05D2 +gjecyrillic;0453 +glottalinvertedstroke;01BE +glottalstop;0294 +glottalstopinverted;0296 +glottalstopmod;02C0 +glottalstopreversed;0295 +glottalstopreversedmod;02C1 +glottalstopreversedsuperior;02E4 +glottalstopstroke;02A1 +glottalstopstrokereversed;02A2 +gmacron;1E21 +gmonospace;FF47 +gohiragana;3054 +gokatakana;30B4 +gparen;24A2 +gpasquare;33AC +gradient;2207 +grave;0060 +gravebelowcmb;0316 +gravecmb;0300 +gravecomb;0300 +gravedeva;0953 +gravelowmod;02CE +gravemonospace;FF40 +gravetonecmb;0340 +greater;003E +greaterequal;2265 +greaterequalorless;22DB +greatermonospace;FF1E +greaterorequivalent;2273 +greaterorless;2277 +greateroverequal;2267 +greatersmall;FE65 +gscript;0261 +gstroke;01E5 +guhiragana;3050 +guillemotleft;00AB +guillemotright;00BB +guilsinglleft;2039 +guilsinglright;203A +gukatakana;30B0 +guramusquare;3318 +gysquare;33C9 +h;0068 +haabkhasiancyrillic;04A9 +haaltonearabic;06C1 +habengali;09B9 +hadescendercyrillic;04B3 +hadeva;0939 +hagujarati;0AB9 +hagurmukhi;0A39 +haharabic;062D +hahfinalarabic;FEA2 +hahinitialarabic;FEA3 +hahiragana;306F +hahmedialarabic;FEA4 +haitusquare;332A +hakatakana;30CF +hakatakanahalfwidth;FF8A +halantgurmukhi;0A4D +hamzaarabic;0621 +hamzadammaarabic;0621 064F +hamzadammatanarabic;0621 064C +hamzafathaarabic;0621 064E +hamzafathatanarabic;0621 064B +hamzalowarabic;0621 +hamzalowkasraarabic;0621 0650 +hamzalowkasratanarabic;0621 064D +hamzasukunarabic;0621 0652 +hangulfiller;3164 +hardsigncyrillic;044A +harpoonleftbarbup;21BC +harpoonrightbarbup;21C0 +hasquare;33CA +hatafpatah;05B2 +hatafpatah16;05B2 +hatafpatah23;05B2 +hatafpatah2f;05B2 +hatafpatahhebrew;05B2 +hatafpatahnarrowhebrew;05B2 +hatafpatahquarterhebrew;05B2 +hatafpatahwidehebrew;05B2 +hatafqamats;05B3 +hatafqamats1b;05B3 +hatafqamats28;05B3 +hatafqamats34;05B3 +hatafqamatshebrew;05B3 +hatafqamatsnarrowhebrew;05B3 +hatafqamatsquarterhebrew;05B3 +hatafqamatswidehebrew;05B3 +hatafsegol;05B1 +hatafsegol17;05B1 +hatafsegol24;05B1 +hatafsegol30;05B1 +hatafsegolhebrew;05B1 +hatafsegolnarrowhebrew;05B1 +hatafsegolquarterhebrew;05B1 +hatafsegolwidehebrew;05B1 +hbar;0127 +hbopomofo;310F +hbrevebelow;1E2B +hcedilla;1E29 +hcircle;24D7 +hcircumflex;0125 +hdieresis;1E27 +hdotaccent;1E23 +hdotbelow;1E25 +he;05D4 +heart;2665 +heartsuitblack;2665 +heartsuitwhite;2661 +hedagesh;FB34 +hedageshhebrew;FB34 +hehaltonearabic;06C1 +heharabic;0647 +hehebrew;05D4 +hehfinalaltonearabic;FBA7 +hehfinalalttwoarabic;FEEA +hehfinalarabic;FEEA +hehhamzaabovefinalarabic;FBA5 +hehhamzaaboveisolatedarabic;FBA4 +hehinitialaltonearabic;FBA8 +hehinitialarabic;FEEB +hehiragana;3078 +hehmedialaltonearabic;FBA9 +hehmedialarabic;FEEC +heiseierasquare;337B +hekatakana;30D8 +hekatakanahalfwidth;FF8D +hekutaarusquare;3336 +henghook;0267 +herutusquare;3339 +het;05D7 +hethebrew;05D7 +hhook;0266 +hhooksuperior;02B1 +hieuhacirclekorean;327B +hieuhaparenkorean;321B +hieuhcirclekorean;326D +hieuhkorean;314E +hieuhparenkorean;320D +hihiragana;3072 +hikatakana;30D2 +hikatakanahalfwidth;FF8B +hiriq;05B4 +hiriq14;05B4 +hiriq21;05B4 +hiriq2d;05B4 +hiriqhebrew;05B4 +hiriqnarrowhebrew;05B4 +hiriqquarterhebrew;05B4 +hiriqwidehebrew;05B4 +hlinebelow;1E96 +hmonospace;FF48 +hoarmenian;0570 +hohipthai;0E2B +hohiragana;307B +hokatakana;30DB +hokatakanahalfwidth;FF8E +holam;05B9 +holam19;05B9 +holam26;05B9 +holam32;05B9 +holamhebrew;05B9 +holamnarrowhebrew;05B9 +holamquarterhebrew;05B9 +holamwidehebrew;05B9 +honokhukthai;0E2E +hookabovecomb;0309 +hookcmb;0309 +hookpalatalizedbelowcmb;0321 +hookretroflexbelowcmb;0322 +hoonsquare;3342 +horicoptic;03E9 +horizontalbar;2015 +horncmb;031B +hotsprings;2668 +house;2302 +hparen;24A3 +hsuperior;02B0 +hturned;0265 +huhiragana;3075 +huiitosquare;3333 +hukatakana;30D5 +hukatakanahalfwidth;FF8C +hungarumlaut;02DD +hungarumlautcmb;030B +hv;0195 +hyphen;002D +hypheninferior;F6E5 +hyphenmonospace;FF0D +hyphensmall;FE63 +hyphensuperior;F6E6 +hyphentwo;2010 +i;0069 +iacute;00ED +iacyrillic;044F +ibengali;0987 +ibopomofo;3127 +ibreve;012D +icaron;01D0 +icircle;24D8 +icircumflex;00EE +icyrillic;0456 +idblgrave;0209 +ideographearthcircle;328F +ideographfirecircle;328B +ideographicallianceparen;323F +ideographiccallparen;323A +ideographiccentrecircle;32A5 +ideographicclose;3006 +ideographiccomma;3001 +ideographiccommaleft;FF64 +ideographiccongratulationparen;3237 +ideographiccorrectcircle;32A3 +ideographicearthparen;322F +ideographicenterpriseparen;323D +ideographicexcellentcircle;329D +ideographicfestivalparen;3240 +ideographicfinancialcircle;3296 +ideographicfinancialparen;3236 +ideographicfireparen;322B +ideographichaveparen;3232 +ideographichighcircle;32A4 +ideographiciterationmark;3005 +ideographiclaborcircle;3298 +ideographiclaborparen;3238 +ideographicleftcircle;32A7 +ideographiclowcircle;32A6 +ideographicmedicinecircle;32A9 +ideographicmetalparen;322E +ideographicmoonparen;322A +ideographicnameparen;3234 +ideographicperiod;3002 +ideographicprintcircle;329E +ideographicreachparen;3243 +ideographicrepresentparen;3239 +ideographicresourceparen;323E +ideographicrightcircle;32A8 +ideographicsecretcircle;3299 +ideographicselfparen;3242 +ideographicsocietyparen;3233 +ideographicspace;3000 +ideographicspecialparen;3235 +ideographicstockparen;3231 +ideographicstudyparen;323B +ideographicsunparen;3230 +ideographicsuperviseparen;323C +ideographicwaterparen;322C +ideographicwoodparen;322D +ideographiczero;3007 +ideographmetalcircle;328E +ideographmooncircle;328A +ideographnamecircle;3294 +ideographsuncircle;3290 +ideographwatercircle;328C +ideographwoodcircle;328D +ideva;0907 +idieresis;00EF +idieresisacute;1E2F +idieresiscyrillic;04E5 +idotbelow;1ECB +iebrevecyrillic;04D7 +iecyrillic;0435 +ieungacirclekorean;3275 +ieungaparenkorean;3215 +ieungcirclekorean;3267 +ieungkorean;3147 +ieungparenkorean;3207 +igrave;00EC +igujarati;0A87 +igurmukhi;0A07 +ihiragana;3044 +ihookabove;1EC9 +iibengali;0988 +iicyrillic;0438 +iideva;0908 +iigujarati;0A88 +iigurmukhi;0A08 +iimatragurmukhi;0A40 +iinvertedbreve;020B +iishortcyrillic;0439 +iivowelsignbengali;09C0 +iivowelsigndeva;0940 +iivowelsigngujarati;0AC0 +ij;0133 +ikatakana;30A4 +ikatakanahalfwidth;FF72 +ikorean;3163 +ilde;02DC +iluyhebrew;05AC +imacron;012B +imacroncyrillic;04E3 +imageorapproximatelyequal;2253 +imatragurmukhi;0A3F +imonospace;FF49 +increment;2206 +infinity;221E +iniarmenian;056B +integral;222B +integralbottom;2321 +integralbt;2321 +integralex;F8F5 +integraltop;2320 +integraltp;2320 +intersection;2229 +intisquare;3305 +invbullet;25D8 +invcircle;25D9 +invsmileface;263B +iocyrillic;0451 +iogonek;012F +iota;03B9 +iotadieresis;03CA +iotadieresistonos;0390 +iotalatin;0269 +iotatonos;03AF +iparen;24A4 +irigurmukhi;0A72 +ismallhiragana;3043 +ismallkatakana;30A3 +ismallkatakanahalfwidth;FF68 +issharbengali;09FA +istroke;0268 +isuperior;F6ED +iterationhiragana;309D +iterationkatakana;30FD +itilde;0129 +itildebelow;1E2D +iubopomofo;3129 +iucyrillic;044E +ivowelsignbengali;09BF +ivowelsigndeva;093F +ivowelsigngujarati;0ABF +izhitsacyrillic;0475 +izhitsadblgravecyrillic;0477 +j;006A +jaarmenian;0571 +jabengali;099C +jadeva;091C +jagujarati;0A9C +jagurmukhi;0A1C +jbopomofo;3110 +jcaron;01F0 +jcircle;24D9 +jcircumflex;0135 +jcrossedtail;029D +jdotlessstroke;025F +jecyrillic;0458 +jeemarabic;062C +jeemfinalarabic;FE9E +jeeminitialarabic;FE9F +jeemmedialarabic;FEA0 +jeharabic;0698 +jehfinalarabic;FB8B +jhabengali;099D +jhadeva;091D +jhagujarati;0A9D +jhagurmukhi;0A1D +jheharmenian;057B +jis;3004 +jmonospace;FF4A +jparen;24A5 +jsuperior;02B2 +k;006B +kabashkircyrillic;04A1 +kabengali;0995 +kacute;1E31 +kacyrillic;043A +kadescendercyrillic;049B +kadeva;0915 +kaf;05DB +kafarabic;0643 +kafdagesh;FB3B +kafdageshhebrew;FB3B +kaffinalarabic;FEDA +kafhebrew;05DB +kafinitialarabic;FEDB +kafmedialarabic;FEDC +kafrafehebrew;FB4D +kagujarati;0A95 +kagurmukhi;0A15 +kahiragana;304B +kahookcyrillic;04C4 +kakatakana;30AB +kakatakanahalfwidth;FF76 +kappa;03BA +kappasymbolgreek;03F0 +kapyeounmieumkorean;3171 +kapyeounphieuphkorean;3184 +kapyeounpieupkorean;3178 +kapyeounssangpieupkorean;3179 +karoriisquare;330D +kashidaautoarabic;0640 +kashidaautonosidebearingarabic;0640 +kasmallkatakana;30F5 +kasquare;3384 +kasraarabic;0650 +kasratanarabic;064D +kastrokecyrillic;049F +katahiraprolongmarkhalfwidth;FF70 +kaverticalstrokecyrillic;049D +kbopomofo;310E +kcalsquare;3389 +kcaron;01E9 +kcedilla;0137 +kcircle;24DA +kcommaaccent;0137 +kdotbelow;1E33 +keharmenian;0584 +kehiragana;3051 +kekatakana;30B1 +kekatakanahalfwidth;FF79 +kenarmenian;056F +kesmallkatakana;30F6 +kgreenlandic;0138 +khabengali;0996 +khacyrillic;0445 +khadeva;0916 +khagujarati;0A96 +khagurmukhi;0A16 +khaharabic;062E +khahfinalarabic;FEA6 +khahinitialarabic;FEA7 +khahmedialarabic;FEA8 +kheicoptic;03E7 +khhadeva;0959 +khhagurmukhi;0A59 +khieukhacirclekorean;3278 +khieukhaparenkorean;3218 +khieukhcirclekorean;326A +khieukhkorean;314B +khieukhparenkorean;320A +khokhaithai;0E02 +khokhonthai;0E05 +khokhuatthai;0E03 +khokhwaithai;0E04 +khomutthai;0E5B +khook;0199 +khorakhangthai;0E06 +khzsquare;3391 +kihiragana;304D +kikatakana;30AD +kikatakanahalfwidth;FF77 +kiroguramusquare;3315 +kiromeetorusquare;3316 +kirosquare;3314 +kiyeokacirclekorean;326E +kiyeokaparenkorean;320E +kiyeokcirclekorean;3260 +kiyeokkorean;3131 +kiyeokparenkorean;3200 +kiyeoksioskorean;3133 +kjecyrillic;045C +klinebelow;1E35 +klsquare;3398 +kmcubedsquare;33A6 +kmonospace;FF4B +kmsquaredsquare;33A2 +kohiragana;3053 +kohmsquare;33C0 +kokaithai;0E01 +kokatakana;30B3 +kokatakanahalfwidth;FF7A +kooposquare;331E +koppacyrillic;0481 +koreanstandardsymbol;327F +koroniscmb;0343 +kparen;24A6 +kpasquare;33AA +ksicyrillic;046F +ktsquare;33CF +kturned;029E +kuhiragana;304F +kukatakana;30AF +kukatakanahalfwidth;FF78 +kvsquare;33B8 +kwsquare;33BE +l;006C +labengali;09B2 +lacute;013A +ladeva;0932 +lagujarati;0AB2 +lagurmukhi;0A32 +lakkhangyaothai;0E45 +lamaleffinalarabic;FEFC +lamalefhamzaabovefinalarabic;FEF8 +lamalefhamzaaboveisolatedarabic;FEF7 +lamalefhamzabelowfinalarabic;FEFA +lamalefhamzabelowisolatedarabic;FEF9 +lamalefisolatedarabic;FEFB +lamalefmaddaabovefinalarabic;FEF6 +lamalefmaddaaboveisolatedarabic;FEF5 +lamarabic;0644 +lambda;03BB +lambdastroke;019B +lamed;05DC +lameddagesh;FB3C +lameddageshhebrew;FB3C +lamedhebrew;05DC +lamedholam;05DC 05B9 +lamedholamdagesh;05DC 05B9 05BC +lamedholamdageshhebrew;05DC 05B9 05BC +lamedholamhebrew;05DC 05B9 +lamfinalarabic;FEDE +lamhahinitialarabic;FCCA +laminitialarabic;FEDF +lamjeeminitialarabic;FCC9 +lamkhahinitialarabic;FCCB +lamlamhehisolatedarabic;FDF2 +lammedialarabic;FEE0 +lammeemhahinitialarabic;FD88 +lammeeminitialarabic;FCCC +lammeemjeeminitialarabic;FEDF FEE4 FEA0 +lammeemkhahinitialarabic;FEDF FEE4 FEA8 +largecircle;25EF +lbar;019A +lbelt;026C +lbopomofo;310C +lcaron;013E +lcedilla;013C +lcircle;24DB +lcircumflexbelow;1E3D +lcommaaccent;013C +ldot;0140 +ldotaccent;0140 +ldotbelow;1E37 +ldotbelowmacron;1E39 +leftangleabovecmb;031A +lefttackbelowcmb;0318 +less;003C +lessequal;2264 +lessequalorgreater;22DA +lessmonospace;FF1C +lessorequivalent;2272 +lessorgreater;2276 +lessoverequal;2266 +lesssmall;FE64 +lezh;026E +lfblock;258C +lhookretroflex;026D +lira;20A4 +liwnarmenian;056C +lj;01C9 +ljecyrillic;0459 +ll;F6C0 +lladeva;0933 +llagujarati;0AB3 +llinebelow;1E3B +llladeva;0934 +llvocalicbengali;09E1 +llvocalicdeva;0961 +llvocalicvowelsignbengali;09E3 +llvocalicvowelsigndeva;0963 +lmiddletilde;026B +lmonospace;FF4C +lmsquare;33D0 +lochulathai;0E2C +logicaland;2227 +logicalnot;00AC +logicalnotreversed;2310 +logicalor;2228 +lolingthai;0E25 +longs;017F +lowlinecenterline;FE4E +lowlinecmb;0332 +lowlinedashed;FE4D +lozenge;25CA +lparen;24A7 +lslash;0142 +lsquare;2113 +lsuperior;F6EE +ltshade;2591 +luthai;0E26 +lvocalicbengali;098C +lvocalicdeva;090C +lvocalicvowelsignbengali;09E2 +lvocalicvowelsigndeva;0962 +lxsquare;33D3 +m;006D +mabengali;09AE +macron;00AF +macronbelowcmb;0331 +macroncmb;0304 +macronlowmod;02CD +macronmonospace;FFE3 +macute;1E3F +madeva;092E +magujarati;0AAE +magurmukhi;0A2E +mahapakhhebrew;05A4 +mahapakhlefthebrew;05A4 +mahiragana;307E +maichattawalowleftthai;F895 +maichattawalowrightthai;F894 +maichattawathai;0E4B +maichattawaupperleftthai;F893 +maieklowleftthai;F88C +maieklowrightthai;F88B +maiekthai;0E48 +maiekupperleftthai;F88A +maihanakatleftthai;F884 +maihanakatthai;0E31 +maitaikhuleftthai;F889 +maitaikhuthai;0E47 +maitholowleftthai;F88F +maitholowrightthai;F88E +maithothai;0E49 +maithoupperleftthai;F88D +maitrilowleftthai;F892 +maitrilowrightthai;F891 +maitrithai;0E4A +maitriupperleftthai;F890 +maiyamokthai;0E46 +makatakana;30DE +makatakanahalfwidth;FF8F +male;2642 +mansyonsquare;3347 +maqafhebrew;05BE +mars;2642 +masoracirclehebrew;05AF +masquare;3383 +mbopomofo;3107 +mbsquare;33D4 +mcircle;24DC +mcubedsquare;33A5 +mdotaccent;1E41 +mdotbelow;1E43 +meemarabic;0645 +meemfinalarabic;FEE2 +meeminitialarabic;FEE3 +meemmedialarabic;FEE4 +meemmeeminitialarabic;FCD1 +meemmeemisolatedarabic;FC48 +meetorusquare;334D +mehiragana;3081 +meizierasquare;337E +mekatakana;30E1 +mekatakanahalfwidth;FF92 +mem;05DE +memdagesh;FB3E +memdageshhebrew;FB3E +memhebrew;05DE +menarmenian;0574 +merkhahebrew;05A5 +merkhakefulahebrew;05A6 +merkhakefulalefthebrew;05A6 +merkhalefthebrew;05A5 +mhook;0271 +mhzsquare;3392 +middledotkatakanahalfwidth;FF65 +middot;00B7 +mieumacirclekorean;3272 +mieumaparenkorean;3212 +mieumcirclekorean;3264 +mieumkorean;3141 +mieumpansioskorean;3170 +mieumparenkorean;3204 +mieumpieupkorean;316E +mieumsioskorean;316F +mihiragana;307F +mikatakana;30DF +mikatakanahalfwidth;FF90 +minus;2212 +minusbelowcmb;0320 +minuscircle;2296 +minusmod;02D7 +minusplus;2213 +minute;2032 +miribaarusquare;334A +mirisquare;3349 +mlonglegturned;0270 +mlsquare;3396 +mmcubedsquare;33A3 +mmonospace;FF4D +mmsquaredsquare;339F +mohiragana;3082 +mohmsquare;33C1 +mokatakana;30E2 +mokatakanahalfwidth;FF93 +molsquare;33D6 +momathai;0E21 +moverssquare;33A7 +moverssquaredsquare;33A8 +mparen;24A8 +mpasquare;33AB +mssquare;33B3 +msuperior;F6EF +mturned;026F +mu;00B5 +mu1;00B5 +muasquare;3382 +muchgreater;226B +muchless;226A +mufsquare;338C +mugreek;03BC +mugsquare;338D +muhiragana;3080 +mukatakana;30E0 +mukatakanahalfwidth;FF91 +mulsquare;3395 +multiply;00D7 +mumsquare;339B +munahhebrew;05A3 +munahlefthebrew;05A3 +musicalnote;266A +musicalnotedbl;266B +musicflatsign;266D +musicsharpsign;266F +mussquare;33B2 +muvsquare;33B6 +muwsquare;33BC +mvmegasquare;33B9 +mvsquare;33B7 +mwmegasquare;33BF +mwsquare;33BD +n;006E +nabengali;09A8 +nabla;2207 +nacute;0144 +nadeva;0928 +nagujarati;0AA8 +nagurmukhi;0A28 +nahiragana;306A +nakatakana;30CA +nakatakanahalfwidth;FF85 +napostrophe;0149 +nasquare;3381 +nbopomofo;310B +nbspace;00A0 +ncaron;0148 +ncedilla;0146 +ncircle;24DD +ncircumflexbelow;1E4B +ncommaaccent;0146 +ndotaccent;1E45 +ndotbelow;1E47 +nehiragana;306D +nekatakana;30CD +nekatakanahalfwidth;FF88 +newsheqelsign;20AA +nfsquare;338B +ngabengali;0999 +ngadeva;0919 +ngagujarati;0A99 +ngagurmukhi;0A19 +ngonguthai;0E07 +nhiragana;3093 +nhookleft;0272 +nhookretroflex;0273 +nieunacirclekorean;326F +nieunaparenkorean;320F +nieuncieuckorean;3135 +nieuncirclekorean;3261 +nieunhieuhkorean;3136 +nieunkorean;3134 +nieunpansioskorean;3168 +nieunparenkorean;3201 +nieunsioskorean;3167 +nieuntikeutkorean;3166 +nihiragana;306B +nikatakana;30CB +nikatakanahalfwidth;FF86 +nikhahitleftthai;F899 +nikhahitthai;0E4D +nine;0039 +ninearabic;0669 +ninebengali;09EF +ninecircle;2468 +ninecircleinversesansserif;2792 +ninedeva;096F +ninegujarati;0AEF +ninegurmukhi;0A6F +ninehackarabic;0669 +ninehangzhou;3029 +nineideographicparen;3228 +nineinferior;2089 +ninemonospace;FF19 +nineoldstyle;F739 +nineparen;247C +nineperiod;2490 +ninepersian;06F9 +nineroman;2178 +ninesuperior;2079 +nineteencircle;2472 +nineteenparen;2486 +nineteenperiod;249A +ninethai;0E59 +nj;01CC +njecyrillic;045A +nkatakana;30F3 +nkatakanahalfwidth;FF9D +nlegrightlong;019E +nlinebelow;1E49 +nmonospace;FF4E +nmsquare;339A +nnabengali;09A3 +nnadeva;0923 +nnagujarati;0AA3 +nnagurmukhi;0A23 +nnnadeva;0929 +nohiragana;306E +nokatakana;30CE +nokatakanahalfwidth;FF89 +nonbreakingspace;00A0 +nonenthai;0E13 +nonuthai;0E19 +noonarabic;0646 +noonfinalarabic;FEE6 +noonghunnaarabic;06BA +noonghunnafinalarabic;FB9F +noonhehinitialarabic;FEE7 FEEC +nooninitialarabic;FEE7 +noonjeeminitialarabic;FCD2 +noonjeemisolatedarabic;FC4B +noonmedialarabic;FEE8 +noonmeeminitialarabic;FCD5 +noonmeemisolatedarabic;FC4E +noonnoonfinalarabic;FC8D +notcontains;220C +notelement;2209 +notelementof;2209 +notequal;2260 +notgreater;226F +notgreaternorequal;2271 +notgreaternorless;2279 +notidentical;2262 +notless;226E +notlessnorequal;2270 +notparallel;2226 +notprecedes;2280 +notsubset;2284 +notsucceeds;2281 +notsuperset;2285 +nowarmenian;0576 +nparen;24A9 +nssquare;33B1 +nsuperior;207F +ntilde;00F1 +nu;03BD +nuhiragana;306C +nukatakana;30CC +nukatakanahalfwidth;FF87 +nuktabengali;09BC +nuktadeva;093C +nuktagujarati;0ABC +nuktagurmukhi;0A3C +numbersign;0023 +numbersignmonospace;FF03 +numbersignsmall;FE5F +numeralsigngreek;0374 +numeralsignlowergreek;0375 +numero;2116 +nun;05E0 +nundagesh;FB40 +nundageshhebrew;FB40 +nunhebrew;05E0 +nvsquare;33B5 +nwsquare;33BB +nyabengali;099E +nyadeva;091E +nyagujarati;0A9E +nyagurmukhi;0A1E +o;006F +oacute;00F3 +oangthai;0E2D +obarred;0275 +obarredcyrillic;04E9 +obarreddieresiscyrillic;04EB +obengali;0993 +obopomofo;311B +obreve;014F +ocandradeva;0911 +ocandragujarati;0A91 +ocandravowelsigndeva;0949 +ocandravowelsigngujarati;0AC9 +ocaron;01D2 +ocircle;24DE +ocircumflex;00F4 +ocircumflexacute;1ED1 +ocircumflexdotbelow;1ED9 +ocircumflexgrave;1ED3 +ocircumflexhookabove;1ED5 +ocircumflextilde;1ED7 +ocyrillic;043E +odblacute;0151 +odblgrave;020D +odeva;0913 +odieresis;00F6 +odieresiscyrillic;04E7 +odotbelow;1ECD +oe;0153 +oekorean;315A +ogonek;02DB +ogonekcmb;0328 +ograve;00F2 +ogujarati;0A93 +oharmenian;0585 +ohiragana;304A +ohookabove;1ECF +ohorn;01A1 +ohornacute;1EDB +ohorndotbelow;1EE3 +ohorngrave;1EDD +ohornhookabove;1EDF +ohorntilde;1EE1 +ohungarumlaut;0151 +oi;01A3 +oinvertedbreve;020F +okatakana;30AA +okatakanahalfwidth;FF75 +okorean;3157 +olehebrew;05AB +omacron;014D +omacronacute;1E53 +omacrongrave;1E51 +omdeva;0950 +omega;03C9 +omega1;03D6 +omegacyrillic;0461 +omegalatinclosed;0277 +omegaroundcyrillic;047B +omegatitlocyrillic;047D +omegatonos;03CE +omgujarati;0AD0 +omicron;03BF +omicrontonos;03CC +omonospace;FF4F +one;0031 +onearabic;0661 +onebengali;09E7 +onecircle;2460 +onecircleinversesansserif;278A +onedeva;0967 +onedotenleader;2024 +oneeighth;215B +onefitted;F6DC +onegujarati;0AE7 +onegurmukhi;0A67 +onehackarabic;0661 +onehalf;00BD +onehangzhou;3021 +oneideographicparen;3220 +oneinferior;2081 +onemonospace;FF11 +onenumeratorbengali;09F4 +oneoldstyle;F731 +oneparen;2474 +oneperiod;2488 +onepersian;06F1 +onequarter;00BC +oneroman;2170 +onesuperior;00B9 +onethai;0E51 +onethird;2153 +oogonek;01EB +oogonekmacron;01ED +oogurmukhi;0A13 +oomatragurmukhi;0A4B +oopen;0254 +oparen;24AA +openbullet;25E6 +option;2325 +ordfeminine;00AA +ordmasculine;00BA +orthogonal;221F +oshortdeva;0912 +oshortvowelsigndeva;094A +oslash;00F8 +oslashacute;01FF +osmallhiragana;3049 +osmallkatakana;30A9 +osmallkatakanahalfwidth;FF6B +ostrokeacute;01FF +osuperior;F6F0 +otcyrillic;047F +otilde;00F5 +otildeacute;1E4D +otildedieresis;1E4F +oubopomofo;3121 +overline;203E +overlinecenterline;FE4A +overlinecmb;0305 +overlinedashed;FE49 +overlinedblwavy;FE4C +overlinewavy;FE4B +overscore;00AF +ovowelsignbengali;09CB +ovowelsigndeva;094B +ovowelsigngujarati;0ACB +p;0070 +paampssquare;3380 +paasentosquare;332B +pabengali;09AA +pacute;1E55 +padeva;092A +pagedown;21DF +pageup;21DE +pagujarati;0AAA +pagurmukhi;0A2A +pahiragana;3071 +paiyannoithai;0E2F +pakatakana;30D1 +palatalizationcyrilliccmb;0484 +palochkacyrillic;04C0 +pansioskorean;317F +paragraph;00B6 +parallel;2225 +parenleft;0028 +parenleftaltonearabic;FD3E +parenleftbt;F8ED +parenleftex;F8EC +parenleftinferior;208D +parenleftmonospace;FF08 +parenleftsmall;FE59 +parenleftsuperior;207D +parenlefttp;F8EB +parenleftvertical;FE35 +parenright;0029 +parenrightaltonearabic;FD3F +parenrightbt;F8F8 +parenrightex;F8F7 +parenrightinferior;208E +parenrightmonospace;FF09 +parenrightsmall;FE5A +parenrightsuperior;207E +parenrighttp;F8F6 +parenrightvertical;FE36 +partialdiff;2202 +paseqhebrew;05C0 +pashtahebrew;0599 +pasquare;33A9 +patah;05B7 +patah11;05B7 +patah1d;05B7 +patah2a;05B7 +patahhebrew;05B7 +patahnarrowhebrew;05B7 +patahquarterhebrew;05B7 +patahwidehebrew;05B7 +pazerhebrew;05A1 +pbopomofo;3106 +pcircle;24DF +pdotaccent;1E57 +pe;05E4 +pecyrillic;043F +pedagesh;FB44 +pedageshhebrew;FB44 +peezisquare;333B +pefinaldageshhebrew;FB43 +peharabic;067E +peharmenian;057A +pehebrew;05E4 +pehfinalarabic;FB57 +pehinitialarabic;FB58 +pehiragana;307A +pehmedialarabic;FB59 +pekatakana;30DA +pemiddlehookcyrillic;04A7 +perafehebrew;FB4E +percent;0025 +percentarabic;066A +percentmonospace;FF05 +percentsmall;FE6A +period;002E +periodarmenian;0589 +periodcentered;00B7 +periodhalfwidth;FF61 +periodinferior;F6E7 +periodmonospace;FF0E +periodsmall;FE52 +periodsuperior;F6E8 +perispomenigreekcmb;0342 +perpendicular;22A5 +perthousand;2030 +peseta;20A7 +pfsquare;338A +phabengali;09AB +phadeva;092B +phagujarati;0AAB +phagurmukhi;0A2B +phi;03C6 +phi1;03D5 +phieuphacirclekorean;327A +phieuphaparenkorean;321A +phieuphcirclekorean;326C +phieuphkorean;314D +phieuphparenkorean;320C +philatin;0278 +phinthuthai;0E3A +phisymbolgreek;03D5 +phook;01A5 +phophanthai;0E1E +phophungthai;0E1C +phosamphaothai;0E20 +pi;03C0 +pieupacirclekorean;3273 +pieupaparenkorean;3213 +pieupcieuckorean;3176 +pieupcirclekorean;3265 +pieupkiyeokkorean;3172 +pieupkorean;3142 +pieupparenkorean;3205 +pieupsioskiyeokkorean;3174 +pieupsioskorean;3144 +pieupsiostikeutkorean;3175 +pieupthieuthkorean;3177 +pieuptikeutkorean;3173 +pihiragana;3074 +pikatakana;30D4 +pisymbolgreek;03D6 +piwrarmenian;0583 +plus;002B +plusbelowcmb;031F +pluscircle;2295 +plusminus;00B1 +plusmod;02D6 +plusmonospace;FF0B +plussmall;FE62 +plussuperior;207A +pmonospace;FF50 +pmsquare;33D8 +pohiragana;307D +pointingindexdownwhite;261F +pointingindexleftwhite;261C +pointingindexrightwhite;261E +pointingindexupwhite;261D +pokatakana;30DD +poplathai;0E1B +postalmark;3012 +postalmarkface;3020 +pparen;24AB +precedes;227A +prescription;211E +primemod;02B9 +primereversed;2035 +product;220F +projective;2305 +prolongedkana;30FC +propellor;2318 +propersubset;2282 +propersuperset;2283 +proportion;2237 +proportional;221D +psi;03C8 +psicyrillic;0471 +psilipneumatacyrilliccmb;0486 +pssquare;33B0 +puhiragana;3077 +pukatakana;30D7 +pvsquare;33B4 +pwsquare;33BA +q;0071 +qadeva;0958 +qadmahebrew;05A8 +qafarabic;0642 +qaffinalarabic;FED6 +qafinitialarabic;FED7 +qafmedialarabic;FED8 +qamats;05B8 +qamats10;05B8 +qamats1a;05B8 +qamats1c;05B8 +qamats27;05B8 +qamats29;05B8 +qamats33;05B8 +qamatsde;05B8 +qamatshebrew;05B8 +qamatsnarrowhebrew;05B8 +qamatsqatanhebrew;05B8 +qamatsqatannarrowhebrew;05B8 +qamatsqatanquarterhebrew;05B8 +qamatsqatanwidehebrew;05B8 +qamatsquarterhebrew;05B8 +qamatswidehebrew;05B8 +qarneyparahebrew;059F +qbopomofo;3111 +qcircle;24E0 +qhook;02A0 +qmonospace;FF51 +qof;05E7 +qofdagesh;FB47 +qofdageshhebrew;FB47 +qofhatafpatah;05E7 05B2 +qofhatafpatahhebrew;05E7 05B2 +qofhatafsegol;05E7 05B1 +qofhatafsegolhebrew;05E7 05B1 +qofhebrew;05E7 +qofhiriq;05E7 05B4 +qofhiriqhebrew;05E7 05B4 +qofholam;05E7 05B9 +qofholamhebrew;05E7 05B9 +qofpatah;05E7 05B7 +qofpatahhebrew;05E7 05B7 +qofqamats;05E7 05B8 +qofqamatshebrew;05E7 05B8 +qofqubuts;05E7 05BB +qofqubutshebrew;05E7 05BB +qofsegol;05E7 05B6 +qofsegolhebrew;05E7 05B6 +qofsheva;05E7 05B0 +qofshevahebrew;05E7 05B0 +qoftsere;05E7 05B5 +qoftserehebrew;05E7 05B5 +qparen;24AC +quarternote;2669 +qubuts;05BB +qubuts18;05BB +qubuts25;05BB +qubuts31;05BB +qubutshebrew;05BB +qubutsnarrowhebrew;05BB +qubutsquarterhebrew;05BB +qubutswidehebrew;05BB +question;003F +questionarabic;061F +questionarmenian;055E +questiondown;00BF +questiondownsmall;F7BF +questiongreek;037E +questionmonospace;FF1F +questionsmall;F73F +quotedbl;0022 +quotedblbase;201E +quotedblleft;201C +quotedblmonospace;FF02 +quotedblprime;301E +quotedblprimereversed;301D +quotedblright;201D +quoteleft;2018 +quoteleftreversed;201B +quotereversed;201B +quoteright;2019 +quoterightn;0149 +quotesinglbase;201A +quotesingle;0027 +quotesinglemonospace;FF07 +r;0072 +raarmenian;057C +rabengali;09B0 +racute;0155 +radeva;0930 +radical;221A +radicalex;F8E5 +radoverssquare;33AE +radoverssquaredsquare;33AF +radsquare;33AD +rafe;05BF +rafehebrew;05BF +ragujarati;0AB0 +ragurmukhi;0A30 +rahiragana;3089 +rakatakana;30E9 +rakatakanahalfwidth;FF97 +ralowerdiagonalbengali;09F1 +ramiddlediagonalbengali;09F0 +ramshorn;0264 +ratio;2236 +rbopomofo;3116 +rcaron;0159 +rcedilla;0157 +rcircle;24E1 +rcommaaccent;0157 +rdblgrave;0211 +rdotaccent;1E59 +rdotbelow;1E5B +rdotbelowmacron;1E5D +referencemark;203B +reflexsubset;2286 +reflexsuperset;2287 +registered;00AE +registersans;F8E8 +registerserif;F6DA +reharabic;0631 +reharmenian;0580 +rehfinalarabic;FEAE +rehiragana;308C +rehyehaleflamarabic;0631 FEF3 FE8E 0644 +rekatakana;30EC +rekatakanahalfwidth;FF9A +resh;05E8 +reshdageshhebrew;FB48 +reshhatafpatah;05E8 05B2 +reshhatafpatahhebrew;05E8 05B2 +reshhatafsegol;05E8 05B1 +reshhatafsegolhebrew;05E8 05B1 +reshhebrew;05E8 +reshhiriq;05E8 05B4 +reshhiriqhebrew;05E8 05B4 +reshholam;05E8 05B9 +reshholamhebrew;05E8 05B9 +reshpatah;05E8 05B7 +reshpatahhebrew;05E8 05B7 +reshqamats;05E8 05B8 +reshqamatshebrew;05E8 05B8 +reshqubuts;05E8 05BB +reshqubutshebrew;05E8 05BB +reshsegol;05E8 05B6 +reshsegolhebrew;05E8 05B6 +reshsheva;05E8 05B0 +reshshevahebrew;05E8 05B0 +reshtsere;05E8 05B5 +reshtserehebrew;05E8 05B5 +reversedtilde;223D +reviahebrew;0597 +reviamugrashhebrew;0597 +revlogicalnot;2310 +rfishhook;027E +rfishhookreversed;027F +rhabengali;09DD +rhadeva;095D +rho;03C1 +rhook;027D +rhookturned;027B +rhookturnedsuperior;02B5 +rhosymbolgreek;03F1 +rhotichookmod;02DE +rieulacirclekorean;3271 +rieulaparenkorean;3211 +rieulcirclekorean;3263 +rieulhieuhkorean;3140 +rieulkiyeokkorean;313A +rieulkiyeoksioskorean;3169 +rieulkorean;3139 +rieulmieumkorean;313B +rieulpansioskorean;316C +rieulparenkorean;3203 +rieulphieuphkorean;313F +rieulpieupkorean;313C +rieulpieupsioskorean;316B +rieulsioskorean;313D +rieulthieuthkorean;313E +rieultikeutkorean;316A +rieulyeorinhieuhkorean;316D +rightangle;221F +righttackbelowcmb;0319 +righttriangle;22BF +rihiragana;308A +rikatakana;30EA +rikatakanahalfwidth;FF98 +ring;02DA +ringbelowcmb;0325 +ringcmb;030A +ringhalfleft;02BF +ringhalfleftarmenian;0559 +ringhalfleftbelowcmb;031C +ringhalfleftcentered;02D3 +ringhalfright;02BE +ringhalfrightbelowcmb;0339 +ringhalfrightcentered;02D2 +rinvertedbreve;0213 +rittorusquare;3351 +rlinebelow;1E5F +rlongleg;027C +rlonglegturned;027A +rmonospace;FF52 +rohiragana;308D +rokatakana;30ED +rokatakanahalfwidth;FF9B +roruathai;0E23 +rparen;24AD +rrabengali;09DC +rradeva;0931 +rragurmukhi;0A5C +rreharabic;0691 +rrehfinalarabic;FB8D +rrvocalicbengali;09E0 +rrvocalicdeva;0960 +rrvocalicgujarati;0AE0 +rrvocalicvowelsignbengali;09C4 +rrvocalicvowelsigndeva;0944 +rrvocalicvowelsigngujarati;0AC4 +rsuperior;F6F1 +rtblock;2590 +rturned;0279 +rturnedsuperior;02B4 +ruhiragana;308B +rukatakana;30EB +rukatakanahalfwidth;FF99 +rupeemarkbengali;09F2 +rupeesignbengali;09F3 +rupiah;F6DD +ruthai;0E24 +rvocalicbengali;098B +rvocalicdeva;090B +rvocalicgujarati;0A8B +rvocalicvowelsignbengali;09C3 +rvocalicvowelsigndeva;0943 +rvocalicvowelsigngujarati;0AC3 +s;0073 +sabengali;09B8 +sacute;015B +sacutedotaccent;1E65 +sadarabic;0635 +sadeva;0938 +sadfinalarabic;FEBA +sadinitialarabic;FEBB +sadmedialarabic;FEBC +sagujarati;0AB8 +sagurmukhi;0A38 +sahiragana;3055 +sakatakana;30B5 +sakatakanahalfwidth;FF7B +sallallahoualayhewasallamarabic;FDFA +samekh;05E1 +samekhdagesh;FB41 +samekhdageshhebrew;FB41 +samekhhebrew;05E1 +saraaathai;0E32 +saraaethai;0E41 +saraaimaimalaithai;0E44 +saraaimaimuanthai;0E43 +saraamthai;0E33 +saraathai;0E30 +saraethai;0E40 +saraiileftthai;F886 +saraiithai;0E35 +saraileftthai;F885 +saraithai;0E34 +saraothai;0E42 +saraueeleftthai;F888 +saraueethai;0E37 +saraueleftthai;F887 +sarauethai;0E36 +sarauthai;0E38 +sarauuthai;0E39 +sbopomofo;3119 +scaron;0161 +scarondotaccent;1E67 +scedilla;015F +schwa;0259 +schwacyrillic;04D9 +schwadieresiscyrillic;04DB +schwahook;025A +scircle;24E2 +scircumflex;015D +scommaaccent;0219 +sdotaccent;1E61 +sdotbelow;1E63 +sdotbelowdotaccent;1E69 +seagullbelowcmb;033C +second;2033 +secondtonechinese;02CA +section;00A7 +seenarabic;0633 +seenfinalarabic;FEB2 +seeninitialarabic;FEB3 +seenmedialarabic;FEB4 +segol;05B6 +segol13;05B6 +segol1f;05B6 +segol2c;05B6 +segolhebrew;05B6 +segolnarrowhebrew;05B6 +segolquarterhebrew;05B6 +segoltahebrew;0592 +segolwidehebrew;05B6 +seharmenian;057D +sehiragana;305B +sekatakana;30BB +sekatakanahalfwidth;FF7E +semicolon;003B +semicolonarabic;061B +semicolonmonospace;FF1B +semicolonsmall;FE54 +semivoicedmarkkana;309C +semivoicedmarkkanahalfwidth;FF9F +sentisquare;3322 +sentosquare;3323 +seven;0037 +sevenarabic;0667 +sevenbengali;09ED +sevencircle;2466 +sevencircleinversesansserif;2790 +sevendeva;096D +seveneighths;215E +sevengujarati;0AED +sevengurmukhi;0A6D +sevenhackarabic;0667 +sevenhangzhou;3027 +sevenideographicparen;3226 +seveninferior;2087 +sevenmonospace;FF17 +sevenoldstyle;F737 +sevenparen;247A +sevenperiod;248E +sevenpersian;06F7 +sevenroman;2176 +sevensuperior;2077 +seventeencircle;2470 +seventeenparen;2484 +seventeenperiod;2498 +seventhai;0E57 +sfthyphen;00AD +shaarmenian;0577 +shabengali;09B6 +shacyrillic;0448 +shaddaarabic;0651 +shaddadammaarabic;FC61 +shaddadammatanarabic;FC5E +shaddafathaarabic;FC60 +shaddafathatanarabic;0651 064B +shaddakasraarabic;FC62 +shaddakasratanarabic;FC5F +shade;2592 +shadedark;2593 +shadelight;2591 +shademedium;2592 +shadeva;0936 +shagujarati;0AB6 +shagurmukhi;0A36 +shalshelethebrew;0593 +shbopomofo;3115 +shchacyrillic;0449 +sheenarabic;0634 +sheenfinalarabic;FEB6 +sheeninitialarabic;FEB7 +sheenmedialarabic;FEB8 +sheicoptic;03E3 +sheqel;20AA +sheqelhebrew;20AA +sheva;05B0 +sheva115;05B0 +sheva15;05B0 +sheva22;05B0 +sheva2e;05B0 +shevahebrew;05B0 +shevanarrowhebrew;05B0 +shevaquarterhebrew;05B0 +shevawidehebrew;05B0 +shhacyrillic;04BB +shimacoptic;03ED +shin;05E9 +shindagesh;FB49 +shindageshhebrew;FB49 +shindageshshindot;FB2C +shindageshshindothebrew;FB2C +shindageshsindot;FB2D +shindageshsindothebrew;FB2D +shindothebrew;05C1 +shinhebrew;05E9 +shinshindot;FB2A +shinshindothebrew;FB2A +shinsindot;FB2B +shinsindothebrew;FB2B +shook;0282 +sigma;03C3 +sigma1;03C2 +sigmafinal;03C2 +sigmalunatesymbolgreek;03F2 +sihiragana;3057 +sikatakana;30B7 +sikatakanahalfwidth;FF7C +siluqhebrew;05BD +siluqlefthebrew;05BD +similar;223C +sindothebrew;05C2 +siosacirclekorean;3274 +siosaparenkorean;3214 +sioscieuckorean;317E +sioscirclekorean;3266 +sioskiyeokkorean;317A +sioskorean;3145 +siosnieunkorean;317B +siosparenkorean;3206 +siospieupkorean;317D +siostikeutkorean;317C +six;0036 +sixarabic;0666 +sixbengali;09EC +sixcircle;2465 +sixcircleinversesansserif;278F +sixdeva;096C +sixgujarati;0AEC +sixgurmukhi;0A6C +sixhackarabic;0666 +sixhangzhou;3026 +sixideographicparen;3225 +sixinferior;2086 +sixmonospace;FF16 +sixoldstyle;F736 +sixparen;2479 +sixperiod;248D +sixpersian;06F6 +sixroman;2175 +sixsuperior;2076 +sixteencircle;246F +sixteencurrencydenominatorbengali;09F9 +sixteenparen;2483 +sixteenperiod;2497 +sixthai;0E56 +slash;002F +slashmonospace;FF0F +slong;017F +slongdotaccent;1E9B +smileface;263A +smonospace;FF53 +sofpasuqhebrew;05C3 +softhyphen;00AD +softsigncyrillic;044C +sohiragana;305D +sokatakana;30BD +sokatakanahalfwidth;FF7F +soliduslongoverlaycmb;0338 +solidusshortoverlaycmb;0337 +sorusithai;0E29 +sosalathai;0E28 +sosothai;0E0B +sosuathai;0E2A +space;0020 +spacehackarabic;0020 +spade;2660 +spadesuitblack;2660 +spadesuitwhite;2664 +sparen;24AE +squarebelowcmb;033B +squarecc;33C4 +squarecm;339D +squarediagonalcrosshatchfill;25A9 +squarehorizontalfill;25A4 +squarekg;338F +squarekm;339E +squarekmcapital;33CE +squareln;33D1 +squarelog;33D2 +squaremg;338E +squaremil;33D5 +squaremm;339C +squaremsquared;33A1 +squareorthogonalcrosshatchfill;25A6 +squareupperlefttolowerrightfill;25A7 +squareupperrighttolowerleftfill;25A8 +squareverticalfill;25A5 +squarewhitewithsmallblack;25A3 +srsquare;33DB +ssabengali;09B7 +ssadeva;0937 +ssagujarati;0AB7 +ssangcieuckorean;3149 +ssanghieuhkorean;3185 +ssangieungkorean;3180 +ssangkiyeokkorean;3132 +ssangnieunkorean;3165 +ssangpieupkorean;3143 +ssangsioskorean;3146 +ssangtikeutkorean;3138 +ssuperior;F6F2 +sterling;00A3 +sterlingmonospace;FFE1 +strokelongoverlaycmb;0336 +strokeshortoverlaycmb;0335 +subset;2282 +subsetnotequal;228A +subsetorequal;2286 +succeeds;227B +suchthat;220B +suhiragana;3059 +sukatakana;30B9 +sukatakanahalfwidth;FF7D +sukunarabic;0652 +summation;2211 +sun;263C +superset;2283 +supersetnotequal;228B +supersetorequal;2287 +svsquare;33DC +syouwaerasquare;337C +t;0074 +tabengali;09A4 +tackdown;22A4 +tackleft;22A3 +tadeva;0924 +tagujarati;0AA4 +tagurmukhi;0A24 +taharabic;0637 +tahfinalarabic;FEC2 +tahinitialarabic;FEC3 +tahiragana;305F +tahmedialarabic;FEC4 +taisyouerasquare;337D +takatakana;30BF +takatakanahalfwidth;FF80 +tatweelarabic;0640 +tau;03C4 +tav;05EA +tavdages;FB4A +tavdagesh;FB4A +tavdageshhebrew;FB4A +tavhebrew;05EA +tbar;0167 +tbopomofo;310A +tcaron;0165 +tccurl;02A8 +tcedilla;0163 +tcheharabic;0686 +tchehfinalarabic;FB7B +tchehinitialarabic;FB7C +tchehmedialarabic;FB7D +tchehmeeminitialarabic;FB7C FEE4 +tcircle;24E3 +tcircumflexbelow;1E71 +tcommaaccent;0163 +tdieresis;1E97 +tdotaccent;1E6B +tdotbelow;1E6D +tecyrillic;0442 +tedescendercyrillic;04AD +teharabic;062A +tehfinalarabic;FE96 +tehhahinitialarabic;FCA2 +tehhahisolatedarabic;FC0C +tehinitialarabic;FE97 +tehiragana;3066 +tehjeeminitialarabic;FCA1 +tehjeemisolatedarabic;FC0B +tehmarbutaarabic;0629 +tehmarbutafinalarabic;FE94 +tehmedialarabic;FE98 +tehmeeminitialarabic;FCA4 +tehmeemisolatedarabic;FC0E +tehnoonfinalarabic;FC73 +tekatakana;30C6 +tekatakanahalfwidth;FF83 +telephone;2121 +telephoneblack;260E +telishagedolahebrew;05A0 +telishaqetanahebrew;05A9 +tencircle;2469 +tenideographicparen;3229 +tenparen;247D +tenperiod;2491 +tenroman;2179 +tesh;02A7 +tet;05D8 +tetdagesh;FB38 +tetdageshhebrew;FB38 +tethebrew;05D8 +tetsecyrillic;04B5 +tevirhebrew;059B +tevirlefthebrew;059B +thabengali;09A5 +thadeva;0925 +thagujarati;0AA5 +thagurmukhi;0A25 +thalarabic;0630 +thalfinalarabic;FEAC +thanthakhatlowleftthai;F898 +thanthakhatlowrightthai;F897 +thanthakhatthai;0E4C +thanthakhatupperleftthai;F896 +theharabic;062B +thehfinalarabic;FE9A +thehinitialarabic;FE9B +thehmedialarabic;FE9C +thereexists;2203 +therefore;2234 +theta;03B8 +theta1;03D1 +thetasymbolgreek;03D1 +thieuthacirclekorean;3279 +thieuthaparenkorean;3219 +thieuthcirclekorean;326B +thieuthkorean;314C +thieuthparenkorean;320B +thirteencircle;246C +thirteenparen;2480 +thirteenperiod;2494 +thonangmonthothai;0E11 +thook;01AD +thophuthaothai;0E12 +thorn;00FE +thothahanthai;0E17 +thothanthai;0E10 +thothongthai;0E18 +thothungthai;0E16 +thousandcyrillic;0482 +thousandsseparatorarabic;066C +thousandsseparatorpersian;066C +three;0033 +threearabic;0663 +threebengali;09E9 +threecircle;2462 +threecircleinversesansserif;278C +threedeva;0969 +threeeighths;215C +threegujarati;0AE9 +threegurmukhi;0A69 +threehackarabic;0663 +threehangzhou;3023 +threeideographicparen;3222 +threeinferior;2083 +threemonospace;FF13 +threenumeratorbengali;09F6 +threeoldstyle;F733 +threeparen;2476 +threeperiod;248A +threepersian;06F3 +threequarters;00BE +threequartersemdash;F6DE +threeroman;2172 +threesuperior;00B3 +threethai;0E53 +thzsquare;3394 +tihiragana;3061 +tikatakana;30C1 +tikatakanahalfwidth;FF81 +tikeutacirclekorean;3270 +tikeutaparenkorean;3210 +tikeutcirclekorean;3262 +tikeutkorean;3137 +tikeutparenkorean;3202 +tilde;02DC +tildebelowcmb;0330 +tildecmb;0303 +tildecomb;0303 +tildedoublecmb;0360 +tildeoperator;223C +tildeoverlaycmb;0334 +tildeverticalcmb;033E +timescircle;2297 +tipehahebrew;0596 +tipehalefthebrew;0596 +tippigurmukhi;0A70 +titlocyrilliccmb;0483 +tiwnarmenian;057F +tlinebelow;1E6F +tmonospace;FF54 +toarmenian;0569 +tohiragana;3068 +tokatakana;30C8 +tokatakanahalfwidth;FF84 +tonebarextrahighmod;02E5 +tonebarextralowmod;02E9 +tonebarhighmod;02E6 +tonebarlowmod;02E8 +tonebarmidmod;02E7 +tonefive;01BD +tonesix;0185 +tonetwo;01A8 +tonos;0384 +tonsquare;3327 +topatakthai;0E0F +tortoiseshellbracketleft;3014 +tortoiseshellbracketleftsmall;FE5D +tortoiseshellbracketleftvertical;FE39 +tortoiseshellbracketright;3015 +tortoiseshellbracketrightsmall;FE5E +tortoiseshellbracketrightvertical;FE3A +totaothai;0E15 +tpalatalhook;01AB +tparen;24AF +trademark;2122 +trademarksans;F8EA +trademarkserif;F6DB +tretroflexhook;0288 +triagdn;25BC +triaglf;25C4 +triagrt;25BA +triagup;25B2 +ts;02A6 +tsadi;05E6 +tsadidagesh;FB46 +tsadidageshhebrew;FB46 +tsadihebrew;05E6 +tsecyrillic;0446 +tsere;05B5 +tsere12;05B5 +tsere1e;05B5 +tsere2b;05B5 +tserehebrew;05B5 +tserenarrowhebrew;05B5 +tserequarterhebrew;05B5 +tserewidehebrew;05B5 +tshecyrillic;045B +tsuperior;F6F3 +ttabengali;099F +ttadeva;091F +ttagujarati;0A9F +ttagurmukhi;0A1F +tteharabic;0679 +ttehfinalarabic;FB67 +ttehinitialarabic;FB68 +ttehmedialarabic;FB69 +tthabengali;09A0 +tthadeva;0920 +tthagujarati;0AA0 +tthagurmukhi;0A20 +tturned;0287 +tuhiragana;3064 +tukatakana;30C4 +tukatakanahalfwidth;FF82 +tusmallhiragana;3063 +tusmallkatakana;30C3 +tusmallkatakanahalfwidth;FF6F +twelvecircle;246B +twelveparen;247F +twelveperiod;2493 +twelveroman;217B +twentycircle;2473 +twentyhangzhou;5344 +twentyparen;2487 +twentyperiod;249B +two;0032 +twoarabic;0662 +twobengali;09E8 +twocircle;2461 +twocircleinversesansserif;278B +twodeva;0968 +twodotenleader;2025 +twodotleader;2025 +twodotleadervertical;FE30 +twogujarati;0AE8 +twogurmukhi;0A68 +twohackarabic;0662 +twohangzhou;3022 +twoideographicparen;3221 +twoinferior;2082 +twomonospace;FF12 +twonumeratorbengali;09F5 +twooldstyle;F732 +twoparen;2475 +twoperiod;2489 +twopersian;06F2 +tworoman;2171 +twostroke;01BB +twosuperior;00B2 +twothai;0E52 +twothirds;2154 +u;0075 +uacute;00FA +ubar;0289 +ubengali;0989 +ubopomofo;3128 +ubreve;016D +ucaron;01D4 +ucircle;24E4 +ucircumflex;00FB +ucircumflexbelow;1E77 +ucyrillic;0443 +udattadeva;0951 +udblacute;0171 +udblgrave;0215 +udeva;0909 +udieresis;00FC +udieresisacute;01D8 +udieresisbelow;1E73 +udieresiscaron;01DA +udieresiscyrillic;04F1 +udieresisgrave;01DC +udieresismacron;01D6 +udotbelow;1EE5 +ugrave;00F9 +ugujarati;0A89 +ugurmukhi;0A09 +uhiragana;3046 +uhookabove;1EE7 +uhorn;01B0 +uhornacute;1EE9 +uhorndotbelow;1EF1 +uhorngrave;1EEB +uhornhookabove;1EED +uhorntilde;1EEF +uhungarumlaut;0171 +uhungarumlautcyrillic;04F3 +uinvertedbreve;0217 +ukatakana;30A6 +ukatakanahalfwidth;FF73 +ukcyrillic;0479 +ukorean;315C +umacron;016B +umacroncyrillic;04EF +umacrondieresis;1E7B +umatragurmukhi;0A41 +umonospace;FF55 +underscore;005F +underscoredbl;2017 +underscoremonospace;FF3F +underscorevertical;FE33 +underscorewavy;FE4F +union;222A +universal;2200 +uogonek;0173 +uparen;24B0 +upblock;2580 +upperdothebrew;05C4 +upsilon;03C5 +upsilondieresis;03CB +upsilondieresistonos;03B0 +upsilonlatin;028A +upsilontonos;03CD +uptackbelowcmb;031D +uptackmod;02D4 +uragurmukhi;0A73 +uring;016F +ushortcyrillic;045E +usmallhiragana;3045 +usmallkatakana;30A5 +usmallkatakanahalfwidth;FF69 +ustraightcyrillic;04AF +ustraightstrokecyrillic;04B1 +utilde;0169 +utildeacute;1E79 +utildebelow;1E75 +uubengali;098A +uudeva;090A +uugujarati;0A8A +uugurmukhi;0A0A +uumatragurmukhi;0A42 +uuvowelsignbengali;09C2 +uuvowelsigndeva;0942 +uuvowelsigngujarati;0AC2 +uvowelsignbengali;09C1 +uvowelsigndeva;0941 +uvowelsigngujarati;0AC1 +v;0076 +vadeva;0935 +vagujarati;0AB5 +vagurmukhi;0A35 +vakatakana;30F7 +vav;05D5 +vavdagesh;FB35 +vavdagesh65;FB35 +vavdageshhebrew;FB35 +vavhebrew;05D5 +vavholam;FB4B +vavholamhebrew;FB4B +vavvavhebrew;05F0 +vavyodhebrew;05F1 +vcircle;24E5 +vdotbelow;1E7F +vecyrillic;0432 +veharabic;06A4 +vehfinalarabic;FB6B +vehinitialarabic;FB6C +vehmedialarabic;FB6D +vekatakana;30F9 +venus;2640 +verticalbar;007C +verticallineabovecmb;030D +verticallinebelowcmb;0329 +verticallinelowmod;02CC +verticallinemod;02C8 +vewarmenian;057E +vhook;028B +vikatakana;30F8 +viramabengali;09CD +viramadeva;094D +viramagujarati;0ACD +visargabengali;0983 +visargadeva;0903 +visargagujarati;0A83 +vmonospace;FF56 +voarmenian;0578 +voicediterationhiragana;309E +voicediterationkatakana;30FE +voicedmarkkana;309B +voicedmarkkanahalfwidth;FF9E +vokatakana;30FA +vparen;24B1 +vtilde;1E7D +vturned;028C +vuhiragana;3094 +vukatakana;30F4 +w;0077 +wacute;1E83 +waekorean;3159 +wahiragana;308F +wakatakana;30EF +wakatakanahalfwidth;FF9C +wakorean;3158 +wasmallhiragana;308E +wasmallkatakana;30EE +wattosquare;3357 +wavedash;301C +wavyunderscorevertical;FE34 +wawarabic;0648 +wawfinalarabic;FEEE +wawhamzaabovearabic;0624 +wawhamzaabovefinalarabic;FE86 +wbsquare;33DD +wcircle;24E6 +wcircumflex;0175 +wdieresis;1E85 +wdotaccent;1E87 +wdotbelow;1E89 +wehiragana;3091 +weierstrass;2118 +wekatakana;30F1 +wekorean;315E +weokorean;315D +wgrave;1E81 +whitebullet;25E6 +whitecircle;25CB +whitecircleinverse;25D9 +whitecornerbracketleft;300E +whitecornerbracketleftvertical;FE43 +whitecornerbracketright;300F +whitecornerbracketrightvertical;FE44 +whitediamond;25C7 +whitediamondcontainingblacksmalldiamond;25C8 +whitedownpointingsmalltriangle;25BF +whitedownpointingtriangle;25BD +whiteleftpointingsmalltriangle;25C3 +whiteleftpointingtriangle;25C1 +whitelenticularbracketleft;3016 +whitelenticularbracketright;3017 +whiterightpointingsmalltriangle;25B9 +whiterightpointingtriangle;25B7 +whitesmallsquare;25AB +whitesmilingface;263A +whitesquare;25A1 +whitestar;2606 +whitetelephone;260F +whitetortoiseshellbracketleft;3018 +whitetortoiseshellbracketright;3019 +whiteuppointingsmalltriangle;25B5 +whiteuppointingtriangle;25B3 +wihiragana;3090 +wikatakana;30F0 +wikorean;315F +wmonospace;FF57 +wohiragana;3092 +wokatakana;30F2 +wokatakanahalfwidth;FF66 +won;20A9 +wonmonospace;FFE6 +wowaenthai;0E27 +wparen;24B2 +wring;1E98 +wsuperior;02B7 +wturned;028D +wynn;01BF +x;0078 +xabovecmb;033D +xbopomofo;3112 +xcircle;24E7 +xdieresis;1E8D +xdotaccent;1E8B +xeharmenian;056D +xi;03BE +xmonospace;FF58 +xparen;24B3 +xsuperior;02E3 +y;0079 +yaadosquare;334E +yabengali;09AF +yacute;00FD +yadeva;092F +yaekorean;3152 +yagujarati;0AAF +yagurmukhi;0A2F +yahiragana;3084 +yakatakana;30E4 +yakatakanahalfwidth;FF94 +yakorean;3151 +yamakkanthai;0E4E +yasmallhiragana;3083 +yasmallkatakana;30E3 +yasmallkatakanahalfwidth;FF6C +yatcyrillic;0463 +ycircle;24E8 +ycircumflex;0177 +ydieresis;00FF +ydotaccent;1E8F +ydotbelow;1EF5 +yeharabic;064A +yehbarreearabic;06D2 +yehbarreefinalarabic;FBAF +yehfinalarabic;FEF2 +yehhamzaabovearabic;0626 +yehhamzaabovefinalarabic;FE8A +yehhamzaaboveinitialarabic;FE8B +yehhamzaabovemedialarabic;FE8C +yehinitialarabic;FEF3 +yehmedialarabic;FEF4 +yehmeeminitialarabic;FCDD +yehmeemisolatedarabic;FC58 +yehnoonfinalarabic;FC94 +yehthreedotsbelowarabic;06D1 +yekorean;3156 +yen;00A5 +yenmonospace;FFE5 +yeokorean;3155 +yeorinhieuhkorean;3186 +yerahbenyomohebrew;05AA +yerahbenyomolefthebrew;05AA +yericyrillic;044B +yerudieresiscyrillic;04F9 +yesieungkorean;3181 +yesieungpansioskorean;3183 +yesieungsioskorean;3182 +yetivhebrew;059A +ygrave;1EF3 +yhook;01B4 +yhookabove;1EF7 +yiarmenian;0575 +yicyrillic;0457 +yikorean;3162 +yinyang;262F +yiwnarmenian;0582 +ymonospace;FF59 +yod;05D9 +yoddagesh;FB39 +yoddageshhebrew;FB39 +yodhebrew;05D9 +yodyodhebrew;05F2 +yodyodpatahhebrew;FB1F +yohiragana;3088 +yoikorean;3189 +yokatakana;30E8 +yokatakanahalfwidth;FF96 +yokorean;315B +yosmallhiragana;3087 +yosmallkatakana;30E7 +yosmallkatakanahalfwidth;FF6E +yotgreek;03F3 +yoyaekorean;3188 +yoyakorean;3187 +yoyakthai;0E22 +yoyingthai;0E0D +yparen;24B4 +ypogegrammeni;037A +ypogegrammenigreekcmb;0345 +yr;01A6 +yring;1E99 +ysuperior;02B8 +ytilde;1EF9 +yturned;028E +yuhiragana;3086 +yuikorean;318C +yukatakana;30E6 +yukatakanahalfwidth;FF95 +yukorean;3160 +yusbigcyrillic;046B +yusbigiotifiedcyrillic;046D +yuslittlecyrillic;0467 +yuslittleiotifiedcyrillic;0469 +yusmallhiragana;3085 +yusmallkatakana;30E5 +yusmallkatakanahalfwidth;FF6D +yuyekorean;318B +yuyeokorean;318A +yyabengali;09DF +yyadeva;095F +z;007A +zaarmenian;0566 +zacute;017A +zadeva;095B +zagurmukhi;0A5B +zaharabic;0638 +zahfinalarabic;FEC6 +zahinitialarabic;FEC7 +zahiragana;3056 +zahmedialarabic;FEC8 +zainarabic;0632 +zainfinalarabic;FEB0 +zakatakana;30B6 +zaqefgadolhebrew;0595 +zaqefqatanhebrew;0594 +zarqahebrew;0598 +zayin;05D6 +zayindagesh;FB36 +zayindageshhebrew;FB36 +zayinhebrew;05D6 +zbopomofo;3117 +zcaron;017E +zcircle;24E9 +zcircumflex;1E91 +zcurl;0291 +zdot;017C +zdotaccent;017C +zdotbelow;1E93 +zecyrillic;0437 +zedescendercyrillic;0499 +zedieresiscyrillic;04DF +zehiragana;305C +zekatakana;30BC +zero;0030 +zeroarabic;0660 +zerobengali;09E6 +zerodeva;0966 +zerogujarati;0AE6 +zerogurmukhi;0A66 +zerohackarabic;0660 +zeroinferior;2080 +zeromonospace;FF10 +zerooldstyle;F730 +zeropersian;06F0 +zerosuperior;2070 +zerothai;0E50 +zerowidthjoiner;FEFF +zerowidthnonjoiner;200C +zerowidthspace;200B +zeta;03B6 +zhbopomofo;3113 +zhearmenian;056A +zhebrevecyrillic;04C2 +zhecyrillic;0436 +zhedescendercyrillic;0497 +zhedieresiscyrillic;04DD +zihiragana;3058 +zikatakana;30B8 +zinorhebrew;05AE +zlinebelow;1E95 +zmonospace;FF5A +zohiragana;305E +zokatakana;30BE +zparen;24B5 +zretroflexhook;0290 +zstroke;01B6 +zuhiragana;305A +zukatakana;30BA +# END +""" + + +_aglfnText = """\ +# ----------------------------------------------------------- +# Copyright 2002-2019 Adobe (http://www.adobe.com/). +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the +# following conditions are met: +# +# Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# Neither the name of Adobe nor the names of its contributors +# may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------- +# Name: Adobe Glyph List For New Fonts +# Table version: 1.7 +# Date: November 6, 2008 +# URL: https://github.com/adobe-type-tools/agl-aglfn +# +# Description: +# +# AGLFN (Adobe Glyph List For New Fonts) provides a list of base glyph +# names that are recommended for new fonts, which are compatible with +# the AGL (Adobe Glyph List) Specification, and which should be used +# as described in Section 6 of that document. AGLFN comprises the set +# of glyph names from AGL that map via the AGL Specification rules to +# the semantically correct UV (Unicode Value). For example, "Asmall" +# is omitted because AGL maps this glyph name to the PUA (Private Use +# Area) value U+F761, rather than to the UV that maps from the glyph +# name "A." Also omitted is "ffi," because AGL maps this to the +# Alphabetic Presentation Forms value U+FB03, rather than decomposing +# it into the following sequence of three UVs: U+0066, U+0066, and +# U+0069. The name "arrowvertex" has been omitted because this glyph +# now has a real UV, and AGL is now incorrect in mapping it to the PUA +# value U+F8E6. If you do not find an appropriate name for your glyph +# in this list, then please refer to Section 6 of the AGL +# Specification. +# +# Format: three semicolon-delimited fields: +# (1) Standard UV or CUS UV--four uppercase hexadecimal digits +# (2) Glyph name--upper/lowercase letters and digits +# (3) Character names: Unicode character names for standard UVs, and +# descriptive names for CUS UVs--uppercase letters, hyphen, and +# space +# +# The records are sorted by glyph name in increasing ASCII order, +# entries with the same glyph name are sorted in decreasing priority +# order, the UVs and Unicode character names are provided for +# convenience, lines starting with "#" are comments, and blank lines +# should be ignored. +# +# Revision History: +# +# 1.7 [6 November 2008] +# - Reverted to the original 1.4 and earlier mappings for Delta, +# Omega, and mu. +# - Removed mappings for "afii" names. These should now be assigned +# "uni" names. +# - Removed mappings for "commaaccent" names. These should now be +# assigned "uni" names. +# +# 1.6 [30 January 2006] +# - Completed work intended in 1.5. +# +# 1.5 [23 November 2005] +# - Removed duplicated block at end of file. +# - Changed mappings: +# 2206;Delta;INCREMENT changed to 0394;Delta;GREEK CAPITAL LETTER DELTA +# 2126;Omega;OHM SIGN changed to 03A9;Omega;GREEK CAPITAL LETTER OMEGA +# 03BC;mu;MICRO SIGN changed to 03BC;mu;GREEK SMALL LETTER MU +# - Corrected statement above about why "ffi" is omitted. +# +# 1.4 [24 September 2003] +# - Changed version to 1.4, to avoid confusion with the AGL 1.3. +# - Fixed spelling errors in the header. +# - Fully removed "arrowvertex," as it is mapped only to a PUA Unicode +# value in some fonts. +# +# 1.1 [17 April 2003] +# - Renamed [Tt]cedilla back to [Tt]commaaccent. +# +# 1.0 [31 January 2003] +# - Original version. +# - Derived from the AGLv1.2 by: +# removing the PUA area codes; +# removing duplicate Unicode mappings; and +# renaming "tcommaaccent" to "tcedilla" and "Tcommaaccent" to "Tcedilla" +# +0041;A;LATIN CAPITAL LETTER A +00C6;AE;LATIN CAPITAL LETTER AE +01FC;AEacute;LATIN CAPITAL LETTER AE WITH ACUTE +00C1;Aacute;LATIN CAPITAL LETTER A WITH ACUTE +0102;Abreve;LATIN CAPITAL LETTER A WITH BREVE +00C2;Acircumflex;LATIN CAPITAL LETTER A WITH CIRCUMFLEX +00C4;Adieresis;LATIN CAPITAL LETTER A WITH DIAERESIS +00C0;Agrave;LATIN CAPITAL LETTER A WITH GRAVE +0391;Alpha;GREEK CAPITAL LETTER ALPHA +0386;Alphatonos;GREEK CAPITAL LETTER ALPHA WITH TONOS +0100;Amacron;LATIN CAPITAL LETTER A WITH MACRON +0104;Aogonek;LATIN CAPITAL LETTER A WITH OGONEK +00C5;Aring;LATIN CAPITAL LETTER A WITH RING ABOVE +01FA;Aringacute;LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE +00C3;Atilde;LATIN CAPITAL LETTER A WITH TILDE +0042;B;LATIN CAPITAL LETTER B +0392;Beta;GREEK CAPITAL LETTER BETA +0043;C;LATIN CAPITAL LETTER C +0106;Cacute;LATIN CAPITAL LETTER C WITH ACUTE +010C;Ccaron;LATIN CAPITAL LETTER C WITH CARON +00C7;Ccedilla;LATIN CAPITAL LETTER C WITH CEDILLA +0108;Ccircumflex;LATIN CAPITAL LETTER C WITH CIRCUMFLEX +010A;Cdotaccent;LATIN CAPITAL LETTER C WITH DOT ABOVE +03A7;Chi;GREEK CAPITAL LETTER CHI +0044;D;LATIN CAPITAL LETTER D +010E;Dcaron;LATIN CAPITAL LETTER D WITH CARON +0110;Dcroat;LATIN CAPITAL LETTER D WITH STROKE +2206;Delta;INCREMENT +0045;E;LATIN CAPITAL LETTER E +00C9;Eacute;LATIN CAPITAL LETTER E WITH ACUTE +0114;Ebreve;LATIN CAPITAL LETTER E WITH BREVE +011A;Ecaron;LATIN CAPITAL LETTER E WITH CARON +00CA;Ecircumflex;LATIN CAPITAL LETTER E WITH CIRCUMFLEX +00CB;Edieresis;LATIN CAPITAL LETTER E WITH DIAERESIS +0116;Edotaccent;LATIN CAPITAL LETTER E WITH DOT ABOVE +00C8;Egrave;LATIN CAPITAL LETTER E WITH GRAVE +0112;Emacron;LATIN CAPITAL LETTER E WITH MACRON +014A;Eng;LATIN CAPITAL LETTER ENG +0118;Eogonek;LATIN CAPITAL LETTER E WITH OGONEK +0395;Epsilon;GREEK CAPITAL LETTER EPSILON +0388;Epsilontonos;GREEK CAPITAL LETTER EPSILON WITH TONOS +0397;Eta;GREEK CAPITAL LETTER ETA +0389;Etatonos;GREEK CAPITAL LETTER ETA WITH TONOS +00D0;Eth;LATIN CAPITAL LETTER ETH +20AC;Euro;EURO SIGN +0046;F;LATIN CAPITAL LETTER F +0047;G;LATIN CAPITAL LETTER G +0393;Gamma;GREEK CAPITAL LETTER GAMMA +011E;Gbreve;LATIN CAPITAL LETTER G WITH BREVE +01E6;Gcaron;LATIN CAPITAL LETTER G WITH CARON +011C;Gcircumflex;LATIN CAPITAL LETTER G WITH CIRCUMFLEX +0120;Gdotaccent;LATIN CAPITAL LETTER G WITH DOT ABOVE +0048;H;LATIN CAPITAL LETTER H +25CF;H18533;BLACK CIRCLE +25AA;H18543;BLACK SMALL SQUARE +25AB;H18551;WHITE SMALL SQUARE +25A1;H22073;WHITE SQUARE +0126;Hbar;LATIN CAPITAL LETTER H WITH STROKE +0124;Hcircumflex;LATIN CAPITAL LETTER H WITH CIRCUMFLEX +0049;I;LATIN CAPITAL LETTER I +0132;IJ;LATIN CAPITAL LIGATURE IJ +00CD;Iacute;LATIN CAPITAL LETTER I WITH ACUTE +012C;Ibreve;LATIN CAPITAL LETTER I WITH BREVE +00CE;Icircumflex;LATIN CAPITAL LETTER I WITH CIRCUMFLEX +00CF;Idieresis;LATIN CAPITAL LETTER I WITH DIAERESIS +0130;Idotaccent;LATIN CAPITAL LETTER I WITH DOT ABOVE +2111;Ifraktur;BLACK-LETTER CAPITAL I +00CC;Igrave;LATIN CAPITAL LETTER I WITH GRAVE +012A;Imacron;LATIN CAPITAL LETTER I WITH MACRON +012E;Iogonek;LATIN CAPITAL LETTER I WITH OGONEK +0399;Iota;GREEK CAPITAL LETTER IOTA +03AA;Iotadieresis;GREEK CAPITAL LETTER IOTA WITH DIALYTIKA +038A;Iotatonos;GREEK CAPITAL LETTER IOTA WITH TONOS +0128;Itilde;LATIN CAPITAL LETTER I WITH TILDE +004A;J;LATIN CAPITAL LETTER J +0134;Jcircumflex;LATIN CAPITAL LETTER J WITH CIRCUMFLEX +004B;K;LATIN CAPITAL LETTER K +039A;Kappa;GREEK CAPITAL LETTER KAPPA +004C;L;LATIN CAPITAL LETTER L +0139;Lacute;LATIN CAPITAL LETTER L WITH ACUTE +039B;Lambda;GREEK CAPITAL LETTER LAMDA +013D;Lcaron;LATIN CAPITAL LETTER L WITH CARON +013F;Ldot;LATIN CAPITAL LETTER L WITH MIDDLE DOT +0141;Lslash;LATIN CAPITAL LETTER L WITH STROKE +004D;M;LATIN CAPITAL LETTER M +039C;Mu;GREEK CAPITAL LETTER MU +004E;N;LATIN CAPITAL LETTER N +0143;Nacute;LATIN CAPITAL LETTER N WITH ACUTE +0147;Ncaron;LATIN CAPITAL LETTER N WITH CARON +00D1;Ntilde;LATIN CAPITAL LETTER N WITH TILDE +039D;Nu;GREEK CAPITAL LETTER NU +004F;O;LATIN CAPITAL LETTER O +0152;OE;LATIN CAPITAL LIGATURE OE +00D3;Oacute;LATIN CAPITAL LETTER O WITH ACUTE +014E;Obreve;LATIN CAPITAL LETTER O WITH BREVE +00D4;Ocircumflex;LATIN CAPITAL LETTER O WITH CIRCUMFLEX +00D6;Odieresis;LATIN CAPITAL LETTER O WITH DIAERESIS +00D2;Ograve;LATIN CAPITAL LETTER O WITH GRAVE +01A0;Ohorn;LATIN CAPITAL LETTER O WITH HORN +0150;Ohungarumlaut;LATIN CAPITAL LETTER O WITH DOUBLE ACUTE +014C;Omacron;LATIN CAPITAL LETTER O WITH MACRON +2126;Omega;OHM SIGN +038F;Omegatonos;GREEK CAPITAL LETTER OMEGA WITH TONOS +039F;Omicron;GREEK CAPITAL LETTER OMICRON +038C;Omicrontonos;GREEK CAPITAL LETTER OMICRON WITH TONOS +00D8;Oslash;LATIN CAPITAL LETTER O WITH STROKE +01FE;Oslashacute;LATIN CAPITAL LETTER O WITH STROKE AND ACUTE +00D5;Otilde;LATIN CAPITAL LETTER O WITH TILDE +0050;P;LATIN CAPITAL LETTER P +03A6;Phi;GREEK CAPITAL LETTER PHI +03A0;Pi;GREEK CAPITAL LETTER PI +03A8;Psi;GREEK CAPITAL LETTER PSI +0051;Q;LATIN CAPITAL LETTER Q +0052;R;LATIN CAPITAL LETTER R +0154;Racute;LATIN CAPITAL LETTER R WITH ACUTE +0158;Rcaron;LATIN CAPITAL LETTER R WITH CARON +211C;Rfraktur;BLACK-LETTER CAPITAL R +03A1;Rho;GREEK CAPITAL LETTER RHO +0053;S;LATIN CAPITAL LETTER S +250C;SF010000;BOX DRAWINGS LIGHT DOWN AND RIGHT +2514;SF020000;BOX DRAWINGS LIGHT UP AND RIGHT +2510;SF030000;BOX DRAWINGS LIGHT DOWN AND LEFT +2518;SF040000;BOX DRAWINGS LIGHT UP AND LEFT +253C;SF050000;BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL +252C;SF060000;BOX DRAWINGS LIGHT DOWN AND HORIZONTAL +2534;SF070000;BOX DRAWINGS LIGHT UP AND HORIZONTAL +251C;SF080000;BOX DRAWINGS LIGHT VERTICAL AND RIGHT +2524;SF090000;BOX DRAWINGS LIGHT VERTICAL AND LEFT +2500;SF100000;BOX DRAWINGS LIGHT HORIZONTAL +2502;SF110000;BOX DRAWINGS LIGHT VERTICAL +2561;SF190000;BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE +2562;SF200000;BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE +2556;SF210000;BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE +2555;SF220000;BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE +2563;SF230000;BOX DRAWINGS DOUBLE VERTICAL AND LEFT +2551;SF240000;BOX DRAWINGS DOUBLE VERTICAL +2557;SF250000;BOX DRAWINGS DOUBLE DOWN AND LEFT +255D;SF260000;BOX DRAWINGS DOUBLE UP AND LEFT +255C;SF270000;BOX DRAWINGS UP DOUBLE AND LEFT SINGLE +255B;SF280000;BOX DRAWINGS UP SINGLE AND LEFT DOUBLE +255E;SF360000;BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE +255F;SF370000;BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE +255A;SF380000;BOX DRAWINGS DOUBLE UP AND RIGHT +2554;SF390000;BOX DRAWINGS DOUBLE DOWN AND RIGHT +2569;SF400000;BOX DRAWINGS DOUBLE UP AND HORIZONTAL +2566;SF410000;BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL +2560;SF420000;BOX DRAWINGS DOUBLE VERTICAL AND RIGHT +2550;SF430000;BOX DRAWINGS DOUBLE HORIZONTAL +256C;SF440000;BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL +2567;SF450000;BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE +2568;SF460000;BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE +2564;SF470000;BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE +2565;SF480000;BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE +2559;SF490000;BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE +2558;SF500000;BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE +2552;SF510000;BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE +2553;SF520000;BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE +256B;SF530000;BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE +256A;SF540000;BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE +015A;Sacute;LATIN CAPITAL LETTER S WITH ACUTE +0160;Scaron;LATIN CAPITAL LETTER S WITH CARON +015E;Scedilla;LATIN CAPITAL LETTER S WITH CEDILLA +015C;Scircumflex;LATIN CAPITAL LETTER S WITH CIRCUMFLEX +03A3;Sigma;GREEK CAPITAL LETTER SIGMA +0054;T;LATIN CAPITAL LETTER T +03A4;Tau;GREEK CAPITAL LETTER TAU +0166;Tbar;LATIN CAPITAL LETTER T WITH STROKE +0164;Tcaron;LATIN CAPITAL LETTER T WITH CARON +0398;Theta;GREEK CAPITAL LETTER THETA +00DE;Thorn;LATIN CAPITAL LETTER THORN +0055;U;LATIN CAPITAL LETTER U +00DA;Uacute;LATIN CAPITAL LETTER U WITH ACUTE +016C;Ubreve;LATIN CAPITAL LETTER U WITH BREVE +00DB;Ucircumflex;LATIN CAPITAL LETTER U WITH CIRCUMFLEX +00DC;Udieresis;LATIN CAPITAL LETTER U WITH DIAERESIS +00D9;Ugrave;LATIN CAPITAL LETTER U WITH GRAVE +01AF;Uhorn;LATIN CAPITAL LETTER U WITH HORN +0170;Uhungarumlaut;LATIN CAPITAL LETTER U WITH DOUBLE ACUTE +016A;Umacron;LATIN CAPITAL LETTER U WITH MACRON +0172;Uogonek;LATIN CAPITAL LETTER U WITH OGONEK +03A5;Upsilon;GREEK CAPITAL LETTER UPSILON +03D2;Upsilon1;GREEK UPSILON WITH HOOK SYMBOL +03AB;Upsilondieresis;GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA +038E;Upsilontonos;GREEK CAPITAL LETTER UPSILON WITH TONOS +016E;Uring;LATIN CAPITAL LETTER U WITH RING ABOVE +0168;Utilde;LATIN CAPITAL LETTER U WITH TILDE +0056;V;LATIN CAPITAL LETTER V +0057;W;LATIN CAPITAL LETTER W +1E82;Wacute;LATIN CAPITAL LETTER W WITH ACUTE +0174;Wcircumflex;LATIN CAPITAL LETTER W WITH CIRCUMFLEX +1E84;Wdieresis;LATIN CAPITAL LETTER W WITH DIAERESIS +1E80;Wgrave;LATIN CAPITAL LETTER W WITH GRAVE +0058;X;LATIN CAPITAL LETTER X +039E;Xi;GREEK CAPITAL LETTER XI +0059;Y;LATIN CAPITAL LETTER Y +00DD;Yacute;LATIN CAPITAL LETTER Y WITH ACUTE +0176;Ycircumflex;LATIN CAPITAL LETTER Y WITH CIRCUMFLEX +0178;Ydieresis;LATIN CAPITAL LETTER Y WITH DIAERESIS +1EF2;Ygrave;LATIN CAPITAL LETTER Y WITH GRAVE +005A;Z;LATIN CAPITAL LETTER Z +0179;Zacute;LATIN CAPITAL LETTER Z WITH ACUTE +017D;Zcaron;LATIN CAPITAL LETTER Z WITH CARON +017B;Zdotaccent;LATIN CAPITAL LETTER Z WITH DOT ABOVE +0396;Zeta;GREEK CAPITAL LETTER ZETA +0061;a;LATIN SMALL LETTER A +00E1;aacute;LATIN SMALL LETTER A WITH ACUTE +0103;abreve;LATIN SMALL LETTER A WITH BREVE +00E2;acircumflex;LATIN SMALL LETTER A WITH CIRCUMFLEX +00B4;acute;ACUTE ACCENT +0301;acutecomb;COMBINING ACUTE ACCENT +00E4;adieresis;LATIN SMALL LETTER A WITH DIAERESIS +00E6;ae;LATIN SMALL LETTER AE +01FD;aeacute;LATIN SMALL LETTER AE WITH ACUTE +00E0;agrave;LATIN SMALL LETTER A WITH GRAVE +2135;aleph;ALEF SYMBOL +03B1;alpha;GREEK SMALL LETTER ALPHA +03AC;alphatonos;GREEK SMALL LETTER ALPHA WITH TONOS +0101;amacron;LATIN SMALL LETTER A WITH MACRON +0026;ampersand;AMPERSAND +2220;angle;ANGLE +2329;angleleft;LEFT-POINTING ANGLE BRACKET +232A;angleright;RIGHT-POINTING ANGLE BRACKET +0387;anoteleia;GREEK ANO TELEIA +0105;aogonek;LATIN SMALL LETTER A WITH OGONEK +2248;approxequal;ALMOST EQUAL TO +00E5;aring;LATIN SMALL LETTER A WITH RING ABOVE +01FB;aringacute;LATIN SMALL LETTER A WITH RING ABOVE AND ACUTE +2194;arrowboth;LEFT RIGHT ARROW +21D4;arrowdblboth;LEFT RIGHT DOUBLE ARROW +21D3;arrowdbldown;DOWNWARDS DOUBLE ARROW +21D0;arrowdblleft;LEFTWARDS DOUBLE ARROW +21D2;arrowdblright;RIGHTWARDS DOUBLE ARROW +21D1;arrowdblup;UPWARDS DOUBLE ARROW +2193;arrowdown;DOWNWARDS ARROW +2190;arrowleft;LEFTWARDS ARROW +2192;arrowright;RIGHTWARDS ARROW +2191;arrowup;UPWARDS ARROW +2195;arrowupdn;UP DOWN ARROW +21A8;arrowupdnbse;UP DOWN ARROW WITH BASE +005E;asciicircum;CIRCUMFLEX ACCENT +007E;asciitilde;TILDE +002A;asterisk;ASTERISK +2217;asteriskmath;ASTERISK OPERATOR +0040;at;COMMERCIAL AT +00E3;atilde;LATIN SMALL LETTER A WITH TILDE +0062;b;LATIN SMALL LETTER B +005C;backslash;REVERSE SOLIDUS +007C;bar;VERTICAL LINE +03B2;beta;GREEK SMALL LETTER BETA +2588;block;FULL BLOCK +007B;braceleft;LEFT CURLY BRACKET +007D;braceright;RIGHT CURLY BRACKET +005B;bracketleft;LEFT SQUARE BRACKET +005D;bracketright;RIGHT SQUARE BRACKET +02D8;breve;BREVE +00A6;brokenbar;BROKEN BAR +2022;bullet;BULLET +0063;c;LATIN SMALL LETTER C +0107;cacute;LATIN SMALL LETTER C WITH ACUTE +02C7;caron;CARON +21B5;carriagereturn;DOWNWARDS ARROW WITH CORNER LEFTWARDS +010D;ccaron;LATIN SMALL LETTER C WITH CARON +00E7;ccedilla;LATIN SMALL LETTER C WITH CEDILLA +0109;ccircumflex;LATIN SMALL LETTER C WITH CIRCUMFLEX +010B;cdotaccent;LATIN SMALL LETTER C WITH DOT ABOVE +00B8;cedilla;CEDILLA +00A2;cent;CENT SIGN +03C7;chi;GREEK SMALL LETTER CHI +25CB;circle;WHITE CIRCLE +2297;circlemultiply;CIRCLED TIMES +2295;circleplus;CIRCLED PLUS +02C6;circumflex;MODIFIER LETTER CIRCUMFLEX ACCENT +2663;club;BLACK CLUB SUIT +003A;colon;COLON +20A1;colonmonetary;COLON SIGN +002C;comma;COMMA +2245;congruent;APPROXIMATELY EQUAL TO +00A9;copyright;COPYRIGHT SIGN +00A4;currency;CURRENCY SIGN +0064;d;LATIN SMALL LETTER D +2020;dagger;DAGGER +2021;daggerdbl;DOUBLE DAGGER +010F;dcaron;LATIN SMALL LETTER D WITH CARON +0111;dcroat;LATIN SMALL LETTER D WITH STROKE +00B0;degree;DEGREE SIGN +03B4;delta;GREEK SMALL LETTER DELTA +2666;diamond;BLACK DIAMOND SUIT +00A8;dieresis;DIAERESIS +0385;dieresistonos;GREEK DIALYTIKA TONOS +00F7;divide;DIVISION SIGN +2593;dkshade;DARK SHADE +2584;dnblock;LOWER HALF BLOCK +0024;dollar;DOLLAR SIGN +20AB;dong;DONG SIGN +02D9;dotaccent;DOT ABOVE +0323;dotbelowcomb;COMBINING DOT BELOW +0131;dotlessi;LATIN SMALL LETTER DOTLESS I +22C5;dotmath;DOT OPERATOR +0065;e;LATIN SMALL LETTER E +00E9;eacute;LATIN SMALL LETTER E WITH ACUTE +0115;ebreve;LATIN SMALL LETTER E WITH BREVE +011B;ecaron;LATIN SMALL LETTER E WITH CARON +00EA;ecircumflex;LATIN SMALL LETTER E WITH CIRCUMFLEX +00EB;edieresis;LATIN SMALL LETTER E WITH DIAERESIS +0117;edotaccent;LATIN SMALL LETTER E WITH DOT ABOVE +00E8;egrave;LATIN SMALL LETTER E WITH GRAVE +0038;eight;DIGIT EIGHT +2208;element;ELEMENT OF +2026;ellipsis;HORIZONTAL ELLIPSIS +0113;emacron;LATIN SMALL LETTER E WITH MACRON +2014;emdash;EM DASH +2205;emptyset;EMPTY SET +2013;endash;EN DASH +014B;eng;LATIN SMALL LETTER ENG +0119;eogonek;LATIN SMALL LETTER E WITH OGONEK +03B5;epsilon;GREEK SMALL LETTER EPSILON +03AD;epsilontonos;GREEK SMALL LETTER EPSILON WITH TONOS +003D;equal;EQUALS SIGN +2261;equivalence;IDENTICAL TO +212E;estimated;ESTIMATED SYMBOL +03B7;eta;GREEK SMALL LETTER ETA +03AE;etatonos;GREEK SMALL LETTER ETA WITH TONOS +00F0;eth;LATIN SMALL LETTER ETH +0021;exclam;EXCLAMATION MARK +203C;exclamdbl;DOUBLE EXCLAMATION MARK +00A1;exclamdown;INVERTED EXCLAMATION MARK +2203;existential;THERE EXISTS +0066;f;LATIN SMALL LETTER F +2640;female;FEMALE SIGN +2012;figuredash;FIGURE DASH +25A0;filledbox;BLACK SQUARE +25AC;filledrect;BLACK RECTANGLE +0035;five;DIGIT FIVE +215D;fiveeighths;VULGAR FRACTION FIVE EIGHTHS +0192;florin;LATIN SMALL LETTER F WITH HOOK +0034;four;DIGIT FOUR +2044;fraction;FRACTION SLASH +20A3;franc;FRENCH FRANC SIGN +0067;g;LATIN SMALL LETTER G +03B3;gamma;GREEK SMALL LETTER GAMMA +011F;gbreve;LATIN SMALL LETTER G WITH BREVE +01E7;gcaron;LATIN SMALL LETTER G WITH CARON +011D;gcircumflex;LATIN SMALL LETTER G WITH CIRCUMFLEX +0121;gdotaccent;LATIN SMALL LETTER G WITH DOT ABOVE +00DF;germandbls;LATIN SMALL LETTER SHARP S +2207;gradient;NABLA +0060;grave;GRAVE ACCENT +0300;gravecomb;COMBINING GRAVE ACCENT +003E;greater;GREATER-THAN SIGN +2265;greaterequal;GREATER-THAN OR EQUAL TO +00AB;guillemotleft;LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +00BB;guillemotright;RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +2039;guilsinglleft;SINGLE LEFT-POINTING ANGLE QUOTATION MARK +203A;guilsinglright;SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +0068;h;LATIN SMALL LETTER H +0127;hbar;LATIN SMALL LETTER H WITH STROKE +0125;hcircumflex;LATIN SMALL LETTER H WITH CIRCUMFLEX +2665;heart;BLACK HEART SUIT +0309;hookabovecomb;COMBINING HOOK ABOVE +2302;house;HOUSE +02DD;hungarumlaut;DOUBLE ACUTE ACCENT +002D;hyphen;HYPHEN-MINUS +0069;i;LATIN SMALL LETTER I +00ED;iacute;LATIN SMALL LETTER I WITH ACUTE +012D;ibreve;LATIN SMALL LETTER I WITH BREVE +00EE;icircumflex;LATIN SMALL LETTER I WITH CIRCUMFLEX +00EF;idieresis;LATIN SMALL LETTER I WITH DIAERESIS +00EC;igrave;LATIN SMALL LETTER I WITH GRAVE +0133;ij;LATIN SMALL LIGATURE IJ +012B;imacron;LATIN SMALL LETTER I WITH MACRON +221E;infinity;INFINITY +222B;integral;INTEGRAL +2321;integralbt;BOTTOM HALF INTEGRAL +2320;integraltp;TOP HALF INTEGRAL +2229;intersection;INTERSECTION +25D8;invbullet;INVERSE BULLET +25D9;invcircle;INVERSE WHITE CIRCLE +263B;invsmileface;BLACK SMILING FACE +012F;iogonek;LATIN SMALL LETTER I WITH OGONEK +03B9;iota;GREEK SMALL LETTER IOTA +03CA;iotadieresis;GREEK SMALL LETTER IOTA WITH DIALYTIKA +0390;iotadieresistonos;GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS +03AF;iotatonos;GREEK SMALL LETTER IOTA WITH TONOS +0129;itilde;LATIN SMALL LETTER I WITH TILDE +006A;j;LATIN SMALL LETTER J +0135;jcircumflex;LATIN SMALL LETTER J WITH CIRCUMFLEX +006B;k;LATIN SMALL LETTER K +03BA;kappa;GREEK SMALL LETTER KAPPA +0138;kgreenlandic;LATIN SMALL LETTER KRA +006C;l;LATIN SMALL LETTER L +013A;lacute;LATIN SMALL LETTER L WITH ACUTE +03BB;lambda;GREEK SMALL LETTER LAMDA +013E;lcaron;LATIN SMALL LETTER L WITH CARON +0140;ldot;LATIN SMALL LETTER L WITH MIDDLE DOT +003C;less;LESS-THAN SIGN +2264;lessequal;LESS-THAN OR EQUAL TO +258C;lfblock;LEFT HALF BLOCK +20A4;lira;LIRA SIGN +2227;logicaland;LOGICAL AND +00AC;logicalnot;NOT SIGN +2228;logicalor;LOGICAL OR +017F;longs;LATIN SMALL LETTER LONG S +25CA;lozenge;LOZENGE +0142;lslash;LATIN SMALL LETTER L WITH STROKE +2591;ltshade;LIGHT SHADE +006D;m;LATIN SMALL LETTER M +00AF;macron;MACRON +2642;male;MALE SIGN +2212;minus;MINUS SIGN +2032;minute;PRIME +00B5;mu;MICRO SIGN +00D7;multiply;MULTIPLICATION SIGN +266A;musicalnote;EIGHTH NOTE +266B;musicalnotedbl;BEAMED EIGHTH NOTES +006E;n;LATIN SMALL LETTER N +0144;nacute;LATIN SMALL LETTER N WITH ACUTE +0149;napostrophe;LATIN SMALL LETTER N PRECEDED BY APOSTROPHE +0148;ncaron;LATIN SMALL LETTER N WITH CARON +0039;nine;DIGIT NINE +2209;notelement;NOT AN ELEMENT OF +2260;notequal;NOT EQUAL TO +2284;notsubset;NOT A SUBSET OF +00F1;ntilde;LATIN SMALL LETTER N WITH TILDE +03BD;nu;GREEK SMALL LETTER NU +0023;numbersign;NUMBER SIGN +006F;o;LATIN SMALL LETTER O +00F3;oacute;LATIN SMALL LETTER O WITH ACUTE +014F;obreve;LATIN SMALL LETTER O WITH BREVE +00F4;ocircumflex;LATIN SMALL LETTER O WITH CIRCUMFLEX +00F6;odieresis;LATIN SMALL LETTER O WITH DIAERESIS +0153;oe;LATIN SMALL LIGATURE OE +02DB;ogonek;OGONEK +00F2;ograve;LATIN SMALL LETTER O WITH GRAVE +01A1;ohorn;LATIN SMALL LETTER O WITH HORN +0151;ohungarumlaut;LATIN SMALL LETTER O WITH DOUBLE ACUTE +014D;omacron;LATIN SMALL LETTER O WITH MACRON +03C9;omega;GREEK SMALL LETTER OMEGA +03D6;omega1;GREEK PI SYMBOL +03CE;omegatonos;GREEK SMALL LETTER OMEGA WITH TONOS +03BF;omicron;GREEK SMALL LETTER OMICRON +03CC;omicrontonos;GREEK SMALL LETTER OMICRON WITH TONOS +0031;one;DIGIT ONE +2024;onedotenleader;ONE DOT LEADER +215B;oneeighth;VULGAR FRACTION ONE EIGHTH +00BD;onehalf;VULGAR FRACTION ONE HALF +00BC;onequarter;VULGAR FRACTION ONE QUARTER +2153;onethird;VULGAR FRACTION ONE THIRD +25E6;openbullet;WHITE BULLET +00AA;ordfeminine;FEMININE ORDINAL INDICATOR +00BA;ordmasculine;MASCULINE ORDINAL INDICATOR +221F;orthogonal;RIGHT ANGLE +00F8;oslash;LATIN SMALL LETTER O WITH STROKE +01FF;oslashacute;LATIN SMALL LETTER O WITH STROKE AND ACUTE +00F5;otilde;LATIN SMALL LETTER O WITH TILDE +0070;p;LATIN SMALL LETTER P +00B6;paragraph;PILCROW SIGN +0028;parenleft;LEFT PARENTHESIS +0029;parenright;RIGHT PARENTHESIS +2202;partialdiff;PARTIAL DIFFERENTIAL +0025;percent;PERCENT SIGN +002E;period;FULL STOP +00B7;periodcentered;MIDDLE DOT +22A5;perpendicular;UP TACK +2030;perthousand;PER MILLE SIGN +20A7;peseta;PESETA SIGN +03C6;phi;GREEK SMALL LETTER PHI +03D5;phi1;GREEK PHI SYMBOL +03C0;pi;GREEK SMALL LETTER PI +002B;plus;PLUS SIGN +00B1;plusminus;PLUS-MINUS SIGN +211E;prescription;PRESCRIPTION TAKE +220F;product;N-ARY PRODUCT +2282;propersubset;SUBSET OF +2283;propersuperset;SUPERSET OF +221D;proportional;PROPORTIONAL TO +03C8;psi;GREEK SMALL LETTER PSI +0071;q;LATIN SMALL LETTER Q +003F;question;QUESTION MARK +00BF;questiondown;INVERTED QUESTION MARK +0022;quotedbl;QUOTATION MARK +201E;quotedblbase;DOUBLE LOW-9 QUOTATION MARK +201C;quotedblleft;LEFT DOUBLE QUOTATION MARK +201D;quotedblright;RIGHT DOUBLE QUOTATION MARK +2018;quoteleft;LEFT SINGLE QUOTATION MARK +201B;quotereversed;SINGLE HIGH-REVERSED-9 QUOTATION MARK +2019;quoteright;RIGHT SINGLE QUOTATION MARK +201A;quotesinglbase;SINGLE LOW-9 QUOTATION MARK +0027;quotesingle;APOSTROPHE +0072;r;LATIN SMALL LETTER R +0155;racute;LATIN SMALL LETTER R WITH ACUTE +221A;radical;SQUARE ROOT +0159;rcaron;LATIN SMALL LETTER R WITH CARON +2286;reflexsubset;SUBSET OF OR EQUAL TO +2287;reflexsuperset;SUPERSET OF OR EQUAL TO +00AE;registered;REGISTERED SIGN +2310;revlogicalnot;REVERSED NOT SIGN +03C1;rho;GREEK SMALL LETTER RHO +02DA;ring;RING ABOVE +2590;rtblock;RIGHT HALF BLOCK +0073;s;LATIN SMALL LETTER S +015B;sacute;LATIN SMALL LETTER S WITH ACUTE +0161;scaron;LATIN SMALL LETTER S WITH CARON +015F;scedilla;LATIN SMALL LETTER S WITH CEDILLA +015D;scircumflex;LATIN SMALL LETTER S WITH CIRCUMFLEX +2033;second;DOUBLE PRIME +00A7;section;SECTION SIGN +003B;semicolon;SEMICOLON +0037;seven;DIGIT SEVEN +215E;seveneighths;VULGAR FRACTION SEVEN EIGHTHS +2592;shade;MEDIUM SHADE +03C3;sigma;GREEK SMALL LETTER SIGMA +03C2;sigma1;GREEK SMALL LETTER FINAL SIGMA +223C;similar;TILDE OPERATOR +0036;six;DIGIT SIX +002F;slash;SOLIDUS +263A;smileface;WHITE SMILING FACE +0020;space;SPACE +2660;spade;BLACK SPADE SUIT +00A3;sterling;POUND SIGN +220B;suchthat;CONTAINS AS MEMBER +2211;summation;N-ARY SUMMATION +263C;sun;WHITE SUN WITH RAYS +0074;t;LATIN SMALL LETTER T +03C4;tau;GREEK SMALL LETTER TAU +0167;tbar;LATIN SMALL LETTER T WITH STROKE +0165;tcaron;LATIN SMALL LETTER T WITH CARON +2234;therefore;THEREFORE +03B8;theta;GREEK SMALL LETTER THETA +03D1;theta1;GREEK THETA SYMBOL +00FE;thorn;LATIN SMALL LETTER THORN +0033;three;DIGIT THREE +215C;threeeighths;VULGAR FRACTION THREE EIGHTHS +00BE;threequarters;VULGAR FRACTION THREE QUARTERS +02DC;tilde;SMALL TILDE +0303;tildecomb;COMBINING TILDE +0384;tonos;GREEK TONOS +2122;trademark;TRADE MARK SIGN +25BC;triagdn;BLACK DOWN-POINTING TRIANGLE +25C4;triaglf;BLACK LEFT-POINTING POINTER +25BA;triagrt;BLACK RIGHT-POINTING POINTER +25B2;triagup;BLACK UP-POINTING TRIANGLE +0032;two;DIGIT TWO +2025;twodotenleader;TWO DOT LEADER +2154;twothirds;VULGAR FRACTION TWO THIRDS +0075;u;LATIN SMALL LETTER U +00FA;uacute;LATIN SMALL LETTER U WITH ACUTE +016D;ubreve;LATIN SMALL LETTER U WITH BREVE +00FB;ucircumflex;LATIN SMALL LETTER U WITH CIRCUMFLEX +00FC;udieresis;LATIN SMALL LETTER U WITH DIAERESIS +00F9;ugrave;LATIN SMALL LETTER U WITH GRAVE +01B0;uhorn;LATIN SMALL LETTER U WITH HORN +0171;uhungarumlaut;LATIN SMALL LETTER U WITH DOUBLE ACUTE +016B;umacron;LATIN SMALL LETTER U WITH MACRON +005F;underscore;LOW LINE +2017;underscoredbl;DOUBLE LOW LINE +222A;union;UNION +2200;universal;FOR ALL +0173;uogonek;LATIN SMALL LETTER U WITH OGONEK +2580;upblock;UPPER HALF BLOCK +03C5;upsilon;GREEK SMALL LETTER UPSILON +03CB;upsilondieresis;GREEK SMALL LETTER UPSILON WITH DIALYTIKA +03B0;upsilondieresistonos;GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS +03CD;upsilontonos;GREEK SMALL LETTER UPSILON WITH TONOS +016F;uring;LATIN SMALL LETTER U WITH RING ABOVE +0169;utilde;LATIN SMALL LETTER U WITH TILDE +0076;v;LATIN SMALL LETTER V +0077;w;LATIN SMALL LETTER W +1E83;wacute;LATIN SMALL LETTER W WITH ACUTE +0175;wcircumflex;LATIN SMALL LETTER W WITH CIRCUMFLEX +1E85;wdieresis;LATIN SMALL LETTER W WITH DIAERESIS +2118;weierstrass;SCRIPT CAPITAL P +1E81;wgrave;LATIN SMALL LETTER W WITH GRAVE +0078;x;LATIN SMALL LETTER X +03BE;xi;GREEK SMALL LETTER XI +0079;y;LATIN SMALL LETTER Y +00FD;yacute;LATIN SMALL LETTER Y WITH ACUTE +0177;ycircumflex;LATIN SMALL LETTER Y WITH CIRCUMFLEX +00FF;ydieresis;LATIN SMALL LETTER Y WITH DIAERESIS +00A5;yen;YEN SIGN +1EF3;ygrave;LATIN SMALL LETTER Y WITH GRAVE +007A;z;LATIN SMALL LETTER Z +017A;zacute;LATIN SMALL LETTER Z WITH ACUTE +017E;zcaron;LATIN SMALL LETTER Z WITH CARON +017C;zdotaccent;LATIN SMALL LETTER Z WITH DOT ABOVE +0030;zero;DIGIT ZERO +03B6;zeta;GREEK SMALL LETTER ZETA +# END +""" + + +class AGLError(Exception): + pass + + +LEGACY_AGL2UV = {} +AGL2UV = {} +UV2AGL = {} + + +def _builddicts(): + import re + + lines = _aglText.splitlines() + + parseAGL_RE = re.compile("([A-Za-z0-9]+);((?:[0-9A-F]{4})(?: (?:[0-9A-F]{4}))*)$") + + for line in lines: + if not line or line[:1] == "#": + continue + m = parseAGL_RE.match(line) + if not m: + raise AGLError("syntax error in glyphlist.txt: %s" % repr(line[:20])) + unicodes = m.group(2) + assert len(unicodes) % 5 == 4 + unicodes = [int(unicode, 16) for unicode in unicodes.split()] + glyphName = tostr(m.group(1)) + LEGACY_AGL2UV[glyphName] = unicodes + + lines = _aglfnText.splitlines() + + parseAGLFN_RE = re.compile("([0-9A-F]{4});([A-Za-z0-9]+);.*?$") + + for line in lines: + if not line or line[:1] == "#": + continue + m = parseAGLFN_RE.match(line) + if not m: + raise AGLError("syntax error in aglfn.txt: %s" % repr(line[:20])) + unicode = m.group(1) + assert len(unicode) == 4 + unicode = int(unicode, 16) + glyphName = tostr(m.group(2)) + AGL2UV[glyphName] = unicode + UV2AGL[unicode] = glyphName + + +_builddicts() + + +def toUnicode(glyph, isZapfDingbats=False): + """Convert glyph names to Unicode, such as ``'longs_t.oldstyle'`` --> ``u'ſt'`` + + If ``isZapfDingbats`` is ``True``, the implementation recognizes additional + glyph names (as required by the AGL specification). + """ + # https://github.com/adobe-type-tools/agl-specification#2-the-mapping + # + # 1. Drop all the characters from the glyph name starting with + # the first occurrence of a period (U+002E; FULL STOP), if any. + glyph = glyph.split(".", 1)[0] + + # 2. Split the remaining string into a sequence of components, + # using underscore (U+005F; LOW LINE) as the delimiter. + components = glyph.split("_") + + # 3. Map each component to a character string according to the + # procedure below, and concatenate those strings; the result + # is the character string to which the glyph name is mapped. + result = [_glyphComponentToUnicode(c, isZapfDingbats) for c in components] + return "".join(result) + + +def _glyphComponentToUnicode(component, isZapfDingbats): + # If the font is Zapf Dingbats (PostScript FontName: ZapfDingbats), + # and the component is in the ITC Zapf Dingbats Glyph List, then + # map it to the corresponding character in that list. + dingbat = _zapfDingbatsToUnicode(component) if isZapfDingbats else None + if dingbat: + return dingbat + + # Otherwise, if the component is in AGL, then map it + # to the corresponding character in that list. + uchars = LEGACY_AGL2UV.get(component) + if uchars: + return "".join(map(chr, uchars)) + + # Otherwise, if the component is of the form "uni" (U+0075, + # U+006E, and U+0069) followed by a sequence of uppercase + # hexadecimal digits (0–9 and A–F, meaning U+0030 through + # U+0039 and U+0041 through U+0046), if the length of that + # sequence is a multiple of four, and if each group of four + # digits represents a value in the ranges 0000 through D7FF + # or E000 through FFFF, then interpret each as a Unicode scalar + # value and map the component to the string made of those + # scalar values. Note that the range and digit-length + # restrictions mean that the "uni" glyph name prefix can be + # used only with UVs in the Basic Multilingual Plane (BMP). + uni = _uniToUnicode(component) + if uni: + return uni + + # Otherwise, if the component is of the form "u" (U+0075) + # followed by a sequence of four to six uppercase hexadecimal + # digits (0–9 and A–F, meaning U+0030 through U+0039 and + # U+0041 through U+0046), and those digits represents a value + # in the ranges 0000 through D7FF or E000 through 10FFFF, then + # interpret it as a Unicode scalar value and map the component + # to the string made of this scalar value. + uni = _uToUnicode(component) + if uni: + return uni + + # Otherwise, map the component to an empty string. + return "" + + +# https://github.com/adobe-type-tools/agl-aglfn/blob/master/zapfdingbats.txt +_AGL_ZAPF_DINGBATS = ( + " ✁✂✄☎✆✝✞✟✠✡☛☞✌✍✎✏✑✒✓✔✕✖✗✘✙✚✛✜✢✣✤✥✦✧★✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀" + "❁❂❃❄❅❆❇❈❉❊❋●❍■❏❑▲▼◆❖ ◗❘❙❚❯❱❲❳❨❩❬❭❪❫❴❵❛❜❝❞❡❢❣❤✐❥❦❧♠♥♦♣ ✉✈✇" + "①②③④⑤⑥⑦⑧⑨⑩❶❷❸❹❺❻❼❽❾❿➀➁➂➃➄➅➆➇➈➉➊➋➌➍➎➏➐➑➒➓➔→➣↔" + "↕➙➛➜➝➞➟➠➡➢➤➥➦➧➨➩➫➭➯➲➳➵➸➺➻➼➽➾➚➪➶➹➘➴➷➬➮➱✃❐❒❮❰" +) + + +def _zapfDingbatsToUnicode(glyph): + """Helper for toUnicode().""" + if len(glyph) < 2 or glyph[0] != "a": + return None + try: + gid = int(glyph[1:]) + except ValueError: + return None + if gid < 0 or gid >= len(_AGL_ZAPF_DINGBATS): + return None + uchar = _AGL_ZAPF_DINGBATS[gid] + return uchar if uchar != " " else None + + +_re_uni = re.compile("^uni([0-9A-F]+)$") + + +def _uniToUnicode(component): + """Helper for toUnicode() to handle "uniABCD" components.""" + match = _re_uni.match(component) + if match is None: + return None + digits = match.group(1) + if len(digits) % 4 != 0: + return None + chars = [int(digits[i : i + 4], 16) for i in range(0, len(digits), 4)] + if any(c >= 0xD800 and c <= 0xDFFF for c in chars): + # The AGL specification explicitly excluded surrogate pairs. + return None + return "".join([chr(c) for c in chars]) + + +_re_u = re.compile("^u([0-9A-F]{4,6})$") + + +def _uToUnicode(component): + """Helper for toUnicode() to handle "u1ABCD" components.""" + match = _re_u.match(component) + if match is None: + return None + digits = match.group(1) + try: + value = int(digits, 16) + except ValueError: + return None + if (value >= 0x0000 and value <= 0xD7FF) or (value >= 0xE000 and value <= 0x10FFFF): + return chr(value) + return None diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/CFF2ToCFF.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/CFF2ToCFF.py new file mode 100644 index 00000000..689412ce --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/CFF2ToCFF.py @@ -0,0 +1,187 @@ +"""CFF2 to CFF converter.""" + +from fontTools.ttLib import TTFont, newTable +from fontTools.misc.cliTools import makeOutputFileName +from fontTools.cffLib import ( + TopDictIndex, + buildOrder, + buildDefaults, + topDictOperators, + privateDictOperators, +) +from .width import optimizeWidths +from collections import defaultdict +import logging + + +__all__ = ["convertCFF2ToCFF", "main"] + + +log = logging.getLogger("fontTools.cffLib") + + +def _convertCFF2ToCFF(cff, otFont): + """Converts this object from CFF2 format to CFF format. This conversion + is done 'in-place'. The conversion cannot be reversed. + + The CFF2 font cannot be variable. (TODO Accept those and convert to the + default instance?) + + This assumes a decompiled CFF table. (i.e. that the object has been + filled via :meth:`decompile` and e.g. not loaded from XML.)""" + + cff.major = 1 + + topDictData = TopDictIndex(None, isCFF2=True) + for item in cff.topDictIndex: + # Iterate over, such that all are decompiled + topDictData.append(item) + cff.topDictIndex = topDictData + topDict = topDictData[0] + + if hasattr(topDict, "VarStore"): + raise ValueError("Variable CFF2 font cannot be converted to CFF format.") + + opOrder = buildOrder(topDictOperators) + topDict.order = opOrder + for key in topDict.rawDict.keys(): + if key not in opOrder: + del topDict.rawDict[key] + if hasattr(topDict, key): + delattr(topDict, key) + + fdArray = topDict.FDArray + charStrings = topDict.CharStrings + + defaults = buildDefaults(privateDictOperators) + order = buildOrder(privateDictOperators) + for fd in fdArray: + fd.setCFF2(False) + privateDict = fd.Private + privateDict.order = order + for key in order: + if key not in privateDict.rawDict and key in defaults: + privateDict.rawDict[key] = defaults[key] + for key in privateDict.rawDict.keys(): + if key not in order: + del privateDict.rawDict[key] + if hasattr(privateDict, key): + delattr(privateDict, key) + + for cs in charStrings.values(): + cs.decompile() + cs.program.append("endchar") + for subrSets in [cff.GlobalSubrs] + [ + getattr(fd.Private, "Subrs", []) for fd in fdArray + ]: + for cs in subrSets: + cs.program.append("return") + + # Add (optimal) width to CharStrings that need it. + widths = defaultdict(list) + metrics = otFont["hmtx"].metrics + for glyphName in charStrings.keys(): + cs, fdIndex = charStrings.getItemAndSelector(glyphName) + if fdIndex == None: + fdIndex = 0 + widths[fdIndex].append(metrics[glyphName][0]) + for fdIndex, widthList in widths.items(): + bestDefault, bestNominal = optimizeWidths(widthList) + private = fdArray[fdIndex].Private + private.defaultWidthX = bestDefault + private.nominalWidthX = bestNominal + for glyphName in charStrings.keys(): + cs, fdIndex = charStrings.getItemAndSelector(glyphName) + if fdIndex == None: + fdIndex = 0 + private = fdArray[fdIndex].Private + width = metrics[glyphName][0] + if width != private.defaultWidthX: + cs.program.insert(0, width - private.nominalWidthX) + + +def convertCFF2ToCFF(font, *, updatePostTable=True): + cff = font["CFF2"].cff + _convertCFF2ToCFF(cff, font) + del font["CFF2"] + table = font["CFF "] = newTable("CFF ") + table.cff = cff + + if updatePostTable and "post" in font: + # Only version supported for fonts with CFF table is 0x00030000 not 0x20000 + post = font["post"] + if post.formatType == 2.0: + post.formatType = 3.0 + + +def main(args=None): + """Convert CFF OTF font to CFF2 OTF font""" + if args is None: + import sys + + args = sys.argv[1:] + + import argparse + + parser = argparse.ArgumentParser( + "fonttools cffLib.CFFToCFF2", + description="Upgrade a CFF font to CFF2.", + ) + parser.add_argument( + "input", metavar="INPUT.ttf", help="Input OTF file with CFF table." + ) + parser.add_argument( + "-o", + "--output", + metavar="OUTPUT.ttf", + default=None, + help="Output instance OTF file (default: INPUT-CFF2.ttf).", + ) + parser.add_argument( + "--no-recalc-timestamp", + dest="recalc_timestamp", + action="store_false", + help="Don't set the output font's timestamp to the current time.", + ) + loggingGroup = parser.add_mutually_exclusive_group(required=False) + loggingGroup.add_argument( + "-v", "--verbose", action="store_true", help="Run more verbosely." + ) + loggingGroup.add_argument( + "-q", "--quiet", action="store_true", help="Turn verbosity off." + ) + options = parser.parse_args(args) + + from fontTools import configLogger + + configLogger( + level=("DEBUG" if options.verbose else "ERROR" if options.quiet else "INFO") + ) + + import os + + infile = options.input + if not os.path.isfile(infile): + parser.error("No such file '{}'".format(infile)) + + outfile = ( + makeOutputFileName(infile, overWrite=True, suffix="-CFF") + if not options.output + else options.output + ) + + font = TTFont(infile, recalcTimestamp=options.recalc_timestamp, recalcBBoxes=False) + + convertCFF2ToCFF(font) + + log.info( + "Saving %s", + outfile, + ) + font.save(outfile) + + +if __name__ == "__main__": + import sys + + sys.exit(main(sys.argv[1:])) diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/CFFToCFF2.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/CFFToCFF2.py new file mode 100644 index 00000000..37463a5b --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/CFFToCFF2.py @@ -0,0 +1,303 @@ +"""CFF to CFF2 converter.""" + +from fontTools.ttLib import TTFont, newTable +from fontTools.misc.cliTools import makeOutputFileName +from fontTools.misc.psCharStrings import T2WidthExtractor +from fontTools.cffLib import ( + TopDictIndex, + FDArrayIndex, + FontDict, + buildOrder, + topDictOperators, + privateDictOperators, + topDictOperators2, + privateDictOperators2, +) +from io import BytesIO +import logging + +__all__ = ["convertCFFToCFF2", "main"] + + +log = logging.getLogger("fontTools.cffLib") + + +class _NominalWidthUsedError(Exception): + def __add__(self, other): + raise self + + def __radd__(self, other): + raise self + + +def _convertCFFToCFF2(cff, otFont): + """Converts this object from CFF format to CFF2 format. This conversion + is done 'in-place'. The conversion cannot be reversed. + + This assumes a decompiled CFF table. (i.e. that the object has been + filled via :meth:`decompile` and e.g. not loaded from XML.)""" + + # Clean up T2CharStrings + + topDict = cff.topDictIndex[0] + fdArray = topDict.FDArray if hasattr(topDict, "FDArray") else None + charStrings = topDict.CharStrings + globalSubrs = cff.GlobalSubrs + localSubrs = ( + [getattr(fd.Private, "Subrs", []) for fd in fdArray] + if fdArray + else ( + [topDict.Private.Subrs] + if hasattr(topDict, "Private") and hasattr(topDict.Private, "Subrs") + else [] + ) + ) + + for glyphName in charStrings.keys(): + cs, fdIndex = charStrings.getItemAndSelector(glyphName) + cs.decompile() + + # Clean up subroutines first + for subrs in [globalSubrs] + localSubrs: + for subr in subrs: + program = subr.program + i = j = len(program) + try: + i = program.index("return") + except ValueError: + pass + try: + j = program.index("endchar") + except ValueError: + pass + program[min(i, j) :] = [] + + # Clean up glyph charstrings + removeUnusedSubrs = False + nominalWidthXError = _NominalWidthUsedError() + for glyphName in charStrings.keys(): + cs, fdIndex = charStrings.getItemAndSelector(glyphName) + program = cs.program + + thisLocalSubrs = ( + localSubrs[fdIndex] + if fdIndex + else ( + getattr(topDict.Private, "Subrs", []) + if hasattr(topDict, "Private") + else [] + ) + ) + + # Intentionally use custom type for nominalWidthX, such that any + # CharString that has an explicit width encoded will throw back to us. + extractor = T2WidthExtractor( + thisLocalSubrs, + globalSubrs, + nominalWidthXError, + 0, + ) + try: + extractor.execute(cs) + except _NominalWidthUsedError: + # Program has explicit width. We want to drop it, but can't + # just pop the first number since it may be a subroutine call. + # Instead, when seeing that, we embed the subroutine and recurse. + # If this ever happened, we later prune unused subroutines. + while program[1] in ["callsubr", "callgsubr"]: + removeUnusedSubrs = True + subrNumber = program.pop(0) + op = program.pop(0) + bias = extractor.localBias if op == "callsubr" else extractor.globalBias + subrNumber += bias + subrSet = thisLocalSubrs if op == "callsubr" else globalSubrs + subrProgram = subrSet[subrNumber].program + program[:0] = subrProgram + # Now pop the actual width + program.pop(0) + + if program and program[-1] == "endchar": + program.pop() + + if removeUnusedSubrs: + cff.remove_unused_subroutines() + + # Upconvert TopDict + + cff.major = 2 + cff2GetGlyphOrder = cff.otFont.getGlyphOrder + topDictData = TopDictIndex(None, cff2GetGlyphOrder) + for item in cff.topDictIndex: + # Iterate over, such that all are decompiled + topDictData.append(item) + cff.topDictIndex = topDictData + topDict = topDictData[0] + if hasattr(topDict, "Private"): + privateDict = topDict.Private + else: + privateDict = None + opOrder = buildOrder(topDictOperators2) + topDict.order = opOrder + topDict.cff2GetGlyphOrder = cff2GetGlyphOrder + + if not hasattr(topDict, "FDArray"): + fdArray = topDict.FDArray = FDArrayIndex() + fdArray.strings = None + fdArray.GlobalSubrs = topDict.GlobalSubrs + topDict.GlobalSubrs.fdArray = fdArray + charStrings = topDict.CharStrings + if charStrings.charStringsAreIndexed: + charStrings.charStringsIndex.fdArray = fdArray + else: + charStrings.fdArray = fdArray + fontDict = FontDict() + fontDict.setCFF2(True) + fdArray.append(fontDict) + fontDict.Private = privateDict + privateOpOrder = buildOrder(privateDictOperators2) + if privateDict is not None: + for entry in privateDictOperators: + key = entry[1] + if key not in privateOpOrder: + if key in privateDict.rawDict: + # print "Removing private dict", key + del privateDict.rawDict[key] + if hasattr(privateDict, key): + delattr(privateDict, key) + # print "Removing privateDict attr", key + else: + # clean up the PrivateDicts in the fdArray + fdArray = topDict.FDArray + privateOpOrder = buildOrder(privateDictOperators2) + for fontDict in fdArray: + fontDict.setCFF2(True) + for key in list(fontDict.rawDict.keys()): + if key not in fontDict.order: + del fontDict.rawDict[key] + if hasattr(fontDict, key): + delattr(fontDict, key) + + privateDict = fontDict.Private + for entry in privateDictOperators: + key = entry[1] + if key not in privateOpOrder: + if key in list(privateDict.rawDict.keys()): + # print "Removing private dict", key + del privateDict.rawDict[key] + if hasattr(privateDict, key): + delattr(privateDict, key) + # print "Removing privateDict attr", key + + # Now delete up the deprecated topDict operators from CFF 1.0 + for entry in topDictOperators: + key = entry[1] + # We seem to need to keep the charset operator for now, + # or we fail to compile with some fonts, like AdditionFont.otf. + # I don't know which kind of CFF font those are. But keeping + # charset seems to work. It will be removed when we save and + # read the font again. + # + # AdditionFont.otf has . + if key == "charset": + continue + if key not in opOrder: + if key in topDict.rawDict: + del topDict.rawDict[key] + if hasattr(topDict, key): + delattr(topDict, key) + + # TODO(behdad): What does the following comment even mean? Both CFF and CFF2 + # use the same T2Charstring class. I *think* what it means is that the CharStrings + # were loaded for CFF1, and we need to reload them for CFF2 to set varstore, etc + # on them. At least that's what I understand. It's probably safe to remove this + # and just set vstore where needed. + # + # See comment above about charset as well. + + # At this point, the Subrs and Charstrings are all still T2Charstring class + # easiest to fix this by compiling, then decompiling again + file = BytesIO() + cff.compile(file, otFont, isCFF2=True) + file.seek(0) + cff.decompile(file, otFont, isCFF2=True) + + +def convertCFFToCFF2(font): + cff = font["CFF "].cff + del font["CFF "] + _convertCFFToCFF2(cff, font) + table = font["CFF2"] = newTable("CFF2") + table.cff = cff + + +def main(args=None): + """Convert CFF OTF font to CFF2 OTF font""" + if args is None: + import sys + + args = sys.argv[1:] + + import argparse + + parser = argparse.ArgumentParser( + "fonttools cffLib.CFFToCFF2", + description="Upgrade a CFF font to CFF2.", + ) + parser.add_argument( + "input", metavar="INPUT.ttf", help="Input OTF file with CFF table." + ) + parser.add_argument( + "-o", + "--output", + metavar="OUTPUT.ttf", + default=None, + help="Output instance OTF file (default: INPUT-CFF2.ttf).", + ) + parser.add_argument( + "--no-recalc-timestamp", + dest="recalc_timestamp", + action="store_false", + help="Don't set the output font's timestamp to the current time.", + ) + loggingGroup = parser.add_mutually_exclusive_group(required=False) + loggingGroup.add_argument( + "-v", "--verbose", action="store_true", help="Run more verbosely." + ) + loggingGroup.add_argument( + "-q", "--quiet", action="store_true", help="Turn verbosity off." + ) + options = parser.parse_args(args) + + from fontTools import configLogger + + configLogger( + level=("DEBUG" if options.verbose else "ERROR" if options.quiet else "INFO") + ) + + import os + + infile = options.input + if not os.path.isfile(infile): + parser.error("No such file '{}'".format(infile)) + + outfile = ( + makeOutputFileName(infile, overWrite=True, suffix="-CFF2") + if not options.output + else options.output + ) + + font = TTFont(infile, recalcTimestamp=options.recalc_timestamp, recalcBBoxes=False) + + convertCFFToCFF2(font) + + log.info( + "Saving %s", + outfile, + ) + font.save(outfile) + + +if __name__ == "__main__": + import sys + + sys.exit(main(sys.argv[1:])) diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/__init__.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/__init__.py new file mode 100644 index 00000000..c192ec77 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/__init__.py @@ -0,0 +1,3654 @@ +"""cffLib: read/write Adobe CFF fonts + +OpenType fonts with PostScript outlines contain a completely independent +font file, Adobe's *Compact Font Format*. So dealing with OpenType fonts +requires also dealing with CFF. This module allows you to read and write +fonts written in the CFF format. + +In 2016, OpenType 1.8 introduced the `CFF2 `_ +format which, along with other changes, extended the CFF format to deal with +the demands of variable fonts. This module parses both original CFF and CFF2. + +""" + +from fontTools.misc import sstruct +from fontTools.misc import psCharStrings +from fontTools.misc.arrayTools import unionRect, intRect +from fontTools.misc.textTools import ( + bytechr, + byteord, + bytesjoin, + tobytes, + tostr, + safeEval, +) +from fontTools.ttLib import TTFont +from fontTools.ttLib.tables.otBase import OTTableWriter +from fontTools.ttLib.tables.otBase import OTTableReader +from fontTools.ttLib.tables import otTables as ot +from io import BytesIO +import struct +import logging +import re + +# mute cffLib debug messages when running ttx in verbose mode +DEBUG = logging.DEBUG - 1 +log = logging.getLogger(__name__) + +cffHeaderFormat = """ + major: B + minor: B + hdrSize: B +""" + +maxStackLimit = 513 +# maxstack operator has been deprecated. max stack is now always 513. + + +class CFFFontSet(object): + """A CFF font "file" can contain more than one font, although this is + extremely rare (and not allowed within OpenType fonts). + + This class is the entry point for parsing a CFF table. To actually + manipulate the data inside the CFF font, you will want to access the + ``CFFFontSet``'s :class:`TopDict` object. To do this, a ``CFFFontSet`` + object can either be treated as a dictionary (with appropriate + ``keys()`` and ``values()`` methods) mapping font names to :class:`TopDict` + objects, or as a list. + + .. code:: python + + from fontTools import ttLib + tt = ttLib.TTFont("Tests/cffLib/data/LinLibertine_RBI.otf") + tt["CFF "].cff + # + tt["CFF "].cff[0] # Here's your actual font data + # + + """ + + def decompile(self, file, otFont, isCFF2=None): + """Parse a binary CFF file into an internal representation. ``file`` + should be a file handle object. ``otFont`` is the top-level + :py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file. + + If ``isCFF2`` is passed and set to ``True`` or ``False``, then the + library makes an assertion that the CFF header is of the appropriate + version. + """ + + self.otFont = otFont + sstruct.unpack(cffHeaderFormat, file.read(3), self) + if isCFF2 is not None: + # called from ttLib: assert 'major' as read from file matches the + # expected version + expected_major = 2 if isCFF2 else 1 + if self.major != expected_major: + raise ValueError( + "Invalid CFF 'major' version: expected %d, found %d" + % (expected_major, self.major) + ) + else: + # use 'major' version from file to determine if isCFF2 + assert self.major in (1, 2), "Unknown CFF format" + isCFF2 = self.major == 2 + if not isCFF2: + self.offSize = struct.unpack("B", file.read(1))[0] + file.seek(self.hdrSize) + self.fontNames = list(tostr(s) for s in Index(file, isCFF2=isCFF2)) + self.topDictIndex = TopDictIndex(file, isCFF2=isCFF2) + self.strings = IndexedStrings(file) + else: # isCFF2 + self.topDictSize = struct.unpack(">H", file.read(2))[0] + file.seek(self.hdrSize) + self.fontNames = ["CFF2Font"] + cff2GetGlyphOrder = otFont.getGlyphOrder + # in CFF2, offsetSize is the size of the TopDict data. + self.topDictIndex = TopDictIndex( + file, cff2GetGlyphOrder, self.topDictSize, isCFF2=isCFF2 + ) + self.strings = None + self.GlobalSubrs = GlobalSubrsIndex(file, isCFF2=isCFF2) + self.topDictIndex.strings = self.strings + self.topDictIndex.GlobalSubrs = self.GlobalSubrs + + def __len__(self): + return len(self.fontNames) + + def keys(self): + return list(self.fontNames) + + def values(self): + return self.topDictIndex + + def __getitem__(self, nameOrIndex): + """Return TopDict instance identified by name (str) or index (int + or any object that implements `__index__`). + """ + if hasattr(nameOrIndex, "__index__"): + index = nameOrIndex.__index__() + elif isinstance(nameOrIndex, str): + name = nameOrIndex + try: + index = self.fontNames.index(name) + except ValueError: + raise KeyError(nameOrIndex) + else: + raise TypeError(nameOrIndex) + return self.topDictIndex[index] + + def compile(self, file, otFont, isCFF2=None): + """Write the object back into binary representation onto the given file. + ``file`` should be a file handle object. ``otFont`` is the top-level + :py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file. + + If ``isCFF2`` is passed and set to ``True`` or ``False``, then the + library makes an assertion that the CFF header is of the appropriate + version. + """ + self.otFont = otFont + if isCFF2 is not None: + # called from ttLib: assert 'major' value matches expected version + expected_major = 2 if isCFF2 else 1 + if self.major != expected_major: + raise ValueError( + "Invalid CFF 'major' version: expected %d, found %d" + % (expected_major, self.major) + ) + else: + # use current 'major' value to determine output format + assert self.major in (1, 2), "Unknown CFF format" + isCFF2 = self.major == 2 + + if otFont.recalcBBoxes and not isCFF2: + for topDict in self.topDictIndex: + topDict.recalcFontBBox() + + if not isCFF2: + strings = IndexedStrings() + else: + strings = None + writer = CFFWriter(isCFF2) + topCompiler = self.topDictIndex.getCompiler(strings, self, isCFF2=isCFF2) + if isCFF2: + self.hdrSize = 5 + writer.add(sstruct.pack(cffHeaderFormat, self)) + # Note: topDictSize will most likely change in CFFWriter.toFile(). + self.topDictSize = topCompiler.getDataLength() + writer.add(struct.pack(">H", self.topDictSize)) + else: + self.hdrSize = 4 + self.offSize = 4 # will most likely change in CFFWriter.toFile(). + writer.add(sstruct.pack(cffHeaderFormat, self)) + writer.add(struct.pack("B", self.offSize)) + if not isCFF2: + fontNames = Index() + for name in self.fontNames: + fontNames.append(name) + writer.add(fontNames.getCompiler(strings, self, isCFF2=isCFF2)) + writer.add(topCompiler) + if not isCFF2: + writer.add(strings.getCompiler()) + writer.add(self.GlobalSubrs.getCompiler(strings, self, isCFF2=isCFF2)) + + for topDict in self.topDictIndex: + if not hasattr(topDict, "charset") or topDict.charset is None: + charset = otFont.getGlyphOrder() + topDict.charset = charset + children = topCompiler.getChildren(strings) + for child in children: + writer.add(child) + + writer.toFile(file) + + def toXML(self, xmlWriter): + """Write the object into XML representation onto the given + :class:`fontTools.misc.xmlWriter.XMLWriter`. + + .. code:: python + + writer = xmlWriter.XMLWriter(sys.stdout) + tt["CFF "].cff.toXML(writer) + + """ + + xmlWriter.simpletag("major", value=self.major) + xmlWriter.newline() + xmlWriter.simpletag("minor", value=self.minor) + xmlWriter.newline() + for fontName in self.fontNames: + xmlWriter.begintag("CFFFont", name=tostr(fontName)) + xmlWriter.newline() + font = self[fontName] + font.toXML(xmlWriter) + xmlWriter.endtag("CFFFont") + xmlWriter.newline() + xmlWriter.newline() + xmlWriter.begintag("GlobalSubrs") + xmlWriter.newline() + self.GlobalSubrs.toXML(xmlWriter) + xmlWriter.endtag("GlobalSubrs") + xmlWriter.newline() + + def fromXML(self, name, attrs, content, otFont=None): + """Reads data from the XML element into the ``CFFFontSet`` object.""" + self.otFont = otFont + + # set defaults. These will be replaced if there are entries for them + # in the XML file. + if not hasattr(self, "major"): + self.major = 1 + if not hasattr(self, "minor"): + self.minor = 0 + + if name == "CFFFont": + if self.major == 1: + if not hasattr(self, "offSize"): + # this will be recalculated when the cff is compiled. + self.offSize = 4 + if not hasattr(self, "hdrSize"): + self.hdrSize = 4 + if not hasattr(self, "GlobalSubrs"): + self.GlobalSubrs = GlobalSubrsIndex() + if not hasattr(self, "fontNames"): + self.fontNames = [] + self.topDictIndex = TopDictIndex() + fontName = attrs["name"] + self.fontNames.append(fontName) + topDict = TopDict(GlobalSubrs=self.GlobalSubrs) + topDict.charset = None # gets filled in later + elif self.major == 2: + if not hasattr(self, "hdrSize"): + self.hdrSize = 5 + if not hasattr(self, "GlobalSubrs"): + self.GlobalSubrs = GlobalSubrsIndex() + if not hasattr(self, "fontNames"): + self.fontNames = ["CFF2Font"] + cff2GetGlyphOrder = self.otFont.getGlyphOrder + topDict = TopDict( + GlobalSubrs=self.GlobalSubrs, cff2GetGlyphOrder=cff2GetGlyphOrder + ) + self.topDictIndex = TopDictIndex(None, cff2GetGlyphOrder) + self.topDictIndex.append(topDict) + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + topDict.fromXML(name, attrs, content) + + if hasattr(topDict, "VarStore") and topDict.FDArray[0].vstore is None: + fdArray = topDict.FDArray + for fontDict in fdArray: + if hasattr(fontDict, "Private"): + fontDict.Private.vstore = topDict.VarStore + + elif name == "GlobalSubrs": + subrCharStringClass = psCharStrings.T2CharString + if not hasattr(self, "GlobalSubrs"): + self.GlobalSubrs = GlobalSubrsIndex() + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + subr = subrCharStringClass() + subr.fromXML(name, attrs, content) + self.GlobalSubrs.append(subr) + elif name == "major": + self.major = int(attrs["value"]) + elif name == "minor": + self.minor = int(attrs["value"]) + + def convertCFFToCFF2(self, otFont): + from .CFFToCFF2 import _convertCFFToCFF2 + + _convertCFFToCFF2(self, otFont) + + def convertCFF2ToCFF(self, otFont): + from .CFF2ToCFF import _convertCFF2ToCFF + + _convertCFF2ToCFF(self, otFont) + + def desubroutinize(self): + from .transforms import desubroutinize + + desubroutinize(self) + + def remove_hints(self): + from .transforms import remove_hints + + remove_hints(self) + + def remove_unused_subroutines(self): + from .transforms import remove_unused_subroutines + + remove_unused_subroutines(self) + + +class CFFWriter(object): + """Helper class for serializing CFF data to binary. Used by + :meth:`CFFFontSet.compile`.""" + + def __init__(self, isCFF2): + self.data = [] + self.isCFF2 = isCFF2 + + def add(self, table): + self.data.append(table) + + def toFile(self, file): + lastPosList = None + count = 1 + while True: + log.log(DEBUG, "CFFWriter.toFile() iteration: %d", count) + count = count + 1 + pos = 0 + posList = [pos] + for item in self.data: + if hasattr(item, "getDataLength"): + endPos = pos + item.getDataLength() + if isinstance(item, TopDictIndexCompiler) and item.isCFF2: + self.topDictSize = item.getDataLength() + else: + endPos = pos + len(item) + if hasattr(item, "setPos"): + item.setPos(pos, endPos) + pos = endPos + posList.append(pos) + if posList == lastPosList: + break + lastPosList = posList + log.log(DEBUG, "CFFWriter.toFile() writing to file.") + begin = file.tell() + if self.isCFF2: + self.data[1] = struct.pack(">H", self.topDictSize) + else: + self.offSize = calcOffSize(lastPosList[-1]) + self.data[1] = struct.pack("B", self.offSize) + posList = [0] + for item in self.data: + if hasattr(item, "toFile"): + item.toFile(file) + else: + file.write(item) + posList.append(file.tell() - begin) + assert posList == lastPosList + + +def calcOffSize(largestOffset): + if largestOffset < 0x100: + offSize = 1 + elif largestOffset < 0x10000: + offSize = 2 + elif largestOffset < 0x1000000: + offSize = 3 + else: + offSize = 4 + return offSize + + +class IndexCompiler(object): + """Base class for writing CFF `INDEX data `_ + to binary.""" + + def __init__(self, items, strings, parent, isCFF2=None): + if isCFF2 is None and hasattr(parent, "isCFF2"): + isCFF2 = parent.isCFF2 + assert isCFF2 is not None + self.isCFF2 = isCFF2 + self.items = self.getItems(items, strings) + self.parent = parent + + def getItems(self, items, strings): + return items + + def getOffsets(self): + # An empty INDEX contains only the count field. + if self.items: + pos = 1 + offsets = [pos] + for item in self.items: + if hasattr(item, "getDataLength"): + pos = pos + item.getDataLength() + else: + pos = pos + len(item) + offsets.append(pos) + else: + offsets = [] + return offsets + + def getDataLength(self): + if self.isCFF2: + countSize = 4 + else: + countSize = 2 + + if self.items: + lastOffset = self.getOffsets()[-1] + offSize = calcOffSize(lastOffset) + dataLength = ( + countSize + + 1 # count + + (len(self.items) + 1) * offSize # offSize + + lastOffset # the offsets + - 1 # size of object data + ) + else: + # count. For empty INDEX tables, this is the only entry. + dataLength = countSize + + return dataLength + + def toFile(self, file): + offsets = self.getOffsets() + if self.isCFF2: + writeCard32(file, len(self.items)) + else: + writeCard16(file, len(self.items)) + # An empty INDEX contains only the count field. + if self.items: + offSize = calcOffSize(offsets[-1]) + writeCard8(file, offSize) + offSize = -offSize + pack = struct.pack + for offset in offsets: + binOffset = pack(">l", offset)[offSize:] + assert len(binOffset) == -offSize + file.write(binOffset) + for item in self.items: + if hasattr(item, "toFile"): + item.toFile(file) + else: + data = tobytes(item, encoding="latin1") + file.write(data) + + +class IndexedStringsCompiler(IndexCompiler): + def getItems(self, items, strings): + return items.strings + + +class TopDictIndexCompiler(IndexCompiler): + """Helper class for writing the TopDict to binary.""" + + def getItems(self, items, strings): + out = [] + for item in items: + out.append(item.getCompiler(strings, self)) + return out + + def getChildren(self, strings): + children = [] + for topDict in self.items: + children.extend(topDict.getChildren(strings)) + return children + + def getOffsets(self): + if self.isCFF2: + offsets = [0, self.items[0].getDataLength()] + return offsets + else: + return super(TopDictIndexCompiler, self).getOffsets() + + def getDataLength(self): + if self.isCFF2: + dataLength = self.items[0].getDataLength() + return dataLength + else: + return super(TopDictIndexCompiler, self).getDataLength() + + def toFile(self, file): + if self.isCFF2: + self.items[0].toFile(file) + else: + super(TopDictIndexCompiler, self).toFile(file) + + +class FDArrayIndexCompiler(IndexCompiler): + """Helper class for writing the + `Font DICT INDEX `_ + to binary.""" + + def getItems(self, items, strings): + out = [] + for item in items: + out.append(item.getCompiler(strings, self)) + return out + + def getChildren(self, strings): + children = [] + for fontDict in self.items: + children.extend(fontDict.getChildren(strings)) + return children + + def toFile(self, file): + offsets = self.getOffsets() + if self.isCFF2: + writeCard32(file, len(self.items)) + else: + writeCard16(file, len(self.items)) + offSize = calcOffSize(offsets[-1]) + writeCard8(file, offSize) + offSize = -offSize + pack = struct.pack + for offset in offsets: + binOffset = pack(">l", offset)[offSize:] + assert len(binOffset) == -offSize + file.write(binOffset) + for item in self.items: + if hasattr(item, "toFile"): + item.toFile(file) + else: + file.write(item) + + def setPos(self, pos, endPos): + self.parent.rawDict["FDArray"] = pos + + +class GlobalSubrsCompiler(IndexCompiler): + """Helper class for writing the `global subroutine INDEX `_ + to binary.""" + + def getItems(self, items, strings): + out = [] + for cs in items: + cs.compile(self.isCFF2) + out.append(cs.bytecode) + return out + + +class SubrsCompiler(GlobalSubrsCompiler): + """Helper class for writing the `local subroutine INDEX `_ + to binary.""" + + def setPos(self, pos, endPos): + offset = pos - self.parent.pos + self.parent.rawDict["Subrs"] = offset + + +class CharStringsCompiler(GlobalSubrsCompiler): + """Helper class for writing the `CharStrings INDEX `_ + to binary.""" + + def getItems(self, items, strings): + out = [] + for cs in items: + cs.compile(self.isCFF2) + out.append(cs.bytecode) + return out + + def setPos(self, pos, endPos): + self.parent.rawDict["CharStrings"] = pos + + +class Index(object): + """This class represents what the CFF spec calls an INDEX (an array of + variable-sized objects). `Index` items can be addressed and set using + Python list indexing.""" + + compilerClass = IndexCompiler + + def __init__(self, file=None, isCFF2=None): + self.items = [] + self.offsets = offsets = [] + name = self.__class__.__name__ + if file is None: + return + self._isCFF2 = isCFF2 + log.log(DEBUG, "loading %s at %s", name, file.tell()) + self.file = file + if isCFF2: + count = readCard32(file) + else: + count = readCard16(file) + if count == 0: + return + self.items = [None] * count + offSize = readCard8(file) + log.log(DEBUG, " index count: %s offSize: %s", count, offSize) + assert offSize <= 4, "offSize too large: %s" % offSize + pad = b"\0" * (4 - offSize) + for index in range(count + 1): + chunk = file.read(offSize) + chunk = pad + chunk + (offset,) = struct.unpack(">L", chunk) + offsets.append(int(offset)) + self.offsetBase = file.tell() - 1 + file.seek(self.offsetBase + offsets[-1]) # pretend we've read the whole lot + log.log(DEBUG, " end of %s at %s", name, file.tell()) + + def __len__(self): + return len(self.items) + + def __getitem__(self, index): + item = self.items[index] + if item is not None: + return item + offset = self.offsets[index] + self.offsetBase + size = self.offsets[index + 1] - self.offsets[index] + file = self.file + file.seek(offset) + data = file.read(size) + assert len(data) == size + item = self.produceItem(index, data, file, offset) + self.items[index] = item + return item + + def __setitem__(self, index, item): + self.items[index] = item + + def produceItem(self, index, data, file, offset): + return data + + def append(self, item): + """Add an item to an INDEX.""" + self.items.append(item) + + def getCompiler(self, strings, parent, isCFF2=None): + return self.compilerClass(self, strings, parent, isCFF2=isCFF2) + + def clear(self): + """Empty the INDEX.""" + del self.items[:] + + +class GlobalSubrsIndex(Index): + """This index contains all the global subroutines in the font. A global + subroutine is a set of ``CharString`` data which is accessible to any + glyph in the font, and are used to store repeated instructions - for + example, components may be encoded as global subroutines, but so could + hinting instructions. + + Remember that when interpreting a ``callgsubr`` instruction (or indeed + a ``callsubr`` instruction) that you will need to add the "subroutine + number bias" to number given: + + .. code:: python + + tt = ttLib.TTFont("Almendra-Bold.otf") + u = tt["CFF "].cff[0].CharStrings["udieresis"] + u.decompile() + + u.toXML(XMLWriter(sys.stdout)) + # + # -64 callgsubr <-- Subroutine which implements the dieresis mark + # + + tt["CFF "].cff[0].GlobalSubrs[-64] # <-- WRONG + # + + tt["CFF "].cff[0].GlobalSubrs[-64 + 107] # <-- RIGHT + # + + ("The bias applied depends on the number of subrs (gsubrs). If the number of + subrs (gsubrs) is less than 1240, the bias is 107. Otherwise if it is less + than 33900, it is 1131; otherwise it is 32768.", + `Subroutine Operators `) + """ + + compilerClass = GlobalSubrsCompiler + subrClass = psCharStrings.T2CharString + charStringClass = psCharStrings.T2CharString + + def __init__( + self, + file=None, + globalSubrs=None, + private=None, + fdSelect=None, + fdArray=None, + isCFF2=None, + ): + super(GlobalSubrsIndex, self).__init__(file, isCFF2=isCFF2) + self.globalSubrs = globalSubrs + self.private = private + if fdSelect: + self.fdSelect = fdSelect + if fdArray: + self.fdArray = fdArray + + def produceItem(self, index, data, file, offset): + if self.private is not None: + private = self.private + elif hasattr(self, "fdArray") and self.fdArray is not None: + if hasattr(self, "fdSelect") and self.fdSelect is not None: + fdIndex = self.fdSelect[index] + else: + fdIndex = 0 + private = self.fdArray[fdIndex].Private + else: + private = None + return self.subrClass(data, private=private, globalSubrs=self.globalSubrs) + + def toXML(self, xmlWriter): + """Write the subroutines index into XML representation onto the given + :class:`fontTools.misc.xmlWriter.XMLWriter`. + + .. code:: python + + writer = xmlWriter.XMLWriter(sys.stdout) + tt["CFF "].cff[0].GlobalSubrs.toXML(writer) + + """ + xmlWriter.comment( + "The 'index' attribute is only for humans; " "it is ignored when parsed." + ) + xmlWriter.newline() + for i in range(len(self)): + subr = self[i] + if subr.needsDecompilation(): + xmlWriter.begintag("CharString", index=i, raw=1) + else: + xmlWriter.begintag("CharString", index=i) + xmlWriter.newline() + subr.toXML(xmlWriter) + xmlWriter.endtag("CharString") + xmlWriter.newline() + + def fromXML(self, name, attrs, content): + if name != "CharString": + return + subr = self.subrClass() + subr.fromXML(name, attrs, content) + self.append(subr) + + def getItemAndSelector(self, index): + sel = None + if hasattr(self, "fdSelect"): + sel = self.fdSelect[index] + return self[index], sel + + +class SubrsIndex(GlobalSubrsIndex): + """This index contains a glyph's local subroutines. A local subroutine is a + private set of ``CharString`` data which is accessible only to the glyph to + which the index is attached.""" + + compilerClass = SubrsCompiler + + +class TopDictIndex(Index): + """This index represents the array of ``TopDict`` structures in the font + (again, usually only one entry is present). Hence the following calls are + equivalent: + + .. code:: python + + tt["CFF "].cff[0] + # + tt["CFF "].cff.topDictIndex[0] + # + + """ + + compilerClass = TopDictIndexCompiler + + def __init__(self, file=None, cff2GetGlyphOrder=None, topSize=0, isCFF2=None): + self.cff2GetGlyphOrder = cff2GetGlyphOrder + if file is not None and isCFF2: + self._isCFF2 = isCFF2 + self.items = [] + name = self.__class__.__name__ + log.log(DEBUG, "loading %s at %s", name, file.tell()) + self.file = file + count = 1 + self.items = [None] * count + self.offsets = [0, topSize] + self.offsetBase = file.tell() + # pretend we've read the whole lot + file.seek(self.offsetBase + topSize) + log.log(DEBUG, " end of %s at %s", name, file.tell()) + else: + super(TopDictIndex, self).__init__(file, isCFF2=isCFF2) + + def produceItem(self, index, data, file, offset): + top = TopDict( + self.strings, + file, + offset, + self.GlobalSubrs, + self.cff2GetGlyphOrder, + isCFF2=self._isCFF2, + ) + top.decompile(data) + return top + + def toXML(self, xmlWriter): + for i in range(len(self)): + xmlWriter.begintag("FontDict", index=i) + xmlWriter.newline() + self[i].toXML(xmlWriter) + xmlWriter.endtag("FontDict") + xmlWriter.newline() + + +class FDArrayIndex(Index): + compilerClass = FDArrayIndexCompiler + + def toXML(self, xmlWriter): + for i in range(len(self)): + xmlWriter.begintag("FontDict", index=i) + xmlWriter.newline() + self[i].toXML(xmlWriter) + xmlWriter.endtag("FontDict") + xmlWriter.newline() + + def produceItem(self, index, data, file, offset): + fontDict = FontDict( + self.strings, + file, + offset, + self.GlobalSubrs, + isCFF2=self._isCFF2, + vstore=self.vstore, + ) + fontDict.decompile(data) + return fontDict + + def fromXML(self, name, attrs, content): + if name != "FontDict": + return + fontDict = FontDict() + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + fontDict.fromXML(name, attrs, content) + self.append(fontDict) + + +class VarStoreData(object): + def __init__(self, file=None, otVarStore=None): + self.file = file + self.data = None + self.otVarStore = otVarStore + self.font = TTFont() # dummy font for the decompile function. + + def decompile(self): + if self.file: + # read data in from file. Assume position is correct. + length = readCard16(self.file) + self.data = self.file.read(length) + globalState = {} + reader = OTTableReader(self.data, globalState) + self.otVarStore = ot.VarStore() + self.otVarStore.decompile(reader, self.font) + self.data = None + return self + + def compile(self): + writer = OTTableWriter() + self.otVarStore.compile(writer, self.font) + # Note that this omits the initial Card16 length from the CFF2 + # VarStore data block + self.data = writer.getAllData() + + def writeXML(self, xmlWriter, name): + self.otVarStore.toXML(xmlWriter, self.font) + + def xmlRead(self, name, attrs, content, parent): + self.otVarStore = ot.VarStore() + for element in content: + if isinstance(element, tuple): + name, attrs, content = element + self.otVarStore.fromXML(name, attrs, content, self.font) + else: + pass + return None + + def __len__(self): + return len(self.data) + + def getNumRegions(self, vsIndex): + if vsIndex is None: + vsIndex = 0 + varData = self.otVarStore.VarData[vsIndex] + numRegions = varData.VarRegionCount + return numRegions + + +class FDSelect(object): + def __init__(self, file=None, numGlyphs=None, format=None): + if file: + # read data in from file + self.format = readCard8(file) + if self.format == 0: + from array import array + + self.gidArray = array("B", file.read(numGlyphs)).tolist() + elif self.format == 3: + gidArray = [None] * numGlyphs + nRanges = readCard16(file) + fd = None + prev = None + for i in range(nRanges): + first = readCard16(file) + if prev is not None: + for glyphID in range(prev, first): + gidArray[glyphID] = fd + prev = first + fd = readCard8(file) + if prev is not None: + first = readCard16(file) + for glyphID in range(prev, first): + gidArray[glyphID] = fd + self.gidArray = gidArray + elif self.format == 4: + gidArray = [None] * numGlyphs + nRanges = readCard32(file) + fd = None + prev = None + for i in range(nRanges): + first = readCard32(file) + if prev is not None: + for glyphID in range(prev, first): + gidArray[glyphID] = fd + prev = first + fd = readCard16(file) + if prev is not None: + first = readCard32(file) + for glyphID in range(prev, first): + gidArray[glyphID] = fd + self.gidArray = gidArray + else: + assert False, "unsupported FDSelect format: %s" % format + else: + # reading from XML. Make empty gidArray, and leave format as passed in. + # format is None will result in the smallest representation being used. + self.format = format + self.gidArray = [] + + def __len__(self): + return len(self.gidArray) + + def __getitem__(self, index): + return self.gidArray[index] + + def __setitem__(self, index, fdSelectValue): + self.gidArray[index] = fdSelectValue + + def append(self, fdSelectValue): + self.gidArray.append(fdSelectValue) + + +class CharStrings(object): + """The ``CharStrings`` in the font represent the instructions for drawing + each glyph. This object presents a dictionary interface to the font's + CharStrings, indexed by glyph name: + + .. code:: python + + tt["CFF "].cff[0].CharStrings["a"] + # + + See :class:`fontTools.misc.psCharStrings.T1CharString` and + :class:`fontTools.misc.psCharStrings.T2CharString` for how to decompile, + compile and interpret the glyph drawing instructions in the returned objects. + + """ + + def __init__( + self, + file, + charset, + globalSubrs, + private, + fdSelect, + fdArray, + isCFF2=None, + varStore=None, + ): + self.globalSubrs = globalSubrs + self.varStore = varStore + if file is not None: + self.charStringsIndex = SubrsIndex( + file, globalSubrs, private, fdSelect, fdArray, isCFF2=isCFF2 + ) + self.charStrings = charStrings = {} + for i in range(len(charset)): + charStrings[charset[i]] = i + # read from OTF file: charStrings.values() are indices into + # charStringsIndex. + self.charStringsAreIndexed = 1 + else: + self.charStrings = {} + # read from ttx file: charStrings.values() are actual charstrings + self.charStringsAreIndexed = 0 + self.private = private + if fdSelect is not None: + self.fdSelect = fdSelect + if fdArray is not None: + self.fdArray = fdArray + + def keys(self): + return list(self.charStrings.keys()) + + def values(self): + if self.charStringsAreIndexed: + return self.charStringsIndex + else: + return list(self.charStrings.values()) + + def has_key(self, name): + return name in self.charStrings + + __contains__ = has_key + + def __len__(self): + return len(self.charStrings) + + def __getitem__(self, name): + charString = self.charStrings[name] + if self.charStringsAreIndexed: + charString = self.charStringsIndex[charString] + return charString + + def __setitem__(self, name, charString): + if self.charStringsAreIndexed: + index = self.charStrings[name] + self.charStringsIndex[index] = charString + else: + self.charStrings[name] = charString + + def getItemAndSelector(self, name): + if self.charStringsAreIndexed: + index = self.charStrings[name] + return self.charStringsIndex.getItemAndSelector(index) + else: + if hasattr(self, "fdArray"): + if hasattr(self, "fdSelect"): + sel = self.charStrings[name].fdSelectIndex + else: + sel = 0 + else: + sel = None + return self.charStrings[name], sel + + def toXML(self, xmlWriter): + names = sorted(self.keys()) + for name in names: + charStr, fdSelectIndex = self.getItemAndSelector(name) + if charStr.needsDecompilation(): + raw = [("raw", 1)] + else: + raw = [] + if fdSelectIndex is None: + xmlWriter.begintag("CharString", [("name", name)] + raw) + else: + xmlWriter.begintag( + "CharString", + [("name", name), ("fdSelectIndex", fdSelectIndex)] + raw, + ) + xmlWriter.newline() + charStr.toXML(xmlWriter) + xmlWriter.endtag("CharString") + xmlWriter.newline() + + def fromXML(self, name, attrs, content): + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + if name != "CharString": + continue + fdID = -1 + if hasattr(self, "fdArray"): + try: + fdID = safeEval(attrs["fdSelectIndex"]) + except KeyError: + fdID = 0 + private = self.fdArray[fdID].Private + else: + private = self.private + + glyphName = attrs["name"] + charStringClass = psCharStrings.T2CharString + charString = charStringClass(private=private, globalSubrs=self.globalSubrs) + charString.fromXML(name, attrs, content) + if fdID >= 0: + charString.fdSelectIndex = fdID + self[glyphName] = charString + + +def readCard8(file): + return byteord(file.read(1)) + + +def readCard16(file): + (value,) = struct.unpack(">H", file.read(2)) + return value + + +def readCard32(file): + (value,) = struct.unpack(">L", file.read(4)) + return value + + +def writeCard8(file, value): + file.write(bytechr(value)) + + +def writeCard16(file, value): + file.write(struct.pack(">H", value)) + + +def writeCard32(file, value): + file.write(struct.pack(">L", value)) + + +def packCard8(value): + return bytechr(value) + + +def packCard16(value): + return struct.pack(">H", value) + + +def packCard32(value): + return struct.pack(">L", value) + + +def buildOperatorDict(table): + d = {} + for op, name, arg, default, conv in table: + d[op] = (name, arg) + return d + + +def buildOpcodeDict(table): + d = {} + for op, name, arg, default, conv in table: + if isinstance(op, tuple): + op = bytechr(op[0]) + bytechr(op[1]) + else: + op = bytechr(op) + d[name] = (op, arg) + return d + + +def buildOrder(table): + l = [] + for op, name, arg, default, conv in table: + l.append(name) + return l + + +def buildDefaults(table): + d = {} + for op, name, arg, default, conv in table: + if default is not None: + d[name] = default + return d + + +def buildConverters(table): + d = {} + for op, name, arg, default, conv in table: + d[name] = conv + return d + + +class SimpleConverter(object): + def read(self, parent, value): + if not hasattr(parent, "file"): + return self._read(parent, value) + file = parent.file + pos = file.tell() + try: + return self._read(parent, value) + finally: + file.seek(pos) + + def _read(self, parent, value): + return value + + def write(self, parent, value): + return value + + def xmlWrite(self, xmlWriter, name, value): + xmlWriter.simpletag(name, value=value) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + return attrs["value"] + + +class ASCIIConverter(SimpleConverter): + def _read(self, parent, value): + return tostr(value, encoding="ascii") + + def write(self, parent, value): + return tobytes(value, encoding="ascii") + + def xmlWrite(self, xmlWriter, name, value): + xmlWriter.simpletag(name, value=tostr(value, encoding="ascii")) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + return tobytes(attrs["value"], encoding=("ascii")) + + +class Latin1Converter(SimpleConverter): + def _read(self, parent, value): + return tostr(value, encoding="latin1") + + def write(self, parent, value): + return tobytes(value, encoding="latin1") + + def xmlWrite(self, xmlWriter, name, value): + value = tostr(value, encoding="latin1") + if name in ["Notice", "Copyright"]: + value = re.sub(r"[\r\n]\s+", " ", value) + xmlWriter.simpletag(name, value=value) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + return tobytes(attrs["value"], encoding=("latin1")) + + +def parseNum(s): + try: + value = int(s) + except: + value = float(s) + return value + + +def parseBlendList(s): + valueList = [] + for element in s: + if isinstance(element, str): + continue + name, attrs, content = element + blendList = attrs["value"].split() + blendList = [eval(val) for val in blendList] + valueList.append(blendList) + if len(valueList) == 1: + valueList = valueList[0] + return valueList + + +class NumberConverter(SimpleConverter): + def xmlWrite(self, xmlWriter, name, value): + if isinstance(value, list): + xmlWriter.begintag(name) + xmlWriter.newline() + xmlWriter.indent() + blendValue = " ".join([str(val) for val in value]) + xmlWriter.simpletag(kBlendDictOpName, value=blendValue) + xmlWriter.newline() + xmlWriter.dedent() + xmlWriter.endtag(name) + xmlWriter.newline() + else: + xmlWriter.simpletag(name, value=value) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + valueString = attrs.get("value", None) + if valueString is None: + value = parseBlendList(content) + else: + value = parseNum(attrs["value"]) + return value + + +class ArrayConverter(SimpleConverter): + def xmlWrite(self, xmlWriter, name, value): + if value and isinstance(value[0], list): + xmlWriter.begintag(name) + xmlWriter.newline() + xmlWriter.indent() + for valueList in value: + blendValue = " ".join([str(val) for val in valueList]) + xmlWriter.simpletag(kBlendDictOpName, value=blendValue) + xmlWriter.newline() + xmlWriter.dedent() + xmlWriter.endtag(name) + xmlWriter.newline() + else: + value = " ".join([str(val) for val in value]) + xmlWriter.simpletag(name, value=value) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + valueString = attrs.get("value", None) + if valueString is None: + valueList = parseBlendList(content) + else: + values = valueString.split() + valueList = [parseNum(value) for value in values] + return valueList + + +class TableConverter(SimpleConverter): + def xmlWrite(self, xmlWriter, name, value): + xmlWriter.begintag(name) + xmlWriter.newline() + value.toXML(xmlWriter) + xmlWriter.endtag(name) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + ob = self.getClass()() + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + ob.fromXML(name, attrs, content) + return ob + + +class PrivateDictConverter(TableConverter): + def getClass(self): + return PrivateDict + + def _read(self, parent, value): + size, offset = value + file = parent.file + isCFF2 = parent._isCFF2 + try: + vstore = parent.vstore + except AttributeError: + vstore = None + priv = PrivateDict(parent.strings, file, offset, isCFF2=isCFF2, vstore=vstore) + file.seek(offset) + data = file.read(size) + assert len(data) == size + priv.decompile(data) + return priv + + def write(self, parent, value): + return (0, 0) # dummy value + + +class SubrsConverter(TableConverter): + def getClass(self): + return SubrsIndex + + def _read(self, parent, value): + file = parent.file + isCFF2 = parent._isCFF2 + file.seek(parent.offset + value) # Offset(self) + return SubrsIndex(file, isCFF2=isCFF2) + + def write(self, parent, value): + return 0 # dummy value + + +class CharStringsConverter(TableConverter): + def _read(self, parent, value): + file = parent.file + isCFF2 = parent._isCFF2 + charset = parent.charset + varStore = getattr(parent, "VarStore", None) + globalSubrs = parent.GlobalSubrs + if hasattr(parent, "FDArray"): + fdArray = parent.FDArray + if hasattr(parent, "FDSelect"): + fdSelect = parent.FDSelect + else: + fdSelect = None + private = None + else: + fdSelect, fdArray = None, None + private = parent.Private + file.seek(value) # Offset(0) + charStrings = CharStrings( + file, + charset, + globalSubrs, + private, + fdSelect, + fdArray, + isCFF2=isCFF2, + varStore=varStore, + ) + return charStrings + + def write(self, parent, value): + return 0 # dummy value + + def xmlRead(self, name, attrs, content, parent): + if hasattr(parent, "FDArray"): + # if it is a CID-keyed font, then the private Dict is extracted from the + # parent.FDArray + fdArray = parent.FDArray + if hasattr(parent, "FDSelect"): + fdSelect = parent.FDSelect + else: + fdSelect = None + private = None + else: + # if it is a name-keyed font, then the private dict is in the top dict, + # and + # there is no fdArray. + private, fdSelect, fdArray = parent.Private, None, None + charStrings = CharStrings( + None, + None, + parent.GlobalSubrs, + private, + fdSelect, + fdArray, + varStore=getattr(parent, "VarStore", None), + ) + charStrings.fromXML(name, attrs, content) + return charStrings + + +class CharsetConverter(SimpleConverter): + def _read(self, parent, value): + isCID = hasattr(parent, "ROS") + if value > 2: + numGlyphs = parent.numGlyphs + file = parent.file + file.seek(value) + log.log(DEBUG, "loading charset at %s", value) + format = readCard8(file) + if format == 0: + charset = parseCharset0(numGlyphs, file, parent.strings, isCID) + elif format == 1 or format == 2: + charset = parseCharset(numGlyphs, file, parent.strings, isCID, format) + else: + raise NotImplementedError + assert len(charset) == numGlyphs + log.log(DEBUG, " charset end at %s", file.tell()) + # make sure glyph names are unique + allNames = {} + newCharset = [] + for glyphName in charset: + if glyphName in allNames: + # make up a new glyphName that's unique + n = allNames[glyphName] + while (glyphName + "#" + str(n)) in allNames: + n += 1 + allNames[glyphName] = n + 1 + glyphName = glyphName + "#" + str(n) + allNames[glyphName] = 1 + newCharset.append(glyphName) + charset = newCharset + else: # offset == 0 -> no charset data. + if isCID or "CharStrings" not in parent.rawDict: + # We get here only when processing fontDicts from the FDArray of + # CFF-CID fonts. Only the real topDict references the charset. + assert value == 0 + charset = None + elif value == 0: + charset = cffISOAdobeStrings + elif value == 1: + charset = cffIExpertStrings + elif value == 2: + charset = cffExpertSubsetStrings + if charset and (len(charset) != parent.numGlyphs): + charset = charset[: parent.numGlyphs] + return charset + + def write(self, parent, value): + return 0 # dummy value + + def xmlWrite(self, xmlWriter, name, value): + # XXX only write charset when not in OT/TTX context, where we + # dump charset as a separate "GlyphOrder" table. + # # xmlWriter.simpletag("charset") + xmlWriter.comment("charset is dumped separately as the 'GlyphOrder' element") + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + pass + + +class CharsetCompiler(object): + def __init__(self, strings, charset, parent): + assert charset[0] == ".notdef" + isCID = hasattr(parent.dictObj, "ROS") + data0 = packCharset0(charset, isCID, strings) + data = packCharset(charset, isCID, strings) + if len(data) < len(data0): + self.data = data + else: + self.data = data0 + self.parent = parent + + def setPos(self, pos, endPos): + self.parent.rawDict["charset"] = pos + + def getDataLength(self): + return len(self.data) + + def toFile(self, file): + file.write(self.data) + + +def getStdCharSet(charset): + # check to see if we can use a predefined charset value. + predefinedCharSetVal = None + predefinedCharSets = [ + (cffISOAdobeStringCount, cffISOAdobeStrings, 0), + (cffExpertStringCount, cffIExpertStrings, 1), + (cffExpertSubsetStringCount, cffExpertSubsetStrings, 2), + ] + lcs = len(charset) + for cnt, pcs, csv in predefinedCharSets: + if predefinedCharSetVal is not None: + break + if lcs > cnt: + continue + predefinedCharSetVal = csv + for i in range(lcs): + if charset[i] != pcs[i]: + predefinedCharSetVal = None + break + return predefinedCharSetVal + + +def getCIDfromName(name, strings): + return int(name[3:]) + + +def getSIDfromName(name, strings): + return strings.getSID(name) + + +def packCharset0(charset, isCID, strings): + fmt = 0 + data = [packCard8(fmt)] + if isCID: + getNameID = getCIDfromName + else: + getNameID = getSIDfromName + + for name in charset[1:]: + data.append(packCard16(getNameID(name, strings))) + return bytesjoin(data) + + +def packCharset(charset, isCID, strings): + fmt = 1 + ranges = [] + first = None + end = 0 + if isCID: + getNameID = getCIDfromName + else: + getNameID = getSIDfromName + + for name in charset[1:]: + SID = getNameID(name, strings) + if first is None: + first = SID + elif end + 1 != SID: + nLeft = end - first + if nLeft > 255: + fmt = 2 + ranges.append((first, nLeft)) + first = SID + end = SID + if end: + nLeft = end - first + if nLeft > 255: + fmt = 2 + ranges.append((first, nLeft)) + + data = [packCard8(fmt)] + if fmt == 1: + nLeftFunc = packCard8 + else: + nLeftFunc = packCard16 + for first, nLeft in ranges: + data.append(packCard16(first) + nLeftFunc(nLeft)) + return bytesjoin(data) + + +def parseCharset0(numGlyphs, file, strings, isCID): + charset = [".notdef"] + if isCID: + for i in range(numGlyphs - 1): + CID = readCard16(file) + charset.append("cid" + str(CID).zfill(5)) + else: + for i in range(numGlyphs - 1): + SID = readCard16(file) + charset.append(strings[SID]) + return charset + + +def parseCharset(numGlyphs, file, strings, isCID, fmt): + charset = [".notdef"] + count = 1 + if fmt == 1: + nLeftFunc = readCard8 + else: + nLeftFunc = readCard16 + while count < numGlyphs: + first = readCard16(file) + nLeft = nLeftFunc(file) + if isCID: + for CID in range(first, first + nLeft + 1): + charset.append("cid" + str(CID).zfill(5)) + else: + for SID in range(first, first + nLeft + 1): + charset.append(strings[SID]) + count = count + nLeft + 1 + return charset + + +class EncodingCompiler(object): + def __init__(self, strings, encoding, parent): + assert not isinstance(encoding, str) + data0 = packEncoding0(parent.dictObj.charset, encoding, parent.strings) + data1 = packEncoding1(parent.dictObj.charset, encoding, parent.strings) + if len(data0) < len(data1): + self.data = data0 + else: + self.data = data1 + self.parent = parent + + def setPos(self, pos, endPos): + self.parent.rawDict["Encoding"] = pos + + def getDataLength(self): + return len(self.data) + + def toFile(self, file): + file.write(self.data) + + +class EncodingConverter(SimpleConverter): + def _read(self, parent, value): + if value == 0: + return "StandardEncoding" + elif value == 1: + return "ExpertEncoding" + else: + assert value > 1 + file = parent.file + file.seek(value) + log.log(DEBUG, "loading Encoding at %s", value) + fmt = readCard8(file) + haveSupplement = fmt & 0x80 + if haveSupplement: + raise NotImplementedError("Encoding supplements are not yet supported") + fmt = fmt & 0x7F + if fmt == 0: + encoding = parseEncoding0( + parent.charset, file, haveSupplement, parent.strings + ) + elif fmt == 1: + encoding = parseEncoding1( + parent.charset, file, haveSupplement, parent.strings + ) + return encoding + + def write(self, parent, value): + if value == "StandardEncoding": + return 0 + elif value == "ExpertEncoding": + return 1 + return 0 # dummy value + + def xmlWrite(self, xmlWriter, name, value): + if value in ("StandardEncoding", "ExpertEncoding"): + xmlWriter.simpletag(name, name=value) + xmlWriter.newline() + return + xmlWriter.begintag(name) + xmlWriter.newline() + for code in range(len(value)): + glyphName = value[code] + if glyphName != ".notdef": + xmlWriter.simpletag("map", code=hex(code), name=glyphName) + xmlWriter.newline() + xmlWriter.endtag(name) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + if "name" in attrs: + return attrs["name"] + encoding = [".notdef"] * 256 + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + code = safeEval(attrs["code"]) + glyphName = attrs["name"] + encoding[code] = glyphName + return encoding + + +def parseEncoding0(charset, file, haveSupplement, strings): + nCodes = readCard8(file) + encoding = [".notdef"] * 256 + for glyphID in range(1, nCodes + 1): + code = readCard8(file) + if code != 0: + encoding[code] = charset[glyphID] + return encoding + + +def parseEncoding1(charset, file, haveSupplement, strings): + nRanges = readCard8(file) + encoding = [".notdef"] * 256 + glyphID = 1 + for i in range(nRanges): + code = readCard8(file) + nLeft = readCard8(file) + for glyphID in range(glyphID, glyphID + nLeft + 1): + encoding[code] = charset[glyphID] + code = code + 1 + glyphID = glyphID + 1 + return encoding + + +def packEncoding0(charset, encoding, strings): + fmt = 0 + m = {} + for code in range(len(encoding)): + name = encoding[code] + if name != ".notdef": + m[name] = code + codes = [] + for name in charset[1:]: + code = m.get(name) + codes.append(code) + + while codes and codes[-1] is None: + codes.pop() + + data = [packCard8(fmt), packCard8(len(codes))] + for code in codes: + if code is None: + code = 0 + data.append(packCard8(code)) + return bytesjoin(data) + + +def packEncoding1(charset, encoding, strings): + fmt = 1 + m = {} + for code in range(len(encoding)): + name = encoding[code] + if name != ".notdef": + m[name] = code + ranges = [] + first = None + end = 0 + for name in charset[1:]: + code = m.get(name, -1) + if first is None: + first = code + elif end + 1 != code: + nLeft = end - first + ranges.append((first, nLeft)) + first = code + end = code + nLeft = end - first + ranges.append((first, nLeft)) + + # remove unencoded glyphs at the end. + while ranges and ranges[-1][0] == -1: + ranges.pop() + + data = [packCard8(fmt), packCard8(len(ranges))] + for first, nLeft in ranges: + if first == -1: # unencoded + first = 0 + data.append(packCard8(first) + packCard8(nLeft)) + return bytesjoin(data) + + +class FDArrayConverter(TableConverter): + def _read(self, parent, value): + try: + vstore = parent.VarStore + except AttributeError: + vstore = None + file = parent.file + isCFF2 = parent._isCFF2 + file.seek(value) + fdArray = FDArrayIndex(file, isCFF2=isCFF2) + fdArray.vstore = vstore + fdArray.strings = parent.strings + fdArray.GlobalSubrs = parent.GlobalSubrs + return fdArray + + def write(self, parent, value): + return 0 # dummy value + + def xmlRead(self, name, attrs, content, parent): + fdArray = FDArrayIndex() + for element in content: + if isinstance(element, str): + continue + name, attrs, content = element + fdArray.fromXML(name, attrs, content) + return fdArray + + +class FDSelectConverter(SimpleConverter): + def _read(self, parent, value): + file = parent.file + file.seek(value) + fdSelect = FDSelect(file, parent.numGlyphs) + return fdSelect + + def write(self, parent, value): + return 0 # dummy value + + # The FDSelect glyph data is written out to XML in the charstring keys, + # so we write out only the format selector + def xmlWrite(self, xmlWriter, name, value): + xmlWriter.simpletag(name, [("format", value.format)]) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + fmt = safeEval(attrs["format"]) + file = None + numGlyphs = None + fdSelect = FDSelect(file, numGlyphs, fmt) + return fdSelect + + +class VarStoreConverter(SimpleConverter): + def _read(self, parent, value): + file = parent.file + file.seek(value) + varStore = VarStoreData(file) + varStore.decompile() + return varStore + + def write(self, parent, value): + return 0 # dummy value + + def xmlWrite(self, xmlWriter, name, value): + value.writeXML(xmlWriter, name) + + def xmlRead(self, name, attrs, content, parent): + varStore = VarStoreData() + varStore.xmlRead(name, attrs, content, parent) + return varStore + + +def packFDSelect0(fdSelectArray): + fmt = 0 + data = [packCard8(fmt)] + for index in fdSelectArray: + data.append(packCard8(index)) + return bytesjoin(data) + + +def packFDSelect3(fdSelectArray): + fmt = 3 + fdRanges = [] + lenArray = len(fdSelectArray) + lastFDIndex = -1 + for i in range(lenArray): + fdIndex = fdSelectArray[i] + if lastFDIndex != fdIndex: + fdRanges.append([i, fdIndex]) + lastFDIndex = fdIndex + sentinelGID = i + 1 + + data = [packCard8(fmt)] + data.append(packCard16(len(fdRanges))) + for fdRange in fdRanges: + data.append(packCard16(fdRange[0])) + data.append(packCard8(fdRange[1])) + data.append(packCard16(sentinelGID)) + return bytesjoin(data) + + +def packFDSelect4(fdSelectArray): + fmt = 4 + fdRanges = [] + lenArray = len(fdSelectArray) + lastFDIndex = -1 + for i in range(lenArray): + fdIndex = fdSelectArray[i] + if lastFDIndex != fdIndex: + fdRanges.append([i, fdIndex]) + lastFDIndex = fdIndex + sentinelGID = i + 1 + + data = [packCard8(fmt)] + data.append(packCard32(len(fdRanges))) + for fdRange in fdRanges: + data.append(packCard32(fdRange[0])) + data.append(packCard16(fdRange[1])) + data.append(packCard32(sentinelGID)) + return bytesjoin(data) + + +class FDSelectCompiler(object): + def __init__(self, fdSelect, parent): + fmt = fdSelect.format + fdSelectArray = fdSelect.gidArray + if fmt == 0: + self.data = packFDSelect0(fdSelectArray) + elif fmt == 3: + self.data = packFDSelect3(fdSelectArray) + elif fmt == 4: + self.data = packFDSelect4(fdSelectArray) + else: + # choose smaller of the two formats + data0 = packFDSelect0(fdSelectArray) + data3 = packFDSelect3(fdSelectArray) + if len(data0) < len(data3): + self.data = data0 + fdSelect.format = 0 + else: + self.data = data3 + fdSelect.format = 3 + + self.parent = parent + + def setPos(self, pos, endPos): + self.parent.rawDict["FDSelect"] = pos + + def getDataLength(self): + return len(self.data) + + def toFile(self, file): + file.write(self.data) + + +class VarStoreCompiler(object): + def __init__(self, varStoreData, parent): + self.parent = parent + if not varStoreData.data: + varStoreData.compile() + data = [packCard16(len(varStoreData.data)), varStoreData.data] + self.data = bytesjoin(data) + + def setPos(self, pos, endPos): + self.parent.rawDict["VarStore"] = pos + + def getDataLength(self): + return len(self.data) + + def toFile(self, file): + file.write(self.data) + + +class ROSConverter(SimpleConverter): + def xmlWrite(self, xmlWriter, name, value): + registry, order, supplement = value + xmlWriter.simpletag( + name, + [ + ("Registry", tostr(registry)), + ("Order", tostr(order)), + ("Supplement", supplement), + ], + ) + xmlWriter.newline() + + def xmlRead(self, name, attrs, content, parent): + return (attrs["Registry"], attrs["Order"], safeEval(attrs["Supplement"])) + + +topDictOperators = [ + # opcode name argument type default converter + (25, "maxstack", "number", None, None), + ((12, 30), "ROS", ("SID", "SID", "number"), None, ROSConverter()), + ((12, 20), "SyntheticBase", "number", None, None), + (0, "version", "SID", None, None), + (1, "Notice", "SID", None, Latin1Converter()), + ((12, 0), "Copyright", "SID", None, Latin1Converter()), + (2, "FullName", "SID", None, Latin1Converter()), + ((12, 38), "FontName", "SID", None, Latin1Converter()), + (3, "FamilyName", "SID", None, Latin1Converter()), + (4, "Weight", "SID", None, None), + ((12, 1), "isFixedPitch", "number", 0, None), + ((12, 2), "ItalicAngle", "number", 0, None), + ((12, 3), "UnderlinePosition", "number", -100, None), + ((12, 4), "UnderlineThickness", "number", 50, None), + ((12, 5), "PaintType", "number", 0, None), + ((12, 6), "CharstringType", "number", 2, None), + ((12, 7), "FontMatrix", "array", [0.001, 0, 0, 0.001, 0, 0], None), + (13, "UniqueID", "number", None, None), + (5, "FontBBox", "array", [0, 0, 0, 0], None), + ((12, 8), "StrokeWidth", "number", 0, None), + (14, "XUID", "array", None, None), + ((12, 21), "PostScript", "SID", None, None), + ((12, 22), "BaseFontName", "SID", None, None), + ((12, 23), "BaseFontBlend", "delta", None, None), + ((12, 31), "CIDFontVersion", "number", 0, None), + ((12, 32), "CIDFontRevision", "number", 0, None), + ((12, 33), "CIDFontType", "number", 0, None), + ((12, 34), "CIDCount", "number", 8720, None), + (15, "charset", "number", None, CharsetConverter()), + ((12, 35), "UIDBase", "number", None, None), + (16, "Encoding", "number", 0, EncodingConverter()), + (18, "Private", ("number", "number"), None, PrivateDictConverter()), + ((12, 37), "FDSelect", "number", None, FDSelectConverter()), + ((12, 36), "FDArray", "number", None, FDArrayConverter()), + (17, "CharStrings", "number", None, CharStringsConverter()), + (24, "VarStore", "number", None, VarStoreConverter()), +] + +topDictOperators2 = [ + # opcode name argument type default converter + (25, "maxstack", "number", None, None), + ((12, 7), "FontMatrix", "array", [0.001, 0, 0, 0.001, 0, 0], None), + ((12, 37), "FDSelect", "number", None, FDSelectConverter()), + ((12, 36), "FDArray", "number", None, FDArrayConverter()), + (17, "CharStrings", "number", None, CharStringsConverter()), + (24, "VarStore", "number", None, VarStoreConverter()), +] + +# Note! FDSelect and FDArray must both preceed CharStrings in the output XML build order, +# in order for the font to compile back from xml. + +kBlendDictOpName = "blend" +blendOp = 23 + +privateDictOperators = [ + # opcode name argument type default converter + (22, "vsindex", "number", None, None), + ( + blendOp, + kBlendDictOpName, + "blendList", + None, + None, + ), # This is for reading to/from XML: it not written to CFF. + (6, "BlueValues", "delta", None, None), + (7, "OtherBlues", "delta", None, None), + (8, "FamilyBlues", "delta", None, None), + (9, "FamilyOtherBlues", "delta", None, None), + ((12, 9), "BlueScale", "number", 0.039625, None), + ((12, 10), "BlueShift", "number", 7, None), + ((12, 11), "BlueFuzz", "number", 1, None), + (10, "StdHW", "number", None, None), + (11, "StdVW", "number", None, None), + ((12, 12), "StemSnapH", "delta", None, None), + ((12, 13), "StemSnapV", "delta", None, None), + ((12, 14), "ForceBold", "number", 0, None), + ((12, 15), "ForceBoldThreshold", "number", None, None), # deprecated + ((12, 16), "lenIV", "number", None, None), # deprecated + ((12, 17), "LanguageGroup", "number", 0, None), + ((12, 18), "ExpansionFactor", "number", 0.06, None), + ((12, 19), "initialRandomSeed", "number", 0, None), + (20, "defaultWidthX", "number", 0, None), + (21, "nominalWidthX", "number", 0, None), + (19, "Subrs", "number", None, SubrsConverter()), +] + +privateDictOperators2 = [ + # opcode name argument type default converter + (22, "vsindex", "number", None, None), + ( + blendOp, + kBlendDictOpName, + "blendList", + None, + None, + ), # This is for reading to/from XML: it not written to CFF. + (6, "BlueValues", "delta", None, None), + (7, "OtherBlues", "delta", None, None), + (8, "FamilyBlues", "delta", None, None), + (9, "FamilyOtherBlues", "delta", None, None), + ((12, 9), "BlueScale", "number", 0.039625, None), + ((12, 10), "BlueShift", "number", 7, None), + ((12, 11), "BlueFuzz", "number", 1, None), + (10, "StdHW", "number", None, None), + (11, "StdVW", "number", None, None), + ((12, 12), "StemSnapH", "delta", None, None), + ((12, 13), "StemSnapV", "delta", None, None), + ((12, 17), "LanguageGroup", "number", 0, None), + ((12, 18), "ExpansionFactor", "number", 0.06, None), + (19, "Subrs", "number", None, SubrsConverter()), +] + + +def addConverters(table): + for i in range(len(table)): + op, name, arg, default, conv = table[i] + if conv is not None: + continue + if arg in ("delta", "array"): + conv = ArrayConverter() + elif arg == "number": + conv = NumberConverter() + elif arg == "SID": + conv = ASCIIConverter() + elif arg == "blendList": + conv = None + else: + assert False + table[i] = op, name, arg, default, conv + + +addConverters(privateDictOperators) +addConverters(topDictOperators) + + +class TopDictDecompiler(psCharStrings.DictDecompiler): + operators = buildOperatorDict(topDictOperators) + + +class PrivateDictDecompiler(psCharStrings.DictDecompiler): + operators = buildOperatorDict(privateDictOperators) + + +class DictCompiler(object): + maxBlendStack = 0 + + def __init__(self, dictObj, strings, parent, isCFF2=None): + if strings: + assert isinstance(strings, IndexedStrings) + if isCFF2 is None and hasattr(parent, "isCFF2"): + isCFF2 = parent.isCFF2 + assert isCFF2 is not None + self.isCFF2 = isCFF2 + self.dictObj = dictObj + self.strings = strings + self.parent = parent + rawDict = {} + for name in dictObj.order: + value = getattr(dictObj, name, None) + if value is None: + continue + conv = dictObj.converters[name] + value = conv.write(dictObj, value) + if value == dictObj.defaults.get(name): + continue + rawDict[name] = value + self.rawDict = rawDict + + def setPos(self, pos, endPos): + pass + + def getDataLength(self): + return len(self.compile("getDataLength")) + + def compile(self, reason): + log.log(DEBUG, "-- compiling %s for %s", self.__class__.__name__, reason) + rawDict = self.rawDict + data = [] + for name in self.dictObj.order: + value = rawDict.get(name) + if value is None: + continue + op, argType = self.opcodes[name] + if isinstance(argType, tuple): + l = len(argType) + assert len(value) == l, "value doesn't match arg type" + for i in range(l): + arg = argType[i] + v = value[i] + arghandler = getattr(self, "arg_" + arg) + data.append(arghandler(v)) + else: + arghandler = getattr(self, "arg_" + argType) + data.append(arghandler(value)) + data.append(op) + data = bytesjoin(data) + return data + + def toFile(self, file): + data = self.compile("toFile") + file.write(data) + + def arg_number(self, num): + if isinstance(num, list): + data = [encodeNumber(val) for val in num] + data.append(encodeNumber(1)) + data.append(bytechr(blendOp)) + datum = bytesjoin(data) + else: + datum = encodeNumber(num) + return datum + + def arg_SID(self, s): + return psCharStrings.encodeIntCFF(self.strings.getSID(s)) + + def arg_array(self, value): + data = [] + for num in value: + data.append(self.arg_number(num)) + return bytesjoin(data) + + def arg_delta(self, value): + if not value: + return b"" + val0 = value[0] + if isinstance(val0, list): + data = self.arg_delta_blend(value) + else: + out = [] + last = 0 + for v in value: + out.append(v - last) + last = v + data = [] + for num in out: + data.append(encodeNumber(num)) + return bytesjoin(data) + + def arg_delta_blend(self, value): + """A delta list with blend lists has to be *all* blend lists. + + The value is a list is arranged as follows:: + + [ + [V0, d0..dn] + [V1, d0..dn] + ... + [Vm, d0..dn] + ] + + ``V`` is the absolute coordinate value from the default font, and ``d0-dn`` + are the delta values from the *n* regions. Each ``V`` is an absolute + coordinate from the default font. + + We want to return a list:: + + [ + [v0, v1..vm] + [d0..dn] + ... + [d0..dn] + numBlends + blendOp + ] + + where each ``v`` is relative to the previous default font value. + """ + numMasters = len(value[0]) + numBlends = len(value) + numStack = (numBlends * numMasters) + 1 + if numStack > self.maxBlendStack: + # Figure out the max number of value we can blend + # and divide this list up into chunks of that size. + + numBlendValues = int((self.maxBlendStack - 1) / numMasters) + out = [] + while True: + numVal = min(len(value), numBlendValues) + if numVal == 0: + break + valList = value[0:numVal] + out1 = self.arg_delta_blend(valList) + out.extend(out1) + value = value[numVal:] + else: + firstList = [0] * numBlends + deltaList = [None] * numBlends + i = 0 + prevVal = 0 + while i < numBlends: + # For PrivateDict BlueValues, the default font + # values are absolute, not relative. + # Must convert these back to relative coordinates + # befor writing to CFF2. + defaultValue = value[i][0] + firstList[i] = defaultValue - prevVal + prevVal = defaultValue + deltaList[i] = value[i][1:] + i += 1 + + relValueList = firstList + for blendList in deltaList: + relValueList.extend(blendList) + out = [encodeNumber(val) for val in relValueList] + out.append(encodeNumber(numBlends)) + out.append(bytechr(blendOp)) + return out + + +def encodeNumber(num): + if isinstance(num, float): + return psCharStrings.encodeFloat(num) + else: + return psCharStrings.encodeIntCFF(num) + + +class TopDictCompiler(DictCompiler): + opcodes = buildOpcodeDict(topDictOperators) + + def getChildren(self, strings): + isCFF2 = self.isCFF2 + children = [] + if self.dictObj.cff2GetGlyphOrder is None: + if hasattr(self.dictObj, "charset") and self.dictObj.charset: + if hasattr(self.dictObj, "ROS"): # aka isCID + charsetCode = None + else: + charsetCode = getStdCharSet(self.dictObj.charset) + if charsetCode is None: + children.append( + CharsetCompiler(strings, self.dictObj.charset, self) + ) + else: + self.rawDict["charset"] = charsetCode + if hasattr(self.dictObj, "Encoding") and self.dictObj.Encoding: + encoding = self.dictObj.Encoding + if not isinstance(encoding, str): + children.append(EncodingCompiler(strings, encoding, self)) + else: + if hasattr(self.dictObj, "VarStore"): + varStoreData = self.dictObj.VarStore + varStoreComp = VarStoreCompiler(varStoreData, self) + children.append(varStoreComp) + if hasattr(self.dictObj, "FDSelect"): + # I have not yet supported merging a ttx CFF-CID font, as there are + # interesting issues about merging the FDArrays. Here I assume that + # either the font was read from XML, and the FDSelect indices are all + # in the charstring data, or the FDSelect array is already fully defined. + fdSelect = self.dictObj.FDSelect + # probably read in from XML; assume fdIndex in CharString data + if len(fdSelect) == 0: + charStrings = self.dictObj.CharStrings + for name in self.dictObj.charset: + fdSelect.append(charStrings[name].fdSelectIndex) + fdSelectComp = FDSelectCompiler(fdSelect, self) + children.append(fdSelectComp) + if hasattr(self.dictObj, "CharStrings"): + items = [] + charStrings = self.dictObj.CharStrings + for name in self.dictObj.charset: + items.append(charStrings[name]) + charStringsComp = CharStringsCompiler(items, strings, self, isCFF2=isCFF2) + children.append(charStringsComp) + if hasattr(self.dictObj, "FDArray"): + # I have not yet supported merging a ttx CFF-CID font, as there are + # interesting issues about merging the FDArrays. Here I assume that the + # FDArray info is correct and complete. + fdArrayIndexComp = self.dictObj.FDArray.getCompiler(strings, self) + children.append(fdArrayIndexComp) + children.extend(fdArrayIndexComp.getChildren(strings)) + if hasattr(self.dictObj, "Private"): + privComp = self.dictObj.Private.getCompiler(strings, self) + children.append(privComp) + children.extend(privComp.getChildren(strings)) + return children + + +class FontDictCompiler(DictCompiler): + opcodes = buildOpcodeDict(topDictOperators) + + def __init__(self, dictObj, strings, parent, isCFF2=None): + super(FontDictCompiler, self).__init__(dictObj, strings, parent, isCFF2=isCFF2) + # + # We now take some effort to detect if there were any key/value pairs + # supplied that were ignored in the FontDict context, and issue a warning + # for those cases. + # + ignoredNames = [] + dictObj = self.dictObj + for name in sorted(set(dictObj.converters) - set(dictObj.order)): + if name in dictObj.rawDict: + # The font was directly read from binary. In this + # case, we want to report *all* "useless" key/value + # pairs that are in the font, not just the ones that + # are different from the default. + ignoredNames.append(name) + else: + # The font was probably read from a TTX file. We only + # warn about keys whos value is not the default. The + # ones that have the default value will not be written + # to binary anyway. + default = dictObj.defaults.get(name) + if default is not None: + conv = dictObj.converters[name] + default = conv.read(dictObj, default) + if getattr(dictObj, name, None) != default: + ignoredNames.append(name) + if ignoredNames: + log.warning( + "Some CFF FDArray/FontDict keys were ignored upon compile: " + + " ".join(sorted(ignoredNames)) + ) + + def getChildren(self, strings): + children = [] + if hasattr(self.dictObj, "Private"): + privComp = self.dictObj.Private.getCompiler(strings, self) + children.append(privComp) + children.extend(privComp.getChildren(strings)) + return children + + +class PrivateDictCompiler(DictCompiler): + maxBlendStack = maxStackLimit + opcodes = buildOpcodeDict(privateDictOperators) + + def setPos(self, pos, endPos): + size = endPos - pos + self.parent.rawDict["Private"] = size, pos + self.pos = pos + + def getChildren(self, strings): + children = [] + if hasattr(self.dictObj, "Subrs"): + children.append(self.dictObj.Subrs.getCompiler(strings, self)) + return children + + +class BaseDict(object): + def __init__(self, strings=None, file=None, offset=None, isCFF2=None): + assert (isCFF2 is None) == (file is None) + self.rawDict = {} + self.skipNames = [] + self.strings = strings + if file is None: + return + self._isCFF2 = isCFF2 + self.file = file + if offset is not None: + log.log(DEBUG, "loading %s at %s", self.__class__.__name__, offset) + self.offset = offset + + def decompile(self, data): + log.log(DEBUG, " length %s is %d", self.__class__.__name__, len(data)) + dec = self.decompilerClass(self.strings, self) + dec.decompile(data) + self.rawDict = dec.getDict() + self.postDecompile() + + def postDecompile(self): + pass + + def getCompiler(self, strings, parent, isCFF2=None): + return self.compilerClass(self, strings, parent, isCFF2=isCFF2) + + def __getattr__(self, name): + if name[:2] == name[-2:] == "__": + # to make deepcopy() and pickle.load() work, we need to signal with + # AttributeError that dunder methods like '__deepcopy__' or '__getstate__' + # aren't implemented. For more details, see: + # https://github.com/fonttools/fonttools/pull/1488 + raise AttributeError(name) + value = self.rawDict.get(name, None) + if value is None: + value = self.defaults.get(name) + if value is None: + raise AttributeError(name) + conv = self.converters[name] + value = conv.read(self, value) + setattr(self, name, value) + return value + + def toXML(self, xmlWriter): + for name in self.order: + if name in self.skipNames: + continue + value = getattr(self, name, None) + # XXX For "charset" we never skip calling xmlWrite even if the + # value is None, so we always write the following XML comment: + # + # + # + # Charset is None when 'CFF ' table is imported from XML into an + # empty TTFont(). By writing this comment all the time, we obtain + # the same XML output whether roundtripping XML-to-XML or + # dumping binary-to-XML + if value is None and name != "charset": + continue + conv = self.converters[name] + conv.xmlWrite(xmlWriter, name, value) + ignoredNames = set(self.rawDict) - set(self.order) + if ignoredNames: + xmlWriter.comment( + "some keys were ignored: %s" % " ".join(sorted(ignoredNames)) + ) + xmlWriter.newline() + + def fromXML(self, name, attrs, content): + conv = self.converters[name] + value = conv.xmlRead(name, attrs, content, self) + setattr(self, name, value) + + +class TopDict(BaseDict): + """The ``TopDict`` represents the top-level dictionary holding font + information. CFF2 tables contain a restricted set of top-level entries + as described `here `_, + but CFF tables may contain a wider range of information. This information + can be accessed through attributes or through the dictionary returned + through the ``rawDict`` property: + + .. code:: python + + font = tt["CFF "].cff[0] + font.FamilyName + # 'Linux Libertine O' + font.rawDict["FamilyName"] + # 'Linux Libertine O' + + More information is available in the CFF file's private dictionary, accessed + via the ``Private`` property: + + .. code:: python + + tt["CFF "].cff[0].Private.BlueValues + # [-15, 0, 515, 515, 666, 666] + + """ + + defaults = buildDefaults(topDictOperators) + converters = buildConverters(topDictOperators) + compilerClass = TopDictCompiler + order = buildOrder(topDictOperators) + decompilerClass = TopDictDecompiler + + def __init__( + self, + strings=None, + file=None, + offset=None, + GlobalSubrs=None, + cff2GetGlyphOrder=None, + isCFF2=None, + ): + super(TopDict, self).__init__(strings, file, offset, isCFF2=isCFF2) + self.cff2GetGlyphOrder = cff2GetGlyphOrder + self.GlobalSubrs = GlobalSubrs + if isCFF2: + self.defaults = buildDefaults(topDictOperators2) + self.charset = cff2GetGlyphOrder() + self.order = buildOrder(topDictOperators2) + else: + self.defaults = buildDefaults(topDictOperators) + self.order = buildOrder(topDictOperators) + + def getGlyphOrder(self): + """Returns a list of glyph names in the CFF font.""" + return self.charset + + def postDecompile(self): + offset = self.rawDict.get("CharStrings") + if offset is None: + return + # get the number of glyphs beforehand. + self.file.seek(offset) + if self._isCFF2: + self.numGlyphs = readCard32(self.file) + else: + self.numGlyphs = readCard16(self.file) + + def toXML(self, xmlWriter): + if hasattr(self, "CharStrings"): + self.decompileAllCharStrings() + if hasattr(self, "ROS"): + self.skipNames = ["Encoding"] + if not hasattr(self, "ROS") or not hasattr(self, "CharStrings"): + # these values have default values, but I only want them to show up + # in CID fonts. + self.skipNames = [ + "CIDFontVersion", + "CIDFontRevision", + "CIDFontType", + "CIDCount", + ] + BaseDict.toXML(self, xmlWriter) + + def decompileAllCharStrings(self): + # Make sure that all the Private Dicts have been instantiated. + for i, charString in enumerate(self.CharStrings.values()): + try: + charString.decompile() + except: + log.error("Error in charstring %s", i) + raise + + def recalcFontBBox(self): + fontBBox = None + for charString in self.CharStrings.values(): + bounds = charString.calcBounds(self.CharStrings) + if bounds is not None: + if fontBBox is not None: + fontBBox = unionRect(fontBBox, bounds) + else: + fontBBox = bounds + + if fontBBox is None: + self.FontBBox = self.defaults["FontBBox"][:] + else: + self.FontBBox = list(intRect(fontBBox)) + + +class FontDict(BaseDict): + # + # Since fonttools used to pass a lot of fields that are not relevant in the FDArray + # FontDict, there are 'ttx' files in the wild that contain all these. These got in + # the ttx files because fonttools writes explicit values for all the TopDict default + # values. These are not actually illegal in the context of an FDArray FontDict - you + # can legally, per spec, put any arbitrary key/value pair in a FontDict - but are + # useless since current major company CFF interpreters ignore anything but the set + # listed in this file. So, we just silently skip them. An exception is Weight: this + # is not used by any interpreter, but some foundries have asked that this be + # supported in FDArray FontDicts just to preserve information about the design when + # the font is being inspected. + # + # On top of that, there are fonts out there that contain such useless FontDict values. + # + # By subclassing TopDict, we *allow* all key/values from TopDict, both when reading + # from binary or when reading from XML, but by overriding `order` with a limited + # list of names, we ensure that only the useful names ever get exported to XML and + # ever get compiled into the binary font. + # + # We override compilerClass so we can warn about "useless" key/value pairs, either + # from the original binary font or from TTX input. + # + # See: + # - https://github.com/fonttools/fonttools/issues/740 + # - https://github.com/fonttools/fonttools/issues/601 + # - https://github.com/adobe-type-tools/afdko/issues/137 + # + defaults = {} + converters = buildConverters(topDictOperators) + compilerClass = FontDictCompiler + orderCFF = ["FontName", "FontMatrix", "Weight", "Private"] + orderCFF2 = ["Private"] + decompilerClass = TopDictDecompiler + + def __init__( + self, + strings=None, + file=None, + offset=None, + GlobalSubrs=None, + isCFF2=None, + vstore=None, + ): + super(FontDict, self).__init__(strings, file, offset, isCFF2=isCFF2) + self.vstore = vstore + self.setCFF2(isCFF2) + + def setCFF2(self, isCFF2): + # isCFF2 may be None. + if isCFF2: + self.order = self.orderCFF2 + self._isCFF2 = True + else: + self.order = self.orderCFF + self._isCFF2 = False + + +class PrivateDict(BaseDict): + defaults = buildDefaults(privateDictOperators) + converters = buildConverters(privateDictOperators) + order = buildOrder(privateDictOperators) + decompilerClass = PrivateDictDecompiler + compilerClass = PrivateDictCompiler + + def __init__(self, strings=None, file=None, offset=None, isCFF2=None, vstore=None): + super(PrivateDict, self).__init__(strings, file, offset, isCFF2=isCFF2) + self.vstore = vstore + if isCFF2: + self.defaults = buildDefaults(privateDictOperators2) + self.order = buildOrder(privateDictOperators2) + # Provide dummy values. This avoids needing to provide + # an isCFF2 state in a lot of places. + self.nominalWidthX = self.defaultWidthX = None + self._isCFF2 = True + else: + self.defaults = buildDefaults(privateDictOperators) + self.order = buildOrder(privateDictOperators) + self._isCFF2 = False + + @property + def in_cff2(self): + return self._isCFF2 + + def getNumRegions(self, vi=None): # called from misc/psCharStrings.py + # if getNumRegions is being called, we can assume that VarStore exists. + if vi is None: + if hasattr(self, "vsindex"): + vi = self.vsindex + else: + vi = 0 + numRegions = self.vstore.getNumRegions(vi) + return numRegions + + +class IndexedStrings(object): + """SID -> string mapping.""" + + def __init__(self, file=None): + if file is None: + strings = [] + else: + strings = [tostr(s, encoding="latin1") for s in Index(file, isCFF2=False)] + self.strings = strings + + def getCompiler(self): + return IndexedStringsCompiler(self, None, self, isCFF2=False) + + def __len__(self): + return len(self.strings) + + def __getitem__(self, SID): + if SID < cffStandardStringCount: + return cffStandardStrings[SID] + else: + return self.strings[SID - cffStandardStringCount] + + def getSID(self, s): + if not hasattr(self, "stringMapping"): + self.buildStringMapping() + s = tostr(s, encoding="latin1") + if s in cffStandardStringMapping: + SID = cffStandardStringMapping[s] + elif s in self.stringMapping: + SID = self.stringMapping[s] + else: + SID = len(self.strings) + cffStandardStringCount + self.strings.append(s) + self.stringMapping[s] = SID + return SID + + def getStrings(self): + return self.strings + + def buildStringMapping(self): + self.stringMapping = {} + for index in range(len(self.strings)): + self.stringMapping[self.strings[index]] = index + cffStandardStringCount + + +# The 391 Standard Strings as used in the CFF format. +# from Adobe Technical None #5176, version 1.0, 18 March 1998 + +cffStandardStrings = [ + ".notdef", + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quoteright", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "quoteleft", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "exclamdown", + "cent", + "sterling", + "fraction", + "yen", + "florin", + "section", + "currency", + "quotesingle", + "quotedblleft", + "guillemotleft", + "guilsinglleft", + "guilsinglright", + "fi", + "fl", + "endash", + "dagger", + "daggerdbl", + "periodcentered", + "paragraph", + "bullet", + "quotesinglbase", + "quotedblbase", + "quotedblright", + "guillemotright", + "ellipsis", + "perthousand", + "questiondown", + "grave", + "acute", + "circumflex", + "tilde", + "macron", + "breve", + "dotaccent", + "dieresis", + "ring", + "cedilla", + "hungarumlaut", + "ogonek", + "caron", + "emdash", + "AE", + "ordfeminine", + "Lslash", + "Oslash", + "OE", + "ordmasculine", + "ae", + "dotlessi", + "lslash", + "oslash", + "oe", + "germandbls", + "onesuperior", + "logicalnot", + "mu", + "trademark", + "Eth", + "onehalf", + "plusminus", + "Thorn", + "onequarter", + "divide", + "brokenbar", + "degree", + "thorn", + "threequarters", + "twosuperior", + "registered", + "minus", + "eth", + "multiply", + "threesuperior", + "copyright", + "Aacute", + "Acircumflex", + "Adieresis", + "Agrave", + "Aring", + "Atilde", + "Ccedilla", + "Eacute", + "Ecircumflex", + "Edieresis", + "Egrave", + "Iacute", + "Icircumflex", + "Idieresis", + "Igrave", + "Ntilde", + "Oacute", + "Ocircumflex", + "Odieresis", + "Ograve", + "Otilde", + "Scaron", + "Uacute", + "Ucircumflex", + "Udieresis", + "Ugrave", + "Yacute", + "Ydieresis", + "Zcaron", + "aacute", + "acircumflex", + "adieresis", + "agrave", + "aring", + "atilde", + "ccedilla", + "eacute", + "ecircumflex", + "edieresis", + "egrave", + "iacute", + "icircumflex", + "idieresis", + "igrave", + "ntilde", + "oacute", + "ocircumflex", + "odieresis", + "ograve", + "otilde", + "scaron", + "uacute", + "ucircumflex", + "udieresis", + "ugrave", + "yacute", + "ydieresis", + "zcaron", + "exclamsmall", + "Hungarumlautsmall", + "dollaroldstyle", + "dollarsuperior", + "ampersandsmall", + "Acutesmall", + "parenleftsuperior", + "parenrightsuperior", + "twodotenleader", + "onedotenleader", + "zerooldstyle", + "oneoldstyle", + "twooldstyle", + "threeoldstyle", + "fouroldstyle", + "fiveoldstyle", + "sixoldstyle", + "sevenoldstyle", + "eightoldstyle", + "nineoldstyle", + "commasuperior", + "threequartersemdash", + "periodsuperior", + "questionsmall", + "asuperior", + "bsuperior", + "centsuperior", + "dsuperior", + "esuperior", + "isuperior", + "lsuperior", + "msuperior", + "nsuperior", + "osuperior", + "rsuperior", + "ssuperior", + "tsuperior", + "ff", + "ffi", + "ffl", + "parenleftinferior", + "parenrightinferior", + "Circumflexsmall", + "hyphensuperior", + "Gravesmall", + "Asmall", + "Bsmall", + "Csmall", + "Dsmall", + "Esmall", + "Fsmall", + "Gsmall", + "Hsmall", + "Ismall", + "Jsmall", + "Ksmall", + "Lsmall", + "Msmall", + "Nsmall", + "Osmall", + "Psmall", + "Qsmall", + "Rsmall", + "Ssmall", + "Tsmall", + "Usmall", + "Vsmall", + "Wsmall", + "Xsmall", + "Ysmall", + "Zsmall", + "colonmonetary", + "onefitted", + "rupiah", + "Tildesmall", + "exclamdownsmall", + "centoldstyle", + "Lslashsmall", + "Scaronsmall", + "Zcaronsmall", + "Dieresissmall", + "Brevesmall", + "Caronsmall", + "Dotaccentsmall", + "Macronsmall", + "figuredash", + "hypheninferior", + "Ogoneksmall", + "Ringsmall", + "Cedillasmall", + "questiondownsmall", + "oneeighth", + "threeeighths", + "fiveeighths", + "seveneighths", + "onethird", + "twothirds", + "zerosuperior", + "foursuperior", + "fivesuperior", + "sixsuperior", + "sevensuperior", + "eightsuperior", + "ninesuperior", + "zeroinferior", + "oneinferior", + "twoinferior", + "threeinferior", + "fourinferior", + "fiveinferior", + "sixinferior", + "seveninferior", + "eightinferior", + "nineinferior", + "centinferior", + "dollarinferior", + "periodinferior", + "commainferior", + "Agravesmall", + "Aacutesmall", + "Acircumflexsmall", + "Atildesmall", + "Adieresissmall", + "Aringsmall", + "AEsmall", + "Ccedillasmall", + "Egravesmall", + "Eacutesmall", + "Ecircumflexsmall", + "Edieresissmall", + "Igravesmall", + "Iacutesmall", + "Icircumflexsmall", + "Idieresissmall", + "Ethsmall", + "Ntildesmall", + "Ogravesmall", + "Oacutesmall", + "Ocircumflexsmall", + "Otildesmall", + "Odieresissmall", + "OEsmall", + "Oslashsmall", + "Ugravesmall", + "Uacutesmall", + "Ucircumflexsmall", + "Udieresissmall", + "Yacutesmall", + "Thornsmall", + "Ydieresissmall", + "001.000", + "001.001", + "001.002", + "001.003", + "Black", + "Bold", + "Book", + "Light", + "Medium", + "Regular", + "Roman", + "Semibold", +] + +cffStandardStringCount = 391 +assert len(cffStandardStrings) == cffStandardStringCount +# build reverse mapping +cffStandardStringMapping = {} +for _i in range(cffStandardStringCount): + cffStandardStringMapping[cffStandardStrings[_i]] = _i + +cffISOAdobeStrings = [ + ".notdef", + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quoteright", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "quoteleft", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "exclamdown", + "cent", + "sterling", + "fraction", + "yen", + "florin", + "section", + "currency", + "quotesingle", + "quotedblleft", + "guillemotleft", + "guilsinglleft", + "guilsinglright", + "fi", + "fl", + "endash", + "dagger", + "daggerdbl", + "periodcentered", + "paragraph", + "bullet", + "quotesinglbase", + "quotedblbase", + "quotedblright", + "guillemotright", + "ellipsis", + "perthousand", + "questiondown", + "grave", + "acute", + "circumflex", + "tilde", + "macron", + "breve", + "dotaccent", + "dieresis", + "ring", + "cedilla", + "hungarumlaut", + "ogonek", + "caron", + "emdash", + "AE", + "ordfeminine", + "Lslash", + "Oslash", + "OE", + "ordmasculine", + "ae", + "dotlessi", + "lslash", + "oslash", + "oe", + "germandbls", + "onesuperior", + "logicalnot", + "mu", + "trademark", + "Eth", + "onehalf", + "plusminus", + "Thorn", + "onequarter", + "divide", + "brokenbar", + "degree", + "thorn", + "threequarters", + "twosuperior", + "registered", + "minus", + "eth", + "multiply", + "threesuperior", + "copyright", + "Aacute", + "Acircumflex", + "Adieresis", + "Agrave", + "Aring", + "Atilde", + "Ccedilla", + "Eacute", + "Ecircumflex", + "Edieresis", + "Egrave", + "Iacute", + "Icircumflex", + "Idieresis", + "Igrave", + "Ntilde", + "Oacute", + "Ocircumflex", + "Odieresis", + "Ograve", + "Otilde", + "Scaron", + "Uacute", + "Ucircumflex", + "Udieresis", + "Ugrave", + "Yacute", + "Ydieresis", + "Zcaron", + "aacute", + "acircumflex", + "adieresis", + "agrave", + "aring", + "atilde", + "ccedilla", + "eacute", + "ecircumflex", + "edieresis", + "egrave", + "iacute", + "icircumflex", + "idieresis", + "igrave", + "ntilde", + "oacute", + "ocircumflex", + "odieresis", + "ograve", + "otilde", + "scaron", + "uacute", + "ucircumflex", + "udieresis", + "ugrave", + "yacute", + "ydieresis", + "zcaron", +] + +cffISOAdobeStringCount = 229 +assert len(cffISOAdobeStrings) == cffISOAdobeStringCount + +cffIExpertStrings = [ + ".notdef", + "space", + "exclamsmall", + "Hungarumlautsmall", + "dollaroldstyle", + "dollarsuperior", + "ampersandsmall", + "Acutesmall", + "parenleftsuperior", + "parenrightsuperior", + "twodotenleader", + "onedotenleader", + "comma", + "hyphen", + "period", + "fraction", + "zerooldstyle", + "oneoldstyle", + "twooldstyle", + "threeoldstyle", + "fouroldstyle", + "fiveoldstyle", + "sixoldstyle", + "sevenoldstyle", + "eightoldstyle", + "nineoldstyle", + "colon", + "semicolon", + "commasuperior", + "threequartersemdash", + "periodsuperior", + "questionsmall", + "asuperior", + "bsuperior", + "centsuperior", + "dsuperior", + "esuperior", + "isuperior", + "lsuperior", + "msuperior", + "nsuperior", + "osuperior", + "rsuperior", + "ssuperior", + "tsuperior", + "ff", + "fi", + "fl", + "ffi", + "ffl", + "parenleftinferior", + "parenrightinferior", + "Circumflexsmall", + "hyphensuperior", + "Gravesmall", + "Asmall", + "Bsmall", + "Csmall", + "Dsmall", + "Esmall", + "Fsmall", + "Gsmall", + "Hsmall", + "Ismall", + "Jsmall", + "Ksmall", + "Lsmall", + "Msmall", + "Nsmall", + "Osmall", + "Psmall", + "Qsmall", + "Rsmall", + "Ssmall", + "Tsmall", + "Usmall", + "Vsmall", + "Wsmall", + "Xsmall", + "Ysmall", + "Zsmall", + "colonmonetary", + "onefitted", + "rupiah", + "Tildesmall", + "exclamdownsmall", + "centoldstyle", + "Lslashsmall", + "Scaronsmall", + "Zcaronsmall", + "Dieresissmall", + "Brevesmall", + "Caronsmall", + "Dotaccentsmall", + "Macronsmall", + "figuredash", + "hypheninferior", + "Ogoneksmall", + "Ringsmall", + "Cedillasmall", + "onequarter", + "onehalf", + "threequarters", + "questiondownsmall", + "oneeighth", + "threeeighths", + "fiveeighths", + "seveneighths", + "onethird", + "twothirds", + "zerosuperior", + "onesuperior", + "twosuperior", + "threesuperior", + "foursuperior", + "fivesuperior", + "sixsuperior", + "sevensuperior", + "eightsuperior", + "ninesuperior", + "zeroinferior", + "oneinferior", + "twoinferior", + "threeinferior", + "fourinferior", + "fiveinferior", + "sixinferior", + "seveninferior", + "eightinferior", + "nineinferior", + "centinferior", + "dollarinferior", + "periodinferior", + "commainferior", + "Agravesmall", + "Aacutesmall", + "Acircumflexsmall", + "Atildesmall", + "Adieresissmall", + "Aringsmall", + "AEsmall", + "Ccedillasmall", + "Egravesmall", + "Eacutesmall", + "Ecircumflexsmall", + "Edieresissmall", + "Igravesmall", + "Iacutesmall", + "Icircumflexsmall", + "Idieresissmall", + "Ethsmall", + "Ntildesmall", + "Ogravesmall", + "Oacutesmall", + "Ocircumflexsmall", + "Otildesmall", + "Odieresissmall", + "OEsmall", + "Oslashsmall", + "Ugravesmall", + "Uacutesmall", + "Ucircumflexsmall", + "Udieresissmall", + "Yacutesmall", + "Thornsmall", + "Ydieresissmall", +] + +cffExpertStringCount = 166 +assert len(cffIExpertStrings) == cffExpertStringCount + +cffExpertSubsetStrings = [ + ".notdef", + "space", + "dollaroldstyle", + "dollarsuperior", + "parenleftsuperior", + "parenrightsuperior", + "twodotenleader", + "onedotenleader", + "comma", + "hyphen", + "period", + "fraction", + "zerooldstyle", + "oneoldstyle", + "twooldstyle", + "threeoldstyle", + "fouroldstyle", + "fiveoldstyle", + "sixoldstyle", + "sevenoldstyle", + "eightoldstyle", + "nineoldstyle", + "colon", + "semicolon", + "commasuperior", + "threequartersemdash", + "periodsuperior", + "asuperior", + "bsuperior", + "centsuperior", + "dsuperior", + "esuperior", + "isuperior", + "lsuperior", + "msuperior", + "nsuperior", + "osuperior", + "rsuperior", + "ssuperior", + "tsuperior", + "ff", + "fi", + "fl", + "ffi", + "ffl", + "parenleftinferior", + "parenrightinferior", + "hyphensuperior", + "colonmonetary", + "onefitted", + "rupiah", + "centoldstyle", + "figuredash", + "hypheninferior", + "onequarter", + "onehalf", + "threequarters", + "oneeighth", + "threeeighths", + "fiveeighths", + "seveneighths", + "onethird", + "twothirds", + "zerosuperior", + "onesuperior", + "twosuperior", + "threesuperior", + "foursuperior", + "fivesuperior", + "sixsuperior", + "sevensuperior", + "eightsuperior", + "ninesuperior", + "zeroinferior", + "oneinferior", + "twoinferior", + "threeinferior", + "fourinferior", + "fiveinferior", + "sixinferior", + "seveninferior", + "eightinferior", + "nineinferior", + "centinferior", + "dollarinferior", + "periodinferior", + "commainferior", +] + +cffExpertSubsetStringCount = 87 +assert len(cffExpertSubsetStrings) == cffExpertSubsetStringCount diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/specializer.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/specializer.py new file mode 100644 index 00000000..bb7f89e4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/specializer.py @@ -0,0 +1,847 @@ +# -*- coding: utf-8 -*- + +"""T2CharString operator specializer and generalizer. + +PostScript glyph drawing operations can be expressed in multiple different +ways. For example, as well as the ``lineto`` operator, there is also a +``hlineto`` operator which draws a horizontal line, removing the need to +specify a ``dx`` coordinate, and a ``vlineto`` operator which draws a +vertical line, removing the need to specify a ``dy`` coordinate. As well +as decompiling :class:`fontTools.misc.psCharStrings.T2CharString` objects +into lists of operations, this module allows for conversion between general +and specific forms of the operation. + +""" + +from fontTools.cffLib import maxStackLimit + + +def stringToProgram(string): + if isinstance(string, str): + string = string.split() + program = [] + for token in string: + try: + token = int(token) + except ValueError: + try: + token = float(token) + except ValueError: + pass + program.append(token) + return program + + +def programToString(program): + return " ".join(str(x) for x in program) + + +def programToCommands(program, getNumRegions=None): + """Takes a T2CharString program list and returns list of commands. + Each command is a two-tuple of commandname,arg-list. The commandname might + be empty string if no commandname shall be emitted (used for glyph width, + hintmask/cntrmask argument, as well as stray arguments at the end of the + program (🤷). + 'getNumRegions' may be None, or a callable object. It must return the + number of regions. 'getNumRegions' takes a single argument, vsindex. It + returns the numRegions for the vsindex. + The Charstring may or may not start with a width value. If the first + non-blend operator has an odd number of arguments, then the first argument is + a width, and is popped off. This is complicated with blend operators, as + there may be more than one before the first hint or moveto operator, and each + one reduces several arguments to just one list argument. We have to sum the + number of arguments that are not part of the blend arguments, and all the + 'numBlends' values. We could instead have said that by definition, if there + is a blend operator, there is no width value, since CFF2 Charstrings don't + have width values. I discussed this with Behdad, and we are allowing for an + initial width value in this case because developers may assemble a CFF2 + charstring from CFF Charstrings, which could have width values. + """ + + seenWidthOp = False + vsIndex = 0 + lenBlendStack = 0 + lastBlendIndex = 0 + commands = [] + stack = [] + it = iter(program) + + for token in it: + if not isinstance(token, str): + stack.append(token) + continue + + if token == "blend": + assert getNumRegions is not None + numSourceFonts = 1 + getNumRegions(vsIndex) + # replace the blend op args on the stack with a single list + # containing all the blend op args. + numBlends = stack[-1] + numBlendArgs = numBlends * numSourceFonts + 1 + # replace first blend op by a list of the blend ops. + stack[-numBlendArgs:] = [stack[-numBlendArgs:]] + lenBlendStack += numBlends + len(stack) - 1 + lastBlendIndex = len(stack) + # if a blend op exists, this is or will be a CFF2 charstring. + continue + + elif token == "vsindex": + vsIndex = stack[-1] + assert type(vsIndex) is int + + elif (not seenWidthOp) and token in { + "hstem", + "hstemhm", + "vstem", + "vstemhm", + "cntrmask", + "hintmask", + "hmoveto", + "vmoveto", + "rmoveto", + "endchar", + }: + seenWidthOp = True + parity = token in {"hmoveto", "vmoveto"} + if lenBlendStack: + # lenBlendStack has the number of args represented by the last blend + # arg and all the preceding args. We need to now add the number of + # args following the last blend arg. + numArgs = lenBlendStack + len(stack[lastBlendIndex:]) + else: + numArgs = len(stack) + if numArgs and (numArgs % 2) ^ parity: + width = stack.pop(0) + commands.append(("", [width])) + + if token in {"hintmask", "cntrmask"}: + if stack: + commands.append(("", stack)) + commands.append((token, [])) + commands.append(("", [next(it)])) + else: + commands.append((token, stack)) + stack = [] + if stack: + commands.append(("", stack)) + return commands + + +def _flattenBlendArgs(args): + token_list = [] + for arg in args: + if isinstance(arg, list): + token_list.extend(arg) + token_list.append("blend") + else: + token_list.append(arg) + return token_list + + +def commandsToProgram(commands): + """Takes a commands list as returned by programToCommands() and converts + it back to a T2CharString program list.""" + program = [] + for op, args in commands: + if any(isinstance(arg, list) for arg in args): + args = _flattenBlendArgs(args) + program.extend(args) + if op: + program.append(op) + return program + + +def _everyN(el, n): + """Group the list el into groups of size n""" + if len(el) % n != 0: + raise ValueError(el) + for i in range(0, len(el), n): + yield el[i : i + n] + + +class _GeneralizerDecombinerCommandsMap(object): + @staticmethod + def rmoveto(args): + if len(args) != 2: + raise ValueError(args) + yield ("rmoveto", args) + + @staticmethod + def hmoveto(args): + if len(args) != 1: + raise ValueError(args) + yield ("rmoveto", [args[0], 0]) + + @staticmethod + def vmoveto(args): + if len(args) != 1: + raise ValueError(args) + yield ("rmoveto", [0, args[0]]) + + @staticmethod + def rlineto(args): + if not args: + raise ValueError(args) + for args in _everyN(args, 2): + yield ("rlineto", args) + + @staticmethod + def hlineto(args): + if not args: + raise ValueError(args) + it = iter(args) + try: + while True: + yield ("rlineto", [next(it), 0]) + yield ("rlineto", [0, next(it)]) + except StopIteration: + pass + + @staticmethod + def vlineto(args): + if not args: + raise ValueError(args) + it = iter(args) + try: + while True: + yield ("rlineto", [0, next(it)]) + yield ("rlineto", [next(it), 0]) + except StopIteration: + pass + + @staticmethod + def rrcurveto(args): + if not args: + raise ValueError(args) + for args in _everyN(args, 6): + yield ("rrcurveto", args) + + @staticmethod + def hhcurveto(args): + if len(args) < 4 or len(args) % 4 > 1: + raise ValueError(args) + if len(args) % 2 == 1: + yield ("rrcurveto", [args[1], args[0], args[2], args[3], args[4], 0]) + args = args[5:] + for args in _everyN(args, 4): + yield ("rrcurveto", [args[0], 0, args[1], args[2], args[3], 0]) + + @staticmethod + def vvcurveto(args): + if len(args) < 4 or len(args) % 4 > 1: + raise ValueError(args) + if len(args) % 2 == 1: + yield ("rrcurveto", [args[0], args[1], args[2], args[3], 0, args[4]]) + args = args[5:] + for args in _everyN(args, 4): + yield ("rrcurveto", [0, args[0], args[1], args[2], 0, args[3]]) + + @staticmethod + def hvcurveto(args): + if len(args) < 4 or len(args) % 8 not in {0, 1, 4, 5}: + raise ValueError(args) + last_args = None + if len(args) % 2 == 1: + lastStraight = len(args) % 8 == 5 + args, last_args = args[:-5], args[-5:] + it = _everyN(args, 4) + try: + while True: + args = next(it) + yield ("rrcurveto", [args[0], 0, args[1], args[2], 0, args[3]]) + args = next(it) + yield ("rrcurveto", [0, args[0], args[1], args[2], args[3], 0]) + except StopIteration: + pass + if last_args: + args = last_args + if lastStraight: + yield ("rrcurveto", [args[0], 0, args[1], args[2], args[4], args[3]]) + else: + yield ("rrcurveto", [0, args[0], args[1], args[2], args[3], args[4]]) + + @staticmethod + def vhcurveto(args): + if len(args) < 4 or len(args) % 8 not in {0, 1, 4, 5}: + raise ValueError(args) + last_args = None + if len(args) % 2 == 1: + lastStraight = len(args) % 8 == 5 + args, last_args = args[:-5], args[-5:] + it = _everyN(args, 4) + try: + while True: + args = next(it) + yield ("rrcurveto", [0, args[0], args[1], args[2], args[3], 0]) + args = next(it) + yield ("rrcurveto", [args[0], 0, args[1], args[2], 0, args[3]]) + except StopIteration: + pass + if last_args: + args = last_args + if lastStraight: + yield ("rrcurveto", [0, args[0], args[1], args[2], args[3], args[4]]) + else: + yield ("rrcurveto", [args[0], 0, args[1], args[2], args[4], args[3]]) + + @staticmethod + def rcurveline(args): + if len(args) < 8 or len(args) % 6 != 2: + raise ValueError(args) + args, last_args = args[:-2], args[-2:] + for args in _everyN(args, 6): + yield ("rrcurveto", args) + yield ("rlineto", last_args) + + @staticmethod + def rlinecurve(args): + if len(args) < 8 or len(args) % 2 != 0: + raise ValueError(args) + args, last_args = args[:-6], args[-6:] + for args in _everyN(args, 2): + yield ("rlineto", args) + yield ("rrcurveto", last_args) + + +def _convertBlendOpToArgs(blendList): + # args is list of blend op args. Since we are supporting + # recursive blend op calls, some of these args may also + # be a list of blend op args, and need to be converted before + # we convert the current list. + if any([isinstance(arg, list) for arg in blendList]): + args = [ + i + for e in blendList + for i in (_convertBlendOpToArgs(e) if isinstance(e, list) else [e]) + ] + else: + args = blendList + + # We now know that blendList contains a blend op argument list, even if + # some of the args are lists that each contain a blend op argument list. + # Convert from: + # [default font arg sequence x0,...,xn] + [delta tuple for x0] + ... + [delta tuple for xn] + # to: + # [ [x0] + [delta tuple for x0], + # ..., + # [xn] + [delta tuple for xn] ] + numBlends = args[-1] + # Can't use args.pop() when the args are being used in a nested list + # comprehension. See calling context + args = args[:-1] + + numRegions = len(args) // numBlends - 1 + if not (numBlends * (numRegions + 1) == len(args)): + raise ValueError(blendList) + + defaultArgs = [[arg] for arg in args[:numBlends]] + deltaArgs = args[numBlends:] + numDeltaValues = len(deltaArgs) + deltaList = [ + deltaArgs[i : i + numRegions] for i in range(0, numDeltaValues, numRegions) + ] + blend_args = [a + b + [1] for a, b in zip(defaultArgs, deltaList)] + return blend_args + + +def generalizeCommands(commands, ignoreErrors=False): + result = [] + mapping = _GeneralizerDecombinerCommandsMap + for op, args in commands: + # First, generalize any blend args in the arg list. + if any([isinstance(arg, list) for arg in args]): + try: + args = [ + n + for arg in args + for n in ( + _convertBlendOpToArgs(arg) if isinstance(arg, list) else [arg] + ) + ] + except ValueError: + if ignoreErrors: + # Store op as data, such that consumers of commands do not have to + # deal with incorrect number of arguments. + result.append(("", args)) + result.append(("", [op])) + else: + raise + + func = getattr(mapping, op, None) + if not func: + result.append((op, args)) + continue + try: + for command in func(args): + result.append(command) + except ValueError: + if ignoreErrors: + # Store op as data, such that consumers of commands do not have to + # deal with incorrect number of arguments. + result.append(("", args)) + result.append(("", [op])) + else: + raise + return result + + +def generalizeProgram(program, getNumRegions=None, **kwargs): + return commandsToProgram( + generalizeCommands(programToCommands(program, getNumRegions), **kwargs) + ) + + +def _categorizeVector(v): + """ + Takes X,Y vector v and returns one of r, h, v, or 0 depending on which + of X and/or Y are zero, plus tuple of nonzero ones. If both are zero, + it returns a single zero still. + + >>> _categorizeVector((0,0)) + ('0', (0,)) + >>> _categorizeVector((1,0)) + ('h', (1,)) + >>> _categorizeVector((0,2)) + ('v', (2,)) + >>> _categorizeVector((1,2)) + ('r', (1, 2)) + """ + if not v[0]: + if not v[1]: + return "0", v[:1] + else: + return "v", v[1:] + else: + if not v[1]: + return "h", v[:1] + else: + return "r", v + + +def _mergeCategories(a, b): + if a == "0": + return b + if b == "0": + return a + if a == b: + return a + return None + + +def _negateCategory(a): + if a == "h": + return "v" + if a == "v": + return "h" + assert a in "0r" + return a + + +def _convertToBlendCmds(args): + # return a list of blend commands, and + # the remaining non-blended args, if any. + num_args = len(args) + stack_use = 0 + new_args = [] + i = 0 + while i < num_args: + arg = args[i] + if not isinstance(arg, list): + new_args.append(arg) + i += 1 + stack_use += 1 + else: + prev_stack_use = stack_use + # The arg is a tuple of blend values. + # These are each (master 0,delta 1..delta n, 1) + # Combine as many successive tuples as we can, + # up to the max stack limit. + num_sources = len(arg) - 1 + blendlist = [arg] + i += 1 + stack_use += 1 + num_sources # 1 for the num_blends arg + while (i < num_args) and isinstance(args[i], list): + blendlist.append(args[i]) + i += 1 + stack_use += num_sources + if stack_use + num_sources > maxStackLimit: + # if we are here, max stack is the CFF2 max stack. + # I use the CFF2 max stack limit here rather than + # the 'maxstack' chosen by the client, as the default + # maxstack may have been used unintentionally. For all + # the other operators, this just produces a little less + # optimization, but here it puts a hard (and low) limit + # on the number of source fonts that can be used. + break + # blendList now contains as many single blend tuples as can be + # combined without exceeding the CFF2 stack limit. + num_blends = len(blendlist) + # append the 'num_blends' default font values + blend_args = [] + for arg in blendlist: + blend_args.append(arg[0]) + for arg in blendlist: + assert arg[-1] == 1 + blend_args.extend(arg[1:-1]) + blend_args.append(num_blends) + new_args.append(blend_args) + stack_use = prev_stack_use + num_blends + + return new_args + + +def _addArgs(a, b): + if isinstance(b, list): + if isinstance(a, list): + if len(a) != len(b) or a[-1] != b[-1]: + raise ValueError() + return [_addArgs(va, vb) for va, vb in zip(a[:-1], b[:-1])] + [a[-1]] + else: + a, b = b, a + if isinstance(a, list): + assert a[-1] == 1 + return [_addArgs(a[0], b)] + a[1:] + return a + b + + +def specializeCommands( + commands, + ignoreErrors=False, + generalizeFirst=True, + preserveTopology=False, + maxstack=48, +): + # We perform several rounds of optimizations. They are carefully ordered and are: + # + # 0. Generalize commands. + # This ensures that they are in our expected simple form, with each line/curve only + # having arguments for one segment, and using the generic form (rlineto/rrcurveto). + # If caller is sure the input is in this form, they can turn off generalization to + # save time. + # + # 1. Combine successive rmoveto operations. + # + # 2. Specialize rmoveto/rlineto/rrcurveto operators into horizontal/vertical variants. + # We specialize into some, made-up, variants as well, which simplifies following + # passes. + # + # 3. Merge or delete redundant operations, to the extent requested. + # OpenType spec declares point numbers in CFF undefined. As such, we happily + # change topology. If client relies on point numbers (in GPOS anchors, or for + # hinting purposes(what?)) they can turn this off. + # + # 4. Peephole optimization to revert back some of the h/v variants back into their + # original "relative" operator (rline/rrcurveto) if that saves a byte. + # + # 5. Combine adjacent operators when possible, minding not to go over max stack size. + # + # 6. Resolve any remaining made-up operators into real operators. + # + # I have convinced myself that this produces optimal bytecode (except for, possibly + # one byte each time maxstack size prohibits combining.) YMMV, but you'd be wrong. :-) + # A dynamic-programming approach can do the same but would be significantly slower. + # + # 7. For any args which are blend lists, convert them to a blend command. + + # 0. Generalize commands. + if generalizeFirst: + commands = generalizeCommands(commands, ignoreErrors=ignoreErrors) + else: + commands = list(commands) # Make copy since we modify in-place later. + + # 1. Combine successive rmoveto operations. + for i in range(len(commands) - 1, 0, -1): + if "rmoveto" == commands[i][0] == commands[i - 1][0]: + v1, v2 = commands[i - 1][1], commands[i][1] + commands[i - 1] = ("rmoveto", [v1[0] + v2[0], v1[1] + v2[1]]) + del commands[i] + + # 2. Specialize rmoveto/rlineto/rrcurveto operators into horizontal/vertical variants. + # + # We, in fact, specialize into more, made-up, variants that special-case when both + # X and Y components are zero. This simplifies the following optimization passes. + # This case is rare, but OCD does not let me skip it. + # + # After this round, we will have four variants that use the following mnemonics: + # + # - 'r' for relative, ie. non-zero X and non-zero Y, + # - 'h' for horizontal, ie. zero X and non-zero Y, + # - 'v' for vertical, ie. non-zero X and zero Y, + # - '0' for zeros, ie. zero X and zero Y. + # + # The '0' pseudo-operators are not part of the spec, but help simplify the following + # optimization rounds. We resolve them at the end. So, after this, we will have four + # moveto and four lineto variants: + # + # - 0moveto, 0lineto + # - hmoveto, hlineto + # - vmoveto, vlineto + # - rmoveto, rlineto + # + # and sixteen curveto variants. For example, a '0hcurveto' operator means a curve + # dx0,dy0,dx1,dy1,dx2,dy2,dx3,dy3 where dx0, dx1, and dy3 are zero but not dx3. + # An 'rvcurveto' means dx3 is zero but not dx0,dy0,dy3. + # + # There are nine different variants of curves without the '0'. Those nine map exactly + # to the existing curve variants in the spec: rrcurveto, and the four variants hhcurveto, + # vvcurveto, hvcurveto, and vhcurveto each cover two cases, one with an odd number of + # arguments and one without. Eg. an hhcurveto with an extra argument (odd number of + # arguments) is in fact an rhcurveto. The operators in the spec are designed such that + # all four of rhcurveto, rvcurveto, hrcurveto, and vrcurveto are encodable for one curve. + # + # Of the curve types with '0', the 00curveto is equivalent to a lineto variant. The rest + # of the curve types with a 0 need to be encoded as a h or v variant. Ie. a '0' can be + # thought of a "don't care" and can be used as either an 'h' or a 'v'. As such, we always + # encode a number 0 as argument when we use a '0' variant. Later on, we can just substitute + # the '0' with either 'h' or 'v' and it works. + # + # When we get to curve splines however, things become more complicated... XXX finish this. + # There's one more complexity with splines. If one side of the spline is not horizontal or + # vertical (or zero), ie. if it's 'r', then it limits which spline types we can encode. + # Only hhcurveto and vvcurveto operators can encode a spline starting with 'r', and + # only hvcurveto and vhcurveto operators can encode a spline ending with 'r'. + # This limits our merge opportunities later. + # + for i in range(len(commands)): + op, args = commands[i] + + if op in {"rmoveto", "rlineto"}: + c, args = _categorizeVector(args) + commands[i] = c + op[1:], args + continue + + if op == "rrcurveto": + c1, args1 = _categorizeVector(args[:2]) + c2, args2 = _categorizeVector(args[-2:]) + commands[i] = c1 + c2 + "curveto", args1 + args[2:4] + args2 + continue + + # 3. Merge or delete redundant operations, to the extent requested. + # + # TODO + # A 0moveto that comes before all other path operations can be removed. + # though I find conflicting evidence for this. + # + # TODO + # "If hstem and vstem hints are both declared at the beginning of a + # CharString, and this sequence is followed directly by the hintmask or + # cntrmask operators, then the vstem hint operator (or, if applicable, + # the vstemhm operator) need not be included." + # + # "The sequence and form of a CFF2 CharString program may be represented as: + # {hs* vs* cm* hm* mt subpath}? {mt subpath}*" + # + # https://www.microsoft.com/typography/otspec/cff2charstr.htm#section3.1 + # + # For Type2 CharStrings the sequence is: + # w? {hs* vs* cm* hm* mt subpath}? {mt subpath}* endchar" + + # Some other redundancies change topology (point numbers). + if not preserveTopology: + for i in range(len(commands) - 1, -1, -1): + op, args = commands[i] + + # A 00curveto is demoted to a (specialized) lineto. + if op == "00curveto": + assert len(args) == 4 + c, args = _categorizeVector(args[1:3]) + op = c + "lineto" + commands[i] = op, args + # and then... + + # A 0lineto can be deleted. + if op == "0lineto": + del commands[i] + continue + + # Merge adjacent hlineto's and vlineto's. + # In CFF2 charstrings from variable fonts, each + # arg item may be a list of blendable values, one from + # each source font. + if i and op in {"hlineto", "vlineto"} and (op == commands[i - 1][0]): + _, other_args = commands[i - 1] + assert len(args) == 1 and len(other_args) == 1 + try: + new_args = [_addArgs(args[0], other_args[0])] + except ValueError: + continue + commands[i - 1] = (op, new_args) + del commands[i] + continue + + # 4. Peephole optimization to revert back some of the h/v variants back into their + # original "relative" operator (rline/rrcurveto) if that saves a byte. + for i in range(1, len(commands) - 1): + op, args = commands[i] + prv, nxt = commands[i - 1][0], commands[i + 1][0] + + if op in {"0lineto", "hlineto", "vlineto"} and prv == nxt == "rlineto": + assert len(args) == 1 + args = [0, args[0]] if op[0] == "v" else [args[0], 0] + commands[i] = ("rlineto", args) + continue + + if op[2:] == "curveto" and len(args) == 5 and prv == nxt == "rrcurveto": + assert (op[0] == "r") ^ (op[1] == "r") + if op[0] == "v": + pos = 0 + elif op[0] != "r": + pos = 1 + elif op[1] == "v": + pos = 4 + else: + pos = 5 + # Insert, while maintaining the type of args (can be tuple or list). + args = args[:pos] + type(args)((0,)) + args[pos:] + commands[i] = ("rrcurveto", args) + continue + + # 5. Combine adjacent operators when possible, minding not to go over max stack size. + for i in range(len(commands) - 1, 0, -1): + op1, args1 = commands[i - 1] + op2, args2 = commands[i] + new_op = None + + # Merge logic... + if {op1, op2} <= {"rlineto", "rrcurveto"}: + if op1 == op2: + new_op = op1 + else: + if op2 == "rrcurveto" and len(args2) == 6: + new_op = "rlinecurve" + elif len(args2) == 2: + new_op = "rcurveline" + + elif (op1, op2) in {("rlineto", "rlinecurve"), ("rrcurveto", "rcurveline")}: + new_op = op2 + + elif {op1, op2} == {"vlineto", "hlineto"}: + new_op = op1 + + elif "curveto" == op1[2:] == op2[2:]: + d0, d1 = op1[:2] + d2, d3 = op2[:2] + + if d1 == "r" or d2 == "r" or d0 == d3 == "r": + continue + + d = _mergeCategories(d1, d2) + if d is None: + continue + if d0 == "r": + d = _mergeCategories(d, d3) + if d is None: + continue + new_op = "r" + d + "curveto" + elif d3 == "r": + d0 = _mergeCategories(d0, _negateCategory(d)) + if d0 is None: + continue + new_op = d0 + "r" + "curveto" + else: + d0 = _mergeCategories(d0, d3) + if d0 is None: + continue + new_op = d0 + d + "curveto" + + # Make sure the stack depth does not exceed (maxstack - 1), so + # that subroutinizer can insert subroutine calls at any point. + if new_op and len(args1) + len(args2) < maxstack: + commands[i - 1] = (new_op, args1 + args2) + del commands[i] + + # 6. Resolve any remaining made-up operators into real operators. + for i in range(len(commands)): + op, args = commands[i] + + if op in {"0moveto", "0lineto"}: + commands[i] = "h" + op[1:], args + continue + + if op[2:] == "curveto" and op[:2] not in {"rr", "hh", "vv", "vh", "hv"}: + op0, op1 = op[:2] + if (op0 == "r") ^ (op1 == "r"): + assert len(args) % 2 == 1 + if op0 == "0": + op0 = "h" + if op1 == "0": + op1 = "h" + if op0 == "r": + op0 = op1 + if op1 == "r": + op1 = _negateCategory(op0) + assert {op0, op1} <= {"h", "v"}, (op0, op1) + + if len(args) % 2: + if op0 != op1: # vhcurveto / hvcurveto + if (op0 == "h") ^ (len(args) % 8 == 1): + # Swap last two args order + args = args[:-2] + args[-1:] + args[-2:-1] + else: # hhcurveto / vvcurveto + if op0 == "h": # hhcurveto + # Swap first two args order + args = args[1:2] + args[:1] + args[2:] + + commands[i] = op0 + op1 + "curveto", args + continue + + # 7. For any series of args which are blend lists, convert the series to a single blend arg. + for i in range(len(commands)): + op, args = commands[i] + if any(isinstance(arg, list) for arg in args): + commands[i] = op, _convertToBlendCmds(args) + + return commands + + +def specializeProgram(program, getNumRegions=None, **kwargs): + return commandsToProgram( + specializeCommands(programToCommands(program, getNumRegions), **kwargs) + ) + + +if __name__ == "__main__": + import sys + + if len(sys.argv) == 1: + import doctest + + sys.exit(doctest.testmod().failed) + + import argparse + + parser = argparse.ArgumentParser( + "fonttools cffLib.specializer", + description="CFF CharString generalizer/specializer", + ) + parser.add_argument("program", metavar="command", nargs="*", help="Commands.") + parser.add_argument( + "--num-regions", + metavar="NumRegions", + nargs="*", + default=None, + help="Number of variable-font regions for blend opertaions.", + ) + + options = parser.parse_args(sys.argv[1:]) + + getNumRegions = ( + None + if options.num_regions is None + else lambda vsIndex: int(options.num_regions[0 if vsIndex is None else vsIndex]) + ) + + program = stringToProgram(options.program) + print("Program:") + print(programToString(program)) + commands = programToCommands(program, getNumRegions) + print("Commands:") + print(commands) + program2 = commandsToProgram(commands) + print("Program from commands:") + print(programToString(program2)) + assert program == program2 + print("Generalized program:") + print(programToString(generalizeProgram(program, getNumRegions))) + print("Specialized program:") + print(programToString(specializeProgram(program, getNumRegions))) diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/transforms.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/transforms.py new file mode 100644 index 00000000..91f6999f --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/transforms.py @@ -0,0 +1,483 @@ +from fontTools.misc.psCharStrings import ( + SimpleT2Decompiler, + T2WidthExtractor, + calcSubrBias, +) + + +def _uniq_sort(l): + return sorted(set(l)) + + +class StopHintCountEvent(Exception): + pass + + +class _DesubroutinizingT2Decompiler(SimpleT2Decompiler): + stop_hintcount_ops = ( + "op_hintmask", + "op_cntrmask", + "op_rmoveto", + "op_hmoveto", + "op_vmoveto", + ) + + def __init__(self, localSubrs, globalSubrs, private=None): + SimpleT2Decompiler.__init__(self, localSubrs, globalSubrs, private) + + def execute(self, charString): + self.need_hintcount = True # until proven otherwise + for op_name in self.stop_hintcount_ops: + setattr(self, op_name, self.stop_hint_count) + + if hasattr(charString, "_desubroutinized"): + # If a charstring has already been desubroutinized, we will still + # need to execute it if we need to count hints in order to + # compute the byte length for mask arguments, and haven't finished + # counting hints pairs. + if self.need_hintcount and self.callingStack: + try: + SimpleT2Decompiler.execute(self, charString) + except StopHintCountEvent: + del self.callingStack[-1] + return + + charString._patches = [] + SimpleT2Decompiler.execute(self, charString) + desubroutinized = charString.program[:] + for idx, expansion in reversed(charString._patches): + assert idx >= 2 + assert desubroutinized[idx - 1] in [ + "callsubr", + "callgsubr", + ], desubroutinized[idx - 1] + assert type(desubroutinized[idx - 2]) == int + if expansion[-1] == "return": + expansion = expansion[:-1] + desubroutinized[idx - 2 : idx] = expansion + if not self.private.in_cff2: + if "endchar" in desubroutinized: + # Cut off after first endchar + desubroutinized = desubroutinized[ + : desubroutinized.index("endchar") + 1 + ] + + charString._desubroutinized = desubroutinized + del charString._patches + + def op_callsubr(self, index): + subr = self.localSubrs[self.operandStack[-1] + self.localBias] + SimpleT2Decompiler.op_callsubr(self, index) + self.processSubr(index, subr) + + def op_callgsubr(self, index): + subr = self.globalSubrs[self.operandStack[-1] + self.globalBias] + SimpleT2Decompiler.op_callgsubr(self, index) + self.processSubr(index, subr) + + def stop_hint_count(self, *args): + self.need_hintcount = False + for op_name in self.stop_hintcount_ops: + setattr(self, op_name, None) + cs = self.callingStack[-1] + if hasattr(cs, "_desubroutinized"): + raise StopHintCountEvent() + + def op_hintmask(self, index): + SimpleT2Decompiler.op_hintmask(self, index) + if self.need_hintcount: + self.stop_hint_count() + + def processSubr(self, index, subr): + cs = self.callingStack[-1] + if not hasattr(cs, "_desubroutinized"): + cs._patches.append((index, subr._desubroutinized)) + + +def desubroutinize(cff): + for fontName in cff.fontNames: + font = cff[fontName] + cs = font.CharStrings + for c in cs.values(): + c.decompile() + subrs = getattr(c.private, "Subrs", []) + decompiler = _DesubroutinizingT2Decompiler(subrs, c.globalSubrs, c.private) + decompiler.execute(c) + c.program = c._desubroutinized + del c._desubroutinized + # Delete all the local subrs + if hasattr(font, "FDArray"): + for fd in font.FDArray: + pd = fd.Private + if hasattr(pd, "Subrs"): + del pd.Subrs + if "Subrs" in pd.rawDict: + del pd.rawDict["Subrs"] + else: + pd = font.Private + if hasattr(pd, "Subrs"): + del pd.Subrs + if "Subrs" in pd.rawDict: + del pd.rawDict["Subrs"] + # as well as the global subrs + cff.GlobalSubrs.clear() + + +class _MarkingT2Decompiler(SimpleT2Decompiler): + def __init__(self, localSubrs, globalSubrs, private): + SimpleT2Decompiler.__init__(self, localSubrs, globalSubrs, private) + for subrs in [localSubrs, globalSubrs]: + if subrs and not hasattr(subrs, "_used"): + subrs._used = set() + + def op_callsubr(self, index): + self.localSubrs._used.add(self.operandStack[-1] + self.localBias) + SimpleT2Decompiler.op_callsubr(self, index) + + def op_callgsubr(self, index): + self.globalSubrs._used.add(self.operandStack[-1] + self.globalBias) + SimpleT2Decompiler.op_callgsubr(self, index) + + +class _DehintingT2Decompiler(T2WidthExtractor): + class Hints(object): + def __init__(self): + # Whether calling this charstring produces any hint stems + # Note that if a charstring starts with hintmask, it will + # have has_hint set to True, because it *might* produce an + # implicit vstem if called under certain conditions. + self.has_hint = False + # Index to start at to drop all hints + self.last_hint = 0 + # Index up to which we know more hints are possible. + # Only relevant if status is 0 or 1. + self.last_checked = 0 + # The status means: + # 0: after dropping hints, this charstring is empty + # 1: after dropping hints, there may be more hints + # continuing after this, or there might be + # other things. Not clear yet. + # 2: no more hints possible after this charstring + self.status = 0 + # Has hintmask instructions; not recursive + self.has_hintmask = False + # List of indices of calls to empty subroutines to remove. + self.deletions = [] + + pass + + def __init__( + self, css, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None + ): + self._css = css + T2WidthExtractor.__init__( + self, localSubrs, globalSubrs, nominalWidthX, defaultWidthX + ) + self.private = private + + def execute(self, charString): + old_hints = charString._hints if hasattr(charString, "_hints") else None + charString._hints = self.Hints() + + T2WidthExtractor.execute(self, charString) + + hints = charString._hints + + if hints.has_hint or hints.has_hintmask: + self._css.add(charString) + + if hints.status != 2: + # Check from last_check, make sure we didn't have any operators. + for i in range(hints.last_checked, len(charString.program) - 1): + if isinstance(charString.program[i], str): + hints.status = 2 + break + else: + hints.status = 1 # There's *something* here + hints.last_checked = len(charString.program) + + if old_hints: + assert hints.__dict__ == old_hints.__dict__ + + def op_callsubr(self, index): + subr = self.localSubrs[self.operandStack[-1] + self.localBias] + T2WidthExtractor.op_callsubr(self, index) + self.processSubr(index, subr) + + def op_callgsubr(self, index): + subr = self.globalSubrs[self.operandStack[-1] + self.globalBias] + T2WidthExtractor.op_callgsubr(self, index) + self.processSubr(index, subr) + + def op_hstem(self, index): + T2WidthExtractor.op_hstem(self, index) + self.processHint(index) + + def op_vstem(self, index): + T2WidthExtractor.op_vstem(self, index) + self.processHint(index) + + def op_hstemhm(self, index): + T2WidthExtractor.op_hstemhm(self, index) + self.processHint(index) + + def op_vstemhm(self, index): + T2WidthExtractor.op_vstemhm(self, index) + self.processHint(index) + + def op_hintmask(self, index): + rv = T2WidthExtractor.op_hintmask(self, index) + self.processHintmask(index) + return rv + + def op_cntrmask(self, index): + rv = T2WidthExtractor.op_cntrmask(self, index) + self.processHintmask(index) + return rv + + def processHintmask(self, index): + cs = self.callingStack[-1] + hints = cs._hints + hints.has_hintmask = True + if hints.status != 2: + # Check from last_check, see if we may be an implicit vstem + for i in range(hints.last_checked, index - 1): + if isinstance(cs.program[i], str): + hints.status = 2 + break + else: + # We are an implicit vstem + hints.has_hint = True + hints.last_hint = index + 1 + hints.status = 0 + hints.last_checked = index + 1 + + def processHint(self, index): + cs = self.callingStack[-1] + hints = cs._hints + hints.has_hint = True + hints.last_hint = index + hints.last_checked = index + + def processSubr(self, index, subr): + cs = self.callingStack[-1] + hints = cs._hints + subr_hints = subr._hints + + # Check from last_check, make sure we didn't have + # any operators. + if hints.status != 2: + for i in range(hints.last_checked, index - 1): + if isinstance(cs.program[i], str): + hints.status = 2 + break + hints.last_checked = index + + if hints.status != 2: + if subr_hints.has_hint: + hints.has_hint = True + + # Decide where to chop off from + if subr_hints.status == 0: + hints.last_hint = index + else: + hints.last_hint = index - 2 # Leave the subr call in + + elif subr_hints.status == 0: + hints.deletions.append(index) + + hints.status = max(hints.status, subr_hints.status) + + +def _cs_subset_subroutines(charstring, subrs, gsubrs): + p = charstring.program + for i in range(1, len(p)): + if p[i] == "callsubr": + assert isinstance(p[i - 1], int) + p[i - 1] = subrs._used.index(p[i - 1] + subrs._old_bias) - subrs._new_bias + elif p[i] == "callgsubr": + assert isinstance(p[i - 1], int) + p[i - 1] = ( + gsubrs._used.index(p[i - 1] + gsubrs._old_bias) - gsubrs._new_bias + ) + + +def _cs_drop_hints(charstring): + hints = charstring._hints + + if hints.deletions: + p = charstring.program + for idx in reversed(hints.deletions): + del p[idx - 2 : idx] + + if hints.has_hint: + assert not hints.deletions or hints.last_hint <= hints.deletions[0] + charstring.program = charstring.program[hints.last_hint :] + if not charstring.program: + # TODO CFF2 no need for endchar. + charstring.program.append("endchar") + if hasattr(charstring, "width"): + # Insert width back if needed + if charstring.width != charstring.private.defaultWidthX: + # For CFF2 charstrings, this should never happen + assert ( + charstring.private.defaultWidthX is not None + ), "CFF2 CharStrings must not have an initial width value" + charstring.program.insert( + 0, charstring.width - charstring.private.nominalWidthX + ) + + if hints.has_hintmask: + i = 0 + p = charstring.program + while i < len(p): + if p[i] in ["hintmask", "cntrmask"]: + assert i + 1 <= len(p) + del p[i : i + 2] + continue + i += 1 + + assert len(charstring.program) + + del charstring._hints + + +def remove_hints(cff, *, removeUnusedSubrs: bool = True): + for fontname in cff.keys(): + font = cff[fontname] + cs = font.CharStrings + # This can be tricky, but doesn't have to. What we do is: + # + # - Run all used glyph charstrings and recurse into subroutines, + # - For each charstring (including subroutines), if it has any + # of the hint stem operators, we mark it as such. + # Upon returning, for each charstring we note all the + # subroutine calls it makes that (recursively) contain a stem, + # - Dropping hinting then consists of the following two ops: + # * Drop the piece of the program in each charstring before the + # last call to a stem op or a stem-calling subroutine, + # * Drop all hintmask operations. + # - It's trickier... A hintmask right after hints and a few numbers + # will act as an implicit vstemhm. As such, we track whether + # we have seen any non-hint operators so far and do the right + # thing, recursively... Good luck understanding that :( + css = set() + for c in cs.values(): + c.decompile() + subrs = getattr(c.private, "Subrs", []) + decompiler = _DehintingT2Decompiler( + css, + subrs, + c.globalSubrs, + c.private.nominalWidthX, + c.private.defaultWidthX, + c.private, + ) + decompiler.execute(c) + c.width = decompiler.width + for charstring in css: + _cs_drop_hints(charstring) + del css + + # Drop font-wide hinting values + all_privs = [] + if hasattr(font, "FDArray"): + all_privs.extend(fd.Private for fd in font.FDArray) + else: + all_privs.append(font.Private) + for priv in all_privs: + for k in [ + "BlueValues", + "OtherBlues", + "FamilyBlues", + "FamilyOtherBlues", + "BlueScale", + "BlueShift", + "BlueFuzz", + "StemSnapH", + "StemSnapV", + "StdHW", + "StdVW", + "ForceBold", + "LanguageGroup", + "ExpansionFactor", + ]: + if hasattr(priv, k): + setattr(priv, k, None) + if removeUnusedSubrs: + remove_unused_subroutines(cff) + + +def _pd_delete_empty_subrs(private_dict): + if hasattr(private_dict, "Subrs") and not private_dict.Subrs: + if "Subrs" in private_dict.rawDict: + del private_dict.rawDict["Subrs"] + del private_dict.Subrs + + +def remove_unused_subroutines(cff): + for fontname in cff.keys(): + font = cff[fontname] + cs = font.CharStrings + # Renumber subroutines to remove unused ones + + # Mark all used subroutines + for c in cs.values(): + subrs = getattr(c.private, "Subrs", []) + decompiler = _MarkingT2Decompiler(subrs, c.globalSubrs, c.private) + decompiler.execute(c) + + all_subrs = [font.GlobalSubrs] + if hasattr(font, "FDArray"): + all_subrs.extend( + fd.Private.Subrs + for fd in font.FDArray + if hasattr(fd.Private, "Subrs") and fd.Private.Subrs + ) + elif hasattr(font.Private, "Subrs") and font.Private.Subrs: + all_subrs.append(font.Private.Subrs) + + subrs = set(subrs) # Remove duplicates + + # Prepare + for subrs in all_subrs: + if not hasattr(subrs, "_used"): + subrs._used = set() + subrs._used = _uniq_sort(subrs._used) + subrs._old_bias = calcSubrBias(subrs) + subrs._new_bias = calcSubrBias(subrs._used) + + # Renumber glyph charstrings + for c in cs.values(): + subrs = getattr(c.private, "Subrs", None) + _cs_subset_subroutines(c, subrs, font.GlobalSubrs) + + # Renumber subroutines themselves + for subrs in all_subrs: + if subrs == font.GlobalSubrs: + if not hasattr(font, "FDArray") and hasattr(font.Private, "Subrs"): + local_subrs = font.Private.Subrs + else: + local_subrs = None + else: + local_subrs = subrs + + subrs.items = [subrs.items[i] for i in subrs._used] + if hasattr(subrs, "file"): + del subrs.file + if hasattr(subrs, "offsets"): + del subrs.offsets + + for subr in subrs.items: + _cs_subset_subroutines(subr, local_subrs, font.GlobalSubrs) + + # Delete local SubrsIndex if empty + if hasattr(font, "FDArray"): + for fd in font.FDArray: + _pd_delete_empty_subrs(fd.Private) + else: + _pd_delete_empty_subrs(font.Private) + + # Cleanup + for subrs in all_subrs: + del subrs._used, subrs._old_bias, subrs._new_bias diff --git a/venv/lib/python3.10/site-packages/fontTools/cffLib/width.py b/venv/lib/python3.10/site-packages/fontTools/cffLib/width.py new file mode 100644 index 00000000..78ff27e4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cffLib/width.py @@ -0,0 +1,210 @@ +# -*- coding: utf-8 -*- + +"""T2CharString glyph width optimizer. + +CFF glyphs whose width equals the CFF Private dictionary's ``defaultWidthX`` +value do not need to specify their width in their charstring, saving bytes. +This module determines the optimum ``defaultWidthX`` and ``nominalWidthX`` +values for a font, when provided with a list of glyph widths.""" + +from fontTools.ttLib import TTFont +from collections import defaultdict +from operator import add +from functools import reduce + + +__all__ = ["optimizeWidths", "main"] + + +class missingdict(dict): + def __init__(self, missing_func): + self.missing_func = missing_func + + def __missing__(self, v): + return self.missing_func(v) + + +def cumSum(f, op=add, start=0, decreasing=False): + keys = sorted(f.keys()) + minx, maxx = keys[0], keys[-1] + + total = reduce(op, f.values(), start) + + if decreasing: + missing = lambda x: start if x > maxx else total + domain = range(maxx, minx - 1, -1) + else: + missing = lambda x: start if x < minx else total + domain = range(minx, maxx + 1) + + out = missingdict(missing) + + v = start + for x in domain: + v = op(v, f[x]) + out[x] = v + + return out + + +def byteCost(widths, default, nominal): + if not hasattr(widths, "items"): + d = defaultdict(int) + for w in widths: + d[w] += 1 + widths = d + + cost = 0 + for w, freq in widths.items(): + if w == default: + continue + diff = abs(w - nominal) + if diff <= 107: + cost += freq + elif diff <= 1131: + cost += freq * 2 + else: + cost += freq * 5 + return cost + + +def optimizeWidthsBruteforce(widths): + """Bruteforce version. Veeeeeeeeeeeeeeeeery slow. Only works for smallests of fonts.""" + + d = defaultdict(int) + for w in widths: + d[w] += 1 + + # Maximum number of bytes using default can possibly save + maxDefaultAdvantage = 5 * max(d.values()) + + minw, maxw = min(widths), max(widths) + domain = list(range(minw, maxw + 1)) + + bestCostWithoutDefault = min(byteCost(widths, None, nominal) for nominal in domain) + + bestCost = len(widths) * 5 + 1 + for nominal in domain: + if byteCost(widths, None, nominal) > bestCost + maxDefaultAdvantage: + continue + for default in domain: + cost = byteCost(widths, default, nominal) + if cost < bestCost: + bestCost = cost + bestDefault = default + bestNominal = nominal + + return bestDefault, bestNominal + + +def optimizeWidths(widths): + """Given a list of glyph widths, or dictionary mapping glyph width to number of + glyphs having that, returns a tuple of best CFF default and nominal glyph widths. + + This algorithm is linear in UPEM+numGlyphs.""" + + if not hasattr(widths, "items"): + d = defaultdict(int) + for w in widths: + d[w] += 1 + widths = d + + keys = sorted(widths.keys()) + minw, maxw = keys[0], keys[-1] + domain = list(range(minw, maxw + 1)) + + # Cumulative sum/max forward/backward. + cumFrqU = cumSum(widths, op=add) + cumMaxU = cumSum(widths, op=max) + cumFrqD = cumSum(widths, op=add, decreasing=True) + cumMaxD = cumSum(widths, op=max, decreasing=True) + + # Cost per nominal choice, without default consideration. + nomnCostU = missingdict( + lambda x: cumFrqU[x] + cumFrqU[x - 108] + cumFrqU[x - 1132] * 3 + ) + nomnCostD = missingdict( + lambda x: cumFrqD[x] + cumFrqD[x + 108] + cumFrqD[x + 1132] * 3 + ) + nomnCost = missingdict(lambda x: nomnCostU[x] + nomnCostD[x] - widths[x]) + + # Cost-saving per nominal choice, by best default choice. + dfltCostU = missingdict( + lambda x: max(cumMaxU[x], cumMaxU[x - 108] * 2, cumMaxU[x - 1132] * 5) + ) + dfltCostD = missingdict( + lambda x: max(cumMaxD[x], cumMaxD[x + 108] * 2, cumMaxD[x + 1132] * 5) + ) + dfltCost = missingdict(lambda x: max(dfltCostU[x], dfltCostD[x])) + + # Combined cost per nominal choice. + bestCost = missingdict(lambda x: nomnCost[x] - dfltCost[x]) + + # Best nominal. + nominal = min(domain, key=lambda x: bestCost[x]) + + # Work back the best default. + bestC = bestCost[nominal] + dfltC = nomnCost[nominal] - bestCost[nominal] + ends = [] + if dfltC == dfltCostU[nominal]: + starts = [nominal, nominal - 108, nominal - 1132] + for start in starts: + while cumMaxU[start] and cumMaxU[start] == cumMaxU[start - 1]: + start -= 1 + ends.append(start) + else: + starts = [nominal, nominal + 108, nominal + 1132] + for start in starts: + while cumMaxD[start] and cumMaxD[start] == cumMaxD[start + 1]: + start += 1 + ends.append(start) + default = min(ends, key=lambda default: byteCost(widths, default, nominal)) + + return default, nominal + + +def main(args=None): + """Calculate optimum defaultWidthX/nominalWidthX values""" + + import argparse + + parser = argparse.ArgumentParser( + "fonttools cffLib.width", + description=main.__doc__, + ) + parser.add_argument( + "inputs", metavar="FILE", type=str, nargs="+", help="Input TTF files" + ) + parser.add_argument( + "-b", + "--brute-force", + dest="brute", + action="store_true", + help="Use brute-force approach (VERY slow)", + ) + + args = parser.parse_args(args) + + for fontfile in args.inputs: + font = TTFont(fontfile) + hmtx = font["hmtx"] + widths = [m[0] for m in hmtx.metrics.values()] + if args.brute: + default, nominal = optimizeWidthsBruteforce(widths) + else: + default, nominal = optimizeWidths(widths) + print( + "glyphs=%d default=%d nominal=%d byteCost=%d" + % (len(widths), default, nominal, byteCost(widths, default, nominal)) + ) + + +if __name__ == "__main__": + import sys + + if len(sys.argv) == 1: + import doctest + + sys.exit(doctest.testmod().failed) + main() diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/__init__.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/builder.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/builder.py new file mode 100644 index 00000000..6e45e7a8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/colorLib/builder.py @@ -0,0 +1,664 @@ +""" +colorLib.builder: Build COLR/CPAL tables from scratch + +""" + +import collections +import copy +import enum +from functools import partial +from math import ceil, log +from typing import ( + Any, + Dict, + Generator, + Iterable, + List, + Mapping, + Optional, + Sequence, + Tuple, + Type, + TypeVar, + Union, +) +from fontTools.misc.arrayTools import intRect +from fontTools.misc.fixedTools import fixedToFloat +from fontTools.misc.treeTools import build_n_ary_tree +from fontTools.ttLib.tables import C_O_L_R_ +from fontTools.ttLib.tables import C_P_A_L_ +from fontTools.ttLib.tables import _n_a_m_e +from fontTools.ttLib.tables import otTables as ot +from fontTools.ttLib.tables.otTables import ExtendMode, CompositeMode +from .errors import ColorLibError +from .geometry import round_start_circle_stable_containment +from .table_builder import BuildCallback, TableBuilder + + +# TODO move type aliases to colorLib.types? +T = TypeVar("T") +_Kwargs = Mapping[str, Any] +_PaintInput = Union[int, _Kwargs, ot.Paint, Tuple[str, "_PaintInput"]] +_PaintInputList = Sequence[_PaintInput] +_ColorGlyphsDict = Dict[str, Union[_PaintInputList, _PaintInput]] +_ColorGlyphsV0Dict = Dict[str, Sequence[Tuple[str, int]]] +_ClipBoxInput = Union[ + Tuple[int, int, int, int, int], # format 1, variable + Tuple[int, int, int, int], # format 0, non-variable + ot.ClipBox, +] + + +MAX_PAINT_COLR_LAYER_COUNT = 255 +_DEFAULT_ALPHA = 1.0 +_MAX_REUSE_LEN = 32 + + +def _beforeBuildPaintRadialGradient(paint, source): + x0 = source["x0"] + y0 = source["y0"] + r0 = source["r0"] + x1 = source["x1"] + y1 = source["y1"] + r1 = source["r1"] + + # TODO apparently no builder_test confirms this works (?) + + # avoid abrupt change after rounding when c0 is near c1's perimeter + c = round_start_circle_stable_containment((x0, y0), r0, (x1, y1), r1) + x0, y0 = c.centre + r0 = c.radius + + # update source to ensure paint is built with corrected values + source["x0"] = x0 + source["y0"] = y0 + source["r0"] = r0 + source["x1"] = x1 + source["y1"] = y1 + source["r1"] = r1 + + return paint, source + + +def _defaultColorStop(): + colorStop = ot.ColorStop() + colorStop.Alpha = _DEFAULT_ALPHA + return colorStop + + +def _defaultVarColorStop(): + colorStop = ot.VarColorStop() + colorStop.Alpha = _DEFAULT_ALPHA + return colorStop + + +def _defaultColorLine(): + colorLine = ot.ColorLine() + colorLine.Extend = ExtendMode.PAD + return colorLine + + +def _defaultVarColorLine(): + colorLine = ot.VarColorLine() + colorLine.Extend = ExtendMode.PAD + return colorLine + + +def _defaultPaintSolid(): + paint = ot.Paint() + paint.Alpha = _DEFAULT_ALPHA + return paint + + +def _buildPaintCallbacks(): + return { + ( + BuildCallback.BEFORE_BUILD, + ot.Paint, + ot.PaintFormat.PaintRadialGradient, + ): _beforeBuildPaintRadialGradient, + ( + BuildCallback.BEFORE_BUILD, + ot.Paint, + ot.PaintFormat.PaintVarRadialGradient, + ): _beforeBuildPaintRadialGradient, + (BuildCallback.CREATE_DEFAULT, ot.ColorStop): _defaultColorStop, + (BuildCallback.CREATE_DEFAULT, ot.VarColorStop): _defaultVarColorStop, + (BuildCallback.CREATE_DEFAULT, ot.ColorLine): _defaultColorLine, + (BuildCallback.CREATE_DEFAULT, ot.VarColorLine): _defaultVarColorLine, + ( + BuildCallback.CREATE_DEFAULT, + ot.Paint, + ot.PaintFormat.PaintSolid, + ): _defaultPaintSolid, + ( + BuildCallback.CREATE_DEFAULT, + ot.Paint, + ot.PaintFormat.PaintVarSolid, + ): _defaultPaintSolid, + } + + +def populateCOLRv0( + table: ot.COLR, + colorGlyphsV0: _ColorGlyphsV0Dict, + glyphMap: Optional[Mapping[str, int]] = None, +): + """Build v0 color layers and add to existing COLR table. + + Args: + table: a raw ``otTables.COLR()`` object (not ttLib's ``table_C_O_L_R_``). + colorGlyphsV0: map of base glyph names to lists of (layer glyph names, + color palette index) tuples. Can be empty. + glyphMap: a map from glyph names to glyph indices, as returned from + ``TTFont.getReverseGlyphMap()``, to optionally sort base records by GID. + """ + if glyphMap is not None: + colorGlyphItems = sorted( + colorGlyphsV0.items(), key=lambda item: glyphMap[item[0]] + ) + else: + colorGlyphItems = colorGlyphsV0.items() + baseGlyphRecords = [] + layerRecords = [] + for baseGlyph, layers in colorGlyphItems: + baseRec = ot.BaseGlyphRecord() + baseRec.BaseGlyph = baseGlyph + baseRec.FirstLayerIndex = len(layerRecords) + baseRec.NumLayers = len(layers) + baseGlyphRecords.append(baseRec) + + for layerGlyph, paletteIndex in layers: + layerRec = ot.LayerRecord() + layerRec.LayerGlyph = layerGlyph + layerRec.PaletteIndex = paletteIndex + layerRecords.append(layerRec) + + table.BaseGlyphRecordArray = table.LayerRecordArray = None + if baseGlyphRecords: + table.BaseGlyphRecordArray = ot.BaseGlyphRecordArray() + table.BaseGlyphRecordArray.BaseGlyphRecord = baseGlyphRecords + if layerRecords: + table.LayerRecordArray = ot.LayerRecordArray() + table.LayerRecordArray.LayerRecord = layerRecords + table.BaseGlyphRecordCount = len(baseGlyphRecords) + table.LayerRecordCount = len(layerRecords) + + +def buildCOLR( + colorGlyphs: _ColorGlyphsDict, + version: Optional[int] = None, + *, + glyphMap: Optional[Mapping[str, int]] = None, + varStore: Optional[ot.VarStore] = None, + varIndexMap: Optional[ot.DeltaSetIndexMap] = None, + clipBoxes: Optional[Dict[str, _ClipBoxInput]] = None, + allowLayerReuse: bool = True, +) -> C_O_L_R_.table_C_O_L_R_: + """Build COLR table from color layers mapping. + + Args: + + colorGlyphs: map of base glyph name to, either list of (layer glyph name, + color palette index) tuples for COLRv0; or a single ``Paint`` (dict) or + list of ``Paint`` for COLRv1. + version: the version of COLR table. If None, the version is determined + by the presence of COLRv1 paints or variation data (varStore), which + require version 1; otherwise, if all base glyphs use only simple color + layers, version 0 is used. + glyphMap: a map from glyph names to glyph indices, as returned from + TTFont.getReverseGlyphMap(), to optionally sort base records by GID. + varStore: Optional ItemVarationStore for deltas associated with v1 layer. + varIndexMap: Optional DeltaSetIndexMap for deltas associated with v1 layer. + clipBoxes: Optional map of base glyph name to clip box 4- or 5-tuples: + (xMin, yMin, xMax, yMax) or (xMin, yMin, xMax, yMax, varIndexBase). + + Returns: + A new COLR table. + """ + self = C_O_L_R_.table_C_O_L_R_() + + if varStore is not None and version == 0: + raise ValueError("Can't add VarStore to COLRv0") + + if version in (None, 0) and not varStore: + # split color glyphs into v0 and v1 and encode separately + colorGlyphsV0, colorGlyphsV1 = _split_color_glyphs_by_version(colorGlyphs) + if version == 0 and colorGlyphsV1: + raise ValueError("Can't encode COLRv1 glyphs in COLRv0") + else: + # unless explicitly requested for v1 or have variations, in which case + # we encode all color glyph as v1 + colorGlyphsV0, colorGlyphsV1 = {}, colorGlyphs + + colr = ot.COLR() + + populateCOLRv0(colr, colorGlyphsV0, glyphMap) + + colr.LayerList, colr.BaseGlyphList = buildColrV1( + colorGlyphsV1, + glyphMap, + allowLayerReuse=allowLayerReuse, + ) + + if version is None: + version = 1 if (varStore or colorGlyphsV1) else 0 + elif version not in (0, 1): + raise NotImplementedError(version) + self.version = colr.Version = version + + if version == 0: + self.ColorLayers = self._decompileColorLayersV0(colr) + else: + colr.ClipList = buildClipList(clipBoxes) if clipBoxes else None + colr.VarIndexMap = varIndexMap + colr.VarStore = varStore + self.table = colr + + return self + + +def buildClipList(clipBoxes: Dict[str, _ClipBoxInput]) -> ot.ClipList: + clipList = ot.ClipList() + clipList.Format = 1 + clipList.clips = {name: buildClipBox(box) for name, box in clipBoxes.items()} + return clipList + + +def buildClipBox(clipBox: _ClipBoxInput) -> ot.ClipBox: + if isinstance(clipBox, ot.ClipBox): + return clipBox + n = len(clipBox) + clip = ot.ClipBox() + if n not in (4, 5): + raise ValueError(f"Invalid ClipBox: expected 4 or 5 values, found {n}") + clip.xMin, clip.yMin, clip.xMax, clip.yMax = intRect(clipBox[:4]) + clip.Format = int(n == 5) + 1 + if n == 5: + clip.VarIndexBase = int(clipBox[4]) + return clip + + +class ColorPaletteType(enum.IntFlag): + USABLE_WITH_LIGHT_BACKGROUND = 0x0001 + USABLE_WITH_DARK_BACKGROUND = 0x0002 + + @classmethod + def _missing_(cls, value): + # enforce reserved bits + if isinstance(value, int) and (value < 0 or value & 0xFFFC != 0): + raise ValueError(f"{value} is not a valid {cls.__name__}") + return super()._missing_(value) + + +# None, 'abc' or {'en': 'abc', 'de': 'xyz'} +_OptionalLocalizedString = Union[None, str, Dict[str, str]] + + +def buildPaletteLabels( + labels: Iterable[_OptionalLocalizedString], nameTable: _n_a_m_e.table__n_a_m_e +) -> List[Optional[int]]: + return [ + ( + nameTable.addMultilingualName(l, mac=False) + if isinstance(l, dict) + else ( + C_P_A_L_.table_C_P_A_L_.NO_NAME_ID + if l is None + else nameTable.addMultilingualName({"en": l}, mac=False) + ) + ) + for l in labels + ] + + +def buildCPAL( + palettes: Sequence[Sequence[Tuple[float, float, float, float]]], + paletteTypes: Optional[Sequence[ColorPaletteType]] = None, + paletteLabels: Optional[Sequence[_OptionalLocalizedString]] = None, + paletteEntryLabels: Optional[Sequence[_OptionalLocalizedString]] = None, + nameTable: Optional[_n_a_m_e.table__n_a_m_e] = None, +) -> C_P_A_L_.table_C_P_A_L_: + """Build CPAL table from list of color palettes. + + Args: + palettes: list of lists of colors encoded as tuples of (R, G, B, A) floats + in the range [0..1]. + paletteTypes: optional list of ColorPaletteType, one for each palette. + paletteLabels: optional list of palette labels. Each lable can be either: + None (no label), a string (for for default English labels), or a + localized string (as a dict keyed with BCP47 language codes). + paletteEntryLabels: optional list of palette entry labels, one for each + palette entry (see paletteLabels). + nameTable: optional name table where to store palette and palette entry + labels. Required if either paletteLabels or paletteEntryLabels is set. + + Return: + A new CPAL v0 or v1 table, if custom palette types or labels are specified. + """ + if len({len(p) for p in palettes}) != 1: + raise ColorLibError("color palettes have different lengths") + + if (paletteLabels or paletteEntryLabels) and not nameTable: + raise TypeError( + "nameTable is required if palette or palette entries have labels" + ) + + cpal = C_P_A_L_.table_C_P_A_L_() + cpal.numPaletteEntries = len(palettes[0]) + + cpal.palettes = [] + for i, palette in enumerate(palettes): + colors = [] + for j, color in enumerate(palette): + if not isinstance(color, tuple) or len(color) != 4: + raise ColorLibError( + f"In palette[{i}][{j}]: expected (R, G, B, A) tuple, got {color!r}" + ) + if any(v > 1 or v < 0 for v in color): + raise ColorLibError( + f"palette[{i}][{j}] has invalid out-of-range [0..1] color: {color!r}" + ) + # input colors are RGBA, CPAL encodes them as BGRA + red, green, blue, alpha = color + colors.append( + C_P_A_L_.Color(*(round(v * 255) for v in (blue, green, red, alpha))) + ) + cpal.palettes.append(colors) + + if any(v is not None for v in (paletteTypes, paletteLabels, paletteEntryLabels)): + cpal.version = 1 + + if paletteTypes is not None: + if len(paletteTypes) != len(palettes): + raise ColorLibError( + f"Expected {len(palettes)} paletteTypes, got {len(paletteTypes)}" + ) + cpal.paletteTypes = [ColorPaletteType(t).value for t in paletteTypes] + else: + cpal.paletteTypes = [C_P_A_L_.table_C_P_A_L_.DEFAULT_PALETTE_TYPE] * len( + palettes + ) + + if paletteLabels is not None: + if len(paletteLabels) != len(palettes): + raise ColorLibError( + f"Expected {len(palettes)} paletteLabels, got {len(paletteLabels)}" + ) + cpal.paletteLabels = buildPaletteLabels(paletteLabels, nameTable) + else: + cpal.paletteLabels = [C_P_A_L_.table_C_P_A_L_.NO_NAME_ID] * len(palettes) + + if paletteEntryLabels is not None: + if len(paletteEntryLabels) != cpal.numPaletteEntries: + raise ColorLibError( + f"Expected {cpal.numPaletteEntries} paletteEntryLabels, " + f"got {len(paletteEntryLabels)}" + ) + cpal.paletteEntryLabels = buildPaletteLabels(paletteEntryLabels, nameTable) + else: + cpal.paletteEntryLabels = [ + C_P_A_L_.table_C_P_A_L_.NO_NAME_ID + ] * cpal.numPaletteEntries + else: + cpal.version = 0 + + return cpal + + +# COLR v1 tables +# See draft proposal at: https://github.com/googlefonts/colr-gradients-spec + + +def _is_colrv0_layer(layer: Any) -> bool: + # Consider as COLRv0 layer any sequence of length 2 (be it tuple or list) in which + # the first element is a str (the layerGlyph) and the second element is an int + # (CPAL paletteIndex). + # https://github.com/googlefonts/ufo2ft/issues/426 + try: + layerGlyph, paletteIndex = layer + except (TypeError, ValueError): + return False + else: + return isinstance(layerGlyph, str) and isinstance(paletteIndex, int) + + +def _split_color_glyphs_by_version( + colorGlyphs: _ColorGlyphsDict, +) -> Tuple[_ColorGlyphsV0Dict, _ColorGlyphsDict]: + colorGlyphsV0 = {} + colorGlyphsV1 = {} + for baseGlyph, layers in colorGlyphs.items(): + if all(_is_colrv0_layer(l) for l in layers): + colorGlyphsV0[baseGlyph] = layers + else: + colorGlyphsV1[baseGlyph] = layers + + # sanity check + assert set(colorGlyphs) == (set(colorGlyphsV0) | set(colorGlyphsV1)) + + return colorGlyphsV0, colorGlyphsV1 + + +def _reuse_ranges(num_layers: int) -> Generator[Tuple[int, int], None, None]: + # TODO feels like something itertools might have already + for lbound in range(num_layers): + # Reuse of very large #s of layers is relatively unlikely + # +2: we want sequences of at least 2 + # otData handles single-record duplication + for ubound in range( + lbound + 2, min(num_layers + 1, lbound + 2 + _MAX_REUSE_LEN) + ): + yield (lbound, ubound) + + +class LayerReuseCache: + reusePool: Mapping[Tuple[Any, ...], int] + tuples: Mapping[int, Tuple[Any, ...]] + keepAlive: List[ot.Paint] # we need id to remain valid + + def __init__(self): + self.reusePool = {} + self.tuples = {} + self.keepAlive = [] + + def _paint_tuple(self, paint: ot.Paint): + # start simple, who even cares about cyclic graphs or interesting field types + def _tuple_safe(value): + if isinstance(value, enum.Enum): + return value + elif hasattr(value, "__dict__"): + return tuple( + (k, _tuple_safe(v)) for k, v in sorted(value.__dict__.items()) + ) + elif isinstance(value, collections.abc.MutableSequence): + return tuple(_tuple_safe(e) for e in value) + return value + + # Cache the tuples for individual Paint instead of the whole sequence + # because the seq could be a transient slice + result = self.tuples.get(id(paint), None) + if result is None: + result = _tuple_safe(paint) + self.tuples[id(paint)] = result + self.keepAlive.append(paint) + return result + + def _as_tuple(self, paints: Sequence[ot.Paint]) -> Tuple[Any, ...]: + return tuple(self._paint_tuple(p) for p in paints) + + def try_reuse(self, layers: List[ot.Paint]) -> List[ot.Paint]: + found_reuse = True + while found_reuse: + found_reuse = False + + ranges = sorted( + _reuse_ranges(len(layers)), + key=lambda t: (t[1] - t[0], t[1], t[0]), + reverse=True, + ) + for lbound, ubound in ranges: + reuse_lbound = self.reusePool.get( + self._as_tuple(layers[lbound:ubound]), -1 + ) + if reuse_lbound == -1: + continue + new_slice = ot.Paint() + new_slice.Format = int(ot.PaintFormat.PaintColrLayers) + new_slice.NumLayers = ubound - lbound + new_slice.FirstLayerIndex = reuse_lbound + layers = layers[:lbound] + [new_slice] + layers[ubound:] + found_reuse = True + break + return layers + + def add(self, layers: List[ot.Paint], first_layer_index: int): + for lbound, ubound in _reuse_ranges(len(layers)): + self.reusePool[self._as_tuple(layers[lbound:ubound])] = ( + lbound + first_layer_index + ) + + +class LayerListBuilder: + layers: List[ot.Paint] + cache: LayerReuseCache + allowLayerReuse: bool + + def __init__(self, *, allowLayerReuse=True): + self.layers = [] + if allowLayerReuse: + self.cache = LayerReuseCache() + else: + self.cache = None + + # We need to intercept construction of PaintColrLayers + callbacks = _buildPaintCallbacks() + callbacks[ + ( + BuildCallback.BEFORE_BUILD, + ot.Paint, + ot.PaintFormat.PaintColrLayers, + ) + ] = self._beforeBuildPaintColrLayers + self.tableBuilder = TableBuilder(callbacks) + + # COLR layers is unusual in that it modifies shared state + # so we need a callback into an object + def _beforeBuildPaintColrLayers(self, dest, source): + # Sketchy gymnastics: a sequence input will have dropped it's layers + # into NumLayers; get it back + if isinstance(source.get("NumLayers", None), collections.abc.Sequence): + layers = source["NumLayers"] + else: + layers = source["Layers"] + + # Convert maps seqs or whatever into typed objects + layers = [self.buildPaint(l) for l in layers] + + # No reason to have a colr layers with just one entry + if len(layers) == 1: + return layers[0], {} + + if self.cache is not None: + # Look for reuse, with preference to longer sequences + # This may make the layer list smaller + layers = self.cache.try_reuse(layers) + + # The layer list is now final; if it's too big we need to tree it + is_tree = len(layers) > MAX_PAINT_COLR_LAYER_COUNT + layers = build_n_ary_tree(layers, n=MAX_PAINT_COLR_LAYER_COUNT) + + # We now have a tree of sequences with Paint leaves. + # Convert the sequences into PaintColrLayers. + def listToColrLayers(layer): + if isinstance(layer, collections.abc.Sequence): + return self.buildPaint( + { + "Format": ot.PaintFormat.PaintColrLayers, + "Layers": [listToColrLayers(l) for l in layer], + } + ) + return layer + + layers = [listToColrLayers(l) for l in layers] + + # No reason to have a colr layers with just one entry + if len(layers) == 1: + return layers[0], {} + + paint = ot.Paint() + paint.Format = int(ot.PaintFormat.PaintColrLayers) + paint.NumLayers = len(layers) + paint.FirstLayerIndex = len(self.layers) + self.layers.extend(layers) + + # Register our parts for reuse provided we aren't a tree + # If we are a tree the leaves registered for reuse and that will suffice + if self.cache is not None and not is_tree: + self.cache.add(layers, paint.FirstLayerIndex) + + # we've fully built dest; empty source prevents generalized build from kicking in + return paint, {} + + def buildPaint(self, paint: _PaintInput) -> ot.Paint: + return self.tableBuilder.build(ot.Paint, paint) + + def build(self) -> Optional[ot.LayerList]: + if not self.layers: + return None + layers = ot.LayerList() + layers.LayerCount = len(self.layers) + layers.Paint = self.layers + return layers + + +def buildBaseGlyphPaintRecord( + baseGlyph: str, layerBuilder: LayerListBuilder, paint: _PaintInput +) -> ot.BaseGlyphList: + self = ot.BaseGlyphPaintRecord() + self.BaseGlyph = baseGlyph + self.Paint = layerBuilder.buildPaint(paint) + return self + + +def _format_glyph_errors(errors: Mapping[str, Exception]) -> str: + lines = [] + for baseGlyph, error in sorted(errors.items()): + lines.append(f" {baseGlyph} => {type(error).__name__}: {error}") + return "\n".join(lines) + + +def buildColrV1( + colorGlyphs: _ColorGlyphsDict, + glyphMap: Optional[Mapping[str, int]] = None, + *, + allowLayerReuse: bool = True, +) -> Tuple[Optional[ot.LayerList], ot.BaseGlyphList]: + if glyphMap is not None: + colorGlyphItems = sorted( + colorGlyphs.items(), key=lambda item: glyphMap[item[0]] + ) + else: + colorGlyphItems = colorGlyphs.items() + + errors = {} + baseGlyphs = [] + layerBuilder = LayerListBuilder(allowLayerReuse=allowLayerReuse) + for baseGlyph, paint in colorGlyphItems: + try: + baseGlyphs.append(buildBaseGlyphPaintRecord(baseGlyph, layerBuilder, paint)) + + except (ColorLibError, OverflowError, ValueError, TypeError) as e: + errors[baseGlyph] = e + + if errors: + failed_glyphs = _format_glyph_errors(errors) + exc = ColorLibError(f"Failed to build BaseGlyphList:\n{failed_glyphs}") + exc.errors = errors + raise exc from next(iter(errors.values())) + + layers = layerBuilder.build() + glyphs = ot.BaseGlyphList() + glyphs.BaseGlyphCount = len(baseGlyphs) + glyphs.BaseGlyphPaintRecord = baseGlyphs + return (layers, glyphs) diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/errors.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/errors.py new file mode 100644 index 00000000..18cbebba --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/colorLib/errors.py @@ -0,0 +1,2 @@ +class ColorLibError(Exception): + pass diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/geometry.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/geometry.py new file mode 100644 index 00000000..1ce161bf --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/colorLib/geometry.py @@ -0,0 +1,143 @@ +"""Helpers for manipulating 2D points and vectors in COLR table.""" + +from math import copysign, cos, hypot, isclose, pi +from fontTools.misc.roundTools import otRound + + +def _vector_between(origin, target): + return (target[0] - origin[0], target[1] - origin[1]) + + +def _round_point(pt): + return (otRound(pt[0]), otRound(pt[1])) + + +def _unit_vector(vec): + length = hypot(*vec) + if length == 0: + return None + return (vec[0] / length, vec[1] / length) + + +_CIRCLE_INSIDE_TOLERANCE = 1e-4 + + +# The unit vector's X and Y components are respectively +# U = (cos(α), sin(α)) +# where α is the angle between the unit vector and the positive x axis. +_UNIT_VECTOR_THRESHOLD = cos(3 / 8 * pi) # == sin(1/8 * pi) == 0.38268343236508984 + + +def _rounding_offset(direction): + # Return 2-tuple of -/+ 1.0 or 0.0 approximately based on the direction vector. + # We divide the unit circle in 8 equal slices oriented towards the cardinal + # (N, E, S, W) and intermediate (NE, SE, SW, NW) directions. To each slice we + # map one of the possible cases: -1, 0, +1 for either X and Y coordinate. + # E.g. Return (+1.0, -1.0) if unit vector is oriented towards SE, or + # (-1.0, 0.0) if it's pointing West, etc. + uv = _unit_vector(direction) + if not uv: + return (0, 0) + + result = [] + for uv_component in uv: + if -_UNIT_VECTOR_THRESHOLD <= uv_component < _UNIT_VECTOR_THRESHOLD: + # unit vector component near 0: direction almost orthogonal to the + # direction of the current axis, thus keep coordinate unchanged + result.append(0) + else: + # nudge coord by +/- 1.0 in direction of unit vector + result.append(copysign(1.0, uv_component)) + return tuple(result) + + +class Circle: + def __init__(self, centre, radius): + self.centre = centre + self.radius = radius + + def __repr__(self): + return f"Circle(centre={self.centre}, radius={self.radius})" + + def round(self): + return Circle(_round_point(self.centre), otRound(self.radius)) + + def inside(self, outer_circle, tolerance=_CIRCLE_INSIDE_TOLERANCE): + dist = self.radius + hypot(*_vector_between(self.centre, outer_circle.centre)) + return ( + isclose(outer_circle.radius, dist, rel_tol=_CIRCLE_INSIDE_TOLERANCE) + or outer_circle.radius > dist + ) + + def concentric(self, other): + return self.centre == other.centre + + def move(self, dx, dy): + self.centre = (self.centre[0] + dx, self.centre[1] + dy) + + +def round_start_circle_stable_containment(c0, r0, c1, r1): + """Round start circle so that it stays inside/outside end circle after rounding. + + The rounding of circle coordinates to integers may cause an abrupt change + if the start circle c0 is so close to the end circle c1's perimiter that + it ends up falling outside (or inside) as a result of the rounding. + To keep the gradient unchanged, we nudge it in the right direction. + + See: + https://github.com/googlefonts/colr-gradients-spec/issues/204 + https://github.com/googlefonts/picosvg/issues/158 + """ + start, end = Circle(c0, r0), Circle(c1, r1) + + inside_before_round = start.inside(end) + + round_start = start.round() + round_end = end.round() + inside_after_round = round_start.inside(round_end) + + if inside_before_round == inside_after_round: + return round_start + elif inside_after_round: + # start was outside before rounding: we need to push start away from end + direction = _vector_between(round_end.centre, round_start.centre) + radius_delta = +1.0 + else: + # start was inside before rounding: we need to push start towards end + direction = _vector_between(round_start.centre, round_end.centre) + radius_delta = -1.0 + dx, dy = _rounding_offset(direction) + + # At most 2 iterations ought to be enough to converge. Before the loop, we + # know the start circle didn't keep containment after normal rounding; thus + # we continue adjusting by -/+ 1.0 until containment is restored. + # Normal rounding can at most move each coordinates -/+0.5; in the worst case + # both the start and end circle's centres and radii will be rounded in opposite + # directions, e.g. when they move along a 45 degree diagonal: + # c0 = (1.5, 1.5) ===> (2.0, 2.0) + # r0 = 0.5 ===> 1.0 + # c1 = (0.499, 0.499) ===> (0.0, 0.0) + # r1 = 2.499 ===> 2.0 + # In this example, the relative distance between the circles, calculated + # as r1 - (r0 + distance(c0, c1)) is initially 0.57437 (c0 is inside c1), and + # -1.82842 after rounding (c0 is now outside c1). Nudging c0 by -1.0 on both + # x and y axes moves it towards c1 by hypot(-1.0, -1.0) = 1.41421. Two of these + # moves cover twice that distance, which is enough to restore containment. + max_attempts = 2 + for _ in range(max_attempts): + if round_start.concentric(round_end): + # can't move c0 towards c1 (they are the same), so we change the radius + round_start.radius += radius_delta + assert round_start.radius >= 0 + else: + round_start.move(dx, dy) + if inside_before_round == round_start.inside(round_end): + break + else: # likely a bug + raise AssertionError( + f"Rounding circle {start} " + f"{'inside' if inside_before_round else 'outside'} " + f"{end} failed after {max_attempts} attempts!" + ) + + return round_start diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/table_builder.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/table_builder.py new file mode 100644 index 00000000..f1e182c4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/colorLib/table_builder.py @@ -0,0 +1,223 @@ +""" +colorLib.table_builder: Generic helper for filling in BaseTable derivatives from tuples and maps and such. + +""" + +import collections +import enum +from fontTools.ttLib.tables.otBase import ( + BaseTable, + FormatSwitchingBaseTable, + UInt8FormatSwitchingBaseTable, +) +from fontTools.ttLib.tables.otConverters import ( + ComputedInt, + SimpleValue, + Struct, + Short, + UInt8, + UShort, + IntValue, + FloatValue, + OptionalValue, +) +from fontTools.misc.roundTools import otRound + + +class BuildCallback(enum.Enum): + """Keyed on (BEFORE_BUILD, class[, Format if available]). + Receives (dest, source). + Should return (dest, source), which can be new objects. + """ + + BEFORE_BUILD = enum.auto() + + """Keyed on (AFTER_BUILD, class[, Format if available]). + Receives (dest). + Should return dest, which can be a new object. + """ + AFTER_BUILD = enum.auto() + + """Keyed on (CREATE_DEFAULT, class[, Format if available]). + Receives no arguments. + Should return a new instance of class. + """ + CREATE_DEFAULT = enum.auto() + + +def _assignable(convertersByName): + return {k: v for k, v in convertersByName.items() if not isinstance(v, ComputedInt)} + + +def _isNonStrSequence(value): + return isinstance(value, collections.abc.Sequence) and not isinstance(value, str) + + +def _split_format(cls, source): + if _isNonStrSequence(source): + assert len(source) > 0, f"{cls} needs at least format from {source}" + fmt, remainder = source[0], source[1:] + elif isinstance(source, collections.abc.Mapping): + assert "Format" in source, f"{cls} needs at least Format from {source}" + remainder = source.copy() + fmt = remainder.pop("Format") + else: + raise ValueError(f"Not sure how to populate {cls} from {source}") + + assert isinstance( + fmt, collections.abc.Hashable + ), f"{cls} Format is not hashable: {fmt!r}" + assert fmt in cls.convertersByName, f"{cls} invalid Format: {fmt!r}" + + return fmt, remainder + + +class TableBuilder: + """ + Helps to populate things derived from BaseTable from maps, tuples, etc. + + A table of lifecycle callbacks may be provided to add logic beyond what is possible + based on otData info for the target class. See BuildCallbacks. + """ + + def __init__(self, callbackTable=None): + if callbackTable is None: + callbackTable = {} + self._callbackTable = callbackTable + + def _convert(self, dest, field, converter, value): + enumClass = getattr(converter, "enumClass", None) + + if enumClass: + if isinstance(value, enumClass): + pass + elif isinstance(value, str): + try: + value = getattr(enumClass, value.upper()) + except AttributeError: + raise ValueError(f"{value} is not a valid {enumClass}") + else: + value = enumClass(value) + + elif isinstance(converter, IntValue): + value = otRound(value) + elif isinstance(converter, FloatValue): + value = float(value) + + elif isinstance(converter, Struct): + if converter.repeat: + if _isNonStrSequence(value): + value = [self.build(converter.tableClass, v) for v in value] + else: + value = [self.build(converter.tableClass, value)] + setattr(dest, converter.repeat, len(value)) + else: + value = self.build(converter.tableClass, value) + elif callable(converter): + value = converter(value) + + setattr(dest, field, value) + + def build(self, cls, source): + assert issubclass(cls, BaseTable) + + if isinstance(source, cls): + return source + + callbackKey = (cls,) + fmt = None + if issubclass(cls, FormatSwitchingBaseTable): + fmt, source = _split_format(cls, source) + callbackKey = (cls, fmt) + + dest = self._callbackTable.get( + (BuildCallback.CREATE_DEFAULT,) + callbackKey, lambda: cls() + )() + assert isinstance(dest, cls) + + convByName = _assignable(cls.convertersByName) + skippedFields = set() + + # For format switchers we need to resolve converters based on format + if issubclass(cls, FormatSwitchingBaseTable): + dest.Format = fmt + convByName = _assignable(convByName[dest.Format]) + skippedFields.add("Format") + + # Convert sequence => mapping so before thunk only has to handle one format + if _isNonStrSequence(source): + # Sequence (typically list or tuple) assumed to match fields in declaration order + assert len(source) <= len( + convByName + ), f"Sequence of {len(source)} too long for {cls}; expected <= {len(convByName)} values" + source = dict(zip(convByName.keys(), source)) + + dest, source = self._callbackTable.get( + (BuildCallback.BEFORE_BUILD,) + callbackKey, lambda d, s: (d, s) + )(dest, source) + + if isinstance(source, collections.abc.Mapping): + for field, value in source.items(): + if field in skippedFields: + continue + converter = convByName.get(field, None) + if not converter: + raise ValueError( + f"Unrecognized field {field} for {cls}; expected one of {sorted(convByName.keys())}" + ) + self._convert(dest, field, converter, value) + else: + # let's try as a 1-tuple + dest = self.build(cls, (source,)) + + for field, conv in convByName.items(): + if not hasattr(dest, field) and isinstance(conv, OptionalValue): + setattr(dest, field, conv.DEFAULT) + + dest = self._callbackTable.get( + (BuildCallback.AFTER_BUILD,) + callbackKey, lambda d: d + )(dest) + + return dest + + +class TableUnbuilder: + def __init__(self, callbackTable=None): + if callbackTable is None: + callbackTable = {} + self._callbackTable = callbackTable + + def unbuild(self, table): + assert isinstance(table, BaseTable) + + source = {} + + callbackKey = (type(table),) + if isinstance(table, FormatSwitchingBaseTable): + source["Format"] = int(table.Format) + callbackKey += (table.Format,) + + for converter in table.getConverters(): + if isinstance(converter, ComputedInt): + continue + value = getattr(table, converter.name) + + enumClass = getattr(converter, "enumClass", None) + if enumClass: + source[converter.name] = value.name.lower() + elif isinstance(converter, Struct): + if converter.repeat: + source[converter.name] = [self.unbuild(v) for v in value] + else: + source[converter.name] = self.unbuild(value) + elif isinstance(converter, SimpleValue): + # "simple" values (e.g. int, float, str) need no further un-building + source[converter.name] = value + else: + raise NotImplementedError( + "Don't know how unbuild {value!r} with {converter!r}" + ) + + source = self._callbackTable.get(callbackKey, lambda s: s)(source) + + return source diff --git a/venv/lib/python3.10/site-packages/fontTools/colorLib/unbuilder.py b/venv/lib/python3.10/site-packages/fontTools/colorLib/unbuilder.py new file mode 100644 index 00000000..ac243550 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/colorLib/unbuilder.py @@ -0,0 +1,81 @@ +from fontTools.ttLib.tables import otTables as ot +from .table_builder import TableUnbuilder + + +def unbuildColrV1(layerList, baseGlyphList): + layers = [] + if layerList: + layers = layerList.Paint + unbuilder = LayerListUnbuilder(layers) + return { + rec.BaseGlyph: unbuilder.unbuildPaint(rec.Paint) + for rec in baseGlyphList.BaseGlyphPaintRecord + } + + +def _flatten_layers(lst): + for paint in lst: + if paint["Format"] == ot.PaintFormat.PaintColrLayers: + yield from _flatten_layers(paint["Layers"]) + else: + yield paint + + +class LayerListUnbuilder: + def __init__(self, layers): + self.layers = layers + + callbacks = { + ( + ot.Paint, + ot.PaintFormat.PaintColrLayers, + ): self._unbuildPaintColrLayers, + } + self.tableUnbuilder = TableUnbuilder(callbacks) + + def unbuildPaint(self, paint): + assert isinstance(paint, ot.Paint) + return self.tableUnbuilder.unbuild(paint) + + def _unbuildPaintColrLayers(self, source): + assert source["Format"] == ot.PaintFormat.PaintColrLayers + + layers = list( + _flatten_layers( + [ + self.unbuildPaint(childPaint) + for childPaint in self.layers[ + source["FirstLayerIndex"] : source["FirstLayerIndex"] + + source["NumLayers"] + ] + ] + ) + ) + + if len(layers) == 1: + return layers[0] + + return {"Format": source["Format"], "Layers": layers} + + +if __name__ == "__main__": + from pprint import pprint + import sys + from fontTools.ttLib import TTFont + + try: + fontfile = sys.argv[1] + except IndexError: + sys.exit("usage: fonttools colorLib.unbuilder FONTFILE") + + font = TTFont(fontfile) + colr = font["COLR"] + if colr.version < 1: + sys.exit(f"error: No COLR table version=1 found in {fontfile}") + + colorGlyphs = unbuildColrV1( + colr.table.LayerList, + colr.table.BaseGlyphList, + ) + + pprint(colorGlyphs) diff --git a/venv/lib/python3.10/site-packages/fontTools/config/__init__.py b/venv/lib/python3.10/site-packages/fontTools/config/__init__.py new file mode 100644 index 00000000..41ab8f75 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/config/__init__.py @@ -0,0 +1,75 @@ +""" +Define all configuration options that can affect the working of fontTools +modules. E.g. optimization levels of varLib IUP, otlLib GPOS compression level, +etc. If this file gets too big, split it into smaller files per-module. + +An instance of the Config class can be attached to a TTFont object, so that +the various modules can access their configuration options from it. +""" + +from textwrap import dedent + +from fontTools.misc.configTools import * + + +class Config(AbstractConfig): + options = Options() + + +OPTIONS = Config.options + + +Config.register_option( + name="fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL", + help=dedent( + """\ + GPOS Lookup type 2 (PairPos) compression level: + 0 = do not attempt to compact PairPos lookups; + 1 to 8 = create at most 1 to 8 new subtables for each existing + subtable, provided that it would yield a 50%% file size saving; + 9 = create as many new subtables as needed to yield a file size saving. + Default: 0. + + This compaction aims to save file size, by splitting large class + kerning subtables (Format 2) that contain many zero values into + smaller and denser subtables. It's a trade-off between the overhead + of several subtables versus the sparseness of one big subtable. + + See the pull request: https://github.com/fonttools/fonttools/pull/2326 + """ + ), + default=0, + parse=int, + validate=lambda v: v in range(10), +) + +Config.register_option( + name="fontTools.ttLib.tables.otBase:USE_HARFBUZZ_REPACKER", + help=dedent( + """\ + FontTools tries to use the HarfBuzz Repacker to serialize GPOS/GSUB tables + if the uharfbuzz python bindings are importable, otherwise falls back to its + slower, less efficient serializer. Set to False to always use the latter. + Set to True to explicitly request the HarfBuzz Repacker (will raise an + error if uharfbuzz cannot be imported). + """ + ), + default=None, + parse=Option.parse_optional_bool, + validate=Option.validate_optional_bool, +) + +Config.register_option( + name="fontTools.otlLib.builder:WRITE_GPOS7", + help=dedent( + """\ + macOS before 13.2 didn’t support GPOS LookupType 7 (non-chaining + ContextPos lookups), so FontTools.otlLib.builder disables a file size + optimisation that would use LookupType 7 instead of 8 when there is no + chaining (no prefix or suffix). Set to True to enable the optimization. + """ + ), + default=False, + parse=Option.parse_optional_bool, + validate=Option.validate_optional_bool, +) diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/__init__.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/__init__.py new file mode 100644 index 00000000..4ae6356e --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .cu2qu import * diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/__main__.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/__main__.py new file mode 100644 index 00000000..5205ffee --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/__main__.py @@ -0,0 +1,6 @@ +import sys +from .cli import _main as main + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/benchmark.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/benchmark.py new file mode 100644 index 00000000..007f75d8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/benchmark.py @@ -0,0 +1,54 @@ +"""Benchmark the cu2qu algorithm performance.""" + +from .cu2qu import * +import random +import timeit + +MAX_ERR = 0.05 + + +def generate_curve(): + return [ + tuple(float(random.randint(0, 2048)) for coord in range(2)) + for point in range(4) + ] + + +def setup_curve_to_quadratic(): + return generate_curve(), MAX_ERR + + +def setup_curves_to_quadratic(): + num_curves = 3 + return ([generate_curve() for curve in range(num_curves)], [MAX_ERR] * num_curves) + + +def run_benchmark(module, function, setup_suffix="", repeat=5, number=1000): + setup_func = "setup_" + function + if setup_suffix: + print("%s with %s:" % (function, setup_suffix), end="") + setup_func += "_" + setup_suffix + else: + print("%s:" % function, end="") + + def wrapper(function, setup_func): + function = globals()[function] + setup_func = globals()[setup_func] + + def wrapped(): + return function(*setup_func()) + + return wrapped + + results = timeit.repeat(wrapper(function, setup_func), repeat=repeat, number=number) + print("\t%5.1fus" % (min(results) * 1000000.0 / number)) + + +def main(): + run_benchmark("cu2qu", "curve_to_quadratic") + run_benchmark("cu2qu", "curves_to_quadratic") + + +if __name__ == "__main__": + random.seed(1) + main() diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/cli.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cli.py new file mode 100644 index 00000000..ddc64502 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cli.py @@ -0,0 +1,198 @@ +import os +import argparse +import logging +import shutil +import multiprocessing as mp +from contextlib import closing +from functools import partial + +import fontTools +from .ufo import font_to_quadratic, fonts_to_quadratic + +ufo_module = None +try: + import ufoLib2 as ufo_module +except ImportError: + try: + import defcon as ufo_module + except ImportError as e: + pass + + +logger = logging.getLogger("fontTools.cu2qu") + + +def _cpu_count(): + try: + return mp.cpu_count() + except NotImplementedError: # pragma: no cover + return 1 + + +def open_ufo(path): + if hasattr(ufo_module.Font, "open"): # ufoLib2 + return ufo_module.Font.open(path) + return ufo_module.Font(path) # defcon + + +def _font_to_quadratic(input_path, output_path=None, **kwargs): + ufo = open_ufo(input_path) + logger.info("Converting curves for %s", input_path) + if font_to_quadratic(ufo, **kwargs): + logger.info("Saving %s", output_path) + if output_path: + ufo.save(output_path) + else: + ufo.save() # save in-place + elif output_path: + _copytree(input_path, output_path) + + +def _samepath(path1, path2): + # TODO on python3+, there's os.path.samefile + path1 = os.path.normcase(os.path.abspath(os.path.realpath(path1))) + path2 = os.path.normcase(os.path.abspath(os.path.realpath(path2))) + return path1 == path2 + + +def _copytree(input_path, output_path): + if _samepath(input_path, output_path): + logger.debug("input and output paths are the same file; skipped copy") + return + if os.path.exists(output_path): + shutil.rmtree(output_path) + shutil.copytree(input_path, output_path) + + +def _main(args=None): + """Convert a UFO font from cubic to quadratic curves""" + parser = argparse.ArgumentParser(prog="cu2qu") + parser.add_argument("--version", action="version", version=fontTools.__version__) + parser.add_argument( + "infiles", + nargs="+", + metavar="INPUT", + help="one or more input UFO source file(s).", + ) + parser.add_argument("-v", "--verbose", action="count", default=0) + parser.add_argument( + "-e", + "--conversion-error", + type=float, + metavar="ERROR", + default=None, + help="maxiumum approximation error measured in EM (default: 0.001)", + ) + parser.add_argument( + "-m", + "--mixed", + default=False, + action="store_true", + help="whether to used mixed quadratic and cubic curves", + ) + parser.add_argument( + "--keep-direction", + dest="reverse_direction", + action="store_false", + help="do not reverse the contour direction", + ) + + mode_parser = parser.add_mutually_exclusive_group() + mode_parser.add_argument( + "-i", + "--interpolatable", + action="store_true", + help="whether curve conversion should keep interpolation compatibility", + ) + mode_parser.add_argument( + "-j", + "--jobs", + type=int, + nargs="?", + default=1, + const=_cpu_count(), + metavar="N", + help="Convert using N multiple processes (default: %(default)s)", + ) + + output_parser = parser.add_mutually_exclusive_group() + output_parser.add_argument( + "-o", + "--output-file", + default=None, + metavar="OUTPUT", + help=( + "output filename for the converted UFO. By default fonts are " + "modified in place. This only works with a single input." + ), + ) + output_parser.add_argument( + "-d", + "--output-dir", + default=None, + metavar="DIRECTORY", + help="output directory where to save converted UFOs", + ) + + options = parser.parse_args(args) + + if ufo_module is None: + parser.error("Either ufoLib2 or defcon are required to run this script.") + + if not options.verbose: + level = "WARNING" + elif options.verbose == 1: + level = "INFO" + else: + level = "DEBUG" + logging.basicConfig(level=level) + + if len(options.infiles) > 1 and options.output_file: + parser.error("-o/--output-file can't be used with multile inputs") + + if options.output_dir: + output_dir = options.output_dir + if not os.path.exists(output_dir): + os.mkdir(output_dir) + elif not os.path.isdir(output_dir): + parser.error("'%s' is not a directory" % output_dir) + output_paths = [ + os.path.join(output_dir, os.path.basename(p)) for p in options.infiles + ] + elif options.output_file: + output_paths = [options.output_file] + else: + # save in-place + output_paths = [None] * len(options.infiles) + + kwargs = dict( + dump_stats=options.verbose > 0, + max_err_em=options.conversion_error, + reverse_direction=options.reverse_direction, + all_quadratic=False if options.mixed else True, + ) + + if options.interpolatable: + logger.info("Converting curves compatibly") + ufos = [open_ufo(infile) for infile in options.infiles] + if fonts_to_quadratic(ufos, **kwargs): + for ufo, output_path in zip(ufos, output_paths): + logger.info("Saving %s", output_path) + if output_path: + ufo.save(output_path) + else: + ufo.save() + else: + for input_path, output_path in zip(options.infiles, output_paths): + if output_path: + _copytree(input_path, output_path) + else: + jobs = min(len(options.infiles), options.jobs) if options.jobs > 1 else 1 + if jobs > 1: + func = partial(_font_to_quadratic, **kwargs) + logger.info("Running %d parallel processes", jobs) + with closing(mp.Pool(jobs)) as pool: + pool.starmap(func, zip(options.infiles, output_paths)) + else: + for input_path, output_path in zip(options.infiles, output_paths): + _font_to_quadratic(input_path, output_path, **kwargs) diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.c b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.c new file mode 100644 index 00000000..bd33633b --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.c @@ -0,0 +1,14915 @@ +/* Generated by Cython 3.0.10 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "define_macros": [ + [ + "CYTHON_TRACE_NOGIL", + "1" + ] + ], + "name": "fontTools.cu2qu.cu2qu", + "sources": [ + "Lib/fontTools/cu2qu/cu2qu.py" + ] + }, + "module_name": "fontTools.cu2qu.cu2qu" +} +END: Cython Metadata */ + +#ifndef PY_SSIZE_T_CLEAN +#define PY_SSIZE_T_CLEAN +#endif /* PY_SSIZE_T_CLEAN */ +#if defined(CYTHON_LIMITED_API) && 0 + #ifndef Py_LIMITED_API + #if CYTHON_LIMITED_API+0 > 0x03030000 + #define Py_LIMITED_API CYTHON_LIMITED_API + #else + #define Py_LIMITED_API 0x03030000 + #endif + #endif +#endif + +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.7+ or Python 3.3+. +#else +#if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API +#define __PYX_EXTRA_ABI_MODULE_NAME "limited" +#else +#define __PYX_EXTRA_ABI_MODULE_NAME "" +#endif +#define CYTHON_ABI "3_0_10" __PYX_EXTRA_ABI_MODULE_NAME +#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI +#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." +#define CYTHON_HEX_VERSION 0x03000AF0 +#define CYTHON_FUTURE_DIVISION 1 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #define HAVE_LONG_LONG +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX +#if defined(GRAALVM_PYTHON) + /* For very preliminary testing purposes. Most variables are set the same as PyPy. + The existence of this section does not imply that anything works or is even tested */ + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_LIMITED_API 0 + #define CYTHON_COMPILING_IN_GRAAL 1 + #define CYTHON_COMPILING_IN_NOGIL 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL 0 + #undef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) + #endif + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 1 + #undef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 +#elif defined(PYPY_VERSION) + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_LIMITED_API 0 + #define CYTHON_COMPILING_IN_GRAAL 0 + #define CYTHON_COMPILING_IN_NOGIL 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #ifndef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL 0 + #undef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) + #endif + #if PY_VERSION_HEX < 0x03090000 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) + #define CYTHON_PEP489_MULTI_PHASE_INIT 1 + #endif + #undef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00) + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 +#elif defined(CYTHON_LIMITED_API) + #ifdef Py_LIMITED_API + #undef __PYX_LIMITED_VERSION_HEX + #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API + #endif + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_LIMITED_API 1 + #define CYTHON_COMPILING_IN_GRAAL 0 + #define CYTHON_COMPILING_IN_NOGIL 0 + #undef CYTHON_CLINE_IN_TRACEBACK + #define CYTHON_CLINE_IN_TRACEBACK 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 1 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #endif + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL 0 + #undef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS 1 + #endif + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 1 + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #endif + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 +#elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_LIMITED_API 0 + #define CYTHON_COMPILING_IN_GRAAL 0 + #define CYTHON_COMPILING_IN_NOGIL 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #ifndef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #ifndef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #ifndef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL 0 + #ifndef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL 1 + #endif + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS 1 + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 1 + #endif + #ifndef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 0 + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 1 + #endif + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif + #ifndef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 + #endif +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #define CYTHON_COMPILING_IN_LIMITED_API 0 + #define CYTHON_COMPILING_IN_GRAAL 0 + #define CYTHON_COMPILING_IN_NOGIL 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #ifndef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #endif + #ifndef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #ifndef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL (PY_MAJOR_VERSION < 3 || PY_VERSION_HEX >= 0x03060000 && PY_VERSION_HEX < 0x030C00A6) + #endif + #ifndef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL (PY_VERSION_HEX >= 0x030700A1) + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS 1 + #endif + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) + #define CYTHON_PEP489_MULTI_PHASE_INIT 1 + #endif + #ifndef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 0 + #endif + #if PY_VERSION_HEX < 0x030400a1 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #elif !defined(CYTHON_USE_TP_FINALIZE) + #define CYTHON_USE_TP_FINALIZE 1 + #endif + #if PY_VERSION_HEX < 0x030600B1 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #elif !defined(CYTHON_USE_DICT_VERSIONS) + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5) + #endif + #if PY_VERSION_HEX < 0x030700A3 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #elif !defined(CYTHON_USE_EXC_INFO_STACK) + #define CYTHON_USE_EXC_INFO_STACK 1 + #endif + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif + #ifndef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 1 + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if !defined(CYTHON_VECTORCALL) +#define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL && PY_VERSION_HEX >= 0x030800B1) +#endif +#define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1) +#if CYTHON_USE_PYLONG_INTERNALS + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif + #undef SHIFT + #undef BASE + #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED + #if defined(__cplusplus) + /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 + * but leads to warnings with -pedantic, since it is a C++17 feature */ + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + #if __has_cpp_attribute(maybe_unused) + #define CYTHON_UNUSED [[maybe_unused]] + #endif + #endif + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR + #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_USE_CPP_STD_MOVE + #if defined(__cplusplus) && (\ + __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) + #define CYTHON_USE_CPP_STD_MOVE 1 + #else + #define CYTHON_USE_CPP_STD_MOVE 0 + #endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; + #endif + #endif + #if _MSC_VER < 1300 + #ifdef _WIN64 + typedef unsigned long long __pyx_uintptr_t; + #else + typedef unsigned int __pyx_uintptr_t; + #endif + #else + #ifdef _WIN64 + typedef unsigned __int64 __pyx_uintptr_t; + #else + typedef unsigned __int32 __pyx_uintptr_t; + #endif + #endif +#else + #include + typedef uintptr_t __pyx_uintptr_t; +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) + /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 + * but leads to warnings with -pedantic, since it is a C++17 feature */ + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif +#ifdef __cplusplus + template + struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; + #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) +#else + #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) +#endif +#if CYTHON_COMPILING_IN_PYPY == 1 + #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x030A0000) +#else + #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000) +#endif +#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_DefaultClassType PyClass_Type + #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_DefaultClassType PyType_Type +#if CYTHON_COMPILING_IN_LIMITED_API + static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + PyObject *exception_table = NULL; + PyObject *types_module=NULL, *code_type=NULL, *result=NULL; + #if __PYX_LIMITED_VERSION_HEX < 0x030B0000 + PyObject *version_info; + PyObject *py_minor_version = NULL; + #endif + long minor_version = 0; + PyObject *type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); + #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000 + minor_version = 11; + #else + if (!(version_info = PySys_GetObject("version_info"))) goto end; + if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; + minor_version = PyLong_AsLong(py_minor_version); + Py_DECREF(py_minor_version); + if (minor_version == -1 && PyErr_Occurred()) goto end; + #endif + if (!(types_module = PyImport_ImportModule("types"))) goto end; + if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; + if (minor_version <= 7) { + (void)p; + result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code, + c, n, v, fn, name, fline, lnos, fv, cell); + } else if (minor_version <= 10) { + result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code, + c, n, v, fn, name, fline, lnos, fv, cell); + } else { + if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; + result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code, + c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); + } + end: + Py_XDECREF(code_type); + Py_XDECREF(exception_table); + Py_XDECREF(types_module); + if (type) { + PyErr_Restore(type, value, traceback); + } + return result; + } + #ifndef CO_OPTIMIZED + #define CO_OPTIMIZED 0x0001 + #endif + #ifndef CO_NEWLOCALS + #define CO_NEWLOCALS 0x0002 + #endif + #ifndef CO_VARARGS + #define CO_VARARGS 0x0004 + #endif + #ifndef CO_VARKEYWORDS + #define CO_VARKEYWORDS 0x0008 + #endif + #ifndef CO_ASYNC_GENERATOR + #define CO_ASYNC_GENERATOR 0x0200 + #endif + #ifndef CO_GENERATOR + #define CO_GENERATOR 0x0020 + #endif + #ifndef CO_COROUTINE + #define CO_COROUTINE 0x0080 + #endif +#elif PY_VERSION_HEX >= 0x030B0000 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + PyCodeObject *result; + PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0); + if (!empty_bytes) return NULL; + result = + #if PY_VERSION_HEX >= 0x030C0000 + PyUnstable_Code_NewWithPosOnlyArgs + #else + PyCode_NewWithPosOnlyArgs + #endif + (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes); + Py_DECREF(empty_bytes); + return result; + } +#elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#endif +#if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) + #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) +#else + #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) +#endif +#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) + #define __Pyx_Py_Is(x, y) Py_Is(x, y) +#else + #define __Pyx_Py_Is(x, y) ((x) == (y)) +#endif +#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) + #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) +#else + #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) +#endif +#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) + #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) +#else + #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) +#endif +#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) + #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) +#else + #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) +#endif +#define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) +#if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) +#else + #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) +#endif +#ifndef CO_COROUTINE + #define CO_COROUTINE 0x80 +#endif +#ifndef CO_ASYNC_GENERATOR + #define CO_ASYNC_GENERATOR 0x200 +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef Py_TPFLAGS_SEQUENCE + #define Py_TPFLAGS_SEQUENCE 0 +#endif +#ifndef Py_TPFLAGS_MAPPING + #define Py_TPFLAGS_MAPPING 0 +#endif +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #if PY_VERSION_HEX >= 0x030d00A4 + # define __Pyx_PyCFunctionFast PyCFunctionFast + # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords + #else + # define __Pyx_PyCFunctionFast _PyCFunctionFast + # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords + #endif +#endif +#if CYTHON_METH_FASTCALL + #define __Pyx_METH_FASTCALL METH_FASTCALL + #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast + #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords +#else + #define __Pyx_METH_FASTCALL METH_VARARGS + #define __Pyx_PyCFunction_FastCall PyCFunction + #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords +#endif +#if CYTHON_VECTORCALL + #define __pyx_vectorcallfunc vectorcallfunc + #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET + #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) +#elif CYTHON_BACKPORT_VECTORCALL + typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, + size_t nargsf, PyObject *kwnames); + #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1)) + #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)) +#else + #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 + #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) +#endif +#if PY_MAJOR_VERSION >= 0x030900B1 +#define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) +#else +#define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) +#endif +#define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) +#elif !CYTHON_COMPILING_IN_LIMITED_API +#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) +#endif +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) +static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { + return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; +} +#endif +static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) { +#if CYTHON_COMPILING_IN_LIMITED_API + return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; +#else + return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; +#endif +} +#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) +#if __PYX_LIMITED_VERSION_HEX < 0x030900B1 + #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) + typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); +#else + #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) + #define __Pyx_PyCMethod PyCMethod +#endif +#ifndef METH_METHOD + #define METH_METHOD 0x200 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_PyThreadState_Current PyThreadState_Get() +#elif !CYTHON_FAST_THREAD_STATE + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x030d00A1 + #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_LIMITED_API +static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op) +{ + void *result; + result = PyModule_GetState(op); + if (!result) + Py_FatalError("Couldn't find the module state"); + return result; +} +#endif +#define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE(obj), name, func_ctype) +#if CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) +#else + #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif +#if PY_MAJOR_VERSION < 3 + #if CYTHON_COMPILING_IN_PYPY + #if PYPY_VERSION_NUM < 0x07030600 + #if defined(__cplusplus) && __cplusplus >= 201402L + [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]] + #elif defined(__GNUC__) || defined(__clang__) + __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))) + #elif defined(_MSC_VER) + __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")) + #endif + static CYTHON_INLINE int PyGILState_Check(void) { + return 0; + } + #else // PYPY_VERSION_NUM < 0x07030600 + #endif // PYPY_VERSION_NUM < 0x07030600 + #else + static CYTHON_INLINE int PyGILState_Check(void) { + PyThreadState * tstate = _PyThreadState_Current; + return tstate && (tstate == PyGILState_GetThisThreadState()); + } + #endif +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { + PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); + if (res == NULL) PyErr_Clear(); + return res; +} +#elif PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) +#define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError +#define __Pyx_PyDict_GetItemStr PyDict_GetItem +#else +static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { +#if CYTHON_COMPILING_IN_PYPY + return PyDict_GetItem(dict, name); +#else + PyDictEntry *ep; + PyDictObject *mp = (PyDictObject*) dict; + long hash = ((PyStringObject *) name)->ob_shash; + assert(hash != -1); + ep = (mp->ma_lookup)(mp, name, hash); + if (ep == NULL) { + return NULL; + } + return ep->me_value; +#endif +} +#define __Pyx_PyDict_GetItemStr PyDict_GetItem +#endif +#if CYTHON_USE_TYPE_SLOTS + #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) + #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) + #define __Pyx_PyObject_GetIterNextFunc(obj) (Py_TYPE(obj)->tp_iternext) +#else + #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) + #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) + #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next +#endif +#if CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v) +#else + #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v) +#endif +#if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 +#define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ + PyTypeObject *type = Py_TYPE((PyObject*)obj);\ + assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ + PyObject_GC_Del(obj);\ + Py_DECREF(type);\ +} +#else +#define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) +#endif +#if CYTHON_COMPILING_IN_LIMITED_API + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) + #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) + #define __Pyx_PyUnicode_DATA(u) ((void*)u) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) +#elif PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #if PY_VERSION_HEX >= 0x030C0000 + #define __Pyx_PyUnicode_READY(op) (0) + #else + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #endif + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) + #if PY_VERSION_HEX >= 0x030C0000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) + #else + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif + #endif +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U) + #define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = (Py_UNICODE) ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #if !defined(PyUnicode_DecodeUnicodeEscape) + #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) + #endif + #if !defined(PyUnicode_Contains) || (PY_MAJOR_VERSION == 2 && PYPY_VERSION_NUM < 0x07030500) + #undef PyUnicode_Contains + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) + #endif + #if !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) + #endif + #if !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) + #endif +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#ifndef PyObject_Unicode + #define PyObject_Unicode PyObject_Str +#endif +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#if CYTHON_COMPILING_IN_CPYTHON + #define __Pyx_PySequence_ListKeepNew(obj)\ + (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) +#else + #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) +#endif +#if PY_VERSION_HEX >= 0x030900A4 + #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) +#else + #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) +#endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) + #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) + #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) + #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) + #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) + #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) + #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) + #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) +#else + #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) + #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) + #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) + #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) + #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) + #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) + #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) + #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) +#endif +#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 + #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) +#else + static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { + PyObject *module = PyImport_AddModule(name); + Py_XINCREF(module); + return module; + } +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define __Pyx_Py3Int_Check(op) PyLong_Check(op) + #define __Pyx_Py3Int_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#else + #define __Pyx_Py3Int_Check(op) (PyLong_Check(op) || PyInt_Check(op)) + #define __Pyx_Py3Int_CheckExact(op) (PyLong_CheckExact(op) || PyInt_CheckExact(op)) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + +#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) + #if !defined(_USE_MATH_DEFINES) + #define _USE_MATH_DEFINES + #endif +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + +#define __PYX_MARK_ERR_POS(f_index, lineno) \ + { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } +#define __PYX_ERR(f_index, lineno, Ln_error) \ + { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } + +#ifdef CYTHON_EXTERN_C + #undef __PYX_EXTERN_C + #define __PYX_EXTERN_C CYTHON_EXTERN_C +#elif defined(__PYX_EXTERN_C) + #ifdef _MSC_VER + #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") + #else + #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. + #endif +#else + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__fontTools__cu2qu__cu2qu +#define __PYX_HAVE_API__fontTools__cu2qu__cu2qu +/* Early includes */ +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #if PY_VERSION_HEX >= 0x030C00A7 + #ifndef _PyLong_SIGN_MASK + #define _PyLong_SIGN_MASK 3 + #endif + #ifndef _PyLong_NON_SIZE_BITS + #define _PyLong_NON_SIZE_BITS 3 + #endif + #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) + #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) + #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) + #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) + #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) + #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) + #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) + #define __Pyx_PyLong_SignedDigitCount(x)\ + ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) + #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) + #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) + #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) + #else + #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) + #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) + #endif + typedef Py_ssize_t __Pyx_compact_pylong; + typedef size_t __Pyx_compact_upylong; + #else + #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) + #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) + #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) + #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) + #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) + #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) + #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) + #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) + #define __Pyx_PyLong_CompactValue(x)\ + ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) + typedef sdigit __Pyx_compact_pylong; + typedef digit __Pyx_compact_upylong; + #endif + #if PY_VERSION_HEX >= 0x030C00A5 + #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) + #else + #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) + #endif +#endif +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +#include +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = (char) c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#include +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +#if !CYTHON_USE_MODULE_STATE +static PyObject *__pyx_m = NULL; +#endif +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm = __FILE__; +static const char *__pyx_filename; + +/* Header.proto */ +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER)) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + +/* #### Code section: filename_table ### */ + +static const char *__pyx_f[] = { + "Lib/fontTools/cu2qu/cu2qu.py", +}; +/* #### Code section: utility_code_proto_before_types ### */ +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* #### Code section: numeric_typedefs ### */ +/* #### Code section: complex_type_declarations ### */ +/* Declarations.proto */ +#if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus) + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +/* #### Code section: type_declarations ### */ + +/*--- Type declarations ---*/ +struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; + +/* "fontTools/cu2qu/cu2qu.py":127 + * + * + * @cython.locals( # <<<<<<<<<<<<<< + * p0=cython.complex, + * p1=cython.complex, + */ +struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen { + PyObject_HEAD + __pyx_t_double_complex __pyx_v_a; + __pyx_t_double_complex __pyx_v_a1; + __pyx_t_double_complex __pyx_v_b; + __pyx_t_double_complex __pyx_v_b1; + __pyx_t_double_complex __pyx_v_c; + __pyx_t_double_complex __pyx_v_c1; + __pyx_t_double_complex __pyx_v_d; + __pyx_t_double_complex __pyx_v_d1; + double __pyx_v_delta_2; + double __pyx_v_delta_3; + double __pyx_v_dt; + int __pyx_v_i; + int __pyx_v_n; + __pyx_t_double_complex __pyx_v_p0; + __pyx_t_double_complex __pyx_v_p1; + __pyx_t_double_complex __pyx_v_p2; + __pyx_t_double_complex __pyx_v_p3; + double __pyx_v_t1; + double __pyx_v_t1_2; + int __pyx_t_0; + int __pyx_t_1; + int __pyx_t_2; +}; + +/* #### Code section: utility_code_proto ### */ + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, Py_ssize_t); + void (*DECREF)(void*, PyObject*, Py_ssize_t); + void (*GOTREF)(void*, PyObject*, Py_ssize_t); + void (*GIVEREF)(void*, PyObject*, Py_ssize_t); + void* (*SetupContext)(const char*, Py_ssize_t, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ + } + #define __Pyx_RefNannyFinishContextNogil() {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __Pyx_RefNannyFinishContext();\ + PyGILState_Release(__pyx_gilstate_save);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)) + #define __Pyx_RefNannyFinishContextNogil() __Pyx_RefNannyFinishContext() +#endif + #define __Pyx_RefNannyFinishContextNogil() {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __Pyx_RefNannyFinishContext();\ + PyGILState_Release(__pyx_gilstate_save);\ + } + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) + #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContextNogil() + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_Py_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; Py_XDECREF(tmp);\ + } while (0) +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#if PY_VERSION_HEX >= 0x030C00A6 +#define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) +#define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) +#else +#define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) +#define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) +#endif +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) +#define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* PyObjectGetAttrStrNoError.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* PyIntCompare.proto */ +static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* IterFinish.proto */ +static CYTHON_INLINE int __Pyx_IterFinish(void); + +/* UnpackItemEndCheck.proto */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* PyDictVersioning.proto */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif + +/* GetModuleGlobalName.proto */ +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) do {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} while(0) +#define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} while(0) +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#if !CYTHON_VECTORCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +#endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif +#if !CYTHON_VECTORCALL +#if PY_VERSION_HEX >= 0x03080000 + #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + #define __Pxy_PyFrame_Initialize_Offsets() + #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) +#else + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif +#endif +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectFastCall.proto */ +#define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) +static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); + +/* TupleAndListFromArray.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); +static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); +#endif + +/* IncludeStringH.proto */ +#include + +/* BytesEquals.proto */ +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); + +/* UnicodeEquals.proto */ +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); + +/* fastcall.proto */ +#if CYTHON_AVOID_BORROWED_REFS + #define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i) +#elif CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i) +#else + #define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i) +#endif +#if CYTHON_AVOID_BORROWED_REFS + #define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg) + #define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg) +#else + #define __Pyx_Arg_NewRef_VARARGS(arg) arg + #define __Pyx_Arg_XDECREF_VARARGS(arg) +#endif +#define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) +#define __Pyx_KwValues_VARARGS(args, nargs) NULL +#define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) +#define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) +#if CYTHON_METH_FASTCALL + #define __Pyx_Arg_FASTCALL(args, i) args[i] + #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds) + #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) + static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 + CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); + #else + #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) + #endif + #define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs + to have the same reference counting */ + #define __Pyx_Arg_XDECREF_FASTCALL(arg) +#else + #define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS + #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS + #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS + #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS + #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS + #define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg) + #define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS +#define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start) +#define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start) +#else +#define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) +#define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) +#endif + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject *const *kwvalues, + PyObject **argnames[], + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, + const char* function_name); + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* pep479.proto */ +static void __Pyx_Generator_Replace_StopIteration(int in_async_gen); + +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* IterNext.proto */ +#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL) +static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 + L->ob_item[len] = x; + #else + PyList_SET_ITEM(list, len, x); + #endif + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* ListCompAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 + L->ob_item[len] = x; + #else + PyList_SET_ITEM(list, len, x); + #endif + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* AssertionsEnabled.proto */ +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define __Pyx_init_assertions_enabled() (0) + #define __pyx_assertions_enabled() (1) +#elif CYTHON_COMPILING_IN_LIMITED_API || (CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030C0000) + static int __pyx_assertions_enabled_flag; + #define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag) + static int __Pyx_init_assertions_enabled(void) { + PyObject *builtins, *debug, *debug_str; + int flag; + builtins = PyEval_GetBuiltins(); + if (!builtins) goto bad; + debug_str = PyUnicode_FromStringAndSize("__debug__", 9); + if (!debug_str) goto bad; + debug = PyObject_GetItem(builtins, debug_str); + Py_DECREF(debug_str); + if (!debug) goto bad; + flag = PyObject_IsTrue(debug); + Py_DECREF(debug); + if (flag == -1) goto bad; + __pyx_assertions_enabled_flag = flag; + return 0; + bad: + __pyx_assertions_enabled_flag = 1; + return -1; + } +#else + #define __Pyx_init_assertions_enabled() (0) + #define __pyx_assertions_enabled() (!Py_OptimizeFlag) +#endif + +/* SetItemInt.proto */ +#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +/* ModInt[long].proto */ +static CYTHON_INLINE long __Pyx_mod_long(long, long); + +/* IncludeStructmemberH.proto */ +#include + +/* FixUpExtensionType.proto */ +#if CYTHON_USE_TYPE_SPECS +static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); +#endif + +/* PyObjectCallNoArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyObjectGetMethod.proto */ +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); + +/* PyObjectCallMethod0.proto */ +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); + +/* ValidateBasesTuple.proto */ +#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS +static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); +#endif + +/* PyType_Ready.proto */ +CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); + +/* PyObject_GenericGetAttrNoDict.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +#define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* ImportDottedModule.proto */ +static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple); +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple); +#endif + +/* pybytes_as_double.proto */ +static double __Pyx_SlowPyString_AsDouble(PyObject *obj); +static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length); +static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) { + char* as_c_string; + Py_ssize_t size; +#if CYTHON_ASSUME_SAFE_MACROS + as_c_string = PyBytes_AS_STRING(obj); + size = PyBytes_GET_SIZE(obj); +#else + if (PyBytes_AsStringAndSize(obj, &as_c_string, &size) < 0) { + return (double)-1; + } +#endif + return __Pyx__PyBytes_AsDouble(obj, as_c_string, size); +} +static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) { + char* as_c_string; + Py_ssize_t size; +#if CYTHON_ASSUME_SAFE_MACROS + as_c_string = PyByteArray_AS_STRING(obj); + size = PyByteArray_GET_SIZE(obj); +#else + as_c_string = PyByteArray_AsString(obj); + if (as_c_string == NULL) { + return (double)-1; + } + size = PyByteArray_Size(obj); +#endif + return __Pyx__PyBytes_AsDouble(obj, as_c_string, size); +} + +/* pyunicode_as_double.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS +static const char* __Pyx__PyUnicode_AsDouble_Copy(const void* data, const int kind, char* buffer, Py_ssize_t start, Py_ssize_t end) { + int last_was_punctuation; + Py_ssize_t i; + last_was_punctuation = 1; + for (i=start; i <= end; i++) { + Py_UCS4 chr = PyUnicode_READ(kind, data, i); + int is_punctuation = (chr == '_') | (chr == '.'); + *buffer = (char)chr; + buffer += (chr != '_'); + if (unlikely(chr > 127)) goto parse_failure; + if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure; + last_was_punctuation = is_punctuation; + } + if (unlikely(last_was_punctuation)) goto parse_failure; + *buffer = '\0'; + return buffer; +parse_failure: + return NULL; +} +static double __Pyx__PyUnicode_AsDouble_inf_nan(const void* data, int kind, Py_ssize_t start, Py_ssize_t length) { + int matches = 1; + Py_UCS4 chr; + Py_UCS4 sign = PyUnicode_READ(kind, data, start); + int is_signed = (sign == '-') | (sign == '+'); + start += is_signed; + length -= is_signed; + switch (PyUnicode_READ(kind, data, start)) { + #ifdef Py_NAN + case 'n': + case 'N': + if (unlikely(length != 3)) goto parse_failure; + chr = PyUnicode_READ(kind, data, start+1); + matches &= (chr == 'a') | (chr == 'A'); + chr = PyUnicode_READ(kind, data, start+2); + matches &= (chr == 'n') | (chr == 'N'); + if (unlikely(!matches)) goto parse_failure; + return (sign == '-') ? -Py_NAN : Py_NAN; + #endif + case 'i': + case 'I': + if (unlikely(length < 3)) goto parse_failure; + chr = PyUnicode_READ(kind, data, start+1); + matches &= (chr == 'n') | (chr == 'N'); + chr = PyUnicode_READ(kind, data, start+2); + matches &= (chr == 'f') | (chr == 'F'); + if (likely(length == 3 && matches)) + return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; + if (unlikely(length != 8)) goto parse_failure; + chr = PyUnicode_READ(kind, data, start+3); + matches &= (chr == 'i') | (chr == 'I'); + chr = PyUnicode_READ(kind, data, start+4); + matches &= (chr == 'n') | (chr == 'N'); + chr = PyUnicode_READ(kind, data, start+5); + matches &= (chr == 'i') | (chr == 'I'); + chr = PyUnicode_READ(kind, data, start+6); + matches &= (chr == 't') | (chr == 'T'); + chr = PyUnicode_READ(kind, data, start+7); + matches &= (chr == 'y') | (chr == 'Y'); + if (unlikely(!matches)) goto parse_failure; + return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; + case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + break; + default: + goto parse_failure; + } + return 0.0; +parse_failure: + return -1.0; +} +static double __Pyx_PyUnicode_AsDouble_WithSpaces(PyObject *obj) { + double value; + const char *last; + char *end; + Py_ssize_t start, length = PyUnicode_GET_LENGTH(obj); + const int kind = PyUnicode_KIND(obj); + const void* data = PyUnicode_DATA(obj); + start = 0; + while (Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, start))) + start++; + while (start < length - 1 && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, length - 1))) + length--; + length -= start; + if (unlikely(length <= 0)) goto fallback; + value = __Pyx__PyUnicode_AsDouble_inf_nan(data, kind, start, length); + if (unlikely(value == -1.0)) goto fallback; + if (value != 0.0) return value; + if (length < 40) { + char number[40]; + last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length); + if (unlikely(!last)) goto fallback; + value = PyOS_string_to_double(number, &end, NULL); + } else { + char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char)); + if (unlikely(!number)) goto fallback; + last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length); + if (unlikely(!last)) { + PyMem_Free(number); + goto fallback; + } + value = PyOS_string_to_double(number, &end, NULL); + PyMem_Free(number); + } + if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) { + return value; + } +fallback: + return __Pyx_SlowPyString_AsDouble(obj); +} +#endif +static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) { +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS + if (unlikely(__Pyx_PyUnicode_READY(obj) == -1)) + return (double)-1; + if (likely(PyUnicode_IS_ASCII(obj))) { + const char *s; + Py_ssize_t length; + s = PyUnicode_AsUTF8AndSize(obj, &length); + return __Pyx__PyBytes_AsDouble(obj, s, length); + } + return __Pyx_PyUnicode_AsDouble_WithSpaces(obj); +#else + return __Pyx_SlowPyString_AsDouble(obj); +#endif +} + +/* FetchSharedCythonModule.proto */ +static PyObject *__Pyx_FetchSharedCythonABIModule(void); + +/* FetchCommonType.proto */ +#if !CYTHON_USE_TYPE_SPECS +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); +#else +static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases); +#endif + +/* PyMethodNew.proto */ +#if CYTHON_COMPILING_IN_LIMITED_API +static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { + PyObject *typesModule=NULL, *methodType=NULL, *result=NULL; + CYTHON_UNUSED_VAR(typ); + if (!self) + return __Pyx_NewRef(func); + typesModule = PyImport_ImportModule("types"); + if (!typesModule) return NULL; + methodType = PyObject_GetAttrString(typesModule, "MethodType"); + Py_DECREF(typesModule); + if (!methodType) return NULL; + result = PyObject_CallFunctionObjArgs(methodType, func, self, NULL); + Py_DECREF(methodType); + return result; +} +#elif PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { + CYTHON_UNUSED_VAR(typ); + if (!self) + return __Pyx_NewRef(func); + return PyMethod_New(func, self); +} +#else + #define __Pyx_PyMethod_New PyMethod_New +#endif + +/* PyVectorcallFastCallDict.proto */ +#if CYTHON_METH_FASTCALL +static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); +#endif + +/* CythonFunctionShared.proto */ +#define __Pyx_CyFunction_USED +#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 +#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 +#define __Pyx_CYFUNCTION_CCLASS 0x04 +#define __Pyx_CYFUNCTION_COROUTINE 0x08 +#define __Pyx_CyFunction_GetClosure(f)\ + (((__pyx_CyFunctionObject *) (f))->func_closure) +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_CyFunction_GetClassObj(f)\ + (((__pyx_CyFunctionObject *) (f))->func_classobj) +#else + #define __Pyx_CyFunction_GetClassObj(f)\ + ((PyObject*) ((PyCMethodObject *) (f))->mm_class) +#endif +#define __Pyx_CyFunction_SetClassObj(f, classobj)\ + __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) +#define __Pyx_CyFunction_Defaults(type, f)\ + ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) +#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ + ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) +typedef struct { +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject_HEAD + PyObject *func; +#elif PY_VERSION_HEX < 0x030900B1 + PyCFunctionObject func; +#else + PyCMethodObject func; +#endif +#if CYTHON_BACKPORT_VECTORCALL + __pyx_vectorcallfunc func_vectorcall; +#endif +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API + PyObject *func_weakreflist; +#endif + PyObject *func_dict; + PyObject *func_name; + PyObject *func_qualname; + PyObject *func_doc; + PyObject *func_globals; + PyObject *func_code; + PyObject *func_closure; +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API + PyObject *func_classobj; +#endif + void *defaults; + int defaults_pyobjects; + size_t defaults_size; + int flags; + PyObject *defaults_tuple; + PyObject *defaults_kwdict; + PyObject *(*defaults_getter)(PyObject *); + PyObject *func_annotations; + PyObject *func_is_coroutine; +} __pyx_CyFunctionObject; +#undef __Pyx_CyOrPyCFunction_Check +#define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_CyFunctionType) +#define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type) +#define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_CyFunctionType) +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc); +#undef __Pyx_IsSameCFunction +#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *closure, + PyObject *module, PyObject *globals, + PyObject* code); +static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, + size_t size, + int pyobjects); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, + PyObject *tuple); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, + PyObject *dict); +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, + PyObject *dict); +static int __pyx_CyFunction_init(PyObject *module); +#if CYTHON_METH_FASTCALL +static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); +static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); +static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); +static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); +#if CYTHON_BACKPORT_VECTORCALL +#define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) +#else +#define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) +#endif +#endif + +/* CythonFunction.proto */ +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *closure, + PyObject *module, PyObject *globals, + PyObject* code); + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +#if !CYTHON_COMPILING_IN_LIMITED_API +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); +#endif + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* RealImag.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(__cplusplus) && CYTHON_CCOMPLEX\ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus) + #define __Pyx_c_eq_double(a, b) ((a)==(b)) + #define __Pyx_c_sum_double(a, b) ((a)+(b)) + #define __Pyx_c_diff_double(a, b) ((a)-(b)) + #define __Pyx_c_prod_double(a, b) ((a)*(b)) + #define __Pyx_c_quot_double(a, b) ((a)/(b)) + #define __Pyx_c_neg_double(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_double(z) ((z)==(double)0) + #define __Pyx_c_conj_double(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (::std::abs(z)) + #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_double(z) ((z)==0) + #define __Pyx_c_conj_double(z) (conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (cabs(z)) + #define __Pyx_c_pow_double(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +/* FromPy.proto */ +static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*); + +/* GCCDiagnostics.proto */ +#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif + +/* ToPy.proto */ +#define __pyx_PyComplex_FromComplex(z)\ + PyComplex_FromDoubles((double)__Pyx_CREAL(z),\ + (double)__Pyx_CIMAG(z)) + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FormatTypeName.proto */ +#if CYTHON_COMPILING_IN_LIMITED_API +typedef PyObject *__Pyx_TypeName; +#define __Pyx_FMT_TYPENAME "%U" +static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); +#define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) +#else +typedef const char *__Pyx_TypeName; +#define __Pyx_FMT_TYPENAME "%.200s" +#define __Pyx_PyType_GetName(tp) ((tp)->tp_name) +#define __Pyx_DECREF_TypeName(obj) +#endif + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* PyObjectCall2Args.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); + +/* PyObjectCallMethod1.proto */ +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); + +/* CoroutineBase.proto */ +struct __pyx_CoroutineObject; +typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *); +#if CYTHON_USE_EXC_INFO_STACK +#define __Pyx_ExcInfoStruct _PyErr_StackItem +#else +typedef struct { + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; +} __Pyx_ExcInfoStruct; +#endif +typedef struct __pyx_CoroutineObject { + PyObject_HEAD + __pyx_coroutine_body_t body; + PyObject *closure; + __Pyx_ExcInfoStruct gi_exc_state; + PyObject *gi_weakreflist; + PyObject *classobj; + PyObject *yieldfrom; + PyObject *gi_name; + PyObject *gi_qualname; + PyObject *gi_modulename; + PyObject *gi_code; + PyObject *gi_frame; + int resume_label; + char is_running; +} __pyx_CoroutineObject; +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); +static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); +static int __Pyx_Coroutine_clear(PyObject *self); +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); +static PyObject *__Pyx_Coroutine_Close(PyObject *self); +static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); +#if CYTHON_USE_EXC_INFO_STACK +#define __Pyx_Coroutine_SwapException(self) +#define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state) +#else +#define __Pyx_Coroutine_SwapException(self) {\ + __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\ + __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\ + } +#define __Pyx_Coroutine_ResetAndClearException(self) {\ + __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\ + (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\ + } +#endif +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue) +#else +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) +#endif +static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); + +/* PatchModuleWithCoroutine.proto */ +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); + +/* PatchGeneratorABC.proto */ +static int __Pyx_patch_abc(void); + +/* Generator.proto */ +#define __Pyx_Generator_USED +#define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_GeneratorType) +#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\ + __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name) +static PyObject *__Pyx_Generator_Next(PyObject *self); +static int __pyx_Generator_init(PyObject *module); + +/* CheckBinaryVersion.proto */ +static unsigned long __Pyx_get_runtime_version(void); +static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +/* #### Code section: module_declarations ### */ + +/* Module declarations from "cython" */ + +/* Module declarations from "fontTools.cu2qu.cu2qu" */ +static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ +static int __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, double); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *, double); /*proto*/ +static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *, int, double, int); /*proto*/ +/* #### Code section: typeinfo ### */ +/* #### Code section: before_global_var ### */ +#define __Pyx_MODULE_NAME "fontTools.cu2qu.cu2qu" +extern int __pyx_module_is_main_fontTools__cu2qu__cu2qu; +int __pyx_module_is_main_fontTools__cu2qu__cu2qu = 0; + +/* Implementation of "fontTools.cu2qu.cu2qu" */ +/* #### Code section: global_var ### */ +static PyObject *__pyx_builtin_AttributeError; +static PyObject *__pyx_builtin_ImportError; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_ZeroDivisionError; +static PyObject *__pyx_builtin_AssertionError; +/* #### Code section: string_decls ### */ +static const char __pyx_k_a[] = "a"; +static const char __pyx_k_b[] = "b"; +static const char __pyx_k_c[] = "c"; +static const char __pyx_k_d[] = "d"; +static const char __pyx_k_i[] = "i"; +static const char __pyx_k_l[] = "l"; +static const char __pyx_k_n[] = "n"; +static const char __pyx_k_p[] = "p"; +static const char __pyx_k_s[] = "s"; +static const char __pyx_k__2[] = "."; +static const char __pyx_k__3[] = "*"; +static const char __pyx_k__9[] = "?"; +static const char __pyx_k_a1[] = "a1"; +static const char __pyx_k_b1[] = "b1"; +static const char __pyx_k_c1[] = "c1"; +static const char __pyx_k_d1[] = "d1"; +static const char __pyx_k_dt[] = "dt"; +static const char __pyx_k_gc[] = "gc"; +static const char __pyx_k_p0[] = "p0"; +static const char __pyx_k_p1[] = "p1"; +static const char __pyx_k_p2[] = "p2"; +static const char __pyx_k_p3[] = "p3"; +static const char __pyx_k_t1[] = "t1"; +static const char __pyx_k_NAN[] = "NAN"; +static const char __pyx_k_NaN[] = "NaN"; +static const char __pyx_k_all[] = "__all__"; +static const char __pyx_k_args[] = "args"; +static const char __pyx_k_imag[] = "imag"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_math[] = "math"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_real[] = "real"; +static const char __pyx_k_send[] = "send"; +static const char __pyx_k_spec[] = "__spec__"; +static const char __pyx_k_t1_2[] = "t1_2"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_Error[] = "Error"; +static const char __pyx_k_MAX_N[] = "MAX_N"; +static const char __pyx_k_close[] = "close"; +static const char __pyx_k_curve[] = "curve"; +static const char __pyx_k_isnan[] = "isnan"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_throw[] = "throw"; +static const char __pyx_k_curves[] = "curves"; +static const char __pyx_k_cython[] = "cython"; +static const char __pyx_k_enable[] = "enable"; +static const char __pyx_k_errors[] = "errors"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_last_i[] = "last_i"; +static const char __pyx_k_spline[] = "spline"; +static const char __pyx_k_delta_2[] = "delta_2"; +static const char __pyx_k_delta_3[] = "delta_3"; +static const char __pyx_k_disable[] = "disable"; +static const char __pyx_k_max_err[] = "max_err"; +static const char __pyx_k_splines[] = "splines"; +static const char __pyx_k_COMPILED[] = "COMPILED"; +static const char __pyx_k_isenabled[] = "isenabled"; +static const char __pyx_k_Cu2QuError[] = "Cu2QuError"; +static const char __pyx_k_max_errors[] = "max_errors"; +static const char __pyx_k_ImportError[] = "ImportError"; +static const char __pyx_k_initializing[] = "_initializing"; +static const char __pyx_k_is_coroutine[] = "_is_coroutine"; +static const char __pyx_k_all_quadratic[] = "all_quadratic"; +static const char __pyx_k_AssertionError[] = "AssertionError"; +static const char __pyx_k_AttributeError[] = "AttributeError"; +static const char __pyx_k_fontTools_misc[] = "fontTools.misc"; +static const char __pyx_k_ZeroDivisionError[] = "ZeroDivisionError"; +static const char __pyx_k_asyncio_coroutines[] = "asyncio.coroutines"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_curve_to_quadratic[] = "curve_to_quadratic"; +static const char __pyx_k_ApproxNotFoundError[] = "ApproxNotFoundError"; +static const char __pyx_k_curves_to_quadratic[] = "curves_to_quadratic"; +static const char __pyx_k_fontTools_cu2qu_cu2qu[] = "fontTools.cu2qu.cu2qu"; +static const char __pyx_k_split_cubic_into_n_gen[] = "_split_cubic_into_n_gen"; +static const char __pyx_k_Lib_fontTools_cu2qu_cu2qu_py[] = "Lib/fontTools/cu2qu/cu2qu.py"; +static const char __pyx_k_curves_to_quadratic_line_474[] = "curves_to_quadratic (line 474)"; +static const char __pyx_k_Return_quadratic_Bezier_splines[] = "Return quadratic Bezier splines approximating the input cubic Beziers.\n\n Args:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\n Example::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\n The returned splines have \"implied oncurve points\" suitable for use in\n TrueType ``glif`` outlines - i.e. in the first spline returned above,\n the first quadratic segment runs from (50,50) to\n ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\n Returns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\n Raises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.\n "; +/* #### Code section: decls ### */ +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n); /* proto */ +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic); /* proto */ +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic); /* proto */ +static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +/* #### Code section: late_includes ### */ +/* #### Code section: module_state ### */ +typedef struct { + PyObject *__pyx_d; + PyObject *__pyx_b; + PyObject *__pyx_cython_runtime; + PyObject *__pyx_empty_tuple; + PyObject *__pyx_empty_bytes; + PyObject *__pyx_empty_unicode; + #ifdef __Pyx_CyFunction_USED + PyTypeObject *__pyx_CyFunctionType; + #endif + #ifdef __Pyx_FusedFunction_USED + PyTypeObject *__pyx_FusedFunctionType; + #endif + #ifdef __Pyx_Generator_USED + PyTypeObject *__pyx_GeneratorType; + #endif + #ifdef __Pyx_IterableCoroutine_USED + PyTypeObject *__pyx_IterableCoroutineType; + #endif + #ifdef __Pyx_Coroutine_USED + PyTypeObject *__pyx_CoroutineAwaitType; + #endif + #ifdef __Pyx_Coroutine_USED + PyTypeObject *__pyx_CoroutineType; + #endif + #if CYTHON_USE_MODULE_STATE + #endif + #if CYTHON_USE_MODULE_STATE + PyObject *__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; + #endif + PyTypeObject *__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; + PyObject *__pyx_n_s_ApproxNotFoundError; + PyObject *__pyx_n_s_AssertionError; + PyObject *__pyx_n_s_AttributeError; + PyObject *__pyx_n_s_COMPILED; + PyObject *__pyx_n_s_Cu2QuError; + PyObject *__pyx_n_s_Error; + PyObject *__pyx_n_s_ImportError; + PyObject *__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py; + PyObject *__pyx_n_s_MAX_N; + PyObject *__pyx_n_s_NAN; + PyObject *__pyx_n_u_NaN; + PyObject *__pyx_kp_u_Return_quadratic_Bezier_splines; + PyObject *__pyx_n_s_ZeroDivisionError; + PyObject *__pyx_kp_u__2; + PyObject *__pyx_n_s__3; + PyObject *__pyx_n_s__9; + PyObject *__pyx_n_s_a; + PyObject *__pyx_n_s_a1; + PyObject *__pyx_n_s_all; + PyObject *__pyx_n_s_all_quadratic; + PyObject *__pyx_n_s_args; + PyObject *__pyx_n_s_asyncio_coroutines; + PyObject *__pyx_n_s_b; + PyObject *__pyx_n_s_b1; + PyObject *__pyx_n_s_c; + PyObject *__pyx_n_s_c1; + PyObject *__pyx_n_s_cline_in_traceback; + PyObject *__pyx_n_s_close; + PyObject *__pyx_n_s_curve; + PyObject *__pyx_n_s_curve_to_quadratic; + PyObject *__pyx_n_u_curve_to_quadratic; + PyObject *__pyx_n_s_curves; + PyObject *__pyx_n_s_curves_to_quadratic; + PyObject *__pyx_n_u_curves_to_quadratic; + PyObject *__pyx_kp_u_curves_to_quadratic_line_474; + PyObject *__pyx_n_s_cython; + PyObject *__pyx_n_s_d; + PyObject *__pyx_n_s_d1; + PyObject *__pyx_n_s_delta_2; + PyObject *__pyx_n_s_delta_3; + PyObject *__pyx_kp_u_disable; + PyObject *__pyx_n_s_dt; + PyObject *__pyx_kp_u_enable; + PyObject *__pyx_n_s_errors; + PyObject *__pyx_n_s_fontTools_cu2qu_cu2qu; + PyObject *__pyx_n_s_fontTools_misc; + PyObject *__pyx_kp_u_gc; + PyObject *__pyx_n_s_i; + PyObject *__pyx_n_s_imag; + PyObject *__pyx_n_s_import; + PyObject *__pyx_n_s_initializing; + PyObject *__pyx_n_s_is_coroutine; + PyObject *__pyx_kp_u_isenabled; + PyObject *__pyx_n_s_isnan; + PyObject *__pyx_n_s_l; + PyObject *__pyx_n_s_last_i; + PyObject *__pyx_n_s_main; + PyObject *__pyx_n_s_math; + PyObject *__pyx_n_s_max_err; + PyObject *__pyx_n_s_max_errors; + PyObject *__pyx_n_s_n; + PyObject *__pyx_n_s_name; + PyObject *__pyx_n_s_p; + PyObject *__pyx_n_s_p0; + PyObject *__pyx_n_s_p1; + PyObject *__pyx_n_s_p2; + PyObject *__pyx_n_s_p3; + PyObject *__pyx_n_s_range; + PyObject *__pyx_n_s_real; + PyObject *__pyx_n_s_s; + PyObject *__pyx_n_s_send; + PyObject *__pyx_n_s_spec; + PyObject *__pyx_n_s_spline; + PyObject *__pyx_n_s_splines; + PyObject *__pyx_n_s_split_cubic_into_n_gen; + PyObject *__pyx_n_s_t1; + PyObject *__pyx_n_s_t1_2; + PyObject *__pyx_n_s_test; + PyObject *__pyx_n_s_throw; + PyObject *__pyx_int_1; + PyObject *__pyx_int_2; + PyObject *__pyx_int_3; + PyObject *__pyx_int_4; + PyObject *__pyx_int_6; + PyObject *__pyx_int_100; + PyObject *__pyx_codeobj_; + PyObject *__pyx_tuple__4; + PyObject *__pyx_tuple__5; + PyObject *__pyx_tuple__7; + PyObject *__pyx_codeobj__6; + PyObject *__pyx_codeobj__8; +} __pyx_mstate; + +#if CYTHON_USE_MODULE_STATE +#ifdef __cplusplus +namespace { + extern struct PyModuleDef __pyx_moduledef; +} /* anonymous namespace */ +#else +static struct PyModuleDef __pyx_moduledef; +#endif + +#define __pyx_mstate(o) ((__pyx_mstate *)__Pyx_PyModule_GetState(o)) + +#define __pyx_mstate_global (__pyx_mstate(PyState_FindModule(&__pyx_moduledef))) + +#define __pyx_m (PyState_FindModule(&__pyx_moduledef)) +#else +static __pyx_mstate __pyx_mstate_global_static = +#ifdef __cplusplus + {}; +#else + {0}; +#endif +static __pyx_mstate *__pyx_mstate_global = &__pyx_mstate_global_static; +#endif +/* #### Code section: module_state_clear ### */ +#if CYTHON_USE_MODULE_STATE +static int __pyx_m_clear(PyObject *m) { + __pyx_mstate *clear_module_state = __pyx_mstate(m); + if (!clear_module_state) return 0; + Py_CLEAR(clear_module_state->__pyx_d); + Py_CLEAR(clear_module_state->__pyx_b); + Py_CLEAR(clear_module_state->__pyx_cython_runtime); + Py_CLEAR(clear_module_state->__pyx_empty_tuple); + Py_CLEAR(clear_module_state->__pyx_empty_bytes); + Py_CLEAR(clear_module_state->__pyx_empty_unicode); + #ifdef __Pyx_CyFunction_USED + Py_CLEAR(clear_module_state->__pyx_CyFunctionType); + #endif + #ifdef __Pyx_FusedFunction_USED + Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); + #endif + Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen); + Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen); + Py_CLEAR(clear_module_state->__pyx_n_s_ApproxNotFoundError); + Py_CLEAR(clear_module_state->__pyx_n_s_AssertionError); + Py_CLEAR(clear_module_state->__pyx_n_s_AttributeError); + Py_CLEAR(clear_module_state->__pyx_n_s_COMPILED); + Py_CLEAR(clear_module_state->__pyx_n_s_Cu2QuError); + Py_CLEAR(clear_module_state->__pyx_n_s_Error); + Py_CLEAR(clear_module_state->__pyx_n_s_ImportError); + Py_CLEAR(clear_module_state->__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py); + Py_CLEAR(clear_module_state->__pyx_n_s_MAX_N); + Py_CLEAR(clear_module_state->__pyx_n_s_NAN); + Py_CLEAR(clear_module_state->__pyx_n_u_NaN); + Py_CLEAR(clear_module_state->__pyx_kp_u_Return_quadratic_Bezier_splines); + Py_CLEAR(clear_module_state->__pyx_n_s_ZeroDivisionError); + Py_CLEAR(clear_module_state->__pyx_kp_u__2); + Py_CLEAR(clear_module_state->__pyx_n_s__3); + Py_CLEAR(clear_module_state->__pyx_n_s__9); + Py_CLEAR(clear_module_state->__pyx_n_s_a); + Py_CLEAR(clear_module_state->__pyx_n_s_a1); + Py_CLEAR(clear_module_state->__pyx_n_s_all); + Py_CLEAR(clear_module_state->__pyx_n_s_all_quadratic); + Py_CLEAR(clear_module_state->__pyx_n_s_args); + Py_CLEAR(clear_module_state->__pyx_n_s_asyncio_coroutines); + Py_CLEAR(clear_module_state->__pyx_n_s_b); + Py_CLEAR(clear_module_state->__pyx_n_s_b1); + Py_CLEAR(clear_module_state->__pyx_n_s_c); + Py_CLEAR(clear_module_state->__pyx_n_s_c1); + Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback); + Py_CLEAR(clear_module_state->__pyx_n_s_close); + Py_CLEAR(clear_module_state->__pyx_n_s_curve); + Py_CLEAR(clear_module_state->__pyx_n_s_curve_to_quadratic); + Py_CLEAR(clear_module_state->__pyx_n_u_curve_to_quadratic); + Py_CLEAR(clear_module_state->__pyx_n_s_curves); + Py_CLEAR(clear_module_state->__pyx_n_s_curves_to_quadratic); + Py_CLEAR(clear_module_state->__pyx_n_u_curves_to_quadratic); + Py_CLEAR(clear_module_state->__pyx_kp_u_curves_to_quadratic_line_474); + Py_CLEAR(clear_module_state->__pyx_n_s_cython); + Py_CLEAR(clear_module_state->__pyx_n_s_d); + Py_CLEAR(clear_module_state->__pyx_n_s_d1); + Py_CLEAR(clear_module_state->__pyx_n_s_delta_2); + Py_CLEAR(clear_module_state->__pyx_n_s_delta_3); + Py_CLEAR(clear_module_state->__pyx_kp_u_disable); + Py_CLEAR(clear_module_state->__pyx_n_s_dt); + Py_CLEAR(clear_module_state->__pyx_kp_u_enable); + Py_CLEAR(clear_module_state->__pyx_n_s_errors); + Py_CLEAR(clear_module_state->__pyx_n_s_fontTools_cu2qu_cu2qu); + Py_CLEAR(clear_module_state->__pyx_n_s_fontTools_misc); + Py_CLEAR(clear_module_state->__pyx_kp_u_gc); + Py_CLEAR(clear_module_state->__pyx_n_s_i); + Py_CLEAR(clear_module_state->__pyx_n_s_imag); + Py_CLEAR(clear_module_state->__pyx_n_s_import); + Py_CLEAR(clear_module_state->__pyx_n_s_initializing); + Py_CLEAR(clear_module_state->__pyx_n_s_is_coroutine); + Py_CLEAR(clear_module_state->__pyx_kp_u_isenabled); + Py_CLEAR(clear_module_state->__pyx_n_s_isnan); + Py_CLEAR(clear_module_state->__pyx_n_s_l); + Py_CLEAR(clear_module_state->__pyx_n_s_last_i); + Py_CLEAR(clear_module_state->__pyx_n_s_main); + Py_CLEAR(clear_module_state->__pyx_n_s_math); + Py_CLEAR(clear_module_state->__pyx_n_s_max_err); + Py_CLEAR(clear_module_state->__pyx_n_s_max_errors); + Py_CLEAR(clear_module_state->__pyx_n_s_n); + Py_CLEAR(clear_module_state->__pyx_n_s_name); + Py_CLEAR(clear_module_state->__pyx_n_s_p); + Py_CLEAR(clear_module_state->__pyx_n_s_p0); + Py_CLEAR(clear_module_state->__pyx_n_s_p1); + Py_CLEAR(clear_module_state->__pyx_n_s_p2); + Py_CLEAR(clear_module_state->__pyx_n_s_p3); + Py_CLEAR(clear_module_state->__pyx_n_s_range); + Py_CLEAR(clear_module_state->__pyx_n_s_real); + Py_CLEAR(clear_module_state->__pyx_n_s_s); + Py_CLEAR(clear_module_state->__pyx_n_s_send); + Py_CLEAR(clear_module_state->__pyx_n_s_spec); + Py_CLEAR(clear_module_state->__pyx_n_s_spline); + Py_CLEAR(clear_module_state->__pyx_n_s_splines); + Py_CLEAR(clear_module_state->__pyx_n_s_split_cubic_into_n_gen); + Py_CLEAR(clear_module_state->__pyx_n_s_t1); + Py_CLEAR(clear_module_state->__pyx_n_s_t1_2); + Py_CLEAR(clear_module_state->__pyx_n_s_test); + Py_CLEAR(clear_module_state->__pyx_n_s_throw); + Py_CLEAR(clear_module_state->__pyx_int_1); + Py_CLEAR(clear_module_state->__pyx_int_2); + Py_CLEAR(clear_module_state->__pyx_int_3); + Py_CLEAR(clear_module_state->__pyx_int_4); + Py_CLEAR(clear_module_state->__pyx_int_6); + Py_CLEAR(clear_module_state->__pyx_int_100); + Py_CLEAR(clear_module_state->__pyx_codeobj_); + Py_CLEAR(clear_module_state->__pyx_tuple__4); + Py_CLEAR(clear_module_state->__pyx_tuple__5); + Py_CLEAR(clear_module_state->__pyx_tuple__7); + Py_CLEAR(clear_module_state->__pyx_codeobj__6); + Py_CLEAR(clear_module_state->__pyx_codeobj__8); + return 0; +} +#endif +/* #### Code section: module_state_traverse ### */ +#if CYTHON_USE_MODULE_STATE +static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { + __pyx_mstate *traverse_module_state = __pyx_mstate(m); + if (!traverse_module_state) return 0; + Py_VISIT(traverse_module_state->__pyx_d); + Py_VISIT(traverse_module_state->__pyx_b); + Py_VISIT(traverse_module_state->__pyx_cython_runtime); + Py_VISIT(traverse_module_state->__pyx_empty_tuple); + Py_VISIT(traverse_module_state->__pyx_empty_bytes); + Py_VISIT(traverse_module_state->__pyx_empty_unicode); + #ifdef __Pyx_CyFunction_USED + Py_VISIT(traverse_module_state->__pyx_CyFunctionType); + #endif + #ifdef __Pyx_FusedFunction_USED + Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); + #endif + Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen); + Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen); + Py_VISIT(traverse_module_state->__pyx_n_s_ApproxNotFoundError); + Py_VISIT(traverse_module_state->__pyx_n_s_AssertionError); + Py_VISIT(traverse_module_state->__pyx_n_s_AttributeError); + Py_VISIT(traverse_module_state->__pyx_n_s_COMPILED); + Py_VISIT(traverse_module_state->__pyx_n_s_Cu2QuError); + Py_VISIT(traverse_module_state->__pyx_n_s_Error); + Py_VISIT(traverse_module_state->__pyx_n_s_ImportError); + Py_VISIT(traverse_module_state->__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py); + Py_VISIT(traverse_module_state->__pyx_n_s_MAX_N); + Py_VISIT(traverse_module_state->__pyx_n_s_NAN); + Py_VISIT(traverse_module_state->__pyx_n_u_NaN); + Py_VISIT(traverse_module_state->__pyx_kp_u_Return_quadratic_Bezier_splines); + Py_VISIT(traverse_module_state->__pyx_n_s_ZeroDivisionError); + Py_VISIT(traverse_module_state->__pyx_kp_u__2); + Py_VISIT(traverse_module_state->__pyx_n_s__3); + Py_VISIT(traverse_module_state->__pyx_n_s__9); + Py_VISIT(traverse_module_state->__pyx_n_s_a); + Py_VISIT(traverse_module_state->__pyx_n_s_a1); + Py_VISIT(traverse_module_state->__pyx_n_s_all); + Py_VISIT(traverse_module_state->__pyx_n_s_all_quadratic); + Py_VISIT(traverse_module_state->__pyx_n_s_args); + Py_VISIT(traverse_module_state->__pyx_n_s_asyncio_coroutines); + Py_VISIT(traverse_module_state->__pyx_n_s_b); + Py_VISIT(traverse_module_state->__pyx_n_s_b1); + Py_VISIT(traverse_module_state->__pyx_n_s_c); + Py_VISIT(traverse_module_state->__pyx_n_s_c1); + Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback); + Py_VISIT(traverse_module_state->__pyx_n_s_close); + Py_VISIT(traverse_module_state->__pyx_n_s_curve); + Py_VISIT(traverse_module_state->__pyx_n_s_curve_to_quadratic); + Py_VISIT(traverse_module_state->__pyx_n_u_curve_to_quadratic); + Py_VISIT(traverse_module_state->__pyx_n_s_curves); + Py_VISIT(traverse_module_state->__pyx_n_s_curves_to_quadratic); + Py_VISIT(traverse_module_state->__pyx_n_u_curves_to_quadratic); + Py_VISIT(traverse_module_state->__pyx_kp_u_curves_to_quadratic_line_474); + Py_VISIT(traverse_module_state->__pyx_n_s_cython); + Py_VISIT(traverse_module_state->__pyx_n_s_d); + Py_VISIT(traverse_module_state->__pyx_n_s_d1); + Py_VISIT(traverse_module_state->__pyx_n_s_delta_2); + Py_VISIT(traverse_module_state->__pyx_n_s_delta_3); + Py_VISIT(traverse_module_state->__pyx_kp_u_disable); + Py_VISIT(traverse_module_state->__pyx_n_s_dt); + Py_VISIT(traverse_module_state->__pyx_kp_u_enable); + Py_VISIT(traverse_module_state->__pyx_n_s_errors); + Py_VISIT(traverse_module_state->__pyx_n_s_fontTools_cu2qu_cu2qu); + Py_VISIT(traverse_module_state->__pyx_n_s_fontTools_misc); + Py_VISIT(traverse_module_state->__pyx_kp_u_gc); + Py_VISIT(traverse_module_state->__pyx_n_s_i); + Py_VISIT(traverse_module_state->__pyx_n_s_imag); + Py_VISIT(traverse_module_state->__pyx_n_s_import); + Py_VISIT(traverse_module_state->__pyx_n_s_initializing); + Py_VISIT(traverse_module_state->__pyx_n_s_is_coroutine); + Py_VISIT(traverse_module_state->__pyx_kp_u_isenabled); + Py_VISIT(traverse_module_state->__pyx_n_s_isnan); + Py_VISIT(traverse_module_state->__pyx_n_s_l); + Py_VISIT(traverse_module_state->__pyx_n_s_last_i); + Py_VISIT(traverse_module_state->__pyx_n_s_main); + Py_VISIT(traverse_module_state->__pyx_n_s_math); + Py_VISIT(traverse_module_state->__pyx_n_s_max_err); + Py_VISIT(traverse_module_state->__pyx_n_s_max_errors); + Py_VISIT(traverse_module_state->__pyx_n_s_n); + Py_VISIT(traverse_module_state->__pyx_n_s_name); + Py_VISIT(traverse_module_state->__pyx_n_s_p); + Py_VISIT(traverse_module_state->__pyx_n_s_p0); + Py_VISIT(traverse_module_state->__pyx_n_s_p1); + Py_VISIT(traverse_module_state->__pyx_n_s_p2); + Py_VISIT(traverse_module_state->__pyx_n_s_p3); + Py_VISIT(traverse_module_state->__pyx_n_s_range); + Py_VISIT(traverse_module_state->__pyx_n_s_real); + Py_VISIT(traverse_module_state->__pyx_n_s_s); + Py_VISIT(traverse_module_state->__pyx_n_s_send); + Py_VISIT(traverse_module_state->__pyx_n_s_spec); + Py_VISIT(traverse_module_state->__pyx_n_s_spline); + Py_VISIT(traverse_module_state->__pyx_n_s_splines); + Py_VISIT(traverse_module_state->__pyx_n_s_split_cubic_into_n_gen); + Py_VISIT(traverse_module_state->__pyx_n_s_t1); + Py_VISIT(traverse_module_state->__pyx_n_s_t1_2); + Py_VISIT(traverse_module_state->__pyx_n_s_test); + Py_VISIT(traverse_module_state->__pyx_n_s_throw); + Py_VISIT(traverse_module_state->__pyx_int_1); + Py_VISIT(traverse_module_state->__pyx_int_2); + Py_VISIT(traverse_module_state->__pyx_int_3); + Py_VISIT(traverse_module_state->__pyx_int_4); + Py_VISIT(traverse_module_state->__pyx_int_6); + Py_VISIT(traverse_module_state->__pyx_int_100); + Py_VISIT(traverse_module_state->__pyx_codeobj_); + Py_VISIT(traverse_module_state->__pyx_tuple__4); + Py_VISIT(traverse_module_state->__pyx_tuple__5); + Py_VISIT(traverse_module_state->__pyx_tuple__7); + Py_VISIT(traverse_module_state->__pyx_codeobj__6); + Py_VISIT(traverse_module_state->__pyx_codeobj__8); + return 0; +} +#endif +/* #### Code section: module_state_defines ### */ +#define __pyx_d __pyx_mstate_global->__pyx_d +#define __pyx_b __pyx_mstate_global->__pyx_b +#define __pyx_cython_runtime __pyx_mstate_global->__pyx_cython_runtime +#define __pyx_empty_tuple __pyx_mstate_global->__pyx_empty_tuple +#define __pyx_empty_bytes __pyx_mstate_global->__pyx_empty_bytes +#define __pyx_empty_unicode __pyx_mstate_global->__pyx_empty_unicode +#ifdef __Pyx_CyFunction_USED +#define __pyx_CyFunctionType __pyx_mstate_global->__pyx_CyFunctionType +#endif +#ifdef __Pyx_FusedFunction_USED +#define __pyx_FusedFunctionType __pyx_mstate_global->__pyx_FusedFunctionType +#endif +#ifdef __Pyx_Generator_USED +#define __pyx_GeneratorType __pyx_mstate_global->__pyx_GeneratorType +#endif +#ifdef __Pyx_IterableCoroutine_USED +#define __pyx_IterableCoroutineType __pyx_mstate_global->__pyx_IterableCoroutineType +#endif +#ifdef __Pyx_Coroutine_USED +#define __pyx_CoroutineAwaitType __pyx_mstate_global->__pyx_CoroutineAwaitType +#endif +#ifdef __Pyx_Coroutine_USED +#define __pyx_CoroutineType __pyx_mstate_global->__pyx_CoroutineType +#endif +#if CYTHON_USE_MODULE_STATE +#endif +#if CYTHON_USE_MODULE_STATE +#define __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen __pyx_mstate_global->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen +#endif +#define __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen __pyx_mstate_global->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen +#define __pyx_n_s_ApproxNotFoundError __pyx_mstate_global->__pyx_n_s_ApproxNotFoundError +#define __pyx_n_s_AssertionError __pyx_mstate_global->__pyx_n_s_AssertionError +#define __pyx_n_s_AttributeError __pyx_mstate_global->__pyx_n_s_AttributeError +#define __pyx_n_s_COMPILED __pyx_mstate_global->__pyx_n_s_COMPILED +#define __pyx_n_s_Cu2QuError __pyx_mstate_global->__pyx_n_s_Cu2QuError +#define __pyx_n_s_Error __pyx_mstate_global->__pyx_n_s_Error +#define __pyx_n_s_ImportError __pyx_mstate_global->__pyx_n_s_ImportError +#define __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py __pyx_mstate_global->__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py +#define __pyx_n_s_MAX_N __pyx_mstate_global->__pyx_n_s_MAX_N +#define __pyx_n_s_NAN __pyx_mstate_global->__pyx_n_s_NAN +#define __pyx_n_u_NaN __pyx_mstate_global->__pyx_n_u_NaN +#define __pyx_kp_u_Return_quadratic_Bezier_splines __pyx_mstate_global->__pyx_kp_u_Return_quadratic_Bezier_splines +#define __pyx_n_s_ZeroDivisionError __pyx_mstate_global->__pyx_n_s_ZeroDivisionError +#define __pyx_kp_u__2 __pyx_mstate_global->__pyx_kp_u__2 +#define __pyx_n_s__3 __pyx_mstate_global->__pyx_n_s__3 +#define __pyx_n_s__9 __pyx_mstate_global->__pyx_n_s__9 +#define __pyx_n_s_a __pyx_mstate_global->__pyx_n_s_a +#define __pyx_n_s_a1 __pyx_mstate_global->__pyx_n_s_a1 +#define __pyx_n_s_all __pyx_mstate_global->__pyx_n_s_all +#define __pyx_n_s_all_quadratic __pyx_mstate_global->__pyx_n_s_all_quadratic +#define __pyx_n_s_args __pyx_mstate_global->__pyx_n_s_args +#define __pyx_n_s_asyncio_coroutines __pyx_mstate_global->__pyx_n_s_asyncio_coroutines +#define __pyx_n_s_b __pyx_mstate_global->__pyx_n_s_b +#define __pyx_n_s_b1 __pyx_mstate_global->__pyx_n_s_b1 +#define __pyx_n_s_c __pyx_mstate_global->__pyx_n_s_c +#define __pyx_n_s_c1 __pyx_mstate_global->__pyx_n_s_c1 +#define __pyx_n_s_cline_in_traceback __pyx_mstate_global->__pyx_n_s_cline_in_traceback +#define __pyx_n_s_close __pyx_mstate_global->__pyx_n_s_close +#define __pyx_n_s_curve __pyx_mstate_global->__pyx_n_s_curve +#define __pyx_n_s_curve_to_quadratic __pyx_mstate_global->__pyx_n_s_curve_to_quadratic +#define __pyx_n_u_curve_to_quadratic __pyx_mstate_global->__pyx_n_u_curve_to_quadratic +#define __pyx_n_s_curves __pyx_mstate_global->__pyx_n_s_curves +#define __pyx_n_s_curves_to_quadratic __pyx_mstate_global->__pyx_n_s_curves_to_quadratic +#define __pyx_n_u_curves_to_quadratic __pyx_mstate_global->__pyx_n_u_curves_to_quadratic +#define __pyx_kp_u_curves_to_quadratic_line_474 __pyx_mstate_global->__pyx_kp_u_curves_to_quadratic_line_474 +#define __pyx_n_s_cython __pyx_mstate_global->__pyx_n_s_cython +#define __pyx_n_s_d __pyx_mstate_global->__pyx_n_s_d +#define __pyx_n_s_d1 __pyx_mstate_global->__pyx_n_s_d1 +#define __pyx_n_s_delta_2 __pyx_mstate_global->__pyx_n_s_delta_2 +#define __pyx_n_s_delta_3 __pyx_mstate_global->__pyx_n_s_delta_3 +#define __pyx_kp_u_disable __pyx_mstate_global->__pyx_kp_u_disable +#define __pyx_n_s_dt __pyx_mstate_global->__pyx_n_s_dt +#define __pyx_kp_u_enable __pyx_mstate_global->__pyx_kp_u_enable +#define __pyx_n_s_errors __pyx_mstate_global->__pyx_n_s_errors +#define __pyx_n_s_fontTools_cu2qu_cu2qu __pyx_mstate_global->__pyx_n_s_fontTools_cu2qu_cu2qu +#define __pyx_n_s_fontTools_misc __pyx_mstate_global->__pyx_n_s_fontTools_misc +#define __pyx_kp_u_gc __pyx_mstate_global->__pyx_kp_u_gc +#define __pyx_n_s_i __pyx_mstate_global->__pyx_n_s_i +#define __pyx_n_s_imag __pyx_mstate_global->__pyx_n_s_imag +#define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import +#define __pyx_n_s_initializing __pyx_mstate_global->__pyx_n_s_initializing +#define __pyx_n_s_is_coroutine __pyx_mstate_global->__pyx_n_s_is_coroutine +#define __pyx_kp_u_isenabled __pyx_mstate_global->__pyx_kp_u_isenabled +#define __pyx_n_s_isnan __pyx_mstate_global->__pyx_n_s_isnan +#define __pyx_n_s_l __pyx_mstate_global->__pyx_n_s_l +#define __pyx_n_s_last_i __pyx_mstate_global->__pyx_n_s_last_i +#define __pyx_n_s_main __pyx_mstate_global->__pyx_n_s_main +#define __pyx_n_s_math __pyx_mstate_global->__pyx_n_s_math +#define __pyx_n_s_max_err __pyx_mstate_global->__pyx_n_s_max_err +#define __pyx_n_s_max_errors __pyx_mstate_global->__pyx_n_s_max_errors +#define __pyx_n_s_n __pyx_mstate_global->__pyx_n_s_n +#define __pyx_n_s_name __pyx_mstate_global->__pyx_n_s_name +#define __pyx_n_s_p __pyx_mstate_global->__pyx_n_s_p +#define __pyx_n_s_p0 __pyx_mstate_global->__pyx_n_s_p0 +#define __pyx_n_s_p1 __pyx_mstate_global->__pyx_n_s_p1 +#define __pyx_n_s_p2 __pyx_mstate_global->__pyx_n_s_p2 +#define __pyx_n_s_p3 __pyx_mstate_global->__pyx_n_s_p3 +#define __pyx_n_s_range __pyx_mstate_global->__pyx_n_s_range +#define __pyx_n_s_real __pyx_mstate_global->__pyx_n_s_real +#define __pyx_n_s_s __pyx_mstate_global->__pyx_n_s_s +#define __pyx_n_s_send __pyx_mstate_global->__pyx_n_s_send +#define __pyx_n_s_spec __pyx_mstate_global->__pyx_n_s_spec +#define __pyx_n_s_spline __pyx_mstate_global->__pyx_n_s_spline +#define __pyx_n_s_splines __pyx_mstate_global->__pyx_n_s_splines +#define __pyx_n_s_split_cubic_into_n_gen __pyx_mstate_global->__pyx_n_s_split_cubic_into_n_gen +#define __pyx_n_s_t1 __pyx_mstate_global->__pyx_n_s_t1 +#define __pyx_n_s_t1_2 __pyx_mstate_global->__pyx_n_s_t1_2 +#define __pyx_n_s_test __pyx_mstate_global->__pyx_n_s_test +#define __pyx_n_s_throw __pyx_mstate_global->__pyx_n_s_throw +#define __pyx_int_1 __pyx_mstate_global->__pyx_int_1 +#define __pyx_int_2 __pyx_mstate_global->__pyx_int_2 +#define __pyx_int_3 __pyx_mstate_global->__pyx_int_3 +#define __pyx_int_4 __pyx_mstate_global->__pyx_int_4 +#define __pyx_int_6 __pyx_mstate_global->__pyx_int_6 +#define __pyx_int_100 __pyx_mstate_global->__pyx_int_100 +#define __pyx_codeobj_ __pyx_mstate_global->__pyx_codeobj_ +#define __pyx_tuple__4 __pyx_mstate_global->__pyx_tuple__4 +#define __pyx_tuple__5 __pyx_mstate_global->__pyx_tuple__5 +#define __pyx_tuple__7 __pyx_mstate_global->__pyx_tuple__7 +#define __pyx_codeobj__6 __pyx_mstate_global->__pyx_codeobj__6 +#define __pyx_codeobj__8 __pyx_mstate_global->__pyx_codeobj__8 +/* #### Code section: module_code ### */ + +/* "fontTools/cu2qu/cu2qu.py":40 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.double) + */ + +static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex __pyx_v_v1, __pyx_t_double_complex __pyx_v_v2) { + double __pyx_r; + + /* "fontTools/cu2qu/cu2qu.py":54 + * double: Dot product. + * """ + * return (v1 * v2.conjugate()).real # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __Pyx_CREAL(__Pyx_c_prod_double(__pyx_v_v1, __Pyx_c_conj_double(__pyx_v_v2))); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":40 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.double) + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":57 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) { + __pyx_t_double_complex __pyx_v__1; + __pyx_t_double_complex __pyx_v__2; + __pyx_t_double_complex __pyx_v__3; + __pyx_t_double_complex __pyx_v__4; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __pyx_t_double_complex __pyx_t_1; + __pyx_t_double_complex __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("calc_cubic_points", 1); + + /* "fontTools/cu2qu/cu2qu.py":64 + * ) + * def calc_cubic_points(a, b, c, d): + * _1 = d # <<<<<<<<<<<<<< + * _2 = (c / 3.0) + d + * _3 = (b + c) / 3.0 + _2 + */ + __pyx_v__1 = __pyx_v_d; + + /* "fontTools/cu2qu/cu2qu.py":65 + * def calc_cubic_points(a, b, c, d): + * _1 = d + * _2 = (c / 3.0) + d # <<<<<<<<<<<<<< + * _3 = (b + c) / 3.0 + _2 + * _4 = a + d + c + b + */ + __pyx_t_1 = __pyx_t_double_complex_from_parts(3.0, 0); + if (unlikely(__Pyx_c_is_zero_double(__pyx_t_1))) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 65, __pyx_L1_error) + } + __pyx_v__2 = __Pyx_c_sum_double(__Pyx_c_quot_double(__pyx_v_c, __pyx_t_1), __pyx_v_d); + + /* "fontTools/cu2qu/cu2qu.py":66 + * _1 = d + * _2 = (c / 3.0) + d + * _3 = (b + c) / 3.0 + _2 # <<<<<<<<<<<<<< + * _4 = a + d + c + b + * return _1, _2, _3, _4 + */ + __pyx_t_1 = __Pyx_c_sum_double(__pyx_v_b, __pyx_v_c); + __pyx_t_2 = __pyx_t_double_complex_from_parts(3.0, 0); + if (unlikely(__Pyx_c_is_zero_double(__pyx_t_2))) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 66, __pyx_L1_error) + } + __pyx_v__3 = __Pyx_c_sum_double(__Pyx_c_quot_double(__pyx_t_1, __pyx_t_2), __pyx_v__2); + + /* "fontTools/cu2qu/cu2qu.py":67 + * _2 = (c / 3.0) + d + * _3 = (b + c) / 3.0 + _2 + * _4 = a + d + c + b # <<<<<<<<<<<<<< + * return _1, _2, _3, _4 + * + */ + __pyx_v__4 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_a, __pyx_v_d), __pyx_v_c), __pyx_v_b); + + /* "fontTools/cu2qu/cu2qu.py":68 + * _3 = (b + c) / 3.0 + _2 + * _4 = a + d + c + b + * return _1, _2, _3, _4 # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v__1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v__3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_v__4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_3); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_4); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":57 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_points", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":71 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { + __pyx_t_double_complex __pyx_v_a; + __pyx_t_double_complex __pyx_v_b; + __pyx_t_double_complex __pyx_v_c; + __pyx_t_double_complex __pyx_v_d; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("calc_cubic_parameters", 1); + + /* "fontTools/cu2qu/cu2qu.py":78 + * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) + * def calc_cubic_parameters(p0, p1, p2, p3): + * c = (p1 - p0) * 3.0 # <<<<<<<<<<<<<< + * b = (p2 - p1) * 3.0 - c + * d = p0 + */ + __pyx_v_c = __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(3.0, 0)); + + /* "fontTools/cu2qu/cu2qu.py":79 + * def calc_cubic_parameters(p0, p1, p2, p3): + * c = (p1 - p0) * 3.0 + * b = (p2 - p1) * 3.0 - c # <<<<<<<<<<<<<< + * d = p0 + * a = p3 - d - c - b + */ + __pyx_v_b = __Pyx_c_diff_double(__Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p1), __pyx_t_double_complex_from_parts(3.0, 0)), __pyx_v_c); + + /* "fontTools/cu2qu/cu2qu.py":80 + * c = (p1 - p0) * 3.0 + * b = (p2 - p1) * 3.0 - c + * d = p0 # <<<<<<<<<<<<<< + * a = p3 - d - c - b + * return a, b, c, d + */ + __pyx_v_d = __pyx_v_p0; + + /* "fontTools/cu2qu/cu2qu.py":81 + * b = (p2 - p1) * 3.0 - c + * d = p0 + * a = p3 - d - c - b # <<<<<<<<<<<<<< + * return a, b, c, d + * + */ + __pyx_v_a = __Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__pyx_v_p3, __pyx_v_d), __pyx_v_c), __pyx_v_b); + + /* "fontTools/cu2qu/cu2qu.py":82 + * d = p0 + * a = p3 - d - c - b + * return a, b, c, d # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v_c); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_2); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_3); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_4); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":71 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":85 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, PyObject *__pyx_v_n) { + PyObject *__pyx_v_a = NULL; + PyObject *__pyx_v_b = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + __pyx_t_double_complex __pyx_t_7; + __pyx_t_double_complex __pyx_t_8; + __pyx_t_double_complex __pyx_t_9; + __pyx_t_double_complex __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("split_cubic_into_n_iter", 1); + + /* "fontTools/cu2qu/cu2qu.py":107 + * """ + * # Hand-coded special-cases + * if n == 2: # <<<<<<<<<<<<<< + * return iter(split_cubic_into_two(p0, p1, p2, p3)) + * if n == 3: + */ + __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_n, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 107, __pyx_L1_error) + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":108 + * # Hand-coded special-cases + * if n == 2: + * return iter(split_cubic_into_two(p0, p1, p2, p3)) # <<<<<<<<<<<<<< + * if n == 3: + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":107 + * """ + * # Hand-coded special-cases + * if n == 2: # <<<<<<<<<<<<<< + * return iter(split_cubic_into_two(p0, p1, p2, p3)) + * if n == 3: + */ + } + + /* "fontTools/cu2qu/cu2qu.py":109 + * if n == 2: + * return iter(split_cubic_into_two(p0, p1, p2, p3)) + * if n == 3: # <<<<<<<<<<<<<< + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + * if n == 4: + */ + __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_n, __pyx_int_3, 3, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 109, __pyx_L1_error) + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":110 + * return iter(split_cubic_into_two(p0, p1, p2, p3)) + * if n == 3: + * return iter(split_cubic_into_three(p0, p1, p2, p3)) # <<<<<<<<<<<<<< + * if n == 4: + * a, b = split_cubic_into_two(p0, p1, p2, p3) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":109 + * if n == 2: + * return iter(split_cubic_into_two(p0, p1, p2, p3)) + * if n == 3: # <<<<<<<<<<<<<< + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + * if n == 4: + */ + } + + /* "fontTools/cu2qu/cu2qu.py":111 + * if n == 3: + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + * if n == 4: # <<<<<<<<<<<<<< + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + */ + __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_n, __pyx_int_4, 4, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 111, __pyx_L1_error) + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":112 + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + * if n == 4: + * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<< + * return iter( + * split_cubic_into_two(a[0], a[1], a[2], a[3]) + */ + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { + PyObject* sequence = __pyx_t_2; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 112, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_3 = PyList_GET_ITEM(sequence, 0); + __pyx_t_4 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L7_unpacking_done; + __pyx_L6_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_L7_unpacking_done:; + } + __pyx_v_a = __pyx_t_3; + __pyx_t_3 = 0; + __pyx_v_b = __pyx_t_4; + __pyx_t_4 = 0; + + /* "fontTools/cu2qu/cu2qu.py":113 + * if n == 4: + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( # <<<<<<<<<<<<<< + * split_cubic_into_two(a[0], a[1], a[2], a[3]) + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) + */ + __Pyx_XDECREF(__pyx_r); + + /* "fontTools/cu2qu/cu2qu.py":114 + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + * split_cubic_into_two(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<< + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) + * ) + */ + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + + /* "fontTools/cu2qu/cu2qu.py":115 + * return iter( + * split_cubic_into_two(a[0], a[1], a[2], a[3]) + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<< + * ) + * if n == 6: + */ + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "fontTools/cu2qu/cu2qu.py":113 + * if n == 4: + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( # <<<<<<<<<<<<<< + * split_cubic_into_two(a[0], a[1], a[2], a[3]) + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) + */ + __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":111 + * if n == 3: + * return iter(split_cubic_into_three(p0, p1, p2, p3)) + * if n == 4: # <<<<<<<<<<<<<< + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + */ + } + + /* "fontTools/cu2qu/cu2qu.py":117 + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) + * ) + * if n == 6: # <<<<<<<<<<<<<< + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + */ + __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_n, __pyx_int_6, 6, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 117, __pyx_L1_error) + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":118 + * ) + * if n == 6: + * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<< + * return iter( + * split_cubic_into_three(a[0], a[1], a[2], a[3]) + */ + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 118, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_3 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L10_unpacking_done; + __pyx_L9_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_L10_unpacking_done:; + } + __pyx_v_a = __pyx_t_3; + __pyx_t_3 = 0; + __pyx_v_b = __pyx_t_2; + __pyx_t_2 = 0; + + /* "fontTools/cu2qu/cu2qu.py":119 + * if n == 6: + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( # <<<<<<<<<<<<<< + * split_cubic_into_three(a[0], a[1], a[2], a[3]) + * + split_cubic_into_three(b[0], b[1], b[2], b[3]) + */ + __Pyx_XDECREF(__pyx_r); + + /* "fontTools/cu2qu/cu2qu.py":120 + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + * split_cubic_into_three(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<< + * + split_cubic_into_three(b[0], b[1], b[2], b[3]) + * ) + */ + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + + /* "fontTools/cu2qu/cu2qu.py":121 + * return iter( + * split_cubic_into_three(a[0], a[1], a[2], a[3]) + * + split_cubic_into_three(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<< + * ) + * + */ + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "fontTools/cu2qu/cu2qu.py":119 + * if n == 6: + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( # <<<<<<<<<<<<<< + * split_cubic_into_three(a[0], a[1], a[2], a[3]) + * + split_cubic_into_three(b[0], b[1], b[2], b[3]) + */ + __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":117 + * + split_cubic_into_two(b[0], b[1], b[2], b[3]) + * ) + * if n == 6: # <<<<<<<<<<<<<< + * a, b = split_cubic_into_two(p0, p1, p2, p3) + * return iter( + */ + } + + /* "fontTools/cu2qu/cu2qu.py":124 + * ) + * + * return _split_cubic_into_n_gen(p0, p1, p2, p3, n) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_split_cubic_into_n_gen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_11 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_12 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = NULL; + __pyx_t_14 = 0; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_13)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_13); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_14 = 1; + } + } + #endif + { + PyObject *__pyx_callargs[6] = {__pyx_t_13, __pyx_t_4, __pyx_t_5, __pyx_t_11, __pyx_t_12, __pyx_v_n}; + __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_14, 5+__pyx_t_14); + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":85 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_n_iter", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_a); + __Pyx_XDECREF(__pyx_v_b); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ + +/* "fontTools/cu2qu/cu2qu.py":127 + * + * + * @cython.locals( # <<<<<<<<<<<<<< + * p0=cython.complex, + * p1=cython.complex, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen, "_split_cubic_into_n_gen(double complex p0, double complex p1, double complex p2, double complex p3, int n)"); +static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen = {"_split_cubic_into_n_gen", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen}; +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + __pyx_t_double_complex __pyx_v_p0; + __pyx_t_double_complex __pyx_v_p1; + __pyx_t_double_complex __pyx_v_p2; + __pyx_t_double_complex __pyx_v_p3; + int __pyx_v_n; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[5] = {0,0,0,0,0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_split_cubic_into_n_gen (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject **__pyx_pyargnames[] = {&__pyx_n_s_p0,&__pyx_n_s_p1,&__pyx_n_s_p2,&__pyx_n_s_p3,&__pyx_n_s_n,0}; + if (__pyx_kwds) { + Py_ssize_t kw_args; + switch (__pyx_nargs) { + case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); + switch (__pyx_nargs) { + case 0: + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_p0)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_p1)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 1); __PYX_ERR(0, 127, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_p2)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 2); __PYX_ERR(0, 127, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 3: + if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_p3)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[3]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 3); __PYX_ERR(0, 127, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 4: + if (likely((values[4] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[4]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 4); __PYX_ERR(0, 127, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_split_cubic_into_n_gen") < 0)) __PYX_ERR(0, 127, __pyx_L3_error) + } + } else if (unlikely(__pyx_nargs != 5)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); + values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); + } + __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_p3 = __Pyx_PyComplex_As___pyx_t_double_complex(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + __pyx_v_n = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 127, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(__pyx_self, __pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3, __pyx_v_n); + + /* function exit code */ + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n) { + struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0); + __pyx_cur_scope = (struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 127, __pyx_L1_error) + } else { + __Pyx_GOTREF((PyObject *)__pyx_cur_scope); + } + __pyx_cur_scope->__pyx_v_p0 = __pyx_v_p0; + __pyx_cur_scope->__pyx_v_p1 = __pyx_v_p1; + __pyx_cur_scope->__pyx_v_p2 = __pyx_v_p2; + __pyx_cur_scope->__pyx_v_p3 = __pyx_v_p3; + __pyx_cur_scope->__pyx_v_n = __pyx_v_n; + { + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator, __pyx_codeobj_, (PyObject *) __pyx_cur_scope, __pyx_n_s_split_cubic_into_n_gen, __pyx_n_s_split_cubic_into_n_gen, __pyx_n_s_fontTools_cu2qu_cu2qu); if (unlikely(!gen)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF((PyObject *)__pyx_cur_scope); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *(*__pyx_t_7)(PyObject *); + __pyx_t_double_complex __pyx_t_8; + __pyx_t_double_complex __pyx_t_9; + __pyx_t_double_complex __pyx_t_10; + __pyx_t_double_complex __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L8_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 127, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":142 + * ) + * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): + * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) # <<<<<<<<<<<<<< + * dt = 1 / n + * delta_2 = dt * dt + */ + __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_cur_scope->__pyx_v_p0, __pyx_cur_scope->__pyx_v_p1, __pyx_cur_scope->__pyx_v_p2, __pyx_cur_scope->__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 4)) { + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 142, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); + } else { + __pyx_t_2 = PyList_GET_ITEM(sequence, 0); + __pyx_t_3 = PyList_GET_ITEM(sequence, 1); + __pyx_t_4 = PyList_GET_ITEM(sequence, 2); + __pyx_t_5 = PyList_GET_ITEM(sequence, 3); + } + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + #else + { + Py_ssize_t i; + PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5}; + for (i=0; i < 4; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5}; + __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); + for (index=0; index < 4; index++) { + PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L4_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_7 = NULL; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L5_unpacking_done; + __pyx_L4_unpacking_failed:; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_L5_unpacking_done:; + } + __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_11 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_cur_scope->__pyx_v_a = __pyx_t_8; + __pyx_cur_scope->__pyx_v_b = __pyx_t_9; + __pyx_cur_scope->__pyx_v_c = __pyx_t_10; + __pyx_cur_scope->__pyx_v_d = __pyx_t_11; + + /* "fontTools/cu2qu/cu2qu.py":143 + * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): + * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) + * dt = 1 / n # <<<<<<<<<<<<<< + * delta_2 = dt * dt + * delta_3 = dt * delta_2 + */ + if (unlikely(__pyx_cur_scope->__pyx_v_n == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 143, __pyx_L1_error) + } + __pyx_cur_scope->__pyx_v_dt = (1.0 / ((double)__pyx_cur_scope->__pyx_v_n)); + + /* "fontTools/cu2qu/cu2qu.py":144 + * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) + * dt = 1 / n + * delta_2 = dt * dt # <<<<<<<<<<<<<< + * delta_3 = dt * delta_2 + * for i in range(n): + */ + __pyx_cur_scope->__pyx_v_delta_2 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_dt); + + /* "fontTools/cu2qu/cu2qu.py":145 + * dt = 1 / n + * delta_2 = dt * dt + * delta_3 = dt * delta_2 # <<<<<<<<<<<<<< + * for i in range(n): + * t1 = i * dt + */ + __pyx_cur_scope->__pyx_v_delta_3 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_delta_2); + + /* "fontTools/cu2qu/cu2qu.py":146 + * delta_2 = dt * dt + * delta_3 = dt * delta_2 + * for i in range(n): # <<<<<<<<<<<<<< + * t1 = i * dt + * t1_2 = t1 * t1 + */ + __pyx_t_12 = __pyx_cur_scope->__pyx_v_n; + __pyx_t_13 = __pyx_t_12; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { + __pyx_cur_scope->__pyx_v_i = __pyx_t_14; + + /* "fontTools/cu2qu/cu2qu.py":147 + * delta_3 = dt * delta_2 + * for i in range(n): + * t1 = i * dt # <<<<<<<<<<<<<< + * t1_2 = t1 * t1 + * # calc new a, b, c and d + */ + __pyx_cur_scope->__pyx_v_t1 = (__pyx_cur_scope->__pyx_v_i * __pyx_cur_scope->__pyx_v_dt); + + /* "fontTools/cu2qu/cu2qu.py":148 + * for i in range(n): + * t1 = i * dt + * t1_2 = t1 * t1 # <<<<<<<<<<<<<< + * # calc new a, b, c and d + * a1 = a * delta_3 + */ + __pyx_cur_scope->__pyx_v_t1_2 = (__pyx_cur_scope->__pyx_v_t1 * __pyx_cur_scope->__pyx_v_t1); + + /* "fontTools/cu2qu/cu2qu.py":150 + * t1_2 = t1 * t1 + * # calc new a, b, c and d + * a1 = a * delta_3 # <<<<<<<<<<<<<< + * b1 = (3 * a * t1 + b) * delta_2 + * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt + */ + __pyx_cur_scope->__pyx_v_a1 = __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_3, 0)); + + /* "fontTools/cu2qu/cu2qu.py":151 + * # calc new a, b, c and d + * a1 = a * delta_3 + * b1 = (3 * a * t1 + b) * delta_2 # <<<<<<<<<<<<<< + * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt + * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d + */ + __pyx_cur_scope->__pyx_v_b1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_2, 0)); + + /* "fontTools/cu2qu/cu2qu.py":152 + * a1 = a * delta_3 + * b1 = (3 * a * t1 + b) * delta_2 + * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt # <<<<<<<<<<<<<< + * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d + * yield calc_cubic_points(a1, b1, c1, d1) + */ + __pyx_cur_scope->__pyx_v_c1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_c), __Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_dt, 0)); + + /* "fontTools/cu2qu/cu2qu.py":153 + * b1 = (3 * a * t1 + b) * delta_2 + * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt + * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d # <<<<<<<<<<<<<< + * yield calc_cubic_points(a1, b1, c1, d1) + * + */ + __pyx_cur_scope->__pyx_v_d1 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0)), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_b, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_c, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0))), __pyx_cur_scope->__pyx_v_d); + + /* "fontTools/cu2qu/cu2qu.py":154 + * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt + * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d + * yield calc_cubic_points(a1, b1, c1, d1) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_cur_scope->__pyx_v_a1, __pyx_cur_scope->__pyx_v_b1, __pyx_cur_scope->__pyx_v_c1, __pyx_cur_scope->__pyx_v_d1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_12; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_13; + __pyx_cur_scope->__pyx_t_2 = __pyx_t_14; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L8_resume_from_yield:; + __pyx_t_12 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_13 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_14 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 154, __pyx_L1_error) + } + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* "fontTools/cu2qu/cu2qu.py":127 + * + * + * @cython.locals( # <<<<<<<<<<<<<< + * p0=cython.complex, + * p1=cython.complex, + */ + + /* function exit code */ + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_Generator_Replace_StopIteration(0); + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("_split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + #if !CYTHON_USE_EXC_INFO_STACK + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + #endif + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":157 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { + __pyx_t_double_complex __pyx_v_mid; + __pyx_t_double_complex __pyx_v_deriv3; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_double_complex __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("split_cubic_into_two", 1); + + /* "fontTools/cu2qu/cu2qu.py":178 + * values). + * """ + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<< + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return ( + */ + __pyx_v_mid = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __Pyx_c_sum_double(__pyx_v_p1, __pyx_v_p2))), __pyx_v_p3), __pyx_t_double_complex_from_parts(0.125, 0)); + + /* "fontTools/cu2qu/cu2qu.py":179 + * """ + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<< + * return ( + * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), + */ + __pyx_v_deriv3 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __pyx_v_p2), __pyx_v_p1), __pyx_v_p0), __pyx_t_double_complex_from_parts(0.125, 0)); + + /* "fontTools/cu2qu/cu2qu.py":180 + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return ( # <<<<<<<<<<<<<< + * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), + * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), + */ + __Pyx_XDECREF(__pyx_r); + + /* "fontTools/cu2qu/cu2qu.py":181 + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return ( + * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<< + * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), + * ) + */ + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0)); + __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3); + __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_3); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_4); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + + /* "fontTools/cu2qu/cu2qu.py":182 + * return ( + * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), + * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), # <<<<<<<<<<<<<< + * ) + * + */ + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3); + __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0)); + __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5)) __PYX_ERR(0, 182, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_4); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4)) __PYX_ERR(0, 182, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_3); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error); + __pyx_t_5 = 0; + __pyx_t_4 = 0; + __pyx_t_3 = 0; + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":181 + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return ( + * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<< + * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), + * ) + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_7); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":157 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_two", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":186 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { + __pyx_t_double_complex __pyx_v_mid1; + __pyx_t_double_complex __pyx_v_deriv1; + __pyx_t_double_complex __pyx_v_mid2; + __pyx_t_double_complex __pyx_v_deriv2; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_double_complex __pyx_t_2; + __pyx_t_double_complex __pyx_t_3; + __pyx_t_double_complex __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("split_cubic_into_three", 1); + + /* "fontTools/cu2qu/cu2qu.py":215 + * values). + * """ + * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) # <<<<<<<<<<<<<< + * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) + * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) + */ + __pyx_v_mid1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p0), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p2)), __pyx_v_p3), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); + + /* "fontTools/cu2qu/cu2qu.py":216 + * """ + * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) + * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) # <<<<<<<<<<<<<< + * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + */ + __pyx_v_deriv1 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p0)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); + + /* "fontTools/cu2qu/cu2qu.py":217 + * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) + * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) + * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) # <<<<<<<<<<<<<< + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + * return ( + */ + __pyx_v_mid2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p3)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); + + /* "fontTools/cu2qu/cu2qu.py":218 + * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) + * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) # <<<<<<<<<<<<<< + * return ( + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), + */ + __pyx_v_deriv2 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p3), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p1)), __pyx_v_p0), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); + + /* "fontTools/cu2qu/cu2qu.py":219 + * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + * return ( # <<<<<<<<<<<<<< + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), + * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), + */ + __Pyx_XDECREF(__pyx_r); + + /* "fontTools/cu2qu/cu2qu.py":220 + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + * return ( + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<< + * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), + * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), + */ + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p0), __pyx_v_p1); + __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0); + if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 220, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_c_quot_double(__pyx_t_2, __pyx_t_3); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid1, __pyx_v_deriv1); + __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6)) __PYX_ERR(0, 220, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_7); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + + /* "fontTools/cu2qu/cu2qu.py":221 + * return ( + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), + * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), # <<<<<<<<<<<<<< + * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), + * ) + */ + __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid1, __pyx_v_deriv1); + __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid2, __pyx_v_deriv2); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_7); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7)) __PYX_ERR(0, 221, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error); + __pyx_t_7 = 0; + __pyx_t_6 = 0; + __pyx_t_5 = 0; + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":222 + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), + * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), + * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), # <<<<<<<<<<<<<< + * ) + * + */ + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid2, __pyx_v_deriv2); + __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_p2, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p3)); + __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0); + if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 222, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_c_quot_double(__pyx_t_4, __pyx_t_3); + __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5)) __PYX_ERR(0, 222, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_7); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + + /* "fontTools/cu2qu/cu2qu.py":220 + * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + * return ( + * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<< + * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), + * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), + */ + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8)) __PYX_ERR(0, 220, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_9); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9)) __PYX_ERR(0, 220, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_10); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10)) __PYX_ERR(0, 220, __pyx_L1_error); + __pyx_t_8 = 0; + __pyx_t_9 = 0; + __pyx_t_10 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":186 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals( + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_three", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":226 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.complex) + */ + +static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double __pyx_v_t, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { + __pyx_t_double_complex __pyx_v__p1; + __pyx_t_double_complex __pyx_v__p2; + __pyx_t_double_complex __pyx_r; + + /* "fontTools/cu2qu/cu2qu.py":250 + * complex: Location of candidate control point on quadratic curve. + * """ + * _p1 = p0 + (p1 - p0) * 1.5 # <<<<<<<<<<<<<< + * _p2 = p3 + (p2 - p3) * 1.5 + * return _p1 + (_p2 - _p1) * t + */ + __pyx_v__p1 = __Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(1.5, 0))); + + /* "fontTools/cu2qu/cu2qu.py":251 + * """ + * _p1 = p0 + (p1 - p0) * 1.5 + * _p2 = p3 + (p2 - p3) * 1.5 # <<<<<<<<<<<<<< + * return _p1 + (_p2 - _p1) * t + * + */ + __pyx_v__p2 = __Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(1.5, 0))); + + /* "fontTools/cu2qu/cu2qu.py":252 + * _p1 = p0 + (p1 - p0) * 1.5 + * _p2 = p3 + (p2 - p3) * 1.5 + * return _p1 + (_p2 - _p1) * t # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __Pyx_c_sum_double(__pyx_v__p1, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v__p2, __pyx_v__p1), __pyx_t_double_complex_from_parts(__pyx_v_t, 0))); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":226 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.complex) + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":255 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.complex) + */ + +static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) { + __pyx_t_double_complex __pyx_v_ab; + __pyx_t_double_complex __pyx_v_cd; + __pyx_t_double_complex __pyx_v_p; + double __pyx_v_h; + __pyx_t_double_complex __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + double __pyx_t_4; + double __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + __pyx_t_double_complex __pyx_t_13; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("calc_intersect", 1); + + /* "fontTools/cu2qu/cu2qu.py":273 + * if no intersection was found. + * """ + * ab = b - a # <<<<<<<<<<<<<< + * cd = d - c + * p = ab * 1j + */ + __pyx_v_ab = __Pyx_c_diff_double(__pyx_v_b, __pyx_v_a); + + /* "fontTools/cu2qu/cu2qu.py":274 + * """ + * ab = b - a + * cd = d - c # <<<<<<<<<<<<<< + * p = ab * 1j + * try: + */ + __pyx_v_cd = __Pyx_c_diff_double(__pyx_v_d, __pyx_v_c); + + /* "fontTools/cu2qu/cu2qu.py":275 + * ab = b - a + * cd = d - c + * p = ab * 1j # <<<<<<<<<<<<<< + * try: + * h = dot(p, a - c) / dot(p, cd) + */ + __pyx_v_p = __Pyx_c_prod_double(__pyx_v_ab, __pyx_t_double_complex_from_parts(0, 1.0)); + + /* "fontTools/cu2qu/cu2qu.py":276 + * cd = d - c + * p = ab * 1j + * try: # <<<<<<<<<<<<<< + * h = dot(p, a - c) / dot(p, cd) + * except ZeroDivisionError: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "fontTools/cu2qu/cu2qu.py":277 + * p = ab * 1j + * try: + * h = dot(p, a - c) / dot(p, cd) # <<<<<<<<<<<<<< + * except ZeroDivisionError: + * return complex(NAN, NAN) + */ + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __Pyx_c_diff_double(__pyx_v_a, __pyx_v_c)); if (unlikely(__pyx_t_4 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 277, __pyx_L3_error) + __pyx_t_5 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __pyx_v_cd); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 277, __pyx_L3_error) + if (unlikely(__pyx_t_5 == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 277, __pyx_L3_error) + } + __pyx_v_h = (__pyx_t_4 / __pyx_t_5); + + /* "fontTools/cu2qu/cu2qu.py":276 + * cd = d - c + * p = ab * 1j + * try: # <<<<<<<<<<<<<< + * h = dot(p, a - c) / dot(p, cd) + * except ZeroDivisionError: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "fontTools/cu2qu/cu2qu.py":278 + * try: + * h = dot(p, a - c) / dot(p, cd) + * except ZeroDivisionError: # <<<<<<<<<<<<<< + * return complex(NAN, NAN) + * return c + cd * h + */ + __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ZeroDivisionError); + if (__pyx_t_6) { + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 278, __pyx_L5_except_error) + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_9); + + /* "fontTools/cu2qu/cu2qu.py":279 + * h = dot(p, a - c) / dot(p, cd) + * except ZeroDivisionError: + * return complex(NAN, NAN) # <<<<<<<<<<<<<< + * return c + cd * h + * + */ + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_NAN); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 279, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_NAN); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_10); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10)) __PYX_ERR(0, 279, __pyx_L5_except_error); + __Pyx_GIVEREF(__pyx_t_11); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11)) __PYX_ERR(0, 279, __pyx_L5_except_error); + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_13 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_11); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L5_except_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_r = __pyx_t_13; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L6_except_return; + } + goto __pyx_L5_except_error; + + /* "fontTools/cu2qu/cu2qu.py":276 + * cd = d - c + * p = ab * 1j + * try: # <<<<<<<<<<<<<< + * h = dot(p, a - c) / dot(p, cd) + * except ZeroDivisionError: + */ + __pyx_L5_except_error:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L6_except_return:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L0; + __pyx_L8_try_end:; + } + + /* "fontTools/cu2qu/cu2qu.py":280 + * except ZeroDivisionError: + * return complex(NAN, NAN) + * return c + cd * h # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __Pyx_c_sum_double(__pyx_v_c, __Pyx_c_prod_double(__pyx_v_cd, __pyx_t_double_complex_from_parts(__pyx_v_h, 0))); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":255 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.returns(cython.complex) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = __pyx_t_double_complex_from_parts(0, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":283 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.returns(cython.int) + * @cython.locals( + */ + +static int __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, double __pyx_v_tolerance) { + __pyx_t_double_complex __pyx_v_mid; + __pyx_t_double_complex __pyx_v_deriv3; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + + /* "fontTools/cu2qu/cu2qu.py":312 + * """ + * # First check p2 then p1, as p2 has higher error early on. + * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<< + * return True + * + */ + __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":313 + * # First check p2 then p1, as p2 has higher error early on. + * if abs(p2) <= tolerance and abs(p1) <= tolerance: + * return True # <<<<<<<<<<<<<< + * + * # Split. + */ + __pyx_r = 1; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":312 + * """ + * # First check p2 then p1, as p2 has higher error early on. + * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<< + * return True + * + */ + } + + /* "fontTools/cu2qu/cu2qu.py":316 + * + * # Split. + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<< + * if abs(mid) > tolerance: + * return False + */ + __pyx_v_mid = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __Pyx_c_sum_double(__pyx_v_p1, __pyx_v_p2))), __pyx_v_p3), __pyx_t_double_complex_from_parts(0.125, 0)); + + /* "fontTools/cu2qu/cu2qu.py":317 + * # Split. + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + * if abs(mid) > tolerance: # <<<<<<<<<<<<<< + * return False + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + */ + __pyx_t_1 = (__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance); + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":318 + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + * if abs(mid) > tolerance: + * return False # <<<<<<<<<<<<<< + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return cubic_farthest_fit_inside( + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":317 + * # Split. + * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + * if abs(mid) > tolerance: # <<<<<<<<<<<<<< + * return False + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + */ + } + + /* "fontTools/cu2qu/cu2qu.py":319 + * if abs(mid) > tolerance: + * return False + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<< + * return cubic_farthest_fit_inside( + * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance + */ + __pyx_v_deriv3 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __pyx_v_p2), __pyx_v_p1), __pyx_v_p0), __pyx_t_double_complex_from_parts(0.125, 0)); + + /* "fontTools/cu2qu/cu2qu.py":320 + * return False + * deriv3 = (p3 + p2 - p1 - p0) * 0.125 + * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<< + * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance + * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) + */ + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0)), __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3), __pyx_v_mid, __pyx_v_tolerance); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 320, __pyx_L1_error) + if (__pyx_t_4) { + } else { + __pyx_t_3 = __pyx_t_4; + goto __pyx_L7_bool_binop_done; + } + + /* "fontTools/cu2qu/cu2qu.py":322 + * return cubic_farthest_fit_inside( + * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance + * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_mid, __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3), __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0)), __pyx_v_p3, __pyx_v_tolerance); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L1_error) + __pyx_t_3 = __pyx_t_4; + __pyx_L7_bool_binop_done:; + __pyx_r = __pyx_t_3; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":283 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.returns(cython.int) + * @cython.locals( + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_farthest_fit_inside", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":325 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals(tolerance=cython.double) + */ + +static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *__pyx_v_cubic, double __pyx_v_tolerance) { + __pyx_t_double_complex __pyx_v_q1; + __pyx_t_double_complex __pyx_v_c0; + __pyx_t_double_complex __pyx_v_c1; + __pyx_t_double_complex __pyx_v_c2; + __pyx_t_double_complex __pyx_v_c3; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_double_complex __pyx_t_2; + __pyx_t_double_complex __pyx_t_3; + __pyx_t_double_complex __pyx_t_4; + __pyx_t_double_complex __pyx_t_5; + __pyx_t_double_complex __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("cubic_approx_quadratic", 1); + + /* "fontTools/cu2qu/cu2qu.py":349 + * """ + * + * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) # <<<<<<<<<<<<<< + * if math.isnan(q1.imag): + * return None + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) + __pyx_v_q1 = __pyx_t_6; + + /* "fontTools/cu2qu/cu2qu.py":350 + * + * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) + * if math.isnan(q1.imag): # <<<<<<<<<<<<<< + * return None + * c0 = cubic[0] + */ + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_math); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isnan); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyFloat_FromDouble(__Pyx_CIMAG(__pyx_v_q1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = NULL; + __pyx_t_10 = 0; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_8))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_8, function); + __pyx_t_10 = 1; + } + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_7}; + __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_11) { + + /* "fontTools/cu2qu/cu2qu.py":351 + * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) + * if math.isnan(q1.imag): + * return None # <<<<<<<<<<<<<< + * c0 = cubic[0] + * c3 = cubic[3] + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":350 + * + * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) + * if math.isnan(q1.imag): # <<<<<<<<<<<<<< + * return None + * c0 = cubic[0] + */ + } + + /* "fontTools/cu2qu/cu2qu.py":352 + * if math.isnan(q1.imag): + * return None + * c0 = cubic[0] # <<<<<<<<<<<<<< + * c3 = cubic[3] + * c1 = c0 + (q1 - c0) * (2 / 3) + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 352, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_c0 = __pyx_t_6; + + /* "fontTools/cu2qu/cu2qu.py":353 + * return None + * c0 = cubic[0] + * c3 = cubic[3] # <<<<<<<<<<<<<< + * c1 = c0 + (q1 - c0) * (2 / 3) + * c2 = c3 + (q1 - c3) * (2 / 3) + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 353, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_c3 = __pyx_t_6; + + /* "fontTools/cu2qu/cu2qu.py":354 + * c0 = cubic[0] + * c3 = cubic[3] + * c1 = c0 + (q1 - c0) * (2 / 3) # <<<<<<<<<<<<<< + * c2 = c3 + (q1 - c3) * (2 / 3) + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): + */ + __pyx_v_c1 = __Pyx_c_sum_double(__pyx_v_c0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))); + + /* "fontTools/cu2qu/cu2qu.py":355 + * c3 = cubic[3] + * c1 = c0 + (q1 - c0) * (2 / 3) + * c2 = c3 + (q1 - c3) * (2 / 3) # <<<<<<<<<<<<<< + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): + * return None + */ + __pyx_v_c2 = __Pyx_c_sum_double(__pyx_v_c3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c3), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))); + + /* "fontTools/cu2qu/cu2qu.py":356 + * c1 = c0 + (q1 - c0) * (2 / 3) + * c2 = c3 + (q1 - c3) * (2 / 3) + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<< + * return None + * return c0, q1, c3 + */ + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_c2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_1 = PyNumber_Subtract(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_10 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex_from_parts(0, 0), __pyx_t_6, __pyx_t_5, __pyx_t_double_complex_from_parts(0, 0), __pyx_v_tolerance); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) + __pyx_t_11 = (!(__pyx_t_10 != 0)); + if (__pyx_t_11) { + + /* "fontTools/cu2qu/cu2qu.py":357 + * c2 = c3 + (q1 - c3) * (2 / 3) + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): + * return None # <<<<<<<<<<<<<< + * return c0, q1, c3 + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":356 + * c1 = c0 + (q1 - c0) * (2 / 3) + * c2 = c3 + (q1 - c3) * (2 / 3) + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<< + * return None + * return c0, q1, c3 + */ + } + + /* "fontTools/cu2qu/cu2qu.py":358 + * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): + * return None + * return c0, q1, c3 # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_q1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_c3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_8); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_7); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_7)) __PYX_ERR(0, 358, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_8 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_9; + __pyx_t_9 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":325 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.inline + * @cython.locals(tolerance=cython.double) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":361 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int, tolerance=cython.double) + * @cython.locals(i=cython.int) + */ + +static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *__pyx_v_cubic, int __pyx_v_n, double __pyx_v_tolerance, int __pyx_v_all_quadratic) { + __pyx_t_double_complex __pyx_v_q0; + __pyx_t_double_complex __pyx_v_q1; + __pyx_t_double_complex __pyx_v_next_q1; + __pyx_t_double_complex __pyx_v_q2; + __pyx_t_double_complex __pyx_v_d1; + CYTHON_UNUSED __pyx_t_double_complex __pyx_v_c0; + __pyx_t_double_complex __pyx_v_c1; + __pyx_t_double_complex __pyx_v_c2; + __pyx_t_double_complex __pyx_v_c3; + int __pyx_v_i; + PyObject *__pyx_v_cubics = NULL; + PyObject *__pyx_v_next_cubic = NULL; + PyObject *__pyx_v_spline = NULL; + __pyx_t_double_complex __pyx_v_d0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __pyx_t_double_complex __pyx_t_4; + __pyx_t_double_complex __pyx_t_5; + __pyx_t_double_complex __pyx_t_6; + __pyx_t_double_complex __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + __pyx_t_double_complex __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + long __pyx_t_11; + long __pyx_t_12; + int __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *(*__pyx_t_16)(PyObject *); + long __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("cubic_approx_spline", 1); + + /* "fontTools/cu2qu/cu2qu.py":390 + * """ + * + * if n == 1: # <<<<<<<<<<<<<< + * return cubic_approx_quadratic(cubic, tolerance) + * if n == 2 and all_quadratic == False: + */ + __pyx_t_1 = (__pyx_v_n == 1); + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":391 + * + * if n == 1: + * return cubic_approx_quadratic(cubic, tolerance) # <<<<<<<<<<<<<< + * if n == 2 and all_quadratic == False: + * return cubic + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(__pyx_v_cubic, __pyx_v_tolerance); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":390 + * """ + * + * if n == 1: # <<<<<<<<<<<<<< + * return cubic_approx_quadratic(cubic, tolerance) + * if n == 2 and all_quadratic == False: + */ + } + + /* "fontTools/cu2qu/cu2qu.py":392 + * if n == 1: + * return cubic_approx_quadratic(cubic, tolerance) + * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<< + * return cubic + * + */ + __pyx_t_3 = (__pyx_v_n == 2); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L5_bool_binop_done; + } + __pyx_t_3 = (__pyx_v_all_quadratic == 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L5_bool_binop_done:; + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":393 + * return cubic_approx_quadratic(cubic, tolerance) + * if n == 2 and all_quadratic == False: + * return cubic # <<<<<<<<<<<<<< + * + * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_cubic); + __pyx_r = __pyx_v_cubic; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":392 + * if n == 1: + * return cubic_approx_quadratic(cubic, tolerance) + * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<< + * return cubic + * + */ + } + + /* "fontTools/cu2qu/cu2qu.py":395 + * return cubic + * + * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) # <<<<<<<<<<<<<< + * + * # calculate the spline of quadratics and check errors at the same time. + */ + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 395, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_cubics = __pyx_t_8; + __pyx_t_8 = 0; + + /* "fontTools/cu2qu/cu2qu.py":398 + * + * # calculate the spline of quadratics and check errors at the same time. + * next_cubic = next(cubics) # <<<<<<<<<<<<<< + * next_q1 = cubic_approx_control( + * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + */ + __pyx_t_8 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 398, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_v_next_cubic = __pyx_t_8; + __pyx_t_8 = 0; + + /* "fontTools/cu2qu/cu2qu.py":400 + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( + * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<< + * ) + * q2 = cubic[0] + */ + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "fontTools/cu2qu/cu2qu.py":399 + * # calculate the spline of quadratics and check errors at the same time. + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<< + * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + * ) + */ + __pyx_t_9 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(0.0, __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error) + __pyx_v_next_q1 = __pyx_t_9; + + /* "fontTools/cu2qu/cu2qu.py":402 + * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + * ) + * q2 = cubic[0] # <<<<<<<<<<<<<< + * d1 = 0j + * spline = [cubic[0], next_q1] + */ + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_v_q2 = __pyx_t_9; + + /* "fontTools/cu2qu/cu2qu.py":403 + * ) + * q2 = cubic[0] + * d1 = 0j # <<<<<<<<<<<<<< + * spline = [cubic[0], next_q1] + * for i in range(1, n + 1): + */ + __pyx_v_d1 = __pyx_t_double_complex_from_parts(0, 0.0); + + /* "fontTools/cu2qu/cu2qu.py":404 + * q2 = cubic[0] + * d1 = 0j + * spline = [cubic[0], next_q1] # <<<<<<<<<<<<<< + * for i in range(1, n + 1): + * # Current cubic to convert + */ + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 404, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 404, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_8); + if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_8)) __PYX_ERR(0, 404, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_2); + if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 1, __pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error); + __pyx_t_8 = 0; + __pyx_t_2 = 0; + __pyx_v_spline = ((PyObject*)__pyx_t_10); + __pyx_t_10 = 0; + + /* "fontTools/cu2qu/cu2qu.py":405 + * d1 = 0j + * spline = [cubic[0], next_q1] + * for i in range(1, n + 1): # <<<<<<<<<<<<<< + * # Current cubic to convert + * c0, c1, c2, c3 = next_cubic + */ + __pyx_t_11 = (__pyx_v_n + 1); + __pyx_t_12 = __pyx_t_11; + for (__pyx_t_13 = 1; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_i = __pyx_t_13; + + /* "fontTools/cu2qu/cu2qu.py":407 + * for i in range(1, n + 1): + * # Current cubic to convert + * c0, c1, c2, c3 = next_cubic # <<<<<<<<<<<<<< + * + * # Current quadratic approximation of current cubic + */ + if ((likely(PyTuple_CheckExact(__pyx_v_next_cubic))) || (PyList_CheckExact(__pyx_v_next_cubic))) { + PyObject* sequence = __pyx_v_next_cubic; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 4)) { + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 407, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 3); + } else { + __pyx_t_10 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + __pyx_t_8 = PyList_GET_ITEM(sequence, 2); + __pyx_t_14 = PyList_GET_ITEM(sequence, 3); + } + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(__pyx_t_14); + #else + { + Py_ssize_t i; + PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14}; + for (i=0; i < 4; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + } else { + Py_ssize_t index = -1; + PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14}; + __pyx_t_15 = PyObject_GetIter(__pyx_v_next_cubic); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); + for (index=0; index < 4; index++) { + PyObject* item = __pyx_t_16(__pyx_t_15); if (unlikely(!item)) goto __pyx_L9_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 4) < 0) __PYX_ERR(0, 407, __pyx_L1_error) + __pyx_t_16 = NULL; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + goto __pyx_L10_unpacking_done; + __pyx_L9_unpacking_failed:; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_16 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 407, __pyx_L1_error) + __pyx_L10_unpacking_done:; + } + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_v_c0 = __pyx_t_9; + __pyx_v_c1 = __pyx_t_4; + __pyx_v_c2 = __pyx_t_5; + __pyx_v_c3 = __pyx_t_6; + + /* "fontTools/cu2qu/cu2qu.py":410 + * + * # Current quadratic approximation of current cubic + * q0 = q2 # <<<<<<<<<<<<<< + * q1 = next_q1 + * if i < n: + */ + __pyx_v_q0 = __pyx_v_q2; + + /* "fontTools/cu2qu/cu2qu.py":411 + * # Current quadratic approximation of current cubic + * q0 = q2 + * q1 = next_q1 # <<<<<<<<<<<<<< + * if i < n: + * next_cubic = next(cubics) + */ + __pyx_v_q1 = __pyx_v_next_q1; + + /* "fontTools/cu2qu/cu2qu.py":412 + * q0 = q2 + * q1 = next_q1 + * if i < n: # <<<<<<<<<<<<<< + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( + */ + __pyx_t_1 = (__pyx_v_i < __pyx_v_n); + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":413 + * q1 = next_q1 + * if i < n: + * next_cubic = next(cubics) # <<<<<<<<<<<<<< + * next_q1 = cubic_approx_control( + * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + */ + __pyx_t_14 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 413, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF_SET(__pyx_v_next_cubic, __pyx_t_14); + __pyx_t_14 = 0; + + /* "fontTools/cu2qu/cu2qu.py":415 + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( + * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<< + * ) + * spline.append(next_q1) + */ + __pyx_t_17 = (__pyx_v_n - 1); + if (unlikely(__pyx_t_17 == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 415, __pyx_L1_error) + } + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "fontTools/cu2qu/cu2qu.py":414 + * if i < n: + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<< + * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + * ) + */ + __pyx_t_7 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control((((double)__pyx_v_i) / ((double)__pyx_t_17)), __pyx_t_6, __pyx_t_5, __pyx_t_4, __pyx_t_9); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L1_error) + __pyx_v_next_q1 = __pyx_t_7; + + /* "fontTools/cu2qu/cu2qu.py":417 + * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + * ) + * spline.append(next_q1) # <<<<<<<<<<<<<< + * q2 = (q1 + next_q1) * 0.5 + * else: + */ + __pyx_t_14 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_14); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "fontTools/cu2qu/cu2qu.py":418 + * ) + * spline.append(next_q1) + * q2 = (q1 + next_q1) * 0.5 # <<<<<<<<<<<<<< + * else: + * q2 = c3 + */ + __pyx_v_q2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_q1, __pyx_v_next_q1), __pyx_t_double_complex_from_parts(0.5, 0)); + + /* "fontTools/cu2qu/cu2qu.py":412 + * q0 = q2 + * q1 = next_q1 + * if i < n: # <<<<<<<<<<<<<< + * next_cubic = next(cubics) + * next_q1 = cubic_approx_control( + */ + goto __pyx_L11; + } + + /* "fontTools/cu2qu/cu2qu.py":420 + * q2 = (q1 + next_q1) * 0.5 + * else: + * q2 = c3 # <<<<<<<<<<<<<< + * + * # End-point deltas + */ + /*else*/ { + __pyx_v_q2 = __pyx_v_c3; + } + __pyx_L11:; + + /* "fontTools/cu2qu/cu2qu.py":423 + * + * # End-point deltas + * d0 = d1 # <<<<<<<<<<<<<< + * d1 = q2 - c3 + * + */ + __pyx_v_d0 = __pyx_v_d1; + + /* "fontTools/cu2qu/cu2qu.py":424 + * # End-point deltas + * d0 = d1 + * d1 = q2 - c3 # <<<<<<<<<<<<<< + * + * if abs(d1) > tolerance or not cubic_farthest_fit_inside( + */ + __pyx_v_d1 = __Pyx_c_diff_double(__pyx_v_q2, __pyx_v_c3); + + /* "fontTools/cu2qu/cu2qu.py":426 + * d1 = q2 - c3 + * + * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< + * d0, + * q0 + (q1 - q0) * (2 / 3) - c1, + */ + __pyx_t_3 = (__Pyx_c_abs_double(__pyx_v_d1) > __pyx_v_tolerance); + if (!__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L13_bool_binop_done; + } + + /* "fontTools/cu2qu/cu2qu.py":431 + * q2 + (q1 - q2) * (2 / 3) - c2, + * d1, + * tolerance, # <<<<<<<<<<<<<< + * ): + * return None + */ + __pyx_t_19 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_d0, __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c1), __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q2, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q2), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c2), __pyx_v_d1, __pyx_v_tolerance); if (unlikely(__pyx_t_19 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 426, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":426 + * d1 = q2 - c3 + * + * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< + * d0, + * q0 + (q1 - q0) * (2 / 3) - c1, + */ + __pyx_t_3 = (!(__pyx_t_19 != 0)); + __pyx_t_1 = __pyx_t_3; + __pyx_L13_bool_binop_done:; + if (__pyx_t_1) { + + /* "fontTools/cu2qu/cu2qu.py":433 + * tolerance, + * ): + * return None # <<<<<<<<<<<<<< + * spline.append(cubic[3]) + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":426 + * d1 = q2 - c3 + * + * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< + * d0, + * q0 + (q1 - q0) * (2 / 3) - c1, + */ + } + } + + /* "fontTools/cu2qu/cu2qu.py":434 + * ): + * return None + * spline.append(cubic[3]) # <<<<<<<<<<<<<< + * + * return spline + */ + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 434, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_14); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 434, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "fontTools/cu2qu/cu2qu.py":436 + * spline.append(cubic[3]) + * + * return spline # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_spline); + __pyx_r = __pyx_v_spline; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":361 + * + * + * @cython.cfunc # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int, tolerance=cython.double) + * @cython.locals(i=cython.int) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_spline", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_cubics); + __Pyx_XDECREF(__pyx_v_next_cubic); + __Pyx_XDECREF(__pyx_v_spline); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":439 + * + * + * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic, "curve_to_quadratic(curve, double max_err, int all_quadratic=True)\nApproximate a cubic Bezier curve with a spline of n quadratics.\n\n Args:\n cubic (sequence): Four 2D tuples representing control points of\n the cubic Bezier curve.\n max_err (double): Permitted deviation from the original curve.\n all_quadratic (bool): If True (default) returned value is a\n quadratic spline. If False, it's either a single quadratic\n curve or a single cubic curve.\n\n Returns:\n If all_quadratic is True: A list of 2D tuples, representing\n control points of the quadratic spline if it fits within the\n given tolerance, or ``None`` if no suitable spline could be\n calculated.\n\n If all_quadratic is False: Either a quadratic curve (if length\n of output is 3), or a cubic curve (if length of output is 4).\n "); +static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic = {"curve_to_quadratic", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic}; +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + PyObject *__pyx_v_curve = 0; + double __pyx_v_max_err; + int __pyx_v_all_quadratic; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[3] = {0,0,0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("curve_to_quadratic (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject **__pyx_pyargnames[] = {&__pyx_n_s_curve,&__pyx_n_s_max_err,&__pyx_n_s_all_quadratic,0}; + if (__pyx_kwds) { + Py_ssize_t kw_args; + switch (__pyx_nargs) { + case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); + switch (__pyx_nargs) { + case 0: + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_curve)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L3_error) + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_err)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, 1); __PYX_ERR(0, 439, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_all_quadratic); + if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "curve_to_quadratic") < 0)) __PYX_ERR(0, 439, __pyx_L3_error) + } + } else { + switch (__pyx_nargs) { + case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_curve = values[0]; + __pyx_v_max_err = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_err == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L3_error) + if (values[2]) { + __pyx_v_all_quadratic = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L3_error) + } else { + + /* "fontTools/cu2qu/cu2qu.py":442 + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< + * """Approximate a cubic Bezier curve with a spline of n quadratics. + * + */ + __pyx_v_all_quadratic = ((int)((int)1)); + } + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 439, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(__pyx_self, __pyx_v_curve, __pyx_v_max_err, __pyx_v_all_quadratic); + + /* "fontTools/cu2qu/cu2qu.py":439 + * + * + * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + */ + + /* function exit code */ + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic) { + int __pyx_v_n; + PyObject *__pyx_v_spline = NULL; + PyObject *__pyx_7genexpr__pyx_v_p = NULL; + PyObject *__pyx_8genexpr1__pyx_v_s = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + long __pyx_t_7; + long __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("curve_to_quadratic", 0); + __Pyx_INCREF(__pyx_v_curve); + + /* "fontTools/cu2qu/cu2qu.py":463 + * """ + * + * curve = [complex(*p) for p in curve] # <<<<<<<<<<<<<< + * + * for n in range(1, MAX_N + 1): + */ + { /* enter inner scope */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_v_curve)) || PyTuple_CheckExact(__pyx_v_curve)) { + __pyx_t_2 = __pyx_v_curve; __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 463, __pyx_L5_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 463, __pyx_L5_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 463, __pyx_L5_error) + #else + __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + { + Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 463, __pyx_L5_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 463, __pyx_L5_error) + #else + __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 463, __pyx_L5_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_p, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_7genexpr__pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 463, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0; + goto __pyx_L9_exit_scope; + __pyx_L5_error:; + __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0; + goto __pyx_L1_error; + __pyx_L9_exit_scope:; + } /* exit inner scope */ + __Pyx_DECREF_SET(__pyx_v_curve, __pyx_t_1); + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":465 + * curve = [complex(*p) for p in curve] + * + * for n in range(1, MAX_N + 1): # <<<<<<<<<<<<<< + * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) + * if spline is not None: + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MAX_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 465, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_8 = __pyx_t_7; + for (__pyx_t_9 = 1; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_n = __pyx_t_9; + + /* "fontTools/cu2qu/cu2qu.py":466 + * + * for n in range(1, MAX_N + 1): + * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) # <<<<<<<<<<<<<< + * if spline is not None: + * # done. go home + */ + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_v_curve, __pyx_v_n, __pyx_v_max_err, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2); + __pyx_t_2 = 0; + + /* "fontTools/cu2qu/cu2qu.py":467 + * for n in range(1, MAX_N + 1): + * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) + * if spline is not None: # <<<<<<<<<<<<<< + * # done. go home + * return [(s.real, s.imag) for s in spline] + */ + __pyx_t_10 = (__pyx_v_spline != Py_None); + if (__pyx_t_10) { + + /* "fontTools/cu2qu/cu2qu.py":469 + * if spline is not None: + * # done. go home + * return [(s.real, s.imag) for s in spline] # <<<<<<<<<<<<<< + * + * raise ApproxNotFoundError(curve) + */ + __Pyx_XDECREF(__pyx_r); + { /* enter inner scope */ + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_2); + if (likely(PyList_CheckExact(__pyx_v_spline)) || PyTuple_CheckExact(__pyx_v_spline)) { + __pyx_t_1 = __pyx_v_spline; __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_spline); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L15_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 469, __pyx_L15_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 469, __pyx_L15_error) + #else + __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } else { + { + Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 469, __pyx_L15_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 469, __pyx_L15_error) + #else + __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } + } else { + __pyx_t_6 = __pyx_t_4(__pyx_t_1); + if (unlikely(!__pyx_t_6)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 469, __pyx_L15_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_s, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_n_s_real); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_n_s_imag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6)) __PYX_ERR(0, 469, __pyx_L15_error); + __Pyx_GIVEREF(__pyx_t_5); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_5)) __PYX_ERR(0, 469, __pyx_L15_error); + __pyx_t_6 = 0; + __pyx_t_5 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 469, __pyx_L15_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0; + goto __pyx_L19_exit_scope; + __pyx_L15_error:; + __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0; + goto __pyx_L1_error; + __pyx_L19_exit_scope:; + } /* exit inner scope */ + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":467 + * for n in range(1, MAX_N + 1): + * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) + * if spline is not None: # <<<<<<<<<<<<<< + * # done. go home + * return [(s.real, s.imag) for s in spline] + */ + } + } + + /* "fontTools/cu2qu/cu2qu.py":471 + * return [(s.real, s.imag) for s in spline] + * + * raise ApproxNotFoundError(curve) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = NULL; + __pyx_t_9 = 0; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_curve}; + __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 471, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":439 + * + * + * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_spline); + __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); + __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); + __Pyx_XDECREF(__pyx_v_curve); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "fontTools/cu2qu/cu2qu.py":474 + * + * + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<< + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic, "curves_to_quadratic(curves, max_errors, int all_quadratic=True)\nReturn quadratic Bezier splines approximating the input cubic Beziers.\n\n Args:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\n Example::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\n The returned splines have \"implied oncurve points\" suitable for use in\n TrueType ``glif`` outlines - i.e. in the first spline returned above,\n the first quadratic segment runs from (50,50) to\n ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\n Returns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\n Raises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.\n "); +static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic = {"curves_to_quadratic", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic}; +static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + PyObject *__pyx_v_curves = 0; + PyObject *__pyx_v_max_errors = 0; + int __pyx_v_all_quadratic; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[3] = {0,0,0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("curves_to_quadratic (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject **__pyx_pyargnames[] = {&__pyx_n_s_curves,&__pyx_n_s_max_errors,&__pyx_n_s_all_quadratic,0}; + if (__pyx_kwds) { + Py_ssize_t kw_args; + switch (__pyx_nargs) { + case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); + switch (__pyx_nargs) { + case 0: + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_curves)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 474, __pyx_L3_error) + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_errors)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 474, __pyx_L3_error) + else { + __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, 1); __PYX_ERR(0, 474, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_all_quadratic); + if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } + else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 474, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "curves_to_quadratic") < 0)) __PYX_ERR(0, 474, __pyx_L3_error) + } + } else { + switch (__pyx_nargs) { + case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); + values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_curves = values[0]; + __pyx_v_max_errors = values[1]; + if (values[2]) { + __pyx_v_all_quadratic = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 476, __pyx_L3_error) + } else { + + /* "fontTools/cu2qu/cu2qu.py":476 + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< + * """Return quadratic Bezier splines approximating the input cubic Beziers. + * + */ + __pyx_v_all_quadratic = ((int)((int)1)); + } + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 474, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(__pyx_self, __pyx_v_curves, __pyx_v_max_errors, __pyx_v_all_quadratic); + + /* "fontTools/cu2qu/cu2qu.py":474 + * + * + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<< + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): + */ + + /* function exit code */ + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic) { + int __pyx_v_l; + int __pyx_v_last_i; + int __pyx_v_i; + PyObject *__pyx_v_splines = NULL; + PyObject *__pyx_v_n = NULL; + PyObject *__pyx_v_spline = NULL; + PyObject *__pyx_8genexpr2__pyx_v_curve = NULL; + PyObject *__pyx_8genexpr3__pyx_v_p = NULL; + PyObject *__pyx_8genexpr4__pyx_v_spline = NULL; + PyObject *__pyx_8genexpr5__pyx_v_s = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + int __pyx_t_12; + double __pyx_t_13; + long __pyx_t_14; + PyObject *__pyx_t_15 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("curves_to_quadratic", 0); + __Pyx_INCREF(__pyx_v_curves); + + /* "fontTools/cu2qu/cu2qu.py":513 + * """ + * + * curves = [[complex(*p) for p in curve] for curve in curves] # <<<<<<<<<<<<<< + * assert len(max_errors) == len(curves) + * + */ + { /* enter inner scope */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) { + __pyx_t_2 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L5_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 513, __pyx_L5_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 513, __pyx_L5_error) + #else + __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + { + Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 513, __pyx_L5_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 513, __pyx_L5_error) + #else + __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 513, __pyx_L5_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_curve, __pyx_t_5); + __pyx_t_5 = 0; + { /* enter inner scope */ + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_5); + if (likely(PyList_CheckExact(__pyx_8genexpr2__pyx_v_curve)) || PyTuple_CheckExact(__pyx_8genexpr2__pyx_v_curve)) { + __pyx_t_6 = __pyx_8genexpr2__pyx_v_curve; __Pyx_INCREF(__pyx_t_6); + __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr2__pyx_v_curve); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 513, __pyx_L10_error) + } + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_6))) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 513, __pyx_L10_error) + #endif + if (__pyx_t_7 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 513, __pyx_L10_error) + #else + __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } else { + { + Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 513, __pyx_L10_error) + #endif + if (__pyx_t_7 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 513, __pyx_L10_error) + #else + __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } + } else { + __pyx_t_9 = __pyx_t_8(__pyx_t_6); + if (unlikely(!__pyx_t_9)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 513, __pyx_L10_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_p, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_8genexpr3__pyx_v_p); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 513, __pyx_L10_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0; + goto __pyx_L14_exit_scope; + __pyx_L10_error:; + __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0; + goto __pyx_L5_error; + __pyx_L14_exit_scope:; + } /* exit inner scope */ + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 513, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0; + goto __pyx_L16_exit_scope; + __pyx_L5_error:; + __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0; + goto __pyx_L1_error; + __pyx_L16_exit_scope:; + } /* exit inner scope */ + __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_1); + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":514 + * + * curves = [[complex(*p) for p in curve] for curve in curves] + * assert len(max_errors) == len(curves) # <<<<<<<<<<<<<< + * + * l = len(curves) + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(__pyx_assertions_enabled())) { + __pyx_t_3 = PyObject_Length(__pyx_v_max_errors); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 514, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 514, __pyx_L1_error) + __pyx_t_11 = (__pyx_t_3 == __pyx_t_7); + if (unlikely(!__pyx_t_11)) { + __Pyx_Raise(__pyx_builtin_AssertionError, 0, 0, 0); + __PYX_ERR(0, 514, __pyx_L1_error) + } + } + #else + if ((1)); else __PYX_ERR(0, 514, __pyx_L1_error) + #endif + + /* "fontTools/cu2qu/cu2qu.py":516 + * assert len(max_errors) == len(curves) + * + * l = len(curves) # <<<<<<<<<<<<<< + * splines = [None] * l + * last_i = i = 0 + */ + __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 516, __pyx_L1_error) + __pyx_v_l = __pyx_t_7; + + /* "fontTools/cu2qu/cu2qu.py":517 + * + * l = len(curves) + * splines = [None] * l # <<<<<<<<<<<<<< + * last_i = i = 0 + * n = 1 + */ + __pyx_t_1 = PyList_New(1 * ((__pyx_v_l<0) ? 0:__pyx_v_l)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < __pyx_v_l; __pyx_temp++) { + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + if (__Pyx_PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None)) __PYX_ERR(0, 517, __pyx_L1_error); + } + } + __pyx_v_splines = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":518 + * l = len(curves) + * splines = [None] * l + * last_i = i = 0 # <<<<<<<<<<<<<< + * n = 1 + * while True: + */ + __pyx_v_last_i = 0; + __pyx_v_i = 0; + + /* "fontTools/cu2qu/cu2qu.py":519 + * splines = [None] * l + * last_i = i = 0 + * n = 1 # <<<<<<<<<<<<<< + * while True: + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + */ + __Pyx_INCREF(__pyx_int_1); + __pyx_v_n = __pyx_int_1; + + /* "fontTools/cu2qu/cu2qu.py":520 + * last_i = i = 0 + * n = 1 + * while True: # <<<<<<<<<<<<<< + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + * if spline is None: + */ + while (1) { + + /* "fontTools/cu2qu/cu2qu.py":521 + * n = 1 + * while True: + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) # <<<<<<<<<<<<<< + * if spline is None: + * if n == MAX_N: + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 521, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_max_errors, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 521, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_t_1, __pyx_t_12, __pyx_t_13, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2); + __pyx_t_2 = 0; + + /* "fontTools/cu2qu/cu2qu.py":522 + * while True: + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + * if spline is None: # <<<<<<<<<<<<<< + * if n == MAX_N: + * break + */ + __pyx_t_11 = (__pyx_v_spline == Py_None); + if (__pyx_t_11) { + + /* "fontTools/cu2qu/cu2qu.py":523 + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + * if spline is None: + * if n == MAX_N: # <<<<<<<<<<<<<< + * break + * n += 1 + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MAX_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_RichCompare(__pyx_v_n, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 523, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_11) { + + /* "fontTools/cu2qu/cu2qu.py":524 + * if spline is None: + * if n == MAX_N: + * break # <<<<<<<<<<<<<< + * n += 1 + * last_i = i + */ + goto __pyx_L18_break; + + /* "fontTools/cu2qu/cu2qu.py":523 + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + * if spline is None: + * if n == MAX_N: # <<<<<<<<<<<<<< + * break + * n += 1 + */ + } + + /* "fontTools/cu2qu/cu2qu.py":525 + * if n == MAX_N: + * break + * n += 1 # <<<<<<<<<<<<<< + * last_i = i + * continue + */ + __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_n, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_1); + __pyx_t_1 = 0; + + /* "fontTools/cu2qu/cu2qu.py":526 + * break + * n += 1 + * last_i = i # <<<<<<<<<<<<<< + * continue + * splines[i] = spline + */ + __pyx_v_last_i = __pyx_v_i; + + /* "fontTools/cu2qu/cu2qu.py":527 + * n += 1 + * last_i = i + * continue # <<<<<<<<<<<<<< + * splines[i] = spline + * i = (i + 1) % l + */ + goto __pyx_L17_continue; + + /* "fontTools/cu2qu/cu2qu.py":522 + * while True: + * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + * if spline is None: # <<<<<<<<<<<<<< + * if n == MAX_N: + * break + */ + } + + /* "fontTools/cu2qu/cu2qu.py":528 + * last_i = i + * continue + * splines[i] = spline # <<<<<<<<<<<<<< + * i = (i + 1) % l + * if i == last_i: + */ + if (unlikely((__Pyx_SetItemInt(__pyx_v_splines, __pyx_v_i, __pyx_v_spline, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 528, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":529 + * continue + * splines[i] = spline + * i = (i + 1) % l # <<<<<<<<<<<<<< + * if i == last_i: + * # done. go home + */ + __pyx_t_14 = (__pyx_v_i + 1); + if (unlikely(__pyx_v_l == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(0, 529, __pyx_L1_error) + } + __pyx_v_i = __Pyx_mod_long(__pyx_t_14, __pyx_v_l); + + /* "fontTools/cu2qu/cu2qu.py":530 + * splines[i] = spline + * i = (i + 1) % l + * if i == last_i: # <<<<<<<<<<<<<< + * # done. go home + * return [[(s.real, s.imag) for s in spline] for spline in splines] + */ + __pyx_t_11 = (__pyx_v_i == __pyx_v_last_i); + if (__pyx_t_11) { + + /* "fontTools/cu2qu/cu2qu.py":532 + * if i == last_i: + * # done. go home + * return [[(s.real, s.imag) for s in spline] for spline in splines] # <<<<<<<<<<<<<< + * + * raise ApproxNotFoundError(curves) + */ + __Pyx_XDECREF(__pyx_r); + { /* enter inner scope */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L24_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_v_splines; __Pyx_INCREF(__pyx_t_2); + __pyx_t_7 = 0; + for (;;) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 532, __pyx_L24_error) + #endif + if (__pyx_t_7 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 532, __pyx_L24_error) + #else + __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L24_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_spline, __pyx_t_5); + __pyx_t_5 = 0; + { /* enter inner scope */ + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_5); + if (likely(PyList_CheckExact(__pyx_8genexpr4__pyx_v_spline)) || PyTuple_CheckExact(__pyx_8genexpr4__pyx_v_spline)) { + __pyx_t_6 = __pyx_8genexpr4__pyx_v_spline; __Pyx_INCREF(__pyx_t_6); + __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr4__pyx_v_spline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 532, __pyx_L29_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_6))) { + { + Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 532, __pyx_L29_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_10); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 532, __pyx_L29_error) + #else + __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } else { + { + Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); + #if !CYTHON_ASSUME_SAFE_MACROS + if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 532, __pyx_L29_error) + #endif + if (__pyx_t_3 >= __pyx_temp) break; + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_10); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 532, __pyx_L29_error) + #else + __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } + } else { + __pyx_t_10 = __pyx_t_4(__pyx_t_6); + if (unlikely(!__pyx_t_10)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 532, __pyx_L29_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_10); + } + __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_s, __pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_n_s_real); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_n_s_imag); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GIVEREF(__pyx_t_10); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10)) __PYX_ERR(0, 532, __pyx_L29_error); + __Pyx_GIVEREF(__pyx_t_9); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_9)) __PYX_ERR(0, 532, __pyx_L29_error); + __pyx_t_10 = 0; + __pyx_t_9 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 532, __pyx_L29_error) + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0; + goto __pyx_L33_exit_scope; + __pyx_L29_error:; + __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0; + goto __pyx_L24_error; + __pyx_L33_exit_scope:; + } /* exit inner scope */ + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 532, __pyx_L24_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0; + goto __pyx_L35_exit_scope; + __pyx_L24_error:; + __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0; + goto __pyx_L1_error; + __pyx_L35_exit_scope:; + } /* exit inner scope */ + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "fontTools/cu2qu/cu2qu.py":530 + * splines[i] = spline + * i = (i + 1) % l + * if i == last_i: # <<<<<<<<<<<<<< + * # done. go home + * return [[(s.real, s.imag) for s in spline] for spline in splines] + */ + } + __pyx_L17_continue:; + } + __pyx_L18_break:; + + /* "fontTools/cu2qu/cu2qu.py":534 + * return [[(s.real, s.imag) for s in spline] for spline in splines] + * + * raise ApproxNotFoundError(curves) # <<<<<<<<<<<<<< + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = NULL; + __pyx_t_12 = 0; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_12 = 1; + } + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_curves}; + __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 534, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":474 + * + * + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<< + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_splines); + __Pyx_XDECREF(__pyx_v_n); + __Pyx_XDECREF(__pyx_v_spline); + __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); + __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); + __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); + __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); + __Pyx_XDECREF(__pyx_v_curves); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +#if CYTHON_USE_FREELISTS +static struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[8]; +static int __pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = 0; +#endif + +static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + #if CYTHON_COMPILING_IN_LIMITED_API + allocfunc alloc_func = (allocfunc)PyType_GetSlot(t, Py_tp_alloc); + o = alloc_func(t, 0); + #else + #if CYTHON_USE_FREELISTS + if (likely((int)(__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen > 0) & (int)(t->tp_basicsize == sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)))) { + o = (PyObject*)__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[--__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen]; + memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)); + (void) PyObject_INIT(o, t); + } else + #endif + { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + #endif + return o; +} + +static void __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyObject *o) { + #if CYTHON_USE_TP_FINALIZE + if (unlikely((PY_VERSION_HEX >= 0x03080000 || __Pyx_PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)) && __Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) { + if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + } + #endif + #if CYTHON_USE_FREELISTS + if (((int)(__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen < 8) & (int)(Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)))) { + __pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen++] = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)o); + } else + #endif + { + #if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY + (*Py_TYPE(o)->tp_free)(o); + #else + { + freefunc tp_free = (freefunc)PyType_GetSlot(Py_TYPE(o), Py_tp_free); + if (tp_free) tp_free(o); + } + #endif + } +} +#if CYTHON_USE_TYPE_SPECS +static PyType_Slot __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots[] = { + {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen}, + {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen}, + {0, 0}, +}; +static PyType_Spec __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec = { + "fontTools.cu2qu.cu2qu.__pyx_scope_struct___split_cubic_into_n_gen", + sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen), + 0, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_FINALIZE, + __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots, +}; +#else + +static PyTypeObject __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = { + PyVarObject_HEAD_INIT(0, 0) + "fontTools.cu2qu.cu2qu.""__pyx_scope_struct___split_cubic_into_n_gen", /*tp_name*/ + sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + #if !CYTHON_USE_TYPE_SPECS + 0, /*tp_dictoffset*/ + #endif + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE + 0, /*tp_finalize*/ + #else + NULL, /*tp_finalize*/ + #endif + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if __PYX_NEED_TP_PRINT_SLOT == 1 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030C0000 + 0, /*tp_watched*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 + 0, /*tp_pypy_flags*/ + #endif +}; +#endif + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif +/* #### Code section: pystring_table ### */ + +static int __Pyx_CreateStringTabAndInitStrings(void) { + __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_ApproxNotFoundError, __pyx_k_ApproxNotFoundError, sizeof(__pyx_k_ApproxNotFoundError), 0, 0, 1, 1}, + {&__pyx_n_s_AssertionError, __pyx_k_AssertionError, sizeof(__pyx_k_AssertionError), 0, 0, 1, 1}, + {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, + {&__pyx_n_s_COMPILED, __pyx_k_COMPILED, sizeof(__pyx_k_COMPILED), 0, 0, 1, 1}, + {&__pyx_n_s_Cu2QuError, __pyx_k_Cu2QuError, sizeof(__pyx_k_Cu2QuError), 0, 0, 1, 1}, + {&__pyx_n_s_Error, __pyx_k_Error, sizeof(__pyx_k_Error), 0, 0, 1, 1}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_k_Lib_fontTools_cu2qu_cu2qu_py, sizeof(__pyx_k_Lib_fontTools_cu2qu_cu2qu_py), 0, 0, 1, 0}, + {&__pyx_n_s_MAX_N, __pyx_k_MAX_N, sizeof(__pyx_k_MAX_N), 0, 0, 1, 1}, + {&__pyx_n_s_NAN, __pyx_k_NAN, sizeof(__pyx_k_NAN), 0, 0, 1, 1}, + {&__pyx_n_u_NaN, __pyx_k_NaN, sizeof(__pyx_k_NaN), 0, 1, 0, 1}, + {&__pyx_kp_u_Return_quadratic_Bezier_splines, __pyx_k_Return_quadratic_Bezier_splines, sizeof(__pyx_k_Return_quadratic_Bezier_splines), 0, 1, 0, 0}, + {&__pyx_n_s_ZeroDivisionError, __pyx_k_ZeroDivisionError, sizeof(__pyx_k_ZeroDivisionError), 0, 0, 1, 1}, + {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0}, + {&__pyx_n_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 1}, + {&__pyx_n_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 1}, + {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, + {&__pyx_n_s_a1, __pyx_k_a1, sizeof(__pyx_k_a1), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_all_quadratic, __pyx_k_all_quadratic, sizeof(__pyx_k_all_quadratic), 0, 0, 1, 1}, + {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, + {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1}, + {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1}, + {&__pyx_n_s_b1, __pyx_k_b1, sizeof(__pyx_k_b1), 0, 0, 1, 1}, + {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, + {&__pyx_n_s_c1, __pyx_k_c1, sizeof(__pyx_k_c1), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, + {&__pyx_n_s_curve, __pyx_k_curve, sizeof(__pyx_k_curve), 0, 0, 1, 1}, + {&__pyx_n_s_curve_to_quadratic, __pyx_k_curve_to_quadratic, sizeof(__pyx_k_curve_to_quadratic), 0, 0, 1, 1}, + {&__pyx_n_u_curve_to_quadratic, __pyx_k_curve_to_quadratic, sizeof(__pyx_k_curve_to_quadratic), 0, 1, 0, 1}, + {&__pyx_n_s_curves, __pyx_k_curves, sizeof(__pyx_k_curves), 0, 0, 1, 1}, + {&__pyx_n_s_curves_to_quadratic, __pyx_k_curves_to_quadratic, sizeof(__pyx_k_curves_to_quadratic), 0, 0, 1, 1}, + {&__pyx_n_u_curves_to_quadratic, __pyx_k_curves_to_quadratic, sizeof(__pyx_k_curves_to_quadratic), 0, 1, 0, 1}, + {&__pyx_kp_u_curves_to_quadratic_line_474, __pyx_k_curves_to_quadratic_line_474, sizeof(__pyx_k_curves_to_quadratic_line_474), 0, 1, 0, 0}, + {&__pyx_n_s_cython, __pyx_k_cython, sizeof(__pyx_k_cython), 0, 0, 1, 1}, + {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, + {&__pyx_n_s_d1, __pyx_k_d1, sizeof(__pyx_k_d1), 0, 0, 1, 1}, + {&__pyx_n_s_delta_2, __pyx_k_delta_2, sizeof(__pyx_k_delta_2), 0, 0, 1, 1}, + {&__pyx_n_s_delta_3, __pyx_k_delta_3, sizeof(__pyx_k_delta_3), 0, 0, 1, 1}, + {&__pyx_kp_u_disable, __pyx_k_disable, sizeof(__pyx_k_disable), 0, 1, 0, 0}, + {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, + {&__pyx_kp_u_enable, __pyx_k_enable, sizeof(__pyx_k_enable), 0, 1, 0, 0}, + {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1}, + {&__pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_k_fontTools_cu2qu_cu2qu, sizeof(__pyx_k_fontTools_cu2qu_cu2qu), 0, 0, 1, 1}, + {&__pyx_n_s_fontTools_misc, __pyx_k_fontTools_misc, sizeof(__pyx_k_fontTools_misc), 0, 0, 1, 1}, + {&__pyx_kp_u_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 1, 0, 0}, + {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, + {&__pyx_n_s_imag, __pyx_k_imag, sizeof(__pyx_k_imag), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_initializing, __pyx_k_initializing, sizeof(__pyx_k_initializing), 0, 0, 1, 1}, + {&__pyx_n_s_is_coroutine, __pyx_k_is_coroutine, sizeof(__pyx_k_is_coroutine), 0, 0, 1, 1}, + {&__pyx_kp_u_isenabled, __pyx_k_isenabled, sizeof(__pyx_k_isenabled), 0, 1, 0, 0}, + {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1}, + {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1}, + {&__pyx_n_s_last_i, __pyx_k_last_i, sizeof(__pyx_k_last_i), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1}, + {&__pyx_n_s_max_err, __pyx_k_max_err, sizeof(__pyx_k_max_err), 0, 0, 1, 1}, + {&__pyx_n_s_max_errors, __pyx_k_max_errors, sizeof(__pyx_k_max_errors), 0, 0, 1, 1}, + {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1}, + {&__pyx_n_s_p0, __pyx_k_p0, sizeof(__pyx_k_p0), 0, 0, 1, 1}, + {&__pyx_n_s_p1, __pyx_k_p1, sizeof(__pyx_k_p1), 0, 0, 1, 1}, + {&__pyx_n_s_p2, __pyx_k_p2, sizeof(__pyx_k_p2), 0, 0, 1, 1}, + {&__pyx_n_s_p3, __pyx_k_p3, sizeof(__pyx_k_p3), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_real, __pyx_k_real, sizeof(__pyx_k_real), 0, 0, 1, 1}, + {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, + {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, + {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1}, + {&__pyx_n_s_spline, __pyx_k_spline, sizeof(__pyx_k_spline), 0, 0, 1, 1}, + {&__pyx_n_s_splines, __pyx_k_splines, sizeof(__pyx_k_splines), 0, 0, 1, 1}, + {&__pyx_n_s_split_cubic_into_n_gen, __pyx_k_split_cubic_into_n_gen, sizeof(__pyx_k_split_cubic_into_n_gen), 0, 0, 1, 1}, + {&__pyx_n_s_t1, __pyx_k_t1, sizeof(__pyx_k_t1), 0, 0, 1, 1}, + {&__pyx_n_s_t1_2, __pyx_k_t1_2, sizeof(__pyx_k_t1_2), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} + }; + return __Pyx_InitStrings(__pyx_string_tab); +} +/* #### Code section: cached_builtins ### */ +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_builtin_ZeroDivisionError = __Pyx_GetBuiltinName(__pyx_n_s_ZeroDivisionError); if (!__pyx_builtin_ZeroDivisionError) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 514, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} +/* #### Code section: cached_constants ### */ + +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "fontTools/cu2qu/cu2qu.py":127 + * + * + * @cython.locals( # <<<<<<<<<<<<<< + * p0=cython.complex, + * p1=cython.complex, + */ + __pyx_tuple__4 = PyTuple_Pack(19, __pyx_n_s_p0, __pyx_n_s_p1, __pyx_n_s_p2, __pyx_n_s_p3, __pyx_n_s_n, __pyx_n_s_a1, __pyx_n_s_b1, __pyx_n_s_c1, __pyx_n_s_d1, __pyx_n_s_dt, __pyx_n_s_delta_2, __pyx_n_s_delta_3, __pyx_n_s_i, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_c, __pyx_n_s_d, __pyx_n_s_t1, __pyx_n_s_t1_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 19, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_split_cubic_into_n_gen, 127, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 127, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":439 + * + * + * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + */ + __pyx_tuple__5 = PyTuple_Pack(7, __pyx_n_s_curve, __pyx_n_s_max_err, __pyx_n_s_all_quadratic, __pyx_n_s_n, __pyx_n_s_spline, __pyx_n_s_p, __pyx_n_s_s); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_curve_to_quadratic, 439, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 439, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":474 + * + * + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<< + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): + */ + __pyx_tuple__7 = PyTuple_Pack(13, __pyx_n_s_curves, __pyx_n_s_max_errors, __pyx_n_s_all_quadratic, __pyx_n_s_l, __pyx_n_s_last_i, __pyx_n_s_i, __pyx_n_s_splines, __pyx_n_s_n, __pyx_n_s_spline, __pyx_n_s_curve, __pyx_n_s_p, __pyx_n_s_spline, __pyx_n_s_s); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_curves_to_quadratic, 474, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} +/* #### Code section: init_constants ### */ + +static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) { + if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} +/* #### Code section: init_globals ### */ + +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + /* AssertionsEnabled.init */ + if (likely(__Pyx_init_assertions_enabled() == 0)); else + +if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) + + return 0; + __pyx_L1_error:; + return -1; +} +/* #### Code section: init_module ### */ + +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + #if CYTHON_USE_TYPE_SPECS + __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec, NULL); if (unlikely(!__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)) __PYX_ERR(0, 127, __pyx_L1_error) + if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec, __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) < 0) __PYX_ERR(0, 127, __pyx_L1_error) + #else + __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = &__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + #endif + #if !CYTHON_USE_TYPE_SPECS + if (__Pyx_PyType_Ready(__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) < 0) __PYX_ERR(0, 127, __pyx_L1_error) + #endif + #if PY_MAJOR_VERSION < 3 + __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_print = 0; + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_dictoffset && __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_getattro == PyObject_GenericGetAttr)) { + __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + #endif + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_cu2qu(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_cu2qu}, + {0, NULL} +}; +#endif + +#ifdef __cplusplus +namespace { + struct PyModuleDef __pyx_moduledef = + #else + static struct PyModuleDef __pyx_moduledef = + #endif + { + PyModuleDef_HEAD_INIT, + "cu2qu", + 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #elif CYTHON_USE_MODULE_STATE + sizeof(__pyx_mstate), /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + #if CYTHON_USE_MODULE_STATE + __pyx_m_traverse, /* m_traverse */ + __pyx_m_clear, /* m_clear */ + NULL /* m_free */ + #else + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ + #endif + }; + #ifdef __cplusplus +} /* anonymous namespace */ +#endif +#endif + +#ifndef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#elif PY_MAJOR_VERSION < 3 +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" void +#else +#define __Pyx_PyMODINIT_FUNC void +#endif +#else +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyObject * +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initcu2qu(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcu2qu(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_cu2qu(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_cu2qu(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +#if CYTHON_COMPILING_IN_LIMITED_API +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none) +#else +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) +#endif +{ + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { +#if CYTHON_COMPILING_IN_LIMITED_API + result = PyModule_AddObject(module, to_name, value); +#else + result = PyDict_SetItemString(moddict, to_name, value); +#endif + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + CYTHON_UNUSED_VAR(def); + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; +#if CYTHON_COMPILING_IN_LIMITED_API + moddict = module; +#else + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; +#endif + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_cu2qu(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + int stringtab_initialized = 0; + #if CYTHON_USE_MODULE_STATE + int pystate_addmodule_run = 0; + #endif + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + double __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'cu2qu' has already been imported. Re-initialisation is not supported."); + return -1; + } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("cu2qu", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #elif CYTHON_USE_MODULE_STATE + __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + { + int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); + __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "cu2qu" pseudovariable */ + if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) + pystate_addmodule_run = 1; + } + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #endif + CYTHON_UNUSED_VAR(__pyx_t_1); + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cu2qu(void)", 0); + if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + PyEval_InitThreads(); + #endif + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + stringtab_initialized = 1; + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_fontTools__cu2qu__cu2qu) { + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "fontTools.cu2qu.cu2qu")) { + if (unlikely((PyDict_SetItemString(modules, "fontTools.cu2qu.cu2qu", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + if (unlikely((__Pyx_modinit_type_init_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) + (void)__Pyx_modinit_type_import_code(); + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "fontTools/cu2qu/cu2qu.py":18 + * # limitations under the License. + * + * try: # <<<<<<<<<<<<<< + * import cython + * + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "fontTools/cu2qu/cu2qu.py":21 + * import cython + * + * COMPILED = cython.compiled # <<<<<<<<<<<<<< + * except (AttributeError, ImportError): + * # if cython not installed, use mock module with no-op decorators and types + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPILED, Py_True) < 0) __PYX_ERR(0, 21, __pyx_L2_error) + + /* "fontTools/cu2qu/cu2qu.py":18 + * # limitations under the License. + * + * try: # <<<<<<<<<<<<<< + * import cython + * + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L7_try_end; + __pyx_L2_error:; + + /* "fontTools/cu2qu/cu2qu.py":22 + * + * COMPILED = cython.compiled + * except (AttributeError, ImportError): # <<<<<<<<<<<<<< + * # if cython not installed, use mock module with no-op decorators and types + * from fontTools.misc import cython + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_AttributeError, __pyx_builtin_ImportError); + if (__pyx_t_4) { + __Pyx_AddTraceback("fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 22, __pyx_L4_except_error) + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + + /* "fontTools/cu2qu/cu2qu.py":24 + * except (AttributeError, ImportError): + * # if cython not installed, use mock module with no-op decorators and types + * from fontTools.misc import cython # <<<<<<<<<<<<<< + * + * COMPILED = False + */ + __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L4_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_n_s_cython); + __Pyx_GIVEREF(__pyx_n_s_cython); + if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_cython)) __PYX_ERR(0, 24, __pyx_L4_except_error); + __pyx_t_9 = __Pyx_Import(__pyx_n_s_fontTools_misc, __pyx_t_8, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 24, __pyx_L4_except_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_cython); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L4_except_error) + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cython, __pyx_t_8) < 0) __PYX_ERR(0, 24, __pyx_L4_except_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "fontTools/cu2qu/cu2qu.py":26 + * from fontTools.misc import cython + * + * COMPILED = False # <<<<<<<<<<<<<< + * + * import math + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPILED, Py_False) < 0) __PYX_ERR(0, 26, __pyx_L4_except_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L3_exception_handled; + } + goto __pyx_L4_except_error; + + /* "fontTools/cu2qu/cu2qu.py":18 + * # limitations under the License. + * + * try: # <<<<<<<<<<<<<< + * import cython + * + */ + __pyx_L4_except_error:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L3_exception_handled:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + __pyx_L7_try_end:; + } + + /* "fontTools/cu2qu/cu2qu.py":28 + * COMPILED = False + * + * import math # <<<<<<<<<<<<<< + * + * from .errors import Error as Cu2QuError, ApproxNotFoundError + */ + __pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_math, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_7) < 0) __PYX_ERR(0, 28, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "fontTools/cu2qu/cu2qu.py":30 + * import math + * + * from .errors import Error as Cu2QuError, ApproxNotFoundError # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_n_s_Error); + __Pyx_GIVEREF(__pyx_n_s_Error); + if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_Error)) __PYX_ERR(0, 30, __pyx_L1_error); + __Pyx_INCREF(__pyx_n_s_ApproxNotFoundError); + __Pyx_GIVEREF(__pyx_n_s_ApproxNotFoundError); + if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ApproxNotFoundError)) __PYX_ERR(0, 30, __pyx_L1_error); + __pyx_t_6 = __Pyx_Import(__pyx_n_s_errors, __pyx_t_7, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_Error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_Cu2QuError, __pyx_t_7) < 0) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproxNotFoundError, __pyx_t_7) < 0) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":33 + * + * + * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] # <<<<<<<<<<<<<< + * + * MAX_N = 100 + */ + __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_n_u_curve_to_quadratic); + __Pyx_GIVEREF(__pyx_n_u_curve_to_quadratic); + if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_curve_to_quadratic)) __PYX_ERR(0, 33, __pyx_L1_error); + __Pyx_INCREF(__pyx_n_u_curves_to_quadratic); + __Pyx_GIVEREF(__pyx_n_u_curves_to_quadratic); + if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_curves_to_quadratic)) __PYX_ERR(0, 33, __pyx_L1_error); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_6) < 0) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":35 + * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] + * + * MAX_N = 100 # <<<<<<<<<<<<<< + * + * NAN = float("NaN") + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_N, __pyx_int_100) < 0) __PYX_ERR(0, 35, __pyx_L1_error) + + /* "fontTools/cu2qu/cu2qu.py":37 + * MAX_N = 100 + * + * NAN = float("NaN") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_10 = __Pyx_PyUnicode_AsDouble(__pyx_n_u_NaN); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NAN, __pyx_t_6) < 0) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":127 + * + * + * @cython.locals( # <<<<<<<<<<<<<< + * p0=cython.complex, + * p1=cython.complex, + */ + __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, 0, __pyx_n_s_split_cubic_into_n_gen, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_cubic_into_n_gen, __pyx_t_6) < 0) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":442 + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< + * """Approximate a cubic Bezier curve with a spline of n quadratics. + * + */ + __pyx_t_6 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + + /* "fontTools/cu2qu/cu2qu.py":439 + * + * + * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<< + * @cython.locals(n=cython.int) + * @cython.locals(all_quadratic=cython.int) + */ + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6)) __PYX_ERR(0, 439, __pyx_L1_error); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, 0, __pyx_n_s_curve_to_quadratic, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_curve_to_quadratic, __pyx_t_6) < 0) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":476 + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< + * """Return quadratic Bezier splines approximating the input cubic Beziers. + * + */ + __pyx_t_6 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + + /* "fontTools/cu2qu/cu2qu.py":474 + * + * + * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<< + * @cython.locals(all_quadratic=cython.int) + * def curves_to_quadratic(curves, max_errors, all_quadratic=True): + */ + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6)) __PYX_ERR(0, 474, __pyx_L1_error); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, 0, __pyx_n_s_curves_to_quadratic, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_curves_to_quadratic, __pyx_t_6) < 0) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "fontTools/cu2qu/cu2qu.py":1 + * # cython: language_level=3 # <<<<<<<<<<<<<< + * # distutils: define_macros=CYTHON_TRACE_NOGIL=1 + * + */ + __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_kp_u_curves_to_quadratic_line_474, __pyx_kp_u_Return_quadratic_Bezier_splines) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_6) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + if (__pyx_m) { + if (__pyx_d && stringtab_initialized) { + __Pyx_AddTraceback("init fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + #if !CYTHON_USE_MODULE_STATE + Py_CLEAR(__pyx_m); + #else + Py_DECREF(__pyx_m); + if (pystate_addmodule_run) { + PyObject *tp, *value, *tb; + PyErr_Fetch(&tp, &value, &tb); + PyState_RemoveModule(&__pyx_moduledef); + PyErr_Restore(tp, value, tb); + } + #endif + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init fontTools.cu2qu.cu2qu"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} +/* #### Code section: cleanup_globals ### */ +/* #### Code section: cleanup_module ### */ +/* #### Code section: main_method ### */ +/* #### Code section: utility_code_pragmas ### */ +#ifdef _MSC_VER +#pragma warning( push ) +/* Warning 4127: conditional expression is constant + * Cython uses constant conditional expressions to allow in inline functions to be optimized at + * compile-time, so this warning is not useful + */ +#pragma warning( disable : 4127 ) +#endif + + + +/* #### Code section: utility_code_def ### */ + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule(modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, "RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* PyErrExceptionMatches */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; i= 0x030C00A6 + PyObject *current_exception = tstate->current_exception; + if (unlikely(!current_exception)) return 0; + exc_type = (PyObject*) Py_TYPE(current_exception); + if (exc_type == err) return 1; +#else + exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; +#endif + #if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(exc_type); + #endif + if (unlikely(PyTuple_Check(err))) { + result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + } else { + result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); + } + #if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(exc_type); + #endif + return result; +} +#endif + +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { +#if PY_VERSION_HEX >= 0x030C00A6 + PyObject *tmp_value; + assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); + if (value) { + #if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) + #endif + PyException_SetTraceback(value, tb); + } + tmp_value = tstate->current_exception; + tstate->current_exception = value; + Py_XDECREF(tmp_value); + Py_XDECREF(type); + Py_XDECREF(tb); +#else + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#if PY_VERSION_HEX >= 0x030C00A6 + PyObject* exc_value; + exc_value = tstate->current_exception; + tstate->current_exception = 0; + *value = exc_value; + *type = NULL; + *tb = NULL; + if (exc_value) { + *type = (PyObject*) Py_TYPE(exc_value); + Py_INCREF(*type); + #if CYTHON_COMPILING_IN_CPYTHON + *tb = ((PyBaseExceptionObject*) exc_value)->traceback; + Py_XINCREF(*tb); + #else + *tb = PyException_GetTraceback(exc_value); + #endif + } +#else + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#endif +} +#endif + +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + +/* PyObjectGetAttrStrNoError */ +#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} +#endif +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 + (void) PyObject_GetOptionalAttr(obj, attr_name, &result); + return result; +#else +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +#endif +} + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name); + if (unlikely(!result) && !PyErr_Occurred()) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* PyIntCompare */ +static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) { + CYTHON_MAYBE_UNUSED_VAR(intval); + CYTHON_UNUSED_VAR(inplace); + if (op1 == op2) { + return 1; + } + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long a = PyInt_AS_LONG(op1); + return (a == b); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + int unequal; + unsigned long uintval; + Py_ssize_t size = __Pyx_PyLong_DigitCount(op1); + const digit* digits = __Pyx_PyLong_Digits(op1); + if (intval == 0) { + return (__Pyx_PyLong_IsZero(op1) == 1); + } else if (intval < 0) { + if (__Pyx_PyLong_IsNonNeg(op1)) + return 0; + intval = -intval; + } else { + if (__Pyx_PyLong_IsNeg(op1)) + return 0; + } + uintval = (unsigned long) intval; +#if PyLong_SHIFT * 4 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 4)) { + unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 3 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 3)) { + unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 2 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 2)) { + unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 1 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 1)) { + unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif + unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); + return (unequal == 0); + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; +#if CYTHON_COMPILING_IN_LIMITED_API + double a = __pyx_PyFloat_AsDouble(op1); +#else + double a = PyFloat_AS_DOUBLE(op1); +#endif + return ((double)a == (double)b); + } + return __Pyx_PyObject_IsTrueAndDecref( + PyObject_RichCompare(op1, op2, Py_EQ)); +} + +/* RaiseTooManyValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* IterFinish */ +static CYTHON_INLINE int __Pyx_IterFinish(void) { + PyObject* exc_type; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + exc_type = __Pyx_PyErr_CurrentExceptionType(); + if (unlikely(exc_type)) { + if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) + return -1; + __Pyx_PyErr_Clear(); + return 0; + } + return 0; +} + +/* UnpackItemEndCheck */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } + return __Pyx_IterFinish(); +} + +/* GetItemInt */ +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (unlikely(!j)) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; + PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; + if (mm && mm->mp_subscript) { + PyObject *r, *key = PyInt_FromSsize_t(i); + if (unlikely(!key)) return NULL; + r = mm->mp_subscript(o, key); + Py_DECREF(key); + return r; + } + if (likely(sm && sm->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { + Py_ssize_t l = sm->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return sm->sq_item(o, i); + } + } +#else + if (is_list || !PyMapping_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* PyDictVersioning */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); +} +#endif + +/* GetModuleGlobalName */ +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#elif CYTHON_COMPILING_IN_LIMITED_API + if (unlikely(!__pyx_m)) { + return NULL; + } + result = PyObject_GetAttr(__pyx_m, name); + if (likely(result)) { + return result; + } +#else + result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } +#endif +#else + result = PyObject_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +/* PyFunctionFastCall */ +#if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + #if PY_MAJOR_VERSION < 3 + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) { + return NULL; + } + #else + if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) { + return NULL; + } + #endif + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif + +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = Py_TYPE(func)->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + #if PY_MAJOR_VERSION < 3 + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + #else + if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) + return NULL; + #endif + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); + self = __Pyx_CyOrPyCFunction_GET_SELF(func); + #if PY_MAJOR_VERSION < 3 + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + #else + if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) + return NULL; + #endif + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectFastCall */ +#if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API +static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) { + PyObject *argstuple; + PyObject *result = 0; + size_t i; + argstuple = PyTuple_New((Py_ssize_t)nargs); + if (unlikely(!argstuple)) return NULL; + for (i = 0; i < nargs; i++) { + Py_INCREF(args[i]); + if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) < 0) goto bad; + } + result = __Pyx_PyObject_Call(func, argstuple, kwargs); + bad: + Py_DECREF(argstuple); + return result; +} +#endif +static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { + Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); +#if CYTHON_COMPILING_IN_CPYTHON + if (nargs == 0 && kwargs == NULL) { + if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) + return __Pyx_PyObject_CallMethO(func, NULL); + } + else if (nargs == 1 && kwargs == NULL) { + if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) + return __Pyx_PyObject_CallMethO(func, args[0]); + } +#endif + #if PY_VERSION_HEX < 0x030800B1 + #if CYTHON_FAST_PYCCALL + if (PyCFunction_Check(func)) { + if (kwargs) { + return _PyCFunction_FastCallDict(func, args, nargs, kwargs); + } else { + return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); + } + } + #if PY_VERSION_HEX >= 0x030700A1 + if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { + return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); + } + #endif + #endif + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); + } + #endif + #endif + if (kwargs == NULL) { + #if CYTHON_VECTORCALL + #if PY_VERSION_HEX < 0x03090000 + vectorcallfunc f = _PyVectorcall_Function(func); + #else + vectorcallfunc f = PyVectorcall_Function(func); + #endif + if (f) { + return f(func, args, (size_t)nargs, NULL); + } + #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL + if (__Pyx_CyFunction_CheckExact(func)) { + __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); + if (f) return f(func, args, (size_t)nargs, NULL); + } + #endif + } + if (nargs == 0) { + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs); + } + #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API + return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); + #else + return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); + #endif +} + +/* TupleAndListFromArray */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { + PyObject *v; + Py_ssize_t i; + for (i = 0; i < length; i++) { + v = dest[i] = src[i]; + Py_INCREF(v); + } +} +static CYTHON_INLINE PyObject * +__Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) +{ + PyObject *res; + if (n <= 0) { + Py_INCREF(__pyx_empty_tuple); + return __pyx_empty_tuple; + } + res = PyTuple_New(n); + if (unlikely(res == NULL)) return NULL; + __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); + return res; +} +static CYTHON_INLINE PyObject * +__Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) +{ + PyObject *res; + if (n <= 0) { + return PyList_New(0); + } + res = PyList_New(n); + if (unlikely(res == NULL)) return NULL; + __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); + return res; +} +#endif + +/* BytesEquals */ +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API + return PyObject_RichCompareBool(s1, s2, equals); +#else + if (s1 == s2) { + return (equals == Py_EQ); + } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { + const char *ps1, *ps2; + Py_ssize_t length = PyBytes_GET_SIZE(s1); + if (length != PyBytes_GET_SIZE(s2)) + return (equals == Py_NE); + ps1 = PyBytes_AS_STRING(s1); + ps2 = PyBytes_AS_STRING(s2); + if (ps1[0] != ps2[0]) { + return (equals == Py_NE); + } else if (length == 1) { + return (equals == Py_EQ); + } else { + int result; +#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) + Py_hash_t hash1, hash2; + hash1 = ((PyBytesObject*)s1)->ob_shash; + hash2 = ((PyBytesObject*)s2)->ob_shash; + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + return (equals == Py_NE); + } +#endif + result = memcmp(ps1, ps2, (size_t)length); + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { + return (equals == Py_NE); + } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { + return (equals == Py_NE); + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +#endif +} + +/* UnicodeEquals */ +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API + return PyObject_RichCompareBool(s1, s2, equals); +#else +#if PY_MAJOR_VERSION < 3 + PyObject* owned_ref = NULL; +#endif + int s1_is_unicode, s2_is_unicode; + if (s1 == s2) { + goto return_eq; + } + s1_is_unicode = PyUnicode_CheckExact(s1); + s2_is_unicode = PyUnicode_CheckExact(s2); +#if PY_MAJOR_VERSION < 3 + if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { + owned_ref = PyUnicode_FromObject(s2); + if (unlikely(!owned_ref)) + return -1; + s2 = owned_ref; + s2_is_unicode = 1; + } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { + owned_ref = PyUnicode_FromObject(s1); + if (unlikely(!owned_ref)) + return -1; + s1 = owned_ref; + s1_is_unicode = 1; + } else if (((!s2_is_unicode) & (!s1_is_unicode))) { + return __Pyx_PyBytes_Equals(s1, s2, equals); + } +#endif + if (s1_is_unicode & s2_is_unicode) { + Py_ssize_t length; + int kind; + void *data1, *data2; + if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) + return -1; + length = __Pyx_PyUnicode_GET_LENGTH(s1); + if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { + goto return_ne; + } +#if CYTHON_USE_UNICODE_INTERNALS + { + Py_hash_t hash1, hash2; + #if CYTHON_PEP393_ENABLED + hash1 = ((PyASCIIObject*)s1)->hash; + hash2 = ((PyASCIIObject*)s2)->hash; + #else + hash1 = ((PyUnicodeObject*)s1)->hash; + hash2 = ((PyUnicodeObject*)s2)->hash; + #endif + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + goto return_ne; + } + } +#endif + kind = __Pyx_PyUnicode_KIND(s1); + if (kind != __Pyx_PyUnicode_KIND(s2)) { + goto return_ne; + } + data1 = __Pyx_PyUnicode_DATA(s1); + data2 = __Pyx_PyUnicode_DATA(s2); + if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { + goto return_ne; + } else if (length == 1) { + goto return_eq; + } else { + int result = memcmp(data1, data2, (size_t)(length * kind)); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & s2_is_unicode) { + goto return_ne; + } else if ((s2 == Py_None) & s1_is_unicode) { + goto return_ne; + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +return_eq: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ); +return_ne: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_NE); +#endif +} + +/* fastcall */ +#if CYTHON_METH_FASTCALL +static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) +{ + Py_ssize_t i, n = PyTuple_GET_SIZE(kwnames); + for (i = 0; i < n; i++) + { + if (s == PyTuple_GET_ITEM(kwnames, i)) return kwvalues[i]; + } + for (i = 0; i < n; i++) + { + int eq = __Pyx_PyUnicode_Equals(s, PyTuple_GET_ITEM(kwnames, i), Py_EQ); + if (unlikely(eq != 0)) { + if (unlikely(eq < 0)) return NULL; + return kwvalues[i]; + } + } + return NULL; +} +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 +CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { + Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames); + PyObject *dict; + dict = PyDict_New(); + if (unlikely(!dict)) + return NULL; + for (i=0; i= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject *const *kwvalues, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)); + while (1) { + Py_XDECREF(key); key = NULL; + Py_XDECREF(value); value = NULL; + if (kwds_is_tuple) { + Py_ssize_t size; +#if CYTHON_ASSUME_SAFE_MACROS + size = PyTuple_GET_SIZE(kwds); +#else + size = PyTuple_Size(kwds); + if (size < 0) goto bad; +#endif + if (pos >= size) break; +#if CYTHON_AVOID_BORROWED_REFS + key = __Pyx_PySequence_ITEM(kwds, pos); + if (!key) goto bad; +#elif CYTHON_ASSUME_SAFE_MACROS + key = PyTuple_GET_ITEM(kwds, pos); +#else + key = PyTuple_GetItem(kwds, pos); + if (!key) goto bad; +#endif + value = kwvalues[pos]; + pos++; + } + else + { + if (!PyDict_Next(kwds, &pos, &key, &value)) break; +#if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(key); +#endif + } + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(value); + Py_DECREF(key); +#endif + key = NULL; + value = NULL; + continue; + } +#if !CYTHON_AVOID_BORROWED_REFS + Py_INCREF(key); +#endif + Py_INCREF(value); + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + value = NULL; +#endif + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = ( + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key) + ); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + value = NULL; +#endif + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + Py_XDECREF(key); + Py_XDECREF(value); + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + #if PY_MAJOR_VERSION < 3 + PyErr_Format(PyExc_TypeError, + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + PyErr_Format(PyExc_TypeError, + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + Py_XDECREF(key); + Py_XDECREF(value); + return -1; +} + +/* GetException */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) +#endif +{ + PyObject *local_type = NULL, *local_value, *local_tb = NULL; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if PY_VERSION_HEX >= 0x030C00A6 + local_value = tstate->current_exception; + tstate->current_exception = 0; + if (likely(local_value)) { + local_type = (PyObject*) Py_TYPE(local_value); + Py_INCREF(local_type); + local_tb = PyException_GetTraceback(local_value); + } + #else + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + #endif +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE && PY_VERSION_HEX >= 0x030C00A6 + if (unlikely(tstate->current_exception)) +#elif CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + #if PY_VERSION_HEX >= 0x030B00a4 + tmp_value = exc_info->exc_value; + exc_info->exc_value = local_value; + tmp_type = NULL; + tmp_tb = NULL; + Py_XDECREF(local_type); + Py_XDECREF(local_tb); + #else + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + #endif + } + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* pep479 */ +static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) { + PyObject *exc, *val, *tb, *cur_exc; + __Pyx_PyThreadState_declare + #ifdef __Pyx_StopAsyncIteration_USED + int is_async_stopiteration = 0; + #endif + CYTHON_MAYBE_UNUSED_VAR(in_async_gen); + cur_exc = PyErr_Occurred(); + if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) { + #ifdef __Pyx_StopAsyncIteration_USED + if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, __Pyx_PyExc_StopAsyncIteration))) { + is_async_stopiteration = 1; + } else + #endif + return; + } + __Pyx_PyThreadState_assign + __Pyx_GetException(&exc, &val, &tb); + Py_XDECREF(exc); + Py_XDECREF(val); + Py_XDECREF(tb); + PyErr_SetString(PyExc_RuntimeError, + #ifdef __Pyx_StopAsyncIteration_USED + is_async_stopiteration ? "async generator raised StopAsyncIteration" : + in_async_gen ? "async generator raised StopIteration" : + #endif + "generator raised StopIteration"); +} + +/* GetTopmostException */ +#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + +/* SaveResetException */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + PyObject *exc_value = exc_info->exc_value; + if (exc_value == NULL || exc_value == Py_None) { + *value = NULL; + *type = NULL; + *tb = NULL; + } else { + *value = exc_value; + Py_INCREF(*value); + *type = (PyObject*) Py_TYPE(exc_value); + Py_INCREF(*type); + *tb = PyException_GetTraceback(exc_value); + } + #elif CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); + #endif +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 + _PyErr_StackItem *exc_info = tstate->exc_info; + PyObject *tmp_value = exc_info->exc_value; + exc_info->exc_value = value; + Py_XDECREF(tmp_value); + Py_XDECREF(type); + Py_XDECREF(tb); + #else + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); + #endif +} +#endif + +/* IterNext */ +static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { + PyObject* exc_type; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + exc_type = __Pyx_PyErr_CurrentExceptionType(); + if (unlikely(exc_type)) { + if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) + return NULL; + __Pyx_PyErr_Clear(); + Py_INCREF(defval); + return defval; + } + if (defval) { + Py_INCREF(defval); + return defval; + } + __Pyx_PyErr_SetNone(PyExc_StopIteration); + return NULL; +} +static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { + __Pyx_TypeName iterator_type_name = __Pyx_PyType_GetName(Py_TYPE(iterator)); + PyErr_Format(PyExc_TypeError, + __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name); + __Pyx_DECREF_TypeName(iterator_type_name); +} +static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) { + PyObject* next; + iternextfunc iternext = Py_TYPE(iterator)->tp_iternext; + if (likely(iternext)) { +#if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY + next = iternext(iterator); + if (likely(next)) + return next; +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 + if (unlikely(iternext == &_PyObject_NextNotImplemented)) + return NULL; +#endif +#else + next = PyIter_Next(iterator); + if (likely(next)) + return next; +#endif + } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) { + __Pyx_PyIter_Next_ErrorNoIterator(iterator); + return NULL; + } +#if !CYTHON_USE_TYPE_SLOTS + else { + next = PyIter_Next(iterator); + if (likely(next)) + return next; + } +#endif + return __Pyx_PyIter_Next2Default(defval); +} + +/* PyIntBinop */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { + CYTHON_MAYBE_UNUSED_VAR(intval); + CYTHON_MAYBE_UNUSED_VAR(inplace); + CYTHON_UNUSED_VAR(zerodivision_check); + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + + x = (long)((unsigned long)a + (unsigned long)b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + if (unlikely(__Pyx_PyLong_IsZero(op1))) { + return __Pyx_NewRef(op2); + } + if (likely(__Pyx_PyLong_IsCompact(op1))) { + a = __Pyx_PyLong_CompactValue(op1); + } else { + const digit* digits = __Pyx_PyLong_Digits(op1); + const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1); + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + #ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + #endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; +#if CYTHON_COMPILING_IN_LIMITED_API + double a = __pyx_PyFloat_AsDouble(op1); +#else + double a = PyFloat_AS_DOUBLE(op1); +#endif + double result; + + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* RaiseException */ +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + __Pyx_PyThreadState_declare + CYTHON_UNUSED_VAR(cause); + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + #if PY_VERSION_HEX >= 0x030C00A6 + PyException_SetTraceback(value, tb); + #elif CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#else + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* SetItemInt */ +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (unlikely(!j)) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, + CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; + PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; + if (mm && mm->mp_ass_subscript) { + int r; + PyObject *key = PyInt_FromSsize_t(i); + if (unlikely(!key)) return -1; + r = mm->mp_ass_subscript(o, key, v); + Py_DECREF(key); + return r; + } + if (likely(sm && sm->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { + Py_ssize_t l = sm->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; + PyErr_Clear(); + } + } + return sm->sq_ass_item(o, i, v); + } + } +#else + if (is_list || !PyMapping_Check(o)) + { + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +/* ModInt[long] */ +static CYTHON_INLINE long __Pyx_mod_long(long a, long b) { + long r = a % b; + r += ((r != 0) & ((r ^ b) < 0)) * b; + return r; +} + +/* FixUpExtensionType */ +#if CYTHON_USE_TYPE_SPECS +static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { +#if PY_VERSION_HEX > 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API + CYTHON_UNUSED_VAR(spec); + CYTHON_UNUSED_VAR(type); +#else + const PyType_Slot *slot = spec->slots; + while (slot && slot->slot && slot->slot != Py_tp_members) + slot++; + if (slot && slot->slot == Py_tp_members) { + int changed = 0; +#if !(PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON) + const +#endif + PyMemberDef *memb = (PyMemberDef*) slot->pfunc; + while (memb && memb->name) { + if (memb->name[0] == '_' && memb->name[1] == '_') { +#if PY_VERSION_HEX < 0x030900b1 + if (strcmp(memb->name, "__weaklistoffset__") == 0) { + assert(memb->type == T_PYSSIZET); + assert(memb->flags == READONLY); + type->tp_weaklistoffset = memb->offset; + changed = 1; + } + else if (strcmp(memb->name, "__dictoffset__") == 0) { + assert(memb->type == T_PYSSIZET); + assert(memb->flags == READONLY); + type->tp_dictoffset = memb->offset; + changed = 1; + } +#if CYTHON_METH_FASTCALL + else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { + assert(memb->type == T_PYSSIZET); + assert(memb->flags == READONLY); +#if PY_VERSION_HEX >= 0x030800b4 + type->tp_vectorcall_offset = memb->offset; +#else + type->tp_print = (printfunc) memb->offset; +#endif + changed = 1; + } +#endif +#else + if ((0)); +#endif +#if PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON + else if (strcmp(memb->name, "__module__") == 0) { + PyObject *descr; + assert(memb->type == T_OBJECT); + assert(memb->flags == 0 || memb->flags == READONLY); + descr = PyDescr_NewMember(type, memb); + if (unlikely(!descr)) + return -1; + if (unlikely(PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr) < 0)) { + Py_DECREF(descr); + return -1; + } + Py_DECREF(descr); + changed = 1; + } +#endif + } + memb++; + } + if (changed) + PyType_Modified(type); + } +#endif + return 0; +} +#endif + +/* PyObjectCallNoArg */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { + PyObject *arg[2] = {NULL, NULL}; + return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); +} + +/* PyObjectCallOneArg */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *args[2] = {NULL, arg}; + return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); +} + +/* PyObjectGetMethod */ +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { + PyObject *attr; +#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP + __Pyx_TypeName type_name; + PyTypeObject *tp = Py_TYPE(obj); + PyObject *descr; + descrgetfunc f = NULL; + PyObject **dictptr, *dict; + int meth_found = 0; + assert (*method == NULL); + if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; + } + if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { + return 0; + } + descr = _PyType_Lookup(tp, name); + if (likely(descr != NULL)) { + Py_INCREF(descr); +#if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR + if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) +#elif PY_MAJOR_VERSION >= 3 + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) + #endif +#else + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr))) + #endif +#endif + { + meth_found = 1; + } else { + f = Py_TYPE(descr)->tp_descr_get; + if (f != NULL && PyDescr_IsData(descr)) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + } + } + dictptr = _PyObject_GetDictPtr(obj); + if (dictptr != NULL && (dict = *dictptr) != NULL) { + Py_INCREF(dict); + attr = __Pyx_PyDict_GetItemStr(dict, name); + if (attr != NULL) { + Py_INCREF(attr); + Py_DECREF(dict); + Py_XDECREF(descr); + goto try_unpack; + } + Py_DECREF(dict); + } + if (meth_found) { + *method = descr; + return 1; + } + if (f != NULL) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + if (likely(descr != NULL)) { + *method = descr; + return 0; + } + type_name = __Pyx_PyType_GetName(tp); + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", + type_name, name); +#else + "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", + type_name, PyString_AS_STRING(name)); +#endif + __Pyx_DECREF_TypeName(type_name); + return 0; +#else + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; +#endif +try_unpack: +#if CYTHON_UNPACK_METHODS + if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { + PyObject *function = PyMethod_GET_FUNCTION(attr); + Py_INCREF(function); + Py_DECREF(attr); + *method = function; + return 1; + } +#endif + *method = attr; + return 0; +} + +/* PyObjectCallMethod0 */ +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { + PyObject *method = NULL, *result = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_CallOneArg(method, obj); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) goto bad; + result = __Pyx_PyObject_CallNoArg(method); + Py_DECREF(method); +bad: + return result; +} + +/* ValidateBasesTuple */ +#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS +static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) { + Py_ssize_t i, n; +#if CYTHON_ASSUME_SAFE_MACROS + n = PyTuple_GET_SIZE(bases); +#else + n = PyTuple_Size(bases); + if (n < 0) return -1; +#endif + for (i = 1; i < n; i++) + { +#if CYTHON_AVOID_BORROWED_REFS + PyObject *b0 = PySequence_GetItem(bases, i); + if (!b0) return -1; +#elif CYTHON_ASSUME_SAFE_MACROS + PyObject *b0 = PyTuple_GET_ITEM(bases, i); +#else + PyObject *b0 = PyTuple_GetItem(bases, i); + if (!b0) return -1; +#endif + PyTypeObject *b; +#if PY_MAJOR_VERSION < 3 + if (PyClass_Check(b0)) + { + PyErr_Format(PyExc_TypeError, "base class '%.200s' is an old-style class", + PyString_AS_STRING(((PyClassObject*)b0)->cl_name)); +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(b0); +#endif + return -1; + } +#endif + b = (PyTypeObject*) b0; + if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) + { + __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); + PyErr_Format(PyExc_TypeError, + "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name); + __Pyx_DECREF_TypeName(b_name); +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(b0); +#endif + return -1; + } + if (dictoffset == 0) + { + Py_ssize_t b_dictoffset = 0; +#if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY + b_dictoffset = b->tp_dictoffset; +#else + PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__"); + if (!py_b_dictoffset) goto dictoffset_return; + b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset); + Py_DECREF(py_b_dictoffset); + if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return; +#endif + if (b_dictoffset) { + { + __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); + PyErr_Format(PyExc_TypeError, + "extension type '%.200s' has no __dict__ slot, " + "but base type '" __Pyx_FMT_TYPENAME "' has: " + "either add 'cdef dict __dict__' to the extension type " + "or add '__slots__ = [...]' to the base type", + type_name, b_name); + __Pyx_DECREF_TypeName(b_name); + } +#if !(CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY) + dictoffset_return: +#endif +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(b0); +#endif + return -1; + } + } +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(b0); +#endif + } + return 0; +} +#endif + +/* PyType_Ready */ +static int __Pyx_PyType_Ready(PyTypeObject *t) { +#if CYTHON_USE_TYPE_SPECS || !(CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API) || defined(PYSTON_MAJOR_VERSION) + (void)__Pyx_PyObject_CallMethod0; +#if CYTHON_USE_TYPE_SPECS + (void)__Pyx_validate_bases_tuple; +#endif + return PyType_Ready(t); +#else + int r; + PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); + if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1)) + return -1; +#if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) + { + int gc_was_enabled; + #if PY_VERSION_HEX >= 0x030A00b1 + gc_was_enabled = PyGC_Disable(); + (void)__Pyx_PyObject_CallMethod0; + #else + PyObject *ret, *py_status; + PyObject *gc = NULL; + #if PY_VERSION_HEX >= 0x030700a1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) + gc = PyImport_GetModule(__pyx_kp_u_gc); + #endif + if (unlikely(!gc)) gc = PyImport_Import(__pyx_kp_u_gc); + if (unlikely(!gc)) return -1; + py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_isenabled); + if (unlikely(!py_status)) { + Py_DECREF(gc); + return -1; + } + gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); + Py_DECREF(py_status); + if (gc_was_enabled > 0) { + ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_disable); + if (unlikely(!ret)) { + Py_DECREF(gc); + return -1; + } + Py_DECREF(ret); + } else if (unlikely(gc_was_enabled == -1)) { + Py_DECREF(gc); + return -1; + } + #endif + t->tp_flags |= Py_TPFLAGS_HEAPTYPE; +#if PY_VERSION_HEX >= 0x030A0000 + t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE; +#endif +#else + (void)__Pyx_PyObject_CallMethod0; +#endif + r = PyType_Ready(t); +#if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) + t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; + #if PY_VERSION_HEX >= 0x030A00b1 + if (gc_was_enabled) + PyGC_Enable(); + #else + if (gc_was_enabled) { + PyObject *tp, *v, *tb; + PyErr_Fetch(&tp, &v, &tb); + ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_enable); + if (likely(ret || r == -1)) { + Py_XDECREF(ret); + PyErr_Restore(tp, v, tb); + } else { + Py_XDECREF(tp); + Py_XDECREF(v); + Py_XDECREF(tb); + r = -1; + } + } + Py_DECREF(gc); + #endif + } +#endif + return r; +#endif +} + +/* PyObject_GenericGetAttrNoDict */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + __Pyx_TypeName type_name = __Pyx_PyType_GetName(tp); + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", + type_name, attr_name); +#else + "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", + type_name, PyString_AS_STRING(attr_name)); +#endif + __Pyx_DECREF_TypeName(type_name); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + Py_INCREF(descr); + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (cls == a || cls == b) return 1; + mro = cls->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + PyObject *base = PyTuple_GET_ITEM(mro, i); + if (base == (PyObject *)a || base == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + if (exc_type1) { + return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); + } else { + return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; i= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.') != NULL) { + module = PyImport_ImportModuleLevelObject( + name, __pyx_d, empty_dict, from_list, 1); + if (unlikely(!module)) { + if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (unlikely(!py_level)) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, __pyx_d, empty_dict, from_list, level); + #endif + } + } +bad: + Py_XDECREF(empty_dict); + Py_XDECREF(empty_list); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + return module; +} + +/* ImportFrom */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + const char* module_name_str = 0; + PyObject* module_name = 0; + PyObject* module_dot = 0; + PyObject* full_name = 0; + PyErr_Clear(); + module_name_str = PyModule_GetName(module); + if (unlikely(!module_name_str)) { goto modbad; } + module_name = PyUnicode_FromString(module_name_str); + if (unlikely(!module_name)) { goto modbad; } + module_dot = PyUnicode_Concat(module_name, __pyx_kp_u__2); + if (unlikely(!module_dot)) { goto modbad; } + full_name = PyUnicode_Concat(module_dot, name); + if (unlikely(!full_name)) { goto modbad; } + #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) + { + PyObject *modules = PyImport_GetModuleDict(); + if (unlikely(!modules)) + goto modbad; + value = PyObject_GetItem(modules, full_name); + } + #else + value = PyImport_GetModule(full_name); + #endif + modbad: + Py_XDECREF(full_name); + Py_XDECREF(module_dot); + Py_XDECREF(module_name); + } + if (unlikely(!value)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* ImportDottedModule */ +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) { + PyObject *partial_name = NULL, *slice = NULL, *sep = NULL; + if (unlikely(PyErr_Occurred())) { + PyErr_Clear(); + } + if (likely(PyTuple_GET_SIZE(parts_tuple) == count)) { + partial_name = name; + } else { + slice = PySequence_GetSlice(parts_tuple, 0, count); + if (unlikely(!slice)) + goto bad; + sep = PyUnicode_FromStringAndSize(".", 1); + if (unlikely(!sep)) + goto bad; + partial_name = PyUnicode_Join(sep, slice); + } + PyErr_Format( +#if PY_MAJOR_VERSION < 3 + PyExc_ImportError, + "No module named '%s'", PyString_AS_STRING(partial_name)); +#else +#if PY_VERSION_HEX >= 0x030600B1 + PyExc_ModuleNotFoundError, +#else + PyExc_ImportError, +#endif + "No module named '%U'", partial_name); +#endif +bad: + Py_XDECREF(sep); + Py_XDECREF(slice); + Py_XDECREF(partial_name); + return NULL; +} +#endif +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) { + PyObject *imported_module; +#if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) + PyObject *modules = PyImport_GetModuleDict(); + if (unlikely(!modules)) + return NULL; + imported_module = __Pyx_PyDict_GetItemStr(modules, name); + Py_XINCREF(imported_module); +#else + imported_module = PyImport_GetModule(name); +#endif + return imported_module; +} +#endif +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) { + Py_ssize_t i, nparts; + nparts = PyTuple_GET_SIZE(parts_tuple); + for (i=1; i < nparts && module; i++) { + PyObject *part, *submodule; +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + part = PyTuple_GET_ITEM(parts_tuple, i); +#else + part = PySequence_ITEM(parts_tuple, i); +#endif + submodule = __Pyx_PyObject_GetAttrStrNoError(module, part); +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(part); +#endif + Py_DECREF(module); + module = submodule; + } + if (unlikely(!module)) { + return __Pyx__ImportDottedModule_Error(name, parts_tuple, i); + } + return module; +} +#endif +static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) { +#if PY_MAJOR_VERSION < 3 + PyObject *module, *from_list, *star = __pyx_n_s__3; + CYTHON_UNUSED_VAR(parts_tuple); + from_list = PyList_New(1); + if (unlikely(!from_list)) + return NULL; + Py_INCREF(star); + PyList_SET_ITEM(from_list, 0, star); + module = __Pyx_Import(name, from_list, 0); + Py_DECREF(from_list); + return module; +#else + PyObject *imported_module; + PyObject *module = __Pyx_Import(name, NULL, 0); + if (!parts_tuple || unlikely(!module)) + return module; + imported_module = __Pyx__ImportDottedModule_Lookup(name); + if (likely(imported_module)) { + Py_DECREF(module); + return imported_module; + } + PyErr_Clear(); + return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); +#endif +} +static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030400B1 + PyObject *module = __Pyx__ImportDottedModule_Lookup(name); + if (likely(module)) { + PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, __pyx_n_s_spec); + if (likely(spec)) { + PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, __pyx_n_s_initializing); + if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) { + Py_DECREF(spec); + spec = NULL; + } + Py_XDECREF(unsafe); + } + if (likely(!spec)) { + PyErr_Clear(); + return module; + } + Py_DECREF(spec); + Py_DECREF(module); + } else if (PyErr_Occurred()) { + PyErr_Clear(); + } +#endif + return __Pyx__ImportDottedModule(name, parts_tuple); +} + +/* pybytes_as_double */ +static double __Pyx_SlowPyString_AsDouble(PyObject *obj) { + PyObject *float_value; +#if PY_MAJOR_VERSION >= 3 + float_value = PyFloat_FromString(obj); +#else + float_value = PyFloat_FromString(obj, 0); +#endif + if (likely(float_value)) { +#if CYTHON_ASSUME_SAFE_MACROS + double value = PyFloat_AS_DOUBLE(float_value); +#else + double value = PyFloat_AsDouble(float_value); +#endif + Py_DECREF(float_value); + return value; + } + return (double)-1; +} +static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) { + int last_was_punctuation = 1; + Py_ssize_t i; + for (i=0; i < length; i++) { + char chr = start[i]; + int is_punctuation = (chr == '_') | (chr == '.') | (chr == 'e') | (chr == 'E'); + *buffer = chr; + buffer += (chr != '_'); + if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure; + last_was_punctuation = is_punctuation; + } + if (unlikely(last_was_punctuation)) goto parse_failure; + *buffer = '\0'; + return buffer; +parse_failure: + return NULL; +} +static double __Pyx__PyBytes_AsDouble_inf_nan(const char* start, Py_ssize_t length) { + int matches = 1; + char sign = start[0]; + int is_signed = (sign == '+') | (sign == '-'); + start += is_signed; + length -= is_signed; + switch (start[0]) { + #ifdef Py_NAN + case 'n': + case 'N': + if (unlikely(length != 3)) goto parse_failure; + matches &= (start[1] == 'a' || start[1] == 'A'); + matches &= (start[2] == 'n' || start[2] == 'N'); + if (unlikely(!matches)) goto parse_failure; + return (sign == '-') ? -Py_NAN : Py_NAN; + #endif + case 'i': + case 'I': + if (unlikely(length < 3)) goto parse_failure; + matches &= (start[1] == 'n' || start[1] == 'N'); + matches &= (start[2] == 'f' || start[2] == 'F'); + if (likely(length == 3 && matches)) + return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; + if (unlikely(length != 8)) goto parse_failure; + matches &= (start[3] == 'i' || start[3] == 'I'); + matches &= (start[4] == 'n' || start[4] == 'N'); + matches &= (start[5] == 'i' || start[5] == 'I'); + matches &= (start[6] == 't' || start[6] == 'T'); + matches &= (start[7] == 'y' || start[7] == 'Y'); + if (unlikely(!matches)) goto parse_failure; + return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; + case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + break; + default: + goto parse_failure; + } + return 0.0; +parse_failure: + return -1.0; +} +static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) { + return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd)); +} +CYTHON_UNUSED static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) { + double value; + Py_ssize_t i, digits; + const char *last = start + length; + char *end; + while (__Pyx__PyBytes_AsDouble_IsSpace(*start)) + start++; + while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1])) + last--; + length = last - start; + if (unlikely(length <= 0)) goto fallback; + value = __Pyx__PyBytes_AsDouble_inf_nan(start, length); + if (unlikely(value == -1.0)) goto fallback; + if (value != 0.0) return value; + digits = 0; + for (i=0; i < length; digits += start[i++] != '_'); + if (likely(digits == length)) { + value = PyOS_string_to_double(start, &end, NULL); + } else if (digits < 40) { + char number[40]; + last = __Pyx__PyBytes_AsDouble_Copy(start, number, length); + if (unlikely(!last)) goto fallback; + value = PyOS_string_to_double(number, &end, NULL); + } else { + char *number = (char*) PyMem_Malloc((digits + 1) * sizeof(char)); + if (unlikely(!number)) goto fallback; + last = __Pyx__PyBytes_AsDouble_Copy(start, number, length); + if (unlikely(!last)) { + PyMem_Free(number); + goto fallback; + } + value = PyOS_string_to_double(number, &end, NULL); + PyMem_Free(number); + } + if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) { + return value; + } +fallback: + return __Pyx_SlowPyString_AsDouble(obj); +} + +/* FetchSharedCythonModule */ +static PyObject *__Pyx_FetchSharedCythonABIModule(void) { + return __Pyx_PyImport_AddModuleRef((char*) __PYX_ABI_MODULE_NAME); +} + +/* FetchCommonType */ +static int __Pyx_VerifyCachedType(PyObject *cached_type, + const char *name, + Py_ssize_t basicsize, + Py_ssize_t expected_basicsize) { + if (!PyType_Check(cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", name); + return -1; + } + if (basicsize != expected_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + name); + return -1; + } + return 0; +} +#if !CYTHON_USE_TYPE_SPECS +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* abi_module; + const char* object_name; + PyTypeObject *cached_type = NULL; + abi_module = __Pyx_FetchSharedCythonABIModule(); + if (!abi_module) return NULL; + object_name = strrchr(type->tp_name, '.'); + object_name = object_name ? object_name+1 : type->tp_name; + cached_type = (PyTypeObject*) PyObject_GetAttrString(abi_module, object_name); + if (cached_type) { + if (__Pyx_VerifyCachedType( + (PyObject *)cached_type, + object_name, + cached_type->tp_basicsize, + type->tp_basicsize) < 0) { + goto bad; + } + goto done; + } + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(abi_module, object_name, (PyObject *)type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; +done: + Py_DECREF(abi_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} +#else +static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) { + PyObject *abi_module, *cached_type = NULL; + const char* object_name = strrchr(spec->name, '.'); + object_name = object_name ? object_name+1 : spec->name; + abi_module = __Pyx_FetchSharedCythonABIModule(); + if (!abi_module) return NULL; + cached_type = PyObject_GetAttrString(abi_module, object_name); + if (cached_type) { + Py_ssize_t basicsize; +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject *py_basicsize; + py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); + if (unlikely(!py_basicsize)) goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; +#else + basicsize = likely(PyType_Check(cached_type)) ? ((PyTypeObject*) cached_type)->tp_basicsize : -1; +#endif + if (__Pyx_VerifyCachedType( + cached_type, + object_name, + basicsize, + spec->basicsize) < 0) { + goto bad; + } + goto done; + } + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + CYTHON_UNUSED_VAR(module); + cached_type = __Pyx_PyType_FromModuleAndSpec(abi_module, spec, bases); + if (unlikely(!cached_type)) goto bad; + if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; + if (PyObject_SetAttrString(abi_module, object_name, cached_type) < 0) goto bad; +done: + Py_DECREF(abi_module); + assert(cached_type == NULL || PyType_Check(cached_type)); + return (PyTypeObject *) cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} +#endif + +/* PyVectorcallFastCallDict */ +#if CYTHON_METH_FASTCALL +static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) +{ + PyObject *res = NULL; + PyObject *kwnames; + PyObject **newargs; + PyObject **kwvalues; + Py_ssize_t i, pos; + size_t j; + PyObject *key, *value; + unsigned long keys_are_strings; + Py_ssize_t nkw = PyDict_GET_SIZE(kw); + newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); + if (unlikely(newargs == NULL)) { + PyErr_NoMemory(); + return NULL; + } + for (j = 0; j < nargs; j++) newargs[j] = args[j]; + kwnames = PyTuple_New(nkw); + if (unlikely(kwnames == NULL)) { + PyMem_Free(newargs); + return NULL; + } + kwvalues = newargs + nargs; + pos = i = 0; + keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; + while (PyDict_Next(kw, &pos, &key, &value)) { + keys_are_strings &= Py_TYPE(key)->tp_flags; + Py_INCREF(key); + Py_INCREF(value); + PyTuple_SET_ITEM(kwnames, i, key); + kwvalues[i] = value; + i++; + } + if (unlikely(!keys_are_strings)) { + PyErr_SetString(PyExc_TypeError, "keywords must be strings"); + goto cleanup; + } + res = vc(func, newargs, nargs, kwnames); +cleanup: + Py_DECREF(kwnames); + for (i = 0; i < nkw; i++) + Py_DECREF(kwvalues[i]); + PyMem_Free(newargs); + return res; +} +static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) +{ + if (likely(kw == NULL) || PyDict_GET_SIZE(kw) == 0) { + return vc(func, args, nargs, NULL); + } + return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); +} +#endif + +/* CythonFunctionShared */ +#if CYTHON_COMPILING_IN_LIMITED_API +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { + if (__Pyx_CyFunction_Check(func)) { + return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; + } else if (PyCFunction_Check(func)) { + return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; + } + return 0; +} +#else +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { + return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; +} +#endif +static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API + __Pyx_Py_XDECREF_SET( + __Pyx_CyFunction_GetClassObj(f), + ((classobj) ? __Pyx_NewRef(classobj) : NULL)); +#else + __Pyx_Py_XDECREF_SET( + ((PyCMethodObject *) (f))->mm_class, + (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); +#endif +} +static PyObject * +__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) +{ + CYTHON_UNUSED_VAR(closure); + if (unlikely(op->func_doc == NULL)) { +#if CYTHON_COMPILING_IN_LIMITED_API + op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); + if (unlikely(!op->func_doc)) return NULL; +#else + if (((PyCFunctionObject*)op)->m_ml->ml_doc) { +#if PY_MAJOR_VERSION >= 3 + op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); +#else + op->func_doc = PyString_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); +#endif + if (unlikely(op->func_doc == NULL)) + return NULL; + } else { + Py_INCREF(Py_None); + return Py_None; + } +#endif + } + Py_INCREF(op->func_doc); + return op->func_doc; +} +static int +__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); + if (value == NULL) { + value = Py_None; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->func_doc, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) +{ + CYTHON_UNUSED_VAR(context); + if (unlikely(op->func_name == NULL)) { +#if CYTHON_COMPILING_IN_LIMITED_API + op->func_name = PyObject_GetAttrString(op->func, "__name__"); +#elif PY_MAJOR_VERSION >= 3 + op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); +#else + op->func_name = PyString_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); +#endif + if (unlikely(op->func_name == NULL)) + return NULL; + } + Py_INCREF(op->func_name); + return op->func_name; +} +static int +__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->func_name, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) +{ + CYTHON_UNUSED_VAR(context); + Py_INCREF(op->func_qualname); + return op->func_qualname; +} +static int +__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->func_qualname, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) +{ + CYTHON_UNUSED_VAR(context); + if (unlikely(op->func_dict == NULL)) { + op->func_dict = PyDict_New(); + if (unlikely(op->func_dict == NULL)) + return NULL; + } + Py_INCREF(op->func_dict); + return op->func_dict; +} +static int +__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); + if (unlikely(value == NULL)) { + PyErr_SetString(PyExc_TypeError, + "function's dictionary may not be deleted"); + return -1; + } + if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "setting function's dictionary to a non-dict"); + return -1; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->func_dict, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) +{ + CYTHON_UNUSED_VAR(context); + Py_INCREF(op->func_globals); + return op->func_globals; +} +static PyObject * +__Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) +{ + CYTHON_UNUSED_VAR(op); + CYTHON_UNUSED_VAR(context); + Py_INCREF(Py_None); + return Py_None; +} +static PyObject * +__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) +{ + PyObject* result = (op->func_code) ? op->func_code : Py_None; + CYTHON_UNUSED_VAR(context); + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { + int result = 0; + PyObject *res = op->defaults_getter((PyObject *) op); + if (unlikely(!res)) + return -1; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + op->defaults_tuple = PyTuple_GET_ITEM(res, 0); + Py_INCREF(op->defaults_tuple); + op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); + Py_INCREF(op->defaults_kwdict); + #else + op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); + if (unlikely(!op->defaults_tuple)) result = -1; + else { + op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); + if (unlikely(!op->defaults_kwdict)) result = -1; + } + #endif + Py_DECREF(res); + return result; +} +static int +__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { + CYTHON_UNUSED_VAR(context); + if (!value) { + value = Py_None; + } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "__defaults__ must be set to a tuple object"); + return -1; + } + PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " + "currently affect the values used in function calls", 1); + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { + PyObject* result = op->defaults_tuple; + CYTHON_UNUSED_VAR(context); + if (unlikely(!result)) { + if (op->defaults_getter) { + if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; + result = op->defaults_tuple; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { + CYTHON_UNUSED_VAR(context); + if (!value) { + value = Py_None; + } else if (unlikely(value != Py_None && !PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "__kwdefaults__ must be set to a dict object"); + return -1; + } + PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " + "currently affect the values used in function calls", 1); + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { + PyObject* result = op->defaults_kwdict; + CYTHON_UNUSED_VAR(context); + if (unlikely(!result)) { + if (op->defaults_getter) { + if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; + result = op->defaults_kwdict; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { + CYTHON_UNUSED_VAR(context); + if (!value || value == Py_None) { + value = NULL; + } else if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "__annotations__ must be set to a dict object"); + return -1; + } + Py_XINCREF(value); + __Pyx_Py_XDECREF_SET(op->func_annotations, value); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { + PyObject* result = op->func_annotations; + CYTHON_UNUSED_VAR(context); + if (unlikely(!result)) { + result = PyDict_New(); + if (unlikely(!result)) return NULL; + op->func_annotations = result; + } + Py_INCREF(result); + return result; +} +static PyObject * +__Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { + int is_coroutine; + CYTHON_UNUSED_VAR(context); + if (op->func_is_coroutine) { + return __Pyx_NewRef(op->func_is_coroutine); + } + is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; +#if PY_VERSION_HEX >= 0x03050000 + if (is_coroutine) { + PyObject *module, *fromlist, *marker = __pyx_n_s_is_coroutine; + fromlist = PyList_New(1); + if (unlikely(!fromlist)) return NULL; + Py_INCREF(marker); +#if CYTHON_ASSUME_SAFE_MACROS + PyList_SET_ITEM(fromlist, 0, marker); +#else + if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { + Py_DECREF(marker); + Py_DECREF(fromlist); + return NULL; + } +#endif + module = PyImport_ImportModuleLevelObject(__pyx_n_s_asyncio_coroutines, NULL, NULL, fromlist, 0); + Py_DECREF(fromlist); + if (unlikely(!module)) goto ignore; + op->func_is_coroutine = __Pyx_PyObject_GetAttrStr(module, marker); + Py_DECREF(module); + if (likely(op->func_is_coroutine)) { + return __Pyx_NewRef(op->func_is_coroutine); + } +ignore: + PyErr_Clear(); + } +#endif + op->func_is_coroutine = __Pyx_PyBool_FromLong(is_coroutine); + return __Pyx_NewRef(op->func_is_coroutine); +} +#if CYTHON_COMPILING_IN_LIMITED_API +static PyObject * +__Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { + CYTHON_UNUSED_VAR(context); + return PyObject_GetAttrString(op->func, "__module__"); +} +static int +__Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { + CYTHON_UNUSED_VAR(context); + return PyObject_SetAttrString(op->func, "__module__", value); +} +#endif +static PyGetSetDef __pyx_CyFunction_getsets[] = { + {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, + {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, + {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, + {(char *) "_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, +#if CYTHON_COMPILING_IN_LIMITED_API + {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, +#endif + {0, 0, 0, 0, 0} +}; +static PyMemberDef __pyx_CyFunction_members[] = { +#if !CYTHON_COMPILING_IN_LIMITED_API + {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, +#endif +#if CYTHON_USE_TYPE_SPECS + {(char *) "__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, +#if CYTHON_METH_FASTCALL +#if CYTHON_BACKPORT_VECTORCALL + {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, +#else +#if !CYTHON_COMPILING_IN_LIMITED_API + {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, +#endif +#endif +#endif +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API + {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, +#else + {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, +#endif +#endif + {0, 0, 0, 0, 0} +}; +static PyObject * +__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) +{ + CYTHON_UNUSED_VAR(args); +#if PY_MAJOR_VERSION >= 3 + Py_INCREF(m->func_qualname); + return m->func_qualname; +#else + return PyString_FromString(((PyCFunctionObject*)m)->m_ml->ml_name); +#endif +} +static PyMethodDef __pyx_CyFunction_methods[] = { + {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, + {0, 0, 0, 0} +}; +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) +#else +#define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) +#endif +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { +#if !CYTHON_COMPILING_IN_LIMITED_API + PyCFunctionObject *cf = (PyCFunctionObject*) op; +#endif + if (unlikely(op == NULL)) + return NULL; +#if CYTHON_COMPILING_IN_LIMITED_API + op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); + if (unlikely(!op->func)) return NULL; +#endif + op->flags = flags; + __Pyx_CyFunction_weakreflist(op) = NULL; +#if !CYTHON_COMPILING_IN_LIMITED_API + cf->m_ml = ml; + cf->m_self = (PyObject *) op; +#endif + Py_XINCREF(closure); + op->func_closure = closure; +#if !CYTHON_COMPILING_IN_LIMITED_API + Py_XINCREF(module); + cf->m_module = module; +#endif + op->func_dict = NULL; + op->func_name = NULL; + Py_INCREF(qualname); + op->func_qualname = qualname; + op->func_doc = NULL; +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API + op->func_classobj = NULL; +#else + ((PyCMethodObject*)op)->mm_class = NULL; +#endif + op->func_globals = globals; + Py_INCREF(op->func_globals); + Py_XINCREF(code); + op->func_code = code; + op->defaults_pyobjects = 0; + op->defaults_size = 0; + op->defaults = NULL; + op->defaults_tuple = NULL; + op->defaults_kwdict = NULL; + op->defaults_getter = NULL; + op->func_annotations = NULL; + op->func_is_coroutine = NULL; +#if CYTHON_METH_FASTCALL + switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { + case METH_NOARGS: + __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; + break; + case METH_O: + __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; + break; + case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: + __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; + break; + case METH_FASTCALL | METH_KEYWORDS: + __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; + break; + case METH_VARARGS | METH_KEYWORDS: + __Pyx_CyFunction_func_vectorcall(op) = NULL; + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); + Py_DECREF(op); + return NULL; + } +#endif + return (PyObject *) op; +} +static int +__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) +{ + Py_CLEAR(m->func_closure); +#if CYTHON_COMPILING_IN_LIMITED_API + Py_CLEAR(m->func); +#else + Py_CLEAR(((PyCFunctionObject*)m)->m_module); +#endif + Py_CLEAR(m->func_dict); + Py_CLEAR(m->func_name); + Py_CLEAR(m->func_qualname); + Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); + Py_CLEAR(m->func_code); +#if !CYTHON_COMPILING_IN_LIMITED_API +#if PY_VERSION_HEX < 0x030900B1 + Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); +#else + { + PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; + ((PyCMethodObject *) (m))->mm_class = NULL; + Py_XDECREF(cls); + } +#endif +#endif + Py_CLEAR(m->defaults_tuple); + Py_CLEAR(m->defaults_kwdict); + Py_CLEAR(m->func_annotations); + Py_CLEAR(m->func_is_coroutine); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_XDECREF(pydefaults[i]); + PyObject_Free(m->defaults); + m->defaults = NULL; + } + return 0; +} +static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + if (__Pyx_CyFunction_weakreflist(m) != NULL) + PyObject_ClearWeakRefs((PyObject *) m); + __Pyx_CyFunction_clear(m); + __Pyx_PyHeapTypeObject_GC_Del(m); +} +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + __Pyx__CyFunction_dealloc(m); +} +static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) +{ + Py_VISIT(m->func_closure); +#if CYTHON_COMPILING_IN_LIMITED_API + Py_VISIT(m->func); +#else + Py_VISIT(((PyCFunctionObject*)m)->m_module); +#endif + Py_VISIT(m->func_dict); + Py_VISIT(m->func_name); + Py_VISIT(m->func_qualname); + Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); + Py_VISIT(m->func_code); +#if !CYTHON_COMPILING_IN_LIMITED_API + Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); +#endif + Py_VISIT(m->defaults_tuple); + Py_VISIT(m->defaults_kwdict); + Py_VISIT(m->func_is_coroutine); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_VISIT(pydefaults[i]); + } + return 0; +} +static PyObject* +__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromFormat("", + op->func_qualname, (void *)op); +#else + return PyString_FromFormat("", + PyString_AsString(op->func_qualname), (void *)op); +#endif +} +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject *f = ((__pyx_CyFunctionObject*)func)->func; + PyObject *py_name = NULL; + PyCFunction meth; + int flags; + meth = PyCFunction_GetFunction(f); + if (unlikely(!meth)) return NULL; + flags = PyCFunction_GetFlags(f); + if (unlikely(flags < 0)) return NULL; +#else + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = f->m_ml->ml_meth; + int flags = f->m_ml->ml_flags; +#endif + Py_ssize_t size; + switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + case METH_VARARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { +#if CYTHON_ASSUME_SAFE_MACROS + size = PyTuple_GET_SIZE(arg); +#else + size = PyTuple_Size(arg); + if (unlikely(size < 0)) return NULL; +#endif + if (likely(size == 0)) + return (*meth)(self, NULL); +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, + "%.200S() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + py_name, size); + Py_DECREF(py_name); +#else + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); +#endif + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { +#if CYTHON_ASSUME_SAFE_MACROS + size = PyTuple_GET_SIZE(arg); +#else + size = PyTuple_Size(arg); + if (unlikely(size < 0)) return NULL; +#endif + if (likely(size == 1)) { + PyObject *result, *arg0; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + arg0 = PyTuple_GET_ITEM(arg, 0); + #else + arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; + #endif + result = (*meth)(self, arg0); + #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(arg0); + #endif + return result; + } +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, + "%.200S() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + py_name, size); + Py_DECREF(py_name); +#else + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); +#endif + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); + return NULL; + } +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, "%.200S() takes no keyword arguments", + py_name); + Py_DECREF(py_name); +#else + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); +#endif + return NULL; +} +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *self, *result; +#if CYTHON_COMPILING_IN_LIMITED_API + self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); + if (unlikely(!self) && PyErr_Occurred()) return NULL; +#else + self = ((PyCFunctionObject*)func)->m_self; +#endif + result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); + return result; +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; +#if CYTHON_METH_FASTCALL + __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); + if (vc) { +#if CYTHON_ASSUME_SAFE_MACROS + return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); +#else + (void) &__Pyx_PyVectorcall_FastCallDict; + return PyVectorcall_Call(func, args, kw); +#endif + } +#endif + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; +#if CYTHON_ASSUME_SAFE_MACROS + argc = PyTuple_GET_SIZE(args); +#else + argc = PyTuple_Size(args); + if (unlikely(!argc) < 0) return NULL; +#endif + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); +#if PY_MAJOR_VERSION > 2 + PyErr_Format(PyExc_TypeError, + "unbound method %.200S() needs an argument", + cyfunc->func_qualname); +#else + PyErr_SetString(PyExc_TypeError, + "unbound method needs an argument"); +#endif + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; +} +#if CYTHON_METH_FASTCALL +static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) +{ + int ret = 0; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + if (unlikely(nargs < 1)) { + PyErr_Format(PyExc_TypeError, "%.200s() needs an argument", + ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); + return -1; + } + ret = 1; + } + if (unlikely(kwnames) && unlikely(PyTuple_GET_SIZE(kwnames))) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes no keyword arguments", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); + return -1; + } + return ret; +} +static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) +{ + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; + PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; +#if CYTHON_BACKPORT_VECTORCALL + Py_ssize_t nargs = (Py_ssize_t)nargsf; +#else + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); +#endif + PyObject *self; + switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { + case 1: + self = args[0]; + args += 1; + nargs -= 1; + break; + case 0: + self = ((PyCFunctionObject*)cyfunc)->m_self; + break; + default: + return NULL; + } + if (unlikely(nargs != 0)) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + def->ml_name, nargs); + return NULL; + } + return def->ml_meth(self, NULL); +} +static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) +{ + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; + PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; +#if CYTHON_BACKPORT_VECTORCALL + Py_ssize_t nargs = (Py_ssize_t)nargsf; +#else + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); +#endif + PyObject *self; + switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { + case 1: + self = args[0]; + args += 1; + nargs -= 1; + break; + case 0: + self = ((PyCFunctionObject*)cyfunc)->m_self; + break; + default: + return NULL; + } + if (unlikely(nargs != 1)) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + def->ml_name, nargs); + return NULL; + } + return def->ml_meth(self, args[0]); +} +static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) +{ + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; + PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; +#if CYTHON_BACKPORT_VECTORCALL + Py_ssize_t nargs = (Py_ssize_t)nargsf; +#else + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); +#endif + PyObject *self; + switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { + case 1: + self = args[0]; + args += 1; + nargs -= 1; + break; + case 0: + self = ((PyCFunctionObject*)cyfunc)->m_self; + break; + default: + return NULL; + } + return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames); +} +static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) +{ + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; + PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; + PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); +#if CYTHON_BACKPORT_VECTORCALL + Py_ssize_t nargs = (Py_ssize_t)nargsf; +#else + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); +#endif + PyObject *self; + switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { + case 1: + self = args[0]; + args += 1; + nargs -= 1; + break; + case 0: + self = ((PyCFunctionObject*)cyfunc)->m_self; + break; + default: + return NULL; + } + return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, (size_t)nargs, kwnames); +} +#endif +#if CYTHON_USE_TYPE_SPECS +static PyType_Slot __pyx_CyFunctionType_slots[] = { + {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, + {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, + {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, + {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, + {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, + {Py_tp_methods, (void *)__pyx_CyFunction_methods}, + {Py_tp_members, (void *)__pyx_CyFunction_members}, + {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, + {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, + {0, 0}, +}; +static PyType_Spec __pyx_CyFunctionType_spec = { + __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", + sizeof(__pyx_CyFunctionObject), + 0, +#ifdef Py_TPFLAGS_METHOD_DESCRIPTOR + Py_TPFLAGS_METHOD_DESCRIPTOR | +#endif +#if (defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL) + _Py_TPFLAGS_HAVE_VECTORCALL | +#endif + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + __pyx_CyFunctionType_slots +}; +#else +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", + sizeof(__pyx_CyFunctionObject), + 0, + (destructor) __Pyx_CyFunction_dealloc, +#if !CYTHON_METH_FASTCALL + 0, +#elif CYTHON_BACKPORT_VECTORCALL + (printfunc)offsetof(__pyx_CyFunctionObject, func_vectorcall), +#else + offsetof(PyCFunctionObject, vectorcall), +#endif + 0, + 0, +#if PY_MAJOR_VERSION < 3 + 0, +#else + 0, +#endif + (reprfunc) __Pyx_CyFunction_repr, + 0, + 0, + 0, + 0, + __Pyx_CyFunction_CallAsMethod, + 0, + 0, + 0, + 0, +#ifdef Py_TPFLAGS_METHOD_DESCRIPTOR + Py_TPFLAGS_METHOD_DESCRIPTOR | +#endif +#if defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL + _Py_TPFLAGS_HAVE_VECTORCALL | +#endif + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + 0, + (traverseproc) __Pyx_CyFunction_traverse, + (inquiry) __Pyx_CyFunction_clear, + 0, +#if PY_VERSION_HEX < 0x030500A0 + offsetof(__pyx_CyFunctionObject, func_weakreflist), +#else + offsetof(PyCFunctionObject, m_weakreflist), +#endif + 0, + 0, + __pyx_CyFunction_methods, + __pyx_CyFunction_members, + __pyx_CyFunction_getsets, + 0, + 0, + __Pyx_PyMethod_New, + 0, + offsetof(__pyx_CyFunctionObject, func_dict), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, +#endif +#if __PYX_NEED_TP_PRINT_SLOT + 0, +#endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 + 0, +#endif +}; +#endif +static int __pyx_CyFunction_init(PyObject *module) { +#if CYTHON_USE_TYPE_SPECS + __pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL); +#else + CYTHON_UNUSED_VAR(module); + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); +#endif + if (unlikely(__pyx_CyFunctionType == NULL)) { + return -1; + } + return 0; +} +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults = PyObject_Malloc(size); + if (unlikely(!m->defaults)) + return PyErr_NoMemory(); + memset(m->defaults, 0, size); + m->defaults_pyobjects = pyobjects; + m->defaults_size = size; + return m->defaults; +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_kwdict = dict; + Py_INCREF(dict); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->func_annotations = dict; + Py_INCREF(dict); +} + +/* CythonFunction */ +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + PyObject *op = __Pyx_CyFunction_Init( + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + PyObject_GC_Track(op); + } + return op; +} + +/* CLineInTraceback */ +#ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + CYTHON_MAYBE_UNUSED_VAR(tstate); + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ +#if !CYTHON_COMPILING_IN_LIMITED_API +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} +#endif + +/* AddTraceback */ +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif +#if CYTHON_COMPILING_IN_LIMITED_API +static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, + PyObject *firstlineno, PyObject *name) { + PyObject *replace = NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; + replace = PyObject_GetAttrString(code, "replace"); + if (likely(replace)) { + PyObject *result; + result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict); + Py_DECREF(replace); + return result; + } + PyErr_Clear(); + #if __PYX_LIMITED_VERSION_HEX < 0x030780000 + { + PyObject *compiled = NULL, *result = NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL; + compiled = Py_CompileString( + "out = type(code)(\n" + " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n" + " code.co_flags, code.co_code, code.co_consts, code.co_names,\n" + " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n" + " code.co_lnotab)\n", "", Py_file_input); + if (!compiled) return NULL; + result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict); + Py_DECREF(compiled); + if (!result) PyErr_Print(); + Py_DECREF(result); + result = PyDict_GetItemString(scratch_dict, "out"); + if (result) Py_INCREF(result); + return result; + } + #else + return NULL; + #endif +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; + PyObject *replace = NULL, *getframe = NULL, *frame = NULL; + PyObject *exc_type, *exc_value, *exc_traceback; + int success = 0; + if (c_line) { + (void) __pyx_cfilenm; + (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); + } + PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); + code_object = Py_CompileString("_getframe()", filename, Py_eval_input); + if (unlikely(!code_object)) goto bad; + py_py_line = PyLong_FromLong(py_line); + if (unlikely(!py_py_line)) goto bad; + py_funcname = PyUnicode_FromString(funcname); + if (unlikely(!py_funcname)) goto bad; + dict = PyDict_New(); + if (unlikely(!dict)) goto bad; + { + PyObject *old_code_object = code_object; + code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); + Py_DECREF(old_code_object); + } + if (unlikely(!code_object)) goto bad; + getframe = PySys_GetObject("_getframe"); + if (unlikely(!getframe)) goto bad; + if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; + frame = PyEval_EvalCode(code_object, dict, dict); + if (unlikely(!frame) || frame == Py_None) goto bad; + success = 1; + bad: + PyErr_Restore(exc_type, exc_value, exc_traceback); + Py_XDECREF(code_object); + Py_XDECREF(py_py_line); + Py_XDECREF(py_funcname); + Py_XDECREF(dict); + Py_XDECREF(replace); + if (success) { + PyTraceBack_Here( + (struct _frame*)frame); + } + Py_XDECREF(frame); +} +#else +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = NULL; + PyObject *py_funcname = NULL; + #if PY_MAJOR_VERSION < 3 + PyObject *py_srcfile = NULL; + py_srcfile = PyString_FromString(filename); + if (!py_srcfile) goto bad; + #endif + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + funcname = PyUnicode_AsUTF8(py_funcname); + if (!funcname) goto bad; + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + #endif + } + #if PY_MAJOR_VERSION < 3 + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + #else + py_code = PyCode_NewEmpty(filename, funcname, py_line); + #endif + Py_XDECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_funcname); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_srcfile); + #endif + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject *ptype, *pvalue, *ptraceback; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) { + /* If the code object creation fails, then we should clear the + fetched exception references and propagate the new exception */ + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + goto bad; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} +#endif + +/* Declarations */ +#if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus) + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ +#if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus) +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs(b.real) >= fabs(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + double r = b.imag / b.real; + double s = (double)(1.0) / (b.real + b.imag * r); + return __pyx_t_double_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + double r = b.real / b.imag; + double s = (double)(1.0) / (b.imag + b.real * r); + return __pyx_t_double_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + double denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_double_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + return __Pyx_c_prod_double(a, a); + case 3: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, a); + case 4: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if ((b.imag == 0) && (a.real >= 0)) { + z.real = pow(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2(0.0, -1.0); + } + } else { + r = __Pyx_c_abs_double(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +/* FromPy */ +static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) { + Py_complex cval; +#if !CYTHON_COMPILING_IN_PYPY + if (PyComplex_CheckExact(o)) + cval = ((PyComplexObject *)o)->cval; + else +#endif + cval = PyComplex_AsCComplex(o); + return __pyx_t_double_complex_from_parts( + (double)cval.real, + (double)cval.imag); +} + +/* CIntFromPyVerify */ +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntFromPy */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if ((sizeof(int) < sizeof(long))) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + if (unlikely(__Pyx_PyLong_IsNeg(x))) { + goto raise_neg_overflow; + } else if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_DigitCount(x)) { + case 2: + if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if ((sizeof(int) <= sizeof(unsigned long))) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_SignedDigitCount(x)) { + case -2: + if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } + } +#endif + if ((sizeof(int) <= sizeof(long))) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); +#if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } +#endif + if (likely(v)) { + int ret = -1; +#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); +#else + PyObject *stepval = NULL, *mask = NULL, *shift = NULL; + int bits, remaining_bits, is_negative = 0; + long idigit; + int chunk_size = (sizeof(long) < 8) ? 30 : 62; + if (unlikely(!PyLong_CheckExact(v))) { + PyObject *tmp = v; + v = PyNumber_Long(v); + assert(PyLong_CheckExact(v)); + Py_DECREF(tmp); + if (unlikely(!v)) return (int) -1; + } +#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + if (Py_SIZE(x) == 0) + return (int) 0; + is_negative = Py_SIZE(x) < 0; +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + is_negative = result == 1; + } +#endif + if (is_unsigned && unlikely(is_negative)) { + goto raise_neg_overflow; + } else if (is_negative) { + stepval = PyNumber_Invert(v); + if (unlikely(!stepval)) + return (int) -1; + } else { + stepval = __Pyx_NewRef(v); + } + val = (int) 0; + mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; + shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; + for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { + PyObject *tmp, *digit; + digit = PyNumber_And(stepval, mask); + if (unlikely(!digit)) goto done; + idigit = PyLong_AsLong(digit); + Py_DECREF(digit); + if (unlikely(idigit < 0)) goto done; + tmp = PyNumber_Rshift(stepval, shift); + if (unlikely(!tmp)) goto done; + Py_DECREF(stepval); stepval = tmp; + val |= ((int) idigit) << bits; + #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + if (Py_SIZE(stepval) == 0) + goto unpacking_done; + #endif + } + idigit = PyLong_AsLong(stepval); + if (unlikely(idigit < 0)) goto done; + remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); + if (unlikely(idigit >= (1L << remaining_bits))) + goto raise_overflow; + val |= ((int) idigit) << bits; + #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + unpacking_done: + #endif + if (!is_unsigned) { + if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) + goto raise_overflow; + if (is_negative) + val = ~val; + } + ret = 0; + done: + Py_XDECREF(shift); + Py_XDECREF(mask); + Py_XDECREF(stepval); +#endif + Py_DECREF(v); + if (likely(!ret)) + return val; + } + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; +#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); +#else + PyObject *from_bytes, *result = NULL; + PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; + from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); + if (!from_bytes) return NULL; + py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); + if (!py_bytes) goto limited_bad; + order_str = PyUnicode_FromString(little ? "little" : "big"); + if (!order_str) goto limited_bad; + arg_tuple = PyTuple_Pack(2, py_bytes, order_str); + if (!arg_tuple) goto limited_bad; + if (!is_unsigned) { + kwds = PyDict_New(); + if (!kwds) goto limited_bad; + if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; + } + result = PyObject_Call(from_bytes, arg_tuple, kwds); + limited_bad: + Py_XDECREF(kwds); + Py_XDECREF(arg_tuple); + Py_XDECREF(order_str); + Py_XDECREF(py_bytes); + Py_XDECREF(from_bytes); + return result; +#endif + } +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; +#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); +#else + PyObject *from_bytes, *result = NULL; + PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; + from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); + if (!from_bytes) return NULL; + py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int)); + if (!py_bytes) goto limited_bad; + order_str = PyUnicode_FromString(little ? "little" : "big"); + if (!order_str) goto limited_bad; + arg_tuple = PyTuple_Pack(2, py_bytes, order_str); + if (!arg_tuple) goto limited_bad; + if (!is_unsigned) { + kwds = PyDict_New(); + if (!kwds) goto limited_bad; + if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; + } + result = PyObject_Call(from_bytes, arg_tuple, kwds); + limited_bad: + Py_XDECREF(kwds); + Py_XDECREF(arg_tuple); + Py_XDECREF(order_str); + Py_XDECREF(py_bytes); + Py_XDECREF(from_bytes); + return result; +#endif + } +} + +/* CIntFromPy */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if ((sizeof(long) < sizeof(long))) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + if (unlikely(__Pyx_PyLong_IsNeg(x))) { + goto raise_neg_overflow; + } else if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_DigitCount(x)) { + case 2: + if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if ((sizeof(long) <= sizeof(unsigned long))) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_SignedDigitCount(x)) { + case -2: + if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } + } +#endif + if ((sizeof(long) <= sizeof(long))) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); +#if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } +#endif + if (likely(v)) { + int ret = -1; +#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); +#else + PyObject *stepval = NULL, *mask = NULL, *shift = NULL; + int bits, remaining_bits, is_negative = 0; + long idigit; + int chunk_size = (sizeof(long) < 8) ? 30 : 62; + if (unlikely(!PyLong_CheckExact(v))) { + PyObject *tmp = v; + v = PyNumber_Long(v); + assert(PyLong_CheckExact(v)); + Py_DECREF(tmp); + if (unlikely(!v)) return (long) -1; + } +#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + if (Py_SIZE(x) == 0) + return (long) 0; + is_negative = Py_SIZE(x) < 0; +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + is_negative = result == 1; + } +#endif + if (is_unsigned && unlikely(is_negative)) { + goto raise_neg_overflow; + } else if (is_negative) { + stepval = PyNumber_Invert(v); + if (unlikely(!stepval)) + return (long) -1; + } else { + stepval = __Pyx_NewRef(v); + } + val = (long) 0; + mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; + shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; + for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { + PyObject *tmp, *digit; + digit = PyNumber_And(stepval, mask); + if (unlikely(!digit)) goto done; + idigit = PyLong_AsLong(digit); + Py_DECREF(digit); + if (unlikely(idigit < 0)) goto done; + tmp = PyNumber_Rshift(stepval, shift); + if (unlikely(!tmp)) goto done; + Py_DECREF(stepval); stepval = tmp; + val |= ((long) idigit) << bits; + #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + if (Py_SIZE(stepval) == 0) + goto unpacking_done; + #endif + } + idigit = PyLong_AsLong(stepval); + if (unlikely(idigit < 0)) goto done; + remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); + if (unlikely(idigit >= (1L << remaining_bits))) + goto raise_overflow; + val |= ((long) idigit) << bits; + #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 + unpacking_done: + #endif + if (!is_unsigned) { + if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) + goto raise_overflow; + if (is_negative) + val = ~val; + } + ret = 0; + done: + Py_XDECREF(shift); + Py_XDECREF(mask); + Py_XDECREF(stepval); +#endif + Py_DECREF(v); + if (likely(!ret)) + return val; + } + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FormatTypeName */ +#if CYTHON_COMPILING_IN_LIMITED_API +static __Pyx_TypeName +__Pyx_PyType_GetName(PyTypeObject* tp) +{ + PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, + __pyx_n_s_name); + if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { + PyErr_Clear(); + Py_XDECREF(name); + name = __Pyx_NewRef(__pyx_n_s__9); + } + return name; +} +#endif + +/* SwapException */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_value = exc_info->exc_value; + exc_info->exc_value = *value; + if (tmp_value == NULL || tmp_value == Py_None) { + Py_XDECREF(tmp_value); + tmp_value = NULL; + tmp_type = NULL; + tmp_tb = NULL; + } else { + tmp_type = (PyObject*) Py_TYPE(tmp_value); + Py_INCREF(tmp_type); + #if CYTHON_COMPILING_IN_CPYTHON + tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback; + Py_XINCREF(tmp_tb); + #else + tmp_tb = PyException_GetTraceback(tmp_value); + #endif + } + #elif CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = *type; + exc_info->exc_value = *value; + exc_info->exc_traceback = *tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + #endif + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* PyObjectCall2Args */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args[3] = {NULL, arg1, arg2}; + return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); +} + +/* PyObjectCallMethod1 */ +#if !(CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2) +static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { + PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); + Py_DECREF(method); + return result; +} +#endif +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { +#if CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2 + PyObject *args[2] = {obj, arg}; + (void) __Pyx_PyObject_GetMethod; + (void) __Pyx_PyObject_CallOneArg; + (void) __Pyx_PyObject_Call2Args; + return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); +#else + PyObject *method = NULL, *result; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_Call2Args(method, obj, arg); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) return NULL; + return __Pyx__PyObject_CallMethod1(method, arg); +#endif +} + +/* CoroutineBase */ +#include +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif +#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) +static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) { + PyObject *et, *ev, *tb; + PyObject *value = NULL; + CYTHON_UNUSED_VAR(__pyx_tstate); + __Pyx_ErrFetch(&et, &ev, &tb); + if (!et) { + Py_XDECREF(tb); + Py_XDECREF(ev); + Py_INCREF(Py_None); + *pvalue = Py_None; + return 0; + } + if (likely(et == PyExc_StopIteration)) { + if (!ev) { + Py_INCREF(Py_None); + value = Py_None; + } +#if PY_VERSION_HEX >= 0x030300A0 + else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) { + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); + } +#endif + else if (unlikely(PyTuple_Check(ev))) { + if (PyTuple_GET_SIZE(ev) >= 1) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + value = PyTuple_GET_ITEM(ev, 0); + Py_INCREF(value); +#else + value = PySequence_ITEM(ev, 0); +#endif + } else { + Py_INCREF(Py_None); + value = Py_None; + } + Py_DECREF(ev); + } + else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { + value = ev; + } + if (likely(value)) { + Py_XDECREF(tb); + Py_DECREF(et); + *pvalue = value; + return 0; + } + } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + PyErr_NormalizeException(&et, &ev, &tb); + if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + Py_XDECREF(tb); + Py_DECREF(et); +#if PY_VERSION_HEX >= 0x030300A0 + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); +#else + { + PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); + Py_DECREF(ev); + if (likely(args)) { + value = PySequence_GetItem(args, 0); + Py_DECREF(args); + } + if (unlikely(!value)) { + __Pyx_ErrRestore(NULL, NULL, NULL); + Py_INCREF(Py_None); + value = Py_None; + } + } +#endif + *pvalue = value; + return 0; +} +static CYTHON_INLINE +void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { +#if PY_VERSION_HEX >= 0x030B00a4 + Py_CLEAR(exc_state->exc_value); +#else + PyObject *t, *v, *tb; + t = exc_state->exc_type; + v = exc_state->exc_value; + tb = exc_state->exc_traceback; + exc_state->exc_type = NULL; + exc_state->exc_value = NULL; + exc_state->exc_traceback = NULL; + Py_XDECREF(t); + Py_XDECREF(v); + Py_XDECREF(tb); +#endif +} +#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) { + const char *msg; + CYTHON_MAYBE_UNUSED_VAR(gen); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { + msg = "coroutine already executing"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { + msg = "async generator already executing"; + #endif + } else { + msg = "generator already executing"; + } + PyErr_SetString(PyExc_ValueError, msg); +} +#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_NotStartedError(PyObject *gen) { + const char *msg; + CYTHON_MAYBE_UNUSED_VAR(gen); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(gen)) { + msg = "can't send non-None value to a just-started coroutine"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(gen)) { + msg = "can't send non-None value to a just-started async generator"; + #endif + } else { + msg = "can't send non-None value to a just-started generator"; + } + PyErr_SetString(PyExc_TypeError, msg); +} +#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) { + CYTHON_MAYBE_UNUSED_VAR(gen); + CYTHON_MAYBE_UNUSED_VAR(closing); + #ifdef __Pyx_Coroutine_USED + if (!closing && __Pyx_Coroutine_Check(gen)) { + PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); + } else + #endif + if (value) { + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); + else + #endif + PyErr_SetNone(PyExc_StopIteration); + } +} +static +PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { + __Pyx_PyThreadState_declare + PyThreadState *tstate; + __Pyx_ExcInfoStruct *exc_state; + PyObject *retval; + assert(!self->is_running); + if (unlikely(self->resume_label == 0)) { + if (unlikely(value && value != Py_None)) { + return __Pyx_Coroutine_NotStartedError((PyObject*)self); + } + } + if (unlikely(self->resume_label == -1)) { + return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); + } +#if CYTHON_FAST_THREAD_STATE + __Pyx_PyThreadState_assign + tstate = __pyx_tstate; +#else + tstate = __Pyx_PyThreadState_Current; +#endif + exc_state = &self->gi_exc_state; + if (exc_state->exc_value) { + #if CYTHON_COMPILING_IN_PYPY + #else + PyObject *exc_tb; + #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON + exc_tb = PyException_GetTraceback(exc_state->exc_value); + #elif PY_VERSION_HEX >= 0x030B00a4 + exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback; + #else + exc_tb = exc_state->exc_traceback; + #endif + if (exc_tb) { + PyTracebackObject *tb = (PyTracebackObject *) exc_tb; + PyFrameObject *f = tb->tb_frame; + assert(f->f_back == NULL); + #if PY_VERSION_HEX >= 0x030B00A1 + f->f_back = PyThreadState_GetFrame(tstate); + #else + Py_XINCREF(tstate->frame); + f->f_back = tstate->frame; + #endif + #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON + Py_DECREF(exc_tb); + #endif + } + #endif + } +#if CYTHON_USE_EXC_INFO_STACK + exc_state->previous_item = tstate->exc_info; + tstate->exc_info = exc_state; +#else + if (exc_state->exc_type) { + __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + } else { + __Pyx_Coroutine_ExceptionClear(exc_state); + __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + } +#endif + self->is_running = 1; + retval = self->body(self, tstate, value); + self->is_running = 0; +#if CYTHON_USE_EXC_INFO_STACK + exc_state = &self->gi_exc_state; + tstate->exc_info = exc_state->previous_item; + exc_state->previous_item = NULL; + __Pyx_Coroutine_ResetFrameBackpointer(exc_state); +#endif + return retval; +} +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { +#if CYTHON_COMPILING_IN_PYPY + CYTHON_UNUSED_VAR(exc_state); +#else + PyObject *exc_tb; + #if PY_VERSION_HEX >= 0x030B00a4 + if (!exc_state->exc_value) return; + exc_tb = PyException_GetTraceback(exc_state->exc_value); + #else + exc_tb = exc_state->exc_traceback; + #endif + if (likely(exc_tb)) { + PyTracebackObject *tb = (PyTracebackObject *) exc_tb; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); + #if PY_VERSION_HEX >= 0x030B00a4 + Py_DECREF(exc_tb); + #endif + } +#endif +} +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_MethodReturn(PyObject* gen, PyObject *retval) { + CYTHON_MAYBE_UNUSED_VAR(gen); + if (unlikely(!retval)) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (!__Pyx_PyErr_Occurred()) { + PyObject *exc = PyExc_StopIteration; + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + exc = __Pyx_PyExc_StopAsyncIteration; + #endif + __Pyx_PyErr_SetNone(exc); + } + } + return retval; +} +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) +static CYTHON_INLINE +PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { +#if PY_VERSION_HEX <= 0x030A00A1 + return _PyGen_Send(gen, arg); +#else + PyObject *result; + if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { + if (PyAsyncGen_CheckExact(gen)) { + assert(result == Py_None); + PyErr_SetNone(PyExc_StopAsyncIteration); + } + else if (result == Py_None) { + PyErr_SetNone(PyExc_StopIteration); + } + else { +#if PY_VERSION_HEX < 0x030d00A1 + _PyGen_SetStopIterationValue(result); +#else + if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) { + PyErr_SetObject(PyExc_StopIteration, result); + } else { + PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result); + if (likely(exc != NULL)) { + PyErr_SetObject(PyExc_StopIteration, exc); + Py_DECREF(exc); + } + } +#endif + } + Py_DECREF(result); + result = NULL; + } + return result; +#endif +} +#endif +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { + PyObject *ret; + PyObject *val = NULL; + __Pyx_Coroutine_Undelegate(gen); + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); + ret = __Pyx_Coroutine_SendEx(gen, val, 0); + Py_XDECREF(val); + return ret; +} +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { + PyObject *retval; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + ret = __Pyx_async_gen_asend_send(yf, value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyCoro_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + { + if (value == Py_None) + ret = __Pyx_PyObject_GetIterNextFunc(yf)(yf); + else + ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); + } + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + retval = __Pyx_Coroutine_FinishDelegation(gen); + } else { + retval = __Pyx_Coroutine_SendEx(gen, value, 0); + } + return __Pyx_Coroutine_MethodReturn(self, retval); +} +static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { + PyObject *retval = NULL; + int err = 0; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + if (__Pyx_CoroutineAwait_CheckExact(yf)) { + retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + retval = __Pyx_async_gen_asend_close(yf, NULL); + } else + if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { + retval = __Pyx_async_gen_athrow_close(yf, NULL); + } else + #endif + { + PyObject *meth; + gen->is_running = 1; + meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_n_s_close); + if (unlikely(!meth)) { + if (unlikely(PyErr_Occurred())) { + PyErr_WriteUnraisable(yf); + } + } else { + retval = __Pyx_PyObject_CallNoArg(meth); + Py_DECREF(meth); + if (unlikely(!retval)) + err = -1; + } + gen->is_running = 0; + } + Py_XDECREF(retval); + return err; +} +static PyObject *__Pyx_Generator_Next(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Next(yf); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, Py_None); + } else + #endif + ret = __Pyx_PyObject_GetIterNextFunc(yf)(yf); + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + return __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_SendEx(gen, Py_None, 0); +} +static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) { + CYTHON_UNUSED_VAR(arg); + return __Pyx_Coroutine_Close(self); +} +static PyObject *__Pyx_Coroutine_Close(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *retval, *raised_exception; + PyObject *yf = gen->yieldfrom; + int err = 0; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + Py_INCREF(yf); + err = __Pyx_Coroutine_CloseIter(gen, yf); + __Pyx_Coroutine_Undelegate(gen); + Py_DECREF(yf); + } + if (err == 0) + PyErr_SetNone(PyExc_GeneratorExit); + retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); + if (unlikely(retval)) { + const char *msg; + Py_DECREF(retval); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(self)) { + msg = "coroutine ignored GeneratorExit"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(self)) { +#if PY_VERSION_HEX < 0x03060000 + msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; +#else + msg = "async generator ignored GeneratorExit"; +#endif + #endif + } else { + msg = "generator ignored GeneratorExit"; + } + PyErr_SetString(PyExc_RuntimeError, msg); + return NULL; + } + raised_exception = PyErr_Occurred(); + if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { + if (raised_exception) PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + return NULL; +} +static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, + PyObject *args, int close_on_genexit) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + Py_INCREF(yf); + if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { + int err = __Pyx_Coroutine_CloseIter(gen, yf); + Py_DECREF(yf); + __Pyx_Coroutine_Undelegate(gen); + if (err < 0) + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); + goto throw_here; + } + gen->is_running = 1; + if (0 + #ifdef __Pyx_Generator_USED + || __Pyx_Generator_CheckExact(yf) + #endif + #ifdef __Pyx_Coroutine_USED + || __Pyx_Coroutine_Check(yf) + #endif + ) { + ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { + ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); + #endif + } else { + PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_n_s_throw); + if (unlikely(!meth)) { + Py_DECREF(yf); + if (unlikely(PyErr_Occurred())) { + gen->is_running = 0; + return NULL; + } + __Pyx_Coroutine_Undelegate(gen); + gen->is_running = 0; + goto throw_here; + } + if (likely(args)) { + ret = __Pyx_PyObject_Call(meth, args, NULL); + } else { + PyObject *cargs[4] = {NULL, typ, val, tb}; + ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); + } + Py_DECREF(meth); + } + gen->is_running = 0; + Py_DECREF(yf); + if (!ret) { + ret = __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_MethodReturn(self, ret); + } +throw_here: + __Pyx_Raise(typ, val, tb, NULL); + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); +} +static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { + PyObject *typ; + PyObject *val = NULL; + PyObject *tb = NULL; + if (unlikely(!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))) + return NULL; + return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); +} +static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { +#if PY_VERSION_HEX >= 0x030B00a4 + Py_VISIT(exc_state->exc_value); +#else + Py_VISIT(exc_state->exc_type); + Py_VISIT(exc_state->exc_value); + Py_VISIT(exc_state->exc_traceback); +#endif + return 0; +} +static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { + Py_VISIT(gen->closure); + Py_VISIT(gen->classobj); + Py_VISIT(gen->yieldfrom); + return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); +} +static int __Pyx_Coroutine_clear(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + Py_CLEAR(gen->closure); + Py_CLEAR(gen->classobj); + Py_CLEAR(gen->yieldfrom); + __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); + } +#endif + Py_CLEAR(gen->gi_code); + Py_CLEAR(gen->gi_frame); + Py_CLEAR(gen->gi_name); + Py_CLEAR(gen->gi_qualname); + Py_CLEAR(gen->gi_modulename); + return 0; +} +static void __Pyx_Coroutine_dealloc(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject_GC_UnTrack(gen); + if (gen->gi_weakreflist != NULL) + PyObject_ClearWeakRefs(self); + if (gen->resume_label >= 0) { + PyObject_GC_Track(self); +#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE + if (unlikely(PyObject_CallFinalizerFromDealloc(self))) +#else + Py_TYPE(gen)->tp_del(self); + if (unlikely(Py_REFCNT(self) > 0)) +#endif + { + return; + } + PyObject_GC_UnTrack(self); + } +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + /* We have to handle this case for asynchronous generators + right here, because this code has to be between UNTRACK + and GC_Del. */ + Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); + } +#endif + __Pyx_Coroutine_clear(self); + __Pyx_PyHeapTypeObject_GC_Del(gen); +} +static void __Pyx_Coroutine_del(PyObject *self) { + PyObject *error_type, *error_value, *error_traceback; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + __Pyx_PyThreadState_declare + if (gen->resume_label < 0) { + return; + } +#if !CYTHON_USE_TP_FINALIZE + assert(self->ob_refcnt == 0); + __Pyx_SET_REFCNT(self, 1); +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; + PyObject *finalizer = agen->ag_finalizer; + if (finalizer && !agen->ag_closed) { + PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); + if (unlikely(!res)) { + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + __Pyx_ErrRestore(error_type, error_value, error_traceback); + return; + } + } +#endif + if (unlikely(gen->resume_label == 0 && !error_value)) { +#ifdef __Pyx_Coroutine_USED +#ifdef __Pyx_Generator_USED + if (!__Pyx_Generator_CheckExact(self)) +#endif + { + PyObject_GC_UnTrack(self); +#if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat) + if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) + PyErr_WriteUnraisable(self); +#else + {PyObject *msg; + char *cmsg; + #if CYTHON_COMPILING_IN_PYPY + msg = NULL; + cmsg = (char*) "coroutine was never awaited"; + #else + char *cname; + PyObject *qualname; + qualname = gen->gi_qualname; + cname = PyString_AS_STRING(qualname); + msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); + if (unlikely(!msg)) { + PyErr_Clear(); + cmsg = (char*) "coroutine was never awaited"; + } else { + cmsg = PyString_AS_STRING(msg); + } + #endif + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) + PyErr_WriteUnraisable(self); + Py_XDECREF(msg);} +#endif + PyObject_GC_Track(self); + } +#endif + } else { + PyObject *res = __Pyx_Coroutine_Close(self); + if (unlikely(!res)) { + if (PyErr_Occurred()) + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + } + __Pyx_ErrRestore(error_type, error_value, error_traceback); +#if !CYTHON_USE_TP_FINALIZE + assert(Py_REFCNT(self) > 0); + if (likely(--self->ob_refcnt == 0)) { + return; + } + { + Py_ssize_t refcnt = Py_REFCNT(self); + _Py_NewReference(self); + __Pyx_SET_REFCNT(self, refcnt); + } +#if CYTHON_COMPILING_IN_CPYTHON + assert(PyType_IS_GC(Py_TYPE(self)) && + _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); + _Py_DEC_REFTOTAL; +#endif +#ifdef COUNT_ALLOCS + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; +#endif +#endif +} +static PyObject * +__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context) +{ + PyObject *name = self->gi_name; + CYTHON_UNUSED_VAR(context); + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(self->gi_name, value); + return 0; +} +static PyObject * +__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context) +{ + PyObject *name = self->gi_qualname; + CYTHON_UNUSED_VAR(context); + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context) +{ + CYTHON_UNUSED_VAR(context); +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + Py_INCREF(value); + __Pyx_Py_XDECREF_SET(self->gi_qualname, value); + return 0; +} +static PyObject * +__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) +{ + PyObject *frame = self->gi_frame; + CYTHON_UNUSED_VAR(context); + if (!frame) { + if (unlikely(!self->gi_code)) { + Py_RETURN_NONE; + } + frame = (PyObject *) PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (unlikely(!frame)) + return NULL; + self->gi_frame = frame; + } + Py_INCREF(frame); + return frame; +} +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); + if (unlikely(!gen)) + return NULL; + return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); +} +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + gen->body = body; + gen->closure = closure; + Py_XINCREF(closure); + gen->is_running = 0; + gen->resume_label = 0; + gen->classobj = NULL; + gen->yieldfrom = NULL; + #if PY_VERSION_HEX >= 0x030B00a4 + gen->gi_exc_state.exc_value = NULL; + #else + gen->gi_exc_state.exc_type = NULL; + gen->gi_exc_state.exc_value = NULL; + gen->gi_exc_state.exc_traceback = NULL; + #endif +#if CYTHON_USE_EXC_INFO_STACK + gen->gi_exc_state.previous_item = NULL; +#endif + gen->gi_weakreflist = NULL; + Py_XINCREF(qualname); + gen->gi_qualname = qualname; + Py_XINCREF(name); + gen->gi_name = name; + Py_XINCREF(module_name); + gen->gi_modulename = module_name; + Py_XINCREF(code); + gen->gi_code = code; + gen->gi_frame = NULL; + PyObject_GC_Track(gen); + return gen; +} + +/* PatchModuleWithCoroutine */ +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + int result; + PyObject *globals, *result_obj; + globals = PyDict_New(); if (unlikely(!globals)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_coroutine_type", + #ifdef __Pyx_Coroutine_USED + (PyObject*)__pyx_CoroutineType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_generator_type", + #ifdef __Pyx_Generator_USED + (PyObject*)__pyx_GeneratorType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; + result_obj = PyRun_String(py_code, Py_file_input, globals, globals); + if (unlikely(!result_obj)) goto ignore; + Py_DECREF(result_obj); + Py_DECREF(globals); + return module; +ignore: + Py_XDECREF(globals); + PyErr_WriteUnraisable(module); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { + Py_DECREF(module); + module = NULL; + } +#else + py_code++; +#endif + return module; +} + +/* PatchGeneratorABC */ +#ifndef CYTHON_REGISTER_ABCS +#define CYTHON_REGISTER_ABCS 1 +#endif +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) +static PyObject* __Pyx_patch_abc_module(PyObject *module); +static PyObject* __Pyx_patch_abc_module(PyObject *module) { + module = __Pyx_Coroutine_patch_module( + module, "" +"if _cython_generator_type is not None:\n" +" try: Generator = _module.Generator\n" +" except AttributeError: pass\n" +" else: Generator.register(_cython_generator_type)\n" +"if _cython_coroutine_type is not None:\n" +" try: Coroutine = _module.Coroutine\n" +" except AttributeError: pass\n" +" else: Coroutine.register(_cython_coroutine_type)\n" + ); + return module; +} +#endif +static int __Pyx_patch_abc(void) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + static int abc_patched = 0; + if (CYTHON_REGISTER_ABCS && !abc_patched) { + PyObject *module; + module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); + if (unlikely(!module)) { + PyErr_WriteUnraisable(NULL); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, + ((PY_MAJOR_VERSION >= 3) ? + "Cython module failed to register with collections.abc module" : + "Cython module failed to register with collections module"), 1) < 0)) { + return -1; + } + } else { + module = __Pyx_patch_abc_module(module); + abc_patched = 1; + if (unlikely(!module)) + return -1; + Py_DECREF(module); + } + module = PyImport_ImportModule("backports_abc"); + if (module) { + module = __Pyx_patch_abc_module(module); + Py_XDECREF(module); + } + if (!module) { + PyErr_Clear(); + } + } +#else + if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); +#endif + return 0; +} + +/* Generator */ +static PyMethodDef __pyx_Generator_methods[] = { + {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, + {0, 0, 0, 0} +}; +static PyMemberDef __pyx_Generator_memberlist[] = { + {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, + {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, + {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0}, +#if CYTHON_USE_TYPE_SPECS + {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0}, +#endif + {0, 0, 0, 0, 0} +}; +static PyGetSetDef __pyx_Generator_getsets[] = { + {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the generator"), 0}, + {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the generator"), 0}, + {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, + (char*) PyDoc_STR("Frame of the generator"), 0}, + {0, 0, 0, 0, 0} +}; +#if CYTHON_USE_TYPE_SPECS +static PyType_Slot __pyx_GeneratorType_slots[] = { + {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc}, + {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse}, + {Py_tp_iter, (void *)PyObject_SelfIter}, + {Py_tp_iternext, (void *)__Pyx_Generator_Next}, + {Py_tp_methods, (void *)__pyx_Generator_methods}, + {Py_tp_members, (void *)__pyx_Generator_memberlist}, + {Py_tp_getset, (void *)__pyx_Generator_getsets}, + {Py_tp_getattro, (void *) __Pyx_PyObject_GenericGetAttrNoDict}, +#if CYTHON_USE_TP_FINALIZE + {Py_tp_finalize, (void *)__Pyx_Coroutine_del}, +#endif + {0, 0}, +}; +static PyType_Spec __pyx_GeneratorType_spec = { + __PYX_TYPE_MODULE_PREFIX "generator", + sizeof(__pyx_CoroutineObject), + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, + __pyx_GeneratorType_slots +}; +#else +static PyTypeObject __pyx_GeneratorType_type = { + PyVarObject_HEAD_INIT(0, 0) + __PYX_TYPE_MODULE_PREFIX "generator", + sizeof(__pyx_CoroutineObject), + 0, + (destructor) __Pyx_Coroutine_dealloc, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, + 0, + (traverseproc) __Pyx_Coroutine_traverse, + 0, + 0, + offsetof(__pyx_CoroutineObject, gi_weakreflist), + 0, + (iternextfunc) __Pyx_Generator_Next, + __pyx_Generator_methods, + __pyx_Generator_memberlist, + __pyx_Generator_getsets, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if CYTHON_USE_TP_FINALIZE + 0, +#else + __Pyx_Coroutine_del, +#endif + 0, +#if CYTHON_USE_TP_FINALIZE + __Pyx_Coroutine_del, +#elif PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, +#endif +#if __PYX_NEED_TP_PRINT_SLOT + 0, +#endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 + 0, +#endif +}; +#endif +static int __pyx_Generator_init(PyObject *module) { +#if CYTHON_USE_TYPE_SPECS + __pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_GeneratorType_spec, NULL); +#else + CYTHON_UNUSED_VAR(module); + __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; + __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); +#endif + if (unlikely(!__pyx_GeneratorType)) { + return -1; + } + return 0; +} + +/* CheckBinaryVersion */ +static unsigned long __Pyx_get_runtime_version(void) { +#if __PYX_LIMITED_VERSION_HEX >= 0x030B00A4 + return Py_Version & ~0xFFUL; +#else + const char* rt_version = Py_GetVersion(); + unsigned long version = 0; + unsigned long factor = 0x01000000UL; + unsigned int digit = 0; + int i = 0; + while (factor) { + while ('0' <= rt_version[i] && rt_version[i] <= '9') { + digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); + ++i; + } + version += factor * digit; + if (rt_version[i] != '.') + break; + digit = 0; + factor >>= 8; + ++i; + } + return version; +#endif +} +static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { + const unsigned long MAJOR_MINOR = 0xFFFF0000UL; + if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) + return 0; + if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) + return 1; + { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compile time Python version %d.%d " + "of module '%.100s' " + "%s " + "runtime version %d.%d", + (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), + __Pyx_MODULE_NAME, + (allow_newer) ? "was newer than" : "does not match", + (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) + ); + return PyErr_WarnEx(NULL, message, 1); + } +} + +/* InitStrings */ +#if PY_MAJOR_VERSION >= 3 +static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) { + if (t.is_unicode | t.is_str) { + if (t.intern) { + *str = PyUnicode_InternFromString(t.s); + } else if (t.encoding) { + *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL); + } else { + *str = PyUnicode_FromStringAndSize(t.s, t.n - 1); + } + } else { + *str = PyBytes_FromStringAndSize(t.s, t.n - 1); + } + if (!*str) + return -1; + if (PyObject_Hash(*str) == -1) + return -1; + return 0; +} +#endif +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION >= 3 + __Pyx_InitString(*t, t->p); + #else + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; + #endif + ++t; + } + return 0; +} + +#include +static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { + size_t len = strlen(s); + if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, "byte string is too long"); + return -1; + } + return (Py_ssize_t) len; +} +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + Py_ssize_t len = __Pyx_ssize_strlen(c_str); + if (unlikely(len < 0)) return NULL; + return __Pyx_PyUnicode_FromStringAndSize(c_str, len); +} +static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { + Py_ssize_t len = __Pyx_ssize_strlen(c_str); + if (unlikely(len < 0)) return NULL; + return PyByteArray_FromStringAndSize(c_str, len); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { + __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result)); +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " + "The ability to return an instance of a strict subclass of int is deprecated, " + "and may be removed in a future version of Python.", + result_type_name)) { + __Pyx_DECREF_TypeName(result_type_name); + Py_DECREF(result); + return NULL; + } + __Pyx_DECREF_TypeName(result_type_name); + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")", + type_name, type_name, result_type_name); + __Pyx_DECREF_TypeName(result_type_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(b); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(__Pyx_PyLong_IsCompact(b))) { + return __Pyx_PyLong_CompactValue(b); + } else { + const digit* digits = __Pyx_PyLong_Digits(b); + const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { + if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { + return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); +#if PY_MAJOR_VERSION < 3 + } else if (likely(PyInt_CheckExact(o))) { + return PyInt_AS_LONG(o); +#endif + } else { + Py_ssize_t ival; + PyObject *x; + x = PyNumber_Index(o); + if (!x) return -1; + ival = PyInt_AsLong(x); + Py_DECREF(x); + return ival; + } +} +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +/* #### Code section: utility_code_pragmas_end ### */ +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + + + +/* #### Code section: end ### */ +#endif /* Py_PYTHON_H */ diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..9ba92103 Binary files /dev/null and b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.py new file mode 100644 index 00000000..e620b48a --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/cu2qu.py @@ -0,0 +1,534 @@ +# cython: language_level=3 +# distutils: define_macros=CYTHON_TRACE_NOGIL=1 + +# Copyright 2015 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +try: + import cython + + COMPILED = cython.compiled +except (AttributeError, ImportError): + # if cython not installed, use mock module with no-op decorators and types + from fontTools.misc import cython + + COMPILED = False + +import math + +from .errors import Error as Cu2QuError, ApproxNotFoundError + + +__all__ = ["curve_to_quadratic", "curves_to_quadratic"] + +MAX_N = 100 + +NAN = float("NaN") + + +@cython.cfunc +@cython.inline +@cython.returns(cython.double) +@cython.locals(v1=cython.complex, v2=cython.complex) +def dot(v1, v2): + """Return the dot product of two vectors. + + Args: + v1 (complex): First vector. + v2 (complex): Second vector. + + Returns: + double: Dot product. + """ + return (v1 * v2.conjugate()).real + + +@cython.cfunc +@cython.inline +@cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) +@cython.locals( + _1=cython.complex, _2=cython.complex, _3=cython.complex, _4=cython.complex +) +def calc_cubic_points(a, b, c, d): + _1 = d + _2 = (c / 3.0) + d + _3 = (b + c) / 3.0 + _2 + _4 = a + d + c + b + return _1, _2, _3, _4 + + +@cython.cfunc +@cython.inline +@cython.locals( + p0=cython.complex, p1=cython.complex, p2=cython.complex, p3=cython.complex +) +@cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) +def calc_cubic_parameters(p0, p1, p2, p3): + c = (p1 - p0) * 3.0 + b = (p2 - p1) * 3.0 - c + d = p0 + a = p3 - d - c - b + return a, b, c, d + + +@cython.cfunc +@cython.inline +@cython.locals( + p0=cython.complex, p1=cython.complex, p2=cython.complex, p3=cython.complex +) +def split_cubic_into_n_iter(p0, p1, p2, p3, n): + """Split a cubic Bezier into n equal parts. + + Splits the curve into `n` equal parts by curve time. + (t=0..1/n, t=1/n..2/n, ...) + + Args: + p0 (complex): Start point of curve. + p1 (complex): First handle of curve. + p2 (complex): Second handle of curve. + p3 (complex): End point of curve. + + Returns: + An iterator yielding the control points (four complex values) of the + subcurves. + """ + # Hand-coded special-cases + if n == 2: + return iter(split_cubic_into_two(p0, p1, p2, p3)) + if n == 3: + return iter(split_cubic_into_three(p0, p1, p2, p3)) + if n == 4: + a, b = split_cubic_into_two(p0, p1, p2, p3) + return iter( + split_cubic_into_two(a[0], a[1], a[2], a[3]) + + split_cubic_into_two(b[0], b[1], b[2], b[3]) + ) + if n == 6: + a, b = split_cubic_into_two(p0, p1, p2, p3) + return iter( + split_cubic_into_three(a[0], a[1], a[2], a[3]) + + split_cubic_into_three(b[0], b[1], b[2], b[3]) + ) + + return _split_cubic_into_n_gen(p0, p1, p2, p3, n) + + +@cython.locals( + p0=cython.complex, + p1=cython.complex, + p2=cython.complex, + p3=cython.complex, + n=cython.int, +) +@cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) +@cython.locals( + dt=cython.double, delta_2=cython.double, delta_3=cython.double, i=cython.int +) +@cython.locals( + a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex +) +def _split_cubic_into_n_gen(p0, p1, p2, p3, n): + a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) + dt = 1 / n + delta_2 = dt * dt + delta_3 = dt * delta_2 + for i in range(n): + t1 = i * dt + t1_2 = t1 * t1 + # calc new a, b, c and d + a1 = a * delta_3 + b1 = (3 * a * t1 + b) * delta_2 + c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt + d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d + yield calc_cubic_points(a1, b1, c1, d1) + + +@cython.cfunc +@cython.inline +@cython.locals( + p0=cython.complex, p1=cython.complex, p2=cython.complex, p3=cython.complex +) +@cython.locals(mid=cython.complex, deriv3=cython.complex) +def split_cubic_into_two(p0, p1, p2, p3): + """Split a cubic Bezier into two equal parts. + + Splits the curve into two equal parts at t = 0.5 + + Args: + p0 (complex): Start point of curve. + p1 (complex): First handle of curve. + p2 (complex): Second handle of curve. + p3 (complex): End point of curve. + + Returns: + tuple: Two cubic Beziers (each expressed as a tuple of four complex + values). + """ + mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + deriv3 = (p3 + p2 - p1 - p0) * 0.125 + return ( + (p0, (p0 + p1) * 0.5, mid - deriv3, mid), + (mid, mid + deriv3, (p2 + p3) * 0.5, p3), + ) + + +@cython.cfunc +@cython.inline +@cython.locals( + p0=cython.complex, + p1=cython.complex, + p2=cython.complex, + p3=cython.complex, +) +@cython.locals( + mid1=cython.complex, + deriv1=cython.complex, + mid2=cython.complex, + deriv2=cython.complex, +) +def split_cubic_into_three(p0, p1, p2, p3): + """Split a cubic Bezier into three equal parts. + + Splits the curve into three equal parts at t = 1/3 and t = 2/3 + + Args: + p0 (complex): Start point of curve. + p1 (complex): First handle of curve. + p2 (complex): Second handle of curve. + p3 (complex): End point of curve. + + Returns: + tuple: Three cubic Beziers (each expressed as a tuple of four complex + values). + """ + mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) + deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) + mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) + deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) + return ( + (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), + (mid1, mid1 + deriv1, mid2 - deriv2, mid2), + (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), + ) + + +@cython.cfunc +@cython.inline +@cython.returns(cython.complex) +@cython.locals( + t=cython.double, + p0=cython.complex, + p1=cython.complex, + p2=cython.complex, + p3=cython.complex, +) +@cython.locals(_p1=cython.complex, _p2=cython.complex) +def cubic_approx_control(t, p0, p1, p2, p3): + """Approximate a cubic Bezier using a quadratic one. + + Args: + t (double): Position of control point. + p0 (complex): Start point of curve. + p1 (complex): First handle of curve. + p2 (complex): Second handle of curve. + p3 (complex): End point of curve. + + Returns: + complex: Location of candidate control point on quadratic curve. + """ + _p1 = p0 + (p1 - p0) * 1.5 + _p2 = p3 + (p2 - p3) * 1.5 + return _p1 + (_p2 - _p1) * t + + +@cython.cfunc +@cython.inline +@cython.returns(cython.complex) +@cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) +@cython.locals(ab=cython.complex, cd=cython.complex, p=cython.complex, h=cython.double) +def calc_intersect(a, b, c, d): + """Calculate the intersection of two lines. + + Args: + a (complex): Start point of first line. + b (complex): End point of first line. + c (complex): Start point of second line. + d (complex): End point of second line. + + Returns: + complex: Location of intersection if one present, ``complex(NaN,NaN)`` + if no intersection was found. + """ + ab = b - a + cd = d - c + p = ab * 1j + try: + h = dot(p, a - c) / dot(p, cd) + except ZeroDivisionError: + return complex(NAN, NAN) + return c + cd * h + + +@cython.cfunc +@cython.returns(cython.int) +@cython.locals( + tolerance=cython.double, + p0=cython.complex, + p1=cython.complex, + p2=cython.complex, + p3=cython.complex, +) +@cython.locals(mid=cython.complex, deriv3=cython.complex) +def cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): + """Check if a cubic Bezier lies within a given distance of the origin. + + "Origin" means *the* origin (0,0), not the start of the curve. Note that no + checks are made on the start and end positions of the curve; this function + only checks the inside of the curve. + + Args: + p0 (complex): Start point of curve. + p1 (complex): First handle of curve. + p2 (complex): Second handle of curve. + p3 (complex): End point of curve. + tolerance (double): Distance from origin. + + Returns: + bool: True if the cubic Bezier ``p`` entirely lies within a distance + ``tolerance`` of the origin, False otherwise. + """ + # First check p2 then p1, as p2 has higher error early on. + if abs(p2) <= tolerance and abs(p1) <= tolerance: + return True + + # Split. + mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 + if abs(mid) > tolerance: + return False + deriv3 = (p3 + p2 - p1 - p0) * 0.125 + return cubic_farthest_fit_inside( + p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance + ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) + + +@cython.cfunc +@cython.inline +@cython.locals(tolerance=cython.double) +@cython.locals( + q1=cython.complex, + c0=cython.complex, + c1=cython.complex, + c2=cython.complex, + c3=cython.complex, +) +def cubic_approx_quadratic(cubic, tolerance): + """Approximate a cubic Bezier with a single quadratic within a given tolerance. + + Args: + cubic (sequence): Four complex numbers representing control points of + the cubic Bezier curve. + tolerance (double): Permitted deviation from the original curve. + + Returns: + Three complex numbers representing control points of the quadratic + curve if it fits within the given tolerance, or ``None`` if no suitable + curve could be calculated. + """ + + q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) + if math.isnan(q1.imag): + return None + c0 = cubic[0] + c3 = cubic[3] + c1 = c0 + (q1 - c0) * (2 / 3) + c2 = c3 + (q1 - c3) * (2 / 3) + if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): + return None + return c0, q1, c3 + + +@cython.cfunc +@cython.locals(n=cython.int, tolerance=cython.double) +@cython.locals(i=cython.int) +@cython.locals(all_quadratic=cython.int) +@cython.locals( + c0=cython.complex, c1=cython.complex, c2=cython.complex, c3=cython.complex +) +@cython.locals( + q0=cython.complex, + q1=cython.complex, + next_q1=cython.complex, + q2=cython.complex, + d1=cython.complex, +) +def cubic_approx_spline(cubic, n, tolerance, all_quadratic): + """Approximate a cubic Bezier curve with a spline of n quadratics. + + Args: + cubic (sequence): Four complex numbers representing control points of + the cubic Bezier curve. + n (int): Number of quadratic Bezier curves in the spline. + tolerance (double): Permitted deviation from the original curve. + + Returns: + A list of ``n+2`` complex numbers, representing control points of the + quadratic spline if it fits within the given tolerance, or ``None`` if + no suitable spline could be calculated. + """ + + if n == 1: + return cubic_approx_quadratic(cubic, tolerance) + if n == 2 and all_quadratic == False: + return cubic + + cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) + + # calculate the spline of quadratics and check errors at the same time. + next_cubic = next(cubics) + next_q1 = cubic_approx_control( + 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + ) + q2 = cubic[0] + d1 = 0j + spline = [cubic[0], next_q1] + for i in range(1, n + 1): + # Current cubic to convert + c0, c1, c2, c3 = next_cubic + + # Current quadratic approximation of current cubic + q0 = q2 + q1 = next_q1 + if i < n: + next_cubic = next(cubics) + next_q1 = cubic_approx_control( + i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] + ) + spline.append(next_q1) + q2 = (q1 + next_q1) * 0.5 + else: + q2 = c3 + + # End-point deltas + d0 = d1 + d1 = q2 - c3 + + if abs(d1) > tolerance or not cubic_farthest_fit_inside( + d0, + q0 + (q1 - q0) * (2 / 3) - c1, + q2 + (q1 - q2) * (2 / 3) - c2, + d1, + tolerance, + ): + return None + spline.append(cubic[3]) + + return spline + + +@cython.locals(max_err=cython.double) +@cython.locals(n=cython.int) +@cython.locals(all_quadratic=cython.int) +def curve_to_quadratic(curve, max_err, all_quadratic=True): + """Approximate a cubic Bezier curve with a spline of n quadratics. + + Args: + cubic (sequence): Four 2D tuples representing control points of + the cubic Bezier curve. + max_err (double): Permitted deviation from the original curve. + all_quadratic (bool): If True (default) returned value is a + quadratic spline. If False, it's either a single quadratic + curve or a single cubic curve. + + Returns: + If all_quadratic is True: A list of 2D tuples, representing + control points of the quadratic spline if it fits within the + given tolerance, or ``None`` if no suitable spline could be + calculated. + + If all_quadratic is False: Either a quadratic curve (if length + of output is 3), or a cubic curve (if length of output is 4). + """ + + curve = [complex(*p) for p in curve] + + for n in range(1, MAX_N + 1): + spline = cubic_approx_spline(curve, n, max_err, all_quadratic) + if spline is not None: + # done. go home + return [(s.real, s.imag) for s in spline] + + raise ApproxNotFoundError(curve) + + +@cython.locals(l=cython.int, last_i=cython.int, i=cython.int) +@cython.locals(all_quadratic=cython.int) +def curves_to_quadratic(curves, max_errors, all_quadratic=True): + """Return quadratic Bezier splines approximating the input cubic Beziers. + + Args: + curves: A sequence of *n* curves, each curve being a sequence of four + 2D tuples. + max_errors: A sequence of *n* floats representing the maximum permissible + deviation from each of the cubic Bezier curves. + all_quadratic (bool): If True (default) returned values are a + quadratic spline. If False, they are either a single quadratic + curve or a single cubic curve. + + Example:: + + >>> curves_to_quadratic( [ + ... [ (50,50), (100,100), (150,100), (200,50) ], + ... [ (75,50), (120,100), (150,75), (200,60) ] + ... ], [1,1] ) + [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]] + + The returned splines have "implied oncurve points" suitable for use in + TrueType ``glif`` outlines - i.e. in the first spline returned above, + the first quadratic segment runs from (50,50) to + ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...). + + Returns: + If all_quadratic is True, a list of splines, each spline being a list + of 2D tuples. + + If all_quadratic is False, a list of curves, each curve being a quadratic + (length 3), or cubic (length 4). + + Raises: + fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation + can be found for all curves with the given parameters. + """ + + curves = [[complex(*p) for p in curve] for curve in curves] + assert len(max_errors) == len(curves) + + l = len(curves) + splines = [None] * l + last_i = i = 0 + n = 1 + while True: + spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) + if spline is None: + if n == MAX_N: + break + n += 1 + last_i = i + continue + splines[i] = spline + i = (i + 1) % l + if i == last_i: + # done. go home + return [[(s.real, s.imag) for s in spline] for spline in splines] + + raise ApproxNotFoundError(curves) diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/errors.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/errors.py new file mode 100644 index 00000000..fa3dc429 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/errors.py @@ -0,0 +1,77 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +class Error(Exception): + """Base Cu2Qu exception class for all other errors.""" + + +class ApproxNotFoundError(Error): + def __init__(self, curve): + message = "no approximation found: %s" % curve + super().__init__(message) + self.curve = curve + + +class UnequalZipLengthsError(Error): + pass + + +class IncompatibleGlyphsError(Error): + def __init__(self, glyphs): + assert len(glyphs) > 1 + self.glyphs = glyphs + names = set(repr(g.name) for g in glyphs) + if len(names) > 1: + self.combined_name = "{%s}" % ", ".join(sorted(names)) + else: + self.combined_name = names.pop() + + def __repr__(self): + return "<%s %s>" % (type(self).__name__, self.combined_name) + + +class IncompatibleSegmentNumberError(IncompatibleGlyphsError): + def __str__(self): + return "Glyphs named %s have different number of segments" % ( + self.combined_name + ) + + +class IncompatibleSegmentTypesError(IncompatibleGlyphsError): + def __init__(self, glyphs, segments): + IncompatibleGlyphsError.__init__(self, glyphs) + self.segments = segments + + def __str__(self): + lines = [] + ndigits = len(str(max(self.segments))) + for i, tags in sorted(self.segments.items()): + lines.append( + "%s: (%s)" % (str(i).rjust(ndigits), ", ".join(repr(t) for t in tags)) + ) + return "Glyphs named %s have incompatible segment types:\n %s" % ( + self.combined_name, + "\n ".join(lines), + ) + + +class IncompatibleFontsError(Error): + def __init__(self, glyph_errors): + self.glyph_errors = glyph_errors + + def __str__(self): + return "fonts contains incompatible glyphs: %s" % ( + ", ".join(repr(g) for g in sorted(self.glyph_errors.keys())) + ) diff --git a/venv/lib/python3.10/site-packages/fontTools/cu2qu/ufo.py b/venv/lib/python3.10/site-packages/fontTools/cu2qu/ufo.py new file mode 100644 index 00000000..7a6dbc67 --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/cu2qu/ufo.py @@ -0,0 +1,349 @@ +# Copyright 2015 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +"""Converts cubic bezier curves to quadratic splines. + +Conversion is performed such that the quadratic splines keep the same end-curve +tangents as the original cubics. The approach is iterative, increasing the +number of segments for a spline until the error gets below a bound. + +Respective curves from multiple fonts will be converted at once to ensure that +the resulting splines are interpolation-compatible. +""" + +import logging +from fontTools.pens.basePen import AbstractPen +from fontTools.pens.pointPen import PointToSegmentPen +from fontTools.pens.reverseContourPen import ReverseContourPen + +from . import curves_to_quadratic +from .errors import ( + UnequalZipLengthsError, + IncompatibleSegmentNumberError, + IncompatibleSegmentTypesError, + IncompatibleGlyphsError, + IncompatibleFontsError, +) + + +__all__ = ["fonts_to_quadratic", "font_to_quadratic"] + +# The default approximation error below is a relative value (1/1000 of the EM square). +# Later on, we convert it to absolute font units by multiplying it by a font's UPEM +# (see fonts_to_quadratic). +DEFAULT_MAX_ERR = 0.001 +CURVE_TYPE_LIB_KEY = "com.github.googlei18n.cu2qu.curve_type" + +logger = logging.getLogger(__name__) + + +_zip = zip + + +def zip(*args): + """Ensure each argument to zip has the same length. Also make sure a list is + returned for python 2/3 compatibility. + """ + + if len(set(len(a) for a in args)) != 1: + raise UnequalZipLengthsError(*args) + return list(_zip(*args)) + + +class GetSegmentsPen(AbstractPen): + """Pen to collect segments into lists of points for conversion. + + Curves always include their initial on-curve point, so some points are + duplicated between segments. + """ + + def __init__(self): + self._last_pt = None + self.segments = [] + + def _add_segment(self, tag, *args): + if tag in ["move", "line", "qcurve", "curve"]: + self._last_pt = args[-1] + self.segments.append((tag, args)) + + def moveTo(self, pt): + self._add_segment("move", pt) + + def lineTo(self, pt): + self._add_segment("line", pt) + + def qCurveTo(self, *points): + self._add_segment("qcurve", self._last_pt, *points) + + def curveTo(self, *points): + self._add_segment("curve", self._last_pt, *points) + + def closePath(self): + self._add_segment("close") + + def endPath(self): + self._add_segment("end") + + def addComponent(self, glyphName, transformation): + pass + + +def _get_segments(glyph): + """Get a glyph's segments as extracted by GetSegmentsPen.""" + + pen = GetSegmentsPen() + # glyph.draw(pen) + # We can't simply draw the glyph with the pen, but we must initialize the + # PointToSegmentPen explicitly with outputImpliedClosingLine=True. + # By default PointToSegmentPen does not outputImpliedClosingLine -- unless + # last and first point on closed contour are duplicated. Because we are + # converting multiple glyphs at the same time, we want to make sure + # this function returns the same number of segments, whether or not + # the last and first point overlap. + # https://github.com/googlefonts/fontmake/issues/572 + # https://github.com/fonttools/fonttools/pull/1720 + pointPen = PointToSegmentPen(pen, outputImpliedClosingLine=True) + glyph.drawPoints(pointPen) + return pen.segments + + +def _set_segments(glyph, segments, reverse_direction): + """Draw segments as extracted by GetSegmentsPen back to a glyph.""" + + glyph.clearContours() + pen = glyph.getPen() + if reverse_direction: + pen = ReverseContourPen(pen) + for tag, args in segments: + if tag == "move": + pen.moveTo(*args) + elif tag == "line": + pen.lineTo(*args) + elif tag == "curve": + pen.curveTo(*args[1:]) + elif tag == "qcurve": + pen.qCurveTo(*args[1:]) + elif tag == "close": + pen.closePath() + elif tag == "end": + pen.endPath() + else: + raise AssertionError('Unhandled segment type "%s"' % tag) + + +def _segments_to_quadratic(segments, max_err, stats, all_quadratic=True): + """Return quadratic approximations of cubic segments.""" + + assert all(s[0] == "curve" for s in segments), "Non-cubic given to convert" + + new_points = curves_to_quadratic([s[1] for s in segments], max_err, all_quadratic) + n = len(new_points[0]) + assert all(len(s) == n for s in new_points[1:]), "Converted incompatibly" + + spline_length = str(n - 2) + stats[spline_length] = stats.get(spline_length, 0) + 1 + + if all_quadratic or n == 3: + return [("qcurve", p) for p in new_points] + else: + return [("curve", p) for p in new_points] + + +def _glyphs_to_quadratic(glyphs, max_err, reverse_direction, stats, all_quadratic=True): + """Do the actual conversion of a set of compatible glyphs, after arguments + have been set up. + + Return True if the glyphs were modified, else return False. + """ + + try: + segments_by_location = zip(*[_get_segments(g) for g in glyphs]) + except UnequalZipLengthsError: + raise IncompatibleSegmentNumberError(glyphs) + if not any(segments_by_location): + return False + + # always modify input glyphs if reverse_direction is True + glyphs_modified = reverse_direction + + new_segments_by_location = [] + incompatible = {} + for i, segments in enumerate(segments_by_location): + tag = segments[0][0] + if not all(s[0] == tag for s in segments[1:]): + incompatible[i] = [s[0] for s in segments] + elif tag == "curve": + new_segments = _segments_to_quadratic( + segments, max_err, stats, all_quadratic + ) + if all_quadratic or new_segments != segments: + glyphs_modified = True + segments = new_segments + new_segments_by_location.append(segments) + + if glyphs_modified: + new_segments_by_glyph = zip(*new_segments_by_location) + for glyph, new_segments in zip(glyphs, new_segments_by_glyph): + _set_segments(glyph, new_segments, reverse_direction) + + if incompatible: + raise IncompatibleSegmentTypesError(glyphs, segments=incompatible) + return glyphs_modified + + +def glyphs_to_quadratic( + glyphs, max_err=None, reverse_direction=False, stats=None, all_quadratic=True +): + """Convert the curves of a set of compatible of glyphs to quadratic. + + All curves will be converted to quadratic at once, ensuring interpolation + compatibility. If this is not required, calling glyphs_to_quadratic with one + glyph at a time may yield slightly more optimized results. + + Return True if glyphs were modified, else return False. + + Raises IncompatibleGlyphsError if glyphs have non-interpolatable outlines. + """ + if stats is None: + stats = {} + + if not max_err: + # assume 1000 is the default UPEM + max_err = DEFAULT_MAX_ERR * 1000 + + if isinstance(max_err, (list, tuple)): + max_errors = max_err + else: + max_errors = [max_err] * len(glyphs) + assert len(max_errors) == len(glyphs) + + return _glyphs_to_quadratic( + glyphs, max_errors, reverse_direction, stats, all_quadratic + ) + + +def fonts_to_quadratic( + fonts, + max_err_em=None, + max_err=None, + reverse_direction=False, + stats=None, + dump_stats=False, + remember_curve_type=True, + all_quadratic=True, +): + """Convert the curves of a collection of fonts to quadratic. + + All curves will be converted to quadratic at once, ensuring interpolation + compatibility. If this is not required, calling fonts_to_quadratic with one + font at a time may yield slightly more optimized results. + + Return the set of modified glyph names if any, else return an empty set. + + By default, cu2qu stores the curve type in the fonts' lib, under a private + key "com.github.googlei18n.cu2qu.curve_type", and will not try to convert + them again if the curve type is already set to "quadratic". + Setting 'remember_curve_type' to False disables this optimization. + + Raises IncompatibleFontsError if same-named glyphs from different fonts + have non-interpolatable outlines. + """ + + if remember_curve_type: + curve_types = {f.lib.get(CURVE_TYPE_LIB_KEY, "cubic") for f in fonts} + if len(curve_types) == 1: + curve_type = next(iter(curve_types)) + if curve_type in ("quadratic", "mixed"): + logger.info("Curves already converted to quadratic") + return False + elif curve_type == "cubic": + pass # keep converting + else: + raise NotImplementedError(curve_type) + elif len(curve_types) > 1: + # going to crash later if they do differ + logger.warning("fonts may contain different curve types") + + if stats is None: + stats = {} + + if max_err_em and max_err: + raise TypeError("Only one of max_err and max_err_em can be specified.") + if not (max_err_em or max_err): + max_err_em = DEFAULT_MAX_ERR + + if isinstance(max_err, (list, tuple)): + assert len(max_err) == len(fonts) + max_errors = max_err + elif max_err: + max_errors = [max_err] * len(fonts) + + if isinstance(max_err_em, (list, tuple)): + assert len(fonts) == len(max_err_em) + max_errors = [f.info.unitsPerEm * e for f, e in zip(fonts, max_err_em)] + elif max_err_em: + max_errors = [f.info.unitsPerEm * max_err_em for f in fonts] + + modified = set() + glyph_errors = {} + for name in set().union(*(f.keys() for f in fonts)): + glyphs = [] + cur_max_errors = [] + for font, error in zip(fonts, max_errors): + if name in font: + glyphs.append(font[name]) + cur_max_errors.append(error) + try: + if _glyphs_to_quadratic( + glyphs, cur_max_errors, reverse_direction, stats, all_quadratic + ): + modified.add(name) + except IncompatibleGlyphsError as exc: + logger.error(exc) + glyph_errors[name] = exc + + if glyph_errors: + raise IncompatibleFontsError(glyph_errors) + + if modified and dump_stats: + spline_lengths = sorted(stats.keys()) + logger.info( + "New spline lengths: %s" + % (", ".join("%s: %d" % (l, stats[l]) for l in spline_lengths)) + ) + + if remember_curve_type: + for font in fonts: + curve_type = font.lib.get(CURVE_TYPE_LIB_KEY, "cubic") + new_curve_type = "quadratic" if all_quadratic else "mixed" + if curve_type != new_curve_type: + font.lib[CURVE_TYPE_LIB_KEY] = new_curve_type + return modified + + +def glyph_to_quadratic(glyph, **kwargs): + """Convenience wrapper around glyphs_to_quadratic, for just one glyph. + Return True if the glyph was modified, else return False. + """ + + return glyphs_to_quadratic([glyph], **kwargs) + + +def font_to_quadratic(font, **kwargs): + """Convenience wrapper around fonts_to_quadratic, for just one font. + Return the set of modified glyph names if any, else return empty set. + """ + + return fonts_to_quadratic([font], **kwargs) diff --git a/venv/lib/python3.10/site-packages/fontTools/designspaceLib/__init__.py b/venv/lib/python3.10/site-packages/fontTools/designspaceLib/__init__.py new file mode 100644 index 00000000..342f1dec --- /dev/null +++ b/venv/lib/python3.10/site-packages/fontTools/designspaceLib/__init__.py @@ -0,0 +1,3337 @@ +from __future__ import annotations + +import collections +import copy +import itertools +import math +import os +import posixpath +from io import BytesIO, StringIO +from textwrap import indent +from typing import Any, Dict, List, MutableMapping, Optional, Tuple, Union, cast + +from fontTools.misc import etree as ET +from fontTools.misc import plistlib +from fontTools.misc.loggingTools import LogMixin +from fontTools.misc.textTools import tobytes, tostr + +""" + designSpaceDocument + + - read and write designspace files +""" + +__all__ = [ + "AxisDescriptor", + "AxisLabelDescriptor", + "AxisMappingDescriptor", + "BaseDocReader", + "BaseDocWriter", + "DesignSpaceDocument", + "DesignSpaceDocumentError", + "DiscreteAxisDescriptor", + "InstanceDescriptor", + "LocationLabelDescriptor", + "RangeAxisSubsetDescriptor", + "RuleDescriptor", + "SourceDescriptor", + "ValueAxisSubsetDescriptor", + "VariableFontDescriptor", +] + +# ElementTree allows to find namespace-prefixed elements, but not attributes +# so we have to do it ourselves for 'xml:lang' +XML_NS = "{http://www.w3.org/XML/1998/namespace}" +XML_LANG = XML_NS + "lang" + + +def posix(path): + """Normalize paths using forward slash to work also on Windows.""" + new_path = posixpath.join(*path.split(os.path.sep)) + if path.startswith("/"): + # The above transformation loses absolute paths + new_path = "/" + new_path + elif path.startswith(r"\\"): + # The above transformation loses leading slashes of UNC path mounts + new_path = "//" + new_path + return new_path + + +def posixpath_property(private_name): + """Generate a propery that holds a path always using forward slashes.""" + + def getter(self): + # Normal getter + return getattr(self, private_name) + + def setter(self, value): + # The setter rewrites paths using forward slashes + if value is not None: + value = posix(value) + setattr(self, private_name, value) + + return property(getter, setter) + + +class DesignSpaceDocumentError(Exception): + def __init__(self, msg, obj=None): + self.msg = msg + self.obj = obj + + def __str__(self): + return str(self.msg) + (": %r" % self.obj if self.obj is not None else "") + + +class AsDictMixin(object): + def asdict(self): + d = {} + for attr, value in self.__dict__.items(): + if attr.startswith("_"): + continue + if hasattr(value, "asdict"): + value = value.asdict() + elif isinstance(value, list): + value = [v.asdict() if hasattr(v, "asdict") else v for v in value] + d[attr] = value + return d + + +class SimpleDescriptor(AsDictMixin): + """Containers for a bunch of attributes""" + + # XXX this is ugly. The 'print' is inappropriate here, and instead of + # assert, it should simply return True/False + def compare(self, other): + # test if this object contains the same data as the other + for attr in self._attrs: + try: + assert getattr(self, attr) == getattr(other, attr) + except AssertionError: + print( + "failed attribute", + attr, + getattr(self, attr), + "!=", + getattr(other, attr), + ) + + def __repr__(self): + attrs = [f"{a}={repr(getattr(self, a))}," for a in self._attrs] + attrs = indent("\n".join(attrs), " ") + return f"{self.__class__.__name__}(\n{attrs}\n)" + + +class SourceDescriptor(SimpleDescriptor): + """Simple container for data related to the source + + .. code:: python + + doc = DesignSpaceDocument() + s1 = SourceDescriptor() + s1.path = masterPath1 + s1.name = "master.ufo1" + s1.font = defcon.Font("master.ufo1") + s1.location = dict(weight=0) + s1.familyName = "MasterFamilyName" + s1.styleName = "MasterStyleNameOne" + s1.localisedFamilyName = dict(fr="Caractère") + s1.mutedGlyphNames.append("A") + s1.mutedGlyphNames.append("Z") + doc.addSource(s1) + + """ + + flavor = "source" + _attrs = [ + "filename", + "path", + "name", + "layerName", + "location", + "copyLib", + "copyGroups", + "copyFeatures", + "muteKerning", + "muteInfo", + "mutedGlyphNames", + "familyName", + "styleName", + "localisedFamilyName", + ] + + filename = posixpath_property("_filename") + path = posixpath_property("_path") + + def __init__( + self, + *, + filename=None, + path=None, + font=None, + name=None, + location=None, + designLocation=None, + layerName=None, + familyName=None, + styleName=None, + localisedFamilyName=None, + copyLib=False, + copyInfo=False, + copyGroups=False, + copyFeatures=False, + muteKerning=False, + muteInfo=False, + mutedGlyphNames=None, + ): + self.filename = filename + """string. A relative path to the source file, **as it is in the document**. + + MutatorMath + VarLib. + """ + self.path = path + """The absolute path, calculated from filename.""" + + self.font = font + """Any Python object. Optional. Points to a representation of this + source font that is loaded in memory, as a Python object (e.g. a + ``defcon.Font`` or a ``fontTools.ttFont.TTFont``). + + The default document reader will not fill-in this attribute, and the + default writer will not use this attribute. It is up to the user of + ``designspaceLib`` to either load the resource identified by + ``filename`` and store it in this field, or write the contents of + this field to the disk and make ```filename`` point to that. + """ + + self.name = name + """string. Optional. Unique identifier name for this source. + + MutatorMath + varLib. + """ + + self.designLocation = ( + designLocation if designLocation is not None else location or {} + ) + """dict. Axis values for this source, in design space coordinates. + + MutatorMath + varLib. + + This may be only part of the full design location. + See :meth:`getFullDesignLocation()` + + .. versionadded:: 5.0 + """ + + self.layerName = layerName + """string. The name of the layer in the source to look for + outline data. Default ``None`` which means ``foreground``. + """ + self.familyName = familyName + """string. Family name of this source. Though this data + can be extracted from the font, it can be efficient to have it right + here. + + varLib. + """ + self.styleName = styleName + """string. Style name of this source. Though this data + can be extracted from the font, it can be efficient to have it right + here. + + varLib. + """ + self.localisedFamilyName = localisedFamilyName or {} + """dict. A dictionary of localised family name strings, keyed by + language code. + + If present, will be used to build localized names for all instances. + + .. versionadded:: 5.0 + """ + + self.copyLib = copyLib + """bool. Indicates if the contents of the font.lib need to + be copied to the instances. + + MutatorMath. + + .. deprecated:: 5.0 + """ + self.copyInfo = copyInfo + """bool. Indicates if the non-interpolating font.info needs + to be copied to the instances. + + MutatorMath. + + .. deprecated:: 5.0 + """ + self.copyGroups = copyGroups + """bool. Indicates if the groups need to be copied to the + instances. + + MutatorMath. + + .. deprecated:: 5.0 + """ + self.copyFeatures = copyFeatures + """bool. Indicates if the feature text needs to be + copied to the instances. + + MutatorMath. + + .. deprecated:: 5.0 + """ + self.muteKerning = muteKerning + """bool. Indicates if the kerning data from this source + needs to be muted (i.e. not be part of the calculations). + + MutatorMath only. + """ + self.muteInfo = muteInfo + """bool. Indicated if the interpolating font.info data for + this source needs to be muted. + + MutatorMath only. + """ + self.mutedGlyphNames = mutedGlyphNames or [] + """list. Glyphnames that need to be muted in the + instances. + + MutatorMath only. + """ + + @property + def location(self): + """dict. Axis values for this source, in design space coordinates. + + MutatorMath + varLib. + + .. deprecated:: 5.0 + Use the more explicit alias for this property :attr:`designLocation`. + """ + return self.designLocation + + @location.setter + def location(self, location: Optional[SimpleLocationDict]): + self.designLocation = location or {} + + def setFamilyName(self, familyName, languageCode="en"): + """Setter for :attr:`localisedFamilyName` + + .. versionadded:: 5.0 + """ + self.localisedFamilyName[languageCode] = tostr(familyName) + + def getFamilyName(self, languageCode="en"): + """Getter for :attr:`localisedFamilyName` + + .. versionadded:: 5.0 + """ + return self.localisedFamilyName.get(languageCode) + + def getFullDesignLocation(self, doc: "DesignSpaceDocument") -> SimpleLocationDict: + """Get the complete design location of this source, from its + :attr:`designLocation` and the document's axis defaults. + + .. versionadded:: 5.0 + """ + result: SimpleLocationDict = {} + for axis in doc.axes: + if axis.name in self.designLocation: + result[axis.name] = self.designLocation[axis.name] + else: + result[axis.name] = axis.map_forward(axis.default) + return result + + +class RuleDescriptor(SimpleDescriptor): + """Represents the rule descriptor element: a set of glyph substitutions to + trigger conditionally in some parts of the designspace. + + .. code:: python + + r1 = RuleDescriptor() + r1.name = "unique.rule.name" + r1.conditionSets.append([dict(name="weight", minimum=-10, maximum=10), dict(...)]) + r1.conditionSets.append([dict(...), dict(...)]) + r1.subs.append(("a", "a.alt")) + + .. code:: xml + + + + + + + + + + + + + + """ + + _attrs = ["name", "conditionSets", "subs"] # what do we need here + + def __init__(self, *, name=None, conditionSets=None, subs=None): + self.name = name + """string. Unique name for this rule. Can be used to reference this rule data.""" + # list of lists of dict(name='aaaa', minimum=0, maximum=1000) + self.conditionSets = conditionSets or [] + """a list of conditionsets. + + - Each conditionset is a list of conditions. + - Each condition is a dict with ``name``, ``minimum`` and ``maximum`` keys. + """ + # list of substitutions stored as tuples of glyphnames ("a", "a.alt") + self.subs = subs or [] + """list of substitutions. + + - Each substitution is stored as tuples of glyphnames, e.g. ("a", "a.alt"). + - Note: By default, rules are applied first, before other text + shaping/OpenType layout, as they are part of the + `Required Variation Alternates OpenType feature `_. + See ref:`rules-element` § Attributes. + """ + + +def evaluateRule(rule, location): + """Return True if any of the rule's conditionsets matches the given location.""" + return any(evaluateConditions(c, location) for c in rule.conditionSets) + + +def evaluateConditions(conditions, location): + """Return True if all the conditions matches the given location. + + - If a condition has no minimum, check for < maximum. + - If a condition has no maximum, check for > minimum. + """ + for cd in conditions: + value = location[cd["name"]] + if cd.get("minimum") is None: + if value > cd["maximum"]: + return False + elif cd.get("maximum") is None: + if cd["minimum"] > value: + return False + elif not cd["minimum"] <= value <= cd["maximum"]: + return False + return True + + +def processRules(rules, location, glyphNames): + """Apply these rules at this location to these glyphnames. + + Return a new list of glyphNames with substitutions applied. + + - rule order matters + """ + newNames = [] + for rule in rules: + if evaluateRule(rule, location): + for name in glyphNames: + swap = False + for a, b in rule.subs: + if name == a: + swap = True + break + if swap: + newNames.append(b) + else: + newNames.append(name) + glyphNames = newNames + newNames = [] + return glyphNames + + +AnisotropicLocationDict = Dict[str, Union[float, Tuple[float, float]]] +SimpleLocationDict = Dict[str, float] + + +class AxisMappingDescriptor(SimpleDescriptor): + """Represents the axis mapping element: mapping an input location + to an output location in the designspace. + + .. code:: python + + m1 = AxisMappingDescriptor() + m1.inputLocation = {"weight": 900, "width": 150} + m1.outputLocation = {"weight": 870} + + .. code:: xml + + + + + + + + + + + + + """ + + _attrs = ["inputLocation", "outputLocation"] + + def __init__( + self, + *, + inputLocation=None, + outputLocation=None, + description=None, + groupDescription=None, + ): + self.inputLocation: SimpleLocationDict = inputLocation or {} + """dict. Axis values for the input of the mapping, in design space coordinates. + + varLib. + + .. versionadded:: 5.1 + """ + self.outputLocation: SimpleLocationDict = outputLocation or {} + """dict. Axis values for the output of the mapping, in design space coordinates. + + varLib. + + .. versionadded:: 5.1 + """ + self.description = description + """string. A description of the mapping. + + varLib. + + .. versionadded:: 5.2 + """ + self.groupDescription = groupDescription + """string. A description of the group of mappings. + + varLib. + + .. versionadded:: 5.2 + """ + + +class InstanceDescriptor(SimpleDescriptor): + """Simple container for data related to the instance + + + .. code:: python + + i2 = InstanceDescriptor() + i2.path = instancePath2 + i2.familyName = "InstanceFamilyName" + i2.styleName = "InstanceStyleName" + i2.name = "instance.ufo2" + # anisotropic location + i2.designLocation = dict(weight=500, width=(400,300)) + i2.postScriptFontName = "InstancePostscriptName" + i2.styleMapFamilyName = "InstanceStyleMapFamilyName" + i2.styleMapStyleName = "InstanceStyleMapStyleName" + i2.lib['com.coolDesignspaceApp.specimenText'] = 'Hamburgerwhatever' + doc.addInstance(i2) + """ + + flavor = "instance" + _defaultLanguageCode = "en" + _attrs = [ + "filename", + "path", + "name", + "locationLabel", + "designLocation", + "userLocation", + "familyName", + "styleName", + "postScriptFontName", + "styleMapFamilyName", + "styleMapStyleName", + "localisedFamilyName", + "localisedStyleName", + "localisedStyleMapFamilyName", + "localisedStyleMapStyleName", + "glyphs", + "kerning", + "info", + "lib", + ] + + filename = posixpath_property("_filename") + path = posixpath_property("_path") + + def __init__( + self, + *, + filename=None, + path=None, + font=None, + name=None, + location=None, + locationLabel=None, + designLocation=None, + userLocation=None, + familyName=None, + styleName=None, + postScriptFontName=None, + styleMapFamilyName=None, + styleMapStyleName=None, + localisedFamilyName=None, + localisedStyleName=None, + localisedStyleMapFamilyName=None, + localisedStyleMapStyleName=None, + glyphs=None, + kerning=True, + info=True, + lib=None, + ): + self.filename = filename + """string. Relative path to the instance file, **as it is + in the document**. The file may or may not exist. + + MutatorMath + VarLib. + """ + self.path = path + """string. Absolute path to the instance file, calculated from + the document path and the string in the filename attr. The file may + or may not exist. + + MutatorMath. + """ + self.font = font + """Same as :attr:`SourceDescriptor.font` + + .. seealso:: :attr:`SourceDescriptor.font` + """ + self.name = name + """string. Unique identifier name of the instance, used to + identify it if it needs to be referenced from elsewhere in the + document. + """ + self.locationLabel = locationLabel + """Name of a :class:`LocationLabelDescriptor`. If + provided, the instance should have the same location as the + LocationLabel. + + .. seealso:: + :meth:`getFullDesignLocation` + :meth:`getFullUserLocation` + + .. versionadded:: 5.0 + """ + self.designLocation: AnisotropicLocationDict = ( + designLocation if designLocation is not None else (location or {}) + ) + """dict. Axis values for this instance, in design space coordinates. + + MutatorMath + varLib. + + .. seealso:: This may be only part of the full location. See: + :meth:`getFullDesignLocation` + :meth:`getFullUserLocation` + + .. versionadded:: 5.0 + """ + self.userLocation: SimpleLocationDict = userLocation or {} + """dict. Axis values for this instance, in user space coordinates. + + MutatorMath + varLib. + + .. seealso:: This may be only part of the full location. See: + :meth:`getFullDesignLocation` + :meth:`getFullUserLocation` + + .. versionadded:: 5.0 + """ + self.familyName = familyName + """string. Family name of this instance. + + MutatorMath + varLib. + """ + self.styleName = styleName + """string. Style name of this instance. + + MutatorMath + varLib. + """ + self.postScriptFontName = postScriptFontName + """string. Postscript fontname for this instance. + + MutatorMath + varLib. + """ + self.styleMapFamilyName = styleMapFamilyName + """string. StyleMap familyname for this instance. + + MutatorMath + varLib. + """ + self.styleMapStyleName = styleMapStyleName + """string. StyleMap stylename for this instance. + + MutatorMath + varLib. + """ + self.localisedFamilyName = localisedFamilyName or {} + """dict. A dictionary of localised family name + strings, keyed by language code. + """ + self.localisedStyleName = localisedStyleName or {} + """dict. A dictionary of localised stylename + strings, keyed by language code. + """ + self.localisedStyleMapFamilyName = localisedStyleMapFamilyName or {} + """A dictionary of localised style map + familyname strings, keyed by language code. + """ + self.localisedStyleMapStyleName = localisedStyleMapStyleName or {} + """A dictionary of localised style map + stylename strings, keyed by language code. + """ + self.glyphs = glyphs or {} + """dict for special master definitions for glyphs. If glyphs + need special masters (to record the results of executed rules for + example). + + MutatorMath. + + .. deprecated:: 5.0 + Use rules or sparse sources instead. + """ + self.kerning = kerning + """ bool. Indicates if this instance needs its kerning + calculated. + + MutatorMath. + + .. deprecated:: 5.0 + """ + self.info = info + """bool. Indicated if this instance needs the interpolating + font.info calculated. + + .. deprecated:: 5.0 + """ + + self.lib = lib or {} + """Custom data associated with this instance.""" + + @property + def location(self): + """dict. Axis values for this instance. + + MutatorMath + varLib. + + .. deprecated:: 5.0 + Use the more explicit alias for this property :attr:`designLocation`. + """ + return self.designLocation + + @location.setter + def location(self, location: Optional[AnisotropicLocationDict]): + self.designLocation = location or {} + + def setStyleName(self, styleName, languageCode="en"): + """These methods give easier access to the localised names.""" + self.localisedStyleName[languageCode] = tostr(styleName) + + def getStyleName(self, languageCode="en"): + return self.localisedStyleName.get(languageCode) + + def setFamilyName(self, familyName, languageCode="en"): + self.localisedFamilyName[languageCode] = tostr(familyName) + + def getFamilyName(self, languageCode="en"): + return self.localisedFamilyName.get(languageCode) + + def setStyleMapStyleName(self, styleMapStyleName, languageCode="en"): + self.localisedStyleMapStyleName[languageCode] = tostr(styleMapStyleName) + + def getStyleMapStyleName(self, languageCode="en"): + return self.localisedStyleMapStyleName.get(languageCode) + + def setStyleMapFamilyName(self, styleMapFamilyName, languageCode="en"): + self.localisedStyleMapFamilyName[languageCode] = tostr(styleMapFamilyName) + + def getStyleMapFamilyName(self, languageCode="en"): + return self.localisedStyleMapFamilyName.get(languageCode) + + def clearLocation(self, axisName: Optional[str] = None): + """Clear all location-related fields. Ensures that + :attr:``designLocation`` and :attr:``userLocation`` are dictionaries + (possibly empty if clearing everything). + + In order to update the location of this instance wholesale, a user + should first clear all the fields, then change the field(s) for which + they have data. + + .. code:: python + + instance.clearLocation() + instance.designLocation = {'Weight': (34, 36.5), 'Width': 100} + instance.userLocation = {'Opsz': 16} + + In order to update a single axis location, the user should only clear + that axis, then edit the values: + + .. code:: python + + instance.clearLocation('Weight') + instance.designLocation['Weight'] = (34, 36.5) + + Args: + axisName: if provided, only clear the location for that axis. + + .. versionadded:: 5.0 + """ + self.locationLabel = None + if axisName is None: + self.designLocation = {} + self.userLocation = {} + else: + if self.designLocation is None: + self.designLocation = {} + if axisName in self.designLocation: + del self.designLocation[axisName] + if self.userLocation is None: + self.userLocation = {} + if axisName in self.userLocation: + del self.userLocation[axisName] + + def getLocationLabelDescriptor( + self, doc: "DesignSpaceDocument" + ) -> Optional[LocationLabelDescriptor]: + """Get the :class:`LocationLabelDescriptor` instance that matches + this instances's :attr:`locationLabel`. + + Raises if the named label can't be found. + + .. versionadded:: 5.0 + """ + if self.locationLabel is None: + return None + label = doc.getLocationLabel(self.locationLabel) + if label is None: + raise DesignSpaceDocumentError( + "InstanceDescriptor.getLocationLabelDescriptor(): " + f"unknown location label `{self.locationLabel}` in instance `{self.name}`." + ) + return label + + def getFullDesignLocation( + self, doc: "DesignSpaceDocument" + ) -> AnisotropicLocationDict: + """Get the complete design location of this instance, by combining data + from the various location fields, default axis values and mappings, and + top-level location labels. + + The source of truth for this instance's location is determined for each + axis independently by taking the first not-None field in this list: + + - ``locationLabel``: the location along this axis is the same as the + matching STAT format 4 label. No anisotropy. + - ``designLocation[axisName]``: the explicit design location along this + axis, possibly anisotropic. + - ``userLocation[axisName]``: the explicit user location along this + axis. No anisotropy. + - ``axis.default``: default axis value. No anisotropy. + + .. versionadded:: 5.0 + """ + label = self.getLocationLabelDescriptor(doc) + if label is not None: + return doc.map_forward(label.userLocation) # type: ignore + result: AnisotropicLocationDict = {} + for axis in doc.axes: + if axis.name in self.designLocation: + result[axis.name] = self.designLocation[axis.name] + elif axis.name in self.userLocation: + result[axis.name] = axis.map_forward(self.userLocation[axis.name]) + else: + result[axis.name] = axis.map_forward(axis.default) + return result + + def getFullUserLocation(self, doc: "DesignSpaceDocument") -> SimpleLocationDict: + """Get the complete user location for this instance. + + .. seealso:: :meth:`getFullDesignLocation` + + .. versionadded:: 5.0 + """ + return doc.map_backward(self.getFullDesignLocation(doc)) + + +def tagForAxisName(name): + # try to find or make a tag name for this axis name + names = { + "weight": ("wght", dict(en="Weight")), + "width": ("wdth", dict(en="Width")), + "optical": ("opsz", dict(en="Optical Size")), + "slant": ("slnt", dict(en="Slant")), + "italic": ("ital", dict(en="Italic")), + } + if name.lower() in names: + return names[name.lower()] + if len(name) < 4: + tag = name + "*" * (4 - len(name)) + else: + tag = name[:4] + return tag, dict(en=name) + + +class AbstractAxisDescriptor(SimpleDescriptor): + flavor = "axis" + + def __init__( + self, + *, + tag=None, + name=None, + labelNames=None, + hidden=False, + map=None, + axisOrdering=None, + axisLabels=None, + ): + # opentype tag for this axis + self.tag = tag + """string. Four letter tag for this axis. Some might be + registered at the `OpenType + specification `__. + Privately-defined axis tags must begin with an uppercase letter and + use only uppercase letters or digits. + """ + # name of the axis used in locations + self.name = name + """string. Name of the axis as it is used in the location dicts. + + MutatorMath + varLib. + """ + # names for UI purposes, if this is not a standard axis, + self.labelNames = labelNames or {} + """dict. When defining a non-registered axis, it will be + necessary to define user-facing readable names for the axis. Keyed by + xml:lang code. Values are required to be ``unicode`` strings, even if + they only contain ASCII characters. + """ + self.hidden = hidden + """bool. Whether this axis should be hidden in user interfaces. + """ + self.map = map or [] + """list of input / output values that can describe a warp of user space + to design space coordinates. If no map values are present, it is assumed + user space is the same as design space, as in [(minimum, minimum), + (maximum, maximum)]. + + varLib. + """ + self.axisOrdering = axisOrdering + """STAT table field ``axisOrdering``. + + See: `OTSpec STAT Axis Record `_ + + .. versionadded:: 5.0 + """ + self.axisLabels: List[AxisLabelDescriptor] = axisLabels or [] + """STAT table entries for Axis Value Tables format 1, 2, 3. + + See: `OTSpec STAT Axis Value Tables `_ + + .. versionadded:: 5.0 + """ + + +class AxisDescriptor(AbstractAxisDescriptor): + """Simple container for the axis data. + + Add more localisations? + + .. code:: python + + a1 = AxisDescriptor() + a1.minimum = 1 + a1.maximum = 1000 + a1.default = 400 + a1.name = "weight" + a1.tag = "wght" + a1.labelNames['fa-IR'] = "قطر" + a1.labelNames['en'] = "Wéíght" + a1.map = [(1.0, 10.0), (400.0, 66.0), (1000.0, 990.0)] + a1.axisOrdering = 1 + a1.axisLabels = [ + AxisLabelDescriptor(name="Regular", userValue=400, elidable=True) + ] + doc.addAxis(a1) + """ + + _attrs = [ + "tag", + "name", + "maximum", + "minimum", + "default", + "map", + "axisOrdering", + "axisLabels", + ] + + def __init__( + self, + *, + tag=None, + name=None, + labelNames=None, + minimum=None, + default=None, + maximum=None, + hidden=False, + map=None, + axisOrdering=None, + axisLabels=None, + ): + super().__init__( + tag=tag, + name=name, + labelNames=labelNames, + hidden=hidden, + map=map, + axisOrdering=axisOrdering, + axisLabels=axisLabels, + ) + self.minimum = minimum + """number. The minimum value for this axis in user space. + + MutatorMath + varLib. + """ + self.maximum = maximum + """number. The maximum value for this axis in user space. + + MutatorMath + varLib. + """ + self.default = default + """number. The default value for this axis, i.e. when a new location is + created, this is the value this axis will get in user space. + + MutatorMath + varLib. + """ + + def serialize(self): + # output to a dict, used in testing + return dict( + tag=self.tag, + name=self.name, + labelNames=self.labelNames, + maximum=self.maximum, + minimum=self.minimum, + default=self.default, + hidden=self.hidden, + map=self.map, + axisOrdering=self.axisOrdering, + axisLabels=self.axisLabels, + ) + + def map_forward(self, v): + """Maps value from axis mapping's input (user) to output (design).""" + from fontTools.varLib.models import piecewiseLinearMap + + if not self.map: + return v + return piecewiseLinearMap(v, {k: v for k, v in self.map}) + + def map_backward(self, v): + """Maps value from axis mapping's output (design) to input (user).""" + from fontTools.varLib.models import piecewiseLinearMap + + if isinstance(v, tuple): + v = v[0] + if not self.map: + return v + return piecewiseLinearMap(v, {v: k for k, v in self.map}) + + +class DiscreteAxisDescriptor(AbstractAxisDescriptor): + """Container for discrete axis data. + + Use this for axes that do not interpolate. The main difference from a + continuous axis is that a continuous axis has a ``minimum`` and ``maximum``, + while a discrete axis has a list of ``values``. + + Example: an Italic axis with 2 stops, Roman and Italic, that are not + compatible. The axis still allows to bind together the full font family, + which is useful for the STAT table, however it can't become a variation + axis in a VF. + + .. code:: python + + a2 = DiscreteAxisDescriptor() + a2.values = [0, 1] + a2.default = 0 + a2.name = "Italic" + a2.tag = "ITAL" + a2.labelNames['fr'] = "Italique" + a2.map = [(0, 0), (1, -11)] + a2.axisOrdering = 2 + a2.axisLabels = [ + AxisLabelDescriptor(name="Roman", userValue=0, elidable=True) + ] + doc.addAxis(a2) + + .. versionadded:: 5.0 + """ + + flavor = "axis" + _attrs = ("tag", "name", "values", "default", "map", "axisOrdering", "axisLabels") + + def __init__( + self, + *, + tag=None, + name=None, + labelNames=None, + values=None, + default=None, + hidden=False, + map=None, + axisOrdering=None, + axisLabels=None, + ): + super().__init__( + tag=tag, + name=name, + labelNames=labelNames, + hidden=hidden, + map=map, + axisOrdering=axisOrdering, + axisLabels=axisLabels, + ) + self.default: float = default + """The default value for this axis, i.e. when a new location is + created, this is the value this axis will get in user space. + + However, this default value is less important than in continuous axes: + + - it doesn't define the "neutral" version of outlines from which + deltas would apply, as this axis does not interpolate. + - it doesn't provide the reference glyph set for the designspace, as + fonts at each value can have different glyph sets. + """ + self.values: List[float] = values or [] + """List of possible values for this axis. Contrary to continuous axes, + only the values in this list can be taken by the axis, nothing in-between. + """ + + def map_forward(self, value): + """Maps value from axis mapping's input to output. + + Returns value unchanged if no mapping entry is found. + + Note: for discrete axes, each value must have its mapping entry, if + you intend that value to be mapped. + """ + return next((v for k, v in self.map if k == value), value) + + def map_backward(self, value): + """Maps value from axis mapping's output to input. + + Returns value unchanged if no mapping entry is found. + + Note: for discrete axes, each value must have its mapping entry, if + you intend that value to be mapped. + """ + if isinstance(value, tuple): + value = value[0] + return next((k for k, v in self.map if v == value), value) + + +class AxisLabelDescriptor(SimpleDescriptor): + """Container for axis label data. + + Analogue of OpenType's STAT data for a single axis (formats 1, 2 and 3). + All values are user values. + See: `OTSpec STAT Axis value table, format 1, 2, 3 `_ + + The STAT format of the Axis value depends on which field are filled-in, + see :meth:`getFormat` + + .. versionadded:: 5.0 + """ + + flavor = "label" + _attrs = ( + "userMinimum", + "userValue", + "userMaximum", + "name", + "elidable", + "olderSibling", + "linkedUserValue", + "labelNames", + ) + + def __init__( + self, + *, + name, + userValue, + userMinimum=None, + userMaximum=None, + elidable=False, + olderSibling=False, + linkedUserValue=None, + labelNames=None, + ): + self.userMinimum: Optional[float] = userMinimum + """STAT field ``rangeMinValue`` (format 2).""" + self.userValue: float = userValue + """STAT field ``value`` (format 1, 3) or ``nominalValue`` (format 2).""" + self.userMaximum: Optional[float] = userMaximum + """STAT field ``rangeMaxValue`` (format 2).""" + self.name: str = name + """Label for this axis location, STAT field ``valueNameID``.""" + self.elidable: bool = elidable + """STAT flag ``ELIDABLE_AXIS_VALUE_NAME``. + + See: `OTSpec STAT Flags `_ + """ + self.olderSibling: bool = olderSibling + """STAT flag ``OLDER_SIBLING_FONT_ATTRIBUTE``. + + See: `OTSpec STAT Flags `_ + """ + self.linkedUserValue: Optional[float] = linkedUserValue + """STAT field ``linkedValue`` (format 3).""" + self.labelNames: MutableMapping[str, str] = labelNames or {} + """User-facing translations of this location's label. Keyed by + ``xml:lang`` code. + """ + + def getFormat(self) -> int: + """Determine which format of STAT Axis value to use to encode this label. + + =========== ========= =========== =========== =============== + STAT Format userValue userMinimum userMaximum linkedUserValue + =========== ========= =========== =========== =============== + 1 ✅ ❌ ❌ ❌ + 2 ✅ ✅ ✅ ❌ + 3 ✅ ❌ ❌ ✅ + =========== ========= =========== =========== =============== + """ + if self.linkedUserValue is not None: + return 3 + if self.userMinimum is not None or self.userMaximum is not None: + return 2 + return 1 + + @property + def defaultName(self) -> str: + """Return the English name from :attr:`labelNames` or the :attr:`name`.""" + return self.labelNames.get("en") or self.name + + +class LocationLabelDescriptor(SimpleDescriptor): + """Container for location label data. + + Analogue of OpenType's STAT data for a free-floating location (format 4). + All values are user values. + + See: `OTSpec STAT Axis value table, format 4 `_ + + .. versionadded:: 5.0 + """ + + flavor = "label" + _attrs = ("name", "elidable", "olderSibling", "userLocation", "labelNames") + + def __init__( + self, + *, + name, + userLocation, + elidable=False, + olderSibling=False, + labelNames=None, + ): + self.name: str = name + """Label for this named location, STAT field ``valueNameID``.""" + self.userLocation: SimpleLocationDict = userLocation or {} + """Location in user coordinates along each axis. + + If an axis is not mentioned, it is assumed to be at its default location. + + .. seealso:: This may be only part of the full location. See: + :meth:`getFullUserLocation` + """ + self.elidable: bool = elidable + """STAT flag ``ELIDABLE_AXIS_VALUE_NAME``. + + See: `OTSpec STAT Flags `_ + """ + self.olderSibling: bool = olderSibling + """STAT flag ``OLDER_SIBLING_FONT_ATTRIBUTE``. + + See: `OTSpec STAT Flags `_ + """ + self.labelNames: Dict[str, str] = labelNames or {} + """User-facing translations of this location's label. Keyed by + xml:lang code. + """ + + @property + def defaultName(self) -> str: + """Return the English name from :attr:`labelNames` or the :attr:`name`.""" + return self.labelNames.get("en") or self.name + + def getFullUserLocation(self, doc: "DesignSpaceDocument") -> SimpleLocationDict: + """Get the complete user location of this label, by combining data + from the explicit user location and default axis values. + + .. versionadded:: 5.0 + """ + return { + axis.name: self.userLocation.get(axis.name, axis.default) + for axis in doc.axes + } + + +class VariableFontDescriptor(SimpleDescriptor): + """Container for variable fonts, sub-spaces of the Designspace. + + Use-cases: + + - From a single DesignSpace with discrete axes, define 1 variable font + per value on the discrete axes. Before version 5, you would have needed + 1 DesignSpace per such variable font, and a lot of data duplication. + - From a big variable font with many axes, define subsets of that variable + font that only include some axes and freeze other axes at a given location. + + .. versionadded:: 5.0 + """ + + flavor = "variable-font" + _attrs = ("filename", "axisSubsets", "lib") + + filename = posixpath_property("_filename") + + def __init__(self, *, name, filename=None, axisSubsets=None, lib=None): + self.name: str = name + """string, required. Name of this variable to identify it during the + build process and from other parts of the document, and also as a + filename in case the filename property is empty. + + VarLib. + """ + self.filename: str = filename + """string, optional. Relative path to the variable font file, **as it is + in the document**. The file may or may not exist. + + If not specified, the :attr:`name` will be used as a basename for the file. + """ + self.axisSubsets: List[ + Union[RangeAxisSubsetDescriptor, ValueAxisSubsetDescriptor] + ] = (axisSubsets or []) + """Axis subsets to include in this variable font. + + If an axis is not mentioned, assume that we only want the default + location of that axis (same as a :class:`ValueAxisSubsetDescriptor`). + """ + self.lib: MutableMapping[str, Any] = lib or {} + """Custom data associated with this variable font.""" + + +class RangeAxisSubsetDescriptor(SimpleDescriptor): + """Subset of a continuous axis to include in a variable font. + + .. versionadded:: 5.0 + """ + + flavor = "axis-subset" + _attrs = ("name", "userMinimum", "userDefault", "userMaximum") + + def __init__( + self, *, name, userMinimum=-math.inf, userDefault=None, userMaximum=math.inf + ): + self.name: str = name + """Name of the :class:`AxisDescriptor` to subset.""" + self.userMinimum: float = userMinimum + """New minimum value of the axis in the target variable font. + If not specified, assume the same minimum value as the full axis. + (default = ``-math.inf``) + """ + self.userDefault: Optional[float] = userDefault + """New default value of the axis in the target variable font. + If not specified, assume the same default value as the full axis. + (default = ``None``) + """ + self.userMaximum: float = userMaximum + """New maximum value of the axis in the target variable font. + If not specified, assume the same maximum value as the full axis. + (default = ``math.inf``) + """ + + +class ValueAxisSubsetDescriptor(SimpleDescriptor): + """Single value of a discrete or continuous axis to use in a variable font. + + .. versionadded:: 5.0 + """ + + flavor = "axis-subset" + _attrs = ("name", "userValue") + + def __init__(self, *, name, userValue): + self.name: str = name + """Name of the :class:`AxisDescriptor` or :class:`DiscreteAxisDescriptor` + to "snapshot" or "freeze". + """ + self.userValue: float = userValue + """Value in user coordinates at which to freeze the given axis.""" + + +class BaseDocWriter(object): + _whiteSpace = " " + axisDescriptorClass = AxisDescriptor + discreteAxisDescriptorClass = DiscreteAxisDescriptor + axisLabelDescriptorClass = AxisLabelDescriptor + axisMappingDescriptorClass = AxisMappingDescriptor + locationLabelDescriptorClass = LocationLabelDescriptor + ruleDescriptorClass = RuleDescriptor + sourceDescriptorClass = SourceDescriptor + variableFontDescriptorClass = VariableFontDescriptor + valueAxisSubsetDescriptorClass = ValueAxisSubsetDescriptor + rangeAxisSubsetDescriptorClass = RangeAxisSubsetDescriptor + instanceDescriptorClass = InstanceDescriptor + + @classmethod + def getAxisDecriptor(cls): + return cls.axisDescriptorClass() + + @classmethod + def getAxisMappingDescriptor(cls): + return cls.axisMappingDescriptorClass() + + @classmethod + def getSourceDescriptor(cls): + return cls.sourceDescriptorClass() + + @classmethod + def getInstanceDescriptor(cls): + return cls.instanceDescriptorClass() + + @classmethod + def getRuleDescriptor(cls): + return cls.ruleDescriptorClass() + + def __init__(self, documentPath, documentObject: DesignSpaceDocument): + self.path = documentPath + self.documentObject = documentObject + self.effectiveFormatTuple = self._getEffectiveFormatTuple() + self.root = ET.Element("designspace") + + def write(self, pretty=True, encoding="UTF-8", xml_declaration=True): + self.root.attrib["format"] = ".".join(str(i) for i in self.effectiveFormatTuple) + + if ( + self.documentObject.axes + or self.documentObject.axisMappings + or self.documentObject.elidedFallbackName is not None + ): + axesElement = ET.Element("axes") + if self.documentObject.elidedFallbackName is not None: + axesElement.attrib["elidedfallbackname"] = ( + self.documentObject.elidedFallbackName + ) + self.root.append(axesElement) + for axisObject in self.documentObject.axes: + self._addAxis(axisObject) + + if self.documentObject.axisMappings: + mappingsElement = None + lastGroup = object() + for mappingObject in self.documentObject.axisMappings: + if getattr(mappingObject, "groupDescription", None) != lastGroup: + if mappingsElement is not None: + self.root.findall(".axes")[0].append(mappingsElement) + lastGroup = getattr(mappingObject, "groupDescription", None) + mappingsElement = ET.Element("mappings") + if lastGroup is not None: + mappingsElement.attrib["description"] = lastGroup + self._addAxisMapping(mappingsElement, mappingObject) + if mappingsElement is not None: + self.root.findall(".axes")[0].append(mappingsElement) + + if self.documentObject.locationLabels: + labelsElement = ET.Element("labels") + for labelObject in self.documentObject.locationLabels: + self._addLocationLabel(labelsElement, labelObject) + self.root.append(labelsElement) + + if self.documentObject.rules: + if getattr(self.documentObject, "rulesProcessingLast", False): + attributes = {"processing": "last"} + else: + attributes = {} + self.root.append(ET.Element("rules", attributes)) + for ruleObject in self.documentObject.rules: + self._addRule(ruleObject) + + if self.documentObject.sources: + self.root.append(ET.Element("sources")) + for sourceObject in self.documentObject.sources: + self._addSource(sourceObject) + + if self.documentObject.variableFonts: + variableFontsElement = ET.Element("variable-fonts") + for variableFont in self.documentObject.variableFonts: + self._addVariableFont(variableFontsElement, variableFont) + self.root.append(variableFontsElement) + + if self.documentObject.instances: + self.root.append(ET.Element("instances")) + for instanceObject in self.documentObject.instances: + self._addInstance(instanceObject) + + if self.documentObject.lib: + self._addLib(self.root, self.documentObject.lib, 2) + + tree = ET.ElementTree(self.root) + tree.write( + self.path, + encoding=encoding, + method="xml", + xml_declaration=xml_declaration, + pretty_print=pretty, + ) + + def _getEffectiveFormatTuple(self): + """Try to use the version specified in the document, or a sufficiently + recent version to be able to encode what the document contains. + """ + minVersion = self.documentObject.formatTuple + if ( + any( + hasattr(axis, "values") + or axis.axisOrdering is not None + or axis.axisLabels + for axis in self.documentObject.axes + ) + or self.documentObject.locationLabels + or any(source.localisedFamilyName for source in self.documentObject.sources) + or self.documentObject.variableFonts + or any( + instance.locationLabel or instance.userLocation + for instance in self.documentObject.instances + ) + ): + if minVersion < (5, 0): + minVersion = (5, 0) + if self.documentObject.axisMappings: + if minVersion < (5, 1): + minVersion = (5, 1) + return minVersion + + def _makeLocationElement(self, locationObject, name=None): + """Convert Location dict to a locationElement.""" + locElement = ET.Element("location") + if name is not None: + locElement.attrib["name"] = name + validatedLocation = self.documentObject.newDefaultLocation() + for axisName, axisValue in locationObject.items(): + if axisName in validatedLocation: + # only accept values we know + validatedLocation[axisName] = axisValue + for dimensionName, dimensionValue in validatedLocation.items(): + dimElement = ET.Element("dimension") + dimElement.attrib["name"] = dimensionName + if type(dimensionValue) == tuple: + dimElement.attrib["xvalue"] = self.intOrFloat(dimensionValue[0]) + dimElement.attrib["yvalue"] = self.intOrFloat(dimensionValue[1]) + else: + dimElement.attrib["xvalue"] = self.intOrFloat(dimensionValue) + locElement.append(dimElement) + return locElement, validatedLocation + + def intOrFloat(self, num): + if int(num) == num: + return "%d" % num + return ("%f" % num).rstrip("0").rstrip(".") + + def _addRule(self, ruleObject): + # if none of the conditions have minimum or maximum values, do not add the rule. + ruleElement = ET.Element("rule") + if ruleObject.name is not None: + ruleElement.attrib["name"] = ruleObject.name + for conditions in ruleObject.conditionSets: + conditionsetElement = ET.Element("conditionset") + for cond in conditions: + if cond.get("minimum") is None and cond.get("maximum") is None: + # neither is defined, don't add this condition + continue + conditionElement = ET.Element("condition") + conditionElement.attrib["name"] = cond.get("name") + if cond.get("minimum") is not None: + conditionElement.attrib["minimum"] = self.intOrFloat( + cond.get("minimum") + ) + if cond.get("maximum") is not None: + conditionElement.attrib["maximum"] = self.intOrFloat( + cond.get("maximum") + ) + conditionsetElement.append(conditionElement) + if len(conditionsetElement): + ruleElement.append(conditionsetElement) + for sub in ruleObject.subs: + subElement = ET.Element("sub") + subElement.attrib["name"] = sub[0] + subElement.attrib["with"] = sub[1] + ruleElement.append(subElement) + if len(ruleElement): + self.root.findall(".rules")[0].append(ruleElement) + + def _addAxis(self, axisObject): + axisElement = ET.Element("axis") + axisElement.attrib["tag"] = axisObject.tag + axisElement.attrib["name"] = axisObject.name + self._addLabelNames(axisElement, axisObject.labelNames) + if axisObject.map: + for inputValue, outputValue in axisObject.map: + mapElement = ET.Element("map") + mapElement.attrib["input"] = self.intOrFloat(inputValue) + mapElement.attrib["output"] = self.intOrFloat(outputValue) + axisElement.append(mapElement) + if axisObject.axisOrdering or axisObject.axisLabels: + labelsElement = ET.Element("labels") + if axisObject.axisOrdering is not None: + labelsElement.attrib["ordering"] = str(axisObject.axisOrdering) + for label in axisObject.axisLabels: + self._addAxisLabel(labelsElement, label) + axisElement.append(labelsElement) + if hasattr(axisObject, "minimum"): + axisElement.attrib["minimum"] = self.intOrFloat(axisObject.minimum) + axisElement.attrib["maximum"] = self.intOrFloat(axisObject.maximum) + elif hasattr(axisObject, "values"): + axisElement.attrib["values"] = " ".join( + self.intOrFloat(v) for v in axisObject.values + ) + axisElement.attrib["default"] = self.intOrFloat(axisObject.default) + if axisObject.hidden: + axisElement.attrib["hidden"] = "1" + self.root.findall(".axes")[0].append(axisElement) + + def _addAxisMapping(self, mappingsElement, mappingObject): + mappingElement = ET.Element("mapping") + if getattr(mappingObject, "description", None) is not None: + mappingElement.attrib["description"] = mappingObject.description + for what in ("inputLocation", "outputLocation"): + whatObject = getattr(mappingObject, what, None) + if whatObject is None: + continue + whatElement = ET.Element(what[:-8]) + mappingElement.append(whatElement) + + for name, value in whatObject.items(): + dimensionElement = ET.Element("dimension") + dimensionElement.attrib["name"] = name + dimensionElement.attrib["xvalue"] = self.intOrFloat(value) + whatElement.append(dimensionElement) + + mappingsElement.append(mappingElement) + + def _addAxisLabel( + self, axisElement: ET.Element, label: AxisLabelDescriptor + ) -> None: + labelElement = ET.Element("label") + labelElement.attrib["uservalue"] = self.intOrFloat(label.userValue) + if label.userMinimum is not None: + labelElement.attrib["userminimum"] = self.intOrFloat(label.userMinimum) + if label.userMaximum is not None: + labelElement.attrib["usermaximum"] = self.intOrFloat(label.userMaximum) + labelElement.attrib["name"] = label.name + if label.elidable: + labelElement.attrib["elidable"] = "true" + if label.olderSibling: + labelElement.attrib["oldersibling"] = "true" + if label.linkedUserValue is not None: + labelElement.attrib["linkeduservalue"] = self.intOrFloat( + label.linkedUserValue + ) + self._addLabelNames(labelElement, label.labelNames) + axisElement.append(labelElement) + + def _addLabelNames(self, parentElement, labelNames): + for languageCode, labelName in sorted(labelNames.items()): + languageElement = ET.Element("labelname") + languageElement.attrib[XML_LANG] = languageCode + languageElement.text = labelName + parentElement.append(languageElement) + + def _addLocationLabel( + self, parentElement: ET.Element, label: LocationLabelDescriptor + ) -> None: + labelElement = ET.Element("label") + labelElement.attrib["name"] = label.name + if label.elidable: + labelElement.attrib["elidable"] = "true" + if label.olderSibling: + labelElement.attrib["oldersibling"] = "true" + self._addLabelNames(labelElement, label.labelNames) + self._addLocationElement(labelElement, userLocation=label.userLocation) + parentElement.append(labelElement) + + def _addLocationElement( + self, + parentElement, + *, + designLocation: AnisotropicLocationDict = None, + userLocation: SimpleLocationDict = None, + ): + locElement = ET.Element("location") + for axis in self.documentObject.axes: + if designLocation is not None and axis.name in designLocation: + dimElement = ET.Element("dimension") + dimElement.attrib["name"] = axis.name + value = designLocation[axis.name] + if isinstance(value, tuple): + dimElement.attrib["xvalue"] = self.intOrFloat(value[0]) + dimElement.attrib["yvalue"] = self.intOrFloat(value[1]) + else: + dimElement.attrib["xvalue"] = self.intOrFloat(value) + locElement.append(dimElement) + elif userLocation is not None and axis.name in userLocation: + dimElement = ET.Element("dimension") + dimElement.attrib["name"] = axis.name + value = userLocation[axis.name] + dimElement.attrib["uservalue"] = self.intOrFloat(value) + locElement.append(dimElement) + if len(locElement) > 0: + parentElement.append(locElement) + + def _addInstance(self, instanceObject): + instanceElement = ET.Element("instance") + if instanceObject.name is not None: + instanceElement.attrib["name"] = instanceObject.name + if instanceObject.locationLabel is not None: + instanceElement.attrib["location"] = instanceObject.locationLabel + if instanceObject.familyName is not None: + instanceElement.attrib["familyname"] = instanceObject.familyName + if instanceObject.styleName is not None: + instanceElement.attrib["stylename"] = instanceObject.styleName + # add localisations + if instanceObject.localisedStyleName: + languageCodes = list(instanceObject.localisedStyleName.keys()) + languageCodes.sort() + for code in languageCodes: + if code == "en": + continue # already stored in the element attribute + localisedStyleNameElement = ET.Element("stylename") + localisedStyleNameElement.attrib[XML_LANG] = code + localisedStyleNameElement.text = instanceObject.getStyleName(code) + instanceElement.append(localisedStyleNameElement) + if instanceObject.localisedFamilyName: + languageCodes = list(instanceObject.localisedFamilyName.keys()) + languageCodes.sort() + for code in languageCodes: + if code == "en": + continue # already stored in the element attribute + localisedFamilyNameElement = ET.Element("familyname") + localisedFamilyNameElement.attrib[XML_LANG] = code + localisedFamilyNameElement.text = instanceObject.getFamilyName(code) + instanceElement.append(localisedFamilyNameElement) + if instanceObject.localisedStyleMapStyleName: + languageCodes = list(instanceObject.localisedStyleMapStyleName.keys()) + languageCodes.sort() + for code in languageCodes: + if code == "en": + continue + localisedStyleMapStyleNameElement = ET.Element("stylemapstylename") + localisedStyleMapStyleNameElement.attrib[XML_LANG] = code + localisedStyleMapStyleNameElement.text = ( + instanceObject.getStyleMapStyleName(code) + ) + instanceElement.append(localisedStyleMapStyleNameElement) + if instanceObject.localisedStyleMapFamilyName: + languageCodes = list(instanceObject.localisedStyleMapFamilyName.keys()) + languageCodes.sort() + for code in languageCodes: + if code == "en": + continue + localisedStyleMapFamilyNameElement = ET.Element("stylemapfamilyname") + localisedStyleMapFamilyNameElement.attrib[XML_LANG] = code + localisedStyleMapFamilyNameElement.text = ( + instanceObject.getStyleMapFamilyName(code) + ) + instanceElement.append(localisedStyleMapFamilyNameElement) + + if self.effectiveFormatTuple >= (5, 0): + if instanceObject.locationLabel is None: + self._addLocationElement( + instanceElement, + designLocation=instanceObject.designLocation, + userLocation=instanceObject.userLocation, + ) + else: + # Pre-version 5.0 code was validating and filling in the location + # dict while writing it out, as preserved below. + if instanceObject.location is not None: + locationElement, instanceObject.location = self._makeLocationElement( + instanceObject.location + ) + instanceElement.append(locationElement) + if instanceObject.filename is not None: + instanceElement.attrib["filename"] = instanceObject.filename + if instanceObject.postScriptFontName is not None: + instanceElement.attrib["postscriptfontname"] = ( + instanceObject.postScriptFontName + ) + if instanceObject.styleMapFamilyName is not None: + instanceElement.attrib["stylemapfamilyname"] = ( + instanceObject.styleMapFamilyName + ) + if instanceObject.styleMapStyleName is not None: + instanceElement.attrib["stylemapstylename"] = ( + instanceObject.styleMapStyleName + ) + if self.effectiveFormatTuple < (5, 0): + # Deprecated members as of version 5.0 + if instanceObject.glyphs: + if instanceElement.findall(".glyphs") == []: + glyphsElement = ET.Element("glyphs") + instanceElement.append(glyphsElement) + glyphsElement = instanceElement.findall(".glyphs")[0] + for glyphName, data in sorted(instanceObject.glyphs.items()): + glyphElement = self._writeGlyphElement( + instanceElement, instanceObject, glyphName, data + ) + glyphsElement.append(glyphElement) + if instanceObject.kerning: + kerningElement = ET.Element("kerning") + instanceElement.append(kerningElement) + if instanceObject.info: + infoElement = ET.Element("info") + instanceElement.append(infoElement) + self._addLib(instanceElement, instanceObject.lib, 4) + self.root.findall(".instances")[0].append(instanceElement) + + def _addSource(self, sourceObject): + sourceElement = ET.Element("source") + if sourceObject.filename is not None: + sourceElement.attrib["filename"] = sourceObject.filename + if sourceObject.name is not None: + if sourceObject.name.find("temp_master") != 0: + # do not save temporary source names + sourceElement.attrib["name"] = sourceObject.name + if sourceObject.familyName is not None: + sourceElement.attrib["familyname"] = sourceObject.familyName + if sourceObject.styleName is not None: + sourceElement.attrib["stylename"] = sourceObject.styleName + if sourceObject.layerName is not None: + sourceElement.attrib["layer"] = sourceObject.layerName + if sourceObject.localisedFamilyName: + languageCodes = list(sourceObject.localisedFamilyName.keys()) + languageCodes.sort() + for code in languageCodes: + if code == "en": + continue # already stored in the element attribute + localisedFamilyNameElement = ET.Element("familyname") + localisedFamilyNameElement.attrib[XML_LANG] = code + localisedFamilyNameElement.text = sourceObject.getFamilyName(code) + sourceElement.append(localisedFamilyNameElement) + if sourceObject.copyLib: + libElement = ET.Element("lib") + libElement.attrib["copy"] = "1" + sourceElement.append(libElement) + if sourceObject.copyGroups: + groupsElement = ET.Element("groups") + groupsElement.attrib["copy"] = "1" + sourceElement.append(groupsElement) + if sourceObject.copyFeatures: + featuresElement = ET.Element("features") + featuresElement.attrib["copy"] = "1" + sourceElement.append(featuresElement) + if sourceObject.copyInfo or sourceObject.muteInfo: + infoElement = ET.Element("info") + if sourceObject.copyInfo: + infoElement.attrib["copy"] = "1" + if sourceObject.muteInfo: + infoElement.attrib["mute"] = "1" + sourceElement.append(infoElement) + if sourceObject.muteKerning: + kerningElement = ET.Element("kerning") + kerningElement.attrib["mute"] = "1" + sourceElement.append(kerningElement) + if sourceObject.mutedGlyphNames: + for name in sourceObject.mutedGlyphNames: + glyphElement = ET.Element("glyph") + glyphElement.attrib["name"] = name + glyphElement.attrib["mute"] = "1" + sourceElement.append(glyphElement) + if self.effectiveFormatTuple >= (5, 0): + self._addLocationElement( + sourceElement, designLocation=sourceObject.location + ) + else: + # Pre-version 5.0 code was validating and filling in the location + # dict while writing it out, as preserved below. + locationElement, sourceObject.location = self._makeLocationElement( + sourceObject.location + ) + sourceElement.append(locationElement) + self.root.findall(".sources")[0].append(sourceElement) + + def _addVariableFont( + self, parentElement: ET.Element, vf: VariableFontDescriptor + ) -> None: + vfElement = ET.Element("variable-font") + vfElement.attrib["name"] = vf.name + if vf.filename is not None: + vfElement.attrib["filename"] = vf.filename + if vf.axisSubsets: + subsetsElement = ET.Element("axis-subsets") + for subset in vf.axisSubsets: + subsetElement = ET.Element("axis-subset") + subsetElement.attrib["name"] = subset.name + # Mypy doesn't support narrowing union types via hasattr() + # https://mypy.readthedocs.io/en/stable/type_narrowing.html + # TODO(Python 3.10): use TypeGuard + if hasattr(subset, "userMinimum"): + subset = cast(RangeAxisSubsetDescriptor, subset) + if subset.userMinimum != -math.inf: + subsetElement.attrib["userminimum"] = self.intOrFloat( + subset.userMinimum + ) + if subset.userMaximum != math.inf: + subsetElement.attrib["usermaximum"] = self.intOrFloat( + subset.userMaximum + ) + if subset.userDefault is not None: + subsetElement.attrib["userdefault"] = self.intOrFloat( + subset.userDefault + ) + elif hasattr(subset, "userValue"): + subset = cast(ValueAxisSubsetDescriptor, subset) + subsetElement.attrib["uservalue"] = self.intOrFloat( + subset.userValue + ) + subsetsElement.append(subsetElement) + vfElement.append(subsetsElement) + self._addLib(vfElement, vf.lib, 4) + parentElement.append(vfElement) + + def _addLib(self, parentElement: ET.Element, data: Any, indent_level: int) -> None: + if not data: + return + libElement = ET.Element("lib") + libElement.append(plistlib.totree(data, indent_level=indent_level)) + parentElement.append(libElement) + + def _writeGlyphElement(self, instanceElement, instanceObject, glyphName, data): + glyphElement = ET.Element("glyph") + if data.get("mute"): + glyphElement.attrib["mute"] = "1" + if data.get("unicodes") is not None: + glyphElement.attrib["unicode"] = " ".join( + [hex(u) for u in data.get("unicodes")] + ) + if data.get("instanceLocation") is not None: + locationElement, data["instanceLocation"] = self._makeLocationElement( + data.get("instanceLocation") + ) + glyphElement.append(locationElement) + if glyphName is not None: + glyphElement.attrib["name"] = glyphName + if data.get("note") is not None: + noteElement = ET.Element("note") + noteElement.text = data.get("note") + glyphElement.append(noteElement) + if data.get("masters") is not None: + mastersElement = ET.Element("masters") + for m in data.get("masters"): + masterElement = ET.Element("master") + if m.get("glyphName") is not None: + masterElement.attrib["glyphname"] = m.get("glyphName") + if m.get("font") is not None: + masterElement.attrib["source"] = m.get("font") + if m.get("location") is not None: + locationElement, m["location"] = self._makeLocationElement( + m.get("location") + ) + masterElement.append(locationElement) + mastersElement.append(masterElement) + glyphElement.append(mastersElement) + return glyphElement + + +class BaseDocReader(LogMixin): + axisDescriptorClass = AxisDescriptor + discreteAxisDescriptorClass = DiscreteAxisDescriptor + axisLabelDescriptorClass = AxisLabelDescriptor + axisMappingDescriptorClass = AxisMappingDescriptor + locationLabelDescriptorClass = LocationLabelDescriptor + ruleDescriptorClass = RuleDescriptor + sourceDescriptorClass = SourceDescriptor + variableFontsDescriptorClass = VariableFontDescriptor + valueAxisSubsetDescriptorClass = ValueAxisSubsetDescriptor + rangeAxisSubsetDescriptorClass = RangeAxisSubsetDescriptor + instanceDescriptorClass = InstanceDescriptor + + def __init__(self, documentPath, documentObject): + self.path = documentPath + self.documentObject = documentObject + tree = ET.parse(self.path) + self.root = tree.getroot() + self.documentObject.formatVersion = self.root.attrib.get("format", "3.0") + self._axes = [] + self.rules = [] + self.sources = [] + self.instances = [] + self.axisDefaults = {} + self._strictAxisNames = True + + @classmethod + def fromstring(cls, string, documentObject): + f = BytesIO(tobytes(string, encoding="utf-8")) + self = cls(f, documentObject) + self.path = None + return self + + def read(self): + self.readAxes() + self.readLabels() + self.readRules() + self.readVariableFonts() + self.readSources() + self.readInstances() + self.readLib() + + def readRules(self): + # we also need to read any conditions that are outside of a condition set. + rules = [] + rulesElement = self.root.find(".rules") + if rulesElement is not None: + processingValue = rulesElement.attrib.get("processing", "first") + if processingValue not in {"first", "last"}: + raise DesignSpaceDocumentError( + " processing attribute value is not valid: %r, " + "expected 'first' or 'last'" % processingValue + ) + self.documentObject.rulesProcessingLast = processingValue == "last" + for ruleElement in self.root.findall(".rules/rule"): + ruleObject = self.ruleDescriptorClass() + ruleName = ruleObject.name = ruleElement.attrib.get("name") + # read any stray conditions outside a condition set + externalConditions = self._readConditionElements( + ruleElement, + ruleName, + ) + if externalConditions: + ruleObject.conditionSets.append(externalConditions) + self.log.info( + "Found stray rule conditions outside a conditionset. " + "Wrapped them in a new conditionset." + ) + # read the conditionsets + for conditionSetElement in ruleElement.findall(".conditionset"): + conditionSet = self._readConditionElements( + conditionSetElement, + ruleName, + ) + if conditionSet is not None: + ruleObject.conditionSets.append(conditionSet) + for subElement in ruleElement.findall(".sub"): + a = subElement.attrib["name"] + b = subElement.attrib["with"] + ruleObject.subs.append((a, b)) + rules.append(ruleObject) + self.documentObject.rules = rules + + def _readConditionElements(self, parentElement, ruleName=None): + cds = [] + for conditionElement in parentElement.findall(".condition"): + cd = {} + cdMin = conditionElement.attrib.get("minimum") + if cdMin is not None: + cd["minimum"] = float(cdMin) + else: + # will allow these to be None, assume axis.minimum + cd["minimum"] = None + cdMax = conditionElement.attrib.get("maximum") + if cdMax is not None: + cd["maximum"] = float(cdMax) + else: + # will allow these to be None, assume axis.maximum + cd["maximum"] = None + cd["name"] = conditionElement.attrib.get("name") + # # test for things + if cd.get("minimum") is None and cd.get("maximum") is None: + raise DesignSpaceDocumentError( + "condition missing required minimum or maximum in rule" + + (" '%s'" % ruleName if ruleName is not None else "") + ) + cds.append(cd) + return cds + + def readAxes(self): + # read the axes elements, including the warp map. + axesElement = self.root.find(".axes") + if axesElement is not None and "elidedfallbackname" in axesElement.attrib: + self.documentObject.elidedFallbackName = axesElement.attrib[ + "elidedfallbackname" + ] + axisElements = self.root.findall(".axes/axis") + if not axisElements: + return + for axisElement in axisElements: + if ( + self.documentObject.formatTuple >= (5, 0) + and "values" in axisElement.attrib + ): + axisObject = self.discreteAxisDescriptorClass() + axisObject.values = [ + float(s) for s in axisElement.attrib["values"].split(" ") + ] + else: + axisObject = self.axisDescriptorClass() + axisObject.minimum = float(axisElement.attrib.get("minimum")) + axisObject.maximum = float(axisElement.attrib.get("maximum")) + axisObject.default = float(axisElement.attrib.get("default")) + axisObject.name = axisElement.attrib.get("name") + if axisElement.attrib.get("hidden", False): + axisObject.hidden = True + axisObject.tag = axisElement.attrib.get("tag") + for mapElement in axisElement.findall("map"): + a = float(mapElement.attrib["input"]) + b = float(mapElement.attrib["output"]) + axisObject.map.append((a, b)) + for labelNameElement in axisElement.findall("labelname"): + # Note: elementtree reads the "xml:lang" attribute name as + # '{http://www.w3.org/XML/1998/namespace}lang' + for key, lang in labelNameElement.items(): + if key == XML_LANG: + axisObject.labelNames[lang] = tostr(labelNameElement.text) + labelElement = axisElement.find(".labels") + if labelElement is not None: + if "ordering" in labelElement.attrib: + axisObject.axisOrdering = int(labelElement.attrib["ordering"]) + for label in labelElement.findall(".label"): + axisObject.axisLabels.append(self.readAxisLabel(label)) + self.documentObject.axes.append(axisObject) + self.axisDefaults[axisObject.name] = axisObject.default + + self.documentObject.axisMappings = [] + for mappingsElement in self.root.findall(".axes/mappings"): + groupDescription = mappingsElement.attrib.get("description") + for mappingElement in mappingsElement.findall("mapping"): + description = mappingElement.attrib.get("description") + inputElement = mappingElement.find("input") + outputElement = mappingElement.find("output") + inputLoc = {} + outputLoc = {} + for dimElement in inputElement.findall(".dimension"): + name = dimElement.attrib["name"] + value = float(dimElement.attrib["xvalue"]) + inputLoc[name] = value + for dimElement in outputElement.findall(".dimension"): + name = dimElement.attrib["name"] + value = float(dimElement.attrib["xvalue"]) + outputLoc[name] = value + axisMappingObject = self.axisMappingDescriptorClass( + inputLocation=inputLoc, + outputLocation=outputLoc, + description=description, + groupDescription=groupDescription, + ) + self.documentObject.axisMappings.append(axisMappingObject) + + def readAxisLabel(self, element: ET.Element): + xml_attrs = { + "userminimum", + "uservalue", + "usermaximum", + "name", + "elidable", + "oldersibling", + "linkeduservalue", + } + unknown_attrs = set(element.attrib) - xml_attrs + if unknown_attrs: + raise DesignSpaceDocumentError( + f"label element contains unknown attributes: {', '.join(unknown_attrs)}" + ) + + name = element.get("name") + if name is None: + raise DesignSpaceDocumentError("label element must have a name attribute.") + valueStr = element.get("uservalue") + if valueStr is None: + raise DesignSpaceDocumentError( + "label element must have a uservalue attribute." + ) + value = float(valueStr) + minimumStr = element.get("userminimum") + minimum = float(minimumStr) if minimumStr is not None else None + maximumStr = element.get("usermaximum") + maximum = float(maximumStr) if maximumStr is not None else None + linkedValueStr = element.get("linkeduservalue") + linkedValue = float(linkedValueStr) if linkedValueStr is not None else None + elidable = True if element.get("elidable") == "true" else False + olderSibling = True if element.get("oldersibling") == "true" else False + labelNames = { + lang: label_name.text or "" + for label_name in element.findall("labelname") + for attr, lang in label_name.items() + if attr == XML_LANG + # Note: elementtree reads the "xml:lang" attribute name as + # '{http://www.w3.org/XML/1998/namespace}lang' + } + return self.axisLabelDescriptorClass( + name=name, + userValue=value, + userMinimum=minimum, + userMaximum=maximum, + elidable=elidable, + olderSibling=olderSibling, + linkedUserValue=linkedValue, + labelNames=labelNames, + ) + + def readLabels(self): + if self.documentObject.formatTuple < (5, 0): + return + + xml_attrs = {"name", "elidable", "oldersibling"} + for labelElement in self.root.findall(".labels/label"): + unknown_attrs = set(labelElement.attrib) - xml_attrs + if unknown_attrs: + raise DesignSpaceDocumentError( + f"Label element contains unknown attributes: {', '.join(unknown_attrs)}" + ) + + name = labelElement.get("name") + if name is None: + raise DesignSpaceDocumentError( + "label element must have a name attribute." + ) + designLocation, userLocation = self.locationFromElement(labelElement) + if designLocation: + raise DesignSpaceDocumentError( + f'

" % self.uuid)) + try: + self.comm = Comm('matplotlib', data={'id': self.uuid}) + except AttributeError as err: + raise RuntimeError('Unable to create an IPython notebook Comm ' + 'instance. Are you in the IPython ' + 'notebook?') from err + self.comm.on_msg(self.on_message) + + manager = self.manager + self._ext_close = False + + def _on_close(close_message): + self._ext_close = True + manager.remove_comm(close_message['content']['comm_id']) + manager.clearup_closed() + + self.comm.on_close(_on_close) + + def is_open(self): + return not (self._ext_close or self.comm._closed) + + def on_close(self): + # When the socket is closed, deregister the websocket with + # the FigureManager. + if self.is_open(): + try: + self.comm.close() + except KeyError: + # apparently already cleaned it up? + pass + + def send_json(self, content): + self.comm.send({'data': json.dumps(content)}) + + def send_binary(self, blob): + if self.supports_binary: + self.comm.send({'blob': 'image/png'}, buffers=[blob]) + else: + # The comm is ASCII, so we send the image in base64 encoded data + # URL form. + data = b64encode(blob).decode('ascii') + data_uri = f"data:image/png;base64,{data}" + self.comm.send({'data': data_uri}) + + def on_message(self, message): + # The 'supports_binary' message is relevant to the + # websocket itself. The other messages get passed along + # to matplotlib as-is. + + # Every message has a "type" and a "figure_id". + message = json.loads(message['content']['data']) + if message['type'] == 'closing': + self.on_close() + self.manager.clearup_closed() + elif message['type'] == 'supports_binary': + self.supports_binary = message['value'] + else: + self.manager.handle_json(message) + + +@_Backend.export +class _BackendNbAgg(_Backend): + FigureCanvas = FigureCanvasNbAgg + FigureManager = FigureManagerNbAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pdf.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pdf.py new file mode 100644 index 00000000..7e3e09f0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pdf.py @@ -0,0 +1,2819 @@ +""" +A PDF Matplotlib backend. + +Author: Jouni K Seppänen and others. +""" + +import codecs +from datetime import timezone +from datetime import datetime +from enum import Enum +from functools import total_ordering +from io import BytesIO +import itertools +import logging +import math +import os +import string +import struct +import sys +import time +import types +import warnings +import zlib + +import numpy as np +from PIL import Image + +import matplotlib as mpl +from matplotlib import _api, _text_helpers, _type1font, cbook, dviread +from matplotlib._pylab_helpers import Gcf +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase, + RendererBase) +from matplotlib.backends.backend_mixed import MixedModeRenderer +from matplotlib.figure import Figure +from matplotlib.font_manager import get_font, fontManager as _fontManager +from matplotlib._afm import AFM +from matplotlib.ft2font import (FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, + LOAD_NO_HINTING, KERNING_UNFITTED, FT2Font) +from matplotlib.transforms import Affine2D, BboxBase +from matplotlib.path import Path +from matplotlib.dates import UTC +from matplotlib import _path +from . import _backend_pdf_ps + +_log = logging.getLogger(__name__) + +# Overview +# +# The low-level knowledge about pdf syntax lies mainly in the pdfRepr +# function and the classes Reference, Name, Operator, and Stream. The +# PdfFile class knows about the overall structure of pdf documents. +# It provides a "write" method for writing arbitrary strings in the +# file, and an "output" method that passes objects through the pdfRepr +# function before writing them in the file. The output method is +# called by the RendererPdf class, which contains the various draw_foo +# methods. RendererPdf contains a GraphicsContextPdf instance, and +# each draw_foo calls self.check_gc before outputting commands. This +# method checks whether the pdf graphics state needs to be modified +# and outputs the necessary commands. GraphicsContextPdf represents +# the graphics state, and its "delta" method returns the commands that +# modify the state. + +# Add "pdf.use14corefonts: True" in your configuration file to use only +# the 14 PDF core fonts. These fonts do not need to be embedded; every +# PDF viewing application is required to have them. This results in very +# light PDF files you can use directly in LaTeX or ConTeXt documents +# generated with pdfTeX, without any conversion. + +# These fonts are: Helvetica, Helvetica-Bold, Helvetica-Oblique, +# Helvetica-BoldOblique, Courier, Courier-Bold, Courier-Oblique, +# Courier-BoldOblique, Times-Roman, Times-Bold, Times-Italic, +# Times-BoldItalic, Symbol, ZapfDingbats. +# +# Some tricky points: +# +# 1. The clip path can only be widened by popping from the state +# stack. Thus the state must be pushed onto the stack before narrowing +# the clip path. This is taken care of by GraphicsContextPdf. +# +# 2. Sometimes it is necessary to refer to something (e.g., font, +# image, or extended graphics state, which contains the alpha value) +# in the page stream by a name that needs to be defined outside the +# stream. PdfFile provides the methods fontName, imageObject, and +# alphaState for this purpose. The implementations of these methods +# should perhaps be generalized. + +# TODOs: +# +# * encoding of fonts, including mathtext fonts and Unicode support +# * TTF support has lots of small TODOs, e.g., how do you know if a font +# is serif/sans-serif, or symbolic/non-symbolic? +# * draw_quad_mesh + + +def _fill(strings, linelen=75): + """ + Make one string from sequence of strings, with whitespace in between. + + The whitespace is chosen to form lines of at most *linelen* characters, + if possible. + """ + currpos = 0 + lasti = 0 + result = [] + for i, s in enumerate(strings): + length = len(s) + if currpos + length < linelen: + currpos += length + 1 + else: + result.append(b' '.join(strings[lasti:i])) + lasti = i + currpos = length + result.append(b' '.join(strings[lasti:])) + return b'\n'.join(result) + + +def _create_pdf_info_dict(backend, metadata): + """ + Create a PDF infoDict based on user-supplied metadata. + + A default ``Creator``, ``Producer``, and ``CreationDate`` are added, though + the user metadata may override it. The date may be the current time, or a + time set by the ``SOURCE_DATE_EPOCH`` environment variable. + + Metadata is verified to have the correct keys and their expected types. Any + unknown keys/types will raise a warning. + + Parameters + ---------- + backend : str + The name of the backend to use in the Producer value. + + metadata : dict[str, Union[str, datetime, Name]] + A dictionary of metadata supplied by the user with information + following the PDF specification, also defined in + `~.backend_pdf.PdfPages` below. + + If any value is *None*, then the key will be removed. This can be used + to remove any pre-defined values. + + Returns + ------- + dict[str, Union[str, datetime, Name]] + A validated dictionary of metadata. + """ + + # get source date from SOURCE_DATE_EPOCH, if set + # See https://reproducible-builds.org/specs/source-date-epoch/ + source_date_epoch = os.getenv("SOURCE_DATE_EPOCH") + if source_date_epoch: + source_date = datetime.fromtimestamp(int(source_date_epoch), timezone.utc) + source_date = source_date.replace(tzinfo=UTC) + else: + source_date = datetime.today() + + info = { + 'Creator': f'Matplotlib v{mpl.__version__}, https://matplotlib.org', + 'Producer': f'Matplotlib {backend} backend v{mpl.__version__}', + 'CreationDate': source_date, + **metadata + } + info = {k: v for (k, v) in info.items() if v is not None} + + def is_string_like(x): + return isinstance(x, str) + is_string_like.text_for_warning = "an instance of str" + + def is_date(x): + return isinstance(x, datetime) + is_date.text_for_warning = "an instance of datetime.datetime" + + def check_trapped(x): + if isinstance(x, Name): + return x.name in (b'True', b'False', b'Unknown') + else: + return x in ('True', 'False', 'Unknown') + check_trapped.text_for_warning = 'one of {"True", "False", "Unknown"}' + + keywords = { + 'Title': is_string_like, + 'Author': is_string_like, + 'Subject': is_string_like, + 'Keywords': is_string_like, + 'Creator': is_string_like, + 'Producer': is_string_like, + 'CreationDate': is_date, + 'ModDate': is_date, + 'Trapped': check_trapped, + } + for k in info: + if k not in keywords: + _api.warn_external(f'Unknown infodict keyword: {k!r}. ' + f'Must be one of {set(keywords)!r}.') + elif not keywords[k](info[k]): + _api.warn_external(f'Bad value for infodict keyword {k}. ' + f'Got {info[k]!r} which is not ' + f'{keywords[k].text_for_warning}.') + if 'Trapped' in info: + info['Trapped'] = Name(info['Trapped']) + + return info + + +def _datetime_to_pdf(d): + """ + Convert a datetime to a PDF string representing it. + + Used for PDF and PGF. + """ + r = d.strftime('D:%Y%m%d%H%M%S') + z = d.utcoffset() + if z is not None: + z = z.seconds + else: + if time.daylight: + z = time.altzone + else: + z = time.timezone + if z == 0: + r += 'Z' + elif z < 0: + r += "+%02d'%02d'" % ((-z) // 3600, (-z) % 3600) + else: + r += "-%02d'%02d'" % (z // 3600, z % 3600) + return r + + +def _calculate_quad_point_coordinates(x, y, width, height, angle=0): + """ + Calculate the coordinates of rectangle when rotated by angle around x, y + """ + + angle = math.radians(-angle) + sin_angle = math.sin(angle) + cos_angle = math.cos(angle) + a = x + height * sin_angle + b = y + height * cos_angle + c = x + width * cos_angle + height * sin_angle + d = y - width * sin_angle + height * cos_angle + e = x + width * cos_angle + f = y - width * sin_angle + return ((x, y), (e, f), (c, d), (a, b)) + + +def _get_coordinates_of_block(x, y, width, height, angle=0): + """ + Get the coordinates of rotated rectangle and rectangle that covers the + rotated rectangle. + """ + + vertices = _calculate_quad_point_coordinates(x, y, width, + height, angle) + + # Find min and max values for rectangle + # adjust so that QuadPoints is inside Rect + # PDF docs says that QuadPoints should be ignored if any point lies + # outside Rect, but for Acrobat it is enough that QuadPoints is on the + # border of Rect. + + pad = 0.00001 if angle % 90 else 0 + min_x = min(v[0] for v in vertices) - pad + min_y = min(v[1] for v in vertices) - pad + max_x = max(v[0] for v in vertices) + pad + max_y = max(v[1] for v in vertices) + pad + return (tuple(itertools.chain.from_iterable(vertices)), + (min_x, min_y, max_x, max_y)) + + +def _get_link_annotation(gc, x, y, width, height, angle=0): + """ + Create a link annotation object for embedding URLs. + """ + quadpoints, rect = _get_coordinates_of_block(x, y, width, height, angle) + link_annotation = { + 'Type': Name('Annot'), + 'Subtype': Name('Link'), + 'Rect': rect, + 'Border': [0, 0, 0], + 'A': { + 'S': Name('URI'), + 'URI': gc.get_url(), + }, + } + if angle % 90: + # Add QuadPoints + link_annotation['QuadPoints'] = quadpoints + return link_annotation + + +# PDF strings are supposed to be able to include any eight-bit data, except +# that unbalanced parens and backslashes must be escaped by a backslash. +# However, sf bug #2708559 shows that the carriage return character may get +# read as a newline; these characters correspond to \gamma and \Omega in TeX's +# math font encoding. Escaping them fixes the bug. +_str_escapes = str.maketrans({ + '\\': '\\\\', '(': '\\(', ')': '\\)', '\n': '\\n', '\r': '\\r'}) + + +def pdfRepr(obj): + """Map Python objects to PDF syntax.""" + + # Some objects defined later have their own pdfRepr method. + if hasattr(obj, 'pdfRepr'): + return obj.pdfRepr() + + # Floats. PDF does not have exponential notation (1.0e-10) so we + # need to use %f with some precision. Perhaps the precision + # should adapt to the magnitude of the number? + elif isinstance(obj, (float, np.floating)): + if not np.isfinite(obj): + raise ValueError("Can only output finite numbers in PDF") + r = b"%.10f" % obj + return r.rstrip(b'0').rstrip(b'.') + + # Booleans. Needs to be tested before integers since + # isinstance(True, int) is true. + elif isinstance(obj, bool): + return [b'false', b'true'][obj] + + # Integers are written as such. + elif isinstance(obj, (int, np.integer)): + return b"%d" % obj + + # Non-ASCII Unicode strings are encoded in UTF-16BE with byte-order mark. + elif isinstance(obj, str): + return pdfRepr(obj.encode('ascii') if obj.isascii() + else codecs.BOM_UTF16_BE + obj.encode('UTF-16BE')) + + # Strings are written in parentheses, with backslashes and parens + # escaped. Actually balanced parens are allowed, but it is + # simpler to escape them all. TODO: cut long strings into lines; + # I believe there is some maximum line length in PDF. + # Despite the extra decode/encode, translate is faster than regex. + elif isinstance(obj, bytes): + return ( + b'(' + + obj.decode('latin-1').translate(_str_escapes).encode('latin-1') + + b')') + + # Dictionaries. The keys must be PDF names, so if we find strings + # there, we make Name objects from them. The values may be + # anything, so the caller must ensure that PDF names are + # represented as Name objects. + elif isinstance(obj, dict): + return _fill([ + b"<<", + *[Name(k).pdfRepr() + b" " + pdfRepr(v) for k, v in obj.items()], + b">>", + ]) + + # Lists. + elif isinstance(obj, (list, tuple)): + return _fill([b"[", *[pdfRepr(val) for val in obj], b"]"]) + + # The null keyword. + elif obj is None: + return b'null' + + # A date. + elif isinstance(obj, datetime): + return pdfRepr(_datetime_to_pdf(obj)) + + # A bounding box + elif isinstance(obj, BboxBase): + return _fill([pdfRepr(val) for val in obj.bounds]) + + else: + raise TypeError(f"Don't know a PDF representation for {type(obj)} " + "objects") + + +def _font_supports_glyph(fonttype, glyph): + """ + Returns True if the font is able to provide codepoint *glyph* in a PDF. + + For a Type 3 font, this method returns True only for single-byte + characters. For Type 42 fonts this method return True if the character is + from the Basic Multilingual Plane. + """ + if fonttype == 3: + return glyph <= 255 + if fonttype == 42: + return glyph <= 65535 + raise NotImplementedError() + + +class Reference: + """ + PDF reference object. + + Use PdfFile.reserveObject() to create References. + """ + + def __init__(self, id): + self.id = id + + def __repr__(self): + return "" % self.id + + def pdfRepr(self): + return b"%d 0 R" % self.id + + def write(self, contents, file): + write = file.write + write(b"%d 0 obj\n" % self.id) + write(pdfRepr(contents)) + write(b"\nendobj\n") + + +@total_ordering +class Name: + """PDF name object.""" + __slots__ = ('name',) + _hexify = {c: '#%02x' % c + for c in {*range(256)} - {*range(ord('!'), ord('~') + 1)}} + + def __init__(self, name): + if isinstance(name, Name): + self.name = name.name + else: + if isinstance(name, bytes): + name = name.decode('ascii') + self.name = name.translate(self._hexify).encode('ascii') + + def __repr__(self): + return "" % self.name + + def __str__(self): + return '/' + self.name.decode('ascii') + + def __eq__(self, other): + return isinstance(other, Name) and self.name == other.name + + def __lt__(self, other): + return isinstance(other, Name) and self.name < other.name + + def __hash__(self): + return hash(self.name) + + def pdfRepr(self): + return b'/' + self.name + + +class Verbatim: + """Store verbatim PDF command content for later inclusion in the stream.""" + def __init__(self, x): + self._x = x + + def pdfRepr(self): + return self._x + + +class Op(Enum): + """PDF operators (not an exhaustive list).""" + + close_fill_stroke = b'b' + fill_stroke = b'B' + fill = b'f' + closepath = b'h' + close_stroke = b's' + stroke = b'S' + endpath = b'n' + begin_text = b'BT' + end_text = b'ET' + curveto = b'c' + rectangle = b're' + lineto = b'l' + moveto = b'm' + concat_matrix = b'cm' + use_xobject = b'Do' + setgray_stroke = b'G' + setgray_nonstroke = b'g' + setrgb_stroke = b'RG' + setrgb_nonstroke = b'rg' + setcolorspace_stroke = b'CS' + setcolorspace_nonstroke = b'cs' + setcolor_stroke = b'SCN' + setcolor_nonstroke = b'scn' + setdash = b'd' + setlinejoin = b'j' + setlinecap = b'J' + setgstate = b'gs' + gsave = b'q' + grestore = b'Q' + textpos = b'Td' + selectfont = b'Tf' + textmatrix = b'Tm' + show = b'Tj' + showkern = b'TJ' + setlinewidth = b'w' + clip = b'W' + shading = b'sh' + + def pdfRepr(self): + return self.value + + @classmethod + def paint_path(cls, fill, stroke): + """ + Return the PDF operator to paint a path. + + Parameters + ---------- + fill : bool + Fill the path with the fill color. + stroke : bool + Stroke the outline of the path with the line color. + """ + if stroke: + if fill: + return cls.fill_stroke + else: + return cls.stroke + else: + if fill: + return cls.fill + else: + return cls.endpath + + +class Stream: + """ + PDF stream object. + + This has no pdfRepr method. Instead, call begin(), then output the + contents of the stream by calling write(), and finally call end(). + """ + __slots__ = ('id', 'len', 'pdfFile', 'file', 'compressobj', 'extra', 'pos') + + def __init__(self, id, len, file, extra=None, png=None): + """ + Parameters + ---------- + id : int + Object id of the stream. + len : Reference or None + An unused Reference object for the length of the stream; + None means to use a memory buffer so the length can be inlined. + file : PdfFile + The underlying object to write the stream to. + extra : dict from Name to anything, or None + Extra key-value pairs to include in the stream header. + png : dict or None + If the data is already png encoded, the decode parameters. + """ + self.id = id # object id + self.len = len # id of length object + self.pdfFile = file + self.file = file.fh # file to which the stream is written + self.compressobj = None # compression object + if extra is None: + self.extra = dict() + else: + self.extra = extra.copy() + if png is not None: + self.extra.update({'Filter': Name('FlateDecode'), + 'DecodeParms': png}) + + self.pdfFile.recordXref(self.id) + if mpl.rcParams['pdf.compression'] and not png: + self.compressobj = zlib.compressobj( + mpl.rcParams['pdf.compression']) + if self.len is None: + self.file = BytesIO() + else: + self._writeHeader() + self.pos = self.file.tell() + + def _writeHeader(self): + write = self.file.write + write(b"%d 0 obj\n" % self.id) + dict = self.extra + dict['Length'] = self.len + if mpl.rcParams['pdf.compression']: + dict['Filter'] = Name('FlateDecode') + + write(pdfRepr(dict)) + write(b"\nstream\n") + + def end(self): + """Finalize stream.""" + + self._flush() + if self.len is None: + contents = self.file.getvalue() + self.len = len(contents) + self.file = self.pdfFile.fh + self._writeHeader() + self.file.write(contents) + self.file.write(b"\nendstream\nendobj\n") + else: + length = self.file.tell() - self.pos + self.file.write(b"\nendstream\nendobj\n") + self.pdfFile.writeObject(self.len, length) + + def write(self, data): + """Write some data on the stream.""" + + if self.compressobj is None: + self.file.write(data) + else: + compressed = self.compressobj.compress(data) + self.file.write(compressed) + + def _flush(self): + """Flush the compression object.""" + + if self.compressobj is not None: + compressed = self.compressobj.flush() + self.file.write(compressed) + self.compressobj = None + + +def _get_pdf_charprocs(font_path, glyph_ids): + font = get_font(font_path, hinting_factor=1) + conv = 1000 / font.units_per_EM # Conversion to PS units (1/1000's). + procs = {} + for glyph_id in glyph_ids: + g = font.load_glyph(glyph_id, LOAD_NO_SCALE) + # NOTE: We should be using round(), but instead use + # "(x+.5).astype(int)" to keep backcompat with the old ttconv code + # (this is different for negative x's). + d1 = (np.array([g.horiAdvance, 0, *g.bbox]) * conv + .5).astype(int) + v, c = font.get_path() + v = (v * 64).astype(int) # Back to TrueType's internal units (1/64's). + # Backcompat with old ttconv code: control points between two quads are + # omitted if they are exactly at the midpoint between the control of + # the quad before and the quad after, but ttconv used to interpolate + # *after* conversion to PS units, causing floating point errors. Here + # we reproduce ttconv's logic, detecting these "implicit" points and + # re-interpolating them. Note that occasionally (e.g. with DejaVu Sans + # glyph "0") a point detected as "implicit" is actually explicit, and + # will thus be shifted by 1. + quads, = np.nonzero(c == 3) + quads_on = quads[1::2] + quads_mid_on = np.array( + sorted({*quads_on} & {*(quads - 1)} & {*(quads + 1)}), int) + implicit = quads_mid_on[ + (v[quads_mid_on] # As above, use astype(int), not // division + == ((v[quads_mid_on - 1] + v[quads_mid_on + 1]) / 2).astype(int)) + .all(axis=1)] + if (font.postscript_name, glyph_id) in [ + ("DejaVuSerif-Italic", 77), # j + ("DejaVuSerif-Italic", 135), # \AA + ]: + v[:, 0] -= 1 # Hard-coded backcompat (FreeType shifts glyph by 1). + v = (v * conv + .5).astype(int) # As above re: truncation vs rounding. + v[implicit] = (( # Fix implicit points; again, truncate. + (v[implicit - 1] + v[implicit + 1]) / 2).astype(int)) + procs[font.get_glyph_name(glyph_id)] = ( + " ".join(map(str, d1)).encode("ascii") + b" d1\n" + + _path.convert_to_string( + Path(v, c), None, None, False, None, -1, + # no code for quad Beziers triggers auto-conversion to cubics. + [b"m", b"l", b"", b"c", b"h"], True) + + b"f") + return procs + + +class PdfFile: + """PDF file object.""" + + def __init__(self, filename, metadata=None): + """ + Parameters + ---------- + filename : str or path-like or file-like + Output target; if a string, a file will be opened for writing. + + metadata : dict from strings to strings and dates + Information dictionary object (see PDF reference section 10.2.1 + 'Document Information Dictionary'), e.g.: + ``{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}``. + + The standard keys are 'Title', 'Author', 'Subject', 'Keywords', + 'Creator', 'Producer', 'CreationDate', 'ModDate', and + 'Trapped'. Values have been predefined for 'Creator', 'Producer' + and 'CreationDate'. They can be removed by setting them to `None`. + """ + super().__init__() + + self._object_seq = itertools.count(1) # consumed by reserveObject + self.xrefTable = [[0, 65535, 'the zero object']] + self.passed_in_file_object = False + self.original_file_like = None + self.tell_base = 0 + fh, opened = cbook.to_filehandle(filename, "wb", return_opened=True) + if not opened: + try: + self.tell_base = filename.tell() + except OSError: + fh = BytesIO() + self.original_file_like = filename + else: + fh = filename + self.passed_in_file_object = True + + self.fh = fh + self.currentstream = None # stream object to write to, if any + fh.write(b"%PDF-1.4\n") # 1.4 is the first version to have alpha + # Output some eight-bit chars as a comment so various utilities + # recognize the file as binary by looking at the first few + # lines (see note in section 3.4.1 of the PDF reference). + fh.write(b"%\254\334 \253\272\n") + + self.rootObject = self.reserveObject('root') + self.pagesObject = self.reserveObject('pages') + self.pageList = [] + self.fontObject = self.reserveObject('fonts') + self._extGStateObject = self.reserveObject('extended graphics states') + self.hatchObject = self.reserveObject('tiling patterns') + self.gouraudObject = self.reserveObject('Gouraud triangles') + self.XObjectObject = self.reserveObject('external objects') + self.resourceObject = self.reserveObject('resources') + + root = {'Type': Name('Catalog'), + 'Pages': self.pagesObject} + self.writeObject(self.rootObject, root) + + self.infoDict = _create_pdf_info_dict('pdf', metadata or {}) + + self.fontNames = {} # maps filenames to internal font names + self._internal_font_seq = (Name(f'F{i}') for i in itertools.count(1)) + self.dviFontInfo = {} # maps dvi font names to embedding information + # differently encoded Type-1 fonts may share the same descriptor + self.type1Descriptors = {} + self._character_tracker = _backend_pdf_ps.CharacterTracker() + + self.alphaStates = {} # maps alpha values to graphics state objects + self._alpha_state_seq = (Name(f'A{i}') for i in itertools.count(1)) + self._soft_mask_states = {} + self._soft_mask_seq = (Name(f'SM{i}') for i in itertools.count(1)) + self._soft_mask_groups = [] + self.hatchPatterns = {} + self._hatch_pattern_seq = (Name(f'H{i}') for i in itertools.count(1)) + self.gouraudTriangles = [] + + self._images = {} + self._image_seq = (Name(f'I{i}') for i in itertools.count(1)) + + self.markers = {} + self.multi_byte_charprocs = {} + + self.paths = [] + + # A list of annotations for each page. Each entry is a tuple of the + # overall Annots object reference that's inserted into the page object, + # followed by a list of the actual annotations. + self._annotations = [] + # For annotations added before a page is created; mostly for the + # purpose of newTextnote. + self.pageAnnotations = [] + + # The PDF spec recommends to include every procset + procsets = [Name(x) for x in "PDF Text ImageB ImageC ImageI".split()] + + # Write resource dictionary. + # Possibly TODO: more general ExtGState (graphics state dictionaries) + # ColorSpace Pattern Shading Properties + resources = {'Font': self.fontObject, + 'XObject': self.XObjectObject, + 'ExtGState': self._extGStateObject, + 'Pattern': self.hatchObject, + 'Shading': self.gouraudObject, + 'ProcSet': procsets} + self.writeObject(self.resourceObject, resources) + + def newPage(self, width, height): + self.endStream() + + self.width, self.height = width, height + contentObject = self.reserveObject('page contents') + annotsObject = self.reserveObject('annotations') + thePage = {'Type': Name('Page'), + 'Parent': self.pagesObject, + 'Resources': self.resourceObject, + 'MediaBox': [0, 0, 72 * width, 72 * height], + 'Contents': contentObject, + 'Annots': annotsObject, + } + pageObject = self.reserveObject('page') + self.writeObject(pageObject, thePage) + self.pageList.append(pageObject) + self._annotations.append((annotsObject, self.pageAnnotations)) + + self.beginStream(contentObject.id, + self.reserveObject('length of content stream')) + # Initialize the pdf graphics state to match the default Matplotlib + # graphics context (colorspace and joinstyle). + self.output(Name('DeviceRGB'), Op.setcolorspace_stroke) + self.output(Name('DeviceRGB'), Op.setcolorspace_nonstroke) + self.output(GraphicsContextPdf.joinstyles['round'], Op.setlinejoin) + + # Clear the list of annotations for the next page + self.pageAnnotations = [] + + def newTextnote(self, text, positionRect=[-100, -100, 0, 0]): + # Create a new annotation of type text + theNote = {'Type': Name('Annot'), + 'Subtype': Name('Text'), + 'Contents': text, + 'Rect': positionRect, + } + self.pageAnnotations.append(theNote) + + def _get_subsetted_psname(self, ps_name, charmap): + def toStr(n, base): + if n < base: + return string.ascii_uppercase[n] + else: + return ( + toStr(n // base, base) + string.ascii_uppercase[n % base] + ) + + # encode to string using base 26 + hashed = hash(frozenset(charmap.keys())) % ((sys.maxsize + 1) * 2) + prefix = toStr(hashed, 26) + + # get first 6 characters from prefix + return prefix[:6] + "+" + ps_name + + def finalize(self): + """Write out the various deferred objects and the pdf end matter.""" + + self.endStream() + self._write_annotations() + self.writeFonts() + self.writeExtGSTates() + self._write_soft_mask_groups() + self.writeHatches() + self.writeGouraudTriangles() + xobjects = { + name: ob for image, name, ob in self._images.values()} + for tup in self.markers.values(): + xobjects[tup[0]] = tup[1] + for name, value in self.multi_byte_charprocs.items(): + xobjects[name] = value + for name, path, trans, ob, join, cap, padding, filled, stroked \ + in self.paths: + xobjects[name] = ob + self.writeObject(self.XObjectObject, xobjects) + self.writeImages() + self.writeMarkers() + self.writePathCollectionTemplates() + self.writeObject(self.pagesObject, + {'Type': Name('Pages'), + 'Kids': self.pageList, + 'Count': len(self.pageList)}) + self.writeInfoDict() + + # Finalize the file + self.writeXref() + self.writeTrailer() + + def close(self): + """Flush all buffers and free all resources.""" + + self.endStream() + if self.passed_in_file_object: + self.fh.flush() + else: + if self.original_file_like is not None: + self.original_file_like.write(self.fh.getvalue()) + self.fh.close() + + def write(self, data): + if self.currentstream is None: + self.fh.write(data) + else: + self.currentstream.write(data) + + def output(self, *data): + self.write(_fill([pdfRepr(x) for x in data])) + self.write(b'\n') + + def beginStream(self, id, len, extra=None, png=None): + assert self.currentstream is None + self.currentstream = Stream(id, len, self, extra, png) + + def endStream(self): + if self.currentstream is not None: + self.currentstream.end() + self.currentstream = None + + def outputStream(self, ref, data, *, extra=None): + self.beginStream(ref.id, None, extra) + self.currentstream.write(data) + self.endStream() + + def _write_annotations(self): + for annotsObject, annotations in self._annotations: + self.writeObject(annotsObject, annotations) + + def fontName(self, fontprop): + """ + Select a font based on fontprop and return a name suitable for + Op.selectfont. If fontprop is a string, it will be interpreted + as the filename of the font. + """ + + if isinstance(fontprop, str): + filenames = [fontprop] + elif mpl.rcParams['pdf.use14corefonts']: + filenames = _fontManager._find_fonts_by_props( + fontprop, fontext='afm', directory=RendererPdf._afm_font_dir + ) + else: + filenames = _fontManager._find_fonts_by_props(fontprop) + first_Fx = None + for fname in filenames: + Fx = self.fontNames.get(fname) + if not first_Fx: + first_Fx = Fx + if Fx is None: + Fx = next(self._internal_font_seq) + self.fontNames[fname] = Fx + _log.debug('Assigning font %s = %r', Fx, fname) + if not first_Fx: + first_Fx = Fx + + # find_fontsprop's first value always adheres to + # findfont's value, so technically no behaviour change + return first_Fx + + def dviFontName(self, dvifont): + """ + Given a dvi font object, return a name suitable for Op.selectfont. + This registers the font information in ``self.dviFontInfo`` if not yet + registered. + """ + + dvi_info = self.dviFontInfo.get(dvifont.texname) + if dvi_info is not None: + return dvi_info.pdfname + + tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) + psfont = tex_font_map[dvifont.texname] + if psfont.filename is None: + raise ValueError( + "No usable font file found for {} (TeX: {}); " + "the font may lack a Type-1 version" + .format(psfont.psname, dvifont.texname)) + + pdfname = next(self._internal_font_seq) + _log.debug('Assigning font %s = %s (dvi)', pdfname, dvifont.texname) + self.dviFontInfo[dvifont.texname] = types.SimpleNamespace( + dvifont=dvifont, + pdfname=pdfname, + fontfile=psfont.filename, + basefont=psfont.psname, + encodingfile=psfont.encoding, + effects=psfont.effects) + return pdfname + + def writeFonts(self): + fonts = {} + for dviname, info in sorted(self.dviFontInfo.items()): + Fx = info.pdfname + _log.debug('Embedding Type-1 font %s from dvi.', dviname) + fonts[Fx] = self._embedTeXFont(info) + for filename in sorted(self.fontNames): + Fx = self.fontNames[filename] + _log.debug('Embedding font %s.', filename) + if filename.endswith('.afm'): + # from pdf.use14corefonts + _log.debug('Writing AFM font.') + fonts[Fx] = self._write_afm_font(filename) + else: + # a normal TrueType font + _log.debug('Writing TrueType font.') + chars = self._character_tracker.used.get(filename) + if chars: + fonts[Fx] = self.embedTTF(filename, chars) + self.writeObject(self.fontObject, fonts) + + def _write_afm_font(self, filename): + with open(filename, 'rb') as fh: + font = AFM(fh) + fontname = font.get_fontname() + fontdict = {'Type': Name('Font'), + 'Subtype': Name('Type1'), + 'BaseFont': Name(fontname), + 'Encoding': Name('WinAnsiEncoding')} + fontdictObject = self.reserveObject('font dictionary') + self.writeObject(fontdictObject, fontdict) + return fontdictObject + + def _embedTeXFont(self, fontinfo): + _log.debug('Embedding TeX font %s - fontinfo=%s', + fontinfo.dvifont.texname, fontinfo.__dict__) + + # Widths + widthsObject = self.reserveObject('font widths') + self.writeObject(widthsObject, fontinfo.dvifont.widths) + + # Font dictionary + fontdictObject = self.reserveObject('font dictionary') + fontdict = { + 'Type': Name('Font'), + 'Subtype': Name('Type1'), + 'FirstChar': 0, + 'LastChar': len(fontinfo.dvifont.widths) - 1, + 'Widths': widthsObject, + } + + # Encoding (if needed) + if fontinfo.encodingfile is not None: + fontdict['Encoding'] = { + 'Type': Name('Encoding'), + 'Differences': [ + 0, *map(Name, dviread._parse_enc(fontinfo.encodingfile))], + } + + # If no file is specified, stop short + if fontinfo.fontfile is None: + _log.warning( + "Because of TeX configuration (pdftex.map, see updmap option " + "pdftexDownloadBase14) the font %s is not embedded. This is " + "deprecated as of PDF 1.5 and it may cause the consumer " + "application to show something that was not intended.", + fontinfo.basefont) + fontdict['BaseFont'] = Name(fontinfo.basefont) + self.writeObject(fontdictObject, fontdict) + return fontdictObject + + # We have a font file to embed - read it in and apply any effects + t1font = _type1font.Type1Font(fontinfo.fontfile) + if fontinfo.effects: + t1font = t1font.transform(fontinfo.effects) + fontdict['BaseFont'] = Name(t1font.prop['FontName']) + + # Font descriptors may be shared between differently encoded + # Type-1 fonts, so only create a new descriptor if there is no + # existing descriptor for this font. + effects = (fontinfo.effects.get('slant', 0.0), + fontinfo.effects.get('extend', 1.0)) + fontdesc = self.type1Descriptors.get((fontinfo.fontfile, effects)) + if fontdesc is None: + fontdesc = self.createType1Descriptor(t1font, fontinfo.fontfile) + self.type1Descriptors[(fontinfo.fontfile, effects)] = fontdesc + fontdict['FontDescriptor'] = fontdesc + + self.writeObject(fontdictObject, fontdict) + return fontdictObject + + def createType1Descriptor(self, t1font, fontfile): + # Create and write the font descriptor and the font file + # of a Type-1 font + fontdescObject = self.reserveObject('font descriptor') + fontfileObject = self.reserveObject('font file') + + italic_angle = t1font.prop['ItalicAngle'] + fixed_pitch = t1font.prop['isFixedPitch'] + + flags = 0 + # fixed width + if fixed_pitch: + flags |= 1 << 0 + # TODO: serif + if 0: + flags |= 1 << 1 + # TODO: symbolic (most TeX fonts are) + if 1: + flags |= 1 << 2 + # non-symbolic + else: + flags |= 1 << 5 + # italic + if italic_angle: + flags |= 1 << 6 + # TODO: all caps + if 0: + flags |= 1 << 16 + # TODO: small caps + if 0: + flags |= 1 << 17 + # TODO: force bold + if 0: + flags |= 1 << 18 + + ft2font = get_font(fontfile) + + descriptor = { + 'Type': Name('FontDescriptor'), + 'FontName': Name(t1font.prop['FontName']), + 'Flags': flags, + 'FontBBox': ft2font.bbox, + 'ItalicAngle': italic_angle, + 'Ascent': ft2font.ascender, + 'Descent': ft2font.descender, + 'CapHeight': 1000, # TODO: find this out + 'XHeight': 500, # TODO: this one too + 'FontFile': fontfileObject, + 'FontFamily': t1font.prop['FamilyName'], + 'StemV': 50, # TODO + # (see also revision 3874; but not all TeX distros have AFM files!) + # 'FontWeight': a number where 400 = Regular, 700 = Bold + } + + self.writeObject(fontdescObject, descriptor) + + self.outputStream(fontfileObject, b"".join(t1font.parts[:2]), + extra={'Length1': len(t1font.parts[0]), + 'Length2': len(t1font.parts[1]), + 'Length3': 0}) + + return fontdescObject + + def _get_xobject_glyph_name(self, filename, glyph_name): + Fx = self.fontName(filename) + return "-".join([ + Fx.name.decode(), + os.path.splitext(os.path.basename(filename))[0], + glyph_name]) + + _identityToUnicodeCMap = b"""/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (Adobe) + /Ordering (UCS) + /Supplement 0 +>> def +/CMapName /Adobe-Identity-UCS def +/CMapType 2 def +1 begincodespacerange +<0000> +endcodespacerange +%d beginbfrange +%s +endbfrange +endcmap +CMapName currentdict /CMap defineresource pop +end +end""" + + def embedTTF(self, filename, characters): + """Embed the TTF font from the named file into the document.""" + + font = get_font(filename) + fonttype = mpl.rcParams['pdf.fonttype'] + + def cvt(length, upe=font.units_per_EM, nearest=True): + """Convert font coordinates to PDF glyph coordinates.""" + value = length / upe * 1000 + if nearest: + return round(value) + # Best(?) to round away from zero for bounding boxes and the like. + if value < 0: + return math.floor(value) + else: + return math.ceil(value) + + def embedTTFType3(font, characters, descriptor): + """The Type 3-specific part of embedding a Truetype font""" + widthsObject = self.reserveObject('font widths') + fontdescObject = self.reserveObject('font descriptor') + fontdictObject = self.reserveObject('font dictionary') + charprocsObject = self.reserveObject('character procs') + differencesArray = [] + firstchar, lastchar = 0, 255 + bbox = [cvt(x, nearest=False) for x in font.bbox] + + fontdict = { + 'Type': Name('Font'), + 'BaseFont': ps_name, + 'FirstChar': firstchar, + 'LastChar': lastchar, + 'FontDescriptor': fontdescObject, + 'Subtype': Name('Type3'), + 'Name': descriptor['FontName'], + 'FontBBox': bbox, + 'FontMatrix': [.001, 0, 0, .001, 0, 0], + 'CharProcs': charprocsObject, + 'Encoding': { + 'Type': Name('Encoding'), + 'Differences': differencesArray}, + 'Widths': widthsObject + } + + from encodings import cp1252 + + # Make the "Widths" array + def get_char_width(charcode): + s = ord(cp1252.decoding_table[charcode]) + width = font.load_char( + s, flags=LOAD_NO_SCALE | LOAD_NO_HINTING).horiAdvance + return cvt(width) + with warnings.catch_warnings(): + # Ignore 'Required glyph missing from current font' warning + # from ft2font: here we're just building the widths table, but + # the missing glyphs may not even be used in the actual string. + warnings.filterwarnings("ignore") + widths = [get_char_width(charcode) + for charcode in range(firstchar, lastchar+1)] + descriptor['MaxWidth'] = max(widths) + + # Make the "Differences" array, sort the ccodes < 255 from + # the multi-byte ccodes, and build the whole set of glyph ids + # that we need from this font. + glyph_ids = [] + differences = [] + multi_byte_chars = set() + for c in characters: + ccode = c + gind = font.get_char_index(ccode) + glyph_ids.append(gind) + glyph_name = font.get_glyph_name(gind) + if ccode <= 255: + differences.append((ccode, glyph_name)) + else: + multi_byte_chars.add(glyph_name) + differences.sort() + + last_c = -2 + for c, name in differences: + if c != last_c + 1: + differencesArray.append(c) + differencesArray.append(Name(name)) + last_c = c + + # Make the charprocs array. + rawcharprocs = _get_pdf_charprocs(filename, glyph_ids) + charprocs = {} + for charname in sorted(rawcharprocs): + stream = rawcharprocs[charname] + charprocDict = {} + # The 2-byte characters are used as XObjects, so they + # need extra info in their dictionary + if charname in multi_byte_chars: + charprocDict = {'Type': Name('XObject'), + 'Subtype': Name('Form'), + 'BBox': bbox} + # Each glyph includes bounding box information, + # but xpdf and ghostscript can't handle it in a + # Form XObject (they segfault!!!), so we remove it + # from the stream here. It's not needed anyway, + # since the Form XObject includes it in its BBox + # value. + stream = stream[stream.find(b"d1") + 2:] + charprocObject = self.reserveObject('charProc') + self.outputStream(charprocObject, stream, extra=charprocDict) + + # Send the glyphs with ccode > 255 to the XObject dictionary, + # and the others to the font itself + if charname in multi_byte_chars: + name = self._get_xobject_glyph_name(filename, charname) + self.multi_byte_charprocs[name] = charprocObject + else: + charprocs[charname] = charprocObject + + # Write everything out + self.writeObject(fontdictObject, fontdict) + self.writeObject(fontdescObject, descriptor) + self.writeObject(widthsObject, widths) + self.writeObject(charprocsObject, charprocs) + + return fontdictObject + + def embedTTFType42(font, characters, descriptor): + """The Type 42-specific part of embedding a Truetype font""" + fontdescObject = self.reserveObject('font descriptor') + cidFontDictObject = self.reserveObject('CID font dictionary') + type0FontDictObject = self.reserveObject('Type 0 font dictionary') + cidToGidMapObject = self.reserveObject('CIDToGIDMap stream') + fontfileObject = self.reserveObject('font file stream') + wObject = self.reserveObject('Type 0 widths') + toUnicodeMapObject = self.reserveObject('ToUnicode map') + + subset_str = "".join(chr(c) for c in characters) + _log.debug("SUBSET %s characters: %s", filename, subset_str) + fontdata = _backend_pdf_ps.get_glyphs_subset(filename, subset_str) + _log.debug( + "SUBSET %s %d -> %d", filename, + os.stat(filename).st_size, fontdata.getbuffer().nbytes + ) + + # We need this ref for XObjects + full_font = font + + # reload the font object from the subset + # (all the necessary data could probably be obtained directly + # using fontLib.ttLib) + font = FT2Font(fontdata) + + cidFontDict = { + 'Type': Name('Font'), + 'Subtype': Name('CIDFontType2'), + 'BaseFont': ps_name, + 'CIDSystemInfo': { + 'Registry': 'Adobe', + 'Ordering': 'Identity', + 'Supplement': 0}, + 'FontDescriptor': fontdescObject, + 'W': wObject, + 'CIDToGIDMap': cidToGidMapObject + } + + type0FontDict = { + 'Type': Name('Font'), + 'Subtype': Name('Type0'), + 'BaseFont': ps_name, + 'Encoding': Name('Identity-H'), + 'DescendantFonts': [cidFontDictObject], + 'ToUnicode': toUnicodeMapObject + } + + # Make fontfile stream + descriptor['FontFile2'] = fontfileObject + self.outputStream( + fontfileObject, fontdata.getvalue(), + extra={'Length1': fontdata.getbuffer().nbytes}) + + # Make the 'W' (Widths) array, CidToGidMap and ToUnicode CMap + # at the same time + cid_to_gid_map = ['\0'] * 65536 + widths = [] + max_ccode = 0 + for c in characters: + ccode = c + gind = font.get_char_index(ccode) + glyph = font.load_char(ccode, + flags=LOAD_NO_SCALE | LOAD_NO_HINTING) + widths.append((ccode, cvt(glyph.horiAdvance))) + if ccode < 65536: + cid_to_gid_map[ccode] = chr(gind) + max_ccode = max(ccode, max_ccode) + widths.sort() + cid_to_gid_map = cid_to_gid_map[:max_ccode + 1] + + last_ccode = -2 + w = [] + max_width = 0 + unicode_groups = [] + for ccode, width in widths: + if ccode != last_ccode + 1: + w.append(ccode) + w.append([width]) + unicode_groups.append([ccode, ccode]) + else: + w[-1].append(width) + unicode_groups[-1][1] = ccode + max_width = max(max_width, width) + last_ccode = ccode + + unicode_bfrange = [] + for start, end in unicode_groups: + # Ensure the CID map contains only chars from BMP + if start > 65535: + continue + end = min(65535, end) + + unicode_bfrange.append( + b"<%04x> <%04x> [%s]" % + (start, end, + b" ".join(b"<%04x>" % x for x in range(start, end+1)))) + unicode_cmap = (self._identityToUnicodeCMap % + (len(unicode_groups), b"\n".join(unicode_bfrange))) + + # Add XObjects for unsupported chars + glyph_ids = [] + for ccode in characters: + if not _font_supports_glyph(fonttype, ccode): + gind = full_font.get_char_index(ccode) + glyph_ids.append(gind) + + bbox = [cvt(x, nearest=False) for x in full_font.bbox] + rawcharprocs = _get_pdf_charprocs(filename, glyph_ids) + for charname in sorted(rawcharprocs): + stream = rawcharprocs[charname] + charprocDict = {'Type': Name('XObject'), + 'Subtype': Name('Form'), + 'BBox': bbox} + # Each glyph includes bounding box information, + # but xpdf and ghostscript can't handle it in a + # Form XObject (they segfault!!!), so we remove it + # from the stream here. It's not needed anyway, + # since the Form XObject includes it in its BBox + # value. + stream = stream[stream.find(b"d1") + 2:] + charprocObject = self.reserveObject('charProc') + self.outputStream(charprocObject, stream, extra=charprocDict) + + name = self._get_xobject_glyph_name(filename, charname) + self.multi_byte_charprocs[name] = charprocObject + + # CIDToGIDMap stream + cid_to_gid_map = "".join(cid_to_gid_map).encode("utf-16be") + self.outputStream(cidToGidMapObject, cid_to_gid_map) + + # ToUnicode CMap + self.outputStream(toUnicodeMapObject, unicode_cmap) + + descriptor['MaxWidth'] = max_width + + # Write everything out + self.writeObject(cidFontDictObject, cidFontDict) + self.writeObject(type0FontDictObject, type0FontDict) + self.writeObject(fontdescObject, descriptor) + self.writeObject(wObject, w) + + return type0FontDictObject + + # Beginning of main embedTTF function... + + ps_name = self._get_subsetted_psname( + font.postscript_name, + font.get_charmap() + ) + ps_name = ps_name.encode('ascii', 'replace') + ps_name = Name(ps_name) + pclt = font.get_sfnt_table('pclt') or {'capHeight': 0, 'xHeight': 0} + post = font.get_sfnt_table('post') or {'italicAngle': (0, 0)} + ff = font.face_flags + sf = font.style_flags + + flags = 0 + symbolic = False # ps_name.name in ('Cmsy10', 'Cmmi10', 'Cmex10') + if ff & FIXED_WIDTH: + flags |= 1 << 0 + if 0: # TODO: serif + flags |= 1 << 1 + if symbolic: + flags |= 1 << 2 + else: + flags |= 1 << 5 + if sf & ITALIC: + flags |= 1 << 6 + if 0: # TODO: all caps + flags |= 1 << 16 + if 0: # TODO: small caps + flags |= 1 << 17 + if 0: # TODO: force bold + flags |= 1 << 18 + + descriptor = { + 'Type': Name('FontDescriptor'), + 'FontName': ps_name, + 'Flags': flags, + 'FontBBox': [cvt(x, nearest=False) for x in font.bbox], + 'Ascent': cvt(font.ascender, nearest=False), + 'Descent': cvt(font.descender, nearest=False), + 'CapHeight': cvt(pclt['capHeight'], nearest=False), + 'XHeight': cvt(pclt['xHeight']), + 'ItalicAngle': post['italicAngle'][1], # ??? + 'StemV': 0 # ??? + } + + if fonttype == 3: + return embedTTFType3(font, characters, descriptor) + elif fonttype == 42: + return embedTTFType42(font, characters, descriptor) + + def alphaState(self, alpha): + """Return name of an ExtGState that sets alpha to the given value.""" + + state = self.alphaStates.get(alpha, None) + if state is not None: + return state[0] + + name = next(self._alpha_state_seq) + self.alphaStates[alpha] = \ + (name, {'Type': Name('ExtGState'), + 'CA': alpha[0], 'ca': alpha[1]}) + return name + + def _soft_mask_state(self, smask): + """ + Return an ExtGState that sets the soft mask to the given shading. + + Parameters + ---------- + smask : Reference + Reference to a shading in DeviceGray color space, whose luminosity + is to be used as the alpha channel. + + Returns + ------- + Name + """ + + state = self._soft_mask_states.get(smask, None) + if state is not None: + return state[0] + + name = next(self._soft_mask_seq) + groupOb = self.reserveObject('transparency group for soft mask') + self._soft_mask_states[smask] = ( + name, + { + 'Type': Name('ExtGState'), + 'AIS': False, + 'SMask': { + 'Type': Name('Mask'), + 'S': Name('Luminosity'), + 'BC': [1], + 'G': groupOb + } + } + ) + self._soft_mask_groups.append(( + groupOb, + { + 'Type': Name('XObject'), + 'Subtype': Name('Form'), + 'FormType': 1, + 'Group': { + 'S': Name('Transparency'), + 'CS': Name('DeviceGray') + }, + 'Matrix': [1, 0, 0, 1, 0, 0], + 'Resources': {'Shading': {'S': smask}}, + 'BBox': [0, 0, 1, 1] + }, + [Name('S'), Op.shading] + )) + return name + + def writeExtGSTates(self): + self.writeObject( + self._extGStateObject, + dict([ + *self.alphaStates.values(), + *self._soft_mask_states.values() + ]) + ) + + def _write_soft_mask_groups(self): + for ob, attributes, content in self._soft_mask_groups: + self.beginStream(ob.id, None, attributes) + self.output(*content) + self.endStream() + + def hatchPattern(self, hatch_style): + # The colors may come in as numpy arrays, which aren't hashable + if hatch_style is not None: + edge, face, hatch = hatch_style + if edge is not None: + edge = tuple(edge) + if face is not None: + face = tuple(face) + hatch_style = (edge, face, hatch) + + pattern = self.hatchPatterns.get(hatch_style, None) + if pattern is not None: + return pattern + + name = next(self._hatch_pattern_seq) + self.hatchPatterns[hatch_style] = name + return name + + def writeHatches(self): + hatchDict = dict() + sidelen = 72.0 + for hatch_style, name in self.hatchPatterns.items(): + ob = self.reserveObject('hatch pattern') + hatchDict[name] = ob + res = {'Procsets': + [Name(x) for x in "PDF Text ImageB ImageC ImageI".split()]} + self.beginStream( + ob.id, None, + {'Type': Name('Pattern'), + 'PatternType': 1, 'PaintType': 1, 'TilingType': 1, + 'BBox': [0, 0, sidelen, sidelen], + 'XStep': sidelen, 'YStep': sidelen, + 'Resources': res, + # Change origin to match Agg at top-left. + 'Matrix': [1, 0, 0, 1, 0, self.height * 72]}) + + stroke_rgb, fill_rgb, hatch = hatch_style + self.output(stroke_rgb[0], stroke_rgb[1], stroke_rgb[2], + Op.setrgb_stroke) + if fill_rgb is not None: + self.output(fill_rgb[0], fill_rgb[1], fill_rgb[2], + Op.setrgb_nonstroke, + 0, 0, sidelen, sidelen, Op.rectangle, + Op.fill) + + self.output(mpl.rcParams['hatch.linewidth'], Op.setlinewidth) + + self.output(*self.pathOperations( + Path.hatch(hatch), + Affine2D().scale(sidelen), + simplify=False)) + self.output(Op.fill_stroke) + + self.endStream() + self.writeObject(self.hatchObject, hatchDict) + + def addGouraudTriangles(self, points, colors): + """ + Add a Gouraud triangle shading. + + Parameters + ---------- + points : np.ndarray + Triangle vertices, shape (n, 3, 2) + where n = number of triangles, 3 = vertices, 2 = x, y. + colors : np.ndarray + Vertex colors, shape (n, 3, 1) or (n, 3, 4) + as with points, but last dimension is either (gray,) + or (r, g, b, alpha). + + Returns + ------- + Name, Reference + """ + name = Name('GT%d' % len(self.gouraudTriangles)) + ob = self.reserveObject(f'Gouraud triangle {name}') + self.gouraudTriangles.append((name, ob, points, colors)) + return name, ob + + def writeGouraudTriangles(self): + gouraudDict = dict() + for name, ob, points, colors in self.gouraudTriangles: + gouraudDict[name] = ob + shape = points.shape + flat_points = points.reshape((shape[0] * shape[1], 2)) + colordim = colors.shape[2] + assert colordim in (1, 4) + flat_colors = colors.reshape((shape[0] * shape[1], colordim)) + if colordim == 4: + # strip the alpha channel + colordim = 3 + points_min = np.min(flat_points, axis=0) - (1 << 8) + points_max = np.max(flat_points, axis=0) + (1 << 8) + factor = 0xffffffff / (points_max - points_min) + + self.beginStream( + ob.id, None, + {'ShadingType': 4, + 'BitsPerCoordinate': 32, + 'BitsPerComponent': 8, + 'BitsPerFlag': 8, + 'ColorSpace': Name( + 'DeviceRGB' if colordim == 3 else 'DeviceGray' + ), + 'AntiAlias': False, + 'Decode': ([points_min[0], points_max[0], + points_min[1], points_max[1]] + + [0, 1] * colordim), + }) + + streamarr = np.empty( + (shape[0] * shape[1],), + dtype=[('flags', 'u1'), + ('points', '>u4', (2,)), + ('colors', 'u1', (colordim,))]) + streamarr['flags'] = 0 + streamarr['points'] = (flat_points - points_min) * factor + streamarr['colors'] = flat_colors[:, :colordim] * 255.0 + + self.write(streamarr.tobytes()) + self.endStream() + self.writeObject(self.gouraudObject, gouraudDict) + + def imageObject(self, image): + """Return name of an image XObject representing the given image.""" + + entry = self._images.get(id(image), None) + if entry is not None: + return entry[1] + + name = next(self._image_seq) + ob = self.reserveObject(f'image {name}') + self._images[id(image)] = (image, name, ob) + return name + + def _unpack(self, im): + """ + Unpack image array *im* into ``(data, alpha)``, which have shape + ``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or + alpha), except that alpha is None if the image is fully opaque. + """ + im = im[::-1] + if im.ndim == 2: + return im, None + else: + rgb = im[:, :, :3] + rgb = np.array(rgb, order='C') + # PDF needs a separate alpha image + if im.shape[2] == 4: + alpha = im[:, :, 3][..., None] + if np.all(alpha == 255): + alpha = None + else: + alpha = np.array(alpha, order='C') + else: + alpha = None + return rgb, alpha + + def _writePng(self, img): + """ + Write the image *img* into the pdf file using png + predictors with Flate compression. + """ + buffer = BytesIO() + img.save(buffer, format="png") + buffer.seek(8) + png_data = b'' + bit_depth = palette = None + while True: + length, type = struct.unpack(b'!L4s', buffer.read(8)) + if type in [b'IHDR', b'PLTE', b'IDAT']: + data = buffer.read(length) + if len(data) != length: + raise RuntimeError("truncated data") + if type == b'IHDR': + bit_depth = int(data[8]) + elif type == b'PLTE': + palette = data + elif type == b'IDAT': + png_data += data + elif type == b'IEND': + break + else: + buffer.seek(length, 1) + buffer.seek(4, 1) # skip CRC + return png_data, bit_depth, palette + + def _writeImg(self, data, id, smask=None): + """ + Write the image *data*, of shape ``(height, width, 1)`` (grayscale) or + ``(height, width, 3)`` (RGB), as pdf object *id* and with the soft mask + (alpha channel) *smask*, which should be either None or a ``(height, + width, 1)`` array. + """ + height, width, color_channels = data.shape + obj = {'Type': Name('XObject'), + 'Subtype': Name('Image'), + 'Width': width, + 'Height': height, + 'ColorSpace': Name({1: 'DeviceGray', 3: 'DeviceRGB'}[color_channels]), + 'BitsPerComponent': 8} + if smask: + obj['SMask'] = smask + if mpl.rcParams['pdf.compression']: + if data.shape[-1] == 1: + data = data.squeeze(axis=-1) + png = {'Predictor': 10, 'Colors': color_channels, 'Columns': width} + img = Image.fromarray(data) + img_colors = img.getcolors(maxcolors=256) + if color_channels == 3 and img_colors is not None: + # Convert to indexed color if there are 256 colors or fewer. This can + # significantly reduce the file size. + num_colors = len(img_colors) + palette = np.array([comp for _, color in img_colors for comp in color], + dtype=np.uint8) + palette24 = ((palette[0::3].astype(np.uint32) << 16) | + (palette[1::3].astype(np.uint32) << 8) | + palette[2::3]) + rgb24 = ((data[:, :, 0].astype(np.uint32) << 16) | + (data[:, :, 1].astype(np.uint32) << 8) | + data[:, :, 2]) + indices = np.argsort(palette24).astype(np.uint8) + rgb8 = indices[np.searchsorted(palette24, rgb24, sorter=indices)] + img = Image.fromarray(rgb8, mode='P') + img.putpalette(palette) + png_data, bit_depth, palette = self._writePng(img) + if bit_depth is None or palette is None: + raise RuntimeError("invalid PNG header") + palette = palette[:num_colors * 3] # Trim padding; remove for Pillow>=9 + obj['ColorSpace'] = [Name('Indexed'), Name('DeviceRGB'), + num_colors - 1, palette] + obj['BitsPerComponent'] = bit_depth + png['Colors'] = 1 + png['BitsPerComponent'] = bit_depth + else: + png_data, _, _ = self._writePng(img) + else: + png = None + self.beginStream( + id, + self.reserveObject('length of image stream'), + obj, + png=png + ) + if png: + self.currentstream.write(png_data) + else: + self.currentstream.write(data.tobytes()) + self.endStream() + + def writeImages(self): + for img, name, ob in self._images.values(): + data, adata = self._unpack(img) + if adata is not None: + smaskObject = self.reserveObject("smask") + self._writeImg(adata, smaskObject.id) + else: + smaskObject = None + self._writeImg(data, ob.id, smaskObject) + + def markerObject(self, path, trans, fill, stroke, lw, joinstyle, + capstyle): + """Return name of a marker XObject representing the given path.""" + # self.markers used by markerObject, writeMarkers, close: + # mapping from (path operations, fill?, stroke?) to + # [name, object reference, bounding box, linewidth] + # This enables different draw_markers calls to share the XObject + # if the gc is sufficiently similar: colors etc can vary, but + # the choices of whether to fill and whether to stroke cannot. + # We need a bounding box enclosing all of the XObject path, + # but since line width may vary, we store the maximum of all + # occurring line widths in self.markers. + # close() is somewhat tightly coupled in that it expects the + # first two components of each value in self.markers to be the + # name and object reference. + pathops = self.pathOperations(path, trans, simplify=False) + key = (tuple(pathops), bool(fill), bool(stroke), joinstyle, capstyle) + result = self.markers.get(key) + if result is None: + name = Name('M%d' % len(self.markers)) + ob = self.reserveObject('marker %d' % len(self.markers)) + bbox = path.get_extents(trans) + self.markers[key] = [name, ob, bbox, lw] + else: + if result[-1] < lw: + result[-1] = lw + name = result[0] + return name + + def writeMarkers(self): + for ((pathops, fill, stroke, joinstyle, capstyle), + (name, ob, bbox, lw)) in self.markers.items(): + # bbox wraps the exact limits of the control points, so half a line + # will appear outside it. If the join style is miter and the line + # is not parallel to the edge, then the line will extend even + # further. From the PDF specification, Section 8.4.3.5, the miter + # limit is miterLength / lineWidth and from Table 52, the default + # is 10. With half the miter length outside, that works out to the + # following padding: + bbox = bbox.padded(lw * 5) + self.beginStream( + ob.id, None, + {'Type': Name('XObject'), 'Subtype': Name('Form'), + 'BBox': list(bbox.extents)}) + self.output(GraphicsContextPdf.joinstyles[joinstyle], + Op.setlinejoin) + self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap) + self.output(*pathops) + self.output(Op.paint_path(fill, stroke)) + self.endStream() + + def pathCollectionObject(self, gc, path, trans, padding, filled, stroked): + name = Name('P%d' % len(self.paths)) + ob = self.reserveObject('path %d' % len(self.paths)) + self.paths.append( + (name, path, trans, ob, gc.get_joinstyle(), gc.get_capstyle(), + padding, filled, stroked)) + return name + + def writePathCollectionTemplates(self): + for (name, path, trans, ob, joinstyle, capstyle, padding, filled, + stroked) in self.paths: + pathops = self.pathOperations(path, trans, simplify=False) + bbox = path.get_extents(trans) + if not np.all(np.isfinite(bbox.extents)): + extents = [0, 0, 0, 0] + else: + bbox = bbox.padded(padding) + extents = list(bbox.extents) + self.beginStream( + ob.id, None, + {'Type': Name('XObject'), 'Subtype': Name('Form'), + 'BBox': extents}) + self.output(GraphicsContextPdf.joinstyles[joinstyle], + Op.setlinejoin) + self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap) + self.output(*pathops) + self.output(Op.paint_path(filled, stroked)) + self.endStream() + + @staticmethod + def pathOperations(path, transform, clip=None, simplify=None, sketch=None): + return [Verbatim(_path.convert_to_string( + path, transform, clip, simplify, sketch, + 6, + [Op.moveto.value, Op.lineto.value, b'', Op.curveto.value, + Op.closepath.value], + True))] + + def writePath(self, path, transform, clip=False, sketch=None): + if clip: + clip = (0.0, 0.0, self.width * 72, self.height * 72) + simplify = path.should_simplify + else: + clip = None + simplify = False + cmds = self.pathOperations(path, transform, clip, simplify=simplify, + sketch=sketch) + self.output(*cmds) + + def reserveObject(self, name=''): + """ + Reserve an ID for an indirect object. + + The name is used for debugging in case we forget to print out + the object with writeObject. + """ + id = next(self._object_seq) + self.xrefTable.append([None, 0, name]) + return Reference(id) + + def recordXref(self, id): + self.xrefTable[id][0] = self.fh.tell() - self.tell_base + + def writeObject(self, object, contents): + self.recordXref(object.id) + object.write(contents, self) + + def writeXref(self): + """Write out the xref table.""" + self.startxref = self.fh.tell() - self.tell_base + self.write(b"xref\n0 %d\n" % len(self.xrefTable)) + for i, (offset, generation, name) in enumerate(self.xrefTable): + if offset is None: + raise AssertionError( + 'No offset for object %d (%s)' % (i, name)) + else: + key = b"f" if name == 'the zero object' else b"n" + text = b"%010d %05d %b \n" % (offset, generation, key) + self.write(text) + + def writeInfoDict(self): + """Write out the info dictionary, checking it for good form""" + + self.infoObject = self.reserveObject('info') + self.writeObject(self.infoObject, self.infoDict) + + def writeTrailer(self): + """Write out the PDF trailer.""" + + self.write(b"trailer\n") + self.write(pdfRepr( + {'Size': len(self.xrefTable), + 'Root': self.rootObject, + 'Info': self.infoObject})) + # Could add 'ID' + self.write(b"\nstartxref\n%d\n%%%%EOF\n" % self.startxref) + + +class RendererPdf(_backend_pdf_ps.RendererPDFPSBase): + + _afm_font_dir = cbook._get_data_path("fonts/pdfcorefonts") + _use_afm_rc_name = "pdf.use14corefonts" + + def __init__(self, file, image_dpi, height, width): + super().__init__(width, height) + self.file = file + self.gc = self.new_gc() + self.image_dpi = image_dpi + + def finalize(self): + self.file.output(*self.gc.finalize()) + + def check_gc(self, gc, fillcolor=None): + orig_fill = getattr(gc, '_fillcolor', (0., 0., 0.)) + gc._fillcolor = fillcolor + + orig_alphas = getattr(gc, '_effective_alphas', (1.0, 1.0)) + + if gc.get_rgb() is None: + # It should not matter what color here since linewidth should be + # 0 unless affected by global settings in rcParams, hence setting + # zero alpha just in case. + gc.set_foreground((0, 0, 0, 0), isRGBA=True) + + if gc._forced_alpha: + gc._effective_alphas = (gc._alpha, gc._alpha) + elif fillcolor is None or len(fillcolor) < 4: + gc._effective_alphas = (gc._rgb[3], 1.0) + else: + gc._effective_alphas = (gc._rgb[3], fillcolor[3]) + + delta = self.gc.delta(gc) + if delta: + self.file.output(*delta) + + # Restore gc to avoid unwanted side effects + gc._fillcolor = orig_fill + gc._effective_alphas = orig_alphas + + def get_image_magnification(self): + return self.image_dpi/72.0 + + def draw_image(self, gc, x, y, im, transform=None): + # docstring inherited + + h, w = im.shape[:2] + if w == 0 or h == 0: + return + + if transform is None: + # If there's no transform, alpha has already been applied + gc.set_alpha(1.0) + + self.check_gc(gc) + + w = 72.0 * w / self.image_dpi + h = 72.0 * h / self.image_dpi + + imob = self.file.imageObject(im) + + if transform is None: + self.file.output(Op.gsave, + w, 0, 0, h, x, y, Op.concat_matrix, + imob, Op.use_xobject, Op.grestore) + else: + tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values() + + self.file.output(Op.gsave, + 1, 0, 0, 1, x, y, Op.concat_matrix, + tr1, tr2, tr3, tr4, tr5, tr6, Op.concat_matrix, + imob, Op.use_xobject, Op.grestore) + + def draw_path(self, gc, path, transform, rgbFace=None): + # docstring inherited + self.check_gc(gc, rgbFace) + self.file.writePath( + path, transform, + rgbFace is None and gc.get_hatch_path() is None, + gc.get_sketch_params()) + self.file.output(self.gc.paint()) + + def draw_path_collection(self, gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position): + # We can only reuse the objects if the presence of fill and + # stroke (and the amount of alpha for each) is the same for + # all of them + can_do_optimization = True + facecolors = np.asarray(facecolors) + edgecolors = np.asarray(edgecolors) + + if not len(facecolors): + filled = False + can_do_optimization = not gc.get_hatch() + else: + if np.all(facecolors[:, 3] == facecolors[0, 3]): + filled = facecolors[0, 3] != 0.0 + else: + can_do_optimization = False + + if not len(edgecolors): + stroked = False + else: + if np.all(np.asarray(linewidths) == 0.0): + stroked = False + elif np.all(edgecolors[:, 3] == edgecolors[0, 3]): + stroked = edgecolors[0, 3] != 0.0 + else: + can_do_optimization = False + + # Is the optimization worth it? Rough calculation: + # cost of emitting a path in-line is len_path * uses_per_path + # cost of XObject is len_path + 5 for the definition, + # uses_per_path for the uses + len_path = len(paths[0].vertices) if len(paths) > 0 else 0 + uses_per_path = self._iter_collection_uses_per_path( + paths, all_transforms, offsets, facecolors, edgecolors) + should_do_optimization = \ + len_path + uses_per_path + 5 < len_path * uses_per_path + + if (not can_do_optimization) or (not should_do_optimization): + return RendererBase.draw_path_collection( + self, gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position) + + padding = np.max(linewidths) + path_codes = [] + for i, (path, transform) in enumerate(self._iter_collection_raw_paths( + master_transform, paths, all_transforms)): + name = self.file.pathCollectionObject( + gc, path, transform, padding, filled, stroked) + path_codes.append(name) + + output = self.file.output + output(*self.gc.push()) + lastx, lasty = 0, 0 + for xo, yo, path_id, gc0, rgbFace in self._iter_collection( + gc, path_codes, offsets, offset_trans, + facecolors, edgecolors, linewidths, linestyles, + antialiaseds, urls, offset_position): + + self.check_gc(gc0, rgbFace) + dx, dy = xo - lastx, yo - lasty + output(1, 0, 0, 1, dx, dy, Op.concat_matrix, path_id, + Op.use_xobject) + lastx, lasty = xo, yo + output(*self.gc.pop()) + + def draw_markers(self, gc, marker_path, marker_trans, path, trans, + rgbFace=None): + # docstring inherited + + # Same logic as in draw_path_collection + len_marker_path = len(marker_path) + uses = len(path) + if len_marker_path * uses < len_marker_path + uses + 5: + RendererBase.draw_markers(self, gc, marker_path, marker_trans, + path, trans, rgbFace) + return + + self.check_gc(gc, rgbFace) + fill = gc.fill(rgbFace) + stroke = gc.stroke() + + output = self.file.output + marker = self.file.markerObject( + marker_path, marker_trans, fill, stroke, self.gc._linewidth, + gc.get_joinstyle(), gc.get_capstyle()) + + output(Op.gsave) + lastx, lasty = 0, 0 + for vertices, code in path.iter_segments( + trans, + clip=(0, 0, self.file.width*72, self.file.height*72), + simplify=False): + if len(vertices): + x, y = vertices[-2:] + if not (0 <= x <= self.file.width * 72 + and 0 <= y <= self.file.height * 72): + continue + dx, dy = x - lastx, y - lasty + output(1, 0, 0, 1, dx, dy, Op.concat_matrix, + marker, Op.use_xobject) + lastx, lasty = x, y + output(Op.grestore) + + def draw_gouraud_triangles(self, gc, points, colors, trans): + assert len(points) == len(colors) + if len(points) == 0: + return + assert points.ndim == 3 + assert points.shape[1] == 3 + assert points.shape[2] == 2 + assert colors.ndim == 3 + assert colors.shape[1] == 3 + assert colors.shape[2] in (1, 4) + + shape = points.shape + points = points.reshape((shape[0] * shape[1], 2)) + tpoints = trans.transform(points) + tpoints = tpoints.reshape(shape) + name, _ = self.file.addGouraudTriangles(tpoints, colors) + output = self.file.output + + if colors.shape[2] == 1: + # grayscale + gc.set_alpha(1.0) + self.check_gc(gc) + output(name, Op.shading) + return + + alpha = colors[0, 0, 3] + if np.allclose(alpha, colors[:, :, 3]): + # single alpha value + gc.set_alpha(alpha) + self.check_gc(gc) + output(name, Op.shading) + else: + # varying alpha: use a soft mask + alpha = colors[:, :, 3][:, :, None] + _, smask_ob = self.file.addGouraudTriangles(tpoints, alpha) + gstate = self.file._soft_mask_state(smask_ob) + output(Op.gsave, gstate, Op.setgstate, + name, Op.shading, + Op.grestore) + + def _setup_textpos(self, x, y, angle, oldx=0, oldy=0, oldangle=0): + if angle == oldangle == 0: + self.file.output(x - oldx, y - oldy, Op.textpos) + else: + angle = math.radians(angle) + self.file.output(math.cos(angle), math.sin(angle), + -math.sin(angle), math.cos(angle), + x, y, Op.textmatrix) + self.file.output(0, 0, Op.textpos) + + def draw_mathtext(self, gc, x, y, s, prop, angle): + # TODO: fix positioning and encoding + width, height, descent, glyphs, rects = \ + self._text2path.mathtext_parser.parse(s, 72, prop) + + if gc.get_url() is not None: + self.file._annotations[-1][1].append(_get_link_annotation( + gc, x, y, width, height, angle)) + + fonttype = mpl.rcParams['pdf.fonttype'] + + # Set up a global transformation matrix for the whole math expression + a = math.radians(angle) + self.file.output(Op.gsave) + self.file.output(math.cos(a), math.sin(a), + -math.sin(a), math.cos(a), + x, y, Op.concat_matrix) + + self.check_gc(gc, gc._rgb) + prev_font = None, None + oldx, oldy = 0, 0 + unsupported_chars = [] + + self.file.output(Op.begin_text) + for font, fontsize, num, ox, oy in glyphs: + self.file._character_tracker.track_glyph(font, num) + fontname = font.fname + if not _font_supports_glyph(fonttype, num): + # Unsupported chars (i.e. multibyte in Type 3 or beyond BMP in + # Type 42) must be emitted separately (below). + unsupported_chars.append((font, fontsize, ox, oy, num)) + else: + self._setup_textpos(ox, oy, 0, oldx, oldy) + oldx, oldy = ox, oy + if (fontname, fontsize) != prev_font: + self.file.output(self.file.fontName(fontname), fontsize, + Op.selectfont) + prev_font = fontname, fontsize + self.file.output(self.encode_string(chr(num), fonttype), + Op.show) + self.file.output(Op.end_text) + + for font, fontsize, ox, oy, num in unsupported_chars: + self._draw_xobject_glyph( + font, fontsize, font.get_char_index(num), ox, oy) + + # Draw any horizontal lines in the math layout + for ox, oy, width, height in rects: + self.file.output(Op.gsave, ox, oy, width, height, + Op.rectangle, Op.fill, Op.grestore) + + # Pop off the global transformation + self.file.output(Op.grestore) + + def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): + # docstring inherited + texmanager = self.get_texmanager() + fontsize = prop.get_size_in_points() + dvifile = texmanager.make_dvi(s, fontsize) + with dviread.Dvi(dvifile, 72) as dvi: + page, = dvi + + if gc.get_url() is not None: + self.file._annotations[-1][1].append(_get_link_annotation( + gc, x, y, page.width, page.height, angle)) + + # Gather font information and do some setup for combining + # characters into strings. The variable seq will contain a + # sequence of font and text entries. A font entry is a list + # ['font', name, size] where name is a Name object for the + # font. A text entry is ['text', x, y, glyphs, x+w] where x + # and y are the starting coordinates, w is the width, and + # glyphs is a list; in this phase it will always contain just + # one single-character string, but later it may have longer + # strings interspersed with kern amounts. + oldfont, seq = None, [] + for x1, y1, dvifont, glyph, width in page.text: + if dvifont != oldfont: + pdfname = self.file.dviFontName(dvifont) + seq += [['font', pdfname, dvifont.size]] + oldfont = dvifont + seq += [['text', x1, y1, [bytes([glyph])], x1+width]] + + # Find consecutive text strings with constant y coordinate and + # combine into a sequence of strings and kerns, or just one + # string (if any kerns would be less than 0.1 points). + i, curx, fontsize = 0, 0, None + while i < len(seq)-1: + elt, nxt = seq[i:i+2] + if elt[0] == 'font': + fontsize = elt[2] + elif elt[0] == nxt[0] == 'text' and elt[2] == nxt[2]: + offset = elt[4] - nxt[1] + if abs(offset) < 0.1: + elt[3][-1] += nxt[3][0] + elt[4] += nxt[4]-nxt[1] + else: + elt[3] += [offset*1000.0/fontsize, nxt[3][0]] + elt[4] = nxt[4] + del seq[i+1] + continue + i += 1 + + # Create a transform to map the dvi contents to the canvas. + mytrans = Affine2D().rotate_deg(angle).translate(x, y) + + # Output the text. + self.check_gc(gc, gc._rgb) + self.file.output(Op.begin_text) + curx, cury, oldx, oldy = 0, 0, 0, 0 + for elt in seq: + if elt[0] == 'font': + self.file.output(elt[1], elt[2], Op.selectfont) + elif elt[0] == 'text': + curx, cury = mytrans.transform((elt[1], elt[2])) + self._setup_textpos(curx, cury, angle, oldx, oldy) + oldx, oldy = curx, cury + if len(elt[3]) == 1: + self.file.output(elt[3][0], Op.show) + else: + self.file.output(elt[3], Op.showkern) + else: + assert False + self.file.output(Op.end_text) + + # Then output the boxes (e.g., variable-length lines of square + # roots). + boxgc = self.new_gc() + boxgc.copy_properties(gc) + boxgc.set_linewidth(0) + pathops = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, + Path.CLOSEPOLY] + for x1, y1, h, w in page.boxes: + path = Path([[x1, y1], [x1+w, y1], [x1+w, y1+h], [x1, y1+h], + [0, 0]], pathops) + self.draw_path(boxgc, path, mytrans, gc._rgb) + + def encode_string(self, s, fonttype): + if fonttype in (1, 3): + return s.encode('cp1252', 'replace') + return s.encode('utf-16be', 'replace') + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + # docstring inherited + + # TODO: combine consecutive texts into one BT/ET delimited section + + self.check_gc(gc, gc._rgb) + if ismath: + return self.draw_mathtext(gc, x, y, s, prop, angle) + + fontsize = prop.get_size_in_points() + + if mpl.rcParams['pdf.use14corefonts']: + font = self._get_font_afm(prop) + fonttype = 1 + else: + font = self._get_font_ttf(prop) + self.file._character_tracker.track(font, s) + fonttype = mpl.rcParams['pdf.fonttype'] + + if gc.get_url() is not None: + font.set_text(s) + width, height = font.get_width_height() + self.file._annotations[-1][1].append(_get_link_annotation( + gc, x, y, width / 64, height / 64, angle)) + + # If fonttype is neither 3 nor 42, emit the whole string at once + # without manual kerning. + if fonttype not in [3, 42]: + self.file.output(Op.begin_text, + self.file.fontName(prop), fontsize, Op.selectfont) + self._setup_textpos(x, y, angle) + self.file.output(self.encode_string(s, fonttype), + Op.show, Op.end_text) + + # A sequence of characters is broken into multiple chunks. The chunking + # serves two purposes: + # - For Type 3 fonts, there is no way to access multibyte characters, + # as they cannot have a CIDMap. Therefore, in this case we break + # the string into chunks, where each chunk contains either a string + # of consecutive 1-byte characters or a single multibyte character. + # - A sequence of 1-byte characters is split into chunks to allow for + # kerning adjustments between consecutive chunks. + # + # Each chunk is emitted with a separate command: 1-byte characters use + # the regular text show command (TJ) with appropriate kerning between + # chunks, whereas multibyte characters use the XObject command (Do). + else: + # List of (ft_object, start_x, [prev_kern, char, char, ...]), + # w/o zero kerns. + singlebyte_chunks = [] + # List of (ft_object, start_x, glyph_index). + multibyte_glyphs = [] + prev_was_multibyte = True + prev_font = font + for item in _text_helpers.layout(s, font, kern_mode=KERNING_UNFITTED): + if _font_supports_glyph(fonttype, ord(item.char)): + if prev_was_multibyte or item.ft_object != prev_font: + singlebyte_chunks.append((item.ft_object, item.x, [])) + prev_font = item.ft_object + if item.prev_kern: + singlebyte_chunks[-1][2].append(item.prev_kern) + singlebyte_chunks[-1][2].append(item.char) + prev_was_multibyte = False + else: + multibyte_glyphs.append((item.ft_object, item.x, item.glyph_idx)) + prev_was_multibyte = True + # Do the rotation and global translation as a single matrix + # concatenation up front + self.file.output(Op.gsave) + a = math.radians(angle) + self.file.output(math.cos(a), math.sin(a), + -math.sin(a), math.cos(a), + x, y, Op.concat_matrix) + # Emit all the 1-byte characters in a BT/ET group. + + self.file.output(Op.begin_text) + prev_start_x = 0 + for ft_object, start_x, kerns_or_chars in singlebyte_chunks: + ft_name = self.file.fontName(ft_object.fname) + self.file.output(ft_name, fontsize, Op.selectfont) + self._setup_textpos(start_x, 0, 0, prev_start_x, 0, 0) + self.file.output( + # See pdf spec "Text space details" for the 1000/fontsize + # (aka. 1000/T_fs) factor. + [-1000 * next(group) / fontsize if tp == float # a kern + else self.encode_string("".join(group), fonttype) + for tp, group in itertools.groupby(kerns_or_chars, type)], + Op.showkern) + prev_start_x = start_x + self.file.output(Op.end_text) + # Then emit all the multibyte characters, one at a time. + for ft_object, start_x, glyph_idx in multibyte_glyphs: + self._draw_xobject_glyph( + ft_object, fontsize, glyph_idx, start_x, 0 + ) + self.file.output(Op.grestore) + + def _draw_xobject_glyph(self, font, fontsize, glyph_idx, x, y): + """Draw a multibyte character from a Type 3 font as an XObject.""" + glyph_name = font.get_glyph_name(glyph_idx) + name = self.file._get_xobject_glyph_name(font.fname, glyph_name) + self.file.output( + Op.gsave, + 0.001 * fontsize, 0, 0, 0.001 * fontsize, x, y, Op.concat_matrix, + Name(name), Op.use_xobject, + Op.grestore, + ) + + def new_gc(self): + # docstring inherited + return GraphicsContextPdf(self.file) + + +class GraphicsContextPdf(GraphicsContextBase): + + def __init__(self, file): + super().__init__() + self._fillcolor = (0.0, 0.0, 0.0) + self._effective_alphas = (1.0, 1.0) + self.file = file + self.parent = None + + def __repr__(self): + d = dict(self.__dict__) + del d['file'] + del d['parent'] + return repr(d) + + def stroke(self): + """ + Predicate: does the path need to be stroked (its outline drawn)? + This tests for the various conditions that disable stroking + the path, in which case it would presumably be filled. + """ + # _linewidth > 0: in pdf a line of width 0 is drawn at minimum + # possible device width, but e.g., agg doesn't draw at all + return (self._linewidth > 0 and self._alpha > 0 and + (len(self._rgb) <= 3 or self._rgb[3] != 0.0)) + + def fill(self, *args): + """ + Predicate: does the path need to be filled? + + An optional argument can be used to specify an alternative + _fillcolor, as needed by RendererPdf.draw_markers. + """ + if len(args): + _fillcolor = args[0] + else: + _fillcolor = self._fillcolor + return (self._hatch or + (_fillcolor is not None and + (len(_fillcolor) <= 3 or _fillcolor[3] != 0.0))) + + def paint(self): + """ + Return the appropriate pdf operator to cause the path to be + stroked, filled, or both. + """ + return Op.paint_path(self.fill(), self.stroke()) + + capstyles = {'butt': 0, 'round': 1, 'projecting': 2} + joinstyles = {'miter': 0, 'round': 1, 'bevel': 2} + + def capstyle_cmd(self, style): + return [self.capstyles[style], Op.setlinecap] + + def joinstyle_cmd(self, style): + return [self.joinstyles[style], Op.setlinejoin] + + def linewidth_cmd(self, width): + return [width, Op.setlinewidth] + + def dash_cmd(self, dashes): + offset, dash = dashes + if dash is None: + dash = [] + offset = 0 + return [list(dash), offset, Op.setdash] + + def alpha_cmd(self, alpha, forced, effective_alphas): + name = self.file.alphaState(effective_alphas) + return [name, Op.setgstate] + + def hatch_cmd(self, hatch, hatch_color): + if not hatch: + if self._fillcolor is not None: + return self.fillcolor_cmd(self._fillcolor) + else: + return [Name('DeviceRGB'), Op.setcolorspace_nonstroke] + else: + hatch_style = (hatch_color, self._fillcolor, hatch) + name = self.file.hatchPattern(hatch_style) + return [Name('Pattern'), Op.setcolorspace_nonstroke, + name, Op.setcolor_nonstroke] + + def rgb_cmd(self, rgb): + if mpl.rcParams['pdf.inheritcolor']: + return [] + if rgb[0] == rgb[1] == rgb[2]: + return [rgb[0], Op.setgray_stroke] + else: + return [*rgb[:3], Op.setrgb_stroke] + + def fillcolor_cmd(self, rgb): + if rgb is None or mpl.rcParams['pdf.inheritcolor']: + return [] + elif rgb[0] == rgb[1] == rgb[2]: + return [rgb[0], Op.setgray_nonstroke] + else: + return [*rgb[:3], Op.setrgb_nonstroke] + + def push(self): + parent = GraphicsContextPdf(self.file) + parent.copy_properties(self) + parent.parent = self.parent + self.parent = parent + return [Op.gsave] + + def pop(self): + assert self.parent is not None + self.copy_properties(self.parent) + self.parent = self.parent.parent + return [Op.grestore] + + def clip_cmd(self, cliprect, clippath): + """Set clip rectangle. Calls `.pop()` and `.push()`.""" + cmds = [] + # Pop graphics state until we hit the right one or the stack is empty + while ((self._cliprect, self._clippath) != (cliprect, clippath) + and self.parent is not None): + cmds.extend(self.pop()) + # Unless we hit the right one, set the clip polygon + if ((self._cliprect, self._clippath) != (cliprect, clippath) or + self.parent is None): + cmds.extend(self.push()) + if self._cliprect != cliprect: + cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath]) + if self._clippath != clippath: + path, affine = clippath.get_transformed_path_and_affine() + cmds.extend( + PdfFile.pathOperations(path, affine, simplify=False) + + [Op.clip, Op.endpath]) + return cmds + + commands = ( + # must come first since may pop + (('_cliprect', '_clippath'), clip_cmd), + (('_alpha', '_forced_alpha', '_effective_alphas'), alpha_cmd), + (('_capstyle',), capstyle_cmd), + (('_fillcolor',), fillcolor_cmd), + (('_joinstyle',), joinstyle_cmd), + (('_linewidth',), linewidth_cmd), + (('_dashes',), dash_cmd), + (('_rgb',), rgb_cmd), + # must come after fillcolor and rgb + (('_hatch', '_hatch_color'), hatch_cmd), + ) + + def delta(self, other): + """ + Copy properties of other into self and return PDF commands + needed to transform *self* into *other*. + """ + cmds = [] + fill_performed = False + for params, cmd in self.commands: + different = False + for p in params: + ours = getattr(self, p) + theirs = getattr(other, p) + try: + if ours is None or theirs is None: + different = ours is not theirs + else: + different = bool(ours != theirs) + except ValueError: + ours = np.asarray(ours) + theirs = np.asarray(theirs) + different = (ours.shape != theirs.shape or + np.any(ours != theirs)) + if different: + break + + # Need to update hatching if we also updated fillcolor + if params == ('_hatch', '_hatch_color') and fill_performed: + different = True + + if different: + if params == ('_fillcolor',): + fill_performed = True + theirs = [getattr(other, p) for p in params] + cmds.extend(cmd(self, *theirs)) + for p in params: + setattr(self, p, getattr(other, p)) + return cmds + + def copy_properties(self, other): + """ + Copy properties of other into self. + """ + super().copy_properties(other) + fillcolor = getattr(other, '_fillcolor', self._fillcolor) + effective_alphas = getattr(other, '_effective_alphas', + self._effective_alphas) + self._fillcolor = fillcolor + self._effective_alphas = effective_alphas + + def finalize(self): + """ + Make sure every pushed graphics state is popped. + """ + cmds = [] + while self.parent is not None: + cmds.extend(self.pop()) + return cmds + + +class PdfPages: + """ + A multi-page PDF file. + + Examples + -------- + >>> import matplotlib.pyplot as plt + >>> # Initialize: + >>> with PdfPages('foo.pdf') as pdf: + ... # As many times as you like, create a figure fig and save it: + ... fig = plt.figure() + ... pdf.savefig(fig) + ... # When no figure is specified the current figure is saved + ... pdf.savefig() + + Notes + ----- + In reality `PdfPages` is a thin wrapper around `PdfFile`, in order to avoid + confusion when using `~.pyplot.savefig` and forgetting the format argument. + """ + + _UNSET = object() + + def __init__(self, filename, keep_empty=_UNSET, metadata=None): + """ + Create a new PdfPages object. + + Parameters + ---------- + filename : str or path-like or file-like + Plots using `PdfPages.savefig` will be written to a file at this location. + The file is opened when a figure is saved for the first time (overwriting + any older file with the same name). + + keep_empty : bool, optional + If set to False, then empty pdf files will be deleted automatically + when closed. + + metadata : dict, optional + Information dictionary object (see PDF reference section 10.2.1 + 'Document Information Dictionary'), e.g.: + ``{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}``. + + The standard keys are 'Title', 'Author', 'Subject', 'Keywords', + 'Creator', 'Producer', 'CreationDate', 'ModDate', and + 'Trapped'. Values have been predefined for 'Creator', 'Producer' + and 'CreationDate'. They can be removed by setting them to `None`. + """ + self._filename = filename + self._metadata = metadata + self._file = None + if keep_empty and keep_empty is not self._UNSET: + _api.warn_deprecated("3.8", message=( + "Keeping empty pdf files is deprecated since %(since)s and support " + "will be removed %(removal)s.")) + self._keep_empty = keep_empty + + keep_empty = _api.deprecate_privatize_attribute("3.8") + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + + def _ensure_file(self): + if self._file is None: + self._file = PdfFile(self._filename, metadata=self._metadata) # init. + return self._file + + def close(self): + """ + Finalize this object, making the underlying file a complete + PDF file. + """ + if self._file is not None: + self._file.finalize() + self._file.close() + self._file = None + elif self._keep_empty: # True *or* UNSET. + _api.warn_deprecated("3.8", message=( + "Keeping empty pdf files is deprecated since %(since)s and support " + "will be removed %(removal)s.")) + PdfFile(self._filename, metadata=self._metadata).close() # touch the file. + + def infodict(self): + """ + Return a modifiable information dictionary object + (see PDF reference section 10.2.1 'Document Information + Dictionary'). + """ + return self._ensure_file().infoDict + + def savefig(self, figure=None, **kwargs): + """ + Save a `.Figure` to this file as a new page. + + Any other keyword arguments are passed to `~.Figure.savefig`. + + Parameters + ---------- + figure : `.Figure` or int, default: the active figure + The figure, or index of the figure, that is saved to the file. + """ + if not isinstance(figure, Figure): + if figure is None: + manager = Gcf.get_active() + else: + manager = Gcf.get_fig_manager(figure) + if manager is None: + raise ValueError(f"No figure {figure}") + figure = manager.canvas.figure + # Force use of pdf backend, as PdfPages is tightly coupled with it. + figure.savefig(self, format="pdf", backend="pdf", **kwargs) + + def get_pagecount(self): + """Return the current number of pages in the multipage pdf file.""" + return len(self._ensure_file().pageList) + + def attach_note(self, text, positionRect=[-100, -100, 0, 0]): + """ + Add a new text note to the page to be saved next. The optional + positionRect specifies the position of the new note on the + page. It is outside the page per default to make sure it is + invisible on printouts. + """ + self._ensure_file().newTextnote(text, positionRect) + + +class FigureCanvasPdf(FigureCanvasBase): + # docstring inherited + + fixed_dpi = 72 + filetypes = {'pdf': 'Portable Document Format'} + + def get_default_filetype(self): + return 'pdf' + + def print_pdf(self, filename, *, + bbox_inches_restore=None, metadata=None): + + dpi = self.figure.dpi + self.figure.dpi = 72 # there are 72 pdf points to an inch + width, height = self.figure.get_size_inches() + if isinstance(filename, PdfPages): + file = filename._ensure_file() + else: + file = PdfFile(filename, metadata=metadata) + try: + file.newPage(width, height) + renderer = MixedModeRenderer( + self.figure, width, height, dpi, + RendererPdf(file, dpi, height, width), + bbox_inches_restore=bbox_inches_restore) + self.figure.draw(renderer) + renderer.finalize() + if not isinstance(filename, PdfPages): + file.finalize() + finally: + if isinstance(filename, PdfPages): # finish off this page + file.endStream() + else: # we opened the file above; now finish it off + file.close() + + def draw(self): + self.figure.draw_without_rendering() + return super().draw() + + +FigureManagerPdf = FigureManagerBase + + +@_Backend.export +class _BackendPdf(_Backend): + FigureCanvas = FigureCanvasPdf diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pgf.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pgf.py new file mode 100644 index 00000000..9705f5fc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_pgf.py @@ -0,0 +1,1012 @@ +import codecs +import datetime +import functools +from io import BytesIO +import logging +import math +import os +import pathlib +import shutil +import subprocess +from tempfile import TemporaryDirectory +import weakref + +from PIL import Image + +import matplotlib as mpl +from matplotlib import _api, cbook, font_manager as fm +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, RendererBase +) +from matplotlib.backends.backend_mixed import MixedModeRenderer +from matplotlib.backends.backend_pdf import ( + _create_pdf_info_dict, _datetime_to_pdf) +from matplotlib.path import Path +from matplotlib.figure import Figure +from matplotlib._pylab_helpers import Gcf + +_log = logging.getLogger(__name__) + + +# Note: When formatting floating point values, it is important to use the +# %f/{:f} format rather than %s/{} to avoid triggering scientific notation, +# which is not recognized by TeX. + +def _get_preamble(): + """Prepare a LaTeX preamble based on the rcParams configuration.""" + return "\n".join([ + # Remove Matplotlib's custom command \mathdefault. (Not using + # \mathnormal instead since this looks odd with Computer Modern.) + r"\def\mathdefault#1{#1}", + # Use displaystyle for all math. + r"\everymath=\expandafter{\the\everymath\displaystyle}", + # Allow pgf.preamble to override the above definitions. + mpl.rcParams["pgf.preamble"], + r"\ifdefined\pdftexversion\else % non-pdftex case.", + r" \usepackage{fontspec}", + *([ + r" \%s{%s}[Path=\detokenize{%s/}]" + % (command, path.name, path.parent.as_posix()) + for command, path in zip( + ["setmainfont", "setsansfont", "setmonofont"], + [pathlib.Path(fm.findfont(family)) + for family in ["serif", "sans\\-serif", "monospace"]] + ) + ] if mpl.rcParams["pgf.rcfonts"] else []), + r"\fi", + # Documented as "must come last". + mpl.texmanager._usepackage_if_not_loaded("underscore", option="strings"), + ]) + + +# It's better to use only one unit for all coordinates, since the +# arithmetic in latex seems to produce inaccurate conversions. +latex_pt_to_in = 1. / 72.27 +latex_in_to_pt = 1. / latex_pt_to_in +mpl_pt_to_in = 1. / 72. +mpl_in_to_pt = 1. / mpl_pt_to_in + + +def _tex_escape(text): + r""" + Do some necessary and/or useful substitutions for texts to be included in + LaTeX documents. + """ + return text.replace("\N{MINUS SIGN}", r"\ensuremath{-}") + + +def _writeln(fh, line): + # Ending lines with a % prevents TeX from inserting spurious spaces + # (https://tex.stackexchange.com/questions/7453). + fh.write(line) + fh.write("%\n") + + +def _escape_and_apply_props(s, prop): + """ + Generate a TeX string that renders string *s* with font properties *prop*, + also applying any required escapes to *s*. + """ + commands = [] + + families = {"serif": r"\rmfamily", "sans": r"\sffamily", + "sans-serif": r"\sffamily", "monospace": r"\ttfamily"} + family = prop.get_family()[0] + if family in families: + commands.append(families[family]) + elif any(font.name == family for font in fm.fontManager.ttflist): + commands.append( + r"\ifdefined\pdftexversion\else\setmainfont{%s}\rmfamily\fi" % family) + else: + _log.warning("Ignoring unknown font: %s", family) + + size = prop.get_size_in_points() + commands.append(r"\fontsize{%f}{%f}" % (size, size * 1.2)) + + styles = {"normal": r"", "italic": r"\itshape", "oblique": r"\slshape"} + commands.append(styles[prop.get_style()]) + + boldstyles = ["semibold", "demibold", "demi", "bold", "heavy", + "extra bold", "black"] + if prop.get_weight() in boldstyles: + commands.append(r"\bfseries") + + commands.append(r"\selectfont") + return ( + "{" + + "".join(commands) + + r"\catcode`\^=\active\def^{\ifmmode\sp\else\^{}\fi}" + # It should normally be enough to set the catcode of % to 12 ("normal + # character"); this works on TeXLive 2021 but not on 2018, so we just + # make it active too. + + r"\catcode`\%=\active\def%{\%}" + + _tex_escape(s) + + "}" + ) + + +def _metadata_to_str(key, value): + """Convert metadata key/value to a form that hyperref accepts.""" + if isinstance(value, datetime.datetime): + value = _datetime_to_pdf(value) + elif key == 'Trapped': + value = value.name.decode('ascii') + else: + value = str(value) + return f'{key}={{{value}}}' + + +def make_pdf_to_png_converter(): + """Return a function that converts a pdf file to a png file.""" + try: + mpl._get_executable_info("pdftocairo") + except mpl.ExecutableNotFoundError: + pass + else: + return lambda pdffile, pngfile, dpi: subprocess.check_output( + ["pdftocairo", "-singlefile", "-transp", "-png", "-r", "%d" % dpi, + pdffile, os.path.splitext(pngfile)[0]], + stderr=subprocess.STDOUT) + try: + gs_info = mpl._get_executable_info("gs") + except mpl.ExecutableNotFoundError: + pass + else: + return lambda pdffile, pngfile, dpi: subprocess.check_output( + [gs_info.executable, + '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT', + '-dUseCIEColor', '-dTextAlphaBits=4', + '-dGraphicsAlphaBits=4', '-dDOINTERPOLATE', + '-sDEVICE=pngalpha', '-sOutputFile=%s' % pngfile, + '-r%d' % dpi, pdffile], + stderr=subprocess.STDOUT) + raise RuntimeError("No suitable pdf to png renderer found.") + + +class LatexError(Exception): + def __init__(self, message, latex_output=""): + super().__init__(message) + self.latex_output = latex_output + + def __str__(self): + s, = self.args + if self.latex_output: + s += "\n" + self.latex_output + return s + + +class LatexManager: + """ + The LatexManager opens an instance of the LaTeX application for + determining the metrics of text elements. The LaTeX environment can be + modified by setting fonts and/or a custom preamble in `.rcParams`. + """ + + @staticmethod + def _build_latex_header(): + latex_header = [ + r"\documentclass{article}", + # Include TeX program name as a comment for cache invalidation. + # TeX does not allow this to be the first line. + rf"% !TeX program = {mpl.rcParams['pgf.texsystem']}", + # Test whether \includegraphics supports interpolate option. + r"\usepackage{graphicx}", + _get_preamble(), + r"\begin{document}", + r"\typeout{pgf_backend_query_start}", + ] + return "\n".join(latex_header) + + @classmethod + def _get_cached_or_new(cls): + """ + Return the previous LatexManager if the header and tex system did not + change, or a new instance otherwise. + """ + return cls._get_cached_or_new_impl(cls._build_latex_header()) + + @classmethod + @functools.lru_cache(1) + def _get_cached_or_new_impl(cls, header): # Helper for _get_cached_or_new. + return cls() + + def _stdin_writeln(self, s): + if self.latex is None: + self._setup_latex_process() + self.latex.stdin.write(s) + self.latex.stdin.write("\n") + self.latex.stdin.flush() + + def _expect(self, s): + s = list(s) + chars = [] + while True: + c = self.latex.stdout.read(1) + chars.append(c) + if chars[-len(s):] == s: + break + if not c: + self.latex.kill() + self.latex = None + raise LatexError("LaTeX process halted", "".join(chars)) + return "".join(chars) + + def _expect_prompt(self): + return self._expect("\n*") + + def __init__(self): + # create a tmp directory for running latex, register it for deletion + self._tmpdir = TemporaryDirectory() + self.tmpdir = self._tmpdir.name + self._finalize_tmpdir = weakref.finalize(self, self._tmpdir.cleanup) + + # test the LaTeX setup to ensure a clean startup of the subprocess + self._setup_latex_process(expect_reply=False) + stdout, stderr = self.latex.communicate("\n\\makeatletter\\@@end\n") + if self.latex.returncode != 0: + raise LatexError( + f"LaTeX errored (probably missing font or error in preamble) " + f"while processing the following input:\n" + f"{self._build_latex_header()}", + stdout) + self.latex = None # Will be set up on first use. + # Per-instance cache. + self._get_box_metrics = functools.lru_cache(self._get_box_metrics) + + def _setup_latex_process(self, *, expect_reply=True): + # Open LaTeX process for real work; register it for deletion. On + # Windows, we must ensure that the subprocess has quit before being + # able to delete the tmpdir in which it runs; in order to do so, we + # must first `kill()` it, and then `communicate()` with or `wait()` on + # it. + try: + self.latex = subprocess.Popen( + [mpl.rcParams["pgf.texsystem"], "-halt-on-error"], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + encoding="utf-8", cwd=self.tmpdir) + except FileNotFoundError as err: + raise RuntimeError( + f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change " + f"rcParams['pgf.texsystem'] to an available TeX implementation" + ) from err + except OSError as err: + raise RuntimeError( + f"Error starting {mpl.rcParams['pgf.texsystem']!r}") from err + + def finalize_latex(latex): + latex.kill() + try: + latex.communicate() + except RuntimeError: + latex.wait() + + self._finalize_latex = weakref.finalize( + self, finalize_latex, self.latex) + # write header with 'pgf_backend_query_start' token + self._stdin_writeln(self._build_latex_header()) + if expect_reply: # read until 'pgf_backend_query_start' token appears + self._expect("*pgf_backend_query_start") + self._expect_prompt() + + def get_width_height_descent(self, text, prop): + """ + Get the width, total height, and descent (in TeX points) for a text + typeset by the current LaTeX environment. + """ + return self._get_box_metrics(_escape_and_apply_props(text, prop)) + + def _get_box_metrics(self, tex): + """ + Get the width, total height and descent (in TeX points) for a TeX + command's output in the current LaTeX environment. + """ + # This method gets wrapped in __init__ for per-instance caching. + self._stdin_writeln( # Send textbox to TeX & request metrics typeout. + # \sbox doesn't handle catcode assignments inside its argument, + # so repeat the assignment of the catcode of "^" and "%" outside. + r"{\catcode`\^=\active\catcode`\%%=\active\sbox0{%s}" + r"\typeout{\the\wd0,\the\ht0,\the\dp0}}" + % tex) + try: + answer = self._expect_prompt() + except LatexError as err: + # Here and below, use '{}' instead of {!r} to avoid doubling all + # backslashes. + raise ValueError("Error measuring {}\nLaTeX Output:\n{}" + .format(tex, err.latex_output)) from err + try: + # Parse metrics from the answer string. Last line is prompt, and + # next-to-last-line is blank line from \typeout. + width, height, offset = answer.splitlines()[-3].split(",") + except Exception as err: + raise ValueError("Error measuring {}\nLaTeX Output:\n{}" + .format(tex, answer)) from err + w, h, o = float(width[:-2]), float(height[:-2]), float(offset[:-2]) + # The height returned from LaTeX goes from base to top; + # the height Matplotlib expects goes from bottom to top. + return w, h + o, o + + +@functools.lru_cache(1) +def _get_image_inclusion_command(): + man = LatexManager._get_cached_or_new() + man._stdin_writeln( + r"\includegraphics[interpolate=true]{%s}" + # Don't mess with backslashes on Windows. + % cbook._get_data_path("images/matplotlib.png").as_posix()) + try: + man._expect_prompt() + return r"\includegraphics" + except LatexError: + # Discard the broken manager. + LatexManager._get_cached_or_new_impl.cache_clear() + return r"\pgfimage" + + +class RendererPgf(RendererBase): + + def __init__(self, figure, fh): + """ + Create a new PGF renderer that translates any drawing instruction + into text commands to be interpreted in a latex pgfpicture environment. + + Attributes + ---------- + figure : `~matplotlib.figure.Figure` + Matplotlib figure to initialize height, width and dpi from. + fh : file-like + File handle for the output of the drawing commands. + """ + + super().__init__() + self.dpi = figure.dpi + self.fh = fh + self.figure = figure + self.image_counter = 0 + + def draw_markers(self, gc, marker_path, marker_trans, path, trans, + rgbFace=None): + # docstring inherited + + _writeln(self.fh, r"\begin{pgfscope}") + + # convert from display units to in + f = 1. / self.dpi + + # set style and clip + self._print_pgf_clip(gc) + self._print_pgf_path_styles(gc, rgbFace) + + # build marker definition + bl, tr = marker_path.get_extents(marker_trans).get_points() + coords = bl[0] * f, bl[1] * f, tr[0] * f, tr[1] * f + _writeln(self.fh, + r"\pgfsys@defobject{currentmarker}" + r"{\pgfqpoint{%fin}{%fin}}{\pgfqpoint{%fin}{%fin}}{" % coords) + self._print_pgf_path(None, marker_path, marker_trans) + self._pgf_path_draw(stroke=gc.get_linewidth() != 0.0, + fill=rgbFace is not None) + _writeln(self.fh, r"}") + + maxcoord = 16383 / 72.27 * self.dpi # Max dimensions in LaTeX. + clip = (-maxcoord, -maxcoord, maxcoord, maxcoord) + + # draw marker for each vertex + for point, code in path.iter_segments(trans, simplify=False, + clip=clip): + x, y = point[0] * f, point[1] * f + _writeln(self.fh, r"\begin{pgfscope}") + _writeln(self.fh, r"\pgfsys@transformshift{%fin}{%fin}" % (x, y)) + _writeln(self.fh, r"\pgfsys@useobject{currentmarker}{}") + _writeln(self.fh, r"\end{pgfscope}") + + _writeln(self.fh, r"\end{pgfscope}") + + def draw_path(self, gc, path, transform, rgbFace=None): + # docstring inherited + _writeln(self.fh, r"\begin{pgfscope}") + # draw the path + self._print_pgf_clip(gc) + self._print_pgf_path_styles(gc, rgbFace) + self._print_pgf_path(gc, path, transform, rgbFace) + self._pgf_path_draw(stroke=gc.get_linewidth() != 0.0, + fill=rgbFace is not None) + _writeln(self.fh, r"\end{pgfscope}") + + # if present, draw pattern on top + if gc.get_hatch(): + _writeln(self.fh, r"\begin{pgfscope}") + self._print_pgf_path_styles(gc, rgbFace) + + # combine clip and path for clipping + self._print_pgf_clip(gc) + self._print_pgf_path(gc, path, transform, rgbFace) + _writeln(self.fh, r"\pgfusepath{clip}") + + # build pattern definition + _writeln(self.fh, + r"\pgfsys@defobject{currentpattern}" + r"{\pgfqpoint{0in}{0in}}{\pgfqpoint{1in}{1in}}{") + _writeln(self.fh, r"\begin{pgfscope}") + _writeln(self.fh, + r"\pgfpathrectangle" + r"{\pgfqpoint{0in}{0in}}{\pgfqpoint{1in}{1in}}") + _writeln(self.fh, r"\pgfusepath{clip}") + scale = mpl.transforms.Affine2D().scale(self.dpi) + self._print_pgf_path(None, gc.get_hatch_path(), scale) + self._pgf_path_draw(stroke=True) + _writeln(self.fh, r"\end{pgfscope}") + _writeln(self.fh, r"}") + # repeat pattern, filling the bounding rect of the path + f = 1. / self.dpi + (xmin, ymin), (xmax, ymax) = \ + path.get_extents(transform).get_points() + xmin, xmax = f * xmin, f * xmax + ymin, ymax = f * ymin, f * ymax + repx, repy = math.ceil(xmax - xmin), math.ceil(ymax - ymin) + _writeln(self.fh, + r"\pgfsys@transformshift{%fin}{%fin}" % (xmin, ymin)) + for iy in range(repy): + for ix in range(repx): + _writeln(self.fh, r"\pgfsys@useobject{currentpattern}{}") + _writeln(self.fh, r"\pgfsys@transformshift{1in}{0in}") + _writeln(self.fh, r"\pgfsys@transformshift{-%din}{0in}" % repx) + _writeln(self.fh, r"\pgfsys@transformshift{0in}{1in}") + + _writeln(self.fh, r"\end{pgfscope}") + + def _print_pgf_clip(self, gc): + f = 1. / self.dpi + # check for clip box + bbox = gc.get_clip_rectangle() + if bbox: + p1, p2 = bbox.get_points() + w, h = p2 - p1 + coords = p1[0] * f, p1[1] * f, w * f, h * f + _writeln(self.fh, + r"\pgfpathrectangle" + r"{\pgfqpoint{%fin}{%fin}}{\pgfqpoint{%fin}{%fin}}" + % coords) + _writeln(self.fh, r"\pgfusepath{clip}") + + # check for clip path + clippath, clippath_trans = gc.get_clip_path() + if clippath is not None: + self._print_pgf_path(gc, clippath, clippath_trans) + _writeln(self.fh, r"\pgfusepath{clip}") + + def _print_pgf_path_styles(self, gc, rgbFace): + # cap style + capstyles = {"butt": r"\pgfsetbuttcap", + "round": r"\pgfsetroundcap", + "projecting": r"\pgfsetrectcap"} + _writeln(self.fh, capstyles[gc.get_capstyle()]) + + # join style + joinstyles = {"miter": r"\pgfsetmiterjoin", + "round": r"\pgfsetroundjoin", + "bevel": r"\pgfsetbeveljoin"} + _writeln(self.fh, joinstyles[gc.get_joinstyle()]) + + # filling + has_fill = rgbFace is not None + + if gc.get_forced_alpha(): + fillopacity = strokeopacity = gc.get_alpha() + else: + strokeopacity = gc.get_rgb()[3] + fillopacity = rgbFace[3] if has_fill and len(rgbFace) > 3 else 1.0 + + if has_fill: + _writeln(self.fh, + r"\definecolor{currentfill}{rgb}{%f,%f,%f}" + % tuple(rgbFace[:3])) + _writeln(self.fh, r"\pgfsetfillcolor{currentfill}") + if has_fill and fillopacity != 1.0: + _writeln(self.fh, r"\pgfsetfillopacity{%f}" % fillopacity) + + # linewidth and color + lw = gc.get_linewidth() * mpl_pt_to_in * latex_in_to_pt + stroke_rgba = gc.get_rgb() + _writeln(self.fh, r"\pgfsetlinewidth{%fpt}" % lw) + _writeln(self.fh, + r"\definecolor{currentstroke}{rgb}{%f,%f,%f}" + % stroke_rgba[:3]) + _writeln(self.fh, r"\pgfsetstrokecolor{currentstroke}") + if strokeopacity != 1.0: + _writeln(self.fh, r"\pgfsetstrokeopacity{%f}" % strokeopacity) + + # line style + dash_offset, dash_list = gc.get_dashes() + if dash_list is None: + _writeln(self.fh, r"\pgfsetdash{}{0pt}") + else: + _writeln(self.fh, + r"\pgfsetdash{%s}{%fpt}" + % ("".join(r"{%fpt}" % dash for dash in dash_list), + dash_offset)) + + def _print_pgf_path(self, gc, path, transform, rgbFace=None): + f = 1. / self.dpi + # check for clip box / ignore clip for filled paths + bbox = gc.get_clip_rectangle() if gc else None + maxcoord = 16383 / 72.27 * self.dpi # Max dimensions in LaTeX. + if bbox and (rgbFace is None): + p1, p2 = bbox.get_points() + clip = (max(p1[0], -maxcoord), max(p1[1], -maxcoord), + min(p2[0], maxcoord), min(p2[1], maxcoord)) + else: + clip = (-maxcoord, -maxcoord, maxcoord, maxcoord) + # build path + for points, code in path.iter_segments(transform, clip=clip): + if code == Path.MOVETO: + x, y = tuple(points) + _writeln(self.fh, + r"\pgfpathmoveto{\pgfqpoint{%fin}{%fin}}" % + (f * x, f * y)) + elif code == Path.CLOSEPOLY: + _writeln(self.fh, r"\pgfpathclose") + elif code == Path.LINETO: + x, y = tuple(points) + _writeln(self.fh, + r"\pgfpathlineto{\pgfqpoint{%fin}{%fin}}" % + (f * x, f * y)) + elif code == Path.CURVE3: + cx, cy, px, py = tuple(points) + coords = cx * f, cy * f, px * f, py * f + _writeln(self.fh, + r"\pgfpathquadraticcurveto" + r"{\pgfqpoint{%fin}{%fin}}{\pgfqpoint{%fin}{%fin}}" + % coords) + elif code == Path.CURVE4: + c1x, c1y, c2x, c2y, px, py = tuple(points) + coords = c1x * f, c1y * f, c2x * f, c2y * f, px * f, py * f + _writeln(self.fh, + r"\pgfpathcurveto" + r"{\pgfqpoint{%fin}{%fin}}" + r"{\pgfqpoint{%fin}{%fin}}" + r"{\pgfqpoint{%fin}{%fin}}" + % coords) + + # apply pgf decorators + sketch_params = gc.get_sketch_params() if gc else None + if sketch_params is not None: + # Only "length" directly maps to "segment length" in PGF's API. + # PGF uses "amplitude" to pass the combined deviation in both x- + # and y-direction, while matplotlib only varies the length of the + # wiggle along the line ("randomness" and "length" parameters) + # and has a separate "scale" argument for the amplitude. + # -> Use "randomness" as PRNG seed to allow the user to force the + # same shape on multiple sketched lines + scale, length, randomness = sketch_params + if scale is not None: + # make matplotlib and PGF rendering visually similar + length *= 0.5 + scale *= 2 + # PGF guarantees that repeated loading is a no-op + _writeln(self.fh, r"\usepgfmodule{decorations}") + _writeln(self.fh, r"\usepgflibrary{decorations.pathmorphing}") + _writeln(self.fh, r"\pgfkeys{/pgf/decoration/.cd, " + f"segment length = {(length * f):f}in, " + f"amplitude = {(scale * f):f}in}}") + _writeln(self.fh, f"\\pgfmathsetseed{{{int(randomness)}}}") + _writeln(self.fh, r"\pgfdecoratecurrentpath{random steps}") + + def _pgf_path_draw(self, stroke=True, fill=False): + actions = [] + if stroke: + actions.append("stroke") + if fill: + actions.append("fill") + _writeln(self.fh, r"\pgfusepath{%s}" % ",".join(actions)) + + def option_scale_image(self): + # docstring inherited + return True + + def option_image_nocomposite(self): + # docstring inherited + return not mpl.rcParams['image.composite_image'] + + def draw_image(self, gc, x, y, im, transform=None): + # docstring inherited + + h, w = im.shape[:2] + if w == 0 or h == 0: + return + + if not os.path.exists(getattr(self.fh, "name", "")): + raise ValueError( + "streamed pgf-code does not support raster graphics, consider " + "using the pgf-to-pdf option") + + # save the images to png files + path = pathlib.Path(self.fh.name) + fname_img = "%s-img%d.png" % (path.stem, self.image_counter) + Image.fromarray(im[::-1]).save(path.parent / fname_img) + self.image_counter += 1 + + # reference the image in the pgf picture + _writeln(self.fh, r"\begin{pgfscope}") + self._print_pgf_clip(gc) + f = 1. / self.dpi # from display coords to inch + if transform is None: + _writeln(self.fh, + r"\pgfsys@transformshift{%fin}{%fin}" % (x * f, y * f)) + w, h = w * f, h * f + else: + tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values() + _writeln(self.fh, + r"\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}" % + (tr1 * f, tr2 * f, tr3 * f, tr4 * f, + (tr5 + x) * f, (tr6 + y) * f)) + w = h = 1 # scale is already included in the transform + interp = str(transform is None).lower() # interpolation in PDF reader + _writeln(self.fh, + r"\pgftext[left,bottom]" + r"{%s[interpolate=%s,width=%fin,height=%fin]{%s}}" % + (_get_image_inclusion_command(), + interp, w, h, fname_img)) + _writeln(self.fh, r"\end{pgfscope}") + + def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): + # docstring inherited + self.draw_text(gc, x, y, s, prop, angle, ismath="TeX", mtext=mtext) + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + # docstring inherited + + # prepare string for tex + s = _escape_and_apply_props(s, prop) + + _writeln(self.fh, r"\begin{pgfscope}") + self._print_pgf_clip(gc) + + alpha = gc.get_alpha() + if alpha != 1.0: + _writeln(self.fh, r"\pgfsetfillopacity{%f}" % alpha) + _writeln(self.fh, r"\pgfsetstrokeopacity{%f}" % alpha) + rgb = tuple(gc.get_rgb())[:3] + _writeln(self.fh, r"\definecolor{textcolor}{rgb}{%f,%f,%f}" % rgb) + _writeln(self.fh, r"\pgfsetstrokecolor{textcolor}") + _writeln(self.fh, r"\pgfsetfillcolor{textcolor}") + s = r"\color{textcolor}" + s + + dpi = self.figure.dpi + text_args = [] + if mtext and ( + (angle == 0 or + mtext.get_rotation_mode() == "anchor") and + mtext.get_verticalalignment() != "center_baseline"): + # if text anchoring can be supported, get the original coordinates + # and add alignment information + pos = mtext.get_unitless_position() + x, y = mtext.get_transform().transform(pos) + halign = {"left": "left", "right": "right", "center": ""} + valign = {"top": "top", "bottom": "bottom", + "baseline": "base", "center": ""} + text_args.extend([ + f"x={x/dpi:f}in", + f"y={y/dpi:f}in", + halign[mtext.get_horizontalalignment()], + valign[mtext.get_verticalalignment()], + ]) + else: + # if not, use the text layout provided by Matplotlib. + text_args.append(f"x={x/dpi:f}in, y={y/dpi:f}in, left, base") + + if angle != 0: + text_args.append("rotate=%f" % angle) + + _writeln(self.fh, r"\pgftext[%s]{%s}" % (",".join(text_args), s)) + _writeln(self.fh, r"\end{pgfscope}") + + def get_text_width_height_descent(self, s, prop, ismath): + # docstring inherited + # get text metrics in units of latex pt, convert to display units + w, h, d = (LatexManager._get_cached_or_new() + .get_width_height_descent(s, prop)) + # TODO: this should be latex_pt_to_in instead of mpl_pt_to_in + # but having a little bit more space around the text looks better, + # plus the bounding box reported by LaTeX is VERY narrow + f = mpl_pt_to_in * self.dpi + return w * f, h * f, d * f + + def flipy(self): + # docstring inherited + return False + + def get_canvas_width_height(self): + # docstring inherited + return (self.figure.get_figwidth() * self.dpi, + self.figure.get_figheight() * self.dpi) + + def points_to_pixels(self, points): + # docstring inherited + return points * mpl_pt_to_in * self.dpi + + +class FigureCanvasPgf(FigureCanvasBase): + filetypes = {"pgf": "LaTeX PGF picture", + "pdf": "LaTeX compiled PGF picture", + "png": "Portable Network Graphics", } + + def get_default_filetype(self): + return 'pdf' + + def _print_pgf_to_fh(self, fh, *, bbox_inches_restore=None): + + header_text = """%% Creator: Matplotlib, PGF backend +%% +%% To include the figure in your LaTeX document, write +%% \\input{.pgf} +%% +%% Make sure the required packages are loaded in your preamble +%% \\usepackage{pgf} +%% +%% Also ensure that all the required font packages are loaded; for instance, +%% the lmodern package is sometimes necessary when using math font. +%% \\usepackage{lmodern} +%% +%% Figures using additional raster images can only be included by \\input if +%% they are in the same directory as the main LaTeX file. For loading figures +%% from other directories you can use the `import` package +%% \\usepackage{import} +%% +%% and then include the figures with +%% \\import{}{.pgf} +%% +""" + + # append the preamble used by the backend as a comment for debugging + header_info_preamble = ["%% Matplotlib used the following preamble"] + for line in _get_preamble().splitlines(): + header_info_preamble.append("%% " + line) + header_info_preamble.append("%%") + header_info_preamble = "\n".join(header_info_preamble) + + # get figure size in inch + w, h = self.figure.get_figwidth(), self.figure.get_figheight() + dpi = self.figure.dpi + + # create pgfpicture environment and write the pgf code + fh.write(header_text) + fh.write(header_info_preamble) + fh.write("\n") + _writeln(fh, r"\begingroup") + _writeln(fh, r"\makeatletter") + _writeln(fh, r"\begin{pgfpicture}") + _writeln(fh, + r"\pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{%fin}{%fin}}" + % (w, h)) + _writeln(fh, r"\pgfusepath{use as bounding box, clip}") + renderer = MixedModeRenderer(self.figure, w, h, dpi, + RendererPgf(self.figure, fh), + bbox_inches_restore=bbox_inches_restore) + self.figure.draw(renderer) + + # end the pgfpicture environment + _writeln(fh, r"\end{pgfpicture}") + _writeln(fh, r"\makeatother") + _writeln(fh, r"\endgroup") + + def print_pgf(self, fname_or_fh, **kwargs): + """ + Output pgf macros for drawing the figure so it can be included and + rendered in latex documents. + """ + with cbook.open_file_cm(fname_or_fh, "w", encoding="utf-8") as file: + if not cbook.file_requires_unicode(file): + file = codecs.getwriter("utf-8")(file) + self._print_pgf_to_fh(file, **kwargs) + + def print_pdf(self, fname_or_fh, *, metadata=None, **kwargs): + """Use LaTeX to compile a pgf generated figure to pdf.""" + w, h = self.figure.get_size_inches() + + info_dict = _create_pdf_info_dict('pgf', metadata or {}) + pdfinfo = ','.join( + _metadata_to_str(k, v) for k, v in info_dict.items()) + + # print figure to pgf and compile it with latex + with TemporaryDirectory() as tmpdir: + tmppath = pathlib.Path(tmpdir) + self.print_pgf(tmppath / "figure.pgf", **kwargs) + (tmppath / "figure.tex").write_text( + "\n".join([ + r"\documentclass[12pt]{article}", + r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo, + r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}" + % (w, h), + r"\usepackage{pgf}", + _get_preamble(), + r"\begin{document}", + r"\centering", + r"\input{figure.pgf}", + r"\end{document}", + ]), encoding="utf-8") + texcommand = mpl.rcParams["pgf.texsystem"] + cbook._check_and_log_subprocess( + [texcommand, "-interaction=nonstopmode", "-halt-on-error", + "figure.tex"], _log, cwd=tmpdir) + with (tmppath / "figure.pdf").open("rb") as orig, \ + cbook.open_file_cm(fname_or_fh, "wb") as dest: + shutil.copyfileobj(orig, dest) # copy file contents to target + + def print_png(self, fname_or_fh, **kwargs): + """Use LaTeX to compile a pgf figure to pdf and convert it to png.""" + converter = make_pdf_to_png_converter() + with TemporaryDirectory() as tmpdir: + tmppath = pathlib.Path(tmpdir) + pdf_path = tmppath / "figure.pdf" + png_path = tmppath / "figure.png" + self.print_pdf(pdf_path, **kwargs) + converter(pdf_path, png_path, dpi=self.figure.dpi) + with png_path.open("rb") as orig, \ + cbook.open_file_cm(fname_or_fh, "wb") as dest: + shutil.copyfileobj(orig, dest) # copy file contents to target + + def get_renderer(self): + return RendererPgf(self.figure, None) + + def draw(self): + self.figure.draw_without_rendering() + return super().draw() + + +FigureManagerPgf = FigureManagerBase + + +@_Backend.export +class _BackendPgf(_Backend): + FigureCanvas = FigureCanvasPgf + + +class PdfPages: + """ + A multi-page PDF file using the pgf backend + + Examples + -------- + >>> import matplotlib.pyplot as plt + >>> # Initialize: + >>> with PdfPages('foo.pdf') as pdf: + ... # As many times as you like, create a figure fig and save it: + ... fig = plt.figure() + ... pdf.savefig(fig) + ... # When no figure is specified the current figure is saved + ... pdf.savefig() + """ + + _UNSET = object() + + def __init__(self, filename, *, keep_empty=_UNSET, metadata=None): + """ + Create a new PdfPages object. + + Parameters + ---------- + filename : str or path-like + Plots using `PdfPages.savefig` will be written to a file at this + location. Any older file with the same name is overwritten. + + keep_empty : bool, default: True + If set to False, then empty pdf files will be deleted automatically + when closed. + + metadata : dict, optional + Information dictionary object (see PDF reference section 10.2.1 + 'Document Information Dictionary'), e.g.: + ``{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}``. + + The standard keys are 'Title', 'Author', 'Subject', 'Keywords', + 'Creator', 'Producer', 'CreationDate', 'ModDate', and + 'Trapped'. Values have been predefined for 'Creator', 'Producer' + and 'CreationDate'. They can be removed by setting them to `None`. + + Note that some versions of LaTeX engines may ignore the 'Producer' + key and set it to themselves. + """ + self._output_name = filename + self._n_figures = 0 + if keep_empty and keep_empty is not self._UNSET: + _api.warn_deprecated("3.8", message=( + "Keeping empty pdf files is deprecated since %(since)s and support " + "will be removed %(removal)s.")) + self._keep_empty = keep_empty + self._metadata = (metadata or {}).copy() + self._info_dict = _create_pdf_info_dict('pgf', self._metadata) + self._file = BytesIO() + + keep_empty = _api.deprecate_privatize_attribute("3.8") + + def _write_header(self, width_inches, height_inches): + pdfinfo = ','.join( + _metadata_to_str(k, v) for k, v in self._info_dict.items()) + latex_header = "\n".join([ + r"\documentclass[12pt]{article}", + r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo, + r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}" + % (width_inches, height_inches), + r"\usepackage{pgf}", + _get_preamble(), + r"\setlength{\parindent}{0pt}", + r"\begin{document}%", + ]) + self._file.write(latex_header.encode('utf-8')) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + + def close(self): + """ + Finalize this object, running LaTeX in a temporary directory + and moving the final pdf file to *filename*. + """ + self._file.write(rb'\end{document}\n') + if self._n_figures > 0: + self._run_latex() + elif self._keep_empty: + _api.warn_deprecated("3.8", message=( + "Keeping empty pdf files is deprecated since %(since)s and support " + "will be removed %(removal)s.")) + open(self._output_name, 'wb').close() + self._file.close() + + def _run_latex(self): + texcommand = mpl.rcParams["pgf.texsystem"] + with TemporaryDirectory() as tmpdir: + tex_source = pathlib.Path(tmpdir, "pdf_pages.tex") + tex_source.write_bytes(self._file.getvalue()) + cbook._check_and_log_subprocess( + [texcommand, "-interaction=nonstopmode", "-halt-on-error", + tex_source], + _log, cwd=tmpdir) + shutil.move(tex_source.with_suffix(".pdf"), self._output_name) + + def savefig(self, figure=None, **kwargs): + """ + Save a `.Figure` to this file as a new page. + + Any other keyword arguments are passed to `~.Figure.savefig`. + + Parameters + ---------- + figure : `.Figure` or int, default: the active figure + The figure, or index of the figure, that is saved to the file. + """ + if not isinstance(figure, Figure): + if figure is None: + manager = Gcf.get_active() + else: + manager = Gcf.get_fig_manager(figure) + if manager is None: + raise ValueError(f"No figure {figure}") + figure = manager.canvas.figure + + width, height = figure.get_size_inches() + if self._n_figures == 0: + self._write_header(width, height) + else: + # \pdfpagewidth and \pdfpageheight exist on pdftex, xetex, and + # luatex<0.85; they were renamed to \pagewidth and \pageheight + # on luatex>=0.85. + self._file.write( + ( + r'\newpage' + r'\ifdefined\pdfpagewidth\pdfpagewidth' + fr'\else\pagewidth\fi={width}in' + r'\ifdefined\pdfpageheight\pdfpageheight' + fr'\else\pageheight\fi={height}in' + '%%\n' + ).encode("ascii") + ) + figure.savefig(self._file, format="pgf", backend="pgf", **kwargs) + self._n_figures += 1 + + def get_pagecount(self): + """Return the current number of pages in the multipage pdf file.""" + return self._n_figures diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_ps.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_ps.py new file mode 100644 index 00000000..5f224f38 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_ps.py @@ -0,0 +1,1326 @@ +""" +A PostScript backend, which can produce both PostScript .ps and .eps. +""" + +import codecs +import datetime +from enum import Enum +import functools +from io import StringIO +import itertools +import logging +import math +import os +import pathlib +import shutil +from tempfile import TemporaryDirectory +import time + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, cbook, _path, _text_helpers +from matplotlib._afm import AFM +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, RendererBase) +from matplotlib.cbook import is_writable_file_like, file_requires_unicode +from matplotlib.font_manager import get_font +from matplotlib.ft2font import LOAD_NO_SCALE, FT2Font +from matplotlib._ttconv import convert_ttf_to_ps +from matplotlib._mathtext_data import uni2type1 +from matplotlib.path import Path +from matplotlib.texmanager import TexManager +from matplotlib.transforms import Affine2D +from matplotlib.backends.backend_mixed import MixedModeRenderer +from . import _backend_pdf_ps + + +_log = logging.getLogger(__name__) +debugPS = False + + +@_api.caching_module_getattr +class __getattr__: + # module-level deprecations + psDefs = _api.deprecated("3.8", obj_type="")(property(lambda self: _psDefs)) + + +papersize = {'letter': (8.5, 11), + 'legal': (8.5, 14), + 'ledger': (11, 17), + 'a0': (33.11, 46.81), + 'a1': (23.39, 33.11), + 'a2': (16.54, 23.39), + 'a3': (11.69, 16.54), + 'a4': (8.27, 11.69), + 'a5': (5.83, 8.27), + 'a6': (4.13, 5.83), + 'a7': (2.91, 4.13), + 'a8': (2.05, 2.91), + 'a9': (1.46, 2.05), + 'a10': (1.02, 1.46), + 'b0': (40.55, 57.32), + 'b1': (28.66, 40.55), + 'b2': (20.27, 28.66), + 'b3': (14.33, 20.27), + 'b4': (10.11, 14.33), + 'b5': (7.16, 10.11), + 'b6': (5.04, 7.16), + 'b7': (3.58, 5.04), + 'b8': (2.51, 3.58), + 'b9': (1.76, 2.51), + 'b10': (1.26, 1.76)} + + +def _get_papertype(w, h): + for key, (pw, ph) in sorted(papersize.items(), reverse=True): + if key.startswith('l'): + continue + if w < pw and h < ph: + return key + return 'a0' + + +def _nums_to_str(*args, sep=" "): + return sep.join(f"{arg:1.3f}".rstrip("0").rstrip(".") for arg in args) + + +def _move_path_to_path_or_stream(src, dst): + """ + Move the contents of file at *src* to path-or-filelike *dst*. + + If *dst* is a path, the metadata of *src* are *not* copied. + """ + if is_writable_file_like(dst): + fh = (open(src, encoding='latin-1') + if file_requires_unicode(dst) + else open(src, 'rb')) + with fh: + shutil.copyfileobj(fh, dst) + else: + shutil.move(src, dst, copy_function=shutil.copyfile) + + +def _font_to_ps_type3(font_path, chars): + """ + Subset *chars* from the font at *font_path* into a Type 3 font. + + Parameters + ---------- + font_path : path-like + Path to the font to be subsetted. + chars : str + The characters to include in the subsetted font. + + Returns + ------- + str + The string representation of a Type 3 font, which can be included + verbatim into a PostScript file. + """ + font = get_font(font_path, hinting_factor=1) + glyph_ids = [font.get_char_index(c) for c in chars] + + preamble = """\ +%!PS-Adobe-3.0 Resource-Font +%%Creator: Converted from TrueType to Type 3 by Matplotlib. +10 dict begin +/FontName /{font_name} def +/PaintType 0 def +/FontMatrix [{inv_units_per_em} 0 0 {inv_units_per_em} 0 0] def +/FontBBox [{bbox}] def +/FontType 3 def +/Encoding [{encoding}] def +/CharStrings {num_glyphs} dict dup begin +/.notdef 0 def +""".format(font_name=font.postscript_name, + inv_units_per_em=1 / font.units_per_EM, + bbox=" ".join(map(str, font.bbox)), + encoding=" ".join(f"/{font.get_glyph_name(glyph_id)}" + for glyph_id in glyph_ids), + num_glyphs=len(glyph_ids) + 1) + postamble = """ +end readonly def + +/BuildGlyph { + exch begin + CharStrings exch + 2 copy known not {pop /.notdef} if + true 3 1 roll get exec + end +} _d + +/BuildChar { + 1 index /Encoding get exch get + 1 index /BuildGlyph get exec +} _d + +FontName currentdict end definefont pop +""" + + entries = [] + for glyph_id in glyph_ids: + g = font.load_glyph(glyph_id, LOAD_NO_SCALE) + v, c = font.get_path() + entries.append( + "/%(name)s{%(bbox)s sc\n" % { + "name": font.get_glyph_name(glyph_id), + "bbox": " ".join(map(str, [g.horiAdvance, 0, *g.bbox])), + } + + _path.convert_to_string( + # Convert back to TrueType's internal units (1/64's). + # (Other dimensions are already in these units.) + Path(v * 64, c), None, None, False, None, 0, + # No code for quad Beziers triggers auto-conversion to cubics. + # Drop intermediate closepolys (relying on the outline + # decomposer always explicitly moving to the closing point + # first). + [b"m", b"l", b"", b"c", b""], True).decode("ascii") + + "ce} _d" + ) + + return preamble + "\n".join(entries) + postamble + + +def _font_to_ps_type42(font_path, chars, fh): + """ + Subset *chars* from the font at *font_path* into a Type 42 font at *fh*. + + Parameters + ---------- + font_path : path-like + Path to the font to be subsetted. + chars : str + The characters to include in the subsetted font. + fh : file-like + Where to write the font. + """ + subset_str = ''.join(chr(c) for c in chars) + _log.debug("SUBSET %s characters: %s", font_path, subset_str) + try: + fontdata = _backend_pdf_ps.get_glyphs_subset(font_path, subset_str) + _log.debug("SUBSET %s %d -> %d", font_path, os.stat(font_path).st_size, + fontdata.getbuffer().nbytes) + + # Give ttconv a subsetted font along with updated glyph_ids. + font = FT2Font(fontdata) + glyph_ids = [font.get_char_index(c) for c in chars] + with TemporaryDirectory() as tmpdir: + tmpfile = os.path.join(tmpdir, "tmp.ttf") + + with open(tmpfile, 'wb') as tmp: + tmp.write(fontdata.getvalue()) + + # TODO: allow convert_ttf_to_ps to input file objects (BytesIO) + convert_ttf_to_ps(os.fsencode(tmpfile), fh, 42, glyph_ids) + except RuntimeError: + _log.warning( + "The PostScript backend does not currently " + "support the selected font.") + raise + + +def _log_if_debug_on(meth): + """ + Wrap `RendererPS` method *meth* to emit a PS comment with the method name, + if the global flag `debugPS` is set. + """ + @functools.wraps(meth) + def wrapper(self, *args, **kwargs): + if debugPS: + self._pswriter.write(f"% {meth.__name__}\n") + return meth(self, *args, **kwargs) + + return wrapper + + +class RendererPS(_backend_pdf_ps.RendererPDFPSBase): + """ + The renderer handles all the drawing primitives using a graphics + context instance that controls the colors/styles. + """ + + _afm_font_dir = cbook._get_data_path("fonts/afm") + _use_afm_rc_name = "ps.useafm" + + def __init__(self, width, height, pswriter, imagedpi=72): + # Although postscript itself is dpi independent, we need to inform the + # image code about a requested dpi to generate high resolution images + # and them scale them before embedding them. + super().__init__(width, height) + self._pswriter = pswriter + if mpl.rcParams['text.usetex']: + self.textcnt = 0 + self.psfrag = [] + self.imagedpi = imagedpi + + # current renderer state (None=uninitialised) + self.color = None + self.linewidth = None + self.linejoin = None + self.linecap = None + self.linedash = None + self.fontname = None + self.fontsize = None + self._hatches = {} + self.image_magnification = imagedpi / 72 + self._clip_paths = {} + self._path_collection_id = 0 + + self._character_tracker = _backend_pdf_ps.CharacterTracker() + self._logwarn_once = functools.cache(_log.warning) + + def _is_transparent(self, rgb_or_rgba): + if rgb_or_rgba is None: + return True # Consistent with rgbFace semantics. + elif len(rgb_or_rgba) == 4: + if rgb_or_rgba[3] == 0: + return True + if rgb_or_rgba[3] != 1: + self._logwarn_once( + "The PostScript backend does not support transparency; " + "partially transparent artists will be rendered opaque.") + return False + else: # len() == 3. + return False + + def set_color(self, r, g, b, store=True): + if (r, g, b) != self.color: + self._pswriter.write(f"{_nums_to_str(r)} setgray\n" + if r == g == b else + f"{_nums_to_str(r, g, b)} setrgbcolor\n") + if store: + self.color = (r, g, b) + + def set_linewidth(self, linewidth, store=True): + linewidth = float(linewidth) + if linewidth != self.linewidth: + self._pswriter.write(f"{_nums_to_str(linewidth)} setlinewidth\n") + if store: + self.linewidth = linewidth + + @staticmethod + def _linejoin_cmd(linejoin): + # Support for directly passing integer values is for backcompat. + linejoin = {'miter': 0, 'round': 1, 'bevel': 2, 0: 0, 1: 1, 2: 2}[ + linejoin] + return f"{linejoin:d} setlinejoin\n" + + def set_linejoin(self, linejoin, store=True): + if linejoin != self.linejoin: + self._pswriter.write(self._linejoin_cmd(linejoin)) + if store: + self.linejoin = linejoin + + @staticmethod + def _linecap_cmd(linecap): + # Support for directly passing integer values is for backcompat. + linecap = {'butt': 0, 'round': 1, 'projecting': 2, 0: 0, 1: 1, 2: 2}[ + linecap] + return f"{linecap:d} setlinecap\n" + + def set_linecap(self, linecap, store=True): + if linecap != self.linecap: + self._pswriter.write(self._linecap_cmd(linecap)) + if store: + self.linecap = linecap + + def set_linedash(self, offset, seq, store=True): + if self.linedash is not None: + oldo, oldseq = self.linedash + if np.array_equal(seq, oldseq) and oldo == offset: + return + + self._pswriter.write(f"[{_nums_to_str(*seq)}] {_nums_to_str(offset)} setdash\n" + if seq is not None and len(seq) else + "[] 0 setdash\n") + if store: + self.linedash = (offset, seq) + + def set_font(self, fontname, fontsize, store=True): + if (fontname, fontsize) != (self.fontname, self.fontsize): + self._pswriter.write(f"/{fontname} {fontsize:1.3f} selectfont\n") + if store: + self.fontname = fontname + self.fontsize = fontsize + + def create_hatch(self, hatch): + sidelen = 72 + if hatch in self._hatches: + return self._hatches[hatch] + name = 'H%d' % len(self._hatches) + linewidth = mpl.rcParams['hatch.linewidth'] + pageheight = self.height * 72 + self._pswriter.write(f"""\ + << /PatternType 1 + /PaintType 2 + /TilingType 2 + /BBox[0 0 {sidelen:d} {sidelen:d}] + /XStep {sidelen:d} + /YStep {sidelen:d} + + /PaintProc {{ + pop + {linewidth:g} setlinewidth +{self._convert_path(Path.hatch(hatch), Affine2D().scale(sidelen), simplify=False)} + gsave + fill + grestore + stroke + }} bind + >> + matrix + 0 {pageheight:g} translate + makepattern + /{name} exch def +""") + self._hatches[hatch] = name + return name + + def get_image_magnification(self): + """ + Get the factor by which to magnify images passed to draw_image. + Allows a backend to have images at a different resolution to other + artists. + """ + return self.image_magnification + + def _convert_path(self, path, transform, clip=False, simplify=None): + if clip: + clip = (0.0, 0.0, self.width * 72.0, self.height * 72.0) + else: + clip = None + return _path.convert_to_string( + path, transform, clip, simplify, None, + 6, [b"m", b"l", b"", b"c", b"cl"], True).decode("ascii") + + def _get_clip_cmd(self, gc): + clip = [] + rect = gc.get_clip_rectangle() + if rect is not None: + clip.append(f"{_nums_to_str(*rect.p0, *rect.size)} rectclip\n") + path, trf = gc.get_clip_path() + if path is not None: + key = (path, id(trf)) + custom_clip_cmd = self._clip_paths.get(key) + if custom_clip_cmd is None: + custom_clip_cmd = "c%d" % len(self._clip_paths) + self._pswriter.write(f"""\ +/{custom_clip_cmd} {{ +{self._convert_path(path, trf, simplify=False)} +clip +newpath +}} bind def +""") + self._clip_paths[key] = custom_clip_cmd + clip.append(f"{custom_clip_cmd}\n") + return "".join(clip) + + @_log_if_debug_on + def draw_image(self, gc, x, y, im, transform=None): + # docstring inherited + + h, w = im.shape[:2] + imagecmd = "false 3 colorimage" + data = im[::-1, :, :3] # Vertically flipped rgb values. + hexdata = data.tobytes().hex("\n", -64) # Linewrap to 128 chars. + + if transform is None: + matrix = "1 0 0 1 0 0" + xscale = w / self.image_magnification + yscale = h / self.image_magnification + else: + matrix = " ".join(map(str, transform.frozen().to_values())) + xscale = 1.0 + yscale = 1.0 + + self._pswriter.write(f"""\ +gsave +{self._get_clip_cmd(gc)} +{x:g} {y:g} translate +[{matrix}] concat +{xscale:g} {yscale:g} scale +/DataString {w:d} string def +{w:d} {h:d} 8 [ {w:d} 0 0 -{h:d} 0 {h:d} ] +{{ +currentfile DataString readhexstring pop +}} bind {imagecmd} +{hexdata} +grestore +""") + + @_log_if_debug_on + def draw_path(self, gc, path, transform, rgbFace=None): + # docstring inherited + clip = rgbFace is None and gc.get_hatch_path() is None + simplify = path.should_simplify and clip + ps = self._convert_path(path, transform, clip=clip, simplify=simplify) + self._draw_ps(ps, gc, rgbFace) + + @_log_if_debug_on + def draw_markers( + self, gc, marker_path, marker_trans, path, trans, rgbFace=None): + # docstring inherited + + ps_color = ( + None + if self._is_transparent(rgbFace) + else f'{_nums_to_str(rgbFace[0])} setgray' + if rgbFace[0] == rgbFace[1] == rgbFace[2] + else f'{_nums_to_str(*rgbFace[:3])} setrgbcolor') + + # construct the generic marker command: + + # don't want the translate to be global + ps_cmd = ['/o {', 'gsave', 'newpath', 'translate'] + + lw = gc.get_linewidth() + alpha = (gc.get_alpha() + if gc.get_forced_alpha() or len(gc.get_rgb()) == 3 + else gc.get_rgb()[3]) + stroke = lw > 0 and alpha > 0 + if stroke: + ps_cmd.append('%.1f setlinewidth' % lw) + ps_cmd.append(self._linejoin_cmd(gc.get_joinstyle())) + ps_cmd.append(self._linecap_cmd(gc.get_capstyle())) + + ps_cmd.append(self._convert_path(marker_path, marker_trans, + simplify=False)) + + if rgbFace: + if stroke: + ps_cmd.append('gsave') + if ps_color: + ps_cmd.extend([ps_color, 'fill']) + if stroke: + ps_cmd.append('grestore') + + if stroke: + ps_cmd.append('stroke') + ps_cmd.extend(['grestore', '} bind def']) + + for vertices, code in path.iter_segments( + trans, + clip=(0, 0, self.width*72, self.height*72), + simplify=False): + if len(vertices): + x, y = vertices[-2:] + ps_cmd.append(f"{x:g} {y:g} o") + + ps = '\n'.join(ps_cmd) + self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False) + + @_log_if_debug_on + def draw_path_collection(self, gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position): + # Is the optimization worth it? Rough calculation: + # cost of emitting a path in-line is + # (len_path + 2) * uses_per_path + # cost of definition+use is + # (len_path + 3) + 3 * uses_per_path + len_path = len(paths[0].vertices) if len(paths) > 0 else 0 + uses_per_path = self._iter_collection_uses_per_path( + paths, all_transforms, offsets, facecolors, edgecolors) + should_do_optimization = \ + len_path + 3 * uses_per_path + 3 < (len_path + 2) * uses_per_path + if not should_do_optimization: + return RendererBase.draw_path_collection( + self, gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position) + + path_codes = [] + for i, (path, transform) in enumerate(self._iter_collection_raw_paths( + master_transform, paths, all_transforms)): + name = 'p%d_%d' % (self._path_collection_id, i) + path_bytes = self._convert_path(path, transform, simplify=False) + self._pswriter.write(f"""\ +/{name} {{ +newpath +translate +{path_bytes} +}} bind def +""") + path_codes.append(name) + + for xo, yo, path_id, gc0, rgbFace in self._iter_collection( + gc, path_codes, offsets, offset_trans, + facecolors, edgecolors, linewidths, linestyles, + antialiaseds, urls, offset_position): + ps = f"{xo:g} {yo:g} {path_id}" + self._draw_ps(ps, gc0, rgbFace) + + self._path_collection_id += 1 + + @_log_if_debug_on + def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): + # docstring inherited + if self._is_transparent(gc.get_rgb()): + return # Special handling for fully transparent. + + if not hasattr(self, "psfrag"): + self._logwarn_once( + "The PS backend determines usetex status solely based on " + "rcParams['text.usetex'] and does not support having " + "usetex=True only for some elements; this element will thus " + "be rendered as if usetex=False.") + self.draw_text(gc, x, y, s, prop, angle, False, mtext) + return + + w, h, bl = self.get_text_width_height_descent(s, prop, ismath="TeX") + fontsize = prop.get_size_in_points() + thetext = 'psmarker%d' % self.textcnt + color = _nums_to_str(*gc.get_rgb()[:3], sep=',') + fontcmd = {'sans-serif': r'{\sffamily %s}', + 'monospace': r'{\ttfamily %s}'}.get( + mpl.rcParams['font.family'][0], r'{\rmfamily %s}') + s = fontcmd % s + tex = r'\color[rgb]{%s} %s' % (color, s) + + # Stick to bottom-left alignment, so subtract descent from the text-normal + # direction since text is normally positioned by its baseline. + rangle = np.radians(angle + 90) + pos = _nums_to_str(x - bl * np.cos(rangle), y - bl * np.sin(rangle)) + self.psfrag.append( + r'\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}' % ( + thetext, angle, fontsize, fontsize*1.25, tex)) + + self._pswriter.write(f"""\ +gsave +{pos} moveto +({thetext}) +show +grestore +""") + self.textcnt += 1 + + @_log_if_debug_on + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + # docstring inherited + + if self._is_transparent(gc.get_rgb()): + return # Special handling for fully transparent. + + if ismath == 'TeX': + return self.draw_tex(gc, x, y, s, prop, angle) + + if ismath: + return self.draw_mathtext(gc, x, y, s, prop, angle) + + stream = [] # list of (ps_name, x, char_name) + + if mpl.rcParams['ps.useafm']: + font = self._get_font_afm(prop) + ps_name = (font.postscript_name.encode("ascii", "replace") + .decode("ascii")) + scale = 0.001 * prop.get_size_in_points() + thisx = 0 + last_name = None # kerns returns 0 for None. + for c in s: + name = uni2type1.get(ord(c), f"uni{ord(c):04X}") + try: + width = font.get_width_from_char_name(name) + except KeyError: + name = 'question' + width = font.get_width_char('?') + kern = font.get_kern_dist_from_name(last_name, name) + last_name = name + thisx += kern * scale + stream.append((ps_name, thisx, name)) + thisx += width * scale + + else: + font = self._get_font_ttf(prop) + self._character_tracker.track(font, s) + for item in _text_helpers.layout(s, font): + ps_name = (item.ft_object.postscript_name + .encode("ascii", "replace").decode("ascii")) + glyph_name = item.ft_object.get_glyph_name(item.glyph_idx) + stream.append((ps_name, item.x, glyph_name)) + self.set_color(*gc.get_rgb()) + + for ps_name, group in itertools. \ + groupby(stream, lambda entry: entry[0]): + self.set_font(ps_name, prop.get_size_in_points(), False) + thetext = "\n".join(f"{x:g} 0 m /{name:s} glyphshow" + for _, x, name in group) + self._pswriter.write(f"""\ +gsave +{self._get_clip_cmd(gc)} +{x:g} {y:g} translate +{angle:g} rotate +{thetext} +grestore +""") + + @_log_if_debug_on + def draw_mathtext(self, gc, x, y, s, prop, angle): + """Draw the math text using matplotlib.mathtext.""" + width, height, descent, glyphs, rects = \ + self._text2path.mathtext_parser.parse(s, 72, prop) + self.set_color(*gc.get_rgb()) + self._pswriter.write( + f"gsave\n" + f"{x:g} {y:g} translate\n" + f"{angle:g} rotate\n") + lastfont = None + for font, fontsize, num, ox, oy in glyphs: + self._character_tracker.track_glyph(font, num) + if (font.postscript_name, fontsize) != lastfont: + lastfont = font.postscript_name, fontsize + self._pswriter.write( + f"/{font.postscript_name} {fontsize} selectfont\n") + glyph_name = ( + font.get_name_char(chr(num)) if isinstance(font, AFM) else + font.get_glyph_name(font.get_char_index(num))) + self._pswriter.write( + f"{ox:g} {oy:g} moveto\n" + f"/{glyph_name} glyphshow\n") + for ox, oy, w, h in rects: + self._pswriter.write(f"{ox} {oy} {w} {h} rectfill\n") + self._pswriter.write("grestore\n") + + @_log_if_debug_on + def draw_gouraud_triangles(self, gc, points, colors, trans): + assert len(points) == len(colors) + if len(points) == 0: + return + assert points.ndim == 3 + assert points.shape[1] == 3 + assert points.shape[2] == 2 + assert colors.ndim == 3 + assert colors.shape[1] == 3 + assert colors.shape[2] == 4 + + shape = points.shape + flat_points = points.reshape((shape[0] * shape[1], 2)) + flat_points = trans.transform(flat_points) + flat_colors = colors.reshape((shape[0] * shape[1], 4)) + points_min = np.min(flat_points, axis=0) - (1 << 12) + points_max = np.max(flat_points, axis=0) + (1 << 12) + factor = np.ceil((2 ** 32 - 1) / (points_max - points_min)) + + xmin, ymin = points_min + xmax, ymax = points_max + + data = np.empty( + shape[0] * shape[1], + dtype=[('flags', 'u1'), ('points', '2>u4'), ('colors', '3u1')]) + data['flags'] = 0 + data['points'] = (flat_points - points_min) * factor + data['colors'] = flat_colors[:, :3] * 255.0 + hexdata = data.tobytes().hex("\n", -64) # Linewrap to 128 chars. + + self._pswriter.write(f"""\ +gsave +<< /ShadingType 4 + /ColorSpace [/DeviceRGB] + /BitsPerCoordinate 32 + /BitsPerComponent 8 + /BitsPerFlag 8 + /AntiAlias true + /Decode [ {xmin:g} {xmax:g} {ymin:g} {ymax:g} 0 1 0 1 0 1 ] + /DataSource < +{hexdata} +> +>> +shfill +grestore +""") + + def _draw_ps(self, ps, gc, rgbFace, *, fill=True, stroke=True): + """ + Emit the PostScript snippet *ps* with all the attributes from *gc* + applied. *ps* must consist of PostScript commands to construct a path. + + The *fill* and/or *stroke* kwargs can be set to False if the *ps* + string already includes filling and/or stroking, in which case + `_draw_ps` is just supplying properties and clipping. + """ + write = self._pswriter.write + mightstroke = (gc.get_linewidth() > 0 + and not self._is_transparent(gc.get_rgb())) + if not mightstroke: + stroke = False + if self._is_transparent(rgbFace): + fill = False + hatch = gc.get_hatch() + + if mightstroke: + self.set_linewidth(gc.get_linewidth()) + self.set_linejoin(gc.get_joinstyle()) + self.set_linecap(gc.get_capstyle()) + self.set_linedash(*gc.get_dashes()) + if mightstroke or hatch: + self.set_color(*gc.get_rgb()[:3]) + write('gsave\n') + + write(self._get_clip_cmd(gc)) + + write(ps.strip()) + write("\n") + + if fill: + if stroke or hatch: + write("gsave\n") + self.set_color(*rgbFace[:3], store=False) + write("fill\n") + if stroke or hatch: + write("grestore\n") + + if hatch: + hatch_name = self.create_hatch(hatch) + write("gsave\n") + write(_nums_to_str(*gc.get_hatch_color()[:3])) + write(f" {hatch_name} setpattern fill grestore\n") + + if stroke: + write("stroke\n") + + write("grestore\n") + + +class _Orientation(Enum): + portrait, landscape = range(2) + + def swap_if_landscape(self, shape): + return shape[::-1] if self.name == "landscape" else shape + + +class FigureCanvasPS(FigureCanvasBase): + fixed_dpi = 72 + filetypes = {'ps': 'Postscript', + 'eps': 'Encapsulated Postscript'} + + def get_default_filetype(self): + return 'ps' + + def _print_ps( + self, fmt, outfile, *, + metadata=None, papertype=None, orientation='portrait', + bbox_inches_restore=None, **kwargs): + + dpi = self.figure.dpi + self.figure.dpi = 72 # Override the dpi kwarg + + dsc_comments = {} + if isinstance(outfile, (str, os.PathLike)): + filename = pathlib.Path(outfile).name + dsc_comments["Title"] = \ + filename.encode("ascii", "replace").decode("ascii") + dsc_comments["Creator"] = (metadata or {}).get( + "Creator", + f"Matplotlib v{mpl.__version__}, https://matplotlib.org/") + # See https://reproducible-builds.org/specs/source-date-epoch/ + source_date_epoch = os.getenv("SOURCE_DATE_EPOCH") + dsc_comments["CreationDate"] = ( + datetime.datetime.fromtimestamp( + int(source_date_epoch), + datetime.timezone.utc).strftime("%a %b %d %H:%M:%S %Y") + if source_date_epoch + else time.ctime()) + dsc_comments = "\n".join( + f"%%{k}: {v}" for k, v in dsc_comments.items()) + + if papertype is None: + papertype = mpl.rcParams['ps.papersize'] + papertype = papertype.lower() + _api.check_in_list(['figure', 'auto', *papersize], papertype=papertype) + + orientation = _api.check_getitem( + _Orientation, orientation=orientation.lower()) + + printer = (self._print_figure_tex + if mpl.rcParams['text.usetex'] else + self._print_figure) + printer(fmt, outfile, dpi=dpi, dsc_comments=dsc_comments, + orientation=orientation, papertype=papertype, + bbox_inches_restore=bbox_inches_restore, **kwargs) + + def _print_figure( + self, fmt, outfile, *, + dpi, dsc_comments, orientation, papertype, + bbox_inches_restore=None): + """ + Render the figure to a filesystem path or a file-like object. + + Parameters are as for `.print_figure`, except that *dsc_comments* is a + string containing Document Structuring Convention comments, + generated from the *metadata* parameter to `.print_figure`. + """ + is_eps = fmt == 'eps' + if not (isinstance(outfile, (str, os.PathLike)) + or is_writable_file_like(outfile)): + raise ValueError("outfile must be a path or a file-like object") + + # find the appropriate papertype + width, height = self.figure.get_size_inches() + if papertype == 'auto': + papertype = _get_papertype(*orientation.swap_if_landscape((width, height))) + + if is_eps or papertype == 'figure': + paper_width, paper_height = width, height + else: + paper_width, paper_height = orientation.swap_if_landscape( + papersize[papertype]) + + # center the figure on the paper + xo = 72 * 0.5 * (paper_width - width) + yo = 72 * 0.5 * (paper_height - height) + + llx = xo + lly = yo + urx = llx + self.figure.bbox.width + ury = lly + self.figure.bbox.height + rotation = 0 + if orientation is _Orientation.landscape: + llx, lly, urx, ury = lly, llx, ury, urx + xo, yo = 72 * paper_height - yo, xo + rotation = 90 + bbox = (llx, lly, urx, ury) + + self._pswriter = StringIO() + + # mixed mode rendering + ps_renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi) + renderer = MixedModeRenderer( + self.figure, width, height, dpi, ps_renderer, + bbox_inches_restore=bbox_inches_restore) + + self.figure.draw(renderer) + + def print_figure_impl(fh): + # write the PostScript headers + if is_eps: + print("%!PS-Adobe-3.0 EPSF-3.0", file=fh) + else: + print("%!PS-Adobe-3.0", file=fh) + if papertype != 'figure': + print(f"%%DocumentPaperSizes: {papertype}", file=fh) + print("%%Pages: 1", file=fh) + print(f"%%LanguageLevel: 3\n" + f"{dsc_comments}\n" + f"%%Orientation: {orientation.name}\n" + f"{_get_bbox_header(bbox)}\n" + f"%%EndComments\n", + end="", file=fh) + + Ndict = len(_psDefs) + print("%%BeginProlog", file=fh) + if not mpl.rcParams['ps.useafm']: + Ndict += len(ps_renderer._character_tracker.used) + print("/mpldict %d dict def" % Ndict, file=fh) + print("mpldict begin", file=fh) + print("\n".join(_psDefs), file=fh) + if not mpl.rcParams['ps.useafm']: + for font_path, chars \ + in ps_renderer._character_tracker.used.items(): + if not chars: + continue + fonttype = mpl.rcParams['ps.fonttype'] + # Can't use more than 255 chars from a single Type 3 font. + if len(chars) > 255: + fonttype = 42 + fh.flush() + if fonttype == 3: + fh.write(_font_to_ps_type3(font_path, chars)) + else: # Type 42 only. + _font_to_ps_type42(font_path, chars, fh) + print("end", file=fh) + print("%%EndProlog", file=fh) + + if not is_eps: + print("%%Page: 1 1", file=fh) + print("mpldict begin", file=fh) + + print("%s translate" % _nums_to_str(xo, yo), file=fh) + if rotation: + print("%d rotate" % rotation, file=fh) + print(f"0 0 {_nums_to_str(width*72, height*72)} rectclip", file=fh) + + # write the figure + print(self._pswriter.getvalue(), file=fh) + + # write the trailer + print("end", file=fh) + print("showpage", file=fh) + if not is_eps: + print("%%EOF", file=fh) + fh.flush() + + if mpl.rcParams['ps.usedistiller']: + # We are going to use an external program to process the output. + # Write to a temporary file. + with TemporaryDirectory() as tmpdir: + tmpfile = os.path.join(tmpdir, "tmp.ps") + with open(tmpfile, 'w', encoding='latin-1') as fh: + print_figure_impl(fh) + if mpl.rcParams['ps.usedistiller'] == 'ghostscript': + _try_distill(gs_distill, + tmpfile, is_eps, ptype=papertype, bbox=bbox) + elif mpl.rcParams['ps.usedistiller'] == 'xpdf': + _try_distill(xpdf_distill, + tmpfile, is_eps, ptype=papertype, bbox=bbox) + _move_path_to_path_or_stream(tmpfile, outfile) + + else: # Write directly to outfile. + with cbook.open_file_cm(outfile, "w", encoding="latin-1") as file: + if not file_requires_unicode(file): + file = codecs.getwriter("latin-1")(file) + print_figure_impl(file) + + def _print_figure_tex( + self, fmt, outfile, *, + dpi, dsc_comments, orientation, papertype, + bbox_inches_restore=None): + """ + If :rc:`text.usetex` is True, a temporary pair of tex/eps files + are created to allow tex to manage the text layout via the PSFrags + package. These files are processed to yield the final ps or eps file. + + The rest of the behavior is as for `._print_figure`. + """ + is_eps = fmt == 'eps' + + width, height = self.figure.get_size_inches() + xo = 0 + yo = 0 + + llx = xo + lly = yo + urx = llx + self.figure.bbox.width + ury = lly + self.figure.bbox.height + bbox = (llx, lly, urx, ury) + + self._pswriter = StringIO() + + # mixed mode rendering + ps_renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi) + renderer = MixedModeRenderer(self.figure, + width, height, dpi, ps_renderer, + bbox_inches_restore=bbox_inches_restore) + + self.figure.draw(renderer) + + # write to a temp file, we'll move it to outfile when done + with TemporaryDirectory() as tmpdir: + tmppath = pathlib.Path(tmpdir, "tmp.ps") + tmppath.write_text( + f"""\ +%!PS-Adobe-3.0 EPSF-3.0 +%%LanguageLevel: 3 +{dsc_comments} +{_get_bbox_header(bbox)} +%%EndComments +%%BeginProlog +/mpldict {len(_psDefs)} dict def +mpldict begin +{"".join(_psDefs)} +end +%%EndProlog +mpldict begin +{_nums_to_str(xo, yo)} translate +0 0 {_nums_to_str(width*72, height*72)} rectclip +{self._pswriter.getvalue()} +end +showpage +""", + encoding="latin-1") + + if orientation is _Orientation.landscape: # now, ready to rotate + width, height = height, width + bbox = (lly, llx, ury, urx) + + # set the paper size to the figure size if is_eps. The + # resulting ps file has the given size with correct bounding + # box so that there is no need to call 'pstoeps' + if is_eps or papertype == 'figure': + paper_width, paper_height = orientation.swap_if_landscape( + self.figure.get_size_inches()) + else: + if papertype == 'auto': + papertype = _get_papertype(width, height) + paper_width, paper_height = papersize[papertype] + + psfrag_rotated = _convert_psfrags( + tmppath, ps_renderer.psfrag, paper_width, paper_height, + orientation.name) + + if (mpl.rcParams['ps.usedistiller'] == 'ghostscript' + or mpl.rcParams['text.usetex']): + _try_distill(gs_distill, + tmppath, is_eps, ptype=papertype, bbox=bbox, + rotated=psfrag_rotated) + elif mpl.rcParams['ps.usedistiller'] == 'xpdf': + _try_distill(xpdf_distill, + tmppath, is_eps, ptype=papertype, bbox=bbox, + rotated=psfrag_rotated) + + _move_path_to_path_or_stream(tmppath, outfile) + + print_ps = functools.partialmethod(_print_ps, "ps") + print_eps = functools.partialmethod(_print_ps, "eps") + + def draw(self): + self.figure.draw_without_rendering() + return super().draw() + + +def _convert_psfrags(tmppath, psfrags, paper_width, paper_height, orientation): + """ + When we want to use the LaTeX backend with postscript, we write PSFrag tags + to a temporary postscript file, each one marking a position for LaTeX to + render some text. convert_psfrags generates a LaTeX document containing the + commands to convert those tags to text. LaTeX/dvips produces the postscript + file that includes the actual text. + """ + with mpl.rc_context({ + "text.latex.preamble": + mpl.rcParams["text.latex.preamble"] + + mpl.texmanager._usepackage_if_not_loaded("color") + + mpl.texmanager._usepackage_if_not_loaded("graphicx") + + mpl.texmanager._usepackage_if_not_loaded("psfrag") + + r"\geometry{papersize={%(width)sin,%(height)sin},margin=0in}" + % {"width": paper_width, "height": paper_height} + }): + dvifile = TexManager().make_dvi( + "\n" + r"\begin{figure}""\n" + r" \centering\leavevmode""\n" + r" %(psfrags)s""\n" + r" \includegraphics*[angle=%(angle)s]{%(epsfile)s}""\n" + r"\end{figure}" + % { + "psfrags": "\n".join(psfrags), + "angle": 90 if orientation == 'landscape' else 0, + "epsfile": tmppath.resolve().as_posix(), + }, + fontsize=10) # tex's default fontsize. + + with TemporaryDirectory() as tmpdir: + psfile = os.path.join(tmpdir, "tmp.ps") + cbook._check_and_log_subprocess( + ['dvips', '-q', '-R0', '-o', psfile, dvifile], _log) + shutil.move(psfile, tmppath) + + # check if the dvips created a ps in landscape paper. Somehow, + # above latex+dvips results in a ps file in a landscape mode for a + # certain figure sizes (e.g., 8.3in, 5.8in which is a5). And the + # bounding box of the final output got messed up. We check see if + # the generated ps file is in landscape and return this + # information. The return value is used in pstoeps step to recover + # the correct bounding box. 2010-06-05 JJL + with open(tmppath) as fh: + psfrag_rotated = "Landscape" in fh.read(1000) + return psfrag_rotated + + +def _try_distill(func, tmppath, *args, **kwargs): + try: + func(str(tmppath), *args, **kwargs) + except mpl.ExecutableNotFoundError as exc: + _log.warning("%s. Distillation step skipped.", exc) + + +def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False): + """ + Use ghostscript's pswrite or epswrite device to distill a file. + This yields smaller files without illegal encapsulated postscript + operators. The output is low-level, converting text to outlines. + """ + + if eps: + paper_option = ["-dEPSCrop"] + elif ptype == "figure": + # The bbox will have its lower-left corner at (0, 0), so upper-right + # corner corresponds with paper size. + paper_option = [f"-dDEVICEWIDTHPOINTS={bbox[2]}", + f"-dDEVICEHEIGHTPOINTS={bbox[3]}"] + else: + paper_option = [f"-sPAPERSIZE={ptype}"] + + psfile = tmpfile + '.ps' + dpi = mpl.rcParams['ps.distiller.res'] + + cbook._check_and_log_subprocess( + [mpl._get_executable_info("gs").executable, + "-dBATCH", "-dNOPAUSE", "-r%d" % dpi, "-sDEVICE=ps2write", + *paper_option, f"-sOutputFile={psfile}", tmpfile], + _log) + + os.remove(tmpfile) + shutil.move(psfile, tmpfile) + + # While it is best if above steps preserve the original bounding + # box, there seem to be cases when it is not. For those cases, + # the original bbox can be restored during the pstoeps step. + + if eps: + # For some versions of gs, above steps result in a ps file where the + # original bbox is no more correct. Do not adjust bbox for now. + pstoeps(tmpfile, bbox, rotated=rotated) + + +def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False): + """ + Use ghostscript's ps2pdf and xpdf's/poppler's pdftops to distill a file. + This yields smaller files without illegal encapsulated postscript + operators. This distiller is preferred, generating high-level postscript + output that treats text as text. + """ + mpl._get_executable_info("gs") # Effectively checks for ps2pdf. + mpl._get_executable_info("pdftops") + + if eps: + paper_option = ["-dEPSCrop"] + elif ptype == "figure": + # The bbox will have its lower-left corner at (0, 0), so upper-right + # corner corresponds with paper size. + paper_option = [f"-dDEVICEWIDTHPOINTS#{bbox[2]}", + f"-dDEVICEHEIGHTPOINTS#{bbox[3]}"] + else: + paper_option = [f"-sPAPERSIZE#{ptype}"] + + with TemporaryDirectory() as tmpdir: + tmppdf = pathlib.Path(tmpdir, "tmp.pdf") + tmpps = pathlib.Path(tmpdir, "tmp.ps") + # Pass options as `-foo#bar` instead of `-foo=bar` to keep Windows + # happy (https://ghostscript.com/doc/9.56.1/Use.htm#MS_Windows). + cbook._check_and_log_subprocess( + ["ps2pdf", + "-dAutoFilterColorImages#false", + "-dAutoFilterGrayImages#false", + "-sAutoRotatePages#None", + "-sGrayImageFilter#FlateEncode", + "-sColorImageFilter#FlateEncode", + *paper_option, + tmpfile, tmppdf], _log) + cbook._check_and_log_subprocess( + ["pdftops", "-paper", "match", "-level3", tmppdf, tmpps], _log) + shutil.move(tmpps, tmpfile) + if eps: + pstoeps(tmpfile) + + +@_api.deprecated("3.9") +def get_bbox_header(lbrt, rotated=False): + """ + Return a postscript header string for the given bbox lbrt=(l, b, r, t). + Optionally, return rotate command. + """ + return _get_bbox_header(lbrt), (_get_rotate_command(lbrt) if rotated else "") + + +def _get_bbox_header(lbrt): + """Return a PostScript header string for bounding box *lbrt*=(l, b, r, t).""" + l, b, r, t = lbrt + return (f"%%BoundingBox: {int(l)} {int(b)} {math.ceil(r)} {math.ceil(t)}\n" + f"%%HiResBoundingBox: {l:.6f} {b:.6f} {r:.6f} {t:.6f}") + + +def _get_rotate_command(lbrt): + """Return a PostScript 90° rotation command for bounding box *lbrt*=(l, b, r, t).""" + l, b, r, t = lbrt + return f"{l+r:.2f} {0:.2f} translate\n90 rotate" + + +def pstoeps(tmpfile, bbox=None, rotated=False): + """ + Convert the postscript to encapsulated postscript. The bbox of + the eps file will be replaced with the given *bbox* argument. If + None, original bbox will be used. + """ + + epsfile = tmpfile + '.eps' + with open(epsfile, 'wb') as epsh, open(tmpfile, 'rb') as tmph: + write = epsh.write + # Modify the header: + for line in tmph: + if line.startswith(b'%!PS'): + write(b"%!PS-Adobe-3.0 EPSF-3.0\n") + if bbox: + write(_get_bbox_header(bbox).encode('ascii') + b'\n') + elif line.startswith(b'%%EndComments'): + write(line) + write(b'%%BeginProlog\n' + b'save\n' + b'countdictstack\n' + b'mark\n' + b'newpath\n' + b'/showpage {} def\n' + b'/setpagedevice {pop} def\n' + b'%%EndProlog\n' + b'%%Page 1 1\n') + if rotated: # The output eps file need to be rotated. + write(_get_rotate_command(bbox).encode('ascii') + b'\n') + break + elif bbox and line.startswith((b'%%Bound', b'%%HiResBound', + b'%%DocumentMedia', b'%%Pages')): + pass + else: + write(line) + # Now rewrite the rest of the file, and modify the trailer. + # This is done in a second loop such that the header of the embedded + # eps file is not modified. + for line in tmph: + if line.startswith(b'%%EOF'): + write(b'cleartomark\n' + b'countdictstack\n' + b'exch sub { end } repeat\n' + b'restore\n' + b'showpage\n' + b'%%EOF\n') + elif line.startswith(b'%%PageBoundingBox'): + pass + else: + write(line) + + os.remove(tmpfile) + shutil.move(epsfile, tmpfile) + + +FigureManagerPS = FigureManagerBase + + +# The following Python dictionary psDefs contains the entries for the +# PostScript dictionary mpldict. This dictionary implements most of +# the matplotlib primitives and some abbreviations. +# +# References: +# https://www.adobe.com/content/dam/acom/en/devnet/actionscript/articles/PLRM.pdf +# http://preserve.mactech.com/articles/mactech/Vol.09/09.04/PostscriptTutorial +# http://www.math.ubc.ca/people/faculty/cass/graphics/text/www/ +# + +# The usage comments use the notation of the operator summary +# in the PostScript Language reference manual. +_psDefs = [ + # name proc *_d* - + # Note that this cannot be bound to /d, because when embedding a Type3 font + # we may want to define a "d" glyph using "/d{...} d" which would locally + # overwrite the definition. + "/_d { bind def } bind def", + # x y *m* - + "/m { moveto } _d", + # x y *l* - + "/l { lineto } _d", + # x y *r* - + "/r { rlineto } _d", + # x1 y1 x2 y2 x y *c* - + "/c { curveto } _d", + # *cl* - + "/cl { closepath } _d", + # *ce* - + "/ce { closepath eofill } _d", + # wx wy llx lly urx ury *setcachedevice* - + "/sc { setcachedevice } _d", +] + + +@_Backend.export +class _BackendPS(_Backend): + backend_version = 'Level II' + FigureCanvas = FigureCanvasPS diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py new file mode 100644 index 00000000..a93b3779 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py @@ -0,0 +1,1067 @@ +import functools +import os +import sys +import traceback + +import matplotlib as mpl +from matplotlib import _api, backend_tools, cbook +from matplotlib._pylab_helpers import Gcf +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2, + TimerBase, cursors, ToolContainerBase, MouseButton, + CloseEvent, KeyEvent, LocationEvent, MouseEvent, ResizeEvent, + _allow_interrupt) +import matplotlib.backends.qt_editor.figureoptions as figureoptions +from . import qt_compat +from .qt_compat import ( + QtCore, QtGui, QtWidgets, __version__, QT_API, _to_int, _isdeleted) + + +# SPECIAL_KEYS are Qt::Key that do *not* return their Unicode name +# instead they have manually specified names. +SPECIAL_KEYS = { + _to_int(getattr(QtCore.Qt.Key, k)): v for k, v in [ + ("Key_Escape", "escape"), + ("Key_Tab", "tab"), + ("Key_Backspace", "backspace"), + ("Key_Return", "enter"), + ("Key_Enter", "enter"), + ("Key_Insert", "insert"), + ("Key_Delete", "delete"), + ("Key_Pause", "pause"), + ("Key_SysReq", "sysreq"), + ("Key_Clear", "clear"), + ("Key_Home", "home"), + ("Key_End", "end"), + ("Key_Left", "left"), + ("Key_Up", "up"), + ("Key_Right", "right"), + ("Key_Down", "down"), + ("Key_PageUp", "pageup"), + ("Key_PageDown", "pagedown"), + ("Key_Shift", "shift"), + # In macOS, the control and super (aka cmd/apple) keys are switched. + ("Key_Control", "control" if sys.platform != "darwin" else "cmd"), + ("Key_Meta", "meta" if sys.platform != "darwin" else "control"), + ("Key_Alt", "alt"), + ("Key_CapsLock", "caps_lock"), + ("Key_F1", "f1"), + ("Key_F2", "f2"), + ("Key_F3", "f3"), + ("Key_F4", "f4"), + ("Key_F5", "f5"), + ("Key_F6", "f6"), + ("Key_F7", "f7"), + ("Key_F8", "f8"), + ("Key_F9", "f9"), + ("Key_F10", "f10"), + ("Key_F10", "f11"), + ("Key_F12", "f12"), + ("Key_Super_L", "super"), + ("Key_Super_R", "super"), + ] +} +# Define which modifier keys are collected on keyboard events. +# Elements are (Qt::KeyboardModifiers, Qt::Key) tuples. +# Order determines the modifier order (ctrl+alt+...) reported by Matplotlib. +_MODIFIER_KEYS = [ + (_to_int(getattr(QtCore.Qt.KeyboardModifier, mod)), + _to_int(getattr(QtCore.Qt.Key, key))) + for mod, key in [ + ("ControlModifier", "Key_Control"), + ("AltModifier", "Key_Alt"), + ("ShiftModifier", "Key_Shift"), + ("MetaModifier", "Key_Meta"), + ] +] +cursord = { + k: getattr(QtCore.Qt.CursorShape, v) for k, v in [ + (cursors.MOVE, "SizeAllCursor"), + (cursors.HAND, "PointingHandCursor"), + (cursors.POINTER, "ArrowCursor"), + (cursors.SELECT_REGION, "CrossCursor"), + (cursors.WAIT, "WaitCursor"), + (cursors.RESIZE_HORIZONTAL, "SizeHorCursor"), + (cursors.RESIZE_VERTICAL, "SizeVerCursor"), + ] +} + + +# lru_cache keeps a reference to the QApplication instance, keeping it from +# being GC'd. +@functools.lru_cache(1) +def _create_qApp(): + app = QtWidgets.QApplication.instance() + + # Create a new QApplication and configure it if none exists yet, as only + # one QApplication can exist at a time. + if app is None: + # display_is_valid returns False only if on Linux and neither X11 + # nor Wayland display can be opened. + if not mpl._c_internal_utils.display_is_valid(): + raise RuntimeError('Invalid DISPLAY variable') + + # Check to make sure a QApplication from a different major version + # of Qt is not instantiated in the process + if QT_API in {'PyQt6', 'PySide6'}: + other_bindings = ('PyQt5', 'PySide2') + qt_version = 6 + elif QT_API in {'PyQt5', 'PySide2'}: + other_bindings = ('PyQt6', 'PySide6') + qt_version = 5 + else: + raise RuntimeError("Should never be here") + + for binding in other_bindings: + mod = sys.modules.get(f'{binding}.QtWidgets') + if mod is not None and mod.QApplication.instance() is not None: + other_core = sys.modules.get(f'{binding}.QtCore') + _api.warn_external( + f'Matplotlib is using {QT_API} which wraps ' + f'{QtCore.qVersion()} however an instantiated ' + f'QApplication from {binding} which wraps ' + f'{other_core.qVersion()} exists. Mixing Qt major ' + 'versions may not work as expected.' + ) + break + if qt_version == 5: + try: + QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) + except AttributeError: # Only for Qt>=5.6, <6. + pass + try: + QtWidgets.QApplication.setHighDpiScaleFactorRoundingPolicy( + QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) + except AttributeError: # Only for Qt>=5.14. + pass + app = QtWidgets.QApplication(["matplotlib"]) + if sys.platform == "darwin": + image = str(cbook._get_data_path('images/matplotlib.svg')) + icon = QtGui.QIcon(image) + app.setWindowIcon(icon) + app.setQuitOnLastWindowClosed(True) + cbook._setup_new_guiapp() + if qt_version == 5: + app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) + + return app + + +def _allow_interrupt_qt(qapp_or_eventloop): + """A context manager that allows terminating a plot by sending a SIGINT.""" + + # Use QSocketNotifier to read the socketpair while the Qt event loop runs. + + def prepare_notifier(rsock): + sn = QtCore.QSocketNotifier(rsock.fileno(), QtCore.QSocketNotifier.Type.Read) + + @sn.activated.connect + def _may_clear_sock(): + # Running a Python function on socket activation gives the interpreter a + # chance to handle the signal in Python land. We also need to drain the + # socket with recv() to re-arm it, because it will be written to as part of + # the wakeup. (We need this in case set_wakeup_fd catches a signal other + # than SIGINT and we shall continue waiting.) + try: + rsock.recv(1) + except BlockingIOError: + # This may occasionally fire too soon or more than once on Windows, so + # be forgiving about reading an empty socket. + pass + + return sn # Actually keep the notifier alive. + + def handle_sigint(): + if hasattr(qapp_or_eventloop, 'closeAllWindows'): + qapp_or_eventloop.closeAllWindows() + qapp_or_eventloop.quit() + + return _allow_interrupt(prepare_notifier, handle_sigint) + + +class TimerQT(TimerBase): + """Subclass of `.TimerBase` using QTimer events.""" + + def __init__(self, *args, **kwargs): + # Create a new timer and connect the timeout() signal to the + # _on_timer method. + self._timer = QtCore.QTimer() + self._timer.timeout.connect(self._on_timer) + super().__init__(*args, **kwargs) + + def __del__(self): + # The check for deletedness is needed to avoid an error at animation + # shutdown with PySide2. + if not _isdeleted(self._timer): + self._timer_stop() + + def _timer_set_single_shot(self): + self._timer.setSingleShot(self._single) + + def _timer_set_interval(self): + self._timer.setInterval(self._interval) + + def _timer_start(self): + self._timer.start() + + def _timer_stop(self): + self._timer.stop() + + +class FigureCanvasQT(FigureCanvasBase, QtWidgets.QWidget): + required_interactive_framework = "qt" + _timer_cls = TimerQT + manager_class = _api.classproperty(lambda cls: FigureManagerQT) + + buttond = { + getattr(QtCore.Qt.MouseButton, k): v for k, v in [ + ("LeftButton", MouseButton.LEFT), + ("RightButton", MouseButton.RIGHT), + ("MiddleButton", MouseButton.MIDDLE), + ("XButton1", MouseButton.BACK), + ("XButton2", MouseButton.FORWARD), + ] + } + + def __init__(self, figure=None): + _create_qApp() + super().__init__(figure=figure) + + self._draw_pending = False + self._is_drawing = False + self._draw_rect_callback = lambda painter: None + self._in_resize_event = False + + self.setAttribute(QtCore.Qt.WidgetAttribute.WA_OpaquePaintEvent) + self.setMouseTracking(True) + self.resize(*self.get_width_height()) + + palette = QtGui.QPalette(QtGui.QColor("white")) + self.setPalette(palette) + + def _update_pixel_ratio(self): + if self._set_device_pixel_ratio( + self.devicePixelRatioF() or 1): # rarely, devicePixelRatioF=0 + # The easiest way to resize the canvas is to emit a resizeEvent + # since we implement all the logic for resizing the canvas for + # that event. + event = QtGui.QResizeEvent(self.size(), self.size()) + self.resizeEvent(event) + + def _update_screen(self, screen): + # Handler for changes to a window's attached screen. + self._update_pixel_ratio() + if screen is not None: + screen.physicalDotsPerInchChanged.connect(self._update_pixel_ratio) + screen.logicalDotsPerInchChanged.connect(self._update_pixel_ratio) + + def showEvent(self, event): + # Set up correct pixel ratio, and connect to any signal changes for it, + # once the window is shown (and thus has these attributes). + window = self.window().windowHandle() + window.screenChanged.connect(self._update_screen) + self._update_screen(window.screen()) + + def set_cursor(self, cursor): + # docstring inherited + self.setCursor(_api.check_getitem(cursord, cursor=cursor)) + + def mouseEventCoords(self, pos=None): + """ + Calculate mouse coordinates in physical pixels. + + Qt uses logical pixels, but the figure is scaled to physical + pixels for rendering. Transform to physical pixels so that + all of the down-stream transforms work as expected. + + Also, the origin is different and needs to be corrected. + """ + if pos is None: + pos = self.mapFromGlobal(QtGui.QCursor.pos()) + elif hasattr(pos, "position"): # qt6 QtGui.QEvent + pos = pos.position() + elif hasattr(pos, "pos"): # qt5 QtCore.QEvent + pos = pos.pos() + # (otherwise, it's already a QPoint) + x = pos.x() + # flip y so y=0 is bottom of canvas + y = self.figure.bbox.height / self.device_pixel_ratio - pos.y() + return x * self.device_pixel_ratio, y * self.device_pixel_ratio + + def enterEvent(self, event): + # Force querying of the modifiers, as the cached modifier state can + # have been invalidated while the window was out of focus. + mods = QtWidgets.QApplication.instance().queryKeyboardModifiers() + if self.figure is None: + return + LocationEvent("figure_enter_event", self, + *self.mouseEventCoords(event), + modifiers=self._mpl_modifiers(mods), + guiEvent=event)._process() + + def leaveEvent(self, event): + QtWidgets.QApplication.restoreOverrideCursor() + if self.figure is None: + return + LocationEvent("figure_leave_event", self, + *self.mouseEventCoords(), + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def mousePressEvent(self, event): + button = self.buttond.get(event.button()) + if button is not None and self.figure is not None: + MouseEvent("button_press_event", self, + *self.mouseEventCoords(event), button, + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def mouseDoubleClickEvent(self, event): + button = self.buttond.get(event.button()) + if button is not None and self.figure is not None: + MouseEvent("button_press_event", self, + *self.mouseEventCoords(event), button, dblclick=True, + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def mouseMoveEvent(self, event): + if self.figure is None: + return + MouseEvent("motion_notify_event", self, + *self.mouseEventCoords(event), + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def mouseReleaseEvent(self, event): + button = self.buttond.get(event.button()) + if button is not None and self.figure is not None: + MouseEvent("button_release_event", self, + *self.mouseEventCoords(event), button, + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def wheelEvent(self, event): + # from QWheelEvent::pixelDelta doc: pixelDelta is sometimes not + # provided (`isNull()`) and is unreliable on X11 ("xcb"). + if (event.pixelDelta().isNull() + or QtWidgets.QApplication.instance().platformName() == "xcb"): + steps = event.angleDelta().y() / 120 + else: + steps = event.pixelDelta().y() + if steps and self.figure is not None: + MouseEvent("scroll_event", self, + *self.mouseEventCoords(event), step=steps, + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def keyPressEvent(self, event): + key = self._get_key(event) + if key is not None and self.figure is not None: + KeyEvent("key_press_event", self, + key, *self.mouseEventCoords(), + guiEvent=event)._process() + + def keyReleaseEvent(self, event): + key = self._get_key(event) + if key is not None and self.figure is not None: + KeyEvent("key_release_event", self, + key, *self.mouseEventCoords(), + guiEvent=event)._process() + + def resizeEvent(self, event): + if self._in_resize_event: # Prevent PyQt6 recursion + return + if self.figure is None: + return + self._in_resize_event = True + try: + w = event.size().width() * self.device_pixel_ratio + h = event.size().height() * self.device_pixel_ratio + dpival = self.figure.dpi + winch = w / dpival + hinch = h / dpival + self.figure.set_size_inches(winch, hinch, forward=False) + # pass back into Qt to let it finish + QtWidgets.QWidget.resizeEvent(self, event) + # emit our resize events + ResizeEvent("resize_event", self)._process() + self.draw_idle() + finally: + self._in_resize_event = False + + def sizeHint(self): + w, h = self.get_width_height() + return QtCore.QSize(w, h) + + def minumumSizeHint(self): + return QtCore.QSize(10, 10) + + @staticmethod + def _mpl_modifiers(modifiers=None, *, exclude=None): + if modifiers is None: + modifiers = QtWidgets.QApplication.instance().keyboardModifiers() + modifiers = _to_int(modifiers) + # get names of the pressed modifier keys + # 'control' is named 'control' when a standalone key, but 'ctrl' when a + # modifier + # bit twiddling to pick out modifier keys from modifiers bitmask, + # if exclude is a MODIFIER, it should not be duplicated in mods + return [SPECIAL_KEYS[key].replace('control', 'ctrl') + for mask, key in _MODIFIER_KEYS + if exclude != key and modifiers & mask] + + def _get_key(self, event): + event_key = event.key() + mods = self._mpl_modifiers(exclude=event_key) + try: + # for certain keys (enter, left, backspace, etc) use a word for the + # key, rather than Unicode + key = SPECIAL_KEYS[event_key] + except KeyError: + # Unicode defines code points up to 0x10ffff (sys.maxunicode) + # QT will use Key_Codes larger than that for keyboard keys that are + # not Unicode characters (like multimedia keys) + # skip these + # if you really want them, you should add them to SPECIAL_KEYS + if event_key > sys.maxunicode: + return None + + key = chr(event_key) + # qt delivers capitalized letters. fix capitalization + # note that capslock is ignored + if 'shift' in mods: + mods.remove('shift') + else: + key = key.lower() + + return '+'.join(mods + [key]) + + def flush_events(self): + # docstring inherited + QtWidgets.QApplication.instance().processEvents() + + def start_event_loop(self, timeout=0): + # docstring inherited + if hasattr(self, "_event_loop") and self._event_loop.isRunning(): + raise RuntimeError("Event loop already running") + self._event_loop = event_loop = QtCore.QEventLoop() + if timeout > 0: + _ = QtCore.QTimer.singleShot(int(timeout * 1000), event_loop.quit) + + with _allow_interrupt_qt(event_loop): + qt_compat._exec(event_loop) + + def stop_event_loop(self, event=None): + # docstring inherited + if hasattr(self, "_event_loop"): + self._event_loop.quit() + + def draw(self): + """Render the figure, and queue a request for a Qt draw.""" + # The renderer draw is done here; delaying causes problems with code + # that uses the result of the draw() to update plot elements. + if self._is_drawing: + return + with cbook._setattr_cm(self, _is_drawing=True): + super().draw() + self.update() + + def draw_idle(self): + """Queue redraw of the Agg buffer and request Qt paintEvent.""" + # The Agg draw needs to be handled by the same thread Matplotlib + # modifies the scene graph from. Post Agg draw request to the + # current event loop in order to ensure thread affinity and to + # accumulate multiple draw requests from event handling. + # TODO: queued signal connection might be safer than singleShot + if not (getattr(self, '_draw_pending', False) or + getattr(self, '_is_drawing', False)): + self._draw_pending = True + QtCore.QTimer.singleShot(0, self._draw_idle) + + def blit(self, bbox=None): + # docstring inherited + if bbox is None and self.figure: + bbox = self.figure.bbox # Blit the entire canvas if bbox is None. + # repaint uses logical pixels, not physical pixels like the renderer. + l, b, w, h = [int(pt / self.device_pixel_ratio) for pt in bbox.bounds] + t = b + h + self.repaint(l, self.rect().height() - t, w, h) + + def _draw_idle(self): + with self._idle_draw_cntx(): + if not self._draw_pending: + return + self._draw_pending = False + if self.height() < 0 or self.width() < 0: + return + try: + self.draw() + except Exception: + # Uncaught exceptions are fatal for PyQt5, so catch them. + traceback.print_exc() + + def drawRectangle(self, rect): + # Draw the zoom rectangle to the QPainter. _draw_rect_callback needs + # to be called at the end of paintEvent. + if rect is not None: + x0, y0, w, h = [int(pt / self.device_pixel_ratio) for pt in rect] + x1 = x0 + w + y1 = y0 + h + def _draw_rect_callback(painter): + pen = QtGui.QPen( + QtGui.QColor("black"), + 1 / self.device_pixel_ratio + ) + + pen.setDashPattern([3, 3]) + for color, offset in [ + (QtGui.QColor("black"), 0), + (QtGui.QColor("white"), 3), + ]: + pen.setDashOffset(offset) + pen.setColor(color) + painter.setPen(pen) + # Draw the lines from x0, y0 towards x1, y1 so that the + # dashes don't "jump" when moving the zoom box. + painter.drawLine(x0, y0, x0, y1) + painter.drawLine(x0, y0, x1, y0) + painter.drawLine(x0, y1, x1, y1) + painter.drawLine(x1, y0, x1, y1) + else: + def _draw_rect_callback(painter): + return + self._draw_rect_callback = _draw_rect_callback + self.update() + + +class MainWindow(QtWidgets.QMainWindow): + closing = QtCore.Signal() + + def closeEvent(self, event): + self.closing.emit() + super().closeEvent(event) + + +class FigureManagerQT(FigureManagerBase): + """ + Attributes + ---------- + canvas : `FigureCanvas` + The FigureCanvas instance + num : int or str + The Figure number + toolbar : qt.QToolBar + The qt.QToolBar + window : qt.QMainWindow + The qt.QMainWindow + """ + + def __init__(self, canvas, num): + self.window = MainWindow() + super().__init__(canvas, num) + self.window.closing.connect(self._widgetclosed) + + if sys.platform != "darwin": + image = str(cbook._get_data_path('images/matplotlib.svg')) + icon = QtGui.QIcon(image) + self.window.setWindowIcon(icon) + + self.window._destroying = False + + if self.toolbar: + self.window.addToolBar(self.toolbar) + tbs_height = self.toolbar.sizeHint().height() + else: + tbs_height = 0 + + # resize the main window so it will display the canvas with the + # requested size: + cs = canvas.sizeHint() + cs_height = cs.height() + height = cs_height + tbs_height + self.window.resize(cs.width(), height) + + self.window.setCentralWidget(self.canvas) + + if mpl.is_interactive(): + self.window.show() + self.canvas.draw_idle() + + # Give the keyboard focus to the figure instead of the manager: + # StrongFocus accepts both tab and click to focus and will enable the + # canvas to process event without clicking. + # https://doc.qt.io/qt-5/qt.html#FocusPolicy-enum + self.canvas.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus) + self.canvas.setFocus() + + self.window.raise_() + + def full_screen_toggle(self): + if self.window.isFullScreen(): + self.window.showNormal() + else: + self.window.showFullScreen() + + def _widgetclosed(self): + CloseEvent("close_event", self.canvas)._process() + if self.window._destroying: + return + self.window._destroying = True + try: + Gcf.destroy(self) + except AttributeError: + pass + # It seems that when the python session is killed, + # Gcf can get destroyed before the Gcf.destroy + # line is run, leading to a useless AttributeError. + + def resize(self, width, height): + # The Qt methods return sizes in 'virtual' pixels so we do need to + # rescale from physical to logical pixels. + width = int(width / self.canvas.device_pixel_ratio) + height = int(height / self.canvas.device_pixel_ratio) + extra_width = self.window.width() - self.canvas.width() + extra_height = self.window.height() - self.canvas.height() + self.canvas.resize(width, height) + self.window.resize(width + extra_width, height + extra_height) + + @classmethod + def start_main_loop(cls): + qapp = QtWidgets.QApplication.instance() + if qapp: + with _allow_interrupt_qt(qapp): + qt_compat._exec(qapp) + + def show(self): + self.window._destroying = False + self.window.show() + if mpl.rcParams['figure.raise_window']: + self.window.activateWindow() + self.window.raise_() + + def destroy(self, *args): + # check for qApp first, as PySide deletes it in its atexit handler + if QtWidgets.QApplication.instance() is None: + return + if self.window._destroying: + return + self.window._destroying = True + if self.toolbar: + self.toolbar.destroy() + self.window.close() + + def get_window_title(self): + return self.window.windowTitle() + + def set_window_title(self, title): + self.window.setWindowTitle(title) + + +class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar): + _message = QtCore.Signal(str) # Remove once deprecation below elapses. + message = _api.deprecate_privatize_attribute("3.8") + + toolitems = [*NavigationToolbar2.toolitems] + toolitems.insert( + # Add 'customize' action after 'subplots' + [name for name, *_ in toolitems].index("Subplots") + 1, + ("Customize", "Edit axis, curve and image parameters", + "qt4_editor_options", "edit_parameters")) + + def __init__(self, canvas, parent=None, coordinates=True): + """coordinates: should we show the coordinates on the right?""" + QtWidgets.QToolBar.__init__(self, parent) + self.setAllowedAreas(QtCore.Qt.ToolBarArea( + _to_int(QtCore.Qt.ToolBarArea.TopToolBarArea) | + _to_int(QtCore.Qt.ToolBarArea.BottomToolBarArea))) + self.coordinates = coordinates + self._actions = {} # mapping of toolitem method names to QActions. + self._subplot_dialog = None + + for text, tooltip_text, image_file, callback in self.toolitems: + if text is None: + self.addSeparator() + else: + slot = getattr(self, callback) + # https://bugreports.qt.io/browse/PYSIDE-2512 + slot = functools.wraps(slot)(functools.partial(slot)) + slot = QtCore.Slot()(slot) + + a = self.addAction(self._icon(image_file + '.png'), + text, slot) + self._actions[callback] = a + if callback in ['zoom', 'pan']: + a.setCheckable(True) + if tooltip_text is not None: + a.setToolTip(tooltip_text) + + # Add the (x, y) location widget at the right side of the toolbar + # The stretch factor is 1 which means any resizing of the toolbar + # will resize this label instead of the buttons. + if self.coordinates: + self.locLabel = QtWidgets.QLabel("", self) + self.locLabel.setAlignment(QtCore.Qt.AlignmentFlag( + _to_int(QtCore.Qt.AlignmentFlag.AlignRight) | + _to_int(QtCore.Qt.AlignmentFlag.AlignVCenter))) + + self.locLabel.setSizePolicy(QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Policy.Expanding, + QtWidgets.QSizePolicy.Policy.Ignored, + )) + labelAction = self.addWidget(self.locLabel) + labelAction.setVisible(True) + + NavigationToolbar2.__init__(self, canvas) + + def _icon(self, name): + """ + Construct a `.QIcon` from an image file *name*, including the extension + and relative to Matplotlib's "images" data directory. + """ + # use a high-resolution icon with suffix '_large' if available + # note: user-provided icons may not have '_large' versions + path_regular = cbook._get_data_path('images', name) + path_large = path_regular.with_name( + path_regular.name.replace('.png', '_large.png')) + filename = str(path_large if path_large.exists() else path_regular) + + pm = QtGui.QPixmap(filename) + pm.setDevicePixelRatio( + self.devicePixelRatioF() or 1) # rarely, devicePixelRatioF=0 + if self.palette().color(self.backgroundRole()).value() < 128: + icon_color = self.palette().color(self.foregroundRole()) + mask = pm.createMaskFromColor( + QtGui.QColor('black'), + QtCore.Qt.MaskMode.MaskOutColor) + pm.fill(icon_color) + pm.setMask(mask) + return QtGui.QIcon(pm) + + def edit_parameters(self): + axes = self.canvas.figure.get_axes() + if not axes: + QtWidgets.QMessageBox.warning( + self.canvas.parent(), "Error", "There are no Axes to edit.") + return + elif len(axes) == 1: + ax, = axes + else: + titles = [ + ax.get_label() or + ax.get_title() or + ax.get_title("left") or + ax.get_title("right") or + " - ".join(filter(None, [ax.get_xlabel(), ax.get_ylabel()])) or + f"" + for ax in axes] + duplicate_titles = [ + title for title in titles if titles.count(title) > 1] + for i, ax in enumerate(axes): + if titles[i] in duplicate_titles: + titles[i] += f" (id: {id(ax):#x})" # Deduplicate titles. + item, ok = QtWidgets.QInputDialog.getItem( + self.canvas.parent(), + 'Customize', 'Select Axes:', titles, 0, False) + if not ok: + return + ax = axes[titles.index(item)] + figureoptions.figure_edit(ax, self) + + def _update_buttons_checked(self): + # sync button checkstates to match active mode + if 'pan' in self._actions: + self._actions['pan'].setChecked(self.mode.name == 'PAN') + if 'zoom' in self._actions: + self._actions['zoom'].setChecked(self.mode.name == 'ZOOM') + + def pan(self, *args): + super().pan(*args) + self._update_buttons_checked() + + def zoom(self, *args): + super().zoom(*args) + self._update_buttons_checked() + + def set_message(self, s): + self._message.emit(s) + if self.coordinates: + self.locLabel.setText(s) + + def draw_rubberband(self, event, x0, y0, x1, y1): + height = self.canvas.figure.bbox.height + y1 = height - y1 + y0 = height - y0 + rect = [int(val) for val in (x0, y0, x1 - x0, y1 - y0)] + self.canvas.drawRectangle(rect) + + def remove_rubberband(self): + self.canvas.drawRectangle(None) + + def configure_subplots(self): + if self._subplot_dialog is None: + self._subplot_dialog = SubplotToolQt( + self.canvas.figure, self.canvas.parent()) + self.canvas.mpl_connect( + "close_event", lambda e: self._subplot_dialog.reject()) + self._subplot_dialog.update_from_current_subplotpars() + self._subplot_dialog.setModal(True) + self._subplot_dialog.show() + return self._subplot_dialog + + def save_figure(self, *args): + filetypes = self.canvas.get_supported_filetypes_grouped() + sorted_filetypes = sorted(filetypes.items()) + default_filetype = self.canvas.get_default_filetype() + + startpath = os.path.expanduser(mpl.rcParams['savefig.directory']) + start = os.path.join(startpath, self.canvas.get_default_filename()) + filters = [] + selectedFilter = None + for name, exts in sorted_filetypes: + exts_list = " ".join(['*.%s' % ext for ext in exts]) + filter = f'{name} ({exts_list})' + if default_filetype in exts: + selectedFilter = filter + filters.append(filter) + filters = ';;'.join(filters) + + fname, filter = QtWidgets.QFileDialog.getSaveFileName( + self.canvas.parent(), "Choose a filename to save to", start, + filters, selectedFilter) + if fname: + # Save dir for next time, unless empty str (i.e., use cwd). + if startpath != "": + mpl.rcParams['savefig.directory'] = os.path.dirname(fname) + try: + self.canvas.figure.savefig(fname) + except Exception as e: + QtWidgets.QMessageBox.critical( + self, "Error saving file", str(e), + QtWidgets.QMessageBox.StandardButton.Ok, + QtWidgets.QMessageBox.StandardButton.NoButton) + + def set_history_buttons(self): + can_backward = self._nav_stack._pos > 0 + can_forward = self._nav_stack._pos < len(self._nav_stack) - 1 + if 'back' in self._actions: + self._actions['back'].setEnabled(can_backward) + if 'forward' in self._actions: + self._actions['forward'].setEnabled(can_forward) + + +class SubplotToolQt(QtWidgets.QDialog): + def __init__(self, targetfig, parent): + super().__init__() + self.setWindowIcon(QtGui.QIcon( + str(cbook._get_data_path("images/matplotlib.png")))) + self.setObjectName("SubplotTool") + self._spinboxes = {} + main_layout = QtWidgets.QHBoxLayout() + self.setLayout(main_layout) + for group, spinboxes, buttons in [ + ("Borders", + ["top", "bottom", "left", "right"], + [("Export values", self._export_values)]), + ("Spacings", + ["hspace", "wspace"], + [("Tight layout", self._tight_layout), + ("Reset", self._reset), + ("Close", self.close)])]: + layout = QtWidgets.QVBoxLayout() + main_layout.addLayout(layout) + box = QtWidgets.QGroupBox(group) + layout.addWidget(box) + inner = QtWidgets.QFormLayout(box) + for name in spinboxes: + self._spinboxes[name] = spinbox = QtWidgets.QDoubleSpinBox() + spinbox.setRange(0, 1) + spinbox.setDecimals(3) + spinbox.setSingleStep(0.005) + spinbox.setKeyboardTracking(False) + spinbox.valueChanged.connect(self._on_value_changed) + inner.addRow(name, spinbox) + layout.addStretch(1) + for name, method in buttons: + button = QtWidgets.QPushButton(name) + # Don't trigger on , which is used to input values. + button.setAutoDefault(False) + button.clicked.connect(method) + layout.addWidget(button) + if name == "Close": + button.setFocus() + self._figure = targetfig + self._defaults = {} + self._export_values_dialog = None + self.update_from_current_subplotpars() + + def update_from_current_subplotpars(self): + self._defaults = {spinbox: getattr(self._figure.subplotpars, name) + for name, spinbox in self._spinboxes.items()} + self._reset() # Set spinbox current values without triggering signals. + + def _export_values(self): + # Explicitly round to 3 decimals (which is also the spinbox precision) + # to avoid numbers of the form 0.100...001. + self._export_values_dialog = QtWidgets.QDialog() + layout = QtWidgets.QVBoxLayout() + self._export_values_dialog.setLayout(layout) + text = QtWidgets.QPlainTextEdit() + text.setReadOnly(True) + layout.addWidget(text) + text.setPlainText( + ",\n".join(f"{attr}={spinbox.value():.3}" + for attr, spinbox in self._spinboxes.items())) + # Adjust the height of the text widget to fit the whole text, plus + # some padding. + size = text.maximumSize() + size.setHeight( + QtGui.QFontMetrics(text.document().defaultFont()) + .size(0, text.toPlainText()).height() + 20) + text.setMaximumSize(size) + self._export_values_dialog.show() + + def _on_value_changed(self): + spinboxes = self._spinboxes + # Set all mins and maxes, so that this can also be used in _reset(). + for lower, higher in [("bottom", "top"), ("left", "right")]: + spinboxes[higher].setMinimum(spinboxes[lower].value() + .001) + spinboxes[lower].setMaximum(spinboxes[higher].value() - .001) + self._figure.subplots_adjust( + **{attr: spinbox.value() for attr, spinbox in spinboxes.items()}) + self._figure.canvas.draw_idle() + + def _tight_layout(self): + self._figure.tight_layout() + for attr, spinbox in self._spinboxes.items(): + spinbox.blockSignals(True) + spinbox.setValue(getattr(self._figure.subplotpars, attr)) + spinbox.blockSignals(False) + self._figure.canvas.draw_idle() + + def _reset(self): + for spinbox, value in self._defaults.items(): + spinbox.setRange(0, 1) + spinbox.blockSignals(True) + spinbox.setValue(value) + spinbox.blockSignals(False) + self._on_value_changed() + + +class ToolbarQt(ToolContainerBase, QtWidgets.QToolBar): + def __init__(self, toolmanager, parent=None): + ToolContainerBase.__init__(self, toolmanager) + QtWidgets.QToolBar.__init__(self, parent) + self.setAllowedAreas(QtCore.Qt.ToolBarArea( + _to_int(QtCore.Qt.ToolBarArea.TopToolBarArea) | + _to_int(QtCore.Qt.ToolBarArea.BottomToolBarArea))) + message_label = QtWidgets.QLabel("") + message_label.setAlignment(QtCore.Qt.AlignmentFlag( + _to_int(QtCore.Qt.AlignmentFlag.AlignRight) | + _to_int(QtCore.Qt.AlignmentFlag.AlignVCenter))) + message_label.setSizePolicy(QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Policy.Expanding, + QtWidgets.QSizePolicy.Policy.Ignored, + )) + self._message_action = self.addWidget(message_label) + self._toolitems = {} + self._groups = {} + + def add_toolitem( + self, name, group, position, image_file, description, toggle): + + button = QtWidgets.QToolButton(self) + if image_file: + button.setIcon(NavigationToolbar2QT._icon(self, image_file)) + button.setText(name) + if description: + button.setToolTip(description) + + def handler(): + self.trigger_tool(name) + if toggle: + button.setCheckable(True) + button.toggled.connect(handler) + else: + button.clicked.connect(handler) + + self._toolitems.setdefault(name, []) + self._add_to_group(group, name, button, position) + self._toolitems[name].append((button, handler)) + + def _add_to_group(self, group, name, button, position): + gr = self._groups.get(group, []) + if not gr: + sep = self.insertSeparator(self._message_action) + gr.append(sep) + before = gr[position] + widget = self.insertWidget(before, button) + gr.insert(position, widget) + self._groups[group] = gr + + def toggle_toolitem(self, name, toggled): + if name not in self._toolitems: + return + for button, handler in self._toolitems[name]: + button.toggled.disconnect(handler) + button.setChecked(toggled) + button.toggled.connect(handler) + + def remove_toolitem(self, name): + for button, handler in self._toolitems.pop(name, []): + button.setParent(None) + + def set_message(self, s): + self.widgetForAction(self._message_action).setText(s) + + +@backend_tools._register_tool_class(FigureCanvasQT) +class ConfigureSubplotsQt(backend_tools.ConfigureSubplotsBase): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._subplot_dialog = None + + def trigger(self, *args): + NavigationToolbar2QT.configure_subplots(self) + + +@backend_tools._register_tool_class(FigureCanvasQT) +class SaveFigureQt(backend_tools.SaveFigureBase): + def trigger(self, *args): + NavigationToolbar2QT.save_figure( + self._make_classic_style_pseudo_toolbar()) + + +@backend_tools._register_tool_class(FigureCanvasQT) +class RubberbandQt(backend_tools.RubberbandBase): + def draw_rubberband(self, x0, y0, x1, y1): + NavigationToolbar2QT.draw_rubberband( + self._make_classic_style_pseudo_toolbar(), None, x0, y0, x1, y1) + + def remove_rubberband(self): + NavigationToolbar2QT.remove_rubberband( + self._make_classic_style_pseudo_toolbar()) + + +@backend_tools._register_tool_class(FigureCanvasQT) +class HelpQt(backend_tools.ToolHelpBase): + def trigger(self, *args): + QtWidgets.QMessageBox.information(None, "Help", self._get_help_html()) + + +@backend_tools._register_tool_class(FigureCanvasQT) +class ToolCopyToClipboardQT(backend_tools.ToolCopyToClipboardBase): + def trigger(self, *args, **kwargs): + pixmap = self.canvas.grab() + QtWidgets.QApplication.instance().clipboard().setPixmap(pixmap) + + +FigureManagerQT._toolbar2_class = NavigationToolbar2QT +FigureManagerQT._toolmanager_toolbar_class = ToolbarQt + + +@_Backend.export +class _BackendQT(_Backend): + backend_version = __version__ + FigureCanvas = FigureCanvasQT + FigureManager = FigureManagerQT + mainloop = FigureManagerQT.start_main_loop diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5.py new file mode 100644 index 00000000..d94062b7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5.py @@ -0,0 +1,28 @@ +from .. import backends + +backends._QT_FORCE_QT5_BINDING = True + + +from .backend_qt import ( # noqa + SPECIAL_KEYS, + # Public API + cursord, _create_qApp, _BackendQT, TimerQT, MainWindow, FigureCanvasQT, + FigureManagerQT, ToolbarQt, NavigationToolbar2QT, SubplotToolQt, + SaveFigureQt, ConfigureSubplotsQt, RubberbandQt, + HelpQt, ToolCopyToClipboardQT, + # internal re-exports + FigureCanvasBase, FigureManagerBase, MouseButton, NavigationToolbar2, + TimerBase, ToolContainerBase, figureoptions, Gcf +) +from . import backend_qt as _backend_qt # noqa + + +@_BackendQT.export +class _BackendQT5(_BackendQT): + pass + + +def __getattr__(name): + if name == 'qApp': + return _backend_qt.qApp + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py new file mode 100644 index 00000000..8a92fd51 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py @@ -0,0 +1,14 @@ +""" +Render to qt from agg +""" +from .. import backends + +backends._QT_FORCE_QT5_BINDING = True +from .backend_qtagg import ( # noqa: F401, E402 # pylint: disable=W0611 + _BackendQTAgg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT, + FigureCanvasAgg, FigureCanvasQT) + + +@_BackendQTAgg.export +class _BackendQT5Agg(_BackendQTAgg): + pass diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5cairo.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5cairo.py new file mode 100644 index 00000000..a4263f59 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qt5cairo.py @@ -0,0 +1,11 @@ +from .. import backends + +backends._QT_FORCE_QT5_BINDING = True +from .backend_qtcairo import ( # noqa: F401, E402 # pylint: disable=W0611 + _BackendQTCairo, FigureCanvasQTCairo, FigureCanvasCairo, FigureCanvasQT +) + + +@_BackendQTCairo.export +class _BackendQT5Cairo(_BackendQTCairo): + pass diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py new file mode 100644 index 00000000..256e50a3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py @@ -0,0 +1,86 @@ +""" +Render to qt from agg. +""" + +import ctypes + +from matplotlib.transforms import Bbox + +from .qt_compat import QT_API, QtCore, QtGui +from .backend_agg import FigureCanvasAgg +from .backend_qt import _BackendQT, FigureCanvasQT +from .backend_qt import ( # noqa: F401 # pylint: disable=W0611 + FigureManagerQT, NavigationToolbar2QT) + + +class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT): + + def paintEvent(self, event): + """ + Copy the image from the Agg canvas to the qt.drawable. + + In Qt, all drawing should be done inside of here when a widget is + shown onscreen. + """ + self._draw_idle() # Only does something if a draw is pending. + + # If the canvas does not have a renderer, then give up and wait for + # FigureCanvasAgg.draw(self) to be called. + if not hasattr(self, 'renderer'): + return + + painter = QtGui.QPainter(self) + try: + # See documentation of QRect: bottom() and right() are off + # by 1, so use left() + width() and top() + height(). + rect = event.rect() + # scale rect dimensions using the screen dpi ratio to get + # correct values for the Figure coordinates (rather than + # QT5's coords) + width = rect.width() * self.device_pixel_ratio + height = rect.height() * self.device_pixel_ratio + left, top = self.mouseEventCoords(rect.topLeft()) + # shift the "top" by the height of the image to get the + # correct corner for our coordinate system + bottom = top - height + # same with the right side of the image + right = left + width + # create a buffer using the image bounding box + bbox = Bbox([[left, bottom], [right, top]]) + buf = memoryview(self.copy_from_bbox(bbox)) + + if QT_API == "PyQt6": + from PyQt6 import sip + ptr = int(sip.voidptr(buf)) + else: + ptr = buf + + painter.eraseRect(rect) # clear the widget canvas + qimage = QtGui.QImage(ptr, buf.shape[1], buf.shape[0], + QtGui.QImage.Format.Format_RGBA8888) + qimage.setDevicePixelRatio(self.device_pixel_ratio) + # set origin using original QT coordinates + origin = QtCore.QPoint(rect.left(), rect.top()) + painter.drawImage(origin, qimage) + # Adjust the buf reference count to work around a memory + # leak bug in QImage under PySide. + if QT_API == "PySide2" and QtCore.__version_info__ < (5, 12): + ctypes.c_long.from_address(id(buf)).value = 1 + + self._draw_rect_callback(painter) + finally: + painter.end() + + def print_figure(self, *args, **kwargs): + super().print_figure(*args, **kwargs) + # In some cases, Qt will itself trigger a paint event after closing the file + # save dialog. When that happens, we need to be sure that the internal canvas is + # re-drawn. However, if the user is using an automatically-chosen Qt backend but + # saving with a different backend (such as pgf), we do not want to trigger a + # full draw in Qt, so just set the flag for next time. + self._draw_pending = True + + +@_BackendQT.export +class _BackendQTAgg(_BackendQT): + FigureCanvas = FigureCanvasQTAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtcairo.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtcairo.py new file mode 100644 index 00000000..72eb2dc7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_qtcairo.py @@ -0,0 +1,46 @@ +import ctypes + +from .backend_cairo import cairo, FigureCanvasCairo +from .backend_qt import _BackendQT, FigureCanvasQT +from .qt_compat import QT_API, QtCore, QtGui + + +class FigureCanvasQTCairo(FigureCanvasCairo, FigureCanvasQT): + def draw(self): + if hasattr(self._renderer.gc, "ctx"): + self._renderer.dpi = self.figure.dpi + self.figure.draw(self._renderer) + super().draw() + + def paintEvent(self, event): + width = int(self.device_pixel_ratio * self.width()) + height = int(self.device_pixel_ratio * self.height()) + if (width, height) != self._renderer.get_canvas_width_height(): + surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) + self._renderer.set_context(cairo.Context(surface)) + self._renderer.dpi = self.figure.dpi + self.figure.draw(self._renderer) + buf = self._renderer.gc.ctx.get_target().get_data() + if QT_API == "PyQt6": + from PyQt6 import sip + ptr = int(sip.voidptr(buf)) + else: + ptr = buf + qimage = QtGui.QImage( + ptr, width, height, + QtGui.QImage.Format.Format_ARGB32_Premultiplied) + # Adjust the buf reference count to work around a memory leak bug in + # QImage under PySide. + if QT_API == "PySide2" and QtCore.__version_info__ < (5, 12): + ctypes.c_long.from_address(id(buf)).value = 1 + qimage.setDevicePixelRatio(self.device_pixel_ratio) + painter = QtGui.QPainter(self) + painter.eraseRect(event.rect()) + painter.drawImage(0, 0, qimage) + self._draw_rect_callback(painter) + painter.end() + + +@_BackendQT.export +class _BackendQTCairo(_BackendQT): + FigureCanvas = FigureCanvasQTCairo diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py new file mode 100644 index 00000000..72354b81 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py @@ -0,0 +1,1368 @@ +import base64 +import codecs +import datetime +import gzip +import hashlib +from io import BytesIO +import itertools +import logging +import os +import re +import uuid + +import numpy as np +from PIL import Image + +import matplotlib as mpl +from matplotlib import cbook, font_manager as fm +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, RendererBase) +from matplotlib.backends.backend_mixed import MixedModeRenderer +from matplotlib.colors import rgb2hex +from matplotlib.dates import UTC +from matplotlib.path import Path +from matplotlib import _path +from matplotlib.transforms import Affine2D, Affine2DBase + + +_log = logging.getLogger(__name__) + + +# ---------------------------------------------------------------------- +# SimpleXMLWriter class +# +# Based on an original by Fredrik Lundh, but modified here to: +# 1. Support modern Python idioms +# 2. Remove encoding support (it's handled by the file writer instead) +# 3. Support proper indentation +# 4. Minify things a little bit + +# -------------------------------------------------------------------- +# The SimpleXMLWriter module is +# +# Copyright (c) 2001-2004 by Fredrik Lundh +# +# By obtaining, using, and/or copying this software and/or its +# associated documentation, you agree that you have read, understood, +# and will comply with the following terms and conditions: +# +# Permission to use, copy, modify, and distribute this software and +# its associated documentation for any purpose and without fee is +# hereby granted, provided that the above copyright notice appears in +# all copies, and that both that copyright notice and this permission +# notice appear in supporting documentation, and that the name of +# Secret Labs AB or the author not be used in advertising or publicity +# pertaining to distribution of the software without specific, written +# prior permission. +# +# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD +# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- +# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR +# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# -------------------------------------------------------------------- + + +def _escape_cdata(s): + s = s.replace("&", "&") + s = s.replace("<", "<") + s = s.replace(">", ">") + return s + + +_escape_xml_comment = re.compile(r'-(?=-)') + + +def _escape_comment(s): + s = _escape_cdata(s) + return _escape_xml_comment.sub('- ', s) + + +def _escape_attrib(s): + s = s.replace("&", "&") + s = s.replace("'", "'") + s = s.replace('"', """) + s = s.replace("<", "<") + s = s.replace(">", ">") + return s + + +def _quote_escape_attrib(s): + return ('"' + _escape_cdata(s) + '"' if '"' not in s else + "'" + _escape_cdata(s) + "'" if "'" not in s else + '"' + _escape_attrib(s) + '"') + + +def _short_float_fmt(x): + """ + Create a short string representation of a float, which is %f + formatting with trailing zeros and the decimal point removed. + """ + return f'{x:f}'.rstrip('0').rstrip('.') + + +class XMLWriter: + """ + Parameters + ---------- + file : writable text file-like object + """ + + def __init__(self, file): + self.__write = file.write + if hasattr(file, "flush"): + self.flush = file.flush + self.__open = 0 # true if start tag is open + self.__tags = [] + self.__data = [] + self.__indentation = " " * 64 + + def __flush(self, indent=True): + # flush internal buffers + if self.__open: + if indent: + self.__write(">\n") + else: + self.__write(">") + self.__open = 0 + if self.__data: + data = ''.join(self.__data) + self.__write(_escape_cdata(data)) + self.__data = [] + + def start(self, tag, attrib={}, **extra): + """ + Open a new element. Attributes can be given as keyword + arguments, or as a string/string dictionary. The method returns + an opaque identifier that can be passed to the :meth:`close` + method, to close all open elements up to and including this one. + + Parameters + ---------- + tag + Element tag. + attrib + Attribute dictionary. Alternatively, attributes can be given as + keyword arguments. + + Returns + ------- + An element identifier. + """ + self.__flush() + tag = _escape_cdata(tag) + self.__data = [] + self.__tags.append(tag) + self.__write(self.__indentation[:len(self.__tags) - 1]) + self.__write(f"<{tag}") + for k, v in {**attrib, **extra}.items(): + if v: + k = _escape_cdata(k) + v = _quote_escape_attrib(v) + self.__write(f' {k}={v}') + self.__open = 1 + return len(self.__tags) - 1 + + def comment(self, comment): + """ + Add a comment to the output stream. + + Parameters + ---------- + comment : str + Comment text. + """ + self.__flush() + self.__write(self.__indentation[:len(self.__tags)]) + self.__write(f"\n") + + def data(self, text): + """ + Add character data to the output stream. + + Parameters + ---------- + text : str + Character data. + """ + self.__data.append(text) + + def end(self, tag=None, indent=True): + """ + Close the current element (opened by the most recent call to + :meth:`start`). + + Parameters + ---------- + tag + Element tag. If given, the tag must match the start tag. If + omitted, the current element is closed. + indent : bool, default: True + """ + if tag: + assert self.__tags, f"unbalanced end({tag})" + assert _escape_cdata(tag) == self.__tags[-1], \ + f"expected end({self.__tags[-1]}), got {tag}" + else: + assert self.__tags, "unbalanced end()" + tag = self.__tags.pop() + if self.__data: + self.__flush(indent) + elif self.__open: + self.__open = 0 + self.__write("/>\n") + return + if indent: + self.__write(self.__indentation[:len(self.__tags)]) + self.__write(f"\n") + + def close(self, id): + """ + Close open elements, up to (and including) the element identified + by the given identifier. + + Parameters + ---------- + id + Element identifier, as returned by the :meth:`start` method. + """ + while len(self.__tags) > id: + self.end() + + def element(self, tag, text=None, attrib={}, **extra): + """ + Add an entire element. This is the same as calling :meth:`start`, + :meth:`data`, and :meth:`end` in sequence. The *text* argument can be + omitted. + """ + self.start(tag, attrib, **extra) + if text: + self.data(text) + self.end(indent=False) + + def flush(self): + """Flush the output stream.""" + pass # replaced by the constructor + + +def _generate_transform(transform_list): + parts = [] + for type, value in transform_list: + if (type == 'scale' and (value == (1,) or value == (1, 1)) + or type == 'translate' and value == (0, 0) + or type == 'rotate' and value == (0,)): + continue + if type == 'matrix' and isinstance(value, Affine2DBase): + value = value.to_values() + parts.append('{}({})'.format( + type, ' '.join(_short_float_fmt(x) for x in value))) + return ' '.join(parts) + + +def _generate_css(attrib): + return "; ".join(f"{k}: {v}" for k, v in attrib.items()) + + +_capstyle_d = {'projecting': 'square', 'butt': 'butt', 'round': 'round'} + + +def _check_is_str(info, key): + if not isinstance(info, str): + raise TypeError(f'Invalid type for {key} metadata. Expected str, not ' + f'{type(info)}.') + + +def _check_is_iterable_of_str(infos, key): + if np.iterable(infos): + for info in infos: + if not isinstance(info, str): + raise TypeError(f'Invalid type for {key} metadata. Expected ' + f'iterable of str, not {type(info)}.') + else: + raise TypeError(f'Invalid type for {key} metadata. Expected str or ' + f'iterable of str, not {type(infos)}.') + + +class RendererSVG(RendererBase): + def __init__(self, width, height, svgwriter, basename=None, image_dpi=72, + *, metadata=None): + self.width = width + self.height = height + self.writer = XMLWriter(svgwriter) + self.image_dpi = image_dpi # actual dpi at which we rasterize stuff + + if basename is None: + basename = getattr(svgwriter, "name", "") + if not isinstance(basename, str): + basename = "" + self.basename = basename + + self._groupd = {} + self._image_counter = itertools.count() + self._clipd = {} + self._markers = {} + self._path_collection_id = 0 + self._hatchd = {} + self._has_gouraud = False + self._n_gradients = 0 + + super().__init__() + self._glyph_map = dict() + str_height = _short_float_fmt(height) + str_width = _short_float_fmt(width) + svgwriter.write(svgProlog) + self._start_id = self.writer.start( + 'svg', + width=f'{str_width}pt', + height=f'{str_height}pt', + viewBox=f'0 0 {str_width} {str_height}', + xmlns="http://www.w3.org/2000/svg", + version="1.1", + attrib={'xmlns:xlink': "http://www.w3.org/1999/xlink"}) + self._write_metadata(metadata) + self._write_default_style() + + def finalize(self): + self._write_clips() + self._write_hatches() + self.writer.close(self._start_id) + self.writer.flush() + + def _write_metadata(self, metadata): + # Add metadata following the Dublin Core Metadata Initiative, and the + # Creative Commons Rights Expression Language. This is mainly for + # compatibility with Inkscape. + if metadata is None: + metadata = {} + metadata = { + 'Format': 'image/svg+xml', + 'Type': 'http://purl.org/dc/dcmitype/StillImage', + 'Creator': + f'Matplotlib v{mpl.__version__}, https://matplotlib.org/', + **metadata + } + writer = self.writer + + if 'Title' in metadata: + title = metadata['Title'] + _check_is_str(title, 'Title') + writer.element('title', text=title) + + # Special handling. + date = metadata.get('Date', None) + if date is not None: + if isinstance(date, str): + dates = [date] + elif isinstance(date, (datetime.datetime, datetime.date)): + dates = [date.isoformat()] + elif np.iterable(date): + dates = [] + for d in date: + if isinstance(d, str): + dates.append(d) + elif isinstance(d, (datetime.datetime, datetime.date)): + dates.append(d.isoformat()) + else: + raise TypeError( + f'Invalid type for Date metadata. ' + f'Expected iterable of str, date, or datetime, ' + f'not {type(d)}.') + else: + raise TypeError(f'Invalid type for Date metadata. ' + f'Expected str, date, datetime, or iterable ' + f'of the same, not {type(date)}.') + metadata['Date'] = '/'.join(dates) + elif 'Date' not in metadata: + # Do not add `Date` if the user explicitly set `Date` to `None` + # Get source date from SOURCE_DATE_EPOCH, if set. + # See https://reproducible-builds.org/specs/source-date-epoch/ + date = os.getenv("SOURCE_DATE_EPOCH") + if date: + date = datetime.datetime.fromtimestamp(int(date), datetime.timezone.utc) + metadata['Date'] = date.replace(tzinfo=UTC).isoformat() + else: + metadata['Date'] = datetime.datetime.today().isoformat() + + mid = None + def ensure_metadata(mid): + if mid is not None: + return mid + mid = writer.start('metadata') + writer.start('rdf:RDF', attrib={ + 'xmlns:dc': "http://purl.org/dc/elements/1.1/", + 'xmlns:cc': "http://creativecommons.org/ns#", + 'xmlns:rdf': "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + }) + writer.start('cc:Work') + return mid + + uri = metadata.pop('Type', None) + if uri is not None: + mid = ensure_metadata(mid) + writer.element('dc:type', attrib={'rdf:resource': uri}) + + # Single value only. + for key in ['Title', 'Coverage', 'Date', 'Description', 'Format', + 'Identifier', 'Language', 'Relation', 'Source']: + info = metadata.pop(key, None) + if info is not None: + mid = ensure_metadata(mid) + _check_is_str(info, key) + writer.element(f'dc:{key.lower()}', text=info) + + # Multiple Agent values. + for key in ['Creator', 'Contributor', 'Publisher', 'Rights']: + agents = metadata.pop(key, None) + if agents is None: + continue + + if isinstance(agents, str): + agents = [agents] + + _check_is_iterable_of_str(agents, key) + # Now we know that we have an iterable of str + mid = ensure_metadata(mid) + writer.start(f'dc:{key.lower()}') + for agent in agents: + writer.start('cc:Agent') + writer.element('dc:title', text=agent) + writer.end('cc:Agent') + writer.end(f'dc:{key.lower()}') + + # Multiple values. + keywords = metadata.pop('Keywords', None) + if keywords is not None: + if isinstance(keywords, str): + keywords = [keywords] + _check_is_iterable_of_str(keywords, 'Keywords') + # Now we know that we have an iterable of str + mid = ensure_metadata(mid) + writer.start('dc:subject') + writer.start('rdf:Bag') + for keyword in keywords: + writer.element('rdf:li', text=keyword) + writer.end('rdf:Bag') + writer.end('dc:subject') + + if mid is not None: + writer.close(mid) + + if metadata: + raise ValueError('Unknown metadata key(s) passed to SVG writer: ' + + ','.join(metadata)) + + def _write_default_style(self): + writer = self.writer + default_style = _generate_css({ + 'stroke-linejoin': 'round', + 'stroke-linecap': 'butt'}) + writer.start('defs') + writer.element('style', type='text/css', text='*{%s}' % default_style) + writer.end('defs') + + def _make_id(self, type, content): + salt = mpl.rcParams['svg.hashsalt'] + if salt is None: + salt = str(uuid.uuid4()) + m = hashlib.sha256() + m.update(salt.encode('utf8')) + m.update(str(content).encode('utf8')) + return f'{type}{m.hexdigest()[:10]}' + + def _make_flip_transform(self, transform): + return transform + Affine2D().scale(1, -1).translate(0, self.height) + + def _get_hatch(self, gc, rgbFace): + """ + Create a new hatch pattern + """ + if rgbFace is not None: + rgbFace = tuple(rgbFace) + edge = gc.get_hatch_color() + if edge is not None: + edge = tuple(edge) + dictkey = (gc.get_hatch(), rgbFace, edge) + oid = self._hatchd.get(dictkey) + if oid is None: + oid = self._make_id('h', dictkey) + self._hatchd[dictkey] = ((gc.get_hatch_path(), rgbFace, edge), oid) + else: + _, oid = oid + return oid + + def _write_hatches(self): + if not len(self._hatchd): + return + HATCH_SIZE = 72 + writer = self.writer + writer.start('defs') + for (path, face, stroke), oid in self._hatchd.values(): + writer.start( + 'pattern', + id=oid, + patternUnits="userSpaceOnUse", + x="0", y="0", width=str(HATCH_SIZE), + height=str(HATCH_SIZE)) + path_data = self._convert_path( + path, + Affine2D() + .scale(HATCH_SIZE).scale(1.0, -1.0).translate(0, HATCH_SIZE), + simplify=False) + if face is None: + fill = 'none' + else: + fill = rgb2hex(face) + writer.element( + 'rect', + x="0", y="0", width=str(HATCH_SIZE+1), + height=str(HATCH_SIZE+1), + fill=fill) + hatch_style = { + 'fill': rgb2hex(stroke), + 'stroke': rgb2hex(stroke), + 'stroke-width': str(mpl.rcParams['hatch.linewidth']), + 'stroke-linecap': 'butt', + 'stroke-linejoin': 'miter' + } + if stroke[3] < 1: + hatch_style['stroke-opacity'] = str(stroke[3]) + writer.element( + 'path', + d=path_data, + style=_generate_css(hatch_style) + ) + writer.end('pattern') + writer.end('defs') + + def _get_style_dict(self, gc, rgbFace): + """Generate a style string from the GraphicsContext and rgbFace.""" + attrib = {} + + forced_alpha = gc.get_forced_alpha() + + if gc.get_hatch() is not None: + attrib['fill'] = f"url(#{self._get_hatch(gc, rgbFace)})" + if (rgbFace is not None and len(rgbFace) == 4 and rgbFace[3] != 1.0 + and not forced_alpha): + attrib['fill-opacity'] = _short_float_fmt(rgbFace[3]) + else: + if rgbFace is None: + attrib['fill'] = 'none' + else: + if tuple(rgbFace[:3]) != (0, 0, 0): + attrib['fill'] = rgb2hex(rgbFace) + if (len(rgbFace) == 4 and rgbFace[3] != 1.0 + and not forced_alpha): + attrib['fill-opacity'] = _short_float_fmt(rgbFace[3]) + + if forced_alpha and gc.get_alpha() != 1.0: + attrib['opacity'] = _short_float_fmt(gc.get_alpha()) + + offset, seq = gc.get_dashes() + if seq is not None: + attrib['stroke-dasharray'] = ','.join( + _short_float_fmt(val) for val in seq) + attrib['stroke-dashoffset'] = _short_float_fmt(float(offset)) + + linewidth = gc.get_linewidth() + if linewidth: + rgb = gc.get_rgb() + attrib['stroke'] = rgb2hex(rgb) + if not forced_alpha and rgb[3] != 1.0: + attrib['stroke-opacity'] = _short_float_fmt(rgb[3]) + if linewidth != 1.0: + attrib['stroke-width'] = _short_float_fmt(linewidth) + if gc.get_joinstyle() != 'round': + attrib['stroke-linejoin'] = gc.get_joinstyle() + if gc.get_capstyle() != 'butt': + attrib['stroke-linecap'] = _capstyle_d[gc.get_capstyle()] + + return attrib + + def _get_style(self, gc, rgbFace): + return _generate_css(self._get_style_dict(gc, rgbFace)) + + def _get_clip_attrs(self, gc): + cliprect = gc.get_clip_rectangle() + clippath, clippath_trans = gc.get_clip_path() + if clippath is not None: + clippath_trans = self._make_flip_transform(clippath_trans) + dictkey = (id(clippath), str(clippath_trans)) + elif cliprect is not None: + x, y, w, h = cliprect.bounds + y = self.height-(y+h) + dictkey = (x, y, w, h) + else: + return {} + clip = self._clipd.get(dictkey) + if clip is None: + oid = self._make_id('p', dictkey) + if clippath is not None: + self._clipd[dictkey] = ((clippath, clippath_trans), oid) + else: + self._clipd[dictkey] = (dictkey, oid) + else: + clip, oid = clip + return {'clip-path': f'url(#{oid})'} + + def _write_clips(self): + if not len(self._clipd): + return + writer = self.writer + writer.start('defs') + for clip, oid in self._clipd.values(): + writer.start('clipPath', id=oid) + if len(clip) == 2: + clippath, clippath_trans = clip + path_data = self._convert_path( + clippath, clippath_trans, simplify=False) + writer.element('path', d=path_data) + else: + x, y, w, h = clip + writer.element( + 'rect', + x=_short_float_fmt(x), + y=_short_float_fmt(y), + width=_short_float_fmt(w), + height=_short_float_fmt(h)) + writer.end('clipPath') + writer.end('defs') + + def open_group(self, s, gid=None): + # docstring inherited + if gid: + self.writer.start('g', id=gid) + else: + self._groupd[s] = self._groupd.get(s, 0) + 1 + self.writer.start('g', id=f"{s}_{self._groupd[s]:d}") + + def close_group(self, s): + # docstring inherited + self.writer.end('g') + + def option_image_nocomposite(self): + # docstring inherited + return not mpl.rcParams['image.composite_image'] + + def _convert_path(self, path, transform=None, clip=None, simplify=None, + sketch=None): + if clip: + clip = (0.0, 0.0, self.width, self.height) + else: + clip = None + return _path.convert_to_string( + path, transform, clip, simplify, sketch, 6, + [b'M', b'L', b'Q', b'C', b'z'], False).decode('ascii') + + def draw_path(self, gc, path, transform, rgbFace=None): + # docstring inherited + trans_and_flip = self._make_flip_transform(transform) + clip = (rgbFace is None and gc.get_hatch_path() is None) + simplify = path.should_simplify and clip + path_data = self._convert_path( + path, trans_and_flip, clip=clip, simplify=simplify, + sketch=gc.get_sketch_params()) + + if gc.get_url() is not None: + self.writer.start('a', {'xlink:href': gc.get_url()}) + self.writer.element('path', d=path_data, **self._get_clip_attrs(gc), + style=self._get_style(gc, rgbFace)) + if gc.get_url() is not None: + self.writer.end('a') + + def draw_markers( + self, gc, marker_path, marker_trans, path, trans, rgbFace=None): + # docstring inherited + + if not len(path.vertices): + return + + writer = self.writer + path_data = self._convert_path( + marker_path, + marker_trans + Affine2D().scale(1.0, -1.0), + simplify=False) + style = self._get_style_dict(gc, rgbFace) + dictkey = (path_data, _generate_css(style)) + oid = self._markers.get(dictkey) + style = _generate_css({k: v for k, v in style.items() + if k.startswith('stroke')}) + + if oid is None: + oid = self._make_id('m', dictkey) + writer.start('defs') + writer.element('path', id=oid, d=path_data, style=style) + writer.end('defs') + self._markers[dictkey] = oid + + writer.start('g', **self._get_clip_attrs(gc)) + trans_and_flip = self._make_flip_transform(trans) + attrib = {'xlink:href': f'#{oid}'} + clip = (0, 0, self.width*72, self.height*72) + for vertices, code in path.iter_segments( + trans_and_flip, clip=clip, simplify=False): + if len(vertices): + x, y = vertices[-2:] + attrib['x'] = _short_float_fmt(x) + attrib['y'] = _short_float_fmt(y) + attrib['style'] = self._get_style(gc, rgbFace) + writer.element('use', attrib=attrib) + writer.end('g') + + def draw_path_collection(self, gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position): + # Is the optimization worth it? Rough calculation: + # cost of emitting a path in-line is + # (len_path + 5) * uses_per_path + # cost of definition+use is + # (len_path + 3) + 9 * uses_per_path + len_path = len(paths[0].vertices) if len(paths) > 0 else 0 + uses_per_path = self._iter_collection_uses_per_path( + paths, all_transforms, offsets, facecolors, edgecolors) + should_do_optimization = \ + len_path + 9 * uses_per_path + 3 < (len_path + 5) * uses_per_path + if not should_do_optimization: + return super().draw_path_collection( + gc, master_transform, paths, all_transforms, + offsets, offset_trans, facecolors, edgecolors, + linewidths, linestyles, antialiaseds, urls, + offset_position) + + writer = self.writer + path_codes = [] + writer.start('defs') + for i, (path, transform) in enumerate(self._iter_collection_raw_paths( + master_transform, paths, all_transforms)): + transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0) + d = self._convert_path(path, transform, simplify=False) + oid = 'C{:x}_{:x}_{}'.format( + self._path_collection_id, i, self._make_id('', d)) + writer.element('path', id=oid, d=d) + path_codes.append(oid) + writer.end('defs') + + for xo, yo, path_id, gc0, rgbFace in self._iter_collection( + gc, path_codes, offsets, offset_trans, + facecolors, edgecolors, linewidths, linestyles, + antialiaseds, urls, offset_position): + url = gc0.get_url() + if url is not None: + writer.start('a', attrib={'xlink:href': url}) + clip_attrs = self._get_clip_attrs(gc0) + if clip_attrs: + writer.start('g', **clip_attrs) + attrib = { + 'xlink:href': f'#{path_id}', + 'x': _short_float_fmt(xo), + 'y': _short_float_fmt(self.height - yo), + 'style': self._get_style(gc0, rgbFace) + } + writer.element('use', attrib=attrib) + if clip_attrs: + writer.end('g') + if url is not None: + writer.end('a') + + self._path_collection_id += 1 + + def _draw_gouraud_triangle(self, transformed_points, colors): + # This uses a method described here: + # + # http://www.svgopen.org/2005/papers/Converting3DFaceToSVG/index.html + # + # that uses three overlapping linear gradients to simulate a + # Gouraud triangle. Each gradient goes from fully opaque in + # one corner to fully transparent along the opposite edge. + # The line between the stop points is perpendicular to the + # opposite edge. Underlying these three gradients is a solid + # triangle whose color is the average of all three points. + + avg_color = np.average(colors, axis=0) + if avg_color[-1] == 0: + # Skip fully-transparent triangles + return + + writer = self.writer + writer.start('defs') + for i in range(3): + x1, y1 = transformed_points[i] + x2, y2 = transformed_points[(i + 1) % 3] + x3, y3 = transformed_points[(i + 2) % 3] + rgba_color = colors[i] + + if x2 == x3: + xb = x2 + yb = y1 + elif y2 == y3: + xb = x1 + yb = y2 + else: + m1 = (y2 - y3) / (x2 - x3) + b1 = y2 - (m1 * x2) + m2 = -(1.0 / m1) + b2 = y1 - (m2 * x1) + xb = (-b1 + b2) / (m1 - m2) + yb = m2 * xb + b2 + + writer.start( + 'linearGradient', + id=f"GR{self._n_gradients:x}_{i:d}", + gradientUnits="userSpaceOnUse", + x1=_short_float_fmt(x1), y1=_short_float_fmt(y1), + x2=_short_float_fmt(xb), y2=_short_float_fmt(yb)) + writer.element( + 'stop', + offset='1', + style=_generate_css({ + 'stop-color': rgb2hex(avg_color), + 'stop-opacity': _short_float_fmt(rgba_color[-1])})) + writer.element( + 'stop', + offset='0', + style=_generate_css({'stop-color': rgb2hex(rgba_color), + 'stop-opacity': "0"})) + + writer.end('linearGradient') + + writer.end('defs') + + # triangle formation using "path" + dpath = (f"M {_short_float_fmt(x1)},{_short_float_fmt(y1)}" + f" L {_short_float_fmt(x2)},{_short_float_fmt(y2)}" + f" {_short_float_fmt(x3)},{_short_float_fmt(y3)} Z") + + writer.element( + 'path', + attrib={'d': dpath, + 'fill': rgb2hex(avg_color), + 'fill-opacity': '1', + 'shape-rendering': "crispEdges"}) + + writer.start( + 'g', + attrib={'stroke': "none", + 'stroke-width': "0", + 'shape-rendering': "crispEdges", + 'filter': "url(#colorMat)"}) + + writer.element( + 'path', + attrib={'d': dpath, + 'fill': f'url(#GR{self._n_gradients:x}_0)', + 'shape-rendering': "crispEdges"}) + + writer.element( + 'path', + attrib={'d': dpath, + 'fill': f'url(#GR{self._n_gradients:x}_1)', + 'filter': 'url(#colorAdd)', + 'shape-rendering': "crispEdges"}) + + writer.element( + 'path', + attrib={'d': dpath, + 'fill': f'url(#GR{self._n_gradients:x}_2)', + 'filter': 'url(#colorAdd)', + 'shape-rendering': "crispEdges"}) + + writer.end('g') + + self._n_gradients += 1 + + def draw_gouraud_triangles(self, gc, triangles_array, colors_array, + transform): + writer = self.writer + writer.start('g', **self._get_clip_attrs(gc)) + transform = transform.frozen() + trans_and_flip = self._make_flip_transform(transform) + + if not self._has_gouraud: + self._has_gouraud = True + writer.start( + 'filter', + id='colorAdd') + writer.element( + 'feComposite', + attrib={'in': 'SourceGraphic'}, + in2='BackgroundImage', + operator='arithmetic', + k2="1", k3="1") + writer.end('filter') + # feColorMatrix filter to correct opacity + writer.start( + 'filter', + id='colorMat') + writer.element( + 'feColorMatrix', + attrib={'type': 'matrix'}, + values='1 0 0 0 0 \n0 1 0 0 0 \n0 0 1 0 0 \n1 1 1 1 0 \n0 0 0 0 1 ') + writer.end('filter') + + for points, colors in zip(triangles_array, colors_array): + self._draw_gouraud_triangle(trans_and_flip.transform(points), colors) + writer.end('g') + + def option_scale_image(self): + # docstring inherited + return True + + def get_image_magnification(self): + return self.image_dpi / 72.0 + + def draw_image(self, gc, x, y, im, transform=None): + # docstring inherited + + h, w = im.shape[:2] + + if w == 0 or h == 0: + return + + clip_attrs = self._get_clip_attrs(gc) + if clip_attrs: + # Can't apply clip-path directly to the image because the image has + # a transformation, which would also be applied to the clip-path. + self.writer.start('g', **clip_attrs) + + url = gc.get_url() + if url is not None: + self.writer.start('a', attrib={'xlink:href': url}) + + attrib = {} + oid = gc.get_gid() + if mpl.rcParams['svg.image_inline']: + buf = BytesIO() + Image.fromarray(im).save(buf, format="png") + oid = oid or self._make_id('image', buf.getvalue()) + attrib['xlink:href'] = ( + "data:image/png;base64,\n" + + base64.b64encode(buf.getvalue()).decode('ascii')) + else: + if self.basename is None: + raise ValueError("Cannot save image data to filesystem when " + "writing SVG to an in-memory buffer") + filename = f'{self.basename}.image{next(self._image_counter)}.png' + _log.info('Writing image file for inclusion: %s', filename) + Image.fromarray(im).save(filename) + oid = oid or 'Im_' + self._make_id('image', filename) + attrib['xlink:href'] = filename + attrib['id'] = oid + + if transform is None: + w = 72.0 * w / self.image_dpi + h = 72.0 * h / self.image_dpi + + self.writer.element( + 'image', + transform=_generate_transform([ + ('scale', (1, -1)), ('translate', (0, -h))]), + x=_short_float_fmt(x), + y=_short_float_fmt(-(self.height - y - h)), + width=_short_float_fmt(w), height=_short_float_fmt(h), + attrib=attrib) + else: + alpha = gc.get_alpha() + if alpha != 1.0: + attrib['opacity'] = _short_float_fmt(alpha) + + flipped = ( + Affine2D().scale(1.0 / w, 1.0 / h) + + transform + + Affine2D() + .translate(x, y) + .scale(1.0, -1.0) + .translate(0.0, self.height)) + + attrib['transform'] = _generate_transform( + [('matrix', flipped.frozen())]) + attrib['style'] = ( + 'image-rendering:crisp-edges;' + 'image-rendering:pixelated') + self.writer.element( + 'image', + width=_short_float_fmt(w), height=_short_float_fmt(h), + attrib=attrib) + + if url is not None: + self.writer.end('a') + if clip_attrs: + self.writer.end('g') + + def _update_glyph_map_defs(self, glyph_map_new): + """ + Emit definitions for not-yet-defined glyphs, and record them as having + been defined. + """ + writer = self.writer + if glyph_map_new: + writer.start('defs') + for char_id, (vertices, codes) in glyph_map_new.items(): + char_id = self._adjust_char_id(char_id) + # x64 to go back to FreeType's internal (integral) units. + path_data = self._convert_path( + Path(vertices * 64, codes), simplify=False) + writer.element( + 'path', id=char_id, d=path_data, + transform=_generate_transform([('scale', (1 / 64,))])) + writer.end('defs') + self._glyph_map.update(glyph_map_new) + + def _adjust_char_id(self, char_id): + return char_id.replace("%20", "_") + + def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext=None): + # docstring inherited + writer = self.writer + + writer.comment(s) + + glyph_map = self._glyph_map + + text2path = self._text2path + color = rgb2hex(gc.get_rgb()) + fontsize = prop.get_size_in_points() + + style = {} + if color != '#000000': + style['fill'] = color + alpha = gc.get_alpha() if gc.get_forced_alpha() else gc.get_rgb()[3] + if alpha != 1: + style['opacity'] = _short_float_fmt(alpha) + font_scale = fontsize / text2path.FONT_SCALE + attrib = { + 'style': _generate_css(style), + 'transform': _generate_transform([ + ('translate', (x, y)), + ('rotate', (-angle,)), + ('scale', (font_scale, -font_scale))]), + } + writer.start('g', attrib=attrib) + + if not ismath: + font = text2path._get_font(prop) + _glyphs = text2path.get_glyphs_with_font( + font, s, glyph_map=glyph_map, return_new_glyphs_only=True) + glyph_info, glyph_map_new, rects = _glyphs + self._update_glyph_map_defs(glyph_map_new) + + for glyph_id, xposition, yposition, scale in glyph_info: + attrib = {'xlink:href': f'#{glyph_id}'} + if xposition != 0.0: + attrib['x'] = _short_float_fmt(xposition) + if yposition != 0.0: + attrib['y'] = _short_float_fmt(yposition) + writer.element('use', attrib=attrib) + + else: + if ismath == "TeX": + _glyphs = text2path.get_glyphs_tex( + prop, s, glyph_map=glyph_map, return_new_glyphs_only=True) + else: + _glyphs = text2path.get_glyphs_mathtext( + prop, s, glyph_map=glyph_map, return_new_glyphs_only=True) + glyph_info, glyph_map_new, rects = _glyphs + self._update_glyph_map_defs(glyph_map_new) + + for char_id, xposition, yposition, scale in glyph_info: + char_id = self._adjust_char_id(char_id) + writer.element( + 'use', + transform=_generate_transform([ + ('translate', (xposition, yposition)), + ('scale', (scale,)), + ]), + attrib={'xlink:href': f'#{char_id}'}) + + for verts, codes in rects: + path = Path(verts, codes) + path_data = self._convert_path(path, simplify=False) + writer.element('path', d=path_data) + + writer.end('g') + + def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None): + # NOTE: If you change the font styling CSS, then be sure the check for + # svg.fonttype = none in `lib/matplotlib/testing/compare.py::convert` remains in + # sync. Also be sure to re-generate any SVG using this mode, or else such tests + # will fail to use the right converter for the expected images, and they will + # fail strangely. + writer = self.writer + + color = rgb2hex(gc.get_rgb()) + style = {} + if color != '#000000': + style['fill'] = color + + alpha = gc.get_alpha() if gc.get_forced_alpha() else gc.get_rgb()[3] + if alpha != 1: + style['opacity'] = _short_float_fmt(alpha) + + if not ismath: + attrib = {} + + font_parts = [] + if prop.get_style() != 'normal': + font_parts.append(prop.get_style()) + if prop.get_variant() != 'normal': + font_parts.append(prop.get_variant()) + weight = fm.weight_dict[prop.get_weight()] + if weight != 400: + font_parts.append(f'{weight}') + + def _normalize_sans(name): + return 'sans-serif' if name in ['sans', 'sans serif'] else name + + def _expand_family_entry(fn): + fn = _normalize_sans(fn) + # prepend generic font families with all configured font names + if fn in fm.font_family_aliases: + # get all of the font names and fix spelling of sans-serif + # (we accept 3 ways CSS only supports 1) + for name in fm.FontManager._expand_aliases(fn): + yield _normalize_sans(name) + # whether a generic name or a family name, it must appear at + # least once + yield fn + + def _get_all_quoted_names(prop): + # only quote specific names, not generic names + return [name if name in fm.font_family_aliases else repr(name) + for entry in prop.get_family() + for name in _expand_family_entry(entry)] + + font_parts.extend([ + f'{_short_float_fmt(prop.get_size())}px', + # ensure expansion, quoting, and dedupe of font names + ", ".join(dict.fromkeys(_get_all_quoted_names(prop))) + ]) + style['font'] = ' '.join(font_parts) + if prop.get_stretch() != 'normal': + style['font-stretch'] = prop.get_stretch() + attrib['style'] = _generate_css(style) + + if mtext and (angle == 0 or mtext.get_rotation_mode() == "anchor"): + # If text anchoring can be supported, get the original + # coordinates and add alignment information. + + # Get anchor coordinates. + transform = mtext.get_transform() + ax, ay = transform.transform(mtext.get_unitless_position()) + ay = self.height - ay + + # Don't do vertical anchor alignment. Most applications do not + # support 'alignment-baseline' yet. Apply the vertical layout + # to the anchor point manually for now. + angle_rad = np.deg2rad(angle) + dir_vert = np.array([np.sin(angle_rad), np.cos(angle_rad)]) + v_offset = np.dot(dir_vert, [(x - ax), (y - ay)]) + ax = ax + v_offset * dir_vert[0] + ay = ay + v_offset * dir_vert[1] + + ha_mpl_to_svg = {'left': 'start', 'right': 'end', + 'center': 'middle'} + style['text-anchor'] = ha_mpl_to_svg[mtext.get_ha()] + + attrib['x'] = _short_float_fmt(ax) + attrib['y'] = _short_float_fmt(ay) + attrib['style'] = _generate_css(style) + attrib['transform'] = _generate_transform([ + ("rotate", (-angle, ax, ay))]) + + else: + attrib['transform'] = _generate_transform([ + ('translate', (x, y)), + ('rotate', (-angle,))]) + + writer.element('text', s, attrib=attrib) + + else: + writer.comment(s) + + width, height, descent, glyphs, rects = \ + self._text2path.mathtext_parser.parse(s, 72, prop) + + # Apply attributes to 'g', not 'text', because we likely have some + # rectangles as well with the same style and transformation. + writer.start('g', + style=_generate_css(style), + transform=_generate_transform([ + ('translate', (x, y)), + ('rotate', (-angle,))]), + ) + + writer.start('text') + + # Sort the characters by font, and output one tspan for each. + spans = {} + for font, fontsize, thetext, new_x, new_y in glyphs: + entry = fm.ttfFontProperty(font) + font_parts = [] + if entry.style != 'normal': + font_parts.append(entry.style) + if entry.variant != 'normal': + font_parts.append(entry.variant) + if entry.weight != 400: + font_parts.append(f'{entry.weight}') + font_parts.extend([ + f'{_short_float_fmt(fontsize)}px', + f'{entry.name!r}', # ensure quoting + ]) + style = {'font': ' '.join(font_parts)} + if entry.stretch != 'normal': + style['font-stretch'] = entry.stretch + style = _generate_css(style) + if thetext == 32: + thetext = 0xa0 # non-breaking space + spans.setdefault(style, []).append((new_x, -new_y, thetext)) + + for style, chars in spans.items(): + chars.sort() + + if len({y for x, y, t in chars}) == 1: # Are all y's the same? + ys = str(chars[0][1]) + else: + ys = ' '.join(str(c[1]) for c in chars) + + attrib = { + 'style': style, + 'x': ' '.join(_short_float_fmt(c[0]) for c in chars), + 'y': ys + } + + writer.element( + 'tspan', + ''.join(chr(c[2]) for c in chars), + attrib=attrib) + + writer.end('text') + + for x, y, width, height in rects: + writer.element( + 'rect', + x=_short_float_fmt(x), + y=_short_float_fmt(-y-1), + width=_short_float_fmt(width), + height=_short_float_fmt(height) + ) + + writer.end('g') + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + # docstring inherited + + clip_attrs = self._get_clip_attrs(gc) + if clip_attrs: + # Cannot apply clip-path directly to the text, because + # it has a transformation + self.writer.start('g', **clip_attrs) + + if gc.get_url() is not None: + self.writer.start('a', {'xlink:href': gc.get_url()}) + + if mpl.rcParams['svg.fonttype'] == 'path': + self._draw_text_as_path(gc, x, y, s, prop, angle, ismath, mtext) + else: + self._draw_text_as_text(gc, x, y, s, prop, angle, ismath, mtext) + + if gc.get_url() is not None: + self.writer.end('a') + + if clip_attrs: + self.writer.end('g') + + def flipy(self): + # docstring inherited + return True + + def get_canvas_width_height(self): + # docstring inherited + return self.width, self.height + + def get_text_width_height_descent(self, s, prop, ismath): + # docstring inherited + return self._text2path.get_text_width_height_descent(s, prop, ismath) + + +class FigureCanvasSVG(FigureCanvasBase): + filetypes = {'svg': 'Scalable Vector Graphics', + 'svgz': 'Scalable Vector Graphics'} + + fixed_dpi = 72 + + def print_svg(self, filename, *, bbox_inches_restore=None, metadata=None): + """ + Parameters + ---------- + filename : str or path-like or file-like + Output target; if a string, a file will be opened for writing. + + metadata : dict[str, Any], optional + Metadata in the SVG file defined as key-value pairs of strings, + datetimes, or lists of strings, e.g., ``{'Creator': 'My software', + 'Contributor': ['Me', 'My Friend'], 'Title': 'Awesome'}``. + + The standard keys and their value types are: + + * *str*: ``'Coverage'``, ``'Description'``, ``'Format'``, + ``'Identifier'``, ``'Language'``, ``'Relation'``, ``'Source'``, + ``'Title'``, and ``'Type'``. + * *str* or *list of str*: ``'Contributor'``, ``'Creator'``, + ``'Keywords'``, ``'Publisher'``, and ``'Rights'``. + * *str*, *date*, *datetime*, or *tuple* of same: ``'Date'``. If a + non-*str*, then it will be formatted as ISO 8601. + + Values have been predefined for ``'Creator'``, ``'Date'``, + ``'Format'``, and ``'Type'``. They can be removed by setting them + to `None`. + + Information is encoded as `Dublin Core Metadata`__. + + .. _DC: https://www.dublincore.org/specifications/dublin-core/ + + __ DC_ + """ + with cbook.open_file_cm(filename, "w", encoding="utf-8") as fh: + if not cbook.file_requires_unicode(fh): + fh = codecs.getwriter('utf-8')(fh) + dpi = self.figure.dpi + self.figure.dpi = 72 + width, height = self.figure.get_size_inches() + w, h = width * 72, height * 72 + renderer = MixedModeRenderer( + self.figure, width, height, dpi, + RendererSVG(w, h, fh, image_dpi=dpi, metadata=metadata), + bbox_inches_restore=bbox_inches_restore) + self.figure.draw(renderer) + renderer.finalize() + + def print_svgz(self, filename, **kwargs): + with cbook.open_file_cm(filename, "wb") as fh, \ + gzip.GzipFile(mode='w', fileobj=fh) as gzipwriter: + return self.print_svg(gzipwriter, **kwargs) + + def get_default_filetype(self): + return 'svg' + + def draw(self): + self.figure.draw_without_rendering() + return super().draw() + + +FigureManagerSVG = FigureManagerBase + + +svgProlog = """\ + + +""" + + +@_Backend.export +class _BackendSVG(_Backend): + backend_version = mpl.__version__ + FigureCanvas = FigureCanvasSVG diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_template.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_template.py new file mode 100644 index 00000000..d997ec16 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_template.py @@ -0,0 +1,213 @@ +""" +A fully functional, do-nothing backend intended as a template for backend +writers. It is fully functional in that you can select it as a backend e.g. +with :: + + import matplotlib + matplotlib.use("template") + +and your program will (should!) run without error, though no output is +produced. This provides a starting point for backend writers; you can +selectively implement drawing methods (`~.RendererTemplate.draw_path`, +`~.RendererTemplate.draw_image`, etc.) and slowly see your figure come to life +instead having to have a full-blown implementation before getting any results. + +Copy this file to a directory outside the Matplotlib source tree, somewhere +where Python can import it (by adding the directory to your ``sys.path`` or by +packaging it as a normal Python package); if the backend is importable as +``import my.backend`` you can then select it using :: + + import matplotlib + matplotlib.use("module://my.backend") + +If your backend implements support for saving figures (i.e. has a `print_xyz` +method), you can register it as the default handler for a given file type:: + + from matplotlib.backend_bases import register_backend + register_backend('xyz', 'my_backend', 'XYZ File Format') + ... + plt.savefig("figure.xyz") +""" + +from matplotlib import _api +from matplotlib._pylab_helpers import Gcf +from matplotlib.backend_bases import ( + FigureCanvasBase, FigureManagerBase, GraphicsContextBase, RendererBase) +from matplotlib.figure import Figure + + +class RendererTemplate(RendererBase): + """ + The renderer handles drawing/rendering operations. + + This is a minimal do-nothing class that can be used to get started when + writing a new backend. Refer to `.backend_bases.RendererBase` for + documentation of the methods. + """ + + def __init__(self, dpi): + super().__init__() + self.dpi = dpi + + def draw_path(self, gc, path, transform, rgbFace=None): + pass + + # draw_markers is optional, and we get more correct relative + # timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it +# def draw_markers(self, gc, marker_path, marker_trans, path, trans, +# rgbFace=None): +# pass + + # draw_path_collection is optional, and we get more correct + # relative timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it +# def draw_path_collection(self, gc, master_transform, paths, +# all_transforms, offsets, offset_trans, +# facecolors, edgecolors, linewidths, linestyles, +# antialiaseds): +# pass + + # draw_quad_mesh is optional, and we get more correct + # relative timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it +# def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight, +# coordinates, offsets, offsetTrans, facecolors, +# antialiased, edgecolors): +# pass + + def draw_image(self, gc, x, y, im): + pass + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + pass + + def flipy(self): + # docstring inherited + return True + + def get_canvas_width_height(self): + # docstring inherited + return 100, 100 + + def get_text_width_height_descent(self, s, prop, ismath): + return 1, 1, 1 + + def new_gc(self): + # docstring inherited + return GraphicsContextTemplate() + + def points_to_pixels(self, points): + # if backend doesn't have dpi, e.g., postscript or svg + return points + # elif backend assumes a value for pixels_per_inch + # return points/72.0 * self.dpi.get() * pixels_per_inch/72.0 + # else + # return points/72.0 * self.dpi.get() + + +class GraphicsContextTemplate(GraphicsContextBase): + """ + The graphics context provides the color, line styles, etc. See the cairo + and postscript backends for examples of mapping the graphics context + attributes (cap styles, join styles, line widths, colors) to a particular + backend. In cairo this is done by wrapping a cairo.Context object and + forwarding the appropriate calls to it using a dictionary mapping styles + to gdk constants. In Postscript, all the work is done by the renderer, + mapping line styles to postscript calls. + + If it's more appropriate to do the mapping at the renderer level (as in + the postscript backend), you don't need to override any of the GC methods. + If it's more appropriate to wrap an instance (as in the cairo backend) and + do the mapping here, you'll need to override several of the setter + methods. + + The base GraphicsContext stores colors as an RGB tuple on the unit + interval, e.g., (0.5, 0.0, 1.0). You may need to map this to colors + appropriate for your backend. + """ + + +######################################################################## +# +# The following functions and classes are for pyplot and implement +# window/figure managers, etc. +# +######################################################################## + + +class FigureManagerTemplate(FigureManagerBase): + """ + Helper class for pyplot mode, wraps everything up into a neat bundle. + + For non-interactive backends, the base class is sufficient. For + interactive backends, see the documentation of the `.FigureManagerBase` + class for the list of methods that can/should be overridden. + """ + + +class FigureCanvasTemplate(FigureCanvasBase): + """ + The canvas the figure renders into. Calls the draw and print fig + methods, creates the renderers, etc. + + Note: GUI templates will want to connect events for button presses, + mouse movements and key presses to functions that call the base + class methods button_press_event, button_release_event, + motion_notify_event, key_press_event, and key_release_event. See the + implementations of the interactive backends for examples. + + Attributes + ---------- + figure : `~matplotlib.figure.Figure` + A high-level Figure instance + """ + + # The instantiated manager class. For further customization, + # ``FigureManager.create_with_canvas`` can also be overridden; see the + # wx-based backends for an example. + manager_class = FigureManagerTemplate + + def draw(self): + """ + Draw the figure using the renderer. + + It is important that this method actually walk the artist tree + even if not output is produced because this will trigger + deferred work (like computing limits auto-limits and tick + values) that users may want access to before saving to disk. + """ + renderer = RendererTemplate(self.figure.dpi) + self.figure.draw(renderer) + + # You should provide a print_xxx function for every file format + # you can write. + + # If the file type is not in the base set of filetypes, + # you should add it to the class-scope filetypes dictionary as follows: + filetypes = {**FigureCanvasBase.filetypes, 'foo': 'My magic Foo format'} + + def print_foo(self, filename, **kwargs): + """ + Write out format foo. + + This method is normally called via `.Figure.savefig` and + `.FigureCanvasBase.print_figure`, which take care of setting the figure + facecolor, edgecolor, and dpi to the desired output values, and will + restore them to the original values. Therefore, `print_foo` does not + need to handle these settings. + """ + self.draw() + + def get_default_filetype(self): + return 'foo' + + +######################################################################## +# +# Now just provide the standard names that backend.__init__ is expecting +# +######################################################################## + +FigureCanvas = FigureCanvasTemplate +FigureManager = FigureManagerTemplate diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkagg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkagg.py new file mode 100644 index 00000000..f95b6011 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkagg.py @@ -0,0 +1,20 @@ +from . import _backend_tk +from .backend_agg import FigureCanvasAgg +from ._backend_tk import _BackendTk, FigureCanvasTk +from ._backend_tk import ( # noqa: F401 # pylint: disable=W0611 + FigureManagerTk, NavigationToolbar2Tk) + + +class FigureCanvasTkAgg(FigureCanvasAgg, FigureCanvasTk): + def draw(self): + super().draw() + self.blit() + + def blit(self, bbox=None): + _backend_tk.blit(self._tkphoto, self.renderer.buffer_rgba(), + (0, 1, 2, 3), bbox=bbox) + + +@_BackendTk.export +class _BackendTkAgg(_BackendTk): + FigureCanvas = FigureCanvasTkAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkcairo.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkcairo.py new file mode 100644 index 00000000..a6951c03 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_tkcairo.py @@ -0,0 +1,26 @@ +import sys + +import numpy as np + +from . import _backend_tk +from .backend_cairo import cairo, FigureCanvasCairo +from ._backend_tk import _BackendTk, FigureCanvasTk + + +class FigureCanvasTkCairo(FigureCanvasCairo, FigureCanvasTk): + def draw(self): + width = int(self.figure.bbox.width) + height = int(self.figure.bbox.height) + surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) + self._renderer.set_context(cairo.Context(surface)) + self._renderer.dpi = self.figure.dpi + self.figure.draw(self._renderer) + buf = np.reshape(surface.get_data(), (height, width, 4)) + _backend_tk.blit( + self._tkphoto, buf, + (2, 1, 0, 3) if sys.byteorder == "little" else (1, 2, 3, 0)) + + +@_BackendTk.export +class _BackendTkCairo(_BackendTk): + FigureCanvas = FigureCanvasTkCairo diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg.py new file mode 100644 index 00000000..dfc5747e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg.py @@ -0,0 +1,328 @@ +"""Displays Agg images in the browser, with interactivity.""" + +# The WebAgg backend is divided into two modules: +# +# - `backend_webagg_core.py` contains code necessary to embed a WebAgg +# plot inside of a web application, and communicate in an abstract +# way over a web socket. +# +# - `backend_webagg.py` contains a concrete implementation of a basic +# application, implemented with tornado. + +from contextlib import contextmanager +import errno +from io import BytesIO +import json +import mimetypes +from pathlib import Path +import random +import sys +import signal +import threading + +try: + import tornado +except ImportError as err: + raise RuntimeError("The WebAgg backend requires Tornado.") from err + +import tornado.web +import tornado.ioloop +import tornado.websocket + +import matplotlib as mpl +from matplotlib.backend_bases import _Backend +from matplotlib._pylab_helpers import Gcf +from . import backend_webagg_core as core +from .backend_webagg_core import ( # noqa: F401 # pylint: disable=W0611 + TimerAsyncio, TimerTornado) + + +webagg_server_thread = threading.Thread( + target=lambda: tornado.ioloop.IOLoop.instance().start()) + + +class FigureManagerWebAgg(core.FigureManagerWebAgg): + _toolbar2_class = core.NavigationToolbar2WebAgg + + @classmethod + def pyplot_show(cls, *, block=None): + WebAggApplication.initialize() + + url = "http://{address}:{port}{prefix}".format( + address=WebAggApplication.address, + port=WebAggApplication.port, + prefix=WebAggApplication.url_prefix) + + if mpl.rcParams['webagg.open_in_browser']: + import webbrowser + if not webbrowser.open(url): + print(f"To view figure, visit {url}") + else: + print(f"To view figure, visit {url}") + + WebAggApplication.start() + + +class FigureCanvasWebAgg(core.FigureCanvasWebAggCore): + manager_class = FigureManagerWebAgg + + +class WebAggApplication(tornado.web.Application): + initialized = False + started = False + + class FavIcon(tornado.web.RequestHandler): + def get(self): + self.set_header('Content-Type', 'image/png') + self.write(Path(mpl.get_data_path(), + 'images/matplotlib.png').read_bytes()) + + class SingleFigurePage(tornado.web.RequestHandler): + def __init__(self, application, request, *, url_prefix='', **kwargs): + self.url_prefix = url_prefix + super().__init__(application, request, **kwargs) + + def get(self, fignum): + fignum = int(fignum) + manager = Gcf.get_fig_manager(fignum) + + ws_uri = f'ws://{self.request.host}{self.url_prefix}/' + self.render( + "single_figure.html", + prefix=self.url_prefix, + ws_uri=ws_uri, + fig_id=fignum, + toolitems=core.NavigationToolbar2WebAgg.toolitems, + canvas=manager.canvas) + + class AllFiguresPage(tornado.web.RequestHandler): + def __init__(self, application, request, *, url_prefix='', **kwargs): + self.url_prefix = url_prefix + super().__init__(application, request, **kwargs) + + def get(self): + ws_uri = f'ws://{self.request.host}{self.url_prefix}/' + self.render( + "all_figures.html", + prefix=self.url_prefix, + ws_uri=ws_uri, + figures=sorted(Gcf.figs.items()), + toolitems=core.NavigationToolbar2WebAgg.toolitems) + + class MplJs(tornado.web.RequestHandler): + def get(self): + self.set_header('Content-Type', 'application/javascript') + + js_content = core.FigureManagerWebAgg.get_javascript() + + self.write(js_content) + + class Download(tornado.web.RequestHandler): + def get(self, fignum, fmt): + fignum = int(fignum) + manager = Gcf.get_fig_manager(fignum) + self.set_header( + 'Content-Type', mimetypes.types_map.get(fmt, 'binary')) + buff = BytesIO() + manager.canvas.figure.savefig(buff, format=fmt) + self.write(buff.getvalue()) + + class WebSocket(tornado.websocket.WebSocketHandler): + supports_binary = True + + def open(self, fignum): + self.fignum = int(fignum) + self.manager = Gcf.get_fig_manager(self.fignum) + self.manager.add_web_socket(self) + if hasattr(self, 'set_nodelay'): + self.set_nodelay(True) + + def on_close(self): + self.manager.remove_web_socket(self) + + def on_message(self, message): + message = json.loads(message) + # The 'supports_binary' message is on a client-by-client + # basis. The others affect the (shared) canvas as a + # whole. + if message['type'] == 'supports_binary': + self.supports_binary = message['value'] + else: + manager = Gcf.get_fig_manager(self.fignum) + # It is possible for a figure to be closed, + # but a stale figure UI is still sending messages + # from the browser. + if manager is not None: + manager.handle_json(message) + + def send_json(self, content): + self.write_message(json.dumps(content)) + + def send_binary(self, blob): + if self.supports_binary: + self.write_message(blob, binary=True) + else: + data_uri = "data:image/png;base64,{}".format( + blob.encode('base64').replace('\n', '')) + self.write_message(data_uri) + + def __init__(self, url_prefix=''): + if url_prefix: + assert url_prefix[0] == '/' and url_prefix[-1] != '/', \ + 'url_prefix must start with a "/" and not end with one.' + + super().__init__( + [ + # Static files for the CSS and JS + (url_prefix + r'/_static/(.*)', + tornado.web.StaticFileHandler, + {'path': core.FigureManagerWebAgg.get_static_file_path()}), + + # Static images for the toolbar + (url_prefix + r'/_images/(.*)', + tornado.web.StaticFileHandler, + {'path': Path(mpl.get_data_path(), 'images')}), + + # A Matplotlib favicon + (url_prefix + r'/favicon.ico', self.FavIcon), + + # The page that contains all of the pieces + (url_prefix + r'/([0-9]+)', self.SingleFigurePage, + {'url_prefix': url_prefix}), + + # The page that contains all of the figures + (url_prefix + r'/?', self.AllFiguresPage, + {'url_prefix': url_prefix}), + + (url_prefix + r'/js/mpl.js', self.MplJs), + + # Sends images and events to the browser, and receives + # events from the browser + (url_prefix + r'/([0-9]+)/ws', self.WebSocket), + + # Handles the downloading (i.e., saving) of static images + (url_prefix + r'/([0-9]+)/download.([a-z0-9.]+)', + self.Download), + ], + template_path=core.FigureManagerWebAgg.get_static_file_path()) + + @classmethod + def initialize(cls, url_prefix='', port=None, address=None): + if cls.initialized: + return + + # Create the class instance + app = cls(url_prefix=url_prefix) + + cls.url_prefix = url_prefix + + # This port selection algorithm is borrowed, more or less + # verbatim, from IPython. + def random_ports(port, n): + """ + Generate a list of n random ports near the given port. + + The first 5 ports will be sequential, and the remaining n-5 will be + randomly selected in the range [port-2*n, port+2*n]. + """ + for i in range(min(5, n)): + yield port + i + for i in range(n - 5): + yield port + random.randint(-2 * n, 2 * n) + + if address is None: + cls.address = mpl.rcParams['webagg.address'] + else: + cls.address = address + cls.port = mpl.rcParams['webagg.port'] + for port in random_ports(cls.port, + mpl.rcParams['webagg.port_retries']): + try: + app.listen(port, cls.address) + except OSError as e: + if e.errno != errno.EADDRINUSE: + raise + else: + cls.port = port + break + else: + raise SystemExit( + "The webagg server could not be started because an available " + "port could not be found") + + cls.initialized = True + + @classmethod + def start(cls): + import asyncio + try: + asyncio.get_running_loop() + except RuntimeError: + pass + else: + cls.started = True + + if cls.started: + return + + """ + IOLoop.running() was removed as of Tornado 2.4; see for example + https://groups.google.com/forum/#!topic/python-tornado/QLMzkpQBGOY + Thus there is no correct way to check if the loop has already been + launched. We may end up with two concurrently running loops in that + unlucky case with all the expected consequences. + """ + ioloop = tornado.ioloop.IOLoop.instance() + + def shutdown(): + ioloop.stop() + print("Server is stopped") + sys.stdout.flush() + cls.started = False + + @contextmanager + def catch_sigint(): + old_handler = signal.signal( + signal.SIGINT, + lambda sig, frame: ioloop.add_callback_from_signal(shutdown)) + try: + yield + finally: + signal.signal(signal.SIGINT, old_handler) + + # Set the flag to True *before* blocking on ioloop.start() + cls.started = True + + print("Press Ctrl+C to stop WebAgg server") + sys.stdout.flush() + with catch_sigint(): + ioloop.start() + + +def ipython_inline_display(figure): + import tornado.template + + WebAggApplication.initialize() + import asyncio + try: + asyncio.get_running_loop() + except RuntimeError: + if not webagg_server_thread.is_alive(): + webagg_server_thread.start() + + fignum = figure.number + tpl = Path(core.FigureManagerWebAgg.get_static_file_path(), + "ipython_inline_figure.html").read_text() + t = tornado.template.Template(tpl) + return t.generate( + prefix=WebAggApplication.url_prefix, + fig_id=fignum, + toolitems=core.NavigationToolbar2WebAgg.toolitems, + canvas=figure.canvas, + port=WebAggApplication.port).decode('utf-8') + + +@_Backend.export +class _BackendWebAgg(_Backend): + FigureCanvas = FigureCanvasWebAgg + FigureManager = FigureManagerWebAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py new file mode 100644 index 00000000..4ceac169 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py @@ -0,0 +1,517 @@ +"""Displays Agg images in the browser, with interactivity.""" +# The WebAgg backend is divided into two modules: +# +# - `backend_webagg_core.py` contains code necessary to embed a WebAgg +# plot inside of a web application, and communicate in an abstract +# way over a web socket. +# +# - `backend_webagg.py` contains a concrete implementation of a basic +# application, implemented with asyncio. + +import asyncio +import datetime +from io import BytesIO, StringIO +import json +import logging +import os +from pathlib import Path + +import numpy as np +from PIL import Image + +from matplotlib import _api, backend_bases, backend_tools +from matplotlib.backends import backend_agg +from matplotlib.backend_bases import ( + _Backend, KeyEvent, LocationEvent, MouseEvent, ResizeEvent) + +_log = logging.getLogger(__name__) + +_SPECIAL_KEYS_LUT = {'Alt': 'alt', + 'AltGraph': 'alt', + 'CapsLock': 'caps_lock', + 'Control': 'control', + 'Meta': 'meta', + 'NumLock': 'num_lock', + 'ScrollLock': 'scroll_lock', + 'Shift': 'shift', + 'Super': 'super', + 'Enter': 'enter', + 'Tab': 'tab', + 'ArrowDown': 'down', + 'ArrowLeft': 'left', + 'ArrowRight': 'right', + 'ArrowUp': 'up', + 'End': 'end', + 'Home': 'home', + 'PageDown': 'pagedown', + 'PageUp': 'pageup', + 'Backspace': 'backspace', + 'Delete': 'delete', + 'Insert': 'insert', + 'Escape': 'escape', + 'Pause': 'pause', + 'Select': 'select', + 'Dead': 'dead', + 'F1': 'f1', + 'F2': 'f2', + 'F3': 'f3', + 'F4': 'f4', + 'F5': 'f5', + 'F6': 'f6', + 'F7': 'f7', + 'F8': 'f8', + 'F9': 'f9', + 'F10': 'f10', + 'F11': 'f11', + 'F12': 'f12'} + + +def _handle_key(key): + """Handle key values""" + value = key[key.index('k') + 1:] + if 'shift+' in key: + if len(value) == 1: + key = key.replace('shift+', '') + if value in _SPECIAL_KEYS_LUT: + value = _SPECIAL_KEYS_LUT[value] + key = key[:key.index('k')] + value + return key + + +class TimerTornado(backend_bases.TimerBase): + def __init__(self, *args, **kwargs): + self._timer = None + super().__init__(*args, **kwargs) + + def _timer_start(self): + import tornado + + self._timer_stop() + if self._single: + ioloop = tornado.ioloop.IOLoop.instance() + self._timer = ioloop.add_timeout( + datetime.timedelta(milliseconds=self.interval), + self._on_timer) + else: + self._timer = tornado.ioloop.PeriodicCallback( + self._on_timer, + max(self.interval, 1e-6)) + self._timer.start() + + def _timer_stop(self): + import tornado + + if self._timer is None: + return + elif self._single: + ioloop = tornado.ioloop.IOLoop.instance() + ioloop.remove_timeout(self._timer) + else: + self._timer.stop() + self._timer = None + + def _timer_set_interval(self): + # Only stop and restart it if the timer has already been started + if self._timer is not None: + self._timer_stop() + self._timer_start() + + +class TimerAsyncio(backend_bases.TimerBase): + def __init__(self, *args, **kwargs): + self._task = None + super().__init__(*args, **kwargs) + + async def _timer_task(self, interval): + while True: + try: + await asyncio.sleep(interval) + self._on_timer() + + if self._single: + break + except asyncio.CancelledError: + break + + def _timer_start(self): + self._timer_stop() + + self._task = asyncio.ensure_future( + self._timer_task(max(self.interval / 1_000., 1e-6)) + ) + + def _timer_stop(self): + if self._task is not None: + self._task.cancel() + self._task = None + + def _timer_set_interval(self): + # Only stop and restart it if the timer has already been started + if self._task is not None: + self._timer_stop() + self._timer_start() + + +class FigureCanvasWebAggCore(backend_agg.FigureCanvasAgg): + manager_class = _api.classproperty(lambda cls: FigureManagerWebAgg) + _timer_cls = TimerAsyncio + # Webagg and friends having the right methods, but still + # having bugs in practice. Do not advertise that it works until + # we can debug this. + supports_blit = False + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Set to True when the renderer contains data that is newer + # than the PNG buffer. + self._png_is_old = True + # Set to True by the `refresh` message so that the next frame + # sent to the clients will be a full frame. + self._force_full = True + # The last buffer, for diff mode. + self._last_buff = np.empty((0, 0)) + # Store the current image mode so that at any point, clients can + # request the information. This should be changed by calling + # self.set_image_mode(mode) so that the notification can be given + # to the connected clients. + self._current_image_mode = 'full' + # Track mouse events to fill in the x, y position of key events. + self._last_mouse_xy = (None, None) + + def show(self): + # show the figure window + from matplotlib.pyplot import show + show() + + def draw(self): + self._png_is_old = True + try: + super().draw() + finally: + self.manager.refresh_all() # Swap the frames. + + def blit(self, bbox=None): + self._png_is_old = True + self.manager.refresh_all() + + def draw_idle(self): + self.send_event("draw") + + def set_cursor(self, cursor): + # docstring inherited + cursor = _api.check_getitem({ + backend_tools.Cursors.HAND: 'pointer', + backend_tools.Cursors.POINTER: 'default', + backend_tools.Cursors.SELECT_REGION: 'crosshair', + backend_tools.Cursors.MOVE: 'move', + backend_tools.Cursors.WAIT: 'wait', + backend_tools.Cursors.RESIZE_HORIZONTAL: 'ew-resize', + backend_tools.Cursors.RESIZE_VERTICAL: 'ns-resize', + }, cursor=cursor) + self.send_event('cursor', cursor=cursor) + + def set_image_mode(self, mode): + """ + Set the image mode for any subsequent images which will be sent + to the clients. The modes may currently be either 'full' or 'diff'. + + Note: diff images may not contain transparency, therefore upon + draw this mode may be changed if the resulting image has any + transparent component. + """ + _api.check_in_list(['full', 'diff'], mode=mode) + if self._current_image_mode != mode: + self._current_image_mode = mode + self.handle_send_image_mode(None) + + def get_diff_image(self): + if self._png_is_old: + renderer = self.get_renderer() + + pixels = np.asarray(renderer.buffer_rgba()) + # The buffer is created as type uint32 so that entire + # pixels can be compared in one numpy call, rather than + # needing to compare each plane separately. + buff = pixels.view(np.uint32).squeeze(2) + + if (self._force_full + # If the buffer has changed size we need to do a full draw. + or buff.shape != self._last_buff.shape + # If any pixels have transparency, we need to force a full + # draw as we cannot overlay new on top of old. + or (pixels[:, :, 3] != 255).any()): + self.set_image_mode('full') + output = buff + else: + self.set_image_mode('diff') + diff = buff != self._last_buff + output = np.where(diff, buff, 0) + + # Store the current buffer so we can compute the next diff. + self._last_buff = buff.copy() + self._force_full = False + self._png_is_old = False + + data = output.view(dtype=np.uint8).reshape((*output.shape, 4)) + with BytesIO() as png: + Image.fromarray(data).save(png, format="png") + return png.getvalue() + + def handle_event(self, event): + e_type = event['type'] + handler = getattr(self, f'handle_{e_type}', + self.handle_unknown_event) + return handler(event) + + def handle_unknown_event(self, event): + _log.warning('Unhandled message type %s. %s', event["type"], event) + + def handle_ack(self, event): + # Network latency tends to decrease if traffic is flowing + # in both directions. Therefore, the browser sends back + # an "ack" message after each image frame is received. + # This could also be used as a simple sanity check in the + # future, but for now the performance increase is enough + # to justify it, even if the server does nothing with it. + pass + + def handle_draw(self, event): + self.draw() + + def _handle_mouse(self, event): + x = event['x'] + y = event['y'] + y = self.get_renderer().height - y + self._last_mouse_xy = x, y + # JavaScript button numbers and Matplotlib button numbers are off by 1. + button = event['button'] + 1 + + e_type = event['type'] + modifiers = event['modifiers'] + guiEvent = event.get('guiEvent') + if e_type in ['button_press', 'button_release']: + MouseEvent(e_type + '_event', self, x, y, button, + modifiers=modifiers, guiEvent=guiEvent)._process() + elif e_type == 'dblclick': + MouseEvent('button_press_event', self, x, y, button, dblclick=True, + modifiers=modifiers, guiEvent=guiEvent)._process() + elif e_type == 'scroll': + MouseEvent('scroll_event', self, x, y, step=event['step'], + modifiers=modifiers, guiEvent=guiEvent)._process() + elif e_type == 'motion_notify': + MouseEvent(e_type + '_event', self, x, y, + modifiers=modifiers, guiEvent=guiEvent)._process() + elif e_type in ['figure_enter', 'figure_leave']: + LocationEvent(e_type + '_event', self, x, y, + modifiers=modifiers, guiEvent=guiEvent)._process() + handle_button_press = handle_button_release = handle_dblclick = \ + handle_figure_enter = handle_figure_leave = handle_motion_notify = \ + handle_scroll = _handle_mouse + + def _handle_key(self, event): + KeyEvent(event['type'] + '_event', self, + _handle_key(event['key']), *self._last_mouse_xy, + guiEvent=event.get('guiEvent'))._process() + handle_key_press = handle_key_release = _handle_key + + def handle_toolbar_button(self, event): + # TODO: Be more suspicious of the input + getattr(self.toolbar, event['name'])() + + def handle_refresh(self, event): + figure_label = self.figure.get_label() + if not figure_label: + figure_label = f"Figure {self.manager.num}" + self.send_event('figure_label', label=figure_label) + self._force_full = True + if self.toolbar: + # Normal toolbar init would refresh this, but it happens before the + # browser canvas is set up. + self.toolbar.set_history_buttons() + self.draw_idle() + + def handle_resize(self, event): + x = int(event.get('width', 800)) * self.device_pixel_ratio + y = int(event.get('height', 800)) * self.device_pixel_ratio + fig = self.figure + # An attempt at approximating the figure size in pixels. + fig.set_size_inches(x / fig.dpi, y / fig.dpi, forward=False) + # Acknowledge the resize, and force the viewer to update the + # canvas size to the figure's new size (which is hopefully + # identical or within a pixel or so). + self._png_is_old = True + self.manager.resize(*fig.bbox.size, forward=False) + ResizeEvent('resize_event', self)._process() + self.draw_idle() + + def handle_send_image_mode(self, event): + # The client requests notification of what the current image mode is. + self.send_event('image_mode', mode=self._current_image_mode) + + def handle_set_device_pixel_ratio(self, event): + self._handle_set_device_pixel_ratio(event.get('device_pixel_ratio', 1)) + + def handle_set_dpi_ratio(self, event): + # This handler is for backwards-compatibility with older ipympl. + self._handle_set_device_pixel_ratio(event.get('dpi_ratio', 1)) + + def _handle_set_device_pixel_ratio(self, device_pixel_ratio): + if self._set_device_pixel_ratio(device_pixel_ratio): + self._force_full = True + self.draw_idle() + + def send_event(self, event_type, **kwargs): + if self.manager: + self.manager._send_event(event_type, **kwargs) + + +_ALLOWED_TOOL_ITEMS = { + 'home', + 'back', + 'forward', + 'pan', + 'zoom', + 'download', + None, +} + + +class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2): + + # Use the standard toolbar items + download button + toolitems = [ + (text, tooltip_text, image_file, name_of_method) + for text, tooltip_text, image_file, name_of_method + in (*backend_bases.NavigationToolbar2.toolitems, + ('Download', 'Download plot', 'filesave', 'download')) + if name_of_method in _ALLOWED_TOOL_ITEMS + ] + + def __init__(self, canvas): + self.message = '' + super().__init__(canvas) + + def set_message(self, message): + if message != self.message: + self.canvas.send_event("message", message=message) + self.message = message + + def draw_rubberband(self, event, x0, y0, x1, y1): + self.canvas.send_event("rubberband", x0=x0, y0=y0, x1=x1, y1=y1) + + def remove_rubberband(self): + self.canvas.send_event("rubberband", x0=-1, y0=-1, x1=-1, y1=-1) + + def save_figure(self, *args): + """Save the current figure""" + self.canvas.send_event('save') + + def pan(self): + super().pan() + self.canvas.send_event('navigate_mode', mode=self.mode.name) + + def zoom(self): + super().zoom() + self.canvas.send_event('navigate_mode', mode=self.mode.name) + + def set_history_buttons(self): + can_backward = self._nav_stack._pos > 0 + can_forward = self._nav_stack._pos < len(self._nav_stack) - 1 + self.canvas.send_event('history_buttons', + Back=can_backward, Forward=can_forward) + + +class FigureManagerWebAgg(backend_bases.FigureManagerBase): + # This must be None to not break ipympl + _toolbar2_class = None + ToolbarCls = NavigationToolbar2WebAgg + _window_title = "Matplotlib" + + def __init__(self, canvas, num): + self.web_sockets = set() + super().__init__(canvas, num) + + def show(self): + pass + + def resize(self, w, h, forward=True): + self._send_event( + 'resize', + size=(w / self.canvas.device_pixel_ratio, + h / self.canvas.device_pixel_ratio), + forward=forward) + + def set_window_title(self, title): + self._send_event('figure_label', label=title) + self._window_title = title + + def get_window_title(self): + return self._window_title + + # The following methods are specific to FigureManagerWebAgg + + def add_web_socket(self, web_socket): + assert hasattr(web_socket, 'send_binary') + assert hasattr(web_socket, 'send_json') + self.web_sockets.add(web_socket) + self.resize(*self.canvas.figure.bbox.size) + self._send_event('refresh') + + def remove_web_socket(self, web_socket): + self.web_sockets.remove(web_socket) + + def handle_json(self, content): + self.canvas.handle_event(content) + + def refresh_all(self): + if self.web_sockets: + diff = self.canvas.get_diff_image() + if diff is not None: + for s in self.web_sockets: + s.send_binary(diff) + + @classmethod + def get_javascript(cls, stream=None): + if stream is None: + output = StringIO() + else: + output = stream + + output.write((Path(__file__).parent / "web_backend/js/mpl.js") + .read_text(encoding="utf-8")) + + toolitems = [] + for name, tooltip, image, method in cls.ToolbarCls.toolitems: + if name is None: + toolitems.append(['', '', '', '']) + else: + toolitems.append([name, tooltip, image, method]) + output.write(f"mpl.toolbar_items = {json.dumps(toolitems)};\n\n") + + extensions = [] + for filetype, ext in sorted(FigureCanvasWebAggCore. + get_supported_filetypes_grouped(). + items()): + extensions.append(ext[0]) + output.write(f"mpl.extensions = {json.dumps(extensions)};\n\n") + + output.write("mpl.default_extension = {};".format( + json.dumps(FigureCanvasWebAggCore.get_default_filetype()))) + + if stream is None: + return output.getvalue() + + @classmethod + def get_static_file_path(cls): + return os.path.join(os.path.dirname(__file__), 'web_backend') + + def _send_event(self, event_type, **kwargs): + payload = {'type': event_type, **kwargs} + for s in self.web_sockets: + s.send_json(payload) + + +@_Backend.export +class _BackendWebAggCoreAgg(_Backend): + FigureCanvas = FigureCanvasWebAggCore + FigureManager = FigureManagerWebAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wx.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wx.py new file mode 100644 index 00000000..d39edf40 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wx.py @@ -0,0 +1,1364 @@ +""" +A wxPython backend for matplotlib. + +Originally contributed by Jeremy O'Donoghue (jeremy@o-donoghue.com) and John +Hunter (jdhunter@ace.bsd.uchicago.edu). + +Copyright (C) Jeremy O'Donoghue & John Hunter, 2003-4. +""" + +import functools +import logging +import math +import pathlib +import sys +import weakref + +import numpy as np +import PIL.Image + +import matplotlib as mpl +from matplotlib.backend_bases import ( + _Backend, FigureCanvasBase, FigureManagerBase, + GraphicsContextBase, MouseButton, NavigationToolbar2, RendererBase, + TimerBase, ToolContainerBase, cursors, + CloseEvent, KeyEvent, LocationEvent, MouseEvent, ResizeEvent) + +from matplotlib import _api, cbook, backend_tools, _c_internal_utils +from matplotlib._pylab_helpers import Gcf +from matplotlib.path import Path +from matplotlib.transforms import Affine2D + +import wx +import wx.svg + +_log = logging.getLogger(__name__) + +# the True dots per inch on the screen; should be display dependent; see +# http://groups.google.com/d/msg/comp.lang.postscript/-/omHAc9FEuAsJ?hl=en +# for some info about screen dpi +PIXELS_PER_INCH = 75 + + +# lru_cache holds a reference to the App and prevents it from being gc'ed. +@functools.lru_cache(1) +def _create_wxapp(): + wxapp = wx.App(False) + wxapp.SetExitOnFrameDelete(True) + cbook._setup_new_guiapp() + # Set per-process DPI awareness. This is a NoOp except in MSW + _c_internal_utils.Win32_SetProcessDpiAwareness_max() + return wxapp + + +class TimerWx(TimerBase): + """Subclass of `.TimerBase` using wx.Timer events.""" + + def __init__(self, *args, **kwargs): + self._timer = wx.Timer() + self._timer.Notify = self._on_timer + super().__init__(*args, **kwargs) + + def _timer_start(self): + self._timer.Start(self._interval, self._single) + + def _timer_stop(self): + self._timer.Stop() + + def _timer_set_interval(self): + if self._timer.IsRunning(): + self._timer_start() # Restart with new interval. + + +@_api.deprecated( + "2.0", name="wx", obj_type="backend", removal="the future", + alternative="wxagg", + addendum="See the Matplotlib usage FAQ for more info on backends.") +class RendererWx(RendererBase): + """ + The renderer handles all the drawing primitives using a graphics + context instance that controls the colors/styles. It acts as the + 'renderer' instance used by many classes in the hierarchy. + """ + # In wxPython, drawing is performed on a wxDC instance, which will + # generally be mapped to the client area of the window displaying + # the plot. Under wxPython, the wxDC instance has a wx.Pen which + # describes the colour and weight of any lines drawn, and a wxBrush + # which describes the fill colour of any closed polygon. + + # Font styles, families and weight. + fontweights = { + 100: wx.FONTWEIGHT_LIGHT, + 200: wx.FONTWEIGHT_LIGHT, + 300: wx.FONTWEIGHT_LIGHT, + 400: wx.FONTWEIGHT_NORMAL, + 500: wx.FONTWEIGHT_NORMAL, + 600: wx.FONTWEIGHT_NORMAL, + 700: wx.FONTWEIGHT_BOLD, + 800: wx.FONTWEIGHT_BOLD, + 900: wx.FONTWEIGHT_BOLD, + 'ultralight': wx.FONTWEIGHT_LIGHT, + 'light': wx.FONTWEIGHT_LIGHT, + 'normal': wx.FONTWEIGHT_NORMAL, + 'medium': wx.FONTWEIGHT_NORMAL, + 'semibold': wx.FONTWEIGHT_NORMAL, + 'bold': wx.FONTWEIGHT_BOLD, + 'heavy': wx.FONTWEIGHT_BOLD, + 'ultrabold': wx.FONTWEIGHT_BOLD, + 'black': wx.FONTWEIGHT_BOLD, + } + fontangles = { + 'italic': wx.FONTSTYLE_ITALIC, + 'normal': wx.FONTSTYLE_NORMAL, + 'oblique': wx.FONTSTYLE_SLANT, + } + + # wxPython allows for portable font styles, choosing them appropriately for + # the target platform. Map some standard font names to the portable styles. + # QUESTION: Is it wise to agree to standard fontnames across all backends? + fontnames = { + 'Sans': wx.FONTFAMILY_SWISS, + 'Roman': wx.FONTFAMILY_ROMAN, + 'Script': wx.FONTFAMILY_SCRIPT, + 'Decorative': wx.FONTFAMILY_DECORATIVE, + 'Modern': wx.FONTFAMILY_MODERN, + 'Courier': wx.FONTFAMILY_MODERN, + 'courier': wx.FONTFAMILY_MODERN, + } + + def __init__(self, bitmap, dpi): + """Initialise a wxWindows renderer instance.""" + super().__init__() + _log.debug("%s - __init__()", type(self)) + self.width = bitmap.GetWidth() + self.height = bitmap.GetHeight() + self.bitmap = bitmap + self.fontd = {} + self.dpi = dpi + self.gc = None + + def flipy(self): + # docstring inherited + return True + + def get_text_width_height_descent(self, s, prop, ismath): + # docstring inherited + + if ismath: + s = cbook.strip_math(s) + + if self.gc is None: + gc = self.new_gc() + else: + gc = self.gc + gfx_ctx = gc.gfx_ctx + font = self.get_wx_font(s, prop) + gfx_ctx.SetFont(font, wx.BLACK) + w, h, descent, leading = gfx_ctx.GetFullTextExtent(s) + + return w, h, descent + + def get_canvas_width_height(self): + # docstring inherited + return self.width, self.height + + def handle_clip_rectangle(self, gc): + new_bounds = gc.get_clip_rectangle() + if new_bounds is not None: + new_bounds = new_bounds.bounds + gfx_ctx = gc.gfx_ctx + if gfx_ctx._lastcliprect != new_bounds: + gfx_ctx._lastcliprect = new_bounds + if new_bounds is None: + gfx_ctx.ResetClip() + else: + gfx_ctx.Clip(new_bounds[0], + self.height - new_bounds[1] - new_bounds[3], + new_bounds[2], new_bounds[3]) + + @staticmethod + def convert_path(gfx_ctx, path, transform): + wxpath = gfx_ctx.CreatePath() + for points, code in path.iter_segments(transform): + if code == Path.MOVETO: + wxpath.MoveToPoint(*points) + elif code == Path.LINETO: + wxpath.AddLineToPoint(*points) + elif code == Path.CURVE3: + wxpath.AddQuadCurveToPoint(*points) + elif code == Path.CURVE4: + wxpath.AddCurveToPoint(*points) + elif code == Path.CLOSEPOLY: + wxpath.CloseSubpath() + return wxpath + + def draw_path(self, gc, path, transform, rgbFace=None): + # docstring inherited + gc.select() + self.handle_clip_rectangle(gc) + gfx_ctx = gc.gfx_ctx + transform = transform + \ + Affine2D().scale(1.0, -1.0).translate(0.0, self.height) + wxpath = self.convert_path(gfx_ctx, path, transform) + if rgbFace is not None: + gfx_ctx.SetBrush(wx.Brush(gc.get_wxcolour(rgbFace))) + gfx_ctx.DrawPath(wxpath) + else: + gfx_ctx.StrokePath(wxpath) + gc.unselect() + + def draw_image(self, gc, x, y, im): + bbox = gc.get_clip_rectangle() + if bbox is not None: + l, b, w, h = bbox.bounds + else: + l = 0 + b = 0 + w = self.width + h = self.height + rows, cols = im.shape[:2] + bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tobytes()) + gc.select() + gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b), + int(w), int(-h)) + gc.unselect() + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): + # docstring inherited + + if ismath: + s = cbook.strip_math(s) + _log.debug("%s - draw_text()", type(self)) + gc.select() + self.handle_clip_rectangle(gc) + gfx_ctx = gc.gfx_ctx + + font = self.get_wx_font(s, prop) + color = gc.get_wxcolour(gc.get_rgb()) + gfx_ctx.SetFont(font, color) + + w, h, d = self.get_text_width_height_descent(s, prop, ismath) + x = int(x) + y = int(y - h) + + if angle == 0.0: + gfx_ctx.DrawText(s, x, y) + else: + rads = math.radians(angle) + xo = h * math.sin(rads) + yo = h * math.cos(rads) + gfx_ctx.DrawRotatedText(s, x - xo, y - yo, rads) + + gc.unselect() + + def new_gc(self): + # docstring inherited + _log.debug("%s - new_gc()", type(self)) + self.gc = GraphicsContextWx(self.bitmap, self) + self.gc.select() + self.gc.unselect() + return self.gc + + def get_wx_font(self, s, prop): + """Return a wx font. Cache font instances for efficiency.""" + _log.debug("%s - get_wx_font()", type(self)) + key = hash(prop) + font = self.fontd.get(key) + if font is not None: + return font + size = self.points_to_pixels(prop.get_size_in_points()) + # Font colour is determined by the active wx.Pen + # TODO: It may be wise to cache font information + self.fontd[key] = font = wx.Font( # Cache the font and gc. + pointSize=round(size), + family=self.fontnames.get(prop.get_name(), wx.ROMAN), + style=self.fontangles[prop.get_style()], + weight=self.fontweights[prop.get_weight()]) + return font + + def points_to_pixels(self, points): + # docstring inherited + return points * (PIXELS_PER_INCH / 72.0 * self.dpi / 72.0) + + +class GraphicsContextWx(GraphicsContextBase): + """ + The graphics context provides the color, line styles, etc. + + This class stores a reference to a wxMemoryDC, and a + wxGraphicsContext that draws to it. Creating a wxGraphicsContext + seems to be fairly heavy, so these objects are cached based on the + bitmap object that is passed in. + + The base GraphicsContext stores colors as an RGB tuple on the unit + interval, e.g., (0.5, 0.0, 1.0). wxPython uses an int interval, but + since wxPython colour management is rather simple, I have not chosen + to implement a separate colour manager class. + """ + _capd = {'butt': wx.CAP_BUTT, + 'projecting': wx.CAP_PROJECTING, + 'round': wx.CAP_ROUND} + + _joind = {'bevel': wx.JOIN_BEVEL, + 'miter': wx.JOIN_MITER, + 'round': wx.JOIN_ROUND} + + _cache = weakref.WeakKeyDictionary() + + def __init__(self, bitmap, renderer): + super().__init__() + # assert self.Ok(), "wxMemoryDC not OK to use" + _log.debug("%s - __init__(): %s", type(self), bitmap) + + dc, gfx_ctx = self._cache.get(bitmap, (None, None)) + if dc is None: + dc = wx.MemoryDC(bitmap) + gfx_ctx = wx.GraphicsContext.Create(dc) + gfx_ctx._lastcliprect = None + self._cache[bitmap] = dc, gfx_ctx + + self.bitmap = bitmap + self.dc = dc + self.gfx_ctx = gfx_ctx + self._pen = wx.Pen('BLACK', 1, wx.SOLID) + gfx_ctx.SetPen(self._pen) + self.renderer = renderer + + def select(self): + """Select the current bitmap into this wxDC instance.""" + if sys.platform == 'win32': + self.dc.SelectObject(self.bitmap) + self.IsSelected = True + + def unselect(self): + """Select a Null bitmap into this wxDC instance.""" + if sys.platform == 'win32': + self.dc.SelectObject(wx.NullBitmap) + self.IsSelected = False + + def set_foreground(self, fg, isRGBA=None): + # docstring inherited + # Implementation note: wxPython has a separate concept of pen and + # brush - the brush fills any outline trace left by the pen. + # Here we set both to the same colour - if a figure is not to be + # filled, the renderer will set the brush to be transparent + # Same goes for text foreground... + _log.debug("%s - set_foreground()", type(self)) + self.select() + super().set_foreground(fg, isRGBA) + + self._pen.SetColour(self.get_wxcolour(self.get_rgb())) + self.gfx_ctx.SetPen(self._pen) + self.unselect() + + def set_linewidth(self, w): + # docstring inherited + w = float(w) + _log.debug("%s - set_linewidth()", type(self)) + self.select() + if 0 < w < 1: + w = 1 + super().set_linewidth(w) + lw = int(self.renderer.points_to_pixels(self._linewidth)) + if lw == 0: + lw = 1 + self._pen.SetWidth(lw) + self.gfx_ctx.SetPen(self._pen) + self.unselect() + + def set_capstyle(self, cs): + # docstring inherited + _log.debug("%s - set_capstyle()", type(self)) + self.select() + super().set_capstyle(cs) + self._pen.SetCap(GraphicsContextWx._capd[self._capstyle]) + self.gfx_ctx.SetPen(self._pen) + self.unselect() + + def set_joinstyle(self, js): + # docstring inherited + _log.debug("%s - set_joinstyle()", type(self)) + self.select() + super().set_joinstyle(js) + self._pen.SetJoin(GraphicsContextWx._joind[self._joinstyle]) + self.gfx_ctx.SetPen(self._pen) + self.unselect() + + def get_wxcolour(self, color): + """Convert an RGB(A) color to a wx.Colour.""" + _log.debug("%s - get_wx_color()", type(self)) + return wx.Colour(*[int(255 * x) for x in color]) + + +class _FigureCanvasWxBase(FigureCanvasBase, wx.Panel): + """ + The FigureCanvas contains the figure and does event handling. + + In the wxPython backend, it is derived from wxPanel, and (usually) lives + inside a frame instantiated by a FigureManagerWx. The parent window + probably implements a wx.Sizer to control the displayed control size - but + we give a hint as to our preferred minimum size. + """ + + required_interactive_framework = "wx" + _timer_cls = TimerWx + manager_class = _api.classproperty(lambda cls: FigureManagerWx) + + keyvald = { + wx.WXK_CONTROL: 'control', + wx.WXK_SHIFT: 'shift', + wx.WXK_ALT: 'alt', + wx.WXK_CAPITAL: 'caps_lock', + wx.WXK_LEFT: 'left', + wx.WXK_UP: 'up', + wx.WXK_RIGHT: 'right', + wx.WXK_DOWN: 'down', + wx.WXK_ESCAPE: 'escape', + wx.WXK_F1: 'f1', + wx.WXK_F2: 'f2', + wx.WXK_F3: 'f3', + wx.WXK_F4: 'f4', + wx.WXK_F5: 'f5', + wx.WXK_F6: 'f6', + wx.WXK_F7: 'f7', + wx.WXK_F8: 'f8', + wx.WXK_F9: 'f9', + wx.WXK_F10: 'f10', + wx.WXK_F11: 'f11', + wx.WXK_F12: 'f12', + wx.WXK_SCROLL: 'scroll_lock', + wx.WXK_PAUSE: 'break', + wx.WXK_BACK: 'backspace', + wx.WXK_RETURN: 'enter', + wx.WXK_INSERT: 'insert', + wx.WXK_DELETE: 'delete', + wx.WXK_HOME: 'home', + wx.WXK_END: 'end', + wx.WXK_PAGEUP: 'pageup', + wx.WXK_PAGEDOWN: 'pagedown', + wx.WXK_NUMPAD0: '0', + wx.WXK_NUMPAD1: '1', + wx.WXK_NUMPAD2: '2', + wx.WXK_NUMPAD3: '3', + wx.WXK_NUMPAD4: '4', + wx.WXK_NUMPAD5: '5', + wx.WXK_NUMPAD6: '6', + wx.WXK_NUMPAD7: '7', + wx.WXK_NUMPAD8: '8', + wx.WXK_NUMPAD9: '9', + wx.WXK_NUMPAD_ADD: '+', + wx.WXK_NUMPAD_SUBTRACT: '-', + wx.WXK_NUMPAD_MULTIPLY: '*', + wx.WXK_NUMPAD_DIVIDE: '/', + wx.WXK_NUMPAD_DECIMAL: 'dec', + wx.WXK_NUMPAD_ENTER: 'enter', + wx.WXK_NUMPAD_UP: 'up', + wx.WXK_NUMPAD_RIGHT: 'right', + wx.WXK_NUMPAD_DOWN: 'down', + wx.WXK_NUMPAD_LEFT: 'left', + wx.WXK_NUMPAD_PAGEUP: 'pageup', + wx.WXK_NUMPAD_PAGEDOWN: 'pagedown', + wx.WXK_NUMPAD_HOME: 'home', + wx.WXK_NUMPAD_END: 'end', + wx.WXK_NUMPAD_INSERT: 'insert', + wx.WXK_NUMPAD_DELETE: 'delete', + } + + def __init__(self, parent, id, figure=None): + """ + Initialize a FigureWx instance. + + - Initialize the FigureCanvasBase and wxPanel parents. + - Set event handlers for resize, paint, and keyboard and mouse + interaction. + """ + + FigureCanvasBase.__init__(self, figure) + size = wx.Size(*map(math.ceil, self.figure.bbox.size)) + if wx.Platform != '__WXMSW__': + size = parent.FromDIP(size) + # Set preferred window size hint - helps the sizer, if one is connected + wx.Panel.__init__(self, parent, id, size=size) + self.bitmap = None + self._isDrawn = False + self._rubberband_rect = None + self._rubberband_pen_black = wx.Pen('BLACK', 1, wx.PENSTYLE_SHORT_DASH) + self._rubberband_pen_white = wx.Pen('WHITE', 1, wx.PENSTYLE_SOLID) + + self.Bind(wx.EVT_SIZE, self._on_size) + self.Bind(wx.EVT_PAINT, self._on_paint) + self.Bind(wx.EVT_CHAR_HOOK, self._on_key_down) + self.Bind(wx.EVT_KEY_UP, self._on_key_up) + self.Bind(wx.EVT_LEFT_DOWN, self._on_mouse_button) + self.Bind(wx.EVT_LEFT_DCLICK, self._on_mouse_button) + self.Bind(wx.EVT_LEFT_UP, self._on_mouse_button) + self.Bind(wx.EVT_MIDDLE_DOWN, self._on_mouse_button) + self.Bind(wx.EVT_MIDDLE_DCLICK, self._on_mouse_button) + self.Bind(wx.EVT_MIDDLE_UP, self._on_mouse_button) + self.Bind(wx.EVT_RIGHT_DOWN, self._on_mouse_button) + self.Bind(wx.EVT_RIGHT_DCLICK, self._on_mouse_button) + self.Bind(wx.EVT_RIGHT_UP, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX1_DOWN, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX1_UP, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX2_DOWN, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX2_UP, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX1_DCLICK, self._on_mouse_button) + self.Bind(wx.EVT_MOUSE_AUX2_DCLICK, self._on_mouse_button) + self.Bind(wx.EVT_MOUSEWHEEL, self._on_mouse_wheel) + self.Bind(wx.EVT_MOTION, self._on_motion) + self.Bind(wx.EVT_ENTER_WINDOW, self._on_enter) + self.Bind(wx.EVT_LEAVE_WINDOW, self._on_leave) + + self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._on_capture_lost) + self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._on_capture_lost) + + self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. + self.SetBackgroundColour(wx.WHITE) + + if wx.Platform == '__WXMAC__': + # Initial scaling. Other platforms handle this automatically + dpiScale = self.GetDPIScaleFactor() + self.SetInitialSize(self.GetSize()*(1/dpiScale)) + self._set_device_pixel_ratio(dpiScale) + + def Copy_to_Clipboard(self, event=None): + """Copy bitmap of canvas to system clipboard.""" + bmp_obj = wx.BitmapDataObject() + bmp_obj.SetBitmap(self.bitmap) + + if not wx.TheClipboard.IsOpened(): + open_success = wx.TheClipboard.Open() + if open_success: + wx.TheClipboard.SetData(bmp_obj) + wx.TheClipboard.Flush() + wx.TheClipboard.Close() + + def _update_device_pixel_ratio(self, *args, **kwargs): + # We need to be careful in cases with mixed resolution displays if + # device_pixel_ratio changes. + if self._set_device_pixel_ratio(self.GetDPIScaleFactor()): + self.draw() + + def draw_idle(self): + # docstring inherited + _log.debug("%s - draw_idle()", type(self)) + self._isDrawn = False # Force redraw + # Triggering a paint event is all that is needed to defer drawing + # until later. The platform will send the event when it thinks it is + # a good time (usually as soon as there are no other events pending). + self.Refresh(eraseBackground=False) + + def flush_events(self): + # docstring inherited + wx.Yield() + + def start_event_loop(self, timeout=0): + # docstring inherited + if hasattr(self, '_event_loop'): + raise RuntimeError("Event loop already running") + timer = wx.Timer(self, id=wx.ID_ANY) + if timeout > 0: + timer.Start(int(timeout * 1000), oneShot=True) + self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId()) + # Event loop handler for start/stop event loop + self._event_loop = wx.GUIEventLoop() + self._event_loop.Run() + timer.Stop() + + def stop_event_loop(self, event=None): + # docstring inherited + if hasattr(self, '_event_loop'): + if self._event_loop.IsRunning(): + self._event_loop.Exit() + del self._event_loop + + def _get_imagesave_wildcards(self): + """Return the wildcard string for the filesave dialog.""" + default_filetype = self.get_default_filetype() + filetypes = self.get_supported_filetypes_grouped() + sorted_filetypes = sorted(filetypes.items()) + wildcards = [] + extensions = [] + filter_index = 0 + for i, (name, exts) in enumerate(sorted_filetypes): + ext_list = ';'.join(['*.%s' % ext for ext in exts]) + extensions.append(exts[0]) + wildcard = f'{name} ({ext_list})|{ext_list}' + if default_filetype in exts: + filter_index = i + wildcards.append(wildcard) + wildcards = '|'.join(wildcards) + return wildcards, extensions, filter_index + + def gui_repaint(self, drawDC=None): + """ + Update the displayed image on the GUI canvas, using the supplied + wx.PaintDC device context. + """ + _log.debug("%s - gui_repaint()", type(self)) + # The "if self" check avoids a "wrapped C/C++ object has been deleted" + # RuntimeError if doing things after window is closed. + if not (self and self.IsShownOnScreen()): + return + if not drawDC: # not called from OnPaint use a ClientDC + drawDC = wx.ClientDC(self) + # For 'WX' backend on Windows, the bitmap cannot be in use by another + # DC (see GraphicsContextWx._cache). + bmp = (self.bitmap.ConvertToImage().ConvertToBitmap() + if wx.Platform == '__WXMSW__' + and isinstance(self.figure.canvas.get_renderer(), RendererWx) + else self.bitmap) + drawDC.DrawBitmap(bmp, 0, 0) + if self._rubberband_rect is not None: + # Some versions of wx+python don't support numpy.float64 here. + x0, y0, x1, y1 = map(round, self._rubberband_rect) + rect = [(x0, y0, x1, y0), (x1, y0, x1, y1), + (x0, y0, x0, y1), (x0, y1, x1, y1)] + drawDC.DrawLineList(rect, self._rubberband_pen_white) + drawDC.DrawLineList(rect, self._rubberband_pen_black) + + filetypes = { + **FigureCanvasBase.filetypes, + 'bmp': 'Windows bitmap', + 'jpeg': 'JPEG', + 'jpg': 'JPEG', + 'pcx': 'PCX', + 'png': 'Portable Network Graphics', + 'tif': 'Tagged Image Format File', + 'tiff': 'Tagged Image Format File', + 'xpm': 'X pixmap', + } + + def _on_paint(self, event): + """Called when wxPaintEvt is generated.""" + _log.debug("%s - _on_paint()", type(self)) + drawDC = wx.PaintDC(self) + if not self._isDrawn: + self.draw(drawDC=drawDC) + else: + self.gui_repaint(drawDC=drawDC) + drawDC.Destroy() + + def _on_size(self, event): + """ + Called when wxEventSize is generated. + + In this application we attempt to resize to fit the window, so it + is better to take the performance hit and redraw the whole window. + """ + self._update_device_pixel_ratio() + _log.debug("%s - _on_size()", type(self)) + sz = self.GetParent().GetSizer() + if sz: + si = sz.GetItem(self) + if sz and si and not si.Proportion and not si.Flag & wx.EXPAND: + # managed by a sizer, but with a fixed size + size = self.GetMinSize() + else: + # variable size + size = self.GetClientSize() + # Do not allow size to become smaller than MinSize + size.IncTo(self.GetMinSize()) + if getattr(self, "_width", None): + if size == (self._width, self._height): + # no change in size + return + self._width, self._height = size + self._isDrawn = False + + if self._width <= 1 or self._height <= 1: + return # Empty figure + + # Create a new, correctly sized bitmap + dpival = self.figure.dpi + if not wx.Platform == '__WXMSW__': + scale = self.GetDPIScaleFactor() + dpival /= scale + winch = self._width / dpival + hinch = self._height / dpival + self.figure.set_size_inches(winch, hinch, forward=False) + + # Rendering will happen on the associated paint event + # so no need to do anything here except to make sure + # the whole background is repainted. + self.Refresh(eraseBackground=False) + ResizeEvent("resize_event", self)._process() + self.draw_idle() + + @staticmethod + def _mpl_modifiers(event=None, *, exclude=None): + mod_table = [ + ("ctrl", wx.MOD_CONTROL, wx.WXK_CONTROL), + ("alt", wx.MOD_ALT, wx.WXK_ALT), + ("shift", wx.MOD_SHIFT, wx.WXK_SHIFT), + ] + if event is not None: + modifiers = event.GetModifiers() + return [name for name, mod, key in mod_table + if modifiers & mod and exclude != key] + else: + return [name for name, mod, key in mod_table + if wx.GetKeyState(key)] + + def _get_key(self, event): + keyval = event.KeyCode + if keyval in self.keyvald: + key = self.keyvald[keyval] + elif keyval < 256: + key = chr(keyval) + # wx always returns an uppercase, so make it lowercase if the shift + # key is not depressed (NOTE: this will not handle Caps Lock) + if not event.ShiftDown(): + key = key.lower() + else: + return None + mods = self._mpl_modifiers(event, exclude=keyval) + if "shift" in mods and key.isupper(): + mods.remove("shift") + return "+".join([*mods, key]) + + def _mpl_coords(self, pos=None): + """ + Convert a wx position, defaulting to the current cursor position, to + Matplotlib coordinates. + """ + if pos is None: + pos = wx.GetMouseState() + x, y = self.ScreenToClient(pos.X, pos.Y) + else: + x, y = pos.X, pos.Y + # flip y so y=0 is bottom of canvas + if not wx.Platform == '__WXMSW__': + scale = self.GetDPIScaleFactor() + return x*scale, self.figure.bbox.height - y*scale + else: + return x, self.figure.bbox.height - y + + def _on_key_down(self, event): + """Capture key press.""" + KeyEvent("key_press_event", self, + self._get_key(event), *self._mpl_coords(), + guiEvent=event)._process() + if self: + event.Skip() + + def _on_key_up(self, event): + """Release key.""" + KeyEvent("key_release_event", self, + self._get_key(event), *self._mpl_coords(), + guiEvent=event)._process() + if self: + event.Skip() + + def set_cursor(self, cursor): + # docstring inherited + cursor = wx.Cursor(_api.check_getitem({ + cursors.MOVE: wx.CURSOR_HAND, + cursors.HAND: wx.CURSOR_HAND, + cursors.POINTER: wx.CURSOR_ARROW, + cursors.SELECT_REGION: wx.CURSOR_CROSS, + cursors.WAIT: wx.CURSOR_WAIT, + cursors.RESIZE_HORIZONTAL: wx.CURSOR_SIZEWE, + cursors.RESIZE_VERTICAL: wx.CURSOR_SIZENS, + }, cursor=cursor)) + self.SetCursor(cursor) + self.Refresh() + + def _set_capture(self, capture=True): + """Control wx mouse capture.""" + if self.HasCapture(): + self.ReleaseMouse() + if capture: + self.CaptureMouse() + + def _on_capture_lost(self, event): + """Capture changed or lost""" + self._set_capture(False) + + def _on_mouse_button(self, event): + """Start measuring on an axis.""" + event.Skip() + self._set_capture(event.ButtonDown() or event.ButtonDClick()) + x, y = self._mpl_coords(event) + button_map = { + wx.MOUSE_BTN_LEFT: MouseButton.LEFT, + wx.MOUSE_BTN_MIDDLE: MouseButton.MIDDLE, + wx.MOUSE_BTN_RIGHT: MouseButton.RIGHT, + wx.MOUSE_BTN_AUX1: MouseButton.BACK, + wx.MOUSE_BTN_AUX2: MouseButton.FORWARD, + } + button = event.GetButton() + button = button_map.get(button, button) + modifiers = self._mpl_modifiers(event) + if event.ButtonDown(): + MouseEvent("button_press_event", self, x, y, button, + modifiers=modifiers, guiEvent=event)._process() + elif event.ButtonDClick(): + MouseEvent("button_press_event", self, x, y, button, + dblclick=True, modifiers=modifiers, + guiEvent=event)._process() + elif event.ButtonUp(): + MouseEvent("button_release_event", self, x, y, button, + modifiers=modifiers, guiEvent=event)._process() + + def _on_mouse_wheel(self, event): + """Translate mouse wheel events into matplotlib events""" + x, y = self._mpl_coords(event) + # Convert delta/rotation/rate into a floating point step size + step = event.LinesPerAction * event.WheelRotation / event.WheelDelta + # Done handling event + event.Skip() + # Mac gives two events for every wheel event; skip every second one. + if wx.Platform == '__WXMAC__': + if not hasattr(self, '_skipwheelevent'): + self._skipwheelevent = True + elif self._skipwheelevent: + self._skipwheelevent = False + return # Return without processing event + else: + self._skipwheelevent = True + MouseEvent("scroll_event", self, x, y, step=step, + modifiers=self._mpl_modifiers(event), + guiEvent=event)._process() + + def _on_motion(self, event): + """Start measuring on an axis.""" + event.Skip() + MouseEvent("motion_notify_event", self, + *self._mpl_coords(event), + modifiers=self._mpl_modifiers(event), + guiEvent=event)._process() + + def _on_enter(self, event): + """Mouse has entered the window.""" + event.Skip() + LocationEvent("figure_enter_event", self, + *self._mpl_coords(event), + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + def _on_leave(self, event): + """Mouse has left the window.""" + event.Skip() + LocationEvent("figure_leave_event", self, + *self._mpl_coords(event), + modifiers=self._mpl_modifiers(), + guiEvent=event)._process() + + +class FigureCanvasWx(_FigureCanvasWxBase): + # Rendering to a Wx canvas using the deprecated Wx renderer. + + def draw(self, drawDC=None): + """ + Render the figure using RendererWx instance renderer, or using a + previously defined renderer if none is specified. + """ + _log.debug("%s - draw()", type(self)) + self.renderer = RendererWx(self.bitmap, self.figure.dpi) + self.figure.draw(self.renderer) + self._isDrawn = True + self.gui_repaint(drawDC=drawDC) + + def _print_image(self, filetype, filename): + bitmap = wx.Bitmap(math.ceil(self.figure.bbox.width), + math.ceil(self.figure.bbox.height)) + self.figure.draw(RendererWx(bitmap, self.figure.dpi)) + saved_obj = (bitmap.ConvertToImage() + if cbook.is_writable_file_like(filename) + else bitmap) + if not saved_obj.SaveFile(filename, filetype): + raise RuntimeError(f'Could not save figure to {filename}') + # draw() is required here since bits of state about the last renderer + # are strewn about the artist draw methods. Do not remove the draw + # without first verifying that these have been cleaned up. The artist + # contains() methods will fail otherwise. + if self._isDrawn: + self.draw() + # The "if self" check avoids a "wrapped C/C++ object has been deleted" + # RuntimeError if doing things after window is closed. + if self: + self.Refresh() + + print_bmp = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_BMP) + print_jpeg = print_jpg = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_JPEG) + print_pcx = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_PCX) + print_png = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_PNG) + print_tiff = print_tif = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_TIF) + print_xpm = functools.partialmethod( + _print_image, wx.BITMAP_TYPE_XPM) + + +class FigureFrameWx(wx.Frame): + def __init__(self, num, fig, *, canvas_class): + # On non-Windows platform, explicitly set the position - fix + # positioning bug on some Linux platforms + if wx.Platform == '__WXMSW__': + pos = wx.DefaultPosition + else: + pos = wx.Point(20, 20) + super().__init__(parent=None, id=-1, pos=pos) + # Frame will be sized later by the Fit method + _log.debug("%s - __init__()", type(self)) + _set_frame_icon(self) + + self.canvas = canvas_class(self, -1, fig) + # Auto-attaches itself to self.canvas.manager + manager = FigureManagerWx(self.canvas, num, self) + + toolbar = self.canvas.manager.toolbar + if toolbar is not None: + self.SetToolBar(toolbar) + + # On Windows, canvas sizing must occur after toolbar addition; + # otherwise the toolbar further resizes the canvas. + w, h = map(math.ceil, fig.bbox.size) + self.canvas.SetInitialSize(self.FromDIP(wx.Size(w, h))) + self.canvas.SetMinSize(self.FromDIP(wx.Size(2, 2))) + self.canvas.SetFocus() + + self.Fit() + + self.Bind(wx.EVT_CLOSE, self._on_close) + + def _on_close(self, event): + _log.debug("%s - on_close()", type(self)) + CloseEvent("close_event", self.canvas)._process() + self.canvas.stop_event_loop() + # set FigureManagerWx.frame to None to prevent repeated attempts to + # close this frame from FigureManagerWx.destroy() + self.canvas.manager.frame = None + # remove figure manager from Gcf.figs + Gcf.destroy(self.canvas.manager) + try: # See issue 2941338. + self.canvas.mpl_disconnect(self.canvas.toolbar._id_drag) + except AttributeError: # If there's no toolbar. + pass + # Carry on with close event propagation, frame & children destruction + event.Skip() + + +class FigureManagerWx(FigureManagerBase): + """ + Container/controller for the FigureCanvas and GUI frame. + + It is instantiated by Gcf whenever a new figure is created. Gcf is + responsible for managing multiple instances of FigureManagerWx. + + Attributes + ---------- + canvas : `FigureCanvas` + a FigureCanvasWx(wx.Panel) instance + window : wxFrame + a wxFrame instance - wxpython.org/Phoenix/docs/html/Frame.html + """ + + def __init__(self, canvas, num, frame): + _log.debug("%s - __init__()", type(self)) + self.frame = self.window = frame + super().__init__(canvas, num) + + @classmethod + def create_with_canvas(cls, canvas_class, figure, num): + # docstring inherited + wxapp = wx.GetApp() or _create_wxapp() + frame = FigureFrameWx(num, figure, canvas_class=canvas_class) + manager = figure.canvas.manager + if mpl.is_interactive(): + manager.frame.Show() + figure.canvas.draw_idle() + return manager + + @classmethod + def start_main_loop(cls): + if not wx.App.IsMainLoopRunning(): + wxapp = wx.GetApp() + if wxapp is not None: + wxapp.MainLoop() + + def show(self): + # docstring inherited + self.frame.Show() + self.canvas.draw() + if mpl.rcParams['figure.raise_window']: + self.frame.Raise() + + def destroy(self, *args): + # docstring inherited + _log.debug("%s - destroy()", type(self)) + frame = self.frame + if frame: # Else, may have been already deleted, e.g. when closing. + # As this can be called from non-GUI thread from plt.close use + # wx.CallAfter to ensure thread safety. + wx.CallAfter(frame.Close) + + def full_screen_toggle(self): + # docstring inherited + self.frame.ShowFullScreen(not self.frame.IsFullScreen()) + + def get_window_title(self): + # docstring inherited + return self.window.GetTitle() + + def set_window_title(self, title): + # docstring inherited + self.window.SetTitle(title) + + def resize(self, width, height): + # docstring inherited + # Directly using SetClientSize doesn't handle the toolbar on Windows. + self.window.SetSize(self.window.ClientToWindowSize(wx.Size( + math.ceil(width), math.ceil(height)))) + + +def _load_bitmap(filename): + """ + Load a wx.Bitmap from a file in the "images" directory of the Matplotlib + data. + """ + return wx.Bitmap(str(cbook._get_data_path('images', filename))) + + +def _set_frame_icon(frame): + bundle = wx.IconBundle() + for image in ('matplotlib.png', 'matplotlib_large.png'): + icon = wx.Icon(_load_bitmap(image)) + if not icon.IsOk(): + return + bundle.AddIcon(icon) + frame.SetIcons(bundle) + + +class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar): + def __init__(self, canvas, coordinates=True, *, style=wx.TB_BOTTOM): + wx.ToolBar.__init__(self, canvas.GetParent(), -1, style=style) + if wx.Platform == '__WXMAC__': + self.SetToolBitmapSize(self.GetToolBitmapSize()*self.GetDPIScaleFactor()) + + self.wx_ids = {} + for text, tooltip_text, image_file, callback in self.toolitems: + if text is None: + self.AddSeparator() + continue + self.wx_ids[text] = ( + self.AddTool( + -1, + bitmap=self._icon(f"{image_file}.svg"), + bmpDisabled=wx.NullBitmap, + label=text, shortHelp=tooltip_text, + kind=(wx.ITEM_CHECK if text in ["Pan", "Zoom"] + else wx.ITEM_NORMAL)) + .Id) + self.Bind(wx.EVT_TOOL, getattr(self, callback), + id=self.wx_ids[text]) + + self._coordinates = coordinates + if self._coordinates: + self.AddStretchableSpace() + self._label_text = wx.StaticText(self, style=wx.ALIGN_RIGHT) + self.AddControl(self._label_text) + + self.Realize() + + NavigationToolbar2.__init__(self, canvas) + + @staticmethod + def _icon(name): + """ + Construct a `wx.Bitmap` suitable for use as icon from an image file + *name*, including the extension and relative to Matplotlib's "images" + data directory. + """ + try: + dark = wx.SystemSettings.GetAppearance().IsDark() + except AttributeError: # wxpython < 4.1 + # copied from wx's IsUsingDarkBackground / GetLuminance. + bg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) + fg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT) + # See wx.Colour.GetLuminance. + bg_lum = (.299 * bg.red + .587 * bg.green + .114 * bg.blue) / 255 + fg_lum = (.299 * fg.red + .587 * fg.green + .114 * fg.blue) / 255 + dark = fg_lum - bg_lum > .2 + + path = cbook._get_data_path('images', name) + if path.suffix == '.svg': + svg = path.read_bytes() + if dark: + svg = svg.replace(b'fill:black;', b'fill:white;') + toolbarIconSize = wx.ArtProvider().GetDIPSizeHint(wx.ART_TOOLBAR) + return wx.BitmapBundle.FromSVG(svg, toolbarIconSize) + else: + pilimg = PIL.Image.open(path) + # ensure RGBA as wx BitMap expects RGBA format + image = np.array(pilimg.convert("RGBA")) + if dark: + fg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT) + black_mask = (image[..., :3] == 0).all(axis=-1) + image[black_mask, :3] = (fg.Red(), fg.Green(), fg.Blue()) + return wx.Bitmap.FromBufferRGBA( + image.shape[1], image.shape[0], image.tobytes()) + + def _update_buttons_checked(self): + if "Pan" in self.wx_ids: + self.ToggleTool(self.wx_ids["Pan"], self.mode.name == "PAN") + if "Zoom" in self.wx_ids: + self.ToggleTool(self.wx_ids["Zoom"], self.mode.name == "ZOOM") + + def zoom(self, *args): + super().zoom(*args) + self._update_buttons_checked() + + def pan(self, *args): + super().pan(*args) + self._update_buttons_checked() + + def save_figure(self, *args): + # Fetch the required filename and file type. + filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards() + default_file = self.canvas.get_default_filename() + dialog = wx.FileDialog( + self.canvas.GetParent(), "Save to file", + mpl.rcParams["savefig.directory"], default_file, filetypes, + wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) + dialog.SetFilterIndex(filter_index) + if dialog.ShowModal() == wx.ID_OK: + path = pathlib.Path(dialog.GetPath()) + _log.debug('%s - Save file path: %s', type(self), path) + fmt = exts[dialog.GetFilterIndex()] + ext = path.suffix[1:] + if ext in self.canvas.get_supported_filetypes() and fmt != ext: + # looks like they forgot to set the image type drop + # down, going with the extension. + _log.warning('extension %s did not match the selected ' + 'image type %s; going with %s', + ext, fmt, ext) + fmt = ext + # Save dir for next time, unless empty str (which means use cwd). + if mpl.rcParams["savefig.directory"]: + mpl.rcParams["savefig.directory"] = str(path.parent) + try: + self.canvas.figure.savefig(path, format=fmt) + except Exception as e: + dialog = wx.MessageDialog( + parent=self.canvas.GetParent(), message=str(e), + caption='Matplotlib error') + dialog.ShowModal() + dialog.Destroy() + + def draw_rubberband(self, event, x0, y0, x1, y1): + height = self.canvas.figure.bbox.height + sf = 1 if wx.Platform == '__WXMSW__' else self.canvas.GetDPIScaleFactor() + self.canvas._rubberband_rect = (x0/sf, (height - y0)/sf, + x1/sf, (height - y1)/sf) + self.canvas.Refresh() + + def remove_rubberband(self): + self.canvas._rubberband_rect = None + self.canvas.Refresh() + + def set_message(self, s): + if self._coordinates: + self._label_text.SetLabel(s) + + def set_history_buttons(self): + can_backward = self._nav_stack._pos > 0 + can_forward = self._nav_stack._pos < len(self._nav_stack) - 1 + if 'Back' in self.wx_ids: + self.EnableTool(self.wx_ids['Back'], can_backward) + if 'Forward' in self.wx_ids: + self.EnableTool(self.wx_ids['Forward'], can_forward) + + +# tools for matplotlib.backend_managers.ToolManager: + +class ToolbarWx(ToolContainerBase, wx.ToolBar): + _icon_extension = '.svg' + + def __init__(self, toolmanager, parent=None, style=wx.TB_BOTTOM): + if parent is None: + parent = toolmanager.canvas.GetParent() + ToolContainerBase.__init__(self, toolmanager) + wx.ToolBar.__init__(self, parent, -1, style=style) + self._space = self.AddStretchableSpace() + self._label_text = wx.StaticText(self, style=wx.ALIGN_RIGHT) + self.AddControl(self._label_text) + self._toolitems = {} + self._groups = {} # Mapping of groups to the separator after them. + + def _get_tool_pos(self, tool): + """ + Find the position (index) of a wx.ToolBarToolBase in a ToolBar. + + ``ToolBar.GetToolPos`` is not useful because wx assigns the same Id to + all Separators and StretchableSpaces. + """ + pos, = [pos for pos in range(self.ToolsCount) + if self.GetToolByPos(pos) == tool] + return pos + + def add_toolitem(self, name, group, position, image_file, description, + toggle): + # Find or create the separator that follows this group. + if group not in self._groups: + self._groups[group] = self.InsertSeparator( + self._get_tool_pos(self._space)) + sep = self._groups[group] + # List all separators. + seps = [t for t in map(self.GetToolByPos, range(self.ToolsCount)) + if t.IsSeparator() and not t.IsStretchableSpace()] + # Find where to insert the tool. + if position >= 0: + # Find the start of the group by looking for the separator + # preceding this one; then move forward from it. + start = (0 if sep == seps[0] + else self._get_tool_pos(seps[seps.index(sep) - 1]) + 1) + else: + # Move backwards from this separator. + start = self._get_tool_pos(sep) + 1 + idx = start + position + if image_file: + bmp = NavigationToolbar2Wx._icon(image_file) + kind = wx.ITEM_NORMAL if not toggle else wx.ITEM_CHECK + tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind, + description or "") + else: + size = (self.GetTextExtent(name)[0] + 10, -1) + if toggle: + control = wx.ToggleButton(self, -1, name, size=size) + else: + control = wx.Button(self, -1, name, size=size) + tool = self.InsertControl(idx, control, label=name) + self.Realize() + + def handler(event): + self.trigger_tool(name) + + if image_file: + self.Bind(wx.EVT_TOOL, handler, tool) + else: + control.Bind(wx.EVT_LEFT_DOWN, handler) + + self._toolitems.setdefault(name, []) + self._toolitems[name].append((tool, handler)) + + def toggle_toolitem(self, name, toggled): + if name not in self._toolitems: + return + for tool, handler in self._toolitems[name]: + if not tool.IsControl(): + self.ToggleTool(tool.Id, toggled) + else: + tool.GetControl().SetValue(toggled) + self.Refresh() + + def remove_toolitem(self, name): + for tool, handler in self._toolitems.pop(name, []): + self.DeleteTool(tool.Id) + + def set_message(self, s): + self._label_text.SetLabel(s) + + +@backend_tools._register_tool_class(_FigureCanvasWxBase) +class ConfigureSubplotsWx(backend_tools.ConfigureSubplotsBase): + def trigger(self, *args): + NavigationToolbar2Wx.configure_subplots(self) + + +@backend_tools._register_tool_class(_FigureCanvasWxBase) +class SaveFigureWx(backend_tools.SaveFigureBase): + def trigger(self, *args): + NavigationToolbar2Wx.save_figure( + self._make_classic_style_pseudo_toolbar()) + + +@backend_tools._register_tool_class(_FigureCanvasWxBase) +class RubberbandWx(backend_tools.RubberbandBase): + def draw_rubberband(self, x0, y0, x1, y1): + NavigationToolbar2Wx.draw_rubberband( + self._make_classic_style_pseudo_toolbar(), None, x0, y0, x1, y1) + + def remove_rubberband(self): + NavigationToolbar2Wx.remove_rubberband( + self._make_classic_style_pseudo_toolbar()) + + +class _HelpDialog(wx.Dialog): + _instance = None # a reference to an open dialog singleton + headers = [("Action", "Shortcuts", "Description")] + widths = [100, 140, 300] + + def __init__(self, parent, help_entries): + super().__init__(parent, title="Help", + style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) + + sizer = wx.BoxSizer(wx.VERTICAL) + grid_sizer = wx.FlexGridSizer(0, 3, 8, 6) + # create and add the entries + bold = self.GetFont().MakeBold() + for r, row in enumerate(self.headers + help_entries): + for (col, width) in zip(row, self.widths): + label = wx.StaticText(self, label=col) + if r == 0: + label.SetFont(bold) + label.Wrap(width) + grid_sizer.Add(label, 0, 0, 0) + # finalize layout, create button + sizer.Add(grid_sizer, 0, wx.ALL, 6) + ok = wx.Button(self, wx.ID_OK) + sizer.Add(ok, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 8) + self.SetSizer(sizer) + sizer.Fit(self) + self.Layout() + self.Bind(wx.EVT_CLOSE, self._on_close) + ok.Bind(wx.EVT_BUTTON, self._on_close) + + def _on_close(self, event): + _HelpDialog._instance = None # remove global reference + self.DestroyLater() + event.Skip() + + @classmethod + def show(cls, parent, help_entries): + # if no dialog is shown, create one; otherwise just re-raise it + if cls._instance: + cls._instance.Raise() + return + cls._instance = cls(parent, help_entries) + cls._instance.Show() + + +@backend_tools._register_tool_class(_FigureCanvasWxBase) +class HelpWx(backend_tools.ToolHelpBase): + def trigger(self, *args): + _HelpDialog.show(self.figure.canvas.GetTopLevelParent(), + self._get_help_entries()) + + +@backend_tools._register_tool_class(_FigureCanvasWxBase) +class ToolCopyToClipboardWx(backend_tools.ToolCopyToClipboardBase): + def trigger(self, *args, **kwargs): + if not self.canvas._isDrawn: + self.canvas.draw() + if not self.canvas.bitmap.IsOk() or not wx.TheClipboard.Open(): + return + try: + wx.TheClipboard.SetData(wx.BitmapDataObject(self.canvas.bitmap)) + finally: + wx.TheClipboard.Close() + + +FigureManagerWx._toolbar2_class = NavigationToolbar2Wx +FigureManagerWx._toolmanager_toolbar_class = ToolbarWx + + +@_Backend.export +class _BackendWx(_Backend): + FigureCanvas = FigureCanvasWx + FigureManager = FigureManagerWx + mainloop = FigureManagerWx.start_main_loop diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxagg.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxagg.py new file mode 100644 index 00000000..ab7703ff --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxagg.py @@ -0,0 +1,45 @@ +import wx + +from .backend_agg import FigureCanvasAgg +from .backend_wx import _BackendWx, _FigureCanvasWxBase +from .backend_wx import ( # noqa: F401 # pylint: disable=W0611 + NavigationToolbar2Wx as NavigationToolbar2WxAgg) + + +class FigureCanvasWxAgg(FigureCanvasAgg, _FigureCanvasWxBase): + def draw(self, drawDC=None): + """ + Render the figure using agg. + """ + FigureCanvasAgg.draw(self) + self.bitmap = self._create_bitmap() + self._isDrawn = True + self.gui_repaint(drawDC=drawDC) + + def blit(self, bbox=None): + # docstring inherited + bitmap = self._create_bitmap() + if bbox is None: + self.bitmap = bitmap + else: + srcDC = wx.MemoryDC(bitmap) + destDC = wx.MemoryDC(self.bitmap) + x = int(bbox.x0) + y = int(self.bitmap.GetHeight() - bbox.y1) + destDC.Blit(x, y, int(bbox.width), int(bbox.height), srcDC, x, y) + destDC.SelectObject(wx.NullBitmap) + srcDC.SelectObject(wx.NullBitmap) + self.gui_repaint() + + def _create_bitmap(self): + """Create a wx.Bitmap from the renderer RGBA buffer""" + rgba = self.get_renderer().buffer_rgba() + h, w, _ = rgba.shape + bitmap = wx.Bitmap.FromBufferRGBA(w, h, rgba) + bitmap.SetScaleFactor(self.GetDPIScaleFactor()) + return bitmap + + +@_BackendWx.export +class _BackendWxAgg(_BackendWx): + FigureCanvas = FigureCanvasWxAgg diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxcairo.py b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxcairo.py new file mode 100644 index 00000000..c53e6af4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/backend_wxcairo.py @@ -0,0 +1,23 @@ +import wx.lib.wxcairo as wxcairo + +from .backend_cairo import cairo, FigureCanvasCairo +from .backend_wx import _BackendWx, _FigureCanvasWxBase +from .backend_wx import ( # noqa: F401 # pylint: disable=W0611 + NavigationToolbar2Wx as NavigationToolbar2WxCairo) + + +class FigureCanvasWxCairo(FigureCanvasCairo, _FigureCanvasWxBase): + def draw(self, drawDC=None): + size = self.figure.bbox.size.astype(int) + surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, *size) + self._renderer.set_context(cairo.Context(surface)) + self._renderer.dpi = self.figure.dpi + self.figure.draw(self._renderer) + self.bitmap = wxcairo.BitmapFromImageSurface(surface) + self._isDrawn = True + self.gui_repaint(drawDC=drawDC) + + +@_BackendWx.export +class _BackendWxCairo(_BackendWx): + FigureCanvas = FigureCanvasWxCairo diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py new file mode 100644 index 00000000..d91f7c14 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py @@ -0,0 +1,159 @@ +""" +Qt binding and backend selector. + +The selection logic is as follows: +- if any of PyQt6, PySide6, PyQt5, or PySide2 have already been + imported (checked in that order), use it; +- otherwise, if the QT_API environment variable (used by Enthought) is set, use + it to determine which binding to use; +- otherwise, use whatever the rcParams indicate. +""" + +import operator +import os +import platform +import sys + +from packaging.version import parse as parse_version + +import matplotlib as mpl + +from . import _QT_FORCE_QT5_BINDING + +QT_API_PYQT6 = "PyQt6" +QT_API_PYSIDE6 = "PySide6" +QT_API_PYQT5 = "PyQt5" +QT_API_PYSIDE2 = "PySide2" +QT_API_ENV = os.environ.get("QT_API") +if QT_API_ENV is not None: + QT_API_ENV = QT_API_ENV.lower() +_ETS = { # Mapping of QT_API_ENV to requested binding. + "pyqt6": QT_API_PYQT6, "pyside6": QT_API_PYSIDE6, + "pyqt5": QT_API_PYQT5, "pyside2": QT_API_PYSIDE2, +} +# First, check if anything is already imported. +if sys.modules.get("PyQt6.QtCore"): + QT_API = QT_API_PYQT6 +elif sys.modules.get("PySide6.QtCore"): + QT_API = QT_API_PYSIDE6 +elif sys.modules.get("PyQt5.QtCore"): + QT_API = QT_API_PYQT5 +elif sys.modules.get("PySide2.QtCore"): + QT_API = QT_API_PYSIDE2 +# Otherwise, check the QT_API environment variable (from Enthought). This can +# only override the binding, not the backend (in other words, we check that the +# requested backend actually matches). Use _get_backend_or_none to avoid +# triggering backend resolution (which can result in a partially but +# incompletely imported backend_qt5). +elif (mpl.rcParams._get_backend_or_none() or "").lower().startswith("qt5"): + if QT_API_ENV in ["pyqt5", "pyside2"]: + QT_API = _ETS[QT_API_ENV] + else: + _QT_FORCE_QT5_BINDING = True # noqa + QT_API = None +# A non-Qt backend was selected but we still got there (possible, e.g., when +# fully manually embedding Matplotlib in a Qt app without using pyplot). +elif QT_API_ENV is None: + QT_API = None +elif QT_API_ENV in _ETS: + QT_API = _ETS[QT_API_ENV] +else: + raise RuntimeError( + "The environment variable QT_API has the unrecognized value {!r}; " + "valid values are {}".format(QT_API_ENV, ", ".join(_ETS))) + + +def _setup_pyqt5plus(): + global QtCore, QtGui, QtWidgets, __version__ + global _isdeleted, _to_int + + if QT_API == QT_API_PYQT6: + from PyQt6 import QtCore, QtGui, QtWidgets, sip + __version__ = QtCore.PYQT_VERSION_STR + QtCore.Signal = QtCore.pyqtSignal + QtCore.Slot = QtCore.pyqtSlot + QtCore.Property = QtCore.pyqtProperty + _isdeleted = sip.isdeleted + _to_int = operator.attrgetter('value') + elif QT_API == QT_API_PYSIDE6: + from PySide6 import QtCore, QtGui, QtWidgets, __version__ + import shiboken6 + def _isdeleted(obj): return not shiboken6.isValid(obj) + if parse_version(__version__) >= parse_version('6.4'): + _to_int = operator.attrgetter('value') + else: + _to_int = int + elif QT_API == QT_API_PYQT5: + from PyQt5 import QtCore, QtGui, QtWidgets + import sip + __version__ = QtCore.PYQT_VERSION_STR + QtCore.Signal = QtCore.pyqtSignal + QtCore.Slot = QtCore.pyqtSlot + QtCore.Property = QtCore.pyqtProperty + _isdeleted = sip.isdeleted + _to_int = int + elif QT_API == QT_API_PYSIDE2: + from PySide2 import QtCore, QtGui, QtWidgets, __version__ + try: + from PySide2 import shiboken2 + except ImportError: + import shiboken2 + def _isdeleted(obj): + return not shiboken2.isValid(obj) + _to_int = int + else: + raise AssertionError(f"Unexpected QT_API: {QT_API}") + + +if QT_API in [QT_API_PYQT6, QT_API_PYQT5, QT_API_PYSIDE6, QT_API_PYSIDE2]: + _setup_pyqt5plus() +elif QT_API is None: # See above re: dict.__getitem__. + if _QT_FORCE_QT5_BINDING: + _candidates = [ + (_setup_pyqt5plus, QT_API_PYQT5), + (_setup_pyqt5plus, QT_API_PYSIDE2), + ] + else: + _candidates = [ + (_setup_pyqt5plus, QT_API_PYQT6), + (_setup_pyqt5plus, QT_API_PYSIDE6), + (_setup_pyqt5plus, QT_API_PYQT5), + (_setup_pyqt5plus, QT_API_PYSIDE2), + ] + for _setup, QT_API in _candidates: + try: + _setup() + except ImportError: + continue + break + else: + raise ImportError( + "Failed to import any of the following Qt binding modules: {}" + .format(", ".join([QT_API for _, QT_API in _candidates])) + ) +else: # We should not get there. + raise AssertionError(f"Unexpected QT_API: {QT_API}") +_version_info = tuple(QtCore.QLibraryInfo.version().segments()) + + +if _version_info < (5, 12): + raise ImportError( + f"The Qt version imported is " + f"{QtCore.QLibraryInfo.version().toString()} but Matplotlib requires " + f"Qt>=5.12") + + +# Fixes issues with Big Sur +# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2 +if (sys.platform == 'darwin' and + parse_version(platform.mac_ver()[0]) >= parse_version("10.16") and + _version_info < (5, 15, 2)): + os.environ.setdefault("QT_MAC_WANTS_LAYER", "1") + + +# Backports. + + +def _exec(obj): + # exec on PyQt6, exec_ elsewhere. + obj.exec() if hasattr(obj, "exec") else obj.exec_() diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/_formlayout.py b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/_formlayout.py new file mode 100644 index 00000000..fcf73cef --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/_formlayout.py @@ -0,0 +1,592 @@ +""" +formlayout +========== + +Module creating Qt form dialogs/layouts to edit various type of parameters + + +formlayout License Agreement (MIT License) +------------------------------------------ + +Copyright (c) 2009 Pierre Raybaut + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +""" + +# History: +# 1.0.10: added float validator +# (disable "Ok" and "Apply" button when not valid) +# 1.0.7: added support for "Apply" button +# 1.0.6: code cleaning + +__version__ = '1.0.10' +__license__ = __doc__ + +from ast import literal_eval + +import copy +import datetime +import logging +from numbers import Integral, Real + +from matplotlib import _api, colors as mcolors +from matplotlib.backends.qt_compat import _to_int, QtGui, QtWidgets, QtCore + +_log = logging.getLogger(__name__) + +BLACKLIST = {"title", "label"} + + +class ColorButton(QtWidgets.QPushButton): + """ + Color choosing push button + """ + colorChanged = QtCore.Signal(QtGui.QColor) + + def __init__(self, parent=None): + super().__init__(parent) + self.setFixedSize(20, 20) + self.setIconSize(QtCore.QSize(12, 12)) + self.clicked.connect(self.choose_color) + self._color = QtGui.QColor() + + def choose_color(self): + color = QtWidgets.QColorDialog.getColor( + self._color, self.parentWidget(), "", + QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel) + if color.isValid(): + self.set_color(color) + + def get_color(self): + return self._color + + @QtCore.Slot(QtGui.QColor) + def set_color(self, color): + if color != self._color: + self._color = color + self.colorChanged.emit(self._color) + pixmap = QtGui.QPixmap(self.iconSize()) + pixmap.fill(color) + self.setIcon(QtGui.QIcon(pixmap)) + + color = QtCore.Property(QtGui.QColor, get_color, set_color) + + +def to_qcolor(color): + """Create a QColor from a matplotlib color""" + qcolor = QtGui.QColor() + try: + rgba = mcolors.to_rgba(color) + except ValueError: + _api.warn_external(f'Ignoring invalid color {color!r}') + return qcolor # return invalid QColor + qcolor.setRgbF(*rgba) + return qcolor + + +class ColorLayout(QtWidgets.QHBoxLayout): + """Color-specialized QLineEdit layout""" + def __init__(self, color, parent=None): + super().__init__() + assert isinstance(color, QtGui.QColor) + self.lineedit = QtWidgets.QLineEdit( + mcolors.to_hex(color.getRgbF(), keep_alpha=True), parent) + self.lineedit.editingFinished.connect(self.update_color) + self.addWidget(self.lineedit) + self.colorbtn = ColorButton(parent) + self.colorbtn.color = color + self.colorbtn.colorChanged.connect(self.update_text) + self.addWidget(self.colorbtn) + + def update_color(self): + color = self.text() + qcolor = to_qcolor(color) # defaults to black if not qcolor.isValid() + self.colorbtn.color = qcolor + + def update_text(self, color): + self.lineedit.setText(mcolors.to_hex(color.getRgbF(), keep_alpha=True)) + + def text(self): + return self.lineedit.text() + + +def font_is_installed(font): + """Check if font is installed""" + return [fam for fam in QtGui.QFontDatabase().families() + if str(fam) == font] + + +def tuple_to_qfont(tup): + """ + Create a QFont from tuple: + (family [string], size [int], italic [bool], bold [bool]) + """ + if not (isinstance(tup, tuple) and len(tup) == 4 + and font_is_installed(tup[0]) + and isinstance(tup[1], Integral) + and isinstance(tup[2], bool) + and isinstance(tup[3], bool)): + return None + font = QtGui.QFont() + family, size, italic, bold = tup + font.setFamily(family) + font.setPointSize(size) + font.setItalic(italic) + font.setBold(bold) + return font + + +def qfont_to_tuple(font): + return (str(font.family()), int(font.pointSize()), + font.italic(), font.bold()) + + +class FontLayout(QtWidgets.QGridLayout): + """Font selection""" + def __init__(self, value, parent=None): + super().__init__() + font = tuple_to_qfont(value) + assert font is not None + + # Font family + self.family = QtWidgets.QFontComboBox(parent) + self.family.setCurrentFont(font) + self.addWidget(self.family, 0, 0, 1, -1) + + # Font size + self.size = QtWidgets.QComboBox(parent) + self.size.setEditable(True) + sizelist = [*range(6, 12), *range(12, 30, 2), 36, 48, 72] + size = font.pointSize() + if size not in sizelist: + sizelist.append(size) + sizelist.sort() + self.size.addItems([str(s) for s in sizelist]) + self.size.setCurrentIndex(sizelist.index(size)) + self.addWidget(self.size, 1, 0) + + # Italic or not + self.italic = QtWidgets.QCheckBox(self.tr("Italic"), parent) + self.italic.setChecked(font.italic()) + self.addWidget(self.italic, 1, 1) + + # Bold or not + self.bold = QtWidgets.QCheckBox(self.tr("Bold"), parent) + self.bold.setChecked(font.bold()) + self.addWidget(self.bold, 1, 2) + + def get_font(self): + font = self.family.currentFont() + font.setItalic(self.italic.isChecked()) + font.setBold(self.bold.isChecked()) + font.setPointSize(int(self.size.currentText())) + return qfont_to_tuple(font) + + +def is_edit_valid(edit): + text = edit.text() + state = edit.validator().validate(text, 0)[0] + return state == QtGui.QDoubleValidator.State.Acceptable + + +class FormWidget(QtWidgets.QWidget): + update_buttons = QtCore.Signal() + + def __init__(self, data, comment="", with_margin=False, parent=None): + """ + Parameters + ---------- + data : list of (label, value) pairs + The data to be edited in the form. + comment : str, optional + with_margin : bool, default: False + If False, the form elements reach to the border of the widget. + This is the desired behavior if the FormWidget is used as a widget + alongside with other widgets such as a QComboBox, which also do + not have a margin around them. + However, a margin can be desired if the FormWidget is the only + widget within a container, e.g. a tab in a QTabWidget. + parent : QWidget or None + The parent widget. + """ + super().__init__(parent) + self.data = copy.deepcopy(data) + self.widgets = [] + self.formlayout = QtWidgets.QFormLayout(self) + if not with_margin: + self.formlayout.setContentsMargins(0, 0, 0, 0) + if comment: + self.formlayout.addRow(QtWidgets.QLabel(comment)) + self.formlayout.addRow(QtWidgets.QLabel(" ")) + + def get_dialog(self): + """Return FormDialog instance""" + dialog = self.parent() + while not isinstance(dialog, QtWidgets.QDialog): + dialog = dialog.parent() + return dialog + + def setup(self): + for label, value in self.data: + if label is None and value is None: + # Separator: (None, None) + self.formlayout.addRow(QtWidgets.QLabel(" "), + QtWidgets.QLabel(" ")) + self.widgets.append(None) + continue + elif label is None: + # Comment + self.formlayout.addRow(QtWidgets.QLabel(value)) + self.widgets.append(None) + continue + elif tuple_to_qfont(value) is not None: + field = FontLayout(value, self) + elif (label.lower() not in BLACKLIST + and mcolors.is_color_like(value)): + field = ColorLayout(to_qcolor(value), self) + elif isinstance(value, str): + field = QtWidgets.QLineEdit(value, self) + elif isinstance(value, (list, tuple)): + if isinstance(value, tuple): + value = list(value) + # Note: get() below checks the type of value[0] in self.data so + # it is essential that value gets modified in-place. + # This means that the code is actually broken in the case where + # value is a tuple, but fortunately we always pass a list... + selindex = value.pop(0) + field = QtWidgets.QComboBox(self) + if isinstance(value[0], (list, tuple)): + keys = [key for key, _val in value] + value = [val for _key, val in value] + else: + keys = value + field.addItems(value) + if selindex in value: + selindex = value.index(selindex) + elif selindex in keys: + selindex = keys.index(selindex) + elif not isinstance(selindex, Integral): + _log.warning( + "index '%s' is invalid (label: %s, value: %s)", + selindex, label, value) + selindex = 0 + field.setCurrentIndex(selindex) + elif isinstance(value, bool): + field = QtWidgets.QCheckBox(self) + field.setChecked(value) + elif isinstance(value, Integral): + field = QtWidgets.QSpinBox(self) + field.setRange(-10**9, 10**9) + field.setValue(value) + elif isinstance(value, Real): + field = QtWidgets.QLineEdit(repr(value), self) + field.setCursorPosition(0) + field.setValidator(QtGui.QDoubleValidator(field)) + field.validator().setLocale(QtCore.QLocale("C")) + dialog = self.get_dialog() + dialog.register_float_field(field) + field.textChanged.connect(lambda text: dialog.update_buttons()) + elif isinstance(value, datetime.datetime): + field = QtWidgets.QDateTimeEdit(self) + field.setDateTime(value) + elif isinstance(value, datetime.date): + field = QtWidgets.QDateEdit(self) + field.setDate(value) + else: + field = QtWidgets.QLineEdit(repr(value), self) + self.formlayout.addRow(label, field) + self.widgets.append(field) + + def get(self): + valuelist = [] + for index, (label, value) in enumerate(self.data): + field = self.widgets[index] + if label is None: + # Separator / Comment + continue + elif tuple_to_qfont(value) is not None: + value = field.get_font() + elif isinstance(value, str) or mcolors.is_color_like(value): + value = str(field.text()) + elif isinstance(value, (list, tuple)): + index = int(field.currentIndex()) + if isinstance(value[0], (list, tuple)): + value = value[index][0] + else: + value = value[index] + elif isinstance(value, bool): + value = field.isChecked() + elif isinstance(value, Integral): + value = int(field.value()) + elif isinstance(value, Real): + value = float(str(field.text())) + elif isinstance(value, datetime.datetime): + datetime_ = field.dateTime() + if hasattr(datetime_, "toPyDateTime"): + value = datetime_.toPyDateTime() + else: + value = datetime_.toPython() + elif isinstance(value, datetime.date): + date_ = field.date() + if hasattr(date_, "toPyDate"): + value = date_.toPyDate() + else: + value = date_.toPython() + else: + value = literal_eval(str(field.text())) + valuelist.append(value) + return valuelist + + +class FormComboWidget(QtWidgets.QWidget): + update_buttons = QtCore.Signal() + + def __init__(self, datalist, comment="", parent=None): + super().__init__(parent) + layout = QtWidgets.QVBoxLayout() + self.setLayout(layout) + self.combobox = QtWidgets.QComboBox() + layout.addWidget(self.combobox) + + self.stackwidget = QtWidgets.QStackedWidget(self) + layout.addWidget(self.stackwidget) + self.combobox.currentIndexChanged.connect( + self.stackwidget.setCurrentIndex) + + self.widgetlist = [] + for data, title, comment in datalist: + self.combobox.addItem(title) + widget = FormWidget(data, comment=comment, parent=self) + self.stackwidget.addWidget(widget) + self.widgetlist.append(widget) + + def setup(self): + for widget in self.widgetlist: + widget.setup() + + def get(self): + return [widget.get() for widget in self.widgetlist] + + +class FormTabWidget(QtWidgets.QWidget): + update_buttons = QtCore.Signal() + + def __init__(self, datalist, comment="", parent=None): + super().__init__(parent) + layout = QtWidgets.QVBoxLayout() + self.tabwidget = QtWidgets.QTabWidget() + layout.addWidget(self.tabwidget) + layout.setContentsMargins(0, 0, 0, 0) + self.setLayout(layout) + self.widgetlist = [] + for data, title, comment in datalist: + if len(data[0]) == 3: + widget = FormComboWidget(data, comment=comment, parent=self) + else: + widget = FormWidget(data, with_margin=True, comment=comment, + parent=self) + index = self.tabwidget.addTab(widget, title) + self.tabwidget.setTabToolTip(index, comment) + self.widgetlist.append(widget) + + def setup(self): + for widget in self.widgetlist: + widget.setup() + + def get(self): + return [widget.get() for widget in self.widgetlist] + + +class FormDialog(QtWidgets.QDialog): + """Form Dialog""" + def __init__(self, data, title="", comment="", + icon=None, parent=None, apply=None): + super().__init__(parent) + + self.apply_callback = apply + + # Form + if isinstance(data[0][0], (list, tuple)): + self.formwidget = FormTabWidget(data, comment=comment, + parent=self) + elif len(data[0]) == 3: + self.formwidget = FormComboWidget(data, comment=comment, + parent=self) + else: + self.formwidget = FormWidget(data, comment=comment, + parent=self) + layout = QtWidgets.QVBoxLayout() + layout.addWidget(self.formwidget) + + self.float_fields = [] + self.formwidget.setup() + + # Button box + self.bbox = bbox = QtWidgets.QDialogButtonBox( + QtWidgets.QDialogButtonBox.StandardButton( + _to_int(QtWidgets.QDialogButtonBox.StandardButton.Ok) | + _to_int(QtWidgets.QDialogButtonBox.StandardButton.Cancel) + )) + self.formwidget.update_buttons.connect(self.update_buttons) + if self.apply_callback is not None: + apply_btn = bbox.addButton( + QtWidgets.QDialogButtonBox.StandardButton.Apply) + apply_btn.clicked.connect(self.apply) + + bbox.accepted.connect(self.accept) + bbox.rejected.connect(self.reject) + layout.addWidget(bbox) + + self.setLayout(layout) + + self.setWindowTitle(title) + if not isinstance(icon, QtGui.QIcon): + icon = QtWidgets.QWidget().style().standardIcon( + QtWidgets.QStyle.SP_MessageBoxQuestion) + self.setWindowIcon(icon) + + def register_float_field(self, field): + self.float_fields.append(field) + + def update_buttons(self): + valid = True + for field in self.float_fields: + if not is_edit_valid(field): + valid = False + for btn_type in ["Ok", "Apply"]: + btn = self.bbox.button( + getattr(QtWidgets.QDialogButtonBox.StandardButton, + btn_type)) + if btn is not None: + btn.setEnabled(valid) + + def accept(self): + self.data = self.formwidget.get() + self.apply_callback(self.data) + super().accept() + + def reject(self): + self.data = None + super().reject() + + def apply(self): + self.apply_callback(self.formwidget.get()) + + def get(self): + """Return form result""" + return self.data + + +def fedit(data, title="", comment="", icon=None, parent=None, apply=None): + """ + Create form dialog + + data: datalist, datagroup + title: str + comment: str + icon: QIcon instance + parent: parent QWidget + apply: apply callback (function) + + datalist: list/tuple of (field_name, field_value) + datagroup: list/tuple of (datalist *or* datagroup, title, comment) + + -> one field for each member of a datalist + -> one tab for each member of a top-level datagroup + -> one page (of a multipage widget, each page can be selected with a combo + box) for each member of a datagroup inside a datagroup + + Supported types for field_value: + - int, float, str, bool + - colors: in Qt-compatible text form, i.e. in hex format or name + (red, ...) (automatically detected from a string) + - list/tuple: + * the first element will be the selected index (or value) + * the other elements can be couples (key, value) or only values + """ + + # Create a QApplication instance if no instance currently exists + # (e.g., if the module is used directly from the interpreter) + if QtWidgets.QApplication.startingUp(): + _app = QtWidgets.QApplication([]) + dialog = FormDialog(data, title, comment, icon, parent, apply) + + if parent is not None: + if hasattr(parent, "_fedit_dialog"): + parent._fedit_dialog.close() + parent._fedit_dialog = dialog + + dialog.show() + + +if __name__ == "__main__": + + _app = QtWidgets.QApplication([]) + + def create_datalist_example(): + return [('str', 'this is a string'), + ('list', [0, '1', '3', '4']), + ('list2', ['--', ('none', 'None'), ('--', 'Dashed'), + ('-.', 'DashDot'), ('-', 'Solid'), + ('steps', 'Steps'), (':', 'Dotted')]), + ('float', 1.2), + (None, 'Other:'), + ('int', 12), + ('font', ('Arial', 10, False, True)), + ('color', '#123409'), + ('bool', True), + ('date', datetime.date(2010, 10, 10)), + ('datetime', datetime.datetime(2010, 10, 10)), + ] + + def create_datagroup_example(): + datalist = create_datalist_example() + return ((datalist, "Category 1", "Category 1 comment"), + (datalist, "Category 2", "Category 2 comment"), + (datalist, "Category 3", "Category 3 comment")) + + # --------- datalist example + datalist = create_datalist_example() + + def apply_test(data): + print("data:", data) + fedit(datalist, title="Example", + comment="This is just an example.", + apply=apply_test) + + _app.exec() + + # --------- datagroup example + datagroup = create_datagroup_example() + fedit(datagroup, "Global title", + apply=apply_test) + _app.exec() + + # --------- datagroup inside a datagroup example + datalist = create_datalist_example() + datagroup = create_datagroup_example() + fedit(((datagroup, "Title 1", "Tab 1 comment"), + (datalist, "Title 2", "Tab 2 comment"), + (datalist, "Title 3", "Tab 3 comment")), + "Global title", + apply=apply_test) + _app.exec() diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/figureoptions.py b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/figureoptions.py new file mode 100644 index 00000000..c36bbeb6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/qt_editor/figureoptions.py @@ -0,0 +1,271 @@ +# Copyright © 2009 Pierre Raybaut +# Licensed under the terms of the MIT License +# see the Matplotlib licenses directory for a copy of the license + + +"""Module that provides a GUI-based editor for Matplotlib's figure options.""" + +from itertools import chain +from matplotlib import cbook, cm, colors as mcolors, markers, image as mimage +from matplotlib.backends.qt_compat import QtGui +from matplotlib.backends.qt_editor import _formlayout +from matplotlib.dates import DateConverter, num2date + +LINESTYLES = {'-': 'Solid', + '--': 'Dashed', + '-.': 'DashDot', + ':': 'Dotted', + 'None': 'None', + } + +DRAWSTYLES = { + 'default': 'Default', + 'steps-pre': 'Steps (Pre)', 'steps': 'Steps (Pre)', + 'steps-mid': 'Steps (Mid)', + 'steps-post': 'Steps (Post)'} + +MARKERS = markers.MarkerStyle.markers + + +def figure_edit(axes, parent=None): + """Edit matplotlib figure options""" + sep = (None, None) # separator + + # Get / General + def convert_limits(lim, converter): + """Convert axis limits for correct input editors.""" + if isinstance(converter, DateConverter): + return map(num2date, lim) + # Cast to builtin floats as they have nicer reprs. + return map(float, lim) + + axis_map = axes._axis_map + axis_limits = { + name: tuple(convert_limits( + getattr(axes, f'get_{name}lim')(), axis.converter + )) + for name, axis in axis_map.items() + } + general = [ + ('Title', axes.get_title()), + sep, + *chain.from_iterable([ + ( + (None, f"{name.title()}-Axis"), + ('Min', axis_limits[name][0]), + ('Max', axis_limits[name][1]), + ('Label', axis.get_label().get_text()), + ('Scale', [axis.get_scale(), + 'linear', 'log', 'symlog', 'logit']), + sep, + ) + for name, axis in axis_map.items() + ]), + ('(Re-)Generate automatic legend', False), + ] + + # Save the converter and unit data + axis_converter = { + name: axis.converter + for name, axis in axis_map.items() + } + axis_units = { + name: axis.get_units() + for name, axis in axis_map.items() + } + + # Get / Curves + labeled_lines = [] + for line in axes.get_lines(): + label = line.get_label() + if label == '_nolegend_': + continue + labeled_lines.append((label, line)) + curves = [] + + def prepare_data(d, init): + """ + Prepare entry for FormLayout. + + *d* is a mapping of shorthands to style names (a single style may + have multiple shorthands, in particular the shorthands `None`, + `"None"`, `"none"` and `""` are synonyms); *init* is one shorthand + of the initial style. + + This function returns an list suitable for initializing a + FormLayout combobox, namely `[initial_name, (shorthand, + style_name), (shorthand, style_name), ...]`. + """ + if init not in d: + d = {**d, init: str(init)} + # Drop duplicate shorthands from dict (by overwriting them during + # the dict comprehension). + name2short = {name: short for short, name in d.items()} + # Convert back to {shorthand: name}. + short2name = {short: name for name, short in name2short.items()} + # Find the kept shorthand for the style specified by init. + canonical_init = name2short[d[init]] + # Sort by representation and prepend the initial value. + return ([canonical_init] + + sorted(short2name.items(), + key=lambda short_and_name: short_and_name[1])) + + for label, line in labeled_lines: + color = mcolors.to_hex( + mcolors.to_rgba(line.get_color(), line.get_alpha()), + keep_alpha=True) + ec = mcolors.to_hex( + mcolors.to_rgba(line.get_markeredgecolor(), line.get_alpha()), + keep_alpha=True) + fc = mcolors.to_hex( + mcolors.to_rgba(line.get_markerfacecolor(), line.get_alpha()), + keep_alpha=True) + curvedata = [ + ('Label', label), + sep, + (None, 'Line'), + ('Line style', prepare_data(LINESTYLES, line.get_linestyle())), + ('Draw style', prepare_data(DRAWSTYLES, line.get_drawstyle())), + ('Width', line.get_linewidth()), + ('Color (RGBA)', color), + sep, + (None, 'Marker'), + ('Style', prepare_data(MARKERS, line.get_marker())), + ('Size', line.get_markersize()), + ('Face color (RGBA)', fc), + ('Edge color (RGBA)', ec)] + curves.append([curvedata, label, ""]) + # Is there a curve displayed? + has_curve = bool(curves) + + # Get ScalarMappables. + labeled_mappables = [] + for mappable in [*axes.images, *axes.collections]: + label = mappable.get_label() + if label == '_nolegend_' or mappable.get_array() is None: + continue + labeled_mappables.append((label, mappable)) + mappables = [] + cmaps = [(cmap, name) for name, cmap in sorted(cm._colormaps.items())] + for label, mappable in labeled_mappables: + cmap = mappable.get_cmap() + if cmap not in cm._colormaps.values(): + cmaps = [(cmap, cmap.name), *cmaps] + low, high = mappable.get_clim() + mappabledata = [ + ('Label', label), + ('Colormap', [cmap.name] + cmaps), + ('Min. value', low), + ('Max. value', high), + ] + if hasattr(mappable, "get_interpolation"): # Images. + interpolations = [ + (name, name) for name in sorted(mimage.interpolations_names)] + mappabledata.append(( + 'Interpolation', + [mappable.get_interpolation(), *interpolations])) + + interpolation_stages = ['data', 'rgba'] + mappabledata.append(( + 'Interpolation stage', + [mappable.get_interpolation_stage(), *interpolation_stages])) + + mappables.append([mappabledata, label, ""]) + # Is there a scalarmappable displayed? + has_sm = bool(mappables) + + datalist = [(general, "Axes", "")] + if curves: + datalist.append((curves, "Curves", "")) + if mappables: + datalist.append((mappables, "Images, etc.", "")) + + def apply_callback(data): + """A callback to apply changes.""" + orig_limits = { + name: getattr(axes, f"get_{name}lim")() + for name in axis_map + } + + general = data.pop(0) + curves = data.pop(0) if has_curve else [] + mappables = data.pop(0) if has_sm else [] + if data: + raise ValueError("Unexpected field") + + title = general.pop(0) + axes.set_title(title) + generate_legend = general.pop() + + for i, (name, axis) in enumerate(axis_map.items()): + axis_min = general[4*i] + axis_max = general[4*i + 1] + axis_label = general[4*i + 2] + axis_scale = general[4*i + 3] + if axis.get_scale() != axis_scale: + getattr(axes, f"set_{name}scale")(axis_scale) + + axis._set_lim(axis_min, axis_max, auto=False) + axis.set_label_text(axis_label) + + # Restore the unit data + axis.converter = axis_converter[name] + axis.set_units(axis_units[name]) + + # Set / Curves + for index, curve in enumerate(curves): + line = labeled_lines[index][1] + (label, linestyle, drawstyle, linewidth, color, marker, markersize, + markerfacecolor, markeredgecolor) = curve + line.set_label(label) + line.set_linestyle(linestyle) + line.set_drawstyle(drawstyle) + line.set_linewidth(linewidth) + rgba = mcolors.to_rgba(color) + line.set_alpha(None) + line.set_color(rgba) + if marker != 'none': + line.set_marker(marker) + line.set_markersize(markersize) + line.set_markerfacecolor(markerfacecolor) + line.set_markeredgecolor(markeredgecolor) + + # Set ScalarMappables. + for index, mappable_settings in enumerate(mappables): + mappable = labeled_mappables[index][1] + if len(mappable_settings) == 6: + label, cmap, low, high, interpolation, interpolation_stage = \ + mappable_settings + mappable.set_interpolation(interpolation) + mappable.set_interpolation_stage(interpolation_stage) + elif len(mappable_settings) == 4: + label, cmap, low, high = mappable_settings + mappable.set_label(label) + mappable.set_cmap(cmap) + mappable.set_clim(*sorted([low, high])) + + # re-generate legend, if checkbox is checked + if generate_legend: + draggable = None + ncols = 1 + if axes.legend_ is not None: + old_legend = axes.get_legend() + draggable = old_legend._draggable is not None + ncols = old_legend._ncols + new_legend = axes.legend(ncols=ncols) + if new_legend: + new_legend.set_draggable(draggable) + + # Redraw + figure = axes.get_figure() + figure.canvas.draw() + for name in axis_map: + if getattr(axes, f"get_{name}lim")() != orig_limits[name]: + figure.canvas.toolbar.push_current() + break + + _formlayout.fedit( + datalist, title="Figure options", parent=parent, + icon=QtGui.QIcon( + str(cbook._get_data_path('images', 'qt4_editor_options.svg'))), + apply=apply_callback) diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/registry.py b/venv/lib/python3.10/site-packages/matplotlib/backends/registry.py new file mode 100644 index 00000000..19b4cba2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/registry.py @@ -0,0 +1,411 @@ +from enum import Enum +import importlib + + +class BackendFilter(Enum): + """ + Filter used with :meth:`~matplotlib.backends.registry.BackendRegistry.list_builtin` + + .. versionadded:: 3.9 + """ + INTERACTIVE = 0 + NON_INTERACTIVE = 1 + + +class BackendRegistry: + """ + Registry of backends available within Matplotlib. + + This is the single source of truth for available backends. + + All use of ``BackendRegistry`` should be via the singleton instance + ``backend_registry`` which can be imported from ``matplotlib.backends``. + + Each backend has a name, a module name containing the backend code, and an + optional GUI framework that must be running if the backend is interactive. + There are three sources of backends: built-in (source code is within the + Matplotlib repository), explicit ``module://some.backend`` syntax (backend is + obtained by loading the module), or via an entry point (self-registering + backend in an external package). + + .. versionadded:: 3.9 + """ + # Mapping of built-in backend name to GUI framework, or "headless" for no + # GUI framework. Built-in backends are those which are included in the + # Matplotlib repo. A backend with name 'name' is located in the module + # f"matplotlib.backends.backend_{name.lower()}" + _BUILTIN_BACKEND_TO_GUI_FRAMEWORK = { + "gtk3agg": "gtk3", + "gtk3cairo": "gtk3", + "gtk4agg": "gtk4", + "gtk4cairo": "gtk4", + "macosx": "macosx", + "nbagg": "nbagg", + "notebook": "nbagg", + "qtagg": "qt", + "qtcairo": "qt", + "qt5agg": "qt5", + "qt5cairo": "qt5", + "tkagg": "tk", + "tkcairo": "tk", + "webagg": "webagg", + "wx": "wx", + "wxagg": "wx", + "wxcairo": "wx", + "agg": "headless", + "cairo": "headless", + "pdf": "headless", + "pgf": "headless", + "ps": "headless", + "svg": "headless", + "template": "headless", + } + + # Reverse mapping of gui framework to preferred built-in backend. + _GUI_FRAMEWORK_TO_BACKEND = { + "gtk3": "gtk3agg", + "gtk4": "gtk4agg", + "headless": "agg", + "macosx": "macosx", + "qt": "qtagg", + "qt5": "qt5agg", + "qt6": "qtagg", + "tk": "tkagg", + "wx": "wxagg", + } + + def __init__(self): + # Only load entry points when first needed. + self._loaded_entry_points = False + + # Mapping of non-built-in backend to GUI framework, added dynamically from + # entry points and from matplotlib.use("module://some.backend") format. + # New entries have an "unknown" GUI framework that is determined when first + # needed by calling _get_gui_framework_by_loading. + self._backend_to_gui_framework = {} + + # Mapping of backend name to module name, where different from + # f"matplotlib.backends.backend_{backend_name.lower()}". These are either + # hardcoded for backward compatibility, or loaded from entry points or + # "module://some.backend" syntax. + self._name_to_module = { + "notebook": "nbagg", + } + + def _backend_module_name(self, backend): + # Return name of module containing the specified backend. + # Does not check if the backend is valid, use is_valid_backend for that. + backend = backend.lower() + + # Check if have specific name to module mapping. + backend = self._name_to_module.get(backend, backend) + + return (backend[9:] if backend.startswith("module://") + else f"matplotlib.backends.backend_{backend}") + + def _clear(self): + # Clear all dynamically-added data, used for testing only. + self.__init__() + + def _ensure_entry_points_loaded(self): + # Load entry points, if they have not already been loaded. + if not self._loaded_entry_points: + entries = self._read_entry_points() + self._validate_and_store_entry_points(entries) + self._loaded_entry_points = True + + def _get_gui_framework_by_loading(self, backend): + # Determine GUI framework for a backend by loading its module and reading the + # FigureCanvas.required_interactive_framework attribute. + # Returns "headless" if there is no GUI framework. + module = self.load_backend_module(backend) + canvas_class = module.FigureCanvas + return canvas_class.required_interactive_framework or "headless" + + def _read_entry_points(self): + # Read entry points of modules that self-advertise as Matplotlib backends. + # Expects entry points like this one from matplotlib-inline (in pyproject.toml + # format): + # [project.entry-points."matplotlib.backend"] + # inline = "matplotlib_inline.backend_inline" + import importlib.metadata as im + import sys + + # entry_points group keyword not available before Python 3.10 + group = "matplotlib.backend" + if sys.version_info >= (3, 10): + entry_points = im.entry_points(group=group) + else: + entry_points = im.entry_points().get(group, ()) + entries = [(entry.name, entry.value) for entry in entry_points] + + # For backward compatibility, if matplotlib-inline and/or ipympl are installed + # but too old to include entry points, create them. Do not import ipympl + # directly as this calls matplotlib.use() whilst in this function. + def backward_compatible_entry_points( + entries, module_name, threshold_version, names, target): + from matplotlib import _parse_to_version_info + try: + module_version = im.version(module_name) + if _parse_to_version_info(module_version) < threshold_version: + for name in names: + entries.append((name, target)) + except im.PackageNotFoundError: + pass + + names = [entry[0] for entry in entries] + if "inline" not in names: + backward_compatible_entry_points( + entries, "matplotlib_inline", (0, 1, 7), ["inline"], + "matplotlib_inline.backend_inline") + if "ipympl" not in names: + backward_compatible_entry_points( + entries, "ipympl", (0, 9, 4), ["ipympl", "widget"], + "ipympl.backend_nbagg") + + return entries + + def _validate_and_store_entry_points(self, entries): + # Validate and store entry points so that they can be used via matplotlib.use() + # in the normal manner. Entry point names cannot be of module:// format, cannot + # shadow a built-in backend name, and cannot be duplicated. + for name, module in entries: + name = name.lower() + if name.startswith("module://"): + raise RuntimeError( + f"Entry point name '{name}' cannot start with 'module://'") + if name in self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK: + raise RuntimeError(f"Entry point name '{name}' is a built-in backend") + if name in self._backend_to_gui_framework: + raise RuntimeError(f"Entry point name '{name}' duplicated") + + self._name_to_module[name] = "module://" + module + # Do not yet know backend GUI framework, determine it only when necessary. + self._backend_to_gui_framework[name] = "unknown" + + def backend_for_gui_framework(self, framework): + """ + Return the name of the backend corresponding to the specified GUI framework. + + Parameters + ---------- + framework : str + GUI framework such as "qt". + + Returns + ------- + str or None + Backend name or None if GUI framework not recognised. + """ + return self._GUI_FRAMEWORK_TO_BACKEND.get(framework.lower()) + + def is_valid_backend(self, backend): + """ + Return True if the backend name is valid, False otherwise. + + A backend name is valid if it is one of the built-in backends or has been + dynamically added via an entry point. Those beginning with ``module://`` are + always considered valid and are added to the current list of all backends + within this function. + + Even if a name is valid, it may not be importable or usable. This can only be + determined by loading and using the backend module. + + Parameters + ---------- + backend : str + Name of backend. + + Returns + ------- + bool + True if backend is valid, False otherwise. + """ + backend = backend.lower() + + # For backward compatibility, convert ipympl and matplotlib-inline long + # module:// names to their shortened forms. + backwards_compat = { + "module://ipympl.backend_nbagg": "widget", + "module://matplotlib_inline.backend_inline": "inline", + } + backend = backwards_compat.get(backend, backend) + + if (backend in self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK or + backend in self._backend_to_gui_framework): + return True + + if backend.startswith("module://"): + self._backend_to_gui_framework[backend] = "unknown" + return True + + # Only load entry points if really need to and not already done so. + self._ensure_entry_points_loaded() + if backend in self._backend_to_gui_framework: + return True + + return False + + def list_all(self): + """ + Return list of all known backends. + + These include built-in backends and those obtained at runtime either from entry + points or explicit ``module://some.backend`` syntax. + + Entry points will be loaded if they haven't been already. + + Returns + ------- + list of str + Backend names. + """ + self._ensure_entry_points_loaded() + return [*self.list_builtin(), *self._backend_to_gui_framework] + + def list_builtin(self, filter_=None): + """ + Return list of backends that are built into Matplotlib. + + Parameters + ---------- + filter_ : `~.BackendFilter`, optional + Filter to apply to returned backends. For example, to return only + non-interactive backends use `.BackendFilter.NON_INTERACTIVE`. + + Returns + ------- + list of str + Backend names. + """ + if filter_ == BackendFilter.INTERACTIVE: + return [k for k, v in self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.items() + if v != "headless"] + elif filter_ == BackendFilter.NON_INTERACTIVE: + return [k for k, v in self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.items() + if v == "headless"] + + return [*self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK] + + def list_gui_frameworks(self): + """ + Return list of GUI frameworks used by Matplotlib backends. + + Returns + ------- + list of str + GUI framework names. + """ + return [k for k in self._GUI_FRAMEWORK_TO_BACKEND if k != "headless"] + + def load_backend_module(self, backend): + """ + Load and return the module containing the specified backend. + + Parameters + ---------- + backend : str + Name of backend to load. + + Returns + ------- + Module + Module containing backend. + """ + module_name = self._backend_module_name(backend) + return importlib.import_module(module_name) + + def resolve_backend(self, backend): + """ + Return the backend and GUI framework for the specified backend name. + + If the GUI framework is not yet known then it will be determined by loading the + backend module and checking the ``FigureCanvas.required_interactive_framework`` + attribute. + + This function only loads entry points if they have not already been loaded and + the backend is not built-in and not of ``module://some.backend`` format. + + Parameters + ---------- + backend : str or None + Name of backend, or None to use the default backend. + + Returns + ------- + backend : str + The backend name. + framework : str or None + The GUI framework, which will be None for a backend that is non-interactive. + """ + if isinstance(backend, str): + backend = backend.lower() + else: # Might be _auto_backend_sentinel or None + # Use whatever is already running... + from matplotlib import get_backend + backend = get_backend() + + # Is backend already known (built-in or dynamically loaded)? + gui = (self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.get(backend) or + self._backend_to_gui_framework.get(backend)) + + # Is backend "module://something"? + if gui is None and isinstance(backend, str) and backend.startswith("module://"): + gui = "unknown" + + # Is backend a possible entry point? + if gui is None and not self._loaded_entry_points: + self._ensure_entry_points_loaded() + gui = self._backend_to_gui_framework.get(backend) + + # Backend known but not its gui framework. + if gui == "unknown": + gui = self._get_gui_framework_by_loading(backend) + self._backend_to_gui_framework[backend] = gui + + if gui is None: + raise RuntimeError(f"'{backend}' is not a recognised backend name") + + return backend, gui if gui != "headless" else None + + def resolve_gui_or_backend(self, gui_or_backend): + """ + Return the backend and GUI framework for the specified string that may be + either a GUI framework or a backend name, tested in that order. + + This is for use with the IPython %matplotlib magic command which may be a GUI + framework such as ``%matplotlib qt`` or a backend name such as + ``%matplotlib qtagg``. + + This function only loads entry points if they have not already been loaded and + the backend is not built-in and not of ``module://some.backend`` format. + + Parameters + ---------- + gui_or_backend : str or None + Name of GUI framework or backend, or None to use the default backend. + + Returns + ------- + backend : str + The backend name. + framework : str or None + The GUI framework, which will be None for a backend that is non-interactive. + """ + gui_or_backend = gui_or_backend.lower() + + # First check if it is a gui loop name. + backend = self.backend_for_gui_framework(gui_or_backend) + if backend is not None: + return backend, gui_or_backend if gui_or_backend != "headless" else None + + # Then check if it is a backend name. + try: + return self.resolve_backend(gui_or_backend) + except Exception: # KeyError ? + raise RuntimeError( + f"'{gui_or_backend} is not a recognised GUI loop or backend name") + + +# Singleton +backend_registry = BackendRegistry() diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/all_figures.html b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/all_figures.html new file mode 100644 index 00000000..62f04b65 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/all_figures.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + MPL | WebAgg current figures + + + +
+ +
+ + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/boilerplate.css b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/boilerplate.css new file mode 100644 index 00000000..2b1535f4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/boilerplate.css @@ -0,0 +1,77 @@ +/** + * HTML5 ✰ Boilerplate + * + * style.css contains a reset, font normalization and some base styles. + * + * Credit is left where credit is due. + * Much inspiration was taken from these projects: + * - yui.yahooapis.com/2.8.1/build/base/base.css + * - camendesign.com/design/ + * - praegnanz.de/weblog/htmlcssjs-kickstart + */ + + +/** + * html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline) + * v1.6.1 2010-09-17 | Authors: Eric Meyer & Richard Clark + * html5doctor.com/html-5-reset-stylesheet/ + */ + +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + +sup { vertical-align: super; } +sub { vertical-align: sub; } + +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} + +blockquote, q { quotes: none; } + +blockquote:before, blockquote:after, +q:before, q:after { content: ""; content: none; } + +ins { background-color: #ff9; color: #000; text-decoration: none; } + +mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; } + +del { text-decoration: line-through; } + +abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; } + +table { border-collapse: collapse; border-spacing: 0; } + +hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } + +input, select { vertical-align: middle; } + + +/** + * Font normalization inspired by YUI Library's fonts.css: developer.yahoo.com/yui/ + */ + +body { font:13px/1.231 sans-serif; *font-size:small; } /* Hack retained to preserve specificity */ +select, input, textarea, button { font:99% sans-serif; } + +/* Normalize monospace sizing: + en.wikipedia.org/wiki/MediaWiki_talk:Common.css/Archive_11#Teletype_style_fix_for_Chrome */ +pre, code, kbd, samp { font-family: monospace, sans-serif; } + +em,i { font-style: italic; } +b,strong { font-weight: bold; } diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/fbm.css b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/fbm.css new file mode 100644 index 00000000..ce35d99a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/fbm.css @@ -0,0 +1,97 @@ + +/* Flexible box model classes */ +/* Taken from Alex Russell https://infrequently.org/2009/08/css-3-progress/ */ + +.hbox { + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: stretch; + + display: -moz-box; + -moz-box-orient: horizontal; + -moz-box-align: stretch; + + display: box; + box-orient: horizontal; + box-align: stretch; +} + +.hbox > * { + -webkit-box-flex: 0; + -moz-box-flex: 0; + box-flex: 0; +} + +.vbox { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-box-align: stretch; + + display: -moz-box; + -moz-box-orient: vertical; + -moz-box-align: stretch; + + display: box; + box-orient: vertical; + box-align: stretch; +} + +.vbox > * { + -webkit-box-flex: 0; + -moz-box-flex: 0; + box-flex: 0; +} + +.reverse { + -webkit-box-direction: reverse; + -moz-box-direction: reverse; + box-direction: reverse; +} + +.box-flex0 { + -webkit-box-flex: 0; + -moz-box-flex: 0; + box-flex: 0; +} + +.box-flex1, .box-flex { + -webkit-box-flex: 1; + -moz-box-flex: 1; + box-flex: 1; +} + +.box-flex2 { + -webkit-box-flex: 2; + -moz-box-flex: 2; + box-flex: 2; +} + +.box-group1 { + -webkit-box-flex-group: 1; + -moz-box-flex-group: 1; + box-flex-group: 1; +} + +.box-group2 { + -webkit-box-flex-group: 2; + -moz-box-flex-group: 2; + box-flex-group: 2; +} + +.start { + -webkit-box-pack: start; + -moz-box-pack: start; + box-pack: start; +} + +.end { + -webkit-box-pack: end; + -moz-box-pack: end; + box-pack: end; +} + +.center { + -webkit-box-pack: center; + -moz-box-pack: center; + box-pack: center; +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/mpl.css b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/mpl.css new file mode 100644 index 00000000..e55733d2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/mpl.css @@ -0,0 +1,84 @@ +/* General styling */ +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} + +/* Header */ +.ui-widget-header { + border: 1px solid #dddddd; + border-top-left-radius: 6px; + border-top-right-radius: 6px; + background: #e9e9e9; + color: #333333; + font-weight: bold; +} + +/* Toolbar and items */ +.mpl-toolbar { + width: 100%; +} + +.mpl-toolbar div.mpl-button-group { + display: inline-block; +} + +.mpl-button-group + .mpl-button-group { + margin-left: 0.5em; +} + +.mpl-widget { + background-color: #fff; + border: 1px solid #ccc; + display: inline-block; + cursor: pointer; + color: #333; + padding: 6px; + vertical-align: middle; +} + +.mpl-widget:disabled, +.mpl-widget[disabled] { + background-color: #ddd; + border-color: #ddd !important; + cursor: not-allowed; +} + +.mpl-widget:disabled img, +.mpl-widget[disabled] img { + /* Convert black to grey */ + filter: contrast(0%); +} + +.mpl-widget.active img { + /* Convert black to tab:blue, approximately */ + filter: invert(34%) sepia(97%) saturate(468%) hue-rotate(162deg) brightness(96%) contrast(91%); +} + +button.mpl-widget:focus, +button.mpl-widget:hover { + background-color: #ddd; + border-color: #aaa; +} + +.mpl-button-group button.mpl-widget { + margin-left: -1px; +} +.mpl-button-group button.mpl-widget:first-child { + border-top-left-radius: 6px; + border-bottom-left-radius: 6px; + margin-left: 0px; +} +.mpl-button-group button.mpl-widget:last-child { + border-top-right-radius: 6px; + border-bottom-right-radius: 6px; +} + +select.mpl-widget { + cursor: default; +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/page.css b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/page.css new file mode 100644 index 00000000..ded0d922 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/css/page.css @@ -0,0 +1,82 @@ +/** + * Primary styles + * + * Author: IPython Development Team + */ + + +body { + background-color: white; + /* This makes sure that the body covers the entire window and needs to + be in a different element than the display: box in wrapper below */ + position: absolute; + left: 0px; + right: 0px; + top: 0px; + bottom: 0px; + overflow: visible; +} + + +div#header { + /* Initially hidden to prevent FLOUC */ + display: none; + position: relative; + height: 40px; + padding: 5px; + margin: 0px; + width: 100%; +} + +span#ipython_notebook { + position: absolute; + padding: 2px 2px 2px 5px; +} + +span#ipython_notebook img { + font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; + height: 24px; + text-decoration:none; + display: inline; + color: black; +} + +#site { + width: 100%; + display: none; +} + +/* We set the fonts by hand here to override the values in the theme */ +.ui-widget { + font-family: "Lucinda Grande", "Lucinda Sans Unicode", Helvetica, Arial, Verdana, sans-serif; +} + +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { + font-family: "Lucinda Grande", "Lucinda Sans Unicode", Helvetica, Arial, Verdana, sans-serif; +} + +/* Smaller buttons */ +.ui-button .ui-button-text { + padding: 0.2em 0.8em; + font-size: 77%; +} + +input.ui-button { + padding: 0.3em 0.9em; +} + +span#login_widget { + float: right; +} + +.border-box-sizing { + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; +} + +#figure-div { + display: inline-block; + margin: 10px; + vertical-align: top; +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/ipython_inline_figure.html b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/ipython_inline_figure.html new file mode 100644 index 00000000..b941d352 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/ipython_inline_figure.html @@ -0,0 +1,34 @@ + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl.js b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl.js new file mode 100644 index 00000000..6e8ec449 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl.js @@ -0,0 +1,704 @@ +/* Put everything inside the global mpl namespace */ +/* global mpl */ +window.mpl = {}; + +mpl.get_websocket_type = function () { + if (typeof WebSocket !== 'undefined') { + return WebSocket; + } else if (typeof MozWebSocket !== 'undefined') { + return MozWebSocket; + } else { + alert( + 'Your browser does not have WebSocket support. ' + + 'Please try Chrome, Safari or Firefox ≥ 6. ' + + 'Firefox 4 and 5 are also supported but you ' + + 'have to enable WebSockets in about:config.' + ); + } +}; + +mpl.figure = function (figure_id, websocket, ondownload, parent_element) { + this.id = figure_id; + + this.ws = websocket; + + this.supports_binary = this.ws.binaryType !== undefined; + + if (!this.supports_binary) { + var warnings = document.getElementById('mpl-warnings'); + if (warnings) { + warnings.style.display = 'block'; + warnings.textContent = + 'This browser does not support binary websocket messages. ' + + 'Performance may be slow.'; + } + } + + this.imageObj = new Image(); + + this.context = undefined; + this.message = undefined; + this.canvas = undefined; + this.rubberband_canvas = undefined; + this.rubberband_context = undefined; + this.format_dropdown = undefined; + + this.image_mode = 'full'; + + this.root = document.createElement('div'); + this.root.setAttribute('style', 'display: inline-block'); + this._root_extra_style(this.root); + + parent_element.appendChild(this.root); + + this._init_header(this); + this._init_canvas(this); + this._init_toolbar(this); + + var fig = this; + + this.waiting = false; + + this.ws.onopen = function () { + fig.send_message('supports_binary', { value: fig.supports_binary }); + fig.send_message('send_image_mode', {}); + if (fig.ratio !== 1) { + fig.send_message('set_device_pixel_ratio', { + device_pixel_ratio: fig.ratio, + }); + } + fig.send_message('refresh', {}); + }; + + this.imageObj.onload = function () { + if (fig.image_mode === 'full') { + // Full images could contain transparency (where diff images + // almost always do), so we need to clear the canvas so that + // there is no ghosting. + fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height); + } + fig.context.drawImage(fig.imageObj, 0, 0); + }; + + this.imageObj.onunload = function () { + fig.ws.close(); + }; + + this.ws.onmessage = this._make_on_message_function(this); + + this.ondownload = ondownload; +}; + +mpl.figure.prototype._init_header = function () { + var titlebar = document.createElement('div'); + titlebar.classList = + 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix'; + var titletext = document.createElement('div'); + titletext.classList = 'ui-dialog-title'; + titletext.setAttribute( + 'style', + 'width: 100%; text-align: center; padding: 3px;' + ); + titlebar.appendChild(titletext); + this.root.appendChild(titlebar); + this.header = titletext; +}; + +mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {}; + +mpl.figure.prototype._root_extra_style = function (_canvas_div) {}; + +mpl.figure.prototype._init_canvas = function () { + var fig = this; + + var canvas_div = (this.canvas_div = document.createElement('div')); + canvas_div.setAttribute('tabindex', '0'); + canvas_div.setAttribute( + 'style', + 'border: 1px solid #ddd;' + + 'box-sizing: content-box;' + + 'clear: both;' + + 'min-height: 1px;' + + 'min-width: 1px;' + + 'outline: 0;' + + 'overflow: hidden;' + + 'position: relative;' + + 'resize: both;' + + 'z-index: 2;' + ); + + function on_keyboard_event_closure(name) { + return function (event) { + return fig.key_event(event, name); + }; + } + + canvas_div.addEventListener( + 'keydown', + on_keyboard_event_closure('key_press') + ); + canvas_div.addEventListener( + 'keyup', + on_keyboard_event_closure('key_release') + ); + + this._canvas_extra_style(canvas_div); + this.root.appendChild(canvas_div); + + var canvas = (this.canvas = document.createElement('canvas')); + canvas.classList.add('mpl-canvas'); + canvas.setAttribute( + 'style', + 'box-sizing: content-box;' + + 'pointer-events: none;' + + 'position: relative;' + + 'z-index: 0;' + ); + + this.context = canvas.getContext('2d'); + + var backingStore = + this.context.backingStorePixelRatio || + this.context.webkitBackingStorePixelRatio || + this.context.mozBackingStorePixelRatio || + this.context.msBackingStorePixelRatio || + this.context.oBackingStorePixelRatio || + this.context.backingStorePixelRatio || + 1; + + this.ratio = (window.devicePixelRatio || 1) / backingStore; + + var rubberband_canvas = (this.rubberband_canvas = document.createElement( + 'canvas' + )); + rubberband_canvas.setAttribute( + 'style', + 'box-sizing: content-box;' + + 'left: 0;' + + 'pointer-events: none;' + + 'position: absolute;' + + 'top: 0;' + + 'z-index: 1;' + ); + + // Apply a ponyfill if ResizeObserver is not implemented by browser. + if (this.ResizeObserver === undefined) { + if (window.ResizeObserver !== undefined) { + this.ResizeObserver = window.ResizeObserver; + } else { + var obs = _JSXTOOLS_RESIZE_OBSERVER({}); + this.ResizeObserver = obs.ResizeObserver; + } + } + + this.resizeObserverInstance = new this.ResizeObserver(function (entries) { + // There's no need to resize if the WebSocket is not connected: + // - If it is still connecting, then we will get an initial resize from + // Python once it connects. + // - If it has disconnected, then resizing will clear the canvas and + // never get anything back to refill it, so better to not resize and + // keep something visible. + if (fig.ws.readyState != 1) { + return; + } + var nentries = entries.length; + for (var i = 0; i < nentries; i++) { + var entry = entries[i]; + var width, height; + if (entry.contentBoxSize) { + if (entry.contentBoxSize instanceof Array) { + // Chrome 84 implements new version of spec. + width = entry.contentBoxSize[0].inlineSize; + height = entry.contentBoxSize[0].blockSize; + } else { + // Firefox implements old version of spec. + width = entry.contentBoxSize.inlineSize; + height = entry.contentBoxSize.blockSize; + } + } else { + // Chrome <84 implements even older version of spec. + width = entry.contentRect.width; + height = entry.contentRect.height; + } + + // Keep the size of the canvas and rubber band canvas in sync with + // the canvas container. + if (entry.devicePixelContentBoxSize) { + // Chrome 84 implements new version of spec. + canvas.setAttribute( + 'width', + entry.devicePixelContentBoxSize[0].inlineSize + ); + canvas.setAttribute( + 'height', + entry.devicePixelContentBoxSize[0].blockSize + ); + } else { + canvas.setAttribute('width', width * fig.ratio); + canvas.setAttribute('height', height * fig.ratio); + } + /* This rescales the canvas back to display pixels, so that it + * appears correct on HiDPI screens. */ + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + + rubberband_canvas.setAttribute('width', width); + rubberband_canvas.setAttribute('height', height); + + // And update the size in Python. We ignore the initial 0/0 size + // that occurs as the element is placed into the DOM, which should + // otherwise not happen due to the minimum size styling. + if (width != 0 && height != 0) { + fig.request_resize(width, height); + } + } + }); + this.resizeObserverInstance.observe(canvas_div); + + function on_mouse_event_closure(name) { + /* User Agent sniffing is bad, but WebKit is busted: + * https://bugs.webkit.org/show_bug.cgi?id=144526 + * https://bugs.webkit.org/show_bug.cgi?id=181818 + * The worst that happens here is that they get an extra browser + * selection when dragging, if this check fails to catch them. + */ + var UA = navigator.userAgent; + var isWebKit = /AppleWebKit/.test(UA) && !/Chrome/.test(UA); + if(isWebKit) { + return function (event) { + /* This prevents the web browser from automatically changing to + * the text insertion cursor when the button is pressed. We + * want to control all of the cursor setting manually through + * the 'cursor' event from matplotlib */ + event.preventDefault() + return fig.mouse_event(event, name); + }; + } else { + return function (event) { + return fig.mouse_event(event, name); + }; + } + } + + canvas_div.addEventListener( + 'mousedown', + on_mouse_event_closure('button_press') + ); + canvas_div.addEventListener( + 'mouseup', + on_mouse_event_closure('button_release') + ); + canvas_div.addEventListener( + 'dblclick', + on_mouse_event_closure('dblclick') + ); + // Throttle sequential mouse events to 1 every 20ms. + canvas_div.addEventListener( + 'mousemove', + on_mouse_event_closure('motion_notify') + ); + + canvas_div.addEventListener( + 'mouseenter', + on_mouse_event_closure('figure_enter') + ); + canvas_div.addEventListener( + 'mouseleave', + on_mouse_event_closure('figure_leave') + ); + + canvas_div.addEventListener('wheel', function (event) { + if (event.deltaY < 0) { + event.step = 1; + } else { + event.step = -1; + } + on_mouse_event_closure('scroll')(event); + }); + + canvas_div.appendChild(canvas); + canvas_div.appendChild(rubberband_canvas); + + this.rubberband_context = rubberband_canvas.getContext('2d'); + this.rubberband_context.strokeStyle = '#000000'; + + this._resize_canvas = function (width, height, forward) { + if (forward) { + canvas_div.style.width = width + 'px'; + canvas_div.style.height = height + 'px'; + } + }; + + // Disable right mouse context menu. + canvas_div.addEventListener('contextmenu', function (_e) { + event.preventDefault(); + return false; + }); + + function set_focus() { + canvas.focus(); + canvas_div.focus(); + } + + window.setTimeout(set_focus, 100); +}; + +mpl.figure.prototype._init_toolbar = function () { + var fig = this; + + var toolbar = document.createElement('div'); + toolbar.classList = 'mpl-toolbar'; + this.root.appendChild(toolbar); + + function on_click_closure(name) { + return function (_event) { + return fig.toolbar_button_onclick(name); + }; + } + + function on_mouseover_closure(tooltip) { + return function (event) { + if (!event.currentTarget.disabled) { + return fig.toolbar_button_onmouseover(tooltip); + } + }; + } + + fig.buttons = {}; + var buttonGroup = document.createElement('div'); + buttonGroup.classList = 'mpl-button-group'; + for (var toolbar_ind in mpl.toolbar_items) { + var name = mpl.toolbar_items[toolbar_ind][0]; + var tooltip = mpl.toolbar_items[toolbar_ind][1]; + var image = mpl.toolbar_items[toolbar_ind][2]; + var method_name = mpl.toolbar_items[toolbar_ind][3]; + + if (!name) { + /* Instead of a spacer, we start a new button group. */ + if (buttonGroup.hasChildNodes()) { + toolbar.appendChild(buttonGroup); + } + buttonGroup = document.createElement('div'); + buttonGroup.classList = 'mpl-button-group'; + continue; + } + + var button = (fig.buttons[name] = document.createElement('button')); + button.classList = 'mpl-widget'; + button.setAttribute('role', 'button'); + button.setAttribute('aria-disabled', 'false'); + button.addEventListener('click', on_click_closure(method_name)); + button.addEventListener('mouseover', on_mouseover_closure(tooltip)); + + var icon_img = document.createElement('img'); + icon_img.src = '_images/' + image + '.png'; + icon_img.srcset = '_images/' + image + '_large.png 2x'; + icon_img.alt = tooltip; + button.appendChild(icon_img); + + buttonGroup.appendChild(button); + } + + if (buttonGroup.hasChildNodes()) { + toolbar.appendChild(buttonGroup); + } + + var fmt_picker = document.createElement('select'); + fmt_picker.classList = 'mpl-widget'; + toolbar.appendChild(fmt_picker); + this.format_dropdown = fmt_picker; + + for (var ind in mpl.extensions) { + var fmt = mpl.extensions[ind]; + var option = document.createElement('option'); + option.selected = fmt === mpl.default_extension; + option.innerHTML = fmt; + fmt_picker.appendChild(option); + } + + var status_bar = document.createElement('span'); + status_bar.classList = 'mpl-message'; + toolbar.appendChild(status_bar); + this.message = status_bar; +}; + +mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) { + // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client, + // which will in turn request a refresh of the image. + this.send_message('resize', { width: x_pixels, height: y_pixels }); +}; + +mpl.figure.prototype.send_message = function (type, properties) { + properties['type'] = type; + properties['figure_id'] = this.id; + this.ws.send(JSON.stringify(properties)); +}; + +mpl.figure.prototype.send_draw_message = function () { + if (!this.waiting) { + this.waiting = true; + this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id })); + } +}; + +mpl.figure.prototype.handle_save = function (fig, _msg) { + var format_dropdown = fig.format_dropdown; + var format = format_dropdown.options[format_dropdown.selectedIndex].value; + fig.ondownload(fig, format); +}; + +mpl.figure.prototype.handle_resize = function (fig, msg) { + var size = msg['size']; + if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) { + fig._resize_canvas(size[0], size[1], msg['forward']); + fig.send_message('refresh', {}); + } +}; + +mpl.figure.prototype.handle_rubberband = function (fig, msg) { + var x0 = msg['x0'] / fig.ratio; + var y0 = (fig.canvas.height - msg['y0']) / fig.ratio; + var x1 = msg['x1'] / fig.ratio; + var y1 = (fig.canvas.height - msg['y1']) / fig.ratio; + x0 = Math.floor(x0) + 0.5; + y0 = Math.floor(y0) + 0.5; + x1 = Math.floor(x1) + 0.5; + y1 = Math.floor(y1) + 0.5; + var min_x = Math.min(x0, x1); + var min_y = Math.min(y0, y1); + var width = Math.abs(x1 - x0); + var height = Math.abs(y1 - y0); + + fig.rubberband_context.clearRect( + 0, + 0, + fig.canvas.width / fig.ratio, + fig.canvas.height / fig.ratio + ); + + fig.rubberband_context.strokeRect(min_x, min_y, width, height); +}; + +mpl.figure.prototype.handle_figure_label = function (fig, msg) { + // Updates the figure title. + fig.header.textContent = msg['label']; +}; + +mpl.figure.prototype.handle_cursor = function (fig, msg) { + fig.canvas_div.style.cursor = msg['cursor']; +}; + +mpl.figure.prototype.handle_message = function (fig, msg) { + fig.message.textContent = msg['message']; +}; + +mpl.figure.prototype.handle_draw = function (fig, _msg) { + // Request the server to send over a new figure. + fig.send_draw_message(); +}; + +mpl.figure.prototype.handle_image_mode = function (fig, msg) { + fig.image_mode = msg['mode']; +}; + +mpl.figure.prototype.handle_history_buttons = function (fig, msg) { + for (var key in msg) { + if (!(key in fig.buttons)) { + continue; + } + fig.buttons[key].disabled = !msg[key]; + fig.buttons[key].setAttribute('aria-disabled', !msg[key]); + } +}; + +mpl.figure.prototype.handle_navigate_mode = function (fig, msg) { + if (msg['mode'] === 'PAN') { + fig.buttons['Pan'].classList.add('active'); + fig.buttons['Zoom'].classList.remove('active'); + } else if (msg['mode'] === 'ZOOM') { + fig.buttons['Pan'].classList.remove('active'); + fig.buttons['Zoom'].classList.add('active'); + } else { + fig.buttons['Pan'].classList.remove('active'); + fig.buttons['Zoom'].classList.remove('active'); + } +}; + +mpl.figure.prototype.updated_canvas_event = function () { + // Called whenever the canvas gets updated. + this.send_message('ack', {}); +}; + +// A function to construct a web socket function for onmessage handling. +// Called in the figure constructor. +mpl.figure.prototype._make_on_message_function = function (fig) { + return function socket_on_message(evt) { + if (evt.data instanceof Blob) { + var img = evt.data; + if (img.type !== 'image/png') { + /* FIXME: We get "Resource interpreted as Image but + * transferred with MIME type text/plain:" errors on + * Chrome. But how to set the MIME type? It doesn't seem + * to be part of the websocket stream */ + img.type = 'image/png'; + } + + /* Free the memory for the previous frames */ + if (fig.imageObj.src) { + (window.URL || window.webkitURL).revokeObjectURL( + fig.imageObj.src + ); + } + + fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL( + img + ); + fig.updated_canvas_event(); + fig.waiting = false; + return; + } else if ( + typeof evt.data === 'string' && + evt.data.slice(0, 21) === 'data:image/png;base64' + ) { + fig.imageObj.src = evt.data; + fig.updated_canvas_event(); + fig.waiting = false; + return; + } + + var msg = JSON.parse(evt.data); + var msg_type = msg['type']; + + // Call the "handle_{type}" callback, which takes + // the figure and JSON message as its only arguments. + try { + var callback = fig['handle_' + msg_type]; + } catch (e) { + console.log( + "No handler for the '" + msg_type + "' message type: ", + msg + ); + return; + } + + if (callback) { + try { + // console.log("Handling '" + msg_type + "' message: ", msg); + callback(fig, msg); + } catch (e) { + console.log( + "Exception inside the 'handler_" + msg_type + "' callback:", + e, + e.stack, + msg + ); + } + } + }; +}; + +function getModifiers(event) { + var mods = []; + if (event.ctrlKey) { + mods.push('ctrl'); + } + if (event.altKey) { + mods.push('alt'); + } + if (event.shiftKey) { + mods.push('shift'); + } + if (event.metaKey) { + mods.push('meta'); + } + return mods; +} + +/* + * return a copy of an object with only non-object keys + * we need this to avoid circular references + * https://stackoverflow.com/a/24161582/3208463 + */ +function simpleKeys(original) { + return Object.keys(original).reduce(function (obj, key) { + if (typeof original[key] !== 'object') { + obj[key] = original[key]; + } + return obj; + }, {}); +} + +mpl.figure.prototype.mouse_event = function (event, name) { + if (name === 'button_press') { + this.canvas.focus(); + this.canvas_div.focus(); + } + + // from https://stackoverflow.com/q/1114465 + var boundingRect = this.canvas.getBoundingClientRect(); + var x = (event.clientX - boundingRect.left) * this.ratio; + var y = (event.clientY - boundingRect.top) * this.ratio; + + this.send_message(name, { + x: x, + y: y, + button: event.button, + step: event.step, + modifiers: getModifiers(event), + guiEvent: simpleKeys(event), + }); + + return false; +}; + +mpl.figure.prototype._key_event_extra = function (_event, _name) { + // Handle any extra behaviour associated with a key event +}; + +mpl.figure.prototype.key_event = function (event, name) { + // Prevent repeat events + if (name === 'key_press') { + if (event.key === this._key) { + return; + } else { + this._key = event.key; + } + } + if (name === 'key_release') { + this._key = null; + } + + var value = ''; + if (event.ctrlKey && event.key !== 'Control') { + value += 'ctrl+'; + } + else if (event.altKey && event.key !== 'Alt') { + value += 'alt+'; + } + else if (event.shiftKey && event.key !== 'Shift') { + value += 'shift+'; + } + + value += 'k' + event.key; + + this._key_event_extra(event, name); + + this.send_message(name, { key: value, guiEvent: simpleKeys(event) }); + return false; +}; + +mpl.figure.prototype.toolbar_button_onclick = function (name) { + if (name === 'download') { + this.handle_save(this, null); + } else { + this.send_message('toolbar_button', { name: name }); + } +}; + +mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) { + this.message.textContent = tooltip; +}; + +///////////////// REMAINING CONTENT GENERATED BY embed_js.py ///////////////// +// prettier-ignore +var _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError("Constructor requires 'new' operator");i.set(this,e)}function h(){throw new TypeError("Function is not a constructor")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl_tornado.js b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl_tornado.js new file mode 100644 index 00000000..b3cab8b7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/mpl_tornado.js @@ -0,0 +1,8 @@ +/* This .js file contains functions for matplotlib's built-in + tornado-based server, that are not relevant when embedding WebAgg + in another web application. */ + +/* exported mpl_ondownload */ +function mpl_ondownload(figure, format) { + window.open(figure.id + '/download.' + format, '_blank'); +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/nbagg_mpl.js b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/nbagg_mpl.js new file mode 100644 index 00000000..26d79ff4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/js/nbagg_mpl.js @@ -0,0 +1,275 @@ +/* global mpl */ + +var comm_websocket_adapter = function (comm) { + // Create a "websocket"-like object which calls the given IPython comm + // object with the appropriate methods. Currently this is a non binary + // socket, so there is still some room for performance tuning. + var ws = {}; + + ws.binaryType = comm.kernel.ws.binaryType; + ws.readyState = comm.kernel.ws.readyState; + function updateReadyState(_event) { + if (comm.kernel.ws) { + ws.readyState = comm.kernel.ws.readyState; + } else { + ws.readyState = 3; // Closed state. + } + } + comm.kernel.ws.addEventListener('open', updateReadyState); + comm.kernel.ws.addEventListener('close', updateReadyState); + comm.kernel.ws.addEventListener('error', updateReadyState); + + ws.close = function () { + comm.close(); + }; + ws.send = function (m) { + //console.log('sending', m); + comm.send(m); + }; + // Register the callback with on_msg. + comm.on_msg(function (msg) { + //console.log('receiving', msg['content']['data'], msg); + var data = msg['content']['data']; + if (data['blob'] !== undefined) { + data = { + data: new Blob(msg['buffers'], { type: data['blob'] }), + }; + } + // Pass the mpl event to the overridden (by mpl) onmessage function. + ws.onmessage(data); + }); + return ws; +}; + +mpl.mpl_figure_comm = function (comm, msg) { + // This is the function which gets called when the mpl process + // starts-up an IPython Comm through the "matplotlib" channel. + + var id = msg.content.data.id; + // Get hold of the div created by the display call when the Comm + // socket was opened in Python. + var element = document.getElementById(id); + var ws_proxy = comm_websocket_adapter(comm); + + function ondownload(figure, _format) { + window.open(figure.canvas.toDataURL()); + } + + var fig = new mpl.figure(id, ws_proxy, ondownload, element); + + // Call onopen now - mpl needs it, as it is assuming we've passed it a real + // web socket which is closed, not our websocket->open comm proxy. + ws_proxy.onopen(); + + fig.parent_element = element; + fig.cell_info = mpl.find_output_cell("
"); + if (!fig.cell_info) { + console.error('Failed to find cell for figure', id, fig); + return; + } + fig.cell_info[0].output_area.element.on( + 'cleared', + { fig: fig }, + fig._remove_fig_handler + ); +}; + +mpl.figure.prototype.handle_close = function (fig, msg) { + var width = fig.canvas.width / fig.ratio; + fig.cell_info[0].output_area.element.off( + 'cleared', + fig._remove_fig_handler + ); + fig.resizeObserverInstance.unobserve(fig.canvas_div); + + // Update the output cell to use the data from the current canvas. + fig.push_to_output(); + var dataURL = fig.canvas.toDataURL(); + // Re-enable the keyboard manager in IPython - without this line, in FF, + // the notebook keyboard shortcuts fail. + IPython.keyboard_manager.enable(); + fig.parent_element.innerHTML = + ''; + fig.close_ws(fig, msg); +}; + +mpl.figure.prototype.close_ws = function (fig, msg) { + fig.send_message('closing', msg); + // fig.ws.close() +}; + +mpl.figure.prototype.push_to_output = function (_remove_interactive) { + // Turn the data on the canvas into data in the output cell. + var width = this.canvas.width / this.ratio; + var dataURL = this.canvas.toDataURL(); + this.cell_info[1]['text/html'] = + ''; +}; + +mpl.figure.prototype.updated_canvas_event = function () { + // Tell IPython that the notebook contents must change. + IPython.notebook.set_dirty(true); + this.send_message('ack', {}); + var fig = this; + // Wait a second, then push the new image to the DOM so + // that it is saved nicely (might be nice to debounce this). + setTimeout(function () { + fig.push_to_output(); + }, 1000); +}; + +mpl.figure.prototype._init_toolbar = function () { + var fig = this; + + var toolbar = document.createElement('div'); + toolbar.classList = 'btn-toolbar'; + this.root.appendChild(toolbar); + + function on_click_closure(name) { + return function (_event) { + return fig.toolbar_button_onclick(name); + }; + } + + function on_mouseover_closure(tooltip) { + return function (event) { + if (!event.currentTarget.disabled) { + return fig.toolbar_button_onmouseover(tooltip); + } + }; + } + + fig.buttons = {}; + var buttonGroup = document.createElement('div'); + buttonGroup.classList = 'btn-group'; + var button; + for (var toolbar_ind in mpl.toolbar_items) { + var name = mpl.toolbar_items[toolbar_ind][0]; + var tooltip = mpl.toolbar_items[toolbar_ind][1]; + var image = mpl.toolbar_items[toolbar_ind][2]; + var method_name = mpl.toolbar_items[toolbar_ind][3]; + + if (!name) { + /* Instead of a spacer, we start a new button group. */ + if (buttonGroup.hasChildNodes()) { + toolbar.appendChild(buttonGroup); + } + buttonGroup = document.createElement('div'); + buttonGroup.classList = 'btn-group'; + continue; + } + + button = fig.buttons[name] = document.createElement('button'); + button.classList = 'btn btn-default'; + button.href = '#'; + button.title = name; + button.innerHTML = ''; + button.addEventListener('click', on_click_closure(method_name)); + button.addEventListener('mouseover', on_mouseover_closure(tooltip)); + buttonGroup.appendChild(button); + } + + if (buttonGroup.hasChildNodes()) { + toolbar.appendChild(buttonGroup); + } + + // Add the status bar. + var status_bar = document.createElement('span'); + status_bar.classList = 'mpl-message pull-right'; + toolbar.appendChild(status_bar); + this.message = status_bar; + + // Add the close button to the window. + var buttongrp = document.createElement('div'); + buttongrp.classList = 'btn-group inline pull-right'; + button = document.createElement('button'); + button.classList = 'btn btn-mini btn-primary'; + button.href = '#'; + button.title = 'Stop Interaction'; + button.innerHTML = ''; + button.addEventListener('click', function (_evt) { + fig.handle_close(fig, {}); + }); + button.addEventListener( + 'mouseover', + on_mouseover_closure('Stop Interaction') + ); + buttongrp.appendChild(button); + var titlebar = this.root.querySelector('.ui-dialog-titlebar'); + titlebar.insertBefore(buttongrp, titlebar.firstChild); +}; + +mpl.figure.prototype._remove_fig_handler = function (event) { + var fig = event.data.fig; + if (event.target !== this) { + // Ignore bubbled events from children. + return; + } + fig.close_ws(fig, {}); +}; + +mpl.figure.prototype._root_extra_style = function (el) { + el.style.boxSizing = 'content-box'; // override notebook setting of border-box. +}; + +mpl.figure.prototype._canvas_extra_style = function (el) { + // this is important to make the div 'focusable + el.setAttribute('tabindex', 0); + // reach out to IPython and tell the keyboard manager to turn it's self + // off when our div gets focus + + // location in version 3 + if (IPython.notebook.keyboard_manager) { + IPython.notebook.keyboard_manager.register_events(el); + } else { + // location in version 2 + IPython.keyboard_manager.register_events(el); + } +}; + +mpl.figure.prototype._key_event_extra = function (event, _name) { + // Check for shift+enter + if (event.shiftKey && event.which === 13) { + this.canvas_div.blur(); + // select the cell after this one + var index = IPython.notebook.find_cell_index(this.cell_info[0]); + IPython.notebook.select(index + 1); + } +}; + +mpl.figure.prototype.handle_save = function (fig, _msg) { + fig.ondownload(fig, null); +}; + +mpl.find_output_cell = function (html_output) { + // Return the cell and output element which can be found *uniquely* in the notebook. + // Note - this is a bit hacky, but it is done because the "notebook_saving.Notebook" + // IPython event is triggered only after the cells have been serialised, which for + // our purposes (turning an active figure into a static one), is too late. + var cells = IPython.notebook.get_cells(); + var ncells = cells.length; + for (var i = 0; i < ncells; i++) { + var cell = cells[i]; + if (cell.cell_type === 'code') { + for (var j = 0; j < cell.output_area.outputs.length; j++) { + var data = cell.output_area.outputs[j]; + if (data.data) { + // IPython >= 3 moved mimebundle to data attribute of output + data = data.data; + } + if (data['text/html'] === html_output) { + return [cell, data, j]; + } + } + } + } +}; + +// Register the function which deals with the matplotlib target/channel. +// The kernel may be null if the page has been refreshed. +if (IPython.notebook.kernel !== null) { + IPython.notebook.kernel.comm_manager.register_target( + 'matplotlib', + mpl.mpl_figure_comm + ); +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/single_figure.html b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/single_figure.html new file mode 100644 index 00000000..ceaaab00 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/backends/web_backend/single_figure.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + matplotlib + + + +
+
+ + diff --git a/venv/lib/python3.10/site-packages/matplotlib/bezier.py b/venv/lib/python3.10/site-packages/matplotlib/bezier.py new file mode 100644 index 00000000..069e20d0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/bezier.py @@ -0,0 +1,602 @@ +""" +A module providing some utility functions regarding Bézier path manipulation. +""" + +from functools import lru_cache +import math +import warnings + +import numpy as np + +from matplotlib import _api + + +# same algorithm as 3.8's math.comb +@np.vectorize +@lru_cache(maxsize=128) +def _comb(n, k): + if k > n: + return 0 + k = min(k, n - k) + i = np.arange(1, k + 1) + return np.prod((n + 1 - i)/i).astype(int) + + +class NonIntersectingPathException(ValueError): + pass + + +# some functions + + +def get_intersection(cx1, cy1, cos_t1, sin_t1, + cx2, cy2, cos_t2, sin_t2): + """ + Return the intersection between the line through (*cx1*, *cy1*) at angle + *t1* and the line through (*cx2*, *cy2*) at angle *t2*. + """ + + # line1 => sin_t1 * (x - cx1) - cos_t1 * (y - cy1) = 0. + # line1 => sin_t1 * x + cos_t1 * y = sin_t1*cx1 - cos_t1*cy1 + + line1_rhs = sin_t1 * cx1 - cos_t1 * cy1 + line2_rhs = sin_t2 * cx2 - cos_t2 * cy2 + + # rhs matrix + a, b = sin_t1, -cos_t1 + c, d = sin_t2, -cos_t2 + + ad_bc = a * d - b * c + if abs(ad_bc) < 1e-12: + raise ValueError("Given lines do not intersect. Please verify that " + "the angles are not equal or differ by 180 degrees.") + + # rhs_inverse + a_, b_ = d, -b + c_, d_ = -c, a + a_, b_, c_, d_ = [k / ad_bc for k in [a_, b_, c_, d_]] + + x = a_ * line1_rhs + b_ * line2_rhs + y = c_ * line1_rhs + d_ * line2_rhs + + return x, y + + +def get_normal_points(cx, cy, cos_t, sin_t, length): + """ + For a line passing through (*cx*, *cy*) and having an angle *t*, return + locations of the two points located along its perpendicular line at the + distance of *length*. + """ + + if length == 0.: + return cx, cy, cx, cy + + cos_t1, sin_t1 = sin_t, -cos_t + cos_t2, sin_t2 = -sin_t, cos_t + + x1, y1 = length * cos_t1 + cx, length * sin_t1 + cy + x2, y2 = length * cos_t2 + cx, length * sin_t2 + cy + + return x1, y1, x2, y2 + + +# BEZIER routines + +# subdividing bezier curve +# http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-sub.html + + +def _de_casteljau1(beta, t): + next_beta = beta[:-1] * (1 - t) + beta[1:] * t + return next_beta + + +def split_de_casteljau(beta, t): + """ + Split a Bézier segment defined by its control points *beta* into two + separate segments divided at *t* and return their control points. + """ + beta = np.asarray(beta) + beta_list = [beta] + while True: + beta = _de_casteljau1(beta, t) + beta_list.append(beta) + if len(beta) == 1: + break + left_beta = [beta[0] for beta in beta_list] + right_beta = [beta[-1] for beta in reversed(beta_list)] + + return left_beta, right_beta + + +def find_bezier_t_intersecting_with_closedpath( + bezier_point_at_t, inside_closedpath, t0=0., t1=1., tolerance=0.01): + """ + Find the intersection of the Bézier curve with a closed path. + + The intersection point *t* is approximated by two parameters *t0*, *t1* + such that *t0* <= *t* <= *t1*. + + Search starts from *t0* and *t1* and uses a simple bisecting algorithm + therefore one of the end points must be inside the path while the other + doesn't. The search stops when the distance of the points parametrized by + *t0* and *t1* gets smaller than the given *tolerance*. + + Parameters + ---------- + bezier_point_at_t : callable + A function returning x, y coordinates of the Bézier at parameter *t*. + It must have the signature:: + + bezier_point_at_t(t: float) -> tuple[float, float] + + inside_closedpath : callable + A function returning True if a given point (x, y) is inside the + closed path. It must have the signature:: + + inside_closedpath(point: tuple[float, float]) -> bool + + t0, t1 : float + Start parameters for the search. + + tolerance : float + Maximal allowed distance between the final points. + + Returns + ------- + t0, t1 : float + The Bézier path parameters. + """ + start = bezier_point_at_t(t0) + end = bezier_point_at_t(t1) + + start_inside = inside_closedpath(start) + end_inside = inside_closedpath(end) + + if start_inside == end_inside and start != end: + raise NonIntersectingPathException( + "Both points are on the same side of the closed path") + + while True: + + # return if the distance is smaller than the tolerance + if np.hypot(start[0] - end[0], start[1] - end[1]) < tolerance: + return t0, t1 + + # calculate the middle point + middle_t = 0.5 * (t0 + t1) + middle = bezier_point_at_t(middle_t) + middle_inside = inside_closedpath(middle) + + if start_inside ^ middle_inside: + t1 = middle_t + if end == middle: + # Edge case where infinite loop is possible + # Caused by large numbers relative to tolerance + return t0, t1 + end = middle + else: + t0 = middle_t + if start == middle: + # Edge case where infinite loop is possible + # Caused by large numbers relative to tolerance + return t0, t1 + start = middle + start_inside = middle_inside + + +class BezierSegment: + """ + A d-dimensional Bézier segment. + + Parameters + ---------- + control_points : (N, d) array + Location of the *N* control points. + """ + + def __init__(self, control_points): + self._cpoints = np.asarray(control_points) + self._N, self._d = self._cpoints.shape + self._orders = np.arange(self._N) + coeff = [math.factorial(self._N - 1) + // (math.factorial(i) * math.factorial(self._N - 1 - i)) + for i in range(self._N)] + self._px = (self._cpoints.T * coeff).T + + def __call__(self, t): + """ + Evaluate the Bézier curve at point(s) *t* in [0, 1]. + + Parameters + ---------- + t : (k,) array-like + Points at which to evaluate the curve. + + Returns + ------- + (k, d) array + Value of the curve for each point in *t*. + """ + t = np.asarray(t) + return (np.power.outer(1 - t, self._orders[::-1]) + * np.power.outer(t, self._orders)) @ self._px + + def point_at_t(self, t): + """ + Evaluate the curve at a single point, returning a tuple of *d* floats. + """ + return tuple(self(t)) + + @property + def control_points(self): + """The control points of the curve.""" + return self._cpoints + + @property + def dimension(self): + """The dimension of the curve.""" + return self._d + + @property + def degree(self): + """Degree of the polynomial. One less the number of control points.""" + return self._N - 1 + + @property + def polynomial_coefficients(self): + r""" + The polynomial coefficients of the Bézier curve. + + .. warning:: Follows opposite convention from `numpy.polyval`. + + Returns + ------- + (n+1, d) array + Coefficients after expanding in polynomial basis, where :math:`n` + is the degree of the Bézier curve and :math:`d` its dimension. + These are the numbers (:math:`C_j`) such that the curve can be + written :math:`\sum_{j=0}^n C_j t^j`. + + Notes + ----- + The coefficients are calculated as + + .. math:: + + {n \choose j} \sum_{i=0}^j (-1)^{i+j} {j \choose i} P_i + + where :math:`P_i` are the control points of the curve. + """ + n = self.degree + # matplotlib uses n <= 4. overflow plausible starting around n = 15. + if n > 10: + warnings.warn("Polynomial coefficients formula unstable for high " + "order Bezier curves!", RuntimeWarning) + P = self.control_points + j = np.arange(n+1)[:, None] + i = np.arange(n+1)[None, :] # _comb is non-zero for i <= j + prefactor = (-1)**(i + j) * _comb(j, i) # j on axis 0, i on axis 1 + return _comb(n, j) * prefactor @ P # j on axis 0, self.dimension on 1 + + def axis_aligned_extrema(self): + """ + Return the dimension and location of the curve's interior extrema. + + The extrema are the points along the curve where one of its partial + derivatives is zero. + + Returns + ------- + dims : array of int + Index :math:`i` of the partial derivative which is zero at each + interior extrema. + dzeros : array of float + Of same size as dims. The :math:`t` such that :math:`d/dx_i B(t) = + 0` + """ + n = self.degree + if n <= 1: + return np.array([]), np.array([]) + Cj = self.polynomial_coefficients + dCj = np.arange(1, n+1)[:, None] * Cj[1:] + dims = [] + roots = [] + for i, pi in enumerate(dCj.T): + r = np.roots(pi[::-1]) + roots.append(r) + dims.append(np.full_like(r, i)) + roots = np.concatenate(roots) + dims = np.concatenate(dims) + in_range = np.isreal(roots) & (roots >= 0) & (roots <= 1) + return dims[in_range], np.real(roots)[in_range] + + +def split_bezier_intersecting_with_closedpath( + bezier, inside_closedpath, tolerance=0.01): + """ + Split a Bézier curve into two at the intersection with a closed path. + + Parameters + ---------- + bezier : (N, 2) array-like + Control points of the Bézier segment. See `.BezierSegment`. + inside_closedpath : callable + A function returning True if a given point (x, y) is inside the + closed path. See also `.find_bezier_t_intersecting_with_closedpath`. + tolerance : float + The tolerance for the intersection. See also + `.find_bezier_t_intersecting_with_closedpath`. + + Returns + ------- + left, right + Lists of control points for the two Bézier segments. + """ + + bz = BezierSegment(bezier) + bezier_point_at_t = bz.point_at_t + + t0, t1 = find_bezier_t_intersecting_with_closedpath( + bezier_point_at_t, inside_closedpath, tolerance=tolerance) + + _left, _right = split_de_casteljau(bezier, (t0 + t1) / 2.) + return _left, _right + + +# matplotlib specific + + +def split_path_inout(path, inside, tolerance=0.01, reorder_inout=False): + """ + Divide a path into two segments at the point where ``inside(x, y)`` becomes + False. + """ + from .path import Path + path_iter = path.iter_segments() + + ctl_points, command = next(path_iter) + begin_inside = inside(ctl_points[-2:]) # true if begin point is inside + + ctl_points_old = ctl_points + + iold = 0 + i = 1 + + for ctl_points, command in path_iter: + iold = i + i += len(ctl_points) // 2 + if inside(ctl_points[-2:]) != begin_inside: + bezier_path = np.concatenate([ctl_points_old[-2:], ctl_points]) + break + ctl_points_old = ctl_points + else: + raise ValueError("The path does not intersect with the patch") + + bp = bezier_path.reshape((-1, 2)) + left, right = split_bezier_intersecting_with_closedpath( + bp, inside, tolerance) + if len(left) == 2: + codes_left = [Path.LINETO] + codes_right = [Path.MOVETO, Path.LINETO] + elif len(left) == 3: + codes_left = [Path.CURVE3, Path.CURVE3] + codes_right = [Path.MOVETO, Path.CURVE3, Path.CURVE3] + elif len(left) == 4: + codes_left = [Path.CURVE4, Path.CURVE4, Path.CURVE4] + codes_right = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4] + else: + raise AssertionError("This should never be reached") + + verts_left = left[1:] + verts_right = right[:] + + if path.codes is None: + path_in = Path(np.concatenate([path.vertices[:i], verts_left])) + path_out = Path(np.concatenate([verts_right, path.vertices[i:]])) + + else: + path_in = Path(np.concatenate([path.vertices[:iold], verts_left]), + np.concatenate([path.codes[:iold], codes_left])) + + path_out = Path(np.concatenate([verts_right, path.vertices[i:]]), + np.concatenate([codes_right, path.codes[i:]])) + + if reorder_inout and not begin_inside: + path_in, path_out = path_out, path_in + + return path_in, path_out + + +def inside_circle(cx, cy, r): + """ + Return a function that checks whether a point is in a circle with center + (*cx*, *cy*) and radius *r*. + + The returned function has the signature:: + + f(xy: tuple[float, float]) -> bool + """ + r2 = r ** 2 + + def _f(xy): + x, y = xy + return (x - cx) ** 2 + (y - cy) ** 2 < r2 + return _f + + +# quadratic Bezier lines + +def get_cos_sin(x0, y0, x1, y1): + dx, dy = x1 - x0, y1 - y0 + d = (dx * dx + dy * dy) ** .5 + # Account for divide by zero + if d == 0: + return 0.0, 0.0 + return dx / d, dy / d + + +def check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1.e-5): + """ + Check if two lines are parallel. + + Parameters + ---------- + dx1, dy1, dx2, dy2 : float + The gradients *dy*/*dx* of the two lines. + tolerance : float + The angular tolerance in radians up to which the lines are considered + parallel. + + Returns + ------- + is_parallel + - 1 if two lines are parallel in same direction. + - -1 if two lines are parallel in opposite direction. + - False otherwise. + """ + theta1 = np.arctan2(dx1, dy1) + theta2 = np.arctan2(dx2, dy2) + dtheta = abs(theta1 - theta2) + if dtheta < tolerance: + return 1 + elif abs(dtheta - np.pi) < tolerance: + return -1 + else: + return False + + +def get_parallels(bezier2, width): + """ + Given the quadratic Bézier control points *bezier2*, returns + control points of quadratic Bézier lines roughly parallel to given + one separated by *width*. + """ + + # The parallel Bezier lines are constructed by following ways. + # c1 and c2 are control points representing the start and end of the + # Bezier line. + # cm is the middle point + + c1x, c1y = bezier2[0] + cmx, cmy = bezier2[1] + c2x, c2y = bezier2[2] + + parallel_test = check_if_parallel(c1x - cmx, c1y - cmy, + cmx - c2x, cmy - c2y) + + if parallel_test == -1: + _api.warn_external( + "Lines do not intersect. A straight line is used instead.") + cos_t1, sin_t1 = get_cos_sin(c1x, c1y, c2x, c2y) + cos_t2, sin_t2 = cos_t1, sin_t1 + else: + # t1 and t2 is the angle between c1 and cm, cm, c2. They are + # also an angle of the tangential line of the path at c1 and c2 + cos_t1, sin_t1 = get_cos_sin(c1x, c1y, cmx, cmy) + cos_t2, sin_t2 = get_cos_sin(cmx, cmy, c2x, c2y) + + # find c1_left, c1_right which are located along the lines + # through c1 and perpendicular to the tangential lines of the + # Bezier path at a distance of width. Same thing for c2_left and + # c2_right with respect to c2. + c1x_left, c1y_left, c1x_right, c1y_right = ( + get_normal_points(c1x, c1y, cos_t1, sin_t1, width) + ) + c2x_left, c2y_left, c2x_right, c2y_right = ( + get_normal_points(c2x, c2y, cos_t2, sin_t2, width) + ) + + # find cm_left which is the intersecting point of a line through + # c1_left with angle t1 and a line through c2_left with angle + # t2. Same with cm_right. + try: + cmx_left, cmy_left = get_intersection(c1x_left, c1y_left, cos_t1, + sin_t1, c2x_left, c2y_left, + cos_t2, sin_t2) + cmx_right, cmy_right = get_intersection(c1x_right, c1y_right, cos_t1, + sin_t1, c2x_right, c2y_right, + cos_t2, sin_t2) + except ValueError: + # Special case straight lines, i.e., angle between two lines is + # less than the threshold used by get_intersection (we don't use + # check_if_parallel as the threshold is not the same). + cmx_left, cmy_left = ( + 0.5 * (c1x_left + c2x_left), 0.5 * (c1y_left + c2y_left) + ) + cmx_right, cmy_right = ( + 0.5 * (c1x_right + c2x_right), 0.5 * (c1y_right + c2y_right) + ) + + # the parallel Bezier lines are created with control points of + # [c1_left, cm_left, c2_left] and [c1_right, cm_right, c2_right] + path_left = [(c1x_left, c1y_left), + (cmx_left, cmy_left), + (c2x_left, c2y_left)] + path_right = [(c1x_right, c1y_right), + (cmx_right, cmy_right), + (c2x_right, c2y_right)] + + return path_left, path_right + + +def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y): + """ + Find control points of the Bézier curve passing through (*c1x*, *c1y*), + (*mmx*, *mmy*), and (*c2x*, *c2y*), at parametric values 0, 0.5, and 1. + """ + cmx = .5 * (4 * mmx - (c1x + c2x)) + cmy = .5 * (4 * mmy - (c1y + c2y)) + return [(c1x, c1y), (cmx, cmy), (c2x, c2y)] + + +def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.): + """ + Being similar to `get_parallels`, returns control points of two quadratic + Bézier lines having a width roughly parallel to given one separated by + *width*. + """ + + # c1, cm, c2 + c1x, c1y = bezier2[0] + cmx, cmy = bezier2[1] + c3x, c3y = bezier2[2] + + # t1 and t2 is the angle between c1 and cm, cm, c3. + # They are also an angle of the tangential line of the path at c1 and c3 + cos_t1, sin_t1 = get_cos_sin(c1x, c1y, cmx, cmy) + cos_t2, sin_t2 = get_cos_sin(cmx, cmy, c3x, c3y) + + # find c1_left, c1_right which are located along the lines + # through c1 and perpendicular to the tangential lines of the + # Bezier path at a distance of width. Same thing for c3_left and + # c3_right with respect to c3. + c1x_left, c1y_left, c1x_right, c1y_right = ( + get_normal_points(c1x, c1y, cos_t1, sin_t1, width * w1) + ) + c3x_left, c3y_left, c3x_right, c3y_right = ( + get_normal_points(c3x, c3y, cos_t2, sin_t2, width * w2) + ) + + # find c12, c23 and c123 which are middle points of c1-cm, cm-c3 and + # c12-c23 + c12x, c12y = (c1x + cmx) * .5, (c1y + cmy) * .5 + c23x, c23y = (cmx + c3x) * .5, (cmy + c3y) * .5 + c123x, c123y = (c12x + c23x) * .5, (c12y + c23y) * .5 + + # tangential angle of c123 (angle between c12 and c23) + cos_t123, sin_t123 = get_cos_sin(c12x, c12y, c23x, c23y) + + c123x_left, c123y_left, c123x_right, c123y_right = ( + get_normal_points(c123x, c123y, cos_t123, sin_t123, width * wm) + ) + + path_left = find_control_points(c1x_left, c1y_left, + c123x_left, c123y_left, + c3x_left, c3y_left) + path_right = find_control_points(c1x_right, c1y_right, + c123x_right, c123y_right, + c3x_right, c3y_right) + + return path_left, path_right diff --git a/venv/lib/python3.10/site-packages/matplotlib/bezier.pyi b/venv/lib/python3.10/site-packages/matplotlib/bezier.pyi new file mode 100644 index 00000000..ad82b873 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/bezier.pyi @@ -0,0 +1,74 @@ +from collections.abc import Callable +from typing import Literal + +import numpy as np +from numpy.typing import ArrayLike + +from .path import Path + +class NonIntersectingPathException(ValueError): ... + +def get_intersection( + cx1: float, + cy1: float, + cos_t1: float, + sin_t1: float, + cx2: float, + cy2: float, + cos_t2: float, + sin_t2: float, +) -> tuple[float, float]: ... +def get_normal_points( + cx: float, cy: float, cos_t: float, sin_t: float, length: float +) -> tuple[float, float, float, float]: ... +def split_de_casteljau(beta: ArrayLike, t: float) -> tuple[np.ndarray, np.ndarray]: ... +def find_bezier_t_intersecting_with_closedpath( + bezier_point_at_t: Callable[[float], tuple[float, float]], + inside_closedpath: Callable[[tuple[float, float]], bool], + t0: float = ..., + t1: float = ..., + tolerance: float = ..., +) -> tuple[float, float]: ... + +# TODO make generic over d, the dimension? ndarraydim +class BezierSegment: + def __init__(self, control_points: ArrayLike) -> None: ... + def __call__(self, t: ArrayLike) -> np.ndarray: ... + def point_at_t(self, t: float) -> tuple[float, ...]: ... + @property + def control_points(self) -> np.ndarray: ... + @property + def dimension(self) -> int: ... + @property + def degree(self) -> int: ... + @property + def polynomial_coefficients(self) -> np.ndarray: ... + def axis_aligned_extrema(self) -> tuple[np.ndarray, np.ndarray]: ... + +def split_bezier_intersecting_with_closedpath( + bezier: ArrayLike, + inside_closedpath: Callable[[tuple[float, float]], bool], + tolerance: float = ..., +) -> tuple[np.ndarray, np.ndarray]: ... +def split_path_inout( + path: Path, + inside: Callable[[tuple[float, float]], bool], + tolerance: float = ..., + reorder_inout: bool = ..., +) -> tuple[Path, Path]: ... +def inside_circle( + cx: float, cy: float, r: float +) -> Callable[[tuple[float, float]], bool]: ... +def get_cos_sin(x0: float, y0: float, x1: float, y1: float) -> tuple[float, float]: ... +def check_if_parallel( + dx1: float, dy1: float, dx2: float, dy2: float, tolerance: float = ... +) -> Literal[-1, False, 1]: ... +def get_parallels( + bezier2: ArrayLike, width: float +) -> tuple[list[tuple[float, float]], list[tuple[float, float]]]: ... +def find_control_points( + c1x: float, c1y: float, mmx: float, mmy: float, c2x: float, c2y: float +) -> list[tuple[float, float]]: ... +def make_wedged_bezier2( + bezier2: ArrayLike, width: float, w1: float = ..., wm: float = ..., w2: float = ... +) -> tuple[list[tuple[float, float]], list[tuple[float, float]]]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/category.py b/venv/lib/python3.10/site-packages/matplotlib/category.py new file mode 100644 index 00000000..4ac2379e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/category.py @@ -0,0 +1,233 @@ +""" +Plotting of string "category" data: ``plot(['d', 'f', 'a'], [1, 2, 3])`` will +plot three points with x-axis values of 'd', 'f', 'a'. + +See :doc:`/gallery/lines_bars_and_markers/categorical_variables` for an +example. + +The module uses Matplotlib's `matplotlib.units` mechanism to convert from +strings to integers and provides a tick locator, a tick formatter, and the +`.UnitData` class that creates and stores the string-to-integer mapping. +""" + +from collections import OrderedDict +import dateutil.parser +import itertools +import logging + +import numpy as np + +from matplotlib import _api, ticker, units + + +_log = logging.getLogger(__name__) + + +class StrCategoryConverter(units.ConversionInterface): + @staticmethod + def convert(value, unit, axis): + """ + Convert strings in *value* to floats using mapping information stored + in the *unit* object. + + Parameters + ---------- + value : str or iterable + Value or list of values to be converted. + unit : `.UnitData` + An object mapping strings to integers. + axis : `~matplotlib.axis.Axis` + The axis on which the converted value is plotted. + + .. note:: *axis* is unused. + + Returns + ------- + float or `~numpy.ndarray` of float + """ + if unit is None: + raise ValueError( + 'Missing category information for StrCategoryConverter; ' + 'this might be caused by unintendedly mixing categorical and ' + 'numeric data') + StrCategoryConverter._validate_unit(unit) + # dtype = object preserves numerical pass throughs + values = np.atleast_1d(np.array(value, dtype=object)) + # force an update so it also does type checking + unit.update(values) + return np.vectorize(unit._mapping.__getitem__, otypes=[float])(values) + + @staticmethod + def axisinfo(unit, axis): + """ + Set the default axis ticks and labels. + + Parameters + ---------- + unit : `.UnitData` + object string unit information for value + axis : `~matplotlib.axis.Axis` + axis for which information is being set + + .. note:: *axis* is not used + + Returns + ------- + `~matplotlib.units.AxisInfo` + Information to support default tick labeling + + """ + StrCategoryConverter._validate_unit(unit) + # locator and formatter take mapping dict because + # args need to be pass by reference for updates + majloc = StrCategoryLocator(unit._mapping) + majfmt = StrCategoryFormatter(unit._mapping) + return units.AxisInfo(majloc=majloc, majfmt=majfmt) + + @staticmethod + def default_units(data, axis): + """ + Set and update the `~matplotlib.axis.Axis` units. + + Parameters + ---------- + data : str or iterable of str + axis : `~matplotlib.axis.Axis` + axis on which the data is plotted + + Returns + ------- + `.UnitData` + object storing string to integer mapping + """ + # the conversion call stack is default_units -> axis_info -> convert + if axis.units is None: + axis.set_units(UnitData(data)) + else: + axis.units.update(data) + return axis.units + + @staticmethod + def _validate_unit(unit): + if not hasattr(unit, '_mapping'): + raise ValueError( + f'Provided unit "{unit}" is not valid for a categorical ' + 'converter, as it does not have a _mapping attribute.') + + +class StrCategoryLocator(ticker.Locator): + """Tick at every integer mapping of the string data.""" + def __init__(self, units_mapping): + """ + Parameters + ---------- + units_mapping : dict + Mapping of category names (str) to indices (int). + """ + self._units = units_mapping + + def __call__(self): + # docstring inherited + return list(self._units.values()) + + def tick_values(self, vmin, vmax): + # docstring inherited + return self() + + +class StrCategoryFormatter(ticker.Formatter): + """String representation of the data at every tick.""" + def __init__(self, units_mapping): + """ + Parameters + ---------- + units_mapping : dict + Mapping of category names (str) to indices (int). + """ + self._units = units_mapping + + def __call__(self, x, pos=None): + # docstring inherited + return self.format_ticks([x])[0] + + def format_ticks(self, values): + # docstring inherited + r_mapping = {v: self._text(k) for k, v in self._units.items()} + return [r_mapping.get(round(val), '') for val in values] + + @staticmethod + def _text(value): + """Convert text values into utf-8 or ascii strings.""" + if isinstance(value, bytes): + value = value.decode(encoding='utf-8') + elif not isinstance(value, str): + value = str(value) + return value + + +class UnitData: + def __init__(self, data=None): + """ + Create mapping between unique categorical values and integer ids. + + Parameters + ---------- + data : iterable + sequence of string values + """ + self._mapping = OrderedDict() + self._counter = itertools.count() + if data is not None: + self.update(data) + + @staticmethod + def _str_is_convertible(val): + """ + Helper method to check whether a string can be parsed as float or date. + """ + try: + float(val) + except ValueError: + try: + dateutil.parser.parse(val) + except (ValueError, TypeError): + # TypeError if dateutil >= 2.8.1 else ValueError + return False + return True + + def update(self, data): + """ + Map new values to integer identifiers. + + Parameters + ---------- + data : iterable of str or bytes + + Raises + ------ + TypeError + If elements in *data* are neither str nor bytes. + """ + data = np.atleast_1d(np.array(data, dtype=object)) + # check if convertible to number: + convertible = True + for val in OrderedDict.fromkeys(data): + # OrderedDict just iterates over unique values in data. + _api.check_isinstance((str, bytes), value=val) + if convertible: + # this will only be called so long as convertible is True. + convertible = self._str_is_convertible(val) + if val not in self._mapping: + self._mapping[val] = next(self._counter) + if data.size and convertible: + _log.info('Using categorical units to plot a list of strings ' + 'that are all parsable as floats or dates. If these ' + 'strings should be plotted as numbers, cast to the ' + 'appropriate data type before plotting.') + + +# Register the converter with Matplotlib's unit framework +units.registry[str] = StrCategoryConverter() +units.registry[np.str_] = StrCategoryConverter() +units.registry[bytes] = StrCategoryConverter() +units.registry[np.bytes_] = StrCategoryConverter() diff --git a/venv/lib/python3.10/site-packages/matplotlib/cbook.py b/venv/lib/python3.10/site-packages/matplotlib/cbook.py new file mode 100644 index 00000000..a156ac20 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/cbook.py @@ -0,0 +1,2423 @@ +""" +A collection of utility functions and classes. Originally, many +(but not all) were from the Python Cookbook -- hence the name cbook. +""" + +import collections +import collections.abc +import contextlib +import functools +import gzip +import itertools +import math +import operator +import os +from pathlib import Path +import shlex +import subprocess +import sys +import time +import traceback +import types +import weakref + +import numpy as np + +try: + from numpy.exceptions import VisibleDeprecationWarning # numpy >= 1.25 +except ImportError: + from numpy import VisibleDeprecationWarning + +import matplotlib +from matplotlib import _api, _c_internal_utils + + +def _get_running_interactive_framework(): + """ + Return the interactive framework whose event loop is currently running, if + any, or "headless" if no event loop can be started, or None. + + Returns + ------- + Optional[str] + One of the following values: "qt", "gtk3", "gtk4", "wx", "tk", + "macosx", "headless", ``None``. + """ + # Use ``sys.modules.get(name)`` rather than ``name in sys.modules`` as + # entries can also have been explicitly set to None. + QtWidgets = ( + sys.modules.get("PyQt6.QtWidgets") + or sys.modules.get("PySide6.QtWidgets") + or sys.modules.get("PyQt5.QtWidgets") + or sys.modules.get("PySide2.QtWidgets") + ) + if QtWidgets and QtWidgets.QApplication.instance(): + return "qt" + Gtk = sys.modules.get("gi.repository.Gtk") + if Gtk: + if Gtk.MAJOR_VERSION == 4: + from gi.repository import GLib + if GLib.main_depth(): + return "gtk4" + if Gtk.MAJOR_VERSION == 3 and Gtk.main_level(): + return "gtk3" + wx = sys.modules.get("wx") + if wx and wx.GetApp(): + return "wx" + tkinter = sys.modules.get("tkinter") + if tkinter: + codes = {tkinter.mainloop.__code__, tkinter.Misc.mainloop.__code__} + for frame in sys._current_frames().values(): + while frame: + if frame.f_code in codes: + return "tk" + frame = frame.f_back + # premetively break reference cycle between locals and the frame + del frame + macosx = sys.modules.get("matplotlib.backends._macosx") + if macosx and macosx.event_loop_is_running(): + return "macosx" + if not _c_internal_utils.display_is_valid(): + return "headless" + return None + + +def _exception_printer(exc): + if _get_running_interactive_framework() in ["headless", None]: + raise exc + else: + traceback.print_exc() + + +class _StrongRef: + """ + Wrapper similar to a weakref, but keeping a strong reference to the object. + """ + + def __init__(self, obj): + self._obj = obj + + def __call__(self): + return self._obj + + def __eq__(self, other): + return isinstance(other, _StrongRef) and self._obj == other._obj + + def __hash__(self): + return hash(self._obj) + + +def _weak_or_strong_ref(func, callback): + """ + Return a `WeakMethod` wrapping *func* if possible, else a `_StrongRef`. + """ + try: + return weakref.WeakMethod(func, callback) + except TypeError: + return _StrongRef(func) + + +class CallbackRegistry: + """ + Handle registering, processing, blocking, and disconnecting + for a set of signals and callbacks: + + >>> def oneat(x): + ... print('eat', x) + >>> def ondrink(x): + ... print('drink', x) + + >>> from matplotlib.cbook import CallbackRegistry + >>> callbacks = CallbackRegistry() + + >>> id_eat = callbacks.connect('eat', oneat) + >>> id_drink = callbacks.connect('drink', ondrink) + + >>> callbacks.process('drink', 123) + drink 123 + >>> callbacks.process('eat', 456) + eat 456 + >>> callbacks.process('be merry', 456) # nothing will be called + + >>> callbacks.disconnect(id_eat) + >>> callbacks.process('eat', 456) # nothing will be called + + >>> with callbacks.blocked(signal='drink'): + ... callbacks.process('drink', 123) # nothing will be called + >>> callbacks.process('drink', 123) + drink 123 + + In practice, one should always disconnect all callbacks when they are + no longer needed to avoid dangling references (and thus memory leaks). + However, real code in Matplotlib rarely does so, and due to its design, + it is rather difficult to place this kind of code. To get around this, + and prevent this class of memory leaks, we instead store weak references + to bound methods only, so when the destination object needs to die, the + CallbackRegistry won't keep it alive. + + Parameters + ---------- + exception_handler : callable, optional + If not None, *exception_handler* must be a function that takes an + `Exception` as single parameter. It gets called with any `Exception` + raised by the callbacks during `CallbackRegistry.process`, and may + either re-raise the exception or handle it in another manner. + + The default handler prints the exception (with `traceback.print_exc`) if + an interactive event loop is running; it re-raises the exception if no + interactive event loop is running. + + signals : list, optional + If not None, *signals* is a list of signals that this registry handles: + attempting to `process` or to `connect` to a signal not in the list + throws a `ValueError`. The default, None, does not restrict the + handled signals. + """ + + # We maintain two mappings: + # callbacks: signal -> {cid -> weakref-to-callback} + # _func_cid_map: signal -> {weakref-to-callback -> cid} + + def __init__(self, exception_handler=_exception_printer, *, signals=None): + self._signals = None if signals is None else list(signals) # Copy it. + self.exception_handler = exception_handler + self.callbacks = {} + self._cid_gen = itertools.count() + self._func_cid_map = {} + # A hidden variable that marks cids that need to be pickled. + self._pickled_cids = set() + + def __getstate__(self): + return { + **vars(self), + # In general, callbacks may not be pickled, so we just drop them, + # unless directed otherwise by self._pickled_cids. + "callbacks": {s: {cid: proxy() for cid, proxy in d.items() + if cid in self._pickled_cids} + for s, d in self.callbacks.items()}, + # It is simpler to reconstruct this from callbacks in __setstate__. + "_func_cid_map": None, + "_cid_gen": next(self._cid_gen) + } + + def __setstate__(self, state): + cid_count = state.pop('_cid_gen') + vars(self).update(state) + self.callbacks = { + s: {cid: _weak_or_strong_ref(func, self._remove_proxy) + for cid, func in d.items()} + for s, d in self.callbacks.items()} + self._func_cid_map = { + s: {proxy: cid for cid, proxy in d.items()} + for s, d in self.callbacks.items()} + self._cid_gen = itertools.count(cid_count) + + def connect(self, signal, func): + """Register *func* to be called when signal *signal* is generated.""" + if self._signals is not None: + _api.check_in_list(self._signals, signal=signal) + self._func_cid_map.setdefault(signal, {}) + proxy = _weak_or_strong_ref(func, self._remove_proxy) + if proxy in self._func_cid_map[signal]: + return self._func_cid_map[signal][proxy] + cid = next(self._cid_gen) + self._func_cid_map[signal][proxy] = cid + self.callbacks.setdefault(signal, {}) + self.callbacks[signal][cid] = proxy + return cid + + def _connect_picklable(self, signal, func): + """ + Like `.connect`, but the callback is kept when pickling/unpickling. + + Currently internal-use only. + """ + cid = self.connect(signal, func) + self._pickled_cids.add(cid) + return cid + + # Keep a reference to sys.is_finalizing, as sys may have been cleared out + # at that point. + def _remove_proxy(self, proxy, *, _is_finalizing=sys.is_finalizing): + if _is_finalizing(): + # Weakrefs can't be properly torn down at that point anymore. + return + for signal, proxy_to_cid in list(self._func_cid_map.items()): + cid = proxy_to_cid.pop(proxy, None) + if cid is not None: + del self.callbacks[signal][cid] + self._pickled_cids.discard(cid) + break + else: + # Not found + return + # Clean up empty dicts + if len(self.callbacks[signal]) == 0: + del self.callbacks[signal] + del self._func_cid_map[signal] + + def disconnect(self, cid): + """ + Disconnect the callback registered with callback id *cid*. + + No error is raised if such a callback does not exist. + """ + self._pickled_cids.discard(cid) + # Clean up callbacks + for signal, cid_to_proxy in list(self.callbacks.items()): + proxy = cid_to_proxy.pop(cid, None) + if proxy is not None: + break + else: + # Not found + return + + proxy_to_cid = self._func_cid_map[signal] + for current_proxy, current_cid in list(proxy_to_cid.items()): + if current_cid == cid: + assert proxy is current_proxy + del proxy_to_cid[current_proxy] + # Clean up empty dicts + if len(self.callbacks[signal]) == 0: + del self.callbacks[signal] + del self._func_cid_map[signal] + + def process(self, s, *args, **kwargs): + """ + Process signal *s*. + + All of the functions registered to receive callbacks on *s* will be + called with ``*args`` and ``**kwargs``. + """ + if self._signals is not None: + _api.check_in_list(self._signals, signal=s) + for ref in list(self.callbacks.get(s, {}).values()): + func = ref() + if func is not None: + try: + func(*args, **kwargs) + # this does not capture KeyboardInterrupt, SystemExit, + # and GeneratorExit + except Exception as exc: + if self.exception_handler is not None: + self.exception_handler(exc) + else: + raise + + @contextlib.contextmanager + def blocked(self, *, signal=None): + """ + Block callback signals from being processed. + + A context manager to temporarily block/disable callback signals + from being processed by the registered listeners. + + Parameters + ---------- + signal : str, optional + The callback signal to block. The default is to block all signals. + """ + orig = self.callbacks + try: + if signal is None: + # Empty out the callbacks + self.callbacks = {} + else: + # Only remove the specific signal + self.callbacks = {k: orig[k] for k in orig if k != signal} + yield + finally: + self.callbacks = orig + + +class silent_list(list): + """ + A list with a short ``repr()``. + + This is meant to be used for a homogeneous list of artists, so that they + don't cause long, meaningless output. + + Instead of :: + + [, + , + ] + + one will get :: + + + + If ``self.type`` is None, the type name is obtained from the first item in + the list (if any). + """ + + def __init__(self, type, seq=None): + self.type = type + if seq is not None: + self.extend(seq) + + def __repr__(self): + if self.type is not None or len(self) != 0: + tp = self.type if self.type is not None else type(self[0]).__name__ + return f"" + else: + return "" + + +def _local_over_kwdict( + local_var, kwargs, *keys, + warning_cls=_api.MatplotlibDeprecationWarning): + out = local_var + for key in keys: + kwarg_val = kwargs.pop(key, None) + if kwarg_val is not None: + if out is None: + out = kwarg_val + else: + _api.warn_external(f'"{key}" keyword argument will be ignored', + warning_cls) + return out + + +def strip_math(s): + """ + Remove latex formatting from mathtext. + + Only handles fully math and fully non-math strings. + """ + if len(s) >= 2 and s[0] == s[-1] == "$": + s = s[1:-1] + for tex, plain in [ + (r"\times", "x"), # Specifically for Formatter support. + (r"\mathdefault", ""), + (r"\rm", ""), + (r"\cal", ""), + (r"\tt", ""), + (r"\it", ""), + ("\\", ""), + ("{", ""), + ("}", ""), + ]: + s = s.replace(tex, plain) + return s + + +def _strip_comment(s): + """Strip everything from the first unquoted #.""" + pos = 0 + while True: + quote_pos = s.find('"', pos) + hash_pos = s.find('#', pos) + if quote_pos < 0: + without_comment = s if hash_pos < 0 else s[:hash_pos] + return without_comment.strip() + elif 0 <= hash_pos < quote_pos: + return s[:hash_pos].strip() + else: + closing_quote_pos = s.find('"', quote_pos + 1) + if closing_quote_pos < 0: + raise ValueError( + f"Missing closing quote in: {s!r}. If you need a double-" + 'quote inside a string, use escaping: e.g. "the \" char"') + pos = closing_quote_pos + 1 # behind closing quote + + +def is_writable_file_like(obj): + """Return whether *obj* looks like a file object with a *write* method.""" + return callable(getattr(obj, 'write', None)) + + +def file_requires_unicode(x): + """ + Return whether the given writable file-like object requires Unicode to be + written to it. + """ + try: + x.write(b'') + except TypeError: + return True + else: + return False + + +def to_filehandle(fname, flag='r', return_opened=False, encoding=None): + """ + Convert a path to an open file handle or pass-through a file-like object. + + Consider using `open_file_cm` instead, as it allows one to properly close + newly created file objects more easily. + + Parameters + ---------- + fname : str or path-like or file-like + If `str` or `os.PathLike`, the file is opened using the flags specified + by *flag* and *encoding*. If a file-like object, it is passed through. + flag : str, default: 'r' + Passed as the *mode* argument to `open` when *fname* is `str` or + `os.PathLike`; ignored if *fname* is file-like. + return_opened : bool, default: False + If True, return both the file object and a boolean indicating whether + this was a new file (that the caller needs to close). If False, return + only the new file. + encoding : str or None, default: None + Passed as the *mode* argument to `open` when *fname* is `str` or + `os.PathLike`; ignored if *fname* is file-like. + + Returns + ------- + fh : file-like + opened : bool + *opened* is only returned if *return_opened* is True. + """ + if isinstance(fname, os.PathLike): + fname = os.fspath(fname) + if isinstance(fname, str): + if fname.endswith('.gz'): + fh = gzip.open(fname, flag) + elif fname.endswith('.bz2'): + # python may not be compiled with bz2 support, + # bury import until we need it + import bz2 + fh = bz2.BZ2File(fname, flag) + else: + fh = open(fname, flag, encoding=encoding) + opened = True + elif hasattr(fname, 'seek'): + fh = fname + opened = False + else: + raise ValueError('fname must be a PathLike or file handle') + if return_opened: + return fh, opened + return fh + + +def open_file_cm(path_or_file, mode="r", encoding=None): + r"""Pass through file objects and context-manage path-likes.""" + fh, opened = to_filehandle(path_or_file, mode, True, encoding) + return fh if opened else contextlib.nullcontext(fh) + + +def is_scalar_or_string(val): + """Return whether the given object is a scalar or string like.""" + return isinstance(val, str) or not np.iterable(val) + + +@_api.delete_parameter( + "3.8", "np_load", alternative="open(get_sample_data(..., asfileobj=False))") +def get_sample_data(fname, asfileobj=True, *, np_load=True): + """ + Return a sample data file. *fname* is a path relative to the + :file:`mpl-data/sample_data` directory. If *asfileobj* is `True` + return a file object, otherwise just a file path. + + Sample data files are stored in the 'mpl-data/sample_data' directory within + the Matplotlib package. + + If the filename ends in .gz, the file is implicitly ungzipped. If the + filename ends with .npy or .npz, and *asfileobj* is `True`, the file is + loaded with `numpy.load`. + """ + path = _get_data_path('sample_data', fname) + if asfileobj: + suffix = path.suffix.lower() + if suffix == '.gz': + return gzip.open(path) + elif suffix in ['.npy', '.npz']: + if np_load: + return np.load(path) + else: + return path.open('rb') + elif suffix in ['.csv', '.xrc', '.txt']: + return path.open('r') + else: + return path.open('rb') + else: + return str(path) + + +def _get_data_path(*args): + """ + Return the `pathlib.Path` to a resource file provided by Matplotlib. + + ``*args`` specify a path relative to the base data path. + """ + return Path(matplotlib.get_data_path(), *args) + + +def flatten(seq, scalarp=is_scalar_or_string): + """ + Return a generator of flattened nested containers. + + For example: + + >>> from matplotlib.cbook import flatten + >>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]]) + >>> print(list(flatten(l))) + ['John', 'Hunter', 1, 23, 42, 5, 23] + + By: Composite of Holger Krekel and Luther Blissett + From: https://code.activestate.com/recipes/121294/ + and Recipe 1.12 in cookbook + """ + for item in seq: + if scalarp(item) or item is None: + yield item + else: + yield from flatten(item, scalarp) + + +@_api.deprecated("3.8") +class Stack: + """ + Stack of elements with a movable cursor. + + Mimics home/back/forward in a web browser. + """ + + def __init__(self, default=None): + self.clear() + self._default = default + + def __call__(self): + """Return the current element, or None.""" + if not self._elements: + return self._default + else: + return self._elements[self._pos] + + def __len__(self): + return len(self._elements) + + def __getitem__(self, ind): + return self._elements[ind] + + def forward(self): + """Move the position forward and return the current element.""" + self._pos = min(self._pos + 1, len(self._elements) - 1) + return self() + + def back(self): + """Move the position back and return the current element.""" + if self._pos > 0: + self._pos -= 1 + return self() + + def push(self, o): + """ + Push *o* to the stack at current position. Discard all later elements. + + *o* is returned. + """ + self._elements = self._elements[:self._pos + 1] + [o] + self._pos = len(self._elements) - 1 + return self() + + def home(self): + """ + Push the first element onto the top of the stack. + + The first element is returned. + """ + if not self._elements: + return + self.push(self._elements[0]) + return self() + + def empty(self): + """Return whether the stack is empty.""" + return len(self._elements) == 0 + + def clear(self): + """Empty the stack.""" + self._pos = -1 + self._elements = [] + + def bubble(self, o): + """ + Raise all references of *o* to the top of the stack, and return it. + + Raises + ------ + ValueError + If *o* is not in the stack. + """ + if o not in self._elements: + raise ValueError('Given element not contained in the stack') + old_elements = self._elements.copy() + self.clear() + top_elements = [] + for elem in old_elements: + if elem == o: + top_elements.append(elem) + else: + self.push(elem) + for _ in top_elements: + self.push(o) + return o + + def remove(self, o): + """ + Remove *o* from the stack. + + Raises + ------ + ValueError + If *o* is not in the stack. + """ + if o not in self._elements: + raise ValueError('Given element not contained in the stack') + old_elements = self._elements.copy() + self.clear() + for elem in old_elements: + if elem != o: + self.push(elem) + + +class _Stack: + """ + Stack of elements with a movable cursor. + + Mimics home/back/forward in a web browser. + """ + + def __init__(self): + self._pos = -1 + self._elements = [] + + def clear(self): + """Empty the stack.""" + self._pos = -1 + self._elements = [] + + def __call__(self): + """Return the current element, or None.""" + return self._elements[self._pos] if self._elements else None + + def __len__(self): + return len(self._elements) + + def __getitem__(self, ind): + return self._elements[ind] + + def forward(self): + """Move the position forward and return the current element.""" + self._pos = min(self._pos + 1, len(self._elements) - 1) + return self() + + def back(self): + """Move the position back and return the current element.""" + self._pos = max(self._pos - 1, 0) + return self() + + def push(self, o): + """ + Push *o* to the stack after the current position, and return *o*. + + Discard all later elements. + """ + self._elements[self._pos + 1:] = [o] + self._pos = len(self._elements) - 1 + return o + + def home(self): + """ + Push the first element onto the top of the stack. + + The first element is returned. + """ + return self.push(self._elements[0]) if self._elements else None + + +def safe_masked_invalid(x, copy=False): + x = np.array(x, subok=True, copy=copy) + if not x.dtype.isnative: + # If we have already made a copy, do the byteswap in place, else make a + # copy with the byte order swapped. + # Swap to native order. + x = x.byteswap(inplace=copy).view(x.dtype.newbyteorder('N')) + try: + xm = np.ma.masked_where(~(np.isfinite(x)), x, copy=False) + except TypeError: + return x + return xm + + +def print_cycles(objects, outstream=sys.stdout, show_progress=False): + """ + Print loops of cyclic references in the given *objects*. + + It is often useful to pass in ``gc.garbage`` to find the cycles that are + preventing some objects from being garbage collected. + + Parameters + ---------- + objects + A list of objects to find cycles in. + outstream + The stream for output. + show_progress : bool + If True, print the number of objects reached as they are found. + """ + import gc + + def print_path(path): + for i, step in enumerate(path): + # next "wraps around" + next = path[(i + 1) % len(path)] + + outstream.write(" %s -- " % type(step)) + if isinstance(step, dict): + for key, val in step.items(): + if val is next: + outstream.write(f"[{key!r}]") + break + if key is next: + outstream.write(f"[key] = {val!r}") + break + elif isinstance(step, list): + outstream.write("[%d]" % step.index(next)) + elif isinstance(step, tuple): + outstream.write("( tuple )") + else: + outstream.write(repr(step)) + outstream.write(" ->\n") + outstream.write("\n") + + def recurse(obj, start, all, current_path): + if show_progress: + outstream.write("%d\r" % len(all)) + + all[id(obj)] = None + + referents = gc.get_referents(obj) + for referent in referents: + # If we've found our way back to the start, this is + # a cycle, so print it out + if referent is start: + print_path(current_path) + + # Don't go back through the original list of objects, or + # through temporary references to the object, since those + # are just an artifact of the cycle detector itself. + elif referent is objects or isinstance(referent, types.FrameType): + continue + + # We haven't seen this object before, so recurse + elif id(referent) not in all: + recurse(referent, start, all, current_path + [obj]) + + for obj in objects: + outstream.write(f"Examining: {obj!r}\n") + recurse(obj, obj, {}, []) + + +class Grouper: + """ + A disjoint-set data structure. + + Objects can be joined using :meth:`join`, tested for connectedness + using :meth:`joined`, and all disjoint sets can be retrieved by + using the object as an iterator. + + The objects being joined must be hashable and weak-referenceable. + + Examples + -------- + >>> from matplotlib.cbook import Grouper + >>> class Foo: + ... def __init__(self, s): + ... self.s = s + ... def __repr__(self): + ... return self.s + ... + >>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef'] + >>> grp = Grouper() + >>> grp.join(a, b) + >>> grp.join(b, c) + >>> grp.join(d, e) + >>> list(grp) + [[a, b, c], [d, e]] + >>> grp.joined(a, b) + True + >>> grp.joined(a, c) + True + >>> grp.joined(a, d) + False + """ + + def __init__(self, init=()): + self._mapping = weakref.WeakKeyDictionary( + {x: weakref.WeakSet([x]) for x in init}) + self._ordering = weakref.WeakKeyDictionary() + for x in init: + if x not in self._ordering: + self._ordering[x] = len(self._ordering) + self._next_order = len(self._ordering) # Plain int to simplify pickling. + + def __getstate__(self): + return { + **vars(self), + # Convert weak refs to strong ones. + "_mapping": {k: set(v) for k, v in self._mapping.items()}, + "_ordering": {**self._ordering}, + } + + def __setstate__(self, state): + vars(self).update(state) + # Convert strong refs to weak ones. + self._mapping = weakref.WeakKeyDictionary( + {k: weakref.WeakSet(v) for k, v in self._mapping.items()}) + self._ordering = weakref.WeakKeyDictionary(self._ordering) + + def __contains__(self, item): + return item in self._mapping + + @_api.deprecated("3.8", alternative="none, you no longer need to clean a Grouper") + def clean(self): + """Clean dead weak references from the dictionary.""" + + def join(self, a, *args): + """ + Join given arguments into the same set. Accepts one or more arguments. + """ + mapping = self._mapping + try: + set_a = mapping[a] + except KeyError: + set_a = mapping[a] = weakref.WeakSet([a]) + self._ordering[a] = self._next_order + self._next_order += 1 + for arg in args: + try: + set_b = mapping[arg] + except KeyError: + set_b = mapping[arg] = weakref.WeakSet([arg]) + self._ordering[arg] = self._next_order + self._next_order += 1 + if set_b is not set_a: + if len(set_b) > len(set_a): + set_a, set_b = set_b, set_a + set_a.update(set_b) + for elem in set_b: + mapping[elem] = set_a + + def joined(self, a, b): + """Return whether *a* and *b* are members of the same set.""" + return (self._mapping.get(a, object()) is self._mapping.get(b)) + + def remove(self, a): + """Remove *a* from the grouper, doing nothing if it is not there.""" + self._mapping.pop(a, {a}).remove(a) + self._ordering.pop(a, None) + + def __iter__(self): + """ + Iterate over each of the disjoint sets as a list. + + The iterator is invalid if interleaved with calls to join(). + """ + unique_groups = {id(group): group for group in self._mapping.values()} + for group in unique_groups.values(): + yield sorted(group, key=self._ordering.__getitem__) + + def get_siblings(self, a): + """Return all of the items joined with *a*, including itself.""" + siblings = self._mapping.get(a, [a]) + return sorted(siblings, key=self._ordering.get) + + +class GrouperView: + """Immutable view over a `.Grouper`.""" + + def __init__(self, grouper): self._grouper = grouper + def __contains__(self, item): return item in self._grouper + def __iter__(self): return iter(self._grouper) + def joined(self, a, b): return self._grouper.joined(a, b) + def get_siblings(self, a): return self._grouper.get_siblings(a) + + +def simple_linear_interpolation(a, steps): + """ + Resample an array with ``steps - 1`` points between original point pairs. + + Along each column of *a*, ``(steps - 1)`` points are introduced between + each original values; the values are linearly interpolated. + + Parameters + ---------- + a : array, shape (n, ...) + steps : int + + Returns + ------- + array + shape ``((n - 1) * steps + 1, ...)`` + """ + fps = a.reshape((len(a), -1)) + xp = np.arange(len(a)) * steps + x = np.arange((len(a) - 1) * steps + 1) + return (np.column_stack([np.interp(x, xp, fp) for fp in fps.T]) + .reshape((len(x),) + a.shape[1:])) + + +def delete_masked_points(*args): + """ + Find all masked and/or non-finite points in a set of arguments, + and return the arguments with only the unmasked points remaining. + + Arguments can be in any of 5 categories: + + 1) 1-D masked arrays + 2) 1-D ndarrays + 3) ndarrays with more than one dimension + 4) other non-string iterables + 5) anything else + + The first argument must be in one of the first four categories; + any argument with a length differing from that of the first + argument (and hence anything in category 5) then will be + passed through unchanged. + + Masks are obtained from all arguments of the correct length + in categories 1, 2, and 4; a point is bad if masked in a masked + array or if it is a nan or inf. No attempt is made to + extract a mask from categories 2, 3, and 4 if `numpy.isfinite` + does not yield a Boolean array. + + All input arguments that are not passed unchanged are returned + as ndarrays after removing the points or rows corresponding to + masks in any of the arguments. + + A vastly simpler version of this function was originally + written as a helper for Axes.scatter(). + + """ + if not len(args): + return () + if is_scalar_or_string(args[0]): + raise ValueError("First argument must be a sequence") + nrecs = len(args[0]) + margs = [] + seqlist = [False] * len(args) + for i, x in enumerate(args): + if not isinstance(x, str) and np.iterable(x) and len(x) == nrecs: + seqlist[i] = True + if isinstance(x, np.ma.MaskedArray): + if x.ndim > 1: + raise ValueError("Masked arrays must be 1-D") + else: + x = np.asarray(x) + margs.append(x) + masks = [] # List of masks that are True where good. + for i, x in enumerate(margs): + if seqlist[i]: + if x.ndim > 1: + continue # Don't try to get nan locations unless 1-D. + if isinstance(x, np.ma.MaskedArray): + masks.append(~np.ma.getmaskarray(x)) # invert the mask + xd = x.data + else: + xd = x + try: + mask = np.isfinite(xd) + if isinstance(mask, np.ndarray): + masks.append(mask) + except Exception: # Fixme: put in tuple of possible exceptions? + pass + if len(masks): + mask = np.logical_and.reduce(masks) + igood = mask.nonzero()[0] + if len(igood) < nrecs: + for i, x in enumerate(margs): + if seqlist[i]: + margs[i] = x[igood] + for i, x in enumerate(margs): + if seqlist[i] and isinstance(x, np.ma.MaskedArray): + margs[i] = x.filled() + return margs + + +def _combine_masks(*args): + """ + Find all masked and/or non-finite points in a set of arguments, + and return the arguments as masked arrays with a common mask. + + Arguments can be in any of 5 categories: + + 1) 1-D masked arrays + 2) 1-D ndarrays + 3) ndarrays with more than one dimension + 4) other non-string iterables + 5) anything else + + The first argument must be in one of the first four categories; + any argument with a length differing from that of the first + argument (and hence anything in category 5) then will be + passed through unchanged. + + Masks are obtained from all arguments of the correct length + in categories 1, 2, and 4; a point is bad if masked in a masked + array or if it is a nan or inf. No attempt is made to + extract a mask from categories 2 and 4 if `numpy.isfinite` + does not yield a Boolean array. Category 3 is included to + support RGB or RGBA ndarrays, which are assumed to have only + valid values and which are passed through unchanged. + + All input arguments that are not passed unchanged are returned + as masked arrays if any masked points are found, otherwise as + ndarrays. + + """ + if not len(args): + return () + if is_scalar_or_string(args[0]): + raise ValueError("First argument must be a sequence") + nrecs = len(args[0]) + margs = [] # Output args; some may be modified. + seqlist = [False] * len(args) # Flags: True if output will be masked. + masks = [] # List of masks. + for i, x in enumerate(args): + if is_scalar_or_string(x) or len(x) != nrecs: + margs.append(x) # Leave it unmodified. + else: + if isinstance(x, np.ma.MaskedArray) and x.ndim > 1: + raise ValueError("Masked arrays must be 1-D") + try: + x = np.asanyarray(x) + except (VisibleDeprecationWarning, ValueError): + # NumPy 1.19 raises a warning about ragged arrays, but we want + # to accept basically anything here. + x = np.asanyarray(x, dtype=object) + if x.ndim == 1: + x = safe_masked_invalid(x) + seqlist[i] = True + if np.ma.is_masked(x): + masks.append(np.ma.getmaskarray(x)) + margs.append(x) # Possibly modified. + if len(masks): + mask = np.logical_or.reduce(masks) + for i, x in enumerate(margs): + if seqlist[i]: + margs[i] = np.ma.array(x, mask=mask) + return margs + + +def _broadcast_with_masks(*args, compress=False): + """ + Broadcast inputs, combining all masked arrays. + + Parameters + ---------- + *args : array-like + The inputs to broadcast. + compress : bool, default: False + Whether to compress the masked arrays. If False, the masked values + are replaced by NaNs. + + Returns + ------- + list of array-like + The broadcasted and masked inputs. + """ + # extract the masks, if any + masks = [k.mask for k in args if isinstance(k, np.ma.MaskedArray)] + # broadcast to match the shape + bcast = np.broadcast_arrays(*args, *masks) + inputs = bcast[:len(args)] + masks = bcast[len(args):] + if masks: + # combine the masks into one + mask = np.logical_or.reduce(masks) + # put mask on and compress + if compress: + inputs = [np.ma.array(k, mask=mask).compressed() + for k in inputs] + else: + inputs = [np.ma.array(k, mask=mask, dtype=float).filled(np.nan).ravel() + for k in inputs] + else: + inputs = [np.ravel(k) for k in inputs] + return inputs + + +def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None, autorange=False): + r""" + Return a list of dictionaries of statistics used to draw a series of box + and whisker plots using `~.Axes.bxp`. + + Parameters + ---------- + X : array-like + Data that will be represented in the boxplots. Should have 2 or + fewer dimensions. + + whis : float or (float, float), default: 1.5 + The position of the whiskers. + + If a float, the lower whisker is at the lowest datum above + ``Q1 - whis*(Q3-Q1)``, and the upper whisker at the highest datum below + ``Q3 + whis*(Q3-Q1)``, where Q1 and Q3 are the first and third + quartiles. The default value of ``whis = 1.5`` corresponds to Tukey's + original definition of boxplots. + + If a pair of floats, they indicate the percentiles at which to draw the + whiskers (e.g., (5, 95)). In particular, setting this to (0, 100) + results in whiskers covering the whole range of the data. + + In the edge case where ``Q1 == Q3``, *whis* is automatically set to + (0, 100) (cover the whole range of the data) if *autorange* is True. + + Beyond the whiskers, data are considered outliers and are plotted as + individual points. + + bootstrap : int, optional + Number of times the confidence intervals around the median + should be bootstrapped (percentile method). + + labels : list of str, optional + Labels for each dataset. Length must be compatible with + dimensions of *X*. + + autorange : bool, optional (False) + When `True` and the data are distributed such that the 25th and 75th + percentiles are equal, ``whis`` is set to (0, 100) such that the + whisker ends are at the minimum and maximum of the data. + + Returns + ------- + list of dict + A list of dictionaries containing the results for each column + of data. Keys of each dictionary are the following: + + ======== =================================== + Key Value Description + ======== =================================== + label tick label for the boxplot + mean arithmetic mean value + med 50th percentile + q1 first quartile (25th percentile) + q3 third quartile (75th percentile) + iqr interquartile range + cilo lower notch around the median + cihi upper notch around the median + whislo end of the lower whisker + whishi end of the upper whisker + fliers outliers + ======== =================================== + + Notes + ----- + Non-bootstrapping approach to confidence interval uses Gaussian-based + asymptotic approximation: + + .. math:: + + \mathrm{med} \pm 1.57 \times \frac{\mathrm{iqr}}{\sqrt{N}} + + General approach from: + McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of + Boxplots", The American Statistician, 32:12-16. + """ + + def _bootstrap_median(data, N=5000): + # determine 95% confidence intervals of the median + M = len(data) + percentiles = [2.5, 97.5] + + bs_index = np.random.randint(M, size=(N, M)) + bsData = data[bs_index] + estimate = np.median(bsData, axis=1, overwrite_input=True) + + CI = np.percentile(estimate, percentiles) + return CI + + def _compute_conf_interval(data, med, iqr, bootstrap): + if bootstrap is not None: + # Do a bootstrap estimate of notch locations. + # get conf. intervals around median + CI = _bootstrap_median(data, N=bootstrap) + notch_min = CI[0] + notch_max = CI[1] + else: + + N = len(data) + notch_min = med - 1.57 * iqr / np.sqrt(N) + notch_max = med + 1.57 * iqr / np.sqrt(N) + + return notch_min, notch_max + + # output is a list of dicts + bxpstats = [] + + # convert X to a list of lists + X = _reshape_2D(X, "X") + + ncols = len(X) + if labels is None: + labels = itertools.repeat(None) + elif len(labels) != ncols: + raise ValueError("Dimensions of labels and X must be compatible") + + input_whis = whis + for ii, (x, label) in enumerate(zip(X, labels)): + + # empty dict + stats = {} + if label is not None: + stats['label'] = label + + # restore whis to the input values in case it got changed in the loop + whis = input_whis + + # note tricksiness, append up here and then mutate below + bxpstats.append(stats) + + # if empty, bail + if len(x) == 0: + stats['fliers'] = np.array([]) + stats['mean'] = np.nan + stats['med'] = np.nan + stats['q1'] = np.nan + stats['q3'] = np.nan + stats['iqr'] = np.nan + stats['cilo'] = np.nan + stats['cihi'] = np.nan + stats['whislo'] = np.nan + stats['whishi'] = np.nan + continue + + # up-convert to an array, just to be safe + x = np.ma.asarray(x) + x = x.data[~x.mask].ravel() + + # arithmetic mean + stats['mean'] = np.mean(x) + + # medians and quartiles + q1, med, q3 = np.percentile(x, [25, 50, 75]) + + # interquartile range + stats['iqr'] = q3 - q1 + if stats['iqr'] == 0 and autorange: + whis = (0, 100) + + # conf. interval around median + stats['cilo'], stats['cihi'] = _compute_conf_interval( + x, med, stats['iqr'], bootstrap + ) + + # lowest/highest non-outliers + if np.iterable(whis) and not isinstance(whis, str): + loval, hival = np.percentile(x, whis) + elif np.isreal(whis): + loval = q1 - whis * stats['iqr'] + hival = q3 + whis * stats['iqr'] + else: + raise ValueError('whis must be a float or list of percentiles') + + # get high extreme + wiskhi = x[x <= hival] + if len(wiskhi) == 0 or np.max(wiskhi) < q3: + stats['whishi'] = q3 + else: + stats['whishi'] = np.max(wiskhi) + + # get low extreme + wisklo = x[x >= loval] + if len(wisklo) == 0 or np.min(wisklo) > q1: + stats['whislo'] = q1 + else: + stats['whislo'] = np.min(wisklo) + + # compute a single array of outliers + stats['fliers'] = np.concatenate([ + x[x < stats['whislo']], + x[x > stats['whishi']], + ]) + + # add in the remaining stats + stats['q1'], stats['med'], stats['q3'] = q1, med, q3 + + return bxpstats + + +#: Maps short codes for line style to their full name used by backends. +ls_mapper = {'-': 'solid', '--': 'dashed', '-.': 'dashdot', ':': 'dotted'} +#: Maps full names for line styles used by backends to their short codes. +ls_mapper_r = {v: k for k, v in ls_mapper.items()} + + +def contiguous_regions(mask): + """ + Return a list of (ind0, ind1) such that ``mask[ind0:ind1].all()`` is + True and we cover all such regions. + """ + mask = np.asarray(mask, dtype=bool) + + if not mask.size: + return [] + + # Find the indices of region changes, and correct offset + idx, = np.nonzero(mask[:-1] != mask[1:]) + idx += 1 + + # List operations are faster for moderately sized arrays + idx = idx.tolist() + + # Add first and/or last index if needed + if mask[0]: + idx = [0] + idx + if mask[-1]: + idx.append(len(mask)) + + return list(zip(idx[::2], idx[1::2])) + + +def is_math_text(s): + """ + Return whether the string *s* contains math expressions. + + This is done by checking whether *s* contains an even number of + non-escaped dollar signs. + """ + s = str(s) + dollar_count = s.count(r'$') - s.count(r'\$') + even_dollars = (dollar_count > 0 and dollar_count % 2 == 0) + return even_dollars + + +def _to_unmasked_float_array(x): + """ + Convert a sequence to a float array; if input was a masked array, masked + values are converted to nans. + """ + if hasattr(x, 'mask'): + return np.ma.asarray(x, float).filled(np.nan) + else: + return np.asarray(x, float) + + +def _check_1d(x): + """Convert scalars to 1D arrays; pass-through arrays as is.""" + # Unpack in case of e.g. Pandas or xarray object + x = _unpack_to_numpy(x) + # plot requires `shape` and `ndim`. If passed an + # object that doesn't provide them, then force to numpy array. + # Note this will strip unit information. + if (not hasattr(x, 'shape') or + not hasattr(x, 'ndim') or + len(x.shape) < 1): + return np.atleast_1d(x) + else: + return x + + +def _reshape_2D(X, name): + """ + Use Fortran ordering to convert ndarrays and lists of iterables to lists of + 1D arrays. + + Lists of iterables are converted by applying `numpy.asanyarray` to each of + their elements. 1D ndarrays are returned in a singleton list containing + them. 2D ndarrays are converted to the list of their *columns*. + + *name* is used to generate the error message for invalid inputs. + """ + + # Unpack in case of e.g. Pandas or xarray object + X = _unpack_to_numpy(X) + + # Iterate over columns for ndarrays. + if isinstance(X, np.ndarray): + X = X.T + + if len(X) == 0: + return [[]] + elif X.ndim == 1 and np.ndim(X[0]) == 0: + # 1D array of scalars: directly return it. + return [X] + elif X.ndim in [1, 2]: + # 2D array, or 1D array of iterables: flatten them first. + return [np.reshape(x, -1) for x in X] + else: + raise ValueError(f'{name} must have 2 or fewer dimensions') + + # Iterate over list of iterables. + if len(X) == 0: + return [[]] + + result = [] + is_1d = True + for xi in X: + # check if this is iterable, except for strings which we + # treat as singletons. + if not isinstance(xi, str): + try: + iter(xi) + except TypeError: + pass + else: + is_1d = False + xi = np.asanyarray(xi) + nd = np.ndim(xi) + if nd > 1: + raise ValueError(f'{name} must have 2 or fewer dimensions') + result.append(xi.reshape(-1)) + + if is_1d: + # 1D array of scalars: directly return it. + return [np.reshape(result, -1)] + else: + # 2D array, or 1D array of iterables: use flattened version. + return result + + +def violin_stats(X, method, points=100, quantiles=None): + """ + Return a list of dictionaries of data which can be used to draw a series + of violin plots. + + See the ``Returns`` section below to view the required keys of the + dictionary. + + Users can skip this function and pass a user-defined set of dictionaries + with the same keys to `~.axes.Axes.violinplot` instead of using Matplotlib + to do the calculations. See the *Returns* section below for the keys + that must be present in the dictionaries. + + Parameters + ---------- + X : array-like + Sample data that will be used to produce the gaussian kernel density + estimates. Must have 2 or fewer dimensions. + + method : callable + The method used to calculate the kernel density estimate for each + column of data. When called via ``method(v, coords)``, it should + return a vector of the values of the KDE evaluated at the values + specified in coords. + + points : int, default: 100 + Defines the number of points to evaluate each of the gaussian kernel + density estimates at. + + quantiles : array-like, default: None + Defines (if not None) a list of floats in interval [0, 1] for each + column of data, which represents the quantiles that will be rendered + for that column of data. Must have 2 or fewer dimensions. 1D array will + be treated as a singleton list containing them. + + Returns + ------- + list of dict + A list of dictionaries containing the results for each column of data. + The dictionaries contain at least the following: + + - coords: A list of scalars containing the coordinates this particular + kernel density estimate was evaluated at. + - vals: A list of scalars containing the values of the kernel density + estimate at each of the coordinates given in *coords*. + - mean: The mean value for this column of data. + - median: The median value for this column of data. + - min: The minimum value for this column of data. + - max: The maximum value for this column of data. + - quantiles: The quantile values for this column of data. + """ + + # List of dictionaries describing each of the violins. + vpstats = [] + + # Want X to be a list of data sequences + X = _reshape_2D(X, "X") + + # Want quantiles to be as the same shape as data sequences + if quantiles is not None and len(quantiles) != 0: + quantiles = _reshape_2D(quantiles, "quantiles") + # Else, mock quantiles if it's none or empty + else: + quantiles = [[]] * len(X) + + # quantiles should have the same size as dataset + if len(X) != len(quantiles): + raise ValueError("List of violinplot statistics and quantiles values" + " must have the same length") + + # Zip x and quantiles + for (x, q) in zip(X, quantiles): + # Dictionary of results for this distribution + stats = {} + + # Calculate basic stats for the distribution + min_val = np.min(x) + max_val = np.max(x) + quantile_val = np.percentile(x, 100 * q) + + # Evaluate the kernel density estimate + coords = np.linspace(min_val, max_val, points) + stats['vals'] = method(x, coords) + stats['coords'] = coords + + # Store additional statistics for this distribution + stats['mean'] = np.mean(x) + stats['median'] = np.median(x) + stats['min'] = min_val + stats['max'] = max_val + stats['quantiles'] = np.atleast_1d(quantile_val) + + # Append to output + vpstats.append(stats) + + return vpstats + + +def pts_to_prestep(x, *args): + """ + Convert continuous line to pre-steps. + + Given a set of ``N`` points, convert to ``2N - 1`` points, which when + connected linearly give a step function which changes values at the + beginning of the intervals. + + Parameters + ---------- + x : array + The x location of the steps. May be empty. + + y1, ..., yp : array + y arrays to be turned into steps; all must be the same length as ``x``. + + Returns + ------- + array + The x and y values converted to steps in the same order as the input; + can be unpacked as ``x_out, y1_out, ..., yp_out``. If the input is + length ``N``, each of these arrays will be length ``2N + 1``. For + ``N=0``, the length will be 0. + + Examples + -------- + >>> x_s, y1_s, y2_s = pts_to_prestep(x, y1, y2) + """ + steps = np.zeros((1 + len(args), max(2 * len(x) - 1, 0))) + # In all `pts_to_*step` functions, only assign once using *x* and *args*, + # as converting to an array may be expensive. + steps[0, 0::2] = x + steps[0, 1::2] = steps[0, 0:-2:2] + steps[1:, 0::2] = args + steps[1:, 1::2] = steps[1:, 2::2] + return steps + + +def pts_to_poststep(x, *args): + """ + Convert continuous line to post-steps. + + Given a set of ``N`` points convert to ``2N + 1`` points, which when + connected linearly give a step function which changes values at the end of + the intervals. + + Parameters + ---------- + x : array + The x location of the steps. May be empty. + + y1, ..., yp : array + y arrays to be turned into steps; all must be the same length as ``x``. + + Returns + ------- + array + The x and y values converted to steps in the same order as the input; + can be unpacked as ``x_out, y1_out, ..., yp_out``. If the input is + length ``N``, each of these arrays will be length ``2N + 1``. For + ``N=0``, the length will be 0. + + Examples + -------- + >>> x_s, y1_s, y2_s = pts_to_poststep(x, y1, y2) + """ + steps = np.zeros((1 + len(args), max(2 * len(x) - 1, 0))) + steps[0, 0::2] = x + steps[0, 1::2] = steps[0, 2::2] + steps[1:, 0::2] = args + steps[1:, 1::2] = steps[1:, 0:-2:2] + return steps + + +def pts_to_midstep(x, *args): + """ + Convert continuous line to mid-steps. + + Given a set of ``N`` points convert to ``2N`` points which when connected + linearly give a step function which changes values at the middle of the + intervals. + + Parameters + ---------- + x : array + The x location of the steps. May be empty. + + y1, ..., yp : array + y arrays to be turned into steps; all must be the same length as + ``x``. + + Returns + ------- + array + The x and y values converted to steps in the same order as the input; + can be unpacked as ``x_out, y1_out, ..., yp_out``. If the input is + length ``N``, each of these arrays will be length ``2N``. + + Examples + -------- + >>> x_s, y1_s, y2_s = pts_to_midstep(x, y1, y2) + """ + steps = np.zeros((1 + len(args), 2 * len(x))) + x = np.asanyarray(x) + steps[0, 1:-1:2] = steps[0, 2::2] = (x[:-1] + x[1:]) / 2 + steps[0, :1] = x[:1] # Also works for zero-sized input. + steps[0, -1:] = x[-1:] + steps[1:, 0::2] = args + steps[1:, 1::2] = steps[1:, 0::2] + return steps + + +STEP_LOOKUP_MAP = {'default': lambda x, y: (x, y), + 'steps': pts_to_prestep, + 'steps-pre': pts_to_prestep, + 'steps-post': pts_to_poststep, + 'steps-mid': pts_to_midstep} + + +def index_of(y): + """ + A helper function to create reasonable x values for the given *y*. + + This is used for plotting (x, y) if x values are not explicitly given. + + First try ``y.index`` (assuming *y* is a `pandas.Series`), if that + fails, use ``range(len(y))``. + + This will be extended in the future to deal with more types of + labeled data. + + Parameters + ---------- + y : float or array-like + + Returns + ------- + x, y : ndarray + The x and y values to plot. + """ + try: + return y.index.to_numpy(), y.to_numpy() + except AttributeError: + pass + try: + y = _check_1d(y) + except (VisibleDeprecationWarning, ValueError): + # NumPy 1.19 will warn on ragged input, and we can't actually use it. + pass + else: + return np.arange(y.shape[0], dtype=float), y + raise ValueError('Input could not be cast to an at-least-1D NumPy array') + + +def safe_first_element(obj): + """ + Return the first element in *obj*. + + This is a type-independent way of obtaining the first element, + supporting both index access and the iterator protocol. + """ + if isinstance(obj, collections.abc.Iterator): + # needed to accept `array.flat` as input. + # np.flatiter reports as an instance of collections.Iterator but can still be + # indexed via []. This has the side effect of re-setting the iterator, but + # that is acceptable. + try: + return obj[0] + except TypeError: + pass + raise RuntimeError("matplotlib does not support generators as input") + return next(iter(obj)) + + +def _safe_first_finite(obj): + """ + Return the first finite element in *obj* if one is available and skip_nonfinite is + True. Otherwise, return the first element. + + This is a method for internal use. + + This is a type-independent way of obtaining the first finite element, supporting + both index access and the iterator protocol. + """ + def safe_isfinite(val): + if val is None: + return False + try: + return math.isfinite(val) + except (TypeError, ValueError): + # if the outer object is 2d, then val is a 1d array, and + # - math.isfinite(numpy.zeros(3)) raises TypeError + # - math.isfinite(torch.zeros(3)) raises ValueError + pass + try: + return np.isfinite(val) if np.isscalar(val) else True + except TypeError: + # This is something that NumPy cannot make heads or tails of, + # assume "finite" + return True + + if isinstance(obj, np.flatiter): + # TODO do the finite filtering on this + return obj[0] + elif isinstance(obj, collections.abc.Iterator): + raise RuntimeError("matplotlib does not support generators as input") + else: + for val in obj: + if safe_isfinite(val): + return val + return safe_first_element(obj) + + +def sanitize_sequence(data): + """ + Convert dictview objects to list. Other inputs are returned unchanged. + """ + return (list(data) if isinstance(data, collections.abc.MappingView) + else data) + + +def normalize_kwargs(kw, alias_mapping=None): + """ + Helper function to normalize kwarg inputs. + + Parameters + ---------- + kw : dict or None + A dict of keyword arguments. None is explicitly supported and treated + as an empty dict, to support functions with an optional parameter of + the form ``props=None``. + + alias_mapping : dict or Artist subclass or Artist instance, optional + A mapping between a canonical name to a list of aliases, in order of + precedence from lowest to highest. + + If the canonical value is not in the list it is assumed to have the + highest priority. + + If an Artist subclass or instance is passed, use its properties alias + mapping. + + Raises + ------ + TypeError + To match what Python raises if invalid arguments/keyword arguments are + passed to a callable. + """ + from matplotlib.artist import Artist + + if kw is None: + return {} + + # deal with default value of alias_mapping + if alias_mapping is None: + alias_mapping = {} + elif (isinstance(alias_mapping, type) and issubclass(alias_mapping, Artist) + or isinstance(alias_mapping, Artist)): + alias_mapping = getattr(alias_mapping, "_alias_map", {}) + + to_canonical = {alias: canonical + for canonical, alias_list in alias_mapping.items() + for alias in alias_list} + canonical_to_seen = {} + ret = {} # output dictionary + + for k, v in kw.items(): + canonical = to_canonical.get(k, k) + if canonical in canonical_to_seen: + raise TypeError(f"Got both {canonical_to_seen[canonical]!r} and " + f"{k!r}, which are aliases of one another") + canonical_to_seen[canonical] = k + ret[canonical] = v + + return ret + + +@contextlib.contextmanager +def _lock_path(path): + """ + Context manager for locking a path. + + Usage:: + + with _lock_path(path): + ... + + Another thread or process that attempts to lock the same path will wait + until this context manager is exited. + + The lock is implemented by creating a temporary file in the parent + directory, so that directory must exist and be writable. + """ + path = Path(path) + lock_path = path.with_name(path.name + ".matplotlib-lock") + retries = 50 + sleeptime = 0.1 + for _ in range(retries): + try: + with lock_path.open("xb"): + break + except FileExistsError: + time.sleep(sleeptime) + else: + raise TimeoutError("""\ +Lock error: Matplotlib failed to acquire the following lock file: + {} +This maybe due to another process holding this lock file. If you are sure no +other Matplotlib process is running, remove this file and try again.""".format( + lock_path)) + try: + yield + finally: + lock_path.unlink() + + +def _topmost_artist( + artists, + _cached_max=functools.partial(max, key=operator.attrgetter("zorder"))): + """ + Get the topmost artist of a list. + + In case of a tie, return the *last* of the tied artists, as it will be + drawn on top of the others. `max` returns the first maximum in case of + ties, so we need to iterate over the list in reverse order. + """ + return _cached_max(reversed(artists)) + + +def _str_equal(obj, s): + """ + Return whether *obj* is a string equal to string *s*. + + This helper solely exists to handle the case where *obj* is a numpy array, + because in such cases, a naive ``obj == s`` would yield an array, which + cannot be used in a boolean context. + """ + return isinstance(obj, str) and obj == s + + +def _str_lower_equal(obj, s): + """ + Return whether *obj* is a string equal, when lowercased, to string *s*. + + This helper solely exists to handle the case where *obj* is a numpy array, + because in such cases, a naive ``obj == s`` would yield an array, which + cannot be used in a boolean context. + """ + return isinstance(obj, str) and obj.lower() == s + + +def _array_perimeter(arr): + """ + Get the elements on the perimeter of *arr*. + + Parameters + ---------- + arr : ndarray, shape (M, N) + The input array. + + Returns + ------- + ndarray, shape (2*(M - 1) + 2*(N - 1),) + The elements on the perimeter of the array:: + + [arr[0, 0], ..., arr[0, -1], ..., arr[-1, -1], ..., arr[-1, 0], ...] + + Examples + -------- + >>> i, j = np.ogrid[:3, :4] + >>> a = i*10 + j + >>> a + array([[ 0, 1, 2, 3], + [10, 11, 12, 13], + [20, 21, 22, 23]]) + >>> _array_perimeter(a) + array([ 0, 1, 2, 3, 13, 23, 22, 21, 20, 10]) + """ + # note we use Python's half-open ranges to avoid repeating + # the corners + forward = np.s_[0:-1] # [0 ... -1) + backward = np.s_[-1:0:-1] # [-1 ... 0) + return np.concatenate(( + arr[0, forward], + arr[forward, -1], + arr[-1, backward], + arr[backward, 0], + )) + + +def _unfold(arr, axis, size, step): + """ + Append an extra dimension containing sliding windows along *axis*. + + All windows are of size *size* and begin with every *step* elements. + + Parameters + ---------- + arr : ndarray, shape (N_1, ..., N_k) + The input array + axis : int + Axis along which the windows are extracted + size : int + Size of the windows + step : int + Stride between first elements of subsequent windows. + + Returns + ------- + ndarray, shape (N_1, ..., 1 + (N_axis-size)/step, ..., N_k, size) + + Examples + -------- + >>> i, j = np.ogrid[:3, :7] + >>> a = i*10 + j + >>> a + array([[ 0, 1, 2, 3, 4, 5, 6], + [10, 11, 12, 13, 14, 15, 16], + [20, 21, 22, 23, 24, 25, 26]]) + >>> _unfold(a, axis=1, size=3, step=2) + array([[[ 0, 1, 2], + [ 2, 3, 4], + [ 4, 5, 6]], + [[10, 11, 12], + [12, 13, 14], + [14, 15, 16]], + [[20, 21, 22], + [22, 23, 24], + [24, 25, 26]]]) + """ + new_shape = [*arr.shape, size] + new_strides = [*arr.strides, arr.strides[axis]] + new_shape[axis] = (new_shape[axis] - size) // step + 1 + new_strides[axis] = new_strides[axis] * step + return np.lib.stride_tricks.as_strided(arr, + shape=new_shape, + strides=new_strides, + writeable=False) + + +def _array_patch_perimeters(x, rstride, cstride): + """ + Extract perimeters of patches from *arr*. + + Extracted patches are of size (*rstride* + 1) x (*cstride* + 1) and + share perimeters with their neighbors. The ordering of the vertices matches + that returned by ``_array_perimeter``. + + Parameters + ---------- + x : ndarray, shape (N, M) + Input array + rstride : int + Vertical (row) stride between corresponding elements of each patch + cstride : int + Horizontal (column) stride between corresponding elements of each patch + + Returns + ------- + ndarray, shape (N/rstride * M/cstride, 2 * (rstride + cstride)) + """ + assert rstride > 0 and cstride > 0 + assert (x.shape[0] - 1) % rstride == 0 + assert (x.shape[1] - 1) % cstride == 0 + # We build up each perimeter from four half-open intervals. Here is an + # illustrated explanation for rstride == cstride == 3 + # + # T T T R + # L R + # L R + # L B B B + # + # where T means that this element will be in the top array, R for right, + # B for bottom and L for left. Each of the arrays below has a shape of: + # + # (number of perimeters that can be extracted vertically, + # number of perimeters that can be extracted horizontally, + # cstride for top and bottom and rstride for left and right) + # + # Note that _unfold doesn't incur any memory copies, so the only costly + # operation here is the np.concatenate. + top = _unfold(x[:-1:rstride, :-1], 1, cstride, cstride) + bottom = _unfold(x[rstride::rstride, 1:], 1, cstride, cstride)[..., ::-1] + right = _unfold(x[:-1, cstride::cstride], 0, rstride, rstride) + left = _unfold(x[1:, :-1:cstride], 0, rstride, rstride)[..., ::-1] + return (np.concatenate((top, right, bottom, left), axis=2) + .reshape(-1, 2 * (rstride + cstride))) + + +@contextlib.contextmanager +def _setattr_cm(obj, **kwargs): + """ + Temporarily set some attributes; restore original state at context exit. + """ + sentinel = object() + origs = {} + for attr in kwargs: + orig = getattr(obj, attr, sentinel) + if attr in obj.__dict__ or orig is sentinel: + # if we are pulling from the instance dict or the object + # does not have this attribute we can trust the above + origs[attr] = orig + else: + # if the attribute is not in the instance dict it must be + # from the class level + cls_orig = getattr(type(obj), attr) + # if we are dealing with a property (but not a general descriptor) + # we want to set the original value back. + if isinstance(cls_orig, property): + origs[attr] = orig + # otherwise this is _something_ we are going to shadow at + # the instance dict level from higher up in the MRO. We + # are going to assume we can delattr(obj, attr) to clean + # up after ourselves. It is possible that this code will + # fail if used with a non-property custom descriptor which + # implements __set__ (and __delete__ does not act like a + # stack). However, this is an internal tool and we do not + # currently have any custom descriptors. + else: + origs[attr] = sentinel + + try: + for attr, val in kwargs.items(): + setattr(obj, attr, val) + yield + finally: + for attr, orig in origs.items(): + if orig is sentinel: + delattr(obj, attr) + else: + setattr(obj, attr, orig) + + +class _OrderedSet(collections.abc.MutableSet): + def __init__(self): + self._od = collections.OrderedDict() + + def __contains__(self, key): + return key in self._od + + def __iter__(self): + return iter(self._od) + + def __len__(self): + return len(self._od) + + def add(self, key): + self._od.pop(key, None) + self._od[key] = None + + def discard(self, key): + self._od.pop(key, None) + + +# Agg's buffers are unmultiplied RGBA8888, which neither PyQt<=5.1 nor cairo +# support; however, both do support premultiplied ARGB32. + + +def _premultiplied_argb32_to_unmultiplied_rgba8888(buf): + """ + Convert a premultiplied ARGB32 buffer to an unmultiplied RGBA8888 buffer. + """ + rgba = np.take( # .take() ensures C-contiguity of the result. + buf, + [2, 1, 0, 3] if sys.byteorder == "little" else [1, 2, 3, 0], axis=2) + rgb = rgba[..., :-1] + alpha = rgba[..., -1] + # Un-premultiply alpha. The formula is the same as in cairo-png.c. + mask = alpha != 0 + for channel in np.rollaxis(rgb, -1): + channel[mask] = ( + (channel[mask].astype(int) * 255 + alpha[mask] // 2) + // alpha[mask]) + return rgba + + +def _unmultiplied_rgba8888_to_premultiplied_argb32(rgba8888): + """ + Convert an unmultiplied RGBA8888 buffer to a premultiplied ARGB32 buffer. + """ + if sys.byteorder == "little": + argb32 = np.take(rgba8888, [2, 1, 0, 3], axis=2) + rgb24 = argb32[..., :-1] + alpha8 = argb32[..., -1:] + else: + argb32 = np.take(rgba8888, [3, 0, 1, 2], axis=2) + alpha8 = argb32[..., :1] + rgb24 = argb32[..., 1:] + # Only bother premultiplying when the alpha channel is not fully opaque, + # as the cost is not negligible. The unsafe cast is needed to do the + # multiplication in-place in an integer buffer. + if alpha8.min() != 0xff: + np.multiply(rgb24, alpha8 / 0xff, out=rgb24, casting="unsafe") + return argb32 + + +def _get_nonzero_slices(buf): + """ + Return the bounds of the nonzero region of a 2D array as a pair of slices. + + ``buf[_get_nonzero_slices(buf)]`` is the smallest sub-rectangle in *buf* + that encloses all non-zero entries in *buf*. If *buf* is fully zero, then + ``(slice(0, 0), slice(0, 0))`` is returned. + """ + x_nz, = buf.any(axis=0).nonzero() + y_nz, = buf.any(axis=1).nonzero() + if len(x_nz) and len(y_nz): + l, r = x_nz[[0, -1]] + b, t = y_nz[[0, -1]] + return slice(b, t + 1), slice(l, r + 1) + else: + return slice(0, 0), slice(0, 0) + + +def _pformat_subprocess(command): + """Pretty-format a subprocess command for printing/logging purposes.""" + return (command if isinstance(command, str) + else " ".join(shlex.quote(os.fspath(arg)) for arg in command)) + + +def _check_and_log_subprocess(command, logger, **kwargs): + """ + Run *command*, returning its stdout output if it succeeds. + + If it fails (exits with nonzero return code), raise an exception whose text + includes the failed command and captured stdout and stderr output. + + Regardless of the return code, the command is logged at DEBUG level on + *logger*. In case of success, the output is likewise logged. + """ + logger.debug('%s', _pformat_subprocess(command)) + proc = subprocess.run(command, capture_output=True, **kwargs) + if proc.returncode: + stdout = proc.stdout + if isinstance(stdout, bytes): + stdout = stdout.decode() + stderr = proc.stderr + if isinstance(stderr, bytes): + stderr = stderr.decode() + raise RuntimeError( + f"The command\n" + f" {_pformat_subprocess(command)}\n" + f"failed and generated the following output:\n" + f"{stdout}\n" + f"and the following error:\n" + f"{stderr}") + if proc.stdout: + logger.debug("stdout:\n%s", proc.stdout) + if proc.stderr: + logger.debug("stderr:\n%s", proc.stderr) + return proc.stdout + + +def _setup_new_guiapp(): + """ + Perform OS-dependent setup when Matplotlib creates a new GUI application. + """ + # Windows: If not explicit app user model id has been set yet (so we're not + # already embedded), then set it to "matplotlib", so that taskbar icons are + # correct. + try: + _c_internal_utils.Win32_GetCurrentProcessExplicitAppUserModelID() + except OSError: + _c_internal_utils.Win32_SetCurrentProcessExplicitAppUserModelID( + "matplotlib") + + +def _format_approx(number, precision): + """ + Format the number with at most the number of decimals given as precision. + Remove trailing zeros and possibly the decimal point. + """ + return f'{number:.{precision}f}'.rstrip('0').rstrip('.') or '0' + + +def _g_sig_digits(value, delta): + """ + Return the number of significant digits to %g-format *value*, assuming that + it is known with an error of *delta*. + """ + if delta == 0: + # delta = 0 may occur when trying to format values over a tiny range; + # in that case, replace it by the distance to the closest float. + delta = abs(np.spacing(value)) + # If e.g. value = 45.67 and delta = 0.02, then we want to round to 2 digits + # after the decimal point (floor(log10(0.02)) = -2); 45.67 contributes 2 + # digits before the decimal point (floor(log10(45.67)) + 1 = 2): the total + # is 4 significant digits. A value of 0 contributes 1 "digit" before the + # decimal point. + # For inf or nan, the precision doesn't matter. + return max( + 0, + (math.floor(math.log10(abs(value))) + 1 if value else 1) + - math.floor(math.log10(delta))) if math.isfinite(value) else 0 + + +def _unikey_or_keysym_to_mplkey(unikey, keysym): + """ + Convert a Unicode key or X keysym to a Matplotlib key name. + + The Unicode key is checked first; this avoids having to list most printable + keysyms such as ``EuroSign``. + """ + # For non-printable characters, gtk3 passes "\0" whereas tk passes an "". + if unikey and unikey.isprintable(): + return unikey + key = keysym.lower() + if key.startswith("kp_"): # keypad_x (including kp_enter). + key = key[3:] + if key.startswith("page_"): # page_{up,down} + key = key.replace("page_", "page") + if key.endswith(("_l", "_r")): # alt_l, ctrl_l, shift_l. + key = key[:-2] + if sys.platform == "darwin" and key == "meta": + # meta should be reported as command on mac + key = "cmd" + key = { + "return": "enter", + "prior": "pageup", # Used by tk. + "next": "pagedown", # Used by tk. + }.get(key, key) + return key + + +@functools.cache +def _make_class_factory(mixin_class, fmt, attr_name=None): + """ + Return a function that creates picklable classes inheriting from a mixin. + + After :: + + factory = _make_class_factory(FooMixin, fmt, attr_name) + FooAxes = factory(Axes) + + ``Foo`` is a class that inherits from ``FooMixin`` and ``Axes`` and **is + picklable** (picklability is what differentiates this from a plain call to + `type`). Its ``__name__`` is set to ``fmt.format(Axes.__name__)`` and the + base class is stored in the ``attr_name`` attribute, if not None. + + Moreover, the return value of ``factory`` is memoized: calls with the same + ``Axes`` class always return the same subclass. + """ + + @functools.cache + def class_factory(axes_class): + # if we have already wrapped this class, declare victory! + if issubclass(axes_class, mixin_class): + return axes_class + + # The parameter is named "axes_class" for backcompat but is really just + # a base class; no axes semantics are used. + base_class = axes_class + + class subcls(mixin_class, base_class): + # Better approximation than __module__ = "matplotlib.cbook". + __module__ = mixin_class.__module__ + + def __reduce__(self): + return (_picklable_class_constructor, + (mixin_class, fmt, attr_name, base_class), + self.__getstate__()) + + subcls.__name__ = subcls.__qualname__ = fmt.format(base_class.__name__) + if attr_name is not None: + setattr(subcls, attr_name, base_class) + return subcls + + class_factory.__module__ = mixin_class.__module__ + return class_factory + + +def _picklable_class_constructor(mixin_class, fmt, attr_name, base_class): + """Internal helper for _make_class_factory.""" + factory = _make_class_factory(mixin_class, fmt, attr_name) + cls = factory(base_class) + return cls.__new__(cls) + + +def _is_torch_array(x): + """Check if 'x' is a PyTorch Tensor.""" + try: + # we're intentionally not attempting to import torch. If somebody + # has created a torch array, torch should already be in sys.modules + return isinstance(x, sys.modules['torch'].Tensor) + except Exception: # TypeError, KeyError, AttributeError, maybe others? + # we're attempting to access attributes on imported modules which + # may have arbitrary user code, so we deliberately catch all exceptions + return False + + +def _is_jax_array(x): + """Check if 'x' is a JAX Array.""" + try: + # we're intentionally not attempting to import jax. If somebody + # has created a jax array, jax should already be in sys.modules + return isinstance(x, sys.modules['jax'].Array) + except Exception: # TypeError, KeyError, AttributeError, maybe others? + # we're attempting to access attributes on imported modules which + # may have arbitrary user code, so we deliberately catch all exceptions + return False + + +def _unpack_to_numpy(x): + """Internal helper to extract data from e.g. pandas and xarray objects.""" + if isinstance(x, np.ndarray): + # If numpy, return directly + return x + if hasattr(x, 'to_numpy'): + # Assume that any to_numpy() method actually returns a numpy array + return x.to_numpy() + if hasattr(x, 'values'): + xtmp = x.values + # For example a dict has a 'values' attribute, but it is not a property + # so in this case we do not want to return a function + if isinstance(xtmp, np.ndarray): + return xtmp + if _is_torch_array(x) or _is_jax_array(x): + xtmp = x.__array__() + + # In case __array__() method does not return a numpy array in future + if isinstance(xtmp, np.ndarray): + return xtmp + return x + + +def _auto_format_str(fmt, value): + """ + Apply *value* to the format string *fmt*. + + This works both with unnamed %-style formatting and + unnamed {}-style formatting. %-style formatting has priority. + If *fmt* is %-style formattable that will be used. Otherwise, + {}-formatting is applied. Strings without formatting placeholders + are passed through as is. + + Examples + -------- + >>> _auto_format_str('%.2f m', 0.2) + '0.20 m' + >>> _auto_format_str('{} m', 0.2) + '0.2 m' + >>> _auto_format_str('const', 0.2) + 'const' + >>> _auto_format_str('%d or {}', 0.2) + '0 or {}' + """ + try: + return fmt % (value,) + except (TypeError, ValueError): + return fmt.format(value) diff --git a/venv/lib/python3.10/site-packages/matplotlib/cbook.pyi b/venv/lib/python3.10/site-packages/matplotlib/cbook.pyi new file mode 100644 index 00000000..d727b806 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/cbook.pyi @@ -0,0 +1,186 @@ +import collections.abc +from collections.abc import Callable, Collection, Generator, Iterable, Iterator +import contextlib +import os +from pathlib import Path + +from matplotlib.artist import Artist + +import numpy as np +from numpy.typing import ArrayLike + +from typing import ( + Any, + Generic, + IO, + Literal, + TypeVar, + overload, +) + +_T = TypeVar("_T") + +def _get_running_interactive_framework() -> str | None: ... + +class CallbackRegistry: + exception_handler: Callable[[Exception], Any] + callbacks: dict[Any, dict[int, Any]] + def __init__( + self, + exception_handler: Callable[[Exception], Any] | None = ..., + *, + signals: Iterable[Any] | None = ..., + ) -> None: ... + def connect(self, signal: Any, func: Callable) -> int: ... + def disconnect(self, cid: int) -> None: ... + def process(self, s: Any, *args, **kwargs) -> None: ... + def blocked( + self, *, signal: Any | None = ... + ) -> contextlib.AbstractContextManager[None]: ... + +class silent_list(list[_T]): + type: str | None + def __init__(self, type: str | None, seq: Iterable[_T] | None = ...) -> None: ... + +def strip_math(s: str) -> str: ... +def is_writable_file_like(obj: Any) -> bool: ... +def file_requires_unicode(x: Any) -> bool: ... +@overload +def to_filehandle( + fname: str | os.PathLike | IO, + flag: str = ..., + return_opened: Literal[False] = ..., + encoding: str | None = ..., +) -> IO: ... +@overload +def to_filehandle( + fname: str | os.PathLike | IO, + flag: str, + return_opened: Literal[True], + encoding: str | None = ..., +) -> tuple[IO, bool]: ... +@overload +def to_filehandle( + fname: str | os.PathLike | IO, + *, # if flag given, will match previous sig + return_opened: Literal[True], + encoding: str | None = ..., +) -> tuple[IO, bool]: ... +def open_file_cm( + path_or_file: str | os.PathLike | IO, + mode: str = ..., + encoding: str | None = ..., +) -> contextlib.AbstractContextManager[IO]: ... +def is_scalar_or_string(val: Any) -> bool: ... +@overload +def get_sample_data( + fname: str | os.PathLike, asfileobj: Literal[True] = ..., *, np_load: Literal[True] +) -> np.ndarray: ... +@overload +def get_sample_data( + fname: str | os.PathLike, + asfileobj: Literal[True] = ..., + *, + np_load: Literal[False] = ..., +) -> IO: ... +@overload +def get_sample_data( + fname: str | os.PathLike, asfileobj: Literal[False], *, np_load: bool = ... +) -> str: ... +def _get_data_path(*args: Path | str) -> Path: ... +def flatten( + seq: Iterable[Any], scalarp: Callable[[Any], bool] = ... +) -> Generator[Any, None, None]: ... + +class Stack(Generic[_T]): + def __init__(self, default: _T | None = ...) -> None: ... + def __call__(self) -> _T: ... + def __len__(self) -> int: ... + def __getitem__(self, ind: int) -> _T: ... + def forward(self) -> _T: ... + def back(self) -> _T: ... + def push(self, o: _T) -> _T: ... + def home(self) -> _T: ... + def empty(self) -> bool: ... + def clear(self) -> None: ... + def bubble(self, o: _T) -> _T: ... + def remove(self, o: _T) -> None: ... + +def safe_masked_invalid(x: ArrayLike, copy: bool = ...) -> np.ndarray: ... +def print_cycles( + objects: Iterable[Any], outstream: IO = ..., show_progress: bool = ... +) -> None: ... + +class Grouper(Generic[_T]): + def __init__(self, init: Iterable[_T] = ...) -> None: ... + def __contains__(self, item: _T) -> bool: ... + def clean(self) -> None: ... + def join(self, a: _T, *args: _T) -> None: ... + def joined(self, a: _T, b: _T) -> bool: ... + def remove(self, a: _T) -> None: ... + def __iter__(self) -> Iterator[list[_T]]: ... + def get_siblings(self, a: _T) -> list[_T]: ... + +class GrouperView(Generic[_T]): + def __init__(self, grouper: Grouper[_T]) -> None: ... + def __contains__(self, item: _T) -> bool: ... + def __iter__(self) -> Iterator[list[_T]]: ... + def joined(self, a: _T, b: _T) -> bool: ... + def get_siblings(self, a: _T) -> list[_T]: ... + +def simple_linear_interpolation(a: ArrayLike, steps: int) -> np.ndarray: ... +def delete_masked_points(*args): ... +def _broadcast_with_masks(*args: ArrayLike, compress: bool = ...) -> list[ArrayLike]: ... +def boxplot_stats( + X: ArrayLike, + whis: float | tuple[float, float] = ..., + bootstrap: int | None = ..., + labels: ArrayLike | None = ..., + autorange: bool = ..., +) -> list[dict[str, Any]]: ... + +ls_mapper: dict[str, str] +ls_mapper_r: dict[str, str] + +def contiguous_regions(mask: ArrayLike) -> list[np.ndarray]: ... +def is_math_text(s: str) -> bool: ... +def violin_stats( + X: ArrayLike, method: Callable, points: int = ..., quantiles: ArrayLike | None = ... +) -> list[dict[str, Any]]: ... +def pts_to_prestep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ... +def pts_to_poststep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ... +def pts_to_midstep(x: np.ndarray, *args: np.ndarray) -> np.ndarray: ... + +STEP_LOOKUP_MAP: dict[str, Callable] + +def index_of(y: float | ArrayLike) -> tuple[np.ndarray, np.ndarray]: ... +def safe_first_element(obj: Collection[_T]) -> _T: ... +def sanitize_sequence(data): ... +def normalize_kwargs( + kw: dict[str, Any], + alias_mapping: dict[str, list[str]] | type[Artist] | Artist | None = ..., +) -> dict[str, Any]: ... +def _lock_path(path: str | os.PathLike) -> contextlib.AbstractContextManager[None]: ... +def _str_equal(obj: Any, s: str) -> bool: ... +def _str_lower_equal(obj: Any, s: str) -> bool: ... +def _array_perimeter(arr: np.ndarray) -> np.ndarray: ... +def _unfold(arr: np.ndarray, axis: int, size: int, step: int) -> np.ndarray: ... +def _array_patch_perimeters(x: np.ndarray, rstride: int, cstride: int) -> np.ndarray: ... +def _setattr_cm(obj: Any, **kwargs) -> contextlib.AbstractContextManager[None]: ... + +class _OrderedSet(collections.abc.MutableSet): + def __init__(self) -> None: ... + def __contains__(self, key) -> bool: ... + def __iter__(self): ... + def __len__(self) -> int: ... + def add(self, key) -> None: ... + def discard(self, key) -> None: ... + +def _setup_new_guiapp() -> None: ... +def _format_approx(number: float, precision: int) -> str: ... +def _g_sig_digits(value: float, delta: float) -> int: ... +def _unikey_or_keysym_to_mplkey(unikey: str, keysym: str) -> str: ... +def _is_torch_array(x: Any) -> bool: ... +def _is_jax_array(x: Any) -> bool: ... +def _unpack_to_numpy(x: Any) -> Any: ... +def _auto_format_str(fmt: str, value: Any) -> str: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/cm.py b/venv/lib/python3.10/site-packages/matplotlib/cm.py new file mode 100644 index 00000000..c1497356 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/cm.py @@ -0,0 +1,626 @@ +""" +Builtin colormaps, colormap handling utilities, and the `ScalarMappable` mixin. + +.. seealso:: + + :doc:`/gallery/color/colormap_reference` for a list of builtin colormaps. + + :ref:`colormap-manipulation` for examples of how to make + colormaps. + + :ref:`colormaps` an in-depth discussion of choosing + colormaps. + + :ref:`colormapnorms` for more details about data normalization. +""" + +from collections.abc import Mapping +import functools + +import numpy as np +from numpy import ma + +import matplotlib as mpl +from matplotlib import _api, colors, cbook, scale +from matplotlib._cm import datad +from matplotlib._cm_listed import cmaps as cmaps_listed + + +_LUTSIZE = mpl.rcParams['image.lut'] + + +def _gen_cmap_registry(): + """ + Generate a dict mapping standard colormap names to standard colormaps, as + well as the reversed colormaps. + """ + cmap_d = {**cmaps_listed} + for name, spec in datad.items(): + cmap_d[name] = ( # Precache the cmaps at a fixed lutsize.. + colors.LinearSegmentedColormap(name, spec, _LUTSIZE) + if 'red' in spec else + colors.ListedColormap(spec['listed'], name) + if 'listed' in spec else + colors.LinearSegmentedColormap.from_list(name, spec, _LUTSIZE)) + + # Register colormap aliases for gray and grey. + cmap_d['grey'] = cmap_d['gray'] + cmap_d['gist_grey'] = cmap_d['gist_gray'] + cmap_d['gist_yerg'] = cmap_d['gist_yarg'] + cmap_d['Grays'] = cmap_d['Greys'] + + # Generate reversed cmaps. + for cmap in list(cmap_d.values()): + rmap = cmap.reversed() + cmap_d[rmap.name] = rmap + return cmap_d + + +class ColormapRegistry(Mapping): + r""" + Container for colormaps that are known to Matplotlib by name. + + The universal registry instance is `matplotlib.colormaps`. There should be + no need for users to instantiate `.ColormapRegistry` themselves. + + Read access uses a dict-like interface mapping names to `.Colormap`\s:: + + import matplotlib as mpl + cmap = mpl.colormaps['viridis'] + + Returned `.Colormap`\s are copies, so that their modification does not + change the global definition of the colormap. + + Additional colormaps can be added via `.ColormapRegistry.register`:: + + mpl.colormaps.register(my_colormap) + + To get a list of all registered colormaps, you can do:: + + from matplotlib import colormaps + list(colormaps) + """ + def __init__(self, cmaps): + self._cmaps = cmaps + self._builtin_cmaps = tuple(cmaps) + + def __getitem__(self, item): + try: + return self._cmaps[item].copy() + except KeyError: + raise KeyError(f"{item!r} is not a known colormap name") from None + + def __iter__(self): + return iter(self._cmaps) + + def __len__(self): + return len(self._cmaps) + + def __str__(self): + return ('ColormapRegistry; available colormaps:\n' + + ', '.join(f"'{name}'" for name in self)) + + def __call__(self): + """ + Return a list of the registered colormap names. + + This exists only for backward-compatibility in `.pyplot` which had a + ``plt.colormaps()`` method. The recommended way to get this list is + now ``list(colormaps)``. + """ + return list(self) + + def register(self, cmap, *, name=None, force=False): + """ + Register a new colormap. + + The colormap name can then be used as a string argument to any ``cmap`` + parameter in Matplotlib. It is also available in ``pyplot.get_cmap``. + + The colormap registry stores a copy of the given colormap, so that + future changes to the original colormap instance do not affect the + registered colormap. Think of this as the registry taking a snapshot + of the colormap at registration. + + Parameters + ---------- + cmap : matplotlib.colors.Colormap + The colormap to register. + + name : str, optional + The name for the colormap. If not given, ``cmap.name`` is used. + + force : bool, default: False + If False, a ValueError is raised if trying to overwrite an already + registered name. True supports overwriting registered colormaps + other than the builtin colormaps. + """ + _api.check_isinstance(colors.Colormap, cmap=cmap) + + name = name or cmap.name + if name in self: + if not force: + # don't allow registering an already existing cmap + # unless explicitly asked to + raise ValueError( + f'A colormap named "{name}" is already registered.') + elif name in self._builtin_cmaps: + # We don't allow overriding a builtin. + raise ValueError("Re-registering the builtin cmap " + f"{name!r} is not allowed.") + + # Warn that we are updating an already existing colormap + _api.warn_external(f"Overwriting the cmap {name!r} " + "that was already in the registry.") + + self._cmaps[name] = cmap.copy() + # Someone may set the extremes of a builtin colormap and want to register it + # with a different name for future lookups. The object would still have the + # builtin name, so we should update it to the registered name + if self._cmaps[name].name != name: + self._cmaps[name].name = name + + def unregister(self, name): + """ + Remove a colormap from the registry. + + You cannot remove built-in colormaps. + + If the named colormap is not registered, returns with no error, raises + if you try to de-register a default colormap. + + .. warning:: + + Colormap names are currently a shared namespace that may be used + by multiple packages. Use `unregister` only if you know you + have registered that name before. In particular, do not + unregister just in case to clean the name before registering a + new colormap. + + Parameters + ---------- + name : str + The name of the colormap to be removed. + + Raises + ------ + ValueError + If you try to remove a default built-in colormap. + """ + if name in self._builtin_cmaps: + raise ValueError(f"cannot unregister {name!r} which is a builtin " + "colormap.") + self._cmaps.pop(name, None) + + def get_cmap(self, cmap): + """ + Return a color map specified through *cmap*. + + Parameters + ---------- + cmap : str or `~matplotlib.colors.Colormap` or None + + - if a `.Colormap`, return it + - if a string, look it up in ``mpl.colormaps`` + - if None, return the Colormap defined in :rc:`image.cmap` + + Returns + ------- + Colormap + """ + # get the default color map + if cmap is None: + return self[mpl.rcParams["image.cmap"]] + + # if the user passed in a Colormap, simply return it + if isinstance(cmap, colors.Colormap): + return cmap + if isinstance(cmap, str): + _api.check_in_list(sorted(_colormaps), cmap=cmap) + # otherwise, it must be a string so look it up + return self[cmap] + raise TypeError( + 'get_cmap expects None or an instance of a str or Colormap . ' + + f'you passed {cmap!r} of type {type(cmap)}' + ) + + +# public access to the colormaps should be via `matplotlib.colormaps`. For now, +# we still create the registry here, but that should stay an implementation +# detail. +_colormaps = ColormapRegistry(_gen_cmap_registry()) +globals().update(_colormaps) + + +def _auto_norm_from_scale(scale_cls): + """ + Automatically generate a norm class from *scale_cls*. + + This differs from `.colors.make_norm_from_scale` in the following points: + + - This function is not a class decorator, but directly returns a norm class + (as if decorating `.Normalize`). + - The scale is automatically constructed with ``nonpositive="mask"``, if it + supports such a parameter, to work around the difference in defaults + between standard scales (which use "clip") and norms (which use "mask"). + + Note that ``make_norm_from_scale`` caches the generated norm classes + (not the instances) and reuses them for later calls. For example, + ``type(_auto_norm_from_scale("log")) == LogNorm``. + """ + # Actually try to construct an instance, to verify whether + # ``nonpositive="mask"`` is supported. + try: + norm = colors.make_norm_from_scale( + functools.partial(scale_cls, nonpositive="mask"))( + colors.Normalize)() + except TypeError: + norm = colors.make_norm_from_scale(scale_cls)( + colors.Normalize)() + return type(norm) + + +class ScalarMappable: + """ + A mixin class to map scalar data to RGBA. + + The ScalarMappable applies data normalization before returning RGBA colors + from the given colormap. + """ + + def __init__(self, norm=None, cmap=None): + """ + Parameters + ---------- + norm : `.Normalize` (or subclass thereof) or str or None + The normalizing object which scales data, typically into the + interval ``[0, 1]``. + If a `str`, a `.Normalize` subclass is dynamically generated based + on the scale with the corresponding name. + If *None*, *norm* defaults to a *colors.Normalize* object which + initializes its scaling based on the first data processed. + cmap : str or `~matplotlib.colors.Colormap` + The colormap used to map normalized data values to RGBA colors. + """ + self._A = None + self._norm = None # So that the setter knows we're initializing. + self.set_norm(norm) # The Normalize instance of this ScalarMappable. + self.cmap = None # So that the setter knows we're initializing. + self.set_cmap(cmap) # The Colormap instance of this ScalarMappable. + #: The last colorbar associated with this ScalarMappable. May be None. + self.colorbar = None + self.callbacks = cbook.CallbackRegistry(signals=["changed"]) + + def _scale_norm(self, norm, vmin, vmax): + """ + Helper for initial scaling. + + Used by public functions that create a ScalarMappable and support + parameters *vmin*, *vmax* and *norm*. This makes sure that a *norm* + will take precedence over *vmin*, *vmax*. + + Note that this method does not set the norm. + """ + if vmin is not None or vmax is not None: + self.set_clim(vmin, vmax) + if isinstance(norm, colors.Normalize): + raise ValueError( + "Passing a Normalize instance simultaneously with " + "vmin/vmax is not supported. Please pass vmin/vmax " + "directly to the norm when creating it.") + + # always resolve the autoscaling so we have concrete limits + # rather than deferring to draw time. + self.autoscale_None() + + def to_rgba(self, x, alpha=None, bytes=False, norm=True): + """ + Return a normalized RGBA array corresponding to *x*. + + In the normal case, *x* is a 1D or 2D sequence of scalars, and + the corresponding `~numpy.ndarray` of RGBA values will be returned, + based on the norm and colormap set for this ScalarMappable. + + There is one special case, for handling images that are already + RGB or RGBA, such as might have been read from an image file. + If *x* is an `~numpy.ndarray` with 3 dimensions, + and the last dimension is either 3 or 4, then it will be + treated as an RGB or RGBA array, and no mapping will be done. + The array can be `~numpy.uint8`, or it can be floats with + values in the 0-1 range; otherwise a ValueError will be raised. + Any NaNs or masked elements will be set to 0 alpha. + If the last dimension is 3, the *alpha* kwarg (defaulting to 1) + will be used to fill in the transparency. If the last dimension + is 4, the *alpha* kwarg is ignored; it does not + replace the preexisting alpha. A ValueError will be raised + if the third dimension is other than 3 or 4. + + In either case, if *bytes* is *False* (default), the RGBA + array will be floats in the 0-1 range; if it is *True*, + the returned RGBA array will be `~numpy.uint8` in the 0 to 255 range. + + If norm is False, no normalization of the input data is + performed, and it is assumed to be in the range (0-1). + + """ + # First check for special case, image input: + try: + if x.ndim == 3: + if x.shape[2] == 3: + if alpha is None: + alpha = 1 + if x.dtype == np.uint8: + alpha = np.uint8(alpha * 255) + m, n = x.shape[:2] + xx = np.empty(shape=(m, n, 4), dtype=x.dtype) + xx[:, :, :3] = x + xx[:, :, 3] = alpha + elif x.shape[2] == 4: + xx = x + else: + raise ValueError("Third dimension must be 3 or 4") + if xx.dtype.kind == 'f': + # If any of R, G, B, or A is nan, set to 0 + if np.any(nans := np.isnan(x)): + if x.shape[2] == 4: + xx = xx.copy() + xx[np.any(nans, axis=2), :] = 0 + + if norm and (xx.max() > 1 or xx.min() < 0): + raise ValueError("Floating point image RGB values " + "must be in the 0..1 range.") + if bytes: + xx = (xx * 255).astype(np.uint8) + elif xx.dtype == np.uint8: + if not bytes: + xx = xx.astype(np.float32) / 255 + else: + raise ValueError("Image RGB array must be uint8 or " + "floating point; found %s" % xx.dtype) + # Account for any masked entries in the original array + # If any of R, G, B, or A are masked for an entry, we set alpha to 0 + if np.ma.is_masked(x): + xx[np.any(np.ma.getmaskarray(x), axis=2), 3] = 0 + return xx + except AttributeError: + # e.g., x is not an ndarray; so try mapping it + pass + + # This is the normal case, mapping a scalar array: + x = ma.asarray(x) + if norm: + x = self.norm(x) + rgba = self.cmap(x, alpha=alpha, bytes=bytes) + return rgba + + def set_array(self, A): + """ + Set the value array from array-like *A*. + + Parameters + ---------- + A : array-like or None + The values that are mapped to colors. + + The base class `.ScalarMappable` does not make any assumptions on + the dimensionality and shape of the value array *A*. + """ + if A is None: + self._A = None + return + + A = cbook.safe_masked_invalid(A, copy=True) + if not np.can_cast(A.dtype, float, "same_kind"): + raise TypeError(f"Image data of dtype {A.dtype} cannot be " + "converted to float") + + self._A = A + if not self.norm.scaled(): + self.norm.autoscale_None(A) + + def get_array(self): + """ + Return the array of values, that are mapped to colors. + + The base class `.ScalarMappable` does not make any assumptions on + the dimensionality and shape of the array. + """ + return self._A + + def get_cmap(self): + """Return the `.Colormap` instance.""" + return self.cmap + + def get_clim(self): + """ + Return the values (min, max) that are mapped to the colormap limits. + """ + return self.norm.vmin, self.norm.vmax + + def set_clim(self, vmin=None, vmax=None): + """ + Set the norm limits for image scaling. + + Parameters + ---------- + vmin, vmax : float + The limits. + + The limits may also be passed as a tuple (*vmin*, *vmax*) as a + single positional argument. + + .. ACCEPTS: (vmin: float, vmax: float) + """ + # If the norm's limits are updated self.changed() will be called + # through the callbacks attached to the norm + if vmax is None: + try: + vmin, vmax = vmin + except (TypeError, ValueError): + pass + if vmin is not None: + self.norm.vmin = colors._sanitize_extrema(vmin) + if vmax is not None: + self.norm.vmax = colors._sanitize_extrema(vmax) + + def get_alpha(self): + """ + Returns + ------- + float + Always returns 1. + """ + # This method is intended to be overridden by Artist sub-classes + return 1. + + def set_cmap(self, cmap): + """ + Set the colormap for luminance data. + + Parameters + ---------- + cmap : `.Colormap` or str or None + """ + in_init = self.cmap is None + + self.cmap = _ensure_cmap(cmap) + if not in_init: + self.changed() # Things are not set up properly yet. + + @property + def norm(self): + return self._norm + + @norm.setter + def norm(self, norm): + _api.check_isinstance((colors.Normalize, str, None), norm=norm) + if norm is None: + norm = colors.Normalize() + elif isinstance(norm, str): + try: + scale_cls = scale._scale_mapping[norm] + except KeyError: + raise ValueError( + "Invalid norm str name; the following values are " + f"supported: {', '.join(scale._scale_mapping)}" + ) from None + norm = _auto_norm_from_scale(scale_cls)() + + if norm is self.norm: + # We aren't updating anything + return + + in_init = self.norm is None + # Remove the current callback and connect to the new one + if not in_init: + self.norm.callbacks.disconnect(self._id_norm) + self._norm = norm + self._id_norm = self.norm.callbacks.connect('changed', + self.changed) + if not in_init: + self.changed() + + def set_norm(self, norm): + """ + Set the normalization instance. + + Parameters + ---------- + norm : `.Normalize` or str or None + + Notes + ----- + If there are any colorbars using the mappable for this norm, setting + the norm of the mappable will reset the norm, locator, and formatters + on the colorbar to default. + """ + self.norm = norm + + def autoscale(self): + """ + Autoscale the scalar limits on the norm instance using the + current array + """ + if self._A is None: + raise TypeError('You must first set_array for mappable') + # If the norm's limits are updated self.changed() will be called + # through the callbacks attached to the norm + self.norm.autoscale(self._A) + + def autoscale_None(self): + """ + Autoscale the scalar limits on the norm instance using the + current array, changing only limits that are None + """ + if self._A is None: + raise TypeError('You must first set_array for mappable') + # If the norm's limits are updated self.changed() will be called + # through the callbacks attached to the norm + self.norm.autoscale_None(self._A) + + def changed(self): + """ + Call this whenever the mappable is changed to notify all the + callbackSM listeners to the 'changed' signal. + """ + self.callbacks.process('changed', self) + self.stale = True + + +# The docstrings here must be generic enough to apply to all relevant methods. +mpl._docstring.interpd.update( + cmap_doc="""\ +cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` + The Colormap instance or registered colormap name used to map scalar data + to colors.""", + norm_doc="""\ +norm : str or `~matplotlib.colors.Normalize`, optional + The normalization method used to scale scalar data to the [0, 1] range + before mapping to colors using *cmap*. By default, a linear scaling is + used, mapping the lowest value to 0 and the highest to 1. + + If given, this can be one of the following: + + - An instance of `.Normalize` or one of its subclasses + (see :ref:`colormapnorms`). + - A scale name, i.e. one of "linear", "log", "symlog", "logit", etc. For a + list of available scales, call `matplotlib.scale.get_scale_names()`. + In that case, a suitable `.Normalize` subclass is dynamically generated + and instantiated.""", + vmin_vmax_doc="""\ +vmin, vmax : float, optional + When using scalar data and no explicit *norm*, *vmin* and *vmax* define + the data range that the colormap covers. By default, the colormap covers + the complete value range of the supplied data. It is an error to use + *vmin*/*vmax* when a *norm* instance is given (but using a `str` *norm* + name together with *vmin*/*vmax* is acceptable).""", +) + + +def _ensure_cmap(cmap): + """ + Ensure that we have a `.Colormap` object. + + For internal use to preserve type stability of errors. + + Parameters + ---------- + cmap : None, str, Colormap + + - if a `Colormap`, return it + - if a string, look it up in mpl.colormaps + - if None, look up the default color map in mpl.colormaps + + Returns + ------- + Colormap + + """ + if isinstance(cmap, colors.Colormap): + return cmap + cmap_name = cmap if cmap is not None else mpl.rcParams["image.cmap"] + # use check_in_list to ensure type stability of the exception raised by + # the internal usage of this (ValueError vs KeyError) + if cmap_name not in _colormaps: + _api.check_in_list(sorted(_colormaps), cmap=cmap_name) + return mpl.colormaps[cmap_name] diff --git a/venv/lib/python3.10/site-packages/matplotlib/cm.pyi b/venv/lib/python3.10/site-packages/matplotlib/cm.pyi new file mode 100644 index 00000000..da78d940 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/cm.pyi @@ -0,0 +1,52 @@ +from collections.abc import Iterator, Mapping +from matplotlib import cbook, colors +from matplotlib.colorbar import Colorbar + +import numpy as np +from numpy.typing import ArrayLike + +class ColormapRegistry(Mapping[str, colors.Colormap]): + def __init__(self, cmaps: Mapping[str, colors.Colormap]) -> None: ... + def __getitem__(self, item: str) -> colors.Colormap: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def __call__(self) -> list[str]: ... + def register( + self, cmap: colors.Colormap, *, name: str | None = ..., force: bool = ... + ) -> None: ... + def unregister(self, name: str) -> None: ... + def get_cmap(self, cmap: str | colors.Colormap) -> colors.Colormap: ... + +_colormaps: ColormapRegistry = ... + +class ScalarMappable: + cmap: colors.Colormap | None + colorbar: Colorbar | None + callbacks: cbook.CallbackRegistry + def __init__( + self, + norm: colors.Normalize | None = ..., + cmap: str | colors.Colormap | None = ..., + ) -> None: ... + def to_rgba( + self, + x: np.ndarray, + alpha: float | ArrayLike | None = ..., + bytes: bool = ..., + norm: bool = ..., + ) -> np.ndarray: ... + def set_array(self, A: ArrayLike | None) -> None: ... + def get_array(self) -> np.ndarray | None: ... + def get_cmap(self) -> colors.Colormap: ... + def get_clim(self) -> tuple[float, float]: ... + def set_clim(self, vmin: float | tuple[float, float] | None = ..., vmax: float | None = ...) -> None: ... + def get_alpha(self) -> float | None: ... + def set_cmap(self, cmap: str | colors.Colormap) -> None: ... + @property + def norm(self) -> colors.Normalize: ... + @norm.setter + def norm(self, norm: colors.Normalize | str | None) -> None: ... + def set_norm(self, norm: colors.Normalize | str | None) -> None: ... + def autoscale(self) -> None: ... + def autoscale_None(self) -> None: ... + def changed(self) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/collections.py b/venv/lib/python3.10/site-packages/matplotlib/collections.py new file mode 100644 index 00000000..fd6cc433 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/collections.py @@ -0,0 +1,2376 @@ +""" +Classes for the efficient drawing of large collections of objects that +share most properties, e.g., a large number of line segments or +polygons. + +The classes are not meant to be as flexible as their single element +counterparts (e.g., you may not be able to select all line styles) but +they are meant to be fast for common use cases (e.g., a large set of solid +line segments). +""" + +import itertools +import math +from numbers import Number, Real +import warnings + +import numpy as np + +import matplotlib as mpl +from . import (_api, _path, artist, cbook, cm, colors as mcolors, _docstring, + hatch as mhatch, lines as mlines, path as mpath, transforms) +from ._enums import JoinStyle, CapStyle + + +# "color" is excluded; it is a compound setter, and its docstring differs +# in LineCollection. +@_api.define_aliases({ + "antialiased": ["antialiaseds", "aa"], + "edgecolor": ["edgecolors", "ec"], + "facecolor": ["facecolors", "fc"], + "linestyle": ["linestyles", "dashes", "ls"], + "linewidth": ["linewidths", "lw"], + "offset_transform": ["transOffset"], +}) +class Collection(artist.Artist, cm.ScalarMappable): + r""" + Base class for Collections. Must be subclassed to be usable. + + A Collection represents a sequence of `.Patch`\es that can be drawn + more efficiently together than individually. For example, when a single + path is being drawn repeatedly at different offsets, the renderer can + typically execute a ``draw_marker()`` call much more efficiently than a + series of repeated calls to ``draw_path()`` with the offsets put in + one-by-one. + + Most properties of a collection can be configured per-element. Therefore, + Collections have "plural" versions of many of the properties of a `.Patch` + (e.g. `.Collection.get_paths` instead of `.Patch.get_path`). Exceptions are + the *zorder*, *hatch*, *pickradius*, *capstyle* and *joinstyle* properties, + which can only be set globally for the whole collection. + + Besides these exceptions, all properties can be specified as single values + (applying to all elements) or sequences of values. The property of the + ``i``\th element of the collection is:: + + prop[i % len(prop)] + + Each Collection can optionally be used as its own `.ScalarMappable` by + passing the *norm* and *cmap* parameters to its constructor. If the + Collection's `.ScalarMappable` matrix ``_A`` has been set (via a call + to `.Collection.set_array`), then at draw time this internal scalar + mappable will be used to set the ``facecolors`` and ``edgecolors``, + ignoring those that were manually passed in. + """ + #: Either a list of 3x3 arrays or an Nx3x3 array (representing N + #: transforms), suitable for the `all_transforms` argument to + #: `~matplotlib.backend_bases.RendererBase.draw_path_collection`; + #: each 3x3 array is used to initialize an + #: `~matplotlib.transforms.Affine2D` object. + #: Each kind of collection defines this based on its arguments. + _transforms = np.empty((0, 3, 3)) + + # Whether to draw an edge by default. Set on a + # subclass-by-subclass basis. + _edge_default = False + + @_docstring.interpd + def __init__(self, *, + edgecolors=None, + facecolors=None, + linewidths=None, + linestyles='solid', + capstyle=None, + joinstyle=None, + antialiaseds=None, + offsets=None, + offset_transform=None, + norm=None, # optional for ScalarMappable + cmap=None, # ditto + pickradius=5.0, + hatch=None, + urls=None, + zorder=1, + **kwargs + ): + """ + Parameters + ---------- + edgecolors : :mpltype:`color` or list of colors, default: :rc:`patch.edgecolor` + Edge color for each patch making up the collection. The special + value 'face' can be passed to make the edgecolor match the + facecolor. + facecolors : :mpltype:`color` or list of colors, default: :rc:`patch.facecolor` + Face color for each patch making up the collection. + linewidths : float or list of floats, default: :rc:`patch.linewidth` + Line width for each patch making up the collection. + linestyles : str or tuple or list thereof, default: 'solid' + Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', + '--', '-.', ':']. Dash tuples should be of the form:: + + (offset, onoffseq), + + where *onoffseq* is an even length tuple of on and off ink lengths + in points. For examples, see + :doc:`/gallery/lines_bars_and_markers/linestyles`. + capstyle : `.CapStyle`-like, default: :rc:`patch.capstyle` + Style to use for capping lines for all paths in the collection. + Allowed values are %(CapStyle)s. + joinstyle : `.JoinStyle`-like, default: :rc:`patch.joinstyle` + Style to use for joining lines for all paths in the collection. + Allowed values are %(JoinStyle)s. + antialiaseds : bool or list of bool, default: :rc:`patch.antialiased` + Whether each patch in the collection should be drawn with + antialiasing. + offsets : (float, float) or list thereof, default: (0, 0) + A vector by which to translate each patch after rendering (default + is no translation). The translation is performed in screen (pixel) + coordinates (i.e. after the Artist's transform is applied). + offset_transform : `~.Transform`, default: `.IdentityTransform` + A single transform which will be applied to each *offsets* vector + before it is used. + cmap, norm + Data normalization and colormapping parameters. See + `.ScalarMappable` for a detailed description. + hatch : str, optional + Hatching pattern to use in filled paths, if any. Valid strings are + ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See + :doc:`/gallery/shapes_and_collections/hatch_style_reference` for + the meaning of each hatch type. + pickradius : float, default: 5.0 + If ``pickradius <= 0``, then `.Collection.contains` will return + ``True`` whenever the test point is inside of one of the polygons + formed by the control points of a Path in the Collection. On the + other hand, if it is greater than 0, then we instead check if the + test point is contained in a stroke of width ``2*pickradius`` + following any of the Paths in the Collection. + urls : list of str, default: None + A URL for each patch to link to once drawn. Currently only works + for the SVG backend. See :doc:`/gallery/misc/hyperlinks_sgskip` for + examples. + zorder : float, default: 1 + The drawing order, shared by all Patches in the Collection. See + :doc:`/gallery/misc/zorder_demo` for all defaults and examples. + **kwargs + Remaining keyword arguments will be used to set properties as + ``Collection.set_{key}(val)`` for each key-value pair in *kwargs*. + """ + artist.Artist.__init__(self) + cm.ScalarMappable.__init__(self, norm, cmap) + # list of un-scaled dash patterns + # this is needed scaling the dash pattern by linewidth + self._us_linestyles = [(0, None)] + # list of dash patterns + self._linestyles = [(0, None)] + # list of unbroadcast/scaled linewidths + self._us_lw = [0] + self._linewidths = [0] + + self._gapcolor = None # Currently only used by LineCollection. + + # Flags set by _set_mappable_flags: are colors from mapping an array? + self._face_is_mapped = None + self._edge_is_mapped = None + self._mapped_colors = None # calculated in update_scalarmappable + self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color']) + self.set_facecolor(facecolors) + self.set_edgecolor(edgecolors) + self.set_linewidth(linewidths) + self.set_linestyle(linestyles) + self.set_antialiased(antialiaseds) + self.set_pickradius(pickradius) + self.set_urls(urls) + self.set_hatch(hatch) + self.set_zorder(zorder) + + if capstyle: + self.set_capstyle(capstyle) + else: + self._capstyle = None + + if joinstyle: + self.set_joinstyle(joinstyle) + else: + self._joinstyle = None + + if offsets is not None: + offsets = np.asanyarray(offsets, float) + # Broadcast (2,) -> (1, 2) but nothing else. + if offsets.shape == (2,): + offsets = offsets[None, :] + + self._offsets = offsets + self._offset_transform = offset_transform + + self._path_effects = None + self._internal_update(kwargs) + self._paths = None + + def get_paths(self): + return self._paths + + def set_paths(self, paths): + self._paths = paths + self.stale = True + + def get_transforms(self): + return self._transforms + + def get_offset_transform(self): + """Return the `.Transform` instance used by this artist offset.""" + if self._offset_transform is None: + self._offset_transform = transforms.IdentityTransform() + elif (not isinstance(self._offset_transform, transforms.Transform) + and hasattr(self._offset_transform, '_as_mpl_transform')): + self._offset_transform = \ + self._offset_transform._as_mpl_transform(self.axes) + return self._offset_transform + + def set_offset_transform(self, offset_transform): + """ + Set the artist offset transform. + + Parameters + ---------- + offset_transform : `.Transform` + """ + self._offset_transform = offset_transform + + def get_datalim(self, transData): + # Calculate the data limits and return them as a `.Bbox`. + # + # This operation depends on the transforms for the data in the + # collection and whether the collection has offsets: + # + # 1. offsets = None, transform child of transData: use the paths for + # the automatic limits (i.e. for LineCollection in streamline). + # 2. offsets != None: offset_transform is child of transData: + # + # a. transform is child of transData: use the path + offset for + # limits (i.e for bar). + # b. transform is not a child of transData: just use the offsets + # for the limits (i.e. for scatter) + # + # 3. otherwise return a null Bbox. + + transform = self.get_transform() + offset_trf = self.get_offset_transform() + if not (isinstance(offset_trf, transforms.IdentityTransform) + or offset_trf.contains_branch(transData)): + # if the offsets are in some coords other than data, + # then don't use them for autoscaling. + return transforms.Bbox.null() + + paths = self.get_paths() + if not len(paths): + # No paths to transform + return transforms.Bbox.null() + + if not transform.is_affine: + paths = [transform.transform_path_non_affine(p) for p in paths] + # Don't convert transform to transform.get_affine() here because + # we may have transform.contains_branch(transData) but not + # transforms.get_affine().contains_branch(transData). But later, + # be careful to only apply the affine part that remains. + + offsets = self.get_offsets() + + if any(transform.contains_branch_seperately(transData)): + # collections that are just in data units (like quiver) + # can properly have the axes limits set by their shape + + # offset. LineCollections that have no offsets can + # also use this algorithm (like streamplot). + if isinstance(offsets, np.ma.MaskedArray): + offsets = offsets.filled(np.nan) + # get_path_collection_extents handles nan but not masked arrays + return mpath.get_path_collection_extents( + transform.get_affine() - transData, paths, + self.get_transforms(), + offset_trf.transform_non_affine(offsets), + offset_trf.get_affine().frozen()) + + # NOTE: None is the default case where no offsets were passed in + if self._offsets is not None: + # this is for collections that have their paths (shapes) + # in physical, axes-relative, or figure-relative units + # (i.e. like scatter). We can't uniquely set limits based on + # those shapes, so we just set the limits based on their + # location. + offsets = (offset_trf - transData).transform(offsets) + # note A-B means A B^{-1} + offsets = np.ma.masked_invalid(offsets) + if not offsets.mask.all(): + bbox = transforms.Bbox.null() + bbox.update_from_data_xy(offsets) + return bbox + return transforms.Bbox.null() + + def get_window_extent(self, renderer=None): + # TODO: check to ensure that this does not fail for + # cases other than scatter plot legend + return self.get_datalim(transforms.IdentityTransform()) + + def _prepare_points(self): + # Helper for drawing and hit testing. + + transform = self.get_transform() + offset_trf = self.get_offset_transform() + offsets = self.get_offsets() + paths = self.get_paths() + + if self.have_units(): + paths = [] + for path in self.get_paths(): + vertices = path.vertices + xs, ys = vertices[:, 0], vertices[:, 1] + xs = self.convert_xunits(xs) + ys = self.convert_yunits(ys) + paths.append(mpath.Path(np.column_stack([xs, ys]), path.codes)) + xs = self.convert_xunits(offsets[:, 0]) + ys = self.convert_yunits(offsets[:, 1]) + offsets = np.ma.column_stack([xs, ys]) + + if not transform.is_affine: + paths = [transform.transform_path_non_affine(path) + for path in paths] + transform = transform.get_affine() + if not offset_trf.is_affine: + offsets = offset_trf.transform_non_affine(offsets) + # This might have changed an ndarray into a masked array. + offset_trf = offset_trf.get_affine() + + if isinstance(offsets, np.ma.MaskedArray): + offsets = offsets.filled(np.nan) + # Changing from a masked array to nan-filled ndarray + # is probably most efficient at this point. + + return transform, offset_trf, offsets, paths + + @artist.allow_rasterization + def draw(self, renderer): + if not self.get_visible(): + return + renderer.open_group(self.__class__.__name__, self.get_gid()) + + self.update_scalarmappable() + + transform, offset_trf, offsets, paths = self._prepare_points() + + gc = renderer.new_gc() + self._set_gc_clip(gc) + gc.set_snap(self.get_snap()) + + if self._hatch: + gc.set_hatch(self._hatch) + gc.set_hatch_color(self._hatch_color) + + if self.get_sketch_params() is not None: + gc.set_sketch_params(*self.get_sketch_params()) + + if self.get_path_effects(): + from matplotlib.patheffects import PathEffectRenderer + renderer = PathEffectRenderer(self.get_path_effects(), renderer) + + # If the collection is made up of a single shape/color/stroke, + # it can be rendered once and blitted multiple times, using + # `draw_markers` rather than `draw_path_collection`. This is + # *much* faster for Agg, and results in smaller file sizes in + # PDF/SVG/PS. + + trans = self.get_transforms() + facecolors = self.get_facecolor() + edgecolors = self.get_edgecolor() + do_single_path_optimization = False + if (len(paths) == 1 and len(trans) <= 1 and + len(facecolors) == 1 and len(edgecolors) == 1 and + len(self._linewidths) == 1 and + all(ls[1] is None for ls in self._linestyles) and + len(self._antialiaseds) == 1 and len(self._urls) == 1 and + self.get_hatch() is None): + if len(trans): + combined_transform = transforms.Affine2D(trans[0]) + transform + else: + combined_transform = transform + extents = paths[0].get_extents(combined_transform) + if (extents.width < self.figure.bbox.width + and extents.height < self.figure.bbox.height): + do_single_path_optimization = True + + if self._joinstyle: + gc.set_joinstyle(self._joinstyle) + + if self._capstyle: + gc.set_capstyle(self._capstyle) + + if do_single_path_optimization: + gc.set_foreground(tuple(edgecolors[0])) + gc.set_linewidth(self._linewidths[0]) + gc.set_dashes(*self._linestyles[0]) + gc.set_antialiased(self._antialiaseds[0]) + gc.set_url(self._urls[0]) + renderer.draw_markers( + gc, paths[0], combined_transform.frozen(), + mpath.Path(offsets), offset_trf, tuple(facecolors[0])) + else: + if self._gapcolor is not None: + # First draw paths within the gaps. + ipaths, ilinestyles = self._get_inverse_paths_linestyles() + renderer.draw_path_collection( + gc, transform.frozen(), ipaths, + self.get_transforms(), offsets, offset_trf, + [mcolors.to_rgba("none")], self._gapcolor, + self._linewidths, ilinestyles, + self._antialiaseds, self._urls, + "screen") + + renderer.draw_path_collection( + gc, transform.frozen(), paths, + self.get_transforms(), offsets, offset_trf, + self.get_facecolor(), self.get_edgecolor(), + self._linewidths, self._linestyles, + self._antialiaseds, self._urls, + "screen") # offset_position, kept for backcompat. + + gc.restore() + renderer.close_group(self.__class__.__name__) + self.stale = False + + def set_pickradius(self, pickradius): + """ + Set the pick radius used for containment tests. + + Parameters + ---------- + pickradius : float + Pick radius, in points. + """ + if not isinstance(pickradius, Real): + raise ValueError( + f"pickradius must be a real-valued number, not {pickradius!r}") + self._pickradius = pickradius + + def get_pickradius(self): + return self._pickradius + + def contains(self, mouseevent): + """ + Test whether the mouse event occurred in the collection. + + Returns ``bool, dict(ind=itemlist)``, where every item in itemlist + contains the event. + """ + if self._different_canvas(mouseevent) or not self.get_visible(): + return False, {} + pickradius = ( + float(self._picker) + if isinstance(self._picker, Number) and + self._picker is not True # the bool, not just nonzero or 1 + else self._pickradius) + if self.axes: + self.axes._unstale_viewLim() + transform, offset_trf, offsets, paths = self._prepare_points() + # Tests if the point is contained on one of the polygons formed + # by the control points of each of the paths. A point is considered + # "on" a path if it would lie within a stroke of width 2*pickradius + # following the path. If pickradius <= 0, then we instead simply check + # if the point is *inside* of the path instead. + ind = _path.point_in_path_collection( + mouseevent.x, mouseevent.y, pickradius, + transform.frozen(), paths, self.get_transforms(), + offsets, offset_trf, pickradius <= 0) + return len(ind) > 0, dict(ind=ind) + + def set_urls(self, urls): + """ + Parameters + ---------- + urls : list of str or None + + Notes + ----- + URLs are currently only implemented by the SVG backend. They are + ignored by all other backends. + """ + self._urls = urls if urls is not None else [None] + self.stale = True + + def get_urls(self): + """ + Return a list of URLs, one for each element of the collection. + + The list contains *None* for elements without a URL. See + :doc:`/gallery/misc/hyperlinks_sgskip` for an example. + """ + return self._urls + + def set_hatch(self, hatch): + r""" + Set the hatching pattern + + *hatch* can be one of:: + + / - diagonal hatching + \ - back diagonal + | - vertical + - - horizontal + + - crossed + x - crossed diagonal + o - small circle + O - large circle + . - dots + * - stars + + Letters can be combined, in which case all the specified + hatchings are done. If same letter repeats, it increases the + density of hatching of that pattern. + + Unlike other properties such as linewidth and colors, hatching + can only be specified for the collection as a whole, not separately + for each member. + + Parameters + ---------- + hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} + """ + # Use validate_hatch(list) after deprecation. + mhatch._validate_hatch_pattern(hatch) + self._hatch = hatch + self.stale = True + + def get_hatch(self): + """Return the current hatching pattern.""" + return self._hatch + + def set_offsets(self, offsets): + """ + Set the offsets for the collection. + + Parameters + ---------- + offsets : (N, 2) or (2,) array-like + """ + offsets = np.asanyarray(offsets) + if offsets.shape == (2,): # Broadcast (2,) -> (1, 2) but nothing else. + offsets = offsets[None, :] + cstack = (np.ma.column_stack if isinstance(offsets, np.ma.MaskedArray) + else np.column_stack) + self._offsets = cstack( + (np.asanyarray(self.convert_xunits(offsets[:, 0]), float), + np.asanyarray(self.convert_yunits(offsets[:, 1]), float))) + self.stale = True + + def get_offsets(self): + """Return the offsets for the collection.""" + # Default to zeros in the no-offset (None) case + return np.zeros((1, 2)) if self._offsets is None else self._offsets + + def _get_default_linewidth(self): + # This may be overridden in a subclass. + return mpl.rcParams['patch.linewidth'] # validated as float + + def set_linewidth(self, lw): + """ + Set the linewidth(s) for the collection. *lw* can be a scalar + or a sequence; if it is a sequence the patches will cycle + through the sequence + + Parameters + ---------- + lw : float or list of floats + """ + if lw is None: + lw = self._get_default_linewidth() + # get the un-scaled/broadcast lw + self._us_lw = np.atleast_1d(lw) + + # scale all of the dash patterns. + self._linewidths, self._linestyles = self._bcast_lwls( + self._us_lw, self._us_linestyles) + self.stale = True + + def set_linestyle(self, ls): + """ + Set the linestyle(s) for the collection. + + =========================== ================= + linestyle description + =========================== ================= + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + =========================== ================= + + Alternatively a dash tuple of the following form can be provided:: + + (offset, onoffseq), + + where ``onoffseq`` is an even length tuple of on and off ink in points. + + Parameters + ---------- + ls : str or tuple or list thereof + Valid values for individual linestyles include {'-', '--', '-.', + ':', '', (offset, on-off-seq)}. See `.Line2D.set_linestyle` for a + complete description. + """ + try: + dashes = [mlines._get_dash_pattern(ls)] + except ValueError: + try: + dashes = [mlines._get_dash_pattern(x) for x in ls] + except ValueError as err: + emsg = f'Do not know how to convert {ls!r} to dashes' + raise ValueError(emsg) from err + + # get the list of raw 'unscaled' dash patterns + self._us_linestyles = dashes + + # broadcast and scale the lw and dash patterns + self._linewidths, self._linestyles = self._bcast_lwls( + self._us_lw, self._us_linestyles) + + @_docstring.interpd + def set_capstyle(self, cs): + """ + Set the `.CapStyle` for the collection (for all its elements). + + Parameters + ---------- + cs : `.CapStyle` or %(CapStyle)s + """ + self._capstyle = CapStyle(cs) + + @_docstring.interpd + def get_capstyle(self): + """ + Return the cap style for the collection (for all its elements). + + Returns + ------- + %(CapStyle)s or None + """ + return self._capstyle.name if self._capstyle else None + + @_docstring.interpd + def set_joinstyle(self, js): + """ + Set the `.JoinStyle` for the collection (for all its elements). + + Parameters + ---------- + js : `.JoinStyle` or %(JoinStyle)s + """ + self._joinstyle = JoinStyle(js) + + @_docstring.interpd + def get_joinstyle(self): + """ + Return the join style for the collection (for all its elements). + + Returns + ------- + %(JoinStyle)s or None + """ + return self._joinstyle.name if self._joinstyle else None + + @staticmethod + def _bcast_lwls(linewidths, dashes): + """ + Internal helper function to broadcast + scale ls/lw + + In the collection drawing code, the linewidth and linestyle are cycled + through as circular buffers (via ``v[i % len(v)]``). Thus, if we are + going to scale the dash pattern at set time (not draw time) we need to + do the broadcasting now and expand both lists to be the same length. + + Parameters + ---------- + linewidths : list + line widths of collection + dashes : list + dash specification (offset, (dash pattern tuple)) + + Returns + ------- + linewidths, dashes : list + Will be the same length, dashes are scaled by paired linewidth + """ + if mpl.rcParams['_internal.classic_mode']: + return linewidths, dashes + # make sure they are the same length so we can zip them + if len(dashes) != len(linewidths): + l_dashes = len(dashes) + l_lw = len(linewidths) + gcd = math.gcd(l_dashes, l_lw) + dashes = list(dashes) * (l_lw // gcd) + linewidths = list(linewidths) * (l_dashes // gcd) + + # scale the dash patterns + dashes = [mlines._scale_dashes(o, d, lw) + for (o, d), lw in zip(dashes, linewidths)] + + return linewidths, dashes + + def get_antialiased(self): + """ + Get the antialiasing state for rendering. + + Returns + ------- + array of bools + """ + return self._antialiaseds + + def set_antialiased(self, aa): + """ + Set the antialiasing state for rendering. + + Parameters + ---------- + aa : bool or list of bools + """ + if aa is None: + aa = self._get_default_antialiased() + self._antialiaseds = np.atleast_1d(np.asarray(aa, bool)) + self.stale = True + + def _get_default_antialiased(self): + # This may be overridden in a subclass. + return mpl.rcParams['patch.antialiased'] + + def set_color(self, c): + """ + Set both the edgecolor and the facecolor. + + Parameters + ---------- + c : :mpltype:`color` or list of RGBA tuples + + See Also + -------- + Collection.set_facecolor, Collection.set_edgecolor + For setting the edge or face color individually. + """ + self.set_facecolor(c) + self.set_edgecolor(c) + + def _get_default_facecolor(self): + # This may be overridden in a subclass. + return mpl.rcParams['patch.facecolor'] + + def _set_facecolor(self, c): + if c is None: + c = self._get_default_facecolor() + + self._facecolors = mcolors.to_rgba_array(c, self._alpha) + self.stale = True + + def set_facecolor(self, c): + """ + Set the facecolor(s) of the collection. *c* can be a color (all patches + have same color), or a sequence of colors; if it is a sequence the + patches will cycle through the sequence. + + If *c* is 'none', the patch will not be filled. + + Parameters + ---------- + c : :mpltype:`color` or list of :mpltype:`color` + """ + if isinstance(c, str) and c.lower() in ("none", "face"): + c = c.lower() + self._original_facecolor = c + self._set_facecolor(c) + + def get_facecolor(self): + return self._facecolors + + def get_edgecolor(self): + if cbook._str_equal(self._edgecolors, 'face'): + return self.get_facecolor() + else: + return self._edgecolors + + def _get_default_edgecolor(self): + # This may be overridden in a subclass. + return mpl.rcParams['patch.edgecolor'] + + def _set_edgecolor(self, c): + set_hatch_color = True + if c is None: + if (mpl.rcParams['patch.force_edgecolor'] + or self._edge_default + or cbook._str_equal(self._original_facecolor, 'none')): + c = self._get_default_edgecolor() + else: + c = 'none' + set_hatch_color = False + if cbook._str_lower_equal(c, 'face'): + self._edgecolors = 'face' + self.stale = True + return + self._edgecolors = mcolors.to_rgba_array(c, self._alpha) + if set_hatch_color and len(self._edgecolors): + self._hatch_color = tuple(self._edgecolors[0]) + self.stale = True + + def set_edgecolor(self, c): + """ + Set the edgecolor(s) of the collection. + + Parameters + ---------- + c : :mpltype:`color` or list of :mpltype:`color` or 'face' + The collection edgecolor(s). If a sequence, the patches cycle + through it. If 'face', match the facecolor. + """ + # We pass through a default value for use in LineCollection. + # This allows us to maintain None as the default indicator in + # _original_edgecolor. + if isinstance(c, str) and c.lower() in ("none", "face"): + c = c.lower() + self._original_edgecolor = c + self._set_edgecolor(c) + + def set_alpha(self, alpha): + """ + Set the transparency of the collection. + + Parameters + ---------- + alpha : float or array of float or None + If not None, *alpha* values must be between 0 and 1, inclusive. + If an array is provided, its length must match the number of + elements in the collection. Masked values and nans are not + supported. + """ + artist.Artist._set_alpha_for_array(self, alpha) + self._set_facecolor(self._original_facecolor) + self._set_edgecolor(self._original_edgecolor) + + set_alpha.__doc__ = artist.Artist._set_alpha_for_array.__doc__ + + def get_linewidth(self): + return self._linewidths + + def get_linestyle(self): + return self._linestyles + + def _set_mappable_flags(self): + """ + Determine whether edges and/or faces are color-mapped. + + This is a helper for update_scalarmappable. + It sets Boolean flags '_edge_is_mapped' and '_face_is_mapped'. + + Returns + ------- + mapping_change : bool + True if either flag is True, or if a flag has changed. + """ + # The flags are initialized to None to ensure this returns True + # the first time it is called. + edge0 = self._edge_is_mapped + face0 = self._face_is_mapped + # After returning, the flags must be Booleans, not None. + self._edge_is_mapped = False + self._face_is_mapped = False + if self._A is not None: + if not cbook._str_equal(self._original_facecolor, 'none'): + self._face_is_mapped = True + if cbook._str_equal(self._original_edgecolor, 'face'): + self._edge_is_mapped = True + else: + if self._original_edgecolor is None: + self._edge_is_mapped = True + + mapped = self._face_is_mapped or self._edge_is_mapped + changed = (edge0 is None or face0 is None + or self._edge_is_mapped != edge0 + or self._face_is_mapped != face0) + return mapped or changed + + def update_scalarmappable(self): + """ + Update colors from the scalar mappable array, if any. + + Assign colors to edges and faces based on the array and/or + colors that were directly set, as appropriate. + """ + if not self._set_mappable_flags(): + return + # Allow possibility to call 'self.set_array(None)'. + if self._A is not None: + # QuadMesh can map 2d arrays (but pcolormesh supplies 1d array) + if self._A.ndim > 1 and not isinstance(self, _MeshData): + raise ValueError('Collections can only map rank 1 arrays') + if np.iterable(self._alpha): + if self._alpha.size != self._A.size: + raise ValueError( + f'Data array shape, {self._A.shape} ' + 'is incompatible with alpha array shape, ' + f'{self._alpha.shape}. ' + 'This can occur with the deprecated ' + 'behavior of the "flat" shading option, ' + 'in which a row and/or column of the data ' + 'array is dropped.') + # pcolormesh, scatter, maybe others flatten their _A + self._alpha = self._alpha.reshape(self._A.shape) + self._mapped_colors = self.to_rgba(self._A, self._alpha) + + if self._face_is_mapped: + self._facecolors = self._mapped_colors + else: + self._set_facecolor(self._original_facecolor) + if self._edge_is_mapped: + self._edgecolors = self._mapped_colors + else: + self._set_edgecolor(self._original_edgecolor) + self.stale = True + + def get_fill(self): + """Return whether face is colored.""" + return not cbook._str_lower_equal(self._original_facecolor, "none") + + def update_from(self, other): + """Copy properties from other to self.""" + + artist.Artist.update_from(self, other) + self._antialiaseds = other._antialiaseds + self._mapped_colors = other._mapped_colors + self._edge_is_mapped = other._edge_is_mapped + self._original_edgecolor = other._original_edgecolor + self._edgecolors = other._edgecolors + self._face_is_mapped = other._face_is_mapped + self._original_facecolor = other._original_facecolor + self._facecolors = other._facecolors + self._linewidths = other._linewidths + self._linestyles = other._linestyles + self._us_linestyles = other._us_linestyles + self._pickradius = other._pickradius + self._hatch = other._hatch + + # update_from for scalarmappable + self._A = other._A + self.norm = other.norm + self.cmap = other.cmap + self.stale = True + + +class _CollectionWithSizes(Collection): + """ + Base class for collections that have an array of sizes. + """ + _factor = 1.0 + + def get_sizes(self): + """ + Return the sizes ('areas') of the elements in the collection. + + Returns + ------- + array + The 'area' of each element. + """ + return self._sizes + + def set_sizes(self, sizes, dpi=72.0): + """ + Set the sizes of each member of the collection. + + Parameters + ---------- + sizes : `numpy.ndarray` or None + The size to set for each element of the collection. The + value is the 'area' of the element. + dpi : float, default: 72 + The dpi of the canvas. + """ + if sizes is None: + self._sizes = np.array([]) + self._transforms = np.empty((0, 3, 3)) + else: + self._sizes = np.asarray(sizes) + self._transforms = np.zeros((len(self._sizes), 3, 3)) + scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor + self._transforms[:, 0, 0] = scale + self._transforms[:, 1, 1] = scale + self._transforms[:, 2, 2] = 1.0 + self.stale = True + + @artist.allow_rasterization + def draw(self, renderer): + self.set_sizes(self._sizes, self.figure.dpi) + super().draw(renderer) + + +class PathCollection(_CollectionWithSizes): + r""" + A collection of `~.path.Path`\s, as created by e.g. `~.Axes.scatter`. + """ + + def __init__(self, paths, sizes=None, **kwargs): + """ + Parameters + ---------- + paths : list of `.path.Path` + The paths that will make up the `.Collection`. + sizes : array-like + The factor by which to scale each drawn `~.path.Path`. One unit + squared in the Path's data space is scaled to be ``sizes**2`` + points when rendered. + **kwargs + Forwarded to `.Collection`. + """ + + super().__init__(**kwargs) + self.set_paths(paths) + self.set_sizes(sizes) + self.stale = True + + def get_paths(self): + return self._paths + + def legend_elements(self, prop="colors", num="auto", + fmt=None, func=lambda x: x, **kwargs): + """ + Create legend handles and labels for a PathCollection. + + Each legend handle is a `.Line2D` representing the Path that was drawn, + and each label is a string that represents the Path. + + This is useful for obtaining a legend for a `~.Axes.scatter` plot; + e.g.:: + + scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3], num=None) + plt.legend(*scatter.legend_elements()) + + creates three legend elements, one for each color with the numerical + values passed to *c* as the labels. + + Also see the :ref:`automatedlegendcreation` example. + + Parameters + ---------- + prop : {"colors", "sizes"}, default: "colors" + If "colors", the legend handles will show the different colors of + the collection. If "sizes", the legend will show the different + sizes. To set both, use *kwargs* to directly edit the `.Line2D` + properties. + num : int, None, "auto" (default), array-like, or `~.ticker.Locator` + Target number of elements to create. + If None, use all unique elements of the mappable array. If an + integer, target to use *num* elements in the normed range. + If *"auto"*, try to determine which option better suits the nature + of the data. + The number of created elements may slightly deviate from *num* due + to a `~.ticker.Locator` being used to find useful locations. + If a list or array, use exactly those elements for the legend. + Finally, a `~.ticker.Locator` can be provided. + fmt : str, `~matplotlib.ticker.Formatter`, or None (default) + The format or formatter to use for the labels. If a string must be + a valid input for a `.StrMethodFormatter`. If None (the default), + use a `.ScalarFormatter`. + func : function, default: ``lambda x: x`` + Function to calculate the labels. Often the size (or color) + argument to `~.Axes.scatter` will have been pre-processed by the + user using a function ``s = f(x)`` to make the markers visible; + e.g. ``size = np.log10(x)``. Providing the inverse of this + function here allows that pre-processing to be inverted, so that + the legend labels have the correct values; e.g. ``func = lambda + x: 10**x``. + **kwargs + Allowed keyword arguments are *color* and *size*. E.g. it may be + useful to set the color of the markers if *prop="sizes"* is used; + similarly to set the size of the markers if *prop="colors"* is + used. Any further parameters are passed onto the `.Line2D` + instance. This may be useful to e.g. specify a different + *markeredgecolor* or *alpha* for the legend handles. + + Returns + ------- + handles : list of `.Line2D` + Visual representation of each element of the legend. + labels : list of str + The string labels for elements of the legend. + """ + handles = [] + labels = [] + hasarray = self.get_array() is not None + if fmt is None: + fmt = mpl.ticker.ScalarFormatter(useOffset=False, useMathText=True) + elif isinstance(fmt, str): + fmt = mpl.ticker.StrMethodFormatter(fmt) + fmt.create_dummy_axis() + + if prop == "colors": + if not hasarray: + warnings.warn("Collection without array used. Make sure to " + "specify the values to be colormapped via the " + "`c` argument.") + return handles, labels + u = np.unique(self.get_array()) + size = kwargs.pop("size", mpl.rcParams["lines.markersize"]) + elif prop == "sizes": + u = np.unique(self.get_sizes()) + color = kwargs.pop("color", "k") + else: + raise ValueError("Valid values for `prop` are 'colors' or " + f"'sizes'. You supplied '{prop}' instead.") + + fu = func(u) + fmt.axis.set_view_interval(fu.min(), fu.max()) + fmt.axis.set_data_interval(fu.min(), fu.max()) + if num == "auto": + num = 9 + if len(u) <= num: + num = None + if num is None: + values = u + label_values = func(values) + else: + if prop == "colors": + arr = self.get_array() + elif prop == "sizes": + arr = self.get_sizes() + if isinstance(num, mpl.ticker.Locator): + loc = num + elif np.iterable(num): + loc = mpl.ticker.FixedLocator(num) + else: + num = int(num) + loc = mpl.ticker.MaxNLocator(nbins=num, min_n_ticks=num-1, + steps=[1, 2, 2.5, 3, 5, 6, 8, 10]) + label_values = loc.tick_values(func(arr).min(), func(arr).max()) + cond = ((label_values >= func(arr).min()) & + (label_values <= func(arr).max())) + label_values = label_values[cond] + yarr = np.linspace(arr.min(), arr.max(), 256) + xarr = func(yarr) + ix = np.argsort(xarr) + values = np.interp(label_values, xarr[ix], yarr[ix]) + + kw = {"markeredgewidth": self.get_linewidths()[0], + "alpha": self.get_alpha(), + **kwargs} + + for val, lab in zip(values, label_values): + if prop == "colors": + color = self.cmap(self.norm(val)) + elif prop == "sizes": + size = np.sqrt(val) + if np.isclose(size, 0.0): + continue + h = mlines.Line2D([0], [0], ls="", color=color, ms=size, + marker=self.get_paths()[0], **kw) + handles.append(h) + if hasattr(fmt, "set_locs"): + fmt.set_locs(label_values) + l = fmt(lab) + labels.append(l) + + return handles, labels + + +class PolyCollection(_CollectionWithSizes): + + def __init__(self, verts, sizes=None, *, closed=True, **kwargs): + """ + Parameters + ---------- + verts : list of array-like + The sequence of polygons [*verts0*, *verts1*, ...] where each + element *verts_i* defines the vertices of polygon *i* as a 2D + array-like of shape (M, 2). + sizes : array-like, default: None + Squared scaling factors for the polygons. The coordinates of each + polygon *verts_i* are multiplied by the square-root of the + corresponding entry in *sizes* (i.e., *sizes* specify the scaling + of areas). The scaling is applied before the Artist master + transform. + closed : bool, default: True + Whether the polygon should be closed by adding a CLOSEPOLY + connection at the end. + **kwargs + Forwarded to `.Collection`. + """ + super().__init__(**kwargs) + self.set_sizes(sizes) + self.set_verts(verts, closed) + self.stale = True + + def set_verts(self, verts, closed=True): + """ + Set the vertices of the polygons. + + Parameters + ---------- + verts : list of array-like + The sequence of polygons [*verts0*, *verts1*, ...] where each + element *verts_i* defines the vertices of polygon *i* as a 2D + array-like of shape (M, 2). + closed : bool, default: True + Whether the polygon should be closed by adding a CLOSEPOLY + connection at the end. + """ + self.stale = True + if isinstance(verts, np.ma.MaskedArray): + verts = verts.astype(float).filled(np.nan) + + # No need to do anything fancy if the path isn't closed. + if not closed: + self._paths = [mpath.Path(xy) for xy in verts] + return + + # Fast path for arrays + if isinstance(verts, np.ndarray) and len(verts.shape) == 3: + verts_pad = np.concatenate((verts, verts[:, :1]), axis=1) + # Creating the codes once is much faster than having Path do it + # separately each time by passing closed=True. + codes = np.empty(verts_pad.shape[1], dtype=mpath.Path.code_type) + codes[:] = mpath.Path.LINETO + codes[0] = mpath.Path.MOVETO + codes[-1] = mpath.Path.CLOSEPOLY + self._paths = [mpath.Path(xy, codes) for xy in verts_pad] + return + + self._paths = [] + for xy in verts: + if len(xy): + self._paths.append(mpath.Path._create_closed(xy)) + else: + self._paths.append(mpath.Path(xy)) + + set_paths = set_verts + + def set_verts_and_codes(self, verts, codes): + """Initialize vertices with path codes.""" + if len(verts) != len(codes): + raise ValueError("'codes' must be a 1D list or array " + "with the same length of 'verts'") + self._paths = [mpath.Path(xy, cds) if len(xy) else mpath.Path(xy) + for xy, cds in zip(verts, codes)] + self.stale = True + + +class RegularPolyCollection(_CollectionWithSizes): + """A collection of n-sided regular polygons.""" + + _path_generator = mpath.Path.unit_regular_polygon + _factor = np.pi ** (-1/2) + + def __init__(self, + numsides, + *, + rotation=0, + sizes=(1,), + **kwargs): + """ + Parameters + ---------- + numsides : int + The number of sides of the polygon. + rotation : float + The rotation of the polygon in radians. + sizes : tuple of float + The area of the circle circumscribing the polygon in points^2. + **kwargs + Forwarded to `.Collection`. + + Examples + -------- + See :doc:`/gallery/event_handling/lasso_demo` for a complete example:: + + offsets = np.random.rand(20, 2) + facecolors = [cm.jet(x) for x in np.random.rand(20)] + + collection = RegularPolyCollection( + numsides=5, # a pentagon + rotation=0, sizes=(50,), + facecolors=facecolors, + edgecolors=("black",), + linewidths=(1,), + offsets=offsets, + offset_transform=ax.transData, + ) + """ + super().__init__(**kwargs) + self.set_sizes(sizes) + self._numsides = numsides + self._paths = [self._path_generator(numsides)] + self._rotation = rotation + self.set_transform(transforms.IdentityTransform()) + + def get_numsides(self): + return self._numsides + + def get_rotation(self): + return self._rotation + + @artist.allow_rasterization + def draw(self, renderer): + self.set_sizes(self._sizes, self.figure.dpi) + self._transforms = [ + transforms.Affine2D(x).rotate(-self._rotation).get_matrix() + for x in self._transforms + ] + # Explicitly not super().draw, because set_sizes must be called before + # updating self._transforms. + Collection.draw(self, renderer) + + +class StarPolygonCollection(RegularPolyCollection): + """Draw a collection of regular stars with *numsides* points.""" + _path_generator = mpath.Path.unit_regular_star + + +class AsteriskPolygonCollection(RegularPolyCollection): + """Draw a collection of regular asterisks with *numsides* points.""" + _path_generator = mpath.Path.unit_regular_asterisk + + +class LineCollection(Collection): + r""" + Represents a sequence of `.Line2D`\s that should be drawn together. + + This class extends `.Collection` to represent a sequence of + `.Line2D`\s instead of just a sequence of `.Patch`\s. + Just as in `.Collection`, each property of a *LineCollection* may be either + a single value or a list of values. This list is then used cyclically for + each element of the LineCollection, so the property of the ``i``\th element + of the collection is:: + + prop[i % len(prop)] + + The properties of each member of a *LineCollection* default to their values + in :rc:`lines.*` instead of :rc:`patch.*`, and the property *colors* is + added in place of *edgecolors*. + """ + + _edge_default = True + + def __init__(self, segments, # Can be None. + *, + zorder=2, # Collection.zorder is 1 + **kwargs + ): + """ + Parameters + ---------- + segments : list of array-like + A sequence (*line0*, *line1*, *line2*) of lines, where each line is a list + of points:: + + lineN = [(x0, y0), (x1, y1), ... (xm, ym)] + + or the equivalent Mx2 numpy array with two columns. Each line + can have a different number of segments. + linewidths : float or list of float, default: :rc:`lines.linewidth` + The width of each line in points. + colors : :mpltype:`color` or list of color, default: :rc:`lines.color` + A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not + allowed). + antialiaseds : bool or list of bool, default: :rc:`lines.antialiased` + Whether to use antialiasing for each line. + zorder : float, default: 2 + zorder of the lines once drawn. + + facecolors : :mpltype:`color` or list of :mpltype:`color`, default: 'none' + When setting *facecolors*, each line is interpreted as a boundary + for an area, implicitly closing the path from the last point to the + first point. The enclosed area is filled with *facecolor*. + In order to manually specify what should count as the "interior" of + each line, please use `.PathCollection` instead, where the + "interior" can be specified by appropriate usage of + `~.path.Path.CLOSEPOLY`. + + **kwargs + Forwarded to `.Collection`. + """ + # Unfortunately, mplot3d needs this explicit setting of 'facecolors'. + kwargs.setdefault('facecolors', 'none') + super().__init__( + zorder=zorder, + **kwargs) + self.set_segments(segments) + + def set_segments(self, segments): + if segments is None: + return + + self._paths = [mpath.Path(seg) if isinstance(seg, np.ma.MaskedArray) + else mpath.Path(np.asarray(seg, float)) + for seg in segments] + self.stale = True + + set_verts = set_segments # for compatibility with PolyCollection + set_paths = set_segments + + def get_segments(self): + """ + Returns + ------- + list + List of segments in the LineCollection. Each list item contains an + array of vertices. + """ + segments = [] + + for path in self._paths: + vertices = [ + vertex + for vertex, _ + # Never simplify here, we want to get the data-space values + # back and there in no way to know the "right" simplification + # threshold so never try. + in path.iter_segments(simplify=False) + ] + vertices = np.asarray(vertices) + segments.append(vertices) + + return segments + + def _get_default_linewidth(self): + return mpl.rcParams['lines.linewidth'] + + def _get_default_antialiased(self): + return mpl.rcParams['lines.antialiased'] + + def _get_default_edgecolor(self): + return mpl.rcParams['lines.color'] + + def _get_default_facecolor(self): + return 'none' + + def set_alpha(self, alpha): + # docstring inherited + super().set_alpha(alpha) + if self._gapcolor is not None: + self.set_gapcolor(self._original_gapcolor) + + def set_color(self, c): + """ + Set the edgecolor(s) of the LineCollection. + + Parameters + ---------- + c : :mpltype:`color` or list of :mpltype:`color` + Single color (all lines have same color), or a + sequence of RGBA tuples; if it is a sequence the lines will + cycle through the sequence. + """ + self.set_edgecolor(c) + + set_colors = set_color + + def get_color(self): + return self._edgecolors + + get_colors = get_color # for compatibility with old versions + + def set_gapcolor(self, gapcolor): + """ + Set a color to fill the gaps in the dashed line style. + + .. note:: + + Striped lines are created by drawing two interleaved dashed lines. + There can be overlaps between those two, which may result in + artifacts when using transparency. + + This functionality is experimental and may change. + + Parameters + ---------- + gapcolor : :mpltype:`color` or list of :mpltype:`color` or None + The color with which to fill the gaps. If None, the gaps are + unfilled. + """ + self._original_gapcolor = gapcolor + self._set_gapcolor(gapcolor) + + def _set_gapcolor(self, gapcolor): + if gapcolor is not None: + gapcolor = mcolors.to_rgba_array(gapcolor, self._alpha) + self._gapcolor = gapcolor + self.stale = True + + def get_gapcolor(self): + return self._gapcolor + + def _get_inverse_paths_linestyles(self): + """ + Returns the path and pattern for the gaps in the non-solid lines. + + This path and pattern is the inverse of the path and pattern used to + construct the non-solid lines. For solid lines, we set the inverse path + to nans to prevent drawing an inverse line. + """ + path_patterns = [ + (mpath.Path(np.full((1, 2), np.nan)), ls) + if ls == (0, None) else + (path, mlines._get_inverse_dash_pattern(*ls)) + for (path, ls) in + zip(self._paths, itertools.cycle(self._linestyles))] + + return zip(*path_patterns) + + +class EventCollection(LineCollection): + """ + A collection of locations along a single axis at which an "event" occurred. + + The events are given by a 1-dimensional array. They do not have an + amplitude and are displayed as parallel lines. + """ + + _edge_default = True + + def __init__(self, + positions, # Cannot be None. + orientation='horizontal', + *, + lineoffset=0, + linelength=1, + linewidth=None, + color=None, + linestyle='solid', + antialiased=None, + **kwargs + ): + """ + Parameters + ---------- + positions : 1D array-like + Each value is an event. + orientation : {'horizontal', 'vertical'}, default: 'horizontal' + The sequence of events is plotted along this direction. + The marker lines of the single events are along the orthogonal + direction. + lineoffset : float, default: 0 + The offset of the center of the markers from the origin, in the + direction orthogonal to *orientation*. + linelength : float, default: 1 + The total height of the marker (i.e. the marker stretches from + ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``). + linewidth : float or list thereof, default: :rc:`lines.linewidth` + The line width of the event lines, in points. + color : :mpltype:`color` or list of :mpltype:`color`, default: :rc:`lines.color` + The color of the event lines. + linestyle : str or tuple or list thereof, default: 'solid' + Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', + '-', '--', '-.', ':']. Dash tuples should be of the form:: + + (offset, onoffseq), + + where *onoffseq* is an even length tuple of on and off ink + in points. + antialiased : bool or list thereof, default: :rc:`lines.antialiased` + Whether to use antialiasing for drawing the lines. + **kwargs + Forwarded to `.LineCollection`. + + Examples + -------- + .. plot:: gallery/lines_bars_and_markers/eventcollection_demo.py + """ + super().__init__([], + linewidths=linewidth, linestyles=linestyle, + colors=color, antialiaseds=antialiased, + **kwargs) + self._is_horizontal = True # Initial value, may be switched below. + self._linelength = linelength + self._lineoffset = lineoffset + self.set_orientation(orientation) + self.set_positions(positions) + + def get_positions(self): + """ + Return an array containing the floating-point values of the positions. + """ + pos = 0 if self.is_horizontal() else 1 + return [segment[0, pos] for segment in self.get_segments()] + + def set_positions(self, positions): + """Set the positions of the events.""" + if positions is None: + positions = [] + if np.ndim(positions) != 1: + raise ValueError('positions must be one-dimensional') + lineoffset = self.get_lineoffset() + linelength = self.get_linelength() + pos_idx = 0 if self.is_horizontal() else 1 + segments = np.empty((len(positions), 2, 2)) + segments[:, :, pos_idx] = np.sort(positions)[:, None] + segments[:, 0, 1 - pos_idx] = lineoffset + linelength / 2 + segments[:, 1, 1 - pos_idx] = lineoffset - linelength / 2 + self.set_segments(segments) + + def add_positions(self, position): + """Add one or more events at the specified positions.""" + if position is None or (hasattr(position, 'len') and + len(position) == 0): + return + positions = self.get_positions() + positions = np.hstack([positions, np.asanyarray(position)]) + self.set_positions(positions) + extend_positions = append_positions = add_positions + + def is_horizontal(self): + """True if the eventcollection is horizontal, False if vertical.""" + return self._is_horizontal + + def get_orientation(self): + """ + Return the orientation of the event line ('horizontal' or 'vertical'). + """ + return 'horizontal' if self.is_horizontal() else 'vertical' + + def switch_orientation(self): + """ + Switch the orientation of the event line, either from vertical to + horizontal or vice versus. + """ + segments = self.get_segments() + for i, segment in enumerate(segments): + segments[i] = np.fliplr(segment) + self.set_segments(segments) + self._is_horizontal = not self.is_horizontal() + self.stale = True + + def set_orientation(self, orientation): + """ + Set the orientation of the event line. + + Parameters + ---------- + orientation : {'horizontal', 'vertical'} + """ + is_horizontal = _api.check_getitem( + {"horizontal": True, "vertical": False}, + orientation=orientation) + if is_horizontal == self.is_horizontal(): + return + self.switch_orientation() + + def get_linelength(self): + """Return the length of the lines used to mark each event.""" + return self._linelength + + def set_linelength(self, linelength): + """Set the length of the lines used to mark each event.""" + if linelength == self.get_linelength(): + return + lineoffset = self.get_lineoffset() + segments = self.get_segments() + pos = 1 if self.is_horizontal() else 0 + for segment in segments: + segment[0, pos] = lineoffset + linelength / 2. + segment[1, pos] = lineoffset - linelength / 2. + self.set_segments(segments) + self._linelength = linelength + + def get_lineoffset(self): + """Return the offset of the lines used to mark each event.""" + return self._lineoffset + + def set_lineoffset(self, lineoffset): + """Set the offset of the lines used to mark each event.""" + if lineoffset == self.get_lineoffset(): + return + linelength = self.get_linelength() + segments = self.get_segments() + pos = 1 if self.is_horizontal() else 0 + for segment in segments: + segment[0, pos] = lineoffset + linelength / 2. + segment[1, pos] = lineoffset - linelength / 2. + self.set_segments(segments) + self._lineoffset = lineoffset + + def get_linewidth(self): + """Get the width of the lines used to mark each event.""" + return super().get_linewidth()[0] + + def get_linewidths(self): + return super().get_linewidth() + + def get_color(self): + """Return the color of the lines used to mark each event.""" + return self.get_colors()[0] + + +class CircleCollection(_CollectionWithSizes): + """A collection of circles, drawn using splines.""" + + _factor = np.pi ** (-1/2) + + def __init__(self, sizes, **kwargs): + """ + Parameters + ---------- + sizes : float or array-like + The area of each circle in points^2. + **kwargs + Forwarded to `.Collection`. + """ + super().__init__(**kwargs) + self.set_sizes(sizes) + self.set_transform(transforms.IdentityTransform()) + self._paths = [mpath.Path.unit_circle()] + + +class EllipseCollection(Collection): + """A collection of ellipses, drawn using splines.""" + + def __init__(self, widths, heights, angles, *, units='points', **kwargs): + """ + Parameters + ---------- + widths : array-like + The lengths of the first axes (e.g., major axis lengths). + heights : array-like + The lengths of second axes. + angles : array-like + The angles of the first axes, degrees CCW from the x-axis. + units : {'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'} + The units in which majors and minors are given; 'width' and + 'height' refer to the dimensions of the axes, while 'x' and 'y' + refer to the *offsets* data units. 'xy' differs from all others in + that the angle as plotted varies with the aspect ratio, and equals + the specified angle only when the aspect ratio is unity. Hence + it behaves the same as the `~.patches.Ellipse` with + ``axes.transData`` as its transform. + **kwargs + Forwarded to `Collection`. + """ + super().__init__(**kwargs) + self.set_widths(widths) + self.set_heights(heights) + self.set_angles(angles) + self._units = units + self.set_transform(transforms.IdentityTransform()) + self._transforms = np.empty((0, 3, 3)) + self._paths = [mpath.Path.unit_circle()] + + def _set_transforms(self): + """Calculate transforms immediately before drawing.""" + + ax = self.axes + fig = self.figure + + if self._units == 'xy': + sc = 1 + elif self._units == 'x': + sc = ax.bbox.width / ax.viewLim.width + elif self._units == 'y': + sc = ax.bbox.height / ax.viewLim.height + elif self._units == 'inches': + sc = fig.dpi + elif self._units == 'points': + sc = fig.dpi / 72.0 + elif self._units == 'width': + sc = ax.bbox.width + elif self._units == 'height': + sc = ax.bbox.height + elif self._units == 'dots': + sc = 1.0 + else: + raise ValueError(f'Unrecognized units: {self._units!r}') + + self._transforms = np.zeros((len(self._widths), 3, 3)) + widths = self._widths * sc + heights = self._heights * sc + sin_angle = np.sin(self._angles) + cos_angle = np.cos(self._angles) + self._transforms[:, 0, 0] = widths * cos_angle + self._transforms[:, 0, 1] = heights * -sin_angle + self._transforms[:, 1, 0] = widths * sin_angle + self._transforms[:, 1, 1] = heights * cos_angle + self._transforms[:, 2, 2] = 1.0 + + _affine = transforms.Affine2D + if self._units == 'xy': + m = ax.transData.get_affine().get_matrix().copy() + m[:2, 2:] = 0 + self.set_transform(_affine(m)) + + def set_widths(self, widths): + """Set the lengths of the first axes (e.g., major axis).""" + self._widths = 0.5 * np.asarray(widths).ravel() + self.stale = True + + def set_heights(self, heights): + """Set the lengths of second axes (e.g., minor axes).""" + self._heights = 0.5 * np.asarray(heights).ravel() + self.stale = True + + def set_angles(self, angles): + """Set the angles of the first axes, degrees CCW from the x-axis.""" + self._angles = np.deg2rad(angles).ravel() + self.stale = True + + def get_widths(self): + """Get the lengths of the first axes (e.g., major axis).""" + return self._widths * 2 + + def get_heights(self): + """Set the lengths of second axes (e.g., minor axes).""" + return self._heights * 2 + + def get_angles(self): + """Get the angles of the first axes, degrees CCW from the x-axis.""" + return np.rad2deg(self._angles) + + @artist.allow_rasterization + def draw(self, renderer): + self._set_transforms() + super().draw(renderer) + + +class PatchCollection(Collection): + """ + A generic collection of patches. + + PatchCollection draws faster than a large number of equivalent individual + Patches. It also makes it easier to assign a colormap to a heterogeneous + collection of patches. + """ + + def __init__(self, patches, *, match_original=False, **kwargs): + """ + Parameters + ---------- + patches : list of `.Patch` + A sequence of Patch objects. This list may include + a heterogeneous assortment of different patch types. + + match_original : bool, default: False + If True, use the colors and linewidths of the original + patches. If False, new colors may be assigned by + providing the standard collection arguments, facecolor, + edgecolor, linewidths, norm or cmap. + + **kwargs + All other parameters are forwarded to `.Collection`. + + If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds* + are None, they default to their `.rcParams` patch setting, in + sequence form. + + Notes + ----- + The use of `~matplotlib.cm.ScalarMappable` functionality is optional. + If the `~matplotlib.cm.ScalarMappable` matrix ``_A`` has been set (via + a call to `~.ScalarMappable.set_array`), at draw time a call to scalar + mappable will be made to set the face colors. + """ + + if match_original: + def determine_facecolor(patch): + if patch.get_fill(): + return patch.get_facecolor() + return [0, 0, 0, 0] + + kwargs['facecolors'] = [determine_facecolor(p) for p in patches] + kwargs['edgecolors'] = [p.get_edgecolor() for p in patches] + kwargs['linewidths'] = [p.get_linewidth() for p in patches] + kwargs['linestyles'] = [p.get_linestyle() for p in patches] + kwargs['antialiaseds'] = [p.get_antialiased() for p in patches] + + super().__init__(**kwargs) + + self.set_paths(patches) + + def set_paths(self, patches): + paths = [p.get_transform().transform_path(p.get_path()) + for p in patches] + self._paths = paths + + +class TriMesh(Collection): + """ + Class for the efficient drawing of a triangular mesh using Gouraud shading. + + A triangular mesh is a `~matplotlib.tri.Triangulation` object. + """ + def __init__(self, triangulation, **kwargs): + super().__init__(**kwargs) + self._triangulation = triangulation + self._shading = 'gouraud' + + self._bbox = transforms.Bbox.unit() + + # Unfortunately this requires a copy, unless Triangulation + # was rewritten. + xy = np.hstack((triangulation.x.reshape(-1, 1), + triangulation.y.reshape(-1, 1))) + self._bbox.update_from_data_xy(xy) + + def get_paths(self): + if self._paths is None: + self.set_paths() + return self._paths + + def set_paths(self): + self._paths = self.convert_mesh_to_paths(self._triangulation) + + @staticmethod + def convert_mesh_to_paths(tri): + """ + Convert a given mesh into a sequence of `.Path` objects. + + This function is primarily of use to implementers of backends that do + not directly support meshes. + """ + triangles = tri.get_masked_triangles() + verts = np.stack((tri.x[triangles], tri.y[triangles]), axis=-1) + return [mpath.Path(x) for x in verts] + + @artist.allow_rasterization + def draw(self, renderer): + if not self.get_visible(): + return + renderer.open_group(self.__class__.__name__, gid=self.get_gid()) + transform = self.get_transform() + + # Get a list of triangles and the color at each vertex. + tri = self._triangulation + triangles = tri.get_masked_triangles() + + verts = np.stack((tri.x[triangles], tri.y[triangles]), axis=-1) + + self.update_scalarmappable() + colors = self._facecolors[triangles] + + gc = renderer.new_gc() + self._set_gc_clip(gc) + gc.set_linewidth(self.get_linewidth()[0]) + renderer.draw_gouraud_triangles(gc, verts, colors, transform.frozen()) + gc.restore() + renderer.close_group(self.__class__.__name__) + + +class _MeshData: + r""" + Class for managing the two dimensional coordinates of Quadrilateral meshes + and the associated data with them. This class is a mixin and is intended to + be used with another collection that will implement the draw separately. + + A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are + defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is + defined by the vertices :: + + (m+1, n) ----------- (m+1, n+1) + / / + / / + / / + (m, n) -------- (m, n+1) + + The mesh need not be regular and the polygons need not be convex. + + Parameters + ---------- + coordinates : (M+1, N+1, 2) array-like + The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates + of vertex (m, n). + + shading : {'flat', 'gouraud'}, default: 'flat' + """ + def __init__(self, coordinates, *, shading='flat'): + _api.check_shape((None, None, 2), coordinates=coordinates) + self._coordinates = coordinates + self._shading = shading + + def set_array(self, A): + """ + Set the data values. + + Parameters + ---------- + A : array-like + The mesh data. Supported array shapes are: + + - (M, N) or (M*N,): a mesh with scalar data. The values are mapped + to colors using normalization and a colormap. See parameters + *norm*, *cmap*, *vmin*, *vmax*. + - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). + - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), + i.e. including transparency. + + If the values are provided as a 2D grid, the shape must match the + coordinates grid. If the values are 1D, they are reshaped to 2D. + M, N follow from the coordinates grid, where the coordinates grid + shape is (M, N) for 'gouraud' *shading* and (M+1, N+1) for 'flat' + shading. + """ + height, width = self._coordinates.shape[0:-1] + if self._shading == 'flat': + h, w = height - 1, width - 1 + else: + h, w = height, width + ok_shapes = [(h, w, 3), (h, w, 4), (h, w), (h * w,)] + if A is not None: + shape = np.shape(A) + if shape not in ok_shapes: + raise ValueError( + f"For X ({width}) and Y ({height}) with {self._shading} " + f"shading, A should have shape " + f"{' or '.join(map(str, ok_shapes))}, not {A.shape}") + return super().set_array(A) + + def get_coordinates(self): + """ + Return the vertices of the mesh as an (M+1, N+1, 2) array. + + M, N are the number of quadrilaterals in the rows / columns of the + mesh, corresponding to (M+1, N+1) vertices. + The last dimension specifies the components (x, y). + """ + return self._coordinates + + def get_edgecolor(self): + # docstring inherited + # Note that we want to return an array of shape (N*M, 4) + # a flattened RGBA collection + return super().get_edgecolor().reshape(-1, 4) + + def get_facecolor(self): + # docstring inherited + # Note that we want to return an array of shape (N*M, 4) + # a flattened RGBA collection + return super().get_facecolor().reshape(-1, 4) + + @staticmethod + def _convert_mesh_to_paths(coordinates): + """ + Convert a given mesh into a sequence of `.Path` objects. + + This function is primarily of use to implementers of backends that do + not directly support quadmeshes. + """ + if isinstance(coordinates, np.ma.MaskedArray): + c = coordinates.data + else: + c = coordinates + points = np.concatenate([ + c[:-1, :-1], + c[:-1, 1:], + c[1:, 1:], + c[1:, :-1], + c[:-1, :-1] + ], axis=2).reshape((-1, 5, 2)) + return [mpath.Path(x) for x in points] + + def _convert_mesh_to_triangles(self, coordinates): + """ + Convert a given mesh into a sequence of triangles, each point + with its own color. The result can be used to construct a call to + `~.RendererBase.draw_gouraud_triangles`. + """ + if isinstance(coordinates, np.ma.MaskedArray): + p = coordinates.data + else: + p = coordinates + + p_a = p[:-1, :-1] + p_b = p[:-1, 1:] + p_c = p[1:, 1:] + p_d = p[1:, :-1] + p_center = (p_a + p_b + p_c + p_d) / 4.0 + triangles = np.concatenate([ + p_a, p_b, p_center, + p_b, p_c, p_center, + p_c, p_d, p_center, + p_d, p_a, p_center, + ], axis=2).reshape((-1, 3, 2)) + + c = self.get_facecolor().reshape((*coordinates.shape[:2], 4)) + z = self.get_array() + mask = z.mask if np.ma.is_masked(z) else None + if mask is not None: + c[mask, 3] = np.nan + c_a = c[:-1, :-1] + c_b = c[:-1, 1:] + c_c = c[1:, 1:] + c_d = c[1:, :-1] + c_center = (c_a + c_b + c_c + c_d) / 4.0 + colors = np.concatenate([ + c_a, c_b, c_center, + c_b, c_c, c_center, + c_c, c_d, c_center, + c_d, c_a, c_center, + ], axis=2).reshape((-1, 3, 4)) + tmask = np.isnan(colors[..., 2, 3]) + return triangles[~tmask], colors[~tmask] + + +class QuadMesh(_MeshData, Collection): + r""" + Class for the efficient drawing of a quadrilateral mesh. + + A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are + defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is + defined by the vertices :: + + (m+1, n) ----------- (m+1, n+1) + / / + / / + / / + (m, n) -------- (m, n+1) + + The mesh need not be regular and the polygons need not be convex. + + Parameters + ---------- + coordinates : (M+1, N+1, 2) array-like + The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates + of vertex (m, n). + + antialiased : bool, default: True + + shading : {'flat', 'gouraud'}, default: 'flat' + + Notes + ----- + Unlike other `.Collection`\s, the default *pickradius* of `.QuadMesh` is 0, + i.e. `~.Artist.contains` checks whether the test point is within any of the + mesh quadrilaterals. + + """ + + def __init__(self, coordinates, *, antialiased=True, shading='flat', + **kwargs): + kwargs.setdefault("pickradius", 0) + super().__init__(coordinates=coordinates, shading=shading) + Collection.__init__(self, **kwargs) + + self._antialiased = antialiased + self._bbox = transforms.Bbox.unit() + self._bbox.update_from_data_xy(self._coordinates.reshape(-1, 2)) + self.set_mouseover(False) + + def get_paths(self): + if self._paths is None: + self.set_paths() + return self._paths + + def set_paths(self): + self._paths = self._convert_mesh_to_paths(self._coordinates) + self.stale = True + + def get_datalim(self, transData): + return (self.get_transform() - transData).transform_bbox(self._bbox) + + @artist.allow_rasterization + def draw(self, renderer): + if not self.get_visible(): + return + renderer.open_group(self.__class__.__name__, self.get_gid()) + transform = self.get_transform() + offset_trf = self.get_offset_transform() + offsets = self.get_offsets() + + if self.have_units(): + xs = self.convert_xunits(offsets[:, 0]) + ys = self.convert_yunits(offsets[:, 1]) + offsets = np.column_stack([xs, ys]) + + self.update_scalarmappable() + + if not transform.is_affine: + coordinates = self._coordinates.reshape((-1, 2)) + coordinates = transform.transform(coordinates) + coordinates = coordinates.reshape(self._coordinates.shape) + transform = transforms.IdentityTransform() + else: + coordinates = self._coordinates + + if not offset_trf.is_affine: + offsets = offset_trf.transform_non_affine(offsets) + offset_trf = offset_trf.get_affine() + + gc = renderer.new_gc() + gc.set_snap(self.get_snap()) + self._set_gc_clip(gc) + gc.set_linewidth(self.get_linewidth()[0]) + + if self._shading == 'gouraud': + triangles, colors = self._convert_mesh_to_triangles(coordinates) + renderer.draw_gouraud_triangles( + gc, triangles, colors, transform.frozen()) + else: + renderer.draw_quad_mesh( + gc, transform.frozen(), + coordinates.shape[1] - 1, coordinates.shape[0] - 1, + coordinates, offsets, offset_trf, + # Backends expect flattened rgba arrays (n*m, 4) for fc and ec + self.get_facecolor().reshape((-1, 4)), + self._antialiased, self.get_edgecolors().reshape((-1, 4))) + gc.restore() + renderer.close_group(self.__class__.__name__) + self.stale = False + + def get_cursor_data(self, event): + contained, info = self.contains(event) + if contained and self.get_array() is not None: + return self.get_array().ravel()[info["ind"]] + return None + + +class PolyQuadMesh(_MeshData, PolyCollection): + """ + Class for drawing a quadrilateral mesh as individual Polygons. + + A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are + defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is + defined by the vertices :: + + (m+1, n) ----------- (m+1, n+1) + / / + / / + / / + (m, n) -------- (m, n+1) + + The mesh need not be regular and the polygons need not be convex. + + Parameters + ---------- + coordinates : (M+1, N+1, 2) array-like + The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates + of vertex (m, n). + + Notes + ----- + Unlike `.QuadMesh`, this class will draw each cell as an individual Polygon. + This is significantly slower, but allows for more flexibility when wanting + to add additional properties to the cells, such as hatching. + + Another difference from `.QuadMesh` is that if any of the vertices or data + of a cell are masked, that Polygon will **not** be drawn and it won't be in + the list of paths returned. + """ + + def __init__(self, coordinates, **kwargs): + # We need to keep track of whether we are using deprecated compression + # Update it after the initializers + self._deprecated_compression = False + super().__init__(coordinates=coordinates) + PolyCollection.__init__(self, verts=[], **kwargs) + # Store this during the compression deprecation period + self._original_mask = ~self._get_unmasked_polys() + self._deprecated_compression = np.any(self._original_mask) + # Setting the verts updates the paths of the PolyCollection + # This is called after the initializers to make sure the kwargs + # have all been processed and available for the masking calculations + self._set_unmasked_verts() + + def _get_unmasked_polys(self): + """Get the unmasked regions using the coordinates and array""" + # mask(X) | mask(Y) + mask = np.any(np.ma.getmaskarray(self._coordinates), axis=-1) + + # We want the shape of the polygon, which is the corner of each X/Y array + mask = (mask[0:-1, 0:-1] | mask[1:, 1:] | mask[0:-1, 1:] | mask[1:, 0:-1]) + + if (getattr(self, "_deprecated_compression", False) and + np.any(self._original_mask)): + return ~(mask | self._original_mask) + # Take account of the array data too, temporarily avoiding + # the compression warning and resetting the variable after the call + with cbook._setattr_cm(self, _deprecated_compression=False): + arr = self.get_array() + if arr is not None: + arr = np.ma.getmaskarray(arr) + if arr.ndim == 3: + # RGB(A) case + mask |= np.any(arr, axis=-1) + elif arr.ndim == 2: + mask |= arr + else: + mask |= arr.reshape(self._coordinates[:-1, :-1, :].shape[:2]) + return ~mask + + def _set_unmasked_verts(self): + X = self._coordinates[..., 0] + Y = self._coordinates[..., 1] + + unmask = self._get_unmasked_polys() + X1 = np.ma.filled(X[:-1, :-1])[unmask] + Y1 = np.ma.filled(Y[:-1, :-1])[unmask] + X2 = np.ma.filled(X[1:, :-1])[unmask] + Y2 = np.ma.filled(Y[1:, :-1])[unmask] + X3 = np.ma.filled(X[1:, 1:])[unmask] + Y3 = np.ma.filled(Y[1:, 1:])[unmask] + X4 = np.ma.filled(X[:-1, 1:])[unmask] + Y4 = np.ma.filled(Y[:-1, 1:])[unmask] + npoly = len(X1) + + xy = np.ma.stack([X1, Y1, X2, Y2, X3, Y3, X4, Y4, X1, Y1], axis=-1) + verts = xy.reshape((npoly, 5, 2)) + self.set_verts(verts) + + def get_edgecolor(self): + # docstring inherited + # We only want to return the facecolors of the polygons + # that were drawn. + ec = super().get_edgecolor() + unmasked_polys = self._get_unmasked_polys().ravel() + if len(ec) != len(unmasked_polys): + # Mapping is off + return ec + return ec[unmasked_polys, :] + + def get_facecolor(self): + # docstring inherited + # We only want to return the facecolors of the polygons + # that were drawn. + fc = super().get_facecolor() + unmasked_polys = self._get_unmasked_polys().ravel() + if len(fc) != len(unmasked_polys): + # Mapping is off + return fc + return fc[unmasked_polys, :] + + def set_array(self, A): + # docstring inherited + prev_unmask = self._get_unmasked_polys() + # MPL <3.8 compressed the mask, so we need to handle flattened 1d input + # until the deprecation expires, also only warning when there are masked + # elements and thus compression occurring. + if self._deprecated_compression and np.ndim(A) == 1: + _api.warn_deprecated("3.8", message="Setting a PolyQuadMesh array using " + "the compressed values is deprecated. " + "Pass the full 2D shape of the original array " + f"{prev_unmask.shape} including the masked elements.") + Afull = np.empty(self._original_mask.shape) + Afull[~self._original_mask] = A + # We also want to update the mask with any potential + # new masked elements that came in. But, we don't want + # to update any of the compression from the original + mask = self._original_mask.copy() + mask[~self._original_mask] |= np.ma.getmask(A) + A = np.ma.array(Afull, mask=mask) + return super().set_array(A) + self._deprecated_compression = False + super().set_array(A) + # If the mask has changed at all we need to update + # the set of Polys that we are drawing + if not np.array_equal(prev_unmask, self._get_unmasked_polys()): + self._set_unmasked_verts() + + def get_array(self): + # docstring inherited + # Can remove this entire function once the deprecation period ends + A = super().get_array() + if A is None: + return + if self._deprecated_compression and np.any(np.ma.getmask(A)): + _api.warn_deprecated("3.8", message=( + "Getting the array from a PolyQuadMesh will return the full " + "array in the future (uncompressed). To get this behavior now " + "set the PolyQuadMesh with a 2D array .set_array(data2d).")) + # Setting an array of a polycollection required + # compressing the array + return np.ma.compressed(A) + return A diff --git a/venv/lib/python3.10/site-packages/matplotlib/collections.pyi b/venv/lib/python3.10/site-packages/matplotlib/collections.pyi new file mode 100644 index 00000000..e4c46229 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/collections.pyi @@ -0,0 +1,236 @@ +from collections.abc import Callable, Iterable, Sequence +from typing import Literal + +import numpy as np +from numpy.typing import ArrayLike, NDArray + +from . import artist, cm, transforms +from .backend_bases import MouseEvent +from .artist import Artist +from .colors import Normalize, Colormap +from .lines import Line2D +from .path import Path +from .patches import Patch +from .ticker import Locator, Formatter +from .tri import Triangulation +from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType + +class Collection(artist.Artist, cm.ScalarMappable): + def __init__( + self, + *, + edgecolors: ColorType | Sequence[ColorType] | None = ..., + facecolors: ColorType | Sequence[ColorType] | None = ..., + linewidths: float | Sequence[float] | None = ..., + linestyles: LineStyleType | Sequence[LineStyleType] = ..., + capstyle: CapStyleType | None = ..., + joinstyle: JoinStyleType | None = ..., + antialiaseds: bool | Sequence[bool] | None = ..., + offsets: tuple[float, float] | Sequence[tuple[float, float]] | None = ..., + offset_transform: transforms.Transform | None = ..., + norm: Normalize | None = ..., + cmap: Colormap | None = ..., + pickradius: float = ..., + hatch: str | None = ..., + urls: Sequence[str] | None = ..., + zorder: float = ..., + **kwargs + ) -> None: ... + def get_paths(self) -> Sequence[Path]: ... + def set_paths(self, paths: Sequence[Path]) -> None: ... + def get_transforms(self) -> Sequence[transforms.Transform]: ... + def get_offset_transform(self) -> transforms.Transform: ... + def set_offset_transform(self, offset_transform: transforms.Transform) -> None: ... + def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ... + def set_pickradius(self, pickradius: float) -> None: ... + def get_pickradius(self) -> float: ... + def set_urls(self, urls: Sequence[str | None]) -> None: ... + def get_urls(self) -> Sequence[str | None]: ... + def set_hatch(self, hatch: str) -> None: ... + def get_hatch(self) -> str: ... + def set_offsets(self, offsets: ArrayLike) -> None: ... + def get_offsets(self) -> ArrayLike: ... + def set_linewidth(self, lw: float | Sequence[float]) -> None: ... + def set_linestyle(self, ls: LineStyleType | Sequence[LineStyleType]) -> None: ... + def set_capstyle(self, cs: CapStyleType) -> None: ... + def get_capstyle(self) -> Literal["butt", "projecting", "round"] | None: ... + def set_joinstyle(self, js: JoinStyleType) -> None: ... + def get_joinstyle(self) -> Literal["miter", "round", "bevel"] | None: ... + def set_antialiased(self, aa: bool | Sequence[bool]) -> None: ... + def get_antialiased(self) -> NDArray[np.bool_]: ... + def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ... + def set_facecolor(self, c: ColorType | Sequence[ColorType]) -> None: ... + def get_facecolor(self) -> ColorType | Sequence[ColorType]: ... + def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ... + def set_edgecolor(self, c: ColorType | Sequence[ColorType]) -> None: ... + def set_alpha(self, alpha: float | Sequence[float] | None) -> None: ... + def get_linewidth(self) -> float | Sequence[float]: ... + def get_linestyle(self) -> LineStyleType | Sequence[LineStyleType]: ... + def update_scalarmappable(self) -> None: ... + def get_fill(self) -> bool: ... + def update_from(self, other: Artist) -> None: ... + +class _CollectionWithSizes(Collection): + def get_sizes(self) -> np.ndarray: ... + def set_sizes(self, sizes: ArrayLike | None, dpi: float = ...) -> None: ... + +class PathCollection(_CollectionWithSizes): + def __init__( + self, paths: Sequence[Path], sizes: ArrayLike | None = ..., **kwargs + ) -> None: ... + def set_paths(self, paths: Sequence[Path]) -> None: ... + def get_paths(self) -> Sequence[Path]: ... + def legend_elements( + self, + prop: Literal["colors", "sizes"] = ..., + num: int | Literal["auto"] | ArrayLike | Locator = ..., + fmt: str | Formatter | None = ..., + func: Callable[[ArrayLike], ArrayLike] = ..., + **kwargs, + ) -> tuple[list[Line2D], list[str]]: ... + +class PolyCollection(_CollectionWithSizes): + def __init__( + self, + verts: Sequence[ArrayLike], + sizes: ArrayLike | None = ..., + *, + closed: bool = ..., + **kwargs + ) -> None: ... + def set_verts( + self, verts: Sequence[ArrayLike | Path], closed: bool = ... + ) -> None: ... + def set_paths(self, verts: Sequence[Path], closed: bool = ...) -> None: ... + def set_verts_and_codes( + self, verts: Sequence[ArrayLike | Path], codes: Sequence[int] + ) -> None: ... + +class RegularPolyCollection(_CollectionWithSizes): + def __init__( + self, numsides: int, *, rotation: float = ..., sizes: ArrayLike = ..., **kwargs + ) -> None: ... + def get_numsides(self) -> int: ... + def get_rotation(self) -> float: ... + +class StarPolygonCollection(RegularPolyCollection): ... +class AsteriskPolygonCollection(RegularPolyCollection): ... + +class LineCollection(Collection): + def __init__( + self, segments: Sequence[ArrayLike], *, zorder: float = ..., **kwargs + ) -> None: ... + def set_segments(self, segments: Sequence[ArrayLike] | None) -> None: ... + def set_verts(self, segments: Sequence[ArrayLike] | None) -> None: ... + def set_paths(self, segments: Sequence[ArrayLike] | None) -> None: ... # type: ignore[override] + def get_segments(self) -> list[np.ndarray]: ... + def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ... + def set_colors(self, c: ColorType | Sequence[ColorType]) -> None: ... + def set_gapcolor(self, gapcolor: ColorType | Sequence[ColorType] | None) -> None: ... + def get_color(self) -> ColorType | Sequence[ColorType]: ... + def get_colors(self) -> ColorType | Sequence[ColorType]: ... + def get_gapcolor(self) -> ColorType | Sequence[ColorType] | None: ... + + +class EventCollection(LineCollection): + def __init__( + self, + positions: ArrayLike, + orientation: Literal["horizontal", "vertical"] = ..., + *, + lineoffset: float = ..., + linelength: float = ..., + linewidth: float | Sequence[float] | None = ..., + color: ColorType | Sequence[ColorType] | None = ..., + linestyle: LineStyleType | Sequence[LineStyleType] = ..., + antialiased: bool | Sequence[bool] | None = ..., + **kwargs + ) -> None: ... + def get_positions(self) -> list[float]: ... + def set_positions(self, positions: Sequence[float] | None) -> None: ... + def add_positions(self, position: Sequence[float] | None) -> None: ... + def extend_positions(self, position: Sequence[float] | None) -> None: ... + def append_positions(self, position: Sequence[float] | None) -> None: ... + def is_horizontal(self) -> bool: ... + def get_orientation(self) -> Literal["horizontal", "vertical"]: ... + def switch_orientation(self) -> None: ... + def set_orientation( + self, orientation: Literal["horizontal", "vertical"] + ) -> None: ... + def get_linelength(self) -> float | Sequence[float]: ... + def set_linelength(self, linelength: float | Sequence[float]) -> None: ... + def get_lineoffset(self) -> float: ... + def set_lineoffset(self, lineoffset: float) -> None: ... + def get_linewidth(self) -> float: ... + def get_linewidths(self) -> Sequence[float]: ... + def get_color(self) -> ColorType: ... + +class CircleCollection(_CollectionWithSizes): + def __init__(self, sizes: float | ArrayLike, **kwargs) -> None: ... + +class EllipseCollection(Collection): + def __init__( + self, + widths: ArrayLike, + heights: ArrayLike, + angles: ArrayLike, + *, + units: Literal[ + "points", "inches", "dots", "width", "height", "x", "y", "xy" + ] = ..., + **kwargs + ) -> None: ... + def set_widths(self, widths: ArrayLike) -> None: ... + def set_heights(self, heights: ArrayLike) -> None: ... + def set_angles(self, angles: ArrayLike) -> None: ... + def get_widths(self) -> ArrayLike: ... + def get_heights(self) -> ArrayLike: ... + def get_angles(self) -> ArrayLike: ... + +class PatchCollection(Collection): + def __init__( + self, patches: Iterable[Patch], *, match_original: bool = ..., **kwargs + ) -> None: ... + def set_paths(self, patches: Iterable[Patch]) -> None: ... # type: ignore[override] + +class TriMesh(Collection): + def __init__(self, triangulation: Triangulation, **kwargs) -> None: ... + def get_paths(self) -> list[Path]: ... + # Parent class has an argument, perhaps add a noop arg? + def set_paths(self) -> None: ... # type: ignore[override] + @staticmethod + def convert_mesh_to_paths(tri: Triangulation) -> list[Path]: ... + +class _MeshData: + def __init__( + self, + coordinates: ArrayLike, + *, + shading: Literal["flat", "gouraud"] = ..., + ) -> None: ... + def set_array(self, A: ArrayLike | None) -> None: ... + def get_coordinates(self) -> ArrayLike: ... + def get_facecolor(self) -> ColorType | Sequence[ColorType]: ... + def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ... + +class QuadMesh(_MeshData, Collection): + def __init__( + self, + coordinates: ArrayLike, + *, + antialiased: bool = ..., + shading: Literal["flat", "gouraud"] = ..., + **kwargs + ) -> None: ... + def get_paths(self) -> list[Path]: ... + # Parent class has an argument, perhaps add a noop arg? + def set_paths(self) -> None: ... # type: ignore[override] + def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ... + def get_cursor_data(self, event: MouseEvent) -> float: ... + +class PolyQuadMesh(_MeshData, PolyCollection): + def __init__( + self, + coordinates: ArrayLike, + **kwargs + ) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/colorbar.py b/venv/lib/python3.10/site-packages/matplotlib/colorbar.py new file mode 100644 index 00000000..af61e467 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/colorbar.py @@ -0,0 +1,1563 @@ +""" +Colorbars are a visualization of the mapping from scalar values to colors. +In Matplotlib they are drawn into a dedicated `~.axes.Axes`. + +.. note:: + Colorbars are typically created through `.Figure.colorbar` or its pyplot + wrapper `.pyplot.colorbar`, which internally use `.Colorbar` together with + `.make_axes_gridspec` (for `.GridSpec`-positioned Axes) or `.make_axes` (for + non-`.GridSpec`-positioned Axes). + + End-users most likely won't need to directly use this module's API. +""" + +import logging + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, cbook, collections, cm, colors, contour, ticker +import matplotlib.artist as martist +import matplotlib.patches as mpatches +import matplotlib.path as mpath +import matplotlib.spines as mspines +import matplotlib.transforms as mtransforms +from matplotlib import _docstring + +_log = logging.getLogger(__name__) + +_docstring.interpd.update( + _make_axes_kw_doc=""" +location : None or {'left', 'right', 'top', 'bottom'} + The location, relative to the parent Axes, where the colorbar Axes + is created. It also determines the *orientation* of the colorbar + (colorbars on the left and right are vertical, colorbars at the top + and bottom are horizontal). If None, the location will come from the + *orientation* if it is set (vertical colorbars on the right, horizontal + ones at the bottom), or default to 'right' if *orientation* is unset. + +orientation : None or {'vertical', 'horizontal'} + The orientation of the colorbar. It is preferable to set the *location* + of the colorbar, as that also determines the *orientation*; passing + incompatible values for *location* and *orientation* raises an exception. + +fraction : float, default: 0.15 + Fraction of original Axes to use for colorbar. + +shrink : float, default: 1.0 + Fraction by which to multiply the size of the colorbar. + +aspect : float, default: 20 + Ratio of long to short dimensions. + +pad : float, default: 0.05 if vertical, 0.15 if horizontal + Fraction of original Axes between colorbar and new image Axes. + +anchor : (float, float), optional + The anchor point of the colorbar Axes. + Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal. + +panchor : (float, float), or *False*, optional + The anchor point of the colorbar parent Axes. If *False*, the parent + axes' anchor will be unchanged. + Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.""", + _colormap_kw_doc=""" +extend : {'neither', 'both', 'min', 'max'} + Make pointed end(s) for out-of-range values (unless 'neither'). These are + set for a given colormap using the colormap set_under and set_over methods. + +extendfrac : {*None*, 'auto', length, lengths} + If set to *None*, both the minimum and maximum triangular colorbar + extensions will have a length of 5% of the interior colorbar length (this + is the default setting). + + If set to 'auto', makes the triangular colorbar extensions the same lengths + as the interior boxes (when *spacing* is set to 'uniform') or the same + lengths as the respective adjacent interior boxes (when *spacing* is set to + 'proportional'). + + If a scalar, indicates the length of both the minimum and maximum + triangular colorbar extensions as a fraction of the interior colorbar + length. A two-element sequence of fractions may also be given, indicating + the lengths of the minimum and maximum colorbar extensions respectively as + a fraction of the interior colorbar length. + +extendrect : bool + If *False* the minimum and maximum colorbar extensions will be triangular + (the default). If *True* the extensions will be rectangular. + +spacing : {'uniform', 'proportional'} + For discrete colorbars (`.BoundaryNorm` or contours), 'uniform' gives each + color the same space; 'proportional' makes the space proportional to the + data interval. + +ticks : None or list of ticks or Locator + If None, ticks are determined automatically from the input. + +format : None or str or Formatter + If None, `~.ticker.ScalarFormatter` is used. + Format strings, e.g., ``"%4.2e"`` or ``"{x:.2e}"``, are supported. + An alternative `~.ticker.Formatter` may be given instead. + +drawedges : bool + Whether to draw lines at color boundaries. + +label : str + The label on the colorbar's long axis. + +boundaries, values : None or a sequence + If unset, the colormap will be displayed on a 0-1 scale. + If sequences, *values* must have a length 1 less than *boundaries*. For + each region delimited by adjacent entries in *boundaries*, the color mapped + to the corresponding value in values will be used. + Normally only useful for indexed colors (i.e. ``norm=NoNorm()``) or other + unusual circumstances.""") + + +def _set_ticks_on_axis_warn(*args, **kwargs): + # a top level function which gets put in at the axes' + # set_xticks and set_yticks by Colorbar.__init__. + _api.warn_external("Use the colorbar set_ticks() method instead.") + + +class _ColorbarSpine(mspines.Spine): + def __init__(self, axes): + self._ax = axes + super().__init__(axes, 'colorbar', mpath.Path(np.empty((0, 2)))) + mpatches.Patch.set_transform(self, axes.transAxes) + + def get_window_extent(self, renderer=None): + # This Spine has no Axis associated with it, and doesn't need to adjust + # its location, so we can directly get the window extent from the + # super-super-class. + return mpatches.Patch.get_window_extent(self, renderer=renderer) + + def set_xy(self, xy): + self._path = mpath.Path(xy, closed=True) + self._xy = xy + self.stale = True + + def draw(self, renderer): + ret = mpatches.Patch.draw(self, renderer) + self.stale = False + return ret + + +class _ColorbarAxesLocator: + """ + Shrink the Axes if there are triangular or rectangular extends. + """ + def __init__(self, cbar): + self._cbar = cbar + self._orig_locator = cbar.ax._axes_locator + + def __call__(self, ax, renderer): + if self._orig_locator is not None: + pos = self._orig_locator(ax, renderer) + else: + pos = ax.get_position(original=True) + if self._cbar.extend == 'neither': + return pos + + y, extendlen = self._cbar._proportional_y() + if not self._cbar._extend_lower(): + extendlen[0] = 0 + if not self._cbar._extend_upper(): + extendlen[1] = 0 + len = sum(extendlen) + 1 + shrink = 1 / len + offset = extendlen[0] / len + # we need to reset the aspect ratio of the axes to account + # of the extends... + if hasattr(ax, '_colorbar_info'): + aspect = ax._colorbar_info['aspect'] + else: + aspect = False + # now shrink and/or offset to take into account the + # extend tri/rectangles. + if self._cbar.orientation == 'vertical': + if aspect: + self._cbar.ax.set_box_aspect(aspect*shrink) + pos = pos.shrunk(1, shrink).translated(0, offset * pos.height) + else: + if aspect: + self._cbar.ax.set_box_aspect(1/(aspect * shrink)) + pos = pos.shrunk(shrink, 1).translated(offset * pos.width, 0) + return pos + + def get_subplotspec(self): + # make tight_layout happy.. + return ( + self._cbar.ax.get_subplotspec() + or getattr(self._orig_locator, "get_subplotspec", lambda: None)()) + + +@_docstring.interpd +class Colorbar: + r""" + Draw a colorbar in an existing Axes. + + Typically, colorbars are created using `.Figure.colorbar` or + `.pyplot.colorbar` and associated with `.ScalarMappable`\s (such as an + `.AxesImage` generated via `~.axes.Axes.imshow`). + + In order to draw a colorbar not associated with other elements in the + figure, e.g. when showing a colormap by itself, one can create an empty + `.ScalarMappable`, or directly pass *cmap* and *norm* instead of *mappable* + to `Colorbar`. + + Useful public methods are :meth:`set_label` and :meth:`add_lines`. + + Attributes + ---------- + ax : `~matplotlib.axes.Axes` + The `~.axes.Axes` instance in which the colorbar is drawn. + lines : list + A list of `.LineCollection` (empty if no lines were drawn). + dividers : `.LineCollection` + A LineCollection (empty if *drawedges* is ``False``). + + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The `~.axes.Axes` instance in which the colorbar is drawn. + + mappable : `.ScalarMappable` + The mappable whose colormap and norm will be used. + + To show the under- and over- value colors, the mappable's norm should + be specified as :: + + norm = colors.Normalize(clip=False) + + To show the colors versus index instead of on a 0-1 scale, use:: + + norm=colors.NoNorm() + + cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` + The colormap to use. This parameter is ignored, unless *mappable* is + None. + + norm : `~matplotlib.colors.Normalize` + The normalization to use. This parameter is ignored, unless *mappable* + is None. + + alpha : float + The colorbar transparency between 0 (transparent) and 1 (opaque). + + orientation : None or {'vertical', 'horizontal'} + If None, use the value determined by *location*. If both + *orientation* and *location* are None then defaults to 'vertical'. + + ticklocation : {'auto', 'left', 'right', 'top', 'bottom'} + The location of the colorbar ticks. The *ticklocation* must match + *orientation*. For example, a horizontal colorbar can only have ticks + at the top or the bottom. If 'auto', the ticks will be the same as + *location*, so a colorbar to the left will have ticks to the left. If + *location* is None, the ticks will be at the bottom for a horizontal + colorbar and at the right for a vertical. + + drawedges : bool + Whether to draw lines at color boundaries. + + + %(_colormap_kw_doc)s + + location : None or {'left', 'right', 'top', 'bottom'} + Set the *orientation* and *ticklocation* of the colorbar using a + single argument. Colorbars on the left and right are vertical, + colorbars at the top and bottom are horizontal. The *ticklocation* is + the same as *location*, so if *location* is 'top', the ticks are on + the top. *orientation* and/or *ticklocation* can be provided as well + and overrides the value set by *location*, but there will be an error + for incompatible combinations. + + .. versionadded:: 3.7 + """ + + n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize + + def __init__(self, ax, mappable=None, *, cmap=None, + norm=None, + alpha=None, + values=None, + boundaries=None, + orientation=None, + ticklocation='auto', + extend=None, + spacing='uniform', # uniform or proportional + ticks=None, + format=None, + drawedges=False, + extendfrac=None, + extendrect=False, + label='', + location=None, + ): + + if mappable is None: + mappable = cm.ScalarMappable(norm=norm, cmap=cmap) + + self.mappable = mappable + cmap = mappable.cmap + norm = mappable.norm + + filled = True + if isinstance(mappable, contour.ContourSet): + cs = mappable + alpha = cs.get_alpha() + boundaries = cs._levels + values = cs.cvalues + extend = cs.extend + filled = cs.filled + if ticks is None: + ticks = ticker.FixedLocator(cs.levels, nbins=10) + elif isinstance(mappable, martist.Artist): + alpha = mappable.get_alpha() + + mappable.colorbar = self + mappable.colorbar_cid = mappable.callbacks.connect( + 'changed', self.update_normal) + + location_orientation = _get_orientation_from_location(location) + + _api.check_in_list( + [None, 'vertical', 'horizontal'], orientation=orientation) + _api.check_in_list( + ['auto', 'left', 'right', 'top', 'bottom'], + ticklocation=ticklocation) + _api.check_in_list( + ['uniform', 'proportional'], spacing=spacing) + + if location_orientation is not None and orientation is not None: + if location_orientation != orientation: + raise TypeError( + "location and orientation are mutually exclusive") + else: + orientation = orientation or location_orientation or "vertical" + + self.ax = ax + self.ax._axes_locator = _ColorbarAxesLocator(self) + + if extend is None: + if (not isinstance(mappable, contour.ContourSet) + and getattr(cmap, 'colorbar_extend', False) is not False): + extend = cmap.colorbar_extend + elif hasattr(norm, 'extend'): + extend = norm.extend + else: + extend = 'neither' + self.alpha = None + # Call set_alpha to handle array-like alphas properly + self.set_alpha(alpha) + self.cmap = cmap + self.norm = norm + self.values = values + self.boundaries = boundaries + self.extend = extend + self._inside = _api.check_getitem( + {'neither': slice(0, None), 'both': slice(1, -1), + 'min': slice(1, None), 'max': slice(0, -1)}, + extend=extend) + self.spacing = spacing + self.orientation = orientation + self.drawedges = drawedges + self._filled = filled + self.extendfrac = extendfrac + self.extendrect = extendrect + self._extend_patches = [] + self.solids = None + self.solids_patches = [] + self.lines = [] + + for spine in self.ax.spines.values(): + spine.set_visible(False) + self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax) + + self.dividers = collections.LineCollection( + [], + colors=[mpl.rcParams['axes.edgecolor']], + linewidths=[0.5 * mpl.rcParams['axes.linewidth']], + clip_on=False) + self.ax.add_collection(self.dividers) + + self._locator = None + self._minorlocator = None + self._formatter = None + self._minorformatter = None + + if ticklocation == 'auto': + ticklocation = _get_ticklocation_from_orientation( + orientation) if location is None else location + self.ticklocation = ticklocation + + self.set_label(label) + self._reset_locator_formatter_scale() + + if np.iterable(ticks): + self._locator = ticker.FixedLocator(ticks, nbins=len(ticks)) + else: + self._locator = ticks + + if isinstance(format, str): + # Check format between FormatStrFormatter and StrMethodFormatter + try: + self._formatter = ticker.FormatStrFormatter(format) + _ = self._formatter(0) + except (TypeError, ValueError): + self._formatter = ticker.StrMethodFormatter(format) + else: + self._formatter = format # Assume it is a Formatter or None + self._draw_all() + + if isinstance(mappable, contour.ContourSet) and not mappable.filled: + self.add_lines(mappable) + + # Link the Axes and Colorbar for interactive use + self.ax._colorbar = self + # Don't navigate on any of these types of mappables + if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm)) or + isinstance(self.mappable, contour.ContourSet)): + self.ax.set_navigate(False) + + # These are the functions that set up interactivity on this colorbar + self._interactive_funcs = ["_get_view", "_set_view", + "_set_view_from_bbox", "drag_pan"] + for x in self._interactive_funcs: + setattr(self.ax, x, getattr(self, x)) + # Set the cla function to the cbar's method to override it + self.ax.cla = self._cbar_cla + # Callbacks for the extend calculations to handle inverting the axis + self._extend_cid1 = self.ax.callbacks.connect( + "xlim_changed", self._do_extends) + self._extend_cid2 = self.ax.callbacks.connect( + "ylim_changed", self._do_extends) + + @property + def locator(self): + """Major tick `.Locator` for the colorbar.""" + return self._long_axis().get_major_locator() + + @locator.setter + def locator(self, loc): + self._long_axis().set_major_locator(loc) + self._locator = loc + + @property + def minorlocator(self): + """Minor tick `.Locator` for the colorbar.""" + return self._long_axis().get_minor_locator() + + @minorlocator.setter + def minorlocator(self, loc): + self._long_axis().set_minor_locator(loc) + self._minorlocator = loc + + @property + def formatter(self): + """Major tick label `.Formatter` for the colorbar.""" + return self._long_axis().get_major_formatter() + + @formatter.setter + def formatter(self, fmt): + self._long_axis().set_major_formatter(fmt) + self._formatter = fmt + + @property + def minorformatter(self): + """Minor tick `.Formatter` for the colorbar.""" + return self._long_axis().get_minor_formatter() + + @minorformatter.setter + def minorformatter(self, fmt): + self._long_axis().set_minor_formatter(fmt) + self._minorformatter = fmt + + def _cbar_cla(self): + """Function to clear the interactive colorbar state.""" + for x in self._interactive_funcs: + delattr(self.ax, x) + # We now restore the old cla() back and can call it directly + del self.ax.cla + self.ax.cla() + + def update_normal(self, mappable): + """ + Update solid patches, lines, etc. + + This is meant to be called when the norm of the image or contour plot + to which this colorbar belongs changes. + + If the norm on the mappable is different than before, this resets the + locator and formatter for the axis, so if these have been customized, + they will need to be customized again. However, if the norm only + changes values of *vmin*, *vmax* or *cmap* then the old formatter + and locator will be preserved. + """ + _log.debug('colorbar update normal %r %r', mappable.norm, self.norm) + self.mappable = mappable + self.set_alpha(mappable.get_alpha()) + self.cmap = mappable.cmap + if mappable.norm != self.norm: + self.norm = mappable.norm + self._reset_locator_formatter_scale() + + self._draw_all() + if isinstance(self.mappable, contour.ContourSet): + CS = self.mappable + if not CS.filled: + self.add_lines(CS) + self.stale = True + + def _draw_all(self): + """ + Calculate any free parameters based on the current cmap and norm, + and do all the drawing. + """ + if self.orientation == 'vertical': + if mpl.rcParams['ytick.minor.visible']: + self.minorticks_on() + else: + if mpl.rcParams['xtick.minor.visible']: + self.minorticks_on() + self._long_axis().set(label_position=self.ticklocation, + ticks_position=self.ticklocation) + self._short_axis().set_ticks([]) + self._short_axis().set_ticks([], minor=True) + + # Set self._boundaries and self._values, including extensions. + # self._boundaries are the edges of each square of color, and + # self._values are the value to map into the norm to get the + # color: + self._process_values() + # Set self.vmin and self.vmax to first and last boundary, excluding + # extensions: + self.vmin, self.vmax = self._boundaries[self._inside][[0, -1]] + # Compute the X/Y mesh. + X, Y = self._mesh() + # draw the extend triangles, and shrink the inner Axes to accommodate. + # also adds the outline path to self.outline spine: + self._do_extends() + lower, upper = self.vmin, self.vmax + if self._long_axis().get_inverted(): + # If the axis is inverted, we need to swap the vmin/vmax + lower, upper = upper, lower + if self.orientation == 'vertical': + self.ax.set_xlim(0, 1) + self.ax.set_ylim(lower, upper) + else: + self.ax.set_ylim(0, 1) + self.ax.set_xlim(lower, upper) + + # set up the tick locators and formatters. A bit complicated because + # boundary norms + uniform spacing requires a manual locator. + self.update_ticks() + + if self._filled: + ind = np.arange(len(self._values)) + if self._extend_lower(): + ind = ind[1:] + if self._extend_upper(): + ind = ind[:-1] + self._add_solids(X, Y, self._values[ind, np.newaxis]) + + def _add_solids(self, X, Y, C): + """Draw the colors; optionally add separators.""" + # Cleanup previously set artists. + if self.solids is not None: + self.solids.remove() + for solid in self.solids_patches: + solid.remove() + # Add new artist(s), based on mappable type. Use individual patches if + # hatching is needed, pcolormesh otherwise. + mappable = getattr(self, 'mappable', None) + if (isinstance(mappable, contour.ContourSet) + and any(hatch is not None for hatch in mappable.hatches)): + self._add_solids_patches(X, Y, C, mappable) + else: + self.solids = self.ax.pcolormesh( + X, Y, C, cmap=self.cmap, norm=self.norm, alpha=self.alpha, + edgecolors='none', shading='flat') + if not self.drawedges: + if len(self._y) >= self.n_rasterize: + self.solids.set_rasterized(True) + self._update_dividers() + + def _update_dividers(self): + if not self.drawedges: + self.dividers.set_segments([]) + return + # Place all *internal* dividers. + if self.orientation == 'vertical': + lims = self.ax.get_ylim() + bounds = (lims[0] < self._y) & (self._y < lims[1]) + else: + lims = self.ax.get_xlim() + bounds = (lims[0] < self._y) & (self._y < lims[1]) + y = self._y[bounds] + # And then add outer dividers if extensions are on. + if self._extend_lower(): + y = np.insert(y, 0, lims[0]) + if self._extend_upper(): + y = np.append(y, lims[1]) + X, Y = np.meshgrid([0, 1], y) + if self.orientation == 'vertical': + segments = np.dstack([X, Y]) + else: + segments = np.dstack([Y, X]) + self.dividers.set_segments(segments) + + def _add_solids_patches(self, X, Y, C, mappable): + hatches = mappable.hatches * (len(C) + 1) # Have enough hatches. + if self._extend_lower(): + # remove first hatch that goes into the extend patch + hatches = hatches[1:] + patches = [] + for i in range(len(X) - 1): + xy = np.array([[X[i, 0], Y[i, 1]], + [X[i, 1], Y[i, 0]], + [X[i + 1, 1], Y[i + 1, 0]], + [X[i + 1, 0], Y[i + 1, 1]]]) + patch = mpatches.PathPatch(mpath.Path(xy), + facecolor=self.cmap(self.norm(C[i][0])), + hatch=hatches[i], linewidth=0, + antialiased=False, alpha=self.alpha) + self.ax.add_patch(patch) + patches.append(patch) + self.solids_patches = patches + + def _do_extends(self, ax=None): + """ + Add the extend tri/rectangles on the outside of the Axes. + + ax is unused, but required due to the callbacks on xlim/ylim changed + """ + # Clean up any previous extend patches + for patch in self._extend_patches: + patch.remove() + self._extend_patches = [] + # extend lengths are fraction of the *inner* part of colorbar, + # not the total colorbar: + _, extendlen = self._proportional_y() + bot = 0 - (extendlen[0] if self._extend_lower() else 0) + top = 1 + (extendlen[1] if self._extend_upper() else 0) + + # xyout is the outline of the colorbar including the extend patches: + if not self.extendrect: + # triangle: + xyout = np.array([[0, 0], [0.5, bot], [1, 0], + [1, 1], [0.5, top], [0, 1], [0, 0]]) + else: + # rectangle: + xyout = np.array([[0, 0], [0, bot], [1, bot], [1, 0], + [1, 1], [1, top], [0, top], [0, 1], + [0, 0]]) + + if self.orientation == 'horizontal': + xyout = xyout[:, ::-1] + + # xyout is the path for the spine: + self.outline.set_xy(xyout) + if not self._filled: + return + + # Make extend triangles or rectangles filled patches. These are + # defined in the outer parent axes' coordinates: + mappable = getattr(self, 'mappable', None) + if (isinstance(mappable, contour.ContourSet) + and any(hatch is not None for hatch in mappable.hatches)): + hatches = mappable.hatches * (len(self._y) + 1) + else: + hatches = [None] * (len(self._y) + 1) + + if self._extend_lower(): + if not self.extendrect: + # triangle + xy = np.array([[0, 0], [0.5, bot], [1, 0]]) + else: + # rectangle + xy = np.array([[0, 0], [0, bot], [1., bot], [1, 0]]) + if self.orientation == 'horizontal': + xy = xy[:, ::-1] + # add the patch + val = -1 if self._long_axis().get_inverted() else 0 + color = self.cmap(self.norm(self._values[val])) + patch = mpatches.PathPatch( + mpath.Path(xy), facecolor=color, alpha=self.alpha, + linewidth=0, antialiased=False, + transform=self.ax.transAxes, + hatch=hatches[0], clip_on=False, + # Place it right behind the standard patches, which is + # needed if we updated the extends + zorder=np.nextafter(self.ax.patch.zorder, -np.inf)) + self.ax.add_patch(patch) + self._extend_patches.append(patch) + # remove first hatch that goes into the extend patch + hatches = hatches[1:] + if self._extend_upper(): + if not self.extendrect: + # triangle + xy = np.array([[0, 1], [0.5, top], [1, 1]]) + else: + # rectangle + xy = np.array([[0, 1], [0, top], [1, top], [1, 1]]) + if self.orientation == 'horizontal': + xy = xy[:, ::-1] + # add the patch + val = 0 if self._long_axis().get_inverted() else -1 + color = self.cmap(self.norm(self._values[val])) + hatch_idx = len(self._y) - 1 + patch = mpatches.PathPatch( + mpath.Path(xy), facecolor=color, alpha=self.alpha, + linewidth=0, antialiased=False, + transform=self.ax.transAxes, hatch=hatches[hatch_idx], + clip_on=False, + # Place it right behind the standard patches, which is + # needed if we updated the extends + zorder=np.nextafter(self.ax.patch.zorder, -np.inf)) + self.ax.add_patch(patch) + self._extend_patches.append(patch) + + self._update_dividers() + + def add_lines(self, *args, **kwargs): + """ + Draw lines on the colorbar. + + The lines are appended to the list :attr:`lines`. + + Parameters + ---------- + levels : array-like + The positions of the lines. + colors : :mpltype:`color` or list of :mpltype:`color` + Either a single color applying to all lines or one color value for + each line. + linewidths : float or array-like + Either a single linewidth applying to all lines or one linewidth + for each line. + erase : bool, default: True + Whether to remove any previously added lines. + + Notes + ----- + Alternatively, this method can also be called with the signature + ``colorbar.add_lines(contour_set, erase=True)``, in which case + *levels*, *colors*, and *linewidths* are taken from *contour_set*. + """ + params = _api.select_matching_signature( + [lambda self, CS, erase=True: locals(), + lambda self, levels, colors, linewidths, erase=True: locals()], + self, *args, **kwargs) + if "CS" in params: + self, cs, erase = params.values() + if not isinstance(cs, contour.ContourSet) or cs.filled: + raise ValueError("If a single artist is passed to add_lines, " + "it must be a ContourSet of lines") + # TODO: Make colorbar lines auto-follow changes in contour lines. + return self.add_lines( + cs.levels, + cs.to_rgba(cs.cvalues, cs.alpha), + cs.get_linewidths(), + erase=erase) + else: + self, levels, colors, linewidths, erase = params.values() + + y = self._locate(levels) + rtol = (self._y[-1] - self._y[0]) * 1e-10 + igood = (y < self._y[-1] + rtol) & (y > self._y[0] - rtol) + y = y[igood] + if np.iterable(colors): + colors = np.asarray(colors)[igood] + if np.iterable(linewidths): + linewidths = np.asarray(linewidths)[igood] + X, Y = np.meshgrid([0, 1], y) + if self.orientation == 'vertical': + xy = np.stack([X, Y], axis=-1) + else: + xy = np.stack([Y, X], axis=-1) + col = collections.LineCollection(xy, linewidths=linewidths, + colors=colors) + + if erase and self.lines: + for lc in self.lines: + lc.remove() + self.lines = [] + self.lines.append(col) + + # make a clip path that is just a linewidth bigger than the Axes... + fac = np.max(linewidths) / 72 + xy = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]) + inches = self.ax.get_figure().dpi_scale_trans + # do in inches: + xy = inches.inverted().transform(self.ax.transAxes.transform(xy)) + xy[[0, 1, 4], 1] -= fac + xy[[2, 3], 1] += fac + # back to axes units... + xy = self.ax.transAxes.inverted().transform(inches.transform(xy)) + col.set_clip_path(mpath.Path(xy, closed=True), + self.ax.transAxes) + self.ax.add_collection(col) + self.stale = True + + def update_ticks(self): + """ + Set up the ticks and ticklabels. This should not be needed by users. + """ + # Get the locator and formatter; defaults to self._locator if not None. + self._get_ticker_locator_formatter() + self._long_axis().set_major_locator(self._locator) + self._long_axis().set_minor_locator(self._minorlocator) + self._long_axis().set_major_formatter(self._formatter) + + def _get_ticker_locator_formatter(self): + """ + Return the ``locator`` and ``formatter`` of the colorbar. + + If they have not been defined (i.e. are *None*), the formatter and + locator are retrieved from the axis, or from the value of the + boundaries for a boundary norm. + + Called by update_ticks... + """ + locator = self._locator + formatter = self._formatter + minorlocator = self._minorlocator + if isinstance(self.norm, colors.BoundaryNorm): + b = self.norm.boundaries + if locator is None: + locator = ticker.FixedLocator(b, nbins=10) + if minorlocator is None: + minorlocator = ticker.FixedLocator(b) + elif isinstance(self.norm, colors.NoNorm): + if locator is None: + # put ticks on integers between the boundaries of NoNorm + nv = len(self._values) + base = 1 + int(nv / 10) + locator = ticker.IndexLocator(base=base, offset=.5) + elif self.boundaries is not None: + b = self._boundaries[self._inside] + if locator is None: + locator = ticker.FixedLocator(b, nbins=10) + else: # most cases: + if locator is None: + # we haven't set the locator explicitly, so use the default + # for this axis: + locator = self._long_axis().get_major_locator() + if minorlocator is None: + minorlocator = self._long_axis().get_minor_locator() + + if minorlocator is None: + minorlocator = ticker.NullLocator() + + if formatter is None: + formatter = self._long_axis().get_major_formatter() + + self._locator = locator + self._formatter = formatter + self._minorlocator = minorlocator + _log.debug('locator: %r', locator) + + def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs): + """ + Set tick locations. + + Parameters + ---------- + ticks : 1D array-like + List of tick locations. + labels : list of str, optional + List of tick labels. If not set, the labels show the data value. + minor : bool, default: False + If ``False``, set the major ticks; if ``True``, the minor ticks. + **kwargs + `.Text` properties for the labels. These take effect only if you + pass *labels*. In other cases, please use `~.Axes.tick_params`. + """ + if np.iterable(ticks): + self._long_axis().set_ticks(ticks, labels=labels, minor=minor, + **kwargs) + self._locator = self._long_axis().get_major_locator() + else: + self._locator = ticks + self._long_axis().set_major_locator(self._locator) + self.stale = True + + def get_ticks(self, minor=False): + """ + Return the ticks as a list of locations. + + Parameters + ---------- + minor : boolean, default: False + if True return the minor ticks. + """ + if minor: + return self._long_axis().get_minorticklocs() + else: + return self._long_axis().get_majorticklocs() + + def set_ticklabels(self, ticklabels, *, minor=False, **kwargs): + """ + [*Discouraged*] Set tick labels. + + .. admonition:: Discouraged + + The use of this method is discouraged, because of the dependency + on tick positions. In most cases, you'll want to use + ``set_ticks(positions, labels=labels)`` instead. + + If you are using this method, you should always fix the tick + positions before, e.g. by using `.Colorbar.set_ticks` or by + explicitly setting a `~.ticker.FixedLocator` on the long axis + of the colorbar. Otherwise, ticks are free to move and the + labels may end up in unexpected positions. + + Parameters + ---------- + ticklabels : sequence of str or of `.Text` + Texts for labeling each tick location in the sequence set by + `.Colorbar.set_ticks`; the number of labels must match the number + of locations. + + update_ticks : bool, default: True + This keyword argument is ignored and will be removed. + Deprecated + + minor : bool + If True, set minor ticks instead of major ticks. + + **kwargs + `.Text` properties for the labels. + """ + self._long_axis().set_ticklabels(ticklabels, minor=minor, **kwargs) + + def minorticks_on(self): + """ + Turn on colorbar minor ticks. + """ + self.ax.minorticks_on() + self._short_axis().set_minor_locator(ticker.NullLocator()) + + def minorticks_off(self): + """Turn the minor ticks of the colorbar off.""" + self._minorlocator = ticker.NullLocator() + self._long_axis().set_minor_locator(self._minorlocator) + + def set_label(self, label, *, loc=None, **kwargs): + """ + Add a label to the long axis of the colorbar. + + Parameters + ---------- + label : str + The label text. + loc : str, optional + The location of the label. + + - For horizontal orientation one of {'left', 'center', 'right'} + - For vertical orientation one of {'bottom', 'center', 'top'} + + Defaults to :rc:`xaxis.labellocation` or :rc:`yaxis.labellocation` + depending on the orientation. + **kwargs + Keyword arguments are passed to `~.Axes.set_xlabel` / + `~.Axes.set_ylabel`. + Supported keywords are *labelpad* and `.Text` properties. + """ + if self.orientation == "vertical": + self.ax.set_ylabel(label, loc=loc, **kwargs) + else: + self.ax.set_xlabel(label, loc=loc, **kwargs) + self.stale = True + + def set_alpha(self, alpha): + """ + Set the transparency between 0 (transparent) and 1 (opaque). + + If an array is provided, *alpha* will be set to None to use the + transparency values associated with the colormap. + """ + self.alpha = None if isinstance(alpha, np.ndarray) else alpha + + def _set_scale(self, scale, **kwargs): + """ + Set the colorbar long axis scale. + + Parameters + ---------- + scale : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase` + The axis scale type to apply. + + **kwargs + Different keyword arguments are accepted, depending on the scale. + See the respective class keyword arguments: + + - `matplotlib.scale.LinearScale` + - `matplotlib.scale.LogScale` + - `matplotlib.scale.SymmetricalLogScale` + - `matplotlib.scale.LogitScale` + - `matplotlib.scale.FuncScale` + - `matplotlib.scale.AsinhScale` + + Notes + ----- + By default, Matplotlib supports the above-mentioned scales. + Additionally, custom scales may be registered using + `matplotlib.scale.register_scale`. These scales can then also + be used here. + """ + self._long_axis()._set_axes_scale(scale, **kwargs) + + def remove(self): + """ + Remove this colorbar from the figure. + + If the colorbar was created with ``use_gridspec=True`` the previous + gridspec is restored. + """ + if hasattr(self.ax, '_colorbar_info'): + parents = self.ax._colorbar_info['parents'] + for a in parents: + if self.ax in a._colorbars: + a._colorbars.remove(self.ax) + + self.ax.remove() + + self.mappable.callbacks.disconnect(self.mappable.colorbar_cid) + self.mappable.colorbar = None + self.mappable.colorbar_cid = None + # Remove the extension callbacks + self.ax.callbacks.disconnect(self._extend_cid1) + self.ax.callbacks.disconnect(self._extend_cid2) + + try: + ax = self.mappable.axes + except AttributeError: + return + try: + subplotspec = self.ax.get_subplotspec().get_gridspec()._subplot_spec + except AttributeError: # use_gridspec was False + pos = ax.get_position(original=True) + ax._set_position(pos) + else: # use_gridspec was True + ax.set_subplotspec(subplotspec) + + def _process_values(self): + """ + Set `_boundaries` and `_values` based on the self.boundaries and + self.values if not None, or based on the size of the colormap and + the vmin/vmax of the norm. + """ + if self.values is not None: + # set self._boundaries from the values... + self._values = np.array(self.values) + if self.boundaries is None: + # bracket values by 1/2 dv: + b = np.zeros(len(self.values) + 1) + b[1:-1] = 0.5 * (self._values[:-1] + self._values[1:]) + b[0] = 2.0 * b[1] - b[2] + b[-1] = 2.0 * b[-2] - b[-3] + self._boundaries = b + return + self._boundaries = np.array(self.boundaries) + return + + # otherwise values are set from the boundaries + if isinstance(self.norm, colors.BoundaryNorm): + b = self.norm.boundaries + elif isinstance(self.norm, colors.NoNorm): + # NoNorm has N blocks, so N+1 boundaries, centered on integers: + b = np.arange(self.cmap.N + 1) - .5 + elif self.boundaries is not None: + b = self.boundaries + else: + # otherwise make the boundaries from the size of the cmap: + N = self.cmap.N + 1 + b, _ = self._uniform_y(N) + # add extra boundaries if needed: + if self._extend_lower(): + b = np.hstack((b[0] - 1, b)) + if self._extend_upper(): + b = np.hstack((b, b[-1] + 1)) + + # transform from 0-1 to vmin-vmax: + if self.mappable.get_array() is not None: + self.mappable.autoscale_None() + if not self.norm.scaled(): + # If we still aren't scaled after autoscaling, use 0, 1 as default + self.norm.vmin = 0 + self.norm.vmax = 1 + self.norm.vmin, self.norm.vmax = mtransforms.nonsingular( + self.norm.vmin, self.norm.vmax, expander=0.1) + if (not isinstance(self.norm, colors.BoundaryNorm) and + (self.boundaries is None)): + b = self.norm.inverse(b) + + self._boundaries = np.asarray(b, dtype=float) + self._values = 0.5 * (self._boundaries[:-1] + self._boundaries[1:]) + if isinstance(self.norm, colors.NoNorm): + self._values = (self._values + 0.00001).astype(np.int16) + + def _mesh(self): + """ + Return the coordinate arrays for the colorbar pcolormesh/patches. + + These are scaled between vmin and vmax, and already handle colorbar + orientation. + """ + y, _ = self._proportional_y() + # Use the vmin and vmax of the colorbar, which may not be the same + # as the norm. There are situations where the colormap has a + # narrower range than the colorbar and we want to accommodate the + # extra contours. + if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm)) + or self.boundaries is not None): + # not using a norm. + y = y * (self.vmax - self.vmin) + self.vmin + else: + # Update the norm values in a context manager as it is only + # a temporary change and we don't want to propagate any signals + # attached to the norm (callbacks.blocked). + with self.norm.callbacks.blocked(), \ + cbook._setattr_cm(self.norm, + vmin=self.vmin, + vmax=self.vmax): + y = self.norm.inverse(y) + self._y = y + X, Y = np.meshgrid([0., 1.], y) + if self.orientation == 'vertical': + return (X, Y) + else: + return (Y, X) + + def _forward_boundaries(self, x): + # map boundaries equally between 0 and 1... + b = self._boundaries + y = np.interp(x, b, np.linspace(0, 1, len(b))) + # the following avoids ticks in the extends: + eps = (b[-1] - b[0]) * 1e-6 + # map these _well_ out of bounds to keep any ticks out + # of the extends region... + y[x < b[0]-eps] = -1 + y[x > b[-1]+eps] = 2 + return y + + def _inverse_boundaries(self, x): + # invert the above... + b = self._boundaries + return np.interp(x, np.linspace(0, 1, len(b)), b) + + def _reset_locator_formatter_scale(self): + """ + Reset the locator et al to defaults. Any user-hardcoded changes + need to be re-entered if this gets called (either at init, or when + the mappable normal gets changed: Colorbar.update_normal) + """ + self._process_values() + self._locator = None + self._minorlocator = None + self._formatter = None + self._minorformatter = None + if (isinstance(self.mappable, contour.ContourSet) and + isinstance(self.norm, colors.LogNorm)): + # if contours have lognorm, give them a log scale... + self._set_scale('log') + elif (self.boundaries is not None or + isinstance(self.norm, colors.BoundaryNorm)): + if self.spacing == 'uniform': + funcs = (self._forward_boundaries, self._inverse_boundaries) + self._set_scale('function', functions=funcs) + elif self.spacing == 'proportional': + self._set_scale('linear') + elif getattr(self.norm, '_scale', None): + # use the norm's scale (if it exists and is not None): + self._set_scale(self.norm._scale) + elif type(self.norm) is colors.Normalize: + # plain Normalize: + self._set_scale('linear') + else: + # norm._scale is None or not an attr: derive the scale from + # the Norm: + funcs = (self.norm, self.norm.inverse) + self._set_scale('function', functions=funcs) + + def _locate(self, x): + """ + Given a set of color data values, return their + corresponding colorbar data coordinates. + """ + if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)): + b = self._boundaries + xn = x + else: + # Do calculations using normalized coordinates so + # as to make the interpolation more accurate. + b = self.norm(self._boundaries, clip=False).filled() + xn = self.norm(x, clip=False).filled() + + bunique = b[self._inside] + yunique = self._y + + z = np.interp(xn, bunique, yunique) + return z + + # trivial helpers + + def _uniform_y(self, N): + """ + Return colorbar data coordinates for *N* uniformly + spaced boundaries, plus extension lengths if required. + """ + automin = automax = 1. / (N - 1.) + extendlength = self._get_extension_lengths(self.extendfrac, + automin, automax, + default=0.05) + y = np.linspace(0, 1, N) + return y, extendlength + + def _proportional_y(self): + """ + Return colorbar data coordinates for the boundaries of + a proportional colorbar, plus extension lengths if required: + """ + if (isinstance(self.norm, colors.BoundaryNorm) or + self.boundaries is not None): + y = (self._boundaries - self._boundaries[self._inside][0]) + y = y / (self._boundaries[self._inside][-1] - + self._boundaries[self._inside][0]) + # need yscaled the same as the axes scale to get + # the extend lengths. + if self.spacing == 'uniform': + yscaled = self._forward_boundaries(self._boundaries) + else: + yscaled = y + else: + y = self.norm(self._boundaries.copy()) + y = np.ma.filled(y, np.nan) + # the norm and the scale should be the same... + yscaled = y + y = y[self._inside] + yscaled = yscaled[self._inside] + # normalize from 0..1: + norm = colors.Normalize(y[0], y[-1]) + y = np.ma.filled(norm(y), np.nan) + norm = colors.Normalize(yscaled[0], yscaled[-1]) + yscaled = np.ma.filled(norm(yscaled), np.nan) + # make the lower and upper extend lengths proportional to the lengths + # of the first and last boundary spacing (if extendfrac='auto'): + automin = yscaled[1] - yscaled[0] + automax = yscaled[-1] - yscaled[-2] + extendlength = [0, 0] + if self._extend_lower() or self._extend_upper(): + extendlength = self._get_extension_lengths( + self.extendfrac, automin, automax, default=0.05) + return y, extendlength + + def _get_extension_lengths(self, frac, automin, automax, default=0.05): + """ + Return the lengths of colorbar extensions. + + This is a helper method for _uniform_y and _proportional_y. + """ + # Set the default value. + extendlength = np.array([default, default]) + if isinstance(frac, str): + _api.check_in_list(['auto'], extendfrac=frac.lower()) + # Use the provided values when 'auto' is required. + extendlength[:] = [automin, automax] + elif frac is not None: + try: + # Try to set min and max extension fractions directly. + extendlength[:] = frac + # If frac is a sequence containing None then NaN may + # be encountered. This is an error. + if np.isnan(extendlength).any(): + raise ValueError() + except (TypeError, ValueError) as err: + # Raise an error on encountering an invalid value for frac. + raise ValueError('invalid value for extendfrac') from err + return extendlength + + def _extend_lower(self): + """Return whether the lower limit is open ended.""" + minmax = "max" if self._long_axis().get_inverted() else "min" + return self.extend in ('both', minmax) + + def _extend_upper(self): + """Return whether the upper limit is open ended.""" + minmax = "min" if self._long_axis().get_inverted() else "max" + return self.extend in ('both', minmax) + + def _long_axis(self): + """Return the long axis""" + if self.orientation == 'vertical': + return self.ax.yaxis + return self.ax.xaxis + + def _short_axis(self): + """Return the short axis""" + if self.orientation == 'vertical': + return self.ax.xaxis + return self.ax.yaxis + + def _get_view(self): + # docstring inherited + # An interactive view for a colorbar is the norm's vmin/vmax + return self.norm.vmin, self.norm.vmax + + def _set_view(self, view): + # docstring inherited + # An interactive view for a colorbar is the norm's vmin/vmax + self.norm.vmin, self.norm.vmax = view + + def _set_view_from_bbox(self, bbox, direction='in', + mode=None, twinx=False, twiny=False): + # docstring inherited + # For colorbars, we use the zoom bbox to scale the norm's vmin/vmax + new_xbound, new_ybound = self.ax._prepare_view_from_bbox( + bbox, direction=direction, mode=mode, twinx=twinx, twiny=twiny) + if self.orientation == 'horizontal': + self.norm.vmin, self.norm.vmax = new_xbound + elif self.orientation == 'vertical': + self.norm.vmin, self.norm.vmax = new_ybound + + def drag_pan(self, button, key, x, y): + # docstring inherited + points = self.ax._get_pan_points(button, key, x, y) + if points is not None: + if self.orientation == 'horizontal': + self.norm.vmin, self.norm.vmax = points[:, 0] + elif self.orientation == 'vertical': + self.norm.vmin, self.norm.vmax = points[:, 1] + + +ColorbarBase = Colorbar # Backcompat API + + +def _normalize_location_orientation(location, orientation): + if location is None: + location = _get_ticklocation_from_orientation(orientation) + loc_settings = _api.check_getitem({ + "left": {"location": "left", "anchor": (1.0, 0.5), + "panchor": (0.0, 0.5), "pad": 0.10}, + "right": {"location": "right", "anchor": (0.0, 0.5), + "panchor": (1.0, 0.5), "pad": 0.05}, + "top": {"location": "top", "anchor": (0.5, 0.0), + "panchor": (0.5, 1.0), "pad": 0.05}, + "bottom": {"location": "bottom", "anchor": (0.5, 1.0), + "panchor": (0.5, 0.0), "pad": 0.15}, + }, location=location) + loc_settings["orientation"] = _get_orientation_from_location(location) + if orientation is not None and orientation != loc_settings["orientation"]: + # Allow the user to pass both if they are consistent. + raise TypeError("location and orientation are mutually exclusive") + return loc_settings + + +def _get_orientation_from_location(location): + return _api.check_getitem( + {None: None, "left": "vertical", "right": "vertical", + "top": "horizontal", "bottom": "horizontal"}, location=location) + + +def _get_ticklocation_from_orientation(orientation): + return _api.check_getitem( + {None: "right", "vertical": "right", "horizontal": "bottom"}, + orientation=orientation) + + +@_docstring.interpd +def make_axes(parents, location=None, orientation=None, fraction=0.15, + shrink=1.0, aspect=20, **kwargs): + """ + Create an `~.axes.Axes` suitable for a colorbar. + + The Axes is placed in the figure of the *parents* Axes, by resizing and + repositioning *parents*. + + Parameters + ---------- + parents : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of `~.axes.Axes` + The Axes to use as parents for placing the colorbar. + %(_make_axes_kw_doc)s + + Returns + ------- + cax : `~matplotlib.axes.Axes` + The child Axes. + kwargs : dict + The reduced keyword dictionary to be passed when creating the colorbar + instance. + """ + loc_settings = _normalize_location_orientation(location, orientation) + # put appropriate values into the kwargs dict for passing back to + # the Colorbar class + kwargs['orientation'] = loc_settings['orientation'] + location = kwargs['ticklocation'] = loc_settings['location'] + + anchor = kwargs.pop('anchor', loc_settings['anchor']) + panchor = kwargs.pop('panchor', loc_settings['panchor']) + aspect0 = aspect + # turn parents into a list if it is not already. Note we cannot + # use .flatten or .ravel as these copy the references rather than + # reuse them, leading to a memory leak + if isinstance(parents, np.ndarray): + parents = list(parents.flat) + elif np.iterable(parents): + parents = list(parents) + else: + parents = [parents] + + fig = parents[0].get_figure() + + pad0 = 0.05 if fig.get_constrained_layout() else loc_settings['pad'] + pad = kwargs.pop('pad', pad0) + + if not all(fig is ax.get_figure() for ax in parents): + raise ValueError('Unable to create a colorbar Axes as not all ' + 'parents share the same figure.') + + # take a bounding box around all of the given Axes + parents_bbox = mtransforms.Bbox.union( + [ax.get_position(original=True).frozen() for ax in parents]) + + pb = parents_bbox + if location in ('left', 'right'): + if location == 'left': + pbcb, _, pb1 = pb.splitx(fraction, fraction + pad) + else: + pb1, _, pbcb = pb.splitx(1 - fraction - pad, 1 - fraction) + pbcb = pbcb.shrunk(1.0, shrink).anchored(anchor, pbcb) + else: + if location == 'bottom': + pbcb, _, pb1 = pb.splity(fraction, fraction + pad) + else: + pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction) + pbcb = pbcb.shrunk(shrink, 1.0).anchored(anchor, pbcb) + + # define the aspect ratio in terms of y's per x rather than x's per y + aspect = 1.0 / aspect + + # define a transform which takes us from old axes coordinates to + # new axes coordinates + shrinking_trans = mtransforms.BboxTransform(parents_bbox, pb1) + + # transform each of the Axes in parents using the new transform + for ax in parents: + new_posn = shrinking_trans.transform(ax.get_position(original=True)) + new_posn = mtransforms.Bbox(new_posn) + ax._set_position(new_posn) + if panchor is not False: + ax.set_anchor(panchor) + + cax = fig.add_axes(pbcb, label="") + for a in parents: + # tell the parent it has a colorbar + a._colorbars += [cax] + cax._colorbar_info = dict( + parents=parents, + location=location, + shrink=shrink, + anchor=anchor, + panchor=panchor, + fraction=fraction, + aspect=aspect0, + pad=pad) + # and we need to set the aspect ratio by hand... + cax.set_anchor(anchor) + cax.set_box_aspect(aspect) + cax.set_aspect('auto') + + return cax, kwargs + + +@_docstring.interpd +def make_axes_gridspec(parent, *, location=None, orientation=None, + fraction=0.15, shrink=1.0, aspect=20, **kwargs): + """ + Create an `~.axes.Axes` suitable for a colorbar. + + The Axes is placed in the figure of the *parent* Axes, by resizing and + repositioning *parent*. + + This function is similar to `.make_axes` and mostly compatible with it. + Primary differences are + + - `.make_axes_gridspec` requires the *parent* to have a subplotspec. + - `.make_axes` positions the Axes in figure coordinates; + `.make_axes_gridspec` positions it using a subplotspec. + - `.make_axes` updates the position of the parent. `.make_axes_gridspec` + replaces the parent gridspec with a new one. + + Parameters + ---------- + parent : `~matplotlib.axes.Axes` + The Axes to use as parent for placing the colorbar. + %(_make_axes_kw_doc)s + + Returns + ------- + cax : `~matplotlib.axes.Axes` + The child Axes. + kwargs : dict + The reduced keyword dictionary to be passed when creating the colorbar + instance. + """ + + loc_settings = _normalize_location_orientation(location, orientation) + kwargs['orientation'] = loc_settings['orientation'] + location = kwargs['ticklocation'] = loc_settings['location'] + + aspect0 = aspect + anchor = kwargs.pop('anchor', loc_settings['anchor']) + panchor = kwargs.pop('panchor', loc_settings['panchor']) + pad = kwargs.pop('pad', loc_settings["pad"]) + wh_space = 2 * pad / (1 - pad) + + if location in ('left', 'right'): + gs = parent.get_subplotspec().subgridspec( + 3, 2, wspace=wh_space, hspace=0, + height_ratios=[(1-anchor[1])*(1-shrink), shrink, anchor[1]*(1-shrink)]) + if location == 'left': + gs.set_width_ratios([fraction, 1 - fraction - pad]) + ss_main = gs[:, 1] + ss_cb = gs[1, 0] + else: + gs.set_width_ratios([1 - fraction - pad, fraction]) + ss_main = gs[:, 0] + ss_cb = gs[1, 1] + else: + gs = parent.get_subplotspec().subgridspec( + 2, 3, hspace=wh_space, wspace=0, + width_ratios=[anchor[0]*(1-shrink), shrink, (1-anchor[0])*(1-shrink)]) + if location == 'top': + gs.set_height_ratios([fraction, 1 - fraction - pad]) + ss_main = gs[1, :] + ss_cb = gs[0, 1] + else: + gs.set_height_ratios([1 - fraction - pad, fraction]) + ss_main = gs[0, :] + ss_cb = gs[1, 1] + aspect = 1 / aspect + + parent.set_subplotspec(ss_main) + if panchor is not False: + parent.set_anchor(panchor) + + fig = parent.get_figure() + cax = fig.add_subplot(ss_cb, label="") + cax.set_anchor(anchor) + cax.set_box_aspect(aspect) + cax.set_aspect('auto') + cax._colorbar_info = dict( + location=location, + parents=[parent], + shrink=shrink, + anchor=anchor, + panchor=panchor, + fraction=fraction, + aspect=aspect0, + pad=pad) + + return cax, kwargs diff --git a/venv/lib/python3.10/site-packages/matplotlib/colorbar.pyi b/venv/lib/python3.10/site-packages/matplotlib/colorbar.pyi new file mode 100644 index 00000000..f71c5759 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/colorbar.pyi @@ -0,0 +1,136 @@ +import matplotlib.spines as mspines +from matplotlib import cm, collections, colors, contour +from matplotlib.axes import Axes +from matplotlib.backend_bases import RendererBase +from matplotlib.patches import Patch +from matplotlib.ticker import Locator, Formatter +from matplotlib.transforms import Bbox + +import numpy as np +from numpy.typing import ArrayLike +from collections.abc import Sequence +from typing import Any, Literal, overload +from .typing import ColorType + +class _ColorbarSpine(mspines.Spines): + def __init__(self, axes: Axes): ... + def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox:... + def set_xy(self, xy: ArrayLike) -> None: ... + def draw(self, renderer: RendererBase | None) -> None:... + + +class Colorbar: + n_rasterize: int + mappable: cm.ScalarMappable + ax: Axes + alpha: float | None + cmap: colors.Colormap + norm: colors.Normalize + values: Sequence[float] | None + boundaries: Sequence[float] | None + extend: Literal["neither", "both", "min", "max"] + spacing: Literal["uniform", "proportional"] + orientation: Literal["vertical", "horizontal"] + drawedges: bool + extendfrac: Literal["auto"] | float | Sequence[float] | None + extendrect: bool + solids: None | collections.QuadMesh + solids_patches: list[Patch] + lines: list[collections.LineCollection] + outline: _ColorbarSpine + dividers: collections.LineCollection + ticklocation: Literal["left", "right", "top", "bottom"] + def __init__( + self, + ax: Axes, + mappable: cm.ScalarMappable | None = ..., + *, + cmap: str | colors.Colormap | None = ..., + norm: colors.Normalize | None = ..., + alpha: float | None = ..., + values: Sequence[float] | None = ..., + boundaries: Sequence[float] | None = ..., + orientation: Literal["vertical", "horizontal"] | None = ..., + ticklocation: Literal["auto", "left", "right", "top", "bottom"] = ..., + extend: Literal["neither", "both", "min", "max"] | None = ..., + spacing: Literal["uniform", "proportional"] = ..., + ticks: Sequence[float] | Locator | None = ..., + format: str | Formatter | None = ..., + drawedges: bool = ..., + extendfrac: Literal["auto"] | float | Sequence[float] | None = ..., + extendrect: bool = ..., + label: str = ..., + location: Literal["left", "right", "top", "bottom"] | None = ... + ) -> None: ... + @property + def locator(self) -> Locator: ... + @locator.setter + def locator(self, loc: Locator) -> None: ... + @property + def minorlocator(self) -> Locator: ... + @minorlocator.setter + def minorlocator(self, loc: Locator) -> None: ... + @property + def formatter(self) -> Formatter: ... + @formatter.setter + def formatter(self, fmt: Formatter) -> None: ... + @property + def minorformatter(self) -> Formatter: ... + @minorformatter.setter + def minorformatter(self, fmt: Formatter) -> None: ... + def update_normal(self, mappable: cm.ScalarMappable) -> None: ... + @overload + def add_lines(self, CS: contour.ContourSet, erase: bool = ...) -> None: ... + @overload + def add_lines( + self, + levels: ArrayLike, + colors: ColorType | Sequence[ColorType], + linewidths: float | ArrayLike, + erase: bool = ..., + ) -> None: ... + def update_ticks(self) -> None: ... + def set_ticks( + self, + ticks: Sequence[float] | Locator, + *, + labels: Sequence[str] | None = ..., + minor: bool = ..., + **kwargs + ) -> None: ... + def get_ticks(self, minor: bool = ...) -> np.ndarray: ... + def set_ticklabels( + self, + ticklabels: Sequence[str], + *, + minor: bool = ..., + **kwargs + ) -> None: ... + def minorticks_on(self) -> None: ... + def minorticks_off(self) -> None: ... + def set_label(self, label: str, *, loc: str | None = ..., **kwargs) -> None: ... + def set_alpha(self, alpha: float | np.ndarray) -> None: ... + def remove(self) -> None: ... + def drag_pan(self, button: Any, key: Any, x: float, y: float) -> None: ... + +ColorbarBase = Colorbar + +def make_axes( + parents: Axes | list[Axes] | np.ndarray, + location: Literal["left", "right", "top", "bottom"] | None = ..., + orientation: Literal["vertical", "horizontal"] | None = ..., + fraction: float = ..., + shrink: float = ..., + aspect: float = ..., + **kwargs +) -> tuple[Axes, dict[str, Any]]: ... +def make_axes_gridspec( + parent: Axes, + *, + location: Literal["left", "right", "top", "bottom"] | None = ..., + orientation: Literal["vertical", "horizontal"] | None = ..., + fraction: float = ..., + shrink: float = ..., + aspect: float = ..., + **kwargs +) -> tuple[Axes, dict[str, Any]]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/colors.py b/venv/lib/python3.10/site-packages/matplotlib/colors.py new file mode 100644 index 00000000..c4e5987f --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/colors.py @@ -0,0 +1,2810 @@ +""" +A module for converting numbers or color arguments to *RGB* or *RGBA*. + +*RGB* and *RGBA* are sequences of, respectively, 3 or 4 floats in the +range 0-1. + +This module includes functions and classes for color specification conversions, +and for mapping numbers to colors in a 1-D array of colors called a colormap. + +Mapping data onto colors using a colormap typically involves two steps: a data +array is first mapped onto the range 0-1 using a subclass of `Normalize`, +then this number is mapped to a color using a subclass of `Colormap`. Two +subclasses of `Colormap` provided here: `LinearSegmentedColormap`, which uses +piecewise-linear interpolation to define colormaps, and `ListedColormap`, which +makes a colormap from a list of colors. + +.. seealso:: + + :ref:`colormap-manipulation` for examples of how to + make colormaps and + + :ref:`colormaps` for a list of built-in colormaps. + + :ref:`colormapnorms` for more details about data + normalization + + More colormaps are available at palettable_. + +The module also provides functions for checking whether an object can be +interpreted as a color (`is_color_like`), for converting such an object +to an RGBA tuple (`to_rgba`) or to an HTML-like hex string in the +"#rrggbb" format (`to_hex`), and a sequence of colors to an (n, 4) +RGBA array (`to_rgba_array`). Caching is used for efficiency. + +Colors that Matplotlib recognizes are listed at +:ref:`colors_def`. + +.. _palettable: https://jiffyclub.github.io/palettable/ +.. _xkcd color survey: https://xkcd.com/color/rgb/ +""" + +import base64 +from collections.abc import Sized, Sequence, Mapping +import functools +import importlib +import inspect +import io +import itertools +from numbers import Real +import re + +from PIL import Image +from PIL.PngImagePlugin import PngInfo + +import matplotlib as mpl +import numpy as np +from matplotlib import _api, _cm, cbook, scale +from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, XKCD_COLORS + + +class _ColorMapping(dict): + def __init__(self, mapping): + super().__init__(mapping) + self.cache = {} + + def __setitem__(self, key, value): + super().__setitem__(key, value) + self.cache.clear() + + def __delitem__(self, key): + super().__delitem__(key) + self.cache.clear() + + +_colors_full_map = {} +# Set by reverse priority order. +_colors_full_map.update(XKCD_COLORS) +_colors_full_map.update({k.replace('grey', 'gray'): v + for k, v in XKCD_COLORS.items() + if 'grey' in k}) +_colors_full_map.update(CSS4_COLORS) +_colors_full_map.update(TABLEAU_COLORS) +_colors_full_map.update({k.replace('gray', 'grey'): v + for k, v in TABLEAU_COLORS.items() + if 'gray' in k}) +_colors_full_map.update(BASE_COLORS) +_colors_full_map = _ColorMapping(_colors_full_map) + +_REPR_PNG_SIZE = (512, 64) + + +def get_named_colors_mapping(): + """Return the global mapping of names to named colors.""" + return _colors_full_map + + +class ColorSequenceRegistry(Mapping): + r""" + Container for sequences of colors that are known to Matplotlib by name. + + The universal registry instance is `matplotlib.color_sequences`. There + should be no need for users to instantiate `.ColorSequenceRegistry` + themselves. + + Read access uses a dict-like interface mapping names to lists of colors:: + + import matplotlib as mpl + cmap = mpl.color_sequences['tab10'] + + The returned lists are copies, so that their modification does not change + the global definition of the color sequence. + + Additional color sequences can be added via + `.ColorSequenceRegistry.register`:: + + mpl.color_sequences.register('rgb', ['r', 'g', 'b']) + """ + + _BUILTIN_COLOR_SEQUENCES = { + 'tab10': _cm._tab10_data, + 'tab20': _cm._tab20_data, + 'tab20b': _cm._tab20b_data, + 'tab20c': _cm._tab20c_data, + 'Pastel1': _cm._Pastel1_data, + 'Pastel2': _cm._Pastel2_data, + 'Paired': _cm._Paired_data, + 'Accent': _cm._Accent_data, + 'Dark2': _cm._Dark2_data, + 'Set1': _cm._Set1_data, + 'Set2': _cm._Set2_data, + 'Set3': _cm._Set3_data, + } + + def __init__(self): + self._color_sequences = {**self._BUILTIN_COLOR_SEQUENCES} + + def __getitem__(self, item): + try: + return list(self._color_sequences[item]) + except KeyError: + raise KeyError(f"{item!r} is not a known color sequence name") + + def __iter__(self): + return iter(self._color_sequences) + + def __len__(self): + return len(self._color_sequences) + + def __str__(self): + return ('ColorSequenceRegistry; available colormaps:\n' + + ', '.join(f"'{name}'" for name in self)) + + def register(self, name, color_list): + """ + Register a new color sequence. + + The color sequence registry stores a copy of the given *color_list*, so + that future changes to the original list do not affect the registered + color sequence. Think of this as the registry taking a snapshot + of *color_list* at registration. + + Parameters + ---------- + name : str + The name for the color sequence. + + color_list : list of :mpltype:`color` + An iterable returning valid Matplotlib colors when iterating over. + Note however that the returned color sequence will always be a + list regardless of the input type. + + """ + if name in self._BUILTIN_COLOR_SEQUENCES: + raise ValueError(f"{name!r} is a reserved name for a builtin " + "color sequence") + + color_list = list(color_list) # force copy and coerce type to list + for color in color_list: + try: + to_rgba(color) + except ValueError: + raise ValueError( + f"{color!r} is not a valid color specification") + + self._color_sequences[name] = color_list + + def unregister(self, name): + """ + Remove a sequence from the registry. + + You cannot remove built-in color sequences. + + If the name is not registered, returns with no error. + """ + if name in self._BUILTIN_COLOR_SEQUENCES: + raise ValueError( + f"Cannot unregister builtin color sequence {name!r}") + self._color_sequences.pop(name, None) + + +_color_sequences = ColorSequenceRegistry() + + +def _sanitize_extrema(ex): + if ex is None: + return ex + try: + ret = ex.item() + except AttributeError: + ret = float(ex) + return ret + +_nth_color_re = re.compile(r"\AC[0-9]+\Z") + + +def _is_nth_color(c): + """Return whether *c* can be interpreted as an item in the color cycle.""" + return isinstance(c, str) and _nth_color_re.match(c) + + +def is_color_like(c): + """Return whether *c* can be interpreted as an RGB(A) color.""" + # Special-case nth color syntax because it cannot be parsed during setup. + if _is_nth_color(c): + return True + try: + to_rgba(c) + except ValueError: + return False + else: + return True + + +def _has_alpha_channel(c): + """Return whether *c* is a color with an alpha channel.""" + # 4-element sequences are interpreted as r, g, b, a + return not isinstance(c, str) and len(c) == 4 + + +def _check_color_like(**kwargs): + """ + For each *key, value* pair in *kwargs*, check that *value* is color-like. + """ + for k, v in kwargs.items(): + if not is_color_like(v): + raise ValueError( + f"{v!r} is not a valid value for {k}: supported inputs are " + f"(r, g, b) and (r, g, b, a) 0-1 float tuples; " + f"'#rrggbb', '#rrggbbaa', '#rgb', '#rgba' strings; " + f"named color strings; " + f"string reprs of 0-1 floats for grayscale values; " + f"'C0', 'C1', ... strings for colors of the color cycle; " + f"and pairs combining one of the above with an alpha value") + + +def same_color(c1, c2): + """ + Return whether the colors *c1* and *c2* are the same. + + *c1*, *c2* can be single colors or lists/arrays of colors. + """ + c1 = to_rgba_array(c1) + c2 = to_rgba_array(c2) + n1 = max(c1.shape[0], 1) # 'none' results in shape (0, 4), but is 1-elem + n2 = max(c2.shape[0], 1) # 'none' results in shape (0, 4), but is 1-elem + + if n1 != n2: + raise ValueError('Different number of elements passed.') + # The following shape test is needed to correctly handle comparisons with + # 'none', which results in a shape (0, 4) array and thus cannot be tested + # via value comparison. + return c1.shape == c2.shape and (c1 == c2).all() + + +def to_rgba(c, alpha=None): + """ + Convert *c* to an RGBA color. + + Parameters + ---------- + c : Matplotlib color or ``np.ma.masked`` + + alpha : float, optional + If *alpha* is given, force the alpha value of the returned RGBA tuple + to *alpha*. + + If None, the alpha value from *c* is used. If *c* does not have an + alpha channel, then alpha defaults to 1. + + *alpha* is ignored for the color value ``"none"`` (case-insensitive), + which always maps to ``(0, 0, 0, 0)``. + + Returns + ------- + tuple + Tuple of floats ``(r, g, b, a)``, where each channel (red, green, blue, + alpha) can assume values between 0 and 1. + """ + # Special-case nth color syntax because it should not be cached. + if _is_nth_color(c): + prop_cycler = mpl.rcParams['axes.prop_cycle'] + colors = prop_cycler.by_key().get('color', ['k']) + c = colors[int(c[1:]) % len(colors)] + try: + rgba = _colors_full_map.cache[c, alpha] + except (KeyError, TypeError): # Not in cache, or unhashable. + rgba = None + if rgba is None: # Suppress exception chaining of cache lookup failure. + rgba = _to_rgba_no_colorcycle(c, alpha) + try: + _colors_full_map.cache[c, alpha] = rgba + except TypeError: + pass + return rgba + + +def _to_rgba_no_colorcycle(c, alpha=None): + """ + Convert *c* to an RGBA color, with no support for color-cycle syntax. + + If *alpha* is given, force the alpha value of the returned RGBA tuple + to *alpha*. Otherwise, the alpha value from *c* is used, if it has alpha + information, or defaults to 1. + + *alpha* is ignored for the color value ``"none"`` (case-insensitive), + which always maps to ``(0, 0, 0, 0)``. + """ + if isinstance(c, tuple) and len(c) == 2: + if alpha is None: + c, alpha = c + else: + c = c[0] + if alpha is not None and not 0 <= alpha <= 1: + raise ValueError("'alpha' must be between 0 and 1, inclusive") + orig_c = c + if c is np.ma.masked: + return (0., 0., 0., 0.) + if isinstance(c, str): + if c.lower() == "none": + return (0., 0., 0., 0.) + # Named color. + try: + # This may turn c into a non-string, so we check again below. + c = _colors_full_map[c] + except KeyError: + if len(orig_c) != 1: + try: + c = _colors_full_map[c.lower()] + except KeyError: + pass + if isinstance(c, str): + # hex color in #rrggbb format. + match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c) + if match: + return (tuple(int(n, 16) / 255 + for n in [c[1:3], c[3:5], c[5:7]]) + + (alpha if alpha is not None else 1.,)) + # hex color in #rgb format, shorthand for #rrggbb. + match = re.match(r"\A#[a-fA-F0-9]{3}\Z", c) + if match: + return (tuple(int(n, 16) / 255 + for n in [c[1]*2, c[2]*2, c[3]*2]) + + (alpha if alpha is not None else 1.,)) + # hex color with alpha in #rrggbbaa format. + match = re.match(r"\A#[a-fA-F0-9]{8}\Z", c) + if match: + color = [int(n, 16) / 255 + for n in [c[1:3], c[3:5], c[5:7], c[7:9]]] + if alpha is not None: + color[-1] = alpha + return tuple(color) + # hex color with alpha in #rgba format, shorthand for #rrggbbaa. + match = re.match(r"\A#[a-fA-F0-9]{4}\Z", c) + if match: + color = [int(n, 16) / 255 + for n in [c[1]*2, c[2]*2, c[3]*2, c[4]*2]] + if alpha is not None: + color[-1] = alpha + return tuple(color) + # string gray. + try: + c = float(c) + except ValueError: + pass + else: + if not (0 <= c <= 1): + raise ValueError( + f"Invalid string grayscale value {orig_c!r}. " + f"Value must be within 0-1 range") + return c, c, c, alpha if alpha is not None else 1. + raise ValueError(f"Invalid RGBA argument: {orig_c!r}") + # turn 2-D array into 1-D array + if isinstance(c, np.ndarray): + if c.ndim == 2 and c.shape[0] == 1: + c = c.reshape(-1) + # tuple color. + if not np.iterable(c): + raise ValueError(f"Invalid RGBA argument: {orig_c!r}") + if len(c) not in [3, 4]: + raise ValueError("RGBA sequence should have length 3 or 4") + if not all(isinstance(x, Real) for x in c): + # Checks that don't work: `map(float, ...)`, `np.array(..., float)` and + # `np.array(...).astype(float)` would all convert "0.5" to 0.5. + raise ValueError(f"Invalid RGBA argument: {orig_c!r}") + # Return a tuple to prevent the cached value from being modified. + c = tuple(map(float, c)) + if len(c) == 3 and alpha is None: + alpha = 1 + if alpha is not None: + c = c[:3] + (alpha,) + if any(elem < 0 or elem > 1 for elem in c): + raise ValueError("RGBA values should be within 0-1 range") + return c + + +def to_rgba_array(c, alpha=None): + """ + Convert *c* to a (n, 4) array of RGBA colors. + + Parameters + ---------- + c : Matplotlib color or array of colors + If *c* is a masked array, an `~numpy.ndarray` is returned with a + (0, 0, 0, 0) row for each masked value or row in *c*. + + alpha : float or sequence of floats, optional + If *alpha* is given, force the alpha value of the returned RGBA tuple + to *alpha*. + + If None, the alpha value from *c* is used. If *c* does not have an + alpha channel, then alpha defaults to 1. + + *alpha* is ignored for the color value ``"none"`` (case-insensitive), + which always maps to ``(0, 0, 0, 0)``. + + If *alpha* is a sequence and *c* is a single color, *c* will be + repeated to match the length of *alpha*. + + Returns + ------- + array + (n, 4) array of RGBA colors, where each channel (red, green, blue, + alpha) can assume values between 0 and 1. + """ + if isinstance(c, tuple) and len(c) == 2 and isinstance(c[1], Real): + if alpha is None: + c, alpha = c + else: + c = c[0] + # Special-case inputs that are already arrays, for performance. (If the + # array has the wrong kind or shape, raise the error during one-at-a-time + # conversion.) + if np.iterable(alpha): + alpha = np.asarray(alpha).ravel() + if (isinstance(c, np.ndarray) and c.dtype.kind in "if" + and c.ndim == 2 and c.shape[1] in [3, 4]): + mask = c.mask.any(axis=1) if np.ma.is_masked(c) else None + c = np.ma.getdata(c) + if np.iterable(alpha): + if c.shape[0] == 1 and alpha.shape[0] > 1: + c = np.tile(c, (alpha.shape[0], 1)) + elif c.shape[0] != alpha.shape[0]: + raise ValueError("The number of colors must match the number" + " of alpha values if there are more than one" + " of each.") + if c.shape[1] == 3: + result = np.column_stack([c, np.zeros(len(c))]) + result[:, -1] = alpha if alpha is not None else 1. + elif c.shape[1] == 4: + result = c.copy() + if alpha is not None: + result[:, -1] = alpha + if mask is not None: + result[mask] = 0 + if np.any((result < 0) | (result > 1)): + raise ValueError("RGBA values should be within 0-1 range") + return result + # Handle single values. + # Note that this occurs *after* handling inputs that are already arrays, as + # `to_rgba(c, alpha)` (below) is expensive for such inputs, due to the need + # to format the array in the ValueError message(!). + if cbook._str_lower_equal(c, "none"): + return np.zeros((0, 4), float) + try: + if np.iterable(alpha): + return np.array([to_rgba(c, a) for a in alpha], float) + else: + return np.array([to_rgba(c, alpha)], float) + except TypeError: + pass + except ValueError as e: + if e.args == ("'alpha' must be between 0 and 1, inclusive", ): + # ValueError is from _to_rgba_no_colorcycle(). + raise e + if isinstance(c, str): + raise ValueError(f"{c!r} is not a valid color value.") + + if len(c) == 0: + return np.zeros((0, 4), float) + + # Quick path if the whole sequence can be directly converted to a numpy + # array in one shot. + if isinstance(c, Sequence): + lens = {len(cc) if isinstance(cc, (list, tuple)) else -1 for cc in c} + if lens == {3}: + rgba = np.column_stack([c, np.ones(len(c))]) + elif lens == {4}: + rgba = np.array(c) + else: + rgba = np.array([to_rgba(cc) for cc in c]) + else: + rgba = np.array([to_rgba(cc) for cc in c]) + + if alpha is not None: + rgba[:, 3] = alpha + if isinstance(c, Sequence): + # ensure that an explicit alpha does not overwrite full transparency + # for "none" + none_mask = [cbook._str_equal(cc, "none") for cc in c] + rgba[:, 3][none_mask] = 0 + return rgba + + +def to_rgb(c): + """Convert *c* to an RGB color, silently dropping the alpha channel.""" + return to_rgba(c)[:3] + + +def to_hex(c, keep_alpha=False): + """ + Convert *c* to a hex color. + + Parameters + ---------- + c : :ref:`color ` or `numpy.ma.masked` + + keep_alpha : bool, default: False + If False, use the ``#rrggbb`` format, otherwise use ``#rrggbbaa``. + + Returns + ------- + str + ``#rrggbb`` or ``#rrggbbaa`` hex color string + """ + c = to_rgba(c) + if not keep_alpha: + c = c[:3] + return "#" + "".join(format(round(val * 255), "02x") for val in c) + + +### Backwards-compatible color-conversion API + + +cnames = CSS4_COLORS +hexColorPattern = re.compile(r"\A#[a-fA-F0-9]{6}\Z") +rgb2hex = to_hex +hex2color = to_rgb + + +class ColorConverter: + """ + A class only kept for backwards compatibility. + + Its functionality is entirely provided by module-level functions. + """ + colors = _colors_full_map + cache = _colors_full_map.cache + to_rgb = staticmethod(to_rgb) + to_rgba = staticmethod(to_rgba) + to_rgba_array = staticmethod(to_rgba_array) + + +colorConverter = ColorConverter() + + +### End of backwards-compatible color-conversion API + + +def _create_lookup_table(N, data, gamma=1.0): + r""" + Create an *N* -element 1D lookup table. + + This assumes a mapping :math:`f : [0, 1] \rightarrow [0, 1]`. The returned + data is an array of N values :math:`y = f(x)` where x is sampled from + [0, 1]. + + By default (*gamma* = 1) x is equidistantly sampled from [0, 1]. The + *gamma* correction factor :math:`\gamma` distorts this equidistant + sampling by :math:`x \rightarrow x^\gamma`. + + Parameters + ---------- + N : int + The number of elements of the created lookup table; at least 1. + + data : (M, 3) array-like or callable + Defines the mapping :math:`f`. + + If a (M, 3) array-like, the rows define values (x, y0, y1). The x + values must start with x=0, end with x=1, and all x values be in + increasing order. + + A value between :math:`x_i` and :math:`x_{i+1}` is mapped to the range + :math:`y^1_{i-1} \ldots y^0_i` by linear interpolation. + + For the simple case of a y-continuous mapping, y0 and y1 are identical. + + The two values of y are to allow for discontinuous mapping functions. + E.g. a sawtooth with a period of 0.2 and an amplitude of 1 would be:: + + [(0, 1, 0), (0.2, 1, 0), (0.4, 1, 0), ..., [(1, 1, 0)] + + In the special case of ``N == 1``, by convention the returned value + is y0 for x == 1. + + If *data* is a callable, it must accept and return numpy arrays:: + + data(x : ndarray) -> ndarray + + and map values between 0 - 1 to 0 - 1. + + gamma : float + Gamma correction factor for input distribution x of the mapping. + + See also https://en.wikipedia.org/wiki/Gamma_correction. + + Returns + ------- + array + The lookup table where ``lut[x * (N-1)]`` gives the closest value + for values of x between 0 and 1. + + Notes + ----- + This function is internally used for `.LinearSegmentedColormap`. + """ + + if callable(data): + xind = np.linspace(0, 1, N) ** gamma + lut = np.clip(np.array(data(xind), dtype=float), 0, 1) + return lut + + try: + adata = np.array(data) + except Exception as err: + raise TypeError("data must be convertible to an array") from err + _api.check_shape((None, 3), data=adata) + + x = adata[:, 0] + y0 = adata[:, 1] + y1 = adata[:, 2] + + if x[0] != 0. or x[-1] != 1.0: + raise ValueError( + "data mapping points must start with x=0 and end with x=1") + if (np.diff(x) < 0).any(): + raise ValueError("data mapping points must have x in increasing order") + # begin generation of lookup table + if N == 1: + # convention: use the y = f(x=1) value for a 1-element lookup table + lut = np.array(y0[-1]) + else: + x = x * (N - 1) + xind = (N - 1) * np.linspace(0, 1, N) ** gamma + ind = np.searchsorted(x, xind)[1:-1] + + distance = (xind[1:-1] - x[ind - 1]) / (x[ind] - x[ind - 1]) + lut = np.concatenate([ + [y1[0]], + distance * (y0[ind] - y1[ind - 1]) + y1[ind - 1], + [y0[-1]], + ]) + # ensure that the lut is confined to values between 0 and 1 by clipping it + return np.clip(lut, 0.0, 1.0) + + +class Colormap: + """ + Baseclass for all scalar to RGBA mappings. + + Typically, Colormap instances are used to convert data values (floats) + from the interval ``[0, 1]`` to the RGBA color that the respective + Colormap represents. For scaling of data into the ``[0, 1]`` interval see + `matplotlib.colors.Normalize`. Subclasses of `matplotlib.cm.ScalarMappable` + make heavy use of this ``data -> normalize -> map-to-color`` processing + chain. + """ + + def __init__(self, name, N=256): + """ + Parameters + ---------- + name : str + The name of the colormap. + N : int + The number of RGB quantization levels. + """ + self.name = name + self.N = int(N) # ensure that N is always int + self._rgba_bad = (0.0, 0.0, 0.0, 0.0) # If bad, don't paint anything. + self._rgba_under = None + self._rgba_over = None + self._i_under = self.N + self._i_over = self.N + 1 + self._i_bad = self.N + 2 + self._isinit = False + #: When this colormap exists on a scalar mappable and colorbar_extend + #: is not False, colorbar creation will pick up ``colorbar_extend`` as + #: the default value for the ``extend`` keyword in the + #: `matplotlib.colorbar.Colorbar` constructor. + self.colorbar_extend = False + + def __call__(self, X, alpha=None, bytes=False): + r""" + Parameters + ---------- + X : float or int, `~numpy.ndarray` or scalar + The data value(s) to convert to RGBA. + For floats, *X* should be in the interval ``[0.0, 1.0]`` to + return the RGBA values ``X*100`` percent along the Colormap line. + For integers, *X* should be in the interval ``[0, Colormap.N)`` to + return RGBA values *indexed* from the Colormap with index ``X``. + alpha : float or array-like or None + Alpha must be a scalar between 0 and 1, a sequence of such + floats with shape matching X, or None. + bytes : bool + If False (default), the returned RGBA values will be floats in the + interval ``[0, 1]`` otherwise they will be `numpy.uint8`\s in the + interval ``[0, 255]``. + + Returns + ------- + Tuple of RGBA values if X is scalar, otherwise an array of + RGBA values with a shape of ``X.shape + (4, )``. + """ + if not self._isinit: + self._init() + + xa = np.array(X, copy=True) + if not xa.dtype.isnative: + # Native byteorder is faster. + xa = xa.byteswap().view(xa.dtype.newbyteorder()) + if xa.dtype.kind == "f": + xa *= self.N + # xa == 1 (== N after multiplication) is not out of range. + xa[xa == self.N] = self.N - 1 + # Pre-compute the masks before casting to int (which can truncate + # negative values to zero or wrap large floats to negative ints). + mask_under = xa < 0 + mask_over = xa >= self.N + # If input was masked, get the bad mask from it; else mask out nans. + mask_bad = X.mask if np.ma.is_masked(X) else np.isnan(xa) + with np.errstate(invalid="ignore"): + # We need this cast for unsigned ints as well as floats + xa = xa.astype(int) + xa[mask_under] = self._i_under + xa[mask_over] = self._i_over + xa[mask_bad] = self._i_bad + + lut = self._lut + if bytes: + lut = (lut * 255).astype(np.uint8) + + rgba = lut.take(xa, axis=0, mode='clip') + + if alpha is not None: + alpha = np.clip(alpha, 0, 1) + if bytes: + alpha *= 255 # Will be cast to uint8 upon assignment. + if alpha.shape not in [(), xa.shape]: + raise ValueError( + f"alpha is array-like but its shape {alpha.shape} does " + f"not match that of X {xa.shape}") + rgba[..., -1] = alpha + # If the "bad" color is all zeros, then ignore alpha input. + if (lut[-1] == 0).all(): + rgba[mask_bad] = (0, 0, 0, 0) + + if not np.iterable(X): + rgba = tuple(rgba) + return rgba + + def __copy__(self): + cls = self.__class__ + cmapobject = cls.__new__(cls) + cmapobject.__dict__.update(self.__dict__) + if self._isinit: + cmapobject._lut = np.copy(self._lut) + return cmapobject + + def __eq__(self, other): + if (not isinstance(other, Colormap) or + self.colorbar_extend != other.colorbar_extend): + return False + # To compare lookup tables the Colormaps have to be initialized + if not self._isinit: + self._init() + if not other._isinit: + other._init() + return np.array_equal(self._lut, other._lut) + + def get_bad(self): + """Get the color for masked values.""" + if not self._isinit: + self._init() + return np.array(self._lut[self._i_bad]) + + def set_bad(self, color='k', alpha=None): + """Set the color for masked values.""" + self._rgba_bad = to_rgba(color, alpha) + if self._isinit: + self._set_extremes() + + def get_under(self): + """Get the color for low out-of-range values.""" + if not self._isinit: + self._init() + return np.array(self._lut[self._i_under]) + + def set_under(self, color='k', alpha=None): + """Set the color for low out-of-range values.""" + self._rgba_under = to_rgba(color, alpha) + if self._isinit: + self._set_extremes() + + def get_over(self): + """Get the color for high out-of-range values.""" + if not self._isinit: + self._init() + return np.array(self._lut[self._i_over]) + + def set_over(self, color='k', alpha=None): + """Set the color for high out-of-range values.""" + self._rgba_over = to_rgba(color, alpha) + if self._isinit: + self._set_extremes() + + def set_extremes(self, *, bad=None, under=None, over=None): + """ + Set the colors for masked (*bad*) values and, when ``norm.clip = + False``, low (*under*) and high (*over*) out-of-range values. + """ + if bad is not None: + self.set_bad(bad) + if under is not None: + self.set_under(under) + if over is not None: + self.set_over(over) + + def with_extremes(self, *, bad=None, under=None, over=None): + """ + Return a copy of the colormap, for which the colors for masked (*bad*) + values and, when ``norm.clip = False``, low (*under*) and high (*over*) + out-of-range values, have been set accordingly. + """ + new_cm = self.copy() + new_cm.set_extremes(bad=bad, under=under, over=over) + return new_cm + + def _set_extremes(self): + if self._rgba_under: + self._lut[self._i_under] = self._rgba_under + else: + self._lut[self._i_under] = self._lut[0] + if self._rgba_over: + self._lut[self._i_over] = self._rgba_over + else: + self._lut[self._i_over] = self._lut[self.N - 1] + self._lut[self._i_bad] = self._rgba_bad + + def _init(self): + """Generate the lookup table, ``self._lut``.""" + raise NotImplementedError("Abstract class only") + + def is_gray(self): + """Return whether the colormap is grayscale.""" + if not self._isinit: + self._init() + return (np.all(self._lut[:, 0] == self._lut[:, 1]) and + np.all(self._lut[:, 0] == self._lut[:, 2])) + + def resampled(self, lutsize): + """Return a new colormap with *lutsize* entries.""" + if hasattr(self, '_resample'): + _api.warn_external( + "The ability to resample a color map is now public API " + f"However the class {type(self)} still only implements " + "the previous private _resample method. Please update " + "your class." + ) + return self._resample(lutsize) + + raise NotImplementedError() + + def reversed(self, name=None): + """ + Return a reversed instance of the Colormap. + + .. note:: This function is not implemented for the base class. + + Parameters + ---------- + name : str, optional + The name for the reversed colormap. If None, the + name is set to ``self.name + "_r"``. + + See Also + -------- + LinearSegmentedColormap.reversed + ListedColormap.reversed + """ + raise NotImplementedError() + + def _repr_png_(self): + """Generate a PNG representation of the Colormap.""" + X = np.tile(np.linspace(0, 1, _REPR_PNG_SIZE[0]), + (_REPR_PNG_SIZE[1], 1)) + pixels = self(X, bytes=True) + png_bytes = io.BytesIO() + title = self.name + ' colormap' + author = f'Matplotlib v{mpl.__version__}, https://matplotlib.org' + pnginfo = PngInfo() + pnginfo.add_text('Title', title) + pnginfo.add_text('Description', title) + pnginfo.add_text('Author', author) + pnginfo.add_text('Software', author) + Image.fromarray(pixels).save(png_bytes, format='png', pnginfo=pnginfo) + return png_bytes.getvalue() + + def _repr_html_(self): + """Generate an HTML representation of the Colormap.""" + png_bytes = self._repr_png_() + png_base64 = base64.b64encode(png_bytes).decode('ascii') + def color_block(color): + hex_color = to_hex(color, keep_alpha=True) + return (f'
') + + return ('
' + f'{self.name} ' + '
' + '
' + '
' + '
' + f'{color_block(self.get_under())} under' + '
' + '
' + f'bad {color_block(self.get_bad())}' + '
' + '
' + f'over {color_block(self.get_over())}' + '
') + + def copy(self): + """Return a copy of the colormap.""" + return self.__copy__() + + +class LinearSegmentedColormap(Colormap): + """ + Colormap objects based on lookup tables using linear segments. + + The lookup table is generated using linear interpolation for each + primary color, with the 0-1 domain divided into any number of + segments. + """ + + def __init__(self, name, segmentdata, N=256, gamma=1.0): + """ + Create colormap from linear mapping segments + + segmentdata argument is a dictionary with a red, green and blue + entries. Each entry should be a list of *x*, *y0*, *y1* tuples, + forming rows in a table. Entries for alpha are optional. + + Example: suppose you want red to increase from 0 to 1 over + the bottom half, green to do the same over the middle half, + and blue over the top half. Then you would use:: + + cdict = {'red': [(0.0, 0.0, 0.0), + (0.5, 1.0, 1.0), + (1.0, 1.0, 1.0)], + + 'green': [(0.0, 0.0, 0.0), + (0.25, 0.0, 0.0), + (0.75, 1.0, 1.0), + (1.0, 1.0, 1.0)], + + 'blue': [(0.0, 0.0, 0.0), + (0.5, 0.0, 0.0), + (1.0, 1.0, 1.0)]} + + Each row in the table for a given color is a sequence of + *x*, *y0*, *y1* tuples. In each sequence, *x* must increase + monotonically from 0 to 1. For any input value *z* falling + between *x[i]* and *x[i+1]*, the output value of a given color + will be linearly interpolated between *y1[i]* and *y0[i+1]*:: + + row i: x y0 y1 + / + / + row i+1: x y0 y1 + + Hence y0 in the first row and y1 in the last row are never used. + + See Also + -------- + LinearSegmentedColormap.from_list + Static method; factory function for generating a smoothly-varying + LinearSegmentedColormap. + """ + # True only if all colors in map are identical; needed for contouring. + self.monochrome = False + super().__init__(name, N) + self._segmentdata = segmentdata + self._gamma = gamma + + def _init(self): + self._lut = np.ones((self.N + 3, 4), float) + self._lut[:-3, 0] = _create_lookup_table( + self.N, self._segmentdata['red'], self._gamma) + self._lut[:-3, 1] = _create_lookup_table( + self.N, self._segmentdata['green'], self._gamma) + self._lut[:-3, 2] = _create_lookup_table( + self.N, self._segmentdata['blue'], self._gamma) + if 'alpha' in self._segmentdata: + self._lut[:-3, 3] = _create_lookup_table( + self.N, self._segmentdata['alpha'], 1) + self._isinit = True + self._set_extremes() + + def set_gamma(self, gamma): + """Set a new gamma value and regenerate colormap.""" + self._gamma = gamma + self._init() + + @staticmethod + def from_list(name, colors, N=256, gamma=1.0): + """ + Create a `LinearSegmentedColormap` from a list of colors. + + Parameters + ---------- + name : str + The name of the colormap. + colors : list of :mpltype:`color` or list of (value, color) + If only colors are given, they are equidistantly mapped from the + range :math:`[0, 1]`; i.e. 0 maps to ``colors[0]`` and 1 maps to + ``colors[-1]``. + If (value, color) pairs are given, the mapping is from *value* + to *color*. This can be used to divide the range unevenly. + N : int + The number of RGB quantization levels. + gamma : float + """ + if not np.iterable(colors): + raise ValueError('colors must be iterable') + + if (isinstance(colors[0], Sized) and len(colors[0]) == 2 + and not isinstance(colors[0], str)): + # List of value, color pairs + vals, colors = zip(*colors) + else: + vals = np.linspace(0, 1, len(colors)) + + r, g, b, a = to_rgba_array(colors).T + cdict = { + "red": np.column_stack([vals, r, r]), + "green": np.column_stack([vals, g, g]), + "blue": np.column_stack([vals, b, b]), + "alpha": np.column_stack([vals, a, a]), + } + + return LinearSegmentedColormap(name, cdict, N, gamma) + + def resampled(self, lutsize): + """Return a new colormap with *lutsize* entries.""" + new_cmap = LinearSegmentedColormap(self.name, self._segmentdata, + lutsize) + new_cmap._rgba_over = self._rgba_over + new_cmap._rgba_under = self._rgba_under + new_cmap._rgba_bad = self._rgba_bad + return new_cmap + + # Helper ensuring picklability of the reversed cmap. + @staticmethod + def _reverser(func, x): + return func(1 - x) + + def reversed(self, name=None): + """ + Return a reversed instance of the Colormap. + + Parameters + ---------- + name : str, optional + The name for the reversed colormap. If None, the + name is set to ``self.name + "_r"``. + + Returns + ------- + LinearSegmentedColormap + The reversed colormap. + """ + if name is None: + name = self.name + "_r" + + # Using a partial object keeps the cmap picklable. + data_r = {key: (functools.partial(self._reverser, data) + if callable(data) else + [(1.0 - x, y1, y0) for x, y0, y1 in reversed(data)]) + for key, data in self._segmentdata.items()} + + new_cmap = LinearSegmentedColormap(name, data_r, self.N, self._gamma) + # Reverse the over/under values too + new_cmap._rgba_over = self._rgba_under + new_cmap._rgba_under = self._rgba_over + new_cmap._rgba_bad = self._rgba_bad + return new_cmap + + +class ListedColormap(Colormap): + """ + Colormap object generated from a list of colors. + + This may be most useful when indexing directly into a colormap, + but it can also be used to generate special colormaps for ordinary + mapping. + + Parameters + ---------- + colors : list, array + Sequence of Matplotlib color specifications (color names or RGB(A) + values). + name : str, optional + String to identify the colormap. + N : int, optional + Number of entries in the map. The default is *None*, in which case + there is one colormap entry for each element in the list of colors. + If :: + + N < len(colors) + + the list will be truncated at *N*. If :: + + N > len(colors) + + the list will be extended by repetition. + """ + def __init__(self, colors, name='from_list', N=None): + self.monochrome = False # Are all colors identical? (for contour.py) + if N is None: + self.colors = colors + N = len(colors) + else: + if isinstance(colors, str): + self.colors = [colors] * N + self.monochrome = True + elif np.iterable(colors): + if len(colors) == 1: + self.monochrome = True + self.colors = list( + itertools.islice(itertools.cycle(colors), N)) + else: + try: + gray = float(colors) + except TypeError: + pass + else: + self.colors = [gray] * N + self.monochrome = True + super().__init__(name, N) + + def _init(self): + self._lut = np.zeros((self.N + 3, 4), float) + self._lut[:-3] = to_rgba_array(self.colors) + self._isinit = True + self._set_extremes() + + def resampled(self, lutsize): + """Return a new colormap with *lutsize* entries.""" + colors = self(np.linspace(0, 1, lutsize)) + new_cmap = ListedColormap(colors, name=self.name) + # Keep the over/under values too + new_cmap._rgba_over = self._rgba_over + new_cmap._rgba_under = self._rgba_under + new_cmap._rgba_bad = self._rgba_bad + return new_cmap + + def reversed(self, name=None): + """ + Return a reversed instance of the Colormap. + + Parameters + ---------- + name : str, optional + The name for the reversed colormap. If None, the + name is set to ``self.name + "_r"``. + + Returns + ------- + ListedColormap + A reversed instance of the colormap. + """ + if name is None: + name = self.name + "_r" + + colors_r = list(reversed(self.colors)) + new_cmap = ListedColormap(colors_r, name=name, N=self.N) + # Reverse the over/under values too + new_cmap._rgba_over = self._rgba_under + new_cmap._rgba_under = self._rgba_over + new_cmap._rgba_bad = self._rgba_bad + return new_cmap + + +class Normalize: + """ + A class which, when called, maps values within the interval + ``[vmin, vmax]`` linearly to the interval ``[0.0, 1.0]``. The mapping of + values outside ``[vmin, vmax]`` depends on *clip*. + + Examples + -------- + :: + + x = [-2, -1, 0, 1, 2] + + norm = mpl.colors.Normalize(vmin=-1, vmax=1, clip=False) + norm(x) # [-0.5, 0., 0.5, 1., 1.5] + norm = mpl.colors.Normalize(vmin=-1, vmax=1, clip=True) + norm(x) # [0., 0., 0.5, 1., 1.] + + See Also + -------- + :ref:`colormapnorms` + """ + + def __init__(self, vmin=None, vmax=None, clip=False): + """ + Parameters + ---------- + vmin, vmax : float or None + Values within the range ``[vmin, vmax]`` from the input data will be + linearly mapped to ``[0, 1]``. If either *vmin* or *vmax* is not + provided, they default to the minimum and maximum values of the input, + respectively. + + clip : bool, default: False + Determines the behavior for mapping values outside the range + ``[vmin, vmax]``. + + If clipping is off, values outside the range ``[vmin, vmax]`` are + also transformed, resulting in values outside ``[0, 1]``. This + behavior is usually desirable, as colormaps can mark these *under* + and *over* values with specific colors. + + If clipping is on, values below *vmin* are mapped to 0 and values + above *vmax* are mapped to 1. Such values become indistinguishable + from regular boundary values, which may cause misinterpretation of + the data. + + Notes + ----- + If ``vmin == vmax``, input data will be mapped to 0. + """ + self._vmin = _sanitize_extrema(vmin) + self._vmax = _sanitize_extrema(vmax) + self._clip = clip + self._scale = None + self.callbacks = cbook.CallbackRegistry(signals=["changed"]) + + @property + def vmin(self): + return self._vmin + + @vmin.setter + def vmin(self, value): + value = _sanitize_extrema(value) + if value != self._vmin: + self._vmin = value + self._changed() + + @property + def vmax(self): + return self._vmax + + @vmax.setter + def vmax(self, value): + value = _sanitize_extrema(value) + if value != self._vmax: + self._vmax = value + self._changed() + + @property + def clip(self): + return self._clip + + @clip.setter + def clip(self, value): + if value != self._clip: + self._clip = value + self._changed() + + def _changed(self): + """ + Call this whenever the norm is changed to notify all the + callback listeners to the 'changed' signal. + """ + self.callbacks.process('changed') + + @staticmethod + def process_value(value): + """ + Homogenize the input *value* for easy and efficient normalization. + + *value* can be a scalar or sequence. + + Parameters + ---------- + value + Data to normalize. + + Returns + ------- + result : masked array + Masked array with the same shape as *value*. + is_scalar : bool + Whether *value* is a scalar. + + Notes + ----- + Float dtypes are preserved; integer types with two bytes or smaller are + converted to np.float32, and larger types are converted to np.float64. + Preserving float32 when possible, and using in-place operations, + greatly improves speed for large arrays. + """ + is_scalar = not np.iterable(value) + if is_scalar: + value = [value] + dtype = np.min_scalar_type(value) + if np.issubdtype(dtype, np.integer) or dtype.type is np.bool_: + # bool_/int8/int16 -> float32; int32/int64 -> float64 + dtype = np.promote_types(dtype, np.float32) + # ensure data passed in as an ndarray subclass are interpreted as + # an ndarray. See issue #6622. + mask = np.ma.getmask(value) + data = np.asarray(value) + result = np.ma.array(data, mask=mask, dtype=dtype, copy=True) + return result, is_scalar + + def __call__(self, value, clip=None): + """ + Normalize the data and return the normalized data. + + Parameters + ---------- + value + Data to normalize. + clip : bool, optional + See the description of the parameter *clip* in `.Normalize`. + + If ``None``, defaults to ``self.clip`` (which defaults to + ``False``). + + Notes + ----- + If not already initialized, ``self.vmin`` and ``self.vmax`` are + initialized using ``self.autoscale_None(value)``. + """ + if clip is None: + clip = self.clip + + result, is_scalar = self.process_value(value) + + if self.vmin is None or self.vmax is None: + self.autoscale_None(result) + # Convert at least to float, without losing precision. + (vmin,), _ = self.process_value(self.vmin) + (vmax,), _ = self.process_value(self.vmax) + if vmin == vmax: + result.fill(0) # Or should it be all masked? Or 0.5? + elif vmin > vmax: + raise ValueError("minvalue must be less than or equal to maxvalue") + else: + if clip: + mask = np.ma.getmask(result) + result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax), + mask=mask) + # ma division is very slow; we can take a shortcut + resdat = result.data + resdat -= vmin + resdat /= (vmax - vmin) + result = np.ma.array(resdat, mask=result.mask, copy=False) + if is_scalar: + result = result[0] + return result + + def inverse(self, value): + """ + Maps the normalized value (i.e., index in the colormap) back to image + data value. + + Parameters + ---------- + value + Normalized value. + """ + if not self.scaled(): + raise ValueError("Not invertible until both vmin and vmax are set") + (vmin,), _ = self.process_value(self.vmin) + (vmax,), _ = self.process_value(self.vmax) + + if np.iterable(value): + val = np.ma.asarray(value) + return vmin + val * (vmax - vmin) + else: + return vmin + value * (vmax - vmin) + + def autoscale(self, A): + """Set *vmin*, *vmax* to min, max of *A*.""" + with self.callbacks.blocked(): + # Pause callbacks while we are updating so we only get + # a single update signal at the end + self.vmin = self.vmax = None + self.autoscale_None(A) + self._changed() + + def autoscale_None(self, A): + """If *vmin* or *vmax* are not set, use the min/max of *A* to set them.""" + A = np.asanyarray(A) + + if isinstance(A, np.ma.MaskedArray): + # we need to make the distinction between an array, False, np.bool_(False) + if A.mask is False or not A.mask.shape: + A = A.data + + if self.vmin is None and A.size: + self.vmin = A.min() + if self.vmax is None and A.size: + self.vmax = A.max() + + def scaled(self): + """Return whether *vmin* and *vmax* are both set.""" + return self.vmin is not None and self.vmax is not None + + +class TwoSlopeNorm(Normalize): + def __init__(self, vcenter, vmin=None, vmax=None): + """ + Normalize data with a set center. + + Useful when mapping data with an unequal rates of change around a + conceptual center, e.g., data that range from -2 to 4, with 0 as + the midpoint. + + Parameters + ---------- + vcenter : float + The data value that defines ``0.5`` in the normalization. + vmin : float, optional + The data value that defines ``0.0`` in the normalization. + Defaults to the min value of the dataset. + vmax : float, optional + The data value that defines ``1.0`` in the normalization. + Defaults to the max value of the dataset. + + Examples + -------- + This maps data value -4000 to 0., 0 to 0.5, and +10000 to 1.0; data + between is linearly interpolated:: + + >>> import matplotlib.colors as mcolors + >>> offset = mcolors.TwoSlopeNorm(vmin=-4000., + ... vcenter=0., vmax=10000) + >>> data = [-4000., -2000., 0., 2500., 5000., 7500., 10000.] + >>> offset(data) + array([0., 0.25, 0.5, 0.625, 0.75, 0.875, 1.0]) + """ + + super().__init__(vmin=vmin, vmax=vmax) + self._vcenter = vcenter + if vcenter is not None and vmax is not None and vcenter >= vmax: + raise ValueError('vmin, vcenter, and vmax must be in ' + 'ascending order') + if vcenter is not None and vmin is not None and vcenter <= vmin: + raise ValueError('vmin, vcenter, and vmax must be in ' + 'ascending order') + + @property + def vcenter(self): + return self._vcenter + + @vcenter.setter + def vcenter(self, value): + if value != self._vcenter: + self._vcenter = value + self._changed() + + def autoscale_None(self, A): + """ + Get vmin and vmax. + + If vcenter isn't in the range [vmin, vmax], either vmin or vmax + is expanded so that vcenter lies in the middle of the modified range + [vmin, vmax]. + """ + super().autoscale_None(A) + if self.vmin >= self.vcenter: + self.vmin = self.vcenter - (self.vmax - self.vcenter) + if self.vmax <= self.vcenter: + self.vmax = self.vcenter + (self.vcenter - self.vmin) + + def __call__(self, value, clip=None): + """ + Map value to the interval [0, 1]. The *clip* argument is unused. + """ + result, is_scalar = self.process_value(value) + self.autoscale_None(result) # sets self.vmin, self.vmax if None + + if not self.vmin <= self.vcenter <= self.vmax: + raise ValueError("vmin, vcenter, vmax must increase monotonically") + # note that we must extrapolate for tick locators: + result = np.ma.masked_array( + np.interp(result, [self.vmin, self.vcenter, self.vmax], + [0, 0.5, 1], left=-np.inf, right=np.inf), + mask=np.ma.getmask(result)) + if is_scalar: + result = np.atleast_1d(result)[0] + return result + + def inverse(self, value): + if not self.scaled(): + raise ValueError("Not invertible until both vmin and vmax are set") + (vmin,), _ = self.process_value(self.vmin) + (vmax,), _ = self.process_value(self.vmax) + (vcenter,), _ = self.process_value(self.vcenter) + result = np.interp(value, [0, 0.5, 1], [vmin, vcenter, vmax], + left=-np.inf, right=np.inf) + return result + + +class CenteredNorm(Normalize): + def __init__(self, vcenter=0, halfrange=None, clip=False): + """ + Normalize symmetrical data around a center (0 by default). + + Unlike `TwoSlopeNorm`, `CenteredNorm` applies an equal rate of change + around the center. + + Useful when mapping symmetrical data around a conceptual center + e.g., data that range from -2 to 4, with 0 as the midpoint, and + with equal rates of change around that midpoint. + + Parameters + ---------- + vcenter : float, default: 0 + The data value that defines ``0.5`` in the normalization. + halfrange : float, optional + The range of data values that defines a range of ``0.5`` in the + normalization, so that *vcenter* - *halfrange* is ``0.0`` and + *vcenter* + *halfrange* is ``1.0`` in the normalization. + Defaults to the largest absolute difference to *vcenter* for + the values in the dataset. + clip : bool, default: False + Determines the behavior for mapping values outside the range + ``[vmin, vmax]``. + + If clipping is off, values outside the range ``[vmin, vmax]`` are + also transformed, resulting in values outside ``[0, 1]``. This + behavior is usually desirable, as colormaps can mark these *under* + and *over* values with specific colors. + + If clipping is on, values below *vmin* are mapped to 0 and values + above *vmax* are mapped to 1. Such values become indistinguishable + from regular boundary values, which may cause misinterpretation of + the data. + + Examples + -------- + This maps data values -2 to 0.25, 0 to 0.5, and 4 to 1.0 + (assuming equal rates of change above and below 0.0): + + >>> import matplotlib.colors as mcolors + >>> norm = mcolors.CenteredNorm(halfrange=4.0) + >>> data = [-2., 0., 4.] + >>> norm(data) + array([0.25, 0.5 , 1. ]) + """ + super().__init__(vmin=None, vmax=None, clip=clip) + self._vcenter = vcenter + # calling the halfrange setter to set vmin and vmax + self.halfrange = halfrange + + def autoscale(self, A): + """ + Set *halfrange* to ``max(abs(A-vcenter))``, then set *vmin* and *vmax*. + """ + A = np.asanyarray(A) + self.halfrange = max(self._vcenter-A.min(), + A.max()-self._vcenter) + + def autoscale_None(self, A): + """Set *vmin* and *vmax*.""" + A = np.asanyarray(A) + if self.halfrange is None and A.size: + self.autoscale(A) + + @property + def vmin(self): + return self._vmin + + @vmin.setter + def vmin(self, value): + value = _sanitize_extrema(value) + if value != self._vmin: + self._vmin = value + self._vmax = 2*self.vcenter - value + self._changed() + + @property + def vmax(self): + return self._vmax + + @vmax.setter + def vmax(self, value): + value = _sanitize_extrema(value) + if value != self._vmax: + self._vmax = value + self._vmin = 2*self.vcenter - value + self._changed() + + @property + def vcenter(self): + return self._vcenter + + @vcenter.setter + def vcenter(self, vcenter): + if vcenter != self._vcenter: + self._vcenter = vcenter + # Trigger an update of the vmin/vmax values through the setter + self.halfrange = self.halfrange + self._changed() + + @property + def halfrange(self): + if self.vmin is None or self.vmax is None: + return None + return (self.vmax - self.vmin) / 2 + + @halfrange.setter + def halfrange(self, halfrange): + if halfrange is None: + self.vmin = None + self.vmax = None + else: + self.vmin = self.vcenter - abs(halfrange) + self.vmax = self.vcenter + abs(halfrange) + + +def make_norm_from_scale(scale_cls, base_norm_cls=None, *, init=None): + """ + Decorator for building a `.Normalize` subclass from a `~.scale.ScaleBase` + subclass. + + After :: + + @make_norm_from_scale(scale_cls) + class norm_cls(Normalize): + ... + + *norm_cls* is filled with methods so that normalization computations are + forwarded to *scale_cls* (i.e., *scale_cls* is the scale that would be used + for the colorbar of a mappable normalized with *norm_cls*). + + If *init* is not passed, then the constructor signature of *norm_cls* + will be ``norm_cls(vmin=None, vmax=None, clip=False)``; these three + parameters will be forwarded to the base class (``Normalize.__init__``), + and a *scale_cls* object will be initialized with no arguments (other than + a dummy axis). + + If the *scale_cls* constructor takes additional parameters, then *init* + should be passed to `make_norm_from_scale`. It is a callable which is + *only* used for its signature. First, this signature will become the + signature of *norm_cls*. Second, the *norm_cls* constructor will bind the + parameters passed to it using this signature, extract the bound *vmin*, + *vmax*, and *clip* values, pass those to ``Normalize.__init__``, and + forward the remaining bound values (including any defaults defined by the + signature) to the *scale_cls* constructor. + """ + + if base_norm_cls is None: + return functools.partial(make_norm_from_scale, scale_cls, init=init) + + if isinstance(scale_cls, functools.partial): + scale_args = scale_cls.args + scale_kwargs_items = tuple(scale_cls.keywords.items()) + scale_cls = scale_cls.func + else: + scale_args = scale_kwargs_items = () + + if init is None: + def init(vmin=None, vmax=None, clip=False): pass + + return _make_norm_from_scale( + scale_cls, scale_args, scale_kwargs_items, + base_norm_cls, inspect.signature(init)) + + +@functools.cache +def _make_norm_from_scale( + scale_cls, scale_args, scale_kwargs_items, + base_norm_cls, bound_init_signature, +): + """ + Helper for `make_norm_from_scale`. + + This function is split out to enable caching (in particular so that + different unpickles reuse the same class). In order to do so, + + - ``functools.partial`` *scale_cls* is expanded into ``func, args, kwargs`` + to allow memoizing returned norms (partial instances always compare + unequal, but we can check identity based on ``func, args, kwargs``; + - *init* is replaced by *init_signature*, as signatures are picklable, + unlike to arbitrary lambdas. + """ + + class Norm(base_norm_cls): + def __reduce__(self): + cls = type(self) + # If the class is toplevel-accessible, it is possible to directly + # pickle it "by name". This is required to support norm classes + # defined at a module's toplevel, as the inner base_norm_cls is + # otherwise unpicklable (as it gets shadowed by the generated norm + # class). If either import or attribute access fails, fall back to + # the general path. + try: + if cls is getattr(importlib.import_module(cls.__module__), + cls.__qualname__): + return (_create_empty_object_of_class, (cls,), vars(self)) + except (ImportError, AttributeError): + pass + return (_picklable_norm_constructor, + (scale_cls, scale_args, scale_kwargs_items, + base_norm_cls, bound_init_signature), + vars(self)) + + def __init__(self, *args, **kwargs): + ba = bound_init_signature.bind(*args, **kwargs) + ba.apply_defaults() + super().__init__( + **{k: ba.arguments.pop(k) for k in ["vmin", "vmax", "clip"]}) + self._scale = functools.partial( + scale_cls, *scale_args, **dict(scale_kwargs_items))( + axis=None, **ba.arguments) + self._trf = self._scale.get_transform() + + __init__.__signature__ = bound_init_signature.replace(parameters=[ + inspect.Parameter("self", inspect.Parameter.POSITIONAL_OR_KEYWORD), + *bound_init_signature.parameters.values()]) + + def __call__(self, value, clip=None): + value, is_scalar = self.process_value(value) + if self.vmin is None or self.vmax is None: + self.autoscale_None(value) + if self.vmin > self.vmax: + raise ValueError("vmin must be less or equal to vmax") + if self.vmin == self.vmax: + return np.full_like(value, 0) + if clip is None: + clip = self.clip + if clip: + value = np.clip(value, self.vmin, self.vmax) + t_value = self._trf.transform(value).reshape(np.shape(value)) + t_vmin, t_vmax = self._trf.transform([self.vmin, self.vmax]) + if not np.isfinite([t_vmin, t_vmax]).all(): + raise ValueError("Invalid vmin or vmax") + t_value -= t_vmin + t_value /= (t_vmax - t_vmin) + t_value = np.ma.masked_invalid(t_value, copy=False) + return t_value[0] if is_scalar else t_value + + def inverse(self, value): + if not self.scaled(): + raise ValueError("Not invertible until scaled") + if self.vmin > self.vmax: + raise ValueError("vmin must be less or equal to vmax") + t_vmin, t_vmax = self._trf.transform([self.vmin, self.vmax]) + if not np.isfinite([t_vmin, t_vmax]).all(): + raise ValueError("Invalid vmin or vmax") + value, is_scalar = self.process_value(value) + rescaled = value * (t_vmax - t_vmin) + rescaled += t_vmin + value = (self._trf + .inverted() + .transform(rescaled) + .reshape(np.shape(value))) + return value[0] if is_scalar else value + + def autoscale_None(self, A): + # i.e. A[np.isfinite(...)], but also for non-array A's + in_trf_domain = np.extract(np.isfinite(self._trf.transform(A)), A) + if in_trf_domain.size == 0: + in_trf_domain = np.ma.masked + return super().autoscale_None(in_trf_domain) + + if base_norm_cls is Normalize: + Norm.__name__ = f"{scale_cls.__name__}Norm" + Norm.__qualname__ = f"{scale_cls.__qualname__}Norm" + else: + Norm.__name__ = base_norm_cls.__name__ + Norm.__qualname__ = base_norm_cls.__qualname__ + Norm.__module__ = base_norm_cls.__module__ + Norm.__doc__ = base_norm_cls.__doc__ + + return Norm + + +def _create_empty_object_of_class(cls): + return cls.__new__(cls) + + +def _picklable_norm_constructor(*args): + return _create_empty_object_of_class(_make_norm_from_scale(*args)) + + +@make_norm_from_scale( + scale.FuncScale, + init=lambda functions, vmin=None, vmax=None, clip=False: None) +class FuncNorm(Normalize): + """ + Arbitrary normalization using functions for the forward and inverse. + + Parameters + ---------- + functions : (callable, callable) + two-tuple of the forward and inverse functions for the normalization. + The forward function must be monotonic. + + Both functions must have the signature :: + + def forward(values: array-like) -> array-like + + vmin, vmax : float or None + If *vmin* and/or *vmax* is not given, they are initialized from the + minimum and maximum value, respectively, of the first input + processed; i.e., ``__call__(A)`` calls ``autoscale_None(A)``. + + clip : bool, default: False + Determines the behavior for mapping values outside the range + ``[vmin, vmax]``. + + If clipping is off, values outside the range ``[vmin, vmax]`` are also + transformed by the function, resulting in values outside ``[0, 1]``. + This behavior is usually desirable, as colormaps can mark these *under* + and *over* values with specific colors. + + If clipping is on, values below *vmin* are mapped to 0 and values above + *vmax* are mapped to 1. Such values become indistinguishable from + regular boundary values, which may cause misinterpretation of the data. + """ + + +LogNorm = make_norm_from_scale( + functools.partial(scale.LogScale, nonpositive="mask"))(Normalize) +LogNorm.__name__ = LogNorm.__qualname__ = "LogNorm" +LogNorm.__doc__ = "Normalize a given value to the 0-1 range on a log scale." + + +@make_norm_from_scale( + scale.SymmetricalLogScale, + init=lambda linthresh, linscale=1., vmin=None, vmax=None, clip=False, *, + base=10: None) +class SymLogNorm(Normalize): + """ + The symmetrical logarithmic scale is logarithmic in both the + positive and negative directions from the origin. + + Since the values close to zero tend toward infinity, there is a + need to have a range around zero that is linear. The parameter + *linthresh* allows the user to specify the size of this range + (-*linthresh*, *linthresh*). + + Parameters + ---------- + linthresh : float + The range within which the plot is linear (to avoid having the plot + go to infinity around zero). + linscale : float, default: 1 + This allows the linear range (-*linthresh* to *linthresh*) to be + stretched relative to the logarithmic range. Its value is the + number of decades to use for each half of the linear range. For + example, when *linscale* == 1.0 (the default), the space used for + the positive and negative halves of the linear range will be equal + to one decade in the logarithmic range. + base : float, default: 10 + """ + + @property + def linthresh(self): + return self._scale.linthresh + + @linthresh.setter + def linthresh(self, value): + self._scale.linthresh = value + + +@make_norm_from_scale( + scale.AsinhScale, + init=lambda linear_width=1, vmin=None, vmax=None, clip=False: None) +class AsinhNorm(Normalize): + """ + The inverse hyperbolic sine scale is approximately linear near + the origin, but becomes logarithmic for larger positive + or negative values. Unlike the `SymLogNorm`, the transition between + these linear and logarithmic regions is smooth, which may reduce + the risk of visual artifacts. + + .. note:: + + This API is provisional and may be revised in the future + based on early user feedback. + + Parameters + ---------- + linear_width : float, default: 1 + The effective width of the linear region, beyond which + the transformation becomes asymptotically logarithmic + """ + + @property + def linear_width(self): + return self._scale.linear_width + + @linear_width.setter + def linear_width(self, value): + self._scale.linear_width = value + + +class PowerNorm(Normalize): + r""" + Linearly map a given value to the 0-1 range and then apply + a power-law normalization over that range. + + Parameters + ---------- + gamma : float + Power law exponent. + vmin, vmax : float or None + If *vmin* and/or *vmax* is not given, they are initialized from the + minimum and maximum value, respectively, of the first input + processed; i.e., ``__call__(A)`` calls ``autoscale_None(A)``. + clip : bool, default: False + Determines the behavior for mapping values outside the range + ``[vmin, vmax]``. + + If clipping is off, values above *vmax* are transformed by the power + function, resulting in values above 1, and values below *vmin* are linearly + transformed resulting in values below 0. This behavior is usually desirable, as + colormaps can mark these *under* and *over* values with specific colors. + + If clipping is on, values below *vmin* are mapped to 0 and values above + *vmax* are mapped to 1. Such values become indistinguishable from + regular boundary values, which may cause misinterpretation of the data. + + Notes + ----- + The normalization formula is + + .. math:: + + \left ( \frac{x - v_{min}}{v_{max} - v_{min}} \right )^{\gamma} + + For input values below *vmin*, gamma is set to one. + """ + def __init__(self, gamma, vmin=None, vmax=None, clip=False): + super().__init__(vmin, vmax, clip) + self.gamma = gamma + + def __call__(self, value, clip=None): + if clip is None: + clip = self.clip + + result, is_scalar = self.process_value(value) + + self.autoscale_None(result) + gamma = self.gamma + vmin, vmax = self.vmin, self.vmax + if vmin > vmax: + raise ValueError("minvalue must be less than or equal to maxvalue") + elif vmin == vmax: + result.fill(0) + else: + if clip: + mask = np.ma.getmask(result) + result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax), + mask=mask) + resdat = result.data + resdat -= vmin + resdat /= (vmax - vmin) + resdat[resdat > 0] = np.power(resdat[resdat > 0], gamma) + + result = np.ma.array(resdat, mask=result.mask, copy=False) + if is_scalar: + result = result[0] + return result + + def inverse(self, value): + if not self.scaled(): + raise ValueError("Not invertible until scaled") + + result, is_scalar = self.process_value(value) + + gamma = self.gamma + vmin, vmax = self.vmin, self.vmax + + resdat = result.data + resdat[resdat > 0] = np.power(resdat[resdat > 0], 1 / gamma) + resdat *= (vmax - vmin) + resdat += vmin + + result = np.ma.array(resdat, mask=result.mask, copy=False) + if is_scalar: + result = result[0] + return result + + +class BoundaryNorm(Normalize): + """ + Generate a colormap index based on discrete intervals. + + Unlike `Normalize` or `LogNorm`, `BoundaryNorm` maps values to integers + instead of to the interval 0-1. + """ + + # Mapping to the 0-1 interval could have been done via piece-wise linear + # interpolation, but using integers seems simpler, and reduces the number + # of conversions back and forth between int and float. + + def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'): + """ + Parameters + ---------- + boundaries : array-like + Monotonically increasing sequence of at least 2 bin edges: data + falling in the n-th bin will be mapped to the n-th color. + + ncolors : int + Number of colors in the colormap to be used. + + clip : bool, optional + If clip is ``True``, out of range values are mapped to 0 if they + are below ``boundaries[0]`` or mapped to ``ncolors - 1`` if they + are above ``boundaries[-1]``. + + If clip is ``False``, out of range values are mapped to -1 if + they are below ``boundaries[0]`` or mapped to *ncolors* if they are + above ``boundaries[-1]``. These are then converted to valid indices + by `Colormap.__call__`. + + extend : {'neither', 'both', 'min', 'max'}, default: 'neither' + Extend the number of bins to include one or both of the + regions beyond the boundaries. For example, if ``extend`` + is 'min', then the color to which the region between the first + pair of boundaries is mapped will be distinct from the first + color in the colormap, and by default a + `~matplotlib.colorbar.Colorbar` will be drawn with + the triangle extension on the left or lower end. + + Notes + ----- + If there are fewer bins (including extensions) than colors, then the + color index is chosen by linearly interpolating the ``[0, nbins - 1]`` + range onto the ``[0, ncolors - 1]`` range, effectively skipping some + colors in the middle of the colormap. + """ + if clip and extend != 'neither': + raise ValueError("'clip=True' is not compatible with 'extend'") + super().__init__(vmin=boundaries[0], vmax=boundaries[-1], clip=clip) + self.boundaries = np.asarray(boundaries) + self.N = len(self.boundaries) + if self.N < 2: + raise ValueError("You must provide at least 2 boundaries " + f"(1 region) but you passed in {boundaries!r}") + self.Ncmap = ncolors + self.extend = extend + + self._scale = None # don't use the default scale. + + self._n_regions = self.N - 1 # number of colors needed + self._offset = 0 + if extend in ('min', 'both'): + self._n_regions += 1 + self._offset = 1 + if extend in ('max', 'both'): + self._n_regions += 1 + if self._n_regions > self.Ncmap: + raise ValueError(f"There are {self._n_regions} color bins " + "including extensions, but ncolors = " + f"{ncolors}; ncolors must equal or exceed the " + "number of bins") + + def __call__(self, value, clip=None): + """ + This method behaves similarly to `.Normalize.__call__`, except that it + returns integers or arrays of int16. + """ + if clip is None: + clip = self.clip + + xx, is_scalar = self.process_value(value) + mask = np.ma.getmaskarray(xx) + # Fill masked values a value above the upper boundary + xx = np.atleast_1d(xx.filled(self.vmax + 1)) + if clip: + np.clip(xx, self.vmin, self.vmax, out=xx) + max_col = self.Ncmap - 1 + else: + max_col = self.Ncmap + # this gives us the bins in the lookup table in the range + # [0, _n_regions - 1] (the offset is set in the init) + iret = np.digitize(xx, self.boundaries) - 1 + self._offset + # if we have more colors than regions, stretch the region + # index computed above to full range of the color bins. This + # will make use of the full range (but skip some of the colors + # in the middle) such that the first region is mapped to the + # first color and the last region is mapped to the last color. + if self.Ncmap > self._n_regions: + if self._n_regions == 1: + # special case the 1 region case, pick the middle color + iret[iret == 0] = (self.Ncmap - 1) // 2 + else: + # otherwise linearly remap the values from the region index + # to the color index spaces + iret = (self.Ncmap - 1) / (self._n_regions - 1) * iret + # cast to 16bit integers in all cases + iret = iret.astype(np.int16) + iret[xx < self.vmin] = -1 + iret[xx >= self.vmax] = max_col + ret = np.ma.array(iret, mask=mask) + if is_scalar: + ret = int(ret[0]) # assume python scalar + return ret + + def inverse(self, value): + """ + Raises + ------ + ValueError + BoundaryNorm is not invertible, so calling this method will always + raise an error + """ + raise ValueError("BoundaryNorm is not invertible") + + +class NoNorm(Normalize): + """ + Dummy replacement for `Normalize`, for the case where we want to use + indices directly in a `~matplotlib.cm.ScalarMappable`. + """ + def __call__(self, value, clip=None): + if np.iterable(value): + return np.ma.array(value) + return value + + def inverse(self, value): + if np.iterable(value): + return np.ma.array(value) + return value + + +def rgb_to_hsv(arr): + """ + Convert an array of float RGB values (in the range [0, 1]) to HSV values. + + Parameters + ---------- + arr : (..., 3) array-like + All values must be in the range [0, 1] + + Returns + ------- + (..., 3) `~numpy.ndarray` + Colors converted to HSV values in range [0, 1] + """ + arr = np.asarray(arr) + + # check length of the last dimension, should be _some_ sort of rgb + if arr.shape[-1] != 3: + raise ValueError("Last dimension of input array must be 3; " + f"shape {arr.shape} was found.") + + in_shape = arr.shape + arr = np.array( + arr, copy=False, + dtype=np.promote_types(arr.dtype, np.float32), # Don't work on ints. + ndmin=2, # In case input was 1D. + ) + out = np.zeros_like(arr) + arr_max = arr.max(-1) + ipos = arr_max > 0 + delta = np.ptp(arr, -1) + s = np.zeros_like(delta) + s[ipos] = delta[ipos] / arr_max[ipos] + ipos = delta > 0 + # red is max + idx = (arr[..., 0] == arr_max) & ipos + out[idx, 0] = (arr[idx, 1] - arr[idx, 2]) / delta[idx] + # green is max + idx = (arr[..., 1] == arr_max) & ipos + out[idx, 0] = 2. + (arr[idx, 2] - arr[idx, 0]) / delta[idx] + # blue is max + idx = (arr[..., 2] == arr_max) & ipos + out[idx, 0] = 4. + (arr[idx, 0] - arr[idx, 1]) / delta[idx] + + out[..., 0] = (out[..., 0] / 6.0) % 1.0 + out[..., 1] = s + out[..., 2] = arr_max + + return out.reshape(in_shape) + + +def hsv_to_rgb(hsv): + """ + Convert HSV values to RGB. + + Parameters + ---------- + hsv : (..., 3) array-like + All values assumed to be in range [0, 1] + + Returns + ------- + (..., 3) `~numpy.ndarray` + Colors converted to RGB values in range [0, 1] + """ + hsv = np.asarray(hsv) + + # check length of the last dimension, should be _some_ sort of rgb + if hsv.shape[-1] != 3: + raise ValueError("Last dimension of input array must be 3; " + f"shape {hsv.shape} was found.") + + in_shape = hsv.shape + hsv = np.array( + hsv, copy=False, + dtype=np.promote_types(hsv.dtype, np.float32), # Don't work on ints. + ndmin=2, # In case input was 1D. + ) + + h = hsv[..., 0] + s = hsv[..., 1] + v = hsv[..., 2] + + r = np.empty_like(h) + g = np.empty_like(h) + b = np.empty_like(h) + + i = (h * 6.0).astype(int) + f = (h * 6.0) - i + p = v * (1.0 - s) + q = v * (1.0 - s * f) + t = v * (1.0 - s * (1.0 - f)) + + idx = i % 6 == 0 + r[idx] = v[idx] + g[idx] = t[idx] + b[idx] = p[idx] + + idx = i == 1 + r[idx] = q[idx] + g[idx] = v[idx] + b[idx] = p[idx] + + idx = i == 2 + r[idx] = p[idx] + g[idx] = v[idx] + b[idx] = t[idx] + + idx = i == 3 + r[idx] = p[idx] + g[idx] = q[idx] + b[idx] = v[idx] + + idx = i == 4 + r[idx] = t[idx] + g[idx] = p[idx] + b[idx] = v[idx] + + idx = i == 5 + r[idx] = v[idx] + g[idx] = p[idx] + b[idx] = q[idx] + + idx = s == 0 + r[idx] = v[idx] + g[idx] = v[idx] + b[idx] = v[idx] + + rgb = np.stack([r, g, b], axis=-1) + + return rgb.reshape(in_shape) + + +def _vector_magnitude(arr): + # things that don't work here: + # * np.linalg.norm: drops mask from ma.array + # * np.sum: drops mask from ma.array unless entire vector is masked + sum_sq = 0 + for i in range(arr.shape[-1]): + sum_sq += arr[..., i, np.newaxis] ** 2 + return np.sqrt(sum_sq) + + +class LightSource: + """ + Create a light source coming from the specified azimuth and elevation. + Angles are in degrees, with the azimuth measured + clockwise from north and elevation up from the zero plane of the surface. + + `shade` is used to produce "shaded" RGB values for a data array. + `shade_rgb` can be used to combine an RGB image with an elevation map. + `hillshade` produces an illumination map of a surface. + """ + + def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, + hsv_min_sat=1, hsv_max_sat=0): + """ + Specify the azimuth (measured clockwise from south) and altitude + (measured up from the plane of the surface) of the light source + in degrees. + + Parameters + ---------- + azdeg : float, default: 315 degrees (from the northwest) + The azimuth (0-360, degrees clockwise from North) of the light + source. + altdeg : float, default: 45 degrees + The altitude (0-90, degrees up from horizontal) of the light + source. + hsv_min_val : number, default: 0 + The minimum value ("v" in "hsv") that the *intensity* map can shift the + output image to. + hsv_max_val : number, default: 1 + The maximum value ("v" in "hsv") that the *intensity* map can shift the + output image to. + hsv_min_sat : number, default: 1 + The minimum saturation value that the *intensity* map can shift the output + image to. + hsv_max_sat : number, default: 0 + The maximum saturation value that the *intensity* map can shift the output + image to. + + Notes + ----- + For backwards compatibility, the parameters *hsv_min_val*, + *hsv_max_val*, *hsv_min_sat*, and *hsv_max_sat* may be supplied at + initialization as well. However, these parameters will only be used if + "blend_mode='hsv'" is passed into `shade` or `shade_rgb`. + See the documentation for `blend_hsv` for more details. + """ + self.azdeg = azdeg + self.altdeg = altdeg + self.hsv_min_val = hsv_min_val + self.hsv_max_val = hsv_max_val + self.hsv_min_sat = hsv_min_sat + self.hsv_max_sat = hsv_max_sat + + @property + def direction(self): + """The unit vector direction towards the light source.""" + # Azimuth is in degrees clockwise from North. Convert to radians + # counterclockwise from East (mathematical notation). + az = np.radians(90 - self.azdeg) + alt = np.radians(self.altdeg) + return np.array([ + np.cos(az) * np.cos(alt), + np.sin(az) * np.cos(alt), + np.sin(alt) + ]) + + def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.): + """ + Calculate the illumination intensity for a surface using the defined + azimuth and elevation for the light source. + + This computes the normal vectors for the surface, and then passes them + on to `shade_normals` + + Parameters + ---------- + elevation : 2D array-like + The height values used to generate an illumination map + vert_exag : number, optional + The amount to exaggerate the elevation values by when calculating + illumination. This can be used either to correct for differences in + units between the x-y coordinate system and the elevation + coordinate system (e.g. decimal degrees vs. meters) or to + exaggerate or de-emphasize topographic effects. + dx : number, optional + The x-spacing (columns) of the input *elevation* grid. + dy : number, optional + The y-spacing (rows) of the input *elevation* grid. + fraction : number, optional + Increases or decreases the contrast of the hillshade. Values + greater than one will cause intermediate values to move closer to + full illumination or shadow (and clipping any values that move + beyond 0 or 1). Note that this is not visually or mathematically + the same as vertical exaggeration. + + Returns + ------- + `~numpy.ndarray` + A 2D array of illumination values between 0-1, where 0 is + completely in shadow and 1 is completely illuminated. + """ + + # Because most image and raster GIS data has the first row in the array + # as the "top" of the image, dy is implicitly negative. This is + # consistent to what `imshow` assumes, as well. + dy = -dy + + # compute the normal vectors from the partial derivatives + e_dy, e_dx = np.gradient(vert_exag * elevation, dy, dx) + + # .view is to keep subclasses + normal = np.empty(elevation.shape + (3,)).view(type(elevation)) + normal[..., 0] = -e_dx + normal[..., 1] = -e_dy + normal[..., 2] = 1 + normal /= _vector_magnitude(normal) + + return self.shade_normals(normal, fraction) + + def shade_normals(self, normals, fraction=1.): + """ + Calculate the illumination intensity for the normal vectors of a + surface using the defined azimuth and elevation for the light source. + + Imagine an artificial sun placed at infinity in some azimuth and + elevation position illuminating our surface. The parts of the surface + that slope toward the sun should brighten while those sides facing away + should become darker. + + Parameters + ---------- + fraction : number, optional + Increases or decreases the contrast of the hillshade. Values + greater than one will cause intermediate values to move closer to + full illumination or shadow (and clipping any values that move + beyond 0 or 1). Note that this is not visually or mathematically + the same as vertical exaggeration. + + Returns + ------- + `~numpy.ndarray` + A 2D array of illumination values between 0-1, where 0 is + completely in shadow and 1 is completely illuminated. + """ + + intensity = normals.dot(self.direction) + + # Apply contrast stretch + imin, imax = intensity.min(), intensity.max() + intensity *= fraction + + # Rescale to 0-1, keeping range before contrast stretch + # If constant slope, keep relative scaling (i.e. flat should be 0.5, + # fully occluded 0, etc.) + if (imax - imin) > 1e-6: + # Strictly speaking, this is incorrect. Negative values should be + # clipped to 0 because they're fully occluded. However, rescaling + # in this manner is consistent with the previous implementation and + # visually appears better than a "hard" clip. + intensity -= imin + intensity /= (imax - imin) + intensity = np.clip(intensity, 0, 1) + + return intensity + + def shade(self, data, cmap, norm=None, blend_mode='overlay', vmin=None, + vmax=None, vert_exag=1, dx=1, dy=1, fraction=1, **kwargs): + """ + Combine colormapped data values with an illumination intensity map + (a.k.a. "hillshade") of the values. + + Parameters + ---------- + data : 2D array-like + The height values used to generate a shaded map. + cmap : `~matplotlib.colors.Colormap` + The colormap used to color the *data* array. Note that this must be + a `~matplotlib.colors.Colormap` instance. For example, rather than + passing in ``cmap='gist_earth'``, use + ``cmap=plt.get_cmap('gist_earth')`` instead. + norm : `~matplotlib.colors.Normalize` instance, optional + The normalization used to scale values before colormapping. If + None, the input will be linearly scaled between its min and max. + blend_mode : {'hsv', 'overlay', 'soft'} or callable, optional + The type of blending used to combine the colormapped data + values with the illumination intensity. Default is + "overlay". Note that for most topographic surfaces, + "overlay" or "soft" appear more visually realistic. If a + user-defined function is supplied, it is expected to + combine an (M, N, 3) RGB array of floats (ranging 0 to 1) with + an (M, N, 1) hillshade array (also 0 to 1). (Call signature + ``func(rgb, illum, **kwargs)``) Additional kwargs supplied + to this function will be passed on to the *blend_mode* + function. + vmin : float or None, optional + The minimum value used in colormapping *data*. If *None* the + minimum value in *data* is used. If *norm* is specified, then this + argument will be ignored. + vmax : float or None, optional + The maximum value used in colormapping *data*. If *None* the + maximum value in *data* is used. If *norm* is specified, then this + argument will be ignored. + vert_exag : number, optional + The amount to exaggerate the elevation values by when calculating + illumination. This can be used either to correct for differences in + units between the x-y coordinate system and the elevation + coordinate system (e.g. decimal degrees vs. meters) or to + exaggerate or de-emphasize topography. + dx : number, optional + The x-spacing (columns) of the input *elevation* grid. + dy : number, optional + The y-spacing (rows) of the input *elevation* grid. + fraction : number, optional + Increases or decreases the contrast of the hillshade. Values + greater than one will cause intermediate values to move closer to + full illumination or shadow (and clipping any values that move + beyond 0 or 1). Note that this is not visually or mathematically + the same as vertical exaggeration. + **kwargs + Additional kwargs are passed on to the *blend_mode* function. + + Returns + ------- + `~numpy.ndarray` + An (M, N, 4) array of floats ranging between 0-1. + """ + if vmin is None: + vmin = data.min() + if vmax is None: + vmax = data.max() + if norm is None: + norm = Normalize(vmin=vmin, vmax=vmax) + + rgb0 = cmap(norm(data)) + rgb1 = self.shade_rgb(rgb0, elevation=data, blend_mode=blend_mode, + vert_exag=vert_exag, dx=dx, dy=dy, + fraction=fraction, **kwargs) + # Don't overwrite the alpha channel, if present. + rgb0[..., :3] = rgb1[..., :3] + return rgb0 + + def shade_rgb(self, rgb, elevation, fraction=1., blend_mode='hsv', + vert_exag=1, dx=1, dy=1, **kwargs): + """ + Use this light source to adjust the colors of the *rgb* input array to + give the impression of a shaded relief map with the given *elevation*. + + Parameters + ---------- + rgb : array-like + An (M, N, 3) RGB array, assumed to be in the range of 0 to 1. + elevation : array-like + An (M, N) array of the height values used to generate a shaded map. + fraction : number + Increases or decreases the contrast of the hillshade. Values + greater than one will cause intermediate values to move closer to + full illumination or shadow (and clipping any values that move + beyond 0 or 1). Note that this is not visually or mathematically + the same as vertical exaggeration. + blend_mode : {'hsv', 'overlay', 'soft'} or callable, optional + The type of blending used to combine the colormapped data values + with the illumination intensity. For backwards compatibility, this + defaults to "hsv". Note that for most topographic surfaces, + "overlay" or "soft" appear more visually realistic. If a + user-defined function is supplied, it is expected to combine an + (M, N, 3) RGB array of floats (ranging 0 to 1) with an (M, N, 1) + hillshade array (also 0 to 1). (Call signature + ``func(rgb, illum, **kwargs)``) + Additional kwargs supplied to this function will be passed on to + the *blend_mode* function. + vert_exag : number, optional + The amount to exaggerate the elevation values by when calculating + illumination. This can be used either to correct for differences in + units between the x-y coordinate system and the elevation + coordinate system (e.g. decimal degrees vs. meters) or to + exaggerate or de-emphasize topography. + dx : number, optional + The x-spacing (columns) of the input *elevation* grid. + dy : number, optional + The y-spacing (rows) of the input *elevation* grid. + **kwargs + Additional kwargs are passed on to the *blend_mode* function. + + Returns + ------- + `~numpy.ndarray` + An (m, n, 3) array of floats ranging between 0-1. + """ + # Calculate the "hillshade" intensity. + intensity = self.hillshade(elevation, vert_exag, dx, dy, fraction) + intensity = intensity[..., np.newaxis] + + # Blend the hillshade and rgb data using the specified mode + lookup = { + 'hsv': self.blend_hsv, + 'soft': self.blend_soft_light, + 'overlay': self.blend_overlay, + } + if blend_mode in lookup: + blend = lookup[blend_mode](rgb, intensity, **kwargs) + else: + try: + blend = blend_mode(rgb, intensity, **kwargs) + except TypeError as err: + raise ValueError('"blend_mode" must be callable or one of ' + f'{lookup.keys}') from err + + # Only apply result where hillshade intensity isn't masked + if np.ma.is_masked(intensity): + mask = intensity.mask[..., 0] + for i in range(3): + blend[..., i][mask] = rgb[..., i][mask] + + return blend + + def blend_hsv(self, rgb, intensity, hsv_max_sat=None, hsv_max_val=None, + hsv_min_val=None, hsv_min_sat=None): + """ + Take the input data array, convert to HSV values in the given colormap, + then adjust those color values to give the impression of a shaded + relief map with a specified light source. RGBA values are returned, + which can then be used to plot the shaded image with imshow. + + The color of the resulting image will be darkened by moving the (s, v) + values (in HSV colorspace) toward (hsv_min_sat, hsv_min_val) in the + shaded regions, or lightened by sliding (s, v) toward (hsv_max_sat, + hsv_max_val) in regions that are illuminated. The default extremes are + chose so that completely shaded points are nearly black (s = 1, v = 0) + and completely illuminated points are nearly white (s = 0, v = 1). + + Parameters + ---------- + rgb : `~numpy.ndarray` + An (M, N, 3) RGB array of floats ranging from 0 to 1 (color image). + intensity : `~numpy.ndarray` + An (M, N, 1) array of floats ranging from 0 to 1 (grayscale image). + hsv_max_sat : number, optional + The maximum saturation value that the *intensity* map can shift the output + image to. If not provided, use the value provided upon initialization. + hsv_min_sat : number, optional + The minimum saturation value that the *intensity* map can shift the output + image to. If not provided, use the value provided upon initialization. + hsv_max_val : number, optional + The maximum value ("v" in "hsv") that the *intensity* map can shift the + output image to. If not provided, use the value provided upon + initialization. + hsv_min_val : number, optional + The minimum value ("v" in "hsv") that the *intensity* map can shift the + output image to. If not provided, use the value provided upon + initialization. + + Returns + ------- + `~numpy.ndarray` + An (M, N, 3) RGB array representing the combined images. + """ + # Backward compatibility... + if hsv_max_sat is None: + hsv_max_sat = self.hsv_max_sat + if hsv_max_val is None: + hsv_max_val = self.hsv_max_val + if hsv_min_sat is None: + hsv_min_sat = self.hsv_min_sat + if hsv_min_val is None: + hsv_min_val = self.hsv_min_val + + # Expects a 2D intensity array scaled between -1 to 1... + intensity = intensity[..., 0] + intensity = 2 * intensity - 1 + + # Convert to rgb, then rgb to hsv + hsv = rgb_to_hsv(rgb[:, :, 0:3]) + hue, sat, val = np.moveaxis(hsv, -1, 0) + + # Modify hsv values (in place) to simulate illumination. + # putmask(A, mask, B) <=> A[mask] = B[mask] + np.putmask(sat, (np.abs(sat) > 1.e-10) & (intensity > 0), + (1 - intensity) * sat + intensity * hsv_max_sat) + np.putmask(sat, (np.abs(sat) > 1.e-10) & (intensity < 0), + (1 + intensity) * sat - intensity * hsv_min_sat) + np.putmask(val, intensity > 0, + (1 - intensity) * val + intensity * hsv_max_val) + np.putmask(val, intensity < 0, + (1 + intensity) * val - intensity * hsv_min_val) + np.clip(hsv[:, :, 1:], 0, 1, out=hsv[:, :, 1:]) + + # Convert modified hsv back to rgb. + return hsv_to_rgb(hsv) + + def blend_soft_light(self, rgb, intensity): + """ + Combine an RGB image with an intensity map using "soft light" blending, + using the "pegtop" formula. + + Parameters + ---------- + rgb : `~numpy.ndarray` + An (M, N, 3) RGB array of floats ranging from 0 to 1 (color image). + intensity : `~numpy.ndarray` + An (M, N, 1) array of floats ranging from 0 to 1 (grayscale image). + + Returns + ------- + `~numpy.ndarray` + An (M, N, 3) RGB array representing the combined images. + """ + return 2 * intensity * rgb + (1 - 2 * intensity) * rgb**2 + + def blend_overlay(self, rgb, intensity): + """ + Combine an RGB image with an intensity map using "overlay" blending. + + Parameters + ---------- + rgb : `~numpy.ndarray` + An (M, N, 3) RGB array of floats ranging from 0 to 1 (color image). + intensity : `~numpy.ndarray` + An (M, N, 1) array of floats ranging from 0 to 1 (grayscale image). + + Returns + ------- + ndarray + An (M, N, 3) RGB array representing the combined images. + """ + low = 2 * intensity * rgb + high = 1 - 2 * (1 - intensity) * (1 - rgb) + return np.where(rgb <= 0.5, low, high) + + +def from_levels_and_colors(levels, colors, extend='neither'): + """ + A helper routine to generate a cmap and a norm instance which + behave similar to contourf's levels and colors arguments. + + Parameters + ---------- + levels : sequence of numbers + The quantization levels used to construct the `BoundaryNorm`. + Value ``v`` is quantized to level ``i`` if ``lev[i] <= v < lev[i+1]``. + colors : sequence of colors + The fill color to use for each level. If *extend* is "neither" there + must be ``n_level - 1`` colors. For an *extend* of "min" or "max" add + one extra color, and for an *extend* of "both" add two colors. + extend : {'neither', 'min', 'max', 'both'}, optional + The behaviour when a value falls out of range of the given levels. + See `~.Axes.contourf` for details. + + Returns + ------- + cmap : `~matplotlib.colors.Colormap` + norm : `~matplotlib.colors.Normalize` + """ + slice_map = { + 'both': slice(1, -1), + 'min': slice(1, None), + 'max': slice(0, -1), + 'neither': slice(0, None), + } + _api.check_in_list(slice_map, extend=extend) + color_slice = slice_map[extend] + + n_data_colors = len(levels) - 1 + n_expected = n_data_colors + color_slice.start - (color_slice.stop or 0) + if len(colors) != n_expected: + raise ValueError( + f'With extend == {extend!r} and {len(levels)} levels, ' + f'expected {n_expected} colors, but got {len(colors)}') + + cmap = ListedColormap(colors[color_slice], N=n_data_colors) + + if extend in ['min', 'both']: + cmap.set_under(colors[0]) + else: + cmap.set_under('none') + + if extend in ['max', 'both']: + cmap.set_over(colors[-1]) + else: + cmap.set_over('none') + + cmap.colorbar_extend = extend + + norm = BoundaryNorm(levels, ncolors=n_data_colors) + return cmap, norm diff --git a/venv/lib/python3.10/site-packages/matplotlib/colors.pyi b/venv/lib/python3.10/site-packages/matplotlib/colors.pyi new file mode 100644 index 00000000..514801b7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/colors.pyi @@ -0,0 +1,354 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from matplotlib import cbook, scale +import re + +from typing import Any, Literal, overload +from .typing import ColorType + +import numpy as np +from numpy.typing import ArrayLike + +# Explicitly export colors dictionaries which are imported in the impl +BASE_COLORS: dict[str, ColorType] +CSS4_COLORS: dict[str, ColorType] +TABLEAU_COLORS: dict[str, ColorType] +XKCD_COLORS: dict[str, ColorType] + +class _ColorMapping(dict[str, ColorType]): + cache: dict[tuple[ColorType, float | None], tuple[float, float, float, float]] + def __init__(self, mapping) -> None: ... + def __setitem__(self, key, value) -> None: ... + def __delitem__(self, key) -> None: ... + +def get_named_colors_mapping() -> _ColorMapping: ... + +class ColorSequenceRegistry(Mapping): + def __init__(self) -> None: ... + def __getitem__(self, item: str) -> list[ColorType]: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def register(self, name: str, color_list: Iterable[ColorType]) -> None: ... + def unregister(self, name: str) -> None: ... + +_color_sequences: ColorSequenceRegistry = ... + +def is_color_like(c: Any) -> bool: ... +def same_color(c1: ColorType, c2: ColorType) -> bool: ... +def to_rgba( + c: ColorType, alpha: float | None = ... +) -> tuple[float, float, float, float]: ... +def to_rgba_array( + c: ColorType | ArrayLike, alpha: float | ArrayLike | None = ... +) -> np.ndarray: ... +def to_rgb(c: ColorType) -> tuple[float, float, float]: ... +def to_hex(c: ColorType, keep_alpha: bool = ...) -> str: ... + +cnames: dict[str, ColorType] +hexColorPattern: re.Pattern +rgb2hex = to_hex +hex2color = to_rgb + +class ColorConverter: + colors: _ColorMapping + cache: dict[tuple[ColorType, float | None], tuple[float, float, float, float]] + @staticmethod + def to_rgb(c: ColorType) -> tuple[float, float, float]: ... + @staticmethod + def to_rgba( + c: ColorType, alpha: float | None = ... + ) -> tuple[float, float, float, float]: ... + @staticmethod + def to_rgba_array( + c: ColorType | ArrayLike, alpha: float | ArrayLike | None = ... + ) -> np.ndarray: ... + +colorConverter: ColorConverter + +class Colormap: + name: str + N: int + colorbar_extend: bool + def __init__(self, name: str, N: int = ...) -> None: ... + @overload + def __call__( + self, X: Sequence[float] | np.ndarray, alpha: ArrayLike | None = ..., bytes: bool = ... + ) -> np.ndarray: ... + @overload + def __call__( + self, X: float, alpha: float | None = ..., bytes: bool = ... + ) -> tuple[float, float, float, float]: ... + @overload + def __call__( + self, X: ArrayLike, alpha: ArrayLike | None = ..., bytes: bool = ... + ) -> tuple[float, float, float, float] | np.ndarray: ... + def __copy__(self) -> Colormap: ... + def __eq__(self, other: object) -> bool: ... + def get_bad(self) -> np.ndarray: ... + def set_bad(self, color: ColorType = ..., alpha: float | None = ...) -> None: ... + def get_under(self) -> np.ndarray: ... + def set_under(self, color: ColorType = ..., alpha: float | None = ...) -> None: ... + def get_over(self) -> np.ndarray: ... + def set_over(self, color: ColorType = ..., alpha: float | None = ...) -> None: ... + def set_extremes( + self, + *, + bad: ColorType | None = ..., + under: ColorType | None = ..., + over: ColorType | None = ... + ) -> None: ... + def with_extremes( + self, + *, + bad: ColorType | None = ..., + under: ColorType | None = ..., + over: ColorType | None = ... + ) -> Colormap: ... + def is_gray(self) -> bool: ... + def resampled(self, lutsize: int) -> Colormap: ... + def reversed(self, name: str | None = ...) -> Colormap: ... + def _repr_html_(self) -> str: ... + def _repr_png_(self) -> bytes: ... + def copy(self) -> Colormap: ... + +class LinearSegmentedColormap(Colormap): + monochrome: bool + def __init__( + self, + name: str, + segmentdata: dict[ + Literal["red", "green", "blue", "alpha"], Sequence[tuple[float, ...]] + ], + N: int = ..., + gamma: float = ..., + ) -> None: ... + def set_gamma(self, gamma: float) -> None: ... + @staticmethod + def from_list( + name: str, colors: ArrayLike | Sequence[tuple[float, ColorType]], N: int = ..., gamma: float = ... + ) -> LinearSegmentedColormap: ... + def resampled(self, lutsize: int) -> LinearSegmentedColormap: ... + def reversed(self, name: str | None = ...) -> LinearSegmentedColormap: ... + +class ListedColormap(Colormap): + monochrome: bool + colors: ArrayLike | ColorType + def __init__( + self, colors: ArrayLike | ColorType, name: str = ..., N: int | None = ... + ) -> None: ... + def resampled(self, lutsize: int) -> ListedColormap: ... + def reversed(self, name: str | None = ...) -> ListedColormap: ... + +class Normalize: + callbacks: cbook.CallbackRegistry + def __init__( + self, vmin: float | None = ..., vmax: float | None = ..., clip: bool = ... + ) -> None: ... + @property + def vmin(self) -> float | None: ... + @vmin.setter + def vmin(self, value: float | None) -> None: ... + @property + def vmax(self) -> float | None: ... + @vmax.setter + def vmax(self, value: float | None) -> None: ... + @property + def clip(self) -> bool: ... + @clip.setter + def clip(self, value: bool) -> None: ... + @staticmethod + def process_value(value: ArrayLike) -> tuple[np.ma.MaskedArray, bool]: ... + @overload + def __call__(self, value: float, clip: bool | None = ...) -> float: ... + @overload + def __call__(self, value: np.ndarray, clip: bool | None = ...) -> np.ma.MaskedArray: ... + @overload + def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ... + @overload + def inverse(self, value: float) -> float: ... + @overload + def inverse(self, value: np.ndarray) -> np.ma.MaskedArray: ... + @overload + def inverse(self, value: ArrayLike) -> ArrayLike: ... + def autoscale(self, A: ArrayLike) -> None: ... + def autoscale_None(self, A: ArrayLike) -> None: ... + def scaled(self) -> bool: ... + +class TwoSlopeNorm(Normalize): + def __init__( + self, vcenter: float, vmin: float | None = ..., vmax: float | None = ... + ) -> None: ... + @property + def vcenter(self) -> float: ... + @vcenter.setter + def vcenter(self, value: float) -> None: ... + def autoscale_None(self, A: ArrayLike) -> None: ... + +class CenteredNorm(Normalize): + def __init__( + self, vcenter: float = ..., halfrange: float | None = ..., clip: bool = ... + ) -> None: ... + @property + def vcenter(self) -> float: ... + @vcenter.setter + def vcenter(self, vcenter: float) -> None: ... + @property + def halfrange(self) -> float: ... + @halfrange.setter + def halfrange(self, halfrange: float) -> None: ... + +@overload +def make_norm_from_scale( + scale_cls: type[scale.ScaleBase], + base_norm_cls: type[Normalize], + *, + init: Callable | None = ... +) -> type[Normalize]: ... +@overload +def make_norm_from_scale( + scale_cls: type[scale.ScaleBase], + base_norm_cls: None = ..., + *, + init: Callable | None = ... +) -> Callable[[type[Normalize]], type[Normalize]]: ... + +class FuncNorm(Normalize): + def __init__( + self, + functions: tuple[Callable, Callable], + vmin: float | None = ..., + vmax: float | None = ..., + clip: bool = ..., + ) -> None: ... +class LogNorm(Normalize): ... + +class SymLogNorm(Normalize): + def __init__( + self, + linthresh: float, + linscale: float = ..., + vmin: float | None = ..., + vmax: float | None = ..., + clip: bool = ..., + *, + base: float = ..., + ) -> None: ... + @property + def linthresh(self) -> float: ... + @linthresh.setter + def linthresh(self, value: float) -> None: ... + +class AsinhNorm(Normalize): + def __init__( + self, + linear_width: float = ..., + vmin: float | None = ..., + vmax: float | None = ..., + clip: bool = ..., + ) -> None: ... + @property + def linear_width(self) -> float: ... + @linear_width.setter + def linear_width(self, value: float) -> None: ... + +class PowerNorm(Normalize): + gamma: float + def __init__( + self, + gamma: float, + vmin: float | None = ..., + vmax: float | None = ..., + clip: bool = ..., + ) -> None: ... + +class BoundaryNorm(Normalize): + boundaries: np.ndarray + N: int + Ncmap: int + extend: Literal["neither", "both", "min", "max"] + def __init__( + self, + boundaries: ArrayLike, + ncolors: int, + clip: bool = ..., + *, + extend: Literal["neither", "both", "min", "max"] = ... + ) -> None: ... + +class NoNorm(Normalize): ... + +def rgb_to_hsv(arr: ArrayLike) -> np.ndarray: ... +def hsv_to_rgb(hsv: ArrayLike) -> np.ndarray: ... + +class LightSource: + azdeg: float + altdeg: float + hsv_min_val: float + hsv_max_val: float + hsv_min_sat: float + hsv_max_sat: float + def __init__( + self, + azdeg: float = ..., + altdeg: float = ..., + hsv_min_val: float = ..., + hsv_max_val: float = ..., + hsv_min_sat: float = ..., + hsv_max_sat: float = ..., + ) -> None: ... + @property + def direction(self) -> np.ndarray: ... + def hillshade( + self, + elevation: ArrayLike, + vert_exag: float = ..., + dx: float = ..., + dy: float = ..., + fraction: float = ..., + ) -> np.ndarray: ... + def shade_normals( + self, normals: np.ndarray, fraction: float = ... + ) -> np.ndarray: ... + def shade( + self, + data: ArrayLike, + cmap: Colormap, + norm: Normalize | None = ..., + blend_mode: Literal["hsv", "overlay", "soft"] | Callable = ..., + vmin: float | None = ..., + vmax: float | None = ..., + vert_exag: float = ..., + dx: float = ..., + dy: float = ..., + fraction: float = ..., + **kwargs + ) -> np.ndarray: ... + def shade_rgb( + self, + rgb: ArrayLike, + elevation: ArrayLike, + fraction: float = ..., + blend_mode: Literal["hsv", "overlay", "soft"] | Callable = ..., + vert_exag: float = ..., + dx: float = ..., + dy: float = ..., + **kwargs + ) -> np.ndarray: ... + def blend_hsv( + self, + rgb: ArrayLike, + intensity: ArrayLike, + hsv_max_sat: float | None = ..., + hsv_max_val: float | None = ..., + hsv_min_val: float | None = ..., + hsv_min_sat: float | None = ..., + ) -> ArrayLike: ... + def blend_soft_light( + self, rgb: np.ndarray, intensity: np.ndarray + ) -> np.ndarray: ... + def blend_overlay(self, rgb: np.ndarray, intensity: np.ndarray) -> np.ndarray: ... + +def from_levels_and_colors( + levels: Sequence[float], + colors: Sequence[ColorType], + extend: Literal["neither", "min", "max", "both"] = ..., +) -> tuple[ListedColormap, BoundaryNorm]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/container.py b/venv/lib/python3.10/site-packages/matplotlib/container.py new file mode 100644 index 00000000..0f082e29 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/container.py @@ -0,0 +1,141 @@ +from matplotlib import cbook +from matplotlib.artist import Artist + + +class Container(tuple): + """ + Base class for containers. + + Containers are classes that collect semantically related Artists such as + the bars of a bar plot. + """ + + def __repr__(self): + return f"<{type(self).__name__} object of {len(self)} artists>" + + def __new__(cls, *args, **kwargs): + return tuple.__new__(cls, args[0]) + + def __init__(self, kl, label=None): + self._callbacks = cbook.CallbackRegistry(signals=["pchanged"]) + self._remove_method = None + self._label = str(label) if label is not None else None + + def remove(self): + for c in cbook.flatten( + self, scalarp=lambda x: isinstance(x, Artist)): + if c is not None: + c.remove() + if self._remove_method: + self._remove_method(self) + + def get_children(self): + return [child for child in cbook.flatten(self) if child is not None] + + get_label = Artist.get_label + set_label = Artist.set_label + add_callback = Artist.add_callback + remove_callback = Artist.remove_callback + pchanged = Artist.pchanged + + +class BarContainer(Container): + """ + Container for the artists of bar plots (e.g. created by `.Axes.bar`). + + The container can be treated as a tuple of the *patches* themselves. + Additionally, you can access these and further parameters by the + attributes. + + Attributes + ---------- + patches : list of :class:`~matplotlib.patches.Rectangle` + The artists of the bars. + + errorbar : None or :class:`~matplotlib.container.ErrorbarContainer` + A container for the error bar artists if error bars are present. + *None* otherwise. + + datavalues : None or array-like + The underlying data values corresponding to the bars. + + orientation : {'vertical', 'horizontal'}, default: None + If 'vertical', the bars are assumed to be vertical. + If 'horizontal', the bars are assumed to be horizontal. + + """ + + def __init__(self, patches, errorbar=None, *, datavalues=None, + orientation=None, **kwargs): + self.patches = patches + self.errorbar = errorbar + self.datavalues = datavalues + self.orientation = orientation + super().__init__(patches, **kwargs) + + +class ErrorbarContainer(Container): + """ + Container for the artists of error bars (e.g. created by `.Axes.errorbar`). + + The container can be treated as the *lines* tuple itself. + Additionally, you can access these and further parameters by the + attributes. + + Attributes + ---------- + lines : tuple + Tuple of ``(data_line, caplines, barlinecols)``. + + - data_line : :class:`~matplotlib.lines.Line2D` instance of + x, y plot markers and/or line. + - caplines : tuple of :class:`~matplotlib.lines.Line2D` instances of + the error bar caps. + - barlinecols : list of :class:`~matplotlib.collections.LineCollection` + with the horizontal and vertical error ranges. + + has_xerr, has_yerr : bool + ``True`` if the errorbar has x/y errors. + + """ + + def __init__(self, lines, has_xerr=False, has_yerr=False, **kwargs): + self.lines = lines + self.has_xerr = has_xerr + self.has_yerr = has_yerr + super().__init__(lines, **kwargs) + + +class StemContainer(Container): + """ + Container for the artists created in a :meth:`.Axes.stem` plot. + + The container can be treated like a namedtuple ``(markerline, stemlines, + baseline)``. + + Attributes + ---------- + markerline : :class:`~matplotlib.lines.Line2D` + The artist of the markers at the stem heads. + + stemlines : list of :class:`~matplotlib.lines.Line2D` + The artists of the vertical lines for all stems. + + baseline : :class:`~matplotlib.lines.Line2D` + The artist of the horizontal baseline. + """ + def __init__(self, markerline_stemlines_baseline, **kwargs): + """ + Parameters + ---------- + markerline_stemlines_baseline : tuple + Tuple of ``(markerline, stemlines, baseline)``. + ``markerline`` contains the `.LineCollection` of the markers, + ``stemlines`` is a `.LineCollection` of the main lines, + ``baseline`` is the `.Line2D` of the baseline. + """ + markerline, stemlines, baseline = markerline_stemlines_baseline + self.markerline = markerline + self.stemlines = stemlines + self.baseline = baseline + super().__init__(markerline_stemlines_baseline, **kwargs) diff --git a/venv/lib/python3.10/site-packages/matplotlib/container.pyi b/venv/lib/python3.10/site-packages/matplotlib/container.pyi new file mode 100644 index 00000000..9cc2e1ac --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/container.pyi @@ -0,0 +1,56 @@ +from matplotlib.artist import Artist +from matplotlib.lines import Line2D +from matplotlib.collections import LineCollection +from matplotlib.patches import Rectangle + +from collections.abc import Callable +from typing import Any, Literal +from numpy.typing import ArrayLike + +class Container(tuple): + def __new__(cls, *args, **kwargs): ... + def __init__(self, kl, label: Any | None = ...) -> None: ... + def remove(self) -> None: ... + def get_children(self) -> list[Artist]: ... + def get_label(self) -> str | None: ... + def set_label(self, s: Any) -> None: ... + def add_callback(self, func: Callable[[Artist], Any]) -> int: ... + def remove_callback(self, oid: int) -> None: ... + def pchanged(self) -> None: ... + +class BarContainer(Container): + patches: list[Rectangle] + errorbar: None | ErrorbarContainer + datavalues: None | ArrayLike + orientation: None | Literal["vertical", "horizontal"] + def __init__( + self, + patches: list[Rectangle], + errorbar: ErrorbarContainer | None = ..., + *, + datavalues: ArrayLike | None = ..., + orientation: Literal["vertical", "horizontal"] | None = ..., + **kwargs + ) -> None: ... + +class ErrorbarContainer(Container): + lines: tuple[Line2D, Line2D, LineCollection] + has_xerr: bool + has_yerr: bool + def __init__( + self, + lines: tuple[Line2D, Line2D, LineCollection], + has_xerr: bool = ..., + has_yerr: bool = ..., + **kwargs + ) -> None: ... + +class StemContainer(Container): + markerline: Line2D + stemlines: LineCollection + baseline: Line2D + def __init__( + self, + markerline_stemlines_baseline: tuple[Line2D, LineCollection, Line2D], + **kwargs + ) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/contour.py b/venv/lib/python3.10/site-packages/matplotlib/contour.py new file mode 100644 index 00000000..0e6068c6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/contour.py @@ -0,0 +1,1847 @@ +""" +Classes to support contour plotting and labelling for the Axes class. +""" + +from contextlib import ExitStack +import functools +import math +from numbers import Integral + +import numpy as np +from numpy import ma + +import matplotlib as mpl +from matplotlib import _api, _docstring +from matplotlib.backend_bases import MouseButton +from matplotlib.lines import Line2D +from matplotlib.path import Path +from matplotlib.text import Text +import matplotlib.ticker as ticker +import matplotlib.cm as cm +import matplotlib.colors as mcolors +import matplotlib.collections as mcoll +import matplotlib.font_manager as font_manager +import matplotlib.cbook as cbook +import matplotlib.patches as mpatches +import matplotlib.transforms as mtransforms + + +def _contour_labeler_event_handler(cs, inline, inline_spacing, event): + canvas = cs.axes.figure.canvas + is_button = event.name == "button_press_event" + is_key = event.name == "key_press_event" + # Quit (even if not in infinite mode; this is consistent with + # MATLAB and sometimes quite useful, but will require the user to + # test how many points were actually returned before using data). + if (is_button and event.button == MouseButton.MIDDLE + or is_key and event.key in ["escape", "enter"]): + canvas.stop_event_loop() + # Pop last click. + elif (is_button and event.button == MouseButton.RIGHT + or is_key and event.key in ["backspace", "delete"]): + # Unfortunately, if one is doing inline labels, then there is currently + # no way to fix the broken contour - once humpty-dumpty is broken, he + # can't be put back together. In inline mode, this does nothing. + if not inline: + cs.pop_label() + canvas.draw() + # Add new click. + elif (is_button and event.button == MouseButton.LEFT + # On macOS/gtk, some keys return None. + or is_key and event.key is not None): + if cs.axes.contains(event)[0]: + cs.add_label_near(event.x, event.y, transform=False, + inline=inline, inline_spacing=inline_spacing) + canvas.draw() + + +class ContourLabeler: + """Mixin to provide labelling capability to `.ContourSet`.""" + + def clabel(self, levels=None, *, + fontsize=None, inline=True, inline_spacing=5, fmt=None, + colors=None, use_clabeltext=False, manual=False, + rightside_up=True, zorder=None): + """ + Label a contour plot. + + Adds labels to line contours in this `.ContourSet` (which inherits from + this mixin class). + + Parameters + ---------- + levels : array-like, optional + A list of level values, that should be labeled. The list must be + a subset of ``cs.levels``. If not given, all levels are labeled. + + fontsize : str or float, default: :rc:`font.size` + Size in points or relative size e.g., 'smaller', 'x-large'. + See `.Text.set_size` for accepted string values. + + colors : :mpltype:`color` or colors or None, default: None + The label colors: + + - If *None*, the color of each label matches the color of + the corresponding contour. + + - If one string color, e.g., *colors* = 'r' or *colors* = + 'red', all labels will be plotted in this color. + + - If a tuple of colors (string, float, RGB, etc), different labels + will be plotted in different colors in the order specified. + + inline : bool, default: True + If ``True`` the underlying contour is removed where the label is + placed. + + inline_spacing : float, default: 5 + Space in pixels to leave on each side of label when placing inline. + + This spacing will be exact for labels at locations where the + contour is straight, less so for labels on curved contours. + + fmt : `.Formatter` or str or callable or dict, optional + How the levels are formatted: + + - If a `.Formatter`, it is used to format all levels at once, using + its `.Formatter.format_ticks` method. + - If a str, it is interpreted as a %-style format string. + - If a callable, it is called with one level at a time and should + return the corresponding label. + - If a dict, it should directly map levels to labels. + + The default is to use a standard `.ScalarFormatter`. + + manual : bool or iterable, default: False + If ``True``, contour labels will be placed manually using + mouse clicks. Click the first button near a contour to + add a label, click the second button (or potentially both + mouse buttons at once) to finish adding labels. The third + button can be used to remove the last label added, but + only if labels are not inline. Alternatively, the keyboard + can be used to select label locations (enter to end label + placement, delete or backspace act like the third mouse button, + and any other key will select a label location). + + *manual* can also be an iterable object of (x, y) tuples. + Contour labels will be created as if mouse is clicked at each + (x, y) position. + + rightside_up : bool, default: True + If ``True``, label rotations will always be plus + or minus 90 degrees from level. + + use_clabeltext : bool, default: False + If ``True``, use `.Text.set_transform_rotates_text` to ensure that + label rotation is updated whenever the Axes aspect changes. + + zorder : float or None, default: ``(2 + contour.get_zorder())`` + zorder of the contour labels. + + Returns + ------- + labels + A list of `.Text` instances for the labels. + """ + + # Based on the input arguments, clabel() adds a list of "label + # specific" attributes to the ContourSet object. These attributes are + # all of the form label* and names should be fairly self explanatory. + # + # Once these attributes are set, clabel passes control to the labels() + # method (for automatic label placement) or blocking_input_loop and + # _contour_labeler_event_handler (for manual label placement). + + if fmt is None: + fmt = ticker.ScalarFormatter(useOffset=False) + fmt.create_dummy_axis() + self.labelFmt = fmt + self._use_clabeltext = use_clabeltext + self.labelManual = manual + self.rightside_up = rightside_up + self._clabel_zorder = 2 + self.get_zorder() if zorder is None else zorder + + if levels is None: + levels = self.levels + indices = list(range(len(self.cvalues))) + else: + levlabs = list(levels) + indices, levels = [], [] + for i, lev in enumerate(self.levels): + if lev in levlabs: + indices.append(i) + levels.append(lev) + if len(levels) < len(levlabs): + raise ValueError(f"Specified levels {levlabs} don't match " + f"available levels {self.levels}") + self.labelLevelList = levels + self.labelIndiceList = indices + + self._label_font_props = font_manager.FontProperties(size=fontsize) + + if colors is None: + self.labelMappable = self + self.labelCValueList = np.take(self.cvalues, self.labelIndiceList) + else: + cmap = mcolors.ListedColormap(colors, N=len(self.labelLevelList)) + self.labelCValueList = list(range(len(self.labelLevelList))) + self.labelMappable = cm.ScalarMappable(cmap=cmap, + norm=mcolors.NoNorm()) + + self.labelXYs = [] + + if np.iterable(manual): + for x, y in manual: + self.add_label_near(x, y, inline, inline_spacing) + elif manual: + print('Select label locations manually using first mouse button.') + print('End manual selection with second mouse button.') + if not inline: + print('Remove last label by clicking third mouse button.') + mpl._blocking_input.blocking_input_loop( + self.axes.figure, ["button_press_event", "key_press_event"], + timeout=-1, handler=functools.partial( + _contour_labeler_event_handler, + self, inline, inline_spacing)) + else: + self.labels(inline, inline_spacing) + + return cbook.silent_list('text.Text', self.labelTexts) + + def print_label(self, linecontour, labelwidth): + """Return whether a contour is long enough to hold a label.""" + return (len(linecontour) > 10 * labelwidth + or (len(linecontour) + and (np.ptp(linecontour, axis=0) > 1.2 * labelwidth).any())) + + def too_close(self, x, y, lw): + """Return whether a label is already near this location.""" + thresh = (1.2 * lw) ** 2 + return any((x - loc[0]) ** 2 + (y - loc[1]) ** 2 < thresh + for loc in self.labelXYs) + + def _get_nth_label_width(self, nth): + """Return the width of the *nth* label, in pixels.""" + fig = self.axes.figure + renderer = fig._get_renderer() + return (Text(0, 0, + self.get_text(self.labelLevelList[nth], self.labelFmt), + figure=fig, fontproperties=self._label_font_props) + .get_window_extent(renderer).width) + + def get_text(self, lev, fmt): + """Get the text of the label.""" + if isinstance(lev, str): + return lev + elif isinstance(fmt, dict): + return fmt.get(lev, '%1.3f') + elif callable(getattr(fmt, "format_ticks", None)): + return fmt.format_ticks([*self.labelLevelList, lev])[-1] + elif callable(fmt): + return fmt(lev) + else: + return fmt % lev + + def locate_label(self, linecontour, labelwidth): + """ + Find good place to draw a label (relatively flat part of the contour). + """ + ctr_size = len(linecontour) + n_blocks = int(np.ceil(ctr_size / labelwidth)) if labelwidth > 1 else 1 + block_size = ctr_size if n_blocks == 1 else int(labelwidth) + # Split contour into blocks of length ``block_size``, filling the last + # block by cycling the contour start (per `np.resize` semantics). (Due + # to cycling, the index returned is taken modulo ctr_size.) + xx = np.resize(linecontour[:, 0], (n_blocks, block_size)) + yy = np.resize(linecontour[:, 1], (n_blocks, block_size)) + yfirst = yy[:, :1] + ylast = yy[:, -1:] + xfirst = xx[:, :1] + xlast = xx[:, -1:] + s = (yfirst - yy) * (xlast - xfirst) - (xfirst - xx) * (ylast - yfirst) + l = np.hypot(xlast - xfirst, ylast - yfirst) + # Ignore warning that divide by zero throws, as this is a valid option + with np.errstate(divide='ignore', invalid='ignore'): + distances = (abs(s) / l).sum(axis=-1) + # Labels are drawn in the middle of the block (``hbsize``) where the + # contour is the closest (per ``distances``) to a straight line, but + # not `too_close()` to a preexisting label. + hbsize = block_size // 2 + adist = np.argsort(distances) + # If all candidates are `too_close()`, go back to the straightest part + # (``adist[0]``). + for idx in np.append(adist, adist[0]): + x, y = xx[idx, hbsize], yy[idx, hbsize] + if not self.too_close(x, y, labelwidth): + break + return x, y, (idx * block_size + hbsize) % ctr_size + + def _split_path_and_get_label_rotation(self, path, idx, screen_pos, lw, spacing=5): + """ + Prepare for insertion of a label at index *idx* of *path*. + + Parameters + ---------- + path : Path + The path where the label will be inserted, in data space. + idx : int + The vertex index after which the label will be inserted. + screen_pos : (float, float) + The position where the label will be inserted, in screen space. + lw : float + The label width, in screen space. + spacing : float + Extra spacing around the label, in screen space. + + Returns + ------- + path : Path + The path, broken so that the label can be drawn over it. + angle : float + The rotation of the label. + + Notes + ----- + Both tasks are done together to avoid calculating path lengths multiple times, + which is relatively costly. + + The method used here involves computing the path length along the contour in + pixel coordinates and then looking (label width / 2) away from central point to + determine rotation and then to break contour if desired. The extra spacing is + taken into account when breaking the path, but not when computing the angle. + """ + if hasattr(self, "_old_style_split_collections"): + vis = False + for coll in self._old_style_split_collections: + vis |= coll.get_visible() + coll.remove() + self.set_visible(vis) + del self._old_style_split_collections # Invalidate them. + + xys = path.vertices + codes = path.codes + + # Insert a vertex at idx/pos (converting back to data space), if there isn't yet + # a vertex there. With infinite precision one could also always insert the + # extra vertex (it will get masked out by the label below anyways), but floating + # point inaccuracies (the point can have undergone a data->screen->data + # transform loop) can slightly shift the point and e.g. shift the angle computed + # below from exactly zero to nonzero. + pos = self.get_transform().inverted().transform(screen_pos) + if not np.allclose(pos, xys[idx]): + xys = np.insert(xys, idx, pos, axis=0) + codes = np.insert(codes, idx, Path.LINETO) + + # Find the connected component where the label will be inserted. Note that a + # path always starts with a MOVETO, and we consider there's an implicit + # MOVETO (closing the last path) at the end. + movetos = (codes == Path.MOVETO).nonzero()[0] + start = movetos[movetos <= idx][-1] + try: + stop = movetos[movetos > idx][0] + except IndexError: + stop = len(codes) + + # Restrict ourselves to the connected component. + cc_xys = xys[start:stop] + idx -= start + + # If the path is closed, rotate it s.t. it starts at the label. + is_closed_path = codes[stop - 1] == Path.CLOSEPOLY + if is_closed_path: + cc_xys = np.concatenate([cc_xys[idx:-1], cc_xys[:idx+1]]) + idx = 0 + + # Like np.interp, but additionally vectorized over fp. + def interp_vec(x, xp, fp): return [np.interp(x, xp, col) for col in fp.T] + + # Use cumulative path lengths ("cpl") as curvilinear coordinate along contour. + screen_xys = self.get_transform().transform(cc_xys) + path_cpls = np.insert( + np.cumsum(np.hypot(*np.diff(screen_xys, axis=0).T)), 0, 0) + path_cpls -= path_cpls[idx] + + # Use linear interpolation to get end coordinates of label. + target_cpls = np.array([-lw/2, lw/2]) + if is_closed_path: # For closed paths, target from the other end. + target_cpls[0] += (path_cpls[-1] - path_cpls[0]) + (sx0, sx1), (sy0, sy1) = interp_vec(target_cpls, path_cpls, screen_xys) + angle = np.rad2deg(np.arctan2(sy1 - sy0, sx1 - sx0)) # Screen space. + if self.rightside_up: # Fix angle so text is never upside-down + angle = (angle + 90) % 180 - 90 + + target_cpls += [-spacing, +spacing] # Expand range by spacing. + + # Get indices near points of interest; use -1 as out of bounds marker. + i0, i1 = np.interp(target_cpls, path_cpls, range(len(path_cpls)), + left=-1, right=-1) + i0 = math.floor(i0) + i1 = math.ceil(i1) + (x0, x1), (y0, y1) = interp_vec(target_cpls, path_cpls, cc_xys) + + # Actually break contours (dropping zero-len parts). + new_xy_blocks = [] + new_code_blocks = [] + if is_closed_path: + if i0 != -1 and i1 != -1: + # This is probably wrong in the case that the entire contour would + # be discarded, but ensures that a valid path is returned and is + # consistent with behavior of mpl <3.8 + points = cc_xys[i1:i0+1] + new_xy_blocks.extend([[(x1, y1)], points, [(x0, y0)]]) + nlines = len(points) + 1 + new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * nlines]) + else: + if i0 != -1: + new_xy_blocks.extend([cc_xys[:i0 + 1], [(x0, y0)]]) + new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * (i0 + 1)]) + if i1 != -1: + new_xy_blocks.extend([[(x1, y1)], cc_xys[i1:]]) + new_code_blocks.extend([ + [Path.MOVETO], [Path.LINETO] * (len(cc_xys) - i1)]) + + # Back to the full path. + xys = np.concatenate([xys[:start], *new_xy_blocks, xys[stop:]]) + codes = np.concatenate([codes[:start], *new_code_blocks, codes[stop:]]) + + return angle, Path(xys, codes) + + @_api.deprecated("3.8") + def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5): + """ + Calculate the appropriate label rotation given the linecontour + coordinates in screen units, the index of the label location and the + label width. + + If *lc* is not None or empty, also break contours and compute + inlining. + + *spacing* is the empty space to leave around the label, in pixels. + + Both tasks are done together to avoid calculating path lengths + multiple times, which is relatively costly. + + The method used here involves computing the path length along the + contour in pixel coordinates and then looking approximately (label + width / 2) away from central point to determine rotation and then to + break contour if desired. + """ + + if lc is None: + lc = [] + # Half the label width + hlw = lw / 2.0 + + # Check if closed and, if so, rotate contour so label is at edge + closed = _is_closed_polygon(slc) + if closed: + slc = np.concatenate([slc[ind:-1], slc[:ind + 1]]) + if len(lc): # Rotate lc also if not empty + lc = np.concatenate([lc[ind:-1], lc[:ind + 1]]) + ind = 0 + + # Calculate path lengths + pl = np.zeros(slc.shape[0], dtype=float) + dx = np.diff(slc, axis=0) + pl[1:] = np.cumsum(np.hypot(dx[:, 0], dx[:, 1])) + pl = pl - pl[ind] + + # Use linear interpolation to get points around label + xi = np.array([-hlw, hlw]) + if closed: # Look at end also for closed contours + dp = np.array([pl[-1], 0]) + else: + dp = np.zeros_like(xi) + + # Get angle of vector between the two ends of the label - must be + # calculated in pixel space for text rotation to work correctly. + (dx,), (dy,) = (np.diff(np.interp(dp + xi, pl, slc_col)) + for slc_col in slc.T) + rotation = np.rad2deg(np.arctan2(dy, dx)) + + if self.rightside_up: + # Fix angle so text is never upside-down + rotation = (rotation + 90) % 180 - 90 + + # Break contour if desired + nlc = [] + if len(lc): + # Expand range by spacing + xi = dp + xi + np.array([-spacing, spacing]) + + # Get (integer) indices near points of interest; use -1 as marker + # for out of bounds. + I = np.interp(xi, pl, np.arange(len(pl)), left=-1, right=-1) + I = [np.floor(I[0]).astype(int), np.ceil(I[1]).astype(int)] + if I[0] != -1: + xy1 = [np.interp(xi[0], pl, lc_col) for lc_col in lc.T] + if I[1] != -1: + xy2 = [np.interp(xi[1], pl, lc_col) for lc_col in lc.T] + + # Actually break contours + if closed: + # This will remove contour if shorter than label + if all(i != -1 for i in I): + nlc.append(np.vstack([xy2, lc[I[1]:I[0]+1], xy1])) + else: + # These will remove pieces of contour if they have length zero + if I[0] != -1: + nlc.append(np.vstack([lc[:I[0]+1], xy1])) + if I[1] != -1: + nlc.append(np.vstack([xy2, lc[I[1]:]])) + + # The current implementation removes contours completely + # covered by labels. Uncomment line below to keep + # original contour if this is the preferred behavior. + # if not len(nlc): nlc = [lc] + + return rotation, nlc + + def add_label(self, x, y, rotation, lev, cvalue): + """Add a contour label, respecting whether *use_clabeltext* was set.""" + data_x, data_y = self.axes.transData.inverted().transform((x, y)) + t = Text( + data_x, data_y, + text=self.get_text(lev, self.labelFmt), + rotation=rotation, + horizontalalignment='center', verticalalignment='center', + zorder=self._clabel_zorder, + color=self.labelMappable.to_rgba(cvalue, alpha=self.get_alpha()), + fontproperties=self._label_font_props, + clip_box=self.axes.bbox) + if self._use_clabeltext: + data_rotation, = self.axes.transData.inverted().transform_angles( + [rotation], [[x, y]]) + t.set(rotation=data_rotation, transform_rotates_text=True) + self.labelTexts.append(t) + self.labelCValues.append(cvalue) + self.labelXYs.append((x, y)) + # Add label to plot here - useful for manual mode label selection + self.axes.add_artist(t) + + @_api.deprecated("3.8", alternative="add_label") + def add_label_clabeltext(self, x, y, rotation, lev, cvalue): + """Add contour label with `.Text.set_transform_rotates_text`.""" + with cbook._setattr_cm(self, _use_clabeltext=True): + self.add_label(x, y, rotation, lev, cvalue) + + def add_label_near(self, x, y, inline=True, inline_spacing=5, + transform=None): + """ + Add a label near the point ``(x, y)``. + + Parameters + ---------- + x, y : float + The approximate location of the label. + inline : bool, default: True + If *True* remove the segment of the contour beneath the label. + inline_spacing : int, default: 5 + Space in pixels to leave on each side of label when placing + inline. This spacing will be exact for labels at locations where + the contour is straight, less so for labels on curved contours. + transform : `.Transform` or `False`, default: ``self.axes.transData`` + A transform applied to ``(x, y)`` before labeling. The default + causes ``(x, y)`` to be interpreted as data coordinates. `False` + is a synonym for `.IdentityTransform`; i.e. ``(x, y)`` should be + interpreted as display coordinates. + """ + + if transform is None: + transform = self.axes.transData + if transform: + x, y = transform.transform((x, y)) + + idx_level_min, idx_vtx_min, proj = self._find_nearest_contour( + (x, y), self.labelIndiceList) + path = self._paths[idx_level_min] + level = self.labelIndiceList.index(idx_level_min) + label_width = self._get_nth_label_width(level) + rotation, path = self._split_path_and_get_label_rotation( + path, idx_vtx_min, proj, label_width, inline_spacing) + self.add_label(*proj, rotation, self.labelLevelList[idx_level_min], + self.labelCValueList[idx_level_min]) + + if inline: + self._paths[idx_level_min] = path + + def pop_label(self, index=-1): + """Defaults to removing last label, but any index can be supplied""" + self.labelCValues.pop(index) + t = self.labelTexts.pop(index) + t.remove() + + def labels(self, inline, inline_spacing): + for idx, (icon, lev, cvalue) in enumerate(zip( + self.labelIndiceList, + self.labelLevelList, + self.labelCValueList, + )): + trans = self.get_transform() + label_width = self._get_nth_label_width(idx) + additions = [] + for subpath in self._paths[icon]._iter_connected_components(): + screen_xys = trans.transform(subpath.vertices) + # Check if long enough for a label + if self.print_label(screen_xys, label_width): + x, y, idx = self.locate_label(screen_xys, label_width) + rotation, path = self._split_path_and_get_label_rotation( + subpath, idx, (x, y), + label_width, inline_spacing) + self.add_label(x, y, rotation, lev, cvalue) # Really add label. + if inline: # If inline, add new contours + additions.append(path) + else: # If not adding label, keep old path + additions.append(subpath) + # After looping over all segments on a contour, replace old path by new one + # if inlining. + if inline: + self._paths[icon] = Path.make_compound_path(*additions) + + def remove(self): + super().remove() + for text in self.labelTexts: + text.remove() + + +def _is_closed_polygon(X): + """ + Return whether first and last object in a sequence are the same. These are + presumably coordinates on a polygonal curve, in which case this function + tests if that curve is closed. + """ + return np.allclose(X[0], X[-1], rtol=1e-10, atol=1e-13) + + +def _find_closest_point_on_path(xys, p): + """ + Parameters + ---------- + xys : (N, 2) array-like + Coordinates of vertices. + p : (float, float) + Coordinates of point. + + Returns + ------- + d2min : float + Minimum square distance of *p* to *xys*. + proj : (float, float) + Projection of *p* onto *xys*. + imin : (int, int) + Consecutive indices of vertices of segment in *xys* where *proj* is. + Segments are considered as including their end-points; i.e. if the + closest point on the path is a node in *xys* with index *i*, this + returns ``(i-1, i)``. For the special case where *xys* is a single + point, this returns ``(0, 0)``. + """ + if len(xys) == 1: + return (((p - xys[0]) ** 2).sum(), xys[0], (0, 0)) + dxys = xys[1:] - xys[:-1] # Individual segment vectors. + norms = (dxys ** 2).sum(axis=1) + norms[norms == 0] = 1 # For zero-length segment, replace 0/0 by 0/1. + rel_projs = np.clip( # Project onto each segment in relative 0-1 coords. + ((p - xys[:-1]) * dxys).sum(axis=1) / norms, + 0, 1)[:, None] + projs = xys[:-1] + rel_projs * dxys # Projs. onto each segment, in (x, y). + d2s = ((projs - p) ** 2).sum(axis=1) # Squared distances. + imin = np.argmin(d2s) + return (d2s[imin], projs[imin], (imin, imin+1)) + + +_docstring.interpd.update(contour_set_attributes=r""" +Attributes +---------- +ax : `~matplotlib.axes.Axes` + The Axes object in which the contours are drawn. + +collections : `.silent_list` of `.PathCollection`\s + The `.Artist`\s representing the contour. This is a list of + `.PathCollection`\s for both line and filled contours. + +levels : array + The values of the contour levels. + +layers : array + Same as levels for line contours; half-way between + levels for filled contours. See ``ContourSet._process_colors``. +""") + + +@_docstring.dedent_interpd +class ContourSet(ContourLabeler, mcoll.Collection): + """ + Store a set of contour lines or filled regions. + + User-callable method: `~.Axes.clabel` + + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + + levels : [level0, level1, ..., leveln] + A list of floating point numbers indicating the contour levels. + + allsegs : [level0segs, level1segs, ...] + List of all the polygon segments for all the *levels*. + For contour lines ``len(allsegs) == len(levels)``, and for + filled contour regions ``len(allsegs) = len(levels)-1``. The lists + should look like :: + + level0segs = [polygon0, polygon1, ...] + polygon0 = [[x0, y0], [x1, y1], ...] + + allkinds : ``None`` or [level0kinds, level1kinds, ...] + Optional list of all the polygon vertex kinds (code types), as + described and used in Path. This is used to allow multiply- + connected paths such as holes within filled polygons. + If not ``None``, ``len(allkinds) == len(allsegs)``. The lists + should look like :: + + level0kinds = [polygon0kinds, ...] + polygon0kinds = [vertexcode0, vertexcode1, ...] + + If *allkinds* is not ``None``, usually all polygons for a + particular contour level are grouped together so that + ``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``. + + **kwargs + Keyword arguments are as described in the docstring of + `~.Axes.contour`. + + %(contour_set_attributes)s + """ + + def __init__(self, ax, *args, + levels=None, filled=False, linewidths=None, linestyles=None, + hatches=(None,), alpha=None, origin=None, extent=None, + cmap=None, colors=None, norm=None, vmin=None, vmax=None, + extend='neither', antialiased=None, nchunk=0, locator=None, + transform=None, negative_linestyles=None, clip_path=None, + **kwargs): + """ + Draw contour lines or filled regions, depending on + whether keyword arg *filled* is ``False`` (default) or ``True``. + + Call signature:: + + ContourSet(ax, levels, allsegs, [allkinds], **kwargs) + + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The `~.axes.Axes` object to draw on. + + levels : [level0, level1, ..., leveln] + A list of floating point numbers indicating the contour + levels. + + allsegs : [level0segs, level1segs, ...] + List of all the polygon segments for all the *levels*. + For contour lines ``len(allsegs) == len(levels)``, and for + filled contour regions ``len(allsegs) = len(levels)-1``. The lists + should look like :: + + level0segs = [polygon0, polygon1, ...] + polygon0 = [[x0, y0], [x1, y1], ...] + + allkinds : [level0kinds, level1kinds, ...], optional + Optional list of all the polygon vertex kinds (code types), as + described and used in Path. This is used to allow multiply- + connected paths such as holes within filled polygons. + If not ``None``, ``len(allkinds) == len(allsegs)``. The lists + should look like :: + + level0kinds = [polygon0kinds, ...] + polygon0kinds = [vertexcode0, vertexcode1, ...] + + If *allkinds* is not ``None``, usually all polygons for a + particular contour level are grouped together so that + ``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``. + + **kwargs + Keyword arguments are as described in the docstring of + `~.Axes.contour`. + """ + if antialiased is None and filled: + # Eliminate artifacts; we are not stroking the boundaries. + antialiased = False + # The default for line contours will be taken from the + # LineCollection default, which uses :rc:`lines.antialiased`. + super().__init__( + antialiaseds=antialiased, + alpha=alpha, + clip_path=clip_path, + transform=transform, + ) + self.axes = ax + self.levels = levels + self.filled = filled + self.hatches = hatches + self.origin = origin + self.extent = extent + self.colors = colors + self.extend = extend + + self.nchunk = nchunk + self.locator = locator + if (isinstance(norm, mcolors.LogNorm) + or isinstance(self.locator, ticker.LogLocator)): + self.logscale = True + if norm is None: + norm = mcolors.LogNorm() + else: + self.logscale = False + + _api.check_in_list([None, 'lower', 'upper', 'image'], origin=origin) + if self.extent is not None and len(self.extent) != 4: + raise ValueError( + "If given, 'extent' must be None or (x0, x1, y0, y1)") + if self.colors is not None and cmap is not None: + raise ValueError('Either colors or cmap must be None') + if self.origin == 'image': + self.origin = mpl.rcParams['image.origin'] + + self._orig_linestyles = linestyles # Only kept for user access. + self.negative_linestyles = negative_linestyles + # If negative_linestyles was not defined as a keyword argument, define + # negative_linestyles with rcParams + if self.negative_linestyles is None: + self.negative_linestyles = \ + mpl.rcParams['contour.negative_linestyle'] + + kwargs = self._process_args(*args, **kwargs) + self._process_levels() + + self._extend_min = self.extend in ['min', 'both'] + self._extend_max = self.extend in ['max', 'both'] + if self.colors is not None: + ncolors = len(self.levels) + if self.filled: + ncolors -= 1 + i0 = 0 + + # Handle the case where colors are given for the extended + # parts of the contour. + + use_set_under_over = False + # if we are extending the lower end, and we've been given enough + # colors then skip the first color in the resulting cmap. For the + # extend_max case we don't need to worry about passing more colors + # than ncolors as ListedColormap will clip. + total_levels = (ncolors + + int(self._extend_min) + + int(self._extend_max)) + if (len(self.colors) == total_levels and + (self._extend_min or self._extend_max)): + use_set_under_over = True + if self._extend_min: + i0 = 1 + + cmap = mcolors.ListedColormap(self.colors[i0:None], N=ncolors) + + if use_set_under_over: + if self._extend_min: + cmap.set_under(self.colors[0]) + if self._extend_max: + cmap.set_over(self.colors[-1]) + + # label lists must be initialized here + self.labelTexts = [] + self.labelCValues = [] + + self.set_cmap(cmap) + if norm is not None: + self.set_norm(norm) + with self.norm.callbacks.blocked(signal="changed"): + if vmin is not None: + self.norm.vmin = vmin + if vmax is not None: + self.norm.vmax = vmax + self.norm._changed() + self._process_colors() + + if self._paths is None: + self._paths = self._make_paths_from_contour_generator() + + if self.filled: + if linewidths is not None: + _api.warn_external('linewidths is ignored by contourf') + # Lower and upper contour levels. + lowers, uppers = self._get_lowers_and_uppers() + self.set( + edgecolor="none", + # Default zorder taken from Collection + zorder=kwargs.pop("zorder", 1), + ) + + else: + self.set( + facecolor="none", + linewidths=self._process_linewidths(linewidths), + linestyle=self._process_linestyles(linestyles), + # Default zorder taken from LineCollection, which is higher + # than for filled contours so that lines are displayed on top. + zorder=kwargs.pop("zorder", 2), + label="_nolegend_", + ) + + self.axes.add_collection(self, autolim=False) + self.sticky_edges.x[:] = [self._mins[0], self._maxs[0]] + self.sticky_edges.y[:] = [self._mins[1], self._maxs[1]] + self.axes.update_datalim([self._mins, self._maxs]) + self.axes.autoscale_view(tight=True) + + self.changed() # set the colors + + if kwargs: + _api.warn_external( + 'The following kwargs were not used by contour: ' + + ", ".join(map(repr, kwargs)) + ) + + allsegs = property(lambda self: [ + [subp.vertices for subp in p._iter_connected_components()] + for p in self.get_paths()]) + allkinds = property(lambda self: [ + [subp.codes for subp in p._iter_connected_components()] + for p in self.get_paths()]) + tcolors = _api.deprecated("3.8")(property(lambda self: [ + (tuple(rgba),) for rgba in self.to_rgba(self.cvalues, self.alpha)])) + tlinewidths = _api.deprecated("3.8")(property(lambda self: [ + (w,) for w in self.get_linewidths()])) + alpha = property(lambda self: self.get_alpha()) + linestyles = property(lambda self: self._orig_linestyles) + + @_api.deprecated("3.8", alternative="set_antialiased or get_antialiased", + addendum="Note that get_antialiased returns an array.") + @property + def antialiased(self): + return all(self.get_antialiased()) + + @antialiased.setter + def antialiased(self, aa): + self.set_antialiased(aa) + + @_api.deprecated("3.8") + @property + def collections(self): + # On access, make oneself invisible and instead add the old-style collections + # (one PathCollection per level). We do not try to further split contours into + # connected components as we already lost track of what pairs of contours need + # to be considered as single units to draw filled regions with holes. + if not hasattr(self, "_old_style_split_collections"): + self.set_visible(False) + fcs = self.get_facecolor() + ecs = self.get_edgecolor() + lws = self.get_linewidth() + lss = self.get_linestyle() + self._old_style_split_collections = [] + for idx, path in enumerate(self._paths): + pc = mcoll.PathCollection( + [path] if len(path.vertices) else [], + alpha=self.get_alpha(), + antialiaseds=self._antialiaseds[idx % len(self._antialiaseds)], + transform=self.get_transform(), + zorder=self.get_zorder(), + label="_nolegend_", + facecolor=fcs[idx] if len(fcs) else "none", + edgecolor=ecs[idx] if len(ecs) else "none", + linewidths=[lws[idx % len(lws)]], + linestyles=[lss[idx % len(lss)]], + ) + if self.filled: + pc.set(hatch=self.hatches[idx % len(self.hatches)]) + self._old_style_split_collections.append(pc) + for col in self._old_style_split_collections: + self.axes.add_collection(col) + return self._old_style_split_collections + + def get_transform(self): + """Return the `.Transform` instance used by this ContourSet.""" + if self._transform is None: + self._transform = self.axes.transData + elif (not isinstance(self._transform, mtransforms.Transform) + and hasattr(self._transform, '_as_mpl_transform')): + self._transform = self._transform._as_mpl_transform(self.axes) + return self._transform + + def __getstate__(self): + state = self.__dict__.copy() + # the C object _contour_generator cannot currently be pickled. This + # isn't a big issue as it is not actually used once the contour has + # been calculated. + state['_contour_generator'] = None + return state + + def legend_elements(self, variable_name='x', str_format=str): + """ + Return a list of artists and labels suitable for passing through + to `~.Axes.legend` which represent this ContourSet. + + The labels have the form "0 < x <= 1" stating the data ranges which + the artists represent. + + Parameters + ---------- + variable_name : str + The string used inside the inequality used on the labels. + str_format : function: float -> str + Function used to format the numbers in the labels. + + Returns + ------- + artists : list[`.Artist`] + A list of the artists. + labels : list[str] + A list of the labels. + """ + artists = [] + labels = [] + + if self.filled: + lowers, uppers = self._get_lowers_and_uppers() + n_levels = len(self._paths) + for idx in range(n_levels): + artists.append(mpatches.Rectangle( + (0, 0), 1, 1, + facecolor=self.get_facecolor()[idx], + hatch=self.hatches[idx % len(self.hatches)], + )) + lower = str_format(lowers[idx]) + upper = str_format(uppers[idx]) + if idx == 0 and self.extend in ('min', 'both'): + labels.append(fr'${variable_name} \leq {lower}s$') + elif idx == n_levels - 1 and self.extend in ('max', 'both'): + labels.append(fr'${variable_name} > {upper}s$') + else: + labels.append(fr'${lower} < {variable_name} \leq {upper}$') + else: + for idx, level in enumerate(self.levels): + artists.append(Line2D( + [], [], + color=self.get_edgecolor()[idx], + linewidth=self.get_linewidths()[idx], + linestyle=self.get_linestyles()[idx], + )) + labels.append(fr'${variable_name} = {str_format(level)}$') + + return artists, labels + + def _process_args(self, *args, **kwargs): + """ + Process *args* and *kwargs*; override in derived classes. + + Must set self.levels, self.zmin and self.zmax, and update Axes limits. + """ + self.levels = args[0] + allsegs = args[1] + allkinds = args[2] if len(args) > 2 else None + self.zmax = np.max(self.levels) + self.zmin = np.min(self.levels) + + if allkinds is None: + allkinds = [[None] * len(segs) for segs in allsegs] + + # Check lengths of levels and allsegs. + if self.filled: + if len(allsegs) != len(self.levels) - 1: + raise ValueError('must be one less number of segments as ' + 'levels') + else: + if len(allsegs) != len(self.levels): + raise ValueError('must be same number of segments as levels') + + # Check length of allkinds. + if len(allkinds) != len(allsegs): + raise ValueError('allkinds has different length to allsegs') + + # Determine x, y bounds and update axes data limits. + flatseglist = [s for seg in allsegs for s in seg] + points = np.concatenate(flatseglist, axis=0) + self._mins = points.min(axis=0) + self._maxs = points.max(axis=0) + + # Each entry in (allsegs, allkinds) is a list of (segs, kinds): segs is a list + # of (N, 2) arrays of xy coordinates, kinds is a list of arrays of corresponding + # pathcodes. However, kinds can also be None; in which case all paths in that + # list are codeless (this case is normalized above). These lists are used to + # construct paths, which then get concatenated. + self._paths = [Path.make_compound_path(*map(Path, segs, kinds)) + for segs, kinds in zip(allsegs, allkinds)] + + return kwargs + + def _make_paths_from_contour_generator(self): + """Compute ``paths`` using C extension.""" + if self._paths is not None: + return self._paths + cg = self._contour_generator + empty_path = Path(np.empty((0, 2))) + vertices_and_codes = ( + map(cg.create_filled_contour, *self._get_lowers_and_uppers()) + if self.filled else + map(cg.create_contour, self.levels)) + return [Path(np.concatenate(vs), np.concatenate(cs)) if len(vs) else empty_path + for vs, cs in vertices_and_codes] + + def _get_lowers_and_uppers(self): + """ + Return ``(lowers, uppers)`` for filled contours. + """ + lowers = self._levels[:-1] + if self.zmin == lowers[0]: + # Include minimum values in lowest interval + lowers = lowers.copy() # so we don't change self._levels + if self.logscale: + lowers[0] = 0.99 * self.zmin + else: + lowers[0] -= 1 + uppers = self._levels[1:] + return (lowers, uppers) + + def changed(self): + if not hasattr(self, "cvalues"): + self._process_colors() # Sets cvalues. + # Force an autoscale immediately because self.to_rgba() calls + # autoscale_None() internally with the data passed to it, + # so if vmin/vmax are not set yet, this would override them with + # content from *cvalues* rather than levels like we want + self.norm.autoscale_None(self.levels) + self.set_array(self.cvalues) + self.update_scalarmappable() + alphas = np.broadcast_to(self.get_alpha(), len(self.cvalues)) + for label, cv, alpha in zip(self.labelTexts, self.labelCValues, alphas): + label.set_alpha(alpha) + label.set_color(self.labelMappable.to_rgba(cv)) + super().changed() + + def _autolev(self, N): + """ + Select contour levels to span the data. + + The target number of levels, *N*, is used only when the + scale is not log and default locator is used. + + We need two more levels for filled contours than for + line contours, because for the latter we need to specify + the lower and upper boundary of each range. For example, + a single contour boundary, say at z = 0, requires only + one contour line, but two filled regions, and therefore + three levels to provide boundaries for both regions. + """ + if self.locator is None: + if self.logscale: + self.locator = ticker.LogLocator() + else: + self.locator = ticker.MaxNLocator(N + 1, min_n_ticks=1) + + lev = self.locator.tick_values(self.zmin, self.zmax) + + try: + if self.locator._symmetric: + return lev + except AttributeError: + pass + + # Trim excess levels the locator may have supplied. + under = np.nonzero(lev < self.zmin)[0] + i0 = under[-1] if len(under) else 0 + over = np.nonzero(lev > self.zmax)[0] + i1 = over[0] + 1 if len(over) else len(lev) + if self.extend in ('min', 'both'): + i0 += 1 + if self.extend in ('max', 'both'): + i1 -= 1 + + if i1 - i0 < 3: + i0, i1 = 0, len(lev) + + return lev[i0:i1] + + def _process_contour_level_args(self, args, z_dtype): + """ + Determine the contour levels and store in self.levels. + """ + if self.levels is None: + if args: + levels_arg = args[0] + elif np.issubdtype(z_dtype, bool): + if self.filled: + levels_arg = [0, .5, 1] + else: + levels_arg = [.5] + else: + levels_arg = 7 # Default, hard-wired. + else: + levels_arg = self.levels + if isinstance(levels_arg, Integral): + self.levels = self._autolev(levels_arg) + else: + self.levels = np.asarray(levels_arg, np.float64) + if self.filled and len(self.levels) < 2: + raise ValueError("Filled contours require at least 2 levels.") + if len(self.levels) > 1 and np.min(np.diff(self.levels)) <= 0.0: + raise ValueError("Contour levels must be increasing") + + def _process_levels(self): + """ + Assign values to :attr:`layers` based on :attr:`levels`, + adding extended layers as needed if contours are filled. + + For line contours, layers simply coincide with levels; + a line is a thin layer. No extended levels are needed + with line contours. + """ + # Make a private _levels to include extended regions; we + # want to leave the original levels attribute unchanged. + # (Colorbar needs this even for line contours.) + self._levels = list(self.levels) + + if self.logscale: + lower, upper = 1e-250, 1e250 + else: + lower, upper = -1e250, 1e250 + + if self.extend in ('both', 'min'): + self._levels.insert(0, lower) + if self.extend in ('both', 'max'): + self._levels.append(upper) + self._levels = np.asarray(self._levels) + + if not self.filled: + self.layers = self.levels + return + + # Layer values are mid-way between levels in screen space. + if self.logscale: + # Avoid overflow by taking sqrt before multiplying. + self.layers = (np.sqrt(self._levels[:-1]) + * np.sqrt(self._levels[1:])) + else: + self.layers = 0.5 * (self._levels[:-1] + self._levels[1:]) + + def _process_colors(self): + """ + Color argument processing for contouring. + + Note that we base the colormapping on the contour levels + and layers, not on the actual range of the Z values. This + means we don't have to worry about bad values in Z, and we + always have the full dynamic range available for the selected + levels. + + The color is based on the midpoint of the layer, except for + extended end layers. By default, the norm vmin and vmax + are the extreme values of the non-extended levels. Hence, + the layer color extremes are not the extreme values of + the colormap itself, but approach those values as the number + of levels increases. An advantage of this scheme is that + line contours, when added to filled contours, take on + colors that are consistent with those of the filled regions; + for example, a contour line on the boundary between two + regions will have a color intermediate between those + of the regions. + + """ + self.monochrome = self.cmap.monochrome + if self.colors is not None: + # Generate integers for direct indexing. + i0, i1 = 0, len(self.levels) + if self.filled: + i1 -= 1 + # Out of range indices for over and under: + if self.extend in ('both', 'min'): + i0 -= 1 + if self.extend in ('both', 'max'): + i1 += 1 + self.cvalues = list(range(i0, i1)) + self.set_norm(mcolors.NoNorm()) + else: + self.cvalues = self.layers + self.norm.autoscale_None(self.levels) + self.set_array(self.cvalues) + self.update_scalarmappable() + if self.extend in ('both', 'max', 'min'): + self.norm.clip = False + + def _process_linewidths(self, linewidths): + Nlev = len(self.levels) + if linewidths is None: + default_linewidth = mpl.rcParams['contour.linewidth'] + if default_linewidth is None: + default_linewidth = mpl.rcParams['lines.linewidth'] + return [default_linewidth] * Nlev + elif not np.iterable(linewidths): + return [linewidths] * Nlev + else: + linewidths = list(linewidths) + return (linewidths * math.ceil(Nlev / len(linewidths)))[:Nlev] + + def _process_linestyles(self, linestyles): + Nlev = len(self.levels) + if linestyles is None: + tlinestyles = ['solid'] * Nlev + if self.monochrome: + eps = - (self.zmax - self.zmin) * 1e-15 + for i, lev in enumerate(self.levels): + if lev < eps: + tlinestyles[i] = self.negative_linestyles + else: + if isinstance(linestyles, str): + tlinestyles = [linestyles] * Nlev + elif np.iterable(linestyles): + tlinestyles = list(linestyles) + if len(tlinestyles) < Nlev: + nreps = int(np.ceil(Nlev / len(linestyles))) + tlinestyles = tlinestyles * nreps + if len(tlinestyles) > Nlev: + tlinestyles = tlinestyles[:Nlev] + else: + raise ValueError("Unrecognized type for linestyles kwarg") + return tlinestyles + + def _find_nearest_contour(self, xy, indices=None): + """ + Find the point in the unfilled contour plot that is closest (in screen + space) to point *xy*. + + Parameters + ---------- + xy : tuple[float, float] + The reference point (in screen space). + indices : list of int or None, default: None + Indices of contour levels to consider. If None (the default), all levels + are considered. + + Returns + ------- + idx_level_min : int + The index of the contour level closest to *xy*. + idx_vtx_min : int + The index of the `.Path` segment closest to *xy* (at that level). + proj : (float, float) + The point in the contour plot closest to *xy*. + """ + + # Convert each contour segment to pixel coordinates and then compare the given + # point to those coordinates for each contour. This is fast enough in normal + # cases, but speedups may be possible. + + if self.filled: + raise ValueError("Method does not support filled contours") + + if indices is None: + indices = range(len(self._paths)) + + d2min = np.inf + idx_level_min = idx_vtx_min = proj_min = None + + for idx_level in indices: + path = self._paths[idx_level] + idx_vtx_start = 0 + for subpath in path._iter_connected_components(): + if not len(subpath.vertices): + continue + lc = self.get_transform().transform(subpath.vertices) + d2, proj, leg = _find_closest_point_on_path(lc, xy) + if d2 < d2min: + d2min = d2 + idx_level_min = idx_level + idx_vtx_min = leg[1] + idx_vtx_start + proj_min = proj + idx_vtx_start += len(subpath) + + return idx_level_min, idx_vtx_min, proj_min + + def find_nearest_contour(self, x, y, indices=None, pixel=True): + """ + Find the point in the contour plot that is closest to ``(x, y)``. + + This method does not support filled contours. + + Parameters + ---------- + x, y : float + The reference point. + indices : list of int or None, default: None + Indices of contour levels to consider. If None (the default), all + levels are considered. + pixel : bool, default: True + If *True*, measure distance in pixel (screen) space, which is + useful for manual contour labeling; else, measure distance in axes + space. + + Returns + ------- + path : int + The index of the path that is closest to ``(x, y)``. Each path corresponds + to one contour level. + subpath : int + The index within that closest path of the subpath that is closest to + ``(x, y)``. Each subpath corresponds to one unbroken contour line. + index : int + The index of the vertices within that subpath that are closest to + ``(x, y)``. + xmin, ymin : float + The point in the contour plot that is closest to ``(x, y)``. + d2 : float + The squared distance from ``(xmin, ymin)`` to ``(x, y)``. + """ + segment = index = d2 = None + + with ExitStack() as stack: + if not pixel: + # _find_nearest_contour works in pixel space. We want axes space, so + # effectively disable the transformation here by setting to identity. + stack.enter_context(self._cm_set( + transform=mtransforms.IdentityTransform())) + + i_level, i_vtx, (xmin, ymin) = self._find_nearest_contour((x, y), indices) + + if i_level is not None: + cc_cumlens = np.cumsum( + [*map(len, self._paths[i_level]._iter_connected_components())]) + segment = cc_cumlens.searchsorted(i_vtx, "right") + index = i_vtx if segment == 0 else i_vtx - cc_cumlens[segment - 1] + d2 = (xmin-x)**2 + (ymin-y)**2 + + return (i_level, segment, index, xmin, ymin, d2) + + def draw(self, renderer): + paths = self._paths + n_paths = len(paths) + if not self.filled or all(hatch is None for hatch in self.hatches): + super().draw(renderer) + return + # In presence of hatching, draw contours one at a time. + for idx in range(n_paths): + with cbook._setattr_cm(self, _paths=[paths[idx]]), self._cm_set( + hatch=self.hatches[idx % len(self.hatches)], + array=[self.get_array()[idx]], + linewidths=[self.get_linewidths()[idx % len(self.get_linewidths())]], + linestyles=[self.get_linestyles()[idx % len(self.get_linestyles())]], + ): + super().draw(renderer) + + +@_docstring.dedent_interpd +class QuadContourSet(ContourSet): + """ + Create and store a set of contour lines or filled regions. + + This class is typically not instantiated directly by the user but by + `~.Axes.contour` and `~.Axes.contourf`. + + %(contour_set_attributes)s + """ + + def _process_args(self, *args, corner_mask=None, algorithm=None, **kwargs): + """ + Process args and kwargs. + """ + if args and isinstance(args[0], QuadContourSet): + if self.levels is None: + self.levels = args[0].levels + self.zmin = args[0].zmin + self.zmax = args[0].zmax + self._corner_mask = args[0]._corner_mask + contour_generator = args[0]._contour_generator + self._mins = args[0]._mins + self._maxs = args[0]._maxs + self._algorithm = args[0]._algorithm + else: + import contourpy + + if algorithm is None: + algorithm = mpl.rcParams['contour.algorithm'] + mpl.rcParams.validate["contour.algorithm"](algorithm) + self._algorithm = algorithm + + if corner_mask is None: + if self._algorithm == "mpl2005": + # mpl2005 does not support corner_mask=True so if not + # specifically requested then disable it. + corner_mask = False + else: + corner_mask = mpl.rcParams['contour.corner_mask'] + self._corner_mask = corner_mask + + x, y, z = self._contour_args(args, kwargs) + + contour_generator = contourpy.contour_generator( + x, y, z, name=self._algorithm, corner_mask=self._corner_mask, + line_type=contourpy.LineType.SeparateCode, + fill_type=contourpy.FillType.OuterCode, + chunk_size=self.nchunk) + + t = self.get_transform() + + # if the transform is not trans data, and some part of it + # contains transData, transform the xs and ys to data coordinates + if (t != self.axes.transData and + any(t.contains_branch_seperately(self.axes.transData))): + trans_to_data = t - self.axes.transData + pts = np.vstack([x.flat, y.flat]).T + transformed_pts = trans_to_data.transform(pts) + x = transformed_pts[..., 0] + y = transformed_pts[..., 1] + + self._mins = [ma.min(x), ma.min(y)] + self._maxs = [ma.max(x), ma.max(y)] + + self._contour_generator = contour_generator + + return kwargs + + def _contour_args(self, args, kwargs): + if self.filled: + fn = 'contourf' + else: + fn = 'contour' + nargs = len(args) + + if 0 < nargs <= 2: + z, *args = args + z = ma.asarray(z) + x, y = self._initialize_x_y(z) + elif 2 < nargs <= 4: + x, y, z_orig, *args = args + x, y, z = self._check_xyz(x, y, z_orig, kwargs) + + else: + raise _api.nargs_error(fn, takes="from 1 to 4", given=nargs) + z = ma.masked_invalid(z, copy=False) + self.zmax = z.max().astype(float) + self.zmin = z.min().astype(float) + if self.logscale and self.zmin <= 0: + z = ma.masked_where(z <= 0, z) + _api.warn_external('Log scale: values of z <= 0 have been masked') + self.zmin = z.min().astype(float) + self._process_contour_level_args(args, z.dtype) + return (x, y, z) + + def _check_xyz(self, x, y, z, kwargs): + """ + Check that the shapes of the input arrays match; if x and y are 1D, + convert them to 2D using meshgrid. + """ + x, y = self.axes._process_unit_info([("x", x), ("y", y)], kwargs) + + x = np.asarray(x, dtype=np.float64) + y = np.asarray(y, dtype=np.float64) + z = ma.asarray(z) + + if z.ndim != 2: + raise TypeError(f"Input z must be 2D, not {z.ndim}D") + if z.shape[0] < 2 or z.shape[1] < 2: + raise TypeError(f"Input z must be at least a (2, 2) shaped array, " + f"but has shape {z.shape}") + Ny, Nx = z.shape + + if x.ndim != y.ndim: + raise TypeError(f"Number of dimensions of x ({x.ndim}) and y " + f"({y.ndim}) do not match") + if x.ndim == 1: + nx, = x.shape + ny, = y.shape + if nx != Nx: + raise TypeError(f"Length of x ({nx}) must match number of " + f"columns in z ({Nx})") + if ny != Ny: + raise TypeError(f"Length of y ({ny}) must match number of " + f"rows in z ({Ny})") + x, y = np.meshgrid(x, y) + elif x.ndim == 2: + if x.shape != z.shape: + raise TypeError( + f"Shapes of x {x.shape} and z {z.shape} do not match") + if y.shape != z.shape: + raise TypeError( + f"Shapes of y {y.shape} and z {z.shape} do not match") + else: + raise TypeError(f"Inputs x and y must be 1D or 2D, not {x.ndim}D") + + return x, y, z + + def _initialize_x_y(self, z): + """ + Return X, Y arrays such that contour(Z) will match imshow(Z) + if origin is not None. + The center of pixel Z[i, j] depends on origin: + if origin is None, x = j, y = i; + if origin is 'lower', x = j + 0.5, y = i + 0.5; + if origin is 'upper', x = j + 0.5, y = Nrows - i - 0.5 + If extent is not None, x and y will be scaled to match, + as in imshow. + If origin is None and extent is not None, then extent + will give the minimum and maximum values of x and y. + """ + if z.ndim != 2: + raise TypeError(f"Input z must be 2D, not {z.ndim}D") + elif z.shape[0] < 2 or z.shape[1] < 2: + raise TypeError(f"Input z must be at least a (2, 2) shaped array, " + f"but has shape {z.shape}") + else: + Ny, Nx = z.shape + if self.origin is None: # Not for image-matching. + if self.extent is None: + return np.meshgrid(np.arange(Nx), np.arange(Ny)) + else: + x0, x1, y0, y1 = self.extent + x = np.linspace(x0, x1, Nx) + y = np.linspace(y0, y1, Ny) + return np.meshgrid(x, y) + # Match image behavior: + if self.extent is None: + x0, x1, y0, y1 = (0, Nx, 0, Ny) + else: + x0, x1, y0, y1 = self.extent + dx = (x1 - x0) / Nx + dy = (y1 - y0) / Ny + x = x0 + (np.arange(Nx) + 0.5) * dx + y = y0 + (np.arange(Ny) + 0.5) * dy + if self.origin == 'upper': + y = y[::-1] + return np.meshgrid(x, y) + + +_docstring.interpd.update(contour_doc=""" +`.contour` and `.contourf` draw contour lines and filled contours, +respectively. Except as noted, function signatures and return values +are the same for both versions. + +Parameters +---------- +X, Y : array-like, optional + The coordinates of the values in *Z*. + + *X* and *Y* must both be 2D with the same shape as *Z* (e.g. + created via `numpy.meshgrid`), or they must both be 1-D such + that ``len(X) == N`` is the number of columns in *Z* and + ``len(Y) == M`` is the number of rows in *Z*. + + *X* and *Y* must both be ordered monotonically. + + If not given, they are assumed to be integer indices, i.e. + ``X = range(N)``, ``Y = range(M)``. + +Z : (M, N) array-like + The height values over which the contour is drawn. Color-mapping is + controlled by *cmap*, *norm*, *vmin*, and *vmax*. + +levels : int or array-like, optional + Determines the number and positions of the contour lines / regions. + + If an int *n*, use `~matplotlib.ticker.MaxNLocator`, which tries + to automatically choose no more than *n+1* "nice" contour levels + between minimum and maximum numeric values of *Z*. + + If array-like, draw contour lines at the specified levels. + The values must be in increasing order. + +Returns +------- +`~.contour.QuadContourSet` + +Other Parameters +---------------- +corner_mask : bool, default: :rc:`contour.corner_mask` + Enable/disable corner masking, which only has an effect if *Z* is + a masked array. If ``False``, any quad touching a masked point is + masked out. If ``True``, only the triangular corners of quads + nearest those points are always masked out, other triangular + corners comprising three unmasked points are contoured as usual. + +colors : :mpltype:`color` or list of :mpltype:`color`, optional + The colors of the levels, i.e. the lines for `.contour` and the + areas for `.contourf`. + + The sequence is cycled for the levels in ascending order. If the + sequence is shorter than the number of levels, it's repeated. + + As a shortcut, single color strings may be used in place of + one-element lists, i.e. ``'red'`` instead of ``['red']`` to color + all levels with the same color. This shortcut does only work for + color strings, not for other ways of specifying colors. + + By default (value *None*), the colormap specified by *cmap* + will be used. + +alpha : float, default: 1 + The alpha blending value, between 0 (transparent) and 1 (opaque). + +%(cmap_doc)s + + This parameter is ignored if *colors* is set. + +%(norm_doc)s + + This parameter is ignored if *colors* is set. + +%(vmin_vmax_doc)s + + If *vmin* or *vmax* are not given, the default color scaling is based on + *levels*. + + This parameter is ignored if *colors* is set. + +origin : {*None*, 'upper', 'lower', 'image'}, default: None + Determines the orientation and exact position of *Z* by specifying + the position of ``Z[0, 0]``. This is only relevant, if *X*, *Y* + are not given. + + - *None*: ``Z[0, 0]`` is at X=0, Y=0 in the lower left corner. + - 'lower': ``Z[0, 0]`` is at X=0.5, Y=0.5 in the lower left corner. + - 'upper': ``Z[0, 0]`` is at X=N+0.5, Y=0.5 in the upper left + corner. + - 'image': Use the value from :rc:`image.origin`. + +extent : (x0, x1, y0, y1), optional + If *origin* is not *None*, then *extent* is interpreted as in + `.imshow`: it gives the outer pixel boundaries. In this case, the + position of Z[0, 0] is the center of the pixel, not a corner. If + *origin* is *None*, then (*x0*, *y0*) is the position of Z[0, 0], + and (*x1*, *y1*) is the position of Z[-1, -1]. + + This argument is ignored if *X* and *Y* are specified in the call + to contour. + +locator : ticker.Locator subclass, optional + The locator is used to determine the contour levels if they + are not given explicitly via *levels*. + Defaults to `~.ticker.MaxNLocator`. + +extend : {'neither', 'both', 'min', 'max'}, default: 'neither' + Determines the ``contourf``-coloring of values that are outside the + *levels* range. + + If 'neither', values outside the *levels* range are not colored. + If 'min', 'max' or 'both', color the values below, above or below + and above the *levels* range. + + Values below ``min(levels)`` and above ``max(levels)`` are mapped + to the under/over values of the `.Colormap`. Note that most + colormaps do not have dedicated colors for these by default, so + that the over and under values are the edge values of the colormap. + You may want to set these values explicitly using + `.Colormap.set_under` and `.Colormap.set_over`. + + .. note:: + + An existing `.QuadContourSet` does not get notified if + properties of its colormap are changed. Therefore, an explicit + call `.QuadContourSet.changed()` is needed after modifying the + colormap. The explicit call can be left out, if a colorbar is + assigned to the `.QuadContourSet` because it internally calls + `.QuadContourSet.changed()`. + + Example:: + + x = np.arange(1, 10) + y = x.reshape(-1, 1) + h = x * y + + cs = plt.contourf(h, levels=[10, 30, 50], + colors=['#808080', '#A0A0A0', '#C0C0C0'], extend='both') + cs.cmap.set_over('red') + cs.cmap.set_under('blue') + cs.changed() + +xunits, yunits : registered units, optional + Override axis units by specifying an instance of a + :class:`matplotlib.units.ConversionInterface`. + +antialiased : bool, optional + Enable antialiasing, overriding the defaults. For + filled contours, the default is *False*. For line contours, + it is taken from :rc:`lines.antialiased`. + +nchunk : int >= 0, optional + If 0, no subdivision of the domain. Specify a positive integer to + divide the domain into subdomains of *nchunk* by *nchunk* quads. + Chunking reduces the maximum length of polygons generated by the + contouring algorithm which reduces the rendering workload passed + on to the backend and also requires slightly less RAM. It can + however introduce rendering artifacts at chunk boundaries depending + on the backend, the *antialiased* flag and value of *alpha*. + +linewidths : float or array-like, default: :rc:`contour.linewidth` + *Only applies to* `.contour`. + + The line width of the contour lines. + + If a number, all levels will be plotted with this linewidth. + + If a sequence, the levels in ascending order will be plotted with + the linewidths in the order specified. + + If None, this falls back to :rc:`lines.linewidth`. + +linestyles : {*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, optional + *Only applies to* `.contour`. + + If *linestyles* is *None*, the default is 'solid' unless the lines are + monochrome. In that case, negative contours will instead take their + linestyle from the *negative_linestyles* argument. + + *linestyles* can also be an iterable of the above strings specifying a set + of linestyles to be used. If this iterable is shorter than the number of + contour levels it will be repeated as necessary. + +negative_linestyles : {*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, \ + optional + *Only applies to* `.contour`. + + If *linestyles* is *None* and the lines are monochrome, this argument + specifies the line style for negative contours. + + If *negative_linestyles* is *None*, the default is taken from + :rc:`contour.negative_linestyles`. + + *negative_linestyles* can also be an iterable of the above strings + specifying a set of linestyles to be used. If this iterable is shorter than + the number of contour levels it will be repeated as necessary. + +hatches : list[str], optional + *Only applies to* `.contourf`. + + A list of cross hatch patterns to use on the filled areas. + If None, no hatching will be added to the contour. + +algorithm : {'mpl2005', 'mpl2014', 'serial', 'threaded'}, optional + Which contouring algorithm to use to calculate the contour lines and + polygons. The algorithms are implemented in + `ContourPy `_, consult the + `ContourPy documentation `_ for + further information. + + The default is taken from :rc:`contour.algorithm`. + +clip_path : `~matplotlib.patches.Patch` or `.Path` or `.TransformedPath` + Set the clip path. See `~matplotlib.artist.Artist.set_clip_path`. + + .. versionadded:: 3.8 + +data : indexable object, optional + DATA_PARAMETER_PLACEHOLDER + +Notes +----- +1. `.contourf` differs from the MATLAB version in that it does not draw + the polygon edges. To draw edges, add line contours with calls to + `.contour`. + +2. `.contourf` fills intervals that are closed at the top; that is, for + boundaries *z1* and *z2*, the filled region is:: + + z1 < Z <= z2 + + except for the lowest interval, which is closed on both sides (i.e. + it includes the lowest value). + +3. `.contour` and `.contourf` use a `marching squares + `_ algorithm to + compute contour locations. More information can be found in + `ContourPy documentation `_. +""" % _docstring.interpd.params) diff --git a/venv/lib/python3.10/site-packages/matplotlib/contour.pyi b/venv/lib/python3.10/site-packages/matplotlib/contour.pyi new file mode 100644 index 00000000..c386bea4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/contour.pyi @@ -0,0 +1,162 @@ +import matplotlib.cm as cm +from matplotlib.artist import Artist +from matplotlib.axes import Axes +from matplotlib.collections import Collection, PathCollection +from matplotlib.colors import Colormap, Normalize +from matplotlib.font_manager import FontProperties +from matplotlib.path import Path +from matplotlib.patches import Patch +from matplotlib.text import Text +from matplotlib.transforms import Transform, TransformedPatchPath, TransformedPath +from matplotlib.ticker import Locator, Formatter + +from numpy.typing import ArrayLike +import numpy as np +from collections.abc import Callable, Iterable, Sequence +from typing import Literal +from .typing import ColorType + + + +class ContourLabeler: + labelFmt: str | Formatter | Callable[[float], str] | dict[float, str] + labelManual: bool | Iterable[tuple[float, float]] + rightside_up: bool + labelLevelList: list[float] + labelIndiceList: list[int] + labelMappable: cm.ScalarMappable + labelCValueList: list[ColorType] + labelXYs: list[tuple[float, float]] + def clabel( + self, + levels: ArrayLike | None = ..., + *, + fontsize: str | float | None = ..., + inline: bool = ..., + inline_spacing: float = ..., + fmt: str | Formatter | Callable[[float], str] | dict[float, str] | None = ..., + colors: ColorType | Sequence[ColorType] | None = ..., + use_clabeltext: bool = ..., + manual: bool | Iterable[tuple[float, float]] = ..., + rightside_up: bool = ..., + zorder: float | None = ... + ) -> list[Text]: ... + def print_label(self, linecontour: ArrayLike, labelwidth: float) -> bool: ... + def too_close(self, x: float, y: float, lw: float) -> bool: ... + def get_text( + self, + lev: float, + fmt: str | Formatter | Callable[[float], str] | dict[float, str], + ) -> str: ... + def locate_label( + self, linecontour: ArrayLike, labelwidth: float + ) -> tuple[float, float, float]: ... + def calc_label_rot_and_inline( + self, + slc: ArrayLike, + ind: int, + lw: float, + lc: ArrayLike | None = ..., + spacing: int = ..., + ) -> tuple[float, list[ArrayLike]]: ... + def add_label( + self, x: float, y: float, rotation: float, lev: float, cvalue: ColorType + ) -> None: ... + def add_label_clabeltext( + self, x: float, y: float, rotation: float, lev: float, cvalue: ColorType + ) -> None: ... + def add_label_near( + self, + x: float, + y: float, + inline: bool = ..., + inline_spacing: int = ..., + transform: Transform | Literal[False] | None = ..., + ) -> None: ... + def pop_label(self, index: int = ...) -> None: ... + def labels(self, inline: bool, inline_spacing: int) -> None: ... + def remove(self) -> None: ... + +class ContourSet(ContourLabeler, Collection): + axes: Axes + levels: Iterable[float] + filled: bool + linewidths: float | ArrayLike | None + hatches: Iterable[str | None] + origin: Literal["upper", "lower", "image"] | None + extent: tuple[float, float, float, float] | None + colors: ColorType | Sequence[ColorType] + extend: Literal["neither", "both", "min", "max"] + nchunk: int + locator: Locator | None + logscale: bool + negative_linestyles: None | Literal[ + "solid", "dashed", "dashdot", "dotted" + ] | Iterable[Literal["solid", "dashed", "dashdot", "dotted"]] + clip_path: Patch | Path | TransformedPath | TransformedPatchPath | None + labelTexts: list[Text] + labelCValues: list[ColorType] + @property + def tcolors(self) -> list[tuple[tuple[float, float, float, float]]]: ... + + # only for not filled + @property + def tlinewidths(self) -> list[tuple[float]]: ... + + @property + def allkinds(self) -> list[list[np.ndarray | None]]: ... + @property + def allsegs(self) -> list[list[np.ndarray]]: ... + @property + def alpha(self) -> float | None: ... + @property + def antialiased(self) -> bool: ... + @antialiased.setter + def antialiased(self, aa: bool | Sequence[bool]) -> None: ... + @property + def collections(self) -> list[PathCollection]: ... + @property + def linestyles(self) -> ( + None | + Literal["solid", "dashed", "dashdot", "dotted"] | + Iterable[Literal["solid", "dashed", "dashdot", "dotted"]] + ): ... + + def __init__( + self, + ax: Axes, + *args, + levels: Iterable[float] | None = ..., + filled: bool = ..., + linewidths: float | ArrayLike | None = ..., + linestyles: Literal["solid", "dashed", "dashdot", "dotted"] + | Iterable[Literal["solid", "dashed", "dashdot", "dotted"]] + | None = ..., + hatches: Iterable[str | None] = ..., + alpha: float | None = ..., + origin: Literal["upper", "lower", "image"] | None = ..., + extent: tuple[float, float, float, float] | None = ..., + cmap: str | Colormap | None = ..., + colors: ColorType | Sequence[ColorType] | None = ..., + norm: str | Normalize | None = ..., + vmin: float | None = ..., + vmax: float | None = ..., + extend: Literal["neither", "both", "min", "max"] = ..., + antialiased: bool | None = ..., + nchunk: int = ..., + locator: Locator | None = ..., + transform: Transform | None = ..., + negative_linestyles: Literal["solid", "dashed", "dashdot", "dotted"] + | Iterable[Literal["solid", "dashed", "dashdot", "dotted"]] + | None = ..., + clip_path: Patch | Path | TransformedPath | TransformedPatchPath | None = ..., + **kwargs + ) -> None: ... + def legend_elements( + self, variable_name: str = ..., str_format: Callable[[float], str] = ... + ) -> tuple[list[Artist], list[str]]: ... + def find_nearest_contour( + self, x: float, y: float, indices: Iterable[int] | None = ..., pixel: bool = ... + ) -> tuple[int, int, int, float, float, float]: ... + +class QuadContourSet(ContourSet): ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/dates.py b/venv/lib/python3.10/site-packages/matplotlib/dates.py new file mode 100644 index 00000000..c12d9f31 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/dates.py @@ -0,0 +1,1835 @@ +""" +Matplotlib provides sophisticated date plotting capabilities, standing on the +shoulders of python :mod:`datetime` and the add-on module dateutil_. + +By default, Matplotlib uses the units machinery described in +`~matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64` +objects when plotted on an x- or y-axis. The user does not +need to do anything for dates to be formatted, but dates often have strict +formatting needs, so this module provides many tick locators and formatters. +A basic example using `numpy.datetime64` is:: + + import numpy as np + + times = np.arange(np.datetime64('2001-01-02'), + np.datetime64('2002-02-03'), np.timedelta64(75, 'm')) + y = np.random.randn(len(times)) + + fig, ax = plt.subplots() + ax.plot(times, y) + +.. seealso:: + + - :doc:`/gallery/text_labels_and_annotations/date` + - :doc:`/gallery/ticks/date_concise_formatter` + - :doc:`/gallery/ticks/date_demo_convert` + +.. _date-format: + +Matplotlib date format +---------------------- + +Matplotlib represents dates using floating point numbers specifying the number +of days since a default epoch of 1970-01-01 UTC; for example, +1970-01-01, 06:00 is the floating point number 0.25. The formatters and +locators require the use of `datetime.datetime` objects, so only dates between +year 0001 and 9999 can be represented. Microsecond precision +is achievable for (approximately) 70 years on either side of the epoch, and +20 microseconds for the rest of the allowable range of dates (year 0001 to +9999). The epoch can be changed at import time via `.dates.set_epoch` or +:rc:`dates.epoch` to other dates if necessary; see +:doc:`/gallery/ticks/date_precision_and_epochs` for a discussion. + +.. note:: + + Before Matplotlib 3.3, the epoch was 0000-12-31 which lost modern + microsecond precision and also made the default axis limit of 0 an invalid + datetime. In 3.3 the epoch was changed as above. To convert old + ordinal floats to the new epoch, users can do:: + + new_ordinal = old_ordinal + mdates.date2num(np.datetime64('0000-12-31')) + + +There are a number of helper functions to convert between :mod:`datetime` +objects and Matplotlib dates: + +.. currentmodule:: matplotlib.dates + +.. autosummary:: + :nosignatures: + + datestr2num + date2num + num2date + num2timedelta + drange + set_epoch + get_epoch + +.. note:: + + Like Python's `datetime.datetime`, Matplotlib uses the Gregorian calendar + for all conversions between dates and floating point numbers. This practice + is not universal, and calendar differences can cause confusing + differences between what Python and Matplotlib give as the number of days + since 0001-01-01 and what other software and databases yield. For + example, the US Naval Observatory uses a calendar that switches + from Julian to Gregorian in October, 1582. Hence, using their + calculator, the number of days between 0001-01-01 and 2006-04-01 is + 732403, whereas using the Gregorian calendar via the datetime + module we find:: + + In [1]: date(2006, 4, 1).toordinal() - date(1, 1, 1).toordinal() + Out[1]: 732401 + +All the Matplotlib date converters, locators and formatters are timezone aware. +If no explicit timezone is provided, :rc:`timezone` is assumed, provided as a +string. If you want to use a different timezone, pass the *tz* keyword +argument of `num2date` to any date tick locators or formatters you create. This +can be either a `datetime.tzinfo` instance or a string with the timezone name +that can be parsed by `~dateutil.tz.gettz`. + +A wide range of specific and general purpose date tick locators and +formatters are provided in this module. See +:mod:`matplotlib.ticker` for general information on tick locators +and formatters. These are described below. + +The dateutil_ module provides additional code to handle date ticking, making it +easy to place ticks on any kinds of dates. See examples below. + +.. _dateutil: https://dateutil.readthedocs.io + +.. _date-locators: + +Date tick locators +------------------ + +Most of the date tick locators can locate single or multiple ticks. For example:: + + # import constants for the days of the week + from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU + + # tick on Mondays every week + loc = WeekdayLocator(byweekday=MO, tz=tz) + + # tick on Mondays and Saturdays + loc = WeekdayLocator(byweekday=(MO, SA)) + +In addition, most of the constructors take an interval argument:: + + # tick on Mondays every second week + loc = WeekdayLocator(byweekday=MO, interval=2) + +The rrule locator allows completely general date ticking:: + + # tick every 5th easter + rule = rrulewrapper(YEARLY, byeaster=1, interval=5) + loc = RRuleLocator(rule) + +The available date tick locators are: + +* `MicrosecondLocator`: Locate microseconds. + +* `SecondLocator`: Locate seconds. + +* `MinuteLocator`: Locate minutes. + +* `HourLocator`: Locate hours. + +* `DayLocator`: Locate specified days of the month. + +* `WeekdayLocator`: Locate days of the week, e.g., MO, TU. + +* `MonthLocator`: Locate months, e.g., 7 for July. + +* `YearLocator`: Locate years that are multiples of base. + +* `RRuleLocator`: Locate using a `rrulewrapper`. + `rrulewrapper` is a simple wrapper around dateutil_'s `dateutil.rrule` + which allow almost arbitrary date tick specifications. + See :doc:`rrule example `. + +* `AutoDateLocator`: On autoscale, this class picks the best `DateLocator` + (e.g., `RRuleLocator`) to set the view limits and the tick locations. If + called with ``interval_multiples=True`` it will make ticks line up with + sensible multiples of the tick intervals. For example, if the interval is + 4 hours, it will pick hours 0, 4, 8, etc. as ticks. This behaviour is not + guaranteed by default. + +.. _date-formatters: + +Date formatters +--------------- + +The available date formatters are: + +* `AutoDateFormatter`: attempts to figure out the best format to use. This is + most useful when used with the `AutoDateLocator`. + +* `ConciseDateFormatter`: also attempts to figure out the best format to use, + and to make the format as compact as possible while still having complete + date information. This is most useful when used with the `AutoDateLocator`. + +* `DateFormatter`: use `~datetime.datetime.strftime` format strings. +""" + +import datetime +import functools +import logging +import re + +from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, + MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, + SECONDLY) +from dateutil.relativedelta import relativedelta +import dateutil.parser +import dateutil.tz +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, cbook, ticker, units + +__all__ = ('datestr2num', 'date2num', 'num2date', 'num2timedelta', 'drange', + 'set_epoch', 'get_epoch', 'DateFormatter', 'ConciseDateFormatter', + 'AutoDateFormatter', 'DateLocator', 'RRuleLocator', + 'AutoDateLocator', 'YearLocator', 'MonthLocator', 'WeekdayLocator', + 'DayLocator', 'HourLocator', 'MinuteLocator', + 'SecondLocator', 'MicrosecondLocator', + 'rrule', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU', + 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', + 'HOURLY', 'MINUTELY', 'SECONDLY', 'MICROSECONDLY', 'relativedelta', + 'DateConverter', 'ConciseDateConverter', 'rrulewrapper') + + +_log = logging.getLogger(__name__) +UTC = datetime.timezone.utc + + +def _get_tzinfo(tz=None): + """ + Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`. + If None, retrieve the preferred timezone from the rcParams dictionary. + """ + tz = mpl._val_or_rc(tz, 'timezone') + if tz == 'UTC': + return UTC + if isinstance(tz, str): + tzinfo = dateutil.tz.gettz(tz) + if tzinfo is None: + raise ValueError(f"{tz} is not a valid timezone as parsed by" + " dateutil.tz.gettz.") + return tzinfo + if isinstance(tz, datetime.tzinfo): + return tz + raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.") + + +# Time-related constants. +EPOCH_OFFSET = float(datetime.datetime(1970, 1, 1).toordinal()) +# EPOCH_OFFSET is not used by matplotlib +MICROSECONDLY = SECONDLY + 1 +HOURS_PER_DAY = 24. +MIN_PER_HOUR = 60. +SEC_PER_MIN = 60. +MONTHS_PER_YEAR = 12. + +DAYS_PER_WEEK = 7. +DAYS_PER_MONTH = 30. +DAYS_PER_YEAR = 365.0 + +MINUTES_PER_DAY = MIN_PER_HOUR * HOURS_PER_DAY + +SEC_PER_HOUR = SEC_PER_MIN * MIN_PER_HOUR +SEC_PER_DAY = SEC_PER_HOUR * HOURS_PER_DAY +SEC_PER_WEEK = SEC_PER_DAY * DAYS_PER_WEEK + +MUSECONDS_PER_DAY = 1e6 * SEC_PER_DAY + +MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY = ( + MO, TU, WE, TH, FR, SA, SU) +WEEKDAYS = (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) + +# default epoch: passed to np.datetime64... +_epoch = None + + +def _reset_epoch_test_example(): + """ + Reset the Matplotlib date epoch so it can be set again. + + Only for use in tests and examples. + """ + global _epoch + _epoch = None + + +def set_epoch(epoch): + """ + Set the epoch (origin for dates) for datetime calculations. + + The default epoch is :rc:`dates.epoch` (by default 1970-01-01T00:00). + + If microsecond accuracy is desired, the date being plotted needs to be + within approximately 70 years of the epoch. Matplotlib internally + represents dates as days since the epoch, so floating point dynamic + range needs to be within a factor of 2^52. + + `~.dates.set_epoch` must be called before any dates are converted + (i.e. near the import section) or a RuntimeError will be raised. + + See also :doc:`/gallery/ticks/date_precision_and_epochs`. + + Parameters + ---------- + epoch : str + valid UTC date parsable by `numpy.datetime64` (do not include + timezone). + + """ + global _epoch + if _epoch is not None: + raise RuntimeError('set_epoch must be called before dates plotted.') + _epoch = epoch + + +def get_epoch(): + """ + Get the epoch used by `.dates`. + + Returns + ------- + epoch : str + String for the epoch (parsable by `numpy.datetime64`). + """ + global _epoch + + _epoch = mpl._val_or_rc(_epoch, 'date.epoch') + return _epoch + + +def _dt64_to_ordinalf(d): + """ + Convert `numpy.datetime64` or an `numpy.ndarray` of those types to + Gregorian date as UTC float relative to the epoch (see `.get_epoch`). + Roundoff is float64 precision. Practically: microseconds for dates + between 290301 BC, 294241 AD, milliseconds for larger dates + (see `numpy.datetime64`). + """ + + # the "extra" ensures that we at least allow the dynamic range out to + # seconds. That should get out to +/-2e11 years. + dseconds = d.astype('datetime64[s]') + extra = (d - dseconds).astype('timedelta64[ns]') + t0 = np.datetime64(get_epoch(), 's') + dt = (dseconds - t0).astype(np.float64) + dt += extra.astype(np.float64) / 1.0e9 + dt = dt / SEC_PER_DAY + + NaT_int = np.datetime64('NaT').astype(np.int64) + d_int = d.astype(np.int64) + dt[d_int == NaT_int] = np.nan + return dt + + +def _from_ordinalf(x, tz=None): + """ + Convert Gregorian float of the date, preserving hours, minutes, + seconds and microseconds. Return value is a `.datetime`. + + The input date *x* is a float in ordinal days at UTC, and the output will + be the specified `.datetime` object corresponding to that time in + timezone *tz*, or if *tz* is ``None``, in the timezone specified in + :rc:`timezone`. + """ + + tz = _get_tzinfo(tz) + + dt = (np.datetime64(get_epoch()) + + np.timedelta64(int(np.round(x * MUSECONDS_PER_DAY)), 'us')) + if dt < np.datetime64('0001-01-01') or dt >= np.datetime64('10000-01-01'): + raise ValueError(f'Date ordinal {x} converts to {dt} (using ' + f'epoch {get_epoch()}), but Matplotlib dates must be ' + 'between year 0001 and 9999.') + # convert from datetime64 to datetime: + dt = dt.tolist() + + # datetime64 is always UTC: + dt = dt.replace(tzinfo=dateutil.tz.gettz('UTC')) + # but maybe we are working in a different timezone so move. + dt = dt.astimezone(tz) + # fix round off errors + if np.abs(x) > 70 * 365: + # if x is big, round off to nearest twenty microseconds. + # This avoids floating point roundoff error + ms = round(dt.microsecond / 20) * 20 + if ms == 1000000: + dt = dt.replace(microsecond=0) + datetime.timedelta(seconds=1) + else: + dt = dt.replace(microsecond=ms) + + return dt + + +# a version of _from_ordinalf that can operate on numpy arrays +_from_ordinalf_np_vectorized = np.vectorize(_from_ordinalf, otypes="O") +# a version of dateutil.parser.parse that can operate on numpy arrays +_dateutil_parser_parse_np_vectorized = np.vectorize(dateutil.parser.parse) + + +def datestr2num(d, default=None): + """ + Convert a date string to a datenum using `dateutil.parser.parse`. + + Parameters + ---------- + d : str or sequence of str + The dates to convert. + + default : datetime.datetime, optional + The default date to use when fields are missing in *d*. + """ + if isinstance(d, str): + dt = dateutil.parser.parse(d, default=default) + return date2num(dt) + else: + if default is not None: + d = [date2num(dateutil.parser.parse(s, default=default)) + for s in d] + return np.asarray(d) + d = np.asarray(d) + if not d.size: + return d + return date2num(_dateutil_parser_parse_np_vectorized(d)) + + +def date2num(d): + """ + Convert datetime objects to Matplotlib dates. + + Parameters + ---------- + d : `datetime.datetime` or `numpy.datetime64` or sequences of these + + Returns + ------- + float or sequence of floats + Number of days since the epoch. See `.get_epoch` for the + epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`. If + the epoch is "1970-01-01T00:00:00" (default) then noon Jan 1 1970 + ("1970-01-01T12:00:00") returns 0.5. + + Notes + ----- + The Gregorian calendar is assumed; this is not universal practice. + For details see the module docstring. + """ + # Unpack in case of e.g. Pandas or xarray object + d = cbook._unpack_to_numpy(d) + + # make an iterable, but save state to unpack later: + iterable = np.iterable(d) + if not iterable: + d = [d] + + masked = np.ma.is_masked(d) + mask = np.ma.getmask(d) + d = np.asarray(d) + + # convert to datetime64 arrays, if not already: + if not np.issubdtype(d.dtype, np.datetime64): + # datetime arrays + if not d.size: + # deals with an empty array... + return d + tzi = getattr(d[0], 'tzinfo', None) + if tzi is not None: + # make datetime naive: + d = [dt.astimezone(UTC).replace(tzinfo=None) for dt in d] + d = np.asarray(d) + d = d.astype('datetime64[us]') + + d = np.ma.masked_array(d, mask=mask) if masked else d + d = _dt64_to_ordinalf(d) + + return d if iterable else d[0] + + +def num2date(x, tz=None): + """ + Convert Matplotlib dates to `~datetime.datetime` objects. + + Parameters + ---------- + x : float or sequence of floats + Number of days (fraction part represents hours, minutes, seconds) + since the epoch. See `.get_epoch` for the + epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Timezone of *x*. If a string, *tz* is passed to `dateutil.tz`. + + Returns + ------- + `~datetime.datetime` or sequence of `~datetime.datetime` + Dates are returned in timezone *tz*. + + If *x* is a sequence, a sequence of `~datetime.datetime` objects will + be returned. + + Notes + ----- + The Gregorian calendar is assumed; this is not universal practice. + For details, see the module docstring. + """ + tz = _get_tzinfo(tz) + return _from_ordinalf_np_vectorized(x, tz).tolist() + + +_ordinalf_to_timedelta_np_vectorized = np.vectorize( + lambda x: datetime.timedelta(days=x), otypes="O") + + +def num2timedelta(x): + """ + Convert number of days to a `~datetime.timedelta` object. + + If *x* is a sequence, a sequence of `~datetime.timedelta` objects will + be returned. + + Parameters + ---------- + x : float, sequence of floats + Number of days. The fraction part represents hours, minutes, seconds. + + Returns + ------- + `datetime.timedelta` or list[`datetime.timedelta`] + """ + return _ordinalf_to_timedelta_np_vectorized(x).tolist() + + +def drange(dstart, dend, delta): + """ + Return a sequence of equally spaced Matplotlib dates. + + The dates start at *dstart* and reach up to, but not including *dend*. + They are spaced by *delta*. + + Parameters + ---------- + dstart, dend : `~datetime.datetime` + The date limits. + delta : `datetime.timedelta` + Spacing of the dates. + + Returns + ------- + `numpy.array` + A list floats representing Matplotlib dates. + + """ + f1 = date2num(dstart) + f2 = date2num(dend) + step = delta.total_seconds() / SEC_PER_DAY + + # calculate the difference between dend and dstart in times of delta + num = int(np.ceil((f2 - f1) / step)) + + # calculate end of the interval which will be generated + dinterval_end = dstart + num * delta + + # ensure, that an half open interval will be generated [dstart, dend) + if dinterval_end >= dend: + # if the endpoint is greater than or equal to dend, + # just subtract one delta + dinterval_end -= delta + num -= 1 + + f2 = date2num(dinterval_end) # new float-endpoint + return np.linspace(f1, f2, num + 1) + + +def _wrap_in_tex(text): + p = r'([a-zA-Z]+)' + ret_text = re.sub(p, r'}$\1$\\mathdefault{', text) + + # Braces ensure symbols are not spaced like binary operators. + ret_text = ret_text.replace('-', '{-}').replace(':', '{:}') + # To not concatenate space between numbers. + ret_text = ret_text.replace(' ', r'\;') + ret_text = '$\\mathdefault{' + ret_text + '}$' + ret_text = ret_text.replace('$\\mathdefault{}$', '') + return ret_text + + +## date tick locators and formatters ### + + +class DateFormatter(ticker.Formatter): + """ + Format a tick (in days since the epoch) with a + `~datetime.datetime.strftime` format string. + """ + + def __init__(self, fmt, tz=None, *, usetex=None): + """ + Parameters + ---------- + fmt : str + `~datetime.datetime.strftime` format string + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + usetex : bool, default: :rc:`text.usetex` + To enable/disable the use of TeX's math mode for rendering the + results of the formatter. + """ + self.tz = _get_tzinfo(tz) + self.fmt = fmt + self._usetex = mpl._val_or_rc(usetex, 'text.usetex') + + def __call__(self, x, pos=0): + result = num2date(x, self.tz).strftime(self.fmt) + return _wrap_in_tex(result) if self._usetex else result + + def set_tzinfo(self, tz): + self.tz = _get_tzinfo(tz) + + +class ConciseDateFormatter(ticker.Formatter): + """ + A `.Formatter` which attempts to figure out the best format to use for the + date, and to make it as compact as possible, but still be complete. This is + most useful when used with the `AutoDateLocator`:: + + >>> locator = AutoDateLocator() + >>> formatter = ConciseDateFormatter(locator) + + Parameters + ---------- + locator : `.ticker.Locator` + Locator that this axis is using. + + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone, passed to `.dates.num2date`. + + formats : list of 6 strings, optional + Format strings for 6 levels of tick labelling: mostly years, + months, days, hours, minutes, and seconds. Strings use + the same format codes as `~datetime.datetime.strftime`. Default is + ``['%Y', '%b', '%d', '%H:%M', '%H:%M', '%S.%f']`` + + zero_formats : list of 6 strings, optional + Format strings for tick labels that are "zeros" for a given tick + level. For instance, if most ticks are months, ticks around 1 Jan 2005 + will be labeled "Dec", "2005", "Feb". The default is + ``['', '%Y', '%b', '%b-%d', '%H:%M', '%H:%M']`` + + offset_formats : list of 6 strings, optional + Format strings for the 6 levels that is applied to the "offset" + string found on the right side of an x-axis, or top of a y-axis. + Combined with the tick labels this should completely specify the + date. The default is:: + + ['', '%Y', '%Y-%b', '%Y-%b-%d', '%Y-%b-%d', '%Y-%b-%d %H:%M'] + + show_offset : bool, default: True + Whether to show the offset or not. + + usetex : bool, default: :rc:`text.usetex` + To enable/disable the use of TeX's math mode for rendering the results + of the formatter. + + Examples + -------- + See :doc:`/gallery/ticks/date_concise_formatter` + + .. plot:: + + import datetime + import matplotlib.dates as mdates + + base = datetime.datetime(2005, 2, 1) + dates = np.array([base + datetime.timedelta(hours=(2 * i)) + for i in range(732)]) + N = len(dates) + np.random.seed(19680801) + y = np.cumsum(np.random.randn(N)) + + fig, ax = plt.subplots(constrained_layout=True) + locator = mdates.AutoDateLocator() + formatter = mdates.ConciseDateFormatter(locator) + ax.xaxis.set_major_locator(locator) + ax.xaxis.set_major_formatter(formatter) + + ax.plot(dates, y) + ax.set_title('Concise Date Formatter') + + """ + + def __init__(self, locator, tz=None, formats=None, offset_formats=None, + zero_formats=None, show_offset=True, *, usetex=None): + """ + Autoformat the date labels. The default format is used to form an + initial string, and then redundant elements are removed. + """ + self._locator = locator + self._tz = tz + self.defaultfmt = '%Y' + # there are 6 levels with each level getting a specific format + # 0: mostly years, 1: months, 2: days, + # 3: hours, 4: minutes, 5: seconds + if formats: + if len(formats) != 6: + raise ValueError('formats argument must be a list of ' + '6 format strings (or None)') + self.formats = formats + else: + self.formats = ['%Y', # ticks are mostly years + '%b', # ticks are mostly months + '%d', # ticks are mostly days + '%H:%M', # hrs + '%H:%M', # min + '%S.%f', # secs + ] + # fmt for zeros ticks at this level. These are + # ticks that should be labeled w/ info the level above. + # like 1 Jan can just be labelled "Jan". 02:02:00 can + # just be labeled 02:02. + if zero_formats: + if len(zero_formats) != 6: + raise ValueError('zero_formats argument must be a list of ' + '6 format strings (or None)') + self.zero_formats = zero_formats + elif formats: + # use the users formats for the zero tick formats + self.zero_formats = [''] + self.formats[:-1] + else: + # make the defaults a bit nicer: + self.zero_formats = [''] + self.formats[:-1] + self.zero_formats[3] = '%b-%d' + + if offset_formats: + if len(offset_formats) != 6: + raise ValueError('offset_formats argument must be a list of ' + '6 format strings (or None)') + self.offset_formats = offset_formats + else: + self.offset_formats = ['', + '%Y', + '%Y-%b', + '%Y-%b-%d', + '%Y-%b-%d', + '%Y-%b-%d %H:%M'] + self.offset_string = '' + self.show_offset = show_offset + self._usetex = mpl._val_or_rc(usetex, 'text.usetex') + + def __call__(self, x, pos=None): + formatter = DateFormatter(self.defaultfmt, self._tz, + usetex=self._usetex) + return formatter(x, pos=pos) + + def format_ticks(self, values): + tickdatetime = [num2date(value, tz=self._tz) for value in values] + tickdate = np.array([tdt.timetuple()[:6] for tdt in tickdatetime]) + + # basic algorithm: + # 1) only display a part of the date if it changes over the ticks. + # 2) don't display the smaller part of the date if: + # it is always the same or if it is the start of the + # year, month, day etc. + # fmt for most ticks at this level + fmts = self.formats + # format beginnings of days, months, years, etc. + zerofmts = self.zero_formats + # offset fmt are for the offset in the upper left of the + # or lower right of the axis. + offsetfmts = self.offset_formats + show_offset = self.show_offset + + # determine the level we will label at: + # mostly 0: years, 1: months, 2: days, + # 3: hours, 4: minutes, 5: seconds, 6: microseconds + for level in range(5, -1, -1): + unique = np.unique(tickdate[:, level]) + if len(unique) > 1: + # if 1 is included in unique, the year is shown in ticks + if level < 2 and np.any(unique == 1): + show_offset = False + break + elif level == 0: + # all tickdate are the same, so only micros might be different + # set to the most precise (6: microseconds doesn't exist...) + level = 5 + + # level is the basic level we will label at. + # now loop through and decide the actual ticklabels + zerovals = [0, 1, 1, 0, 0, 0, 0] + labels = [''] * len(tickdate) + for nn in range(len(tickdate)): + if level < 5: + if tickdate[nn][level] == zerovals[level]: + fmt = zerofmts[level] + else: + fmt = fmts[level] + else: + # special handling for seconds + microseconds + if (tickdatetime[nn].second == tickdatetime[nn].microsecond + == 0): + fmt = zerofmts[level] + else: + fmt = fmts[level] + labels[nn] = tickdatetime[nn].strftime(fmt) + + # special handling of seconds and microseconds: + # strip extra zeros and decimal if possible. + # this is complicated by two factors. 1) we have some level-4 strings + # here (i.e. 03:00, '0.50000', '1.000') 2) we would like to have the + # same number of decimals for each string (i.e. 0.5 and 1.0). + if level >= 5: + trailing_zeros = min( + (len(s) - len(s.rstrip('0')) for s in labels if '.' in s), + default=None) + if trailing_zeros: + for nn in range(len(labels)): + if '.' in labels[nn]: + labels[nn] = labels[nn][:-trailing_zeros].rstrip('.') + + if show_offset: + # set the offset string: + self.offset_string = tickdatetime[-1].strftime(offsetfmts[level]) + if self._usetex: + self.offset_string = _wrap_in_tex(self.offset_string) + else: + self.offset_string = '' + + if self._usetex: + return [_wrap_in_tex(l) for l in labels] + else: + return labels + + def get_offset(self): + return self.offset_string + + def format_data_short(self, value): + return num2date(value, tz=self._tz).strftime('%Y-%m-%d %H:%M:%S') + + +class AutoDateFormatter(ticker.Formatter): + """ + A `.Formatter` which attempts to figure out the best format to use. This + is most useful when used with the `AutoDateLocator`. + + `.AutoDateFormatter` has a ``.scale`` dictionary that maps tick scales (the + interval in days between one major tick) to format strings; this dictionary + defaults to :: + + self.scaled = { + DAYS_PER_YEAR: rcParams['date.autoformatter.year'], + DAYS_PER_MONTH: rcParams['date.autoformatter.month'], + 1: rcParams['date.autoformatter.day'], + 1 / HOURS_PER_DAY: rcParams['date.autoformatter.hour'], + 1 / MINUTES_PER_DAY: rcParams['date.autoformatter.minute'], + 1 / SEC_PER_DAY: rcParams['date.autoformatter.second'], + 1 / MUSECONDS_PER_DAY: rcParams['date.autoformatter.microsecond'], + } + + The formatter uses the format string corresponding to the lowest key in + the dictionary that is greater or equal to the current scale. Dictionary + entries can be customized:: + + locator = AutoDateLocator() + formatter = AutoDateFormatter(locator) + formatter.scaled[1/(24*60)] = '%M:%S' # only show min and sec + + Custom callables can also be used instead of format strings. The following + example shows how to use a custom format function to strip trailing zeros + from decimal seconds and adds the date to the first ticklabel:: + + def my_format_function(x, pos=None): + x = matplotlib.dates.num2date(x) + if pos == 0: + fmt = '%D %H:%M:%S.%f' + else: + fmt = '%H:%M:%S.%f' + label = x.strftime(fmt) + label = label.rstrip("0") + label = label.rstrip(".") + return label + + formatter.scaled[1/(24*60)] = my_format_function + """ + + # This can be improved by providing some user-level direction on + # how to choose the best format (precedence, etc.). + + # Perhaps a 'struct' that has a field for each time-type where a + # zero would indicate "don't show" and a number would indicate + # "show" with some sort of priority. Same priorities could mean + # show all with the same priority. + + # Or more simply, perhaps just a format string for each + # possibility... + + def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d', *, + usetex=None): + """ + Autoformat the date labels. + + Parameters + ---------- + locator : `.ticker.Locator` + Locator that this axis is using. + + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + + defaultfmt : str + The default format to use if none of the values in ``self.scaled`` + are greater than the unit returned by ``locator._get_unit()``. + + usetex : bool, default: :rc:`text.usetex` + To enable/disable the use of TeX's math mode for rendering the + results of the formatter. If any entries in ``self.scaled`` are set + as functions, then it is up to the customized function to enable or + disable TeX's math mode itself. + """ + self._locator = locator + self._tz = tz + self.defaultfmt = defaultfmt + self._formatter = DateFormatter(self.defaultfmt, tz) + rcParams = mpl.rcParams + self._usetex = mpl._val_or_rc(usetex, 'text.usetex') + self.scaled = { + DAYS_PER_YEAR: rcParams['date.autoformatter.year'], + DAYS_PER_MONTH: rcParams['date.autoformatter.month'], + 1: rcParams['date.autoformatter.day'], + 1 / HOURS_PER_DAY: rcParams['date.autoformatter.hour'], + 1 / MINUTES_PER_DAY: rcParams['date.autoformatter.minute'], + 1 / SEC_PER_DAY: rcParams['date.autoformatter.second'], + 1 / MUSECONDS_PER_DAY: rcParams['date.autoformatter.microsecond'] + } + + def _set_locator(self, locator): + self._locator = locator + + def __call__(self, x, pos=None): + try: + locator_unit_scale = float(self._locator._get_unit()) + except AttributeError: + locator_unit_scale = 1 + # Pick the first scale which is greater than the locator unit. + fmt = next((fmt for scale, fmt in sorted(self.scaled.items()) + if scale >= locator_unit_scale), + self.defaultfmt) + + if isinstance(fmt, str): + self._formatter = DateFormatter(fmt, self._tz, usetex=self._usetex) + result = self._formatter(x, pos) + elif callable(fmt): + result = fmt(x, pos) + else: + raise TypeError(f'Unexpected type passed to {self!r}.') + + return result + + +class rrulewrapper: + """ + A simple wrapper around a `dateutil.rrule` allowing flexible + date tick specifications. + """ + def __init__(self, freq, tzinfo=None, **kwargs): + """ + Parameters + ---------- + freq : {YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY} + Tick frequency. These constants are defined in `dateutil.rrule`, + but they are accessible from `matplotlib.dates` as well. + tzinfo : `datetime.tzinfo`, optional + Time zone information. The default is None. + **kwargs + Additional keyword arguments are passed to the `dateutil.rrule`. + """ + kwargs['freq'] = freq + self._base_tzinfo = tzinfo + + self._update_rrule(**kwargs) + + def set(self, **kwargs): + """Set parameters for an existing wrapper.""" + self._construct.update(kwargs) + + self._update_rrule(**self._construct) + + def _update_rrule(self, **kwargs): + tzinfo = self._base_tzinfo + + # rrule does not play nicely with timezones - especially pytz time + # zones, it's best to use naive zones and attach timezones once the + # datetimes are returned + if 'dtstart' in kwargs: + dtstart = kwargs['dtstart'] + if dtstart.tzinfo is not None: + if tzinfo is None: + tzinfo = dtstart.tzinfo + else: + dtstart = dtstart.astimezone(tzinfo) + + kwargs['dtstart'] = dtstart.replace(tzinfo=None) + + if 'until' in kwargs: + until = kwargs['until'] + if until.tzinfo is not None: + if tzinfo is not None: + until = until.astimezone(tzinfo) + else: + raise ValueError('until cannot be aware if dtstart ' + 'is naive and tzinfo is None') + + kwargs['until'] = until.replace(tzinfo=None) + + self._construct = kwargs.copy() + self._tzinfo = tzinfo + self._rrule = rrule(**self._construct) + + def _attach_tzinfo(self, dt, tzinfo): + # pytz zones are attached by "localizing" the datetime + if hasattr(tzinfo, 'localize'): + return tzinfo.localize(dt, is_dst=True) + + return dt.replace(tzinfo=tzinfo) + + def _aware_return_wrapper(self, f, returns_list=False): + """Decorator function that allows rrule methods to handle tzinfo.""" + # This is only necessary if we're actually attaching a tzinfo + if self._tzinfo is None: + return f + + # All datetime arguments must be naive. If they are not naive, they are + # converted to the _tzinfo zone before dropping the zone. + def normalize_arg(arg): + if isinstance(arg, datetime.datetime) and arg.tzinfo is not None: + if arg.tzinfo is not self._tzinfo: + arg = arg.astimezone(self._tzinfo) + + return arg.replace(tzinfo=None) + + return arg + + def normalize_args(args, kwargs): + args = tuple(normalize_arg(arg) for arg in args) + kwargs = {kw: normalize_arg(arg) for kw, arg in kwargs.items()} + + return args, kwargs + + # There are two kinds of functions we care about - ones that return + # dates and ones that return lists of dates. + if not returns_list: + def inner_func(*args, **kwargs): + args, kwargs = normalize_args(args, kwargs) + dt = f(*args, **kwargs) + return self._attach_tzinfo(dt, self._tzinfo) + else: + def inner_func(*args, **kwargs): + args, kwargs = normalize_args(args, kwargs) + dts = f(*args, **kwargs) + return [self._attach_tzinfo(dt, self._tzinfo) for dt in dts] + + return functools.wraps(f)(inner_func) + + def __getattr__(self, name): + if name in self.__dict__: + return self.__dict__[name] + + f = getattr(self._rrule, name) + + if name in {'after', 'before'}: + return self._aware_return_wrapper(f) + elif name in {'xafter', 'xbefore', 'between'}: + return self._aware_return_wrapper(f, returns_list=True) + else: + return f + + def __setstate__(self, state): + self.__dict__.update(state) + + +class DateLocator(ticker.Locator): + """ + Determines the tick locations when plotting dates. + + This class is subclassed by other Locators and + is not meant to be used on its own. + """ + hms0d = {'byhour': 0, 'byminute': 0, 'bysecond': 0} + + def __init__(self, tz=None): + """ + Parameters + ---------- + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + self.tz = _get_tzinfo(tz) + + def set_tzinfo(self, tz): + """ + Set timezone info. + + Parameters + ---------- + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + self.tz = _get_tzinfo(tz) + + def datalim_to_dt(self): + """Convert axis data interval to datetime objects.""" + dmin, dmax = self.axis.get_data_interval() + if dmin > dmax: + dmin, dmax = dmax, dmin + + return num2date(dmin, self.tz), num2date(dmax, self.tz) + + def viewlim_to_dt(self): + """Convert the view interval to datetime objects.""" + vmin, vmax = self.axis.get_view_interval() + if vmin > vmax: + vmin, vmax = vmax, vmin + return num2date(vmin, self.tz), num2date(vmax, self.tz) + + def _get_unit(self): + """ + Return how many days a unit of the locator is; used for + intelligent autoscaling. + """ + return 1 + + def _get_interval(self): + """ + Return the number of units for each tick. + """ + return 1 + + def nonsingular(self, vmin, vmax): + """ + Given the proposed upper and lower extent, adjust the range + if it is too close to being singular (i.e. a range of ~0). + """ + if not np.isfinite(vmin) or not np.isfinite(vmax): + # Except if there is no data, then use 1970 as default. + return (date2num(datetime.date(1970, 1, 1)), + date2num(datetime.date(1970, 1, 2))) + if vmax < vmin: + vmin, vmax = vmax, vmin + unit = self._get_unit() + interval = self._get_interval() + if abs(vmax - vmin) < 1e-6: + vmin -= 2 * unit * interval + vmax += 2 * unit * interval + return vmin, vmax + + +class RRuleLocator(DateLocator): + # use the dateutil rrule instance + + def __init__(self, o, tz=None): + super().__init__(tz) + self.rule = o + + def __call__(self): + # if no data have been set, this will tank with a ValueError + try: + dmin, dmax = self.viewlim_to_dt() + except ValueError: + return [] + + return self.tick_values(dmin, dmax) + + def tick_values(self, vmin, vmax): + start, stop = self._create_rrule(vmin, vmax) + dates = self.rule.between(start, stop, True) + if len(dates) == 0: + return date2num([vmin, vmax]) + return self.raise_if_exceeds(date2num(dates)) + + def _create_rrule(self, vmin, vmax): + # set appropriate rrule dtstart and until and return + # start and end + delta = relativedelta(vmax, vmin) + + # We need to cap at the endpoints of valid datetime + try: + start = vmin - delta + except (ValueError, OverflowError): + # cap + start = datetime.datetime(1, 1, 1, 0, 0, 0, + tzinfo=datetime.timezone.utc) + + try: + stop = vmax + delta + except (ValueError, OverflowError): + # cap + stop = datetime.datetime(9999, 12, 31, 23, 59, 59, + tzinfo=datetime.timezone.utc) + + self.rule.set(dtstart=start, until=stop) + + return vmin, vmax + + def _get_unit(self): + # docstring inherited + freq = self.rule._rrule._freq + return self.get_unit_generic(freq) + + @staticmethod + def get_unit_generic(freq): + if freq == YEARLY: + return DAYS_PER_YEAR + elif freq == MONTHLY: + return DAYS_PER_MONTH + elif freq == WEEKLY: + return DAYS_PER_WEEK + elif freq == DAILY: + return 1.0 + elif freq == HOURLY: + return 1.0 / HOURS_PER_DAY + elif freq == MINUTELY: + return 1.0 / MINUTES_PER_DAY + elif freq == SECONDLY: + return 1.0 / SEC_PER_DAY + else: + # error + return -1 # or should this just return '1'? + + def _get_interval(self): + return self.rule._rrule._interval + + +class AutoDateLocator(DateLocator): + """ + On autoscale, this class picks the best `DateLocator` to set the view + limits and the tick locations. + + Attributes + ---------- + intervald : dict + + Mapping of tick frequencies to multiples allowed for that ticking. + The default is :: + + self.intervald = { + YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500, + 1000, 2000, 4000, 5000, 10000], + MONTHLY : [1, 2, 3, 4, 6], + DAILY : [1, 2, 3, 7, 14, 21], + HOURLY : [1, 2, 3, 4, 6, 12], + MINUTELY: [1, 5, 10, 15, 30], + SECONDLY: [1, 5, 10, 15, 30], + MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, + 1000, 2000, 5000, 10000, 20000, 50000, + 100000, 200000, 500000, 1000000], + } + + where the keys are defined in `dateutil.rrule`. + + The interval is used to specify multiples that are appropriate for + the frequency of ticking. For instance, every 7 days is sensible + for daily ticks, but for minutes/seconds, 15 or 30 make sense. + + When customizing, you should only modify the values for the existing + keys. You should not add or delete entries. + + Example for forcing ticks every 3 hours:: + + locator = AutoDateLocator() + locator.intervald[HOURLY] = [3] # only show every 3 hours + """ + + def __init__(self, tz=None, minticks=5, maxticks=None, + interval_multiples=True): + """ + Parameters + ---------- + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + minticks : int + The minimum number of ticks desired; controls whether ticks occur + yearly, monthly, etc. + maxticks : int + The maximum number of ticks desired; controls the interval between + ticks (ticking every other, every 3, etc.). For fine-grained + control, this can be a dictionary mapping individual rrule + frequency constants (YEARLY, MONTHLY, etc.) to their own maximum + number of ticks. This can be used to keep the number of ticks + appropriate to the format chosen in `AutoDateFormatter`. Any + frequency not specified in this dictionary is given a default + value. + interval_multiples : bool, default: True + Whether ticks should be chosen to be multiple of the interval, + locking them to 'nicer' locations. For example, this will force + the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done + at 6 hour intervals. + """ + super().__init__(tz=tz) + self._freq = YEARLY + self._freqs = [YEARLY, MONTHLY, DAILY, HOURLY, MINUTELY, + SECONDLY, MICROSECONDLY] + self.minticks = minticks + + self.maxticks = {YEARLY: 11, MONTHLY: 12, DAILY: 11, HOURLY: 12, + MINUTELY: 11, SECONDLY: 11, MICROSECONDLY: 8} + if maxticks is not None: + try: + self.maxticks.update(maxticks) + except TypeError: + # Assume we were given an integer. Use this as the maximum + # number of ticks for every frequency and create a + # dictionary for this + self.maxticks = dict.fromkeys(self._freqs, maxticks) + self.interval_multiples = interval_multiples + self.intervald = { + YEARLY: [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500, + 1000, 2000, 4000, 5000, 10000], + MONTHLY: [1, 2, 3, 4, 6], + DAILY: [1, 2, 3, 7, 14, 21], + HOURLY: [1, 2, 3, 4, 6, 12], + MINUTELY: [1, 5, 10, 15, 30], + SECONDLY: [1, 5, 10, 15, 30], + MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, + 5000, 10000, 20000, 50000, 100000, 200000, 500000, + 1000000], + } + if interval_multiples: + # Swap "3" for "4" in the DAILY list; If we use 3 we get bad + # tick loc for months w/ 31 days: 1, 4, ..., 28, 31, 1 + # If we use 4 then we get: 1, 5, ... 25, 29, 1 + self.intervald[DAILY] = [1, 2, 4, 7, 14] + + self._byranges = [None, range(1, 13), range(1, 32), + range(0, 24), range(0, 60), range(0, 60), None] + + def __call__(self): + # docstring inherited + dmin, dmax = self.viewlim_to_dt() + locator = self.get_locator(dmin, dmax) + return locator() + + def tick_values(self, vmin, vmax): + return self.get_locator(vmin, vmax).tick_values(vmin, vmax) + + def nonsingular(self, vmin, vmax): + # whatever is thrown at us, we can scale the unit. + # But default nonsingular date plots at an ~4 year period. + if not np.isfinite(vmin) or not np.isfinite(vmax): + # Except if there is no data, then use 1970 as default. + return (date2num(datetime.date(1970, 1, 1)), + date2num(datetime.date(1970, 1, 2))) + if vmax < vmin: + vmin, vmax = vmax, vmin + if vmin == vmax: + vmin = vmin - DAYS_PER_YEAR * 2 + vmax = vmax + DAYS_PER_YEAR * 2 + return vmin, vmax + + def _get_unit(self): + if self._freq in [MICROSECONDLY]: + return 1. / MUSECONDS_PER_DAY + else: + return RRuleLocator.get_unit_generic(self._freq) + + def get_locator(self, dmin, dmax): + """Pick the best locator based on a distance.""" + delta = relativedelta(dmax, dmin) + tdelta = dmax - dmin + + # take absolute difference + if dmin > dmax: + delta = -delta + tdelta = -tdelta + # The following uses a mix of calls to relativedelta and timedelta + # methods because there is incomplete overlap in the functionality of + # these similar functions, and it's best to avoid doing our own math + # whenever possible. + numYears = float(delta.years) + numMonths = numYears * MONTHS_PER_YEAR + delta.months + numDays = tdelta.days # Avoids estimates of days/month, days/year. + numHours = numDays * HOURS_PER_DAY + delta.hours + numMinutes = numHours * MIN_PER_HOUR + delta.minutes + numSeconds = np.floor(tdelta.total_seconds()) + numMicroseconds = np.floor(tdelta.total_seconds() * 1e6) + + nums = [numYears, numMonths, numDays, numHours, numMinutes, + numSeconds, numMicroseconds] + + use_rrule_locator = [True] * 6 + [False] + + # Default setting of bymonth, etc. to pass to rrule + # [unused (for year), bymonth, bymonthday, byhour, byminute, + # bysecond, unused (for microseconds)] + byranges = [None, 1, 1, 0, 0, 0, None] + + # Loop over all the frequencies and try to find one that gives at + # least a minticks tick positions. Once this is found, look for + # an interval from a list specific to that frequency that gives no + # more than maxticks tick positions. Also, set up some ranges + # (bymonth, etc.) as appropriate to be passed to rrulewrapper. + for i, (freq, num) in enumerate(zip(self._freqs, nums)): + # If this particular frequency doesn't give enough ticks, continue + if num < self.minticks: + # Since we're not using this particular frequency, set + # the corresponding by_ to None so the rrule can act as + # appropriate + byranges[i] = None + continue + + # Find the first available interval that doesn't give too many + # ticks + for interval in self.intervald[freq]: + if num <= interval * (self.maxticks[freq] - 1): + break + else: + if not (self.interval_multiples and freq == DAILY): + _api.warn_external( + f"AutoDateLocator was unable to pick an appropriate " + f"interval for this date range. It may be necessary " + f"to add an interval value to the AutoDateLocator's " + f"intervald dictionary. Defaulting to {interval}.") + + # Set some parameters as appropriate + self._freq = freq + + if self._byranges[i] and self.interval_multiples: + byranges[i] = self._byranges[i][::interval] + if i in (DAILY, WEEKLY): + if interval == 14: + # just make first and 15th. Avoids 30th. + byranges[i] = [1, 15] + elif interval == 7: + byranges[i] = [1, 8, 15, 22] + + interval = 1 + else: + byranges[i] = self._byranges[i] + break + else: + interval = 1 + + if (freq == YEARLY) and self.interval_multiples: + locator = YearLocator(interval, tz=self.tz) + elif use_rrule_locator[i]: + _, bymonth, bymonthday, byhour, byminute, bysecond, _ = byranges + rrule = rrulewrapper(self._freq, interval=interval, + dtstart=dmin, until=dmax, + bymonth=bymonth, bymonthday=bymonthday, + byhour=byhour, byminute=byminute, + bysecond=bysecond) + + locator = RRuleLocator(rrule, tz=self.tz) + else: + locator = MicrosecondLocator(interval, tz=self.tz) + if date2num(dmin) > 70 * 365 and interval < 1000: + _api.warn_external( + 'Plotting microsecond time intervals for dates far from ' + f'the epoch (time origin: {get_epoch()}) is not well-' + 'supported. See matplotlib.dates.set_epoch to change the ' + 'epoch.') + + locator.set_axis(self.axis) + return locator + + +class YearLocator(RRuleLocator): + """ + Make ticks on a given day of each year that is a multiple of base. + + Examples:: + + # Tick every year on Jan 1st + locator = YearLocator() + + # Tick every 5 years on July 4th + locator = YearLocator(5, month=7, day=4) + """ + def __init__(self, base=1, month=1, day=1, tz=None): + """ + Parameters + ---------- + base : int, default: 1 + Mark ticks every *base* years. + month : int, default: 1 + The month on which to place the ticks, starting from 1. Default is + January. + day : int, default: 1 + The day on which to place the ticks. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + rule = rrulewrapper(YEARLY, interval=base, bymonth=month, + bymonthday=day, **self.hms0d) + super().__init__(rule, tz=tz) + self.base = ticker._Edge_integer(base, 0) + + def _create_rrule(self, vmin, vmax): + # 'start' needs to be a multiple of the interval to create ticks on + # interval multiples when the tick frequency is YEARLY + ymin = max(self.base.le(vmin.year) * self.base.step, 1) + ymax = min(self.base.ge(vmax.year) * self.base.step, 9999) + + c = self.rule._construct + replace = {'year': ymin, + 'month': c.get('bymonth', 1), + 'day': c.get('bymonthday', 1), + 'hour': 0, 'minute': 0, 'second': 0} + + start = vmin.replace(**replace) + stop = start.replace(year=ymax) + self.rule.set(dtstart=start, until=stop) + + return start, stop + + +class MonthLocator(RRuleLocator): + """ + Make ticks on occurrences of each month, e.g., 1, 3, 12. + """ + def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None): + """ + Parameters + ---------- + bymonth : int or list of int, default: all months + Ticks will be placed on every month in *bymonth*. Default is + ``range(1, 13)``, i.e. every month. + bymonthday : int, default: 1 + The day on which to place the ticks. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + if bymonth is None: + bymonth = range(1, 13) + + rule = rrulewrapper(MONTHLY, bymonth=bymonth, bymonthday=bymonthday, + interval=interval, **self.hms0d) + super().__init__(rule, tz=tz) + + +class WeekdayLocator(RRuleLocator): + """ + Make ticks on occurrences of each weekday. + """ + + def __init__(self, byweekday=1, interval=1, tz=None): + """ + Parameters + ---------- + byweekday : int or list of int, default: all days + Ticks will be placed on every weekday in *byweekday*. Default is + every day. + + Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA, + SU, the constants from :mod:`dateutil.rrule`, which have been + imported into the :mod:`matplotlib.dates` namespace. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + rule = rrulewrapper(DAILY, byweekday=byweekday, + interval=interval, **self.hms0d) + super().__init__(rule, tz=tz) + + +class DayLocator(RRuleLocator): + """ + Make ticks on occurrences of each day of the month. For example, + 1, 15, 30. + """ + def __init__(self, bymonthday=None, interval=1, tz=None): + """ + Parameters + ---------- + bymonthday : int or list of int, default: all days + Ticks will be placed on every day in *bymonthday*. Default is + ``bymonthday=range(1, 32)``, i.e., every day of the month. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + if interval != int(interval) or interval < 1: + raise ValueError("interval must be an integer greater than 0") + if bymonthday is None: + bymonthday = range(1, 32) + + rule = rrulewrapper(DAILY, bymonthday=bymonthday, + interval=interval, **self.hms0d) + super().__init__(rule, tz=tz) + + +class HourLocator(RRuleLocator): + """ + Make ticks on occurrences of each hour. + """ + def __init__(self, byhour=None, interval=1, tz=None): + """ + Parameters + ---------- + byhour : int or list of int, default: all hours + Ticks will be placed on every hour in *byhour*. Default is + ``byhour=range(24)``, i.e., every hour. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + if byhour is None: + byhour = range(24) + + rule = rrulewrapper(HOURLY, byhour=byhour, interval=interval, + byminute=0, bysecond=0) + super().__init__(rule, tz=tz) + + +class MinuteLocator(RRuleLocator): + """ + Make ticks on occurrences of each minute. + """ + def __init__(self, byminute=None, interval=1, tz=None): + """ + Parameters + ---------- + byminute : int or list of int, default: all minutes + Ticks will be placed on every minute in *byminute*. Default is + ``byminute=range(60)``, i.e., every minute. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + if byminute is None: + byminute = range(60) + + rule = rrulewrapper(MINUTELY, byminute=byminute, interval=interval, + bysecond=0) + super().__init__(rule, tz=tz) + + +class SecondLocator(RRuleLocator): + """ + Make ticks on occurrences of each second. + """ + def __init__(self, bysecond=None, interval=1, tz=None): + """ + Parameters + ---------- + bysecond : int or list of int, default: all seconds + Ticks will be placed on every second in *bysecond*. Default is + ``bysecond = range(60)``, i.e., every second. + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + if bysecond is None: + bysecond = range(60) + + rule = rrulewrapper(SECONDLY, bysecond=bysecond, interval=interval) + super().__init__(rule, tz=tz) + + +class MicrosecondLocator(DateLocator): + """ + Make ticks on regular intervals of one or more microsecond(s). + + .. note:: + + By default, Matplotlib uses a floating point representation of time in + days since the epoch, so plotting data with + microsecond time resolution does not work well for + dates that are far (about 70 years) from the epoch (check with + `~.dates.get_epoch`). + + If you want sub-microsecond resolution time plots, it is strongly + recommended to use floating point seconds, not datetime-like + time representation. + + If you really must use datetime.datetime() or similar and still + need microsecond precision, change the time origin via + `.dates.set_epoch` to something closer to the dates being plotted. + See :doc:`/gallery/ticks/date_precision_and_epochs`. + + """ + def __init__(self, interval=1, tz=None): + """ + Parameters + ---------- + interval : int, default: 1 + The interval between each iteration. For example, if + ``interval=2``, mark every second occurrence. + tz : str or `~datetime.tzinfo`, default: :rc:`timezone` + Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. + """ + super().__init__(tz=tz) + self._interval = interval + self._wrapped_locator = ticker.MultipleLocator(interval) + + def set_axis(self, axis): + self._wrapped_locator.set_axis(axis) + return super().set_axis(axis) + + def __call__(self): + # if no data have been set, this will tank with a ValueError + try: + dmin, dmax = self.viewlim_to_dt() + except ValueError: + return [] + + return self.tick_values(dmin, dmax) + + def tick_values(self, vmin, vmax): + nmin, nmax = date2num((vmin, vmax)) + t0 = np.floor(nmin) + nmax = nmax - t0 + nmin = nmin - t0 + nmin *= MUSECONDS_PER_DAY + nmax *= MUSECONDS_PER_DAY + + ticks = self._wrapped_locator.tick_values(nmin, nmax) + + ticks = ticks / MUSECONDS_PER_DAY + t0 + return ticks + + def _get_unit(self): + # docstring inherited + return 1. / MUSECONDS_PER_DAY + + def _get_interval(self): + # docstring inherited + return self._interval + + +class DateConverter(units.ConversionInterface): + """ + Converter for `datetime.date` and `datetime.datetime` data, or for + date/time data represented as it would be converted by `date2num`. + + The 'unit' tag for such data is None or a `~datetime.tzinfo` instance. + """ + + def __init__(self, *, interval_multiples=True): + self._interval_multiples = interval_multiples + super().__init__() + + def axisinfo(self, unit, axis): + """ + Return the `~matplotlib.units.AxisInfo` for *unit*. + + *unit* is a `~datetime.tzinfo` instance or None. + The *axis* argument is required but not used. + """ + tz = unit + + majloc = AutoDateLocator(tz=tz, + interval_multiples=self._interval_multiples) + majfmt = AutoDateFormatter(majloc, tz=tz) + datemin = datetime.date(1970, 1, 1) + datemax = datetime.date(1970, 1, 2) + + return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='', + default_limits=(datemin, datemax)) + + @staticmethod + def convert(value, unit, axis): + """ + If *value* is not already a number or sequence of numbers, convert it + with `date2num`. + + The *unit* and *axis* arguments are not used. + """ + return date2num(value) + + @staticmethod + def default_units(x, axis): + """ + Return the `~datetime.tzinfo` instance of *x* or of its first element, + or None + """ + if isinstance(x, np.ndarray): + x = x.ravel() + + try: + x = cbook._safe_first_finite(x) + except (TypeError, StopIteration): + pass + + try: + return x.tzinfo + except AttributeError: + pass + return None + + +class ConciseDateConverter(DateConverter): + # docstring inherited + + def __init__(self, formats=None, zero_formats=None, offset_formats=None, + show_offset=True, *, interval_multiples=True): + self._formats = formats + self._zero_formats = zero_formats + self._offset_formats = offset_formats + self._show_offset = show_offset + self._interval_multiples = interval_multiples + super().__init__() + + def axisinfo(self, unit, axis): + # docstring inherited + tz = unit + majloc = AutoDateLocator(tz=tz, + interval_multiples=self._interval_multiples) + majfmt = ConciseDateFormatter(majloc, tz=tz, formats=self._formats, + zero_formats=self._zero_formats, + offset_formats=self._offset_formats, + show_offset=self._show_offset) + datemin = datetime.date(1970, 1, 1) + datemax = datetime.date(1970, 1, 2) + return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='', + default_limits=(datemin, datemax)) + + +class _SwitchableDateConverter: + """ + Helper converter-like object that generates and dispatches to + temporary ConciseDateConverter or DateConverter instances based on + :rc:`date.converter` and :rc:`date.interval_multiples`. + """ + + @staticmethod + def _get_converter(): + converter_cls = { + "concise": ConciseDateConverter, "auto": DateConverter}[ + mpl.rcParams["date.converter"]] + interval_multiples = mpl.rcParams["date.interval_multiples"] + return converter_cls(interval_multiples=interval_multiples) + + def axisinfo(self, *args, **kwargs): + return self._get_converter().axisinfo(*args, **kwargs) + + def default_units(self, *args, **kwargs): + return self._get_converter().default_units(*args, **kwargs) + + def convert(self, *args, **kwargs): + return self._get_converter().convert(*args, **kwargs) + + +units.registry[np.datetime64] = \ + units.registry[datetime.date] = \ + units.registry[datetime.datetime] = \ + _SwitchableDateConverter() diff --git a/venv/lib/python3.10/site-packages/matplotlib/dviread.py b/venv/lib/python3.10/site-packages/matplotlib/dviread.py new file mode 100644 index 00000000..82f43b56 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/dviread.py @@ -0,0 +1,1107 @@ +""" +A module for reading dvi files output by TeX. Several limitations make +this not (currently) useful as a general-purpose dvi preprocessor, but +it is currently used by the pdf backend for processing usetex text. + +Interface:: + + with Dvi(filename, 72) as dvi: + # iterate over pages: + for page in dvi: + w, h, d = page.width, page.height, page.descent + for x, y, font, glyph, width in page.text: + fontname = font.texname + pointsize = font.size + ... + for x, y, height, width in page.boxes: + ... +""" + +from collections import namedtuple +import enum +from functools import lru_cache, partial, wraps +import logging +import os +from pathlib import Path +import re +import struct +import subprocess +import sys + +import numpy as np + +from matplotlib import _api, cbook + +_log = logging.getLogger(__name__) + +# Many dvi related files are looked for by external processes, require +# additional parsing, and are used many times per rendering, which is why they +# are cached using lru_cache(). + +# Dvi is a bytecode format documented in +# https://ctan.org/pkg/dvitype +# https://texdoc.org/serve/dvitype.pdf/0 +# +# The file consists of a preamble, some number of pages, a postamble, +# and a finale. Different opcodes are allowed in different contexts, +# so the Dvi object has a parser state: +# +# pre: expecting the preamble +# outer: between pages (followed by a page or the postamble, +# also e.g. font definitions are allowed) +# page: processing a page +# post_post: state after the postamble (our current implementation +# just stops reading) +# finale: the finale (unimplemented in our current implementation) + +_dvistate = enum.Enum('DviState', 'pre outer inpage post_post finale') + +# The marks on a page consist of text and boxes. A page also has dimensions. +Page = namedtuple('Page', 'text boxes height width descent') +Box = namedtuple('Box', 'x y height width') + + +# Also a namedtuple, for backcompat. +class Text(namedtuple('Text', 'x y font glyph width')): + """ + A glyph in the dvi file. + + The *x* and *y* attributes directly position the glyph. The *font*, + *glyph*, and *width* attributes are kept public for back-compatibility, + but users wanting to draw the glyph themselves are encouraged to instead + load the font specified by `font_path` at `font_size`, warp it with the + effects specified by `font_effects`, and load the glyph specified by + `glyph_name_or_index`. + """ + + def _get_pdftexmap_entry(self): + return PsfontsMap(find_tex_file("pdftex.map"))[self.font.texname] + + @property + def font_path(self): + """The `~pathlib.Path` to the font for this glyph.""" + psfont = self._get_pdftexmap_entry() + if psfont.filename is None: + raise ValueError("No usable font file found for {} ({}); " + "the font may lack a Type-1 version" + .format(psfont.psname.decode("ascii"), + psfont.texname.decode("ascii"))) + return Path(psfont.filename) + + @property + def font_size(self): + """The font size.""" + return self.font.size + + @property + def font_effects(self): + """ + The "font effects" dict for this glyph. + + This dict contains the values for this glyph of SlantFont and + ExtendFont (if any), read off :file:`pdftex.map`. + """ + return self._get_pdftexmap_entry().effects + + @property + def glyph_name_or_index(self): + """ + Either the glyph name or the native charmap glyph index. + + If :file:`pdftex.map` specifies an encoding for this glyph's font, that + is a mapping of glyph indices to Adobe glyph names; use it to convert + dvi indices to glyph names. Callers can then convert glyph names to + glyph indices (with FT_Get_Name_Index/get_name_index), and load the + glyph using FT_Load_Glyph/load_glyph. + + If :file:`pdftex.map` specifies no encoding, the indices directly map + to the font's "native" charmap; glyphs should directly load using + FT_Load_Char/load_char after selecting the native charmap. + """ + entry = self._get_pdftexmap_entry() + return (_parse_enc(entry.encoding)[self.glyph] + if entry.encoding is not None else self.glyph) + + +# Opcode argument parsing +# +# Each of the following functions takes a Dvi object and delta, which is the +# difference between the opcode and the minimum opcode with the same meaning. +# Dvi opcodes often encode the number of argument bytes in this delta. +_arg_mapping = dict( + # raw: Return delta as is. + raw=lambda dvi, delta: delta, + # u1: Read 1 byte as an unsigned number. + u1=lambda dvi, delta: dvi._arg(1, signed=False), + # u4: Read 4 bytes as an unsigned number. + u4=lambda dvi, delta: dvi._arg(4, signed=False), + # s4: Read 4 bytes as a signed number. + s4=lambda dvi, delta: dvi._arg(4, signed=True), + # slen: Read delta bytes as a signed number, or None if delta is None. + slen=lambda dvi, delta: dvi._arg(delta, signed=True) if delta else None, + # slen1: Read (delta + 1) bytes as a signed number. + slen1=lambda dvi, delta: dvi._arg(delta + 1, signed=True), + # ulen1: Read (delta + 1) bytes as an unsigned number. + ulen1=lambda dvi, delta: dvi._arg(delta + 1, signed=False), + # olen1: Read (delta + 1) bytes as an unsigned number if less than 4 bytes, + # as a signed number if 4 bytes. + olen1=lambda dvi, delta: dvi._arg(delta + 1, signed=(delta == 3)), +) + + +def _dispatch(table, min, max=None, state=None, args=('raw',)): + """ + Decorator for dispatch by opcode. Sets the values in *table* + from *min* to *max* to this method, adds a check that the Dvi state + matches *state* if not None, reads arguments from the file according + to *args*. + + Parameters + ---------- + table : dict[int, callable] + The dispatch table to be filled in. + + min, max : int + Range of opcodes that calls the registered function; *max* defaults to + *min*. + + state : _dvistate, optional + State of the Dvi object in which these opcodes are allowed. + + args : list[str], default: ['raw'] + Sequence of argument specifications: + + - 'raw': opcode minus minimum + - 'u1': read one unsigned byte + - 'u4': read four bytes, treat as an unsigned number + - 's4': read four bytes, treat as a signed number + - 'slen': read (opcode - minimum) bytes, treat as signed + - 'slen1': read (opcode - minimum + 1) bytes, treat as signed + - 'ulen1': read (opcode - minimum + 1) bytes, treat as unsigned + - 'olen1': read (opcode - minimum + 1) bytes, treat as unsigned + if under four bytes, signed if four bytes + """ + def decorate(method): + get_args = [_arg_mapping[x] for x in args] + + @wraps(method) + def wrapper(self, byte): + if state is not None and self.state != state: + raise ValueError("state precondition failed") + return method(self, *[f(self, byte-min) for f in get_args]) + if max is None: + table[min] = wrapper + else: + for i in range(min, max+1): + assert table[i] is None + table[i] = wrapper + return wrapper + return decorate + + +class Dvi: + """ + A reader for a dvi ("device-independent") file, as produced by TeX. + + The current implementation can only iterate through pages in order, + and does not even attempt to verify the postamble. + + This class can be used as a context manager to close the underlying + file upon exit. Pages can be read via iteration. Here is an overly + simple way to extract text without trying to detect whitespace:: + + >>> with matplotlib.dviread.Dvi('input.dvi', 72) as dvi: + ... for page in dvi: + ... print(''.join(chr(t.glyph) for t in page.text)) + """ + # dispatch table + _dtable = [None] * 256 + _dispatch = partial(_dispatch, _dtable) + + def __init__(self, filename, dpi): + """ + Read the data from the file named *filename* and convert + TeX's internal units to units of *dpi* per inch. + *dpi* only sets the units and does not limit the resolution. + Use None to return TeX's internal units. + """ + _log.debug('Dvi: %s', filename) + self.file = open(filename, 'rb') + self.dpi = dpi + self.fonts = {} + self.state = _dvistate.pre + + def __enter__(self): + """Context manager enter method, does nothing.""" + return self + + def __exit__(self, etype, evalue, etrace): + """ + Context manager exit method, closes the underlying file if it is open. + """ + self.close() + + def __iter__(self): + """ + Iterate through the pages of the file. + + Yields + ------ + Page + Details of all the text and box objects on the page. + The Page tuple contains lists of Text and Box tuples and + the page dimensions, and the Text and Box tuples contain + coordinates transformed into a standard Cartesian + coordinate system at the dpi value given when initializing. + The coordinates are floating point numbers, but otherwise + precision is not lost and coordinate values are not clipped to + integers. + """ + while self._read(): + yield self._output() + + def close(self): + """Close the underlying file if it is open.""" + if not self.file.closed: + self.file.close() + + def _output(self): + """ + Output the text and boxes belonging to the most recent page. + page = dvi._output() + """ + minx, miny, maxx, maxy = np.inf, np.inf, -np.inf, -np.inf + maxy_pure = -np.inf + for elt in self.text + self.boxes: + if isinstance(elt, Box): + x, y, h, w = elt + e = 0 # zero depth + else: # glyph + x, y, font, g, w = elt + h, e = font._height_depth_of(g) + minx = min(minx, x) + miny = min(miny, y - h) + maxx = max(maxx, x + w) + maxy = max(maxy, y + e) + maxy_pure = max(maxy_pure, y) + if self._baseline_v is not None: + maxy_pure = self._baseline_v # This should normally be the case. + self._baseline_v = None + + if not self.text and not self.boxes: # Avoid infs/nans from inf+/-inf. + return Page(text=[], boxes=[], width=0, height=0, descent=0) + + if self.dpi is None: + # special case for ease of debugging: output raw dvi coordinates + return Page(text=self.text, boxes=self.boxes, + width=maxx-minx, height=maxy_pure-miny, + descent=maxy-maxy_pure) + + # convert from TeX's "scaled points" to dpi units + d = self.dpi / (72.27 * 2**16) + descent = (maxy - maxy_pure) * d + + text = [Text((x-minx)*d, (maxy-y)*d - descent, f, g, w*d) + for (x, y, f, g, w) in self.text] + boxes = [Box((x-minx)*d, (maxy-y)*d - descent, h*d, w*d) + for (x, y, h, w) in self.boxes] + + return Page(text=text, boxes=boxes, width=(maxx-minx)*d, + height=(maxy_pure-miny)*d, descent=descent) + + def _read(self): + """ + Read one page from the file. Return True if successful, + False if there were no more pages. + """ + # Pages appear to start with the sequence + # bop (begin of page) + # xxx comment + # # if using chemformula + # down + # push + # down + # # if using xcolor + # down + # push + # down (possibly multiple) + # push <= here, v is the baseline position. + # etc. + # (dviasm is useful to explore this structure.) + # Thus, we use the vertical position at the first time the stack depth + # reaches 3, while at least three "downs" have been executed (excluding + # those popped out (corresponding to the chemformula preamble)), as the + # baseline (the "down" count is necessary to handle xcolor). + down_stack = [0] + self._baseline_v = None + while True: + byte = self.file.read(1)[0] + self._dtable[byte](self, byte) + name = self._dtable[byte].__name__ + if name == "_push": + down_stack.append(down_stack[-1]) + elif name == "_pop": + down_stack.pop() + elif name == "_down": + down_stack[-1] += 1 + if (self._baseline_v is None + and len(getattr(self, "stack", [])) == 3 + and down_stack[-1] >= 4): + self._baseline_v = self.v + if byte == 140: # end of page + return True + if self.state is _dvistate.post_post: # end of file + self.close() + return False + + def _arg(self, nbytes, signed=False): + """ + Read and return a big-endian integer *nbytes* long. + Signedness is determined by the *signed* keyword. + """ + return int.from_bytes(self.file.read(nbytes), "big", signed=signed) + + @_dispatch(min=0, max=127, state=_dvistate.inpage) + def _set_char_immediate(self, char): + self._put_char_real(char) + self.h += self.fonts[self.f]._width_of(char) + + @_dispatch(min=128, max=131, state=_dvistate.inpage, args=('olen1',)) + def _set_char(self, char): + self._put_char_real(char) + self.h += self.fonts[self.f]._width_of(char) + + @_dispatch(132, state=_dvistate.inpage, args=('s4', 's4')) + def _set_rule(self, a, b): + self._put_rule_real(a, b) + self.h += b + + @_dispatch(min=133, max=136, state=_dvistate.inpage, args=('olen1',)) + def _put_char(self, char): + self._put_char_real(char) + + def _put_char_real(self, char): + font = self.fonts[self.f] + if font._vf is None: + self.text.append(Text(self.h, self.v, font, char, + font._width_of(char))) + else: + scale = font._scale + for x, y, f, g, w in font._vf[char].text: + newf = DviFont(scale=_mul2012(scale, f._scale), + tfm=f._tfm, texname=f.texname, vf=f._vf) + self.text.append(Text(self.h + _mul2012(x, scale), + self.v + _mul2012(y, scale), + newf, g, newf._width_of(g))) + self.boxes.extend([Box(self.h + _mul2012(x, scale), + self.v + _mul2012(y, scale), + _mul2012(a, scale), _mul2012(b, scale)) + for x, y, a, b in font._vf[char].boxes]) + + @_dispatch(137, state=_dvistate.inpage, args=('s4', 's4')) + def _put_rule(self, a, b): + self._put_rule_real(a, b) + + def _put_rule_real(self, a, b): + if a > 0 and b > 0: + self.boxes.append(Box(self.h, self.v, a, b)) + + @_dispatch(138) + def _nop(self, _): + pass + + @_dispatch(139, state=_dvistate.outer, args=('s4',)*11) + def _bop(self, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, p): + self.state = _dvistate.inpage + self.h, self.v, self.w, self.x, self.y, self.z = 0, 0, 0, 0, 0, 0 + self.stack = [] + self.text = [] # list of Text objects + self.boxes = [] # list of Box objects + + @_dispatch(140, state=_dvistate.inpage) + def _eop(self, _): + self.state = _dvistate.outer + del self.h, self.v, self.w, self.x, self.y, self.z, self.stack + + @_dispatch(141, state=_dvistate.inpage) + def _push(self, _): + self.stack.append((self.h, self.v, self.w, self.x, self.y, self.z)) + + @_dispatch(142, state=_dvistate.inpage) + def _pop(self, _): + self.h, self.v, self.w, self.x, self.y, self.z = self.stack.pop() + + @_dispatch(min=143, max=146, state=_dvistate.inpage, args=('slen1',)) + def _right(self, b): + self.h += b + + @_dispatch(min=147, max=151, state=_dvistate.inpage, args=('slen',)) + def _right_w(self, new_w): + if new_w is not None: + self.w = new_w + self.h += self.w + + @_dispatch(min=152, max=156, state=_dvistate.inpage, args=('slen',)) + def _right_x(self, new_x): + if new_x is not None: + self.x = new_x + self.h += self.x + + @_dispatch(min=157, max=160, state=_dvistate.inpage, args=('slen1',)) + def _down(self, a): + self.v += a + + @_dispatch(min=161, max=165, state=_dvistate.inpage, args=('slen',)) + def _down_y(self, new_y): + if new_y is not None: + self.y = new_y + self.v += self.y + + @_dispatch(min=166, max=170, state=_dvistate.inpage, args=('slen',)) + def _down_z(self, new_z): + if new_z is not None: + self.z = new_z + self.v += self.z + + @_dispatch(min=171, max=234, state=_dvistate.inpage) + def _fnt_num_immediate(self, k): + self.f = k + + @_dispatch(min=235, max=238, state=_dvistate.inpage, args=('olen1',)) + def _fnt_num(self, new_f): + self.f = new_f + + @_dispatch(min=239, max=242, args=('ulen1',)) + def _xxx(self, datalen): + special = self.file.read(datalen) + _log.debug( + 'Dvi._xxx: encountered special: %s', + ''.join([chr(ch) if 32 <= ch < 127 else '<%02x>' % ch + for ch in special])) + + @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1')) + def _fnt_def(self, k, c, s, d, a, l): + self._fnt_def_real(k, c, s, d, a, l) + + def _fnt_def_real(self, k, c, s, d, a, l): + n = self.file.read(a + l) + fontname = n[-l:].decode('ascii') + tfm = _tfmfile(fontname) + if c != 0 and tfm.checksum != 0 and c != tfm.checksum: + raise ValueError('tfm checksum mismatch: %s' % n) + try: + vf = _vffile(fontname) + except FileNotFoundError: + vf = None + self.fonts[k] = DviFont(scale=s, tfm=tfm, texname=n, vf=vf) + + @_dispatch(247, state=_dvistate.pre, args=('u1', 'u4', 'u4', 'u4', 'u1')) + def _pre(self, i, num, den, mag, k): + self.file.read(k) # comment in the dvi file + if i != 2: + raise ValueError("Unknown dvi format %d" % i) + if num != 25400000 or den != 7227 * 2**16: + raise ValueError("Nonstandard units in dvi file") + # meaning: TeX always uses those exact values, so it + # should be enough for us to support those + # (There are 72.27 pt to an inch so 7227 pt = + # 7227 * 2**16 sp to 100 in. The numerator is multiplied + # by 10^5 to get units of 10**-7 meters.) + if mag != 1000: + raise ValueError("Nonstandard magnification in dvi file") + # meaning: LaTeX seems to frown on setting \mag, so + # I think we can assume this is constant + self.state = _dvistate.outer + + @_dispatch(248, state=_dvistate.outer) + def _post(self, _): + self.state = _dvistate.post_post + # TODO: actually read the postamble and finale? + # currently post_post just triggers closing the file + + @_dispatch(249) + def _post_post(self, _): + raise NotImplementedError + + @_dispatch(min=250, max=255) + def _malformed(self, offset): + raise ValueError(f"unknown command: byte {250 + offset}") + + +class DviFont: + """ + Encapsulation of a font that a DVI file can refer to. + + This class holds a font's texname and size, supports comparison, + and knows the widths of glyphs in the same units as the AFM file. + There are also internal attributes (for use by dviread.py) that + are *not* used for comparison. + + The size is in Adobe points (converted from TeX points). + + Parameters + ---------- + scale : float + Factor by which the font is scaled from its natural size. + tfm : Tfm + TeX font metrics for this font + texname : bytes + Name of the font as used internally by TeX and friends, as an ASCII + bytestring. This is usually very different from any external font + names; `PsfontsMap` can be used to find the external name of the font. + vf : Vf + A TeX "virtual font" file, or None if this font is not virtual. + + Attributes + ---------- + texname : bytes + size : float + Size of the font in Adobe points, converted from the slightly + smaller TeX points. + widths : list + Widths of glyphs in glyph-space units, typically 1/1000ths of + the point size. + + """ + __slots__ = ('texname', 'size', 'widths', '_scale', '_vf', '_tfm') + + def __init__(self, scale, tfm, texname, vf): + _api.check_isinstance(bytes, texname=texname) + self._scale = scale + self._tfm = tfm + self.texname = texname + self._vf = vf + self.size = scale * (72.0 / (72.27 * 2**16)) + try: + nchars = max(tfm.width) + 1 + except ValueError: + nchars = 0 + self.widths = [(1000*tfm.width.get(char, 0)) >> 20 + for char in range(nchars)] + + def __eq__(self, other): + return (type(self) is type(other) + and self.texname == other.texname and self.size == other.size) + + def __ne__(self, other): + return not self.__eq__(other) + + def __repr__(self): + return f"<{type(self).__name__}: {self.texname}>" + + def _width_of(self, char): + """Width of char in dvi units.""" + width = self._tfm.width.get(char, None) + if width is not None: + return _mul2012(width, self._scale) + _log.debug('No width for char %d in font %s.', char, self.texname) + return 0 + + def _height_depth_of(self, char): + """Height and depth of char in dvi units.""" + result = [] + for metric, name in ((self._tfm.height, "height"), + (self._tfm.depth, "depth")): + value = metric.get(char, None) + if value is None: + _log.debug('No %s for char %d in font %s', + name, char, self.texname) + result.append(0) + else: + result.append(_mul2012(value, self._scale)) + # cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent + # so that TeX aligns equations properly + # (https://tex.stackexchange.com/q/526103/) + # but we actually care about the rasterization depth to align + # the dvipng-generated images. + if re.match(br'^cmsy\d+$', self.texname) and char == 0: + result[-1] = 0 + return result + + +class Vf(Dvi): + r""" + A virtual font (\*.vf file) containing subroutines for dvi files. + + Parameters + ---------- + filename : str or path-like + + Notes + ----- + The virtual font format is a derivative of dvi: + http://mirrors.ctan.org/info/knuth/virtual-fonts + This class reuses some of the machinery of `Dvi` + but replaces the `_read` loop and dispatch mechanism. + + Examples + -------- + :: + + vf = Vf(filename) + glyph = vf[code] + glyph.text, glyph.boxes, glyph.width + """ + + def __init__(self, filename): + super().__init__(filename, 0) + try: + self._first_font = None + self._chars = {} + self._read() + finally: + self.close() + + def __getitem__(self, code): + return self._chars[code] + + def _read(self): + """ + Read one page from the file. Return True if successful, + False if there were no more pages. + """ + packet_char, packet_ends = None, None + packet_len, packet_width = None, None + while True: + byte = self.file.read(1)[0] + # If we are in a packet, execute the dvi instructions + if self.state is _dvistate.inpage: + byte_at = self.file.tell()-1 + if byte_at == packet_ends: + self._finalize_packet(packet_char, packet_width) + packet_len, packet_char, packet_width = None, None, None + # fall through to out-of-packet code + elif byte_at > packet_ends: + raise ValueError("Packet length mismatch in vf file") + else: + if byte in (139, 140) or byte >= 243: + raise ValueError( + "Inappropriate opcode %d in vf file" % byte) + Dvi._dtable[byte](self, byte) + continue + + # We are outside a packet + if byte < 242: # a short packet (length given by byte) + packet_len = byte + packet_char, packet_width = self._arg(1), self._arg(3) + packet_ends = self._init_packet(byte) + self.state = _dvistate.inpage + elif byte == 242: # a long packet + packet_len, packet_char, packet_width = \ + [self._arg(x) for x in (4, 4, 4)] + self._init_packet(packet_len) + elif 243 <= byte <= 246: + k = self._arg(byte - 242, byte == 246) + c, s, d, a, l = [self._arg(x) for x in (4, 4, 4, 1, 1)] + self._fnt_def_real(k, c, s, d, a, l) + if self._first_font is None: + self._first_font = k + elif byte == 247: # preamble + i, k = self._arg(1), self._arg(1) + x = self.file.read(k) + cs, ds = self._arg(4), self._arg(4) + self._pre(i, x, cs, ds) + elif byte == 248: # postamble (just some number of 248s) + break + else: + raise ValueError("Unknown vf opcode %d" % byte) + + def _init_packet(self, pl): + if self.state != _dvistate.outer: + raise ValueError("Misplaced packet in vf file") + self.h, self.v, self.w, self.x, self.y, self.z = 0, 0, 0, 0, 0, 0 + self.stack, self.text, self.boxes = [], [], [] + self.f = self._first_font + return self.file.tell() + pl + + def _finalize_packet(self, packet_char, packet_width): + self._chars[packet_char] = Page( + text=self.text, boxes=self.boxes, width=packet_width, + height=None, descent=None) + self.state = _dvistate.outer + + def _pre(self, i, x, cs, ds): + if self.state is not _dvistate.pre: + raise ValueError("pre command in middle of vf file") + if i != 202: + raise ValueError("Unknown vf format %d" % i) + if len(x): + _log.debug('vf file comment: %s', x) + self.state = _dvistate.outer + # cs = checksum, ds = design size + + +def _mul2012(num1, num2): + """Multiply two numbers in 20.12 fixed point format.""" + # Separated into a function because >> has surprising precedence + return (num1*num2) >> 20 + + +class Tfm: + """ + A TeX Font Metric file. + + This implementation covers only the bare minimum needed by the Dvi class. + + Parameters + ---------- + filename : str or path-like + + Attributes + ---------- + checksum : int + Used for verifying against the dvi file. + design_size : int + Design size of the font (unknown units) + width, height, depth : dict + Dimensions of each character, need to be scaled by the factor + specified in the dvi file. These are dicts because indexing may + not start from 0. + """ + __slots__ = ('checksum', 'design_size', 'width', 'height', 'depth') + + def __init__(self, filename): + _log.debug('opening tfm file %s', filename) + with open(filename, 'rb') as file: + header1 = file.read(24) + lh, bc, ec, nw, nh, nd = struct.unpack('!6H', header1[2:14]) + _log.debug('lh=%d, bc=%d, ec=%d, nw=%d, nh=%d, nd=%d', + lh, bc, ec, nw, nh, nd) + header2 = file.read(4*lh) + self.checksum, self.design_size = struct.unpack('!2I', header2[:8]) + # there is also encoding information etc. + char_info = file.read(4*(ec-bc+1)) + widths = struct.unpack(f'!{nw}i', file.read(4*nw)) + heights = struct.unpack(f'!{nh}i', file.read(4*nh)) + depths = struct.unpack(f'!{nd}i', file.read(4*nd)) + self.width, self.height, self.depth = {}, {}, {} + for idx, char in enumerate(range(bc, ec+1)): + byte0 = char_info[4*idx] + byte1 = char_info[4*idx+1] + self.width[char] = widths[byte0] + self.height[char] = heights[byte1 >> 4] + self.depth[char] = depths[byte1 & 0xf] + + +PsFont = namedtuple('PsFont', 'texname psname effects encoding filename') + + +class PsfontsMap: + """ + A psfonts.map formatted file, mapping TeX fonts to PS fonts. + + Parameters + ---------- + filename : str or path-like + + Notes + ----- + For historical reasons, TeX knows many Type-1 fonts by different + names than the outside world. (For one thing, the names have to + fit in eight characters.) Also, TeX's native fonts are not Type-1 + but Metafont, which is nontrivial to convert to PostScript except + as a bitmap. While high-quality conversions to Type-1 format exist + and are shipped with modern TeX distributions, we need to know + which Type-1 fonts are the counterparts of which native fonts. For + these reasons a mapping is needed from internal font names to font + file names. + + A texmf tree typically includes mapping files called e.g. + :file:`psfonts.map`, :file:`pdftex.map`, or :file:`dvipdfm.map`. + The file :file:`psfonts.map` is used by :program:`dvips`, + :file:`pdftex.map` by :program:`pdfTeX`, and :file:`dvipdfm.map` + by :program:`dvipdfm`. :file:`psfonts.map` might avoid embedding + the 35 PostScript fonts (i.e., have no filename for them, as in + the Times-Bold example above), while the pdf-related files perhaps + only avoid the "Base 14" pdf fonts. But the user may have + configured these files differently. + + Examples + -------- + >>> map = PsfontsMap(find_tex_file('pdftex.map')) + >>> entry = map[b'ptmbo8r'] + >>> entry.texname + b'ptmbo8r' + >>> entry.psname + b'Times-Bold' + >>> entry.encoding + '/usr/local/texlive/2008/texmf-dist/fonts/enc/dvips/base/8r.enc' + >>> entry.effects + {'slant': 0.16700000000000001} + >>> entry.filename + """ + __slots__ = ('_filename', '_unparsed', '_parsed') + + # Create a filename -> PsfontsMap cache, so that calling + # `PsfontsMap(filename)` with the same filename a second time immediately + # returns the same object. + @lru_cache + def __new__(cls, filename): + self = object.__new__(cls) + self._filename = os.fsdecode(filename) + # Some TeX distributions have enormous pdftex.map files which would + # take hundreds of milliseconds to parse, but it is easy enough to just + # store the unparsed lines (keyed by the first word, which is the + # texname) and parse them on-demand. + with open(filename, 'rb') as file: + self._unparsed = {} + for line in file: + tfmname = line.split(b' ', 1)[0] + self._unparsed.setdefault(tfmname, []).append(line) + self._parsed = {} + return self + + def __getitem__(self, texname): + assert isinstance(texname, bytes) + if texname in self._unparsed: + for line in self._unparsed.pop(texname): + if self._parse_and_cache_line(line): + break + try: + return self._parsed[texname] + except KeyError: + raise LookupError( + f"An associated PostScript font (required by Matplotlib) " + f"could not be found for TeX font {texname.decode('ascii')!r} " + f"in {self._filename!r}; this problem can often be solved by " + f"installing a suitable PostScript font package in your TeX " + f"package manager") from None + + def _parse_and_cache_line(self, line): + """ + Parse a line in the font mapping file. + + The format is (partially) documented at + http://mirrors.ctan.org/systems/doc/pdftex/manual/pdftex-a.pdf + https://tug.org/texinfohtml/dvips.html#psfonts_002emap + Each line can have the following fields: + + - tfmname (first, only required field), + - psname (defaults to tfmname, must come immediately after tfmname if + present), + - fontflags (integer, must come immediately after psname if present, + ignored by us), + - special (SlantFont and ExtendFont, only field that is double-quoted), + - fontfile, encodingfile (optional, prefixed by <, <<, or <[; << always + precedes a font, <[ always precedes an encoding, < can precede either + but then an encoding file must have extension .enc; < and << also + request different font subsetting behaviors but we ignore that; < can + be separated from the filename by whitespace). + + special, fontfile, and encodingfile can appear in any order. + """ + # If the map file specifies multiple encodings for a font, we + # follow pdfTeX in choosing the last one specified. Such + # entries are probably mistakes but they have occurred. + # https://tex.stackexchange.com/q/10826/ + + if not line or line.startswith((b" ", b"%", b"*", b";", b"#")): + return + tfmname = basename = special = encodingfile = fontfile = None + is_subsetted = is_t1 = is_truetype = False + matches = re.finditer(br'"([^"]*)(?:"|$)|(\S+)', line) + for match in matches: + quoted, unquoted = match.groups() + if unquoted: + if unquoted.startswith(b"<<"): # font + fontfile = unquoted[2:] + elif unquoted.startswith(b"<["): # encoding + encodingfile = unquoted[2:] + elif unquoted.startswith(b"<"): # font or encoding + word = ( + # foo + unquoted[1:] + # < by itself => read the next word + or next(filter(None, next(matches).groups()))) + if word.endswith(b".enc"): + encodingfile = word + else: + fontfile = word + is_subsetted = True + elif tfmname is None: + tfmname = unquoted + elif basename is None: + basename = unquoted + elif quoted: + special = quoted + effects = {} + if special: + words = reversed(special.split()) + for word in words: + if word == b"SlantFont": + effects["slant"] = float(next(words)) + elif word == b"ExtendFont": + effects["extend"] = float(next(words)) + + # Verify some properties of the line that would cause it to be ignored + # otherwise. + if fontfile is not None: + if fontfile.endswith((b".ttf", b".ttc")): + is_truetype = True + elif not fontfile.endswith(b".otf"): + is_t1 = True + elif basename is not None: + is_t1 = True + if is_truetype and is_subsetted and encodingfile is None: + return + if not is_t1 and ("slant" in effects or "extend" in effects): + return + if abs(effects.get("slant", 0)) > 1: + return + if abs(effects.get("extend", 0)) > 2: + return + + if basename is None: + basename = tfmname + if encodingfile is not None: + encodingfile = find_tex_file(encodingfile) + if fontfile is not None: + fontfile = find_tex_file(fontfile) + self._parsed[tfmname] = PsFont( + texname=tfmname, psname=basename, effects=effects, + encoding=encodingfile, filename=fontfile) + return True + + +def _parse_enc(path): + r""" + Parse a \*.enc file referenced from a psfonts.map style file. + + The format supported by this function is a tiny subset of PostScript. + + Parameters + ---------- + path : `os.PathLike` + + Returns + ------- + list + The nth entry of the list is the PostScript glyph name of the nth + glyph. + """ + no_comments = re.sub("%.*", "", Path(path).read_text(encoding="ascii")) + array = re.search(r"(?s)\[(.*)\]", no_comments).group(1) + lines = [line for line in array.split() if line] + if all(line.startswith("/") for line in lines): + return [line[1:] for line in lines] + else: + raise ValueError(f"Failed to parse {path} as Postscript encoding") + + +class _LuatexKpsewhich: + @lru_cache # A singleton. + def __new__(cls): + self = object.__new__(cls) + self._proc = self._new_proc() + return self + + def _new_proc(self): + return subprocess.Popen( + ["luatex", "--luaonly", + str(cbook._get_data_path("kpsewhich.lua"))], + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + + def search(self, filename): + if self._proc.poll() is not None: # Dead, restart it. + self._proc = self._new_proc() + self._proc.stdin.write(os.fsencode(filename) + b"\n") + self._proc.stdin.flush() + out = self._proc.stdout.readline().rstrip() + return None if out == b"nil" else os.fsdecode(out) + + +@lru_cache +def find_tex_file(filename): + """ + Find a file in the texmf tree using kpathsea_. + + The kpathsea library, provided by most existing TeX distributions, both + on Unix-like systems and on Windows (MikTeX), is invoked via a long-lived + luatex process if luatex is installed, or via kpsewhich otherwise. + + .. _kpathsea: https://www.tug.org/kpathsea/ + + Parameters + ---------- + filename : str or path-like + + Raises + ------ + FileNotFoundError + If the file is not found. + """ + + # we expect these to always be ascii encoded, but use utf-8 + # out of caution + if isinstance(filename, bytes): + filename = filename.decode('utf-8', errors='replace') + + try: + lk = _LuatexKpsewhich() + except FileNotFoundError: + lk = None # Fallback to directly calling kpsewhich, as below. + + if lk: + path = lk.search(filename) + else: + if sys.platform == 'win32': + # On Windows only, kpathsea can use utf-8 for cmd args and output. + # The `command_line_encoding` environment variable is set to force + # it to always use utf-8 encoding. See Matplotlib issue #11848. + kwargs = {'env': {**os.environ, 'command_line_encoding': 'utf-8'}, + 'encoding': 'utf-8'} + else: # On POSIX, run through the equivalent of os.fsdecode(). + kwargs = {'encoding': sys.getfilesystemencoding(), + 'errors': 'surrogateescape'} + + try: + path = (cbook._check_and_log_subprocess(['kpsewhich', filename], + _log, **kwargs) + .rstrip('\n')) + except (FileNotFoundError, RuntimeError): + path = None + + if path: + return path + else: + raise FileNotFoundError( + f"Matplotlib's TeX implementation searched for a file named " + f"{filename!r} in your texmf tree, but could not find it") + + +@lru_cache +def _fontfile(cls, suffix, texname): + return cls(find_tex_file(texname + suffix)) + + +_tfmfile = partial(_fontfile, Tfm, ".tfm") +_vffile = partial(_fontfile, Vf, ".vf") + + +if __name__ == '__main__': + from argparse import ArgumentParser + import itertools + + parser = ArgumentParser() + parser.add_argument("filename") + parser.add_argument("dpi", nargs="?", type=float, default=None) + args = parser.parse_args() + with Dvi(args.filename, args.dpi) as dvi: + fontmap = PsfontsMap(find_tex_file('pdftex.map')) + for page in dvi: + print(f"=== new page === " + f"(w: {page.width}, h: {page.height}, d: {page.descent})") + for font, group in itertools.groupby( + page.text, lambda text: text.font): + print(f"font: {font.texname.decode('latin-1')!r}\t" + f"scale: {font._scale / 2 ** 20}") + print("x", "y", "glyph", "chr", "w", "(glyphs)", sep="\t") + for text in group: + print(text.x, text.y, text.glyph, + chr(text.glyph) if chr(text.glyph).isprintable() + else ".", + text.width, sep="\t") + if page.boxes: + print("x", "y", "h", "w", "", "(boxes)", sep="\t") + for box in page.boxes: + print(box.x, box.y, box.height, box.width, sep="\t") diff --git a/venv/lib/python3.10/site-packages/matplotlib/dviread.pyi b/venv/lib/python3.10/site-packages/matplotlib/dviread.pyi new file mode 100644 index 00000000..bf5cfcbe --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/dviread.pyi @@ -0,0 +1,90 @@ +from pathlib import Path +import io +import os +from enum import Enum +from collections.abc import Generator + +from typing import NamedTuple + +class _dvistate(Enum): + pre: int + outer: int + inpage: int + post_post: int + finale: int + +class Page(NamedTuple): + text: list[Text] + boxes: list[Box] + height: int + width: int + descent: int + +class Box(NamedTuple): + x: int + y: int + height: int + width: int + +class Text(NamedTuple): + x: int + y: int + font: DviFont + glyph: int + width: int + @property + def font_path(self) -> Path: ... + @property + def font_size(self) -> float: ... + @property + def font_effects(self) -> dict[str, float]: ... + @property + def glyph_name_or_index(self) -> int | str: ... + +class Dvi: + file: io.BufferedReader + dpi: float | None + fonts: dict[int, DviFont] + state: _dvistate + def __init__(self, filename: str | os.PathLike, dpi: float | None) -> None: ... + # Replace return with Self when py3.9 is dropped + def __enter__(self) -> Dvi: ... + def __exit__(self, etype, evalue, etrace) -> None: ... + def __iter__(self) -> Generator[Page, None, None]: ... + def close(self) -> None: ... + +class DviFont: + texname: bytes + size: float + widths: list[int] + def __init__( + self, scale: float, tfm: Tfm, texname: bytes, vf: Vf | None + ) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + +class Vf(Dvi): + def __init__(self, filename: str | os.PathLike) -> None: ... + def __getitem__(self, code: int) -> Page: ... + +class Tfm: + checksum: int + design_size: int + width: dict[int, int] + height: dict[int, int] + depth: dict[int, int] + def __init__(self, filename: str | os.PathLike) -> None: ... + +class PsFont(NamedTuple): + texname: bytes + psname: bytes + effects: dict[str, float] + encoding: None | bytes + filename: str + +class PsfontsMap: + # Replace return with Self when py3.9 is dropped + def __new__(cls, filename: str | os.PathLike) -> PsfontsMap: ... + def __getitem__(self, texname: bytes) -> PsFont: ... + +def find_tex_file(filename: str | os.PathLike) -> str: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/figure.py b/venv/lib/python3.10/site-packages/matplotlib/figure.py new file mode 100644 index 00000000..0a0ff01a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/figure.py @@ -0,0 +1,3624 @@ +""" +`matplotlib.figure` implements the following classes: + +`Figure` + Top level `~matplotlib.artist.Artist`, which holds all plot elements. + Many methods are implemented in `FigureBase`. + +`SubFigure` + A logical figure inside a figure, usually added to a figure (or parent + `SubFigure`) with `Figure.add_subfigure` or `Figure.subfigures` methods + (provisional API v3.4). + +Figures are typically created using pyplot methods `~.pyplot.figure`, +`~.pyplot.subplots`, and `~.pyplot.subplot_mosaic`. + +.. plot:: + :include-source: + + fig, ax = plt.subplots(figsize=(2, 2), facecolor='lightskyblue', + layout='constrained') + fig.suptitle('Figure') + ax.set_title('Axes', loc='left', fontstyle='oblique', fontsize='medium') + +Some situations call for directly instantiating a `~.figure.Figure` class, +usually inside an application of some sort (see :ref:`user_interfaces` for a +list of examples) . More information about Figures can be found at +:ref:`figure-intro`. +""" + +from contextlib import ExitStack +import inspect +import itertools +import logging +from numbers import Integral +import threading + +import numpy as np + +import matplotlib as mpl +from matplotlib import _blocking_input, backend_bases, _docstring, projections +from matplotlib.artist import ( + Artist, allow_rasterization, _finalize_rasterization) +from matplotlib.backend_bases import ( + DrawEvent, FigureCanvasBase, NonGuiException, MouseButton, _get_renderer) +import matplotlib._api as _api +import matplotlib.cbook as cbook +import matplotlib.colorbar as cbar +import matplotlib.image as mimage + +from matplotlib.axes import Axes +from matplotlib.gridspec import GridSpec, SubplotParams +from matplotlib.layout_engine import ( + ConstrainedLayoutEngine, TightLayoutEngine, LayoutEngine, + PlaceHolderLayoutEngine +) +import matplotlib.legend as mlegend +from matplotlib.patches import Rectangle +from matplotlib.text import Text +from matplotlib.transforms import (Affine2D, Bbox, BboxTransformTo, + TransformedBbox) + +_log = logging.getLogger(__name__) + + +def _stale_figure_callback(self, val): + if self.figure: + self.figure.stale = val + + +class _AxesStack: + """ + Helper class to track Axes in a figure. + + Axes are tracked both in the order in which they have been added + (``self._axes`` insertion/iteration order) and in the separate "gca" stack + (which is the index to which they map in the ``self._axes`` dict). + """ + + def __init__(self): + self._axes = {} # Mapping of Axes to "gca" order. + self._counter = itertools.count() + + def as_list(self): + """List the Axes that have been added to the figure.""" + return [*self._axes] # This relies on dict preserving order. + + def remove(self, a): + """Remove the Axes from the stack.""" + self._axes.pop(a) + + def bubble(self, a): + """Move an Axes, which must already exist in the stack, to the top.""" + if a not in self._axes: + raise ValueError("Axes has not been added yet") + self._axes[a] = next(self._counter) + + def add(self, a): + """Add an Axes to the stack, ignoring it if already present.""" + if a not in self._axes: + self._axes[a] = next(self._counter) + + def current(self): + """Return the active Axes, or None if the stack is empty.""" + return max(self._axes, key=self._axes.__getitem__, default=None) + + def __getstate__(self): + return { + **vars(self), + "_counter": max(self._axes.values(), default=0) + } + + def __setstate__(self, state): + next_counter = state.pop('_counter') + vars(self).update(state) + self._counter = itertools.count(next_counter) + + +class FigureBase(Artist): + """ + Base class for `.Figure` and `.SubFigure` containing the methods that add + artists to the figure or subfigure, create Axes, etc. + """ + def __init__(self, **kwargs): + super().__init__() + # remove the non-figure artist _axes property + # as it makes no sense for a figure to be _in_ an Axes + # this is used by the property methods in the artist base class + # which are over-ridden in this class + del self._axes + + self._suptitle = None + self._supxlabel = None + self._supylabel = None + + # groupers to keep track of x, y labels and title we want to align. + # see self.align_xlabels, self.align_ylabels, + # self.align_titles, and axis._get_tick_boxes_siblings + self._align_label_groups = { + "x": cbook.Grouper(), + "y": cbook.Grouper(), + "title": cbook.Grouper() + } + + self._localaxes = [] # track all Axes + self.artists = [] + self.lines = [] + self.patches = [] + self.texts = [] + self.images = [] + self.legends = [] + self.subfigs = [] + self.stale = True + self.suppressComposite = None + self.set(**kwargs) + + def _get_draw_artists(self, renderer): + """Also runs apply_aspect""" + artists = self.get_children() + + artists.remove(self.patch) + artists = sorted( + (artist for artist in artists if not artist.get_animated()), + key=lambda artist: artist.get_zorder()) + for ax in self._localaxes: + locator = ax.get_axes_locator() + ax.apply_aspect(locator(ax, renderer) if locator else None) + + for child in ax.get_children(): + if hasattr(child, 'apply_aspect'): + locator = child.get_axes_locator() + child.apply_aspect( + locator(child, renderer) if locator else None) + return artists + + def autofmt_xdate( + self, bottom=0.2, rotation=30, ha='right', which='major'): + """ + Date ticklabels often overlap, so it is useful to rotate them + and right align them. Also, a common use case is a number of + subplots with shared x-axis where the x-axis is date data. The + ticklabels are often long, and it helps to rotate them on the + bottom subplot and turn them off on other subplots, as well as + turn off xlabels. + + Parameters + ---------- + bottom : float, default: 0.2 + The bottom of the subplots for `subplots_adjust`. + rotation : float, default: 30 degrees + The rotation angle of the xtick labels in degrees. + ha : {'left', 'center', 'right'}, default: 'right' + The horizontal alignment of the xticklabels. + which : {'major', 'minor', 'both'}, default: 'major' + Selects which ticklabels to rotate. + """ + _api.check_in_list(['major', 'minor', 'both'], which=which) + allsubplots = all(ax.get_subplotspec() for ax in self.axes) + if len(self.axes) == 1: + for label in self.axes[0].get_xticklabels(which=which): + label.set_ha(ha) + label.set_rotation(rotation) + else: + if allsubplots: + for ax in self.get_axes(): + if ax.get_subplotspec().is_last_row(): + for label in ax.get_xticklabels(which=which): + label.set_ha(ha) + label.set_rotation(rotation) + else: + for label in ax.get_xticklabels(which=which): + label.set_visible(False) + ax.set_xlabel('') + + if allsubplots: + self.subplots_adjust(bottom=bottom) + self.stale = True + + def get_children(self): + """Get a list of artists contained in the figure.""" + return [self.patch, + *self.artists, + *self._localaxes, + *self.lines, + *self.patches, + *self.texts, + *self.images, + *self.legends, + *self.subfigs] + + def contains(self, mouseevent): + """ + Test whether the mouse event occurred on the figure. + + Returns + ------- + bool, {} + """ + if self._different_canvas(mouseevent): + return False, {} + inside = self.bbox.contains(mouseevent.x, mouseevent.y) + return inside, {} + + def get_window_extent(self, renderer=None): + # docstring inherited + return self.bbox + + def _suplabels(self, t, info, **kwargs): + """ + Add a centered %(name)s to the figure. + + Parameters + ---------- + t : str + The %(name)s text. + x : float, default: %(x0)s + The x location of the text in figure coordinates. + y : float, default: %(y0)s + The y location of the text in figure coordinates. + horizontalalignment, ha : {'center', 'left', 'right'}, default: %(ha)s + The horizontal alignment of the text relative to (*x*, *y*). + verticalalignment, va : {'top', 'center', 'bottom', 'baseline'}, \ +default: %(va)s + The vertical alignment of the text relative to (*x*, *y*). + fontsize, size : default: :rc:`figure.%(rc)ssize` + The font size of the text. See `.Text.set_size` for possible + values. + fontweight, weight : default: :rc:`figure.%(rc)sweight` + The font weight of the text. See `.Text.set_weight` for possible + values. + + Returns + ------- + text + The `.Text` instance of the %(name)s. + + Other Parameters + ---------------- + fontproperties : None or dict, optional + A dict of font properties. If *fontproperties* is given the + default values for font size and weight are taken from the + `.FontProperties` defaults. :rc:`figure.%(rc)ssize` and + :rc:`figure.%(rc)sweight` are ignored in this case. + + **kwargs + Additional kwargs are `matplotlib.text.Text` properties. + """ + + x = kwargs.pop('x', None) + y = kwargs.pop('y', None) + if info['name'] in ['_supxlabel', '_suptitle']: + autopos = y is None + elif info['name'] == '_supylabel': + autopos = x is None + if x is None: + x = info['x0'] + if y is None: + y = info['y0'] + + kwargs = cbook.normalize_kwargs(kwargs, Text) + kwargs.setdefault('horizontalalignment', info['ha']) + kwargs.setdefault('verticalalignment', info['va']) + kwargs.setdefault('rotation', info['rotation']) + + if 'fontproperties' not in kwargs: + kwargs.setdefault('fontsize', mpl.rcParams[info['size']]) + kwargs.setdefault('fontweight', mpl.rcParams[info['weight']]) + + suplab = getattr(self, info['name']) + if suplab is not None: + suplab.set_text(t) + suplab.set_position((x, y)) + suplab.set(**kwargs) + else: + suplab = self.text(x, y, t, **kwargs) + setattr(self, info['name'], suplab) + suplab._autopos = autopos + self.stale = True + return suplab + + @_docstring.Substitution(x0=0.5, y0=0.98, name='suptitle', ha='center', + va='top', rc='title') + @_docstring.copy(_suplabels) + def suptitle(self, t, **kwargs): + # docstring from _suplabels... + info = {'name': '_suptitle', 'x0': 0.5, 'y0': 0.98, + 'ha': 'center', 'va': 'top', 'rotation': 0, + 'size': 'figure.titlesize', 'weight': 'figure.titleweight'} + return self._suplabels(t, info, **kwargs) + + def get_suptitle(self): + """Return the suptitle as string or an empty string if not set.""" + text_obj = self._suptitle + return "" if text_obj is None else text_obj.get_text() + + @_docstring.Substitution(x0=0.5, y0=0.01, name='supxlabel', ha='center', + va='bottom', rc='label') + @_docstring.copy(_suplabels) + def supxlabel(self, t, **kwargs): + # docstring from _suplabels... + info = {'name': '_supxlabel', 'x0': 0.5, 'y0': 0.01, + 'ha': 'center', 'va': 'bottom', 'rotation': 0, + 'size': 'figure.labelsize', 'weight': 'figure.labelweight'} + return self._suplabels(t, info, **kwargs) + + def get_supxlabel(self): + """Return the supxlabel as string or an empty string if not set.""" + text_obj = self._supxlabel + return "" if text_obj is None else text_obj.get_text() + + @_docstring.Substitution(x0=0.02, y0=0.5, name='supylabel', ha='left', + va='center', rc='label') + @_docstring.copy(_suplabels) + def supylabel(self, t, **kwargs): + # docstring from _suplabels... + info = {'name': '_supylabel', 'x0': 0.02, 'y0': 0.5, + 'ha': 'left', 'va': 'center', 'rotation': 'vertical', + 'rotation_mode': 'anchor', 'size': 'figure.labelsize', + 'weight': 'figure.labelweight'} + return self._suplabels(t, info, **kwargs) + + def get_supylabel(self): + """Return the supylabel as string or an empty string if not set.""" + text_obj = self._supylabel + return "" if text_obj is None else text_obj.get_text() + + def get_edgecolor(self): + """Get the edge color of the Figure rectangle.""" + return self.patch.get_edgecolor() + + def get_facecolor(self): + """Get the face color of the Figure rectangle.""" + return self.patch.get_facecolor() + + def get_frameon(self): + """ + Return the figure's background patch visibility, i.e. + whether the figure background will be drawn. Equivalent to + ``Figure.patch.get_visible()``. + """ + return self.patch.get_visible() + + def set_linewidth(self, linewidth): + """ + Set the line width of the Figure rectangle. + + Parameters + ---------- + linewidth : number + """ + self.patch.set_linewidth(linewidth) + + def get_linewidth(self): + """ + Get the line width of the Figure rectangle. + """ + return self.patch.get_linewidth() + + def set_edgecolor(self, color): + """ + Set the edge color of the Figure rectangle. + + Parameters + ---------- + color : :mpltype:`color` + """ + self.patch.set_edgecolor(color) + + def set_facecolor(self, color): + """ + Set the face color of the Figure rectangle. + + Parameters + ---------- + color : :mpltype:`color` + """ + self.patch.set_facecolor(color) + + def set_frameon(self, b): + """ + Set the figure's background patch visibility, i.e. + whether the figure background will be drawn. Equivalent to + ``Figure.patch.set_visible()``. + + Parameters + ---------- + b : bool + """ + self.patch.set_visible(b) + self.stale = True + + frameon = property(get_frameon, set_frameon) + + def add_artist(self, artist, clip=False): + """ + Add an `.Artist` to the figure. + + Usually artists are added to `~.axes.Axes` objects using + `.Axes.add_artist`; this method can be used in the rare cases where + one needs to add artists directly to the figure instead. + + Parameters + ---------- + artist : `~matplotlib.artist.Artist` + The artist to add to the figure. If the added artist has no + transform previously set, its transform will be set to + ``figure.transSubfigure``. + clip : bool, default: False + Whether the added artist should be clipped by the figure patch. + + Returns + ------- + `~matplotlib.artist.Artist` + The added artist. + """ + artist.set_figure(self) + self.artists.append(artist) + artist._remove_method = self.artists.remove + + if not artist.is_transform_set(): + artist.set_transform(self.transSubfigure) + + if clip and artist.get_clip_path() is None: + artist.set_clip_path(self.patch) + + self.stale = True + return artist + + @_docstring.dedent_interpd + def add_axes(self, *args, **kwargs): + """ + Add an `~.axes.Axes` to the figure. + + Call signatures:: + + add_axes(rect, projection=None, polar=False, **kwargs) + add_axes(ax) + + Parameters + ---------- + rect : tuple (left, bottom, width, height) + The dimensions (left, bottom, width, height) of the new + `~.axes.Axes`. All quantities are in fractions of figure width and + height. + + projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \ +'polar', 'rectilinear', str}, optional + The projection type of the `~.axes.Axes`. *str* is the name of + a custom projection, see `~matplotlib.projections`. The default + None results in a 'rectilinear' projection. + + polar : bool, default: False + If True, equivalent to projection='polar'. + + axes_class : subclass type of `~.axes.Axes`, optional + The `.axes.Axes` subclass that is instantiated. This parameter + is incompatible with *projection* and *polar*. See + :ref:`axisartist_users-guide-index` for examples. + + sharex, sharey : `~matplotlib.axes.Axes`, optional + Share the x or y `~matplotlib.axis` with sharex and/or sharey. + The axis will have the same limits, ticks, and scale as the axis + of the shared Axes. + + label : str + A label for the returned Axes. + + Returns + ------- + `~.axes.Axes`, or a subclass of `~.axes.Axes` + The returned Axes class depends on the projection used. It is + `~.axes.Axes` if rectilinear projection is used and + `.projections.polar.PolarAxes` if polar projection is used. + + Other Parameters + ---------------- + **kwargs + This method also takes the keyword arguments for + the returned Axes class. The keyword arguments for the + rectilinear Axes class `~.axes.Axes` can be found in + the following table but there might also be other keyword + arguments if another projection is used, see the actual Axes + class. + + %(Axes:kwdoc)s + + Notes + ----- + In rare circumstances, `.add_axes` may be called with a single + argument, an Axes instance already created in the present figure but + not in the figure's list of Axes. + + See Also + -------- + .Figure.add_subplot + .pyplot.subplot + .pyplot.axes + .Figure.subplots + .pyplot.subplots + + Examples + -------- + Some simple examples:: + + rect = l, b, w, h + fig = plt.figure() + fig.add_axes(rect) + fig.add_axes(rect, frameon=False, facecolor='g') + fig.add_axes(rect, polar=True) + ax = fig.add_axes(rect, projection='polar') + fig.delaxes(ax) + fig.add_axes(ax) + """ + + if not len(args) and 'rect' not in kwargs: + raise TypeError( + "add_axes() missing 1 required positional argument: 'rect'") + elif 'rect' in kwargs: + if len(args): + raise TypeError( + "add_axes() got multiple values for argument 'rect'") + args = (kwargs.pop('rect'), ) + + if isinstance(args[0], Axes): + a, *extra_args = args + key = a._projection_init + if a.get_figure() is not self: + raise ValueError( + "The Axes must have been created in the present figure") + else: + rect, *extra_args = args + if not np.isfinite(rect).all(): + raise ValueError(f'all entries in rect must be finite not {rect}') + projection_class, pkw = self._process_projection_requirements(**kwargs) + + # create the new Axes using the Axes class given + a = projection_class(self, rect, **pkw) + key = (projection_class, pkw) + + if extra_args: + _api.warn_deprecated( + "3.8", + name="Passing more than one positional argument to Figure.add_axes", + addendum="Any additional positional arguments are currently ignored.") + return self._add_axes_internal(a, key) + + @_docstring.dedent_interpd + def add_subplot(self, *args, **kwargs): + """ + Add an `~.axes.Axes` to the figure as part of a subplot arrangement. + + Call signatures:: + + add_subplot(nrows, ncols, index, **kwargs) + add_subplot(pos, **kwargs) + add_subplot(ax) + add_subplot() + + Parameters + ---------- + *args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1) + The position of the subplot described by one of + + - Three integers (*nrows*, *ncols*, *index*). The subplot will + take the *index* position on a grid with *nrows* rows and + *ncols* columns. *index* starts at 1 in the upper left corner + and increases to the right. *index* can also be a two-tuple + specifying the (*first*, *last*) indices (1-based, and including + *last*) of the subplot, e.g., ``fig.add_subplot(3, 1, (1, 2))`` + makes a subplot that spans the upper 2/3 of the figure. + - A 3-digit integer. The digits are interpreted as if given + separately as three single-digit integers, i.e. + ``fig.add_subplot(235)`` is the same as + ``fig.add_subplot(2, 3, 5)``. Note that this can only be used + if there are no more than 9 subplots. + - A `.SubplotSpec`. + + In rare circumstances, `.add_subplot` may be called with a single + argument, a subplot Axes instance already created in the + present figure but not in the figure's list of Axes. + + projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \ +'polar', 'rectilinear', str}, optional + The projection type of the subplot (`~.axes.Axes`). *str* is the + name of a custom projection, see `~matplotlib.projections`. The + default None results in a 'rectilinear' projection. + + polar : bool, default: False + If True, equivalent to projection='polar'. + + axes_class : subclass type of `~.axes.Axes`, optional + The `.axes.Axes` subclass that is instantiated. This parameter + is incompatible with *projection* and *polar*. See + :ref:`axisartist_users-guide-index` for examples. + + sharex, sharey : `~matplotlib.axes.Axes`, optional + Share the x or y `~matplotlib.axis` with sharex and/or sharey. + The axis will have the same limits, ticks, and scale as the axis + of the shared Axes. + + label : str + A label for the returned Axes. + + Returns + ------- + `~.axes.Axes` + + The Axes of the subplot. The returned Axes can actually be an + instance of a subclass, such as `.projections.polar.PolarAxes` for + polar projections. + + Other Parameters + ---------------- + **kwargs + This method also takes the keyword arguments for the returned Axes + base class; except for the *figure* argument. The keyword arguments + for the rectilinear base class `~.axes.Axes` can be found in + the following table but there might also be other keyword + arguments if another projection is used. + + %(Axes:kwdoc)s + + See Also + -------- + .Figure.add_axes + .pyplot.subplot + .pyplot.axes + .Figure.subplots + .pyplot.subplots + + Examples + -------- + :: + + fig = plt.figure() + + fig.add_subplot(231) + ax1 = fig.add_subplot(2, 3, 1) # equivalent but more general + + fig.add_subplot(232, frameon=False) # subplot with no frame + fig.add_subplot(233, projection='polar') # polar subplot + fig.add_subplot(234, sharex=ax1) # subplot sharing x-axis with ax1 + fig.add_subplot(235, facecolor="red") # red subplot + + ax1.remove() # delete ax1 from the figure + fig.add_subplot(ax1) # add ax1 back to the figure + """ + if 'figure' in kwargs: + # Axes itself allows for a 'figure' kwarg, but since we want to + # bind the created Axes to self, it is not allowed here. + raise _api.kwarg_error("add_subplot", "figure") + + if (len(args) == 1 + and isinstance(args[0], mpl.axes._base._AxesBase) + and args[0].get_subplotspec()): + ax = args[0] + key = ax._projection_init + if ax.get_figure() is not self: + raise ValueError("The Axes must have been created in " + "the present figure") + else: + if not args: + args = (1, 1, 1) + # Normalize correct ijk values to (i, j, k) here so that + # add_subplot(211) == add_subplot(2, 1, 1). Invalid values will + # trigger errors later (via SubplotSpec._from_subplot_args). + if (len(args) == 1 and isinstance(args[0], Integral) + and 100 <= args[0] <= 999): + args = tuple(map(int, str(args[0]))) + projection_class, pkw = self._process_projection_requirements(**kwargs) + ax = projection_class(self, *args, **pkw) + key = (projection_class, pkw) + return self._add_axes_internal(ax, key) + + def _add_axes_internal(self, ax, key): + """Private helper for `add_axes` and `add_subplot`.""" + self._axstack.add(ax) + if ax not in self._localaxes: + self._localaxes.append(ax) + self.sca(ax) + ax._remove_method = self.delaxes + # this is to support plt.subplot's re-selection logic + ax._projection_init = key + self.stale = True + ax.stale_callback = _stale_figure_callback + return ax + + def subplots(self, nrows=1, ncols=1, *, sharex=False, sharey=False, + squeeze=True, width_ratios=None, height_ratios=None, + subplot_kw=None, gridspec_kw=None): + """ + Add a set of subplots to this figure. + + This utility wrapper makes it convenient to create common layouts of + subplots in a single call. + + Parameters + ---------- + nrows, ncols : int, default: 1 + Number of rows/columns of the subplot grid. + + sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False + Controls sharing of x-axis (*sharex*) or y-axis (*sharey*): + + - True or 'all': x- or y-axis will be shared among all subplots. + - False or 'none': each subplot x- or y-axis will be independent. + - 'row': each subplot row will share an x- or y-axis. + - 'col': each subplot column will share an x- or y-axis. + + When subplots have a shared x-axis along a column, only the x tick + labels of the bottom subplot are created. Similarly, when subplots + have a shared y-axis along a row, only the y tick labels of the + first column subplot are created. To later turn other subplots' + ticklabels on, use `~matplotlib.axes.Axes.tick_params`. + + When subplots have a shared axis that has units, calling + `.Axis.set_units` will update each axis with the new units. + + squeeze : bool, default: True + - If True, extra dimensions are squeezed out from the returned + array of Axes: + + - if only one subplot is constructed (nrows=ncols=1), the + resulting single Axes object is returned as a scalar. + - for Nx1 or 1xM subplots, the returned object is a 1D numpy + object array of Axes objects. + - for NxM, subplots with N>1 and M>1 are returned as a 2D array. + + - If False, no squeezing at all is done: the returned Axes object + is always a 2D array containing Axes instances, even if it ends + up being 1x1. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. Equivalent + to ``gridspec_kw={'width_ratios': [...]}``. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. Equivalent + to ``gridspec_kw={'height_ratios': [...]}``. + + subplot_kw : dict, optional + Dict with keywords passed to the `.Figure.add_subplot` call used to + create each subplot. + + gridspec_kw : dict, optional + Dict with keywords passed to the + `~matplotlib.gridspec.GridSpec` constructor used to create + the grid the subplots are placed on. + + Returns + ------- + `~.axes.Axes` or array of Axes + Either a single `~matplotlib.axes.Axes` object or an array of Axes + objects if more than one subplot was created. The dimensions of the + resulting array can be controlled with the *squeeze* keyword, see + above. + + See Also + -------- + .pyplot.subplots + .Figure.add_subplot + .pyplot.subplot + + Examples + -------- + :: + + # First create some toy data: + x = np.linspace(0, 2*np.pi, 400) + y = np.sin(x**2) + + # Create a figure + fig = plt.figure() + + # Create a subplot + ax = fig.subplots() + ax.plot(x, y) + ax.set_title('Simple plot') + + # Create two subplots and unpack the output array immediately + ax1, ax2 = fig.subplots(1, 2, sharey=True) + ax1.plot(x, y) + ax1.set_title('Sharing Y axis') + ax2.scatter(x, y) + + # Create four polar Axes and access them through the returned array + axes = fig.subplots(2, 2, subplot_kw=dict(projection='polar')) + axes[0, 0].plot(x, y) + axes[1, 1].scatter(x, y) + + # Share an X-axis with each column of subplots + fig.subplots(2, 2, sharex='col') + + # Share a Y-axis with each row of subplots + fig.subplots(2, 2, sharey='row') + + # Share both X- and Y-axes with all subplots + fig.subplots(2, 2, sharex='all', sharey='all') + + # Note that this is the same as + fig.subplots(2, 2, sharex=True, sharey=True) + """ + gridspec_kw = dict(gridspec_kw or {}) + if height_ratios is not None: + if 'height_ratios' in gridspec_kw: + raise ValueError("'height_ratios' must not be defined both as " + "parameter and as key in 'gridspec_kw'") + gridspec_kw['height_ratios'] = height_ratios + if width_ratios is not None: + if 'width_ratios' in gridspec_kw: + raise ValueError("'width_ratios' must not be defined both as " + "parameter and as key in 'gridspec_kw'") + gridspec_kw['width_ratios'] = width_ratios + + gs = self.add_gridspec(nrows, ncols, figure=self, **gridspec_kw) + axs = gs.subplots(sharex=sharex, sharey=sharey, squeeze=squeeze, + subplot_kw=subplot_kw) + return axs + + def delaxes(self, ax): + """ + Remove the `~.axes.Axes` *ax* from the figure; update the current Axes. + """ + self._remove_axes(ax, owners=[self._axstack, self._localaxes]) + + def _remove_axes(self, ax, owners): + """ + Common helper for removal of standard Axes (via delaxes) and of child Axes. + + Parameters + ---------- + ax : `~.AxesBase` + The Axes to remove. + owners + List of objects (list or _AxesStack) "owning" the Axes, from which the Axes + will be remove()d. + """ + for owner in owners: + owner.remove(ax) + + self._axobservers.process("_axes_change_event", self) + self.stale = True + self.canvas.release_mouse(ax) + + for name in ax._axis_names: # Break link between any shared Axes + grouper = ax._shared_axes[name] + siblings = [other for other in grouper.get_siblings(ax) if other is not ax] + if not siblings: # Axes was not shared along this axis; we're done. + continue + grouper.remove(ax) + # Formatters and locators may previously have been associated with the now + # removed axis. Update them to point to an axis still there (we can pick + # any of them, and use the first sibling). + remaining_axis = siblings[0]._axis_map[name] + remaining_axis.get_major_formatter().set_axis(remaining_axis) + remaining_axis.get_major_locator().set_axis(remaining_axis) + remaining_axis.get_minor_formatter().set_axis(remaining_axis) + remaining_axis.get_minor_locator().set_axis(remaining_axis) + + ax._twinned_axes.remove(ax) # Break link between any twinned Axes. + + def clear(self, keep_observers=False): + """ + Clear the figure. + + Parameters + ---------- + keep_observers : bool, default: False + Set *keep_observers* to True if, for example, + a gui widget is tracking the Axes in the figure. + """ + self.suppressComposite = None + + # first clear the Axes in any subfigures + for subfig in self.subfigs: + subfig.clear(keep_observers=keep_observers) + self.subfigs = [] + + for ax in tuple(self.axes): # Iterate over the copy. + ax.clear() + self.delaxes(ax) # Remove ax from self._axstack. + + self.artists = [] + self.lines = [] + self.patches = [] + self.texts = [] + self.images = [] + self.legends = [] + if not keep_observers: + self._axobservers = cbook.CallbackRegistry() + self._suptitle = None + self._supxlabel = None + self._supylabel = None + + self.stale = True + + # synonym for `clear`. + def clf(self, keep_observers=False): + """ + [*Discouraged*] Alias for the `clear()` method. + + .. admonition:: Discouraged + + The use of ``clf()`` is discouraged. Use ``clear()`` instead. + + Parameters + ---------- + keep_observers : bool, default: False + Set *keep_observers* to True if, for example, + a gui widget is tracking the Axes in the figure. + """ + return self.clear(keep_observers=keep_observers) + + # Note: the docstring below is modified with replace for the pyplot + # version of this function because the method name differs (plt.figlegend) + # the replacements are: + # " legend(" -> " figlegend(" for the signatures + # "fig.legend(" -> "plt.figlegend" for the code examples + # "ax.plot" -> "plt.plot" for consistency in using pyplot when able + @_docstring.dedent_interpd + def legend(self, *args, **kwargs): + """ + Place a legend on the figure. + + Call signatures:: + + legend() + legend(handles, labels) + legend(handles=handles) + legend(labels) + + The call signatures correspond to the following different ways to use + this method: + + **1. Automatic detection of elements to be shown in the legend** + + The elements to be added to the legend are automatically determined, + when you do not pass in any extra arguments. + + In this case, the labels are taken from the artist. You can specify + them either at artist creation or by calling the + :meth:`~.Artist.set_label` method on the artist:: + + ax.plot([1, 2, 3], label='Inline label') + fig.legend() + + or:: + + line, = ax.plot([1, 2, 3]) + line.set_label('Label via method') + fig.legend() + + Specific lines can be excluded from the automatic legend element + selection by defining a label starting with an underscore. + This is default for all artists, so calling `.Figure.legend` without + any arguments and without setting the labels manually will result in + no legend being drawn. + + + **2. Explicitly listing the artists and labels in the legend** + + For full control of which artists have a legend entry, it is possible + to pass an iterable of legend artists followed by an iterable of + legend labels respectively:: + + fig.legend([line1, line2, line3], ['label1', 'label2', 'label3']) + + + **3. Explicitly listing the artists in the legend** + + This is similar to 2, but the labels are taken from the artists' + label properties. Example:: + + line1, = ax1.plot([1, 2, 3], label='label1') + line2, = ax2.plot([1, 2, 3], label='label2') + fig.legend(handles=[line1, line2]) + + + **4. Labeling existing plot elements** + + .. admonition:: Discouraged + + This call signature is discouraged, because the relation between + plot elements and labels is only implicit by their order and can + easily be mixed up. + + To make a legend for all artists on all Axes, call this function with + an iterable of strings, one for each legend item. For example:: + + fig, (ax1, ax2) = plt.subplots(1, 2) + ax1.plot([1, 3, 5], color='blue') + ax2.plot([2, 4, 6], color='red') + fig.legend(['the blues', 'the reds']) + + + Parameters + ---------- + handles : list of `.Artist`, optional + A list of Artists (lines, patches) to be added to the legend. + Use this together with *labels*, if you need full control on what + is shown in the legend and the automatic mechanism described above + is not sufficient. + + The length of handles and labels should be the same in this + case. If they are not, they are truncated to the smaller length. + + labels : list of str, optional + A list of labels to show next to the artists. + Use this together with *handles*, if you need full control on what + is shown in the legend and the automatic mechanism described above + is not sufficient. + + Returns + ------- + `~matplotlib.legend.Legend` + + Other Parameters + ---------------- + %(_legend_kw_figure)s + + See Also + -------- + .Axes.legend + + Notes + ----- + Some artists are not supported by this function. See + :ref:`legend_guide` for details. + """ + + handles, labels, kwargs = mlegend._parse_legend_args(self.axes, *args, **kwargs) + # explicitly set the bbox transform if the user hasn't. + kwargs.setdefault("bbox_transform", self.transSubfigure) + l = mlegend.Legend(self, handles, labels, **kwargs) + self.legends.append(l) + l._remove_method = self.legends.remove + self.stale = True + return l + + @_docstring.dedent_interpd + def text(self, x, y, s, fontdict=None, **kwargs): + """ + Add text to figure. + + Parameters + ---------- + x, y : float + The position to place the text. By default, this is in figure + coordinates, floats in [0, 1]. The coordinate system can be changed + using the *transform* keyword. + + s : str + The text string. + + fontdict : dict, optional + A dictionary to override the default text properties. If not given, + the defaults are determined by :rc:`font.*`. Properties passed as + *kwargs* override the corresponding ones given in *fontdict*. + + Returns + ------- + `~.text.Text` + + Other Parameters + ---------------- + **kwargs : `~matplotlib.text.Text` properties + Other miscellaneous text parameters. + + %(Text:kwdoc)s + + See Also + -------- + .Axes.text + .pyplot.text + """ + effective_kwargs = { + 'transform': self.transSubfigure, + **(fontdict if fontdict is not None else {}), + **kwargs, + } + text = Text(x=x, y=y, text=s, **effective_kwargs) + text.set_figure(self) + text.stale_callback = _stale_figure_callback + + self.texts.append(text) + text._remove_method = self.texts.remove + self.stale = True + return text + + @_docstring.dedent_interpd + def colorbar( + self, mappable, cax=None, ax=None, use_gridspec=True, **kwargs): + """ + Add a colorbar to a plot. + + Parameters + ---------- + mappable + The `matplotlib.cm.ScalarMappable` (i.e., `.AxesImage`, + `.ContourSet`, etc.) described by this colorbar. This argument is + mandatory for the `.Figure.colorbar` method but optional for the + `.pyplot.colorbar` function, which sets the default to the current + image. + + Note that one can create a `.ScalarMappable` "on-the-fly" to + generate colorbars not attached to a previously drawn artist, e.g. + :: + + fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax) + + cax : `~matplotlib.axes.Axes`, optional + Axes into which the colorbar will be drawn. If `None`, then a new + Axes is created and the space for it will be stolen from the Axes(s) + specified in *ax*. + + ax : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of Axes, optional + The one or more parent Axes from which space for a new colorbar Axes + will be stolen. This parameter is only used if *cax* is not set. + + Defaults to the Axes that contains the mappable used to create the + colorbar. + + use_gridspec : bool, optional + If *cax* is ``None``, a new *cax* is created as an instance of + Axes. If *ax* is positioned with a subplotspec and *use_gridspec* + is ``True``, then *cax* is also positioned with a subplotspec. + + Returns + ------- + colorbar : `~matplotlib.colorbar.Colorbar` + + Other Parameters + ---------------- + %(_make_axes_kw_doc)s + %(_colormap_kw_doc)s + + Notes + ----- + If *mappable* is a `~.contour.ContourSet`, its *extend* kwarg is + included automatically. + + The *shrink* kwarg provides a simple way to scale the colorbar with + respect to the Axes. Note that if *cax* is specified, it determines the + size of the colorbar, and *shrink* and *aspect* are ignored. + + For more precise control, you can manually specify the positions of the + axes objects in which the mappable and the colorbar are drawn. In this + case, do not use any of the Axes properties kwargs. + + It is known that some vector graphics viewers (svg and pdf) render + white gaps between segments of the colorbar. This is due to bugs in + the viewers, not Matplotlib. As a workaround, the colorbar can be + rendered with overlapping segments:: + + cbar = colorbar() + cbar.solids.set_edgecolor("face") + draw() + + However, this has negative consequences in other circumstances, e.g. + with semi-transparent images (alpha < 1) and colorbar extensions; + therefore, this workaround is not used by default (see issue #1188). + + """ + + if ax is None: + ax = getattr(mappable, "axes", None) + + if cax is None: + if ax is None: + raise ValueError( + 'Unable to determine Axes to steal space for Colorbar. ' + 'Either provide the *cax* argument to use as the Axes for ' + 'the Colorbar, provide the *ax* argument to steal space ' + 'from it, or add *mappable* to an Axes.') + fig = ( # Figure of first Axes; logic copied from make_axes. + [*ax.flat] if isinstance(ax, np.ndarray) + else [*ax] if np.iterable(ax) + else [ax])[0].figure + current_ax = fig.gca() + if (fig.get_layout_engine() is not None and + not fig.get_layout_engine().colorbar_gridspec): + use_gridspec = False + if (use_gridspec + and isinstance(ax, mpl.axes._base._AxesBase) + and ax.get_subplotspec()): + cax, kwargs = cbar.make_axes_gridspec(ax, **kwargs) + else: + cax, kwargs = cbar.make_axes(ax, **kwargs) + # make_axes calls add_{axes,subplot} which changes gca; undo that. + fig.sca(current_ax) + cax.grid(visible=False, which='both', axis='both') + + if hasattr(mappable, "figure") and mappable.figure is not None: + # Get top level artists + mappable_host_fig = mappable.figure + if isinstance(mappable_host_fig, mpl.figure.SubFigure): + mappable_host_fig = mappable_host_fig.figure + # Warn in case of mismatch + if mappable_host_fig is not self.figure: + _api.warn_external( + f'Adding colorbar to a different Figure ' + f'{repr(mappable.figure)} than ' + f'{repr(self.figure)} which ' + f'fig.colorbar is called on.') + + NON_COLORBAR_KEYS = [ # remove kws that cannot be passed to Colorbar + 'fraction', 'pad', 'shrink', 'aspect', 'anchor', 'panchor'] + cb = cbar.Colorbar(cax, mappable, **{ + k: v for k, v in kwargs.items() if k not in NON_COLORBAR_KEYS}) + cax.figure.stale = True + return cb + + def subplots_adjust(self, left=None, bottom=None, right=None, top=None, + wspace=None, hspace=None): + """ + Adjust the subplot layout parameters. + + Unset parameters are left unmodified; initial values are given by + :rc:`figure.subplot.[name]`. + + Parameters + ---------- + left : float, optional + The position of the left edge of the subplots, + as a fraction of the figure width. + right : float, optional + The position of the right edge of the subplots, + as a fraction of the figure width. + bottom : float, optional + The position of the bottom edge of the subplots, + as a fraction of the figure height. + top : float, optional + The position of the top edge of the subplots, + as a fraction of the figure height. + wspace : float, optional + The width of the padding between subplots, + as a fraction of the average Axes width. + hspace : float, optional + The height of the padding between subplots, + as a fraction of the average Axes height. + """ + if (self.get_layout_engine() is not None and + not self.get_layout_engine().adjust_compatible): + _api.warn_external( + "This figure was using a layout engine that is " + "incompatible with subplots_adjust and/or tight_layout; " + "not calling subplots_adjust.") + return + self.subplotpars.update(left, bottom, right, top, wspace, hspace) + for ax in self.axes: + if ax.get_subplotspec() is not None: + ax._set_position(ax.get_subplotspec().get_position(self)) + self.stale = True + + def align_xlabels(self, axs=None): + """ + Align the xlabels of subplots in the same subplot row if label + alignment is being done automatically (i.e. the label position is + not manually set). + + Alignment persists for draw events after this is called. + + If a label is on the bottom, it is aligned with labels on Axes that + also have their label on the bottom and that have the same + bottom-most subplot row. If the label is on the top, + it is aligned with labels on Axes with the same top-most row. + + Parameters + ---------- + axs : list of `~matplotlib.axes.Axes` + Optional list of (or `~numpy.ndarray`) `~matplotlib.axes.Axes` + to align the xlabels. + Default is to align all Axes on the figure. + + See Also + -------- + matplotlib.figure.Figure.align_ylabels + matplotlib.figure.Figure.align_titles + matplotlib.figure.Figure.align_labels + + Notes + ----- + This assumes that ``axs`` are from the same `.GridSpec`, so that + their `.SubplotSpec` positions correspond to figure positions. + + Examples + -------- + Example with rotated xtick labels:: + + fig, axs = plt.subplots(1, 2) + for tick in axs[0].get_xticklabels(): + tick.set_rotation(55) + axs[0].set_xlabel('XLabel 0') + axs[1].set_xlabel('XLabel 1') + fig.align_xlabels() + """ + if axs is None: + axs = self.axes + axs = [ax for ax in np.ravel(axs) if ax.get_subplotspec() is not None] + for ax in axs: + _log.debug(' Working on: %s', ax.get_xlabel()) + rowspan = ax.get_subplotspec().rowspan + pos = ax.xaxis.get_label_position() # top or bottom + # Search through other Axes for label positions that are same as + # this one and that share the appropriate row number. + # Add to a grouper associated with each Axes of siblings. + # This list is inspected in `axis.draw` by + # `axis._update_label_position`. + for axc in axs: + if axc.xaxis.get_label_position() == pos: + rowspanc = axc.get_subplotspec().rowspan + if (pos == 'top' and rowspan.start == rowspanc.start or + pos == 'bottom' and rowspan.stop == rowspanc.stop): + # grouper for groups of xlabels to align + self._align_label_groups['x'].join(ax, axc) + + def align_ylabels(self, axs=None): + """ + Align the ylabels of subplots in the same subplot column if label + alignment is being done automatically (i.e. the label position is + not manually set). + + Alignment persists for draw events after this is called. + + If a label is on the left, it is aligned with labels on Axes that + also have their label on the left and that have the same + left-most subplot column. If the label is on the right, + it is aligned with labels on Axes with the same right-most column. + + Parameters + ---------- + axs : list of `~matplotlib.axes.Axes` + Optional list (or `~numpy.ndarray`) of `~matplotlib.axes.Axes` + to align the ylabels. + Default is to align all Axes on the figure. + + See Also + -------- + matplotlib.figure.Figure.align_xlabels + matplotlib.figure.Figure.align_titles + matplotlib.figure.Figure.align_labels + + Notes + ----- + This assumes that ``axs`` are from the same `.GridSpec`, so that + their `.SubplotSpec` positions correspond to figure positions. + + Examples + -------- + Example with large yticks labels:: + + fig, axs = plt.subplots(2, 1) + axs[0].plot(np.arange(0, 1000, 50)) + axs[0].set_ylabel('YLabel 0') + axs[1].set_ylabel('YLabel 1') + fig.align_ylabels() + """ + if axs is None: + axs = self.axes + axs = [ax for ax in np.ravel(axs) if ax.get_subplotspec() is not None] + for ax in axs: + _log.debug(' Working on: %s', ax.get_ylabel()) + colspan = ax.get_subplotspec().colspan + pos = ax.yaxis.get_label_position() # left or right + # Search through other Axes for label positions that are same as + # this one and that share the appropriate column number. + # Add to a list associated with each Axes of siblings. + # This list is inspected in `axis.draw` by + # `axis._update_label_position`. + for axc in axs: + if axc.yaxis.get_label_position() == pos: + colspanc = axc.get_subplotspec().colspan + if (pos == 'left' and colspan.start == colspanc.start or + pos == 'right' and colspan.stop == colspanc.stop): + # grouper for groups of ylabels to align + self._align_label_groups['y'].join(ax, axc) + + def align_titles(self, axs=None): + """ + Align the titles of subplots in the same subplot row if title + alignment is being done automatically (i.e. the title position is + not manually set). + + Alignment persists for draw events after this is called. + + Parameters + ---------- + axs : list of `~matplotlib.axes.Axes` + Optional list of (or ndarray) `~matplotlib.axes.Axes` + to align the titles. + Default is to align all Axes on the figure. + + See Also + -------- + matplotlib.figure.Figure.align_xlabels + matplotlib.figure.Figure.align_ylabels + matplotlib.figure.Figure.align_labels + + Notes + ----- + This assumes that ``axs`` are from the same `.GridSpec`, so that + their `.SubplotSpec` positions correspond to figure positions. + + Examples + -------- + Example with titles:: + + fig, axs = plt.subplots(1, 2) + axs[0].set_aspect('equal') + axs[0].set_title('Title 0') + axs[1].set_title('Title 1') + fig.align_titles() + """ + if axs is None: + axs = self.axes + axs = [ax for ax in np.ravel(axs) if ax.get_subplotspec() is not None] + for ax in axs: + _log.debug(' Working on: %s', ax.get_title()) + rowspan = ax.get_subplotspec().rowspan + for axc in axs: + rowspanc = axc.get_subplotspec().rowspan + if (rowspan.start == rowspanc.start): + self._align_label_groups['title'].join(ax, axc) + + def align_labels(self, axs=None): + """ + Align the xlabels and ylabels of subplots with the same subplots + row or column (respectively) if label alignment is being + done automatically (i.e. the label position is not manually set). + + Alignment persists for draw events after this is called. + + Parameters + ---------- + axs : list of `~matplotlib.axes.Axes` + Optional list (or `~numpy.ndarray`) of `~matplotlib.axes.Axes` + to align the labels. + Default is to align all Axes on the figure. + + See Also + -------- + matplotlib.figure.Figure.align_xlabels + matplotlib.figure.Figure.align_ylabels + matplotlib.figure.Figure.align_titles + """ + self.align_xlabels(axs=axs) + self.align_ylabels(axs=axs) + + def add_gridspec(self, nrows=1, ncols=1, **kwargs): + """ + Low-level API for creating a `.GridSpec` that has this figure as a parent. + + This is a low-level API, allowing you to create a gridspec and + subsequently add subplots based on the gridspec. Most users do + not need that freedom and should use the higher-level methods + `~.Figure.subplots` or `~.Figure.subplot_mosaic`. + + Parameters + ---------- + nrows : int, default: 1 + Number of rows in grid. + + ncols : int, default: 1 + Number of columns in grid. + + Returns + ------- + `.GridSpec` + + Other Parameters + ---------------- + **kwargs + Keyword arguments are passed to `.GridSpec`. + + See Also + -------- + matplotlib.pyplot.subplots + + Examples + -------- + Adding a subplot that spans two rows:: + + fig = plt.figure() + gs = fig.add_gridspec(2, 2) + ax1 = fig.add_subplot(gs[0, 0]) + ax2 = fig.add_subplot(gs[1, 0]) + # spans two rows: + ax3 = fig.add_subplot(gs[:, 1]) + + """ + + _ = kwargs.pop('figure', None) # pop in case user has added this... + gs = GridSpec(nrows=nrows, ncols=ncols, figure=self, **kwargs) + return gs + + def subfigures(self, nrows=1, ncols=1, squeeze=True, + wspace=None, hspace=None, + width_ratios=None, height_ratios=None, + **kwargs): + """ + Add a set of subfigures to this figure or subfigure. + + A subfigure has the same artist methods as a figure, and is logically + the same as a figure, but cannot print itself. + See :doc:`/gallery/subplots_axes_and_figures/subfigures`. + + .. note:: + The *subfigure* concept is new in v3.4, and the API is still provisional. + + Parameters + ---------- + nrows, ncols : int, default: 1 + Number of rows/columns of the subfigure grid. + + squeeze : bool, default: True + If True, extra dimensions are squeezed out from the returned + array of subfigures. + + wspace, hspace : float, default: None + The amount of width/height reserved for space between subfigures, + expressed as a fraction of the average subfigure width/height. + If not given, the values will be inferred from rcParams if using + constrained layout (see `~.ConstrainedLayoutEngine`), or zero if + not using a layout engine. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. + """ + gs = GridSpec(nrows=nrows, ncols=ncols, figure=self, + wspace=wspace, hspace=hspace, + width_ratios=width_ratios, + height_ratios=height_ratios, + left=0, right=1, bottom=0, top=1) + + sfarr = np.empty((nrows, ncols), dtype=object) + for i in range(ncols): + for j in range(nrows): + sfarr[j, i] = self.add_subfigure(gs[j, i], **kwargs) + + if self.get_layout_engine() is None and (wspace is not None or + hspace is not None): + # Gridspec wspace and hspace is ignored on subfigure instantiation, + # and no space is left. So need to account for it here if required. + bottoms, tops, lefts, rights = gs.get_grid_positions(self) + for sfrow, bottom, top in zip(sfarr, bottoms, tops): + for sf, left, right in zip(sfrow, lefts, rights): + bbox = Bbox.from_extents(left, bottom, right, top) + sf._redo_transform_rel_fig(bbox=bbox) + + if squeeze: + # Discarding unneeded dimensions that equal 1. If we only have one + # subfigure, just return it instead of a 1-element array. + return sfarr.item() if sfarr.size == 1 else sfarr.squeeze() + else: + # Returned axis array will be always 2-d, even if nrows=ncols=1. + return sfarr + + def add_subfigure(self, subplotspec, **kwargs): + """ + Add a `.SubFigure` to the figure as part of a subplot arrangement. + + Parameters + ---------- + subplotspec : `.gridspec.SubplotSpec` + Defines the region in a parent gridspec where the subfigure will + be placed. + + Returns + ------- + `.SubFigure` + + Other Parameters + ---------------- + **kwargs + Are passed to the `.SubFigure` object. + + See Also + -------- + .Figure.subfigures + """ + sf = SubFigure(self, subplotspec, **kwargs) + self.subfigs += [sf] + sf._remove_method = self.subfigs.remove + return sf + + def sca(self, a): + """Set the current Axes to be *a* and return *a*.""" + self._axstack.bubble(a) + self._axobservers.process("_axes_change_event", self) + return a + + def gca(self): + """ + Get the current Axes. + + If there is currently no Axes on this Figure, a new one is created + using `.Figure.add_subplot`. (To test whether there is currently an + Axes on a Figure, check whether ``figure.axes`` is empty. To test + whether there is currently a Figure on the pyplot figure stack, check + whether `.pyplot.get_fignums()` is empty.) + """ + ax = self._axstack.current() + return ax if ax is not None else self.add_subplot() + + def _gci(self): + # Helper for `~matplotlib.pyplot.gci`. Do not use elsewhere. + """ + Get the current colorable artist. + + Specifically, returns the current `.ScalarMappable` instance (`.Image` + created by `imshow` or `figimage`, `.Collection` created by `pcolor` or + `scatter`, etc.), or *None* if no such instance has been defined. + + The current image is an attribute of the current Axes, or the nearest + earlier Axes in the current figure that contains an image. + + Notes + ----- + Historically, the only colorable artists were images; hence the name + ``gci`` (get current image). + """ + # Look first for an image in the current Axes. + ax = self._axstack.current() + if ax is None: + return None + im = ax._gci() + if im is not None: + return im + # If there is no image in the current Axes, search for + # one in a previously created Axes. Whether this makes + # sense is debatable, but it is the documented behavior. + for ax in reversed(self.axes): + im = ax._gci() + if im is not None: + return im + return None + + def _process_projection_requirements(self, *, axes_class=None, polar=False, + projection=None, **kwargs): + """ + Handle the args/kwargs to add_axes/add_subplot/gca, returning:: + + (axes_proj_class, proj_class_kwargs) + + which can be used for new Axes initialization/identification. + """ + if axes_class is not None: + if polar or projection is not None: + raise ValueError( + "Cannot combine 'axes_class' and 'projection' or 'polar'") + projection_class = axes_class + else: + + if polar: + if projection is not None and projection != 'polar': + raise ValueError( + f"polar={polar}, yet projection={projection!r}. " + "Only one of these arguments should be supplied." + ) + projection = 'polar' + + if isinstance(projection, str) or projection is None: + projection_class = projections.get_projection_class(projection) + elif hasattr(projection, '_as_mpl_axes'): + projection_class, extra_kwargs = projection._as_mpl_axes() + kwargs.update(**extra_kwargs) + else: + raise TypeError( + f"projection must be a string, None or implement a " + f"_as_mpl_axes method, not {projection!r}") + return projection_class, kwargs + + def get_default_bbox_extra_artists(self): + """ + Return a list of Artists typically used in `.Figure.get_tightbbox`. + """ + bbox_artists = [artist for artist in self.get_children() + if (artist.get_visible() and artist.get_in_layout())] + for ax in self.axes: + if ax.get_visible(): + bbox_artists.extend(ax.get_default_bbox_extra_artists()) + return bbox_artists + + @_api.make_keyword_only("3.8", "bbox_extra_artists") + def get_tightbbox(self, renderer=None, bbox_extra_artists=None): + """ + Return a (tight) bounding box of the figure *in inches*. + + Note that `.FigureBase` differs from all other artists, which return + their `.Bbox` in pixels. + + Artists that have ``artist.set_in_layout(False)`` are not included + in the bbox. + + Parameters + ---------- + renderer : `.RendererBase` subclass + Renderer that will be used to draw the figures (i.e. + ``fig.canvas.get_renderer()``) + + bbox_extra_artists : list of `.Artist` or ``None`` + List of artists to include in the tight bounding box. If + ``None`` (default), then all artist children of each Axes are + included in the tight bounding box. + + Returns + ------- + `.BboxBase` + containing the bounding box (in figure inches). + """ + + if renderer is None: + renderer = self.figure._get_renderer() + + bb = [] + if bbox_extra_artists is None: + artists = [artist for artist in self.get_children() + if (artist not in self.axes and artist.get_visible() + and artist.get_in_layout())] + else: + artists = bbox_extra_artists + + for a in artists: + bbox = a.get_tightbbox(renderer) + if bbox is not None: + bb.append(bbox) + + for ax in self.axes: + if ax.get_visible(): + # some Axes don't take the bbox_extra_artists kwarg so we + # need this conditional.... + try: + bbox = ax.get_tightbbox( + renderer, bbox_extra_artists=bbox_extra_artists) + except TypeError: + bbox = ax.get_tightbbox(renderer) + bb.append(bbox) + bb = [b for b in bb + if (np.isfinite(b.width) and np.isfinite(b.height) + and (b.width != 0 or b.height != 0))] + + isfigure = hasattr(self, 'bbox_inches') + if len(bb) == 0: + if isfigure: + return self.bbox_inches + else: + # subfigures do not have bbox_inches, but do have a bbox + bb = [self.bbox] + + _bbox = Bbox.union(bb) + + if isfigure: + # transform from pixels to inches... + _bbox = TransformedBbox(_bbox, self.dpi_scale_trans.inverted()) + + return _bbox + + @staticmethod + def _norm_per_subplot_kw(per_subplot_kw): + expanded = {} + for k, v in per_subplot_kw.items(): + if isinstance(k, tuple): + for sub_key in k: + if sub_key in expanded: + raise ValueError(f'The key {sub_key!r} appears multiple times.') + expanded[sub_key] = v + else: + if k in expanded: + raise ValueError(f'The key {k!r} appears multiple times.') + expanded[k] = v + return expanded + + @staticmethod + def _normalize_grid_string(layout): + if '\n' not in layout: + # single-line string + return [list(ln) for ln in layout.split(';')] + else: + # multi-line string + layout = inspect.cleandoc(layout) + return [list(ln) for ln in layout.strip('\n').split('\n')] + + def subplot_mosaic(self, mosaic, *, sharex=False, sharey=False, + width_ratios=None, height_ratios=None, + empty_sentinel='.', + subplot_kw=None, per_subplot_kw=None, gridspec_kw=None): + """ + Build a layout of Axes based on ASCII art or nested lists. + + This is a helper function to build complex GridSpec layouts visually. + + See :ref:`mosaic` + for an example and full API documentation + + Parameters + ---------- + mosaic : list of list of {hashable or nested} or str + + A visual layout of how you want your Axes to be arranged + labeled as strings. For example :: + + x = [['A panel', 'A panel', 'edge'], + ['C panel', '.', 'edge']] + + produces 4 Axes: + + - 'A panel' which is 1 row high and spans the first two columns + - 'edge' which is 2 rows high and is on the right edge + - 'C panel' which in 1 row and 1 column wide in the bottom left + - a blank space 1 row and 1 column wide in the bottom center + + Any of the entries in the layout can be a list of lists + of the same form to create nested layouts. + + If input is a str, then it can either be a multi-line string of + the form :: + + ''' + AAE + C.E + ''' + + where each character is a column and each line is a row. Or it + can be a single-line string where rows are separated by ``;``:: + + 'AB;CC' + + The string notation allows only single character Axes labels and + does not support nesting but is very terse. + + The Axes identifiers may be `str` or a non-iterable hashable + object (e.g. `tuple` s may not be used). + + sharex, sharey : bool, default: False + If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared + among all subplots. In that case, tick label visibility and axis + units behave as for `subplots`. If False, each subplot's x- or + y-axis will be independent. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. Equivalent + to ``gridspec_kw={'width_ratios': [...]}``. In the case of nested + layouts, this argument applies only to the outer layout. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. Equivalent + to ``gridspec_kw={'height_ratios': [...]}``. In the case of nested + layouts, this argument applies only to the outer layout. + + subplot_kw : dict, optional + Dictionary with keywords passed to the `.Figure.add_subplot` call + used to create each subplot. These values may be overridden by + values in *per_subplot_kw*. + + per_subplot_kw : dict, optional + A dictionary mapping the Axes identifiers or tuples of identifiers + to a dictionary of keyword arguments to be passed to the + `.Figure.add_subplot` call used to create each subplot. The values + in these dictionaries have precedence over the values in + *subplot_kw*. + + If *mosaic* is a string, and thus all keys are single characters, + it is possible to use a single string instead of a tuple as keys; + i.e. ``"AB"`` is equivalent to ``("A", "B")``. + + .. versionadded:: 3.7 + + gridspec_kw : dict, optional + Dictionary with keywords passed to the `.GridSpec` constructor used + to create the grid the subplots are placed on. In the case of + nested layouts, this argument applies only to the outer layout. + For more complex layouts, users should use `.Figure.subfigures` + to create the nesting. + + empty_sentinel : object, optional + Entry in the layout to mean "leave this space empty". Defaults + to ``'.'``. Note, if *layout* is a string, it is processed via + `inspect.cleandoc` to remove leading white space, which may + interfere with using white-space as the empty sentinel. + + Returns + ------- + dict[label, Axes] + A dictionary mapping the labels to the Axes objects. The order of + the Axes is left-to-right and top-to-bottom of their position in the + total layout. + + """ + subplot_kw = subplot_kw or {} + gridspec_kw = dict(gridspec_kw or {}) + per_subplot_kw = per_subplot_kw or {} + + if height_ratios is not None: + if 'height_ratios' in gridspec_kw: + raise ValueError("'height_ratios' must not be defined both as " + "parameter and as key in 'gridspec_kw'") + gridspec_kw['height_ratios'] = height_ratios + if width_ratios is not None: + if 'width_ratios' in gridspec_kw: + raise ValueError("'width_ratios' must not be defined both as " + "parameter and as key in 'gridspec_kw'") + gridspec_kw['width_ratios'] = width_ratios + + # special-case string input + if isinstance(mosaic, str): + mosaic = self._normalize_grid_string(mosaic) + per_subplot_kw = { + tuple(k): v for k, v in per_subplot_kw.items() + } + + per_subplot_kw = self._norm_per_subplot_kw(per_subplot_kw) + + # Only accept strict bools to allow a possible future API expansion. + _api.check_isinstance(bool, sharex=sharex, sharey=sharey) + + def _make_array(inp): + """ + Convert input into 2D array + + We need to have this internal function rather than + ``np.asarray(..., dtype=object)`` so that a list of lists + of lists does not get converted to an array of dimension > 2. + + Returns + ------- + 2D object array + """ + r0, *rest = inp + if isinstance(r0, str): + raise ValueError('List mosaic specification must be 2D') + for j, r in enumerate(rest, start=1): + if isinstance(r, str): + raise ValueError('List mosaic specification must be 2D') + if len(r0) != len(r): + raise ValueError( + "All of the rows must be the same length, however " + f"the first row ({r0!r}) has length {len(r0)} " + f"and row {j} ({r!r}) has length {len(r)}." + ) + out = np.zeros((len(inp), len(r0)), dtype=object) + for j, r in enumerate(inp): + for k, v in enumerate(r): + out[j, k] = v + return out + + def _identify_keys_and_nested(mosaic): + """ + Given a 2D object array, identify unique IDs and nested mosaics + + Parameters + ---------- + mosaic : 2D object array + + Returns + ------- + unique_ids : tuple + The unique non-sub mosaic entries in this mosaic + nested : dict[tuple[int, int], 2D object array] + """ + # make sure we preserve the user supplied order + unique_ids = cbook._OrderedSet() + nested = {} + for j, row in enumerate(mosaic): + for k, v in enumerate(row): + if v == empty_sentinel: + continue + elif not cbook.is_scalar_or_string(v): + nested[(j, k)] = _make_array(v) + else: + unique_ids.add(v) + + return tuple(unique_ids), nested + + def _do_layout(gs, mosaic, unique_ids, nested): + """ + Recursively do the mosaic. + + Parameters + ---------- + gs : GridSpec + mosaic : 2D object array + The input converted to a 2D array for this level. + unique_ids : tuple + The identified scalar labels at this level of nesting. + nested : dict[tuple[int, int]], 2D object array + The identified nested mosaics, if any. + + Returns + ------- + dict[label, Axes] + A flat dict of all of the Axes created. + """ + output = dict() + + # we need to merge together the Axes at this level and the Axes + # in the (recursively) nested sub-mosaics so that we can add + # them to the figure in the "natural" order if you were to + # ravel in c-order all of the Axes that will be created + # + # This will stash the upper left index of each object (axes or + # nested mosaic) at this level + this_level = dict() + + # go through the unique keys, + for name in unique_ids: + # sort out where each axes starts/ends + indx = np.argwhere(mosaic == name) + start_row, start_col = np.min(indx, axis=0) + end_row, end_col = np.max(indx, axis=0) + 1 + # and construct the slice object + slc = (slice(start_row, end_row), slice(start_col, end_col)) + # some light error checking + if (mosaic[slc] != name).any(): + raise ValueError( + f"While trying to layout\n{mosaic!r}\n" + f"we found that the label {name!r} specifies a " + "non-rectangular or non-contiguous area.") + # and stash this slice for later + this_level[(start_row, start_col)] = (name, slc, 'axes') + + # do the same thing for the nested mosaics (simpler because these + # cannot be spans yet!) + for (j, k), nested_mosaic in nested.items(): + this_level[(j, k)] = (None, nested_mosaic, 'nested') + + # now go through the things in this level and add them + # in order left-to-right top-to-bottom + for key in sorted(this_level): + name, arg, method = this_level[key] + # we are doing some hokey function dispatch here based + # on the 'method' string stashed above to sort out if this + # element is an Axes or a nested mosaic. + if method == 'axes': + slc = arg + # add a single Axes + if name in output: + raise ValueError(f"There are duplicate keys {name} " + f"in the layout\n{mosaic!r}") + ax = self.add_subplot( + gs[slc], **{ + 'label': str(name), + **subplot_kw, + **per_subplot_kw.get(name, {}) + } + ) + output[name] = ax + elif method == 'nested': + nested_mosaic = arg + j, k = key + # recursively add the nested mosaic + rows, cols = nested_mosaic.shape + nested_output = _do_layout( + gs[j, k].subgridspec(rows, cols), + nested_mosaic, + *_identify_keys_and_nested(nested_mosaic) + ) + overlap = set(output) & set(nested_output) + if overlap: + raise ValueError( + f"There are duplicate keys {overlap} " + f"between the outer layout\n{mosaic!r}\n" + f"and the nested layout\n{nested_mosaic}" + ) + output.update(nested_output) + else: + raise RuntimeError("This should never happen") + return output + + mosaic = _make_array(mosaic) + rows, cols = mosaic.shape + gs = self.add_gridspec(rows, cols, **gridspec_kw) + ret = _do_layout(gs, mosaic, *_identify_keys_and_nested(mosaic)) + ax0 = next(iter(ret.values())) + for ax in ret.values(): + if sharex: + ax.sharex(ax0) + ax._label_outer_xaxis(skip_non_rectangular_axes=True) + if sharey: + ax.sharey(ax0) + ax._label_outer_yaxis(skip_non_rectangular_axes=True) + if extra := set(per_subplot_kw) - set(ret): + raise ValueError( + f"The keys {extra} are in *per_subplot_kw* " + "but not in the mosaic." + ) + return ret + + def _set_artist_props(self, a): + if a != self: + a.set_figure(self) + a.stale_callback = _stale_figure_callback + a.set_transform(self.transSubfigure) + + +@_docstring.interpd +class SubFigure(FigureBase): + """ + Logical figure that can be placed inside a figure. + + See :ref:`figure-api-subfigure` for an index of methods on this class. + Typically instantiated using `.Figure.add_subfigure` or + `.SubFigure.add_subfigure`, or `.SubFigure.subfigures`. A subfigure has + the same methods as a figure except for those particularly tied to the size + or dpi of the figure, and is confined to a prescribed region of the figure. + For example the following puts two subfigures side-by-side:: + + fig = plt.figure() + sfigs = fig.subfigures(1, 2) + axsL = sfigs[0].subplots(1, 2) + axsR = sfigs[1].subplots(2, 1) + + See :doc:`/gallery/subplots_axes_and_figures/subfigures` + + .. note:: + The *subfigure* concept is new in v3.4, and the API is still provisional. + """ + + def __init__(self, parent, subplotspec, *, + facecolor=None, + edgecolor=None, + linewidth=0.0, + frameon=None, + **kwargs): + """ + Parameters + ---------- + parent : `.Figure` or `.SubFigure` + Figure or subfigure that contains the SubFigure. SubFigures + can be nested. + + subplotspec : `.gridspec.SubplotSpec` + Defines the region in a parent gridspec where the subfigure will + be placed. + + facecolor : default: ``"none"`` + The figure patch face color; transparent by default. + + edgecolor : default: :rc:`figure.edgecolor` + The figure patch edge color. + + linewidth : float + The linewidth of the frame (i.e. the edge linewidth of the figure + patch). + + frameon : bool, default: :rc:`figure.frameon` + If ``False``, suppress drawing the figure background patch. + + Other Parameters + ---------------- + **kwargs : `.SubFigure` properties, optional + + %(SubFigure:kwdoc)s + """ + super().__init__(**kwargs) + if facecolor is None: + facecolor = "none" + if edgecolor is None: + edgecolor = mpl.rcParams['figure.edgecolor'] + if frameon is None: + frameon = mpl.rcParams['figure.frameon'] + + self._subplotspec = subplotspec + self._parent = parent + self.figure = parent.figure + + # subfigures use the parent axstack + self._axstack = parent._axstack + self.subplotpars = parent.subplotpars + self.dpi_scale_trans = parent.dpi_scale_trans + self._axobservers = parent._axobservers + self.canvas = parent.canvas + self.transFigure = parent.transFigure + self.bbox_relative = Bbox.null() + self._redo_transform_rel_fig() + self.figbbox = self._parent.figbbox + self.bbox = TransformedBbox(self.bbox_relative, + self._parent.transSubfigure) + self.transSubfigure = BboxTransformTo(self.bbox) + + self.patch = Rectangle( + xy=(0, 0), width=1, height=1, visible=frameon, + facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth, + # Don't let the figure patch influence bbox calculation. + in_layout=False, transform=self.transSubfigure) + self._set_artist_props(self.patch) + self.patch.set_antialiased(False) + + @property + def dpi(self): + return self._parent.dpi + + @dpi.setter + def dpi(self, value): + self._parent.dpi = value + + def get_dpi(self): + """ + Return the resolution of the parent figure in dots-per-inch as a float. + """ + return self._parent.dpi + + def set_dpi(self, val): + """ + Set the resolution of parent figure in dots-per-inch. + + Parameters + ---------- + val : float + """ + self._parent.dpi = val + self.stale = True + + def _get_renderer(self): + return self._parent._get_renderer() + + def _redo_transform_rel_fig(self, bbox=None): + """ + Make the transSubfigure bbox relative to Figure transform. + + Parameters + ---------- + bbox : bbox or None + If not None, then the bbox is used for relative bounding box. + Otherwise, it is calculated from the subplotspec. + """ + if bbox is not None: + self.bbox_relative.p0 = bbox.p0 + self.bbox_relative.p1 = bbox.p1 + return + # need to figure out *where* this subplotspec is. + gs = self._subplotspec.get_gridspec() + wr = np.asarray(gs.get_width_ratios()) + hr = np.asarray(gs.get_height_ratios()) + dx = wr[self._subplotspec.colspan].sum() / wr.sum() + dy = hr[self._subplotspec.rowspan].sum() / hr.sum() + x0 = wr[:self._subplotspec.colspan.start].sum() / wr.sum() + y0 = 1 - hr[:self._subplotspec.rowspan.stop].sum() / hr.sum() + self.bbox_relative.p0 = (x0, y0) + self.bbox_relative.p1 = (x0 + dx, y0 + dy) + + def get_constrained_layout(self): + """ + Return whether constrained layout is being used. + + See :ref:`constrainedlayout_guide`. + """ + return self._parent.get_constrained_layout() + + def get_constrained_layout_pads(self, relative=False): + """ + Get padding for ``constrained_layout``. + + Returns a list of ``w_pad, h_pad`` in inches and + ``wspace`` and ``hspace`` as fractions of the subplot. + + See :ref:`constrainedlayout_guide`. + + Parameters + ---------- + relative : bool + If `True`, then convert from inches to figure relative. + """ + return self._parent.get_constrained_layout_pads(relative=relative) + + def get_layout_engine(self): + return self._parent.get_layout_engine() + + @property + def axes(self): + """ + List of Axes in the SubFigure. You can access and modify the Axes + in the SubFigure through this list. + + Modifying this list has no effect. Instead, use `~.SubFigure.add_axes`, + `~.SubFigure.add_subplot` or `~.SubFigure.delaxes` to add or remove an + Axes. + + Note: The `.SubFigure.axes` property and `~.SubFigure.get_axes` method + are equivalent. + """ + return self._localaxes[:] + + get_axes = axes.fget + + def draw(self, renderer): + # docstring inherited + + # draw the figure bounding box, perhaps none for white figure + if not self.get_visible(): + return + + artists = self._get_draw_artists(renderer) + + try: + renderer.open_group('subfigure', gid=self.get_gid()) + self.patch.draw(renderer) + mimage._draw_list_compositing_images( + renderer, self, artists, self.figure.suppressComposite) + renderer.close_group('subfigure') + + finally: + self.stale = False + + +@_docstring.interpd +class Figure(FigureBase): + """ + The top level container for all the plot elements. + + See `matplotlib.figure` for an index of class methods. + + Attributes + ---------- + patch + The `.Rectangle` instance representing the figure background patch. + + suppressComposite + For multiple images, the figure will make composite images + depending on the renderer option_image_nocomposite function. If + *suppressComposite* is a boolean, this will override the renderer. + """ + + # we want to cache the fonts and mathtext at a global level so that when + # multiple figures are created we can reuse them. This helps with a bug on + # windows where the creation of too many figures leads to too many open + # file handles and improves the performance of parsing mathtext. However, + # these global caches are not thread safe. The solution here is to let the + # Figure acquire a shared lock at the start of the draw, and release it when it + # is done. This allows multiple renderers to share the cached fonts and + # parsed text, but only one figure can draw at a time and so the font cache + # and mathtext cache are used by only one renderer at a time. + + _render_lock = threading.RLock() + + def __str__(self): + return "Figure(%gx%g)" % tuple(self.bbox.size) + + def __repr__(self): + return "<{clsname} size {h:g}x{w:g} with {naxes} Axes>".format( + clsname=self.__class__.__name__, + h=self.bbox.size[0], w=self.bbox.size[1], + naxes=len(self.axes), + ) + + def __init__(self, + figsize=None, + dpi=None, + *, + facecolor=None, + edgecolor=None, + linewidth=0.0, + frameon=None, + subplotpars=None, # rc figure.subplot.* + tight_layout=None, # rc figure.autolayout + constrained_layout=None, # rc figure.constrained_layout.use + layout=None, + **kwargs + ): + """ + Parameters + ---------- + figsize : 2-tuple of floats, default: :rc:`figure.figsize` + Figure dimension ``(width, height)`` in inches. + + dpi : float, default: :rc:`figure.dpi` + Dots per inch. + + facecolor : default: :rc:`figure.facecolor` + The figure patch facecolor. + + edgecolor : default: :rc:`figure.edgecolor` + The figure patch edge color. + + linewidth : float + The linewidth of the frame (i.e. the edge linewidth of the figure + patch). + + frameon : bool, default: :rc:`figure.frameon` + If ``False``, suppress drawing the figure background patch. + + subplotpars : `~matplotlib.gridspec.SubplotParams` + Subplot parameters. If not given, the default subplot + parameters :rc:`figure.subplot.*` are used. + + tight_layout : bool or dict, default: :rc:`figure.autolayout` + Whether to use the tight layout mechanism. See `.set_tight_layout`. + + .. admonition:: Discouraged + + The use of this parameter is discouraged. Please use + ``layout='tight'`` instead for the common case of + ``tight_layout=True`` and use `.set_tight_layout` otherwise. + + constrained_layout : bool, default: :rc:`figure.constrained_layout.use` + This is equal to ``layout='constrained'``. + + .. admonition:: Discouraged + + The use of this parameter is discouraged. Please use + ``layout='constrained'`` instead. + + layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, \ +None}, default: None + The layout mechanism for positioning of plot elements to avoid + overlapping Axes decorations (labels, ticks, etc). Note that + layout managers can have significant performance penalties. + + - 'constrained': The constrained layout solver adjusts Axes sizes + to avoid overlapping Axes decorations. Can handle complex plot + layouts and colorbars, and is thus recommended. + + See :ref:`constrainedlayout_guide` for examples. + + - 'compressed': uses the same algorithm as 'constrained', but + removes extra space between fixed-aspect-ratio Axes. Best for + simple grids of Axes. + + - 'tight': Use the tight layout mechanism. This is a relatively + simple algorithm that adjusts the subplot parameters so that + decorations do not overlap. + + See :ref:`tight_layout_guide` for examples. + + - 'none': Do not use a layout engine. + + - A `.LayoutEngine` instance. Builtin layout classes are + `.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily + accessible by 'constrained' and 'tight'. Passing an instance + allows third parties to provide their own layout engine. + + If not given, fall back to using the parameters *tight_layout* and + *constrained_layout*, including their config defaults + :rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`. + + Other Parameters + ---------------- + **kwargs : `.Figure` properties, optional + + %(Figure:kwdoc)s + """ + super().__init__(**kwargs) + self.figure = self + self._layout_engine = None + + if layout is not None: + if (tight_layout is not None): + _api.warn_external( + "The Figure parameters 'layout' and 'tight_layout' cannot " + "be used together. Please use 'layout' only.") + if (constrained_layout is not None): + _api.warn_external( + "The Figure parameters 'layout' and 'constrained_layout' " + "cannot be used together. Please use 'layout' only.") + self.set_layout_engine(layout=layout) + elif tight_layout is not None: + if constrained_layout is not None: + _api.warn_external( + "The Figure parameters 'tight_layout' and " + "'constrained_layout' cannot be used together. Please use " + "'layout' parameter") + self.set_layout_engine(layout='tight') + if isinstance(tight_layout, dict): + self.get_layout_engine().set(**tight_layout) + elif constrained_layout is not None: + if isinstance(constrained_layout, dict): + self.set_layout_engine(layout='constrained') + self.get_layout_engine().set(**constrained_layout) + elif constrained_layout: + self.set_layout_engine(layout='constrained') + + else: + # everything is None, so use default: + self.set_layout_engine(layout=layout) + + # Callbacks traditionally associated with the canvas (and exposed with + # a proxy property), but that actually need to be on the figure for + # pickling. + self._canvas_callbacks = cbook.CallbackRegistry( + signals=FigureCanvasBase.events) + connect = self._canvas_callbacks._connect_picklable + self._mouse_key_ids = [ + connect('key_press_event', backend_bases._key_handler), + connect('key_release_event', backend_bases._key_handler), + connect('key_release_event', backend_bases._key_handler), + connect('button_press_event', backend_bases._mouse_handler), + connect('button_release_event', backend_bases._mouse_handler), + connect('scroll_event', backend_bases._mouse_handler), + connect('motion_notify_event', backend_bases._mouse_handler), + ] + self._button_pick_id = connect('button_press_event', self.pick) + self._scroll_pick_id = connect('scroll_event', self.pick) + + if figsize is None: + figsize = mpl.rcParams['figure.figsize'] + if dpi is None: + dpi = mpl.rcParams['figure.dpi'] + if facecolor is None: + facecolor = mpl.rcParams['figure.facecolor'] + if edgecolor is None: + edgecolor = mpl.rcParams['figure.edgecolor'] + if frameon is None: + frameon = mpl.rcParams['figure.frameon'] + + if not np.isfinite(figsize).all() or (np.array(figsize) < 0).any(): + raise ValueError('figure size must be positive finite not ' + f'{figsize}') + self.bbox_inches = Bbox.from_bounds(0, 0, *figsize) + + self.dpi_scale_trans = Affine2D().scale(dpi) + # do not use property as it will trigger + self._dpi = dpi + self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans) + self.figbbox = self.bbox + self.transFigure = BboxTransformTo(self.bbox) + self.transSubfigure = self.transFigure + + self.patch = Rectangle( + xy=(0, 0), width=1, height=1, visible=frameon, + facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth, + # Don't let the figure patch influence bbox calculation. + in_layout=False) + self._set_artist_props(self.patch) + self.patch.set_antialiased(False) + + FigureCanvasBase(self) # Set self.canvas. + + if subplotpars is None: + subplotpars = SubplotParams() + + self.subplotpars = subplotpars + + self._axstack = _AxesStack() # track all figure Axes and current Axes + self.clear() + + def pick(self, mouseevent): + if not self.canvas.widgetlock.locked(): + super().pick(mouseevent) + + def _check_layout_engines_compat(self, old, new): + """ + Helper for set_layout engine + + If the figure has used the old engine and added a colorbar then the + value of colorbar_gridspec must be the same on the new engine. + """ + if old is None or new is None: + return True + if old.colorbar_gridspec == new.colorbar_gridspec: + return True + # colorbar layout different, so check if any colorbars are on the + # figure... + for ax in self.axes: + if hasattr(ax, '_colorbar'): + # colorbars list themselves as a colorbar. + return False + return True + + def set_layout_engine(self, layout=None, **kwargs): + """ + Set the layout engine for this figure. + + Parameters + ---------- + layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None} + + - 'constrained' will use `~.ConstrainedLayoutEngine` + - 'compressed' will also use `~.ConstrainedLayoutEngine`, but with + a correction that attempts to make a good layout for fixed-aspect + ratio Axes. + - 'tight' uses `~.TightLayoutEngine` + - 'none' removes layout engine. + + If a `.LayoutEngine` instance, that instance will be used. + + If `None`, the behavior is controlled by :rc:`figure.autolayout` + (which if `True` behaves as if 'tight' was passed) and + :rc:`figure.constrained_layout.use` (which if `True` behaves as if + 'constrained' was passed). If both are `True`, + :rc:`figure.autolayout` takes priority. + + Users and libraries can define their own layout engines and pass + the instance directly as well. + + **kwargs + The keyword arguments are passed to the layout engine to set things + like padding and margin sizes. Only used if *layout* is a string. + + """ + if layout is None: + if mpl.rcParams['figure.autolayout']: + layout = 'tight' + elif mpl.rcParams['figure.constrained_layout.use']: + layout = 'constrained' + else: + self._layout_engine = None + return + if layout == 'tight': + new_layout_engine = TightLayoutEngine(**kwargs) + elif layout == 'constrained': + new_layout_engine = ConstrainedLayoutEngine(**kwargs) + elif layout == 'compressed': + new_layout_engine = ConstrainedLayoutEngine(compress=True, + **kwargs) + elif layout == 'none': + if self._layout_engine is not None: + new_layout_engine = PlaceHolderLayoutEngine( + self._layout_engine.adjust_compatible, + self._layout_engine.colorbar_gridspec + ) + else: + new_layout_engine = None + elif isinstance(layout, LayoutEngine): + new_layout_engine = layout + else: + raise ValueError(f"Invalid value for 'layout': {layout!r}") + + if self._check_layout_engines_compat(self._layout_engine, + new_layout_engine): + self._layout_engine = new_layout_engine + else: + raise RuntimeError('Colorbar layout of new layout engine not ' + 'compatible with old engine, and a colorbar ' + 'has been created. Engine not changed.') + + def get_layout_engine(self): + return self._layout_engine + + # TODO: I'd like to dynamically add the _repr_html_ method + # to the figure in the right context, but then IPython doesn't + # use it, for some reason. + + def _repr_html_(self): + # We can't use "isinstance" here, because then we'd end up importing + # webagg unconditionally. + if 'WebAgg' in type(self.canvas).__name__: + from matplotlib.backends import backend_webagg + return backend_webagg.ipython_inline_display(self) + + def show(self, warn=True): + """ + If using a GUI backend with pyplot, display the figure window. + + If the figure was not created using `~.pyplot.figure`, it will lack + a `~.backend_bases.FigureManagerBase`, and this method will raise an + AttributeError. + + .. warning:: + + This does not manage an GUI event loop. Consequently, the figure + may only be shown briefly or not shown at all if you or your + environment are not managing an event loop. + + Use cases for `.Figure.show` include running this from a GUI + application (where there is persistently an event loop running) or + from a shell, like IPython, that install an input hook to allow the + interactive shell to accept input while the figure is also being + shown and interactive. Some, but not all, GUI toolkits will + register an input hook on import. See :ref:`cp_integration` for + more details. + + If you're in a shell without input hook integration or executing a + python script, you should use `matplotlib.pyplot.show` with + ``block=True`` instead, which takes care of starting and running + the event loop for you. + + Parameters + ---------- + warn : bool, default: True + If ``True`` and we are not running headless (i.e. on Linux with an + unset DISPLAY), issue warning when called on a non-GUI backend. + + """ + if self.canvas.manager is None: + raise AttributeError( + "Figure.show works only for figures managed by pyplot, " + "normally created by pyplot.figure()") + try: + self.canvas.manager.show() + except NonGuiException as exc: + if warn: + _api.warn_external(str(exc)) + + @property + def axes(self): + """ + List of Axes in the Figure. You can access and modify the Axes in the + Figure through this list. + + Do not modify the list itself. Instead, use `~Figure.add_axes`, + `~.Figure.add_subplot` or `~.Figure.delaxes` to add or remove an Axes. + + Note: The `.Figure.axes` property and `~.Figure.get_axes` method are + equivalent. + """ + return self._axstack.as_list() + + get_axes = axes.fget + + def _get_renderer(self): + if hasattr(self.canvas, 'get_renderer'): + return self.canvas.get_renderer() + else: + return _get_renderer(self) + + def _get_dpi(self): + return self._dpi + + def _set_dpi(self, dpi, forward=True): + """ + Parameters + ---------- + dpi : float + + forward : bool + Passed on to `~.Figure.set_size_inches` + """ + if dpi == self._dpi: + # We don't want to cause undue events in backends. + return + self._dpi = dpi + self.dpi_scale_trans.clear().scale(dpi) + w, h = self.get_size_inches() + self.set_size_inches(w, h, forward=forward) + + dpi = property(_get_dpi, _set_dpi, doc="The resolution in dots per inch.") + + def get_tight_layout(self): + """Return whether `.Figure.tight_layout` is called when drawing.""" + return isinstance(self.get_layout_engine(), TightLayoutEngine) + + @_api.deprecated("3.6", alternative="set_layout_engine", + pending=True) + def set_tight_layout(self, tight): + """ + Set whether and how `.Figure.tight_layout` is called when drawing. + + Parameters + ---------- + tight : bool or dict with keys "pad", "w_pad", "h_pad", "rect" or None + If a bool, sets whether to call `.Figure.tight_layout` upon drawing. + If ``None``, use :rc:`figure.autolayout` instead. + If a dict, pass it as kwargs to `.Figure.tight_layout`, overriding the + default paddings. + """ + if tight is None: + tight = mpl.rcParams['figure.autolayout'] + _tight = 'tight' if bool(tight) else 'none' + _tight_parameters = tight if isinstance(tight, dict) else {} + self.set_layout_engine(_tight, **_tight_parameters) + self.stale = True + + def get_constrained_layout(self): + """ + Return whether constrained layout is being used. + + See :ref:`constrainedlayout_guide`. + """ + return isinstance(self.get_layout_engine(), ConstrainedLayoutEngine) + + @_api.deprecated("3.6", alternative="set_layout_engine('constrained')", + pending=True) + def set_constrained_layout(self, constrained): + """ + Set whether ``constrained_layout`` is used upon drawing. + + If None, :rc:`figure.constrained_layout.use` value will be used. + + When providing a dict containing the keys ``w_pad``, ``h_pad`` + the default ``constrained_layout`` paddings will be + overridden. These pads are in inches and default to 3.0/72.0. + ``w_pad`` is the width padding and ``h_pad`` is the height padding. + + Parameters + ---------- + constrained : bool or dict or None + """ + if constrained is None: + constrained = mpl.rcParams['figure.constrained_layout.use'] + _constrained = 'constrained' if bool(constrained) else 'none' + _parameters = constrained if isinstance(constrained, dict) else {} + self.set_layout_engine(_constrained, **_parameters) + self.stale = True + + @_api.deprecated( + "3.6", alternative="figure.get_layout_engine().set()", + pending=True) + def set_constrained_layout_pads(self, **kwargs): + """ + Set padding for ``constrained_layout``. + + Tip: The parameters can be passed from a dictionary by using + ``fig.set_constrained_layout(**pad_dict)``. + + See :ref:`constrainedlayout_guide`. + + Parameters + ---------- + w_pad : float, default: :rc:`figure.constrained_layout.w_pad` + Width padding in inches. This is the pad around Axes + and is meant to make sure there is enough room for fonts to + look good. Defaults to 3 pts = 0.04167 inches + + h_pad : float, default: :rc:`figure.constrained_layout.h_pad` + Height padding in inches. Defaults to 3 pts. + + wspace : float, default: :rc:`figure.constrained_layout.wspace` + Width padding between subplots, expressed as a fraction of the + subplot width. The total padding ends up being w_pad + wspace. + + hspace : float, default: :rc:`figure.constrained_layout.hspace` + Height padding between subplots, expressed as a fraction of the + subplot width. The total padding ends up being h_pad + hspace. + + """ + if isinstance(self.get_layout_engine(), ConstrainedLayoutEngine): + self.get_layout_engine().set(**kwargs) + + @_api.deprecated("3.6", alternative="fig.get_layout_engine().get()", + pending=True) + def get_constrained_layout_pads(self, relative=False): + """ + Get padding for ``constrained_layout``. + + Returns a list of ``w_pad, h_pad`` in inches and + ``wspace`` and ``hspace`` as fractions of the subplot. + All values are None if ``constrained_layout`` is not used. + + See :ref:`constrainedlayout_guide`. + + Parameters + ---------- + relative : bool + If `True`, then convert from inches to figure relative. + """ + if not isinstance(self.get_layout_engine(), ConstrainedLayoutEngine): + return None, None, None, None + info = self.get_layout_engine().get() + w_pad = info['w_pad'] + h_pad = info['h_pad'] + wspace = info['wspace'] + hspace = info['hspace'] + + if relative and (w_pad is not None or h_pad is not None): + renderer = self._get_renderer() + dpi = renderer.dpi + w_pad = w_pad * dpi / renderer.width + h_pad = h_pad * dpi / renderer.height + + return w_pad, h_pad, wspace, hspace + + def set_canvas(self, canvas): + """ + Set the canvas that contains the figure + + Parameters + ---------- + canvas : FigureCanvas + """ + self.canvas = canvas + + @_docstring.interpd + def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None, + vmin=None, vmax=None, origin=None, resize=False, **kwargs): + """ + Add a non-resampled image to the figure. + + The image is attached to the lower or upper left corner depending on + *origin*. + + Parameters + ---------- + X + The image data. This is an array of one of the following shapes: + + - (M, N): an image with scalar data. Color-mapping is controlled + by *cmap*, *norm*, *vmin*, and *vmax*. + - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). + - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), + i.e. including transparency. + + xo, yo : int + The *x*/*y* image offset in pixels. + + alpha : None or float + The alpha blending value. + + %(cmap_doc)s + + This parameter is ignored if *X* is RGB(A). + + %(norm_doc)s + + This parameter is ignored if *X* is RGB(A). + + %(vmin_vmax_doc)s + + This parameter is ignored if *X* is RGB(A). + + origin : {'upper', 'lower'}, default: :rc:`image.origin` + Indicates where the [0, 0] index of the array is in the upper left + or lower left corner of the Axes. + + resize : bool + If *True*, resize the figure to match the given image size. + + Returns + ------- + `matplotlib.image.FigureImage` + + Other Parameters + ---------------- + **kwargs + Additional kwargs are `.Artist` kwargs passed on to `.FigureImage`. + + Notes + ----- + figimage complements the Axes image (`~matplotlib.axes.Axes.imshow`) + which will be resampled to fit the current Axes. If you want + a resampled image to fill the entire figure, you can define an + `~matplotlib.axes.Axes` with extent [0, 0, 1, 1]. + + Examples + -------- + :: + + f = plt.figure() + nx = int(f.get_figwidth() * f.dpi) + ny = int(f.get_figheight() * f.dpi) + data = np.random.random((ny, nx)) + f.figimage(data) + plt.show() + """ + if resize: + dpi = self.get_dpi() + figsize = [x / dpi for x in (X.shape[1], X.shape[0])] + self.set_size_inches(figsize, forward=True) + + im = mimage.FigureImage(self, cmap=cmap, norm=norm, + offsetx=xo, offsety=yo, + origin=origin, **kwargs) + im.stale_callback = _stale_figure_callback + + im.set_array(X) + im.set_alpha(alpha) + if norm is None: + im.set_clim(vmin, vmax) + self.images.append(im) + im._remove_method = self.images.remove + self.stale = True + return im + + def set_size_inches(self, w, h=None, forward=True): + """ + Set the figure size in inches. + + Call signatures:: + + fig.set_size_inches(w, h) # OR + fig.set_size_inches((w, h)) + + Parameters + ---------- + w : (float, float) or float + Width and height in inches (if height not specified as a separate + argument) or width. + h : float + Height in inches. + forward : bool, default: True + If ``True``, the canvas size is automatically updated, e.g., + you can resize the figure window from the shell. + + See Also + -------- + matplotlib.figure.Figure.get_size_inches + matplotlib.figure.Figure.set_figwidth + matplotlib.figure.Figure.set_figheight + + Notes + ----- + To transform from pixels to inches divide by `Figure.dpi`. + """ + if h is None: # Got called with a single pair as argument. + w, h = w + size = np.array([w, h]) + if not np.isfinite(size).all() or (size < 0).any(): + raise ValueError(f'figure size must be positive finite not {size}') + self.bbox_inches.p1 = size + if forward: + manager = self.canvas.manager + if manager is not None: + manager.resize(*(size * self.dpi).astype(int)) + self.stale = True + + def get_size_inches(self): + """ + Return the current size of the figure in inches. + + Returns + ------- + ndarray + The size (width, height) of the figure in inches. + + See Also + -------- + matplotlib.figure.Figure.set_size_inches + matplotlib.figure.Figure.get_figwidth + matplotlib.figure.Figure.get_figheight + + Notes + ----- + The size in pixels can be obtained by multiplying with `Figure.dpi`. + """ + return np.array(self.bbox_inches.p1) + + def get_figwidth(self): + """Return the figure width in inches.""" + return self.bbox_inches.width + + def get_figheight(self): + """Return the figure height in inches.""" + return self.bbox_inches.height + + def get_dpi(self): + """Return the resolution in dots per inch as a float.""" + return self.dpi + + def set_dpi(self, val): + """ + Set the resolution of the figure in dots-per-inch. + + Parameters + ---------- + val : float + """ + self.dpi = val + self.stale = True + + def set_figwidth(self, val, forward=True): + """ + Set the width of the figure in inches. + + Parameters + ---------- + val : float + forward : bool + See `set_size_inches`. + + See Also + -------- + matplotlib.figure.Figure.set_figheight + matplotlib.figure.Figure.set_size_inches + """ + self.set_size_inches(val, self.get_figheight(), forward=forward) + + def set_figheight(self, val, forward=True): + """ + Set the height of the figure in inches. + + Parameters + ---------- + val : float + forward : bool + See `set_size_inches`. + + See Also + -------- + matplotlib.figure.Figure.set_figwidth + matplotlib.figure.Figure.set_size_inches + """ + self.set_size_inches(self.get_figwidth(), val, forward=forward) + + def clear(self, keep_observers=False): + # docstring inherited + super().clear(keep_observers=keep_observers) + # FigureBase.clear does not clear toolbars, as + # only Figure can have toolbars + toolbar = self.canvas.toolbar + if toolbar is not None: + toolbar.update() + + @_finalize_rasterization + @allow_rasterization + def draw(self, renderer): + # docstring inherited + if not self.get_visible(): + return + + with self._render_lock: + + artists = self._get_draw_artists(renderer) + try: + renderer.open_group('figure', gid=self.get_gid()) + if self.axes and self.get_layout_engine() is not None: + try: + self.get_layout_engine().execute(self) + except ValueError: + pass + # ValueError can occur when resizing a window. + + self.patch.draw(renderer) + mimage._draw_list_compositing_images( + renderer, self, artists, self.suppressComposite) + + renderer.close_group('figure') + finally: + self.stale = False + + DrawEvent("draw_event", self.canvas, renderer)._process() + + def draw_without_rendering(self): + """ + Draw the figure with no output. Useful to get the final size of + artists that require a draw before their size is known (e.g. text). + """ + renderer = _get_renderer(self) + with renderer._draw_disabled(): + self.draw(renderer) + + def draw_artist(self, a): + """ + Draw `.Artist` *a* only. + """ + a.draw(self.canvas.get_renderer()) + + def __getstate__(self): + state = super().__getstate__() + + # The canvas cannot currently be pickled, but this has the benefit + # of meaning that a figure can be detached from one canvas, and + # re-attached to another. + state.pop("canvas") + + # discard any changes to the dpi due to pixel ratio changes + state["_dpi"] = state.get('_original_dpi', state['_dpi']) + + # add version information to the state + state['__mpl_version__'] = mpl.__version__ + + # check whether the figure manager (if any) is registered with pyplot + from matplotlib import _pylab_helpers + if self.canvas.manager in _pylab_helpers.Gcf.figs.values(): + state['_restore_to_pylab'] = True + return state + + def __setstate__(self, state): + version = state.pop('__mpl_version__') + restore_to_pylab = state.pop('_restore_to_pylab', False) + + if version != mpl.__version__: + _api.warn_external( + f"This figure was saved with matplotlib version {version} and " + f"loaded with {mpl.__version__} so may not function correctly." + ) + self.__dict__ = state + + # re-initialise some of the unstored state information + FigureCanvasBase(self) # Set self.canvas. + + if restore_to_pylab: + # lazy import to avoid circularity + import matplotlib.pyplot as plt + import matplotlib._pylab_helpers as pylab_helpers + allnums = plt.get_fignums() + num = max(allnums) + 1 if allnums else 1 + backend = plt._get_backend_mod() + mgr = backend.new_figure_manager_given_figure(num, self) + pylab_helpers.Gcf._set_new_active_manager(mgr) + plt.draw_if_interactive() + + self.stale = True + + def add_axobserver(self, func): + """Whenever the Axes state change, ``func(self)`` will be called.""" + # Connect a wrapper lambda and not func itself, to avoid it being + # weakref-collected. + self._axobservers.connect("_axes_change_event", lambda arg: func(arg)) + + def savefig(self, fname, *, transparent=None, **kwargs): + """ + Save the current figure as an image or vector graphic to a file. + + Call signature:: + + savefig(fname, *, transparent=None, dpi='figure', format=None, + metadata=None, bbox_inches=None, pad_inches=0.1, + facecolor='auto', edgecolor='auto', backend=None, + **kwargs + ) + + The available output formats depend on the backend being used. + + Parameters + ---------- + fname : str or path-like or binary file-like + A path, or a Python file-like object, or + possibly some backend-dependent object such as + `matplotlib.backends.backend_pdf.PdfPages`. + + If *format* is set, it determines the output format, and the file + is saved as *fname*. Note that *fname* is used verbatim, and there + is no attempt to make the extension, if any, of *fname* match + *format*, and no extension is appended. + + If *format* is not set, then the format is inferred from the + extension of *fname*, if there is one. If *format* is not + set and *fname* has no extension, then the file is saved with + :rc:`savefig.format` and the appropriate extension is appended to + *fname*. + + Other Parameters + ---------------- + transparent : bool, default: :rc:`savefig.transparent` + If *True*, the Axes patches will all be transparent; the + Figure patch will also be transparent unless *facecolor* + and/or *edgecolor* are specified via kwargs. + + If *False* has no effect and the color of the Axes and + Figure patches are unchanged (unless the Figure patch + is specified via the *facecolor* and/or *edgecolor* keyword + arguments in which case those colors are used). + + The transparency of these patches will be restored to their + original values upon exit of this function. + + This is useful, for example, for displaying + a plot on top of a colored background on a web page. + + dpi : float or 'figure', default: :rc:`savefig.dpi` + The resolution in dots per inch. If 'figure', use the figure's + dpi value. + + format : str + The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when + this is unset is documented under *fname*. + + metadata : dict, optional + Key/value pairs to store in the image metadata. The supported keys + and defaults depend on the image format and backend: + + - 'png' with Agg backend: See the parameter ``metadata`` of + `~.FigureCanvasAgg.print_png`. + - 'pdf' with pdf backend: See the parameter ``metadata`` of + `~.backend_pdf.PdfPages`. + - 'svg' with svg backend: See the parameter ``metadata`` of + `~.FigureCanvasSVG.print_svg`. + - 'eps' and 'ps' with PS backend: Only 'Creator' is supported. + + Not supported for 'pgf', 'raw', and 'rgba' as those formats do not support + embedding metadata. + Does not currently support 'jpg', 'tiff', or 'webp', but may include + embedding EXIF metadata in the future. + + bbox_inches : str or `.Bbox`, default: :rc:`savefig.bbox` + Bounding box in inches: only the given portion of the figure is + saved. If 'tight', try to figure out the tight bbox of the figure. + + pad_inches : float or 'layout', default: :rc:`savefig.pad_inches` + Amount of padding in inches around the figure when bbox_inches is + 'tight'. If 'layout' use the padding from the constrained or + compressed layout engine; ignored if one of those engines is not in + use. + + facecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.facecolor` + The facecolor of the figure. If 'auto', use the current figure + facecolor. + + edgecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.edgecolor` + The edgecolor of the figure. If 'auto', use the current figure + edgecolor. + + backend : str, optional + Use a non-default backend to render the file, e.g. to render a + png file with the "cairo" backend rather than the default "agg", + or a pdf file with the "pgf" backend rather than the default + "pdf". Note that the default backend is normally sufficient. See + :ref:`the-builtin-backends` for a list of valid backends for each + file format. Custom backends can be referenced as "module://...". + + orientation : {'landscape', 'portrait'} + Currently only supported by the postscript backend. + + papertype : str + One of 'letter', 'legal', 'executive', 'ledger', 'a0' through + 'a10', 'b0' through 'b10'. Only supported for postscript + output. + + bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional + A list of extra artists that will be considered when the + tight bbox is calculated. + + pil_kwargs : dict, optional + Additional keyword arguments that are passed to + `PIL.Image.Image.save` when saving the figure. + + """ + + kwargs.setdefault('dpi', mpl.rcParams['savefig.dpi']) + if transparent is None: + transparent = mpl.rcParams['savefig.transparent'] + + with ExitStack() as stack: + if transparent: + def _recursively_make_subfig_transparent(exit_stack, subfig): + exit_stack.enter_context( + subfig.patch._cm_set( + facecolor="none", edgecolor="none")) + for ax in subfig.axes: + exit_stack.enter_context( + ax.patch._cm_set( + facecolor="none", edgecolor="none")) + for sub_subfig in subfig.subfigs: + _recursively_make_subfig_transparent( + exit_stack, sub_subfig) + + def _recursively_make_axes_transparent(exit_stack, ax): + exit_stack.enter_context( + ax.patch._cm_set(facecolor="none", edgecolor="none")) + for child_ax in ax.child_axes: + exit_stack.enter_context( + child_ax.patch._cm_set( + facecolor="none", edgecolor="none")) + for child_childax in ax.child_axes: + _recursively_make_axes_transparent( + exit_stack, child_childax) + + kwargs.setdefault('facecolor', 'none') + kwargs.setdefault('edgecolor', 'none') + # set subfigure to appear transparent in printed image + for subfig in self.subfigs: + _recursively_make_subfig_transparent(stack, subfig) + # set Axes to be transparent + for ax in self.axes: + _recursively_make_axes_transparent(stack, ax) + self.canvas.print_figure(fname, **kwargs) + + def ginput(self, n=1, timeout=30, show_clicks=True, + mouse_add=MouseButton.LEFT, + mouse_pop=MouseButton.RIGHT, + mouse_stop=MouseButton.MIDDLE): + """ + Blocking call to interact with a figure. + + Wait until the user clicks *n* times on the figure, and return the + coordinates of each click in a list. + + There are three possible interactions: + + - Add a point. + - Remove the most recently added point. + - Stop the interaction and return the points added so far. + + The actions are assigned to mouse buttons via the arguments + *mouse_add*, *mouse_pop* and *mouse_stop*. + + Parameters + ---------- + n : int, default: 1 + Number of mouse clicks to accumulate. If negative, accumulate + clicks until the input is terminated manually. + timeout : float, default: 30 seconds + Number of seconds to wait before timing out. If zero or negative + will never time out. + show_clicks : bool, default: True + If True, show a red cross at the location of each click. + mouse_add : `.MouseButton` or None, default: `.MouseButton.LEFT` + Mouse button used to add points. + mouse_pop : `.MouseButton` or None, default: `.MouseButton.RIGHT` + Mouse button used to remove the most recently added point. + mouse_stop : `.MouseButton` or None, default: `.MouseButton.MIDDLE` + Mouse button used to stop input. + + Returns + ------- + list of tuples + A list of the clicked (x, y) coordinates. + + Notes + ----- + The keyboard can also be used to select points in case your mouse + does not have one or more of the buttons. The delete and backspace + keys act like right-clicking (i.e., remove last point), the enter key + terminates input and any other key (not already used by the window + manager) selects a point. + """ + clicks = [] + marks = [] + + def handler(event): + is_button = event.name == "button_press_event" + is_key = event.name == "key_press_event" + # Quit (even if not in infinite mode; this is consistent with + # MATLAB and sometimes quite useful, but will require the user to + # test how many points were actually returned before using data). + if (is_button and event.button == mouse_stop + or is_key and event.key in ["escape", "enter"]): + self.canvas.stop_event_loop() + # Pop last click. + elif (is_button and event.button == mouse_pop + or is_key and event.key in ["backspace", "delete"]): + if clicks: + clicks.pop() + if show_clicks: + marks.pop().remove() + self.canvas.draw() + # Add new click. + elif (is_button and event.button == mouse_add + # On macOS/gtk, some keys return None. + or is_key and event.key is not None): + if event.inaxes: + clicks.append((event.xdata, event.ydata)) + _log.info("input %i: %f, %f", + len(clicks), event.xdata, event.ydata) + if show_clicks: + line = mpl.lines.Line2D([event.xdata], [event.ydata], + marker="+", color="r") + event.inaxes.add_line(line) + marks.append(line) + self.canvas.draw() + if len(clicks) == n and n > 0: + self.canvas.stop_event_loop() + + _blocking_input.blocking_input_loop( + self, ["button_press_event", "key_press_event"], timeout, handler) + + # Cleanup. + for mark in marks: + mark.remove() + self.canvas.draw() + + return clicks + + def waitforbuttonpress(self, timeout=-1): + """ + Blocking call to interact with the figure. + + Wait for user input and return True if a key was pressed, False if a + mouse button was pressed and None if no input was given within + *timeout* seconds. Negative values deactivate *timeout*. + """ + event = None + + def handler(ev): + nonlocal event + event = ev + self.canvas.stop_event_loop() + + _blocking_input.blocking_input_loop( + self, ["button_press_event", "key_press_event"], timeout, handler) + + return None if event is None else event.name == "key_press_event" + + def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None): + """ + Adjust the padding between and around subplots. + + To exclude an artist on the Axes from the bounding box calculation + that determines the subplot parameters (i.e. legend, or annotation), + set ``a.set_in_layout(False)`` for that artist. + + Parameters + ---------- + pad : float, default: 1.08 + Padding between the figure edge and the edges of subplots, + as a fraction of the font size. + h_pad, w_pad : float, default: *pad* + Padding (height/width) between edges of adjacent subplots, + as a fraction of the font size. + rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1) + A rectangle in normalized figure coordinates into which the whole + subplots area (including labels) will fit. + + See Also + -------- + .Figure.set_layout_engine + .pyplot.tight_layout + """ + # note that here we do not permanently set the figures engine to + # tight_layout but rather just perform the layout in place and remove + # any previous engines. + engine = TightLayoutEngine(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) + try: + previous_engine = self.get_layout_engine() + self.set_layout_engine(engine) + engine.execute(self) + if previous_engine is not None and not isinstance( + previous_engine, (TightLayoutEngine, PlaceHolderLayoutEngine) + ): + _api.warn_external('The figure layout has changed to tight') + finally: + self.set_layout_engine('none') + + +def figaspect(arg): + """ + Calculate the width and height for a figure with a specified aspect ratio. + + While the height is taken from :rc:`figure.figsize`, the width is + adjusted to match the desired aspect ratio. Additionally, it is ensured + that the width is in the range [4., 16.] and the height is in the range + [2., 16.]. If necessary, the default height is adjusted to ensure this. + + Parameters + ---------- + arg : float or 2D array + If a float, this defines the aspect ratio (i.e. the ratio height / + width). + In case of an array the aspect ratio is number of rows / number of + columns, so that the array could be fitted in the figure undistorted. + + Returns + ------- + width, height : float + The figure size in inches. + + Notes + ----- + If you want to create an Axes within the figure, that still preserves the + aspect ratio, be sure to create it with equal width and height. See + examples below. + + Thanks to Fernando Perez for this function. + + Examples + -------- + Make a figure twice as tall as it is wide:: + + w, h = figaspect(2.) + fig = Figure(figsize=(w, h)) + ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) + ax.imshow(A, **kwargs) + + Make a figure with the proper aspect for an array:: + + A = rand(5, 3) + w, h = figaspect(A) + fig = Figure(figsize=(w, h)) + ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) + ax.imshow(A, **kwargs) + """ + + isarray = hasattr(arg, 'shape') and not np.isscalar(arg) + + # min/max sizes to respect when autoscaling. If John likes the idea, they + # could become rc parameters, for now they're hardwired. + figsize_min = np.array((4.0, 2.0)) # min length for width/height + figsize_max = np.array((16.0, 16.0)) # max length for width/height + + # Extract the aspect ratio of the array + if isarray: + nr, nc = arg.shape[:2] + arr_ratio = nr / nc + else: + arr_ratio = arg + + # Height of user figure defaults + fig_height = mpl.rcParams['figure.figsize'][1] + + # New size for the figure, keeping the aspect ratio of the caller + newsize = np.array((fig_height / arr_ratio, fig_height)) + + # Sanity checks, don't drop either dimension below figsize_min + newsize /= min(1.0, *(newsize / figsize_min)) + + # Avoid humongous windows as well + newsize /= max(1.0, *(newsize / figsize_max)) + + # Finally, if we have a really funky aspect ratio, break it but respect + # the min/max dimensions (we don't want figures 10 feet tall!) + newsize = np.clip(newsize, figsize_min, figsize_max) + return newsize diff --git a/venv/lib/python3.10/site-packages/matplotlib/figure.pyi b/venv/lib/python3.10/site-packages/matplotlib/figure.pyi new file mode 100644 index 00000000..eae21c26 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/figure.pyi @@ -0,0 +1,391 @@ +from collections.abc import Callable, Hashable, Iterable +import os +from typing import Any, IO, Literal, TypeVar, overload + +import numpy as np +from numpy.typing import ArrayLike + +from matplotlib.artist import Artist +from matplotlib.axes import Axes, SubplotBase +from matplotlib.backend_bases import ( + FigureCanvasBase, + MouseButton, + MouseEvent, + RendererBase, +) +from matplotlib.colors import Colormap, Normalize +from matplotlib.colorbar import Colorbar +from matplotlib.cm import ScalarMappable +from matplotlib.gridspec import GridSpec, SubplotSpec, SubplotParams as SubplotParams +from matplotlib.image import _ImageBase, FigureImage +from matplotlib.layout_engine import LayoutEngine +from matplotlib.legend import Legend +from matplotlib.lines import Line2D +from matplotlib.patches import Rectangle, Patch +from matplotlib.text import Text +from matplotlib.transforms import Affine2D, Bbox, BboxBase, Transform +from .typing import ColorType, HashableList + +_T = TypeVar("_T") + +class FigureBase(Artist): + artists: list[Artist] + lines: list[Line2D] + patches: list[Patch] + texts: list[Text] + images: list[_ImageBase] + legends: list[Legend] + subfigs: list[SubFigure] + stale: bool + suppressComposite: bool | None + def __init__(self, **kwargs) -> None: ... + def autofmt_xdate( + self, + bottom: float = ..., + rotation: int = ..., + ha: Literal["left", "center", "right"] = ..., + which: Literal["major", "minor", "both"] = ..., + ) -> None: ... + def get_children(self) -> list[Artist]: ... + def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ... + def suptitle(self, t: str, **kwargs) -> Text: ... + def get_suptitle(self) -> str: ... + def supxlabel(self, t: str, **kwargs) -> Text: ... + def get_supxlabel(self) -> str: ... + def supylabel(self, t: str, **kwargs) -> Text: ... + def get_supylabel(self) -> str: ... + def get_edgecolor(self) -> ColorType: ... + def get_facecolor(self) -> ColorType: ... + def get_frameon(self) -> bool: ... + def set_linewidth(self, linewidth: float) -> None: ... + def get_linewidth(self) -> float: ... + def set_edgecolor(self, color: ColorType) -> None: ... + def set_facecolor(self, color: ColorType) -> None: ... + def set_frameon(self, b: bool) -> None: ... + @property + def frameon(self) -> bool: ... + @frameon.setter + def frameon(self, b: bool) -> None: ... + def add_artist(self, artist: Artist, clip: bool = ...) -> Artist: ... + @overload + def add_axes(self, ax: Axes) -> Axes: ... + @overload + def add_axes( + self, + rect: tuple[float, float, float, float], + projection: None | str = ..., + polar: bool = ..., + **kwargs + ) -> Axes: ... + + # TODO: docstring indicates SubplotSpec a valid arg, but none of the listed signatures appear to be that + @overload + def add_subplot( + self, nrows: int, ncols: int, index: int | tuple[int, int], **kwargs + ) -> Axes: ... + @overload + def add_subplot(self, pos: int, **kwargs) -> Axes: ... + @overload + def add_subplot(self, ax: Axes, **kwargs) -> Axes: ... + @overload + def add_subplot(self, ax: SubplotSpec, **kwargs) -> Axes: ... + @overload + def add_subplot(self, **kwargs) -> Axes: ... + @overload + def subplots( + self, + nrows: int = ..., + ncols: int = ..., + *, + sharex: bool | Literal["none", "all", "row", "col"] = ..., + sharey: bool | Literal["none", "all", "row", "col"] = ..., + squeeze: Literal[False], + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + subplot_kw: dict[str, Any] | None = ..., + gridspec_kw: dict[str, Any] | None = ... + ) -> np.ndarray: ... + @overload + def subplots( + self, + nrows: int = ..., + ncols: int = ..., + *, + sharex: bool | Literal["none", "all", "row", "col"] = ..., + sharey: bool | Literal["none", "all", "row", "col"] = ..., + squeeze: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + subplot_kw: dict[str, Any] | None = ..., + gridspec_kw: dict[str, Any] | None = ... + ) -> np.ndarray | SubplotBase | Axes: ... + def delaxes(self, ax: Axes) -> None: ... + def clear(self, keep_observers: bool = ...) -> None: ... + def clf(self, keep_observers: bool = ...) -> None: ... + + @overload + def legend(self) -> Legend: ... + @overload + def legend(self, handles: Iterable[Artist], labels: Iterable[str], **kwargs) -> Legend: ... + @overload + def legend(self, *, handles: Iterable[Artist], **kwargs) -> Legend: ... + @overload + def legend(self, labels: Iterable[str], **kwargs) -> Legend: ... + @overload + def legend(self, **kwargs) -> Legend: ... + + def text( + self, + x: float, + y: float, + s: str, + fontdict: dict[str, Any] | None = ..., + **kwargs + ) -> Text: ... + def colorbar( + self, + mappable: ScalarMappable, + cax: Axes | None = ..., + ax: Axes | Iterable[Axes] | None = ..., + use_gridspec: bool = ..., + **kwargs + ) -> Colorbar: ... + def subplots_adjust( + self, + left: float | None = ..., + bottom: float | None = ..., + right: float | None = ..., + top: float | None = ..., + wspace: float | None = ..., + hspace: float | None = ..., + ) -> None: ... + def align_xlabels(self, axs: Iterable[Axes] | None = ...) -> None: ... + def align_ylabels(self, axs: Iterable[Axes] | None = ...) -> None: ... + def align_titles(self, axs: Iterable[Axes] | None = ...) -> None: ... + def align_labels(self, axs: Iterable[Axes] | None = ...) -> None: ... + def add_gridspec(self, nrows: int = ..., ncols: int = ..., **kwargs) -> GridSpec: ... + @overload + def subfigures( + self, + nrows: int = ..., + ncols: int = ..., + squeeze: Literal[False] = ..., + wspace: float | None = ..., + hspace: float | None = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + **kwargs + ) -> np.ndarray: ... + @overload + def subfigures( + self, + nrows: int = ..., + ncols: int = ..., + squeeze: Literal[True] = ..., + wspace: float | None = ..., + hspace: float | None = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + **kwargs + ) -> np.ndarray | SubFigure: ... + def add_subfigure(self, subplotspec: SubplotSpec, **kwargs) -> SubFigure: ... + def sca(self, a: Axes) -> Axes: ... + def gca(self) -> Axes: ... + def _gci(self) -> ScalarMappable | None: ... + def _process_projection_requirements( + self, *, axes_class=None, polar=False, projection=None, **kwargs + ) -> tuple[type[Axes], dict[str, Any]]: ... + def get_default_bbox_extra_artists(self) -> list[Artist]: ... + def get_tightbbox( + self, + renderer: RendererBase | None = ..., + *, + bbox_extra_artists: Iterable[Artist] | None = ..., + ) -> Bbox: ... + @overload + def subplot_mosaic( + self, + mosaic: str, + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: str = ..., + subplot_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + ) -> dict[str, Axes]: ... + @overload + def subplot_mosaic( + self, + mosaic: list[HashableList[_T]], + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: _T = ..., + subplot_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + ) -> dict[_T, Axes]: ... + @overload + def subplot_mosaic( + self, + mosaic: list[HashableList[Hashable]], + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: Any = ..., + subplot_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + ) -> dict[Hashable, Axes]: ... + +class SubFigure(FigureBase): + figure: Figure + subplotpars: SubplotParams + dpi_scale_trans: Affine2D + canvas: FigureCanvasBase + transFigure: Transform + bbox_relative: Bbox + figbbox: BboxBase + bbox: BboxBase + transSubfigure: Transform + patch: Rectangle + def __init__( + self, + parent: Figure | SubFigure, + subplotspec: SubplotSpec, + *, + facecolor: ColorType | None = ..., + edgecolor: ColorType | None = ..., + linewidth: float = ..., + frameon: bool | None = ..., + **kwargs + ) -> None: ... + @property + def dpi(self) -> float: ... + @dpi.setter + def dpi(self, value: float) -> None: ... + def get_dpi(self) -> float: ... + def set_dpi(self, val) -> None: ... + def get_constrained_layout(self) -> bool: ... + def get_constrained_layout_pads( + self, relative: bool = ... + ) -> tuple[float, float, float, float]: ... + def get_layout_engine(self) -> LayoutEngine: ... + @property # type: ignore[misc] + def axes(self) -> list[Axes]: ... # type: ignore[override] + def get_axes(self) -> list[Axes]: ... + +class Figure(FigureBase): + figure: Figure + bbox_inches: Bbox + dpi_scale_trans: Affine2D + bbox: BboxBase + figbbox: BboxBase + transFigure: Transform + transSubfigure: Transform + patch: Rectangle + subplotpars: SubplotParams + def __init__( + self, + figsize: tuple[float, float] | None = ..., + dpi: float | None = ..., + *, + facecolor: ColorType | None = ..., + edgecolor: ColorType | None = ..., + linewidth: float = ..., + frameon: bool | None = ..., + subplotpars: SubplotParams | None = ..., + tight_layout: bool | dict[str, Any] | None = ..., + constrained_layout: bool | dict[str, Any] | None = ..., + layout: Literal["constrained", "compressed", "tight"] + | LayoutEngine + | None = ..., + **kwargs + ) -> None: ... + def pick(self, mouseevent: MouseEvent) -> None: ... + def set_layout_engine( + self, + layout: Literal["constrained", "compressed", "tight", "none"] + | LayoutEngine + | None = ..., + **kwargs + ) -> None: ... + def get_layout_engine(self) -> LayoutEngine | None: ... + def _repr_html_(self) -> str | None: ... + def show(self, warn: bool = ...) -> None: ... + @property # type: ignore[misc] + def axes(self) -> list[Axes]: ... # type: ignore[override] + def get_axes(self) -> list[Axes]: ... + @property + def dpi(self) -> float: ... + @dpi.setter + def dpi(self, dpi: float) -> None: ... + def get_tight_layout(self) -> bool: ... + def get_constrained_layout_pads( + self, relative: bool = ... + ) -> tuple[float, float, float, float]: ... + def get_constrained_layout(self) -> bool: ... + canvas: FigureCanvasBase + def set_canvas(self, canvas: FigureCanvasBase) -> None: ... + def figimage( + self, + X: ArrayLike, + xo: int = ..., + yo: int = ..., + alpha: float | None = ..., + norm: str | Normalize | None = ..., + cmap: str | Colormap | None = ..., + vmin: float | None = ..., + vmax: float | None = ..., + origin: Literal["upper", "lower"] | None = ..., + resize: bool = ..., + **kwargs + ) -> FigureImage: ... + def set_size_inches( + self, w: float | tuple[float, float], h: float | None = ..., forward: bool = ... + ) -> None: ... + def get_size_inches(self) -> np.ndarray: ... + def get_figwidth(self) -> float: ... + def get_figheight(self) -> float: ... + def get_dpi(self) -> float: ... + def set_dpi(self, val: float) -> None: ... + def set_figwidth(self, val: float, forward: bool = ...) -> None: ... + def set_figheight(self, val: float, forward: bool = ...) -> None: ... + def clear(self, keep_observers: bool = ...) -> None: ... + def draw_without_rendering(self) -> None: ... + def draw_artist(self, a: Artist) -> None: ... + def add_axobserver(self, func: Callable[[Figure], Any]) -> None: ... + def savefig( + self, + fname: str | os.PathLike | IO, + *, + transparent: bool | None = ..., + **kwargs + ) -> None: ... + def ginput( + self, + n: int = ..., + timeout: float = ..., + show_clicks: bool = ..., + mouse_add: MouseButton = ..., + mouse_pop: MouseButton = ..., + mouse_stop: MouseButton = ..., + ) -> list[tuple[int, int]]: ... + def waitforbuttonpress(self, timeout: float = ...) -> None | bool: ... + def tight_layout( + self, + *, + pad: float = ..., + h_pad: float | None = ..., + w_pad: float | None = ..., + rect: tuple[float, float, float, float] | None = ... + ) -> None: ... + +def figaspect(arg: float | ArrayLike) -> tuple[float, float]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/font_manager.py b/venv/lib/python3.10/site-packages/matplotlib/font_manager.py new file mode 100644 index 00000000..312e8ee9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/font_manager.py @@ -0,0 +1,1587 @@ +""" +A module for finding, managing, and using fonts across platforms. + +This module provides a single `FontManager` instance, ``fontManager``, that can +be shared across backends and platforms. The `findfont` +function returns the best TrueType (TTF) font file in the local or +system font path that matches the specified `FontProperties` +instance. The `FontManager` also handles Adobe Font Metrics +(AFM) font files for use by the PostScript backend. +The `FontManager.addfont` function adds a custom font from a file without +installing it into your operating system. + +The design is based on the `W3C Cascading Style Sheet, Level 1 (CSS1) +font specification `_. +Future versions may implement the Level 2 or 2.1 specifications. +""" + +# KNOWN ISSUES +# +# - documentation +# - font variant is untested +# - font stretch is incomplete +# - font size is incomplete +# - default font algorithm needs improvement and testing +# - setWeights function needs improvement +# - 'light' is an invalid weight value, remove it. + +from __future__ import annotations + +from base64 import b64encode +from collections import namedtuple +import copy +import dataclasses +from functools import lru_cache +from io import BytesIO +import json +import logging +from numbers import Number +import os +from pathlib import Path +import plistlib +import re +import subprocess +import sys +import threading + +import matplotlib as mpl +from matplotlib import _api, _afm, cbook, ft2font +from matplotlib._fontconfig_pattern import ( + parse_fontconfig_pattern, generate_fontconfig_pattern) +from matplotlib.rcsetup import _validators + +_log = logging.getLogger(__name__) + +font_scalings = { + 'xx-small': 0.579, + 'x-small': 0.694, + 'small': 0.833, + 'medium': 1.0, + 'large': 1.200, + 'x-large': 1.440, + 'xx-large': 1.728, + 'larger': 1.2, + 'smaller': 0.833, + None: 1.0, +} +stretch_dict = { + 'ultra-condensed': 100, + 'extra-condensed': 200, + 'condensed': 300, + 'semi-condensed': 400, + 'normal': 500, + 'semi-expanded': 600, + 'semi-extended': 600, + 'expanded': 700, + 'extended': 700, + 'extra-expanded': 800, + 'extra-extended': 800, + 'ultra-expanded': 900, + 'ultra-extended': 900, +} +weight_dict = { + 'ultralight': 100, + 'light': 200, + 'normal': 400, + 'regular': 400, + 'book': 400, + 'medium': 500, + 'roman': 500, + 'semibold': 600, + 'demibold': 600, + 'demi': 600, + 'bold': 700, + 'heavy': 800, + 'extra bold': 800, + 'black': 900, +} +_weight_regexes = [ + # From fontconfig's FcFreeTypeQueryFaceInternal; not the same as + # weight_dict! + ("thin", 100), + ("extralight", 200), + ("ultralight", 200), + ("demilight", 350), + ("semilight", 350), + ("light", 300), # Needs to come *after* demi/semilight! + ("book", 380), + ("regular", 400), + ("normal", 400), + ("medium", 500), + ("demibold", 600), + ("demi", 600), + ("semibold", 600), + ("extrabold", 800), + ("superbold", 800), + ("ultrabold", 800), + ("bold", 700), # Needs to come *after* extra/super/ultrabold! + ("ultrablack", 1000), + ("superblack", 1000), + ("extrablack", 1000), + (r"\bultra", 1000), + ("black", 900), # Needs to come *after* ultra/super/extrablack! + ("heavy", 900), +] +font_family_aliases = { + 'serif', + 'sans-serif', + 'sans serif', + 'cursive', + 'fantasy', + 'monospace', + 'sans', +} + +_ExceptionProxy = namedtuple('_ExceptionProxy', ['klass', 'message']) + +# OS Font paths +try: + _HOME = Path.home() +except Exception: # Exceptions thrown by home() are not specified... + _HOME = Path(os.devnull) # Just an arbitrary path with no children. +MSFolders = \ + r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders' +MSFontDirectories = [ + r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', + r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts'] +MSUserFontDirectories = [ + str(_HOME / 'AppData/Local/Microsoft/Windows/Fonts'), + str(_HOME / 'AppData/Roaming/Microsoft/Windows/Fonts'), +] +X11FontDirectories = [ + # an old standard installation point + "/usr/X11R6/lib/X11/fonts/TTF/", + "/usr/X11/lib/X11/fonts", + # here is the new standard location for fonts + "/usr/share/fonts/", + # documented as a good place to install new fonts + "/usr/local/share/fonts/", + # common application, not really useful + "/usr/lib/openoffice/share/fonts/truetype/", + # user fonts + str((Path(os.environ.get('XDG_DATA_HOME') or _HOME / ".local/share")) + / "fonts"), + str(_HOME / ".fonts"), +] +OSXFontDirectories = [ + "/Library/Fonts/", + "/Network/Library/Fonts/", + "/System/Library/Fonts/", + # fonts installed via MacPorts + "/opt/local/share/fonts", + # user fonts + str(_HOME / "Library/Fonts"), +] + + +def get_fontext_synonyms(fontext): + """ + Return a list of file extensions that are synonyms for + the given file extension *fileext*. + """ + return { + 'afm': ['afm'], + 'otf': ['otf', 'ttc', 'ttf'], + 'ttc': ['otf', 'ttc', 'ttf'], + 'ttf': ['otf', 'ttc', 'ttf'], + }[fontext] + + +def list_fonts(directory, extensions): + """ + Return a list of all fonts matching any of the extensions, found + recursively under the directory. + """ + extensions = ["." + ext for ext in extensions] + return [os.path.join(dirpath, filename) + # os.walk ignores access errors, unlike Path.glob. + for dirpath, _, filenames in os.walk(directory) + for filename in filenames + if Path(filename).suffix.lower() in extensions] + + +def win32FontDirectory(): + r""" + Return the user-specified font directory for Win32. This is + looked up from the registry key :: + + \\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts + + If the key is not found, ``%WINDIR%\Fonts`` will be returned. + """ # noqa: E501 + import winreg + try: + with winreg.OpenKey(winreg.HKEY_CURRENT_USER, MSFolders) as user: + return winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + return os.path.join(os.environ['WINDIR'], 'Fonts') + + +def _get_win32_installed_fonts(): + """List the font paths known to the Windows registry.""" + import winreg + items = set() + # Search and resolve fonts listed in the registry. + for domain, base_dirs in [ + (winreg.HKEY_LOCAL_MACHINE, [win32FontDirectory()]), # System. + (winreg.HKEY_CURRENT_USER, MSUserFontDirectories), # User. + ]: + for base_dir in base_dirs: + for reg_path in MSFontDirectories: + try: + with winreg.OpenKey(domain, reg_path) as local: + for j in range(winreg.QueryInfoKey(local)[1]): + # value may contain the filename of the font or its + # absolute path. + key, value, tp = winreg.EnumValue(local, j) + if not isinstance(value, str): + continue + try: + # If value contains already an absolute path, + # then it is not changed further. + path = Path(base_dir, value).resolve() + except RuntimeError: + # Don't fail with invalid entries. + continue + items.add(path) + except (OSError, MemoryError): + continue + return items + + +@lru_cache +def _get_fontconfig_fonts(): + """Cache and list the font paths known to ``fc-list``.""" + try: + if b'--format' not in subprocess.check_output(['fc-list', '--help']): + _log.warning( # fontconfig 2.7 implemented --format. + 'Matplotlib needs fontconfig>=2.7 to query system fonts.') + return [] + out = subprocess.check_output(['fc-list', '--format=%{file}\\n']) + except (OSError, subprocess.CalledProcessError): + return [] + return [Path(os.fsdecode(fname)) for fname in out.split(b'\n')] + + +@lru_cache +def _get_macos_fonts(): + """Cache and list the font paths known to ``system_profiler SPFontsDataType``.""" + d, = plistlib.loads( + subprocess.check_output(["system_profiler", "-xml", "SPFontsDataType"])) + return [Path(entry["path"]) for entry in d["_items"]] + + +def findSystemFonts(fontpaths=None, fontext='ttf'): + """ + Search for fonts in the specified font paths. If no paths are + given, will use a standard set of system paths, as well as the + list of fonts tracked by fontconfig if fontconfig is installed and + available. A list of TrueType fonts are returned by default with + AFM fonts as an option. + """ + fontfiles = set() + fontexts = get_fontext_synonyms(fontext) + + if fontpaths is None: + if sys.platform == 'win32': + installed_fonts = _get_win32_installed_fonts() + fontpaths = [] + else: + installed_fonts = _get_fontconfig_fonts() + if sys.platform == 'darwin': + installed_fonts += _get_macos_fonts() + fontpaths = [*X11FontDirectories, *OSXFontDirectories] + else: + fontpaths = X11FontDirectories + fontfiles.update(str(path) for path in installed_fonts + if path.suffix.lower()[1:] in fontexts) + + elif isinstance(fontpaths, str): + fontpaths = [fontpaths] + + for path in fontpaths: + fontfiles.update(map(os.path.abspath, list_fonts(path, fontexts))) + + return [fname for fname in fontfiles if os.path.exists(fname)] + + +@dataclasses.dataclass(frozen=True) +class FontEntry: + """ + A class for storing Font properties. + + It is used when populating the font lookup dictionary. + """ + + fname: str = '' + name: str = '' + style: str = 'normal' + variant: str = 'normal' + weight: str | int = 'normal' + stretch: str = 'normal' + size: str = 'medium' + + def _repr_html_(self) -> str: + png_stream = self._repr_png_() + png_b64 = b64encode(png_stream).decode() + return f"" + + def _repr_png_(self) -> bytes: + from matplotlib.figure import Figure # Circular import. + fig = Figure() + font_path = Path(self.fname) if self.fname != '' else None + fig.text(0, 0, self.name, font=font_path) + with BytesIO() as buf: + fig.savefig(buf, bbox_inches='tight', transparent=True) + return buf.getvalue() + + +def ttfFontProperty(font): + """ + Extract information from a TrueType font file. + + Parameters + ---------- + font : `.FT2Font` + The TrueType font file from which information will be extracted. + + Returns + ------- + `FontEntry` + The extracted font properties. + + """ + name = font.family_name + + # Styles are: italic, oblique, and normal (default) + + sfnt = font.get_sfnt() + mac_key = (1, # platform: macintosh + 0, # id: roman + 0) # langid: english + ms_key = (3, # platform: microsoft + 1, # id: unicode_cs + 0x0409) # langid: english_united_states + + # These tables are actually mac_roman-encoded, but mac_roman support may be + # missing in some alternative Python implementations and we are only going + # to look for ASCII substrings, where any ASCII-compatible encoding works + # - or big-endian UTF-16, since important Microsoft fonts use that. + sfnt2 = (sfnt.get((*mac_key, 2), b'').decode('latin-1').lower() or + sfnt.get((*ms_key, 2), b'').decode('utf_16_be').lower()) + sfnt4 = (sfnt.get((*mac_key, 4), b'').decode('latin-1').lower() or + sfnt.get((*ms_key, 4), b'').decode('utf_16_be').lower()) + + if sfnt4.find('oblique') >= 0: + style = 'oblique' + elif sfnt4.find('italic') >= 0: + style = 'italic' + elif sfnt2.find('regular') >= 0: + style = 'normal' + elif font.style_flags & ft2font.ITALIC: + style = 'italic' + else: + style = 'normal' + + # Variants are: small-caps and normal (default) + + # !!!! Untested + if name.lower() in ['capitals', 'small-caps']: + variant = 'small-caps' + else: + variant = 'normal' + + # The weight-guessing algorithm is directly translated from fontconfig + # 2.13.1's FcFreeTypeQueryFaceInternal (fcfreetype.c). + wws_subfamily = 22 + typographic_subfamily = 16 + font_subfamily = 2 + styles = [ + sfnt.get((*mac_key, wws_subfamily), b'').decode('latin-1'), + sfnt.get((*mac_key, typographic_subfamily), b'').decode('latin-1'), + sfnt.get((*mac_key, font_subfamily), b'').decode('latin-1'), + sfnt.get((*ms_key, wws_subfamily), b'').decode('utf-16-be'), + sfnt.get((*ms_key, typographic_subfamily), b'').decode('utf-16-be'), + sfnt.get((*ms_key, font_subfamily), b'').decode('utf-16-be'), + ] + styles = [*filter(None, styles)] or [font.style_name] + + def get_weight(): # From fontconfig's FcFreeTypeQueryFaceInternal. + # OS/2 table weight. + os2 = font.get_sfnt_table("OS/2") + if os2 and os2["version"] != 0xffff: + return os2["usWeightClass"] + # PostScript font info weight. + try: + ps_font_info_weight = ( + font.get_ps_font_info()["weight"].replace(" ", "") or "") + except ValueError: + pass + else: + for regex, weight in _weight_regexes: + if re.fullmatch(regex, ps_font_info_weight, re.I): + return weight + # Style name weight. + for style in styles: + style = style.replace(" ", "") + for regex, weight in _weight_regexes: + if re.search(regex, style, re.I): + return weight + if font.style_flags & ft2font.BOLD: + return 700 # "bold" + return 500 # "medium", not "regular"! + + weight = int(get_weight()) + + # Stretch can be absolute and relative + # Absolute stretches are: ultra-condensed, extra-condensed, condensed, + # semi-condensed, normal, semi-expanded, expanded, extra-expanded, + # and ultra-expanded. + # Relative stretches are: wider, narrower + # Child value is: inherit + + if any(word in sfnt4 for word in ['narrow', 'condensed', 'cond']): + stretch = 'condensed' + elif 'demi cond' in sfnt4: + stretch = 'semi-condensed' + elif any(word in sfnt4 for word in ['wide', 'expanded', 'extended']): + stretch = 'expanded' + else: + stretch = 'normal' + + # Sizes can be absolute and relative. + # Absolute sizes are: xx-small, x-small, small, medium, large, x-large, + # and xx-large. + # Relative sizes are: larger, smaller + # Length value is an absolute font size, e.g., 12pt + # Percentage values are in 'em's. Most robust specification. + + if not font.scalable: + raise NotImplementedError("Non-scalable fonts are not supported") + size = 'scalable' + + return FontEntry(font.fname, name, style, variant, weight, stretch, size) + + +def afmFontProperty(fontpath, font): + """ + Extract information from an AFM font file. + + Parameters + ---------- + fontpath : str + The filename corresponding to *font*. + font : AFM + The AFM font file from which information will be extracted. + + Returns + ------- + `FontEntry` + The extracted font properties. + """ + + name = font.get_familyname() + fontname = font.get_fontname().lower() + + # Styles are: italic, oblique, and normal (default) + + if font.get_angle() != 0 or 'italic' in name.lower(): + style = 'italic' + elif 'oblique' in name.lower(): + style = 'oblique' + else: + style = 'normal' + + # Variants are: small-caps and normal (default) + + # !!!! Untested + if name.lower() in ['capitals', 'small-caps']: + variant = 'small-caps' + else: + variant = 'normal' + + weight = font.get_weight().lower() + if weight not in weight_dict: + weight = 'normal' + + # Stretch can be absolute and relative + # Absolute stretches are: ultra-condensed, extra-condensed, condensed, + # semi-condensed, normal, semi-expanded, expanded, extra-expanded, + # and ultra-expanded. + # Relative stretches are: wider, narrower + # Child value is: inherit + if 'demi cond' in fontname: + stretch = 'semi-condensed' + elif any(word in fontname for word in ['narrow', 'cond']): + stretch = 'condensed' + elif any(word in fontname for word in ['wide', 'expanded', 'extended']): + stretch = 'expanded' + else: + stretch = 'normal' + + # Sizes can be absolute and relative. + # Absolute sizes are: xx-small, x-small, small, medium, large, x-large, + # and xx-large. + # Relative sizes are: larger, smaller + # Length value is an absolute font size, e.g., 12pt + # Percentage values are in 'em's. Most robust specification. + + # All AFM fonts are apparently scalable. + + size = 'scalable' + + return FontEntry(fontpath, name, style, variant, weight, stretch, size) + + +class FontProperties: + """ + A class for storing and manipulating font properties. + + The font properties are the six properties described in the + `W3C Cascading Style Sheet, Level 1 + `_ font + specification and *math_fontfamily* for math fonts: + + - family: A list of font names in decreasing order of priority. + The items may include a generic font family name, either 'sans-serif', + 'serif', 'cursive', 'fantasy', or 'monospace'. In that case, the actual + font to be used will be looked up from the associated rcParam during the + search process in `.findfont`. Default: :rc:`font.family` + + - style: Either 'normal', 'italic' or 'oblique'. + Default: :rc:`font.style` + + - variant: Either 'normal' or 'small-caps'. + Default: :rc:`font.variant` + + - stretch: A numeric value in the range 0-1000 or one of + 'ultra-condensed', 'extra-condensed', 'condensed', + 'semi-condensed', 'normal', 'semi-expanded', 'expanded', + 'extra-expanded' or 'ultra-expanded'. Default: :rc:`font.stretch` + + - weight: A numeric value in the range 0-1000 or one of + 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', + 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', + 'extra bold', 'black'. Default: :rc:`font.weight` + + - size: Either a relative value of 'xx-small', 'x-small', + 'small', 'medium', 'large', 'x-large', 'xx-large' or an + absolute font size, e.g., 10. Default: :rc:`font.size` + + - math_fontfamily: The family of fonts used to render math text. + Supported values are: 'dejavusans', 'dejavuserif', 'cm', + 'stix', 'stixsans' and 'custom'. Default: :rc:`mathtext.fontset` + + Alternatively, a font may be specified using the absolute path to a font + file, by using the *fname* kwarg. However, in this case, it is typically + simpler to just pass the path (as a `pathlib.Path`, not a `str`) to the + *font* kwarg of the `.Text` object. + + The preferred usage of font sizes is to use the relative values, + e.g., 'large', instead of absolute font sizes, e.g., 12. This + approach allows all text sizes to be made larger or smaller based + on the font manager's default font size. + + This class will also accept a fontconfig_ pattern_, if it is the only + argument provided. This support does not depend on fontconfig; we are + merely borrowing its pattern syntax for use here. + + .. _fontconfig: https://www.freedesktop.org/wiki/Software/fontconfig/ + .. _pattern: + https://www.freedesktop.org/software/fontconfig/fontconfig-user.html + + Note that Matplotlib's internal font manager and fontconfig use a + different algorithm to lookup fonts, so the results of the same pattern + may be different in Matplotlib than in other applications that use + fontconfig. + """ + + def __init__(self, family=None, style=None, variant=None, weight=None, + stretch=None, size=None, + fname=None, # if set, it's a hardcoded filename to use + math_fontfamily=None): + self.set_family(family) + self.set_style(style) + self.set_variant(variant) + self.set_weight(weight) + self.set_stretch(stretch) + self.set_file(fname) + self.set_size(size) + self.set_math_fontfamily(math_fontfamily) + # Treat family as a fontconfig pattern if it is the only parameter + # provided. Even in that case, call the other setters first to set + # attributes not specified by the pattern to the rcParams defaults. + if (isinstance(family, str) + and style is None and variant is None and weight is None + and stretch is None and size is None and fname is None): + self.set_fontconfig_pattern(family) + + @classmethod + def _from_any(cls, arg): + """ + Generic constructor which can build a `.FontProperties` from any of the + following: + + - a `.FontProperties`: it is passed through as is; + - `None`: a `.FontProperties` using rc values is used; + - an `os.PathLike`: it is used as path to the font file; + - a `str`: it is parsed as a fontconfig pattern; + - a `dict`: it is passed as ``**kwargs`` to `.FontProperties`. + """ + if arg is None: + return cls() + elif isinstance(arg, cls): + return arg + elif isinstance(arg, os.PathLike): + return cls(fname=arg) + elif isinstance(arg, str): + return cls(arg) + else: + return cls(**arg) + + def __hash__(self): + l = (tuple(self.get_family()), + self.get_slant(), + self.get_variant(), + self.get_weight(), + self.get_stretch(), + self.get_size(), + self.get_file(), + self.get_math_fontfamily()) + return hash(l) + + def __eq__(self, other): + return hash(self) == hash(other) + + def __str__(self): + return self.get_fontconfig_pattern() + + def get_family(self): + """ + Return a list of individual font family names or generic family names. + + The font families or generic font families (which will be resolved + from their respective rcParams when searching for a matching font) in + the order of preference. + """ + return self._family + + def get_name(self): + """ + Return the name of the font that best matches the font properties. + """ + return get_font(findfont(self)).family_name + + def get_style(self): + """ + Return the font style. Values are: 'normal', 'italic' or 'oblique'. + """ + return self._slant + + def get_variant(self): + """ + Return the font variant. Values are: 'normal' or 'small-caps'. + """ + return self._variant + + def get_weight(self): + """ + Set the font weight. Options are: A numeric value in the + range 0-1000 or one of 'light', 'normal', 'regular', 'book', + 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', + 'heavy', 'extra bold', 'black' + """ + return self._weight + + def get_stretch(self): + """ + Return the font stretch or width. Options are: 'ultra-condensed', + 'extra-condensed', 'condensed', 'semi-condensed', 'normal', + 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'. + """ + return self._stretch + + def get_size(self): + """ + Return the font size. + """ + return self._size + + def get_file(self): + """ + Return the filename of the associated font. + """ + return self._file + + def get_fontconfig_pattern(self): + """ + Get a fontconfig_ pattern_ suitable for looking up the font as + specified with fontconfig's ``fc-match`` utility. + + This support does not depend on fontconfig; we are merely borrowing its + pattern syntax for use here. + """ + return generate_fontconfig_pattern(self) + + def set_family(self, family): + """ + Change the font family. Can be either an alias (generic name + is CSS parlance), such as: 'serif', 'sans-serif', 'cursive', + 'fantasy', or 'monospace', a real font name or a list of real + font names. Real font names are not supported when + :rc:`text.usetex` is `True`. Default: :rc:`font.family` + """ + if family is None: + family = mpl.rcParams['font.family'] + if isinstance(family, str): + family = [family] + self._family = family + + def set_style(self, style): + """ + Set the font style. + + Parameters + ---------- + style : {'normal', 'italic', 'oblique'}, default: :rc:`font.style` + """ + if style is None: + style = mpl.rcParams['font.style'] + _api.check_in_list(['normal', 'italic', 'oblique'], style=style) + self._slant = style + + def set_variant(self, variant): + """ + Set the font variant. + + Parameters + ---------- + variant : {'normal', 'small-caps'}, default: :rc:`font.variant` + """ + if variant is None: + variant = mpl.rcParams['font.variant'] + _api.check_in_list(['normal', 'small-caps'], variant=variant) + self._variant = variant + + def set_weight(self, weight): + """ + Set the font weight. + + Parameters + ---------- + weight : int or {'ultralight', 'light', 'normal', 'regular', 'book', \ +'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', \ +'extra bold', 'black'}, default: :rc:`font.weight` + If int, must be in the range 0-1000. + """ + if weight is None: + weight = mpl.rcParams['font.weight'] + if weight in weight_dict: + self._weight = weight + return + try: + weight = int(weight) + except ValueError: + pass + else: + if 0 <= weight <= 1000: + self._weight = weight + return + raise ValueError(f"{weight=} is invalid") + + def set_stretch(self, stretch): + """ + Set the font stretch or width. + + Parameters + ---------- + stretch : int or {'ultra-condensed', 'extra-condensed', 'condensed', \ +'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', \ +'ultra-expanded'}, default: :rc:`font.stretch` + If int, must be in the range 0-1000. + """ + if stretch is None: + stretch = mpl.rcParams['font.stretch'] + if stretch in stretch_dict: + self._stretch = stretch + return + try: + stretch = int(stretch) + except ValueError: + pass + else: + if 0 <= stretch <= 1000: + self._stretch = stretch + return + raise ValueError(f"{stretch=} is invalid") + + def set_size(self, size): + """ + Set the font size. + + Parameters + ---------- + size : float or {'xx-small', 'x-small', 'small', 'medium', \ +'large', 'x-large', 'xx-large'}, default: :rc:`font.size` + If a float, the font size in points. The string values denote + sizes relative to the default font size. + """ + if size is None: + size = mpl.rcParams['font.size'] + try: + size = float(size) + except ValueError: + try: + scale = font_scalings[size] + except KeyError as err: + raise ValueError( + "Size is invalid. Valid font size are " + + ", ".join(map(str, font_scalings))) from err + else: + size = scale * FontManager.get_default_size() + if size < 1.0: + _log.info('Fontsize %1.2f < 1.0 pt not allowed by FreeType. ' + 'Setting fontsize = 1 pt', size) + size = 1.0 + self._size = size + + def set_file(self, file): + """ + Set the filename of the fontfile to use. In this case, all + other properties will be ignored. + """ + self._file = os.fspath(file) if file is not None else None + + def set_fontconfig_pattern(self, pattern): + """ + Set the properties by parsing a fontconfig_ *pattern*. + + This support does not depend on fontconfig; we are merely borrowing its + pattern syntax for use here. + """ + for key, val in parse_fontconfig_pattern(pattern).items(): + if type(val) is list: + getattr(self, "set_" + key)(val[0]) + else: + getattr(self, "set_" + key)(val) + + def get_math_fontfamily(self): + """ + Return the name of the font family used for math text. + + The default font is :rc:`mathtext.fontset`. + """ + return self._math_fontfamily + + def set_math_fontfamily(self, fontfamily): + """ + Set the font family for text in math mode. + + If not set explicitly, :rc:`mathtext.fontset` will be used. + + Parameters + ---------- + fontfamily : str + The name of the font family. + + Available font families are defined in the + :ref:`default matplotlibrc file `. + + See Also + -------- + .text.Text.get_math_fontfamily + """ + if fontfamily is None: + fontfamily = mpl.rcParams['mathtext.fontset'] + else: + valid_fonts = _validators['mathtext.fontset'].valid.values() + # _check_in_list() Validates the parameter math_fontfamily as + # if it were passed to rcParams['mathtext.fontset'] + _api.check_in_list(valid_fonts, math_fontfamily=fontfamily) + self._math_fontfamily = fontfamily + + def copy(self): + """Return a copy of self.""" + return copy.copy(self) + + # Aliases + set_name = set_family + get_slant = get_style + set_slant = set_style + get_size_in_points = get_size + + +class _JSONEncoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, FontManager): + return dict(o.__dict__, __class__='FontManager') + elif isinstance(o, FontEntry): + d = dict(o.__dict__, __class__='FontEntry') + try: + # Cache paths of fonts shipped with Matplotlib relative to the + # Matplotlib data path, which helps in the presence of venvs. + d["fname"] = str(Path(d["fname"]).relative_to(mpl.get_data_path())) + except ValueError: + pass + return d + else: + return super().default(o) + + +def _json_decode(o): + cls = o.pop('__class__', None) + if cls is None: + return o + elif cls == 'FontManager': + r = FontManager.__new__(FontManager) + r.__dict__.update(o) + return r + elif cls == 'FontEntry': + if not os.path.isabs(o['fname']): + o['fname'] = os.path.join(mpl.get_data_path(), o['fname']) + r = FontEntry(**o) + return r + else: + raise ValueError("Don't know how to deserialize __class__=%s" % cls) + + +def json_dump(data, filename): + """ + Dump `FontManager` *data* as JSON to the file named *filename*. + + See Also + -------- + json_load + + Notes + ----- + File paths that are children of the Matplotlib data path (typically, fonts + shipped with Matplotlib) are stored relative to that data path (to remain + valid across virtualenvs). + + This function temporarily locks the output file to prevent multiple + processes from overwriting one another's output. + """ + with cbook._lock_path(filename), open(filename, 'w') as fh: + try: + json.dump(data, fh, cls=_JSONEncoder, indent=2) + except OSError as e: + _log.warning('Could not save font_manager cache %s', e) + + +def json_load(filename): + """ + Load a `FontManager` from the JSON file named *filename*. + + See Also + -------- + json_dump + """ + with open(filename) as fh: + return json.load(fh, object_hook=_json_decode) + + +class FontManager: + """ + On import, the `FontManager` singleton instance creates a list of ttf and + afm fonts and caches their `FontProperties`. The `FontManager.findfont` + method does a nearest neighbor search to find the font that most closely + matches the specification. If no good enough match is found, the default + font is returned. + + Fonts added with the `FontManager.addfont` method will not persist in the + cache; therefore, `addfont` will need to be called every time Matplotlib is + imported. This method should only be used if and when a font cannot be + installed on your operating system by other means. + + Notes + ----- + The `FontManager.addfont` method must be called on the global `FontManager` + instance. + + Example usage:: + + import matplotlib.pyplot as plt + from matplotlib import font_manager + + font_dirs = ["/resources/fonts"] # The path to the custom font file. + font_files = font_manager.findSystemFonts(fontpaths=font_dirs) + + for font_file in font_files: + font_manager.fontManager.addfont(font_file) + """ + # Increment this version number whenever the font cache data + # format or behavior has changed and requires an existing font + # cache files to be rebuilt. + __version__ = 390 + + def __init__(self, size=None, weight='normal'): + self._version = self.__version__ + + self.__default_weight = weight + self.default_size = size + + # Create list of font paths. + paths = [cbook._get_data_path('fonts', subdir) + for subdir in ['ttf', 'afm', 'pdfcorefonts']] + _log.debug('font search path %s', paths) + + self.defaultFamily = { + 'ttf': 'DejaVu Sans', + 'afm': 'Helvetica'} + + self.afmlist = [] + self.ttflist = [] + + # Delay the warning by 5s. + timer = threading.Timer(5, lambda: _log.warning( + 'Matplotlib is building the font cache; this may take a moment.')) + timer.start() + try: + for fontext in ["afm", "ttf"]: + for path in [*findSystemFonts(paths, fontext=fontext), + *findSystemFonts(fontext=fontext)]: + try: + self.addfont(path) + except OSError as exc: + _log.info("Failed to open font file %s: %s", path, exc) + except Exception as exc: + _log.info("Failed to extract font properties from %s: " + "%s", path, exc) + finally: + timer.cancel() + + def addfont(self, path): + """ + Cache the properties of the font at *path* to make it available to the + `FontManager`. The type of font is inferred from the path suffix. + + Parameters + ---------- + path : str or path-like + + Notes + ----- + This method is useful for adding a custom font without installing it in + your operating system. See the `FontManager` singleton instance for + usage and caveats about this function. + """ + # Convert to string in case of a path as + # afmFontProperty and FT2Font expect this + path = os.fsdecode(path) + if Path(path).suffix.lower() == ".afm": + with open(path, "rb") as fh: + font = _afm.AFM(fh) + prop = afmFontProperty(path, font) + self.afmlist.append(prop) + else: + font = ft2font.FT2Font(path) + prop = ttfFontProperty(font) + self.ttflist.append(prop) + self._findfont_cached.cache_clear() + + @property + def defaultFont(self): + # Lazily evaluated (findfont then caches the result) to avoid including + # the venv path in the json serialization. + return {ext: self.findfont(family, fontext=ext) + for ext, family in self.defaultFamily.items()} + + def get_default_weight(self): + """ + Return the default font weight. + """ + return self.__default_weight + + @staticmethod + def get_default_size(): + """ + Return the default font size. + """ + return mpl.rcParams['font.size'] + + def set_default_weight(self, weight): + """ + Set the default font weight. The initial value is 'normal'. + """ + self.__default_weight = weight + + @staticmethod + def _expand_aliases(family): + if family in ('sans', 'sans serif'): + family = 'sans-serif' + return mpl.rcParams['font.' + family] + + # Each of the scoring functions below should return a value between + # 0.0 (perfect match) and 1.0 (terrible match) + def score_family(self, families, family2): + """ + Return a match score between the list of font families in + *families* and the font family name *family2*. + + An exact match at the head of the list returns 0.0. + + A match further down the list will return between 0 and 1. + + No match will return 1.0. + """ + if not isinstance(families, (list, tuple)): + families = [families] + elif len(families) == 0: + return 1.0 + family2 = family2.lower() + step = 1 / len(families) + for i, family1 in enumerate(families): + family1 = family1.lower() + if family1 in font_family_aliases: + options = [*map(str.lower, self._expand_aliases(family1))] + if family2 in options: + idx = options.index(family2) + return (i + (idx / len(options))) * step + elif family1 == family2: + # The score should be weighted by where in the + # list the font was found. + return i * step + return 1.0 + + def score_style(self, style1, style2): + """ + Return a match score between *style1* and *style2*. + + An exact match returns 0.0. + + A match between 'italic' and 'oblique' returns 0.1. + + No match returns 1.0. + """ + if style1 == style2: + return 0.0 + elif (style1 in ('italic', 'oblique') + and style2 in ('italic', 'oblique')): + return 0.1 + return 1.0 + + def score_variant(self, variant1, variant2): + """ + Return a match score between *variant1* and *variant2*. + + An exact match returns 0.0, otherwise 1.0. + """ + if variant1 == variant2: + return 0.0 + else: + return 1.0 + + def score_stretch(self, stretch1, stretch2): + """ + Return a match score between *stretch1* and *stretch2*. + + The result is the absolute value of the difference between the + CSS numeric values of *stretch1* and *stretch2*, normalized + between 0.0 and 1.0. + """ + try: + stretchval1 = int(stretch1) + except ValueError: + stretchval1 = stretch_dict.get(stretch1, 500) + try: + stretchval2 = int(stretch2) + except ValueError: + stretchval2 = stretch_dict.get(stretch2, 500) + return abs(stretchval1 - stretchval2) / 1000.0 + + def score_weight(self, weight1, weight2): + """ + Return a match score between *weight1* and *weight2*. + + The result is 0.0 if both weight1 and weight 2 are given as strings + and have the same value. + + Otherwise, the result is the absolute value of the difference between + the CSS numeric values of *weight1* and *weight2*, normalized between + 0.05 and 1.0. + """ + # exact match of the weight names, e.g. weight1 == weight2 == "regular" + if cbook._str_equal(weight1, weight2): + return 0.0 + w1 = weight1 if isinstance(weight1, Number) else weight_dict[weight1] + w2 = weight2 if isinstance(weight2, Number) else weight_dict[weight2] + return 0.95 * (abs(w1 - w2) / 1000) + 0.05 + + def score_size(self, size1, size2): + """ + Return a match score between *size1* and *size2*. + + If *size2* (the size specified in the font file) is 'scalable', this + function always returns 0.0, since any font size can be generated. + + Otherwise, the result is the absolute distance between *size1* and + *size2*, normalized so that the usual range of font sizes (6pt - + 72pt) will lie between 0.0 and 1.0. + """ + if size2 == 'scalable': + return 0.0 + # Size value should have already been + try: + sizeval1 = float(size1) + except ValueError: + sizeval1 = self.default_size * font_scalings[size1] + try: + sizeval2 = float(size2) + except ValueError: + return 1.0 + return abs(sizeval1 - sizeval2) / 72 + + def findfont(self, prop, fontext='ttf', directory=None, + fallback_to_default=True, rebuild_if_missing=True): + """ + Find the path to the font file most closely matching the given font properties. + + Parameters + ---------- + prop : str or `~matplotlib.font_manager.FontProperties` + The font properties to search for. This can be either a + `.FontProperties` object or a string defining a + `fontconfig patterns`_. + + fontext : {'ttf', 'afm'}, default: 'ttf' + The extension of the font file: + + - 'ttf': TrueType and OpenType fonts (.ttf, .ttc, .otf) + - 'afm': Adobe Font Metrics (.afm) + + directory : str, optional + If given, only search this directory and its subdirectories. + + fallback_to_default : bool + If True, will fall back to the default font family (usually + "DejaVu Sans" or "Helvetica") if the first lookup hard-fails. + + rebuild_if_missing : bool + Whether to rebuild the font cache and search again if the first + match appears to point to a nonexisting font (i.e., the font cache + contains outdated entries). + + Returns + ------- + str + The filename of the best matching font. + + Notes + ----- + This performs a nearest neighbor search. Each font is given a + similarity score to the target font properties. The first font with + the highest score is returned. If no matches below a certain + threshold are found, the default font (usually DejaVu Sans) is + returned. + + The result is cached, so subsequent lookups don't have to + perform the O(n) nearest neighbor search. + + See the `W3C Cascading Style Sheet, Level 1 + `_ documentation + for a description of the font finding algorithm. + + .. _fontconfig patterns: + https://www.freedesktop.org/software/fontconfig/fontconfig-user.html + """ + # Pass the relevant rcParams (and the font manager, as `self`) to + # _findfont_cached so to prevent using a stale cache entry after an + # rcParam was changed. + rc_params = tuple(tuple(mpl.rcParams[key]) for key in [ + "font.serif", "font.sans-serif", "font.cursive", "font.fantasy", + "font.monospace"]) + ret = self._findfont_cached( + prop, fontext, directory, fallback_to_default, rebuild_if_missing, + rc_params) + if isinstance(ret, _ExceptionProxy): + raise ret.klass(ret.message) + return ret + + def get_font_names(self): + """Return the list of available fonts.""" + return list({font.name for font in self.ttflist}) + + def _find_fonts_by_props(self, prop, fontext='ttf', directory=None, + fallback_to_default=True, rebuild_if_missing=True): + """ + Find the paths to the font files most closely matching the given properties. + + Parameters + ---------- + prop : str or `~matplotlib.font_manager.FontProperties` + The font properties to search for. This can be either a + `.FontProperties` object or a string defining a + `fontconfig patterns`_. + + fontext : {'ttf', 'afm'}, default: 'ttf' + The extension of the font file: + + - 'ttf': TrueType and OpenType fonts (.ttf, .ttc, .otf) + - 'afm': Adobe Font Metrics (.afm) + + directory : str, optional + If given, only search this directory and its subdirectories. + + fallback_to_default : bool + If True, will fall back to the default font family (usually + "DejaVu Sans" or "Helvetica") if none of the families were found. + + rebuild_if_missing : bool + Whether to rebuild the font cache and search again if the first + match appears to point to a nonexisting font (i.e., the font cache + contains outdated entries). + + Returns + ------- + list[str] + The paths of the fonts found. + + Notes + ----- + This is an extension/wrapper of the original findfont API, which only + returns a single font for given font properties. Instead, this API + returns a list of filepaths of multiple fonts which closely match the + given font properties. Since this internally uses the original API, + there's no change to the logic of performing the nearest neighbor + search. See `findfont` for more details. + """ + + prop = FontProperties._from_any(prop) + + fpaths = [] + for family in prop.get_family(): + cprop = prop.copy() + cprop.set_family(family) # set current prop's family + + try: + fpaths.append( + self.findfont( + cprop, fontext, directory, + fallback_to_default=False, # don't fallback to default + rebuild_if_missing=rebuild_if_missing, + ) + ) + except ValueError: + if family in font_family_aliases: + _log.warning( + "findfont: Generic family %r not found because " + "none of the following families were found: %s", + family, ", ".join(self._expand_aliases(family)) + ) + else: + _log.warning("findfont: Font family %r not found.", family) + + # only add default family if no other font was found and + # fallback_to_default is enabled + if not fpaths: + if fallback_to_default: + dfamily = self.defaultFamily[fontext] + cprop = prop.copy() + cprop.set_family(dfamily) + fpaths.append( + self.findfont( + cprop, fontext, directory, + fallback_to_default=True, + rebuild_if_missing=rebuild_if_missing, + ) + ) + else: + raise ValueError("Failed to find any font, and fallback " + "to the default font was disabled") + + return fpaths + + @lru_cache(1024) + def _findfont_cached(self, prop, fontext, directory, fallback_to_default, + rebuild_if_missing, rc_params): + + prop = FontProperties._from_any(prop) + + fname = prop.get_file() + if fname is not None: + return fname + + if fontext == 'afm': + fontlist = self.afmlist + else: + fontlist = self.ttflist + + best_score = 1e64 + best_font = None + + _log.debug('findfont: Matching %s.', prop) + for font in fontlist: + if (directory is not None and + Path(directory) not in Path(font.fname).parents): + continue + # Matching family should have top priority, so multiply it by 10. + score = (self.score_family(prop.get_family(), font.name) * 10 + + self.score_style(prop.get_style(), font.style) + + self.score_variant(prop.get_variant(), font.variant) + + self.score_weight(prop.get_weight(), font.weight) + + self.score_stretch(prop.get_stretch(), font.stretch) + + self.score_size(prop.get_size(), font.size)) + _log.debug('findfont: score(%s) = %s', font, score) + if score < best_score: + best_score = score + best_font = font + if score == 0: + break + + if best_font is None or best_score >= 10.0: + if fallback_to_default: + _log.warning( + 'findfont: Font family %s not found. Falling back to %s.', + prop.get_family(), self.defaultFamily[fontext]) + for family in map(str.lower, prop.get_family()): + if family in font_family_aliases: + _log.warning( + "findfont: Generic family %r not found because " + "none of the following families were found: %s", + family, ", ".join(self._expand_aliases(family))) + default_prop = prop.copy() + default_prop.set_family(self.defaultFamily[fontext]) + return self.findfont(default_prop, fontext, directory, + fallback_to_default=False) + else: + # This return instead of raise is intentional, as we wish to + # cache that it was not found, which will not occur if it was + # actually raised. + return _ExceptionProxy( + ValueError, + f"Failed to find font {prop}, and fallback to the default font was " + f"disabled" + ) + else: + _log.debug('findfont: Matching %s to %s (%r) with score of %f.', + prop, best_font.name, best_font.fname, best_score) + result = best_font.fname + + if not os.path.isfile(result): + if rebuild_if_missing: + _log.info( + 'findfont: Found a missing font file. Rebuilding cache.') + new_fm = _load_fontmanager(try_read_cache=False) + # Replace self by the new fontmanager, because users may have + # a reference to this specific instance. + # TODO: _load_fontmanager should really be (used by) a method + # modifying the instance in place. + vars(self).update(vars(new_fm)) + return self.findfont( + prop, fontext, directory, rebuild_if_missing=False) + else: + # This return instead of raise is intentional, as we wish to + # cache that it was not found, which will not occur if it was + # actually raised. + return _ExceptionProxy(ValueError, "No valid font could be found") + + return _cached_realpath(result) + + +@lru_cache +def is_opentype_cff_font(filename): + """ + Return whether the given font is a Postscript Compact Font Format Font + embedded in an OpenType wrapper. Used by the PostScript and PDF backends + that cannot subset these fonts. + """ + if os.path.splitext(filename)[1].lower() == '.otf': + with open(filename, 'rb') as fd: + return fd.read(4) == b"OTTO" + else: + return False + + +@lru_cache(64) +def _get_font(font_filepaths, hinting_factor, *, _kerning_factor, thread_id): + first_fontpath, *rest = font_filepaths + return ft2font.FT2Font( + first_fontpath, hinting_factor, + _fallback_list=[ + ft2font.FT2Font( + fpath, hinting_factor, + _kerning_factor=_kerning_factor + ) + for fpath in rest + ], + _kerning_factor=_kerning_factor + ) + + +# FT2Font objects cannot be used across fork()s because they reference the same +# FT_Library object. While invalidating *all* existing FT2Fonts after a fork +# would be too complicated to be worth it, the main way FT2Fonts get reused is +# via the cache of _get_font, which we can empty upon forking (not on Windows, +# which has no fork() or register_at_fork()). +if hasattr(os, "register_at_fork"): + os.register_at_fork(after_in_child=_get_font.cache_clear) + + +@lru_cache(64) +def _cached_realpath(path): + # Resolving the path avoids embedding the font twice in pdf/ps output if a + # single font is selected using two different relative paths. + return os.path.realpath(path) + + +def get_font(font_filepaths, hinting_factor=None): + """ + Get an `.ft2font.FT2Font` object given a list of file paths. + + Parameters + ---------- + font_filepaths : Iterable[str, Path, bytes], str, Path, bytes + Relative or absolute paths to the font files to be used. + + If a single string, bytes, or `pathlib.Path`, then it will be treated + as a list with that entry only. + + If more than one filepath is passed, then the returned FT2Font object + will fall back through the fonts, in the order given, to find a needed + glyph. + + Returns + ------- + `.ft2font.FT2Font` + + """ + if isinstance(font_filepaths, (str, Path, bytes)): + paths = (_cached_realpath(font_filepaths),) + else: + paths = tuple(_cached_realpath(fname) for fname in font_filepaths) + + if hinting_factor is None: + hinting_factor = mpl.rcParams['text.hinting_factor'] + + return _get_font( + # must be a tuple to be cached + paths, + hinting_factor, + _kerning_factor=mpl.rcParams['text.kerning_factor'], + # also key on the thread ID to prevent segfaults with multi-threading + thread_id=threading.get_ident() + ) + + +def _load_fontmanager(*, try_read_cache=True): + fm_path = Path( + mpl.get_cachedir(), f"fontlist-v{FontManager.__version__}.json") + if try_read_cache: + try: + fm = json_load(fm_path) + except Exception: + pass + else: + if getattr(fm, "_version", object()) == FontManager.__version__: + _log.debug("Using fontManager instance from %s", fm_path) + return fm + fm = FontManager() + json_dump(fm, fm_path) + _log.info("generated new fontManager") + return fm + + +fontManager = _load_fontmanager() +findfont = fontManager.findfont +get_font_names = fontManager.get_font_names diff --git a/venv/lib/python3.10/site-packages/matplotlib/font_manager.pyi b/venv/lib/python3.10/site-packages/matplotlib/font_manager.pyi new file mode 100644 index 00000000..48d0e362 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/font_manager.pyi @@ -0,0 +1,136 @@ +from dataclasses import dataclass +import os + +from matplotlib._afm import AFM +from matplotlib import ft2font + +from pathlib import Path + +from collections.abc import Iterable +from typing import Any, Literal + +font_scalings: dict[str | None, float] +stretch_dict: dict[str, int] +weight_dict: dict[str, int] +font_family_aliases: set[str] +MSFolders: str +MSFontDirectories: list[str] +MSUserFontDirectories: list[str] +X11FontDirectories: list[str] +OSXFontDirectories: list[str] + +def get_fontext_synonyms(fontext: str) -> list[str]: ... +def list_fonts(directory: str, extensions: Iterable[str]) -> list[str]: ... +def win32FontDirectory() -> str: ... +def _get_fontconfig_fonts() -> list[Path]: ... +def findSystemFonts( + fontpaths: Iterable[str | os.PathLike | Path] | None = ..., fontext: str = ... +) -> list[str]: ... +@dataclass +class FontEntry: + fname: str = ... + name: str = ... + style: str = ... + variant: str = ... + weight: str | int = ... + stretch: str = ... + size: str = ... + def _repr_html_(self) -> str: ... + def _repr_png_(self) -> bytes: ... + +def ttfFontProperty(font: ft2font.FT2Font) -> FontEntry: ... +def afmFontProperty(fontpath: str, font: AFM) -> FontEntry: ... + +class FontProperties: + def __init__( + self, + family: str | Iterable[str] | None = ..., + style: Literal["normal", "italic", "oblique"] | None = ..., + variant: Literal["normal", "small-caps"] | None = ..., + weight: int | str | None = ..., + stretch: int | str | None = ..., + size: float | str | None = ..., + fname: str | os.PathLike | Path | None = ..., + math_fontfamily: str | None = ..., + ) -> None: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def get_family(self) -> list[str]: ... + def get_name(self) -> str: ... + def get_style(self) -> Literal["normal", "italic", "oblique"]: ... + def get_variant(self) -> Literal["normal", "small-caps"]: ... + def get_weight(self) -> int | str: ... + def get_stretch(self) -> int | str: ... + def get_size(self) -> float: ... + def get_file(self) -> str | bytes | None: ... + def get_fontconfig_pattern(self) -> dict[str, list[Any]]: ... + def set_family(self, family: str | Iterable[str] | None) -> None: ... + def set_style( + self, style: Literal["normal", "italic", "oblique"] | None + ) -> None: ... + def set_variant(self, variant: Literal["normal", "small-caps"] | None) -> None: ... + def set_weight(self, weight: int | str | None) -> None: ... + def set_stretch(self, stretch: int | str | None) -> None: ... + def set_size(self, size: float | str | None) -> None: ... + def set_file(self, file: str | os.PathLike | Path | None) -> None: ... + def set_fontconfig_pattern(self, pattern: str) -> None: ... + def get_math_fontfamily(self) -> str: ... + def set_math_fontfamily(self, fontfamily: str | None) -> None: ... + def copy(self) -> FontProperties: ... + # Aliases + set_name = set_family + get_slant = get_style + set_slant = set_style + get_size_in_points = get_size + +def json_dump(data: FontManager, filename: str | Path | os.PathLike) -> None: ... +def json_load(filename: str | Path | os.PathLike) -> FontManager: ... + +class FontManager: + __version__: int + default_size: float | None + defaultFamily: dict[str, str] + afmlist: list[FontEntry] + ttflist: list[FontEntry] + def __init__(self, size: float | None = ..., weight: str = ...) -> None: ... + def addfont(self, path: str | Path | os.PathLike) -> None: ... + @property + def defaultFont(self) -> dict[str, str]: ... + def get_default_weight(self) -> str: ... + @staticmethod + def get_default_size() -> float: ... + def set_default_weight(self, weight: str) -> None: ... + def score_family( + self, families: str | list[str] | tuple[str], family2: str + ) -> float: ... + def score_style(self, style1: str, style2: str) -> float: ... + def score_variant(self, variant1: str, variant2: str) -> float: ... + def score_stretch(self, stretch1: str | int, stretch2: str | int) -> float: ... + def score_weight(self, weight1: str | float, weight2: str | float) -> float: ... + def score_size(self, size1: str | float, size2: str | float) -> float: ... + def findfont( + self, + prop: str | FontProperties, + fontext: Literal["ttf", "afm"] = ..., + directory: str | None = ..., + fallback_to_default: bool = ..., + rebuild_if_missing: bool = ..., + ) -> str: ... + def get_font_names(self) -> list[str]: ... + +def is_opentype_cff_font(filename: str) -> bool: ... +def get_font( + font_filepaths: Iterable[str | Path | bytes] | str | Path | bytes, + hinting_factor: int | None = ..., +) -> ft2font.FT2Font: ... + +fontManager: FontManager + +def findfont( + prop: str | FontProperties, + fontext: Literal["ttf", "afm"] = ..., + directory: str | None = ..., + fallback_to_default: bool = ..., + rebuild_if_missing: bool = ..., +) -> str: ... +def get_font_names() -> list[str]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/ft2font.cpython-310-x86_64-linux-gnu.so b/venv/lib/python3.10/site-packages/matplotlib/ft2font.cpython-310-x86_64-linux-gnu.so new file mode 100755 index 00000000..178930a0 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/ft2font.cpython-310-x86_64-linux-gnu.so differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/ft2font.pyi b/venv/lib/python3.10/site-packages/matplotlib/ft2font.pyi new file mode 100644 index 00000000..6a0716e9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/ft2font.pyi @@ -0,0 +1,253 @@ +from typing import BinaryIO, Literal, TypedDict, overload + +import numpy as np +from numpy.typing import NDArray + +__freetype_build_type__: str +__freetype_version__: str +BOLD: int +EXTERNAL_STREAM: int +FAST_GLYPHS: int +FIXED_SIZES: int +FIXED_WIDTH: int +GLYPH_NAMES: int +HORIZONTAL: int +ITALIC: int +KERNING: int +KERNING_DEFAULT: int +KERNING_UNFITTED: int +KERNING_UNSCALED: int +LOAD_CROP_BITMAP: int +LOAD_DEFAULT: int +LOAD_FORCE_AUTOHINT: int +LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH: int +LOAD_IGNORE_TRANSFORM: int +LOAD_LINEAR_DESIGN: int +LOAD_MONOCHROME: int +LOAD_NO_AUTOHINT: int +LOAD_NO_BITMAP: int +LOAD_NO_HINTING: int +LOAD_NO_RECURSE: int +LOAD_NO_SCALE: int +LOAD_PEDANTIC: int +LOAD_RENDER: int +LOAD_TARGET_LCD: int +LOAD_TARGET_LCD_V: int +LOAD_TARGET_LIGHT: int +LOAD_TARGET_MONO: int +LOAD_TARGET_NORMAL: int +LOAD_VERTICAL_LAYOUT: int +MULTIPLE_MASTERS: int +SCALABLE: int +SFNT: int +VERTICAL: int + +class _SfntHeadDict(TypedDict): + version: tuple[int, int] + fontRevision: tuple[int, int] + checkSumAdjustment: int + magicNumber: int + flags: int + unitsPerEm: int + created: tuple[int, int] + modified: tuple[int, int] + xMin: int + yMin: int + xMax: int + yMax: int + macStyle: int + lowestRecPPEM: int + fontDirectionHint: int + indexToLocFormat: int + glyphDataFormat: int + +class _SfntMaxpDict(TypedDict): + version: tuple[int, int] + numGlyphs: int + maxPoints: int + maxContours: int + maxComponentPoints: int + maxComponentContours: int + maxZones: int + maxTwilightPoints: int + maxStorage: int + maxFunctionDefs: int + maxInstructionDefs: int + maxStackElements: int + maxSizeOfInstructions: int + maxComponentElements: int + maxComponentDepth: int + +class _SfntOs2Dict(TypedDict): + version: int + xAvgCharWidth: int + usWeightClass: int + usWidthClass: int + fsType: int + ySubscriptXSize: int + ySubscriptYSize: int + ySubscriptXOffset: int + ySubscriptYOffset: int + ySuperscriptXSize: int + ySuperscriptYSize: int + ySuperscriptXOffset: int + ySuperscriptYOffset: int + yStrikeoutSize: int + yStrikeoutPosition: int + sFamilyClass: int + panose: bytes + ulCharRange: tuple[int, int, int, int] + achVendID: bytes + fsSelection: int + fsFirstCharIndex: int + fsLastCharIndex: int + +class _SfntHheaDict(TypedDict): + version: tuple[int, int] + ascent: int + descent: int + lineGap: int + advanceWidthMax: int + minLeftBearing: int + minRightBearing: int + xMaxExtent: int + caretSlopeRise: int + caretSlopeRun: int + caretOffset: int + metricDataFormat: int + numOfLongHorMetrics: int + +class _SfntVheaDict(TypedDict): + version: tuple[int, int] + vertTypoAscender: int + vertTypoDescender: int + vertTypoLineGap: int + advanceHeightMax: int + minTopSideBearing: int + minBottomSizeBearing: int + yMaxExtent: int + caretSlopeRise: int + caretSlopeRun: int + caretOffset: int + metricDataFormat: int + numOfLongVerMetrics: int + +class _SfntPostDict(TypedDict): + format: tuple[int, int] + italicAngle: tuple[int, int] + underlinePosition: int + underlineThickness: int + isFixedPitch: int + minMemType42: int + maxMemType42: int + minMemType1: int + maxMemType1: int + +class _SfntPcltDict(TypedDict): + version: tuple[int, int] + fontNumber: int + pitch: int + xHeight: int + style: int + typeFamily: int + capHeight: int + symbolSet: int + typeFace: bytes + characterComplement: bytes + strokeWeight: int + widthType: int + serifStyle: int + +class FT2Font: + ascender: int + bbox: tuple[int, int, int, int] + descender: int + face_flags: int + family_name: str + fname: str + height: int + max_advance_height: int + max_advance_width: int + num_charmaps: int + num_faces: int + num_fixed_sizes: int + num_glyphs: int + postscript_name: str + scalable: bool + style_flags: int + style_name: str + underline_position: int + underline_thickness: int + units_per_EM: int + + def __init__( + self, + filename: str | BinaryIO, + hinting_factor: int = ..., + *, + _fallback_list: list[FT2Font] | None = ..., + _kerning_factor: int = ... + ) -> None: ... + def _get_fontmap(self, string: str) -> dict[str, FT2Font]: ... + def clear(self) -> None: ... + def draw_glyph_to_bitmap( + self, image: FT2Image, x: float, y: float, glyph: Glyph, antialiased: bool = ... + ) -> None: ... + def draw_glyphs_to_bitmap(self, antialiased: bool = ...) -> None: ... + def get_bitmap_offset(self) -> tuple[int, int]: ... + def get_char_index(self, codepoint: int) -> int: ... + def get_charmap(self) -> dict[int, int]: ... + def get_descent(self) -> int: ... + def get_glyph_name(self, index: int) -> str: ... + def get_image(self) -> NDArray[np.uint8]: ... + def get_kerning(self, left: int, right: int, mode: int) -> int: ... + def get_name_index(self, name: str) -> int: ... + def get_num_glyphs(self) -> int: ... + def get_path(self) -> tuple[NDArray[np.float64], NDArray[np.int8]]: ... + def get_ps_font_info( + self, + ) -> tuple[str, str, str, str, str, int, int, int, int]: ... + def get_sfnt(self) -> dict[tuple[int, int, int, int], bytes]: ... + @overload + def get_sfnt_table(self, name: Literal["head"]) -> _SfntHeadDict | None: ... + @overload + def get_sfnt_table(self, name: Literal["maxp"]) -> _SfntMaxpDict | None: ... + @overload + def get_sfnt_table(self, name: Literal["OS/2"]) -> _SfntOs2Dict | None: ... + @overload + def get_sfnt_table(self, name: Literal["hhea"]) -> _SfntHheaDict | None: ... + @overload + def get_sfnt_table(self, name: Literal["vhea"]) -> _SfntVheaDict | None: ... + @overload + def get_sfnt_table(self, name: Literal["post"]) -> _SfntPostDict | None: ... + @overload + def get_sfnt_table(self, name: Literal["pclt"]) -> _SfntPcltDict | None: ... + def get_width_height(self) -> tuple[int, int]: ... + def get_xys(self, antialiased: bool = ...) -> NDArray[np.float64]: ... + def load_char(self, charcode: int, flags: int = ...) -> Glyph: ... + def load_glyph(self, glyphindex: int, flags: int = ...) -> Glyph: ... + def select_charmap(self, i: int) -> None: ... + def set_charmap(self, i: int) -> None: ... + def set_size(self, ptsize: float, dpi: float) -> None: ... + def set_text( + self, string: str, angle: float = ..., flags: int = ... + ) -> NDArray[np.float64]: ... + +class FT2Image: # TODO: When updating mypy>=1.4, subclass from Buffer. + def __init__(self, width: float, height: float) -> None: ... + def draw_rect(self, x0: float, y0: float, x1: float, y1: float) -> None: ... + def draw_rect_filled(self, x0: float, y0: float, x1: float, y1: float) -> None: ... + +class Glyph: + width: int + height: int + horiBearingX: int + horiBearingY: int + horiAdvance: int + linearHoriAdvance: int + vertBearingX: int + vertBearingY: int + vertAdvance: int + + @property + def bbox(self) -> tuple[int, int, int, int]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/gridspec.py b/venv/lib/python3.10/site-packages/matplotlib/gridspec.py new file mode 100644 index 00000000..c6b363d3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/gridspec.py @@ -0,0 +1,788 @@ +r""" +:mod:`~matplotlib.gridspec` contains classes that help to layout multiple +`~.axes.Axes` in a grid-like pattern within a figure. + +The `GridSpec` specifies the overall grid structure. Individual cells within +the grid are referenced by `SubplotSpec`\s. + +Often, users need not access this module directly, and can use higher-level +methods like `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` and +`~.Figure.subfigures`. See the tutorial :ref:`arranging_axes` for a guide. +""" + +import copy +import logging +from numbers import Integral + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, _pylab_helpers, _tight_layout +from matplotlib.transforms import Bbox + +_log = logging.getLogger(__name__) + + +class GridSpecBase: + """ + A base class of GridSpec that specifies the geometry of the grid + that a subplot will be placed. + """ + + def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None): + """ + Parameters + ---------- + nrows, ncols : int + The number of rows and columns of the grid. + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. + """ + if not isinstance(nrows, Integral) or nrows <= 0: + raise ValueError( + f"Number of rows must be a positive integer, not {nrows!r}") + if not isinstance(ncols, Integral) or ncols <= 0: + raise ValueError( + f"Number of columns must be a positive integer, not {ncols!r}") + self._nrows, self._ncols = nrows, ncols + self.set_height_ratios(height_ratios) + self.set_width_ratios(width_ratios) + + def __repr__(self): + height_arg = (f', height_ratios={self._row_height_ratios!r}' + if len(set(self._row_height_ratios)) != 1 else '') + width_arg = (f', width_ratios={self._col_width_ratios!r}' + if len(set(self._col_width_ratios)) != 1 else '') + return '{clsname}({nrows}, {ncols}{optionals})'.format( + clsname=self.__class__.__name__, + nrows=self._nrows, + ncols=self._ncols, + optionals=height_arg + width_arg, + ) + + nrows = property(lambda self: self._nrows, + doc="The number of rows in the grid.") + ncols = property(lambda self: self._ncols, + doc="The number of columns in the grid.") + + def get_geometry(self): + """ + Return a tuple containing the number of rows and columns in the grid. + """ + return self._nrows, self._ncols + + def get_subplot_params(self, figure=None): + # Must be implemented in subclasses + pass + + def new_subplotspec(self, loc, rowspan=1, colspan=1): + """ + Create and return a `.SubplotSpec` instance. + + Parameters + ---------- + loc : (int, int) + The position of the subplot in the grid as + ``(row_index, column_index)``. + rowspan, colspan : int, default: 1 + The number of rows and columns the subplot should span in the grid. + """ + loc1, loc2 = loc + subplotspec = self[loc1:loc1+rowspan, loc2:loc2+colspan] + return subplotspec + + def set_width_ratios(self, width_ratios): + """ + Set the relative widths of the columns. + + *width_ratios* must be of length *ncols*. Each column gets a relative + width of ``width_ratios[i] / sum(width_ratios)``. + """ + if width_ratios is None: + width_ratios = [1] * self._ncols + elif len(width_ratios) != self._ncols: + raise ValueError('Expected the given number of width ratios to ' + 'match the number of columns of the grid') + self._col_width_ratios = width_ratios + + def get_width_ratios(self): + """ + Return the width ratios. + + This is *None* if no width ratios have been set explicitly. + """ + return self._col_width_ratios + + def set_height_ratios(self, height_ratios): + """ + Set the relative heights of the rows. + + *height_ratios* must be of length *nrows*. Each row gets a relative + height of ``height_ratios[i] / sum(height_ratios)``. + """ + if height_ratios is None: + height_ratios = [1] * self._nrows + elif len(height_ratios) != self._nrows: + raise ValueError('Expected the given number of height ratios to ' + 'match the number of rows of the grid') + self._row_height_ratios = height_ratios + + def get_height_ratios(self): + """ + Return the height ratios. + + This is *None* if no height ratios have been set explicitly. + """ + return self._row_height_ratios + + def get_grid_positions(self, fig): + """ + Return the positions of the grid cells in figure coordinates. + + Parameters + ---------- + fig : `~matplotlib.figure.Figure` + The figure the grid should be applied to. The subplot parameters + (margins and spacing between subplots) are taken from *fig*. + + Returns + ------- + bottoms, tops, lefts, rights : array + The bottom, top, left, right positions of the grid cells in + figure coordinates. + """ + nrows, ncols = self.get_geometry() + subplot_params = self.get_subplot_params(fig) + left = subplot_params.left + right = subplot_params.right + bottom = subplot_params.bottom + top = subplot_params.top + wspace = subplot_params.wspace + hspace = subplot_params.hspace + tot_width = right - left + tot_height = top - bottom + + # calculate accumulated heights of columns + cell_h = tot_height / (nrows + hspace*(nrows-1)) + sep_h = hspace * cell_h + norm = cell_h * nrows / sum(self._row_height_ratios) + cell_heights = [r * norm for r in self._row_height_ratios] + sep_heights = [0] + ([sep_h] * (nrows-1)) + cell_hs = np.cumsum(np.column_stack([sep_heights, cell_heights]).flat) + + # calculate accumulated widths of rows + cell_w = tot_width / (ncols + wspace*(ncols-1)) + sep_w = wspace * cell_w + norm = cell_w * ncols / sum(self._col_width_ratios) + cell_widths = [r * norm for r in self._col_width_ratios] + sep_widths = [0] + ([sep_w] * (ncols-1)) + cell_ws = np.cumsum(np.column_stack([sep_widths, cell_widths]).flat) + + fig_tops, fig_bottoms = (top - cell_hs).reshape((-1, 2)).T + fig_lefts, fig_rights = (left + cell_ws).reshape((-1, 2)).T + return fig_bottoms, fig_tops, fig_lefts, fig_rights + + @staticmethod + def _check_gridspec_exists(figure, nrows, ncols): + """ + Check if the figure already has a gridspec with these dimensions, + or create a new one + """ + for ax in figure.get_axes(): + gs = ax.get_gridspec() + if gs is not None: + if hasattr(gs, 'get_topmost_subplotspec'): + # This is needed for colorbar gridspec layouts. + # This is probably OK because this whole logic tree + # is for when the user is doing simple things with the + # add_subplot command. For complicated layouts + # like subgridspecs the proper gridspec is passed in... + gs = gs.get_topmost_subplotspec().get_gridspec() + if gs.get_geometry() == (nrows, ncols): + return gs + # else gridspec not found: + return GridSpec(nrows, ncols, figure=figure) + + def __getitem__(self, key): + """Create and return a `.SubplotSpec` instance.""" + nrows, ncols = self.get_geometry() + + def _normalize(key, size, axis): # Includes last index. + orig_key = key + if isinstance(key, slice): + start, stop, _ = key.indices(size) + if stop > start: + return start, stop - 1 + raise IndexError("GridSpec slice would result in no space " + "allocated for subplot") + else: + if key < 0: + key = key + size + if 0 <= key < size: + return key, key + elif axis is not None: + raise IndexError(f"index {orig_key} is out of bounds for " + f"axis {axis} with size {size}") + else: # flat index + raise IndexError(f"index {orig_key} is out of bounds for " + f"GridSpec with size {size}") + + if isinstance(key, tuple): + try: + k1, k2 = key + except ValueError as err: + raise ValueError("Unrecognized subplot spec") from err + num1, num2 = np.ravel_multi_index( + [_normalize(k1, nrows, 0), _normalize(k2, ncols, 1)], + (nrows, ncols)) + else: # Single key + num1, num2 = _normalize(key, nrows * ncols, None) + + return SubplotSpec(self, num1, num2) + + def subplots(self, *, sharex=False, sharey=False, squeeze=True, + subplot_kw=None): + """ + Add all subplots specified by this `GridSpec` to its parent figure. + + See `.Figure.subplots` for detailed documentation. + """ + + figure = self.figure + + if figure is None: + raise ValueError("GridSpec.subplots() only works for GridSpecs " + "created with a parent figure") + + if not isinstance(sharex, str): + sharex = "all" if sharex else "none" + if not isinstance(sharey, str): + sharey = "all" if sharey else "none" + + _api.check_in_list(["all", "row", "col", "none", False, True], + sharex=sharex, sharey=sharey) + if subplot_kw is None: + subplot_kw = {} + # don't mutate kwargs passed by user... + subplot_kw = subplot_kw.copy() + + # Create array to hold all Axes. + axarr = np.empty((self._nrows, self._ncols), dtype=object) + for row in range(self._nrows): + for col in range(self._ncols): + shared_with = {"none": None, "all": axarr[0, 0], + "row": axarr[row, 0], "col": axarr[0, col]} + subplot_kw["sharex"] = shared_with[sharex] + subplot_kw["sharey"] = shared_with[sharey] + axarr[row, col] = figure.add_subplot( + self[row, col], **subplot_kw) + + # turn off redundant tick labeling + if sharex in ["col", "all"]: + for ax in axarr.flat: + ax._label_outer_xaxis(skip_non_rectangular_axes=True) + if sharey in ["row", "all"]: + for ax in axarr.flat: + ax._label_outer_yaxis(skip_non_rectangular_axes=True) + + if squeeze: + # Discarding unneeded dimensions that equal 1. If we only have one + # subplot, just return it instead of a 1-element array. + return axarr.item() if axarr.size == 1 else axarr.squeeze() + else: + # Returned axis array will be always 2-d, even if nrows=ncols=1. + return axarr + + +class GridSpec(GridSpecBase): + """ + A grid layout to place subplots within a figure. + + The location of the grid cells is determined in a similar way to + `.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace* + and *hspace*. + + Indexing a GridSpec instance returns a `.SubplotSpec`. + """ + def __init__(self, nrows, ncols, figure=None, + left=None, bottom=None, right=None, top=None, + wspace=None, hspace=None, + width_ratios=None, height_ratios=None): + """ + Parameters + ---------- + nrows, ncols : int + The number of rows and columns of the grid. + + figure : `.Figure`, optional + Only used for constrained layout to create a proper layoutgrid. + + left, right, top, bottom : float, optional + Extent of the subplots as a fraction of figure width or height. + Left cannot be larger than right, and bottom cannot be larger than + top. If not given, the values will be inferred from a figure or + rcParams at draw time. See also `GridSpec.get_subplot_params`. + + wspace : float, optional + The amount of width reserved for space between subplots, + expressed as a fraction of the average axis width. + If not given, the values will be inferred from a figure or + rcParams when necessary. See also `GridSpec.get_subplot_params`. + + hspace : float, optional + The amount of height reserved for space between subplots, + expressed as a fraction of the average axis height. + If not given, the values will be inferred from a figure or + rcParams when necessary. See also `GridSpec.get_subplot_params`. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. + + """ + self.left = left + self.bottom = bottom + self.right = right + self.top = top + self.wspace = wspace + self.hspace = hspace + self.figure = figure + + super().__init__(nrows, ncols, + width_ratios=width_ratios, + height_ratios=height_ratios) + + _AllowedKeys = ["left", "bottom", "right", "top", "wspace", "hspace"] + + def update(self, **kwargs): + """ + Update the subplot parameters of the grid. + + Parameters that are not explicitly given are not changed. Setting a + parameter to *None* resets it to :rc:`figure.subplot.*`. + + Parameters + ---------- + left, right, top, bottom : float or None, optional + Extent of the subplots as a fraction of figure width or height. + wspace, hspace : float, optional + Spacing between the subplots as a fraction of the average subplot + width / height. + """ + for k, v in kwargs.items(): + if k in self._AllowedKeys: + setattr(self, k, v) + else: + raise AttributeError(f"{k} is an unknown keyword") + for figmanager in _pylab_helpers.Gcf.figs.values(): + for ax in figmanager.canvas.figure.axes: + if ax.get_subplotspec() is not None: + ss = ax.get_subplotspec().get_topmost_subplotspec() + if ss.get_gridspec() == self: + ax._set_position( + ax.get_subplotspec().get_position(ax.figure)) + + def get_subplot_params(self, figure=None): + """ + Return the `.SubplotParams` for the GridSpec. + + In order of precedence the values are taken from + + - non-*None* attributes of the GridSpec + - the provided *figure* + - :rc:`figure.subplot.*` + + Note that the ``figure`` attribute of the GridSpec is always ignored. + """ + if figure is None: + kw = {k: mpl.rcParams["figure.subplot."+k] + for k in self._AllowedKeys} + subplotpars = SubplotParams(**kw) + else: + subplotpars = copy.copy(figure.subplotpars) + + subplotpars.update(**{k: getattr(self, k) for k in self._AllowedKeys}) + + return subplotpars + + def locally_modified_subplot_params(self): + """ + Return a list of the names of the subplot parameters explicitly set + in the GridSpec. + + This is a subset of the attributes of `.SubplotParams`. + """ + return [k for k in self._AllowedKeys if getattr(self, k)] + + def tight_layout(self, figure, renderer=None, + pad=1.08, h_pad=None, w_pad=None, rect=None): + """ + Adjust subplot parameters to give specified padding. + + Parameters + ---------- + figure : `.Figure` + The figure. + renderer : `.RendererBase` subclass, optional + The renderer to be used. + pad : float + Padding between the figure edge and the edges of subplots, as a + fraction of the font-size. + h_pad, w_pad : float, optional + Padding (height/width) between edges of adjacent subplots. + Defaults to *pad*. + rect : tuple (left, bottom, right, top), default: None + (left, bottom, right, top) rectangle in normalized figure + coordinates that the whole subplots area (including labels) will + fit into. Default (None) is the whole figure. + """ + if renderer is None: + renderer = figure._get_renderer() + kwargs = _tight_layout.get_tight_layout_figure( + figure, figure.axes, + _tight_layout.get_subplotspec_list(figure.axes, grid_spec=self), + renderer, pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) + if kwargs: + self.update(**kwargs) + + +class GridSpecFromSubplotSpec(GridSpecBase): + """ + GridSpec whose subplot layout parameters are inherited from the + location specified by a given SubplotSpec. + """ + def __init__(self, nrows, ncols, + subplot_spec, + wspace=None, hspace=None, + height_ratios=None, width_ratios=None): + """ + Parameters + ---------- + nrows, ncols : int + Number of rows and number of columns of the grid. + subplot_spec : SubplotSpec + Spec from which the layout parameters are inherited. + wspace, hspace : float, optional + See `GridSpec` for more details. If not specified default values + (from the figure or rcParams) are used. + height_ratios : array-like of length *nrows*, optional + See `GridSpecBase` for details. + width_ratios : array-like of length *ncols*, optional + See `GridSpecBase` for details. + """ + self._wspace = wspace + self._hspace = hspace + if isinstance(subplot_spec, SubplotSpec): + self._subplot_spec = subplot_spec + else: + raise TypeError( + "subplot_spec must be type SubplotSpec, " + "usually from GridSpec, or axes.get_subplotspec.") + self.figure = self._subplot_spec.get_gridspec().figure + super().__init__(nrows, ncols, + width_ratios=width_ratios, + height_ratios=height_ratios) + + def get_subplot_params(self, figure=None): + """Return a dictionary of subplot layout parameters.""" + hspace = (self._hspace if self._hspace is not None + else figure.subplotpars.hspace if figure is not None + else mpl.rcParams["figure.subplot.hspace"]) + wspace = (self._wspace if self._wspace is not None + else figure.subplotpars.wspace if figure is not None + else mpl.rcParams["figure.subplot.wspace"]) + + figbox = self._subplot_spec.get_position(figure) + left, bottom, right, top = figbox.extents + + return SubplotParams(left=left, right=right, + bottom=bottom, top=top, + wspace=wspace, hspace=hspace) + + def get_topmost_subplotspec(self): + """ + Return the topmost `.SubplotSpec` instance associated with the subplot. + """ + return self._subplot_spec.get_topmost_subplotspec() + + +class SubplotSpec: + """ + The location of a subplot in a `GridSpec`. + + .. note:: + + Likely, you will never instantiate a `SubplotSpec` yourself. Instead, + you will typically obtain one from a `GridSpec` using item-access. + + Parameters + ---------- + gridspec : `~matplotlib.gridspec.GridSpec` + The GridSpec, which the subplot is referencing. + num1, num2 : int + The subplot will occupy the *num1*-th cell of the given + *gridspec*. If *num2* is provided, the subplot will span between + *num1*-th cell and *num2*-th cell **inclusive**. + + The index starts from 0. + """ + def __init__(self, gridspec, num1, num2=None): + self._gridspec = gridspec + self.num1 = num1 + self.num2 = num2 + + def __repr__(self): + return (f"{self.get_gridspec()}[" + f"{self.rowspan.start}:{self.rowspan.stop}, " + f"{self.colspan.start}:{self.colspan.stop}]") + + @staticmethod + def _from_subplot_args(figure, args): + """ + Construct a `.SubplotSpec` from a parent `.Figure` and either + + - a `.SubplotSpec` -- returned as is; + - one or three numbers -- a MATLAB-style subplot specifier. + """ + if len(args) == 1: + arg, = args + if isinstance(arg, SubplotSpec): + return arg + elif not isinstance(arg, Integral): + raise ValueError( + f"Single argument to subplot must be a three-digit " + f"integer, not {arg!r}") + try: + rows, cols, num = map(int, str(arg)) + except ValueError: + raise ValueError( + f"Single argument to subplot must be a three-digit " + f"integer, not {arg!r}") from None + elif len(args) == 3: + rows, cols, num = args + else: + raise _api.nargs_error("subplot", takes="1 or 3", given=len(args)) + + gs = GridSpec._check_gridspec_exists(figure, rows, cols) + if gs is None: + gs = GridSpec(rows, cols, figure=figure) + if isinstance(num, tuple) and len(num) == 2: + if not all(isinstance(n, Integral) for n in num): + raise ValueError( + f"Subplot specifier tuple must contain integers, not {num}" + ) + i, j = num + else: + if not isinstance(num, Integral) or num < 1 or num > rows*cols: + raise ValueError( + f"num must be an integer with 1 <= num <= {rows*cols}, " + f"not {num!r}" + ) + i = j = num + return gs[i-1:j] + + # num2 is a property only to handle the case where it is None and someone + # mutates num1. + + @property + def num2(self): + return self.num1 if self._num2 is None else self._num2 + + @num2.setter + def num2(self, value): + self._num2 = value + + def get_gridspec(self): + return self._gridspec + + def get_geometry(self): + """ + Return the subplot geometry as tuple ``(n_rows, n_cols, start, stop)``. + + The indices *start* and *stop* define the range of the subplot within + the `GridSpec`. *stop* is inclusive (i.e. for a single cell + ``start == stop``). + """ + rows, cols = self.get_gridspec().get_geometry() + return rows, cols, self.num1, self.num2 + + @property + def rowspan(self): + """The rows spanned by this subplot, as a `range` object.""" + ncols = self.get_gridspec().ncols + return range(self.num1 // ncols, self.num2 // ncols + 1) + + @property + def colspan(self): + """The columns spanned by this subplot, as a `range` object.""" + ncols = self.get_gridspec().ncols + # We explicitly support num2 referring to a column on num1's *left*, so + # we must sort the column indices here so that the range makes sense. + c1, c2 = sorted([self.num1 % ncols, self.num2 % ncols]) + return range(c1, c2 + 1) + + def is_first_row(self): + return self.rowspan.start == 0 + + def is_last_row(self): + return self.rowspan.stop == self.get_gridspec().nrows + + def is_first_col(self): + return self.colspan.start == 0 + + def is_last_col(self): + return self.colspan.stop == self.get_gridspec().ncols + + def get_position(self, figure): + """ + Update the subplot position from ``figure.subplotpars``. + """ + gridspec = self.get_gridspec() + nrows, ncols = gridspec.get_geometry() + rows, cols = np.unravel_index([self.num1, self.num2], (nrows, ncols)) + fig_bottoms, fig_tops, fig_lefts, fig_rights = \ + gridspec.get_grid_positions(figure) + + fig_bottom = fig_bottoms[rows].min() + fig_top = fig_tops[rows].max() + fig_left = fig_lefts[cols].min() + fig_right = fig_rights[cols].max() + return Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) + + def get_topmost_subplotspec(self): + """ + Return the topmost `SubplotSpec` instance associated with the subplot. + """ + gridspec = self.get_gridspec() + if hasattr(gridspec, "get_topmost_subplotspec"): + return gridspec.get_topmost_subplotspec() + else: + return self + + def __eq__(self, other): + """ + Two SubplotSpecs are considered equal if they refer to the same + position(s) in the same `GridSpec`. + """ + # other may not even have the attributes we are checking. + return ((self._gridspec, self.num1, self.num2) + == (getattr(other, "_gridspec", object()), + getattr(other, "num1", object()), + getattr(other, "num2", object()))) + + def __hash__(self): + return hash((self._gridspec, self.num1, self.num2)) + + def subgridspec(self, nrows, ncols, **kwargs): + """ + Create a GridSpec within this subplot. + + The created `.GridSpecFromSubplotSpec` will have this `SubplotSpec` as + a parent. + + Parameters + ---------- + nrows : int + Number of rows in grid. + + ncols : int + Number of columns in grid. + + Returns + ------- + `.GridSpecFromSubplotSpec` + + Other Parameters + ---------------- + **kwargs + All other parameters are passed to `.GridSpecFromSubplotSpec`. + + See Also + -------- + matplotlib.pyplot.subplots + + Examples + -------- + Adding three subplots in the space occupied by a single subplot:: + + fig = plt.figure() + gs0 = fig.add_gridspec(3, 1) + ax1 = fig.add_subplot(gs0[0]) + ax2 = fig.add_subplot(gs0[1]) + gssub = gs0[2].subgridspec(1, 3) + for i in range(3): + fig.add_subplot(gssub[0, i]) + """ + return GridSpecFromSubplotSpec(nrows, ncols, self, **kwargs) + + +class SubplotParams: + """ + Parameters defining the positioning of a subplots grid in a figure. + """ + + def __init__(self, left=None, bottom=None, right=None, top=None, + wspace=None, hspace=None): + """ + Defaults are given by :rc:`figure.subplot.[name]`. + + Parameters + ---------- + left : float + The position of the left edge of the subplots, + as a fraction of the figure width. + right : float + The position of the right edge of the subplots, + as a fraction of the figure width. + bottom : float + The position of the bottom edge of the subplots, + as a fraction of the figure height. + top : float + The position of the top edge of the subplots, + as a fraction of the figure height. + wspace : float + The width of the padding between subplots, + as a fraction of the average Axes width. + hspace : float + The height of the padding between subplots, + as a fraction of the average Axes height. + """ + for key in ["left", "bottom", "right", "top", "wspace", "hspace"]: + setattr(self, key, mpl.rcParams[f"figure.subplot.{key}"]) + self.update(left, bottom, right, top, wspace, hspace) + + def update(self, left=None, bottom=None, right=None, top=None, + wspace=None, hspace=None): + """ + Update the dimensions of the passed parameters. *None* means unchanged. + """ + if ((left if left is not None else self.left) + >= (right if right is not None else self.right)): + raise ValueError('left cannot be >= right') + if ((bottom if bottom is not None else self.bottom) + >= (top if top is not None else self.top)): + raise ValueError('bottom cannot be >= top') + if left is not None: + self.left = left + if right is not None: + self.right = right + if bottom is not None: + self.bottom = bottom + if top is not None: + self.top = top + if wspace is not None: + self.wspace = wspace + if hspace is not None: + self.hspace = hspace diff --git a/venv/lib/python3.10/site-packages/matplotlib/gridspec.pyi b/venv/lib/python3.10/site-packages/matplotlib/gridspec.pyi new file mode 100644 index 00000000..1ac1bb0b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/gridspec.pyi @@ -0,0 +1,160 @@ +from typing import Any, Literal, overload + +from numpy.typing import ArrayLike +import numpy as np + +from matplotlib.axes import Axes, SubplotBase +from matplotlib.backend_bases import RendererBase +from matplotlib.figure import Figure +from matplotlib.transforms import Bbox + +class GridSpecBase: + def __init__( + self, + nrows: int, + ncols: int, + height_ratios: ArrayLike | None = ..., + width_ratios: ArrayLike | None = ..., + ) -> None: ... + @property + def nrows(self) -> int: ... + @property + def ncols(self) -> int: ... + def get_geometry(self) -> tuple[int, int]: ... + def get_subplot_params(self, figure: Figure | None = ...) -> SubplotParams: ... + def new_subplotspec( + self, loc: tuple[int, int], rowspan: int = ..., colspan: int = ... + ) -> SubplotSpec: ... + def set_width_ratios(self, width_ratios: ArrayLike | None) -> None: ... + def get_width_ratios(self) -> ArrayLike: ... + def set_height_ratios(self, height_ratios: ArrayLike | None) -> None: ... + def get_height_ratios(self) -> ArrayLike: ... + def get_grid_positions( + self, fig: Figure + ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: ... + @staticmethod + def _check_gridspec_exists(figure: Figure, nrows: int, ncols: int) -> GridSpec: ... + def __getitem__( + self, key: tuple[int | slice, int | slice] | slice | int + ) -> SubplotSpec: ... + @overload + def subplots( + self, + *, + sharex: bool | Literal["all", "row", "col", "none"] = ..., + sharey: bool | Literal["all", "row", "col", "none"] = ..., + squeeze: Literal[False], + subplot_kw: dict[str, Any] | None = ... + ) -> np.ndarray: ... + @overload + def subplots( + self, + *, + sharex: bool | Literal["all", "row", "col", "none"] = ..., + sharey: bool | Literal["all", "row", "col", "none"] = ..., + squeeze: Literal[True] = ..., + subplot_kw: dict[str, Any] | None = ... + ) -> np.ndarray | SubplotBase | Axes: ... + +class GridSpec(GridSpecBase): + left: float | None + bottom: float | None + right: float | None + top: float | None + wspace: float | None + hspace: float | None + figure: Figure | None + def __init__( + self, + nrows: int, + ncols: int, + figure: Figure | None = ..., + left: float | None = ..., + bottom: float | None = ..., + right: float | None = ..., + top: float | None = ..., + wspace: float | None = ..., + hspace: float | None = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + ) -> None: ... + def update(self, **kwargs: float | None) -> None: ... + def locally_modified_subplot_params(self) -> list[str]: ... + def tight_layout( + self, + figure: Figure, + renderer: RendererBase | None = ..., + pad: float = ..., + h_pad: float | None = ..., + w_pad: float | None = ..., + rect: tuple[float, float, float, float] | None = ..., + ) -> None: ... + +class GridSpecFromSubplotSpec(GridSpecBase): + figure: Figure | None + def __init__( + self, + nrows: int, + ncols: int, + subplot_spec: SubplotSpec, + wspace: float | None = ..., + hspace: float | None = ..., + height_ratios: ArrayLike | None = ..., + width_ratios: ArrayLike | None = ..., + ) -> None: ... + def get_topmost_subplotspec(self) -> SubplotSpec: ... + +class SubplotSpec: + num1: int + def __init__( + self, gridspec: GridSpecBase, num1: int, num2: int | None = ... + ) -> None: ... + @staticmethod + def _from_subplot_args(figure, args): ... + @property + def num2(self) -> int: ... + @num2.setter + def num2(self, value: int) -> None: ... + def get_gridspec(self) -> GridSpec: ... + def get_geometry(self) -> tuple[int, int, int, int]: ... + @property + def rowspan(self) -> range: ... + @property + def colspan(self) -> range: ... + def is_first_row(self) -> bool: ... + def is_last_row(self) -> bool: ... + def is_first_col(self) -> bool: ... + def is_last_col(self) -> bool: ... + def get_position(self, figure: Figure) -> Bbox: ... + def get_topmost_subplotspec(self) -> SubplotSpec: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + def subgridspec( + self, nrows: int, ncols: int, **kwargs + ) -> GridSpecFromSubplotSpec: ... + +class SubplotParams: + def __init__( + self, + left: float | None = ..., + bottom: float | None = ..., + right: float | None = ..., + top: float | None = ..., + wspace: float | None = ..., + hspace: float | None = ..., + ) -> None: ... + left: float + right: float + bottom: float + top: float + wspace: float + hspace: float + def update( + self, + left: float | None = ..., + bottom: float | None = ..., + right: float | None = ..., + top: float | None = ..., + wspace: float | None = ..., + hspace: float | None = ..., + ) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/hatch.py b/venv/lib/python3.10/site-packages/matplotlib/hatch.py new file mode 100644 index 00000000..7a4b283c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/hatch.py @@ -0,0 +1,225 @@ +"""Contains classes for generating hatch patterns.""" + +import numpy as np + +from matplotlib import _api +from matplotlib.path import Path + + +class HatchPatternBase: + """The base class for a hatch pattern.""" + pass + + +class HorizontalHatch(HatchPatternBase): + def __init__(self, hatch, density): + self.num_lines = int((hatch.count('-') + hatch.count('+')) * density) + self.num_vertices = self.num_lines * 2 + + def set_vertices_and_codes(self, vertices, codes): + steps, stepsize = np.linspace(0.0, 1.0, self.num_lines, False, + retstep=True) + steps += stepsize / 2. + vertices[0::2, 0] = 0.0 + vertices[0::2, 1] = steps + vertices[1::2, 0] = 1.0 + vertices[1::2, 1] = steps + codes[0::2] = Path.MOVETO + codes[1::2] = Path.LINETO + + +class VerticalHatch(HatchPatternBase): + def __init__(self, hatch, density): + self.num_lines = int((hatch.count('|') + hatch.count('+')) * density) + self.num_vertices = self.num_lines * 2 + + def set_vertices_and_codes(self, vertices, codes): + steps, stepsize = np.linspace(0.0, 1.0, self.num_lines, False, + retstep=True) + steps += stepsize / 2. + vertices[0::2, 0] = steps + vertices[0::2, 1] = 0.0 + vertices[1::2, 0] = steps + vertices[1::2, 1] = 1.0 + codes[0::2] = Path.MOVETO + codes[1::2] = Path.LINETO + + +class NorthEastHatch(HatchPatternBase): + def __init__(self, hatch, density): + self.num_lines = int( + (hatch.count('/') + hatch.count('x') + hatch.count('X')) * density) + if self.num_lines: + self.num_vertices = (self.num_lines + 1) * 2 + else: + self.num_vertices = 0 + + def set_vertices_and_codes(self, vertices, codes): + steps = np.linspace(-0.5, 0.5, self.num_lines + 1) + vertices[0::2, 0] = 0.0 + steps + vertices[0::2, 1] = 0.0 - steps + vertices[1::2, 0] = 1.0 + steps + vertices[1::2, 1] = 1.0 - steps + codes[0::2] = Path.MOVETO + codes[1::2] = Path.LINETO + + +class SouthEastHatch(HatchPatternBase): + def __init__(self, hatch, density): + self.num_lines = int( + (hatch.count('\\') + hatch.count('x') + hatch.count('X')) + * density) + if self.num_lines: + self.num_vertices = (self.num_lines + 1) * 2 + else: + self.num_vertices = 0 + + def set_vertices_and_codes(self, vertices, codes): + steps = np.linspace(-0.5, 0.5, self.num_lines + 1) + vertices[0::2, 0] = 0.0 + steps + vertices[0::2, 1] = 1.0 + steps + vertices[1::2, 0] = 1.0 + steps + vertices[1::2, 1] = 0.0 + steps + codes[0::2] = Path.MOVETO + codes[1::2] = Path.LINETO + + +class Shapes(HatchPatternBase): + filled = False + + def __init__(self, hatch, density): + if self.num_rows == 0: + self.num_shapes = 0 + self.num_vertices = 0 + else: + self.num_shapes = ((self.num_rows // 2 + 1) * (self.num_rows + 1) + + (self.num_rows // 2) * self.num_rows) + self.num_vertices = (self.num_shapes * + len(self.shape_vertices) * + (1 if self.filled else 2)) + + def set_vertices_and_codes(self, vertices, codes): + offset = 1.0 / self.num_rows + shape_vertices = self.shape_vertices * offset * self.size + shape_codes = self.shape_codes + if not self.filled: + shape_vertices = np.concatenate( # Forward, then backward. + [shape_vertices, shape_vertices[::-1] * 0.9]) + shape_codes = np.concatenate([shape_codes, shape_codes]) + vertices_parts = [] + codes_parts = [] + for row in range(self.num_rows + 1): + if row % 2 == 0: + cols = np.linspace(0, 1, self.num_rows + 1) + else: + cols = np.linspace(offset / 2, 1 - offset / 2, self.num_rows) + row_pos = row * offset + for col_pos in cols: + vertices_parts.append(shape_vertices + [col_pos, row_pos]) + codes_parts.append(shape_codes) + np.concatenate(vertices_parts, out=vertices) + np.concatenate(codes_parts, out=codes) + + +class Circles(Shapes): + def __init__(self, hatch, density): + path = Path.unit_circle() + self.shape_vertices = path.vertices + self.shape_codes = path.codes + super().__init__(hatch, density) + + +class SmallCircles(Circles): + size = 0.2 + + def __init__(self, hatch, density): + self.num_rows = (hatch.count('o')) * density + super().__init__(hatch, density) + + +class LargeCircles(Circles): + size = 0.35 + + def __init__(self, hatch, density): + self.num_rows = (hatch.count('O')) * density + super().__init__(hatch, density) + + +class SmallFilledCircles(Circles): + size = 0.1 + filled = True + + def __init__(self, hatch, density): + self.num_rows = (hatch.count('.')) * density + super().__init__(hatch, density) + + +class Stars(Shapes): + size = 1.0 / 3.0 + filled = True + + def __init__(self, hatch, density): + self.num_rows = (hatch.count('*')) * density + path = Path.unit_regular_star(5) + self.shape_vertices = path.vertices + self.shape_codes = np.full(len(self.shape_vertices), Path.LINETO, + dtype=Path.code_type) + self.shape_codes[0] = Path.MOVETO + super().__init__(hatch, density) + +_hatch_types = [ + HorizontalHatch, + VerticalHatch, + NorthEastHatch, + SouthEastHatch, + SmallCircles, + LargeCircles, + SmallFilledCircles, + Stars + ] + + +def _validate_hatch_pattern(hatch): + valid_hatch_patterns = set(r'-+|/\xXoO.*') + if hatch is not None: + invalids = set(hatch).difference(valid_hatch_patterns) + if invalids: + valid = ''.join(sorted(valid_hatch_patterns)) + invalids = ''.join(sorted(invalids)) + _api.warn_deprecated( + '3.4', + removal='3.11', # one release after custom hatches (#20690) + message=f'hatch must consist of a string of "{valid}" or ' + 'None, but found the following invalid values ' + f'"{invalids}". Passing invalid values is deprecated ' + 'since %(since)s and will become an error %(removal)s.' + ) + + +def get_path(hatchpattern, density=6): + """ + Given a hatch specifier, *hatchpattern*, generates Path to render + the hatch in a unit square. *density* is the number of lines per + unit square. + """ + density = int(density) + + patterns = [hatch_type(hatchpattern, density) + for hatch_type in _hatch_types] + num_vertices = sum([pattern.num_vertices for pattern in patterns]) + + if num_vertices == 0: + return Path(np.empty((0, 2))) + + vertices = np.empty((num_vertices, 2)) + codes = np.empty(num_vertices, Path.code_type) + + cursor = 0 + for pattern in patterns: + if pattern.num_vertices != 0: + vertices_chunk = vertices[cursor:cursor + pattern.num_vertices] + codes_chunk = codes[cursor:cursor + pattern.num_vertices] + pattern.set_vertices_and_codes(vertices_chunk, codes_chunk) + cursor += pattern.num_vertices + + return Path(vertices, codes) diff --git a/venv/lib/python3.10/site-packages/matplotlib/hatch.pyi b/venv/lib/python3.10/site-packages/matplotlib/hatch.pyi new file mode 100644 index 00000000..348cf521 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/hatch.pyi @@ -0,0 +1,68 @@ +from matplotlib.path import Path + +import numpy as np +from numpy.typing import ArrayLike + +class HatchPatternBase: ... + +class HorizontalHatch(HatchPatternBase): + num_lines: int + num_vertices: int + def __init__(self, hatch: str, density: int) -> None: ... + def set_vertices_and_codes(self, vertices: ArrayLike, codes: ArrayLike) -> None: ... + +class VerticalHatch(HatchPatternBase): + num_lines: int + num_vertices: int + def __init__(self, hatch: str, density: int) -> None: ... + def set_vertices_and_codes(self, vertices: ArrayLike, codes: ArrayLike) -> None: ... + +class NorthEastHatch(HatchPatternBase): + num_lines: int + num_vertices: int + def __init__(self, hatch: str, density: int) -> None: ... + def set_vertices_and_codes(self, vertices: ArrayLike, codes: ArrayLike) -> None: ... + +class SouthEastHatch(HatchPatternBase): + num_lines: int + num_vertices: int + def __init__(self, hatch: str, density: int) -> None: ... + def set_vertices_and_codes(self, vertices: ArrayLike, codes: ArrayLike) -> None: ... + +class Shapes(HatchPatternBase): + filled: bool + num_shapes: int + num_vertices: int + def __init__(self, hatch: str, density: int) -> None: ... + def set_vertices_and_codes(self, vertices: ArrayLike, codes: ArrayLike) -> None: ... + +class Circles(Shapes): + shape_vertices: np.ndarray + shape_codes: np.ndarray + def __init__(self, hatch: str, density: int) -> None: ... + +class SmallCircles(Circles): + size: float + num_rows: int + def __init__(self, hatch: str, density: int) -> None: ... + +class LargeCircles(Circles): + size: float + num_rows: int + def __init__(self, hatch: str, density: int) -> None: ... + +class SmallFilledCircles(Circles): + size: float + filled: bool + num_rows: int + def __init__(self, hatch: str, density: int) -> None: ... + +class Stars(Shapes): + size: float + filled: bool + num_rows: int + shape_vertices: np.ndarray + shape_codes: np.ndarray + def __init__(self, hatch: str, density: int) -> None: ... + +def get_path(hatchpattern: str, density: int = ...) -> Path: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/image.py b/venv/lib/python3.10/site-packages/matplotlib/image.py new file mode 100644 index 00000000..2e132930 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/image.py @@ -0,0 +1,1805 @@ +""" +The image module supports basic image loading, rescaling and display +operations. +""" + +import math +import os +import logging +from pathlib import Path +import warnings + +import numpy as np +import PIL.Image +import PIL.PngImagePlugin + +import matplotlib as mpl +from matplotlib import _api, cbook, cm +# For clarity, names from _image are given explicitly in this module +from matplotlib import _image +# For user convenience, the names from _image are also imported into +# the image namespace +from matplotlib._image import * # noqa: F401, F403 +import matplotlib.artist as martist +from matplotlib.backend_bases import FigureCanvasBase +import matplotlib.colors as mcolors +from matplotlib.transforms import ( + Affine2D, BboxBase, Bbox, BboxTransform, BboxTransformTo, + IdentityTransform, TransformedBbox) + +_log = logging.getLogger(__name__) + +# map interpolation strings to module constants +_interpd_ = { + 'antialiased': _image.NEAREST, # this will use nearest or Hanning... + 'none': _image.NEAREST, # fall back to nearest when not supported + 'nearest': _image.NEAREST, + 'bilinear': _image.BILINEAR, + 'bicubic': _image.BICUBIC, + 'spline16': _image.SPLINE16, + 'spline36': _image.SPLINE36, + 'hanning': _image.HANNING, + 'hamming': _image.HAMMING, + 'hermite': _image.HERMITE, + 'kaiser': _image.KAISER, + 'quadric': _image.QUADRIC, + 'catrom': _image.CATROM, + 'gaussian': _image.GAUSSIAN, + 'bessel': _image.BESSEL, + 'mitchell': _image.MITCHELL, + 'sinc': _image.SINC, + 'lanczos': _image.LANCZOS, + 'blackman': _image.BLACKMAN, +} + +interpolations_names = set(_interpd_) + + +def composite_images(images, renderer, magnification=1.0): + """ + Composite a number of RGBA images into one. The images are + composited in the order in which they appear in the *images* list. + + Parameters + ---------- + images : list of Images + Each must have a `make_image` method. For each image, + `can_composite` should return `True`, though this is not + enforced by this function. Each image must have a purely + affine transformation with no shear. + + renderer : `.RendererBase` + + magnification : float, default: 1 + The additional magnification to apply for the renderer in use. + + Returns + ------- + image : (M, N, 4) `numpy.uint8` array + The composited RGBA image. + offset_x, offset_y : float + The (left, bottom) offset where the composited image should be placed + in the output figure. + """ + if len(images) == 0: + return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 + + parts = [] + bboxes = [] + for image in images: + data, x, y, trans = image.make_image(renderer, magnification) + if data is not None: + x *= magnification + y *= magnification + parts.append((data, x, y, image._get_scalar_alpha())) + bboxes.append( + Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) + + if len(parts) == 0: + return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 + + bbox = Bbox.union(bboxes) + + output = np.zeros( + (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) + + for data, x, y, alpha in parts: + trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) + _image.resample(data, output, trans, _image.NEAREST, + resample=False, alpha=alpha) + + return output, bbox.x0 / magnification, bbox.y0 / magnification + + +def _draw_list_compositing_images( + renderer, parent, artists, suppress_composite=None): + """ + Draw a sorted list of artists, compositing images into a single + image where possible. + + For internal Matplotlib use only: It is here to reduce duplication + between `Figure.draw` and `Axes.draw`, but otherwise should not be + generally useful. + """ + has_images = any(isinstance(x, _ImageBase) for x in artists) + + # override the renderer default if suppressComposite is not None + not_composite = (suppress_composite if suppress_composite is not None + else renderer.option_image_nocomposite()) + + if not_composite or not has_images: + for a in artists: + a.draw(renderer) + else: + # Composite any adjacent images together + image_group = [] + mag = renderer.get_image_magnification() + + def flush_images(): + if len(image_group) == 1: + image_group[0].draw(renderer) + elif len(image_group) > 1: + data, l, b = composite_images(image_group, renderer, mag) + if data.size != 0: + gc = renderer.new_gc() + gc.set_clip_rectangle(parent.bbox) + gc.set_clip_path(parent.get_clip_path()) + renderer.draw_image(gc, round(l), round(b), data) + gc.restore() + del image_group[:] + + for a in artists: + if (isinstance(a, _ImageBase) and a.can_composite() and + a.get_clip_on() and not a.get_clip_path()): + image_group.append(a) + else: + flush_images() + a.draw(renderer) + flush_images() + + +def _resample( + image_obj, data, out_shape, transform, *, resample=None, alpha=1): + """ + Convenience wrapper around `._image.resample` to resample *data* to + *out_shape* (with a third dimension if *data* is RGBA) that takes care of + allocating the output array and fetching the relevant properties from the + Image object *image_obj*. + """ + # AGG can only handle coordinates smaller than 24-bit signed integers, + # so raise errors if the input data is larger than _image.resample can + # handle. + msg = ('Data with more than {n} cannot be accurately displayed. ' + 'Downsampling to less than {n} before displaying. ' + 'To remove this warning, manually downsample your data.') + if data.shape[1] > 2**23: + warnings.warn(msg.format(n='2**23 columns')) + step = int(np.ceil(data.shape[1] / 2**23)) + data = data[:, ::step] + transform = Affine2D().scale(step, 1) + transform + if data.shape[0] > 2**24: + warnings.warn(msg.format(n='2**24 rows')) + step = int(np.ceil(data.shape[0] / 2**24)) + data = data[::step, :] + transform = Affine2D().scale(1, step) + transform + # decide if we need to apply anti-aliasing if the data is upsampled: + # compare the number of displayed pixels to the number of + # the data pixels. + interpolation = image_obj.get_interpolation() + if interpolation == 'antialiased': + # don't antialias if upsampling by an integer number or + # if zooming in more than a factor of 3 + pos = np.array([[0, 0], [data.shape[1], data.shape[0]]]) + disp = transform.transform(pos) + dispx = np.abs(np.diff(disp[:, 0])) + dispy = np.abs(np.diff(disp[:, 1])) + if ((dispx > 3 * data.shape[1] or + dispx == data.shape[1] or + dispx == 2 * data.shape[1]) and + (dispy > 3 * data.shape[0] or + dispy == data.shape[0] or + dispy == 2 * data.shape[0])): + interpolation = 'nearest' + else: + interpolation = 'hanning' + out = np.zeros(out_shape + data.shape[2:], data.dtype) # 2D->2D, 3D->3D. + if resample is None: + resample = image_obj.get_resample() + _image.resample(data, out, transform, + _interpd_[interpolation], + resample, + alpha, + image_obj.get_filternorm(), + image_obj.get_filterrad()) + return out + + +def _rgb_to_rgba(A): + """ + Convert an RGB image to RGBA, as required by the image resample C++ + extension. + """ + rgba = np.zeros((A.shape[0], A.shape[1], 4), dtype=A.dtype) + rgba[:, :, :3] = A + if rgba.dtype == np.uint8: + rgba[:, :, 3] = 255 + else: + rgba[:, :, 3] = 1.0 + return rgba + + +class _ImageBase(martist.Artist, cm.ScalarMappable): + """ + Base class for images. + + interpolation and cmap default to their rc settings + + cmap is a colors.Colormap instance + norm is a colors.Normalize instance to map luminance to 0-1 + + extent is data axes (left, right, bottom, top) for making image plots + registered with data plots. Default is to label the pixel + centers with the zero-based row and column indices. + + Additional kwargs are matplotlib.artist properties + """ + zorder = 0 + + def __init__(self, ax, + cmap=None, + norm=None, + interpolation=None, + origin=None, + filternorm=True, + filterrad=4.0, + resample=False, + *, + interpolation_stage=None, + **kwargs + ): + martist.Artist.__init__(self) + cm.ScalarMappable.__init__(self, norm, cmap) + if origin is None: + origin = mpl.rcParams['image.origin'] + _api.check_in_list(["upper", "lower"], origin=origin) + self.origin = origin + self.set_filternorm(filternorm) + self.set_filterrad(filterrad) + self.set_interpolation(interpolation) + self.set_interpolation_stage(interpolation_stage) + self.set_resample(resample) + self.axes = ax + + self._imcache = None + + self._internal_update(kwargs) + + def __str__(self): + try: + shape = self.get_shape() + return f"{type(self).__name__}(shape={shape!r})" + except RuntimeError: + return type(self).__name__ + + def __getstate__(self): + # Save some space on the pickle by not saving the cache. + return {**super().__getstate__(), "_imcache": None} + + def get_size(self): + """Return the size of the image as tuple (numrows, numcols).""" + return self.get_shape()[:2] + + def get_shape(self): + """ + Return the shape of the image as tuple (numrows, numcols, channels). + """ + if self._A is None: + raise RuntimeError('You must first set the image array') + + return self._A.shape + + def set_alpha(self, alpha): + """ + Set the alpha value used for blending - not supported on all backends. + + Parameters + ---------- + alpha : float or 2D array-like or None + """ + martist.Artist._set_alpha_for_array(self, alpha) + if np.ndim(alpha) not in (0, 2): + raise TypeError('alpha must be a float, two-dimensional ' + 'array, or None') + self._imcache = None + + def _get_scalar_alpha(self): + """ + Get a scalar alpha value to be applied to the artist as a whole. + + If the alpha value is a matrix, the method returns 1.0 because pixels + have individual alpha values (see `~._ImageBase._make_image` for + details). If the alpha value is a scalar, the method returns said value + to be applied to the artist as a whole because pixels do not have + individual alpha values. + """ + return 1.0 if self._alpha is None or np.ndim(self._alpha) > 0 \ + else self._alpha + + def changed(self): + """ + Call this whenever the mappable is changed so observers can update. + """ + self._imcache = None + cm.ScalarMappable.changed(self) + + def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, + unsampled=False, round_to_pixel_border=True): + """ + Normalize, rescale, and colormap the image *A* from the given *in_bbox* + (in data space), to the given *out_bbox* (in pixel space) clipped to + the given *clip_bbox* (also in pixel space), and magnified by the + *magnification* factor. + + *A* may be a greyscale image (M, N) with a dtype of `~numpy.float32`, + `~numpy.float64`, `~numpy.float128`, `~numpy.uint16` or `~numpy.uint8`, + or an (M, N, 4) RGBA image with a dtype of `~numpy.float32`, + `~numpy.float64`, `~numpy.float128`, or `~numpy.uint8`. + + If *unsampled* is True, the image will not be scaled, but an + appropriate affine transformation will be returned instead. + + If *round_to_pixel_border* is True, the output image size will be + rounded to the nearest pixel boundary. This makes the images align + correctly with the Axes. It should not be used if exact scaling is + needed, such as for `FigureImage`. + + Returns + ------- + image : (M, N, 4) `numpy.uint8` array + The RGBA image, resampled unless *unsampled* is True. + x, y : float + The upper left corner where the image should be drawn, in pixel + space. + trans : `~matplotlib.transforms.Affine2D` + The affine transformation from image to pixel space. + """ + if A is None: + raise RuntimeError('You must first set the image ' + 'array or the image attribute') + if A.size == 0: + raise RuntimeError("_make_image must get a non-empty image. " + "Your Artist's draw method must filter before " + "this method is called.") + + clipped_bbox = Bbox.intersection(out_bbox, clip_bbox) + + if clipped_bbox is None: + return None, 0, 0, None + + out_width_base = clipped_bbox.width * magnification + out_height_base = clipped_bbox.height * magnification + + if out_width_base == 0 or out_height_base == 0: + return None, 0, 0, None + + if self.origin == 'upper': + # Flip the input image using a transform. This avoids the + # problem with flipping the array, which results in a copy + # when it is converted to contiguous in the C wrapper + t0 = Affine2D().translate(0, -A.shape[0]).scale(1, -1) + else: + t0 = IdentityTransform() + + t0 += ( + Affine2D() + .scale( + in_bbox.width / A.shape[1], + in_bbox.height / A.shape[0]) + .translate(in_bbox.x0, in_bbox.y0) + + self.get_transform()) + + t = (t0 + + (Affine2D() + .translate(-clipped_bbox.x0, -clipped_bbox.y0) + .scale(magnification))) + + # So that the image is aligned with the edge of the Axes, we want to + # round up the output width to the next integer. This also means + # scaling the transform slightly to account for the extra subpixel. + if ((not unsampled) and t.is_affine and round_to_pixel_border and + (out_width_base % 1.0 != 0.0 or out_height_base % 1.0 != 0.0)): + out_width = math.ceil(out_width_base) + out_height = math.ceil(out_height_base) + extra_width = (out_width - out_width_base) / out_width_base + extra_height = (out_height - out_height_base) / out_height_base + t += Affine2D().scale(1.0 + extra_width, 1.0 + extra_height) + else: + out_width = int(out_width_base) + out_height = int(out_height_base) + out_shape = (out_height, out_width) + + if not unsampled: + if not (A.ndim == 2 or A.ndim == 3 and A.shape[-1] in (3, 4)): + raise ValueError(f"Invalid shape {A.shape} for image data") + if A.ndim == 2 and self._interpolation_stage != 'rgba': + # if we are a 2D array, then we are running through the + # norm + colormap transformation. However, in general the + # input data is not going to match the size on the screen so we + # have to resample to the correct number of pixels + + # TODO slice input array first + a_min = A.min() + a_max = A.max() + if a_min is np.ma.masked: # All masked; values don't matter. + a_min, a_max = np.int32(0), np.int32(1) + if A.dtype.kind == 'f': # Float dtype: scale to same dtype. + scaled_dtype = np.dtype( + np.float64 if A.dtype.itemsize > 4 else np.float32) + if scaled_dtype.itemsize < A.dtype.itemsize: + _api.warn_external(f"Casting input data from {A.dtype}" + f" to {scaled_dtype} for imshow.") + else: # Int dtype, likely. + # Scale to appropriately sized float: use float32 if the + # dynamic range is small, to limit the memory footprint. + da = a_max.astype(np.float64) - a_min.astype(np.float64) + scaled_dtype = np.float64 if da > 1e8 else np.float32 + + # Scale the input data to [.1, .9]. The Agg interpolators clip + # to [0, 1] internally, and we use a smaller input scale to + # identify the interpolated points that need to be flagged as + # over/under. This may introduce numeric instabilities in very + # broadly scaled data. + + # Always copy, and don't allow array subtypes. + A_scaled = np.array(A, dtype=scaled_dtype) + # Clip scaled data around norm if necessary. This is necessary + # for big numbers at the edge of float64's ability to represent + # changes. Applying a norm first would be good, but ruins the + # interpolation of over numbers. + self.norm.autoscale_None(A) + dv = np.float64(self.norm.vmax) - np.float64(self.norm.vmin) + vmid = np.float64(self.norm.vmin) + dv / 2 + fact = 1e7 if scaled_dtype == np.float64 else 1e4 + newmin = vmid - dv * fact + if newmin < a_min: + newmin = None + else: + a_min = np.float64(newmin) + newmax = vmid + dv * fact + if newmax > a_max: + newmax = None + else: + a_max = np.float64(newmax) + if newmax is not None or newmin is not None: + np.clip(A_scaled, newmin, newmax, out=A_scaled) + + # Rescale the raw data to [offset, 1-offset] so that the + # resampling code will run cleanly. Using dyadic numbers here + # could reduce the error, but would not fully eliminate it and + # breaks a number of tests (due to the slightly different + # error bouncing some pixels across a boundary in the (very + # quantized) colormapping step). + offset = .1 + frac = .8 + # Run vmin/vmax through the same rescaling as the raw data; + # otherwise, data values close or equal to the boundaries can + # end up on the wrong side due to floating point error. + vmin, vmax = self.norm.vmin, self.norm.vmax + if vmin is np.ma.masked: + vmin, vmax = a_min, a_max + vrange = np.array([vmin, vmax], dtype=scaled_dtype) + + A_scaled -= a_min + vrange -= a_min + # .item() handles a_min/a_max being ndarray subclasses. + a_min = a_min.astype(scaled_dtype).item() + a_max = a_max.astype(scaled_dtype).item() + + if a_min != a_max: + A_scaled /= ((a_max - a_min) / frac) + vrange /= ((a_max - a_min) / frac) + A_scaled += offset + vrange += offset + # resample the input data to the correct resolution and shape + A_resampled = _resample(self, A_scaled, out_shape, t) + del A_scaled # Make sure we don't use A_scaled anymore! + # Un-scale the resampled data to approximately the original + # range. Things that interpolated to outside the original range + # will still be outside, but possibly clipped in the case of + # higher order interpolation + drastically changing data. + A_resampled -= offset + vrange -= offset + if a_min != a_max: + A_resampled *= ((a_max - a_min) / frac) + vrange *= ((a_max - a_min) / frac) + A_resampled += a_min + vrange += a_min + # if using NoNorm, cast back to the original datatype + if isinstance(self.norm, mcolors.NoNorm): + A_resampled = A_resampled.astype(A.dtype) + + mask = (np.where(A.mask, np.float32(np.nan), np.float32(1)) + if A.mask.shape == A.shape # nontrivial mask + else np.ones_like(A, np.float32)) + # we always have to interpolate the mask to account for + # non-affine transformations + out_alpha = _resample(self, mask, out_shape, t, resample=True) + del mask # Make sure we don't use mask anymore! + # Agg updates out_alpha in place. If the pixel has no image + # data it will not be updated (and still be 0 as we initialized + # it), if input data that would go into that output pixel than + # it will be `nan`, if all the input data for a pixel is good + # it will be 1, and if there is _some_ good data in that output + # pixel it will be between [0, 1] (such as a rotated image). + out_mask = np.isnan(out_alpha) + out_alpha[out_mask] = 1 + # Apply the pixel-by-pixel alpha values if present + alpha = self.get_alpha() + if alpha is not None and np.ndim(alpha) > 0: + out_alpha *= _resample(self, alpha, out_shape, + t, resample=True) + # mask and run through the norm + resampled_masked = np.ma.masked_array(A_resampled, out_mask) + # we have re-set the vmin/vmax to account for small errors + # that may have moved input values in/out of range + s_vmin, s_vmax = vrange + if isinstance(self.norm, mcolors.LogNorm) and s_vmin <= 0: + # Don't give 0 or negative values to LogNorm + s_vmin = np.finfo(scaled_dtype).eps + # Block the norm from sending an update signal during the + # temporary vmin/vmax change + with self.norm.callbacks.blocked(), \ + cbook._setattr_cm(self.norm, vmin=s_vmin, vmax=s_vmax): + output = self.norm(resampled_masked) + else: + if A.ndim == 2: # _interpolation_stage == 'rgba' + self.norm.autoscale_None(A) + A = self.to_rgba(A) + alpha = self._get_scalar_alpha() + if A.shape[2] == 3: + # No need to resample alpha or make a full array; NumPy will expand + # this out and cast to uint8 if necessary when it's assigned to the + # alpha channel below. + output_alpha = (255 * alpha) if A.dtype == np.uint8 else alpha + else: + output_alpha = _resample( # resample alpha channel + self, A[..., 3], out_shape, t, alpha=alpha) + output = _resample( # resample rgb channels + self, _rgb_to_rgba(A[..., :3]), out_shape, t, alpha=alpha) + output[..., 3] = output_alpha # recombine rgb and alpha + + # output is now either a 2D array of normed (int or float) data + # or an RGBA array of re-sampled input + output = self.to_rgba(output, bytes=True, norm=False) + # output is now a correctly sized RGBA array of uint8 + + # Apply alpha *after* if the input was greyscale without a mask + if A.ndim == 2: + alpha = self._get_scalar_alpha() + alpha_channel = output[:, :, 3] + alpha_channel[:] = ( # Assignment will cast to uint8. + alpha_channel.astype(np.float32) * out_alpha * alpha) + + else: + if self._imcache is None: + self._imcache = self.to_rgba(A, bytes=True, norm=(A.ndim == 2)) + output = self._imcache + + # Subset the input image to only the part that will be displayed. + subset = TransformedBbox(clip_bbox, t0.inverted()).frozen() + output = output[ + int(max(subset.ymin, 0)): + int(min(subset.ymax + 1, output.shape[0])), + int(max(subset.xmin, 0)): + int(min(subset.xmax + 1, output.shape[1]))] + + t = Affine2D().translate( + int(max(subset.xmin, 0)), int(max(subset.ymin, 0))) + t + + return output, clipped_bbox.x0, clipped_bbox.y0, t + + def make_image(self, renderer, magnification=1.0, unsampled=False): + """ + Normalize, rescale, and colormap this image's data for rendering using + *renderer*, with the given *magnification*. + + If *unsampled* is True, the image will not be scaled, but an + appropriate affine transformation will be returned instead. + + Returns + ------- + image : (M, N, 4) `numpy.uint8` array + The RGBA image, resampled unless *unsampled* is True. + x, y : float + The upper left corner where the image should be drawn, in pixel + space. + trans : `~matplotlib.transforms.Affine2D` + The affine transformation from image to pixel space. + """ + raise NotImplementedError('The make_image method must be overridden') + + def _check_unsampled_image(self): + """ + Return whether the image is better to be drawn unsampled. + + The derived class needs to override it. + """ + return False + + @martist.allow_rasterization + def draw(self, renderer): + # if not visible, declare victory and return + if not self.get_visible(): + self.stale = False + return + # for empty images, there is nothing to draw! + if self.get_array().size == 0: + self.stale = False + return + # actually render the image. + gc = renderer.new_gc() + self._set_gc_clip(gc) + gc.set_alpha(self._get_scalar_alpha()) + gc.set_url(self.get_url()) + gc.set_gid(self.get_gid()) + if (renderer.option_scale_image() # Renderer supports transform kwarg. + and self._check_unsampled_image() + and self.get_transform().is_affine): + im, l, b, trans = self.make_image(renderer, unsampled=True) + if im is not None: + trans = Affine2D().scale(im.shape[1], im.shape[0]) + trans + renderer.draw_image(gc, l, b, im, trans) + else: + im, l, b, trans = self.make_image( + renderer, renderer.get_image_magnification()) + if im is not None: + renderer.draw_image(gc, l, b, im) + gc.restore() + self.stale = False + + def contains(self, mouseevent): + """Test whether the mouse event occurred within the image.""" + if (self._different_canvas(mouseevent) + # This doesn't work for figimage. + or not self.axes.contains(mouseevent)[0]): + return False, {} + # TODO: make sure this is consistent with patch and patch + # collection on nonlinear transformed coordinates. + # TODO: consider returning image coordinates (shouldn't + # be too difficult given that the image is rectilinear + trans = self.get_transform().inverted() + x, y = trans.transform([mouseevent.x, mouseevent.y]) + xmin, xmax, ymin, ymax = self.get_extent() + # This checks xmin <= x <= xmax *or* xmax <= x <= xmin. + inside = (x is not None and (x - xmin) * (x - xmax) <= 0 + and y is not None and (y - ymin) * (y - ymax) <= 0) + return inside, {} + + def write_png(self, fname): + """Write the image to png file *fname*.""" + im = self.to_rgba(self._A[::-1] if self.origin == 'lower' else self._A, + bytes=True, norm=True) + PIL.Image.fromarray(im).save(fname, format="png") + + @staticmethod + def _normalize_image_array(A): + """ + Check validity of image-like input *A* and normalize it to a format suitable for + Image subclasses. + """ + A = cbook.safe_masked_invalid(A, copy=True) + if A.dtype != np.uint8 and not np.can_cast(A.dtype, float, "same_kind"): + raise TypeError(f"Image data of dtype {A.dtype} cannot be " + f"converted to float") + if A.ndim == 3 and A.shape[-1] == 1: + A = A.squeeze(-1) # If just (M, N, 1), assume scalar and apply colormap. + if not (A.ndim == 2 or A.ndim == 3 and A.shape[-1] in [3, 4]): + raise TypeError(f"Invalid shape {A.shape} for image data") + if A.ndim == 3: + # If the input data has values outside the valid range (after + # normalisation), we issue a warning and then clip X to the bounds + # - otherwise casting wraps extreme values, hiding outliers and + # making reliable interpretation impossible. + high = 255 if np.issubdtype(A.dtype, np.integer) else 1 + if A.min() < 0 or high < A.max(): + _log.warning( + 'Clipping input data to the valid range for imshow with ' + 'RGB data ([0..1] for floats or [0..255] for integers). ' + 'Got range [%s..%s].', + A.min(), A.max() + ) + A = np.clip(A, 0, high) + # Cast unsupported integer types to uint8 + if A.dtype != np.uint8 and np.issubdtype(A.dtype, np.integer): + A = A.astype(np.uint8) + return A + + def set_data(self, A): + """ + Set the image array. + + Note that this function does *not* update the normalization used. + + Parameters + ---------- + A : array-like or `PIL.Image.Image` + """ + if isinstance(A, PIL.Image.Image): + A = pil_to_array(A) # Needed e.g. to apply png palette. + self._A = self._normalize_image_array(A) + self._imcache = None + self.stale = True + + def set_array(self, A): + """ + Retained for backwards compatibility - use set_data instead. + + Parameters + ---------- + A : array-like + """ + # This also needs to be here to override the inherited + # cm.ScalarMappable.set_array method so it is not invoked by mistake. + self.set_data(A) + + def get_interpolation(self): + """ + Return the interpolation method the image uses when resizing. + + One of 'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', + 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', + 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', + or 'none'. + """ + return self._interpolation + + def set_interpolation(self, s): + """ + Set the interpolation method the image uses when resizing. + + If None, use :rc:`image.interpolation`. If 'none', the image is + shown as is without interpolating. 'none' is only supported in + agg, ps and pdf backends and will fall back to 'nearest' mode + for other backends. + + Parameters + ---------- + s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', \ +'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', \ +'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None + """ + s = mpl._val_or_rc(s, 'image.interpolation').lower() + _api.check_in_list(interpolations_names, interpolation=s) + self._interpolation = s + self.stale = True + + def get_interpolation_stage(self): + """ + Return when interpolation happens during the transform to RGBA. + + One of 'data', 'rgba'. + """ + return self._interpolation_stage + + def set_interpolation_stage(self, s): + """ + Set when interpolation happens during the transform to RGBA. + + Parameters + ---------- + s : {'data', 'rgba'} or None + Whether to apply up/downsampling interpolation in data or RGBA + space. If None, use :rc:`image.interpolation_stage`. + """ + s = mpl._val_or_rc(s, 'image.interpolation_stage') + _api.check_in_list(['data', 'rgba'], s=s) + self._interpolation_stage = s + self.stale = True + + def can_composite(self): + """Return whether the image can be composited with its neighbors.""" + trans = self.get_transform() + return ( + self._interpolation != 'none' and + trans.is_affine and + trans.is_separable) + + def set_resample(self, v): + """ + Set whether image resampling is used. + + Parameters + ---------- + v : bool or None + If None, use :rc:`image.resample`. + """ + v = mpl._val_or_rc(v, 'image.resample') + self._resample = v + self.stale = True + + def get_resample(self): + """Return whether image resampling is used.""" + return self._resample + + def set_filternorm(self, filternorm): + """ + Set whether the resize filter normalizes the weights. + + See help for `~.Axes.imshow`. + + Parameters + ---------- + filternorm : bool + """ + self._filternorm = bool(filternorm) + self.stale = True + + def get_filternorm(self): + """Return whether the resize filter normalizes the weights.""" + return self._filternorm + + def set_filterrad(self, filterrad): + """ + Set the resize filter radius only applicable to some + interpolation schemes -- see help for imshow + + Parameters + ---------- + filterrad : positive float + """ + r = float(filterrad) + if r <= 0: + raise ValueError("The filter radius must be a positive number") + self._filterrad = r + self.stale = True + + def get_filterrad(self): + """Return the filterrad setting.""" + return self._filterrad + + +class AxesImage(_ImageBase): + """ + An image attached to an Axes. + + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The Axes the image will belong to. + cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` + The Colormap instance or registered colormap name used to map scalar + data to colors. + norm : str or `~matplotlib.colors.Normalize` + Maps luminance to 0-1. + interpolation : str, default: :rc:`image.interpolation` + Supported values are 'none', 'antialiased', 'nearest', 'bilinear', + 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', + 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', + 'sinc', 'lanczos', 'blackman'. + interpolation_stage : {'data', 'rgba'}, default: 'data' + If 'data', interpolation + is carried out on the data provided by the user. If 'rgba', the + interpolation is carried out after the colormapping has been + applied (visual interpolation). + origin : {'upper', 'lower'}, default: :rc:`image.origin` + Place the [0, 0] index of the array in the upper left or lower left + corner of the Axes. The convention 'upper' is typically used for + matrices and images. + extent : tuple, optional + The data axes (left, right, bottom, top) for making image plots + registered with data plots. Default is to label the pixel + centers with the zero-based row and column indices. + filternorm : bool, default: True + A parameter for the antigrain image resize filter + (see the antigrain documentation). + If filternorm is set, the filter normalizes integer values and corrects + the rounding errors. It doesn't do anything with the source floating + point values, it corrects only integers according to the rule of 1.0 + which means that any sum of pixel weights must be equal to 1.0. So, + the filter function must produce a graph of the proper shape. + filterrad : float > 0, default: 4 + The filter radius for filters that have a radius parameter, i.e. when + interpolation is one of: 'sinc', 'lanczos' or 'blackman'. + resample : bool, default: False + When True, use a full resampling method. When False, only resample when + the output image is larger than the input image. + **kwargs : `~matplotlib.artist.Artist` properties + """ + + def __init__(self, ax, + *, + cmap=None, + norm=None, + interpolation=None, + origin=None, + extent=None, + filternorm=True, + filterrad=4.0, + resample=False, + interpolation_stage=None, + **kwargs + ): + + self._extent = extent + + super().__init__( + ax, + cmap=cmap, + norm=norm, + interpolation=interpolation, + origin=origin, + filternorm=filternorm, + filterrad=filterrad, + resample=resample, + interpolation_stage=interpolation_stage, + **kwargs + ) + + def get_window_extent(self, renderer=None): + x0, x1, y0, y1 = self._extent + bbox = Bbox.from_extents([x0, y0, x1, y1]) + return bbox.transformed(self.get_transform()) + + def make_image(self, renderer, magnification=1.0, unsampled=False): + # docstring inherited + trans = self.get_transform() + # image is created in the canvas coordinate. + x1, x2, y1, y2 = self.get_extent() + bbox = Bbox(np.array([[x1, y1], [x2, y2]])) + transformed_bbox = TransformedBbox(bbox, trans) + clip = ((self.get_clip_box() or self.axes.bbox) if self.get_clip_on() + else self.figure.bbox) + return self._make_image(self._A, bbox, transformed_bbox, clip, + magnification, unsampled=unsampled) + + def _check_unsampled_image(self): + """Return whether the image would be better drawn unsampled.""" + return self.get_interpolation() == "none" + + def set_extent(self, extent, **kwargs): + """ + Set the image extent. + + Parameters + ---------- + extent : 4-tuple of float + The position and size of the image as tuple + ``(left, right, bottom, top)`` in data coordinates. + **kwargs + Other parameters from which unit info (i.e., the *xunits*, + *yunits*, *zunits* (for 3D Axes), *runits* and *thetaunits* (for + polar Axes) entries are applied, if present. + + Notes + ----- + This updates ``ax.dataLim``, and, if autoscaling, sets ``ax.viewLim`` + to tightly fit the image, regardless of ``dataLim``. Autoscaling + state is not changed, so following this with ``ax.autoscale_view()`` + will redo the autoscaling in accord with ``dataLim``. + """ + (xmin, xmax), (ymin, ymax) = self.axes._process_unit_info( + [("x", [extent[0], extent[1]]), + ("y", [extent[2], extent[3]])], + kwargs) + if kwargs: + raise _api.kwarg_error("set_extent", kwargs) + xmin = self.axes._validate_converted_limits( + xmin, self.convert_xunits) + xmax = self.axes._validate_converted_limits( + xmax, self.convert_xunits) + ymin = self.axes._validate_converted_limits( + ymin, self.convert_yunits) + ymax = self.axes._validate_converted_limits( + ymax, self.convert_yunits) + extent = [xmin, xmax, ymin, ymax] + + self._extent = extent + corners = (xmin, ymin), (xmax, ymax) + self.axes.update_datalim(corners) + self.sticky_edges.x[:] = [xmin, xmax] + self.sticky_edges.y[:] = [ymin, ymax] + if self.axes.get_autoscalex_on(): + self.axes.set_xlim((xmin, xmax), auto=None) + if self.axes.get_autoscaley_on(): + self.axes.set_ylim((ymin, ymax), auto=None) + self.stale = True + + def get_extent(self): + """Return the image extent as tuple (left, right, bottom, top).""" + if self._extent is not None: + return self._extent + else: + sz = self.get_size() + numrows, numcols = sz + if self.origin == 'upper': + return (-0.5, numcols-0.5, numrows-0.5, -0.5) + else: + return (-0.5, numcols-0.5, -0.5, numrows-0.5) + + def get_cursor_data(self, event): + """ + Return the image value at the event position or *None* if the event is + outside the image. + + See Also + -------- + matplotlib.artist.Artist.get_cursor_data + """ + xmin, xmax, ymin, ymax = self.get_extent() + if self.origin == 'upper': + ymin, ymax = ymax, ymin + arr = self.get_array() + data_extent = Bbox([[xmin, ymin], [xmax, ymax]]) + array_extent = Bbox([[0, 0], [arr.shape[1], arr.shape[0]]]) + trans = self.get_transform().inverted() + trans += BboxTransform(boxin=data_extent, boxout=array_extent) + point = trans.transform([event.x, event.y]) + if any(np.isnan(point)): + return None + j, i = point.astype(int) + # Clip the coordinates at array bounds + if not (0 <= i < arr.shape[0]) or not (0 <= j < arr.shape[1]): + return None + else: + return arr[i, j] + + +class NonUniformImage(AxesImage): + + def __init__(self, ax, *, interpolation='nearest', **kwargs): + """ + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The Axes the image will belong to. + interpolation : {'nearest', 'bilinear'}, default: 'nearest' + The interpolation scheme used in the resampling. + **kwargs + All other keyword arguments are identical to those of `.AxesImage`. + """ + super().__init__(ax, **kwargs) + self.set_interpolation(interpolation) + + def _check_unsampled_image(self): + """Return False. Do not use unsampled image.""" + return False + + def make_image(self, renderer, magnification=1.0, unsampled=False): + # docstring inherited + if self._A is None: + raise RuntimeError('You must first set the image array') + if unsampled: + raise ValueError('unsampled not supported on NonUniformImage') + A = self._A + if A.ndim == 2: + if A.dtype != np.uint8: + A = self.to_rgba(A, bytes=True) + else: + A = np.repeat(A[:, :, np.newaxis], 4, 2) + A[:, :, 3] = 255 + else: + if A.dtype != np.uint8: + A = (255*A).astype(np.uint8) + if A.shape[2] == 3: + B = np.zeros(tuple([*A.shape[0:2], 4]), np.uint8) + B[:, :, 0:3] = A + B[:, :, 3] = 255 + A = B + vl = self.axes.viewLim + l, b, r, t = self.axes.bbox.extents + width = int(((round(r) + 0.5) - (round(l) - 0.5)) * magnification) + height = int(((round(t) + 0.5) - (round(b) - 0.5)) * magnification) + x_pix = np.linspace(vl.x0, vl.x1, width) + y_pix = np.linspace(vl.y0, vl.y1, height) + if self._interpolation == "nearest": + x_mid = (self._Ax[:-1] + self._Ax[1:]) / 2 + y_mid = (self._Ay[:-1] + self._Ay[1:]) / 2 + x_int = x_mid.searchsorted(x_pix) + y_int = y_mid.searchsorted(y_pix) + # The following is equal to `A[y_int[:, None], x_int[None, :]]`, + # but many times faster. Both casting to uint32 (to have an + # effectively 1D array) and manual index flattening matter. + im = ( + np.ascontiguousarray(A).view(np.uint32).ravel()[ + np.add.outer(y_int * A.shape[1], x_int)] + .view(np.uint8).reshape((height, width, 4))) + else: # self._interpolation == "bilinear" + # Use np.interp to compute x_int/x_float has similar speed. + x_int = np.clip( + self._Ax.searchsorted(x_pix) - 1, 0, len(self._Ax) - 2) + y_int = np.clip( + self._Ay.searchsorted(y_pix) - 1, 0, len(self._Ay) - 2) + idx_int = np.add.outer(y_int * A.shape[1], x_int) + x_frac = np.clip( + np.divide(x_pix - self._Ax[x_int], np.diff(self._Ax)[x_int], + dtype=np.float32), # Downcasting helps with speed. + 0, 1) + y_frac = np.clip( + np.divide(y_pix - self._Ay[y_int], np.diff(self._Ay)[y_int], + dtype=np.float32), + 0, 1) + f00 = np.outer(1 - y_frac, 1 - x_frac) + f10 = np.outer(y_frac, 1 - x_frac) + f01 = np.outer(1 - y_frac, x_frac) + f11 = np.outer(y_frac, x_frac) + im = np.empty((height, width, 4), np.uint8) + for chan in range(4): + ac = A[:, :, chan].reshape(-1) # reshape(-1) avoids a copy. + # Shifting the buffer start (`ac[offset:]`) avoids an array + # addition (`ac[idx_int + offset]`). + buf = f00 * ac[idx_int] + buf += f10 * ac[A.shape[1]:][idx_int] + buf += f01 * ac[1:][idx_int] + buf += f11 * ac[A.shape[1] + 1:][idx_int] + im[:, :, chan] = buf # Implicitly casts to uint8. + return im, l, b, IdentityTransform() + + def set_data(self, x, y, A): + """ + Set the grid for the pixel centers, and the pixel values. + + Parameters + ---------- + x, y : 1D array-like + Monotonic arrays of shapes (N,) and (M,), respectively, specifying + pixel centers. + A : array-like + (M, N) `~numpy.ndarray` or masked array of values to be + colormapped, or (M, N, 3) RGB array, or (M, N, 4) RGBA array. + """ + A = self._normalize_image_array(A) + x = np.array(x, np.float32) + y = np.array(y, np.float32) + if not (x.ndim == y.ndim == 1 and A.shape[:2] == y.shape + x.shape): + raise TypeError("Axes don't match array shape") + self._A = A + self._Ax = x + self._Ay = y + self._imcache = None + self.stale = True + + def set_array(self, *args): + raise NotImplementedError('Method not supported') + + def set_interpolation(self, s): + """ + Parameters + ---------- + s : {'nearest', 'bilinear'} or None + If None, use :rc:`image.interpolation`. + """ + if s is not None and s not in ('nearest', 'bilinear'): + raise NotImplementedError('Only nearest neighbor and ' + 'bilinear interpolations are supported') + super().set_interpolation(s) + + def get_extent(self): + if self._A is None: + raise RuntimeError('Must set data first') + return self._Ax[0], self._Ax[-1], self._Ay[0], self._Ay[-1] + + @_api.rename_parameter("3.8", "s", "filternorm") + def set_filternorm(self, filternorm): + pass + + @_api.rename_parameter("3.8", "s", "filterrad") + def set_filterrad(self, filterrad): + pass + + def set_norm(self, norm): + if self._A is not None: + raise RuntimeError('Cannot change colors after loading data') + super().set_norm(norm) + + def set_cmap(self, cmap): + if self._A is not None: + raise RuntimeError('Cannot change colors after loading data') + super().set_cmap(cmap) + + def get_cursor_data(self, event): + # docstring inherited + x, y = event.xdata, event.ydata + if (x < self._Ax[0] or x > self._Ax[-1] or + y < self._Ay[0] or y > self._Ay[-1]): + return None + j = np.searchsorted(self._Ax, x) - 1 + i = np.searchsorted(self._Ay, y) - 1 + return self._A[i, j] + + +class PcolorImage(AxesImage): + """ + Make a pcolor-style plot with an irregular rectangular grid. + + This uses a variation of the original irregular image code, + and it is used by pcolorfast for the corresponding grid type. + """ + + def __init__(self, ax, + x=None, + y=None, + A=None, + *, + cmap=None, + norm=None, + **kwargs + ): + """ + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The Axes the image will belong to. + x, y : 1D array-like, optional + Monotonic arrays of length N+1 and M+1, respectively, specifying + rectangle boundaries. If not given, will default to + ``range(N + 1)`` and ``range(M + 1)``, respectively. + A : array-like + The data to be color-coded. The interpretation depends on the + shape: + + - (M, N) `~numpy.ndarray` or masked array: values to be colormapped + - (M, N, 3): RGB array + - (M, N, 4): RGBA array + + cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` + The Colormap instance or registered colormap name used to map + scalar data to colors. + norm : str or `~matplotlib.colors.Normalize` + Maps luminance to 0-1. + **kwargs : `~matplotlib.artist.Artist` properties + """ + super().__init__(ax, norm=norm, cmap=cmap) + self._internal_update(kwargs) + if A is not None: + self.set_data(x, y, A) + + def make_image(self, renderer, magnification=1.0, unsampled=False): + # docstring inherited + if self._A is None: + raise RuntimeError('You must first set the image array') + if unsampled: + raise ValueError('unsampled not supported on PColorImage') + + if self._imcache is None: + A = self.to_rgba(self._A, bytes=True) + self._imcache = np.pad(A, [(1, 1), (1, 1), (0, 0)], "constant") + padded_A = self._imcache + bg = mcolors.to_rgba(self.axes.patch.get_facecolor(), 0) + bg = (np.array(bg) * 255).astype(np.uint8) + if (padded_A[0, 0] != bg).all(): + padded_A[[0, -1], :] = padded_A[:, [0, -1]] = bg + + l, b, r, t = self.axes.bbox.extents + width = (round(r) + 0.5) - (round(l) - 0.5) + height = (round(t) + 0.5) - (round(b) - 0.5) + width = round(width * magnification) + height = round(height * magnification) + vl = self.axes.viewLim + + x_pix = np.linspace(vl.x0, vl.x1, width) + y_pix = np.linspace(vl.y0, vl.y1, height) + x_int = self._Ax.searchsorted(x_pix) + y_int = self._Ay.searchsorted(y_pix) + im = ( # See comment in NonUniformImage.make_image re: performance. + padded_A.view(np.uint32).ravel()[ + np.add.outer(y_int * padded_A.shape[1], x_int)] + .view(np.uint8).reshape((height, width, 4))) + return im, l, b, IdentityTransform() + + def _check_unsampled_image(self): + return False + + def set_data(self, x, y, A): + """ + Set the grid for the rectangle boundaries, and the data values. + + Parameters + ---------- + x, y : 1D array-like, optional + Monotonic arrays of length N+1 and M+1, respectively, specifying + rectangle boundaries. If not given, will default to + ``range(N + 1)`` and ``range(M + 1)``, respectively. + A : array-like + The data to be color-coded. The interpretation depends on the + shape: + + - (M, N) `~numpy.ndarray` or masked array: values to be colormapped + - (M, N, 3): RGB array + - (M, N, 4): RGBA array + """ + A = self._normalize_image_array(A) + x = np.arange(0., A.shape[1] + 1) if x is None else np.array(x, float).ravel() + y = np.arange(0., A.shape[0] + 1) if y is None else np.array(y, float).ravel() + if A.shape[:2] != (y.size - 1, x.size - 1): + raise ValueError( + "Axes don't match array shape. Got %s, expected %s." % + (A.shape[:2], (y.size - 1, x.size - 1))) + # For efficient cursor readout, ensure x and y are increasing. + if x[-1] < x[0]: + x = x[::-1] + A = A[:, ::-1] + if y[-1] < y[0]: + y = y[::-1] + A = A[::-1] + self._A = A + self._Ax = x + self._Ay = y + self._imcache = None + self.stale = True + + def set_array(self, *args): + raise NotImplementedError('Method not supported') + + def get_cursor_data(self, event): + # docstring inherited + x, y = event.xdata, event.ydata + if (x < self._Ax[0] or x > self._Ax[-1] or + y < self._Ay[0] or y > self._Ay[-1]): + return None + j = np.searchsorted(self._Ax, x) - 1 + i = np.searchsorted(self._Ay, y) - 1 + return self._A[i, j] + + +class FigureImage(_ImageBase): + """An image attached to a figure.""" + + zorder = 0 + + _interpolation = 'nearest' + + def __init__(self, fig, + *, + cmap=None, + norm=None, + offsetx=0, + offsety=0, + origin=None, + **kwargs + ): + """ + cmap is a colors.Colormap instance + norm is a colors.Normalize instance to map luminance to 0-1 + + kwargs are an optional list of Artist keyword args + """ + super().__init__( + None, + norm=norm, + cmap=cmap, + origin=origin + ) + self.figure = fig + self.ox = offsetx + self.oy = offsety + self._internal_update(kwargs) + self.magnification = 1.0 + + def get_extent(self): + """Return the image extent as tuple (left, right, bottom, top).""" + numrows, numcols = self.get_size() + return (-0.5 + self.ox, numcols-0.5 + self.ox, + -0.5 + self.oy, numrows-0.5 + self.oy) + + def make_image(self, renderer, magnification=1.0, unsampled=False): + # docstring inherited + fac = renderer.dpi/self.figure.dpi + # fac here is to account for pdf, eps, svg backends where + # figure.dpi is set to 72. This means we need to scale the + # image (using magnification) and offset it appropriately. + bbox = Bbox([[self.ox/fac, self.oy/fac], + [(self.ox/fac + self._A.shape[1]), + (self.oy/fac + self._A.shape[0])]]) + width, height = self.figure.get_size_inches() + width *= renderer.dpi + height *= renderer.dpi + clip = Bbox([[0, 0], [width, height]]) + return self._make_image( + self._A, bbox, bbox, clip, magnification=magnification / fac, + unsampled=unsampled, round_to_pixel_border=False) + + def set_data(self, A): + """Set the image array.""" + cm.ScalarMappable.set_array(self, A) + self.stale = True + + +class BboxImage(_ImageBase): + """The Image class whose size is determined by the given bbox.""" + + def __init__(self, bbox, + *, + cmap=None, + norm=None, + interpolation=None, + origin=None, + filternorm=True, + filterrad=4.0, + resample=False, + **kwargs + ): + """ + cmap is a colors.Colormap instance + norm is a colors.Normalize instance to map luminance to 0-1 + + kwargs are an optional list of Artist keyword args + """ + super().__init__( + None, + cmap=cmap, + norm=norm, + interpolation=interpolation, + origin=origin, + filternorm=filternorm, + filterrad=filterrad, + resample=resample, + **kwargs + ) + self.bbox = bbox + + def get_window_extent(self, renderer=None): + if renderer is None: + renderer = self.get_figure()._get_renderer() + + if isinstance(self.bbox, BboxBase): + return self.bbox + elif callable(self.bbox): + return self.bbox(renderer) + else: + raise ValueError("Unknown type of bbox") + + def contains(self, mouseevent): + """Test whether the mouse event occurred within the image.""" + if self._different_canvas(mouseevent) or not self.get_visible(): + return False, {} + x, y = mouseevent.x, mouseevent.y + inside = self.get_window_extent().contains(x, y) + return inside, {} + + def make_image(self, renderer, magnification=1.0, unsampled=False): + # docstring inherited + width, height = renderer.get_canvas_width_height() + bbox_in = self.get_window_extent(renderer).frozen() + bbox_in._points /= [width, height] + bbox_out = self.get_window_extent(renderer) + clip = Bbox([[0, 0], [width, height]]) + self._transform = BboxTransformTo(clip) + return self._make_image( + self._A, + bbox_in, bbox_out, clip, magnification, unsampled=unsampled) + + +def imread(fname, format=None): + """ + Read an image from a file into an array. + + .. note:: + + This function exists for historical reasons. It is recommended to + use `PIL.Image.open` instead for loading images. + + Parameters + ---------- + fname : str or file-like + The image file to read: a filename, a URL or a file-like object opened + in read-binary mode. + + Passing a URL is deprecated. Please open the URL + for reading and pass the result to Pillow, e.g. with + ``np.array(PIL.Image.open(urllib.request.urlopen(url)))``. + format : str, optional + The image file format assumed for reading the data. The image is + loaded as a PNG file if *format* is set to "png", if *fname* is a path + or opened file with a ".png" extension, or if it is a URL. In all + other cases, *format* is ignored and the format is auto-detected by + `PIL.Image.open`. + + Returns + ------- + `numpy.array` + The image data. The returned array has shape + + - (M, N) for grayscale images. + - (M, N, 3) for RGB images. + - (M, N, 4) for RGBA images. + + PNG images are returned as float arrays (0-1). All other formats are + returned as int arrays, with a bit depth determined by the file's + contents. + """ + # hide imports to speed initial import on systems with slow linkers + from urllib import parse + + if format is None: + if isinstance(fname, str): + parsed = parse.urlparse(fname) + # If the string is a URL (Windows paths appear as if they have a + # length-1 scheme), assume png. + if len(parsed.scheme) > 1: + ext = 'png' + else: + ext = Path(fname).suffix.lower()[1:] + elif hasattr(fname, 'geturl'): # Returned by urlopen(). + # We could try to parse the url's path and use the extension, but + # returning png is consistent with the block above. Note that this + # if clause has to come before checking for fname.name as + # urlopen("file:///...") also has a name attribute (with the fixed + # value ""). + ext = 'png' + elif hasattr(fname, 'name'): + ext = Path(fname.name).suffix.lower()[1:] + else: + ext = 'png' + else: + ext = format + img_open = ( + PIL.PngImagePlugin.PngImageFile if ext == 'png' else PIL.Image.open) + if isinstance(fname, str) and len(parse.urlparse(fname).scheme) > 1: + # Pillow doesn't handle URLs directly. + raise ValueError( + "Please open the URL for reading and pass the " + "result to Pillow, e.g. with " + "``np.array(PIL.Image.open(urllib.request.urlopen(url)))``." + ) + with img_open(fname) as image: + return (_pil_png_to_float_array(image) + if isinstance(image, PIL.PngImagePlugin.PngImageFile) else + pil_to_array(image)) + + +def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, + origin=None, dpi=100, *, metadata=None, pil_kwargs=None): + """ + Colormap and save an array as an image file. + + RGB(A) images are passed through. Single channel images will be + colormapped according to *cmap* and *norm*. + + .. note:: + + If you want to save a single channel image as gray scale please use an + image I/O library (such as pillow, tifffile, or imageio) directly. + + Parameters + ---------- + fname : str or path-like or file-like + A path or a file-like object to store the image in. + If *format* is not set, then the output format is inferred from the + extension of *fname*, if any, and from :rc:`savefig.format` otherwise. + If *format* is set, it determines the output format. + arr : array-like + The image data. The shape can be one of + MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA). + vmin, vmax : float, optional + *vmin* and *vmax* set the color scaling for the image by fixing the + values that map to the colormap color limits. If either *vmin* + or *vmax* is None, that limit is determined from the *arr* + min/max value. + cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` + A Colormap instance or registered colormap name. The colormap + maps scalar data to colors. It is ignored for RGB(A) data. + format : str, optional + The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when this + is unset is documented under *fname*. + origin : {'upper', 'lower'}, default: :rc:`image.origin` + Indicates whether the ``(0, 0)`` index of the array is in the upper + left or lower left corner of the Axes. + dpi : float + The DPI to store in the metadata of the file. This does not affect the + resolution of the output image. Depending on file format, this may be + rounded to the nearest integer. + metadata : dict, optional + Metadata in the image file. The supported keys depend on the output + format, see the documentation of the respective backends for more + information. + Currently only supported for "png", "pdf", "ps", "eps", and "svg". + pil_kwargs : dict, optional + Keyword arguments passed to `PIL.Image.Image.save`. If the 'pnginfo' + key is present, it completely overrides *metadata*, including the + default 'Software' key. + """ + from matplotlib.figure import Figure + if isinstance(fname, os.PathLike): + fname = os.fspath(fname) + if format is None: + format = (Path(fname).suffix[1:] if isinstance(fname, str) + else mpl.rcParams["savefig.format"]).lower() + if format in ["pdf", "ps", "eps", "svg"]: + # Vector formats that are not handled by PIL. + if pil_kwargs is not None: + raise ValueError( + f"Cannot use 'pil_kwargs' when saving to {format}") + fig = Figure(dpi=dpi, frameon=False) + fig.figimage(arr, cmap=cmap, vmin=vmin, vmax=vmax, origin=origin, + resize=True) + fig.savefig(fname, dpi=dpi, format=format, transparent=True, + metadata=metadata) + else: + # Don't bother creating an image; this avoids rounding errors on the + # size when dividing and then multiplying by dpi. + if origin is None: + origin = mpl.rcParams["image.origin"] + else: + _api.check_in_list(('upper', 'lower'), origin=origin) + if origin == "lower": + arr = arr[::-1] + if (isinstance(arr, memoryview) and arr.format == "B" + and arr.ndim == 3 and arr.shape[-1] == 4): + # Such an ``arr`` would also be handled fine by sm.to_rgba below + # (after casting with asarray), but it is useful to special-case it + # because that's what backend_agg passes, and can be in fact used + # as is, saving a few operations. + rgba = arr + else: + sm = cm.ScalarMappable(cmap=cmap) + sm.set_clim(vmin, vmax) + rgba = sm.to_rgba(arr, bytes=True) + if pil_kwargs is None: + pil_kwargs = {} + else: + # we modify this below, so make a copy (don't modify caller's dict) + pil_kwargs = pil_kwargs.copy() + pil_shape = (rgba.shape[1], rgba.shape[0]) + rgba = np.require(rgba, requirements='C') + image = PIL.Image.frombuffer( + "RGBA", pil_shape, rgba, "raw", "RGBA", 0, 1) + if format == "png": + # Only use the metadata kwarg if pnginfo is not set, because the + # semantics of duplicate keys in pnginfo is unclear. + if "pnginfo" in pil_kwargs: + if metadata: + _api.warn_external("'metadata' is overridden by the " + "'pnginfo' entry in 'pil_kwargs'.") + else: + metadata = { + "Software": (f"Matplotlib version{mpl.__version__}, " + f"https://matplotlib.org/"), + **(metadata if metadata is not None else {}), + } + pil_kwargs["pnginfo"] = pnginfo = PIL.PngImagePlugin.PngInfo() + for k, v in metadata.items(): + if v is not None: + pnginfo.add_text(k, v) + elif metadata is not None: + raise ValueError(f"metadata not supported for format {format!r}") + if format in ["jpg", "jpeg"]: + format = "jpeg" # Pillow doesn't recognize "jpg". + facecolor = mpl.rcParams["savefig.facecolor"] + if cbook._str_equal(facecolor, "auto"): + facecolor = mpl.rcParams["figure.facecolor"] + color = tuple(int(x * 255) for x in mcolors.to_rgb(facecolor)) + background = PIL.Image.new("RGB", pil_shape, color) + background.paste(image, image) + image = background + pil_kwargs.setdefault("format", format) + pil_kwargs.setdefault("dpi", (dpi, dpi)) + image.save(fname, **pil_kwargs) + + +def pil_to_array(pilImage): + """ + Load a `PIL image`_ and return it as a numpy int array. + + .. _PIL image: https://pillow.readthedocs.io/en/latest/reference/Image.html + + Returns + ------- + numpy.array + + The array shape depends on the image type: + + - (M, N) for grayscale images. + - (M, N, 3) for RGB images. + - (M, N, 4) for RGBA images. + """ + if pilImage.mode in ['RGBA', 'RGBX', 'RGB', 'L']: + # return MxNx4 RGBA, MxNx3 RBA, or MxN luminance array + return np.asarray(pilImage) + elif pilImage.mode.startswith('I;16'): + # return MxN luminance array of uint16 + raw = pilImage.tobytes('raw', pilImage.mode) + if pilImage.mode.endswith('B'): + x = np.frombuffer(raw, '>u2') + else: + x = np.frombuffer(raw, ' None: ... + +# +# END names re-exported from matplotlib._image. +# + +interpolations_names: set[str] + +def composite_images( + images: Sequence[_ImageBase], renderer: RendererBase, magnification: float = ... +) -> tuple[np.ndarray, float, float]: ... + +class _ImageBase(martist.Artist, cm.ScalarMappable): + zorder: float + origin: Literal["upper", "lower"] + axes: Axes + def __init__( + self, + ax: Axes, + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + interpolation: str | None = ..., + origin: Literal["upper", "lower"] | None = ..., + filternorm: bool = ..., + filterrad: float = ..., + resample: bool | None = ..., + *, + interpolation_stage: Literal["data", "rgba"] | None = ..., + **kwargs + ) -> None: ... + def get_size(self) -> tuple[int, int]: ... + def set_alpha(self, alpha: float | ArrayLike | None) -> None: ... + def changed(self) -> None: ... + def make_image( + self, renderer: RendererBase, magnification: float = ..., unsampled: bool = ... + ) -> tuple[np.ndarray, float, float, Affine2D]: ... + def draw(self, renderer: RendererBase) -> None: ... + def write_png(self, fname: str | pathlib.Path | BinaryIO) -> None: ... + def set_data(self, A: ArrayLike | None) -> None: ... + def set_array(self, A: ArrayLike | None) -> None: ... + def get_shape(self) -> tuple[int, int, int]: ... + def get_interpolation(self) -> str: ... + def set_interpolation(self, s: str | None) -> None: ... + def get_interpolation_stage(self) -> Literal["data", "rgba"]: ... + def set_interpolation_stage(self, s: Literal["data", "rgba"]) -> None: ... + def can_composite(self) -> bool: ... + def set_resample(self, v: bool | None) -> None: ... + def get_resample(self) -> bool: ... + def set_filternorm(self, filternorm: bool) -> None: ... + def get_filternorm(self) -> bool: ... + def set_filterrad(self, filterrad: float) -> None: ... + def get_filterrad(self) -> float: ... + +class AxesImage(_ImageBase): + def __init__( + self, + ax: Axes, + *, + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + interpolation: str | None = ..., + origin: Literal["upper", "lower"] | None = ..., + extent: tuple[float, float, float, float] | None = ..., + filternorm: bool = ..., + filterrad: float = ..., + resample: bool = ..., + interpolation_stage: Literal["data", "rgba"] | None = ..., + **kwargs + ) -> None: ... + def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... + def make_image( + self, renderer: RendererBase, magnification: float = ..., unsampled: bool = ... + ) -> tuple[np.ndarray, float, float, Affine2D]: ... + def set_extent( + self, extent: tuple[float, float, float, float], **kwargs + ) -> None: ... + def get_extent(self) -> tuple[float, float, float, float]: ... + def get_cursor_data(self, event: MouseEvent) -> None | float: ... + +class NonUniformImage(AxesImage): + mouseover: bool + def __init__( + self, ax: Axes, *, interpolation: Literal["nearest", "bilinear"] = ..., **kwargs + ) -> None: ... + def set_data(self, x: ArrayLike, y: ArrayLike, A: ArrayLike) -> None: ... # type: ignore[override] + # more limited interpolation available here than base class + def set_interpolation(self, s: Literal["nearest", "bilinear"]) -> None: ... # type: ignore[override] + +class PcolorImage(AxesImage): + def __init__( + self, + ax: Axes, + x: ArrayLike | None = ..., + y: ArrayLike | None = ..., + A: ArrayLike | None = ..., + *, + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + **kwargs + ) -> None: ... + def set_data(self, x: ArrayLike, y: ArrayLike, A: ArrayLike) -> None: ... # type: ignore[override] + +class FigureImage(_ImageBase): + zorder: float + figure: Figure + ox: float + oy: float + magnification: float + def __init__( + self, + fig: Figure, + *, + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + offsetx: int = ..., + offsety: int = ..., + origin: Literal["upper", "lower"] | None = ..., + **kwargs + ) -> None: ... + def get_extent(self) -> tuple[float, float, float, float]: ... + +class BboxImage(_ImageBase): + bbox: BboxBase + def __init__( + self, + bbox: BboxBase | Callable[[RendererBase | None], Bbox], + *, + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + interpolation: str | None = ..., + origin: Literal["upper", "lower"] | None = ..., + filternorm: bool = ..., + filterrad: float = ..., + resample: bool = ..., + **kwargs + ) -> None: ... + def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... + +def imread( + fname: str | pathlib.Path | BinaryIO, format: str | None = ... +) -> np.ndarray: ... +def imsave( + fname: str | os.PathLike | BinaryIO, + arr: ArrayLike, + vmin: float | None = ..., + vmax: float | None = ..., + cmap: str | Colormap | None = ..., + format: str | None = ..., + origin: Literal["upper", "lower"] | None = ..., + dpi: float = ..., + *, + metadata: dict[str, str] | None = ..., + pil_kwargs: dict[str, Any] | None = ... +) -> None: ... +def pil_to_array(pilImage: PIL.Image.Image) -> np.ndarray: ... +def thumbnail( + infile: str | BinaryIO, + thumbfile: str | BinaryIO, + scale: float = ..., + interpolation: str = ..., + preview: bool = ..., +) -> Figure: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/layout_engine.py b/venv/lib/python3.10/site-packages/matplotlib/layout_engine.py new file mode 100644 index 00000000..5a96745d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/layout_engine.py @@ -0,0 +1,304 @@ +""" +Classes to layout elements in a `.Figure`. + +Figures have a ``layout_engine`` property that holds a subclass of +`~.LayoutEngine` defined here (or *None* for no layout). At draw time +``figure.get_layout_engine().execute()`` is called, the goal of which is +usually to rearrange Axes on the figure to produce a pleasing layout. This is +like a ``draw`` callback but with two differences. First, when printing we +disable the layout engine for the final draw. Second, it is useful to know the +layout engine while the figure is being created. In particular, colorbars are +made differently with different layout engines (for historical reasons). + +Matplotlib supplies two layout engines, `.TightLayoutEngine` and +`.ConstrainedLayoutEngine`. Third parties can create their own layout engine +by subclassing `.LayoutEngine`. +""" + +from contextlib import nullcontext + +import matplotlib as mpl + +from matplotlib._constrained_layout import do_constrained_layout +from matplotlib._tight_layout import (get_subplotspec_list, + get_tight_layout_figure) + + +class LayoutEngine: + """ + Base class for Matplotlib layout engines. + + A layout engine can be passed to a figure at instantiation or at any time + with `~.figure.Figure.set_layout_engine`. Once attached to a figure, the + layout engine ``execute`` function is called at draw time by + `~.figure.Figure.draw`, providing a special draw-time hook. + + .. note:: + + However, note that layout engines affect the creation of colorbars, so + `~.figure.Figure.set_layout_engine` should be called before any + colorbars are created. + + Currently, there are two properties of `LayoutEngine` classes that are + consulted while manipulating the figure: + + - ``engine.colorbar_gridspec`` tells `.Figure.colorbar` whether to make the + axes using the gridspec method (see `.colorbar.make_axes_gridspec`) or + not (see `.colorbar.make_axes`); + - ``engine.adjust_compatible`` stops `.Figure.subplots_adjust` from being + run if it is not compatible with the layout engine. + + To implement a custom `LayoutEngine`: + + 1. override ``_adjust_compatible`` and ``_colorbar_gridspec`` + 2. override `LayoutEngine.set` to update *self._params* + 3. override `LayoutEngine.execute` with your implementation + + """ + # override these in subclass + _adjust_compatible = None + _colorbar_gridspec = None + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self._params = {} + + def set(self, **kwargs): + """ + Set the parameters for the layout engine. + """ + raise NotImplementedError + + @property + def colorbar_gridspec(self): + """ + Return a boolean if the layout engine creates colorbars using a + gridspec. + """ + if self._colorbar_gridspec is None: + raise NotImplementedError + return self._colorbar_gridspec + + @property + def adjust_compatible(self): + """ + Return a boolean if the layout engine is compatible with + `~.Figure.subplots_adjust`. + """ + if self._adjust_compatible is None: + raise NotImplementedError + return self._adjust_compatible + + def get(self): + """ + Return copy of the parameters for the layout engine. + """ + return dict(self._params) + + def execute(self, fig): + """ + Execute the layout on the figure given by *fig*. + """ + # subclasses must implement this. + raise NotImplementedError + + +class PlaceHolderLayoutEngine(LayoutEngine): + """ + This layout engine does not adjust the figure layout at all. + + The purpose of this `.LayoutEngine` is to act as a placeholder when the user removes + a layout engine to ensure an incompatible `.LayoutEngine` cannot be set later. + + Parameters + ---------- + adjust_compatible, colorbar_gridspec : bool + Allow the PlaceHolderLayoutEngine to mirror the behavior of whatever + layout engine it is replacing. + + """ + def __init__(self, adjust_compatible, colorbar_gridspec, **kwargs): + self._adjust_compatible = adjust_compatible + self._colorbar_gridspec = colorbar_gridspec + super().__init__(**kwargs) + + def execute(self, fig): + """ + Do nothing. + """ + return + + +class TightLayoutEngine(LayoutEngine): + """ + Implements the ``tight_layout`` geometry management. See + :ref:`tight_layout_guide` for details. + """ + _adjust_compatible = True + _colorbar_gridspec = True + + def __init__(self, *, pad=1.08, h_pad=None, w_pad=None, + rect=(0, 0, 1, 1), **kwargs): + """ + Initialize tight_layout engine. + + Parameters + ---------- + pad : float, default: 1.08 + Padding between the figure edge and the edges of subplots, as a + fraction of the font size. + h_pad, w_pad : float + Padding (height/width) between edges of adjacent subplots. + Defaults to *pad*. + rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1). + rectangle in normalized figure coordinates that the subplots + (including labels) will fit into. + """ + super().__init__(**kwargs) + for td in ['pad', 'h_pad', 'w_pad', 'rect']: + # initialize these in case None is passed in above: + self._params[td] = None + self.set(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) + + def execute(self, fig): + """ + Execute tight_layout. + + This decides the subplot parameters given the padding that + will allow the Axes labels to not be covered by other labels + and Axes. + + Parameters + ---------- + fig : `.Figure` to perform layout on. + + See Also + -------- + .figure.Figure.tight_layout + .pyplot.tight_layout + """ + info = self._params + renderer = fig._get_renderer() + with getattr(renderer, "_draw_disabled", nullcontext)(): + kwargs = get_tight_layout_figure( + fig, fig.axes, get_subplotspec_list(fig.axes), renderer, + pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'], + rect=info['rect']) + if kwargs: + fig.subplots_adjust(**kwargs) + + def set(self, *, pad=None, w_pad=None, h_pad=None, rect=None): + """ + Set the pads for tight_layout. + + Parameters + ---------- + pad : float + Padding between the figure edge and the edges of subplots, as a + fraction of the font size. + w_pad, h_pad : float + Padding (width/height) between edges of adjacent subplots. + Defaults to *pad*. + rect : tuple (left, bottom, right, top) + rectangle in normalized figure coordinates that the subplots + (including labels) will fit into. + """ + for td in self.set.__kwdefaults__: + if locals()[td] is not None: + self._params[td] = locals()[td] + + +class ConstrainedLayoutEngine(LayoutEngine): + """ + Implements the ``constrained_layout`` geometry management. See + :ref:`constrainedlayout_guide` for details. + """ + + _adjust_compatible = False + _colorbar_gridspec = False + + def __init__(self, *, h_pad=None, w_pad=None, + hspace=None, wspace=None, rect=(0, 0, 1, 1), + compress=False, **kwargs): + """ + Initialize ``constrained_layout`` settings. + + Parameters + ---------- + h_pad, w_pad : float + Padding around the Axes elements in inches. + Default to :rc:`figure.constrained_layout.h_pad` and + :rc:`figure.constrained_layout.w_pad`. + hspace, wspace : float + Fraction of the figure to dedicate to space between the + axes. These are evenly spread between the gaps between the Axes. + A value of 0.2 for a three-column layout would have a space + of 0.1 of the figure width between each column. + If h/wspace < h/w_pad, then the pads are used instead. + Default to :rc:`figure.constrained_layout.hspace` and + :rc:`figure.constrained_layout.wspace`. + rect : tuple of 4 floats + Rectangle in figure coordinates to perform constrained layout in + (left, bottom, width, height), each from 0-1. + compress : bool + Whether to shift Axes so that white space in between them is + removed. This is useful for simple grids of fixed-aspect Axes (e.g. + a grid of images). See :ref:`compressed_layout`. + """ + super().__init__(**kwargs) + # set the defaults: + self.set(w_pad=mpl.rcParams['figure.constrained_layout.w_pad'], + h_pad=mpl.rcParams['figure.constrained_layout.h_pad'], + wspace=mpl.rcParams['figure.constrained_layout.wspace'], + hspace=mpl.rcParams['figure.constrained_layout.hspace'], + rect=(0, 0, 1, 1)) + # set anything that was passed in (None will be ignored): + self.set(w_pad=w_pad, h_pad=h_pad, wspace=wspace, hspace=hspace, + rect=rect) + self._compress = compress + + def execute(self, fig): + """ + Perform constrained_layout and move and resize Axes accordingly. + + Parameters + ---------- + fig : `.Figure` to perform layout on. + """ + width, height = fig.get_size_inches() + # pads are relative to the current state of the figure... + w_pad = self._params['w_pad'] / width + h_pad = self._params['h_pad'] / height + + return do_constrained_layout(fig, w_pad=w_pad, h_pad=h_pad, + wspace=self._params['wspace'], + hspace=self._params['hspace'], + rect=self._params['rect'], + compress=self._compress) + + def set(self, *, h_pad=None, w_pad=None, + hspace=None, wspace=None, rect=None): + """ + Set the pads for constrained_layout. + + Parameters + ---------- + h_pad, w_pad : float + Padding around the Axes elements in inches. + Default to :rc:`figure.constrained_layout.h_pad` and + :rc:`figure.constrained_layout.w_pad`. + hspace, wspace : float + Fraction of the figure to dedicate to space between the + axes. These are evenly spread between the gaps between the Axes. + A value of 0.2 for a three-column layout would have a space + of 0.1 of the figure width between each column. + If h/wspace < h/w_pad, then the pads are used instead. + Default to :rc:`figure.constrained_layout.hspace` and + :rc:`figure.constrained_layout.wspace`. + rect : tuple of 4 floats + Rectangle in figure coordinates to perform constrained layout in + (left, bottom, width, height), each from 0-1. + """ + for td in self.set.__kwdefaults__: + if locals()[td] is not None: + self._params[td] = locals()[td] diff --git a/venv/lib/python3.10/site-packages/matplotlib/layout_engine.pyi b/venv/lib/python3.10/site-packages/matplotlib/layout_engine.pyi new file mode 100644 index 00000000..5b8c812f --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/layout_engine.pyi @@ -0,0 +1,62 @@ +from matplotlib.figure import Figure + +from typing import Any + +class LayoutEngine: + def __init__(self, **kwargs: Any) -> None: ... + def set(self) -> None: ... + @property + def colorbar_gridspec(self) -> bool: ... + @property + def adjust_compatible(self) -> bool: ... + def get(self) -> dict[str, Any]: ... + def execute(self, fig: Figure) -> None: ... + +class PlaceHolderLayoutEngine(LayoutEngine): + def __init__( + self, adjust_compatible: bool, colorbar_gridspec: bool, **kwargs: Any + ) -> None: ... + def execute(self, fig: Figure) -> None: ... + +class TightLayoutEngine(LayoutEngine): + def __init__( + self, + *, + pad: float = ..., + h_pad: float | None = ..., + w_pad: float | None = ..., + rect: tuple[float, float, float, float] = ..., + **kwargs: Any + ) -> None: ... + def execute(self, fig: Figure) -> None: ... + def set( + self, + *, + pad: float | None = ..., + w_pad: float | None = ..., + h_pad: float | None = ..., + rect: tuple[float, float, float, float] | None = ... + ) -> None: ... + +class ConstrainedLayoutEngine(LayoutEngine): + def __init__( + self, + *, + h_pad: float | None = ..., + w_pad: float | None = ..., + hspace: float | None = ..., + wspace: float | None = ..., + rect: tuple[float, float, float, float] = ..., + compress: bool = ..., + **kwargs: Any + ) -> None: ... + def execute(self, fig: Figure) -> Any: ... + def set( + self, + *, + h_pad: float | None = ..., + w_pad: float | None = ..., + hspace: float | None = ..., + wspace: float | None = ..., + rect: tuple[float, float, float, float] | None = ... + ) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/legend.py b/venv/lib/python3.10/site-packages/matplotlib/legend.py new file mode 100644 index 00000000..9033fc23 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/legend.py @@ -0,0 +1,1385 @@ +""" +The legend module defines the Legend class, which is responsible for +drawing legends associated with Axes and/or figures. + +.. important:: + + It is unlikely that you would ever create a Legend instance manually. + Most users would normally create a legend via the `~.Axes.legend` + function. For more details on legends there is also a :ref:`legend guide + `. + +The `Legend` class is a container of legend handles and legend texts. + +The legend handler map specifies how to create legend handles from artists +(lines, patches, etc.) in the Axes or figures. Default legend handlers are +defined in the :mod:`~matplotlib.legend_handler` module. While not all artist +types are covered by the default legend handlers, custom legend handlers can be +defined to support arbitrary objects. + +See the :ref`` for more +information. +""" + +import itertools +import logging +import numbers +import time + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, _docstring, cbook, colors, offsetbox +from matplotlib.artist import Artist, allow_rasterization +from matplotlib.cbook import silent_list +from matplotlib.font_manager import FontProperties +from matplotlib.lines import Line2D +from matplotlib.patches import (Patch, Rectangle, Shadow, FancyBboxPatch, + StepPatch) +from matplotlib.collections import ( + Collection, CircleCollection, LineCollection, PathCollection, + PolyCollection, RegularPolyCollection) +from matplotlib.text import Text +from matplotlib.transforms import Bbox, BboxBase, TransformedBbox +from matplotlib.transforms import BboxTransformTo, BboxTransformFrom +from matplotlib.offsetbox import ( + AnchoredOffsetbox, DraggableOffsetBox, + HPacker, VPacker, + DrawingArea, TextArea, +) +from matplotlib.container import ErrorbarContainer, BarContainer, StemContainer +from . import legend_handler + + +class DraggableLegend(DraggableOffsetBox): + def __init__(self, legend, use_blit=False, update="loc"): + """ + Wrapper around a `.Legend` to support mouse dragging. + + Parameters + ---------- + legend : `.Legend` + The `.Legend` instance to wrap. + use_blit : bool, optional + Use blitting for faster image composition. For details see + :ref:`func-animation`. + update : {'loc', 'bbox'}, optional + If "loc", update the *loc* parameter of the legend upon finalizing. + If "bbox", update the *bbox_to_anchor* parameter. + """ + self.legend = legend + + _api.check_in_list(["loc", "bbox"], update=update) + self._update = update + + super().__init__(legend, legend._legend_box, use_blit=use_blit) + + def finalize_offset(self): + if self._update == "loc": + self._update_loc(self.get_loc_in_canvas()) + elif self._update == "bbox": + self._update_bbox_to_anchor(self.get_loc_in_canvas()) + + def _update_loc(self, loc_in_canvas): + bbox = self.legend.get_bbox_to_anchor() + # if bbox has zero width or height, the transformation is + # ill-defined. Fall back to the default bbox_to_anchor. + if bbox.width == 0 or bbox.height == 0: + self.legend.set_bbox_to_anchor(None) + bbox = self.legend.get_bbox_to_anchor() + _bbox_transform = BboxTransformFrom(bbox) + self.legend._loc = tuple(_bbox_transform.transform(loc_in_canvas)) + + def _update_bbox_to_anchor(self, loc_in_canvas): + loc_in_bbox = self.legend.axes.transAxes.transform(loc_in_canvas) + self.legend.set_bbox_to_anchor(loc_in_bbox) + + +_legend_kw_doc_base = """ +bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats + Box that is used to position the legend in conjunction with *loc*. + Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or + `figure.bbox` (if `.Figure.legend`). This argument allows arbitrary + placement of the legend. + + Bbox coordinates are interpreted in the coordinate system given by + *bbox_transform*, with the default transform + Axes or Figure coordinates, depending on which ``legend`` is called. + + If a 4-tuple or `.BboxBase` is given, then it specifies the bbox + ``(x, y, width, height)`` that the legend is placed in. + To put the legend in the best location in the bottom right + quadrant of the Axes (or figure):: + + loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5) + + A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at + x, y. For example, to put the legend's upper right-hand corner in the + center of the Axes (or figure) the following keywords can be used:: + + loc='upper right', bbox_to_anchor=(0.5, 0.5) + +ncols : int, default: 1 + The number of columns that the legend has. + + For backward compatibility, the spelling *ncol* is also supported + but it is discouraged. If both are given, *ncols* takes precedence. + +prop : None or `~matplotlib.font_manager.FontProperties` or dict + The font properties of the legend. If None (default), the current + :data:`matplotlib.rcParams` will be used. + +fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', \ +'x-large', 'xx-large'} + The font size of the legend. If the value is numeric the size will be the + absolute font size in points. String values are relative to the current + default font size. This argument is only used if *prop* is not specified. + +labelcolor : str or list, default: :rc:`legend.labelcolor` + The color of the text in the legend. Either a valid color string + (for example, 'red'), or a list of color strings. The labelcolor can + also be made to match the color of the line or marker using 'linecolor', + 'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec'). + + Labelcolor can be set globally using :rc:`legend.labelcolor`. If None, + use :rc:`text.color`. + +numpoints : int, default: :rc:`legend.numpoints` + The number of marker points in the legend when creating a legend + entry for a `.Line2D` (line). + +scatterpoints : int, default: :rc:`legend.scatterpoints` + The number of marker points in the legend when creating + a legend entry for a `.PathCollection` (scatter plot). + +scatteryoffsets : iterable of floats, default: ``[0.375, 0.5, 0.3125]`` + The vertical offset (relative to the font size) for the markers + created for a scatter plot legend entry. 0.0 is at the base the + legend text, and 1.0 is at the top. To draw all markers at the + same height, set to ``[0.5]``. + +markerscale : float, default: :rc:`legend.markerscale` + The relative size of legend markers compared to the originally drawn ones. + +markerfirst : bool, default: True + If *True*, legend marker is placed to the left of the legend label. + If *False*, legend marker is placed to the right of the legend label. + +reverse : bool, default: False + If *True*, the legend labels are displayed in reverse order from the input. + If *False*, the legend labels are displayed in the same order as the input. + + .. versionadded:: 3.7 + +frameon : bool, default: :rc:`legend.frameon` + Whether the legend should be drawn on a patch (frame). + +fancybox : bool, default: :rc:`legend.fancybox` + Whether round edges should be enabled around the `.FancyBboxPatch` which + makes up the legend's background. + +shadow : None, bool or dict, default: :rc:`legend.shadow` + Whether to draw a shadow behind the legend. + The shadow can be configured using `.Patch` keywords. + Customization via :rc:`legend.shadow` is currently not supported. + +framealpha : float, default: :rc:`legend.framealpha` + The alpha transparency of the legend's background. + If *shadow* is activated and *framealpha* is ``None``, the default value is + ignored. + +facecolor : "inherit" or color, default: :rc:`legend.facecolor` + The legend's background color. + If ``"inherit"``, use :rc:`axes.facecolor`. + +edgecolor : "inherit" or color, default: :rc:`legend.edgecolor` + The legend's background patch edge color. + If ``"inherit"``, use :rc:`axes.edgecolor`. + +mode : {"expand", None} + If *mode* is set to ``"expand"`` the legend will be horizontally + expanded to fill the Axes area (or *bbox_to_anchor* if defines + the legend's size). + +bbox_transform : None or `~matplotlib.transforms.Transform` + The transform for the bounding box (*bbox_to_anchor*). For a value + of ``None`` (default) the Axes' + :data:`~matplotlib.axes.Axes.transAxes` transform will be used. + +title : str or None + The legend's title. Default is no title (``None``). + +title_fontproperties : None or `~matplotlib.font_manager.FontProperties` or dict + The font properties of the legend's title. If None (default), the + *title_fontsize* argument will be used if present; if *title_fontsize* is + also None, the current :rc:`legend.title_fontsize` will be used. + +title_fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', \ +'x-large', 'xx-large'}, default: :rc:`legend.title_fontsize` + The font size of the legend's title. + Note: This cannot be combined with *title_fontproperties*. If you want + to set the fontsize alongside other font properties, use the *size* + parameter in *title_fontproperties*. + +alignment : {'center', 'left', 'right'}, default: 'center' + The alignment of the legend title and the box of entries. The entries + are aligned as a single block, so that markers always lined up. + +borderpad : float, default: :rc:`legend.borderpad` + The fractional whitespace inside the legend border, in font-size units. + +labelspacing : float, default: :rc:`legend.labelspacing` + The vertical space between the legend entries, in font-size units. + +handlelength : float, default: :rc:`legend.handlelength` + The length of the legend handles, in font-size units. + +handleheight : float, default: :rc:`legend.handleheight` + The height of the legend handles, in font-size units. + +handletextpad : float, default: :rc:`legend.handletextpad` + The pad between the legend handle and text, in font-size units. + +borderaxespad : float, default: :rc:`legend.borderaxespad` + The pad between the Axes and legend border, in font-size units. + +columnspacing : float, default: :rc:`legend.columnspacing` + The spacing between columns, in font-size units. + +handler_map : dict or None + The custom dictionary mapping instances or types to a legend + handler. This *handler_map* updates the default handler map + found at `matplotlib.legend.Legend.get_legend_handler_map`. + +draggable : bool, default: False + Whether the legend can be dragged with the mouse. +""" + +_loc_doc_base = """ +loc : str or pair of floats, default: {default} + The location of the legend. + + The strings ``'upper left'``, ``'upper right'``, ``'lower left'``, + ``'lower right'`` place the legend at the corresponding corner of the + {parent}. + + The strings ``'upper center'``, ``'lower center'``, ``'center left'``, + ``'center right'`` place the legend at the center of the corresponding edge + of the {parent}. + + The string ``'center'`` places the legend at the center of the {parent}. +{best} + The location can also be a 2-tuple giving the coordinates of the lower-left + corner of the legend in {parent} coordinates (in which case *bbox_to_anchor* + will be ignored). + + For back-compatibility, ``'center right'`` (but no other location) can also + be spelled ``'right'``, and each "string" location can also be given as a + numeric value: + + ================== ============= + Location String Location Code + ================== ============= + 'best' (Axes only) 0 + 'upper right' 1 + 'upper left' 2 + 'lower left' 3 + 'lower right' 4 + 'right' 5 + 'center left' 6 + 'center right' 7 + 'lower center' 8 + 'upper center' 9 + 'center' 10 + ================== ============= + {outside}""" + +_loc_doc_best = """ + The string ``'best'`` places the legend at the location, among the nine + locations defined so far, with the minimum overlap with other drawn + artists. This option can be quite slow for plots with large amounts of + data; your plotting speed may benefit from providing a specific location. +""" + +_legend_kw_axes_st = ( + _loc_doc_base.format(parent='axes', default=':rc:`legend.loc`', + best=_loc_doc_best, outside='') + + _legend_kw_doc_base) +_docstring.interpd.update(_legend_kw_axes=_legend_kw_axes_st) + +_outside_doc = """ + If a figure is using the constrained layout manager, the string codes + of the *loc* keyword argument can get better layout behaviour using the + prefix 'outside'. There is ambiguity at the corners, so 'outside + upper right' will make space for the legend above the rest of the + axes in the layout, and 'outside right upper' will make space on the + right side of the layout. In addition to the values of *loc* + listed above, we have 'outside right upper', 'outside right lower', + 'outside left upper', and 'outside left lower'. See + :ref:`legend_guide` for more details. +""" + +_legend_kw_figure_st = ( + _loc_doc_base.format(parent='figure', default="'upper right'", + best='', outside=_outside_doc) + + _legend_kw_doc_base) +_docstring.interpd.update(_legend_kw_figure=_legend_kw_figure_st) + +_legend_kw_both_st = ( + _loc_doc_base.format(parent='axes/figure', + default=":rc:`legend.loc` for Axes, 'upper right' for Figure", + best=_loc_doc_best, outside=_outside_doc) + + _legend_kw_doc_base) +_docstring.interpd.update(_legend_kw_doc=_legend_kw_both_st) + +_legend_kw_set_loc_st = ( + _loc_doc_base.format(parent='axes/figure', + default=":rc:`legend.loc` for Axes, 'upper right' for Figure", + best=_loc_doc_best, outside=_outside_doc)) +_docstring.interpd.update(_legend_kw_set_loc_doc=_legend_kw_set_loc_st) + + +class Legend(Artist): + """ + Place a legend on the figure/axes. + """ + + # 'best' is only implemented for Axes legends + codes = {'best': 0, **AnchoredOffsetbox.codes} + zorder = 5 + + def __str__(self): + return "Legend" + + @_docstring.dedent_interpd + def __init__( + self, parent, handles, labels, + *, + loc=None, + numpoints=None, # number of points in the legend line + markerscale=None, # relative size of legend markers vs. original + markerfirst=True, # left/right ordering of legend marker and label + reverse=False, # reverse ordering of legend marker and label + scatterpoints=None, # number of scatter points + scatteryoffsets=None, + prop=None, # properties for the legend texts + fontsize=None, # keyword to set font size directly + labelcolor=None, # keyword to set the text color + + # spacing & pad defined as a fraction of the font-size + borderpad=None, # whitespace inside the legend border + labelspacing=None, # vertical space between the legend entries + handlelength=None, # length of the legend handles + handleheight=None, # height of the legend handles + handletextpad=None, # pad between the legend handle and text + borderaxespad=None, # pad between the Axes and legend border + columnspacing=None, # spacing between columns + + ncols=1, # number of columns + mode=None, # horizontal distribution of columns: None or "expand" + + fancybox=None, # True: fancy box, False: rounded box, None: rcParam + shadow=None, + title=None, # legend title + title_fontsize=None, # legend title font size + framealpha=None, # set frame alpha + edgecolor=None, # frame patch edgecolor + facecolor=None, # frame patch facecolor + + bbox_to_anchor=None, # bbox to which the legend will be anchored + bbox_transform=None, # transform for the bbox + frameon=None, # draw frame + handler_map=None, + title_fontproperties=None, # properties for the legend title + alignment="center", # control the alignment within the legend box + ncol=1, # synonym for ncols (backward compatibility) + draggable=False # whether the legend can be dragged with the mouse + ): + """ + Parameters + ---------- + parent : `~matplotlib.axes.Axes` or `.Figure` + The artist that contains the legend. + + handles : list of (`.Artist` or tuple of `.Artist`) + A list of Artists (lines, patches) to be added to the legend. + + labels : list of str + A list of labels to show next to the artists. The length of handles + and labels should be the same. If they are not, they are truncated + to the length of the shorter list. + + Other Parameters + ---------------- + %(_legend_kw_doc)s + + Attributes + ---------- + legend_handles + List of `.Artist` objects added as legend entries. + + .. versionadded:: 3.7 + """ + # local import only to avoid circularity + from matplotlib.axes import Axes + from matplotlib.figure import FigureBase + + super().__init__() + + if prop is None: + self.prop = FontProperties(size=mpl._val_or_rc(fontsize, "legend.fontsize")) + else: + self.prop = FontProperties._from_any(prop) + if isinstance(prop, dict) and "size" not in prop: + self.prop.set_size(mpl.rcParams["legend.fontsize"]) + + self._fontsize = self.prop.get_size_in_points() + + self.texts = [] + self.legend_handles = [] + self._legend_title_box = None + + #: A dictionary with the extra handler mappings for this Legend + #: instance. + self._custom_handler_map = handler_map + + self.numpoints = mpl._val_or_rc(numpoints, 'legend.numpoints') + self.markerscale = mpl._val_or_rc(markerscale, 'legend.markerscale') + self.scatterpoints = mpl._val_or_rc(scatterpoints, 'legend.scatterpoints') + self.borderpad = mpl._val_or_rc(borderpad, 'legend.borderpad') + self.labelspacing = mpl._val_or_rc(labelspacing, 'legend.labelspacing') + self.handlelength = mpl._val_or_rc(handlelength, 'legend.handlelength') + self.handleheight = mpl._val_or_rc(handleheight, 'legend.handleheight') + self.handletextpad = mpl._val_or_rc(handletextpad, 'legend.handletextpad') + self.borderaxespad = mpl._val_or_rc(borderaxespad, 'legend.borderaxespad') + self.columnspacing = mpl._val_or_rc(columnspacing, 'legend.columnspacing') + self.shadow = mpl._val_or_rc(shadow, 'legend.shadow') + # trim handles and labels if illegal label... + _lab, _hand = [], [] + for label, handle in zip(labels, handles): + if isinstance(label, str) and label.startswith('_'): + _api.warn_deprecated("3.8", message=( + "An artist whose label starts with an underscore was passed to " + "legend(); such artists will no longer be ignored in the future. " + "To suppress this warning, explicitly filter out such artists, " + "e.g. with `[art for art in artists if not " + "art.get_label().startswith('_')]`.")) + else: + _lab.append(label) + _hand.append(handle) + labels, handles = _lab, _hand + + if reverse: + labels.reverse() + handles.reverse() + + if len(handles) < 2: + ncols = 1 + self._ncols = ncols if ncols != 1 else ncol + + if self.numpoints <= 0: + raise ValueError("numpoints must be > 0; it was %d" % numpoints) + + # introduce y-offset for handles of the scatter plot + if scatteryoffsets is None: + self._scatteryoffsets = np.array([3. / 8., 4. / 8., 2.5 / 8.]) + else: + self._scatteryoffsets = np.asarray(scatteryoffsets) + reps = self.scatterpoints // len(self._scatteryoffsets) + 1 + self._scatteryoffsets = np.tile(self._scatteryoffsets, + reps)[:self.scatterpoints] + + # _legend_box is a VPacker instance that contains all + # legend items and will be initialized from _init_legend_box() + # method. + self._legend_box = None + + if isinstance(parent, Axes): + self.isaxes = True + self.axes = parent + self.set_figure(parent.figure) + elif isinstance(parent, FigureBase): + self.isaxes = False + self.set_figure(parent) + else: + raise TypeError( + "Legend needs either Axes or FigureBase as parent" + ) + self.parent = parent + + self._mode = mode + self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform) + + # Figure out if self.shadow is valid + # If shadow was None, rcParams loads False + # So it shouldn't be None here + + self._shadow_props = {'ox': 2, 'oy': -2} # default location offsets + if isinstance(self.shadow, dict): + self._shadow_props.update(self.shadow) + self.shadow = True + elif self.shadow in (0, 1, True, False): + self.shadow = bool(self.shadow) + else: + raise ValueError( + 'Legend shadow must be a dict or bool, not ' + f'{self.shadow!r} of type {type(self.shadow)}.' + ) + + # We use FancyBboxPatch to draw a legend frame. The location + # and size of the box will be updated during the drawing time. + + facecolor = mpl._val_or_rc(facecolor, "legend.facecolor") + if facecolor == 'inherit': + facecolor = mpl.rcParams["axes.facecolor"] + + edgecolor = mpl._val_or_rc(edgecolor, "legend.edgecolor") + if edgecolor == 'inherit': + edgecolor = mpl.rcParams["axes.edgecolor"] + + fancybox = mpl._val_or_rc(fancybox, "legend.fancybox") + + self.legendPatch = FancyBboxPatch( + xy=(0, 0), width=1, height=1, + facecolor=facecolor, edgecolor=edgecolor, + # If shadow is used, default to alpha=1 (#8943). + alpha=(framealpha if framealpha is not None + else 1 if shadow + else mpl.rcParams["legend.framealpha"]), + # The width and height of the legendPatch will be set (in draw()) + # to the length that includes the padding. Thus we set pad=0 here. + boxstyle=("round,pad=0,rounding_size=0.2" if fancybox + else "square,pad=0"), + mutation_scale=self._fontsize, + snap=True, + visible=mpl._val_or_rc(frameon, "legend.frameon") + ) + self._set_artist_props(self.legendPatch) + + _api.check_in_list(["center", "left", "right"], alignment=alignment) + self._alignment = alignment + + # init with null renderer + self._init_legend_box(handles, labels, markerfirst) + + # Set legend location + self.set_loc(loc) + + # figure out title font properties: + if title_fontsize is not None and title_fontproperties is not None: + raise ValueError( + "title_fontsize and title_fontproperties can't be specified " + "at the same time. Only use one of them. ") + title_prop_fp = FontProperties._from_any(title_fontproperties) + if isinstance(title_fontproperties, dict): + if "size" not in title_fontproperties: + title_fontsize = mpl.rcParams["legend.title_fontsize"] + title_prop_fp.set_size(title_fontsize) + elif title_fontsize is not None: + title_prop_fp.set_size(title_fontsize) + elif not isinstance(title_fontproperties, FontProperties): + title_fontsize = mpl.rcParams["legend.title_fontsize"] + title_prop_fp.set_size(title_fontsize) + + self.set_title(title, prop=title_prop_fp) + + self._draggable = None + self.set_draggable(state=draggable) + + # set the text color + + color_getters = { # getter function depends on line or patch + 'linecolor': ['get_color', 'get_facecolor'], + 'markerfacecolor': ['get_markerfacecolor', 'get_facecolor'], + 'mfc': ['get_markerfacecolor', 'get_facecolor'], + 'markeredgecolor': ['get_markeredgecolor', 'get_edgecolor'], + 'mec': ['get_markeredgecolor', 'get_edgecolor'], + } + labelcolor = mpl._val_or_rc(labelcolor, 'legend.labelcolor') + if labelcolor is None: + labelcolor = mpl.rcParams['text.color'] + if isinstance(labelcolor, str) and labelcolor in color_getters: + getter_names = color_getters[labelcolor] + for handle, text in zip(self.legend_handles, self.texts): + try: + if handle.get_array() is not None: + continue + except AttributeError: + pass + for getter_name in getter_names: + try: + color = getattr(handle, getter_name)() + if isinstance(color, np.ndarray): + if ( + color.shape[0] == 1 + or np.isclose(color, color[0]).all() + ): + text.set_color(color[0]) + else: + pass + else: + text.set_color(color) + break + except AttributeError: + pass + elif cbook._str_equal(labelcolor, 'none'): + for text in self.texts: + text.set_color(labelcolor) + elif np.iterable(labelcolor): + for text, color in zip(self.texts, + itertools.cycle( + colors.to_rgba_array(labelcolor))): + text.set_color(color) + else: + raise ValueError(f"Invalid labelcolor: {labelcolor!r}") + + def _set_artist_props(self, a): + """ + Set the boilerplate props for artists added to Axes. + """ + a.set_figure(self.figure) + if self.isaxes: + a.axes = self.axes + + a.set_transform(self.get_transform()) + + @_docstring.dedent_interpd + def set_loc(self, loc=None): + """ + Set the location of the legend. + + .. versionadded:: 3.8 + + Parameters + ---------- + %(_legend_kw_set_loc_doc)s + """ + loc0 = loc + self._loc_used_default = loc is None + if loc is None: + loc = mpl.rcParams["legend.loc"] + if not self.isaxes and loc in [0, 'best']: + loc = 'upper right' + + type_err_message = ("loc must be string, coordinate tuple, or" + f" an integer 0-10, not {loc!r}") + + # handle outside legends: + self._outside_loc = None + if isinstance(loc, str): + if loc.split()[0] == 'outside': + # strip outside: + loc = loc.split('outside ')[1] + # strip "center" at the beginning + self._outside_loc = loc.replace('center ', '') + # strip first + self._outside_loc = self._outside_loc.split()[0] + locs = loc.split() + if len(locs) > 1 and locs[0] in ('right', 'left'): + # locs doesn't accept "left upper", etc, so swap + if locs[0] != 'center': + locs = locs[::-1] + loc = locs[0] + ' ' + locs[1] + # check that loc is in acceptable strings + loc = _api.check_getitem(self.codes, loc=loc) + elif np.iterable(loc): + # coerce iterable into tuple + loc = tuple(loc) + # validate the tuple represents Real coordinates + if len(loc) != 2 or not all(isinstance(e, numbers.Real) for e in loc): + raise ValueError(type_err_message) + elif isinstance(loc, int): + # validate the integer represents a string numeric value + if loc < 0 or loc > 10: + raise ValueError(type_err_message) + else: + # all other cases are invalid values of loc + raise ValueError(type_err_message) + + if self.isaxes and self._outside_loc: + raise ValueError( + f"'outside' option for loc='{loc0}' keyword argument only " + "works for figure legends") + + if not self.isaxes and loc == 0: + raise ValueError( + "Automatic legend placement (loc='best') not implemented for " + "figure legend") + + tmp = self._loc_used_default + self._set_loc(loc) + self._loc_used_default = tmp # ignore changes done by _set_loc + + def _set_loc(self, loc): + # find_offset function will be provided to _legend_box and + # _legend_box will draw itself at the location of the return + # value of the find_offset. + self._loc_used_default = False + self._loc_real = loc + self.stale = True + self._legend_box.set_offset(self._findoffset) + + def set_ncols(self, ncols): + """Set the number of columns.""" + self._ncols = ncols + + def _get_loc(self): + return self._loc_real + + _loc = property(_get_loc, _set_loc) + + def _findoffset(self, width, height, xdescent, ydescent, renderer): + """Helper function to locate the legend.""" + + if self._loc == 0: # "best". + x, y = self._find_best_position(width, height, renderer) + elif self._loc in Legend.codes.values(): # Fixed location. + bbox = Bbox.from_bounds(0, 0, width, height) + x, y = self._get_anchored_bbox(self._loc, bbox, + self.get_bbox_to_anchor(), + renderer) + else: # Axes or figure coordinates. + fx, fy = self._loc + bbox = self.get_bbox_to_anchor() + x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy + + return x + xdescent, y + ydescent + + @allow_rasterization + def draw(self, renderer): + # docstring inherited + if not self.get_visible(): + return + + renderer.open_group('legend', gid=self.get_gid()) + + fontsize = renderer.points_to_pixels(self._fontsize) + + # if mode == fill, set the width of the legend_box to the + # width of the parent (minus pads) + if self._mode in ["expand"]: + pad = 2 * (self.borderaxespad + self.borderpad) * fontsize + self._legend_box.set_width(self.get_bbox_to_anchor().width - pad) + + # update the location and size of the legend. This needs to + # be done in any case to clip the figure right. + bbox = self._legend_box.get_window_extent(renderer) + self.legendPatch.set_bounds(bbox.bounds) + self.legendPatch.set_mutation_scale(fontsize) + + # self.shadow is validated in __init__ + # So by here it is a bool and self._shadow_props contains any configs + + if self.shadow: + Shadow(self.legendPatch, **self._shadow_props).draw(renderer) + + self.legendPatch.draw(renderer) + self._legend_box.draw(renderer) + + renderer.close_group('legend') + self.stale = False + + # _default_handler_map defines the default mapping between plot + # elements and the legend handlers. + + _default_handler_map = { + StemContainer: legend_handler.HandlerStem(), + ErrorbarContainer: legend_handler.HandlerErrorbar(), + Line2D: legend_handler.HandlerLine2D(), + Patch: legend_handler.HandlerPatch(), + StepPatch: legend_handler.HandlerStepPatch(), + LineCollection: legend_handler.HandlerLineCollection(), + RegularPolyCollection: legend_handler.HandlerRegularPolyCollection(), + CircleCollection: legend_handler.HandlerCircleCollection(), + BarContainer: legend_handler.HandlerPatch( + update_func=legend_handler.update_from_first_child), + tuple: legend_handler.HandlerTuple(), + PathCollection: legend_handler.HandlerPathCollection(), + PolyCollection: legend_handler.HandlerPolyCollection() + } + + # (get|set|update)_default_handler_maps are public interfaces to + # modify the default handler map. + + @classmethod + def get_default_handler_map(cls): + """Return the global default handler map, shared by all legends.""" + return cls._default_handler_map + + @classmethod + def set_default_handler_map(cls, handler_map): + """Set the global default handler map, shared by all legends.""" + cls._default_handler_map = handler_map + + @classmethod + def update_default_handler_map(cls, handler_map): + """Update the global default handler map, shared by all legends.""" + cls._default_handler_map.update(handler_map) + + def get_legend_handler_map(self): + """Return this legend instance's handler map.""" + default_handler_map = self.get_default_handler_map() + return ({**default_handler_map, **self._custom_handler_map} + if self._custom_handler_map else default_handler_map) + + @staticmethod + def get_legend_handler(legend_handler_map, orig_handle): + """ + Return a legend handler from *legend_handler_map* that + corresponds to *orig_handler*. + + *legend_handler_map* should be a dictionary object (that is + returned by the get_legend_handler_map method). + + It first checks if the *orig_handle* itself is a key in the + *legend_handler_map* and return the associated value. + Otherwise, it checks for each of the classes in its + method-resolution-order. If no matching key is found, it + returns ``None``. + """ + try: + return legend_handler_map[orig_handle] + except (TypeError, KeyError): # TypeError if unhashable. + pass + for handle_type in type(orig_handle).mro(): + try: + return legend_handler_map[handle_type] + except KeyError: + pass + return None + + def _init_legend_box(self, handles, labels, markerfirst=True): + """ + Initialize the legend_box. The legend_box is an instance of + the OffsetBox, which is packed with legend handles and + texts. Once packed, their location is calculated during the + drawing time. + """ + + fontsize = self._fontsize + + # legend_box is a HPacker, horizontally packed with columns. + # Each column is a VPacker, vertically packed with legend items. + # Each legend item is a HPacker packed with: + # - handlebox: a DrawingArea which contains the legend handle. + # - labelbox: a TextArea which contains the legend text. + + text_list = [] # the list of text instances + handle_list = [] # the list of handle instances + handles_and_labels = [] + + # The approximate height and descent of text. These values are + # only used for plotting the legend handle. + descent = 0.35 * fontsize * (self.handleheight - 0.7) # heuristic. + height = fontsize * self.handleheight - descent + # each handle needs to be drawn inside a box of (x, y, w, h) = + # (0, -descent, width, height). And their coordinates should + # be given in the display coordinates. + + # The transformation of each handle will be automatically set + # to self.get_transform(). If the artist does not use its + # default transform (e.g., Collections), you need to + # manually set their transform to the self.get_transform(). + legend_handler_map = self.get_legend_handler_map() + + for orig_handle, label in zip(handles, labels): + handler = self.get_legend_handler(legend_handler_map, orig_handle) + if handler is None: + _api.warn_external( + "Legend does not support handles for " + f"{type(orig_handle).__name__} " + "instances.\nA proxy artist may be used " + "instead.\nSee: https://matplotlib.org/" + "stable/users/explain/axes/legend_guide.html" + "#controlling-the-legend-entries") + # No handle for this artist, so we just defer to None. + handle_list.append(None) + else: + textbox = TextArea(label, multilinebaseline=True, + textprops=dict( + verticalalignment='baseline', + horizontalalignment='left', + fontproperties=self.prop)) + handlebox = DrawingArea(width=self.handlelength * fontsize, + height=height, + xdescent=0., ydescent=descent) + + text_list.append(textbox._text) + # Create the artist for the legend which represents the + # original artist/handle. + handle_list.append(handler.legend_artist(self, orig_handle, + fontsize, handlebox)) + handles_and_labels.append((handlebox, textbox)) + + columnbox = [] + # array_split splits n handles_and_labels into ncols columns, with the + # first n%ncols columns having an extra entry. filter(len, ...) + # handles the case where n < ncols: the last ncols-n columns are empty + # and get filtered out. + for handles_and_labels_column in filter( + len, np.array_split(handles_and_labels, self._ncols)): + # pack handlebox and labelbox into itembox + itemboxes = [HPacker(pad=0, + sep=self.handletextpad * fontsize, + children=[h, t] if markerfirst else [t, h], + align="baseline") + for h, t in handles_and_labels_column] + # pack columnbox + alignment = "baseline" if markerfirst else "right" + columnbox.append(VPacker(pad=0, + sep=self.labelspacing * fontsize, + align=alignment, + children=itemboxes)) + + mode = "expand" if self._mode == "expand" else "fixed" + sep = self.columnspacing * fontsize + self._legend_handle_box = HPacker(pad=0, + sep=sep, align="baseline", + mode=mode, + children=columnbox) + self._legend_title_box = TextArea("") + self._legend_box = VPacker(pad=self.borderpad * fontsize, + sep=self.labelspacing * fontsize, + align=self._alignment, + children=[self._legend_title_box, + self._legend_handle_box]) + self._legend_box.set_figure(self.figure) + self._legend_box.axes = self.axes + self.texts = text_list + self.legend_handles = handle_list + + def _auto_legend_data(self): + """ + Return display coordinates for hit testing for "best" positioning. + + Returns + ------- + bboxes + List of bounding boxes of all patches. + lines + List of `.Path` corresponding to each line. + offsets + List of (x, y) offsets of all collection. + """ + assert self.isaxes # always holds, as this is only called internally + bboxes = [] + lines = [] + offsets = [] + for artist in self.parent._children: + if isinstance(artist, Line2D): + lines.append( + artist.get_transform().transform_path(artist.get_path())) + elif isinstance(artist, Rectangle): + bboxes.append( + artist.get_bbox().transformed(artist.get_data_transform())) + elif isinstance(artist, Patch): + lines.append( + artist.get_transform().transform_path(artist.get_path())) + elif isinstance(artist, PolyCollection): + lines.extend(artist.get_transform().transform_path(path) + for path in artist.get_paths()) + elif isinstance(artist, Collection): + transform, transOffset, hoffsets, _ = artist._prepare_points() + if len(hoffsets): + offsets.extend(transOffset.transform(hoffsets)) + elif isinstance(artist, Text): + bboxes.append(artist.get_window_extent()) + + return bboxes, lines, offsets + + def get_children(self): + # docstring inherited + return [self._legend_box, self.get_frame()] + + def get_frame(self): + """Return the `~.patches.Rectangle` used to frame the legend.""" + return self.legendPatch + + def get_lines(self): + r"""Return the list of `~.lines.Line2D`\s in the legend.""" + return [h for h in self.legend_handles if isinstance(h, Line2D)] + + def get_patches(self): + r"""Return the list of `~.patches.Patch`\s in the legend.""" + return silent_list('Patch', + [h for h in self.legend_handles + if isinstance(h, Patch)]) + + def get_texts(self): + r"""Return the list of `~.text.Text`\s in the legend.""" + return silent_list('Text', self.texts) + + def set_alignment(self, alignment): + """ + Set the alignment of the legend title and the box of entries. + + The entries are aligned as a single block, so that markers always + lined up. + + Parameters + ---------- + alignment : {'center', 'left', 'right'}. + + """ + _api.check_in_list(["center", "left", "right"], alignment=alignment) + self._alignment = alignment + self._legend_box.align = alignment + + def get_alignment(self): + """Get the alignment value of the legend box""" + return self._legend_box.align + + def set_title(self, title, prop=None): + """ + Set legend title and title style. + + Parameters + ---------- + title : str + The legend title. + + prop : `.font_manager.FontProperties` or `str` or `pathlib.Path` + The font properties of the legend title. + If a `str`, it is interpreted as a fontconfig pattern parsed by + `.FontProperties`. If a `pathlib.Path`, it is interpreted as the + absolute path to a font file. + + """ + self._legend_title_box._text.set_text(title) + if title: + self._legend_title_box._text.set_visible(True) + self._legend_title_box.set_visible(True) + else: + self._legend_title_box._text.set_visible(False) + self._legend_title_box.set_visible(False) + + if prop is not None: + self._legend_title_box._text.set_fontproperties(prop) + + self.stale = True + + def get_title(self): + """Return the `.Text` instance for the legend title.""" + return self._legend_title_box._text + + def get_window_extent(self, renderer=None): + # docstring inherited + if renderer is None: + renderer = self.figure._get_renderer() + return self._legend_box.get_window_extent(renderer=renderer) + + def get_tightbbox(self, renderer=None): + # docstring inherited + return self._legend_box.get_window_extent(renderer) + + def get_frame_on(self): + """Get whether the legend box patch is drawn.""" + return self.legendPatch.get_visible() + + def set_frame_on(self, b): + """ + Set whether the legend box patch is drawn. + + Parameters + ---------- + b : bool + """ + self.legendPatch.set_visible(b) + self.stale = True + + draw_frame = set_frame_on # Backcompat alias. + + def get_bbox_to_anchor(self): + """Return the bbox that the legend will be anchored to.""" + if self._bbox_to_anchor is None: + return self.parent.bbox + else: + return self._bbox_to_anchor + + def set_bbox_to_anchor(self, bbox, transform=None): + """ + Set the bbox that the legend will be anchored to. + + Parameters + ---------- + bbox : `~matplotlib.transforms.BboxBase` or tuple + The bounding box can be specified in the following ways: + + - A `.BboxBase` instance + - A tuple of ``(left, bottom, width, height)`` in the given + transform (normalized axes coordinate if None) + - A tuple of ``(left, bottom)`` where the width and height will be + assumed to be zero. + - *None*, to remove the bbox anchoring, and use the parent bbox. + + transform : `~matplotlib.transforms.Transform`, optional + A transform to apply to the bounding box. If not specified, this + will use a transform to the bounding box of the parent. + """ + if bbox is None: + self._bbox_to_anchor = None + return + elif isinstance(bbox, BboxBase): + self._bbox_to_anchor = bbox + else: + try: + l = len(bbox) + except TypeError as err: + raise ValueError(f"Invalid bbox: {bbox}") from err + + if l == 2: + bbox = [bbox[0], bbox[1], 0, 0] + + self._bbox_to_anchor = Bbox.from_bounds(*bbox) + + if transform is None: + transform = BboxTransformTo(self.parent.bbox) + + self._bbox_to_anchor = TransformedBbox(self._bbox_to_anchor, + transform) + self.stale = True + + def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer): + """ + Place the *bbox* inside the *parentbbox* according to a given + location code. Return the (x, y) coordinate of the bbox. + + Parameters + ---------- + loc : int + A location code in range(1, 11). This corresponds to the possible + values for ``self._loc``, excluding "best". + bbox : `~matplotlib.transforms.Bbox` + bbox to be placed, in display coordinates. + parentbbox : `~matplotlib.transforms.Bbox` + A parent box which will contain the bbox, in display coordinates. + """ + return offsetbox._get_anchored_bbox( + loc, bbox, parentbbox, + self.borderaxespad * renderer.points_to_pixels(self._fontsize)) + + def _find_best_position(self, width, height, renderer): + """Determine the best location to place the legend.""" + assert self.isaxes # always holds, as this is only called internally + + start_time = time.perf_counter() + + bboxes, lines, offsets = self._auto_legend_data() + + bbox = Bbox.from_bounds(0, 0, width, height) + + candidates = [] + for idx in range(1, len(self.codes)): + l, b = self._get_anchored_bbox(idx, bbox, + self.get_bbox_to_anchor(), + renderer) + legendBox = Bbox.from_bounds(l, b, width, height) + # XXX TODO: If markers are present, it would be good to take them + # into account when checking vertex overlaps in the next line. + badness = (sum(legendBox.count_contains(line.vertices) + for line in lines) + + legendBox.count_contains(offsets) + + legendBox.count_overlaps(bboxes) + + sum(line.intersects_bbox(legendBox, filled=False) + for line in lines)) + # Include the index to favor lower codes in case of a tie. + candidates.append((badness, idx, (l, b))) + if badness == 0: + break + + _, _, (l, b) = min(candidates) + + if self._loc_used_default and time.perf_counter() - start_time > 1: + _api.warn_external( + 'Creating legend with loc="best" can be slow with large ' + 'amounts of data.') + + return l, b + + @_api.rename_parameter("3.8", "event", "mouseevent") + def contains(self, mouseevent): + return self.legendPatch.contains(mouseevent) + + def set_draggable(self, state, use_blit=False, update='loc'): + """ + Enable or disable mouse dragging support of the legend. + + Parameters + ---------- + state : bool + Whether mouse dragging is enabled. + use_blit : bool, optional + Use blitting for faster image composition. For details see + :ref:`func-animation`. + update : {'loc', 'bbox'}, optional + The legend parameter to be changed when dragged: + + - 'loc': update the *loc* parameter of the legend + - 'bbox': update the *bbox_to_anchor* parameter of the legend + + Returns + ------- + `.DraggableLegend` or *None* + If *state* is ``True`` this returns the `.DraggableLegend` helper + instance. Otherwise this returns *None*. + """ + if state: + if self._draggable is None: + self._draggable = DraggableLegend(self, + use_blit, + update=update) + else: + if self._draggable is not None: + self._draggable.disconnect() + self._draggable = None + return self._draggable + + def get_draggable(self): + """Return ``True`` if the legend is draggable, ``False`` otherwise.""" + return self._draggable is not None + + +# Helper functions to parse legend arguments for both `figure.legend` and +# `axes.legend`: +def _get_legend_handles(axs, legend_handler_map=None): + """Yield artists that can be used as handles in a legend.""" + handles_original = [] + for ax in axs: + handles_original += [ + *(a for a in ax._children + if isinstance(a, (Line2D, Patch, Collection, Text))), + *ax.containers] + # support parasite Axes: + if hasattr(ax, 'parasites'): + for axx in ax.parasites: + handles_original += [ + *(a for a in axx._children + if isinstance(a, (Line2D, Patch, Collection, Text))), + *axx.containers] + + handler_map = {**Legend.get_default_handler_map(), + **(legend_handler_map or {})} + has_handler = Legend.get_legend_handler + for handle in handles_original: + label = handle.get_label() + if label != '_nolegend_' and has_handler(handler_map, handle): + yield handle + elif (label and not label.startswith('_') and + not has_handler(handler_map, handle)): + _api.warn_external( + "Legend does not support handles for " + f"{type(handle).__name__} " + "instances.\nSee: https://matplotlib.org/stable/" + "tutorials/intermediate/legend_guide.html" + "#implementing-a-custom-legend-handler") + continue + + +def _get_legend_handles_labels(axs, legend_handler_map=None): + """Return handles and labels for legend.""" + handles = [] + labels = [] + for handle in _get_legend_handles(axs, legend_handler_map): + label = handle.get_label() + if label and not label.startswith('_'): + handles.append(handle) + labels.append(label) + return handles, labels + + +def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs): + """ + Get the handles and labels from the calls to either ``figure.legend`` + or ``axes.legend``. + + The parser is a bit involved because we support:: + + legend() + legend(labels) + legend(handles, labels) + legend(labels=labels) + legend(handles=handles) + legend(handles=handles, labels=labels) + + The behavior for a mixture of positional and keyword handles and labels + is undefined and issues a warning; it will be an error in the future. + + Parameters + ---------- + axs : list of `.Axes` + If handles are not given explicitly, the artists in these Axes are + used as handles. + *args : tuple + Positional parameters passed to ``legend()``. + handles + The value of the keyword argument ``legend(handles=...)``, or *None* + if that keyword argument was not used. + labels + The value of the keyword argument ``legend(labels=...)``, or *None* + if that keyword argument was not used. + **kwargs + All other keyword arguments passed to ``legend()``. + + Returns + ------- + handles : list of (`.Artist` or tuple of `.Artist`) + The legend handles. + labels : list of str + The legend labels. + kwargs : dict + *kwargs* with keywords handles and labels removed. + + """ + log = logging.getLogger(__name__) + + handlers = kwargs.get('handler_map') + + if (handles is not None or labels is not None) and args: + _api.warn_deprecated("3.9", message=( + "You have mixed positional and keyword arguments, some input may " + "be discarded. This is deprecated since %(since)s and will " + "become an error %(removal)s.")) + + if (hasattr(handles, "__len__") and + hasattr(labels, "__len__") and + len(handles) != len(labels)): + _api.warn_external(f"Mismatched number of handles and labels: " + f"len(handles) = {len(handles)} " + f"len(labels) = {len(labels)}") + # if got both handles and labels as kwargs, make same length + if handles and labels: + handles, labels = zip(*zip(handles, labels)) + + elif handles is not None and labels is None: + labels = [handle.get_label() for handle in handles] + + elif labels is not None and handles is None: + # Get as many handles as there are labels. + handles = [handle for handle, label + in zip(_get_legend_handles(axs, handlers), labels)] + + elif len(args) == 0: # 0 args: automatically detect labels and handles. + handles, labels = _get_legend_handles_labels(axs, handlers) + if not handles: + _api.warn_external( + "No artists with labels found to put in legend. Note that " + "artists whose label start with an underscore are ignored " + "when legend() is called with no argument.") + + elif len(args) == 1: # 1 arg: user defined labels, automatic handle detection. + labels, = args + if any(isinstance(l, Artist) for l in labels): + raise TypeError("A single argument passed to legend() must be a " + "list of labels, but found an Artist in there.") + + # Get as many handles as there are labels. + handles = [handle for handle, label + in zip(_get_legend_handles(axs, handlers), labels)] + + elif len(args) == 2: # 2 args: user defined handles and labels. + handles, labels = args[:2] + + else: + raise _api.nargs_error('legend', '0-2', len(args)) + + return handles, labels, kwargs diff --git a/venv/lib/python3.10/site-packages/matplotlib/legend.pyi b/venv/lib/python3.10/site-packages/matplotlib/legend.pyi new file mode 100644 index 00000000..dde5882d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/legend.pyi @@ -0,0 +1,152 @@ +from matplotlib.axes import Axes +from matplotlib.artist import Artist +from matplotlib.backend_bases import MouseEvent +from matplotlib.figure import Figure +from matplotlib.font_manager import FontProperties +from matplotlib.legend_handler import HandlerBase +from matplotlib.lines import Line2D +from matplotlib.offsetbox import ( + DraggableOffsetBox, +) +from matplotlib.patches import FancyBboxPatch, Patch, Rectangle +from matplotlib.text import Text +from matplotlib.transforms import ( + BboxBase, + Transform, +) + + +import pathlib +from collections.abc import Iterable +from typing import Any, Literal, overload +from .typing import ColorType + +class DraggableLegend(DraggableOffsetBox): + legend: Legend + def __init__( + self, legend: Legend, use_blit: bool = ..., update: Literal["loc", "bbox"] = ... + ) -> None: ... + def finalize_offset(self) -> None: ... + +class Legend(Artist): + codes: dict[str, int] + zorder: float + prop: FontProperties + texts: list[Text] + legend_handles: list[Artist | None] + numpoints: int + markerscale: float + scatterpoints: int + borderpad: float + labelspacing: float + handlelength: float + handleheight: float + handletextpad: float + borderaxespad: float + columnspacing: float + shadow: bool + isaxes: bool + axes: Axes + parent: Axes | Figure + legendPatch: FancyBboxPatch + def __init__( + self, + parent: Axes | Figure, + handles: Iterable[Artist | tuple[Artist, ...]], + labels: Iterable[str], + *, + loc: str | tuple[float, float] | int | None = ..., + numpoints: int | None = ..., + markerscale: float | None = ..., + markerfirst: bool = ..., + reverse: bool = ..., + scatterpoints: int | None = ..., + scatteryoffsets: Iterable[float] | None = ..., + prop: FontProperties | dict[str, Any] | None = ..., + fontsize: float | str | None = ..., + labelcolor: ColorType + | Iterable[ColorType] + | Literal["linecolor", "markerfacecolor", "mfc", "markeredgecolor", "mec"] + | None = ..., + borderpad: float | None = ..., + labelspacing: float | None = ..., + handlelength: float | None = ..., + handleheight: float | None = ..., + handletextpad: float | None = ..., + borderaxespad: float | None = ..., + columnspacing: float | None = ..., + ncols: int = ..., + mode: Literal["expand"] | None = ..., + fancybox: bool | None = ..., + shadow: bool | dict[str, Any] | None = ..., + title: str | None = ..., + title_fontsize: float | None = ..., + framealpha: float | None = ..., + edgecolor: Literal["inherit"] | ColorType | None = ..., + facecolor: Literal["inherit"] | ColorType | None = ..., + bbox_to_anchor: BboxBase + | tuple[float, float] + | tuple[float, float, float, float] + | None = ..., + bbox_transform: Transform | None = ..., + frameon: bool | None = ..., + handler_map: dict[Artist | type, HandlerBase] | None = ..., + title_fontproperties: FontProperties | dict[str, Any] | None = ..., + alignment: Literal["center", "left", "right"] = ..., + ncol: int = ..., + draggable: bool = ... + ) -> None: ... + def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ... + def set_ncols(self, ncols: int) -> None: ... + @classmethod + def get_default_handler_map(cls) -> dict[type, HandlerBase]: ... + @classmethod + def set_default_handler_map(cls, handler_map: dict[type, HandlerBase]) -> None: ... + @classmethod + def update_default_handler_map( + cls, handler_map: dict[type, HandlerBase] + ) -> None: ... + def get_legend_handler_map(self) -> dict[type, HandlerBase]: ... + @staticmethod + def get_legend_handler( + legend_handler_map: dict[type, HandlerBase], orig_handle: Any + ) -> HandlerBase | None: ... + def get_children(self) -> list[Artist]: ... + def get_frame(self) -> Rectangle: ... + def get_lines(self) -> list[Line2D]: ... + def get_patches(self) -> list[Patch]: ... + def get_texts(self) -> list[Text]: ... + def set_alignment(self, alignment: Literal["center", "left", "right"]) -> None: ... + def get_alignment(self) -> Literal["center", "left", "right"]: ... + def set_loc(self, loc: str | tuple[float, float] | int | None = ...) -> None: ... + def set_title( + self, title: str, prop: FontProperties | str | pathlib.Path | None = ... + ) -> None: ... + def get_title(self) -> Text: ... + def get_frame_on(self) -> bool: ... + def set_frame_on(self, b: bool) -> None: ... + draw_frame = set_frame_on + def get_bbox_to_anchor(self) -> BboxBase: ... + def set_bbox_to_anchor( + self, + bbox: BboxBase + | tuple[float, float] + | tuple[float, float, float, float] + | None, + transform: Transform | None = ... + ) -> None: ... + @overload + def set_draggable( + self, + state: Literal[True], + use_blit: bool = ..., + update: Literal["loc", "bbox"] = ..., + ) -> DraggableLegend: ... + @overload + def set_draggable( + self, + state: Literal[False], + use_blit: bool = ..., + update: Literal["loc", "bbox"] = ..., + ) -> None: ... + def get_draggable(self) -> bool: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/legend_handler.py b/venv/lib/python3.10/site-packages/matplotlib/legend_handler.py new file mode 100644 index 00000000..5a929070 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/legend_handler.py @@ -0,0 +1,813 @@ +""" +Default legend handlers. + +.. important:: + + This is a low-level legend API, which most end users do not need. + + We recommend that you are familiar with the :ref:`legend guide + ` before reading this documentation. + +Legend handlers are expected to be a callable object with a following +signature:: + + legend_handler(legend, orig_handle, fontsize, handlebox) + +Where *legend* is the legend itself, *orig_handle* is the original +plot, *fontsize* is the fontsize in pixels, and *handlebox* is an +`.OffsetBox` instance. Within the call, you should create relevant +artists (using relevant properties from the *legend* and/or +*orig_handle*) and add them into the *handlebox*. The artists need to +be scaled according to the *fontsize* (note that the size is in pixels, +i.e., this is dpi-scaled value). + +This module includes definition of several legend handler classes +derived from the base class (HandlerBase) with the following method:: + + def legend_artist(self, legend, orig_handle, fontsize, handlebox) +""" + +from itertools import cycle + +import numpy as np + +from matplotlib import cbook +from matplotlib.lines import Line2D +from matplotlib.patches import Rectangle +import matplotlib.collections as mcoll + + +def update_from_first_child(tgt, src): + first_child = next(iter(src.get_children()), None) + if first_child is not None: + tgt.update_from(first_child) + + +class HandlerBase: + """ + A base class for default legend handlers. + + The derived classes are meant to override *create_artists* method, which + has the following signature:: + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + + The overridden method needs to create artists of the given + transform that fits in the given dimension (xdescent, ydescent, + width, height) that are scaled by fontsize if necessary. + + """ + def __init__(self, xpad=0., ypad=0., update_func=None): + """ + Parameters + ---------- + xpad : float, optional + Padding in x-direction. + ypad : float, optional + Padding in y-direction. + update_func : callable, optional + Function for updating the legend handler properties from another + legend handler, used by `~HandlerBase.update_prop`. + """ + self._xpad, self._ypad = xpad, ypad + self._update_prop_func = update_func + + def _update_prop(self, legend_handle, orig_handle): + if self._update_prop_func is None: + self._default_update_prop(legend_handle, orig_handle) + else: + self._update_prop_func(legend_handle, orig_handle) + + def _default_update_prop(self, legend_handle, orig_handle): + legend_handle.update_from(orig_handle) + + def update_prop(self, legend_handle, orig_handle, legend): + + self._update_prop(legend_handle, orig_handle) + + legend._set_artist_props(legend_handle) + legend_handle.set_clip_box(None) + legend_handle.set_clip_path(None) + + def adjust_drawing_area(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + ): + xdescent = xdescent - self._xpad * fontsize + ydescent = ydescent - self._ypad * fontsize + width = width - self._xpad * fontsize + height = height - self._ypad * fontsize + return xdescent, ydescent, width, height + + def legend_artist(self, legend, orig_handle, + fontsize, handlebox): + """ + Return the artist that this HandlerBase generates for the given + original artist/handle. + + Parameters + ---------- + legend : `~matplotlib.legend.Legend` + The legend for which these legend artists are being created. + orig_handle : :class:`matplotlib.artist.Artist` or similar + The object for which these legend artists are being created. + fontsize : int + The fontsize in pixels. The artists being created should + be scaled according to the given fontsize. + handlebox : `~matplotlib.offsetbox.OffsetBox` + The box which has been created to hold this legend entry's + artists. Artists created in the `legend_artist` method must + be added to this handlebox inside this method. + + """ + xdescent, ydescent, width, height = self.adjust_drawing_area( + legend, orig_handle, + handlebox.xdescent, handlebox.ydescent, + handlebox.width, handlebox.height, + fontsize) + artists = self.create_artists(legend, orig_handle, + xdescent, ydescent, width, height, + fontsize, handlebox.get_transform()) + + # create_artists will return a list of artists. + for a in artists: + handlebox.add_artist(a) + + # we only return the first artist + return artists[0] + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + """ + Return the legend artists generated. + + Parameters + ---------- + legend : `~matplotlib.legend.Legend` + The legend for which these legend artists are being created. + orig_handle : `~matplotlib.artist.Artist` or similar + The object for which these legend artists are being created. + xdescent, ydescent, width, height : int + The rectangle (*xdescent*, *ydescent*, *width*, *height*) that the + legend artists being created should fit within. + fontsize : int + The fontsize in pixels. The legend artists being created should + be scaled according to the given fontsize. + trans : `~matplotlib.transforms.Transform` + The transform that is applied to the legend artists being created. + Typically from unit coordinates in the handler box to screen + coordinates. + """ + raise NotImplementedError('Derived must override') + + +class HandlerNpoints(HandlerBase): + """ + A legend handler that shows *numpoints* points in the legend entry. + """ + + def __init__(self, marker_pad=0.3, numpoints=None, **kwargs): + """ + Parameters + ---------- + marker_pad : float + Padding between points in legend entry. + numpoints : int + Number of points to show in legend entry. + **kwargs + Keyword arguments forwarded to `.HandlerBase`. + """ + super().__init__(**kwargs) + + self._numpoints = numpoints + self._marker_pad = marker_pad + + def get_numpoints(self, legend): + if self._numpoints is None: + return legend.numpoints + else: + return self._numpoints + + def get_xdata(self, legend, xdescent, ydescent, width, height, fontsize): + numpoints = self.get_numpoints(legend) + if numpoints > 1: + # we put some pad here to compensate the size of the marker + pad = self._marker_pad * fontsize + xdata = np.linspace(-xdescent + pad, + -xdescent + width - pad, + numpoints) + xdata_marker = xdata + else: + xdata = [-xdescent, -xdescent + width] + xdata_marker = [-xdescent + 0.5 * width] + return xdata, xdata_marker + + +class HandlerNpointsYoffsets(HandlerNpoints): + """ + A legend handler that shows *numpoints* in the legend, and allows them to + be individually offset in the y-direction. + """ + + def __init__(self, numpoints=None, yoffsets=None, **kwargs): + """ + Parameters + ---------- + numpoints : int + Number of points to show in legend entry. + yoffsets : array of floats + Length *numpoints* list of y offsets for each point in + legend entry. + **kwargs + Keyword arguments forwarded to `.HandlerNpoints`. + """ + super().__init__(numpoints=numpoints, **kwargs) + self._yoffsets = yoffsets + + def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize): + if self._yoffsets is None: + ydata = height * legend._scatteryoffsets + else: + ydata = height * np.asarray(self._yoffsets) + + return ydata + + +class HandlerLine2DCompound(HandlerNpoints): + """ + Original handler for `.Line2D` instances, that relies on combining + a line-only with a marker-only artist. May be deprecated in the future. + """ + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + + ydata = np.full_like(xdata, ((height - ydescent) / 2)) + legline = Line2D(xdata, ydata) + + self.update_prop(legline, orig_handle, legend) + legline.set_drawstyle('default') + legline.set_marker("") + + legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)]) + self.update_prop(legline_marker, orig_handle, legend) + legline_marker.set_linestyle('None') + if legend.markerscale != 1: + newsz = legline_marker.get_markersize() * legend.markerscale + legline_marker.set_markersize(newsz) + # we don't want to add this to the return list because + # the texts and handles are assumed to be in one-to-one + # correspondence. + legline._legmarker = legline_marker + + legline.set_transform(trans) + legline_marker.set_transform(trans) + + return [legline, legline_marker] + + +class HandlerLine2D(HandlerNpoints): + """ + Handler for `.Line2D` instances. + + See Also + -------- + HandlerLine2DCompound : An earlier handler implementation, which used one + artist for the line and another for the marker(s). + """ + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + + markevery = None + if self.get_numpoints(legend) == 1: + # Special case: one wants a single marker in the center + # and a line that extends on both sides. One will use a + # 3 points line, but only mark the #1 (i.e. middle) point. + xdata = np.linspace(xdata[0], xdata[-1], 3) + markevery = [1] + + ydata = np.full_like(xdata, (height - ydescent) / 2) + legline = Line2D(xdata, ydata, markevery=markevery) + + self.update_prop(legline, orig_handle, legend) + + if legend.markerscale != 1: + newsz = legline.get_markersize() * legend.markerscale + legline.set_markersize(newsz) + + legline.set_transform(trans) + + return [legline] + + +class HandlerPatch(HandlerBase): + """ + Handler for `.Patch` instances. + """ + + def __init__(self, patch_func=None, **kwargs): + """ + Parameters + ---------- + patch_func : callable, optional + The function that creates the legend key artist. + *patch_func* should have the signature:: + + def patch_func(legend=legend, orig_handle=orig_handle, + xdescent=xdescent, ydescent=ydescent, + width=width, height=height, fontsize=fontsize) + + Subsequently, the created artist will have its ``update_prop`` + method called and the appropriate transform will be applied. + + **kwargs + Keyword arguments forwarded to `.HandlerBase`. + """ + super().__init__(**kwargs) + self._patch_func = patch_func + + def _create_patch(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize): + if self._patch_func is None: + p = Rectangle(xy=(-xdescent, -ydescent), + width=width, height=height) + else: + p = self._patch_func(legend=legend, orig_handle=orig_handle, + xdescent=xdescent, ydescent=ydescent, + width=width, height=height, fontsize=fontsize) + return p + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, trans): + # docstring inherited + p = self._create_patch(legend, orig_handle, + xdescent, ydescent, width, height, fontsize) + self.update_prop(p, orig_handle, legend) + p.set_transform(trans) + return [p] + + +class HandlerStepPatch(HandlerBase): + """ + Handler for `~.matplotlib.patches.StepPatch` instances. + """ + + @staticmethod + def _create_patch(orig_handle, xdescent, ydescent, width, height): + return Rectangle(xy=(-xdescent, -ydescent), width=width, + height=height, color=orig_handle.get_facecolor()) + + @staticmethod + def _create_line(orig_handle, width, height): + # Unfilled StepPatch should show as a line + legline = Line2D([0, width], [height/2, height/2], + color=orig_handle.get_edgecolor(), + linestyle=orig_handle.get_linestyle(), + linewidth=orig_handle.get_linewidth(), + ) + + # Overwrite manually because patch and line properties don't mix + legline.set_drawstyle('default') + legline.set_marker("") + return legline + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, trans): + # docstring inherited + if orig_handle.get_fill() or (orig_handle.get_hatch() is not None): + p = self._create_patch(orig_handle, xdescent, ydescent, width, + height) + self.update_prop(p, orig_handle, legend) + else: + p = self._create_line(orig_handle, width, height) + p.set_transform(trans) + return [p] + + +class HandlerLineCollection(HandlerLine2D): + """ + Handler for `.LineCollection` instances. + """ + def get_numpoints(self, legend): + if self._numpoints is None: + return legend.scatterpoints + else: + return self._numpoints + + def _default_update_prop(self, legend_handle, orig_handle): + lw = orig_handle.get_linewidths()[0] + dashes = orig_handle._us_linestyles[0] + color = orig_handle.get_colors()[0] + legend_handle.set_color(color) + legend_handle.set_linestyle(dashes) + legend_handle.set_linewidth(lw) + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, trans): + # docstring inherited + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + ydata = np.full_like(xdata, (height - ydescent) / 2) + legline = Line2D(xdata, ydata) + + self.update_prop(legline, orig_handle, legend) + legline.set_transform(trans) + + return [legline] + + +class HandlerRegularPolyCollection(HandlerNpointsYoffsets): + r"""Handler for `.RegularPolyCollection`\s.""" + + def __init__(self, yoffsets=None, sizes=None, **kwargs): + super().__init__(yoffsets=yoffsets, **kwargs) + + self._sizes = sizes + + def get_numpoints(self, legend): + if self._numpoints is None: + return legend.scatterpoints + else: + return self._numpoints + + def get_sizes(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize): + if self._sizes is None: + handle_sizes = orig_handle.get_sizes() + if not len(handle_sizes): + handle_sizes = [1] + size_max = max(handle_sizes) * legend.markerscale ** 2 + size_min = min(handle_sizes) * legend.markerscale ** 2 + + numpoints = self.get_numpoints(legend) + if numpoints < 4: + sizes = [.5 * (size_max + size_min), size_max, + size_min][:numpoints] + else: + rng = (size_max - size_min) + sizes = rng * np.linspace(0, 1, numpoints) + size_min + else: + sizes = self._sizes + + return sizes + + def update_prop(self, legend_handle, orig_handle, legend): + + self._update_prop(legend_handle, orig_handle) + + legend_handle.set_figure(legend.figure) + # legend._set_artist_props(legend_handle) + legend_handle.set_clip_box(None) + legend_handle.set_clip_path(None) + + def create_collection(self, orig_handle, sizes, offsets, offset_transform): + return type(orig_handle)( + orig_handle.get_numsides(), + rotation=orig_handle.get_rotation(), sizes=sizes, + offsets=offsets, offset_transform=offset_transform, + ) + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + + ydata = self.get_ydata(legend, xdescent, ydescent, + width, height, fontsize) + + sizes = self.get_sizes(legend, orig_handle, xdescent, ydescent, + width, height, fontsize) + + p = self.create_collection( + orig_handle, sizes, + offsets=list(zip(xdata_marker, ydata)), offset_transform=trans) + + self.update_prop(p, orig_handle, legend) + p.set_offset_transform(trans) + return [p] + + +class HandlerPathCollection(HandlerRegularPolyCollection): + r"""Handler for `.PathCollection`\s, which are used by `~.Axes.scatter`.""" + + def create_collection(self, orig_handle, sizes, offsets, offset_transform): + return type(orig_handle)( + [orig_handle.get_paths()[0]], sizes=sizes, + offsets=offsets, offset_transform=offset_transform, + ) + + +class HandlerCircleCollection(HandlerRegularPolyCollection): + r"""Handler for `.CircleCollection`\s.""" + + def create_collection(self, orig_handle, sizes, offsets, offset_transform): + return type(orig_handle)( + sizes, offsets=offsets, offset_transform=offset_transform) + + +class HandlerErrorbar(HandlerLine2D): + """Handler for Errorbars.""" + + def __init__(self, xerr_size=0.5, yerr_size=None, + marker_pad=0.3, numpoints=None, **kwargs): + + self._xerr_size = xerr_size + self._yerr_size = yerr_size + + super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kwargs) + + def get_err_size(self, legend, xdescent, ydescent, + width, height, fontsize): + xerr_size = self._xerr_size * fontsize + + if self._yerr_size is None: + yerr_size = xerr_size + else: + yerr_size = self._yerr_size * fontsize + + return xerr_size, yerr_size + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + plotlines, caplines, barlinecols = orig_handle + + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + + ydata = np.full_like(xdata, (height - ydescent) / 2) + legline = Line2D(xdata, ydata) + + xdata_marker = np.asarray(xdata_marker) + ydata_marker = np.asarray(ydata[:len(xdata_marker)]) + + xerr_size, yerr_size = self.get_err_size(legend, xdescent, ydescent, + width, height, fontsize) + + legline_marker = Line2D(xdata_marker, ydata_marker) + + # when plotlines are None (only errorbars are drawn), we just + # make legline invisible. + if plotlines is None: + legline.set_visible(False) + legline_marker.set_visible(False) + else: + self.update_prop(legline, plotlines, legend) + + legline.set_drawstyle('default') + legline.set_marker('none') + + self.update_prop(legline_marker, plotlines, legend) + legline_marker.set_linestyle('None') + + if legend.markerscale != 1: + newsz = legline_marker.get_markersize() * legend.markerscale + legline_marker.set_markersize(newsz) + + handle_barlinecols = [] + handle_caplines = [] + + if orig_handle.has_xerr: + verts = [((x - xerr_size, y), (x + xerr_size, y)) + for x, y in zip(xdata_marker, ydata_marker)] + coll = mcoll.LineCollection(verts) + self.update_prop(coll, barlinecols[0], legend) + handle_barlinecols.append(coll) + + if caplines: + capline_left = Line2D(xdata_marker - xerr_size, ydata_marker) + capline_right = Line2D(xdata_marker + xerr_size, ydata_marker) + self.update_prop(capline_left, caplines[0], legend) + self.update_prop(capline_right, caplines[0], legend) + capline_left.set_marker("|") + capline_right.set_marker("|") + + handle_caplines.append(capline_left) + handle_caplines.append(capline_right) + + if orig_handle.has_yerr: + verts = [((x, y - yerr_size), (x, y + yerr_size)) + for x, y in zip(xdata_marker, ydata_marker)] + coll = mcoll.LineCollection(verts) + self.update_prop(coll, barlinecols[0], legend) + handle_barlinecols.append(coll) + + if caplines: + capline_left = Line2D(xdata_marker, ydata_marker - yerr_size) + capline_right = Line2D(xdata_marker, ydata_marker + yerr_size) + self.update_prop(capline_left, caplines[0], legend) + self.update_prop(capline_right, caplines[0], legend) + capline_left.set_marker("_") + capline_right.set_marker("_") + + handle_caplines.append(capline_left) + handle_caplines.append(capline_right) + + artists = [ + *handle_barlinecols, *handle_caplines, legline, legline_marker, + ] + for artist in artists: + artist.set_transform(trans) + return artists + + +class HandlerStem(HandlerNpointsYoffsets): + """ + Handler for plots produced by `~.Axes.stem`. + """ + + def __init__(self, marker_pad=0.3, numpoints=None, + bottom=None, yoffsets=None, **kwargs): + """ + Parameters + ---------- + marker_pad : float, default: 0.3 + Padding between points in legend entry. + numpoints : int, optional + Number of points to show in legend entry. + bottom : float, optional + + yoffsets : array of floats, optional + Length *numpoints* list of y offsets for each point in + legend entry. + **kwargs + Keyword arguments forwarded to `.HandlerNpointsYoffsets`. + """ + super().__init__(marker_pad=marker_pad, numpoints=numpoints, + yoffsets=yoffsets, **kwargs) + self._bottom = bottom + + def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize): + if self._yoffsets is None: + ydata = height * (0.5 * legend._scatteryoffsets + 0.5) + else: + ydata = height * np.asarray(self._yoffsets) + + return ydata + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + markerline, stemlines, baseline = orig_handle + # Check to see if the stemcontainer is storing lines as a list or a + # LineCollection. Eventually using a list will be removed, and this + # logic can also be removed. + using_linecoll = isinstance(stemlines, mcoll.LineCollection) + + xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent, + width, height, fontsize) + + ydata = self.get_ydata(legend, xdescent, ydescent, + width, height, fontsize) + + if self._bottom is None: + bottom = 0. + else: + bottom = self._bottom + + leg_markerline = Line2D(xdata_marker, ydata[:len(xdata_marker)]) + self.update_prop(leg_markerline, markerline, legend) + + leg_stemlines = [Line2D([x, x], [bottom, y]) + for x, y in zip(xdata_marker, ydata)] + + if using_linecoll: + # change the function used by update_prop() from the default + # to one that handles LineCollection + with cbook._setattr_cm( + self, _update_prop_func=self._copy_collection_props): + for line in leg_stemlines: + self.update_prop(line, stemlines, legend) + + else: + for lm, m in zip(leg_stemlines, stemlines): + self.update_prop(lm, m, legend) + + leg_baseline = Line2D([np.min(xdata), np.max(xdata)], + [bottom, bottom]) + self.update_prop(leg_baseline, baseline, legend) + + artists = [*leg_stemlines, leg_baseline, leg_markerline] + for artist in artists: + artist.set_transform(trans) + return artists + + def _copy_collection_props(self, legend_handle, orig_handle): + """ + Copy properties from the `.LineCollection` *orig_handle* to the + `.Line2D` *legend_handle*. + """ + legend_handle.set_color(orig_handle.get_color()[0]) + legend_handle.set_linestyle(orig_handle.get_linestyle()[0]) + + +class HandlerTuple(HandlerBase): + """ + Handler for Tuple. + """ + + def __init__(self, ndivide=1, pad=None, **kwargs): + """ + Parameters + ---------- + ndivide : int or None, default: 1 + The number of sections to divide the legend area into. If None, + use the length of the input tuple. + pad : float, default: :rc:`legend.borderpad` + Padding in units of fraction of font size. + **kwargs + Keyword arguments forwarded to `.HandlerBase`. + """ + self._ndivide = ndivide + self._pad = pad + super().__init__(**kwargs) + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, + trans): + # docstring inherited + handler_map = legend.get_legend_handler_map() + + if self._ndivide is None: + ndivide = len(orig_handle) + else: + ndivide = self._ndivide + + if self._pad is None: + pad = legend.borderpad * fontsize + else: + pad = self._pad * fontsize + + if ndivide > 1: + width = (width - pad * (ndivide - 1)) / ndivide + + xds_cycle = cycle(xdescent - (width + pad) * np.arange(ndivide)) + + a_list = [] + for handle1 in orig_handle: + handler = legend.get_legend_handler(handler_map, handle1) + _a_list = handler.create_artists( + legend, handle1, + next(xds_cycle), ydescent, width, height, fontsize, trans) + a_list.extend(_a_list) + + return a_list + + +class HandlerPolyCollection(HandlerBase): + """ + Handler for `.PolyCollection` used in `~.Axes.fill_between` and + `~.Axes.stackplot`. + """ + def _update_prop(self, legend_handle, orig_handle): + def first_color(colors): + if colors.size == 0: + return (0, 0, 0, 0) + return tuple(colors[0]) + + def get_first(prop_array): + if len(prop_array): + return prop_array[0] + else: + return None + + # orig_handle is a PolyCollection and legend_handle is a Patch. + # Directly set Patch color attributes (must be RGBA tuples). + legend_handle._facecolor = first_color(orig_handle.get_facecolor()) + legend_handle._edgecolor = first_color(orig_handle.get_edgecolor()) + legend_handle._original_facecolor = orig_handle._original_facecolor + legend_handle._original_edgecolor = orig_handle._original_edgecolor + legend_handle._fill = orig_handle.get_fill() + legend_handle._hatch = orig_handle.get_hatch() + # Hatch color is anomalous in having no getters and setters. + legend_handle._hatch_color = orig_handle._hatch_color + # Setters are fine for the remaining attributes. + legend_handle.set_linewidth(get_first(orig_handle.get_linewidths())) + legend_handle.set_linestyle(get_first(orig_handle.get_linestyles())) + legend_handle.set_transform(get_first(orig_handle.get_transforms())) + legend_handle.set_figure(orig_handle.get_figure()) + # Alpha is already taken into account by the color attributes. + + def create_artists(self, legend, orig_handle, + xdescent, ydescent, width, height, fontsize, trans): + # docstring inherited + p = Rectangle(xy=(-xdescent, -ydescent), + width=width, height=height) + self.update_prop(p, orig_handle, legend) + p.set_transform(trans) + return [p] diff --git a/venv/lib/python3.10/site-packages/matplotlib/legend_handler.pyi b/venv/lib/python3.10/site-packages/matplotlib/legend_handler.pyi new file mode 100644 index 00000000..db028a13 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/legend_handler.pyi @@ -0,0 +1,294 @@ +from collections.abc import Callable, Sequence +from matplotlib.artist import Artist +from matplotlib.legend import Legend +from matplotlib.offsetbox import OffsetBox +from matplotlib.transforms import Transform + +from typing import TypeVar + +from numpy.typing import ArrayLike + +def update_from_first_child(tgt: Artist, src: Artist) -> None: ... + +class HandlerBase: + def __init__( + self, + xpad: float = ..., + ypad: float = ..., + update_func: Callable[[Artist, Artist], None] | None = ..., + ) -> None: ... + def update_prop( + self, legend_handle: Artist, orig_handle: Artist, legend: Legend + ) -> None: ... + def adjust_drawing_area( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> tuple[float, float, float, float]: ... + def legend_artist( + self, legend: Legend, orig_handle: Artist, fontsize: float, handlebox: OffsetBox + ) -> Artist: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerNpoints(HandlerBase): + def __init__( + self, marker_pad: float = ..., numpoints: int | None = ..., **kwargs + ) -> None: ... + def get_numpoints(self, legend: Legend) -> int | None: ... + def get_xdata( + self, + legend: Legend, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> tuple[ArrayLike, ArrayLike]: ... + +class HandlerNpointsYoffsets(HandlerNpoints): + def __init__( + self, + numpoints: int | None = ..., + yoffsets: Sequence[float] | None = ..., + **kwargs + ) -> None: ... + def get_ydata( + self, + legend: Legend, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> ArrayLike: ... + +class HandlerLine2DCompound(HandlerNpoints): + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerLine2D(HandlerNpoints): + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerPatch(HandlerBase): + def __init__(self, patch_func: Callable | None = ..., **kwargs) -> None: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerStepPatch(HandlerBase): + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerLineCollection(HandlerLine2D): + def get_numpoints(self, legend: Legend) -> int: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +_T = TypeVar("_T", bound=Artist) + +class HandlerRegularPolyCollection(HandlerNpointsYoffsets): + def __init__( + self, + yoffsets: Sequence[float] | None = ..., + sizes: Sequence[float] | None = ..., + **kwargs + ) -> None: ... + def get_numpoints(self, legend: Legend) -> int: ... + def get_sizes( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> Sequence[float]: ... + def update_prop( + self, legend_handle, orig_handle: Artist, legend: Legend + ) -> None: ... + def create_collection( + self, + orig_handle: _T, + sizes: Sequence[float] | None, + offsets: Sequence[float] | None, + offset_transform: Transform, + ) -> _T: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerPathCollection(HandlerRegularPolyCollection): + def create_collection( + self, + orig_handle: _T, + sizes: Sequence[float] | None, + offsets: Sequence[float] | None, + offset_transform: Transform, + ) -> _T: ... + +class HandlerCircleCollection(HandlerRegularPolyCollection): + def create_collection( + self, + orig_handle: _T, + sizes: Sequence[float] | None, + offsets: Sequence[float] | None, + offset_transform: Transform, + ) -> _T: ... + +class HandlerErrorbar(HandlerLine2D): + def __init__( + self, + xerr_size: float = ..., + yerr_size: float | None = ..., + marker_pad: float = ..., + numpoints: int | None = ..., + **kwargs + ) -> None: ... + def get_err_size( + self, + legend: Legend, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> tuple[float, float]: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerStem(HandlerNpointsYoffsets): + def __init__( + self, + marker_pad: float = ..., + numpoints: int | None = ..., + bottom: float | None = ..., + yoffsets: Sequence[float] | None = ..., + **kwargs + ) -> None: ... + def get_ydata( + self, + legend: Legend, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + ) -> ArrayLike: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerTuple(HandlerBase): + def __init__( + self, ndivide: int | None = ..., pad: float | None = ..., **kwargs + ) -> None: ... + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... + +class HandlerPolyCollection(HandlerBase): + def create_artists( + self, + legend: Legend, + orig_handle: Artist, + xdescent: float, + ydescent: float, + width: float, + height: float, + fontsize: float, + trans: Transform, + ) -> Sequence[Artist]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/lines.py b/venv/lib/python3.10/site-packages/matplotlib/lines.py new file mode 100644 index 00000000..72e74f4e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/lines.py @@ -0,0 +1,1679 @@ +""" +2D lines with support for a variety of line styles, markers, colors, etc. +""" + +import copy + +from numbers import Integral, Number, Real +import logging + +import numpy as np + +import matplotlib as mpl +from . import _api, cbook, colors as mcolors, _docstring +from .artist import Artist, allow_rasterization +from .cbook import ( + _to_unmasked_float_array, ls_mapper, ls_mapper_r, STEP_LOOKUP_MAP) +from .markers import MarkerStyle +from .path import Path +from .transforms import Bbox, BboxTransformTo, TransformedPath +from ._enums import JoinStyle, CapStyle + +# Imported here for backward compatibility, even though they don't +# really belong. +from . import _path +from .markers import ( # noqa + CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN, + CARETLEFTBASE, CARETRIGHTBASE, CARETUPBASE, CARETDOWNBASE, + TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN) + +_log = logging.getLogger(__name__) + + +def _get_dash_pattern(style): + """Convert linestyle to dash pattern.""" + # go from short hand -> full strings + if isinstance(style, str): + style = ls_mapper.get(style, style) + # un-dashed styles + if style in ['solid', 'None']: + offset = 0 + dashes = None + # dashed styles + elif style in ['dashed', 'dashdot', 'dotted']: + offset = 0 + dashes = tuple(mpl.rcParams[f'lines.{style}_pattern']) + # + elif isinstance(style, tuple): + offset, dashes = style + if offset is None: + raise ValueError(f'Unrecognized linestyle: {style!r}') + else: + raise ValueError(f'Unrecognized linestyle: {style!r}') + + # normalize offset to be positive and shorter than the dash cycle + if dashes is not None: + dsum = sum(dashes) + if dsum: + offset %= dsum + + return offset, dashes + + +def _get_inverse_dash_pattern(offset, dashes): + """Return the inverse of the given dash pattern, for filling the gaps.""" + # Define the inverse pattern by moving the last gap to the start of the + # sequence. + gaps = dashes[-1:] + dashes[:-1] + # Set the offset so that this new first segment is skipped + # (see backend_bases.GraphicsContextBase.set_dashes for offset definition). + offset_gaps = offset + dashes[-1] + + return offset_gaps, gaps + + +def _scale_dashes(offset, dashes, lw): + if not mpl.rcParams['lines.scale_dashes']: + return offset, dashes + scaled_offset = offset * lw + scaled_dashes = ([x * lw if x is not None else None for x in dashes] + if dashes is not None else None) + return scaled_offset, scaled_dashes + + +def segment_hits(cx, cy, x, y, radius): + """ + Return the indices of the segments in the polyline with coordinates (*cx*, + *cy*) that are within a distance *radius* of the point (*x*, *y*). + """ + # Process single points specially + if len(x) <= 1: + res, = np.nonzero((cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2) + return res + + # We need to lop the last element off a lot. + xr, yr = x[:-1], y[:-1] + + # Only look at line segments whose nearest point to C on the line + # lies within the segment. + dx, dy = x[1:] - xr, y[1:] - yr + Lnorm_sq = dx ** 2 + dy ** 2 # Possibly want to eliminate Lnorm==0 + u = ((cx - xr) * dx + (cy - yr) * dy) / Lnorm_sq + candidates = (u >= 0) & (u <= 1) + + # Note that there is a little area near one side of each point + # which will be near neither segment, and another which will + # be near both, depending on the angle of the lines. The + # following radius test eliminates these ambiguities. + point_hits = (cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2 + candidates = candidates & ~(point_hits[:-1] | point_hits[1:]) + + # For those candidates which remain, determine how far they lie away + # from the line. + px, py = xr + u * dx, yr + u * dy + line_hits = (cx - px) ** 2 + (cy - py) ** 2 <= radius ** 2 + line_hits = line_hits & candidates + points, = point_hits.ravel().nonzero() + lines, = line_hits.ravel().nonzero() + return np.concatenate((points, lines)) + + +def _mark_every_path(markevery, tpath, affine, ax): + """ + Helper function that sorts out how to deal the input + `markevery` and returns the points where markers should be drawn. + + Takes in the `markevery` value and the line path and returns the + sub-sampled path. + """ + # pull out the two bits of data we want from the path + codes, verts = tpath.codes, tpath.vertices + + def _slice_or_none(in_v, slc): + """Helper function to cope with `codes` being an ndarray or `None`.""" + if in_v is None: + return None + return in_v[slc] + + # if just an int, assume starting at 0 and make a tuple + if isinstance(markevery, Integral): + markevery = (0, markevery) + # if just a float, assume starting at 0.0 and make a tuple + elif isinstance(markevery, Real): + markevery = (0.0, markevery) + + if isinstance(markevery, tuple): + if len(markevery) != 2: + raise ValueError('`markevery` is a tuple but its len is not 2; ' + f'markevery={markevery}') + start, step = markevery + # if step is an int, old behavior + if isinstance(step, Integral): + # tuple of 2 int is for backwards compatibility, + if not isinstance(start, Integral): + raise ValueError( + '`markevery` is a tuple with len 2 and second element is ' + 'an int, but the first element is not an int; ' + f'markevery={markevery}') + # just return, we are done here + + return Path(verts[slice(start, None, step)], + _slice_or_none(codes, slice(start, None, step))) + + elif isinstance(step, Real): + if not isinstance(start, Real): + raise ValueError( + '`markevery` is a tuple with len 2 and second element is ' + 'a float, but the first element is not a float or an int; ' + f'markevery={markevery}') + if ax is None: + raise ValueError( + "markevery is specified relative to the Axes size, but " + "the line does not have a Axes as parent") + + # calc cumulative distance along path (in display coords): + fin = np.isfinite(verts).all(axis=1) + fverts = verts[fin] + disp_coords = affine.transform(fverts) + + delta = np.empty((len(disp_coords), 2)) + delta[0, :] = 0 + delta[1:, :] = disp_coords[1:, :] - disp_coords[:-1, :] + delta = np.hypot(*delta.T).cumsum() + # calc distance between markers along path based on the Axes + # bounding box diagonal being a distance of unity: + (x0, y0), (x1, y1) = ax.transAxes.transform([[0, 0], [1, 1]]) + scale = np.hypot(x1 - x0, y1 - y0) + marker_delta = np.arange(start * scale, delta[-1], step * scale) + # find closest actual data point that is closest to + # the theoretical distance along the path: + inds = np.abs(delta[np.newaxis, :] - marker_delta[:, np.newaxis]) + inds = inds.argmin(axis=1) + inds = np.unique(inds) + # return, we are done here + return Path(fverts[inds], _slice_or_none(codes, inds)) + else: + raise ValueError( + f"markevery={markevery!r} is a tuple with len 2, but its " + f"second element is not an int or a float") + + elif isinstance(markevery, slice): + # mazol tov, it's already a slice, just return + return Path(verts[markevery], _slice_or_none(codes, markevery)) + + elif np.iterable(markevery): + # fancy indexing + try: + return Path(verts[markevery], _slice_or_none(codes, markevery)) + except (ValueError, IndexError) as err: + raise ValueError( + f"markevery={markevery!r} is iterable but not a valid numpy " + f"fancy index") from err + else: + raise ValueError(f"markevery={markevery!r} is not a recognized value") + + +@_docstring.interpd +@_api.define_aliases({ + "antialiased": ["aa"], + "color": ["c"], + "drawstyle": ["ds"], + "linestyle": ["ls"], + "linewidth": ["lw"], + "markeredgecolor": ["mec"], + "markeredgewidth": ["mew"], + "markerfacecolor": ["mfc"], + "markerfacecoloralt": ["mfcalt"], + "markersize": ["ms"], +}) +class Line2D(Artist): + """ + A line - the line can have both a solid linestyle connecting all + the vertices, and a marker at each vertex. Additionally, the + drawing of the solid line is influenced by the drawstyle, e.g., one + can create "stepped" lines in various styles. + """ + + lineStyles = _lineStyles = { # hidden names deprecated + '-': '_draw_solid', + '--': '_draw_dashed', + '-.': '_draw_dash_dot', + ':': '_draw_dotted', + 'None': '_draw_nothing', + ' ': '_draw_nothing', + '': '_draw_nothing', + } + + _drawStyles_l = { + 'default': '_draw_lines', + 'steps-mid': '_draw_steps_mid', + 'steps-pre': '_draw_steps_pre', + 'steps-post': '_draw_steps_post', + } + + _drawStyles_s = { + 'steps': '_draw_steps_pre', + } + + # drawStyles should now be deprecated. + drawStyles = {**_drawStyles_l, **_drawStyles_s} + # Need a list ordered with long names first: + drawStyleKeys = [*_drawStyles_l, *_drawStyles_s] + + # Referenced here to maintain API. These are defined in + # MarkerStyle + markers = MarkerStyle.markers + filled_markers = MarkerStyle.filled_markers + fillStyles = MarkerStyle.fillstyles + + zorder = 2 + + _subslice_optim_min_size = 1000 + + def __str__(self): + if self._label != "": + return f"Line2D({self._label})" + elif self._x is None: + return "Line2D()" + elif len(self._x) > 3: + return "Line2D(({:g},{:g}),({:g},{:g}),...,({:g},{:g}))".format( + self._x[0], self._y[0], + self._x[1], self._y[1], + self._x[-1], self._y[-1]) + else: + return "Line2D(%s)" % ",".join( + map("({:g},{:g})".format, self._x, self._y)) + + def __init__(self, xdata, ydata, *, + linewidth=None, # all Nones default to rc + linestyle=None, + color=None, + gapcolor=None, + marker=None, + markersize=None, + markeredgewidth=None, + markeredgecolor=None, + markerfacecolor=None, + markerfacecoloralt='none', + fillstyle=None, + antialiased=None, + dash_capstyle=None, + solid_capstyle=None, + dash_joinstyle=None, + solid_joinstyle=None, + pickradius=5, + drawstyle=None, + markevery=None, + **kwargs + ): + """ + Create a `.Line2D` instance with *x* and *y* data in sequences of + *xdata*, *ydata*. + + Additional keyword arguments are `.Line2D` properties: + + %(Line2D:kwdoc)s + + See :meth:`set_linestyle` for a description of the line styles, + :meth:`set_marker` for a description of the markers, and + :meth:`set_drawstyle` for a description of the draw styles. + + """ + super().__init__() + + # Convert sequences to NumPy arrays. + if not np.iterable(xdata): + raise RuntimeError('xdata must be a sequence') + if not np.iterable(ydata): + raise RuntimeError('ydata must be a sequence') + + if linewidth is None: + linewidth = mpl.rcParams['lines.linewidth'] + + if linestyle is None: + linestyle = mpl.rcParams['lines.linestyle'] + if marker is None: + marker = mpl.rcParams['lines.marker'] + if color is None: + color = mpl.rcParams['lines.color'] + + if markersize is None: + markersize = mpl.rcParams['lines.markersize'] + if antialiased is None: + antialiased = mpl.rcParams['lines.antialiased'] + if dash_capstyle is None: + dash_capstyle = mpl.rcParams['lines.dash_capstyle'] + if dash_joinstyle is None: + dash_joinstyle = mpl.rcParams['lines.dash_joinstyle'] + if solid_capstyle is None: + solid_capstyle = mpl.rcParams['lines.solid_capstyle'] + if solid_joinstyle is None: + solid_joinstyle = mpl.rcParams['lines.solid_joinstyle'] + + if drawstyle is None: + drawstyle = 'default' + + self._dashcapstyle = None + self._dashjoinstyle = None + self._solidjoinstyle = None + self._solidcapstyle = None + self.set_dash_capstyle(dash_capstyle) + self.set_dash_joinstyle(dash_joinstyle) + self.set_solid_capstyle(solid_capstyle) + self.set_solid_joinstyle(solid_joinstyle) + + self._linestyles = None + self._drawstyle = None + self._linewidth = linewidth + self._unscaled_dash_pattern = (0, None) # offset, dash + self._dash_pattern = (0, None) # offset, dash (scaled by linewidth) + + self.set_linewidth(linewidth) + self.set_linestyle(linestyle) + self.set_drawstyle(drawstyle) + + self._color = None + self.set_color(color) + if marker is None: + marker = 'none' # Default. + if not isinstance(marker, MarkerStyle): + self._marker = MarkerStyle(marker, fillstyle) + else: + self._marker = marker + + self._gapcolor = None + self.set_gapcolor(gapcolor) + + self._markevery = None + self._markersize = None + self._antialiased = None + + self.set_markevery(markevery) + self.set_antialiased(antialiased) + self.set_markersize(markersize) + + self._markeredgecolor = None + self._markeredgewidth = None + self._markerfacecolor = None + self._markerfacecoloralt = None + + self.set_markerfacecolor(markerfacecolor) # Normalizes None to rc. + self.set_markerfacecoloralt(markerfacecoloralt) + self.set_markeredgecolor(markeredgecolor) # Normalizes None to rc. + self.set_markeredgewidth(markeredgewidth) + + # update kwargs before updating data to give the caller a + # chance to init axes (and hence unit support) + self._internal_update(kwargs) + self.pickradius = pickradius + self.ind_offset = 0 + if (isinstance(self._picker, Number) and + not isinstance(self._picker, bool)): + self._pickradius = self._picker + + self._xorig = np.asarray([]) + self._yorig = np.asarray([]) + self._invalidx = True + self._invalidy = True + self._x = None + self._y = None + self._xy = None + self._path = None + self._transformed_path = None + self._subslice = False + self._x_filled = None # used in subslicing; only x is needed + + self.set_data(xdata, ydata) + + def contains(self, mouseevent): + """ + Test whether *mouseevent* occurred on the line. + + An event is deemed to have occurred "on" the line if it is less + than ``self.pickradius`` (default: 5 points) away from it. Use + `~.Line2D.get_pickradius` or `~.Line2D.set_pickradius` to get or set + the pick radius. + + Parameters + ---------- + mouseevent : `~matplotlib.backend_bases.MouseEvent` + + Returns + ------- + contains : bool + Whether any values are within the radius. + details : dict + A dictionary ``{'ind': pointlist}``, where *pointlist* is a + list of points of the line that are within the pickradius around + the event position. + + TODO: sort returned indices by distance + """ + if self._different_canvas(mouseevent): + return False, {} + + # Make sure we have data to plot + if self._invalidy or self._invalidx: + self.recache() + if len(self._xy) == 0: + return False, {} + + # Convert points to pixels + transformed_path = self._get_transformed_path() + path, affine = transformed_path.get_transformed_path_and_affine() + path = affine.transform_path(path) + xy = path.vertices + xt = xy[:, 0] + yt = xy[:, 1] + + # Convert pick radius from points to pixels + if self.figure is None: + _log.warning('no figure set when check if mouse is on line') + pixels = self._pickradius + else: + pixels = self.figure.dpi / 72. * self._pickradius + + # The math involved in checking for containment (here and inside of + # segment_hits) assumes that it is OK to overflow, so temporarily set + # the error flags accordingly. + with np.errstate(all='ignore'): + # Check for collision + if self._linestyle in ['None', None]: + # If no line, return the nearby point(s) + ind, = np.nonzero( + (xt - mouseevent.x) ** 2 + (yt - mouseevent.y) ** 2 + <= pixels ** 2) + else: + # If line, return the nearby segment(s) + ind = segment_hits(mouseevent.x, mouseevent.y, xt, yt, pixels) + if self._drawstyle.startswith("steps"): + ind //= 2 + + ind += self.ind_offset + + # Return the point(s) within radius + return len(ind) > 0, dict(ind=ind) + + def get_pickradius(self): + """ + Return the pick radius used for containment tests. + + See `.contains` for more details. + """ + return self._pickradius + + def set_pickradius(self, pickradius): + """ + Set the pick radius used for containment tests. + + See `.contains` for more details. + + Parameters + ---------- + pickradius : float + Pick radius, in points. + """ + if not isinstance(pickradius, Real) or pickradius < 0: + raise ValueError("pick radius should be a distance") + self._pickradius = pickradius + + pickradius = property(get_pickradius, set_pickradius) + + def get_fillstyle(self): + """ + Return the marker fill style. + + See also `~.Line2D.set_fillstyle`. + """ + return self._marker.get_fillstyle() + + def set_fillstyle(self, fs): + """ + Set the marker fill style. + + Parameters + ---------- + fs : {'full', 'left', 'right', 'bottom', 'top', 'none'} + Possible values: + + - 'full': Fill the whole marker with the *markerfacecolor*. + - 'left', 'right', 'bottom', 'top': Fill the marker half at + the given side with the *markerfacecolor*. The other + half of the marker is filled with *markerfacecoloralt*. + - 'none': No filling. + + For examples see :ref:`marker_fill_styles`. + """ + self.set_marker(MarkerStyle(self._marker.get_marker(), fs)) + self.stale = True + + def set_markevery(self, every): + """ + Set the markevery property to subsample the plot when using markers. + + e.g., if ``every=5``, every 5-th marker will be plotted. + + Parameters + ---------- + every : None or int or (int, int) or slice or list[int] or float or \ +(float, float) or list[bool] + Which markers to plot. + + - ``every=None``: every point will be plotted. + - ``every=N``: every N-th marker will be plotted starting with + marker 0. + - ``every=(start, N)``: every N-th marker, starting at index + *start*, will be plotted. + - ``every=slice(start, end, N)``: every N-th marker, starting at + index *start*, up to but not including index *end*, will be + plotted. + - ``every=[i, j, m, ...]``: only markers at the given indices + will be plotted. + - ``every=[True, False, True, ...]``: only positions that are True + will be plotted. The list must have the same length as the data + points. + - ``every=0.1``, (i.e. a float): markers will be spaced at + approximately equal visual distances along the line; the distance + along the line between markers is determined by multiplying the + display-coordinate distance of the Axes bounding-box diagonal + by the value of *every*. + - ``every=(0.5, 0.1)`` (i.e. a length-2 tuple of float): similar + to ``every=0.1`` but the first marker will be offset along the + line by 0.5 multiplied by the + display-coordinate-diagonal-distance along the line. + + For examples see + :doc:`/gallery/lines_bars_and_markers/markevery_demo`. + + Notes + ----- + Setting *markevery* will still only draw markers at actual data points. + While the float argument form aims for uniform visual spacing, it has + to coerce from the ideal spacing to the nearest available data point. + Depending on the number and distribution of data points, the result + may still not look evenly spaced. + + When using a start offset to specify the first marker, the offset will + be from the first data point which may be different from the first + the visible data point if the plot is zoomed in. + + If zooming in on a plot when using float arguments then the actual + data points that have markers will change because the distance between + markers is always determined from the display-coordinates + axes-bounding-box-diagonal regardless of the actual axes data limits. + + """ + self._markevery = every + self.stale = True + + def get_markevery(self): + """ + Return the markevery setting for marker subsampling. + + See also `~.Line2D.set_markevery`. + """ + return self._markevery + + def set_picker(self, p): + """ + Set the event picker details for the line. + + Parameters + ---------- + p : float or callable[[Artist, Event], tuple[bool, dict]] + If a float, it is used as the pick radius in points. + """ + if not callable(p): + self.set_pickradius(p) + self._picker = p + + def get_bbox(self): + """Get the bounding box of this line.""" + bbox = Bbox([[0, 0], [0, 0]]) + bbox.update_from_data_xy(self.get_xydata()) + return bbox + + def get_window_extent(self, renderer=None): + bbox = Bbox([[0, 0], [0, 0]]) + trans_data_to_xy = self.get_transform().transform + bbox.update_from_data_xy(trans_data_to_xy(self.get_xydata()), + ignore=True) + # correct for marker size, if any + if self._marker: + ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5 + bbox = bbox.padded(ms) + return bbox + + def set_data(self, *args): + """ + Set the x and y data. + + Parameters + ---------- + *args : (2, N) array or two 1D arrays + + See Also + -------- + set_xdata + set_ydata + """ + if len(args) == 1: + (x, y), = args + else: + x, y = args + + self.set_xdata(x) + self.set_ydata(y) + + def recache_always(self): + self.recache(always=True) + + def recache(self, always=False): + if always or self._invalidx: + xconv = self.convert_xunits(self._xorig) + x = _to_unmasked_float_array(xconv).ravel() + else: + x = self._x + if always or self._invalidy: + yconv = self.convert_yunits(self._yorig) + y = _to_unmasked_float_array(yconv).ravel() + else: + y = self._y + + self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float) + self._x, self._y = self._xy.T # views + + self._subslice = False + if (self.axes + and len(x) > self._subslice_optim_min_size + and _path.is_sorted_and_has_non_nan(x) + and self.axes.name == 'rectilinear' + and self.axes.get_xscale() == 'linear' + and self._markevery is None + and self.get_clip_on() + and self.get_transform() == self.axes.transData): + self._subslice = True + nanmask = np.isnan(x) + if nanmask.any(): + self._x_filled = self._x.copy() + indices = np.arange(len(x)) + self._x_filled[nanmask] = np.interp( + indices[nanmask], indices[~nanmask], self._x[~nanmask]) + else: + self._x_filled = self._x + + if self._path is not None: + interpolation_steps = self._path._interpolation_steps + else: + interpolation_steps = 1 + xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy.T) + self._path = Path(np.asarray(xy).T, + _interpolation_steps=interpolation_steps) + self._transformed_path = None + self._invalidx = False + self._invalidy = False + + def _transform_path(self, subslice=None): + """ + Put a TransformedPath instance at self._transformed_path; + all invalidation of the transform is then handled by the + TransformedPath instance. + """ + # Masked arrays are now handled by the Path class itself + if subslice is not None: + xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T) + _path = Path(np.asarray(xy).T, + _interpolation_steps=self._path._interpolation_steps) + else: + _path = self._path + self._transformed_path = TransformedPath(_path, self.get_transform()) + + def _get_transformed_path(self): + """Return this line's `~matplotlib.transforms.TransformedPath`.""" + if self._transformed_path is None: + self._transform_path() + return self._transformed_path + + def set_transform(self, t): + # docstring inherited + self._invalidx = True + self._invalidy = True + super().set_transform(t) + + @allow_rasterization + def draw(self, renderer): + # docstring inherited + + if not self.get_visible(): + return + + if self._invalidy or self._invalidx: + self.recache() + self.ind_offset = 0 # Needed for contains() method. + if self._subslice and self.axes: + x0, x1 = self.axes.get_xbound() + i0 = self._x_filled.searchsorted(x0, 'left') + i1 = self._x_filled.searchsorted(x1, 'right') + subslice = slice(max(i0 - 1, 0), i1 + 1) + self.ind_offset = subslice.start + self._transform_path(subslice) + else: + subslice = None + + if self.get_path_effects(): + from matplotlib.patheffects import PathEffectRenderer + renderer = PathEffectRenderer(self.get_path_effects(), renderer) + + renderer.open_group('line2d', self.get_gid()) + if self._lineStyles[self._linestyle] != '_draw_nothing': + tpath, affine = (self._get_transformed_path() + .get_transformed_path_and_affine()) + if len(tpath.vertices): + gc = renderer.new_gc() + self._set_gc_clip(gc) + gc.set_url(self.get_url()) + + gc.set_antialiased(self._antialiased) + gc.set_linewidth(self._linewidth) + + if self.is_dashed(): + cap = self._dashcapstyle + join = self._dashjoinstyle + else: + cap = self._solidcapstyle + join = self._solidjoinstyle + gc.set_joinstyle(join) + gc.set_capstyle(cap) + gc.set_snap(self.get_snap()) + if self.get_sketch_params() is not None: + gc.set_sketch_params(*self.get_sketch_params()) + + # We first draw a path within the gaps if needed. + if self.is_dashed() and self._gapcolor is not None: + lc_rgba = mcolors.to_rgba(self._gapcolor, self._alpha) + gc.set_foreground(lc_rgba, isRGBA=True) + + offset_gaps, gaps = _get_inverse_dash_pattern( + *self._dash_pattern) + + gc.set_dashes(offset_gaps, gaps) + renderer.draw_path(gc, tpath, affine.frozen()) + + lc_rgba = mcolors.to_rgba(self._color, self._alpha) + gc.set_foreground(lc_rgba, isRGBA=True) + + gc.set_dashes(*self._dash_pattern) + renderer.draw_path(gc, tpath, affine.frozen()) + gc.restore() + + if self._marker and self._markersize > 0: + gc = renderer.new_gc() + self._set_gc_clip(gc) + gc.set_url(self.get_url()) + gc.set_linewidth(self._markeredgewidth) + gc.set_antialiased(self._antialiased) + + ec_rgba = mcolors.to_rgba( + self.get_markeredgecolor(), self._alpha) + fc_rgba = mcolors.to_rgba( + self._get_markerfacecolor(), self._alpha) + fcalt_rgba = mcolors.to_rgba( + self._get_markerfacecolor(alt=True), self._alpha) + # If the edgecolor is "auto", it is set according to the *line* + # color but inherits the alpha value of the *face* color, if any. + if (cbook._str_equal(self._markeredgecolor, "auto") + and not cbook._str_lower_equal( + self.get_markerfacecolor(), "none")): + ec_rgba = ec_rgba[:3] + (fc_rgba[3],) + gc.set_foreground(ec_rgba, isRGBA=True) + if self.get_sketch_params() is not None: + scale, length, randomness = self.get_sketch_params() + gc.set_sketch_params(scale/2, length/2, 2*randomness) + + marker = self._marker + + # Markers *must* be drawn ignoring the drawstyle (but don't pay the + # recaching if drawstyle is already "default"). + if self.get_drawstyle() != "default": + with cbook._setattr_cm( + self, _drawstyle="default", _transformed_path=None): + self.recache() + self._transform_path(subslice) + tpath, affine = (self._get_transformed_path() + .get_transformed_points_and_affine()) + else: + tpath, affine = (self._get_transformed_path() + .get_transformed_points_and_affine()) + + if len(tpath.vertices): + # subsample the markers if markevery is not None + markevery = self.get_markevery() + if markevery is not None: + subsampled = _mark_every_path( + markevery, tpath, affine, self.axes) + else: + subsampled = tpath + + snap = marker.get_snap_threshold() + if isinstance(snap, Real): + snap = renderer.points_to_pixels(self._markersize) >= snap + gc.set_snap(snap) + gc.set_joinstyle(marker.get_joinstyle()) + gc.set_capstyle(marker.get_capstyle()) + marker_path = marker.get_path() + marker_trans = marker.get_transform() + w = renderer.points_to_pixels(self._markersize) + + if cbook._str_equal(marker.get_marker(), ","): + gc.set_linewidth(0) + else: + # Don't scale for pixels, and don't stroke them + marker_trans = marker_trans.scale(w) + renderer.draw_markers(gc, marker_path, marker_trans, + subsampled, affine.frozen(), + fc_rgba) + + alt_marker_path = marker.get_alt_path() + if alt_marker_path: + alt_marker_trans = marker.get_alt_transform() + alt_marker_trans = alt_marker_trans.scale(w) + renderer.draw_markers( + gc, alt_marker_path, alt_marker_trans, subsampled, + affine.frozen(), fcalt_rgba) + + gc.restore() + + renderer.close_group('line2d') + self.stale = False + + def get_antialiased(self): + """Return whether antialiased rendering is used.""" + return self._antialiased + + def get_color(self): + """ + Return the line color. + + See also `~.Line2D.set_color`. + """ + return self._color + + def get_drawstyle(self): + """ + Return the drawstyle. + + See also `~.Line2D.set_drawstyle`. + """ + return self._drawstyle + + def get_gapcolor(self): + """ + Return the line gapcolor. + + See also `~.Line2D.set_gapcolor`. + """ + return self._gapcolor + + def get_linestyle(self): + """ + Return the linestyle. + + See also `~.Line2D.set_linestyle`. + """ + return self._linestyle + + def get_linewidth(self): + """ + Return the linewidth in points. + + See also `~.Line2D.set_linewidth`. + """ + return self._linewidth + + def get_marker(self): + """ + Return the line marker. + + See also `~.Line2D.set_marker`. + """ + return self._marker.get_marker() + + def get_markeredgecolor(self): + """ + Return the marker edge color. + + See also `~.Line2D.set_markeredgecolor`. + """ + mec = self._markeredgecolor + if cbook._str_equal(mec, 'auto'): + if mpl.rcParams['_internal.classic_mode']: + if self._marker.get_marker() in ('.', ','): + return self._color + if (self._marker.is_filled() + and self._marker.get_fillstyle() != 'none'): + return 'k' # Bad hard-wired default... + return self._color + else: + return mec + + def get_markeredgewidth(self): + """ + Return the marker edge width in points. + + See also `~.Line2D.set_markeredgewidth`. + """ + return self._markeredgewidth + + def _get_markerfacecolor(self, alt=False): + if self._marker.get_fillstyle() == 'none': + return 'none' + fc = self._markerfacecoloralt if alt else self._markerfacecolor + if cbook._str_lower_equal(fc, 'auto'): + return self._color + else: + return fc + + def get_markerfacecolor(self): + """ + Return the marker face color. + + See also `~.Line2D.set_markerfacecolor`. + """ + return self._get_markerfacecolor(alt=False) + + def get_markerfacecoloralt(self): + """ + Return the alternate marker face color. + + See also `~.Line2D.set_markerfacecoloralt`. + """ + return self._get_markerfacecolor(alt=True) + + def get_markersize(self): + """ + Return the marker size in points. + + See also `~.Line2D.set_markersize`. + """ + return self._markersize + + def get_data(self, orig=True): + """ + Return the line data as an ``(xdata, ydata)`` pair. + + If *orig* is *True*, return the original data. + """ + return self.get_xdata(orig=orig), self.get_ydata(orig=orig) + + def get_xdata(self, orig=True): + """ + Return the xdata. + + If *orig* is *True*, return the original data, else the + processed data. + """ + if orig: + return self._xorig + if self._invalidx: + self.recache() + return self._x + + def get_ydata(self, orig=True): + """ + Return the ydata. + + If *orig* is *True*, return the original data, else the + processed data. + """ + if orig: + return self._yorig + if self._invalidy: + self.recache() + return self._y + + def get_path(self): + """Return the `~matplotlib.path.Path` associated with this line.""" + if self._invalidy or self._invalidx: + self.recache() + return self._path + + def get_xydata(self): + """Return the *xy* data as a (N, 2) array.""" + if self._invalidy or self._invalidx: + self.recache() + return self._xy + + def set_antialiased(self, b): + """ + Set whether to use antialiased rendering. + + Parameters + ---------- + b : bool + """ + if self._antialiased != b: + self.stale = True + self._antialiased = b + + def set_color(self, color): + """ + Set the color of the line. + + Parameters + ---------- + color : :mpltype:`color` + """ + mcolors._check_color_like(color=color) + self._color = color + self.stale = True + + def set_drawstyle(self, drawstyle): + """ + Set the drawstyle of the plot. + + The drawstyle determines how the points are connected. + + Parameters + ---------- + drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', \ +'steps-post'}, default: 'default' + For 'default', the points are connected with straight lines. + + The steps variants connect the points with step-like lines, + i.e. horizontal lines with vertical steps. They differ in the + location of the step: + + - 'steps-pre': The step is at the beginning of the line segment, + i.e. the line will be at the y-value of point to the right. + - 'steps-mid': The step is halfway between the points. + - 'steps-post: The step is at the end of the line segment, + i.e. the line will be at the y-value of the point to the left. + - 'steps' is equal to 'steps-pre' and is maintained for + backward-compatibility. + + For examples see :doc:`/gallery/lines_bars_and_markers/step_demo`. + """ + if drawstyle is None: + drawstyle = 'default' + _api.check_in_list(self.drawStyles, drawstyle=drawstyle) + if self._drawstyle != drawstyle: + self.stale = True + # invalidate to trigger a recache of the path + self._invalidx = True + self._drawstyle = drawstyle + + def set_gapcolor(self, gapcolor): + """ + Set a color to fill the gaps in the dashed line style. + + .. note:: + + Striped lines are created by drawing two interleaved dashed lines. + There can be overlaps between those two, which may result in + artifacts when using transparency. + + This functionality is experimental and may change. + + Parameters + ---------- + gapcolor : :mpltype:`color` or None + The color with which to fill the gaps. If None, the gaps are + unfilled. + """ + if gapcolor is not None: + mcolors._check_color_like(color=gapcolor) + self._gapcolor = gapcolor + self.stale = True + + def set_linewidth(self, w): + """ + Set the line width in points. + + Parameters + ---------- + w : float + Line width, in points. + """ + w = float(w) + if self._linewidth != w: + self.stale = True + self._linewidth = w + self._dash_pattern = _scale_dashes(*self._unscaled_dash_pattern, w) + + def set_linestyle(self, ls): + """ + Set the linestyle of the line. + + Parameters + ---------- + ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} + Possible values: + + - A string: + + ========================================== ================= + linestyle description + ========================================== ================= + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing + ========================================== ================= + + - Alternatively a dash tuple of the following form can be + provided:: + + (offset, onoffseq) + + where ``onoffseq`` is an even length tuple of on and off ink + in points. See also :meth:`set_dashes`. + + For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`. + """ + if isinstance(ls, str): + if ls in [' ', '', 'none']: + ls = 'None' + _api.check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls) + if ls not in self._lineStyles: + ls = ls_mapper_r[ls] + self._linestyle = ls + else: + self._linestyle = '--' + self._unscaled_dash_pattern = _get_dash_pattern(ls) + self._dash_pattern = _scale_dashes( + *self._unscaled_dash_pattern, self._linewidth) + self.stale = True + + @_docstring.interpd + def set_marker(self, marker): + """ + Set the line marker. + + Parameters + ---------- + marker : marker style string, `~.path.Path` or `~.markers.MarkerStyle` + See `~matplotlib.markers` for full description of possible + arguments. + """ + self._marker = MarkerStyle(marker, self._marker.get_fillstyle()) + self.stale = True + + def _set_markercolor(self, name, has_rcdefault, val): + if val is None: + val = mpl.rcParams[f"lines.{name}"] if has_rcdefault else "auto" + attr = f"_{name}" + current = getattr(self, attr) + if current is None: + self.stale = True + else: + neq = current != val + # Much faster than `np.any(current != val)` if no arrays are used. + if neq.any() if isinstance(neq, np.ndarray) else neq: + self.stale = True + setattr(self, attr, val) + + def set_markeredgecolor(self, ec): + """ + Set the marker edge color. + + Parameters + ---------- + ec : :mpltype:`color` + """ + self._set_markercolor("markeredgecolor", True, ec) + + def set_markerfacecolor(self, fc): + """ + Set the marker face color. + + Parameters + ---------- + fc : :mpltype:`color` + """ + self._set_markercolor("markerfacecolor", True, fc) + + def set_markerfacecoloralt(self, fc): + """ + Set the alternate marker face color. + + Parameters + ---------- + fc : :mpltype:`color` + """ + self._set_markercolor("markerfacecoloralt", False, fc) + + def set_markeredgewidth(self, ew): + """ + Set the marker edge width in points. + + Parameters + ---------- + ew : float + Marker edge width, in points. + """ + if ew is None: + ew = mpl.rcParams['lines.markeredgewidth'] + if self._markeredgewidth != ew: + self.stale = True + self._markeredgewidth = ew + + def set_markersize(self, sz): + """ + Set the marker size in points. + + Parameters + ---------- + sz : float + Marker size, in points. + """ + sz = float(sz) + if self._markersize != sz: + self.stale = True + self._markersize = sz + + def set_xdata(self, x): + """ + Set the data array for x. + + Parameters + ---------- + x : 1D array + + See Also + -------- + set_data + set_ydata + """ + if not np.iterable(x): + raise RuntimeError('x must be a sequence') + self._xorig = copy.copy(x) + self._invalidx = True + self.stale = True + + def set_ydata(self, y): + """ + Set the data array for y. + + Parameters + ---------- + y : 1D array + + See Also + -------- + set_data + set_xdata + """ + if not np.iterable(y): + raise RuntimeError('y must be a sequence') + self._yorig = copy.copy(y) + self._invalidy = True + self.stale = True + + def set_dashes(self, seq): + """ + Set the dash sequence. + + The dash sequence is a sequence of floats of even length describing + the length of dashes and spaces in points. + + For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point + dashes separated by 2 point spaces. + + See also `~.Line2D.set_gapcolor`, which allows those spaces to be + filled with a color. + + Parameters + ---------- + seq : sequence of floats (on/off ink in points) or (None, None) + If *seq* is empty or ``(None, None)``, the linestyle will be set + to solid. + """ + if seq == (None, None) or len(seq) == 0: + self.set_linestyle('-') + else: + self.set_linestyle((0, seq)) + + def update_from(self, other): + """Copy properties from *other* to self.""" + super().update_from(other) + self._linestyle = other._linestyle + self._linewidth = other._linewidth + self._color = other._color + self._gapcolor = other._gapcolor + self._markersize = other._markersize + self._markerfacecolor = other._markerfacecolor + self._markerfacecoloralt = other._markerfacecoloralt + self._markeredgecolor = other._markeredgecolor + self._markeredgewidth = other._markeredgewidth + self._unscaled_dash_pattern = other._unscaled_dash_pattern + self._dash_pattern = other._dash_pattern + self._dashcapstyle = other._dashcapstyle + self._dashjoinstyle = other._dashjoinstyle + self._solidcapstyle = other._solidcapstyle + self._solidjoinstyle = other._solidjoinstyle + + self._linestyle = other._linestyle + self._marker = MarkerStyle(marker=other._marker) + self._drawstyle = other._drawstyle + + @_docstring.interpd + def set_dash_joinstyle(self, s): + """ + How to join segments of the line if it `~Line2D.is_dashed`. + + The default joinstyle is :rc:`lines.dash_joinstyle`. + + Parameters + ---------- + s : `.JoinStyle` or %(JoinStyle)s + """ + js = JoinStyle(s) + if self._dashjoinstyle != js: + self.stale = True + self._dashjoinstyle = js + + @_docstring.interpd + def set_solid_joinstyle(self, s): + """ + How to join segments if the line is solid (not `~Line2D.is_dashed`). + + The default joinstyle is :rc:`lines.solid_joinstyle`. + + Parameters + ---------- + s : `.JoinStyle` or %(JoinStyle)s + """ + js = JoinStyle(s) + if self._solidjoinstyle != js: + self.stale = True + self._solidjoinstyle = js + + def get_dash_joinstyle(self): + """ + Return the `.JoinStyle` for dashed lines. + + See also `~.Line2D.set_dash_joinstyle`. + """ + return self._dashjoinstyle.name + + def get_solid_joinstyle(self): + """ + Return the `.JoinStyle` for solid lines. + + See also `~.Line2D.set_solid_joinstyle`. + """ + return self._solidjoinstyle.name + + @_docstring.interpd + def set_dash_capstyle(self, s): + """ + How to draw the end caps if the line is `~Line2D.is_dashed`. + + The default capstyle is :rc:`lines.dash_capstyle`. + + Parameters + ---------- + s : `.CapStyle` or %(CapStyle)s + """ + cs = CapStyle(s) + if self._dashcapstyle != cs: + self.stale = True + self._dashcapstyle = cs + + @_docstring.interpd + def set_solid_capstyle(self, s): + """ + How to draw the end caps if the line is solid (not `~Line2D.is_dashed`) + + The default capstyle is :rc:`lines.solid_capstyle`. + + Parameters + ---------- + s : `.CapStyle` or %(CapStyle)s + """ + cs = CapStyle(s) + if self._solidcapstyle != cs: + self.stale = True + self._solidcapstyle = cs + + def get_dash_capstyle(self): + """ + Return the `.CapStyle` for dashed lines. + + See also `~.Line2D.set_dash_capstyle`. + """ + return self._dashcapstyle.name + + def get_solid_capstyle(self): + """ + Return the `.CapStyle` for solid lines. + + See also `~.Line2D.set_solid_capstyle`. + """ + return self._solidcapstyle.name + + def is_dashed(self): + """ + Return whether line has a dashed linestyle. + + A custom linestyle is assumed to be dashed, we do not inspect the + ``onoffseq`` directly. + + See also `~.Line2D.set_linestyle`. + """ + return self._linestyle in ('--', '-.', ':') + + +class AxLine(Line2D): + """ + A helper class that implements `~.Axes.axline`, by recomputing the artist + transform at draw time. + """ + + def __init__(self, xy1, xy2, slope, **kwargs): + """ + Parameters + ---------- + xy1 : (float, float) + The first set of (x, y) coordinates for the line to pass through. + xy2 : (float, float) or None + The second set of (x, y) coordinates for the line to pass through. + Both *xy2* and *slope* must be passed, but one of them must be None. + slope : float or None + The slope of the line. Both *xy2* and *slope* must be passed, but one of + them must be None. + """ + super().__init__([0, 1], [0, 1], **kwargs) + + if (xy2 is None and slope is None or + xy2 is not None and slope is not None): + raise TypeError( + "Exactly one of 'xy2' and 'slope' must be given") + + self._slope = slope + self._xy1 = xy1 + self._xy2 = xy2 + + def get_transform(self): + ax = self.axes + points_transform = self._transform - ax.transData + ax.transScale + + if self._xy2 is not None: + # two points were given + (x1, y1), (x2, y2) = \ + points_transform.transform([self._xy1, self._xy2]) + dx = x2 - x1 + dy = y2 - y1 + if np.allclose(x1, x2): + if np.allclose(y1, y2): + raise ValueError( + f"Cannot draw a line through two identical points " + f"(x={(x1, x2)}, y={(y1, y2)})") + slope = np.inf + else: + slope = dy / dx + else: + # one point and a slope were given + x1, y1 = points_transform.transform(self._xy1) + slope = self._slope + (vxlo, vylo), (vxhi, vyhi) = ax.transScale.transform(ax.viewLim) + # General case: find intersections with view limits in either + # direction, and draw between the middle two points. + if np.isclose(slope, 0): + start = vxlo, y1 + stop = vxhi, y1 + elif np.isinf(slope): + start = x1, vylo + stop = x1, vyhi + else: + _, start, stop, _ = sorted([ + (vxlo, y1 + (vxlo - x1) * slope), + (vxhi, y1 + (vxhi - x1) * slope), + (x1 + (vylo - y1) / slope, vylo), + (x1 + (vyhi - y1) / slope, vyhi), + ]) + return (BboxTransformTo(Bbox([start, stop])) + + ax.transLimits + ax.transAxes) + + def draw(self, renderer): + self._transformed_path = None # Force regen. + super().draw(renderer) + + def get_xy1(self): + """ + Return the *xy1* value of the line. + """ + return self._xy1 + + def get_xy2(self): + """ + Return the *xy2* value of the line. + """ + return self._xy2 + + def get_slope(self): + """ + Return the *slope* value of the line. + """ + return self._slope + + def set_xy1(self, x, y): + """ + Set the *xy1* value of the line. + + Parameters + ---------- + x, y : float + Points for the line to pass through. + """ + self._xy1 = x, y + + def set_xy2(self, x, y): + """ + Set the *xy2* value of the line. + + Parameters + ---------- + x, y : float + Points for the line to pass through. + """ + if self._slope is None: + self._xy2 = x, y + else: + raise ValueError("Cannot set an 'xy2' value while 'slope' is set;" + " they differ but their functionalities overlap") + + def set_slope(self, slope): + """ + Set the *slope* value of the line. + + Parameters + ---------- + slope : float + The slope of the line. + """ + if self._xy2 is None: + self._slope = slope + else: + raise ValueError("Cannot set a 'slope' value while 'xy2' is set;" + " they differ but their functionalities overlap") + + +class VertexSelector: + """ + Manage the callbacks to maintain a list of selected vertices for `.Line2D`. + Derived classes should override the `process_selected` method to do + something with the picks. + + Here is an example which highlights the selected verts with red circles:: + + import numpy as np + import matplotlib.pyplot as plt + import matplotlib.lines as lines + + class HighlightSelected(lines.VertexSelector): + def __init__(self, line, fmt='ro', **kwargs): + super().__init__(line) + self.markers, = self.axes.plot([], [], fmt, **kwargs) + + def process_selected(self, ind, xs, ys): + self.markers.set_data(xs, ys) + self.canvas.draw() + + fig, ax = plt.subplots() + x, y = np.random.rand(2, 30) + line, = ax.plot(x, y, 'bs-', picker=5) + + selector = HighlightSelected(line) + plt.show() + """ + + def __init__(self, line): + """ + Parameters + ---------- + line : `~matplotlib.lines.Line2D` + The line must already have been added to an `~.axes.Axes` and must + have its picker property set. + """ + if line.axes is None: + raise RuntimeError('You must first add the line to the Axes') + if line.get_picker() is None: + raise RuntimeError('You must first set the picker property ' + 'of the line') + self.axes = line.axes + self.line = line + self.cid = self.canvas.callbacks._connect_picklable( + 'pick_event', self.onpick) + self.ind = set() + + canvas = property(lambda self: self.axes.figure.canvas) + + def process_selected(self, ind, xs, ys): + """ + Default "do nothing" implementation of the `process_selected` method. + + Parameters + ---------- + ind : list of int + The indices of the selected vertices. + xs, ys : array-like + The coordinates of the selected vertices. + """ + pass + + def onpick(self, event): + """When the line is picked, update the set of selected indices.""" + if event.artist is not self.line: + return + self.ind ^= set(event.ind) + ind = sorted(self.ind) + xdata, ydata = self.line.get_data() + self.process_selected(ind, xdata[ind], ydata[ind]) + + +lineStyles = Line2D._lineStyles +lineMarkers = MarkerStyle.markers +drawStyles = Line2D.drawStyles +fillStyles = MarkerStyle.fillstyles diff --git a/venv/lib/python3.10/site-packages/matplotlib/lines.pyi b/venv/lib/python3.10/site-packages/matplotlib/lines.pyi new file mode 100644 index 00000000..c91e457e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/lines.pyi @@ -0,0 +1,153 @@ +from .artist import Artist +from .axes import Axes +from .backend_bases import MouseEvent, FigureCanvasBase +from .path import Path +from .transforms import Bbox, Transform + +from collections.abc import Callable, Sequence +from typing import Any, Literal, overload +from .typing import ( + ColorType, + DrawStyleType, + FillStyleType, + LineStyleType, + CapStyleType, + JoinStyleType, + MarkEveryType, + MarkerType, +) +from numpy.typing import ArrayLike + +def segment_hits( + cx: ArrayLike, cy: ArrayLike, x: ArrayLike, y: ArrayLike, radius: ArrayLike +) -> ArrayLike: ... + +class Line2D(Artist): + lineStyles: dict[str, str] + drawStyles: dict[str, str] + drawStyleKeys: list[str] + markers: dict[str | int, str] + filled_markers: tuple[str, ...] + fillStyles: tuple[str, ...] + zorder: float + ind_offset: float + def __init__( + self, + xdata: ArrayLike, + ydata: ArrayLike, + *, + linewidth: float | None = ..., + linestyle: LineStyleType | None = ..., + color: ColorType | None = ..., + gapcolor: ColorType | None = ..., + marker: MarkerType | None = ..., + markersize: float | None = ..., + markeredgewidth: float | None = ..., + markeredgecolor: ColorType | None = ..., + markerfacecolor: ColorType | None = ..., + markerfacecoloralt: ColorType = ..., + fillstyle: FillStyleType | None = ..., + antialiased: bool | None = ..., + dash_capstyle: CapStyleType | None = ..., + solid_capstyle: CapStyleType | None = ..., + dash_joinstyle: JoinStyleType | None = ..., + solid_joinstyle: JoinStyleType | None = ..., + pickradius: float = ..., + drawstyle: DrawStyleType | None = ..., + markevery: MarkEveryType | None = ..., + **kwargs + ) -> None: ... + def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict]: ... + def get_pickradius(self) -> float: ... + def set_pickradius(self, pickradius: float) -> None: ... + pickradius: float + def get_fillstyle(self) -> FillStyleType: ... + stale: bool + def set_fillstyle(self, fs: FillStyleType) -> None: ... + def set_markevery(self, every: MarkEveryType) -> None: ... + def get_markevery(self) -> MarkEveryType: ... + def set_picker( + self, p: None | bool | float | Callable[[Artist, MouseEvent], tuple[bool, dict]] + ) -> None: ... + def get_bbox(self) -> Bbox: ... + @overload + def set_data(self, args: ArrayLike) -> None: ... + @overload + def set_data(self, x: ArrayLike, y: ArrayLike) -> None: ... + def recache_always(self) -> None: ... + def recache(self, always: bool = ...) -> None: ... + def get_antialiased(self) -> bool: ... + def get_color(self) -> ColorType: ... + def get_drawstyle(self) -> DrawStyleType: ... + def get_gapcolor(self) -> ColorType: ... + def get_linestyle(self) -> LineStyleType: ... + def get_linewidth(self) -> float: ... + def get_marker(self) -> MarkerType: ... + def get_markeredgecolor(self) -> ColorType: ... + def get_markeredgewidth(self) -> float: ... + def get_markerfacecolor(self) -> ColorType: ... + def get_markerfacecoloralt(self) -> ColorType: ... + def get_markersize(self) -> float: ... + def get_data(self, orig: bool = ...) -> tuple[ArrayLike, ArrayLike]: ... + def get_xdata(self, orig: bool = ...) -> ArrayLike: ... + def get_ydata(self, orig: bool = ...) -> ArrayLike: ... + def get_path(self) -> Path: ... + def get_xydata(self) -> ArrayLike: ... + def set_antialiased(self, b: bool) -> None: ... + def set_color(self, color: ColorType) -> None: ... + def set_drawstyle(self, drawstyle: DrawStyleType | None) -> None: ... + def set_gapcolor(self, gapcolor: ColorType | None) -> None: ... + def set_linewidth(self, w: float) -> None: ... + def set_linestyle(self, ls: LineStyleType) -> None: ... + def set_marker(self, marker: MarkerType) -> None: ... + def set_markeredgecolor(self, ec: ColorType | None) -> None: ... + def set_markerfacecolor(self, fc: ColorType | None) -> None: ... + def set_markerfacecoloralt(self, fc: ColorType | None) -> None: ... + def set_markeredgewidth(self, ew: float | None) -> None: ... + def set_markersize(self, sz: float) -> None: ... + def set_xdata(self, x: ArrayLike) -> None: ... + def set_ydata(self, y: ArrayLike) -> None: ... + def set_dashes(self, seq: Sequence[float] | tuple[None, None]) -> None: ... + def update_from(self, other: Artist) -> None: ... + def set_dash_joinstyle(self, s: JoinStyleType) -> None: ... + def set_solid_joinstyle(self, s: JoinStyleType) -> None: ... + def get_dash_joinstyle(self) -> Literal["miter", "round", "bevel"]: ... + def get_solid_joinstyle(self) -> Literal["miter", "round", "bevel"]: ... + def set_dash_capstyle(self, s: CapStyleType) -> None: ... + def set_solid_capstyle(self, s: CapStyleType) -> None: ... + def get_dash_capstyle(self) -> Literal["butt", "projecting", "round"]: ... + def get_solid_capstyle(self) -> Literal["butt", "projecting", "round"]: ... + def is_dashed(self) -> bool: ... + +class AxLine(Line2D): + def __init__( + self, + xy1: tuple[float, float], + xy2: tuple[float, float] | None, + slope: float | None, + **kwargs + ) -> None: ... + def get_xy1(self) -> tuple[float, float] | None: ... + def get_xy2(self) -> tuple[float, float] | None: ... + def get_slope(self) -> float: ... + def set_xy1(self, x: float, y: float) -> None: ... + def set_xy2(self, x: float, y: float) -> None: ... + def set_slope(self, slope: float) -> None: ... + +class VertexSelector: + axes: Axes + line: Line2D + cid: int + ind: set[int] + def __init__(self, line: Line2D) -> None: ... + @property + def canvas(self) -> FigureCanvasBase: ... + def process_selected( + self, ind: Sequence[int], xs: ArrayLike, ys: ArrayLike + ) -> None: ... + def onpick(self, event: Any) -> None: ... + +lineStyles: dict[str, str] +lineMarkers: dict[str | int, str] +drawStyles: dict[str, str] +fillStyles: tuple[FillStyleType, ...] diff --git a/venv/lib/python3.10/site-packages/matplotlib/markers.py b/venv/lib/python3.10/site-packages/matplotlib/markers.py new file mode 100644 index 00000000..fa5e66e7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/markers.py @@ -0,0 +1,908 @@ +r""" +Functions to handle markers; used by the marker functionality of +`~matplotlib.axes.Axes.plot`, `~matplotlib.axes.Axes.scatter`, and +`~matplotlib.axes.Axes.errorbar`. + +All possible markers are defined here: + +============================== ====== ========================================= +marker symbol description +============================== ====== ========================================= +``"."`` |m00| point +``","`` |m01| pixel +``"o"`` |m02| circle +``"v"`` |m03| triangle_down +``"^"`` |m04| triangle_up +``"<"`` |m05| triangle_left +``">"`` |m06| triangle_right +``"1"`` |m07| tri_down +``"2"`` |m08| tri_up +``"3"`` |m09| tri_left +``"4"`` |m10| tri_right +``"8"`` |m11| octagon +``"s"`` |m12| square +``"p"`` |m13| pentagon +``"P"`` |m23| plus (filled) +``"*"`` |m14| star +``"h"`` |m15| hexagon1 +``"H"`` |m16| hexagon2 +``"+"`` |m17| plus +``"x"`` |m18| x +``"X"`` |m24| x (filled) +``"D"`` |m19| diamond +``"d"`` |m20| thin_diamond +``"|"`` |m21| vline +``"_"`` |m22| hline +``0`` (``TICKLEFT``) |m25| tickleft +``1`` (``TICKRIGHT``) |m26| tickright +``2`` (``TICKUP``) |m27| tickup +``3`` (``TICKDOWN``) |m28| tickdown +``4`` (``CARETLEFT``) |m29| caretleft +``5`` (``CARETRIGHT``) |m30| caretright +``6`` (``CARETUP``) |m31| caretup +``7`` (``CARETDOWN``) |m32| caretdown +``8`` (``CARETLEFTBASE``) |m33| caretleft (centered at base) +``9`` (``CARETRIGHTBASE``) |m34| caretright (centered at base) +``10`` (``CARETUPBASE``) |m35| caretup (centered at base) +``11`` (``CARETDOWNBASE``) |m36| caretdown (centered at base) +``"none"`` or ``"None"`` nothing +``" "`` or ``""`` nothing +``"$...$"`` |m37| Render the string using mathtext. + E.g ``"$f$"`` for marker showing the + letter ``f``. +``verts`` A list of (x, y) pairs used for Path + vertices. The center of the marker is + located at (0, 0) and the size is + normalized, such that the created path + is encapsulated inside the unit cell. +``path`` A `~matplotlib.path.Path` instance. +``(numsides, 0, angle)`` A regular polygon with ``numsides`` + sides, rotated by ``angle``. +``(numsides, 1, angle)`` A star-like symbol with ``numsides`` + sides, rotated by ``angle``. +``(numsides, 2, angle)`` An asterisk with ``numsides`` sides, + rotated by ``angle``. +============================== ====== ========================================= + +Note that special symbols can be defined via the +:ref:`STIX math font `, +e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer to the +`STIX font table `_. +Also see the :doc:`/gallery/text_labels_and_annotations/stix_fonts_demo`. + +Integer numbers from ``0`` to ``11`` create lines and triangles. Those are +equally accessible via capitalized variables, like ``CARETDOWNBASE``. +Hence the following are equivalent:: + + plt.plot([1, 2, 3], marker=11) + plt.plot([1, 2, 3], marker=matplotlib.markers.CARETDOWNBASE) + +Markers join and cap styles can be customized by creating a new instance of +MarkerStyle. +A MarkerStyle can also have a custom `~matplotlib.transforms.Transform` +allowing it to be arbitrarily rotated or offset. + +Examples showing the use of markers: + +* :doc:`/gallery/lines_bars_and_markers/marker_reference` +* :doc:`/gallery/lines_bars_and_markers/scatter_star_poly` +* :doc:`/gallery/lines_bars_and_markers/multivariate_marker_plot` + +.. |m00| image:: /_static/markers/m00.png +.. |m01| image:: /_static/markers/m01.png +.. |m02| image:: /_static/markers/m02.png +.. |m03| image:: /_static/markers/m03.png +.. |m04| image:: /_static/markers/m04.png +.. |m05| image:: /_static/markers/m05.png +.. |m06| image:: /_static/markers/m06.png +.. |m07| image:: /_static/markers/m07.png +.. |m08| image:: /_static/markers/m08.png +.. |m09| image:: /_static/markers/m09.png +.. |m10| image:: /_static/markers/m10.png +.. |m11| image:: /_static/markers/m11.png +.. |m12| image:: /_static/markers/m12.png +.. |m13| image:: /_static/markers/m13.png +.. |m14| image:: /_static/markers/m14.png +.. |m15| image:: /_static/markers/m15.png +.. |m16| image:: /_static/markers/m16.png +.. |m17| image:: /_static/markers/m17.png +.. |m18| image:: /_static/markers/m18.png +.. |m19| image:: /_static/markers/m19.png +.. |m20| image:: /_static/markers/m20.png +.. |m21| image:: /_static/markers/m21.png +.. |m22| image:: /_static/markers/m22.png +.. |m23| image:: /_static/markers/m23.png +.. |m24| image:: /_static/markers/m24.png +.. |m25| image:: /_static/markers/m25.png +.. |m26| image:: /_static/markers/m26.png +.. |m27| image:: /_static/markers/m27.png +.. |m28| image:: /_static/markers/m28.png +.. |m29| image:: /_static/markers/m29.png +.. |m30| image:: /_static/markers/m30.png +.. |m31| image:: /_static/markers/m31.png +.. |m32| image:: /_static/markers/m32.png +.. |m33| image:: /_static/markers/m33.png +.. |m34| image:: /_static/markers/m34.png +.. |m35| image:: /_static/markers/m35.png +.. |m36| image:: /_static/markers/m36.png +.. |m37| image:: /_static/markers/m37.png +""" +import copy + +from collections.abc import Sized + +import numpy as np + +import matplotlib as mpl +from . import _api, cbook +from .path import Path +from .transforms import IdentityTransform, Affine2D +from ._enums import JoinStyle, CapStyle + +# special-purpose marker identifiers: +(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN, + CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN, + CARETLEFTBASE, CARETRIGHTBASE, CARETUPBASE, CARETDOWNBASE) = range(12) + +_empty_path = Path(np.empty((0, 2))) + + +class MarkerStyle: + """ + A class representing marker types. + + Instances are immutable. If you need to change anything, create a new + instance. + + Attributes + ---------- + markers : dict + All known markers. + filled_markers : tuple + All known filled markers. This is a subset of *markers*. + fillstyles : tuple + The supported fillstyles. + """ + + markers = { + '.': 'point', + ',': 'pixel', + 'o': 'circle', + 'v': 'triangle_down', + '^': 'triangle_up', + '<': 'triangle_left', + '>': 'triangle_right', + '1': 'tri_down', + '2': 'tri_up', + '3': 'tri_left', + '4': 'tri_right', + '8': 'octagon', + 's': 'square', + 'p': 'pentagon', + '*': 'star', + 'h': 'hexagon1', + 'H': 'hexagon2', + '+': 'plus', + 'x': 'x', + 'D': 'diamond', + 'd': 'thin_diamond', + '|': 'vline', + '_': 'hline', + 'P': 'plus_filled', + 'X': 'x_filled', + TICKLEFT: 'tickleft', + TICKRIGHT: 'tickright', + TICKUP: 'tickup', + TICKDOWN: 'tickdown', + CARETLEFT: 'caretleft', + CARETRIGHT: 'caretright', + CARETUP: 'caretup', + CARETDOWN: 'caretdown', + CARETLEFTBASE: 'caretleftbase', + CARETRIGHTBASE: 'caretrightbase', + CARETUPBASE: 'caretupbase', + CARETDOWNBASE: 'caretdownbase', + "None": 'nothing', + "none": 'nothing', + ' ': 'nothing', + '': 'nothing' + } + + # Just used for informational purposes. is_filled() + # is calculated in the _set_* functions. + filled_markers = ( + '.', 'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', + 'P', 'X') + + fillstyles = ('full', 'left', 'right', 'bottom', 'top', 'none') + _half_fillstyles = ('left', 'right', 'bottom', 'top') + + def __init__(self, marker, + fillstyle=None, transform=None, capstyle=None, joinstyle=None): + """ + Parameters + ---------- + marker : str, array-like, Path, MarkerStyle + - Another instance of `MarkerStyle` copies the details of that *marker*. + - For other possible marker values, see the module docstring + `matplotlib.markers`. + + fillstyle : str, default: :rc:`markers.fillstyle` + One of 'full', 'left', 'right', 'bottom', 'top', 'none'. + + transform : `~matplotlib.transforms.Transform`, optional + Transform that will be combined with the native transform of the + marker. + + capstyle : `.CapStyle` or %(CapStyle)s, optional + Cap style that will override the default cap style of the marker. + + joinstyle : `.JoinStyle` or %(JoinStyle)s, optional + Join style that will override the default join style of the marker. + """ + self._marker_function = None + self._user_transform = transform + self._user_capstyle = CapStyle(capstyle) if capstyle is not None else None + self._user_joinstyle = JoinStyle(joinstyle) if joinstyle is not None else None + self._set_fillstyle(fillstyle) + self._set_marker(marker) + + def _recache(self): + if self._marker_function is None: + return + self._path = _empty_path + self._transform = IdentityTransform() + self._alt_path = None + self._alt_transform = None + self._snap_threshold = None + self._joinstyle = JoinStyle.round + self._capstyle = self._user_capstyle or CapStyle.butt + # Initial guess: Assume the marker is filled unless the fillstyle is + # set to 'none'. The marker function will override this for unfilled + # markers. + self._filled = self._fillstyle != 'none' + self._marker_function() + + def __bool__(self): + return bool(len(self._path.vertices)) + + def is_filled(self): + return self._filled + + def get_fillstyle(self): + return self._fillstyle + + def _set_fillstyle(self, fillstyle): + """ + Set the fillstyle. + + Parameters + ---------- + fillstyle : {'full', 'left', 'right', 'bottom', 'top', 'none'} + The part of the marker surface that is colored with + markerfacecolor. + """ + if fillstyle is None: + fillstyle = mpl.rcParams['markers.fillstyle'] + _api.check_in_list(self.fillstyles, fillstyle=fillstyle) + self._fillstyle = fillstyle + + def get_joinstyle(self): + return self._joinstyle.name + + def get_capstyle(self): + return self._capstyle.name + + def get_marker(self): + return self._marker + + def _set_marker(self, marker): + """ + Set the marker. + + Parameters + ---------- + marker : str, array-like, Path, MarkerStyle + - Another instance of `MarkerStyle` copies the details of that *marker*. + - For other possible marker values see the module docstring + `matplotlib.markers`. + """ + if isinstance(marker, str) and cbook.is_math_text(marker): + self._marker_function = self._set_mathtext_path + elif isinstance(marker, (int, str)) and marker in self.markers: + self._marker_function = getattr(self, '_set_' + self.markers[marker]) + elif (isinstance(marker, np.ndarray) and marker.ndim == 2 and + marker.shape[1] == 2): + self._marker_function = self._set_vertices + elif isinstance(marker, Path): + self._marker_function = self._set_path_marker + elif (isinstance(marker, Sized) and len(marker) in (2, 3) and + marker[1] in (0, 1, 2)): + self._marker_function = self._set_tuple_marker + elif isinstance(marker, MarkerStyle): + self.__dict__ = copy.deepcopy(marker.__dict__) + else: + try: + Path(marker) + self._marker_function = self._set_vertices + except ValueError as err: + raise ValueError( + f'Unrecognized marker style {marker!r}') from err + + if not isinstance(marker, MarkerStyle): + self._marker = marker + self._recache() + + def get_path(self): + """ + Return a `.Path` for the primary part of the marker. + + For unfilled markers this is the whole marker, for filled markers, + this is the area to be drawn with *markerfacecolor*. + """ + return self._path + + def get_transform(self): + """ + Return the transform to be applied to the `.Path` from + `MarkerStyle.get_path()`. + """ + if self._user_transform is None: + return self._transform.frozen() + else: + return (self._transform + self._user_transform).frozen() + + def get_alt_path(self): + """ + Return a `.Path` for the alternate part of the marker. + + For unfilled markers, this is *None*; for filled markers, this is the + area to be drawn with *markerfacecoloralt*. + """ + return self._alt_path + + def get_alt_transform(self): + """ + Return the transform to be applied to the `.Path` from + `MarkerStyle.get_alt_path()`. + """ + if self._user_transform is None: + return self._alt_transform.frozen() + else: + return (self._alt_transform + self._user_transform).frozen() + + def get_snap_threshold(self): + return self._snap_threshold + + def get_user_transform(self): + """Return user supplied part of marker transform.""" + if self._user_transform is not None: + return self._user_transform.frozen() + + def transformed(self, transform): + """ + Return a new version of this marker with the transform applied. + + Parameters + ---------- + transform : `~matplotlib.transforms.Affine2D` + Transform will be combined with current user supplied transform. + """ + new_marker = MarkerStyle(self) + if new_marker._user_transform is not None: + new_marker._user_transform += transform + else: + new_marker._user_transform = transform + return new_marker + + def rotated(self, *, deg=None, rad=None): + """ + Return a new version of this marker rotated by specified angle. + + Parameters + ---------- + deg : float, optional + Rotation angle in degrees. + + rad : float, optional + Rotation angle in radians. + + .. note:: You must specify exactly one of deg or rad. + """ + if deg is None and rad is None: + raise ValueError('One of deg or rad is required') + if deg is not None and rad is not None: + raise ValueError('Only one of deg and rad can be supplied') + new_marker = MarkerStyle(self) + if new_marker._user_transform is None: + new_marker._user_transform = Affine2D() + + if deg is not None: + new_marker._user_transform.rotate_deg(deg) + if rad is not None: + new_marker._user_transform.rotate(rad) + + return new_marker + + def scaled(self, sx, sy=None): + """ + Return new marker scaled by specified scale factors. + + If *sy* is not given, the same scale is applied in both the *x*- and + *y*-directions. + + Parameters + ---------- + sx : float + *X*-direction scaling factor. + sy : float, optional + *Y*-direction scaling factor. + """ + if sy is None: + sy = sx + + new_marker = MarkerStyle(self) + _transform = new_marker._user_transform or Affine2D() + new_marker._user_transform = _transform.scale(sx, sy) + return new_marker + + def _set_nothing(self): + self._filled = False + + def _set_custom_marker(self, path): + rescale = np.max(np.abs(path.vertices)) # max of x's and y's. + self._transform = Affine2D().scale(0.5 / rescale) + self._path = path + + def _set_path_marker(self): + self._set_custom_marker(self._marker) + + def _set_vertices(self): + self._set_custom_marker(Path(self._marker)) + + def _set_tuple_marker(self): + marker = self._marker + if len(marker) == 2: + numsides, rotation = marker[0], 0.0 + elif len(marker) == 3: + numsides, rotation = marker[0], marker[2] + symstyle = marker[1] + if symstyle == 0: + self._path = Path.unit_regular_polygon(numsides) + self._joinstyle = self._user_joinstyle or JoinStyle.miter + elif symstyle == 1: + self._path = Path.unit_regular_star(numsides) + self._joinstyle = self._user_joinstyle or JoinStyle.bevel + elif symstyle == 2: + self._path = Path.unit_regular_asterisk(numsides) + self._filled = False + self._joinstyle = self._user_joinstyle or JoinStyle.bevel + else: + raise ValueError(f"Unexpected tuple marker: {marker}") + self._transform = Affine2D().scale(0.5).rotate_deg(rotation) + + def _set_mathtext_path(self): + """ + Draw mathtext markers '$...$' using `.TextPath` object. + + Submitted by tcb + """ + from matplotlib.text import TextPath + + # again, the properties could be initialised just once outside + # this function + text = TextPath(xy=(0, 0), s=self.get_marker(), + usetex=mpl.rcParams['text.usetex']) + if len(text.vertices) == 0: + return + + bbox = text.get_extents() + max_dim = max(bbox.width, bbox.height) + self._transform = ( + Affine2D() + .translate(-bbox.xmin + 0.5 * -bbox.width, -bbox.ymin + 0.5 * -bbox.height) + .scale(1.0 / max_dim)) + self._path = text + self._snap = False + + def _half_fill(self): + return self.get_fillstyle() in self._half_fillstyles + + def _set_circle(self, size=1.0): + self._transform = Affine2D().scale(0.5 * size) + self._snap_threshold = np.inf + if not self._half_fill(): + self._path = Path.unit_circle() + else: + self._path = self._alt_path = Path.unit_circle_righthalf() + fs = self.get_fillstyle() + self._transform.rotate_deg( + {'right': 0, 'top': 90, 'left': 180, 'bottom': 270}[fs]) + self._alt_transform = self._transform.frozen().rotate_deg(180.) + + def _set_point(self): + self._set_circle(size=0.5) + + def _set_pixel(self): + self._path = Path.unit_rectangle() + # Ideally, you'd want -0.5, -0.5 here, but then the snapping + # algorithm in the Agg backend will round this to a 2x2 + # rectangle from (-1, -1) to (1, 1). By offsetting it + # slightly, we can force it to be (0, 0) to (1, 1), which both + # makes it only be a single pixel and places it correctly + # aligned to 1-width stroking (i.e. the ticks). This hack is + # the best of a number of bad alternatives, mainly because the + # backends are not aware of what marker is actually being used + # beyond just its path data. + self._transform = Affine2D().translate(-0.49999, -0.49999) + self._snap_threshold = None + + _triangle_path = Path._create_closed([[0, 1], [-1, -1], [1, -1]]) + # Going down halfway looks to small. Golden ratio is too far. + _triangle_path_u = Path._create_closed([[0, 1], [-3/5, -1/5], [3/5, -1/5]]) + _triangle_path_d = Path._create_closed( + [[-3/5, -1/5], [3/5, -1/5], [1, -1], [-1, -1]]) + _triangle_path_l = Path._create_closed([[0, 1], [0, -1], [-1, -1]]) + _triangle_path_r = Path._create_closed([[0, 1], [0, -1], [1, -1]]) + + def _set_triangle(self, rot, skip): + self._transform = Affine2D().scale(0.5).rotate_deg(rot) + self._snap_threshold = 5.0 + + if not self._half_fill(): + self._path = self._triangle_path + else: + mpaths = [self._triangle_path_u, + self._triangle_path_l, + self._triangle_path_d, + self._triangle_path_r] + + fs = self.get_fillstyle() + if fs == 'top': + self._path = mpaths[(0 + skip) % 4] + self._alt_path = mpaths[(2 + skip) % 4] + elif fs == 'bottom': + self._path = mpaths[(2 + skip) % 4] + self._alt_path = mpaths[(0 + skip) % 4] + elif fs == 'left': + self._path = mpaths[(1 + skip) % 4] + self._alt_path = mpaths[(3 + skip) % 4] + else: + self._path = mpaths[(3 + skip) % 4] + self._alt_path = mpaths[(1 + skip) % 4] + + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_triangle_up(self): + return self._set_triangle(0.0, 0) + + def _set_triangle_down(self): + return self._set_triangle(180.0, 2) + + def _set_triangle_left(self): + return self._set_triangle(90.0, 3) + + def _set_triangle_right(self): + return self._set_triangle(270.0, 1) + + def _set_square(self): + self._transform = Affine2D().translate(-0.5, -0.5) + self._snap_threshold = 2.0 + if not self._half_fill(): + self._path = Path.unit_rectangle() + else: + # Build a bottom filled square out of two rectangles, one filled. + self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 0.5], + [0.0, 0.5], [0.0, 0.0]]) + self._alt_path = Path([[0.0, 0.5], [1.0, 0.5], [1.0, 1.0], + [0.0, 1.0], [0.0, 0.5]]) + fs = self.get_fillstyle() + rotate = {'bottom': 0, 'right': 90, 'top': 180, 'left': 270}[fs] + self._transform.rotate_deg(rotate) + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_diamond(self): + self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45) + self._snap_threshold = 5.0 + if not self._half_fill(): + self._path = Path.unit_rectangle() + else: + self._path = Path([[0, 0], [1, 0], [1, 1], [0, 0]]) + self._alt_path = Path([[0, 0], [0, 1], [1, 1], [0, 0]]) + fs = self.get_fillstyle() + rotate = {'right': 0, 'top': 90, 'left': 180, 'bottom': 270}[fs] + self._transform.rotate_deg(rotate) + self._alt_transform = self._transform + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_thin_diamond(self): + self._set_diamond() + self._transform.scale(0.6, 1.0) + + def _set_pentagon(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 5.0 + + polypath = Path.unit_regular_polygon(5) + + if not self._half_fill(): + self._path = polypath + else: + verts = polypath.vertices + y = (1 + np.sqrt(5)) / 4. + top = Path(verts[[0, 1, 4, 0]]) + bottom = Path(verts[[1, 2, 3, 4, 1]]) + left = Path([verts[0], verts[1], verts[2], [0, -y], verts[0]]) + right = Path([verts[0], verts[4], verts[3], [0, -y], verts[0]]) + self._path, self._alt_path = { + 'top': (top, bottom), 'bottom': (bottom, top), + 'left': (left, right), 'right': (right, left), + }[self.get_fillstyle()] + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_star(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 5.0 + + polypath = Path.unit_regular_star(5, innerCircle=0.381966) + + if not self._half_fill(): + self._path = polypath + else: + verts = polypath.vertices + top = Path(np.concatenate([verts[0:4], verts[7:10], verts[0:1]])) + bottom = Path(np.concatenate([verts[3:8], verts[3:4]])) + left = Path(np.concatenate([verts[0:6], verts[0:1]])) + right = Path(np.concatenate([verts[0:1], verts[5:10], verts[0:1]])) + self._path, self._alt_path = { + 'top': (top, bottom), 'bottom': (bottom, top), + 'left': (left, right), 'right': (right, left), + }[self.get_fillstyle()] + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.bevel + + def _set_hexagon1(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = None + + polypath = Path.unit_regular_polygon(6) + + if not self._half_fill(): + self._path = polypath + else: + verts = polypath.vertices + # not drawing inside lines + x = np.abs(np.cos(5 * np.pi / 6.)) + top = Path(np.concatenate([[(-x, 0)], verts[[1, 0, 5]], [(x, 0)]])) + bottom = Path(np.concatenate([[(-x, 0)], verts[2:5], [(x, 0)]])) + left = Path(verts[0:4]) + right = Path(verts[[0, 5, 4, 3]]) + self._path, self._alt_path = { + 'top': (top, bottom), 'bottom': (bottom, top), + 'left': (left, right), 'right': (right, left), + }[self.get_fillstyle()] + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_hexagon2(self): + self._transform = Affine2D().scale(0.5).rotate_deg(30) + self._snap_threshold = None + + polypath = Path.unit_regular_polygon(6) + + if not self._half_fill(): + self._path = polypath + else: + verts = polypath.vertices + # not drawing inside lines + x, y = np.sqrt(3) / 4, 3 / 4. + top = Path(verts[[1, 0, 5, 4, 1]]) + bottom = Path(verts[1:5]) + left = Path(np.concatenate([ + [(x, y)], verts[:3], [(-x, -y), (x, y)]])) + right = Path(np.concatenate([ + [(x, y)], verts[5:2:-1], [(-x, -y)]])) + self._path, self._alt_path = { + 'top': (top, bottom), 'bottom': (bottom, top), + 'left': (left, right), 'right': (right, left), + }[self.get_fillstyle()] + self._alt_transform = self._transform + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_octagon(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 5.0 + + polypath = Path.unit_regular_polygon(8) + + if not self._half_fill(): + self._transform.rotate_deg(22.5) + self._path = polypath + else: + x = np.sqrt(2.) / 4. + self._path = self._alt_path = Path( + [[0, -1], [0, 1], [-x, 1], [-1, x], + [-1, -x], [-x, -1], [0, -1]]) + fs = self.get_fillstyle() + self._transform.rotate_deg( + {'left': 0, 'bottom': 90, 'right': 180, 'top': 270}[fs]) + self._alt_transform = self._transform.frozen().rotate_deg(180.0) + + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + _line_marker_path = Path([[0.0, -1.0], [0.0, 1.0]]) + + def _set_vline(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._line_marker_path + + def _set_hline(self): + self._set_vline() + self._transform = self._transform.rotate_deg(90) + + _tickhoriz_path = Path([[0.0, 0.0], [1.0, 0.0]]) + + def _set_tickleft(self): + self._transform = Affine2D().scale(-1.0, 1.0) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._tickhoriz_path + + def _set_tickright(self): + self._transform = Affine2D().scale(1.0, 1.0) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._tickhoriz_path + + _tickvert_path = Path([[-0.0, 0.0], [-0.0, 1.0]]) + + def _set_tickup(self): + self._transform = Affine2D().scale(1.0, 1.0) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._tickvert_path + + def _set_tickdown(self): + self._transform = Affine2D().scale(1.0, -1.0) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._tickvert_path + + _tri_path = Path([[0.0, 0.0], [0.0, -1.0], + [0.0, 0.0], [0.8, 0.5], + [0.0, 0.0], [-0.8, 0.5]], + [Path.MOVETO, Path.LINETO, + Path.MOVETO, Path.LINETO, + Path.MOVETO, Path.LINETO]) + + def _set_tri_down(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 5.0 + self._filled = False + self._path = self._tri_path + + def _set_tri_up(self): + self._set_tri_down() + self._transform = self._transform.rotate_deg(180) + + def _set_tri_left(self): + self._set_tri_down() + self._transform = self._transform.rotate_deg(270) + + def _set_tri_right(self): + self._set_tri_down() + self._transform = self._transform.rotate_deg(90) + + _caret_path = Path([[-1.0, 1.5], [0.0, 0.0], [1.0, 1.5]]) + + def _set_caretdown(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 3.0 + self._filled = False + self._path = self._caret_path + self._joinstyle = self._user_joinstyle or JoinStyle.miter + + def _set_caretup(self): + self._set_caretdown() + self._transform = self._transform.rotate_deg(180) + + def _set_caretleft(self): + self._set_caretdown() + self._transform = self._transform.rotate_deg(270) + + def _set_caretright(self): + self._set_caretdown() + self._transform = self._transform.rotate_deg(90) + + _caret_path_base = Path([[-1.0, 0.0], [0.0, -1.5], [1.0, 0]]) + + def _set_caretdownbase(self): + self._set_caretdown() + self._path = self._caret_path_base + + def _set_caretupbase(self): + self._set_caretdownbase() + self._transform = self._transform.rotate_deg(180) + + def _set_caretleftbase(self): + self._set_caretdownbase() + self._transform = self._transform.rotate_deg(270) + + def _set_caretrightbase(self): + self._set_caretdownbase() + self._transform = self._transform.rotate_deg(90) + + _plus_path = Path([[-1.0, 0.0], [1.0, 0.0], + [0.0, -1.0], [0.0, 1.0]], + [Path.MOVETO, Path.LINETO, + Path.MOVETO, Path.LINETO]) + + def _set_plus(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 1.0 + self._filled = False + self._path = self._plus_path + + _x_path = Path([[-1.0, -1.0], [1.0, 1.0], + [-1.0, 1.0], [1.0, -1.0]], + [Path.MOVETO, Path.LINETO, + Path.MOVETO, Path.LINETO]) + + def _set_x(self): + self._transform = Affine2D().scale(0.5) + self._snap_threshold = 3.0 + self._filled = False + self._path = self._x_path + + _plus_filled_path = Path._create_closed(np.array([ + (-1, -3), (+1, -3), (+1, -1), (+3, -1), (+3, +1), (+1, +1), + (+1, +3), (-1, +3), (-1, +1), (-3, +1), (-3, -1), (-1, -1)]) / 6) + _plus_filled_path_t = Path._create_closed(np.array([ + (+3, 0), (+3, +1), (+1, +1), (+1, +3), + (-1, +3), (-1, +1), (-3, +1), (-3, 0)]) / 6) + + def _set_plus_filled(self): + self._transform = Affine2D() + self._snap_threshold = 5.0 + self._joinstyle = self._user_joinstyle or JoinStyle.miter + if not self._half_fill(): + self._path = self._plus_filled_path + else: + # Rotate top half path to support all partitions + self._path = self._alt_path = self._plus_filled_path_t + fs = self.get_fillstyle() + self._transform.rotate_deg( + {'top': 0, 'left': 90, 'bottom': 180, 'right': 270}[fs]) + self._alt_transform = self._transform.frozen().rotate_deg(180) + + _x_filled_path = Path._create_closed(np.array([ + (-1, -2), (0, -1), (+1, -2), (+2, -1), (+1, 0), (+2, +1), + (+1, +2), (0, +1), (-1, +2), (-2, +1), (-1, 0), (-2, -1)]) / 4) + _x_filled_path_t = Path._create_closed(np.array([ + (+1, 0), (+2, +1), (+1, +2), (0, +1), + (-1, +2), (-2, +1), (-1, 0)]) / 4) + + def _set_x_filled(self): + self._transform = Affine2D() + self._snap_threshold = 5.0 + self._joinstyle = self._user_joinstyle or JoinStyle.miter + if not self._half_fill(): + self._path = self._x_filled_path + else: + # Rotate top half path to support all partitions + self._path = self._alt_path = self._x_filled_path_t + fs = self.get_fillstyle() + self._transform.rotate_deg( + {'top': 0, 'left': 90, 'bottom': 180, 'right': 270}[fs]) + self._alt_transform = self._transform.frozen().rotate_deg(180) diff --git a/venv/lib/python3.10/site-packages/matplotlib/markers.pyi b/venv/lib/python3.10/site-packages/matplotlib/markers.pyi new file mode 100644 index 00000000..bd2f7dbc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/markers.pyi @@ -0,0 +1,51 @@ +from typing import Literal + +from .path import Path +from .transforms import Affine2D, Transform + +from numpy.typing import ArrayLike +from .typing import CapStyleType, FillStyleType, JoinStyleType + +TICKLEFT: int +TICKRIGHT: int +TICKUP: int +TICKDOWN: int +CARETLEFT: int +CARETRIGHT: int +CARETUP: int +CARETDOWN: int +CARETLEFTBASE: int +CARETRIGHTBASE: int +CARETUPBASE: int +CARETDOWNBASE: int + +class MarkerStyle: + markers: dict[str | int, str] + filled_markers: tuple[str, ...] + fillstyles: tuple[FillStyleType, ...] + + def __init__( + self, + marker: str | ArrayLike | Path | MarkerStyle, + fillstyle: FillStyleType | None = ..., + transform: Transform | None = ..., + capstyle: CapStyleType | None = ..., + joinstyle: JoinStyleType | None = ..., + ) -> None: ... + def __bool__(self) -> bool: ... + def is_filled(self) -> bool: ... + def get_fillstyle(self) -> FillStyleType: ... + def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ... + def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ... + def get_marker(self) -> str | ArrayLike | Path | None: ... + def get_path(self) -> Path: ... + def get_transform(self) -> Transform: ... + def get_alt_path(self) -> Path | None: ... + def get_alt_transform(self) -> Transform: ... + def get_snap_threshold(self) -> float | None: ... + def get_user_transform(self) -> Transform | None: ... + def transformed(self, transform: Affine2D) -> MarkerStyle: ... + def rotated( + self, *, deg: float | None = ..., rad: float | None = ... + ) -> MarkerStyle: ... + def scaled(self, sx: float, sy: float | None = ...) -> MarkerStyle: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/mathtext.py b/venv/lib/python3.10/site-packages/matplotlib/mathtext.py new file mode 100644 index 00000000..e25b76c4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mathtext.py @@ -0,0 +1,140 @@ +r""" +A module for parsing a subset of the TeX math syntax and rendering it to a +Matplotlib backend. + +For a tutorial of its usage, see :ref:`mathtext`. This +document is primarily concerned with implementation details. + +The module uses pyparsing_ to parse the TeX expression. + +.. _pyparsing: https://pypi.org/project/pyparsing/ + +The Bakoma distribution of the TeX Computer Modern fonts, and STIX +fonts are supported. There is experimental support for using +arbitrary fonts, but results may vary without proper tweaking and +metrics for those fonts. +""" + +import functools +import logging + +import matplotlib as mpl +from matplotlib import _api, _mathtext +from matplotlib.ft2font import LOAD_NO_HINTING +from matplotlib.font_manager import FontProperties +from ._mathtext import ( # noqa: reexported API + RasterParse, VectorParse, get_unicode_index) + +_log = logging.getLogger(__name__) + + +get_unicode_index.__module__ = __name__ + +############################################################################## +# MAIN + + +class MathTextParser: + _parser = None + _font_type_mapping = { + 'cm': _mathtext.BakomaFonts, + 'dejavuserif': _mathtext.DejaVuSerifFonts, + 'dejavusans': _mathtext.DejaVuSansFonts, + 'stix': _mathtext.StixFonts, + 'stixsans': _mathtext.StixSansFonts, + 'custom': _mathtext.UnicodeFonts, + } + + def __init__(self, output): + """ + Create a MathTextParser for the given backend *output*. + + Parameters + ---------- + output : {"path", "agg"} + Whether to return a `VectorParse` ("path") or a + `RasterParse` ("agg", or its synonym "macosx"). + """ + self._output_type = _api.check_getitem( + {"path": "vector", "agg": "raster", "macosx": "raster"}, + output=output.lower()) + + def parse(self, s, dpi=72, prop=None, *, antialiased=None): + """ + Parse the given math expression *s* at the given *dpi*. If *prop* is + provided, it is a `.FontProperties` object specifying the "default" + font to use in the math expression, used for all non-math text. + + The results are cached, so multiple calls to `parse` + with the same expression should be fast. + + Depending on the *output* type, this returns either a `VectorParse` or + a `RasterParse`. + """ + # lru_cache can't decorate parse() directly because prop + # is mutable; key the cache using an internal copy (see + # text._get_text_metrics_with_cache for a similar case). + prop = prop.copy() if prop is not None else None + antialiased = mpl._val_or_rc(antialiased, 'text.antialiased') + return self._parse_cached(s, dpi, prop, antialiased) + + @functools.lru_cache(50) + def _parse_cached(self, s, dpi, prop, antialiased): + from matplotlib.backends import backend_agg + + if prop is None: + prop = FontProperties() + fontset_class = _api.check_getitem( + self._font_type_mapping, fontset=prop.get_math_fontfamily()) + load_glyph_flags = { + "vector": LOAD_NO_HINTING, + "raster": backend_agg.get_hinting_flag(), + }[self._output_type] + fontset = fontset_class(prop, load_glyph_flags) + + fontsize = prop.get_size_in_points() + + if self._parser is None: # Cache the parser globally. + self.__class__._parser = _mathtext.Parser() + + box = self._parser.parse(s, fontset, fontsize, dpi) + output = _mathtext.ship(box) + if self._output_type == "vector": + return output.to_vector() + elif self._output_type == "raster": + return output.to_raster(antialiased=antialiased) + + +def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None, + *, color=None): + """ + Given a math expression, renders it in a closely-clipped bounding + box to an image file. + + Parameters + ---------- + s : str + A math expression. The math portion must be enclosed in dollar signs. + filename_or_obj : str or path-like or file-like + Where to write the image data. + prop : `.FontProperties`, optional + The size and style of the text. + dpi : float, optional + The output dpi. If not set, the dpi is determined as for + `.Figure.savefig`. + format : str, optional + The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the + format is determined as for `.Figure.savefig`. + color : str, optional + Foreground color, defaults to :rc:`text.color`. + """ + from matplotlib import figure + + parser = MathTextParser('path') + width, height, depth, _, _ = parser.parse(s, dpi=72, prop=prop) + + fig = figure.Figure(figsize=(width / 72.0, height / 72.0)) + fig.text(0, depth/height, s, fontproperties=prop, color=color) + fig.savefig(filename_or_obj, dpi=dpi, format=format) + + return depth diff --git a/venv/lib/python3.10/site-packages/matplotlib/mathtext.pyi b/venv/lib/python3.10/site-packages/matplotlib/mathtext.pyi new file mode 100644 index 00000000..607501a2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mathtext.pyi @@ -0,0 +1,33 @@ +import os +from typing import Generic, IO, Literal, TypeVar, overload + +from matplotlib.font_manager import FontProperties +from matplotlib.typing import ColorType + +# Re-exported API from _mathtext. +from ._mathtext import ( + RasterParse as RasterParse, + VectorParse as VectorParse, + get_unicode_index as get_unicode_index, +) + +_ParseType = TypeVar("_ParseType", RasterParse, VectorParse) + +class MathTextParser(Generic[_ParseType]): + @overload + def __init__(self: MathTextParser[VectorParse], output: Literal["path"]) -> None: ... + @overload + def __init__(self: MathTextParser[RasterParse], output: Literal["agg", "raster", "macosx"]) -> None: ... + def parse( + self, s: str, dpi: float = ..., prop: FontProperties | None = ..., *, antialiased: bool | None = ... + ) -> _ParseType: ... + +def math_to_image( + s: str, + filename_or_obj: str | os.PathLike | IO, + prop: FontProperties | None = ..., + dpi: float | None = ..., + format: str | None = ..., + *, + color: ColorType | None = ... +) -> float: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/mlab.py b/venv/lib/python3.10/site-packages/matplotlib/mlab.py new file mode 100644 index 00000000..e1f08c0d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mlab.py @@ -0,0 +1,913 @@ +""" +Numerical Python functions written for compatibility with MATLAB +commands with the same names. Most numerical Python functions can be found in +the `NumPy`_ and `SciPy`_ libraries. What remains here is code for performing +spectral computations and kernel density estimations. + +.. _NumPy: https://numpy.org +.. _SciPy: https://www.scipy.org + +Spectral functions +------------------ + +`cohere` + Coherence (normalized cross spectral density) + +`csd` + Cross spectral density using Welch's average periodogram + +`detrend` + Remove the mean or best fit line from an array + +`psd` + Power spectral density using Welch's average periodogram + +`specgram` + Spectrogram (spectrum over segments of time) + +`complex_spectrum` + Return the complex-valued frequency spectrum of a signal + +`magnitude_spectrum` + Return the magnitude of the frequency spectrum of a signal + +`angle_spectrum` + Return the angle (wrapped phase) of the frequency spectrum of a signal + +`phase_spectrum` + Return the phase (unwrapped angle) of the frequency spectrum of a signal + +`detrend_mean` + Remove the mean from a line. + +`detrend_linear` + Remove the best fit line from a line. + +`detrend_none` + Return the original line. +""" + +import functools +from numbers import Number + +import numpy as np + +from matplotlib import _api, _docstring, cbook + + +def window_hanning(x): + """ + Return *x* times the Hanning (or Hann) window of len(*x*). + + See Also + -------- + window_none : Another window algorithm. + """ + return np.hanning(len(x))*x + + +def window_none(x): + """ + No window function; simply return *x*. + + See Also + -------- + window_hanning : Another window algorithm. + """ + return x + + +def detrend(x, key=None, axis=None): + """ + Return *x* with its trend removed. + + Parameters + ---------- + x : array or sequence + Array or sequence containing the data. + + key : {'default', 'constant', 'mean', 'linear', 'none'} or function + The detrending algorithm to use. 'default', 'mean', and 'constant' are + the same as `detrend_mean`. 'linear' is the same as `detrend_linear`. + 'none' is the same as `detrend_none`. The default is 'mean'. See the + corresponding functions for more details regarding the algorithms. Can + also be a function that carries out the detrend operation. + + axis : int + The axis along which to do the detrending. + + See Also + -------- + detrend_mean : Implementation of the 'mean' algorithm. + detrend_linear : Implementation of the 'linear' algorithm. + detrend_none : Implementation of the 'none' algorithm. + """ + if key is None or key in ['constant', 'mean', 'default']: + return detrend(x, key=detrend_mean, axis=axis) + elif key == 'linear': + return detrend(x, key=detrend_linear, axis=axis) + elif key == 'none': + return detrend(x, key=detrend_none, axis=axis) + elif callable(key): + x = np.asarray(x) + if axis is not None and axis + 1 > x.ndim: + raise ValueError(f'axis(={axis}) out of bounds') + if (axis is None and x.ndim == 0) or (not axis and x.ndim == 1): + return key(x) + # try to use the 'axis' argument if the function supports it, + # otherwise use apply_along_axis to do it + try: + return key(x, axis=axis) + except TypeError: + return np.apply_along_axis(key, axis=axis, arr=x) + else: + raise ValueError( + f"Unknown value for key: {key!r}, must be one of: 'default', " + f"'constant', 'mean', 'linear', or a function") + + +def detrend_mean(x, axis=None): + """ + Return *x* minus the mean(*x*). + + Parameters + ---------- + x : array or sequence + Array or sequence containing the data + Can have any dimensionality + + axis : int + The axis along which to take the mean. See `numpy.mean` for a + description of this argument. + + See Also + -------- + detrend_linear : Another detrend algorithm. + detrend_none : Another detrend algorithm. + detrend : A wrapper around all the detrend algorithms. + """ + x = np.asarray(x) + + if axis is not None and axis+1 > x.ndim: + raise ValueError('axis(=%s) out of bounds' % axis) + + return x - x.mean(axis, keepdims=True) + + +def detrend_none(x, axis=None): + """ + Return *x*: no detrending. + + Parameters + ---------- + x : any object + An object containing the data + + axis : int + This parameter is ignored. + It is included for compatibility with detrend_mean + + See Also + -------- + detrend_mean : Another detrend algorithm. + detrend_linear : Another detrend algorithm. + detrend : A wrapper around all the detrend algorithms. + """ + return x + + +def detrend_linear(y): + """ + Return *x* minus best fit line; 'linear' detrending. + + Parameters + ---------- + y : 0-D or 1-D array or sequence + Array or sequence containing the data + + See Also + -------- + detrend_mean : Another detrend algorithm. + detrend_none : Another detrend algorithm. + detrend : A wrapper around all the detrend algorithms. + """ + # This is faster than an algorithm based on linalg.lstsq. + y = np.asarray(y) + + if y.ndim > 1: + raise ValueError('y cannot have ndim > 1') + + # short-circuit 0-D array. + if not y.ndim: + return np.array(0., dtype=y.dtype) + + x = np.arange(y.size, dtype=float) + + C = np.cov(x, y, bias=1) + b = C[0, 1]/C[0, 0] + + a = y.mean() - b*x.mean() + return y - (b*x + a) + + +def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, + window=None, noverlap=None, pad_to=None, + sides=None, scale_by_freq=None, mode=None): + """ + Private helper implementing the common parts between the psd, csd, + spectrogram and complex, magnitude, angle, and phase spectrums. + """ + if y is None: + # if y is None use x for y + same_data = True + else: + # The checks for if y is x are so that we can use the same function to + # implement the core of psd(), csd(), and spectrogram() without doing + # extra calculations. We return the unaveraged Pxy, freqs, and t. + same_data = y is x + + if Fs is None: + Fs = 2 + if noverlap is None: + noverlap = 0 + if detrend_func is None: + detrend_func = detrend_none + if window is None: + window = window_hanning + + # if NFFT is set to None use the whole signal + if NFFT is None: + NFFT = 256 + + if noverlap >= NFFT: + raise ValueError('noverlap must be less than NFFT') + + if mode is None or mode == 'default': + mode = 'psd' + _api.check_in_list( + ['default', 'psd', 'complex', 'magnitude', 'angle', 'phase'], + mode=mode) + + if not same_data and mode != 'psd': + raise ValueError("x and y must be equal if mode is not 'psd'") + + # Make sure we're dealing with a numpy array. If y and x were the same + # object to start with, keep them that way + x = np.asarray(x) + if not same_data: + y = np.asarray(y) + + if sides is None or sides == 'default': + if np.iscomplexobj(x): + sides = 'twosided' + else: + sides = 'onesided' + _api.check_in_list(['default', 'onesided', 'twosided'], sides=sides) + + # zero pad x and y up to NFFT if they are shorter than NFFT + if len(x) < NFFT: + n = len(x) + x = np.resize(x, NFFT) + x[n:] = 0 + + if not same_data and len(y) < NFFT: + n = len(y) + y = np.resize(y, NFFT) + y[n:] = 0 + + if pad_to is None: + pad_to = NFFT + + if mode != 'psd': + scale_by_freq = False + elif scale_by_freq is None: + scale_by_freq = True + + # For real x, ignore the negative frequencies unless told otherwise + if sides == 'twosided': + numFreqs = pad_to + if pad_to % 2: + freqcenter = (pad_to - 1)//2 + 1 + else: + freqcenter = pad_to//2 + scaling_factor = 1. + elif sides == 'onesided': + if pad_to % 2: + numFreqs = (pad_to + 1)//2 + else: + numFreqs = pad_to//2 + 1 + scaling_factor = 2. + + if not np.iterable(window): + window = window(np.ones(NFFT, x.dtype)) + if len(window) != NFFT: + raise ValueError( + "The window length must match the data's first dimension") + + result = np.lib.stride_tricks.sliding_window_view( + x, NFFT, axis=0)[::NFFT - noverlap].T + result = detrend(result, detrend_func, axis=0) + result = result * window.reshape((-1, 1)) + result = np.fft.fft(result, n=pad_to, axis=0)[:numFreqs, :] + freqs = np.fft.fftfreq(pad_to, 1/Fs)[:numFreqs] + + if not same_data: + # if same_data is False, mode must be 'psd' + resultY = np.lib.stride_tricks.sliding_window_view( + y, NFFT, axis=0)[::NFFT - noverlap].T + resultY = detrend(resultY, detrend_func, axis=0) + resultY = resultY * window.reshape((-1, 1)) + resultY = np.fft.fft(resultY, n=pad_to, axis=0)[:numFreqs, :] + result = np.conj(result) * resultY + elif mode == 'psd': + result = np.conj(result) * result + elif mode == 'magnitude': + result = np.abs(result) / window.sum() + elif mode == 'angle' or mode == 'phase': + # we unwrap the phase later to handle the onesided vs. twosided case + result = np.angle(result) + elif mode == 'complex': + result /= window.sum() + + if mode == 'psd': + + # Also include scaling factors for one-sided densities and dividing by + # the sampling frequency, if desired. Scale everything, except the DC + # component and the NFFT/2 component: + + # if we have a even number of frequencies, don't scale NFFT/2 + if not NFFT % 2: + slc = slice(1, -1, None) + # if we have an odd number, just don't scale DC + else: + slc = slice(1, None, None) + + result[slc] *= scaling_factor + + # MATLAB divides by the sampling frequency so that density function + # has units of dB/Hz and can be integrated by the plotted frequency + # values. Perform the same scaling here. + if scale_by_freq: + result /= Fs + # Scale the spectrum by the norm of the window to compensate for + # windowing loss; see Bendat & Piersol Sec 11.5.2. + result /= (window**2).sum() + else: + # In this case, preserve power in the segment, not amplitude + result /= window.sum()**2 + + t = np.arange(NFFT/2, len(x) - NFFT/2 + 1, NFFT - noverlap)/Fs + + if sides == 'twosided': + # center the frequency range at zero + freqs = np.roll(freqs, -freqcenter, axis=0) + result = np.roll(result, -freqcenter, axis=0) + elif not pad_to % 2: + # get the last value correctly, it is negative otherwise + freqs[-1] *= -1 + + # we unwrap the phase here to handle the onesided vs. twosided case + if mode == 'phase': + result = np.unwrap(result, axis=0) + + return result, freqs, t + + +def _single_spectrum_helper( + mode, x, Fs=None, window=None, pad_to=None, sides=None): + """ + Private helper implementing the commonality between the complex, magnitude, + angle, and phase spectrums. + """ + _api.check_in_list(['complex', 'magnitude', 'angle', 'phase'], mode=mode) + + if pad_to is None: + pad_to = len(x) + + spec, freqs, _ = _spectral_helper(x=x, y=None, NFFT=len(x), Fs=Fs, + detrend_func=detrend_none, window=window, + noverlap=0, pad_to=pad_to, + sides=sides, + scale_by_freq=False, + mode=mode) + if mode != 'complex': + spec = spec.real + + if spec.ndim == 2 and spec.shape[1] == 1: + spec = spec[:, 0] + + return spec, freqs + + +# Split out these keyword docs so that they can be used elsewhere +_docstring.interpd.update( + Spectral="""\ +Fs : float, default: 2 + The sampling frequency (samples per time unit). It is used to calculate + the Fourier frequencies, *freqs*, in cycles per time unit. + +window : callable or ndarray, default: `.window_hanning` + A function or a vector of length *NFFT*. To create window vectors see + `.window_hanning`, `.window_none`, `numpy.blackman`, `numpy.hamming`, + `numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. If a + function is passed as the argument, it must take a data segment as an + argument and return the windowed version of the segment. + +sides : {'default', 'onesided', 'twosided'}, optional + Which sides of the spectrum to return. 'default' is one-sided for real + data and two-sided for complex data. 'onesided' forces the return of a + one-sided spectrum, while 'twosided' forces two-sided.""", + + Single_Spectrum="""\ +pad_to : int, optional + The number of points to which the data segment is padded when performing + the FFT. While not increasing the actual resolution of the spectrum (the + minimum distance between resolvable peaks), this can give more points in + the plot, allowing for more detail. This corresponds to the *n* parameter + in the call to `~numpy.fft.fft`. The default is None, which sets *pad_to* + equal to the length of the input signal (i.e. no padding).""", + + PSD="""\ +pad_to : int, optional + The number of points to which the data segment is padded when performing + the FFT. This can be different from *NFFT*, which specifies the number + of data points used. While not increasing the actual resolution of the + spectrum (the minimum distance between resolvable peaks), this can give + more points in the plot, allowing for more detail. This corresponds to + the *n* parameter in the call to `~numpy.fft.fft`. The default is None, + which sets *pad_to* equal to *NFFT* + +NFFT : int, default: 256 + The number of data points used in each block for the FFT. A power 2 is + most efficient. This should *NOT* be used to get zero padding, or the + scaling of the result will be incorrect; use *pad_to* for this instead. + +detrend : {'none', 'mean', 'linear'} or callable, default: 'none' + The function applied to each segment before fft-ing, designed to remove + the mean or linear trend. Unlike in MATLAB, where the *detrend* parameter + is a vector, in Matplotlib it is a function. The :mod:`~matplotlib.mlab` + module defines `.detrend_none`, `.detrend_mean`, and `.detrend_linear`, + but you can use a custom function as well. You can also use a string to + choose one of the functions: 'none' calls `.detrend_none`. 'mean' calls + `.detrend_mean`. 'linear' calls `.detrend_linear`. + +scale_by_freq : bool, default: True + Whether the resulting density values should be scaled by the scaling + frequency, which gives density in units of 1/Hz. This allows for + integration over the returned frequency values. The default is True for + MATLAB compatibility.""") + + +@_docstring.dedent_interpd +def psd(x, NFFT=None, Fs=None, detrend=None, window=None, + noverlap=None, pad_to=None, sides=None, scale_by_freq=None): + r""" + Compute the power spectral density. + + The power spectral density :math:`P_{xx}` by Welch's average + periodogram method. The vector *x* is divided into *NFFT* length + segments. Each segment is detrended by function *detrend* and + windowed by function *window*. *noverlap* gives the length of + the overlap between segments. The :math:`|\mathrm{fft}(i)|^2` + of each segment :math:`i` are averaged to compute :math:`P_{xx}`. + + If len(*x*) < *NFFT*, it will be zero padded to *NFFT*. + + Parameters + ---------- + x : 1-D array or sequence + Array or sequence containing the data + + %(Spectral)s + + %(PSD)s + + noverlap : int, default: 0 (no overlap) + The number of points of overlap between segments. + + Returns + ------- + Pxx : 1-D array + The values for the power spectrum :math:`P_{xx}` (real valued) + + freqs : 1-D array + The frequencies corresponding to the elements in *Pxx* + + References + ---------- + Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John + Wiley & Sons (1986) + + See Also + -------- + specgram + `specgram` differs in the default overlap; in not returning the mean of + the segment periodograms; and in returning the times of the segments. + + magnitude_spectrum : returns the magnitude spectrum. + + csd : returns the spectral density between two signals. + """ + Pxx, freqs = csd(x=x, y=None, NFFT=NFFT, Fs=Fs, detrend=detrend, + window=window, noverlap=noverlap, pad_to=pad_to, + sides=sides, scale_by_freq=scale_by_freq) + return Pxx.real, freqs + + +@_docstring.dedent_interpd +def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None, + noverlap=None, pad_to=None, sides=None, scale_by_freq=None): + """ + Compute the cross-spectral density. + + The cross spectral density :math:`P_{xy}` by Welch's average + periodogram method. The vectors *x* and *y* are divided into + *NFFT* length segments. Each segment is detrended by function + *detrend* and windowed by function *window*. *noverlap* gives + the length of the overlap between segments. The product of + the direct FFTs of *x* and *y* are averaged over each segment + to compute :math:`P_{xy}`, with a scaling to correct for power + loss due to windowing. + + If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero + padded to *NFFT*. + + Parameters + ---------- + x, y : 1-D arrays or sequences + Arrays or sequences containing the data + + %(Spectral)s + + %(PSD)s + + noverlap : int, default: 0 (no overlap) + The number of points of overlap between segments. + + Returns + ------- + Pxy : 1-D array + The values for the cross spectrum :math:`P_{xy}` before scaling (real + valued) + + freqs : 1-D array + The frequencies corresponding to the elements in *Pxy* + + References + ---------- + Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John + Wiley & Sons (1986) + + See Also + -------- + psd : equivalent to setting ``y = x``. + """ + if NFFT is None: + NFFT = 256 + Pxy, freqs, _ = _spectral_helper(x=x, y=y, NFFT=NFFT, Fs=Fs, + detrend_func=detrend, window=window, + noverlap=noverlap, pad_to=pad_to, + sides=sides, scale_by_freq=scale_by_freq, + mode='psd') + + if Pxy.ndim == 2: + if Pxy.shape[1] > 1: + Pxy = Pxy.mean(axis=1) + else: + Pxy = Pxy[:, 0] + return Pxy, freqs + + +_single_spectrum_docs = """\ +Compute the {quantity} of *x*. +Data is padded to a length of *pad_to* and the windowing function *window* is +applied to the signal. + +Parameters +---------- +x : 1-D array or sequence + Array or sequence containing the data + +{Spectral} + +{Single_Spectrum} + +Returns +------- +spectrum : 1-D array + The {quantity}. +freqs : 1-D array + The frequencies corresponding to the elements in *spectrum*. + +See Also +-------- +psd + Returns the power spectral density. +complex_spectrum + Returns the complex-valued frequency spectrum. +magnitude_spectrum + Returns the absolute value of the `complex_spectrum`. +angle_spectrum + Returns the angle of the `complex_spectrum`. +phase_spectrum + Returns the phase (unwrapped angle) of the `complex_spectrum`. +specgram + Can return the complex spectrum of segments within the signal. +""" + + +complex_spectrum = functools.partial(_single_spectrum_helper, "complex") +complex_spectrum.__doc__ = _single_spectrum_docs.format( + quantity="complex-valued frequency spectrum", + **_docstring.interpd.params) +magnitude_spectrum = functools.partial(_single_spectrum_helper, "magnitude") +magnitude_spectrum.__doc__ = _single_spectrum_docs.format( + quantity="magnitude (absolute value) of the frequency spectrum", + **_docstring.interpd.params) +angle_spectrum = functools.partial(_single_spectrum_helper, "angle") +angle_spectrum.__doc__ = _single_spectrum_docs.format( + quantity="angle of the frequency spectrum (wrapped phase spectrum)", + **_docstring.interpd.params) +phase_spectrum = functools.partial(_single_spectrum_helper, "phase") +phase_spectrum.__doc__ = _single_spectrum_docs.format( + quantity="phase of the frequency spectrum (unwrapped phase spectrum)", + **_docstring.interpd.params) + + +@_docstring.dedent_interpd +def specgram(x, NFFT=None, Fs=None, detrend=None, window=None, + noverlap=None, pad_to=None, sides=None, scale_by_freq=None, + mode=None): + """ + Compute a spectrogram. + + Compute and plot a spectrogram of data in *x*. Data are split into + *NFFT* length segments and the spectrum of each section is + computed. The windowing function *window* is applied to each + segment, and the amount of overlap of each segment is + specified with *noverlap*. + + Parameters + ---------- + x : array-like + 1-D array or sequence. + + %(Spectral)s + + %(PSD)s + + noverlap : int, default: 128 + The number of points of overlap between blocks. + mode : str, default: 'psd' + What sort of spectrum to use: + 'psd' + Returns the power spectral density. + 'complex' + Returns the complex-valued frequency spectrum. + 'magnitude' + Returns the magnitude spectrum. + 'angle' + Returns the phase spectrum without unwrapping. + 'phase' + Returns the phase spectrum with unwrapping. + + Returns + ------- + spectrum : array-like + 2D array, columns are the periodograms of successive segments. + + freqs : array-like + 1-D array, frequencies corresponding to the rows in *spectrum*. + + t : array-like + 1-D array, the times corresponding to midpoints of segments + (i.e the columns in *spectrum*). + + See Also + -------- + psd : differs in the overlap and in the return values. + complex_spectrum : similar, but with complex valued frequencies. + magnitude_spectrum : similar single segment when *mode* is 'magnitude'. + angle_spectrum : similar to single segment when *mode* is 'angle'. + phase_spectrum : similar to single segment when *mode* is 'phase'. + + Notes + ----- + *detrend* and *scale_by_freq* only apply when *mode* is set to 'psd'. + + """ + if noverlap is None: + noverlap = 128 # default in _spectral_helper() is noverlap = 0 + if NFFT is None: + NFFT = 256 # same default as in _spectral_helper() + if len(x) <= NFFT: + _api.warn_external("Only one segment is calculated since parameter " + f"NFFT (={NFFT}) >= signal length (={len(x)}).") + + spec, freqs, t = _spectral_helper(x=x, y=None, NFFT=NFFT, Fs=Fs, + detrend_func=detrend, window=window, + noverlap=noverlap, pad_to=pad_to, + sides=sides, + scale_by_freq=scale_by_freq, + mode=mode) + + if mode != 'complex': + spec = spec.real # Needed since helper implements generically + + return spec, freqs, t + + +@_docstring.dedent_interpd +def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, + noverlap=0, pad_to=None, sides='default', scale_by_freq=None): + r""" + The coherence between *x* and *y*. Coherence is the normalized + cross spectral density: + + .. math:: + + C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}} + + Parameters + ---------- + x, y + Array or sequence containing the data + + %(Spectral)s + + %(PSD)s + + noverlap : int, default: 0 (no overlap) + The number of points of overlap between segments. + + Returns + ------- + Cxy : 1-D array + The coherence vector. + freqs : 1-D array + The frequencies for the elements in *Cxy*. + + See Also + -------- + :func:`psd`, :func:`csd` : + For information about the methods used to compute :math:`P_{xy}`, + :math:`P_{xx}` and :math:`P_{yy}`. + """ + if len(x) < 2 * NFFT: + raise ValueError( + "Coherence is calculated by averaging over *NFFT* length " + "segments. Your signal is too short for your choice of *NFFT*.") + Pxx, f = psd(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides, + scale_by_freq) + Pyy, f = psd(y, NFFT, Fs, detrend, window, noverlap, pad_to, sides, + scale_by_freq) + Pxy, f = csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides, + scale_by_freq) + Cxy = np.abs(Pxy) ** 2 / (Pxx * Pyy) + return Cxy, f + + +class GaussianKDE: + """ + Representation of a kernel-density estimate using Gaussian kernels. + + Parameters + ---------- + dataset : array-like + Datapoints to estimate from. In case of univariate data this is a 1-D + array, otherwise a 2D array with shape (# of dims, # of data). + bw_method : {'scott', 'silverman'} or float or callable, optional + The method used to calculate the estimator bandwidth. If a + float, this will be used directly as `kde.factor`. If a + callable, it should take a `GaussianKDE` instance as only + parameter and return a float. If None (default), 'scott' is used. + + Attributes + ---------- + dataset : ndarray + The dataset passed to the constructor. + dim : int + Number of dimensions. + num_dp : int + Number of datapoints. + factor : float + The bandwidth factor, obtained from `kde.covariance_factor`, with which + the covariance matrix is multiplied. + covariance : ndarray + The covariance matrix of *dataset*, scaled by the calculated bandwidth + (`kde.factor`). + inv_cov : ndarray + The inverse of *covariance*. + + Methods + ------- + kde.evaluate(points) : ndarray + Evaluate the estimated pdf on a provided set of points. + kde(points) : ndarray + Same as kde.evaluate(points) + """ + + # This implementation with minor modification was too good to pass up. + # from scipy: https://github.com/scipy/scipy/blob/master/scipy/stats/kde.py + + def __init__(self, dataset, bw_method=None): + self.dataset = np.atleast_2d(dataset) + if not np.array(self.dataset).size > 1: + raise ValueError("`dataset` input should have multiple elements.") + + self.dim, self.num_dp = np.array(self.dataset).shape + + if bw_method is None: + pass + elif cbook._str_equal(bw_method, 'scott'): + self.covariance_factor = self.scotts_factor + elif cbook._str_equal(bw_method, 'silverman'): + self.covariance_factor = self.silverman_factor + elif isinstance(bw_method, Number): + self._bw_method = 'use constant' + self.covariance_factor = lambda: bw_method + elif callable(bw_method): + self._bw_method = bw_method + self.covariance_factor = lambda: self._bw_method(self) + else: + raise ValueError("`bw_method` should be 'scott', 'silverman', a " + "scalar or a callable") + + # Computes the covariance matrix for each Gaussian kernel using + # covariance_factor(). + + self.factor = self.covariance_factor() + # Cache covariance and inverse covariance of the data + if not hasattr(self, '_data_inv_cov'): + self.data_covariance = np.atleast_2d( + np.cov( + self.dataset, + rowvar=1, + bias=False)) + self.data_inv_cov = np.linalg.inv(self.data_covariance) + + self.covariance = self.data_covariance * self.factor ** 2 + self.inv_cov = self.data_inv_cov / self.factor ** 2 + self.norm_factor = (np.sqrt(np.linalg.det(2 * np.pi * self.covariance)) + * self.num_dp) + + def scotts_factor(self): + return np.power(self.num_dp, -1. / (self.dim + 4)) + + def silverman_factor(self): + return np.power( + self.num_dp * (self.dim + 2.0) / 4.0, -1. / (self.dim + 4)) + + # Default method to calculate bandwidth, can be overwritten by subclass + covariance_factor = scotts_factor + + def evaluate(self, points): + """ + Evaluate the estimated pdf on a set of points. + + Parameters + ---------- + points : (# of dimensions, # of points)-array + Alternatively, a (# of dimensions,) vector can be passed in and + treated as a single point. + + Returns + ------- + (# of points,)-array + The values at each point. + + Raises + ------ + ValueError : if the dimensionality of the input points is different + than the dimensionality of the KDE. + + """ + points = np.atleast_2d(points) + + dim, num_m = np.array(points).shape + if dim != self.dim: + raise ValueError(f"points have dimension {dim}, dataset has " + f"dimension {self.dim}") + + result = np.zeros(num_m) + + if num_m >= self.num_dp: + # there are more points than data, so loop over data + for i in range(self.num_dp): + diff = self.dataset[:, i, np.newaxis] - points + tdiff = np.dot(self.inv_cov, diff) + energy = np.sum(diff * tdiff, axis=0) / 2.0 + result = result + np.exp(-energy) + else: + # loop over points + for i in range(num_m): + diff = self.dataset - points[:, i, np.newaxis] + tdiff = np.dot(self.inv_cov, diff) + energy = np.sum(diff * tdiff, axis=0) / 2.0 + result[i] = np.sum(np.exp(-energy), axis=0) + + result = result / self.norm_factor + + return result + + __call__ = evaluate diff --git a/venv/lib/python3.10/site-packages/matplotlib/mlab.pyi b/venv/lib/python3.10/site-packages/matplotlib/mlab.pyi new file mode 100644 index 00000000..1f23288d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mlab.pyi @@ -0,0 +1,100 @@ +from collections.abc import Callable +import functools +from typing import Literal + +import numpy as np +from numpy.typing import ArrayLike + +def window_hanning(x: ArrayLike) -> ArrayLike: ... +def window_none(x: ArrayLike) -> ArrayLike: ... +def detrend( + x: ArrayLike, + key: Literal["default", "constant", "mean", "linear", "none"] + | Callable[[ArrayLike, int | None], ArrayLike] + | None = ..., + axis: int | None = ..., +) -> ArrayLike: ... +def detrend_mean(x: ArrayLike, axis: int | None = ...) -> ArrayLike: ... +def detrend_none(x: ArrayLike, axis: int | None = ...) -> ArrayLike: ... +def detrend_linear(y: ArrayLike) -> ArrayLike: ... +def psd( + x: ArrayLike, + NFFT: int | None = ..., + Fs: float | None = ..., + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike, int | None], ArrayLike] + | None = ..., + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., + noverlap: int | None = ..., + pad_to: int | None = ..., + sides: Literal["default", "onesided", "twosided"] | None = ..., + scale_by_freq: bool | None = ..., +) -> tuple[ArrayLike, ArrayLike]: ... +def csd( + x: ArrayLike, + y: ArrayLike | None, + NFFT: int | None = ..., + Fs: float | None = ..., + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike, int | None], ArrayLike] + | None = ..., + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., + noverlap: int | None = ..., + pad_to: int | None = ..., + sides: Literal["default", "onesided", "twosided"] | None = ..., + scale_by_freq: bool | None = ..., +) -> tuple[ArrayLike, ArrayLike]: ... + +complex_spectrum = functools.partial(tuple[ArrayLike, ArrayLike]) +magnitude_spectrum = functools.partial(tuple[ArrayLike, ArrayLike]) +angle_spectrum = functools.partial(tuple[ArrayLike, ArrayLike]) +phase_spectrum = functools.partial(tuple[ArrayLike, ArrayLike]) + +def specgram( + x: ArrayLike, + NFFT: int | None = ..., + Fs: float | None = ..., + detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike, int | None], ArrayLike] | None = ..., + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., + noverlap: int | None = ..., + pad_to: int | None = ..., + sides: Literal["default", "onesided", "twosided"] | None = ..., + scale_by_freq: bool | None = ..., + mode: Literal["psd", "complex", "magnitude", "angle", "phase"] | None = ..., +) -> tuple[ArrayLike, ArrayLike, ArrayLike]: ... +def cohere( + x: ArrayLike, + y: ArrayLike, + NFFT: int = ..., + Fs: float = ..., + detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike, int | None], ArrayLike] = ..., + window: Callable[[ArrayLike], ArrayLike] | ArrayLike = ..., + noverlap: int = ..., + pad_to: int | None = ..., + sides: Literal["default", "onesided", "twosided"] = ..., + scale_by_freq: bool | None = ..., +) -> tuple[ArrayLike, ArrayLike]: ... + +class GaussianKDE: + dataset: ArrayLike + dim: int + num_dp: int + factor: float + data_covariance: ArrayLike + data_inv_cov: ArrayLike + covariance: ArrayLike + inv_cov: ArrayLike + norm_factor: float + def __init__( + self, + dataset: ArrayLike, + bw_method: Literal["scott", "silverman"] + | float + | Callable[[GaussianKDE], float] + | None = ..., + ) -> None: ... + def scotts_factor(self) -> float: ... + def silverman_factor(self) -> float: ... + def covariance_factor(self) -> float: ... + def evaluate(self, points: ArrayLike) -> np.ndarray: ... + def __call__(self, points: ArrayLike) -> np.ndarray: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmex10.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmex10.afm new file mode 100644 index 00000000..b9e318ff --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmex10.afm @@ -0,0 +1,220 @@ +StartFontMetrics 2.0 +Comment Creation Date: Thu Jun 21 22:23:20 1990 +Comment UniqueID 5000774 +FontName CMEX10 +EncodingScheme FontSpecific +FullName CMEX10 +FamilyName Computer Modern +Weight Medium +ItalicAngle 0 +IsFixedPitch false +Version 1.00 +Notice Copyright (c) 1997 American Mathematical Society. All Rights Reserved. +Comment Computer Modern fonts were designed by Donald E. Knuth +FontBBox -24 -2960 1454 772 +XHeight 430.556 +Comment CapHeight 0 +Ascender 750 +Comment Descender -1760 +Descender -2960 +Comment FontID CMEX +Comment DesignSize 10 (pts) +Comment CharacterCodingScheme TeX math extension +Comment Space 0 0 0 +Comment ExtraSpace 0 +Comment Quad 1000 +Comment DefaultRuleThickness 40 +Comment BigOpSpacing 111.111 166.667 200 600 100 +Comment Ascendible characters (74) % macro - PS charname +Comment Ascending 0, 16, 18, 32, 48 % ( - parenleft +Comment Ascending 1, 17, 19, 33, 49 % ) - parenright +Comment Ascending 2, 104, 20, 34, 50 % [ - bracketleft +Comment Ascending 3, 105, 21, 35, 51 % ] - bracketright +Comment Ascending 4, 106, 22, 36, 52 % lfloor - floorleft +Comment Ascending 5, 107, 23, 37, 53 % rfloor - floorright +Comment Ascending 6, 108, 24, 38, 54 % lceil - ceilingleft +Comment Ascending 7, 109, 25, 39, 55 % rceil - ceilingright +Comment Ascending 8, 110, 26, 40, 56 % { - braceleft +Comment Ascending 9, 111, 27, 41, 57 % } - braceright +Comment Ascending 10, 68, 28, 42 % < - anglebracketleft +Comment Ascending 11, 69, 29, 43 % > - anglebracketright +Comment Ascending 14, 46, 30, 44 % / - slash +Comment Ascending 15, 47, 31, 45 % \ - backslash +Comment Ascending 70, 71 % bigsqcup - unionsq +Comment Ascending 72, 73 % oint - contintegral +Comment Ascending 74, 75 % bigodot - circledot +Comment Ascending 76, 77 % bigoplus - circleplus +Comment Ascending 78, 79 % bigotimes - circlemultiply +Comment Ascending 80, 88 % sum - summation +Comment Ascending 81, 89 % prod - product +Comment Ascending 82, 90 % int - integral +Comment Ascending 83, 91 % bigcup - union +Comment Ascending 84, 92 % bigcap - intersection +Comment Ascending 85, 93 % biguplus - unionmulti +Comment Ascending 86, 94 % bigwedge - logicaland +Comment Ascending 87, 95 % bigvee - logicalor +Comment Ascending 96, 97 % coprod - coproduct +Comment Ascending 98, 99, 100 % widehat - hatwide +Comment Ascending 101, 102, 103 % widetilde - tildewide +Comment Ascending 112, 113, 114, 115, 116 % radical - sqrt +Comment Extensible characters (28) +Comment Extensible 12 top 0 mid 0 bot 0 rep 12 % vert - thin bar +Comment Extensible 13 top 0 mid 0 bot 0 rep 13 % Vert - thin double bar +Comment Extensible 48 top 48 mid 0 bot 64 rep 66 % ( - parenleft +Comment Extensible 49 top 49 mid 0 bot 65 rep 67 % ) - parenright +Comment Extensible 50 top 50 mid 0 bot 52 rep 54 % [ - bracketleft +Comment Extensible 51 top 51 mid 0 bot 53 rep 55 % ] - bracketright +Comment Extensible 52 top 0 mid 0 bot 52 rep 54 % lfloor - floorleft +Comment Extensible 53 top 0 mid 0 bot 53 rep 55 % rfloor - floorright +Comment Extensible 54 top 50 mid 0 bot 0 rep 54 % lceil - ceilingleft +Comment Extensible 55 top 51 mid 0 bot 0 rep 55 % rceil - ceilingright +Comment Extensible 56 top 56 mid 60 bot 58 rep 62 % { - braceleft +Comment Extensible 57 top 57 mid 61 bot 59 rep 62 % } - braceright +Comment Extensible 58 top 56 mid 0 bot 58 rep 62 % lgroup +Comment Extensible 59 top 57 mid 0 bot 59 rep 62 % rgroup +Comment Extensible 60 top 0 mid 0 bot 0 rep 63 % arrowvert +Comment Extensible 61 top 0 mid 0 bot 0 rep 119 % Arrowvert +Comment Extensible 62 top 0 mid 0 bot 0 rep 62 % bracevert +Comment Extensible 63 top 120 mid 0 bot 121 rep 63 % updownarrow +Comment Extensible 64 top 56 mid 0 bot 59 rep 62 % lmoustache +Comment Extensible 65 top 57 mid 0 bot 58 rep 62 % rmoustache +Comment Extensible 66 top 0 mid 0 bot 0 rep 66 % parenleftexten +Comment Extensible 67 top 0 mid 0 bot 0 rep 67 % parenrightexten +Comment Extensible 116 top 118 mid 0 bot 116 rep 117 % radical +Comment Extensible 119 top 126 mid 0 bot 127 rep 119 % Updownarrow +Comment Extensible 120 top 120 mid 0 bot 0 rep 63 % uparrow +Comment Extensible 121 top 0 mid 0 bot 121 rep 63 % downarrow +Comment Extensible 126 top 126 mid 0 bot 0 rep 119 % Uparrow +Comment Extensible 127 top 0 mid 0 bot 127 rep 119 % Downarrow +StartCharMetrics 129 +C 0 ; WX 458.333 ; N parenleftbig ; B 152 -1159 413 40 ; +C 1 ; WX 458.333 ; N parenrightbig ; B 44 -1159 305 40 ; +C 2 ; WX 416.667 ; N bracketleftbig ; B 202 -1159 394 40 ; +C 3 ; WX 416.667 ; N bracketrightbig ; B 22 -1159 214 40 ; +C 4 ; WX 472.222 ; N floorleftbig ; B 202 -1159 449 40 ; +C 5 ; WX 472.222 ; N floorrightbig ; B 22 -1159 269 40 ; +C 6 ; WX 472.222 ; N ceilingleftbig ; B 202 -1159 449 40 ; +C 7 ; WX 472.222 ; N ceilingrightbig ; B 22 -1159 269 40 ; +C 8 ; WX 583.333 ; N braceleftbig ; B 113 -1159 469 40 ; +C 9 ; WX 583.333 ; N bracerightbig ; B 113 -1159 469 40 ; +C 10 ; WX 472.222 ; N angbracketleftbig ; B 98 -1160 393 40 ; +C 11 ; WX 472.222 ; N angbracketrightbig ; B 78 -1160 373 40 ; +C 12 ; WX 333.333 ; N vextendsingle ; B 145 -621 188 21 ; +C 13 ; WX 555.556 ; N vextenddouble ; B 145 -621 410 21 ; +C 14 ; WX 577.778 ; N slashbig ; B 56 -1159 521 40 ; +C 15 ; WX 577.778 ; N backslashbig ; B 56 -1159 521 40 ; +C 16 ; WX 597.222 ; N parenleftBig ; B 180 -1759 560 40 ; +C 17 ; WX 597.222 ; N parenrightBig ; B 36 -1759 416 40 ; +C 18 ; WX 736.111 ; N parenleftbigg ; B 208 -2359 700 40 ; +C 19 ; WX 736.111 ; N parenrightbigg ; B 35 -2359 527 40 ; +C 20 ; WX 527.778 ; N bracketleftbigg ; B 250 -2359 513 40 ; +C 21 ; WX 527.778 ; N bracketrightbigg ; B 14 -2359 277 40 ; +C 22 ; WX 583.333 ; N floorleftbigg ; B 250 -2359 568 40 ; +C 23 ; WX 583.333 ; N floorrightbigg ; B 14 -2359 332 40 ; +C 24 ; WX 583.333 ; N ceilingleftbigg ; B 250 -2359 568 40 ; +C 25 ; WX 583.333 ; N ceilingrightbigg ; B 14 -2359 332 40 ; +C 26 ; WX 750 ; N braceleftbigg ; B 131 -2359 618 40 ; +C 27 ; WX 750 ; N bracerightbigg ; B 131 -2359 618 40 ; +C 28 ; WX 750 ; N angbracketleftbigg ; B 125 -2359 652 40 ; +C 29 ; WX 750 ; N angbracketrightbigg ; B 97 -2359 624 40 ; +C 30 ; WX 1044.44 ; N slashbigg ; B 56 -2359 987 40 ; +C 31 ; WX 1044.44 ; N backslashbigg ; B 56 -2359 987 40 ; +C 32 ; WX 791.667 ; N parenleftBigg ; B 236 -2959 757 40 ; +C 33 ; WX 791.667 ; N parenrightBigg ; B 34 -2959 555 40 ; +C 34 ; WX 583.333 ; N bracketleftBigg ; B 275 -2959 571 40 ; +C 35 ; WX 583.333 ; N bracketrightBigg ; B 11 -2959 307 40 ; +C 36 ; WX 638.889 ; N floorleftBigg ; B 275 -2959 627 40 ; +C 37 ; WX 638.889 ; N floorrightBigg ; B 11 -2959 363 40 ; +C 38 ; WX 638.889 ; N ceilingleftBigg ; B 275 -2959 627 40 ; +C 39 ; WX 638.889 ; N ceilingrightBigg ; B 11 -2959 363 40 ; +C 40 ; WX 805.556 ; N braceleftBigg ; B 144 -2959 661 40 ; +C 41 ; WX 805.556 ; N bracerightBigg ; B 144 -2959 661 40 ; +C 42 ; WX 805.556 ; N angbracketleftBigg ; B 139 -2960 697 40 ; +C 43 ; WX 805.556 ; N angbracketrightBigg ; B 108 -2960 666 40 ; +C 44 ; WX 1277.78 ; N slashBigg ; B 56 -2959 1221 40 ; +C 45 ; WX 1277.78 ; N backslashBigg ; B 56 -2959 1221 40 ; +C 46 ; WX 811.111 ; N slashBig ; B 56 -1759 754 40 ; +C 47 ; WX 811.111 ; N backslashBig ; B 56 -1759 754 40 ; +C 48 ; WX 875 ; N parenlefttp ; B 291 -1770 842 39 ; +C 49 ; WX 875 ; N parenrighttp ; B 32 -1770 583 39 ; +C 50 ; WX 666.667 ; N bracketlefttp ; B 326 -1760 659 39 ; +C 51 ; WX 666.667 ; N bracketrighttp ; B 7 -1760 340 39 ; +C 52 ; WX 666.667 ; N bracketleftbt ; B 326 -1759 659 40 ; +C 53 ; WX 666.667 ; N bracketrightbt ; B 7 -1759 340 40 ; +C 54 ; WX 666.667 ; N bracketleftex ; B 326 -601 395 1 ; +C 55 ; WX 666.667 ; N bracketrightex ; B 271 -601 340 1 ; +C 56 ; WX 888.889 ; N bracelefttp ; B 384 -910 718 -1 ; +C 57 ; WX 888.889 ; N bracerighttp ; B 170 -910 504 -1 ; +C 58 ; WX 888.889 ; N braceleftbt ; B 384 -899 718 10 ; +C 59 ; WX 888.889 ; N bracerightbt ; B 170 -899 504 10 ; +C 60 ; WX 888.889 ; N braceleftmid ; B 170 -1810 504 10 ; +C 61 ; WX 888.889 ; N bracerightmid ; B 384 -1810 718 10 ; +C 62 ; WX 888.889 ; N braceex ; B 384 -310 504 10 ; +C 63 ; WX 666.667 ; N arrowvertex ; B 312 -601 355 1 ; +C 64 ; WX 875 ; N parenleftbt ; B 291 -1759 842 50 ; +C 65 ; WX 875 ; N parenrightbt ; B 32 -1759 583 50 ; +C 66 ; WX 875 ; N parenleftex ; B 291 -610 402 10 ; +C 67 ; WX 875 ; N parenrightex ; B 472 -610 583 10 ; +C 68 ; WX 611.111 ; N angbracketleftBig ; B 112 -1759 522 40 ; +C 69 ; WX 611.111 ; N angbracketrightBig ; B 88 -1759 498 40 ; +C 70 ; WX 833.333 ; N unionsqtext ; B 56 -1000 776 0 ; +C 71 ; WX 1111.11 ; N unionsqdisplay ; B 56 -1400 1054 0 ; +C 72 ; WX 472.222 ; N contintegraltext ; B 56 -1111 609 0 ; +C 73 ; WX 555.556 ; N contintegraldisplay ; B 56 -2222 943 0 ; +C 74 ; WX 1111.11 ; N circledottext ; B 56 -1000 1054 0 ; +C 75 ; WX 1511.11 ; N circledotdisplay ; B 56 -1400 1454 0 ; +C 76 ; WX 1111.11 ; N circleplustext ; B 56 -1000 1054 0 ; +C 77 ; WX 1511.11 ; N circleplusdisplay ; B 56 -1400 1454 0 ; +C 78 ; WX 1111.11 ; N circlemultiplytext ; B 56 -1000 1054 0 ; +C 79 ; WX 1511.11 ; N circlemultiplydisplay ; B 56 -1400 1454 0 ; +C 80 ; WX 1055.56 ; N summationtext ; B 56 -1000 999 0 ; +C 81 ; WX 944.444 ; N producttext ; B 56 -1000 887 0 ; +C 82 ; WX 472.222 ; N integraltext ; B 56 -1111 609 0 ; +C 83 ; WX 833.333 ; N uniontext ; B 56 -1000 776 0 ; +C 84 ; WX 833.333 ; N intersectiontext ; B 56 -1000 776 0 ; +C 85 ; WX 833.333 ; N unionmultitext ; B 56 -1000 776 0 ; +C 86 ; WX 833.333 ; N logicalandtext ; B 56 -1000 776 0 ; +C 87 ; WX 833.333 ; N logicalortext ; B 56 -1000 776 0 ; +C 88 ; WX 1444.44 ; N summationdisplay ; B 56 -1400 1387 0 ; +C 89 ; WX 1277.78 ; N productdisplay ; B 56 -1400 1221 0 ; +C 90 ; WX 555.556 ; N integraldisplay ; B 56 -2222 943 0 ; +C 91 ; WX 1111.11 ; N uniondisplay ; B 56 -1400 1054 0 ; +C 92 ; WX 1111.11 ; N intersectiondisplay ; B 56 -1400 1054 0 ; +C 93 ; WX 1111.11 ; N unionmultidisplay ; B 56 -1400 1054 0 ; +C 94 ; WX 1111.11 ; N logicalanddisplay ; B 56 -1400 1054 0 ; +C 95 ; WX 1111.11 ; N logicalordisplay ; B 56 -1400 1054 0 ; +C 96 ; WX 944.444 ; N coproducttext ; B 56 -1000 887 0 ; +C 97 ; WX 1277.78 ; N coproductdisplay ; B 56 -1400 1221 0 ; +C 98 ; WX 555.556 ; N hatwide ; B -5 562 561 744 ; +C 99 ; WX 1000 ; N hatwider ; B -4 575 1003 772 ; +C 100 ; WX 1444.44 ; N hatwidest ; B -3 575 1446 772 ; +C 101 ; WX 555.556 ; N tildewide ; B 0 608 555 722 ; +C 102 ; WX 1000 ; N tildewider ; B 0 624 999 750 ; +C 103 ; WX 1444.44 ; N tildewidest ; B 0 623 1443 750 ; +C 104 ; WX 472.222 ; N bracketleftBig ; B 226 -1759 453 40 ; +C 105 ; WX 472.222 ; N bracketrightBig ; B 18 -1759 245 40 ; +C 106 ; WX 527.778 ; N floorleftBig ; B 226 -1759 509 40 ; +C 107 ; WX 527.778 ; N floorrightBig ; B 18 -1759 301 40 ; +C 108 ; WX 527.778 ; N ceilingleftBig ; B 226 -1759 509 40 ; +C 109 ; WX 527.778 ; N ceilingrightBig ; B 18 -1759 301 40 ; +C 110 ; WX 666.667 ; N braceleftBig ; B 119 -1759 547 40 ; +C 111 ; WX 666.667 ; N bracerightBig ; B 119 -1759 547 40 ; +C 112 ; WX 1000 ; N radicalbig ; B 110 -1160 1020 40 ; +C 113 ; WX 1000 ; N radicalBig ; B 110 -1760 1020 40 ; +C 114 ; WX 1000 ; N radicalbigg ; B 111 -2360 1020 40 ; +C 115 ; WX 1000 ; N radicalBigg ; B 111 -2960 1020 40 ; +C 116 ; WX 1055.56 ; N radicalbt ; B 111 -1800 742 20 ; +C 117 ; WX 1055.56 ; N radicalvertex ; B 702 -620 742 20 ; +C 118 ; WX 1055.56 ; N radicaltp ; B 702 -580 1076 40 ; +C 119 ; WX 777.778 ; N arrowvertexdbl ; B 257 -601 521 1 ; +C 120 ; WX 666.667 ; N arrowtp ; B 111 -600 556 0 ; +C 121 ; WX 666.667 ; N arrowbt ; B 111 -600 556 0 ; +C 122 ; WX 450 ; N bracehtipdownleft ; B -24 -214 460 120 ; +C 123 ; WX 450 ; N bracehtipdownright ; B -10 -214 474 120 ; +C 124 ; WX 450 ; N bracehtipupleft ; B -24 0 460 334 ; +C 125 ; WX 450 ; N bracehtipupright ; B -10 0 474 334 ; +C 126 ; WX 777.778 ; N arrowdbltp ; B 56 -600 722 -1 ; +C 127 ; WX 777.778 ; N arrowdblbt ; B 56 -599 722 0 ; +C -1 ; WX 333.333 ; N space ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmmi10.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmmi10.afm new file mode 100644 index 00000000..f47d6ba0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmmi10.afm @@ -0,0 +1,326 @@ +StartFontMetrics 2.0 +Comment Creation Date: Thu Jun 21 22:23:22 1990 +Comment UniqueID 5000785 +FontName CMMI10 +EncodingScheme FontSpecific +FullName CMMI10 +FamilyName Computer Modern +Weight Medium +ItalicAngle -14.04 +IsFixedPitch false +Version 1.00A +Notice Copyright (c) 1997 American Mathematical Society. All Rights Reserved. +Comment Computer Modern fonts were designed by Donald E. Knuth +FontBBox -32 -250 1048 750 +CapHeight 683.333 +XHeight 430.556 +Ascender 694.444 +Descender -194.444 +Comment FontID CMMI +Comment DesignSize 10 (pts) +Comment CharacterCodingScheme TeX math italic +Comment Space 0 0 0 +Comment Quad 1000 +StartCharMetrics 129 +C 0 ; WX 615.276 ; N Gamma ; B 39 0 723 680 ; +C 1 ; WX 833.333 ; N Delta ; B 49 0 787 716 ; +C 2 ; WX 762.774 ; N Theta ; B 50 -22 739 705 ; +C 3 ; WX 694.444 ; N Lambda ; B 35 0 666 716 ; +C 4 ; WX 742.361 ; N Xi ; B 53 0 777 677 ; +C 5 ; WX 831.25 ; N Pi ; B 39 0 880 680 ; +C 6 ; WX 779.861 ; N Sigma ; B 59 0 807 683 ; +C 7 ; WX 583.333 ; N Upsilon ; B 29 0 700 705 ; +C 8 ; WX 666.667 ; N Phi ; B 24 0 642 683 ; +C 9 ; WX 612.221 ; N Psi ; B 28 0 692 683 ; +C 10 ; WX 772.396 ; N Omega ; B 80 0 785 705 ; +C 11 ; WX 639.7 ; N alpha ; B 41 -11 601 442 ; +C 12 ; WX 565.625 ; N beta ; B 25 -194 590 705 ; +C 13 ; WX 517.73 ; N gamma ; B 18 -215 542 442 ; +C 14 ; WX 444.444 ; N delta ; B 41 -12 452 705 ; +C 15 ; WX 405.902 ; N epsilon1 ; B 47 -11 376 431 ; +C 16 ; WX 437.5 ; N zeta ; B 47 -205 474 697 ; +C 17 ; WX 496.53 ; N eta ; B 29 -216 496 442 ; +C 18 ; WX 469.442 ; N theta ; B 42 -11 455 705 ; +C 19 ; WX 353.935 ; N iota ; B 56 -11 324 442 ; +C 20 ; WX 576.159 ; N kappa ; B 55 -11 546 442 ; +C 21 ; WX 583.333 ; N lambda ; B 53 -13 547 694 ; +C 22 ; WX 602.548 ; N mu ; B 30 -216 572 442 ; +C 23 ; WX 493.981 ; N nu ; B 53 0 524 442 ; +C 24 ; WX 437.5 ; N xi ; B 24 -205 446 697 ; +C 25 ; WX 570.025 ; N pi ; B 27 -11 567 431 ; +C 26 ; WX 517.014 ; N rho ; B 30 -216 502 442 ; +C 27 ; WX 571.429 ; N sigma ; B 38 -11 567 431 ; +C 28 ; WX 437.153 ; N tau ; B 27 -12 511 431 ; +C 29 ; WX 540.278 ; N upsilon ; B 29 -11 524 443 ; +C 30 ; WX 595.833 ; N phi ; B 49 -205 573 694 ; +C 31 ; WX 625.691 ; N chi ; B 32 -205 594 442 ; +C 32 ; WX 651.39 ; N psi ; B 29 -205 635 694 ; +C 33 ; WX 622.453 ; N omega ; B 13 -11 605 443 ; +C 34 ; WX 466.316 ; N epsilon ; B 27 -22 428 453 ; +C 35 ; WX 591.438 ; N theta1 ; B 29 -11 561 705 ; +C 36 ; WX 828.125 ; N pi1 ; B 27 -11 817 431 ; +C 37 ; WX 517.014 ; N rho1 ; B 74 -194 502 442 ; +C 38 ; WX 362.846 ; N sigma1 ; B 32 -108 408 442 ; +C 39 ; WX 654.165 ; N phi1 ; B 50 -218 619 442 ; +C 40 ; WX 1000 ; N arrowlefttophalf ; B 56 230 943 428 ; +C 41 ; WX 1000 ; N arrowleftbothalf ; B 56 72 943 270 ; +C 42 ; WX 1000 ; N arrowrighttophalf ; B 56 230 943 428 ; +C 43 ; WX 1000 ; N arrowrightbothalf ; B 56 72 943 270 ; +C 44 ; WX 277.778 ; N arrowhookleft ; B 56 230 221 464 ; +C 45 ; WX 277.778 ; N arrowhookright ; B 56 230 221 464 ; +C 46 ; WX 500 ; N triangleright ; B 27 -4 472 504 ; +C 47 ; WX 500 ; N triangleleft ; B 27 -4 472 504 ; +C 48 ; WX 500 ; N zerooldstyle ; B 40 -22 459 453 ; +C 49 ; WX 500 ; N oneoldstyle ; B 92 0 418 453 ; +C 50 ; WX 500 ; N twooldstyle ; B 44 0 449 453 ; +C 51 ; WX 500 ; N threeoldstyle ; B 42 -216 457 453 ; +C 52 ; WX 500 ; N fouroldstyle ; B 28 -194 471 464 ; +C 53 ; WX 500 ; N fiveoldstyle ; B 50 -216 449 453 ; +C 54 ; WX 500 ; N sixoldstyle ; B 42 -22 457 666 ; +C 55 ; WX 500 ; N sevenoldstyle ; B 56 -216 485 463 ; +C 56 ; WX 500 ; N eightoldstyle ; B 42 -22 457 666 ; +C 57 ; WX 500 ; N nineoldstyle ; B 42 -216 457 453 ; +C 58 ; WX 277.778 ; N period ; B 86 0 192 106 ; +C 59 ; WX 277.778 ; N comma ; B 86 -193 203 106 ; +C 60 ; WX 777.778 ; N less ; B 83 -39 694 539 ; +C 61 ; WX 500 ; N slash ; B 56 -250 443 750 ; +C 62 ; WX 777.778 ; N greater ; B 83 -39 694 539 ; +C 63 ; WX 500 ; N star ; B 4 16 496 486 ; +C 64 ; WX 530.902 ; N partialdiff ; B 40 -22 566 716 ; +C 65 ; WX 750 ; N A ; B 35 0 722 716 ; +C 66 ; WX 758.508 ; N B ; B 42 0 756 683 ; +C 67 ; WX 714.72 ; N C ; B 51 -22 759 705 ; +C 68 ; WX 827.915 ; N D ; B 41 0 803 683 ; +C 69 ; WX 738.193 ; N E ; B 39 0 765 680 ; +C 70 ; WX 643.055 ; N F ; B 39 0 751 680 ; +C 71 ; WX 786.247 ; N G ; B 51 -22 760 705 ; +C 72 ; WX 831.25 ; N H ; B 39 0 881 683 ; +C 73 ; WX 439.583 ; N I ; B 34 0 498 683 ; +C 74 ; WX 554.512 ; N J ; B 73 -22 633 683 ; +C 75 ; WX 849.305 ; N K ; B 39 0 889 683 ; +C 76 ; WX 680.556 ; N L ; B 39 0 643 683 ; +C 77 ; WX 970.138 ; N M ; B 43 0 1044 683 ; +C 78 ; WX 803.471 ; N N ; B 39 0 881 683 ; +C 79 ; WX 762.774 ; N O ; B 50 -22 739 705 ; +C 80 ; WX 642.012 ; N P ; B 41 0 753 683 ; +C 81 ; WX 790.553 ; N Q ; B 50 -194 739 705 ; +C 82 ; WX 759.288 ; N R ; B 41 -22 755 683 ; +C 83 ; WX 613.193 ; N S ; B 53 -22 645 705 ; +C 84 ; WX 584.375 ; N T ; B 24 0 704 677 ; +C 85 ; WX 682.776 ; N U ; B 68 -22 760 683 ; +C 86 ; WX 583.333 ; N V ; B 56 -22 769 683 ; +C 87 ; WX 944.444 ; N W ; B 55 -22 1048 683 ; +C 88 ; WX 828.472 ; N X ; B 27 0 851 683 ; +C 89 ; WX 580.556 ; N Y ; B 34 0 762 683 ; +C 90 ; WX 682.638 ; N Z ; B 59 0 722 683 ; +C 91 ; WX 388.889 ; N flat ; B 56 -22 332 750 ; +C 92 ; WX 388.889 ; N natural ; B 79 -217 309 728 ; +C 93 ; WX 388.889 ; N sharp ; B 56 -216 332 716 ; +C 94 ; WX 1000 ; N slurbelow ; B 56 133 943 371 ; +C 95 ; WX 1000 ; N slurabove ; B 56 130 943 381 ; +C 96 ; WX 416.667 ; N lscript ; B 11 -12 398 705 ; +C 97 ; WX 528.588 ; N a ; B 40 -11 498 442 ; +C 98 ; WX 429.165 ; N b ; B 47 -11 415 694 ; +C 99 ; WX 432.755 ; N c ; B 41 -11 430 442 ; +C 100 ; WX 520.486 ; N d ; B 40 -11 517 694 ; +C 101 ; WX 465.625 ; N e ; B 46 -11 430 442 ; +C 102 ; WX 489.583 ; N f ; B 53 -205 552 705 ; +C 103 ; WX 476.967 ; N g ; B 16 -205 474 442 ; +C 104 ; WX 576.159 ; N h ; B 55 -11 546 694 ; +C 105 ; WX 344.511 ; N i ; B 29 -11 293 661 ; +C 106 ; WX 411.805 ; N j ; B -13 -205 397 661 ; +C 107 ; WX 520.602 ; N k ; B 55 -11 508 694 ; +C 108 ; WX 298.378 ; N l ; B 46 -11 260 694 ; +C 109 ; WX 878.012 ; N m ; B 29 -11 848 442 ; +C 110 ; WX 600.233 ; N n ; B 29 -11 571 442 ; +C 111 ; WX 484.721 ; N o ; B 41 -11 469 442 ; +C 112 ; WX 503.125 ; N p ; B -32 -194 490 442 ; +C 113 ; WX 446.412 ; N q ; B 40 -194 453 442 ; +C 114 ; WX 451.158 ; N r ; B 29 -11 436 442 ; +C 115 ; WX 468.75 ; N s ; B 52 -11 419 442 ; +C 116 ; WX 361.111 ; N t ; B 23 -11 330 626 ; +C 117 ; WX 572.456 ; N u ; B 29 -11 543 442 ; +C 118 ; WX 484.722 ; N v ; B 29 -11 468 443 ; +C 119 ; WX 715.916 ; N w ; B 29 -11 691 443 ; +C 120 ; WX 571.527 ; N x ; B 29 -11 527 442 ; +C 121 ; WX 490.28 ; N y ; B 29 -205 490 442 ; +C 122 ; WX 465.048 ; N z ; B 43 -11 467 442 ; +C 123 ; WX 322.454 ; N dotlessi ; B 29 -11 293 442 ; +C 124 ; WX 384.028 ; N dotlessj ; B -13 -205 360 442 ; +C 125 ; WX 636.457 ; N weierstrass ; B 76 -216 618 453 ; +C 126 ; WX 500 ; N vector ; B 182 516 625 714 ; +C 127 ; WX 277.778 ; N tie ; B 264 538 651 665 ; +C -1 ; WX 333.333 ; N space ; B 0 0 0 0 ; +EndCharMetrics +Comment The following are bogus kern pairs for TeX positioning of accents +StartKernData +StartKernPairs 166 +KPX Gamma slash -55.556 +KPX Gamma comma -111.111 +KPX Gamma period -111.111 +KPX Gamma tie 83.333 +KPX Delta tie 166.667 +KPX Theta tie 83.333 +KPX Lambda tie 166.667 +KPX Xi tie 83.333 +KPX Pi slash -55.556 +KPX Pi comma -55.556 +KPX Pi period -55.556 +KPX Pi tie 55.556 +KPX Sigma tie 83.333 +KPX Upsilon slash -55.556 +KPX Upsilon comma -111.111 +KPX Upsilon period -111.111 +KPX Upsilon tie 55.556 +KPX Phi tie 83.333 +KPX Psi slash -55.556 +KPX Psi comma -55.556 +KPX Psi period -55.556 +KPX Psi tie 55.556 +KPX Omega tie 83.333 +KPX alpha tie 27.778 +KPX beta tie 83.333 +KPX delta comma -55.556 +KPX delta period -55.556 +KPX delta tie 55.556 +KPX epsilon1 tie 55.556 +KPX zeta tie 83.333 +KPX eta tie 55.556 +KPX theta tie 83.333 +KPX iota tie 55.556 +KPX mu tie 27.778 +KPX nu comma -55.556 +KPX nu period -55.556 +KPX nu tie 27.778 +KPX xi tie 111.111 +KPX rho tie 83.333 +KPX sigma comma -55.556 +KPX sigma period -55.556 +KPX tau comma -55.556 +KPX tau period -55.556 +KPX tau tie 27.778 +KPX upsilon tie 27.778 +KPX phi tie 83.333 +KPX chi tie 55.556 +KPX psi tie 111.111 +KPX epsilon tie 83.333 +KPX theta1 tie 83.333 +KPX rho1 tie 83.333 +KPX sigma1 tie 83.333 +KPX phi1 tie 83.333 +KPX slash Delta -55.556 +KPX slash A -55.556 +KPX slash M -55.556 +KPX slash N -55.556 +KPX slash Y 55.556 +KPX slash Z -55.556 +KPX partialdiff tie 83.333 +KPX A tie 138.889 +KPX B tie 83.333 +KPX C slash -27.778 +KPX C comma -55.556 +KPX C period -55.556 +KPX C tie 83.333 +KPX D tie 55.556 +KPX E tie 83.333 +KPX F slash -55.556 +KPX F comma -111.111 +KPX F period -111.111 +KPX F tie 83.333 +KPX G tie 83.333 +KPX H slash -55.556 +KPX H comma -55.556 +KPX H period -55.556 +KPX H tie 55.556 +KPX I tie 111.111 +KPX J slash -55.556 +KPX J comma -111.111 +KPX J period -111.111 +KPX J tie 166.667 +KPX K slash -55.556 +KPX K comma -55.556 +KPX K period -55.556 +KPX K tie 55.556 +KPX L tie 27.778 +KPX M slash -55.556 +KPX M comma -55.556 +KPX M period -55.556 +KPX M tie 83.333 +KPX N slash -83.333 +KPX N slash -27.778 +KPX N comma -55.556 +KPX N period -55.556 +KPX N tie 83.333 +KPX O tie 83.333 +KPX P slash -55.556 +KPX P comma -111.111 +KPX P period -111.111 +KPX P tie 83.333 +KPX Q tie 83.333 +KPX R tie 83.333 +KPX S slash -55.556 +KPX S comma -55.556 +KPX S period -55.556 +KPX S tie 83.333 +KPX T slash -27.778 +KPX T comma -55.556 +KPX T period -55.556 +KPX T tie 83.333 +KPX U comma -111.111 +KPX U period -111.111 +KPX U slash -55.556 +KPX U tie 27.778 +KPX V comma -166.667 +KPX V period -166.667 +KPX V slash -111.111 +KPX W comma -166.667 +KPX W period -166.667 +KPX W slash -111.111 +KPX X slash -83.333 +KPX X slash -27.778 +KPX X comma -55.556 +KPX X period -55.556 +KPX X tie 83.333 +KPX Y comma -166.667 +KPX Y period -166.667 +KPX Y slash -111.111 +KPX Z slash -55.556 +KPX Z comma -55.556 +KPX Z period -55.556 +KPX Z tie 83.333 +KPX lscript tie 111.111 +KPX c tie 55.556 +KPX d Y 55.556 +KPX d Z -55.556 +KPX d j -111.111 +KPX d f -166.667 +KPX d tie 166.667 +KPX e tie 55.556 +KPX f comma -55.556 +KPX f period -55.556 +KPX f tie 166.667 +KPX g tie 27.778 +KPX h tie -27.778 +KPX j comma -55.556 +KPX j period -55.556 +KPX l tie 83.333 +KPX o tie 55.556 +KPX p tie 83.333 +KPX q tie 83.333 +KPX r comma -55.556 +KPX r period -55.556 +KPX r tie 55.556 +KPX s tie 55.556 +KPX t tie 83.333 +KPX u tie 27.778 +KPX v tie 27.778 +KPX w tie 83.333 +KPX x tie 27.778 +KPX y tie 55.556 +KPX z tie 55.556 +KPX dotlessi tie 27.778 +KPX dotlessj tie 83.333 +KPX weierstrass tie 111.111 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmr10.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmr10.afm new file mode 100644 index 00000000..4d586fe6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmr10.afm @@ -0,0 +1,343 @@ +StartFontMetrics 2.0 +Comment Creation Date: Thu Jun 21 22:23:28 1990 +Comment UniqueID 5000793 +FontName CMR10 +EncodingScheme FontSpecific +FullName CMR10 +FamilyName Computer Modern +Weight Medium +ItalicAngle 0.0 +IsFixedPitch false +Version 1.00B +Notice Copyright (c) 1997 American Mathematical Society. All Rights Reserved. +Comment Computer Modern fonts were designed by Donald E. Knuth +FontBBox -40 -250 1009 969 +CapHeight 683.333 +XHeight 430.556 +Ascender 694.444 +Descender -194.444 +Comment FontID CMR +Comment DesignSize 10 (pts) +Comment CharacterCodingScheme TeX text +Comment Space 333.333 166.667 111.111 +Comment ExtraSpace 111.111 +Comment Quad 1000 +StartCharMetrics 129 +C 0 ; WX 625 ; N Gamma ; B 33 0 582 680 ; +C 1 ; WX 833.333 ; N Delta ; B 47 0 785 716 ; +C 2 ; WX 777.778 ; N Theta ; B 56 -22 721 705 ; +C 3 ; WX 694.444 ; N Lambda ; B 32 0 661 716 ; +C 4 ; WX 666.667 ; N Xi ; B 42 0 624 677 ; +C 5 ; WX 750 ; N Pi ; B 33 0 716 680 ; +C 6 ; WX 722.222 ; N Sigma ; B 56 0 665 683 ; +C 7 ; WX 777.778 ; N Upsilon ; B 56 0 721 705 ; +C 8 ; WX 722.222 ; N Phi ; B 56 0 665 683 ; +C 9 ; WX 777.778 ; N Psi ; B 57 0 720 683 ; +C 10 ; WX 722.222 ; N Omega ; B 44 0 677 705 ; +C 11 ; WX 583.333 ; N ff ; B 27 0 628 705 ; L i ffi ; L l ffl ; +C 12 ; WX 555.556 ; N fi ; B 27 0 527 705 ; +C 13 ; WX 555.556 ; N fl ; B 27 0 527 705 ; +C 14 ; WX 833.333 ; N ffi ; B 27 0 804 705 ; +C 15 ; WX 833.333 ; N ffl ; B 27 0 804 705 ; +C 16 ; WX 277.778 ; N dotlessi ; B 33 0 247 442 ; +C 17 ; WX 305.556 ; N dotlessj ; B -40 -205 210 442 ; +C 18 ; WX 500 ; N grave ; B 107 510 293 698 ; +C 19 ; WX 500 ; N acute ; B 206 510 392 698 ; +C 20 ; WX 500 ; N caron ; B 118 516 381 638 ; +C 21 ; WX 500 ; N breve ; B 100 522 399 694 ; +C 22 ; WX 500 ; N macron ; B 69 559 430 590 ; +C 23 ; WX 750 ; N ring ; B 279 541 470 716 ; +C 24 ; WX 444.444 ; N cedilla ; B 131 -203 367 -22 ; +C 25 ; WX 500 ; N germandbls ; B 28 -11 471 705 ; +C 26 ; WX 722.222 ; N ae ; B 45 -11 693 448 ; +C 27 ; WX 777.778 ; N oe ; B 28 -11 749 448 ; +C 28 ; WX 500 ; N oslash ; B 35 -102 464 534 ; +C 29 ; WX 902.778 ; N AE ; B 32 0 874 683 ; +C 30 ; WX 1013.89 ; N OE ; B 70 -22 985 705 ; +C 31 ; WX 777.778 ; N Oslash ; B 56 -56 721 739 ; +C 32 ; WX 277.778 ; N suppress ; B 27 280 262 392 ; +C 33 ; WX 277.778 ; N exclam ; B 86 0 192 716 ; L quoteleft exclamdown ; +C 34 ; WX 500 ; N quotedblright ; B 33 395 347 694 ; +C 35 ; WX 833.333 ; N numbersign ; B 56 -194 776 694 ; +C 36 ; WX 500 ; N dollar ; B 56 -56 443 750 ; +C 37 ; WX 833.333 ; N percent ; B 56 -56 776 750 ; +C 38 ; WX 777.778 ; N ampersand ; B 42 -22 727 716 ; +C 39 ; WX 277.778 ; N quoteright ; B 86 395 206 694 ; L quoteright quotedblright ; +C 40 ; WX 388.889 ; N parenleft ; B 99 -250 331 750 ; +C 41 ; WX 388.889 ; N parenright ; B 57 -250 289 750 ; +C 42 ; WX 500 ; N asterisk ; B 65 319 434 750 ; +C 43 ; WX 777.778 ; N plus ; B 56 -83 721 583 ; +C 44 ; WX 277.778 ; N comma ; B 86 -193 203 106 ; +C 45 ; WX 333.333 ; N hyphen ; B 11 187 276 245 ; L hyphen endash ; +C 46 ; WX 277.778 ; N period ; B 86 0 192 106 ; +C 47 ; WX 500 ; N slash ; B 56 -250 443 750 ; +C 48 ; WX 500 ; N zero ; B 39 -22 460 666 ; +C 49 ; WX 500 ; N one ; B 89 0 419 666 ; +C 50 ; WX 500 ; N two ; B 50 0 449 666 ; +C 51 ; WX 500 ; N three ; B 42 -22 457 666 ; +C 52 ; WX 500 ; N four ; B 28 0 471 677 ; +C 53 ; WX 500 ; N five ; B 50 -22 449 666 ; +C 54 ; WX 500 ; N six ; B 42 -22 457 666 ; +C 55 ; WX 500 ; N seven ; B 56 -22 485 676 ; +C 56 ; WX 500 ; N eight ; B 42 -22 457 666 ; +C 57 ; WX 500 ; N nine ; B 42 -22 457 666 ; +C 58 ; WX 277.778 ; N colon ; B 86 0 192 431 ; +C 59 ; WX 277.778 ; N semicolon ; B 86 -193 195 431 ; +C 60 ; WX 277.778 ; N exclamdown ; B 86 -216 192 500 ; +C 61 ; WX 777.778 ; N equal ; B 56 133 721 367 ; +C 62 ; WX 472.222 ; N questiondown ; B 56 -205 415 500 ; +C 63 ; WX 472.222 ; N question ; B 56 0 415 705 ; L quoteleft questiondown ; +C 64 ; WX 777.778 ; N at ; B 56 -11 721 705 ; +C 65 ; WX 750 ; N A ; B 32 0 717 716 ; +C 66 ; WX 708.333 ; N B ; B 36 0 651 683 ; +C 67 ; WX 722.222 ; N C ; B 56 -22 665 705 ; +C 68 ; WX 763.889 ; N D ; B 35 0 707 683 ; +C 69 ; WX 680.556 ; N E ; B 33 0 652 680 ; +C 70 ; WX 652.778 ; N F ; B 33 0 610 680 ; +C 71 ; WX 784.722 ; N G ; B 56 -22 735 705 ; +C 72 ; WX 750 ; N H ; B 33 0 716 683 ; +C 73 ; WX 361.111 ; N I ; B 28 0 333 683 ; +C 74 ; WX 513.889 ; N J ; B 41 -22 465 683 ; +C 75 ; WX 777.778 ; N K ; B 33 0 736 683 ; +C 76 ; WX 625 ; N L ; B 33 0 582 683 ; +C 77 ; WX 916.667 ; N M ; B 37 0 879 683 ; +C 78 ; WX 750 ; N N ; B 33 0 716 683 ; +C 79 ; WX 777.778 ; N O ; B 56 -22 721 705 ; +C 80 ; WX 680.556 ; N P ; B 35 0 624 683 ; +C 81 ; WX 777.778 ; N Q ; B 56 -194 727 705 ; +C 82 ; WX 736.111 ; N R ; B 35 -22 732 683 ; +C 83 ; WX 555.556 ; N S ; B 56 -22 499 705 ; +C 84 ; WX 722.222 ; N T ; B 36 0 685 677 ; +C 85 ; WX 750 ; N U ; B 33 -22 716 683 ; +C 86 ; WX 750 ; N V ; B 19 -22 730 683 ; +C 87 ; WX 1027.78 ; N W ; B 18 -22 1009 683 ; +C 88 ; WX 750 ; N X ; B 24 0 726 683 ; +C 89 ; WX 750 ; N Y ; B 11 0 738 683 ; +C 90 ; WX 611.111 ; N Z ; B 56 0 560 683 ; +C 91 ; WX 277.778 ; N bracketleft ; B 118 -250 255 750 ; +C 92 ; WX 500 ; N quotedblleft ; B 152 394 466 693 ; +C 93 ; WX 277.778 ; N bracketright ; B 22 -250 159 750 ; +C 94 ; WX 500 ; N circumflex ; B 116 540 383 694 ; +C 95 ; WX 277.778 ; N dotaccent ; B 85 563 192 669 ; +C 96 ; WX 277.778 ; N quoteleft ; B 72 394 192 693 ; L quoteleft quotedblleft ; +C 97 ; WX 500 ; N a ; B 42 -11 493 448 ; +C 98 ; WX 555.556 ; N b ; B 28 -11 521 694 ; +C 99 ; WX 444.444 ; N c ; B 34 -11 415 448 ; +C 100 ; WX 555.556 ; N d ; B 34 -11 527 694 ; +C 101 ; WX 444.444 ; N e ; B 28 -11 415 448 ; +C 102 ; WX 305.556 ; N f ; B 33 0 357 705 ; L i fi ; L f ff ; L l fl ; +C 103 ; WX 500 ; N g ; B 28 -206 485 453 ; +C 104 ; WX 555.556 ; N h ; B 32 0 535 694 ; +C 105 ; WX 277.778 ; N i ; B 33 0 247 669 ; +C 106 ; WX 305.556 ; N j ; B -40 -205 210 669 ; +C 107 ; WX 527.778 ; N k ; B 28 0 511 694 ; +C 108 ; WX 277.778 ; N l ; B 33 0 255 694 ; +C 109 ; WX 833.333 ; N m ; B 32 0 813 442 ; +C 110 ; WX 555.556 ; N n ; B 32 0 535 442 ; +C 111 ; WX 500 ; N o ; B 28 -11 471 448 ; +C 112 ; WX 555.556 ; N p ; B 28 -194 521 442 ; +C 113 ; WX 527.778 ; N q ; B 34 -194 527 442 ; +C 114 ; WX 391.667 ; N r ; B 28 0 364 442 ; +C 115 ; WX 394.444 ; N s ; B 33 -11 360 448 ; +C 116 ; WX 388.889 ; N t ; B 19 -11 332 615 ; +C 117 ; WX 555.556 ; N u ; B 32 -11 535 442 ; +C 118 ; WX 527.778 ; N v ; B 19 -11 508 431 ; +C 119 ; WX 722.222 ; N w ; B 18 -11 703 431 ; +C 120 ; WX 527.778 ; N x ; B 12 0 516 431 ; +C 121 ; WX 527.778 ; N y ; B 19 -205 508 431 ; +C 122 ; WX 444.444 ; N z ; B 28 0 401 431 ; +C 123 ; WX 500 ; N endash ; B 0 255 499 277 ; L hyphen emdash ; +C 124 ; WX 1000 ; N emdash ; B 0 255 999 277 ; +C 125 ; WX 500 ; N hungarumlaut ; B 128 513 420 699 ; +C 126 ; WX 500 ; N tilde ; B 83 575 416 668 ; +C 127 ; WX 500 ; N dieresis ; B 103 569 396 669 ; +C -1 ; WX 333.333 ; N space ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 183 +KPX ff quoteright 77.778 +KPX ff question 77.778 +KPX ff exclam 77.778 +KPX ff parenright 77.778 +KPX ff bracketright 77.778 +KPX suppress l -277.778 +KPX suppress L -319.444 +KPX quoteright question 111.111 +KPX quoteright exclam 111.111 +KPX A t -27.778 +KPX A C -27.778 +KPX A O -27.778 +KPX A G -27.778 +KPX A U -27.778 +KPX A Q -27.778 +KPX A T -83.333 +KPX A Y -83.333 +KPX A V -111.111 +KPX A W -111.111 +KPX D X -27.778 +KPX D W -27.778 +KPX D A -27.778 +KPX D V -27.778 +KPX D Y -27.778 +KPX F o -83.333 +KPX F e -83.333 +KPX F u -83.333 +KPX F r -83.333 +KPX F a -83.333 +KPX F A -111.111 +KPX F O -27.778 +KPX F C -27.778 +KPX F G -27.778 +KPX F Q -27.778 +KPX I I 27.778 +KPX K O -27.778 +KPX K C -27.778 +KPX K G -27.778 +KPX K Q -27.778 +KPX L T -83.333 +KPX L Y -83.333 +KPX L V -111.111 +KPX L W -111.111 +KPX O X -27.778 +KPX O W -27.778 +KPX O A -27.778 +KPX O V -27.778 +KPX O Y -27.778 +KPX P A -83.333 +KPX P o -27.778 +KPX P e -27.778 +KPX P a -27.778 +KPX P period -83.333 +KPX P comma -83.333 +KPX R t -27.778 +KPX R C -27.778 +KPX R O -27.778 +KPX R G -27.778 +KPX R U -27.778 +KPX R Q -27.778 +KPX R T -83.333 +KPX R Y -83.333 +KPX R V -111.111 +KPX R W -111.111 +KPX T y -27.778 +KPX T e -83.333 +KPX T o -83.333 +KPX T r -83.333 +KPX T a -83.333 +KPX T A -83.333 +KPX T u -83.333 +KPX V o -83.333 +KPX V e -83.333 +KPX V u -83.333 +KPX V r -83.333 +KPX V a -83.333 +KPX V A -111.111 +KPX V O -27.778 +KPX V C -27.778 +KPX V G -27.778 +KPX V Q -27.778 +KPX W o -83.333 +KPX W e -83.333 +KPX W u -83.333 +KPX W r -83.333 +KPX W a -83.333 +KPX W A -111.111 +KPX W O -27.778 +KPX W C -27.778 +KPX W G -27.778 +KPX W Q -27.778 +KPX X O -27.778 +KPX X C -27.778 +KPX X G -27.778 +KPX X Q -27.778 +KPX Y e -83.333 +KPX Y o -83.333 +KPX Y r -83.333 +KPX Y a -83.333 +KPX Y A -83.333 +KPX Y u -83.333 +KPX a v -27.778 +KPX a j 55.556 +KPX a y -27.778 +KPX a w -27.778 +KPX b e 27.778 +KPX b o 27.778 +KPX b x -27.778 +KPX b d 27.778 +KPX b c 27.778 +KPX b q 27.778 +KPX b v -27.778 +KPX b j 55.556 +KPX b y -27.778 +KPX b w -27.778 +KPX c h -27.778 +KPX c k -27.778 +KPX f quoteright 77.778 +KPX f question 77.778 +KPX f exclam 77.778 +KPX f parenright 77.778 +KPX f bracketright 77.778 +KPX g j 27.778 +KPX h t -27.778 +KPX h u -27.778 +KPX h b -27.778 +KPX h y -27.778 +KPX h v -27.778 +KPX h w -27.778 +KPX k a -55.556 +KPX k e -27.778 +KPX k a -27.778 +KPX k o -27.778 +KPX k c -27.778 +KPX m t -27.778 +KPX m u -27.778 +KPX m b -27.778 +KPX m y -27.778 +KPX m v -27.778 +KPX m w -27.778 +KPX n t -27.778 +KPX n u -27.778 +KPX n b -27.778 +KPX n y -27.778 +KPX n v -27.778 +KPX n w -27.778 +KPX o e 27.778 +KPX o o 27.778 +KPX o x -27.778 +KPX o d 27.778 +KPX o c 27.778 +KPX o q 27.778 +KPX o v -27.778 +KPX o j 55.556 +KPX o y -27.778 +KPX o w -27.778 +KPX p e 27.778 +KPX p o 27.778 +KPX p x -27.778 +KPX p d 27.778 +KPX p c 27.778 +KPX p q 27.778 +KPX p v -27.778 +KPX p j 55.556 +KPX p y -27.778 +KPX p w -27.778 +KPX t y -27.778 +KPX t w -27.778 +KPX u w -27.778 +KPX v a -55.556 +KPX v e -27.778 +KPX v a -27.778 +KPX v o -27.778 +KPX v c -27.778 +KPX w e -27.778 +KPX w a -27.778 +KPX w o -27.778 +KPX w c -27.778 +KPX y o -27.778 +KPX y e -27.778 +KPX y a -27.778 +KPX y period -83.333 +KPX y comma -83.333 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmsy10.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmsy10.afm new file mode 100644 index 00000000..09e9487d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmsy10.afm @@ -0,0 +1,195 @@ +StartFontMetrics 2.0 +Comment Creation Date: Thu Jun 21 22:23:44 1990 +Comment UniqueID 5000820 +FontName CMSY10 +EncodingScheme FontSpecific +FullName CMSY10 +FamilyName Computer Modern +Weight Medium +ItalicAngle -14.035 +IsFixedPitch false +Version 1.00 +Notice Copyright (c) 1997 American Mathematical Society. All Rights Reserved. +Comment Computer Modern fonts were designed by Donald E. Knuth +FontBBox -29 -960 1116 775 +CapHeight 683.333 +XHeight 430.556 +Ascender 694.444 +Descender -960 +Comment FontID CMSY +Comment DesignSize 10 (pts) +Comment CharacterCodingScheme TeX math symbols +Comment Space 0 0 0 +Comment ExtraSpace 0 +Comment Quad 1000 +Comment Num 676.508 393.732 443.731 +Comment Denom 685.951 344.841 +Comment Sup 412.892 362.892 288.889 +Comment Sub 150 247.217 +Comment Supdrop 386.108 +Comment Subdrop 50 +Comment Delim 2390 1010 +Comment Axisheight 250 +StartCharMetrics 129 +C 0 ; WX 777.778 ; N minus ; B 83 230 694 270 ; +C 1 ; WX 277.778 ; N periodcentered ; B 86 197 192 303 ; +C 2 ; WX 777.778 ; N multiply ; B 147 9 630 491 ; +C 3 ; WX 500 ; N asteriskmath ; B 65 34 434 465 ; +C 4 ; WX 777.778 ; N divide ; B 56 -30 722 530 ; +C 5 ; WX 500 ; N diamondmath ; B 11 11 489 489 ; +C 6 ; WX 777.778 ; N plusminus ; B 56 0 721 666 ; +C 7 ; WX 777.778 ; N minusplus ; B 56 -166 721 500 ; +C 8 ; WX 777.778 ; N circleplus ; B 56 -83 721 583 ; +C 9 ; WX 777.778 ; N circleminus ; B 56 -83 721 583 ; +C 10 ; WX 777.778 ; N circlemultiply ; B 56 -83 721 583 ; +C 11 ; WX 777.778 ; N circledivide ; B 56 -83 721 583 ; +C 12 ; WX 777.778 ; N circledot ; B 56 -83 721 583 ; +C 13 ; WX 1000 ; N circlecopyrt ; B 56 -216 943 716 ; +C 14 ; WX 500 ; N openbullet ; B 56 56 443 444 ; +C 15 ; WX 500 ; N bullet ; B 56 56 443 444 ; +C 16 ; WX 777.778 ; N equivasymptotic ; B 56 16 721 484 ; +C 17 ; WX 777.778 ; N equivalence ; B 56 36 721 464 ; +C 18 ; WX 777.778 ; N reflexsubset ; B 83 -137 694 636 ; +C 19 ; WX 777.778 ; N reflexsuperset ; B 83 -137 694 636 ; +C 20 ; WX 777.778 ; N lessequal ; B 83 -137 694 636 ; +C 21 ; WX 777.778 ; N greaterequal ; B 83 -137 694 636 ; +C 22 ; WX 777.778 ; N precedesequal ; B 83 -137 694 636 ; +C 23 ; WX 777.778 ; N followsequal ; B 83 -137 694 636 ; +C 24 ; WX 777.778 ; N similar ; B 56 133 721 367 ; +C 25 ; WX 777.778 ; N approxequal ; B 56 56 721 483 ; +C 26 ; WX 777.778 ; N propersubset ; B 83 -40 694 540 ; +C 27 ; WX 777.778 ; N propersuperset ; B 83 -40 694 540 ; +C 28 ; WX 1000 ; N lessmuch ; B 56 -66 943 566 ; +C 29 ; WX 1000 ; N greatermuch ; B 56 -66 943 566 ; +C 30 ; WX 777.778 ; N precedes ; B 83 -40 694 539 ; +C 31 ; WX 777.778 ; N follows ; B 83 -40 694 539 ; +C 32 ; WX 1000 ; N arrowleft ; B 57 72 943 428 ; +C 33 ; WX 1000 ; N arrowright ; B 56 72 942 428 ; +C 34 ; WX 500 ; N arrowup ; B 72 -194 428 693 ; +C 35 ; WX 500 ; N arrowdown ; B 72 -193 428 694 ; +C 36 ; WX 1000 ; N arrowboth ; B 57 72 942 428 ; +C 37 ; WX 1000 ; N arrownortheast ; B 56 -193 946 697 ; +C 38 ; WX 1000 ; N arrowsoutheast ; B 56 -197 946 693 ; +C 39 ; WX 777.778 ; N similarequal ; B 56 36 721 464 ; +C 40 ; WX 1000 ; N arrowdblleft ; B 57 -25 943 525 ; +C 41 ; WX 1000 ; N arrowdblright ; B 56 -25 942 525 ; +C 42 ; WX 611.111 ; N arrowdblup ; B 30 -194 580 694 ; +C 43 ; WX 611.111 ; N arrowdbldown ; B 30 -194 580 694 ; +C 44 ; WX 1000 ; N arrowdblboth ; B 35 -25 964 525 ; +C 45 ; WX 1000 ; N arrownorthwest ; B 53 -193 943 697 ; +C 46 ; WX 1000 ; N arrowsouthwest ; B 53 -197 943 693 ; +C 47 ; WX 777.778 ; N proportional ; B 56 -11 722 442 ; +C 48 ; WX 275 ; N prime ; B 29 45 262 559 ; +C 49 ; WX 1000 ; N infinity ; B 56 -11 943 442 ; +C 50 ; WX 666.667 ; N element ; B 83 -40 583 540 ; +C 51 ; WX 666.667 ; N owner ; B 83 -40 583 540 ; +C 52 ; WX 888.889 ; N triangle ; B 59 0 829 716 ; +C 53 ; WX 888.889 ; N triangleinv ; B 59 -216 829 500 ; +C 54 ; WX 0 ; N negationslash ; B 139 -216 638 716 ; +C 55 ; WX 0 ; N mapsto ; B 56 64 124 436 ; +C 56 ; WX 555.556 ; N universal ; B 0 -22 556 694 ; +C 57 ; WX 555.556 ; N existential ; B 56 0 499 694 ; +C 58 ; WX 666.667 ; N logicalnot ; B 56 89 610 356 ; +C 59 ; WX 500 ; N emptyset ; B 47 -78 452 772 ; +C 60 ; WX 722.222 ; N Rfractur ; B 46 -22 714 716 ; +C 61 ; WX 722.222 ; N Ifractur ; B 56 -11 693 705 ; +C 62 ; WX 777.778 ; N latticetop ; B 56 0 722 666 ; +C 63 ; WX 777.778 ; N perpendicular ; B 56 0 722 666 ; +C 64 ; WX 611.111 ; N aleph ; B 56 0 554 693 ; +C 65 ; WX 798.469 ; N A ; B 27 -50 798 722 ; +C 66 ; WX 656.808 ; N B ; B 30 -22 665 706 ; +C 67 ; WX 526.527 ; N C ; B 12 -24 534 705 ; +C 68 ; WX 771.391 ; N D ; B 20 0 766 683 ; +C 69 ; WX 527.778 ; N E ; B 28 -22 565 705 ; +C 70 ; WX 718.75 ; N F ; B 17 -33 829 683 ; +C 71 ; WX 594.864 ; N G ; B 44 -119 601 705 ; +C 72 ; WX 844.516 ; N H ; B 20 -47 818 683 ; +C 73 ; WX 544.513 ; N I ; B -24 0 635 683 ; +C 74 ; WX 677.778 ; N J ; B 47 -119 840 683 ; +C 75 ; WX 761.949 ; N K ; B 30 -22 733 705 ; +C 76 ; WX 689.723 ; N L ; B 31 -22 656 705 ; +C 77 ; WX 1200.9 ; N M ; B 27 -50 1116 705 ; +C 78 ; WX 820.489 ; N N ; B -29 -50 978 775 ; +C 79 ; WX 796.112 ; N O ; B 57 -22 777 705 ; +C 80 ; WX 695.558 ; N P ; B 20 -50 733 683 ; +C 81 ; WX 816.667 ; N Q ; B 113 -124 788 705 ; +C 82 ; WX 847.502 ; N R ; B 20 -22 837 683 ; +C 83 ; WX 605.556 ; N S ; B 18 -22 642 705 ; +C 84 ; WX 544.643 ; N T ; B 29 0 798 717 ; +C 85 ; WX 625.83 ; N U ; B -17 -28 688 683 ; +C 86 ; WX 612.781 ; N V ; B 35 -45 660 683 ; +C 87 ; WX 987.782 ; N W ; B 35 -45 1036 683 ; +C 88 ; WX 713.295 ; N X ; B 50 0 808 683 ; +C 89 ; WX 668.335 ; N Y ; B 31 -135 717 683 ; +C 90 ; WX 724.724 ; N Z ; B 37 0 767 683 ; +C 91 ; WX 666.667 ; N union ; B 56 -22 610 598 ; +C 92 ; WX 666.667 ; N intersection ; B 56 -22 610 598 ; +C 93 ; WX 666.667 ; N unionmulti ; B 56 -22 610 598 ; +C 94 ; WX 666.667 ; N logicaland ; B 56 -22 610 598 ; +C 95 ; WX 666.667 ; N logicalor ; B 56 -22 610 598 ; +C 96 ; WX 611.111 ; N turnstileleft ; B 56 0 554 694 ; +C 97 ; WX 611.111 ; N turnstileright ; B 56 0 554 694 ; +C 98 ; WX 444.444 ; N floorleft ; B 174 -250 422 750 ; +C 99 ; WX 444.444 ; N floorright ; B 21 -250 269 750 ; +C 100 ; WX 444.444 ; N ceilingleft ; B 174 -250 422 750 ; +C 101 ; WX 444.444 ; N ceilingright ; B 21 -250 269 750 ; +C 102 ; WX 500 ; N braceleft ; B 72 -250 427 750 ; +C 103 ; WX 500 ; N braceright ; B 72 -250 427 750 ; +C 104 ; WX 388.889 ; N angbracketleft ; B 110 -250 332 750 ; +C 105 ; WX 388.889 ; N angbracketright ; B 56 -250 278 750 ; +C 106 ; WX 277.778 ; N bar ; B 119 -250 159 750 ; +C 107 ; WX 500 ; N bardbl ; B 132 -250 367 750 ; +C 108 ; WX 500 ; N arrowbothv ; B 72 -272 428 772 ; +C 109 ; WX 611.111 ; N arrowdblbothv ; B 30 -272 580 772 ; +C 110 ; WX 500 ; N backslash ; B 56 -250 443 750 ; +C 111 ; WX 277.778 ; N wreathproduct ; B 56 -83 221 583 ; +C 112 ; WX 833.333 ; N radical ; B 73 -960 853 40 ; +C 113 ; WX 750 ; N coproduct ; B 36 0 713 683 ; +C 114 ; WX 833.333 ; N nabla ; B 47 -33 785 683 ; +C 115 ; WX 416.667 ; N integral ; B 56 -216 471 716 ; +C 116 ; WX 666.667 ; N unionsq ; B 61 0 605 598 ; +C 117 ; WX 666.667 ; N intersectionsq ; B 61 0 605 598 ; +C 118 ; WX 777.778 ; N subsetsqequal ; B 83 -137 714 636 ; +C 119 ; WX 777.778 ; N supersetsqequal ; B 63 -137 694 636 ; +C 120 ; WX 444.444 ; N section ; B 69 -205 374 705 ; +C 121 ; WX 444.444 ; N dagger ; B 56 -216 387 705 ; +C 122 ; WX 444.444 ; N daggerdbl ; B 56 -205 387 705 ; +C 123 ; WX 611.111 ; N paragraph ; B 56 -194 582 694 ; +C 124 ; WX 777.778 ; N club ; B 28 -130 750 727 ; +C 125 ; WX 777.778 ; N diamond ; B 56 -163 722 727 ; +C 126 ; WX 777.778 ; N heart ; B 56 -33 722 716 ; +C 127 ; WX 777.778 ; N spade ; B 56 -130 722 727 ; +C -1 ; WX 333.333 ; N space ; B 0 0 0 0 ; +EndCharMetrics +Comment The following are bogus kern pairs for TeX positioning of accents +StartKernData +StartKernPairs 26 +KPX A prime 194.444 +KPX B prime 138.889 +KPX C prime 138.889 +KPX D prime 83.333 +KPX E prime 111.111 +KPX F prime 111.111 +KPX G prime 111.111 +KPX H prime 111.111 +KPX I prime 27.778 +KPX J prime 166.667 +KPX K prime 55.556 +KPX L prime 138.889 +KPX M prime 138.889 +KPX N prime 83.333 +KPX O prime 111.111 +KPX P prime 83.333 +KPX Q prime 111.111 +KPX R prime 83.333 +KPX S prime 138.889 +KPX T prime 27.778 +KPX U prime 83.333 +KPX V prime 27.778 +KPX W prime 83.333 +KPX X prime 138.889 +KPX Y prime 83.333 +KPX Z prime 138.889 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmtt10.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmtt10.afm new file mode 100644 index 00000000..d6ec19b0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/cmtt10.afm @@ -0,0 +1,156 @@ +StartFontMetrics 2.0 +Comment Creation Date: Thu Jun 21 22:23:51 1990 +Comment UniqueID 5000832 +FontName CMTT10 +EncodingScheme FontSpecific +FullName CMTT10 +FamilyName Computer Modern +Weight Medium +ItalicAngle 0.0 +IsFixedPitch true +Version 1.00B +Notice Copyright (c) 1997 American Mathematical Society. All Rights Reserved. +Comment Computer Modern fonts were designed by Donald E. Knuth +FontBBox -4 -235 731 800 +CapHeight 611.111 +XHeight 430.556 +Ascender 611.111 +Descender -222.222 +Comment FontID CMTT +Comment DesignSize 10 (pts) +Comment CharacterCodingScheme TeX typewriter text +Comment Space 525 0 0 +Comment ExtraSpace 525 +Comment Quad 1050 +StartCharMetrics 129 +C 0 ; WX 525 ; N Gamma ; B 32 0 488 611 ; +C 1 ; WX 525 ; N Delta ; B 34 0 490 623 ; +C 2 ; WX 525 ; N Theta ; B 56 -11 468 622 ; +C 3 ; WX 525 ; N Lambda ; B 29 0 495 623 ; +C 4 ; WX 525 ; N Xi ; B 33 0 491 611 ; +C 5 ; WX 525 ; N Pi ; B 22 0 502 611 ; +C 6 ; WX 525 ; N Sigma ; B 40 0 484 611 ; +C 7 ; WX 525 ; N Upsilon ; B 38 0 486 622 ; +C 8 ; WX 525 ; N Phi ; B 40 0 484 611 ; +C 9 ; WX 525 ; N Psi ; B 38 0 486 611 ; +C 10 ; WX 525 ; N Omega ; B 32 0 492 622 ; +C 11 ; WX 525 ; N arrowup ; B 59 0 465 611 ; +C 12 ; WX 525 ; N arrowdown ; B 59 0 465 611 ; +C 13 ; WX 525 ; N quotesingle ; B 217 328 309 622 ; +C 14 ; WX 525 ; N exclamdown ; B 212 -233 312 389 ; +C 15 ; WX 525 ; N questiondown ; B 62 -228 462 389 ; +C 16 ; WX 525 ; N dotlessi ; B 78 0 455 431 ; +C 17 ; WX 525 ; N dotlessj ; B 48 -228 368 431 ; +C 18 ; WX 525 ; N grave ; B 117 477 329 611 ; +C 19 ; WX 525 ; N acute ; B 195 477 407 611 ; +C 20 ; WX 525 ; N caron ; B 101 454 423 572 ; +C 21 ; WX 525 ; N breve ; B 86 498 438 611 ; +C 22 ; WX 525 ; N macron ; B 73 514 451 577 ; +C 23 ; WX 525 ; N ring ; B 181 499 343 619 ; +C 24 ; WX 525 ; N cedilla ; B 162 -208 428 45 ; +C 25 ; WX 525 ; N germandbls ; B 17 -6 495 617 ; +C 26 ; WX 525 ; N ae ; B 33 -6 504 440 ; +C 27 ; WX 525 ; N oe ; B 19 -6 505 440 ; +C 28 ; WX 525 ; N oslash ; B 43 -140 481 571 ; +C 29 ; WX 525 ; N AE ; B 23 0 499 611 ; +C 30 ; WX 525 ; N OE ; B 29 -11 502 622 ; +C 31 ; WX 525 ; N Oslash ; B 56 -85 468 696 ; +C 32 ; WX 525 ; N visiblespace ; B 44 -132 480 240 ; +C 33 ; WX 525 ; N exclam ; B 212 0 312 622 ; L quoteleft exclamdown ; +C 34 ; WX 525 ; N quotedbl ; B 126 328 398 622 ; +C 35 ; WX 525 ; N numbersign ; B 35 0 489 611 ; +C 36 ; WX 525 ; N dollar ; B 58 -83 466 694 ; +C 37 ; WX 525 ; N percent ; B 35 -83 489 694 ; +C 38 ; WX 525 ; N ampersand ; B 28 -11 490 622 ; +C 39 ; WX 525 ; N quoteright ; B 180 302 341 611 ; +C 40 ; WX 525 ; N parenleft ; B 173 -82 437 694 ; +C 41 ; WX 525 ; N parenright ; B 88 -82 352 694 ; +C 42 ; WX 525 ; N asterisk ; B 68 90 456 521 ; +C 43 ; WX 525 ; N plus ; B 38 81 486 531 ; +C 44 ; WX 525 ; N comma ; B 180 -139 346 125 ; +C 45 ; WX 525 ; N hyphen ; B 56 271 468 341 ; +C 46 ; WX 525 ; N period ; B 200 0 325 125 ; +C 47 ; WX 525 ; N slash ; B 58 -83 466 694 ; +C 48 ; WX 525 ; N zero ; B 50 -11 474 622 ; +C 49 ; WX 525 ; N one ; B 105 0 442 622 ; +C 50 ; WX 525 ; N two ; B 52 0 472 622 ; +C 51 ; WX 525 ; N three ; B 44 -11 480 622 ; +C 52 ; WX 525 ; N four ; B 29 0 495 623 ; +C 53 ; WX 525 ; N five ; B 52 -11 472 611 ; +C 54 ; WX 525 ; N six ; B 53 -11 471 622 ; +C 55 ; WX 525 ; N seven ; B 44 -11 480 627 ; +C 56 ; WX 525 ; N eight ; B 44 -11 480 622 ; +C 57 ; WX 525 ; N nine ; B 53 -11 471 622 ; +C 58 ; WX 525 ; N colon ; B 200 0 325 431 ; +C 59 ; WX 525 ; N semicolon ; B 180 -139 330 431 ; +C 60 ; WX 525 ; N less ; B 56 56 468 556 ; +C 61 ; WX 525 ; N equal ; B 38 195 486 417 ; +C 62 ; WX 525 ; N greater ; B 56 56 468 556 ; +C 63 ; WX 525 ; N question ; B 62 0 462 617 ; L quoteleft questiondown ; +C 64 ; WX 525 ; N at ; B 44 -6 480 617 ; +C 65 ; WX 525 ; N A ; B 27 0 497 623 ; +C 66 ; WX 525 ; N B ; B 23 0 482 611 ; +C 67 ; WX 525 ; N C ; B 40 -11 484 622 ; +C 68 ; WX 525 ; N D ; B 19 0 485 611 ; +C 69 ; WX 525 ; N E ; B 26 0 502 611 ; +C 70 ; WX 525 ; N F ; B 28 0 490 611 ; +C 71 ; WX 525 ; N G ; B 38 -11 496 622 ; +C 72 ; WX 525 ; N H ; B 22 0 502 611 ; +C 73 ; WX 525 ; N I ; B 79 0 446 611 ; +C 74 ; WX 525 ; N J ; B 71 -11 478 611 ; +C 75 ; WX 525 ; N K ; B 26 0 495 611 ; +C 76 ; WX 525 ; N L ; B 32 0 488 611 ; +C 77 ; WX 525 ; N M ; B 17 0 507 611 ; +C 78 ; WX 525 ; N N ; B 28 0 496 611 ; +C 79 ; WX 525 ; N O ; B 56 -11 468 622 ; +C 80 ; WX 525 ; N P ; B 26 0 480 611 ; +C 81 ; WX 525 ; N Q ; B 56 -139 468 622 ; +C 82 ; WX 525 ; N R ; B 22 -11 522 611 ; +C 83 ; WX 525 ; N S ; B 52 -11 472 622 ; +C 84 ; WX 525 ; N T ; B 26 0 498 611 ; +C 85 ; WX 525 ; N U ; B 4 -11 520 611 ; +C 86 ; WX 525 ; N V ; B 18 -8 506 611 ; +C 87 ; WX 525 ; N W ; B 11 -8 513 611 ; +C 88 ; WX 525 ; N X ; B 27 0 496 611 ; +C 89 ; WX 525 ; N Y ; B 19 0 505 611 ; +C 90 ; WX 525 ; N Z ; B 48 0 481 611 ; +C 91 ; WX 525 ; N bracketleft ; B 222 -83 483 694 ; +C 92 ; WX 525 ; N backslash ; B 58 -83 466 694 ; +C 93 ; WX 525 ; N bracketright ; B 41 -83 302 694 ; +C 94 ; WX 525 ; N asciicircum ; B 100 471 424 611 ; +C 95 ; WX 525 ; N underscore ; B 56 -95 468 -25 ; +C 96 ; WX 525 ; N quoteleft ; B 183 372 344 681 ; +C 97 ; WX 525 ; N a ; B 55 -6 524 440 ; +C 98 ; WX 525 ; N b ; B 12 -6 488 611 ; +C 99 ; WX 525 ; N c ; B 73 -6 466 440 ; +C 100 ; WX 525 ; N d ; B 36 -6 512 611 ; +C 101 ; WX 525 ; N e ; B 55 -6 464 440 ; +C 102 ; WX 525 ; N f ; B 42 0 437 617 ; +C 103 ; WX 525 ; N g ; B 29 -229 509 442 ; +C 104 ; WX 525 ; N h ; B 12 0 512 611 ; +C 105 ; WX 525 ; N i ; B 78 0 455 612 ; +C 106 ; WX 525 ; N j ; B 48 -228 368 612 ; +C 107 ; WX 525 ; N k ; B 21 0 508 611 ; +C 108 ; WX 525 ; N l ; B 58 0 467 611 ; +C 109 ; WX 525 ; N m ; B -4 0 516 437 ; +C 110 ; WX 525 ; N n ; B 12 0 512 437 ; +C 111 ; WX 525 ; N o ; B 57 -6 467 440 ; +C 112 ; WX 525 ; N p ; B 12 -222 488 437 ; +C 113 ; WX 525 ; N q ; B 40 -222 537 437 ; +C 114 ; WX 525 ; N r ; B 32 0 487 437 ; +C 115 ; WX 525 ; N s ; B 72 -6 459 440 ; +C 116 ; WX 525 ; N t ; B 25 -6 449 554 ; +C 117 ; WX 525 ; N u ; B 12 -6 512 431 ; +C 118 ; WX 525 ; N v ; B 24 -4 500 431 ; +C 119 ; WX 525 ; N w ; B 16 -4 508 431 ; +C 120 ; WX 525 ; N x ; B 27 0 496 431 ; +C 121 ; WX 525 ; N y ; B 26 -228 500 431 ; +C 122 ; WX 525 ; N z ; B 33 0 475 431 ; +C 123 ; WX 525 ; N braceleft ; B 57 -83 467 694 ; +C 124 ; WX 525 ; N bar ; B 227 -83 297 694 ; +C 125 ; WX 525 ; N braceright ; B 57 -83 467 694 ; +C 126 ; WX 525 ; N asciitilde ; B 87 491 437 611 ; +C 127 ; WX 525 ; N dieresis ; B 110 512 414 612 ; +C -1 ; WX 525 ; N space ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagd8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagd8a.afm new file mode 100644 index 00000000..69eebba1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagd8a.afm @@ -0,0 +1,576 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Mar 4 13:46:34 1991 +Comment UniqueID 34370 +Comment VMusage 24954 31846 +FontName AvantGarde-Demi +FullName ITC Avant Garde Gothic Demi +FamilyName ITC Avant Garde Gothic +Weight Demi +ItalicAngle 0 +IsFixedPitch false +FontBBox -123 -251 1222 1021 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved.ITC Avant Garde Gothic is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 740 +XHeight 555 +Ascender 740 +Descender -185 +StartCharMetrics 228 +C 32 ; WX 280 ; N space ; B 0 0 0 0 ; +C 33 ; WX 280 ; N exclam ; B 73 0 206 740 ; +C 34 ; WX 360 ; N quotedbl ; B 19 444 341 740 ; +C 35 ; WX 560 ; N numbersign ; B 29 0 525 700 ; +C 36 ; WX 560 ; N dollar ; B 58 -86 501 857 ; +C 37 ; WX 860 ; N percent ; B 36 -15 822 755 ; +C 38 ; WX 680 ; N ampersand ; B 34 -15 665 755 ; +C 39 ; WX 280 ; N quoteright ; B 72 466 205 740 ; +C 40 ; WX 380 ; N parenleft ; B 74 -157 350 754 ; +C 41 ; WX 380 ; N parenright ; B 37 -157 313 754 ; +C 42 ; WX 440 ; N asterisk ; B 67 457 374 755 ; +C 43 ; WX 600 ; N plus ; B 48 0 552 506 ; +C 44 ; WX 280 ; N comma ; B 73 -141 206 133 ; +C 45 ; WX 420 ; N hyphen ; B 71 230 349 348 ; +C 46 ; WX 280 ; N period ; B 73 0 206 133 ; +C 47 ; WX 460 ; N slash ; B 6 -100 454 740 ; +C 48 ; WX 560 ; N zero ; B 32 -15 529 755 ; +C 49 ; WX 560 ; N one ; B 137 0 363 740 ; +C 50 ; WX 560 ; N two ; B 36 0 523 755 ; +C 51 ; WX 560 ; N three ; B 28 -15 532 755 ; +C 52 ; WX 560 ; N four ; B 15 0 545 740 ; +C 53 ; WX 560 ; N five ; B 25 -15 535 740 ; +C 54 ; WX 560 ; N six ; B 23 -15 536 739 ; +C 55 ; WX 560 ; N seven ; B 62 0 498 740 ; +C 56 ; WX 560 ; N eight ; B 33 -15 527 755 ; +C 57 ; WX 560 ; N nine ; B 24 0 537 754 ; +C 58 ; WX 280 ; N colon ; B 73 0 206 555 ; +C 59 ; WX 280 ; N semicolon ; B 73 -141 206 555 ; +C 60 ; WX 600 ; N less ; B 46 -8 554 514 ; +C 61 ; WX 600 ; N equal ; B 48 81 552 425 ; +C 62 ; WX 600 ; N greater ; B 46 -8 554 514 ; +C 63 ; WX 560 ; N question ; B 38 0 491 755 ; +C 64 ; WX 740 ; N at ; B 50 -12 750 712 ; +C 65 ; WX 740 ; N A ; B 7 0 732 740 ; +C 66 ; WX 580 ; N B ; B 70 0 551 740 ; +C 67 ; WX 780 ; N C ; B 34 -15 766 755 ; +C 68 ; WX 700 ; N D ; B 63 0 657 740 ; +C 69 ; WX 520 ; N E ; B 61 0 459 740 ; +C 70 ; WX 480 ; N F ; B 61 0 438 740 ; +C 71 ; WX 840 ; N G ; B 27 -15 817 755 ; +C 72 ; WX 680 ; N H ; B 71 0 610 740 ; +C 73 ; WX 280 ; N I ; B 72 0 209 740 ; +C 74 ; WX 480 ; N J ; B 2 -15 409 740 ; +C 75 ; WX 620 ; N K ; B 89 0 620 740 ; +C 76 ; WX 440 ; N L ; B 72 0 435 740 ; +C 77 ; WX 900 ; N M ; B 63 0 837 740 ; +C 78 ; WX 740 ; N N ; B 70 0 671 740 ; +C 79 ; WX 840 ; N O ; B 33 -15 807 755 ; +C 80 ; WX 560 ; N P ; B 72 0 545 740 ; +C 81 ; WX 840 ; N Q ; B 32 -15 824 755 ; +C 82 ; WX 580 ; N R ; B 64 0 565 740 ; +C 83 ; WX 520 ; N S ; B 12 -15 493 755 ; +C 84 ; WX 420 ; N T ; B 6 0 418 740 ; +C 85 ; WX 640 ; N U ; B 55 -15 585 740 ; +C 86 ; WX 700 ; N V ; B 8 0 695 740 ; +C 87 ; WX 900 ; N W ; B 7 0 899 740 ; +C 88 ; WX 680 ; N X ; B 4 0 676 740 ; +C 89 ; WX 620 ; N Y ; B -2 0 622 740 ; +C 90 ; WX 500 ; N Z ; B 19 0 481 740 ; +C 91 ; WX 320 ; N bracketleft ; B 66 -157 284 754 ; +C 92 ; WX 640 ; N backslash ; B 96 -100 544 740 ; +C 93 ; WX 320 ; N bracketright ; B 36 -157 254 754 ; +C 94 ; WX 600 ; N asciicircum ; B 73 375 527 740 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 280 ; N quoteleft ; B 72 466 205 740 ; +C 97 ; WX 660 ; N a ; B 27 -18 613 574 ; +C 98 ; WX 660 ; N b ; B 47 -18 632 740 ; +C 99 ; WX 640 ; N c ; B 37 -18 610 574 ; +C 100 ; WX 660 ; N d ; B 34 -18 618 740 ; +C 101 ; WX 640 ; N e ; B 31 -18 610 577 ; +C 102 ; WX 280 ; N f ; B 15 0 280 755 ; L i fi ; L l fl ; +C 103 ; WX 660 ; N g ; B 32 -226 623 574 ; +C 104 ; WX 600 ; N h ; B 54 0 546 740 ; +C 105 ; WX 240 ; N i ; B 53 0 186 740 ; +C 106 ; WX 260 ; N j ; B 16 -185 205 740 ; +C 107 ; WX 580 ; N k ; B 80 0 571 740 ; +C 108 ; WX 240 ; N l ; B 54 0 187 740 ; +C 109 ; WX 940 ; N m ; B 54 0 887 574 ; +C 110 ; WX 600 ; N n ; B 54 0 547 574 ; +C 111 ; WX 640 ; N o ; B 25 -18 615 574 ; +C 112 ; WX 660 ; N p ; B 47 -185 629 574 ; +C 113 ; WX 660 ; N q ; B 31 -185 613 574 ; +C 114 ; WX 320 ; N r ; B 63 0 317 574 ; +C 115 ; WX 440 ; N s ; B 19 -18 421 574 ; +C 116 ; WX 300 ; N t ; B 21 0 299 740 ; +C 117 ; WX 600 ; N u ; B 50 -18 544 555 ; +C 118 ; WX 560 ; N v ; B 3 0 556 555 ; +C 119 ; WX 800 ; N w ; B 11 0 789 555 ; +C 120 ; WX 560 ; N x ; B 3 0 556 555 ; +C 121 ; WX 580 ; N y ; B 8 -185 571 555 ; +C 122 ; WX 460 ; N z ; B 20 0 442 555 ; +C 123 ; WX 340 ; N braceleft ; B -3 -191 317 747 ; +C 124 ; WX 600 ; N bar ; B 233 -100 366 740 ; +C 125 ; WX 340 ; N braceright ; B 23 -191 343 747 ; +C 126 ; WX 600 ; N asciitilde ; B 67 160 533 347 ; +C 161 ; WX 280 ; N exclamdown ; B 74 -185 207 555 ; +C 162 ; WX 560 ; N cent ; B 43 39 517 715 ; +C 163 ; WX 560 ; N sterling ; B -2 0 562 755 ; +C 164 ; WX 160 ; N fraction ; B -123 0 282 740 ; +C 165 ; WX 560 ; N yen ; B -10 0 570 740 ; +C 166 ; WX 560 ; N florin ; B 0 -151 512 824 ; +C 167 ; WX 560 ; N section ; B 28 -158 530 755 ; +C 168 ; WX 560 ; N currency ; B 27 69 534 577 ; +C 169 ; WX 220 ; N quotesingle ; B 44 444 177 740 ; +C 170 ; WX 480 ; N quotedblleft ; B 70 466 410 740 ; +C 171 ; WX 460 ; N guillemotleft ; B 61 108 400 469 ; +C 172 ; WX 240 ; N guilsinglleft ; B 50 108 190 469 ; +C 173 ; WX 240 ; N guilsinglright ; B 50 108 190 469 ; +C 174 ; WX 520 ; N fi ; B 25 0 461 755 ; +C 175 ; WX 520 ; N fl ; B 25 0 461 755 ; +C 177 ; WX 500 ; N endash ; B 35 230 465 348 ; +C 178 ; WX 560 ; N dagger ; B 51 -142 509 740 ; +C 179 ; WX 560 ; N daggerdbl ; B 51 -142 509 740 ; +C 180 ; WX 280 ; N periodcentered ; B 73 187 206 320 ; +C 182 ; WX 600 ; N paragraph ; B -7 -103 607 740 ; +C 183 ; WX 600 ; N bullet ; B 148 222 453 532 ; +C 184 ; WX 280 ; N quotesinglbase ; B 72 -141 205 133 ; +C 185 ; WX 480 ; N quotedblbase ; B 70 -141 410 133 ; +C 186 ; WX 480 ; N quotedblright ; B 70 466 410 740 ; +C 187 ; WX 460 ; N guillemotright ; B 61 108 400 469 ; +C 188 ; WX 1000 ; N ellipsis ; B 100 0 899 133 ; +C 189 ; WX 1280 ; N perthousand ; B 36 -15 1222 755 ; +C 191 ; WX 560 ; N questiondown ; B 68 -200 521 555 ; +C 193 ; WX 420 ; N grave ; B 50 624 329 851 ; +C 194 ; WX 420 ; N acute ; B 91 624 370 849 ; +C 195 ; WX 540 ; N circumflex ; B 71 636 470 774 ; +C 196 ; WX 480 ; N tilde ; B 44 636 437 767 ; +C 197 ; WX 420 ; N macron ; B 72 648 349 759 ; +C 198 ; WX 480 ; N breve ; B 42 633 439 770 ; +C 199 ; WX 280 ; N dotaccent ; B 74 636 207 769 ; +C 200 ; WX 500 ; N dieresis ; B 78 636 422 769 ; +C 202 ; WX 360 ; N ring ; B 73 619 288 834 ; +C 203 ; WX 340 ; N cedilla ; B 98 -251 298 6 ; +C 205 ; WX 700 ; N hungarumlaut ; B 132 610 609 862 ; +C 206 ; WX 340 ; N ogonek ; B 79 -195 262 9 ; +C 207 ; WX 540 ; N caron ; B 71 636 470 774 ; +C 208 ; WX 1000 ; N emdash ; B 35 230 965 348 ; +C 225 ; WX 900 ; N AE ; B -5 0 824 740 ; +C 227 ; WX 360 ; N ordfeminine ; B 19 438 334 755 ; +C 232 ; WX 480 ; N Lslash ; B 26 0 460 740 ; +C 233 ; WX 840 ; N Oslash ; B 33 -71 807 814 ; +C 234 ; WX 1060 ; N OE ; B 37 -15 1007 755 ; +C 235 ; WX 360 ; N ordmasculine ; B 23 438 338 755 ; +C 241 ; WX 1080 ; N ae ; B 29 -18 1048 574 ; +C 245 ; WX 240 ; N dotlessi ; B 53 0 186 555 ; +C 248 ; WX 320 ; N lslash ; B 34 0 305 740 ; +C 249 ; WX 660 ; N oslash ; B 35 -50 625 608 ; +C 250 ; WX 1080 ; N oe ; B 30 -18 1050 574 ; +C 251 ; WX 600 ; N germandbls ; B 51 -18 585 755 ; +C -1 ; WX 640 ; N ecircumflex ; B 31 -18 610 774 ; +C -1 ; WX 640 ; N edieresis ; B 31 -18 610 769 ; +C -1 ; WX 660 ; N aacute ; B 27 -18 613 849 ; +C -1 ; WX 740 ; N registered ; B -12 -12 752 752 ; +C -1 ; WX 240 ; N icircumflex ; B -79 0 320 774 ; +C -1 ; WX 600 ; N udieresis ; B 50 -18 544 769 ; +C -1 ; WX 640 ; N ograve ; B 25 -18 615 851 ; +C -1 ; WX 600 ; N uacute ; B 50 -18 544 849 ; +C -1 ; WX 600 ; N ucircumflex ; B 50 -18 544 774 ; +C -1 ; WX 740 ; N Aacute ; B 7 0 732 1019 ; +C -1 ; WX 240 ; N igrave ; B -65 0 214 851 ; +C -1 ; WX 280 ; N Icircumflex ; B -59 0 340 944 ; +C -1 ; WX 640 ; N ccedilla ; B 37 -251 610 574 ; +C -1 ; WX 660 ; N adieresis ; B 27 -18 613 769 ; +C -1 ; WX 520 ; N Ecircumflex ; B 61 0 460 944 ; +C -1 ; WX 440 ; N scaron ; B 19 -18 421 774 ; +C -1 ; WX 660 ; N thorn ; B 47 -185 629 740 ; +C -1 ; WX 1000 ; N trademark ; B 9 296 821 740 ; +C -1 ; WX 640 ; N egrave ; B 31 -18 610 851 ; +C -1 ; WX 336 ; N threesuperior ; B 8 287 328 749 ; +C -1 ; WX 460 ; N zcaron ; B 20 0 455 774 ; +C -1 ; WX 660 ; N atilde ; B 27 -18 613 767 ; +C -1 ; WX 660 ; N aring ; B 27 -18 613 834 ; +C -1 ; WX 640 ; N ocircumflex ; B 25 -18 615 774 ; +C -1 ; WX 520 ; N Edieresis ; B 61 0 459 939 ; +C -1 ; WX 840 ; N threequarters ; B 18 0 803 749 ; +C -1 ; WX 580 ; N ydieresis ; B 8 -185 571 769 ; +C -1 ; WX 580 ; N yacute ; B 8 -185 571 849 ; +C -1 ; WX 240 ; N iacute ; B 26 0 305 849 ; +C -1 ; WX 740 ; N Acircumflex ; B 7 0 732 944 ; +C -1 ; WX 640 ; N Uacute ; B 55 -15 585 1019 ; +C -1 ; WX 640 ; N eacute ; B 31 -18 610 849 ; +C -1 ; WX 840 ; N Ograve ; B 33 -15 807 1021 ; +C -1 ; WX 660 ; N agrave ; B 27 -18 613 851 ; +C -1 ; WX 640 ; N Udieresis ; B 55 -15 585 939 ; +C -1 ; WX 660 ; N acircumflex ; B 27 -18 613 774 ; +C -1 ; WX 280 ; N Igrave ; B -45 0 234 1021 ; +C -1 ; WX 336 ; N twosuperior ; B 13 296 322 749 ; +C -1 ; WX 640 ; N Ugrave ; B 55 -15 585 1021 ; +C -1 ; WX 840 ; N onequarter ; B 92 0 746 740 ; +C -1 ; WX 640 ; N Ucircumflex ; B 55 -15 585 944 ; +C -1 ; WX 520 ; N Scaron ; B 12 -15 493 944 ; +C -1 ; WX 280 ; N Idieresis ; B -32 0 312 939 ; +C -1 ; WX 240 ; N idieresis ; B -52 0 292 769 ; +C -1 ; WX 520 ; N Egrave ; B 61 0 459 1021 ; +C -1 ; WX 840 ; N Oacute ; B 33 -15 807 1019 ; +C -1 ; WX 600 ; N divide ; B 48 -20 552 526 ; +C -1 ; WX 740 ; N Atilde ; B 7 0 732 937 ; +C -1 ; WX 740 ; N Aring ; B 7 0 732 969 ; +C -1 ; WX 840 ; N Odieresis ; B 33 -15 807 939 ; +C -1 ; WX 740 ; N Adieresis ; B 7 0 732 939 ; +C -1 ; WX 740 ; N Ntilde ; B 70 0 671 937 ; +C -1 ; WX 500 ; N Zcaron ; B 19 0 481 944 ; +C -1 ; WX 560 ; N Thorn ; B 72 0 545 740 ; +C -1 ; WX 280 ; N Iacute ; B 46 0 325 1019 ; +C -1 ; WX 600 ; N plusminus ; B 48 -62 552 556 ; +C -1 ; WX 600 ; N multiply ; B 59 12 541 494 ; +C -1 ; WX 520 ; N Eacute ; B 61 0 459 1019 ; +C -1 ; WX 620 ; N Ydieresis ; B -2 0 622 939 ; +C -1 ; WX 336 ; N onesuperior ; B 72 296 223 740 ; +C -1 ; WX 600 ; N ugrave ; B 50 -18 544 851 ; +C -1 ; WX 600 ; N logicalnot ; B 48 108 552 425 ; +C -1 ; WX 600 ; N ntilde ; B 54 0 547 767 ; +C -1 ; WX 840 ; N Otilde ; B 33 -15 807 937 ; +C -1 ; WX 640 ; N otilde ; B 25 -18 615 767 ; +C -1 ; WX 780 ; N Ccedilla ; B 34 -251 766 755 ; +C -1 ; WX 740 ; N Agrave ; B 7 0 732 1021 ; +C -1 ; WX 840 ; N onehalf ; B 62 0 771 740 ; +C -1 ; WX 742 ; N Eth ; B 25 0 691 740 ; +C -1 ; WX 400 ; N degree ; B 57 426 343 712 ; +C -1 ; WX 620 ; N Yacute ; B -2 0 622 1019 ; +C -1 ; WX 840 ; N Ocircumflex ; B 33 -15 807 944 ; +C -1 ; WX 640 ; N oacute ; B 25 -18 615 849 ; +C -1 ; WX 576 ; N mu ; B 38 -187 539 555 ; +C -1 ; WX 600 ; N minus ; B 48 193 552 313 ; +C -1 ; WX 640 ; N eth ; B 27 -18 616 754 ; +C -1 ; WX 640 ; N odieresis ; B 25 -18 615 769 ; +C -1 ; WX 740 ; N copyright ; B -12 -12 752 752 ; +C -1 ; WX 600 ; N brokenbar ; B 233 -100 366 740 ; +EndCharMetrics +StartKernData +StartKernPairs 218 + +KPX A y -50 +KPX A w -65 +KPX A v -70 +KPX A u -20 +KPX A quoteright -90 +KPX A Y -80 +KPX A W -60 +KPX A V -102 +KPX A U -40 +KPX A T -25 +KPX A Q -50 +KPX A O -50 +KPX A G -40 +KPX A C -40 + +KPX B A -10 + +KPX C A -40 + +KPX D period -20 +KPX D comma -20 +KPX D Y -45 +KPX D W -25 +KPX D V -50 +KPX D A -50 + +KPX F period -129 +KPX F e -20 +KPX F comma -162 +KPX F a -20 +KPX F A -75 + +KPX G period -20 +KPX G comma -20 +KPX G Y -15 + +KPX J period -15 +KPX J a -20 +KPX J A -30 + +KPX K y -20 +KPX K u -15 +KPX K o -45 +KPX K e -40 +KPX K O -30 + +KPX L y -23 +KPX L quoteright -30 +KPX L quotedblright -30 +KPX L Y -80 +KPX L W -55 +KPX L V -85 +KPX L T -46 + +KPX O period -30 +KPX O comma -30 +KPX O Y -30 +KPX O X -30 +KPX O W -20 +KPX O V -45 +KPX O T -15 +KPX O A -60 + +KPX P period -200 +KPX P o -20 +KPX P e -20 +KPX P comma -220 +KPX P a -20 +KPX P A -100 + +KPX Q comma 20 + +KPX R W 25 +KPX R V -10 +KPX R U 25 +KPX R T 40 +KPX R O 25 + +KPX S comma 20 + +KPX T y -10 +KPX T w -55 +KPX T u -46 +KPX T semicolon -29 +KPX T r -30 +KPX T period -91 +KPX T o -49 +KPX T hyphen -75 +KPX T e -49 +KPX T comma -82 +KPX T colon -15 +KPX T a -70 +KPX T O -15 +KPX T A -25 + +KPX U period -20 +KPX U comma -20 +KPX U A -40 + +KPX V u -55 +KPX V semicolon -33 +KPX V period -145 +KPX V o -101 +KPX V i -15 +KPX V hyphen -75 +KPX V e -101 +KPX V comma -145 +KPX V colon -18 +KPX V a -95 +KPX V O -45 +KPX V G -20 +KPX V A -102 + +KPX W y -15 +KPX W u -30 +KPX W semicolon -33 +KPX W period -106 +KPX W o -46 +KPX W i -10 +KPX W hyphen -35 +KPX W e -47 +KPX W comma -106 +KPX W colon -15 +KPX W a -50 +KPX W O -20 +KPX W A -58 + +KPX Y u -52 +KPX Y semicolon -23 +KPX Y period -145 +KPX Y o -89 +KPX Y hyphen -100 +KPX Y e -89 +KPX Y comma -145 +KPX Y colon -10 +KPX Y a -93 +KPX Y O -30 +KPX Y A -80 + +KPX a t 5 +KPX a p 20 +KPX a b 5 + +KPX b y -20 +KPX b v -20 + +KPX c y -20 +KPX c l -15 +KPX c k -15 + +KPX comma space -50 +KPX comma quoteright -70 +KPX comma quotedblright -70 + +KPX e y -20 +KPX e x -20 +KPX e w -20 +KPX e v -20 + +KPX f period -40 +KPX f o -20 +KPX f l -15 +KPX f i -15 +KPX f f -20 +KPX f dotlessi -15 +KPX f comma -40 +KPX f a -15 + +KPX g i 25 +KPX g a 15 + +KPX h y -30 + +KPX k y -5 +KPX k o -30 +KPX k e -40 + +KPX m y -20 +KPX m u -20 + +KPX n y -15 +KPX n v -30 + +KPX o y -20 +KPX o x -30 +KPX o w -20 +KPX o v -30 + +KPX p y -20 + +KPX period space -50 +KPX period quoteright -70 +KPX period quotedblright -70 + +KPX quotedblleft A -50 + +KPX quotedblright space -50 + +KPX quoteleft quoteleft -80 +KPX quoteleft A -50 + +KPX quoteright v -10 +KPX quoteright t 10 +KPX quoteright space -50 +KPX quoteright s -15 +KPX quoteright r -20 +KPX quoteright quoteright -80 +KPX quoteright d -50 + +KPX r y 40 +KPX r v 40 +KPX r u 20 +KPX r t 20 +KPX r s 20 +KPX r q -8 +KPX r period -73 +KPX r p 20 +KPX r o -15 +KPX r n 21 +KPX r m 15 +KPX r l 20 +KPX r k 5 +KPX r i 20 +KPX r hyphen -60 +KPX r g 1 +KPX r e -4 +KPX r d -6 +KPX r comma -75 +KPX r c -7 + +KPX s period 20 +KPX s comma 20 + +KPX space quoteleft -50 +KPX space quotedblleft -50 +KPX space Y -60 +KPX space W -25 +KPX space V -80 +KPX space T -25 +KPX space A -20 + +KPX v period -90 +KPX v o -20 +KPX v e -20 +KPX v comma -90 +KPX v a -30 + +KPX w period -90 +KPX w o -30 +KPX w e -20 +KPX w comma -90 +KPX w a -30 + +KPX x e -20 + +KPX y period -100 +KPX y o -30 +KPX y e -20 +KPX y comma -100 +KPX y c -35 +KPX y a -30 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 170 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 100 170 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 120 170 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 160 170 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 190 135 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 130 170 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 50 170 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex -10 170 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 10 170 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 50 170 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -45 170 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -130 170 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -110 170 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -95 170 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 130 170 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 210 170 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 150 170 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 170 170 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 210 170 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 180 170 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron -10 170 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 145 170 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 50 170 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 70 170 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 75 170 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 135 170 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 60 170 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 5 170 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 120 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 60 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 80 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 120 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 150 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 90 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 110 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 50 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 70 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 110 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -65 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -150 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -130 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -115 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 60 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 110 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 50 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 70 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 110 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 80 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron -50 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 125 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 30 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 50 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 55 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 115 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 40 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron -15 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagdo8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagdo8a.afm new file mode 100644 index 00000000..c348b117 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagdo8a.afm @@ -0,0 +1,576 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Mar 4 13:49:44 1991 +Comment UniqueID 34373 +Comment VMusage 6550 39938 +FontName AvantGarde-DemiOblique +FullName ITC Avant Garde Gothic Demi Oblique +FamilyName ITC Avant Garde Gothic +Weight Demi +ItalicAngle -10.5 +IsFixedPitch false +FontBBox -123 -251 1256 1021 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved.ITC Avant Garde Gothic is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 740 +XHeight 555 +Ascender 740 +Descender -185 +StartCharMetrics 228 +C 32 ; WX 280 ; N space ; B 0 0 0 0 ; +C 33 ; WX 280 ; N exclam ; B 73 0 343 740 ; +C 34 ; WX 360 ; N quotedbl ; B 127 444 478 740 ; +C 35 ; WX 560 ; N numbersign ; B 66 0 618 700 ; +C 36 ; WX 560 ; N dollar ; B 99 -86 582 857 ; +C 37 ; WX 860 ; N percent ; B 139 -15 856 755 ; +C 38 ; WX 680 ; N ampersand ; B 71 -15 742 755 ; +C 39 ; WX 280 ; N quoteright ; B 159 466 342 740 ; +C 40 ; WX 380 ; N parenleft ; B 120 -157 490 754 ; +C 41 ; WX 380 ; N parenright ; B 8 -157 378 754 ; +C 42 ; WX 440 ; N asterisk ; B 174 457 492 755 ; +C 43 ; WX 600 ; N plus ; B 84 0 610 506 ; +C 44 ; WX 280 ; N comma ; B 48 -141 231 133 ; +C 45 ; WX 420 ; N hyphen ; B 114 230 413 348 ; +C 46 ; WX 280 ; N period ; B 73 0 231 133 ; +C 47 ; WX 460 ; N slash ; B -13 -100 591 740 ; +C 48 ; WX 560 ; N zero ; B 70 -15 628 755 ; +C 49 ; WX 560 ; N one ; B 230 0 500 740 ; +C 50 ; WX 560 ; N two ; B 44 0 622 755 ; +C 51 ; WX 560 ; N three ; B 67 -15 585 755 ; +C 52 ; WX 560 ; N four ; B 36 0 604 740 ; +C 53 ; WX 560 ; N five ; B 64 -15 600 740 ; +C 54 ; WX 560 ; N six ; B 64 -15 587 739 ; +C 55 ; WX 560 ; N seven ; B 83 0 635 740 ; +C 56 ; WX 560 ; N eight ; B 71 -15 590 755 ; +C 57 ; WX 560 ; N nine ; B 110 0 633 754 ; +C 58 ; WX 280 ; N colon ; B 73 0 309 555 ; +C 59 ; WX 280 ; N semicolon ; B 48 -141 309 555 ; +C 60 ; WX 600 ; N less ; B 84 -8 649 514 ; +C 61 ; WX 600 ; N equal ; B 63 81 631 425 ; +C 62 ; WX 600 ; N greater ; B 45 -8 610 514 ; +C 63 ; WX 560 ; N question ; B 135 0 593 755 ; +C 64 ; WX 740 ; N at ; B 109 -12 832 712 ; +C 65 ; WX 740 ; N A ; B 7 0 732 740 ; +C 66 ; WX 580 ; N B ; B 70 0 610 740 ; +C 67 ; WX 780 ; N C ; B 97 -15 864 755 ; +C 68 ; WX 700 ; N D ; B 63 0 732 740 ; +C 69 ; WX 520 ; N E ; B 61 0 596 740 ; +C 70 ; WX 480 ; N F ; B 61 0 575 740 ; +C 71 ; WX 840 ; N G ; B 89 -15 887 755 ; +C 72 ; WX 680 ; N H ; B 71 0 747 740 ; +C 73 ; WX 280 ; N I ; B 72 0 346 740 ; +C 74 ; WX 480 ; N J ; B 34 -15 546 740 ; +C 75 ; WX 620 ; N K ; B 89 0 757 740 ; +C 76 ; WX 440 ; N L ; B 72 0 459 740 ; +C 77 ; WX 900 ; N M ; B 63 0 974 740 ; +C 78 ; WX 740 ; N N ; B 70 0 808 740 ; +C 79 ; WX 840 ; N O ; B 95 -15 882 755 ; +C 80 ; WX 560 ; N P ; B 72 0 645 740 ; +C 81 ; WX 840 ; N Q ; B 94 -15 882 755 ; +C 82 ; WX 580 ; N R ; B 64 0 656 740 ; +C 83 ; WX 520 ; N S ; B 49 -15 578 755 ; +C 84 ; WX 420 ; N T ; B 119 0 555 740 ; +C 85 ; WX 640 ; N U ; B 97 -15 722 740 ; +C 86 ; WX 700 ; N V ; B 145 0 832 740 ; +C 87 ; WX 900 ; N W ; B 144 0 1036 740 ; +C 88 ; WX 680 ; N X ; B 4 0 813 740 ; +C 89 ; WX 620 ; N Y ; B 135 0 759 740 ; +C 90 ; WX 500 ; N Z ; B 19 0 599 740 ; +C 91 ; WX 320 ; N bracketleft ; B 89 -157 424 754 ; +C 92 ; WX 640 ; N backslash ; B 233 -100 525 740 ; +C 93 ; WX 320 ; N bracketright ; B 7 -157 342 754 ; +C 94 ; WX 600 ; N asciicircum ; B 142 375 596 740 ; +C 95 ; WX 500 ; N underscore ; B -23 -125 486 -75 ; +C 96 ; WX 280 ; N quoteleft ; B 158 466 341 740 ; +C 97 ; WX 660 ; N a ; B 73 -18 716 574 ; +C 98 ; WX 660 ; N b ; B 47 -18 689 740 ; +C 99 ; WX 640 ; N c ; B 84 -18 679 574 ; +C 100 ; WX 660 ; N d ; B 80 -18 755 740 ; +C 101 ; WX 640 ; N e ; B 77 -18 667 577 ; +C 102 ; WX 280 ; N f ; B 62 0 420 755 ; L i fi ; L l fl ; +C 103 ; WX 660 ; N g ; B 33 -226 726 574 ; +C 104 ; WX 600 ; N h ; B 54 0 614 740 ; +C 105 ; WX 240 ; N i ; B 53 0 323 740 ; +C 106 ; WX 260 ; N j ; B -18 -185 342 740 ; +C 107 ; WX 580 ; N k ; B 80 0 648 740 ; +C 108 ; WX 240 ; N l ; B 54 0 324 740 ; +C 109 ; WX 940 ; N m ; B 54 0 954 574 ; +C 110 ; WX 600 ; N n ; B 54 0 613 574 ; +C 111 ; WX 640 ; N o ; B 71 -18 672 574 ; +C 112 ; WX 660 ; N p ; B 13 -185 686 574 ; +C 113 ; WX 660 ; N q ; B 78 -185 716 574 ; +C 114 ; WX 320 ; N r ; B 63 0 423 574 ; +C 115 ; WX 440 ; N s ; B 49 -18 483 574 ; +C 116 ; WX 300 ; N t ; B 86 0 402 740 ; +C 117 ; WX 600 ; N u ; B 87 -18 647 555 ; +C 118 ; WX 560 ; N v ; B 106 0 659 555 ; +C 119 ; WX 800 ; N w ; B 114 0 892 555 ; +C 120 ; WX 560 ; N x ; B 3 0 632 555 ; +C 121 ; WX 580 ; N y ; B 75 -185 674 555 ; +C 122 ; WX 460 ; N z ; B 20 0 528 555 ; +C 123 ; WX 340 ; N braceleft ; B 40 -191 455 747 ; +C 124 ; WX 600 ; N bar ; B 214 -100 503 740 ; +C 125 ; WX 340 ; N braceright ; B -12 -191 405 747 ; +C 126 ; WX 600 ; N asciitilde ; B 114 160 579 347 ; +C 161 ; WX 280 ; N exclamdown ; B 40 -185 310 555 ; +C 162 ; WX 560 ; N cent ; B 110 39 599 715 ; +C 163 ; WX 560 ; N sterling ; B 38 0 615 755 ; +C 164 ; WX 160 ; N fraction ; B -123 0 419 740 ; +C 165 ; WX 560 ; N yen ; B 83 0 707 740 ; +C 166 ; WX 560 ; N florin ; B -27 -151 664 824 ; +C 167 ; WX 560 ; N section ; B 65 -158 602 755 ; +C 168 ; WX 560 ; N currency ; B 53 69 628 577 ; +C 169 ; WX 220 ; N quotesingle ; B 152 444 314 740 ; +C 170 ; WX 480 ; N quotedblleft ; B 156 466 546 740 ; +C 171 ; WX 460 ; N guillemotleft ; B 105 108 487 469 ; +C 172 ; WX 240 ; N guilsinglleft ; B 94 108 277 469 ; +C 173 ; WX 240 ; N guilsinglright ; B 70 108 253 469 ; +C 174 ; WX 520 ; N fi ; B 72 0 598 755 ; +C 175 ; WX 520 ; N fl ; B 72 0 598 755 ; +C 177 ; WX 500 ; N endash ; B 78 230 529 348 ; +C 178 ; WX 560 ; N dagger ; B 133 -142 612 740 ; +C 179 ; WX 560 ; N daggerdbl ; B 63 -142 618 740 ; +C 180 ; WX 280 ; N periodcentered ; B 108 187 265 320 ; +C 182 ; WX 600 ; N paragraph ; B 90 -103 744 740 ; +C 183 ; WX 600 ; N bullet ; B 215 222 526 532 ; +C 184 ; WX 280 ; N quotesinglbase ; B 47 -141 230 133 ; +C 185 ; WX 480 ; N quotedblbase ; B 45 -141 435 133 ; +C 186 ; WX 480 ; N quotedblright ; B 157 466 547 740 ; +C 187 ; WX 460 ; N guillemotright ; B 81 108 463 469 ; +C 188 ; WX 1000 ; N ellipsis ; B 100 0 924 133 ; +C 189 ; WX 1280 ; N perthousand ; B 139 -15 1256 755 ; +C 191 ; WX 560 ; N questiondown ; B 69 -200 527 555 ; +C 193 ; WX 420 ; N grave ; B 189 624 462 851 ; +C 194 ; WX 420 ; N acute ; B 224 624 508 849 ; +C 195 ; WX 540 ; N circumflex ; B 189 636 588 774 ; +C 196 ; WX 480 ; N tilde ; B 178 636 564 767 ; +C 197 ; WX 420 ; N macron ; B 192 648 490 759 ; +C 198 ; WX 480 ; N breve ; B 185 633 582 770 ; +C 199 ; WX 280 ; N dotaccent ; B 192 636 350 769 ; +C 200 ; WX 500 ; N dieresis ; B 196 636 565 769 ; +C 202 ; WX 360 ; N ring ; B 206 619 424 834 ; +C 203 ; WX 340 ; N cedilla ; B 67 -251 272 6 ; +C 205 ; WX 700 ; N hungarumlaut ; B 258 610 754 862 ; +C 206 ; WX 340 ; N ogonek ; B 59 -195 243 9 ; +C 207 ; WX 540 ; N caron ; B 214 636 613 774 ; +C 208 ; WX 1000 ; N emdash ; B 78 230 1029 348 ; +C 225 ; WX 900 ; N AE ; B -5 0 961 740 ; +C 227 ; WX 360 ; N ordfeminine ; B 127 438 472 755 ; +C 232 ; WX 480 ; N Lslash ; B 68 0 484 740 ; +C 233 ; WX 840 ; N Oslash ; B 94 -71 891 814 ; +C 234 ; WX 1060 ; N OE ; B 98 -15 1144 755 ; +C 235 ; WX 360 ; N ordmasculine ; B 131 438 451 755 ; +C 241 ; WX 1080 ; N ae ; B 75 -18 1105 574 ; +C 245 ; WX 240 ; N dotlessi ; B 53 0 289 555 ; +C 248 ; WX 320 ; N lslash ; B 74 0 404 740 ; +C 249 ; WX 660 ; N oslash ; B 81 -50 685 608 ; +C 250 ; WX 1080 ; N oe ; B 76 -18 1108 574 ; +C 251 ; WX 600 ; N germandbls ; B 51 -18 629 755 ; +C -1 ; WX 640 ; N ecircumflex ; B 77 -18 667 774 ; +C -1 ; WX 640 ; N edieresis ; B 77 -18 667 769 ; +C -1 ; WX 660 ; N aacute ; B 73 -18 716 849 ; +C -1 ; WX 740 ; N registered ; B 50 -12 827 752 ; +C -1 ; WX 240 ; N icircumflex ; B 39 0 438 774 ; +C -1 ; WX 600 ; N udieresis ; B 87 -18 647 769 ; +C -1 ; WX 640 ; N ograve ; B 71 -18 672 851 ; +C -1 ; WX 600 ; N uacute ; B 87 -18 647 849 ; +C -1 ; WX 600 ; N ucircumflex ; B 87 -18 647 774 ; +C -1 ; WX 740 ; N Aacute ; B 7 0 732 1019 ; +C -1 ; WX 240 ; N igrave ; B 53 0 347 851 ; +C -1 ; WX 280 ; N Icircumflex ; B 72 0 489 944 ; +C -1 ; WX 640 ; N ccedilla ; B 83 -251 679 574 ; +C -1 ; WX 660 ; N adieresis ; B 73 -18 716 769 ; +C -1 ; WX 520 ; N Ecircumflex ; B 61 0 609 944 ; +C -1 ; WX 440 ; N scaron ; B 49 -18 563 774 ; +C -1 ; WX 660 ; N thorn ; B 13 -185 686 740 ; +C -1 ; WX 1000 ; N trademark ; B 131 296 958 740 ; +C -1 ; WX 640 ; N egrave ; B 77 -18 667 851 ; +C -1 ; WX 336 ; N threesuperior ; B 87 287 413 749 ; +C -1 ; WX 460 ; N zcaron ; B 20 0 598 774 ; +C -1 ; WX 660 ; N atilde ; B 73 -18 716 767 ; +C -1 ; WX 660 ; N aring ; B 73 -18 716 834 ; +C -1 ; WX 640 ; N ocircumflex ; B 71 -18 672 774 ; +C -1 ; WX 520 ; N Edieresis ; B 61 0 606 939 ; +C -1 ; WX 840 ; N threequarters ; B 97 0 836 749 ; +C -1 ; WX 580 ; N ydieresis ; B 75 -185 674 769 ; +C -1 ; WX 580 ; N yacute ; B 75 -185 674 849 ; +C -1 ; WX 240 ; N iacute ; B 53 0 443 849 ; +C -1 ; WX 740 ; N Acircumflex ; B 7 0 732 944 ; +C -1 ; WX 640 ; N Uacute ; B 97 -15 722 1019 ; +C -1 ; WX 640 ; N eacute ; B 77 -18 667 849 ; +C -1 ; WX 840 ; N Ograve ; B 95 -15 882 1021 ; +C -1 ; WX 660 ; N agrave ; B 73 -18 716 851 ; +C -1 ; WX 640 ; N Udieresis ; B 97 -15 722 939 ; +C -1 ; WX 660 ; N acircumflex ; B 73 -18 716 774 ; +C -1 ; WX 280 ; N Igrave ; B 72 0 398 1021 ; +C -1 ; WX 336 ; N twosuperior ; B 73 296 436 749 ; +C -1 ; WX 640 ; N Ugrave ; B 97 -15 722 1021 ; +C -1 ; WX 840 ; N onequarter ; B 187 0 779 740 ; +C -1 ; WX 640 ; N Ucircumflex ; B 97 -15 722 944 ; +C -1 ; WX 520 ; N Scaron ; B 49 -15 635 944 ; +C -1 ; WX 280 ; N Idieresis ; B 72 0 486 939 ; +C -1 ; WX 240 ; N idieresis ; B 53 0 435 769 ; +C -1 ; WX 520 ; N Egrave ; B 61 0 596 1021 ; +C -1 ; WX 840 ; N Oacute ; B 95 -15 882 1019 ; +C -1 ; WX 600 ; N divide ; B 84 -20 610 526 ; +C -1 ; WX 740 ; N Atilde ; B 7 0 732 937 ; +C -1 ; WX 740 ; N Aring ; B 7 0 732 969 ; +C -1 ; WX 840 ; N Odieresis ; B 95 -15 882 939 ; +C -1 ; WX 740 ; N Adieresis ; B 7 0 732 939 ; +C -1 ; WX 740 ; N Ntilde ; B 70 0 808 937 ; +C -1 ; WX 500 ; N Zcaron ; B 19 0 650 944 ; +C -1 ; WX 560 ; N Thorn ; B 72 0 619 740 ; +C -1 ; WX 280 ; N Iacute ; B 72 0 494 1019 ; +C -1 ; WX 600 ; N plusminus ; B 37 -62 626 556 ; +C -1 ; WX 600 ; N multiply ; B 76 12 617 494 ; +C -1 ; WX 520 ; N Eacute ; B 61 0 596 1019 ; +C -1 ; WX 620 ; N Ydieresis ; B 135 0 759 939 ; +C -1 ; WX 336 ; N onesuperior ; B 182 296 360 740 ; +C -1 ; WX 600 ; N ugrave ; B 87 -18 647 851 ; +C -1 ; WX 600 ; N logicalnot ; B 105 108 631 425 ; +C -1 ; WX 600 ; N ntilde ; B 54 0 624 767 ; +C -1 ; WX 840 ; N Otilde ; B 95 -15 882 937 ; +C -1 ; WX 640 ; N otilde ; B 71 -18 672 767 ; +C -1 ; WX 780 ; N Ccedilla ; B 97 -251 864 755 ; +C -1 ; WX 740 ; N Agrave ; B 7 0 732 1021 ; +C -1 ; WX 840 ; N onehalf ; B 157 0 830 740 ; +C -1 ; WX 742 ; N Eth ; B 83 0 766 740 ; +C -1 ; WX 400 ; N degree ; B 160 426 451 712 ; +C -1 ; WX 620 ; N Yacute ; B 135 0 759 1019 ; +C -1 ; WX 840 ; N Ocircumflex ; B 95 -15 882 944 ; +C -1 ; WX 640 ; N oacute ; B 71 -18 672 849 ; +C -1 ; WX 576 ; N mu ; B 3 -187 642 555 ; +C -1 ; WX 600 ; N minus ; B 84 193 610 313 ; +C -1 ; WX 640 ; N eth ; B 73 -18 699 754 ; +C -1 ; WX 640 ; N odieresis ; B 71 -18 672 769 ; +C -1 ; WX 740 ; N copyright ; B 50 -12 827 752 ; +C -1 ; WX 600 ; N brokenbar ; B 214 -100 503 740 ; +EndCharMetrics +StartKernData +StartKernPairs 218 + +KPX A y -50 +KPX A w -65 +KPX A v -70 +KPX A u -20 +KPX A quoteright -90 +KPX A Y -80 +KPX A W -60 +KPX A V -102 +KPX A U -40 +KPX A T -25 +KPX A Q -50 +KPX A O -50 +KPX A G -40 +KPX A C -40 + +KPX B A -10 + +KPX C A -40 + +KPX D period -20 +KPX D comma -20 +KPX D Y -45 +KPX D W -25 +KPX D V -50 +KPX D A -50 + +KPX F period -129 +KPX F e -20 +KPX F comma -162 +KPX F a -20 +KPX F A -75 + +KPX G period -20 +KPX G comma -20 +KPX G Y -15 + +KPX J period -15 +KPX J a -20 +KPX J A -30 + +KPX K y -20 +KPX K u -15 +KPX K o -45 +KPX K e -40 +KPX K O -30 + +KPX L y -23 +KPX L quoteright -30 +KPX L quotedblright -30 +KPX L Y -80 +KPX L W -55 +KPX L V -85 +KPX L T -46 + +KPX O period -30 +KPX O comma -30 +KPX O Y -30 +KPX O X -30 +KPX O W -20 +KPX O V -45 +KPX O T -15 +KPX O A -60 + +KPX P period -200 +KPX P o -20 +KPX P e -20 +KPX P comma -220 +KPX P a -20 +KPX P A -100 + +KPX Q comma 20 + +KPX R W 25 +KPX R V -10 +KPX R U 25 +KPX R T 40 +KPX R O 25 + +KPX S comma 20 + +KPX T y -10 +KPX T w -55 +KPX T u -46 +KPX T semicolon -29 +KPX T r -30 +KPX T period -91 +KPX T o -49 +KPX T hyphen -75 +KPX T e -49 +KPX T comma -82 +KPX T colon -15 +KPX T a -70 +KPX T O -15 +KPX T A -25 + +KPX U period -20 +KPX U comma -20 +KPX U A -40 + +KPX V u -55 +KPX V semicolon -33 +KPX V period -145 +KPX V o -101 +KPX V i -15 +KPX V hyphen -75 +KPX V e -101 +KPX V comma -145 +KPX V colon -18 +KPX V a -95 +KPX V O -45 +KPX V G -20 +KPX V A -102 + +KPX W y -15 +KPX W u -30 +KPX W semicolon -33 +KPX W period -106 +KPX W o -46 +KPX W i -10 +KPX W hyphen -35 +KPX W e -47 +KPX W comma -106 +KPX W colon -15 +KPX W a -50 +KPX W O -20 +KPX W A -58 + +KPX Y u -52 +KPX Y semicolon -23 +KPX Y period -145 +KPX Y o -89 +KPX Y hyphen -100 +KPX Y e -89 +KPX Y comma -145 +KPX Y colon -10 +KPX Y a -93 +KPX Y O -30 +KPX Y A -80 + +KPX a t 5 +KPX a p 20 +KPX a b 5 + +KPX b y -20 +KPX b v -20 + +KPX c y -20 +KPX c l -15 +KPX c k -15 + +KPX comma space -50 +KPX comma quoteright -70 +KPX comma quotedblright -70 + +KPX e y -20 +KPX e x -20 +KPX e w -20 +KPX e v -20 + +KPX f period -40 +KPX f o -20 +KPX f l -15 +KPX f i -15 +KPX f f -20 +KPX f dotlessi -15 +KPX f comma -40 +KPX f a -15 + +KPX g i 25 +KPX g a 15 + +KPX h y -30 + +KPX k y -5 +KPX k o -30 +KPX k e -40 + +KPX m y -20 +KPX m u -20 + +KPX n y -15 +KPX n v -30 + +KPX o y -20 +KPX o x -30 +KPX o w -20 +KPX o v -30 + +KPX p y -20 + +KPX period space -50 +KPX period quoteright -70 +KPX period quotedblright -70 + +KPX quotedblleft A -50 + +KPX quotedblright space -50 + +KPX quoteleft quoteleft -80 +KPX quoteleft A -50 + +KPX quoteright v -10 +KPX quoteright t 10 +KPX quoteright space -50 +KPX quoteright s -15 +KPX quoteright r -20 +KPX quoteright quoteright -80 +KPX quoteright d -50 + +KPX r y 40 +KPX r v 40 +KPX r u 20 +KPX r t 20 +KPX r s 20 +KPX r q -8 +KPX r period -73 +KPX r p 20 +KPX r o -15 +KPX r n 21 +KPX r m 15 +KPX r l 20 +KPX r k 5 +KPX r i 20 +KPX r hyphen -60 +KPX r g 1 +KPX r e -4 +KPX r d -6 +KPX r comma -75 +KPX r c -7 + +KPX s period 20 +KPX s comma 20 + +KPX space quoteleft -50 +KPX space quotedblleft -50 +KPX space Y -60 +KPX space W -25 +KPX space V -80 +KPX space T -25 +KPX space A -20 + +KPX v period -90 +KPX v o -20 +KPX v e -20 +KPX v comma -90 +KPX v a -30 + +KPX w period -90 +KPX w o -30 +KPX w e -20 +KPX w comma -90 +KPX w a -30 + +KPX x e -20 + +KPX y period -100 +KPX y o -30 +KPX y e -20 +KPX y comma -100 +KPX y c -35 +KPX y a -30 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 192 170 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 132 170 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 152 170 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 192 170 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 215 135 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 162 170 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 82 170 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 22 170 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 42 170 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 82 170 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -13 170 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -98 170 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -78 170 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -63 170 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 162 170 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 242 170 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 182 170 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 202 170 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 242 170 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 212 170 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 22 170 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 177 170 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 82 170 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 102 170 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 107 170 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 167 170 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 92 170 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 37 170 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 120 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 60 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 80 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 120 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 150 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 90 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 110 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 50 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 70 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 110 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -65 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -150 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -130 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -115 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 60 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 110 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 50 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 70 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 110 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 80 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron -50 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 125 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 30 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 50 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 55 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 115 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 40 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron -15 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagk8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagk8a.afm new file mode 100644 index 00000000..53b03bbb --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagk8a.afm @@ -0,0 +1,573 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Mar 4 13:37:31 1991 +Comment UniqueID 34364 +Comment VMusage 24225 31117 +FontName AvantGarde-Book +FullName ITC Avant Garde Gothic Book +FamilyName ITC Avant Garde Gothic +Weight Book +ItalicAngle 0 +IsFixedPitch false +FontBBox -113 -222 1148 955 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved.ITC Avant Garde Gothic is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 740 +XHeight 547 +Ascender 740 +Descender -192 +StartCharMetrics 228 +C 32 ; WX 277 ; N space ; B 0 0 0 0 ; +C 33 ; WX 295 ; N exclam ; B 111 0 185 740 ; +C 34 ; WX 309 ; N quotedbl ; B 36 444 273 740 ; +C 35 ; WX 554 ; N numbersign ; B 33 0 521 740 ; +C 36 ; WX 554 ; N dollar ; B 70 -70 485 811 ; +C 37 ; WX 775 ; N percent ; B 21 -13 753 751 ; +C 38 ; WX 757 ; N ampersand ; B 56 -12 736 753 ; +C 39 ; WX 351 ; N quoteright ; B 94 546 256 740 ; +C 40 ; WX 369 ; N parenleft ; B 47 -205 355 757 ; +C 41 ; WX 369 ; N parenright ; B 14 -205 322 757 ; +C 42 ; WX 425 ; N asterisk ; B 58 446 367 740 ; +C 43 ; WX 606 ; N plus ; B 51 0 555 506 ; +C 44 ; WX 277 ; N comma ; B 14 -67 176 126 ; +C 45 ; WX 332 ; N hyphen ; B 30 248 302 315 ; +C 46 ; WX 277 ; N period ; B 102 0 176 126 ; +C 47 ; WX 437 ; N slash ; B 44 -100 403 740 ; +C 48 ; WX 554 ; N zero ; B 29 -13 525 753 ; +C 49 ; WX 554 ; N one ; B 135 0 336 740 ; +C 50 ; WX 554 ; N two ; B 40 0 514 753 ; +C 51 ; WX 554 ; N three ; B 34 -13 506 753 ; +C 52 ; WX 554 ; N four ; B 14 0 528 740 ; +C 53 ; WX 554 ; N five ; B 26 -13 530 740 ; +C 54 ; WX 554 ; N six ; B 24 -13 530 739 ; +C 55 ; WX 554 ; N seven ; B 63 0 491 740 ; +C 56 ; WX 554 ; N eight ; B 41 -13 513 753 ; +C 57 ; WX 554 ; N nine ; B 24 0 530 752 ; +C 58 ; WX 277 ; N colon ; B 102 0 176 548 ; +C 59 ; WX 277 ; N semicolon ; B 14 -67 176 548 ; +C 60 ; WX 606 ; N less ; B 46 -8 554 514 ; +C 61 ; WX 606 ; N equal ; B 51 118 555 388 ; +C 62 ; WX 606 ; N greater ; B 52 -8 560 514 ; +C 63 ; WX 591 ; N question ; B 64 0 526 752 ; +C 64 ; WX 867 ; N at ; B 65 -13 803 753 ; +C 65 ; WX 740 ; N A ; B 12 0 729 740 ; +C 66 ; WX 574 ; N B ; B 74 0 544 740 ; +C 67 ; WX 813 ; N C ; B 43 -13 771 752 ; +C 68 ; WX 744 ; N D ; B 74 0 699 740 ; +C 69 ; WX 536 ; N E ; B 70 0 475 740 ; +C 70 ; WX 485 ; N F ; B 70 0 444 740 ; +C 71 ; WX 872 ; N G ; B 40 -13 828 753 ; +C 72 ; WX 683 ; N H ; B 76 0 607 740 ; +C 73 ; WX 226 ; N I ; B 76 0 150 740 ; +C 74 ; WX 482 ; N J ; B 6 -13 402 740 ; +C 75 ; WX 591 ; N K ; B 81 0 591 740 ; +C 76 ; WX 462 ; N L ; B 82 0 462 740 ; +C 77 ; WX 919 ; N M ; B 76 0 843 740 ; +C 78 ; WX 740 ; N N ; B 75 0 664 740 ; +C 79 ; WX 869 ; N O ; B 43 -13 826 753 ; +C 80 ; WX 592 ; N P ; B 75 0 564 740 ; +C 81 ; WX 871 ; N Q ; B 40 -13 837 753 ; +C 82 ; WX 607 ; N R ; B 70 0 572 740 ; +C 83 ; WX 498 ; N S ; B 22 -13 473 753 ; +C 84 ; WX 426 ; N T ; B 6 0 419 740 ; +C 85 ; WX 655 ; N U ; B 75 -13 579 740 ; +C 86 ; WX 702 ; N V ; B 8 0 693 740 ; +C 87 ; WX 960 ; N W ; B 11 0 950 740 ; +C 88 ; WX 609 ; N X ; B 8 0 602 740 ; +C 89 ; WX 592 ; N Y ; B 1 0 592 740 ; +C 90 ; WX 480 ; N Z ; B 12 0 470 740 ; +C 91 ; WX 351 ; N bracketleft ; B 133 -179 337 753 ; +C 92 ; WX 605 ; N backslash ; B 118 -100 477 740 ; +C 93 ; WX 351 ; N bracketright ; B 14 -179 218 753 ; +C 94 ; WX 606 ; N asciicircum ; B 53 307 553 740 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 351 ; N quoteleft ; B 95 546 257 740 ; +C 97 ; WX 683 ; N a ; B 42 -13 621 561 ; +C 98 ; WX 682 ; N b ; B 68 -13 647 740 ; +C 99 ; WX 647 ; N c ; B 41 -13 607 561 ; +C 100 ; WX 685 ; N d ; B 39 -13 618 740 ; +C 101 ; WX 650 ; N e ; B 38 -13 608 561 ; +C 102 ; WX 314 ; N f ; B 19 0 314 753 ; L i fi ; L l fl ; +C 103 ; WX 673 ; N g ; B 37 -215 606 561 ; +C 104 ; WX 610 ; N h ; B 62 0 543 740 ; +C 105 ; WX 200 ; N i ; B 65 0 135 740 ; +C 106 ; WX 203 ; N j ; B -44 -192 137 740 ; +C 107 ; WX 502 ; N k ; B 70 0 498 740 ; +C 108 ; WX 200 ; N l ; B 65 0 135 740 ; +C 109 ; WX 938 ; N m ; B 66 0 872 561 ; +C 110 ; WX 610 ; N n ; B 65 0 546 561 ; +C 111 ; WX 655 ; N o ; B 42 -13 614 561 ; +C 112 ; WX 682 ; N p ; B 64 -192 643 561 ; +C 113 ; WX 682 ; N q ; B 37 -192 616 561 ; +C 114 ; WX 301 ; N r ; B 65 0 291 561 ; +C 115 ; WX 388 ; N s ; B 24 -13 364 561 ; +C 116 ; WX 339 ; N t ; B 14 0 330 740 ; +C 117 ; WX 608 ; N u ; B 62 -13 541 547 ; +C 118 ; WX 554 ; N v ; B 7 0 546 547 ; +C 119 ; WX 831 ; N w ; B 13 0 820 547 ; +C 120 ; WX 480 ; N x ; B 12 0 468 547 ; +C 121 ; WX 536 ; N y ; B 15 -192 523 547 ; +C 122 ; WX 425 ; N z ; B 10 0 415 547 ; +C 123 ; WX 351 ; N braceleft ; B 70 -189 331 740 ; +C 124 ; WX 672 ; N bar ; B 299 -100 373 740 ; +C 125 ; WX 351 ; N braceright ; B 20 -189 281 740 ; +C 126 ; WX 606 ; N asciitilde ; B 72 179 534 319 ; +C 161 ; WX 295 ; N exclamdown ; B 110 -192 184 548 ; +C 162 ; WX 554 ; N cent ; B 48 62 510 707 ; +C 163 ; WX 554 ; N sterling ; B 4 0 552 753 ; +C 164 ; WX 166 ; N fraction ; B -113 0 280 740 ; +C 165 ; WX 554 ; N yen ; B 4 0 550 740 ; +C 166 ; WX 554 ; N florin ; B -12 -153 518 818 ; +C 167 ; WX 615 ; N section ; B 85 -141 529 753 ; +C 168 ; WX 554 ; N currency ; B 8 42 546 580 ; +C 169 ; WX 198 ; N quotesingle ; B 59 444 140 740 ; +C 170 ; WX 502 ; N quotedblleft ; B 97 546 406 740 ; +C 171 ; WX 425 ; N guillemotleft ; B 40 81 386 481 ; +C 172 ; WX 251 ; N guilsinglleft ; B 40 81 212 481 ; +C 173 ; WX 251 ; N guilsinglright ; B 39 81 211 481 ; +C 174 ; WX 487 ; N fi ; B 19 0 422 753 ; +C 175 ; WX 485 ; N fl ; B 19 0 420 753 ; +C 177 ; WX 500 ; N endash ; B 35 248 465 315 ; +C 178 ; WX 553 ; N dagger ; B 59 -133 493 740 ; +C 179 ; WX 553 ; N daggerdbl ; B 59 -133 493 740 ; +C 180 ; WX 277 ; N periodcentered ; B 102 190 176 316 ; +C 182 ; WX 564 ; N paragraph ; B 22 -110 551 740 ; +C 183 ; WX 606 ; N bullet ; B 150 222 455 532 ; +C 184 ; WX 354 ; N quotesinglbase ; B 89 -68 251 126 ; +C 185 ; WX 502 ; N quotedblbase ; B 89 -68 399 126 ; +C 186 ; WX 484 ; N quotedblright ; B 96 546 405 740 ; +C 187 ; WX 425 ; N guillemotright ; B 39 81 385 481 ; +C 188 ; WX 1000 ; N ellipsis ; B 130 0 870 126 ; +C 189 ; WX 1174 ; N perthousand ; B 25 -13 1148 751 ; +C 191 ; WX 591 ; N questiondown ; B 65 -205 527 548 ; +C 193 ; WX 378 ; N grave ; B 69 619 300 786 ; +C 194 ; WX 375 ; N acute ; B 78 619 309 786 ; +C 195 ; WX 502 ; N circumflex ; B 74 639 428 764 ; +C 196 ; WX 439 ; N tilde ; B 47 651 392 754 ; +C 197 ; WX 485 ; N macron ; B 73 669 411 736 ; +C 198 ; WX 453 ; N breve ; B 52 651 401 754 ; +C 199 ; WX 222 ; N dotaccent ; B 74 639 148 765 ; +C 200 ; WX 369 ; N dieresis ; B 73 639 295 765 ; +C 202 ; WX 332 ; N ring ; B 62 600 269 807 ; +C 203 ; WX 324 ; N cedilla ; B 80 -222 254 0 ; +C 205 ; WX 552 ; N hungarumlaut ; B 119 605 453 800 ; +C 206 ; WX 302 ; N ogonek ; B 73 -191 228 0 ; +C 207 ; WX 502 ; N caron ; B 68 639 423 764 ; +C 208 ; WX 1000 ; N emdash ; B 35 248 965 315 ; +C 225 ; WX 992 ; N AE ; B -20 0 907 740 ; +C 227 ; WX 369 ; N ordfeminine ; B -3 407 356 753 ; +C 232 ; WX 517 ; N Lslash ; B 59 0 517 740 ; +C 233 ; WX 868 ; N Oslash ; B 43 -83 826 819 ; +C 234 ; WX 1194 ; N OE ; B 45 -13 1142 753 ; +C 235 ; WX 369 ; N ordmasculine ; B 12 407 356 753 ; +C 241 ; WX 1157 ; N ae ; B 34 -13 1113 561 ; +C 245 ; WX 200 ; N dotlessi ; B 65 0 135 547 ; +C 248 ; WX 300 ; N lslash ; B 43 0 259 740 ; +C 249 ; WX 653 ; N oslash ; B 41 -64 613 614 ; +C 250 ; WX 1137 ; N oe ; B 34 -13 1104 561 ; +C 251 ; WX 554 ; N germandbls ; B 61 -13 525 753 ; +C -1 ; WX 650 ; N ecircumflex ; B 38 -13 608 764 ; +C -1 ; WX 650 ; N edieresis ; B 38 -13 608 765 ; +C -1 ; WX 683 ; N aacute ; B 42 -13 621 786 ; +C -1 ; WX 747 ; N registered ; B -9 -12 755 752 ; +C -1 ; WX 200 ; N icircumflex ; B -77 0 277 764 ; +C -1 ; WX 608 ; N udieresis ; B 62 -13 541 765 ; +C -1 ; WX 655 ; N ograve ; B 42 -13 614 786 ; +C -1 ; WX 608 ; N uacute ; B 62 -13 541 786 ; +C -1 ; WX 608 ; N ucircumflex ; B 62 -13 541 764 ; +C -1 ; WX 740 ; N Aacute ; B 12 0 729 949 ; +C -1 ; WX 200 ; N igrave ; B -60 0 171 786 ; +C -1 ; WX 226 ; N Icircumflex ; B -64 0 290 927 ; +C -1 ; WX 647 ; N ccedilla ; B 41 -222 607 561 ; +C -1 ; WX 683 ; N adieresis ; B 42 -13 621 765 ; +C -1 ; WX 536 ; N Ecircumflex ; B 70 0 475 927 ; +C -1 ; WX 388 ; N scaron ; B 11 -13 366 764 ; +C -1 ; WX 682 ; N thorn ; B 64 -192 643 740 ; +C -1 ; WX 1000 ; N trademark ; B 9 296 816 740 ; +C -1 ; WX 650 ; N egrave ; B 38 -13 608 786 ; +C -1 ; WX 332 ; N threesuperior ; B 18 289 318 747 ; +C -1 ; WX 425 ; N zcaron ; B 10 0 415 764 ; +C -1 ; WX 683 ; N atilde ; B 42 -13 621 754 ; +C -1 ; WX 683 ; N aring ; B 42 -13 621 807 ; +C -1 ; WX 655 ; N ocircumflex ; B 42 -13 614 764 ; +C -1 ; WX 536 ; N Edieresis ; B 70 0 475 928 ; +C -1 ; WX 831 ; N threequarters ; B 46 0 784 747 ; +C -1 ; WX 536 ; N ydieresis ; B 15 -192 523 765 ; +C -1 ; WX 536 ; N yacute ; B 15 -192 523 786 ; +C -1 ; WX 200 ; N iacute ; B 31 0 262 786 ; +C -1 ; WX 740 ; N Acircumflex ; B 12 0 729 927 ; +C -1 ; WX 655 ; N Uacute ; B 75 -13 579 949 ; +C -1 ; WX 650 ; N eacute ; B 38 -13 608 786 ; +C -1 ; WX 869 ; N Ograve ; B 43 -13 826 949 ; +C -1 ; WX 683 ; N agrave ; B 42 -13 621 786 ; +C -1 ; WX 655 ; N Udieresis ; B 75 -13 579 928 ; +C -1 ; WX 683 ; N acircumflex ; B 42 -13 621 764 ; +C -1 ; WX 226 ; N Igrave ; B -47 0 184 949 ; +C -1 ; WX 332 ; N twosuperior ; B 19 296 318 747 ; +C -1 ; WX 655 ; N Ugrave ; B 75 -13 579 949 ; +C -1 ; WX 831 ; N onequarter ; B 100 0 729 740 ; +C -1 ; WX 655 ; N Ucircumflex ; B 75 -13 579 927 ; +C -1 ; WX 498 ; N Scaron ; B 22 -13 473 927 ; +C -1 ; WX 226 ; N Idieresis ; B 2 0 224 928 ; +C -1 ; WX 200 ; N idieresis ; B -11 0 211 765 ; +C -1 ; WX 536 ; N Egrave ; B 70 0 475 949 ; +C -1 ; WX 869 ; N Oacute ; B 43 -13 826 949 ; +C -1 ; WX 606 ; N divide ; B 51 -13 555 519 ; +C -1 ; WX 740 ; N Atilde ; B 12 0 729 917 ; +C -1 ; WX 740 ; N Aring ; B 12 0 729 955 ; +C -1 ; WX 869 ; N Odieresis ; B 43 -13 826 928 ; +C -1 ; WX 740 ; N Adieresis ; B 12 0 729 928 ; +C -1 ; WX 740 ; N Ntilde ; B 75 0 664 917 ; +C -1 ; WX 480 ; N Zcaron ; B 12 0 470 927 ; +C -1 ; WX 592 ; N Thorn ; B 60 0 549 740 ; +C -1 ; WX 226 ; N Iacute ; B 44 0 275 949 ; +C -1 ; WX 606 ; N plusminus ; B 51 -24 555 518 ; +C -1 ; WX 606 ; N multiply ; B 74 24 533 482 ; +C -1 ; WX 536 ; N Eacute ; B 70 0 475 949 ; +C -1 ; WX 592 ; N Ydieresis ; B 1 0 592 928 ; +C -1 ; WX 332 ; N onesuperior ; B 63 296 198 740 ; +C -1 ; WX 608 ; N ugrave ; B 62 -13 541 786 ; +C -1 ; WX 606 ; N logicalnot ; B 51 109 555 388 ; +C -1 ; WX 610 ; N ntilde ; B 65 0 546 754 ; +C -1 ; WX 869 ; N Otilde ; B 43 -13 826 917 ; +C -1 ; WX 655 ; N otilde ; B 42 -13 614 754 ; +C -1 ; WX 813 ; N Ccedilla ; B 43 -222 771 752 ; +C -1 ; WX 740 ; N Agrave ; B 12 0 729 949 ; +C -1 ; WX 831 ; N onehalf ; B 81 0 750 740 ; +C -1 ; WX 790 ; N Eth ; B 40 0 739 740 ; +C -1 ; WX 400 ; N degree ; B 56 421 344 709 ; +C -1 ; WX 592 ; N Yacute ; B 1 0 592 949 ; +C -1 ; WX 869 ; N Ocircumflex ; B 43 -13 826 927 ; +C -1 ; WX 655 ; N oacute ; B 42 -13 614 786 ; +C -1 ; WX 608 ; N mu ; B 80 -184 527 547 ; +C -1 ; WX 606 ; N minus ; B 51 219 555 287 ; +C -1 ; WX 655 ; N eth ; B 42 -12 614 753 ; +C -1 ; WX 655 ; N odieresis ; B 42 -13 614 765 ; +C -1 ; WX 747 ; N copyright ; B -9 -12 755 752 ; +C -1 ; WX 672 ; N brokenbar ; B 299 -100 373 740 ; +EndCharMetrics +StartKernData +StartKernPairs 216 + +KPX A y -62 +KPX A w -65 +KPX A v -70 +KPX A u -20 +KPX A quoteright -100 +KPX A quotedblright -100 +KPX A Y -92 +KPX A W -60 +KPX A V -102 +KPX A U -40 +KPX A T -45 +KPX A Q -40 +KPX A O -50 +KPX A G -40 +KPX A C -40 + +KPX B A -10 + +KPX C A -40 + +KPX D period -20 +KPX D comma -20 +KPX D Y -30 +KPX D W -10 +KPX D V -50 +KPX D A -50 + +KPX F period -160 +KPX F e -20 +KPX F comma -180 +KPX F a -20 +KPX F A -75 + +KPX G period -20 +KPX G comma -20 +KPX G Y -20 + +KPX J period -15 +KPX J a -20 +KPX J A -30 + +KPX K o -15 +KPX K e -20 +KPX K O -20 + +KPX L y -23 +KPX L quoteright -130 +KPX L quotedblright -130 +KPX L Y -91 +KPX L W -67 +KPX L V -113 +KPX L T -46 + +KPX O period -30 +KPX O comma -30 +KPX O Y -30 +KPX O X -30 +KPX O W -20 +KPX O V -60 +KPX O T -30 +KPX O A -60 + +KPX P period -300 +KPX P o -60 +KPX P e -20 +KPX P comma -280 +KPX P a -20 +KPX P A -114 + +KPX Q comma 20 + +KPX R Y -10 +KPX R W 10 +KPX R V -10 +KPX R T 6 + +KPX S comma 20 + +KPX T y -50 +KPX T w -55 +KPX T u -46 +KPX T semicolon -29 +KPX T r -30 +KPX T period -91 +KPX T o -70 +KPX T i 10 +KPX T hyphen -75 +KPX T e -49 +KPX T comma -82 +KPX T colon -15 +KPX T a -90 +KPX T O -30 +KPX T A -45 + +KPX U period -20 +KPX U comma -20 +KPX U A -40 + +KPX V u -40 +KPX V semicolon -33 +KPX V period -165 +KPX V o -101 +KPX V i -5 +KPX V hyphen -75 +KPX V e -101 +KPX V comma -145 +KPX V colon -18 +KPX V a -104 +KPX V O -60 +KPX V G -20 +KPX V A -102 + +KPX W y -2 +KPX W u -30 +KPX W semicolon -33 +KPX W period -106 +KPX W o -46 +KPX W i 6 +KPX W hyphen -35 +KPX W e -47 +KPX W comma -106 +KPX W colon -15 +KPX W a -50 +KPX W O -20 +KPX W A -58 + +KPX Y u -52 +KPX Y semicolon -23 +KPX Y period -175 +KPX Y o -89 +KPX Y hyphen -85 +KPX Y e -89 +KPX Y comma -145 +KPX Y colon -10 +KPX Y a -93 +KPX Y O -30 +KPX Y A -92 + +KPX a p 20 +KPX a b 20 + +KPX b y -20 +KPX b v -20 + +KPX c y -20 +KPX c k -15 + +KPX comma space -110 +KPX comma quoteright -120 +KPX comma quotedblright -120 + +KPX e y -20 +KPX e w -20 +KPX e v -20 + +KPX f period -50 +KPX f o -40 +KPX f l -30 +KPX f i -34 +KPX f f -60 +KPX f e -20 +KPX f dotlessi -34 +KPX f comma -50 +KPX f a -40 + +KPX g a -15 + +KPX h y -30 + +KPX k y -5 +KPX k e -15 + +KPX m y -20 +KPX m u -20 +KPX m a -20 + +KPX n y -15 +KPX n v -20 + +KPX o y -20 +KPX o x -15 +KPX o w -20 +KPX o v -30 + +KPX p y -20 + +KPX period space -110 +KPX period quoteright -120 +KPX period quotedblright -120 + +KPX quotedblleft quoteleft -35 +KPX quotedblleft A -100 + +KPX quotedblright space -110 + +KPX quoteleft quoteleft -203 +KPX quoteleft A -100 + +KPX quoteright v -30 +KPX quoteright t 10 +KPX quoteright space -110 +KPX quoteright s -15 +KPX quoteright r -20 +KPX quoteright quoteright -203 +KPX quoteright quotedblright -35 +KPX quoteright d -110 + +KPX r y 40 +KPX r v 40 +KPX r u 20 +KPX r t 20 +KPX r s 20 +KPX r q -8 +KPX r period -73 +KPX r p 20 +KPX r o -20 +KPX r n 21 +KPX r m 28 +KPX r l 20 +KPX r k 20 +KPX r i 20 +KPX r hyphen -60 +KPX r g -15 +KPX r e -4 +KPX r d -6 +KPX r comma -75 +KPX r c -20 +KPX r a -20 + +KPX s period 20 +KPX s comma 20 + +KPX space quoteleft -110 +KPX space quotedblleft -110 +KPX space Y -60 +KPX space W -25 +KPX space V -50 +KPX space T -25 +KPX space A -20 + +KPX v period -130 +KPX v o -30 +KPX v e -20 +KPX v comma -100 +KPX v a -30 + +KPX w period -100 +KPX w o -30 +KPX w h 15 +KPX w e -20 +KPX w comma -90 +KPX w a -30 + +KPX y period -125 +KPX y o -30 +KPX y e -20 +KPX y comma -110 +KPX y a -30 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 183 163 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 119 163 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 186 163 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 181 163 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 204 148 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 151 163 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 81 163 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 17 163 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 84 163 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 79 163 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -34 163 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -138 163 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -71 163 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -116 163 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 151 163 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 247 163 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 184 163 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 250 163 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 246 163 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 215 163 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron -2 163 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 160 163 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 77 163 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 143 163 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 119 163 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 129 163 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 112 163 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron -11 163 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 154 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 91 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 157 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 153 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 176 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 122 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 138 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 74 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 141 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 136 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -47 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -151 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -84 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -129 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 86 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 140 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 77 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 143 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 139 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 108 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron -57 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 137 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 53 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 120 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 95 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 101 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron -38 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagko8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagko8a.afm new file mode 100644 index 00000000..e0e75f38 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pagko8a.afm @@ -0,0 +1,573 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Mar 4 13:41:11 1991 +Comment UniqueID 34367 +Comment VMusage 6555 39267 +FontName AvantGarde-BookOblique +FullName ITC Avant Garde Gothic Book Oblique +FamilyName ITC Avant Garde Gothic +Weight Book +ItalicAngle -10.5 +IsFixedPitch false +FontBBox -113 -222 1279 955 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1991 Adobe Systems Incorporated. All Rights Reserved.ITC Avant Garde Gothic is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 740 +XHeight 547 +Ascender 740 +Descender -192 +StartCharMetrics 228 +C 32 ; WX 277 ; N space ; B 0 0 0 0 ; +C 33 ; WX 295 ; N exclam ; B 111 0 322 740 ; +C 34 ; WX 309 ; N quotedbl ; B 130 444 410 740 ; +C 35 ; WX 554 ; N numbersign ; B 71 0 620 740 ; +C 36 ; WX 554 ; N dollar ; B 107 -70 581 811 ; +C 37 ; WX 775 ; N percent ; B 124 -13 787 751 ; +C 38 ; WX 757 ; N ampersand ; B 92 -12 775 753 ; +C 39 ; WX 351 ; N quoteright ; B 195 546 393 740 ; +C 40 ; WX 369 ; N parenleft ; B 89 -205 495 757 ; +C 41 ; WX 369 ; N parenright ; B -24 -205 382 757 ; +C 42 ; WX 425 ; N asterisk ; B 170 446 479 740 ; +C 43 ; WX 606 ; N plus ; B 92 0 608 506 ; +C 44 ; WX 277 ; N comma ; B 2 -67 199 126 ; +C 45 ; WX 332 ; N hyphen ; B 76 248 360 315 ; +C 46 ; WX 277 ; N period ; B 102 0 199 126 ; +C 47 ; WX 437 ; N slash ; B 25 -100 540 740 ; +C 48 ; WX 554 ; N zero ; B 71 -13 622 753 ; +C 49 ; WX 554 ; N one ; B 260 0 473 740 ; +C 50 ; WX 554 ; N two ; B 40 0 615 753 ; +C 51 ; WX 554 ; N three ; B 73 -13 565 753 ; +C 52 ; WX 554 ; N four ; B 39 0 598 740 ; +C 53 ; WX 554 ; N five ; B 69 -13 605 740 ; +C 54 ; WX 554 ; N six ; B 65 -13 580 739 ; +C 55 ; WX 554 ; N seven ; B 110 0 628 740 ; +C 56 ; WX 554 ; N eight ; B 77 -13 580 753 ; +C 57 ; WX 554 ; N nine ; B 111 0 626 752 ; +C 58 ; WX 277 ; N colon ; B 102 0 278 548 ; +C 59 ; WX 277 ; N semicolon ; B 2 -67 278 548 ; +C 60 ; WX 606 ; N less ; B 87 -8 649 514 ; +C 61 ; WX 606 ; N equal ; B 73 118 627 388 ; +C 62 ; WX 606 ; N greater ; B 51 -8 613 514 ; +C 63 ; WX 591 ; N question ; B 158 0 628 752 ; +C 64 ; WX 867 ; N at ; B 126 -13 888 753 ; +C 65 ; WX 740 ; N A ; B 12 0 729 740 ; +C 66 ; WX 574 ; N B ; B 74 0 606 740 ; +C 67 ; WX 813 ; N C ; B 105 -13 870 752 ; +C 68 ; WX 744 ; N D ; B 74 0 773 740 ; +C 69 ; WX 536 ; N E ; B 70 0 612 740 ; +C 70 ; WX 485 ; N F ; B 70 0 581 740 ; +C 71 ; WX 872 ; N G ; B 103 -13 891 753 ; +C 72 ; WX 683 ; N H ; B 76 0 744 740 ; +C 73 ; WX 226 ; N I ; B 76 0 287 740 ; +C 74 ; WX 482 ; N J ; B 37 -13 539 740 ; +C 75 ; WX 591 ; N K ; B 81 0 728 740 ; +C 76 ; WX 462 ; N L ; B 82 0 474 740 ; +C 77 ; WX 919 ; N M ; B 76 0 980 740 ; +C 78 ; WX 740 ; N N ; B 75 0 801 740 ; +C 79 ; WX 869 ; N O ; B 105 -13 901 753 ; +C 80 ; WX 592 ; N P ; B 75 0 664 740 ; +C 81 ; WX 871 ; N Q ; B 102 -13 912 753 ; +C 82 ; WX 607 ; N R ; B 70 0 669 740 ; +C 83 ; WX 498 ; N S ; B 57 -13 561 753 ; +C 84 ; WX 426 ; N T ; B 131 0 556 740 ; +C 85 ; WX 655 ; N U ; B 118 -13 716 740 ; +C 86 ; WX 702 ; N V ; B 145 0 830 740 ; +C 87 ; WX 960 ; N W ; B 148 0 1087 740 ; +C 88 ; WX 609 ; N X ; B 8 0 724 740 ; +C 89 ; WX 592 ; N Y ; B 138 0 729 740 ; +C 90 ; WX 480 ; N Z ; B 12 0 596 740 ; +C 91 ; WX 351 ; N bracketleft ; B 145 -179 477 753 ; +C 92 ; WX 605 ; N backslash ; B 255 -100 458 740 ; +C 93 ; WX 351 ; N bracketright ; B -19 -179 312 753 ; +C 94 ; WX 606 ; N asciicircum ; B 110 307 610 740 ; +C 95 ; WX 500 ; N underscore ; B -23 -125 486 -75 ; +C 96 ; WX 351 ; N quoteleft ; B 232 546 358 740 ; +C 97 ; WX 683 ; N a ; B 88 -13 722 561 ; +C 98 ; WX 682 ; N b ; B 68 -13 703 740 ; +C 99 ; WX 647 ; N c ; B 87 -13 678 561 ; +C 100 ; WX 685 ; N d ; B 85 -13 755 740 ; +C 101 ; WX 650 ; N e ; B 84 -13 664 561 ; +C 102 ; WX 314 ; N f ; B 104 0 454 753 ; L i fi ; L l fl ; +C 103 ; WX 673 ; N g ; B 56 -215 707 561 ; +C 104 ; WX 610 ; N h ; B 62 0 606 740 ; +C 105 ; WX 200 ; N i ; B 65 0 272 740 ; +C 106 ; WX 203 ; N j ; B -80 -192 274 740 ; +C 107 ; WX 502 ; N k ; B 70 0 588 740 ; +C 108 ; WX 200 ; N l ; B 65 0 272 740 ; +C 109 ; WX 938 ; N m ; B 66 0 938 561 ; +C 110 ; WX 610 ; N n ; B 65 0 609 561 ; +C 111 ; WX 655 ; N o ; B 88 -13 669 561 ; +C 112 ; WX 682 ; N p ; B 28 -192 699 561 ; +C 113 ; WX 682 ; N q ; B 83 -192 717 561 ; +C 114 ; WX 301 ; N r ; B 65 0 395 561 ; +C 115 ; WX 388 ; N s ; B 49 -13 424 561 ; +C 116 ; WX 339 ; N t ; B 104 0 431 740 ; +C 117 ; WX 608 ; N u ; B 100 -13 642 547 ; +C 118 ; WX 554 ; N v ; B 108 0 647 547 ; +C 119 ; WX 831 ; N w ; B 114 0 921 547 ; +C 120 ; WX 480 ; N x ; B 12 0 569 547 ; +C 121 ; WX 536 ; N y ; B 97 -192 624 547 ; +C 122 ; WX 425 ; N z ; B 10 0 498 547 ; +C 123 ; WX 351 ; N braceleft ; B 115 -189 468 740 ; +C 124 ; WX 672 ; N bar ; B 280 -100 510 740 ; +C 125 ; WX 351 ; N braceright ; B -15 -189 338 740 ; +C 126 ; WX 606 ; N asciitilde ; B 114 179 584 319 ; +C 161 ; WX 295 ; N exclamdown ; B 74 -192 286 548 ; +C 162 ; WX 554 ; N cent ; B 115 62 596 707 ; +C 163 ; WX 554 ; N sterling ; B 29 0 614 753 ; +C 164 ; WX 166 ; N fraction ; B -113 0 417 740 ; +C 165 ; WX 554 ; N yen ; B 75 0 687 740 ; +C 166 ; WX 554 ; N florin ; B -39 -153 669 818 ; +C 167 ; WX 615 ; N section ; B 118 -141 597 753 ; +C 168 ; WX 554 ; N currency ; B 24 42 645 580 ; +C 169 ; WX 198 ; N quotesingle ; B 153 444 277 740 ; +C 170 ; WX 502 ; N quotedblleft ; B 234 546 507 740 ; +C 171 ; WX 425 ; N guillemotleft ; B 92 81 469 481 ; +C 172 ; WX 251 ; N guilsinglleft ; B 92 81 295 481 ; +C 173 ; WX 251 ; N guilsinglright ; B 60 81 263 481 ; +C 174 ; WX 487 ; N fi ; B 104 0 559 753 ; +C 175 ; WX 485 ; N fl ; B 104 0 557 753 ; +C 177 ; WX 500 ; N endash ; B 81 248 523 315 ; +C 178 ; WX 553 ; N dagger ; B 146 -133 593 740 ; +C 179 ; WX 553 ; N daggerdbl ; B 72 -133 593 740 ; +C 180 ; WX 277 ; N periodcentered ; B 137 190 235 316 ; +C 182 ; WX 564 ; N paragraph ; B 119 -110 688 740 ; +C 183 ; WX 606 ; N bullet ; B 217 222 528 532 ; +C 184 ; WX 354 ; N quotesinglbase ; B 76 -68 274 126 ; +C 185 ; WX 502 ; N quotedblbase ; B 76 -68 422 126 ; +C 186 ; WX 484 ; N quotedblright ; B 197 546 542 740 ; +C 187 ; WX 425 ; N guillemotright ; B 60 81 437 481 ; +C 188 ; WX 1000 ; N ellipsis ; B 130 0 893 126 ; +C 189 ; WX 1174 ; N perthousand ; B 128 -13 1182 751 ; +C 191 ; WX 591 ; N questiondown ; B 64 -205 534 548 ; +C 193 ; WX 378 ; N grave ; B 204 619 425 786 ; +C 194 ; WX 375 ; N acute ; B 203 619 444 786 ; +C 195 ; WX 502 ; N circumflex ; B 192 639 546 764 ; +C 196 ; WX 439 ; N tilde ; B 179 651 520 754 ; +C 197 ; WX 485 ; N macron ; B 197 669 547 736 ; +C 198 ; WX 453 ; N breve ; B 192 651 541 754 ; +C 199 ; WX 222 ; N dotaccent ; B 192 639 290 765 ; +C 200 ; WX 369 ; N dieresis ; B 191 639 437 765 ; +C 202 ; WX 332 ; N ring ; B 191 600 401 807 ; +C 203 ; WX 324 ; N cedilla ; B 52 -222 231 0 ; +C 205 ; WX 552 ; N hungarumlaut ; B 239 605 594 800 ; +C 206 ; WX 302 ; N ogonek ; B 53 -191 202 0 ; +C 207 ; WX 502 ; N caron ; B 210 639 565 764 ; +C 208 ; WX 1000 ; N emdash ; B 81 248 1023 315 ; +C 225 ; WX 992 ; N AE ; B -20 0 1044 740 ; +C 227 ; WX 369 ; N ordfeminine ; B 102 407 494 753 ; +C 232 ; WX 517 ; N Lslash ; B 107 0 529 740 ; +C 233 ; WX 868 ; N Oslash ; B 76 -83 929 819 ; +C 234 ; WX 1194 ; N OE ; B 107 -13 1279 753 ; +C 235 ; WX 369 ; N ordmasculine ; B 116 407 466 753 ; +C 241 ; WX 1157 ; N ae ; B 80 -13 1169 561 ; +C 245 ; WX 200 ; N dotlessi ; B 65 0 236 547 ; +C 248 ; WX 300 ; N lslash ; B 95 0 354 740 ; +C 249 ; WX 653 ; N oslash ; B 51 -64 703 614 ; +C 250 ; WX 1137 ; N oe ; B 80 -13 1160 561 ; +C 251 ; WX 554 ; N germandbls ; B 61 -13 578 753 ; +C -1 ; WX 650 ; N ecircumflex ; B 84 -13 664 764 ; +C -1 ; WX 650 ; N edieresis ; B 84 -13 664 765 ; +C -1 ; WX 683 ; N aacute ; B 88 -13 722 786 ; +C -1 ; WX 747 ; N registered ; B 53 -12 830 752 ; +C -1 ; WX 200 ; N icircumflex ; B 41 0 395 764 ; +C -1 ; WX 608 ; N udieresis ; B 100 -13 642 765 ; +C -1 ; WX 655 ; N ograve ; B 88 -13 669 786 ; +C -1 ; WX 608 ; N uacute ; B 100 -13 642 786 ; +C -1 ; WX 608 ; N ucircumflex ; B 100 -13 642 764 ; +C -1 ; WX 740 ; N Aacute ; B 12 0 729 949 ; +C -1 ; WX 200 ; N igrave ; B 65 0 296 786 ; +C -1 ; WX 226 ; N Icircumflex ; B 76 0 439 927 ; +C -1 ; WX 647 ; N ccedilla ; B 87 -222 678 561 ; +C -1 ; WX 683 ; N adieresis ; B 88 -13 722 765 ; +C -1 ; WX 536 ; N Ecircumflex ; B 70 0 612 927 ; +C -1 ; WX 388 ; N scaron ; B 49 -13 508 764 ; +C -1 ; WX 682 ; N thorn ; B 28 -192 699 740 ; +C -1 ; WX 1000 ; N trademark ; B 137 296 953 740 ; +C -1 ; WX 650 ; N egrave ; B 84 -13 664 786 ; +C -1 ; WX 332 ; N threesuperior ; B 98 289 408 747 ; +C -1 ; WX 425 ; N zcaron ; B 10 0 527 764 ; +C -1 ; WX 683 ; N atilde ; B 88 -13 722 754 ; +C -1 ; WX 683 ; N aring ; B 88 -13 722 807 ; +C -1 ; WX 655 ; N ocircumflex ; B 88 -13 669 764 ; +C -1 ; WX 536 ; N Edieresis ; B 70 0 612 928 ; +C -1 ; WX 831 ; N threequarters ; B 126 0 825 747 ; +C -1 ; WX 536 ; N ydieresis ; B 97 -192 624 765 ; +C -1 ; WX 536 ; N yacute ; B 97 -192 624 786 ; +C -1 ; WX 200 ; N iacute ; B 65 0 397 786 ; +C -1 ; WX 740 ; N Acircumflex ; B 12 0 729 927 ; +C -1 ; WX 655 ; N Uacute ; B 118 -13 716 949 ; +C -1 ; WX 650 ; N eacute ; B 84 -13 664 786 ; +C -1 ; WX 869 ; N Ograve ; B 105 -13 901 949 ; +C -1 ; WX 683 ; N agrave ; B 88 -13 722 786 ; +C -1 ; WX 655 ; N Udieresis ; B 118 -13 716 928 ; +C -1 ; WX 683 ; N acircumflex ; B 88 -13 722 764 ; +C -1 ; WX 226 ; N Igrave ; B 76 0 340 949 ; +C -1 ; WX 332 ; N twosuperior ; B 74 296 433 747 ; +C -1 ; WX 655 ; N Ugrave ; B 118 -13 716 949 ; +C -1 ; WX 831 ; N onequarter ; B 183 0 770 740 ; +C -1 ; WX 655 ; N Ucircumflex ; B 118 -13 716 927 ; +C -1 ; WX 498 ; N Scaron ; B 57 -13 593 927 ; +C -1 ; WX 226 ; N Idieresis ; B 76 0 396 928 ; +C -1 ; WX 200 ; N idieresis ; B 65 0 353 765 ; +C -1 ; WX 536 ; N Egrave ; B 70 0 612 949 ; +C -1 ; WX 869 ; N Oacute ; B 105 -13 901 949 ; +C -1 ; WX 606 ; N divide ; B 92 -13 608 519 ; +C -1 ; WX 740 ; N Atilde ; B 12 0 729 917 ; +C -1 ; WX 740 ; N Aring ; B 12 0 729 955 ; +C -1 ; WX 869 ; N Odieresis ; B 105 -13 901 928 ; +C -1 ; WX 740 ; N Adieresis ; B 12 0 729 928 ; +C -1 ; WX 740 ; N Ntilde ; B 75 0 801 917 ; +C -1 ; WX 480 ; N Zcaron ; B 12 0 596 927 ; +C -1 ; WX 592 ; N Thorn ; B 60 0 621 740 ; +C -1 ; WX 226 ; N Iacute ; B 76 0 440 949 ; +C -1 ; WX 606 ; N plusminus ; B 47 -24 618 518 ; +C -1 ; WX 606 ; N multiply ; B 87 24 612 482 ; +C -1 ; WX 536 ; N Eacute ; B 70 0 612 949 ; +C -1 ; WX 592 ; N Ydieresis ; B 138 0 729 928 ; +C -1 ; WX 332 ; N onesuperior ; B 190 296 335 740 ; +C -1 ; WX 608 ; N ugrave ; B 100 -13 642 786 ; +C -1 ; WX 606 ; N logicalnot ; B 110 109 627 388 ; +C -1 ; WX 610 ; N ntilde ; B 65 0 609 754 ; +C -1 ; WX 869 ; N Otilde ; B 105 -13 901 917 ; +C -1 ; WX 655 ; N otilde ; B 88 -13 669 754 ; +C -1 ; WX 813 ; N Ccedilla ; B 105 -222 870 752 ; +C -1 ; WX 740 ; N Agrave ; B 12 0 729 949 ; +C -1 ; WX 831 ; N onehalf ; B 164 0 810 740 ; +C -1 ; WX 790 ; N Eth ; B 104 0 813 740 ; +C -1 ; WX 400 ; N degree ; B 158 421 451 709 ; +C -1 ; WX 592 ; N Yacute ; B 138 0 729 949 ; +C -1 ; WX 869 ; N Ocircumflex ; B 105 -13 901 927 ; +C -1 ; WX 655 ; N oacute ; B 88 -13 669 786 ; +C -1 ; WX 608 ; N mu ; B 46 -184 628 547 ; +C -1 ; WX 606 ; N minus ; B 92 219 608 287 ; +C -1 ; WX 655 ; N eth ; B 88 -12 675 753 ; +C -1 ; WX 655 ; N odieresis ; B 88 -13 669 765 ; +C -1 ; WX 747 ; N copyright ; B 53 -12 830 752 ; +C -1 ; WX 672 ; N brokenbar ; B 280 -100 510 740 ; +EndCharMetrics +StartKernData +StartKernPairs 216 + +KPX A y -62 +KPX A w -65 +KPX A v -70 +KPX A u -20 +KPX A quoteright -100 +KPX A quotedblright -100 +KPX A Y -92 +KPX A W -60 +KPX A V -102 +KPX A U -40 +KPX A T -45 +KPX A Q -40 +KPX A O -50 +KPX A G -40 +KPX A C -40 + +KPX B A -10 + +KPX C A -40 + +KPX D period -20 +KPX D comma -20 +KPX D Y -30 +KPX D W -10 +KPX D V -50 +KPX D A -50 + +KPX F period -160 +KPX F e -20 +KPX F comma -180 +KPX F a -20 +KPX F A -75 + +KPX G period -20 +KPX G comma -20 +KPX G Y -20 + +KPX J period -15 +KPX J a -20 +KPX J A -30 + +KPX K o -15 +KPX K e -20 +KPX K O -20 + +KPX L y -23 +KPX L quoteright -130 +KPX L quotedblright -130 +KPX L Y -91 +KPX L W -67 +KPX L V -113 +KPX L T -46 + +KPX O period -30 +KPX O comma -30 +KPX O Y -30 +KPX O X -30 +KPX O W -20 +KPX O V -60 +KPX O T -30 +KPX O A -60 + +KPX P period -300 +KPX P o -60 +KPX P e -20 +KPX P comma -280 +KPX P a -20 +KPX P A -114 + +KPX Q comma 20 + +KPX R Y -10 +KPX R W 10 +KPX R V -10 +KPX R T 6 + +KPX S comma 20 + +KPX T y -50 +KPX T w -55 +KPX T u -46 +KPX T semicolon -29 +KPX T r -30 +KPX T period -91 +KPX T o -70 +KPX T i 10 +KPX T hyphen -75 +KPX T e -49 +KPX T comma -82 +KPX T colon -15 +KPX T a -90 +KPX T O -30 +KPX T A -45 + +KPX U period -20 +KPX U comma -20 +KPX U A -40 + +KPX V u -40 +KPX V semicolon -33 +KPX V period -165 +KPX V o -101 +KPX V i -5 +KPX V hyphen -75 +KPX V e -101 +KPX V comma -145 +KPX V colon -18 +KPX V a -104 +KPX V O -60 +KPX V G -20 +KPX V A -102 + +KPX W y -2 +KPX W u -30 +KPX W semicolon -33 +KPX W period -106 +KPX W o -46 +KPX W i 6 +KPX W hyphen -35 +KPX W e -47 +KPX W comma -106 +KPX W colon -15 +KPX W a -50 +KPX W O -20 +KPX W A -58 + +KPX Y u -52 +KPX Y semicolon -23 +KPX Y period -175 +KPX Y o -89 +KPX Y hyphen -85 +KPX Y e -89 +KPX Y comma -145 +KPX Y colon -10 +KPX Y a -93 +KPX Y O -30 +KPX Y A -92 + +KPX a p 20 +KPX a b 20 + +KPX b y -20 +KPX b v -20 + +KPX c y -20 +KPX c k -15 + +KPX comma space -110 +KPX comma quoteright -120 +KPX comma quotedblright -120 + +KPX e y -20 +KPX e w -20 +KPX e v -20 + +KPX f period -50 +KPX f o -40 +KPX f l -30 +KPX f i -34 +KPX f f -60 +KPX f e -20 +KPX f dotlessi -34 +KPX f comma -50 +KPX f a -40 + +KPX g a -15 + +KPX h y -30 + +KPX k y -5 +KPX k e -15 + +KPX m y -20 +KPX m u -20 +KPX m a -20 + +KPX n y -15 +KPX n v -20 + +KPX o y -20 +KPX o x -15 +KPX o w -20 +KPX o v -30 + +KPX p y -20 + +KPX period space -110 +KPX period quoteright -120 +KPX period quotedblright -120 + +KPX quotedblleft quoteleft -35 +KPX quotedblleft A -100 + +KPX quotedblright space -110 + +KPX quoteleft quoteleft -203 +KPX quoteleft A -100 + +KPX quoteright v -30 +KPX quoteright t 10 +KPX quoteright space -110 +KPX quoteright s -15 +KPX quoteright r -20 +KPX quoteright quoteright -203 +KPX quoteright quotedblright -35 +KPX quoteright d -110 + +KPX r y 40 +KPX r v 40 +KPX r u 20 +KPX r t 20 +KPX r s 20 +KPX r q -8 +KPX r period -73 +KPX r p 20 +KPX r o -20 +KPX r n 21 +KPX r m 28 +KPX r l 20 +KPX r k 20 +KPX r i 20 +KPX r hyphen -60 +KPX r g -15 +KPX r e -4 +KPX r d -6 +KPX r comma -75 +KPX r c -20 +KPX r a -20 + +KPX s period 20 +KPX s comma 20 + +KPX space quoteleft -110 +KPX space quotedblleft -110 +KPX space Y -60 +KPX space W -25 +KPX space V -50 +KPX space T -25 +KPX space A -20 + +KPX v period -130 +KPX v o -30 +KPX v e -20 +KPX v comma -100 +KPX v a -30 + +KPX w period -100 +KPX w o -30 +KPX w h 15 +KPX w e -20 +KPX w comma -90 +KPX w a -30 + +KPX y period -125 +KPX y o -30 +KPX y e -20 +KPX y comma -110 +KPX y a -30 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 213 163 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 149 163 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 216 163 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 211 163 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 231 148 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 181 163 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 111 163 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 47 163 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 114 163 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 109 163 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -4 163 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -108 163 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -41 163 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -86 163 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 181 163 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 277 163 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 214 163 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 280 163 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 276 163 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 245 163 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 28 163 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 190 163 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 107 163 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 173 163 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 149 163 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 159 163 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 142 163 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 19 163 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 154 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 91 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 157 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 153 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 176 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 122 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 138 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 74 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 141 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 136 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -47 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -151 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -84 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -129 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 86 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 140 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 77 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 143 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 139 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 108 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron -57 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 137 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 53 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 120 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 95 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 101 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron -38 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkd8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkd8a.afm new file mode 100644 index 00000000..036be6d8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkd8a.afm @@ -0,0 +1,415 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Jan 21 16:13:29 1992 +Comment UniqueID 37831 +Comment VMusage 31983 38875 +FontName Bookman-Demi +FullName ITC Bookman Demi +FamilyName ITC Bookman +Weight Demi +ItalicAngle 0 +IsFixedPitch false +FontBBox -194 -250 1346 934 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.004 +Notice Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved.ITC Bookman is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 502 +Ascender 725 +Descender -212 +StartCharMetrics 228 +C 32 ; WX 340 ; N space ; B 0 0 0 0 ; +C 33 ; WX 360 ; N exclam ; B 82 -8 282 698 ; +C 34 ; WX 420 ; N quotedbl ; B 11 379 369 698 ; +C 35 ; WX 660 ; N numbersign ; B 84 0 576 681 ; +C 36 ; WX 660 ; N dollar ; B 48 -119 620 805 ; +C 37 ; WX 940 ; N percent ; B 12 -8 924 698 ; +C 38 ; WX 800 ; N ampersand ; B 21 -17 772 698 ; +C 39 ; WX 320 ; N quoteright ; B 82 440 242 698 ; +C 40 ; WX 320 ; N parenleft ; B 48 -150 289 749 ; +C 41 ; WX 320 ; N parenright ; B 20 -150 262 749 ; +C 42 ; WX 460 ; N asterisk ; B 62 317 405 697 ; +C 43 ; WX 600 ; N plus ; B 51 9 555 514 ; +C 44 ; WX 340 ; N comma ; B 78 -124 257 162 ; +C 45 ; WX 360 ; N hyphen ; B 20 210 340 318 ; +C 46 ; WX 340 ; N period ; B 76 -8 258 172 ; +C 47 ; WX 600 ; N slash ; B 50 -149 555 725 ; +C 48 ; WX 660 ; N zero ; B 30 -17 639 698 ; +C 49 ; WX 660 ; N one ; B 137 0 568 681 ; +C 50 ; WX 660 ; N two ; B 41 0 628 698 ; +C 51 ; WX 660 ; N three ; B 37 -17 631 698 ; +C 52 ; WX 660 ; N four ; B 19 0 649 681 ; +C 53 ; WX 660 ; N five ; B 44 -17 623 723 ; +C 54 ; WX 660 ; N six ; B 34 -17 634 698 ; +C 55 ; WX 660 ; N seven ; B 36 0 632 681 ; +C 56 ; WX 660 ; N eight ; B 36 -17 633 698 ; +C 57 ; WX 660 ; N nine ; B 33 -17 636 698 ; +C 58 ; WX 340 ; N colon ; B 76 -8 258 515 ; +C 59 ; WX 340 ; N semicolon ; B 75 -124 259 515 ; +C 60 ; WX 600 ; N less ; B 49 -9 558 542 ; +C 61 ; WX 600 ; N equal ; B 51 109 555 421 ; +C 62 ; WX 600 ; N greater ; B 48 -9 557 542 ; +C 63 ; WX 660 ; N question ; B 61 -8 608 698 ; +C 64 ; WX 820 ; N at ; B 60 -17 758 698 ; +C 65 ; WX 720 ; N A ; B -34 0 763 681 ; +C 66 ; WX 720 ; N B ; B 20 0 693 681 ; +C 67 ; WX 740 ; N C ; B 35 -17 724 698 ; +C 68 ; WX 780 ; N D ; B 20 0 748 681 ; +C 69 ; WX 720 ; N E ; B 20 0 724 681 ; +C 70 ; WX 680 ; N F ; B 20 0 686 681 ; +C 71 ; WX 780 ; N G ; B 35 -17 773 698 ; +C 72 ; WX 820 ; N H ; B 20 0 800 681 ; +C 73 ; WX 400 ; N I ; B 20 0 379 681 ; +C 74 ; WX 640 ; N J ; B -12 -17 622 681 ; +C 75 ; WX 800 ; N K ; B 20 0 796 681 ; +C 76 ; WX 640 ; N L ; B 20 0 668 681 ; +C 77 ; WX 940 ; N M ; B 20 0 924 681 ; +C 78 ; WX 740 ; N N ; B 20 0 724 681 ; +C 79 ; WX 800 ; N O ; B 35 -17 769 698 ; +C 80 ; WX 660 ; N P ; B 20 0 658 681 ; +C 81 ; WX 800 ; N Q ; B 35 -226 775 698 ; +C 82 ; WX 780 ; N R ; B 20 0 783 681 ; +C 83 ; WX 660 ; N S ; B 21 -17 639 698 ; +C 84 ; WX 700 ; N T ; B -4 0 703 681 ; +C 85 ; WX 740 ; N U ; B 15 -17 724 681 ; +C 86 ; WX 720 ; N V ; B -20 0 730 681 ; +C 87 ; WX 940 ; N W ; B -20 0 963 681 ; +C 88 ; WX 780 ; N X ; B 1 0 770 681 ; +C 89 ; WX 700 ; N Y ; B -20 0 718 681 ; +C 90 ; WX 640 ; N Z ; B 6 0 635 681 ; +C 91 ; WX 300 ; N bracketleft ; B 75 -138 285 725 ; +C 92 ; WX 600 ; N backslash ; B 50 0 555 725 ; +C 93 ; WX 300 ; N bracketright ; B 21 -138 231 725 ; +C 94 ; WX 600 ; N asciicircum ; B 52 281 554 681 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 320 ; N quoteleft ; B 82 440 242 698 ; +C 97 ; WX 580 ; N a ; B 28 -8 588 515 ; +C 98 ; WX 600 ; N b ; B -20 -8 568 725 ; +C 99 ; WX 580 ; N c ; B 31 -8 550 515 ; +C 100 ; WX 640 ; N d ; B 31 -8 622 725 ; +C 101 ; WX 580 ; N e ; B 31 -8 548 515 ; +C 102 ; WX 380 ; N f ; B 22 0 461 741 ; L i fi ; L l fl ; +C 103 ; WX 580 ; N g ; B 9 -243 583 595 ; +C 104 ; WX 680 ; N h ; B 22 0 654 725 ; +C 105 ; WX 360 ; N i ; B 22 0 335 729 ; +C 106 ; WX 340 ; N j ; B -94 -221 278 729 ; +C 107 ; WX 660 ; N k ; B 22 0 643 725 ; +C 108 ; WX 340 ; N l ; B 9 0 322 725 ; +C 109 ; WX 1000 ; N m ; B 22 0 980 515 ; +C 110 ; WX 680 ; N n ; B 22 0 652 515 ; +C 111 ; WX 620 ; N o ; B 31 -8 585 515 ; +C 112 ; WX 640 ; N p ; B 22 -212 611 515 ; +C 113 ; WX 620 ; N q ; B 31 -212 633 515 ; +C 114 ; WX 460 ; N r ; B 22 0 462 502 ; +C 115 ; WX 520 ; N s ; B 22 -8 492 515 ; +C 116 ; WX 460 ; N t ; B 22 -8 445 660 ; +C 117 ; WX 660 ; N u ; B 22 -8 653 502 ; +C 118 ; WX 600 ; N v ; B -6 0 593 502 ; +C 119 ; WX 800 ; N w ; B -6 0 810 502 ; +C 120 ; WX 600 ; N x ; B 8 0 591 502 ; +C 121 ; WX 620 ; N y ; B 6 -221 613 502 ; +C 122 ; WX 560 ; N z ; B 22 0 547 502 ; +C 123 ; WX 320 ; N braceleft ; B 14 -139 301 726 ; +C 124 ; WX 600 ; N bar ; B 243 -250 362 750 ; +C 125 ; WX 320 ; N braceright ; B 15 -140 302 725 ; +C 126 ; WX 600 ; N asciitilde ; B 51 162 555 368 ; +C 161 ; WX 360 ; N exclamdown ; B 84 -191 284 515 ; +C 162 ; WX 660 ; N cent ; B 133 17 535 674 ; +C 163 ; WX 660 ; N sterling ; B 10 -17 659 698 ; +C 164 ; WX 120 ; N fraction ; B -194 0 312 681 ; +C 165 ; WX 660 ; N yen ; B -28 0 696 681 ; +C 166 ; WX 660 ; N florin ; B -46 -209 674 749 ; +C 167 ; WX 600 ; N section ; B 36 -153 560 698 ; +C 168 ; WX 660 ; N currency ; B 77 88 584 593 ; +C 169 ; WX 240 ; N quotesingle ; B 42 379 178 698 ; +C 170 ; WX 540 ; N quotedblleft ; B 82 439 449 698 ; +C 171 ; WX 400 ; N guillemotleft ; B 34 101 360 457 ; +C 172 ; WX 220 ; N guilsinglleft ; B 34 101 188 457 ; +C 173 ; WX 220 ; N guilsinglright ; B 34 101 188 457 ; +C 174 ; WX 740 ; N fi ; B 22 0 710 741 ; +C 175 ; WX 740 ; N fl ; B 22 0 710 741 ; +C 177 ; WX 500 ; N endash ; B -25 212 525 318 ; +C 178 ; WX 440 ; N dagger ; B 33 -156 398 698 ; +C 179 ; WX 380 ; N daggerdbl ; B 8 -156 380 698 ; +C 180 ; WX 340 ; N periodcentered ; B 76 175 258 355 ; +C 182 ; WX 800 ; N paragraph ; B 51 0 698 681 ; +C 183 ; WX 460 ; N bullet ; B 60 170 404 511 ; +C 184 ; WX 320 ; N quotesinglbase ; B 82 -114 242 144 ; +C 185 ; WX 540 ; N quotedblbase ; B 82 -114 450 144 ; +C 186 ; WX 540 ; N quotedblright ; B 82 440 449 698 ; +C 187 ; WX 400 ; N guillemotright ; B 34 101 360 457 ; +C 188 ; WX 1000 ; N ellipsis ; B 76 -8 924 172 ; +C 189 ; WX 1360 ; N perthousand ; B 12 -8 1346 698 ; +C 191 ; WX 660 ; N questiondown ; B 62 -191 609 515 ; +C 193 ; WX 400 ; N grave ; B 68 547 327 730 ; +C 194 ; WX 400 ; N acute ; B 68 547 327 731 ; +C 195 ; WX 500 ; N circumflex ; B 68 555 430 731 ; +C 196 ; WX 480 ; N tilde ; B 69 556 421 691 ; +C 197 ; WX 460 ; N macron ; B 68 577 383 663 ; +C 198 ; WX 500 ; N breve ; B 68 553 429 722 ; +C 199 ; WX 320 ; N dotaccent ; B 68 536 259 730 ; +C 200 ; WX 500 ; N dieresis ; B 68 560 441 698 ; +C 202 ; WX 340 ; N ring ; B 68 552 275 755 ; +C 203 ; WX 360 ; N cedilla ; B 68 -213 284 0 ; +C 205 ; WX 440 ; N hungarumlaut ; B 68 554 365 741 ; +C 206 ; WX 320 ; N ogonek ; B 68 -163 246 0 ; +C 207 ; WX 500 ; N caron ; B 68 541 430 717 ; +C 208 ; WX 1000 ; N emdash ; B -25 212 1025 318 ; +C 225 ; WX 1140 ; N AE ; B -34 0 1149 681 ; +C 227 ; WX 400 ; N ordfeminine ; B 27 383 396 698 ; +C 232 ; WX 640 ; N Lslash ; B 20 0 668 681 ; +C 233 ; WX 800 ; N Oslash ; B 35 -110 771 781 ; +C 234 ; WX 1220 ; N OE ; B 35 -17 1219 698 ; +C 235 ; WX 400 ; N ordmasculine ; B 17 383 383 698 ; +C 241 ; WX 880 ; N ae ; B 28 -8 852 515 ; +C 245 ; WX 360 ; N dotlessi ; B 22 0 335 502 ; +C 248 ; WX 340 ; N lslash ; B 9 0 322 725 ; +C 249 ; WX 620 ; N oslash ; B 31 -40 586 551 ; +C 250 ; WX 940 ; N oe ; B 31 -8 908 515 ; +C 251 ; WX 660 ; N germandbls ; B -61 -91 644 699 ; +C -1 ; WX 580 ; N ecircumflex ; B 31 -8 548 731 ; +C -1 ; WX 580 ; N edieresis ; B 31 -8 548 698 ; +C -1 ; WX 580 ; N aacute ; B 28 -8 588 731 ; +C -1 ; WX 740 ; N registered ; B 23 -17 723 698 ; +C -1 ; WX 360 ; N icircumflex ; B -2 0 360 731 ; +C -1 ; WX 660 ; N udieresis ; B 22 -8 653 698 ; +C -1 ; WX 620 ; N ograve ; B 31 -8 585 730 ; +C -1 ; WX 660 ; N uacute ; B 22 -8 653 731 ; +C -1 ; WX 660 ; N ucircumflex ; B 22 -8 653 731 ; +C -1 ; WX 720 ; N Aacute ; B -34 0 763 910 ; +C -1 ; WX 360 ; N igrave ; B 22 0 335 730 ; +C -1 ; WX 400 ; N Icircumflex ; B 18 0 380 910 ; +C -1 ; WX 580 ; N ccedilla ; B 31 -213 550 515 ; +C -1 ; WX 580 ; N adieresis ; B 28 -8 588 698 ; +C -1 ; WX 720 ; N Ecircumflex ; B 20 0 724 910 ; +C -1 ; WX 520 ; N scaron ; B 22 -8 492 717 ; +C -1 ; WX 640 ; N thorn ; B 22 -212 611 725 ; +C -1 ; WX 980 ; N trademark ; B 42 277 982 681 ; +C -1 ; WX 580 ; N egrave ; B 31 -8 548 730 ; +C -1 ; WX 396 ; N threesuperior ; B 5 269 391 698 ; +C -1 ; WX 560 ; N zcaron ; B 22 0 547 717 ; +C -1 ; WX 580 ; N atilde ; B 28 -8 588 691 ; +C -1 ; WX 580 ; N aring ; B 28 -8 588 755 ; +C -1 ; WX 620 ; N ocircumflex ; B 31 -8 585 731 ; +C -1 ; WX 720 ; N Edieresis ; B 20 0 724 877 ; +C -1 ; WX 990 ; N threequarters ; B 15 0 967 692 ; +C -1 ; WX 620 ; N ydieresis ; B 6 -221 613 698 ; +C -1 ; WX 620 ; N yacute ; B 6 -221 613 731 ; +C -1 ; WX 360 ; N iacute ; B 22 0 335 731 ; +C -1 ; WX 720 ; N Acircumflex ; B -34 0 763 910 ; +C -1 ; WX 740 ; N Uacute ; B 15 -17 724 910 ; +C -1 ; WX 580 ; N eacute ; B 31 -8 548 731 ; +C -1 ; WX 800 ; N Ograve ; B 35 -17 769 909 ; +C -1 ; WX 580 ; N agrave ; B 28 -8 588 730 ; +C -1 ; WX 740 ; N Udieresis ; B 15 -17 724 877 ; +C -1 ; WX 580 ; N acircumflex ; B 28 -8 588 731 ; +C -1 ; WX 400 ; N Igrave ; B 20 0 379 909 ; +C -1 ; WX 396 ; N twosuperior ; B 14 279 396 698 ; +C -1 ; WX 740 ; N Ugrave ; B 15 -17 724 909 ; +C -1 ; WX 990 ; N onequarter ; B 65 0 967 681 ; +C -1 ; WX 740 ; N Ucircumflex ; B 15 -17 724 910 ; +C -1 ; WX 660 ; N Scaron ; B 21 -17 639 896 ; +C -1 ; WX 400 ; N Idieresis ; B 18 0 391 877 ; +C -1 ; WX 360 ; N idieresis ; B -2 0 371 698 ; +C -1 ; WX 720 ; N Egrave ; B 20 0 724 909 ; +C -1 ; WX 800 ; N Oacute ; B 35 -17 769 910 ; +C -1 ; WX 600 ; N divide ; B 51 9 555 521 ; +C -1 ; WX 720 ; N Atilde ; B -34 0 763 870 ; +C -1 ; WX 720 ; N Aring ; B -34 0 763 934 ; +C -1 ; WX 800 ; N Odieresis ; B 35 -17 769 877 ; +C -1 ; WX 720 ; N Adieresis ; B -34 0 763 877 ; +C -1 ; WX 740 ; N Ntilde ; B 20 0 724 870 ; +C -1 ; WX 640 ; N Zcaron ; B 6 0 635 896 ; +C -1 ; WX 660 ; N Thorn ; B 20 0 658 681 ; +C -1 ; WX 400 ; N Iacute ; B 20 0 379 910 ; +C -1 ; WX 600 ; N plusminus ; B 51 0 555 514 ; +C -1 ; WX 600 ; N multiply ; B 48 10 552 514 ; +C -1 ; WX 720 ; N Eacute ; B 20 0 724 910 ; +C -1 ; WX 700 ; N Ydieresis ; B -20 0 718 877 ; +C -1 ; WX 396 ; N onesuperior ; B 65 279 345 687 ; +C -1 ; WX 660 ; N ugrave ; B 22 -8 653 730 ; +C -1 ; WX 600 ; N logicalnot ; B 51 129 555 421 ; +C -1 ; WX 680 ; N ntilde ; B 22 0 652 691 ; +C -1 ; WX 800 ; N Otilde ; B 35 -17 769 870 ; +C -1 ; WX 620 ; N otilde ; B 31 -8 585 691 ; +C -1 ; WX 740 ; N Ccedilla ; B 35 -213 724 698 ; +C -1 ; WX 720 ; N Agrave ; B -34 0 763 909 ; +C -1 ; WX 990 ; N onehalf ; B 65 0 980 681 ; +C -1 ; WX 780 ; N Eth ; B 20 0 748 681 ; +C -1 ; WX 400 ; N degree ; B 50 398 350 698 ; +C -1 ; WX 700 ; N Yacute ; B -20 0 718 910 ; +C -1 ; WX 800 ; N Ocircumflex ; B 35 -17 769 910 ; +C -1 ; WX 620 ; N oacute ; B 31 -8 585 731 ; +C -1 ; WX 660 ; N mu ; B 22 -221 653 502 ; +C -1 ; WX 600 ; N minus ; B 51 207 555 323 ; +C -1 ; WX 620 ; N eth ; B 31 -8 585 741 ; +C -1 ; WX 620 ; N odieresis ; B 31 -8 585 698 ; +C -1 ; WX 740 ; N copyright ; B 23 -17 723 698 ; +C -1 ; WX 600 ; N brokenbar ; B 243 -175 362 675 ; +EndCharMetrics +StartKernData +StartKernPairs 90 + +KPX A y -1 +KPX A w -9 +KPX A v -8 +KPX A Y -52 +KPX A W -20 +KPX A V -68 +KPX A T -40 + +KPX F period -132 +KPX F comma -130 +KPX F A -59 + +KPX L y 19 +KPX L Y -35 +KPX L W -41 +KPX L V -50 +KPX L T -4 + +KPX P period -128 +KPX P comma -129 +KPX P A -46 + +KPX R y -8 +KPX R Y -20 +KPX R W -24 +KPX R V -29 +KPX R T -4 + +KPX T semicolon 5 +KPX T s -10 +KPX T r 27 +KPX T period -122 +KPX T o -28 +KPX T i 27 +KPX T hyphen -10 +KPX T e -29 +KPX T comma -122 +KPX T colon 7 +KPX T c -29 +KPX T a -24 +KPX T A -42 + +KPX V y 12 +KPX V u -11 +KPX V semicolon -38 +KPX V r -15 +KPX V period -105 +KPX V o -79 +KPX V i 15 +KPX V hyphen -10 +KPX V e -80 +KPX V comma -103 +KPX V colon -37 +KPX V a -74 +KPX V A -88 + +KPX W y 12 +KPX W u -11 +KPX W semicolon -38 +KPX W r -15 +KPX W period -105 +KPX W o -78 +KPX W i 15 +KPX W hyphen -10 +KPX W e -79 +KPX W comma -103 +KPX W colon -37 +KPX W a -73 +KPX W A -60 + +KPX Y v 24 +KPX Y u -13 +KPX Y semicolon -34 +KPX Y q -66 +KPX Y period -105 +KPX Y p -23 +KPX Y o -66 +KPX Y i 2 +KPX Y hyphen -10 +KPX Y e -67 +KPX Y comma -103 +KPX Y colon -32 +KPX Y a -60 +KPX Y A -56 + +KPX f f 21 + +KPX r q -9 +KPX r period -102 +KPX r o -9 +KPX r n 20 +KPX r m 20 +KPX r hyphen -10 +KPX r h -23 +KPX r g -9 +KPX r f 20 +KPX r e -10 +KPX r d -10 +KPX r comma -101 +KPX r c -9 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 179 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 110 179 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 110 179 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 160 179 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 190 179 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 120 179 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 160 179 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 110 179 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 110 179 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 160 179 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 0 179 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -50 179 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -50 179 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 0 179 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 130 179 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 200 179 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 150 179 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 150 179 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 200 179 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 160 179 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 80 179 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 170 179 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 120 179 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 120 179 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 170 179 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 150 179 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 100 179 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 70 179 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 90 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 40 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 40 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 90 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 100 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 30 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 90 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 40 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 40 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 90 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -20 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -70 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -70 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -20 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 80 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 110 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 60 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 60 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 110 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 50 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 10 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 130 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 80 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 80 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 130 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 110 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 60 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 30 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkdi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkdi8a.afm new file mode 100644 index 00000000..c2da47a2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkdi8a.afm @@ -0,0 +1,417 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Jan 21 16:12:43 1992 +Comment UniqueID 37832 +Comment VMusage 32139 39031 +FontName Bookman-DemiItalic +FullName ITC Bookman Demi Italic +FamilyName ITC Bookman +Weight Demi +ItalicAngle -10 +IsFixedPitch false +FontBBox -231 -250 1333 941 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.004 +Notice Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved.ITC Bookman is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 515 +Ascender 732 +Descender -213 +StartCharMetrics 228 +C 32 ; WX 340 ; N space ; B 0 0 0 0 ; +C 33 ; WX 320 ; N exclam ; B 86 -8 366 698 ; +C 34 ; WX 380 ; N quotedbl ; B 140 371 507 697 ; +C 35 ; WX 680 ; N numbersign ; B 157 0 649 681 ; +C 36 ; WX 680 ; N dollar ; B 45 -164 697 790 ; +C 37 ; WX 880 ; N percent ; B 106 -17 899 698 ; +C 38 ; WX 980 ; N ampersand ; B 48 -17 1016 698 ; +C 39 ; WX 320 ; N quoteright ; B 171 420 349 698 ; +C 40 ; WX 260 ; N parenleft ; B 31 -134 388 741 ; +C 41 ; WX 260 ; N parenright ; B -35 -134 322 741 ; +C 42 ; WX 460 ; N asterisk ; B 126 346 508 698 ; +C 43 ; WX 600 ; N plus ; B 91 9 595 514 ; +C 44 ; WX 340 ; N comma ; B 100 -124 298 185 ; +C 45 ; WX 280 ; N hyphen ; B 59 218 319 313 ; +C 46 ; WX 340 ; N period ; B 106 -8 296 177 ; +C 47 ; WX 360 ; N slash ; B 9 -106 502 742 ; +C 48 ; WX 680 ; N zero ; B 87 -17 703 698 ; +C 49 ; WX 680 ; N one ; B 123 0 565 681 ; +C 50 ; WX 680 ; N two ; B 67 0 674 698 ; +C 51 ; WX 680 ; N three ; B 72 -17 683 698 ; +C 52 ; WX 680 ; N four ; B 63 0 708 681 ; +C 53 ; WX 680 ; N five ; B 78 -17 669 681 ; +C 54 ; WX 680 ; N six ; B 88 -17 704 698 ; +C 55 ; WX 680 ; N seven ; B 123 0 739 681 ; +C 56 ; WX 680 ; N eight ; B 68 -17 686 698 ; +C 57 ; WX 680 ; N nine ; B 71 -17 712 698 ; +C 58 ; WX 340 ; N colon ; B 106 -8 356 515 ; +C 59 ; WX 340 ; N semicolon ; B 100 -124 352 515 ; +C 60 ; WX 620 ; N less ; B 79 -9 588 540 ; +C 61 ; WX 600 ; N equal ; B 91 109 595 421 ; +C 62 ; WX 620 ; N greater ; B 89 -9 598 540 ; +C 63 ; WX 620 ; N question ; B 145 -8 668 698 ; +C 64 ; WX 780 ; N at ; B 80 -17 790 698 ; +C 65 ; WX 720 ; N A ; B -27 0 769 681 ; +C 66 ; WX 720 ; N B ; B 14 0 762 681 ; +C 67 ; WX 700 ; N C ; B 78 -17 754 698 ; +C 68 ; WX 760 ; N D ; B 14 0 805 681 ; +C 69 ; WX 720 ; N E ; B 14 0 777 681 ; +C 70 ; WX 660 ; N F ; B 14 0 763 681 ; +C 71 ; WX 760 ; N G ; B 77 -17 828 698 ; +C 72 ; WX 800 ; N H ; B 14 0 910 681 ; +C 73 ; WX 380 ; N I ; B 14 0 485 681 ; +C 74 ; WX 620 ; N J ; B 8 -17 721 681 ; +C 75 ; WX 780 ; N K ; B 14 0 879 681 ; +C 76 ; WX 640 ; N L ; B 14 0 725 681 ; +C 77 ; WX 860 ; N M ; B 14 0 970 681 ; +C 78 ; WX 740 ; N N ; B 14 0 845 681 ; +C 79 ; WX 760 ; N O ; B 78 -17 806 698 ; +C 80 ; WX 640 ; N P ; B -6 0 724 681 ; +C 81 ; WX 760 ; N Q ; B 37 -213 805 698 ; +C 82 ; WX 740 ; N R ; B 14 0 765 681 ; +C 83 ; WX 700 ; N S ; B 59 -17 731 698 ; +C 84 ; WX 700 ; N T ; B 70 0 802 681 ; +C 85 ; WX 740 ; N U ; B 112 -17 855 681 ; +C 86 ; WX 660 ; N V ; B 72 0 819 681 ; +C 87 ; WX 1000 ; N W ; B 72 0 1090 681 ; +C 88 ; WX 740 ; N X ; B -7 0 835 681 ; +C 89 ; WX 660 ; N Y ; B 72 0 817 681 ; +C 90 ; WX 680 ; N Z ; B 23 0 740 681 ; +C 91 ; WX 260 ; N bracketleft ; B 9 -118 374 741 ; +C 92 ; WX 580 ; N backslash ; B 73 0 575 741 ; +C 93 ; WX 260 ; N bracketright ; B -18 -118 347 741 ; +C 94 ; WX 620 ; N asciicircum ; B 92 281 594 681 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 320 ; N quoteleft ; B 155 420 333 698 ; +C 97 ; WX 680 ; N a ; B 84 -8 735 515 ; +C 98 ; WX 600 ; N b ; B 57 -8 633 732 ; +C 99 ; WX 560 ; N c ; B 58 -8 597 515 ; +C 100 ; WX 680 ; N d ; B 60 -8 714 732 ; +C 101 ; WX 560 ; N e ; B 59 -8 596 515 ; +C 102 ; WX 420 ; N f ; B -192 -213 641 741 ; L i fi ; L l fl ; +C 103 ; WX 620 ; N g ; B 21 -213 669 515 ; +C 104 ; WX 700 ; N h ; B 93 -8 736 732 ; +C 105 ; WX 380 ; N i ; B 83 -8 420 755 ; +C 106 ; WX 320 ; N j ; B -160 -213 392 755 ; +C 107 ; WX 700 ; N k ; B 97 -8 732 732 ; +C 108 ; WX 380 ; N l ; B 109 -8 410 732 ; +C 109 ; WX 960 ; N m ; B 83 -8 996 515 ; +C 110 ; WX 680 ; N n ; B 83 -8 715 515 ; +C 111 ; WX 600 ; N o ; B 59 -8 627 515 ; +C 112 ; WX 660 ; N p ; B -24 -213 682 515 ; +C 113 ; WX 620 ; N q ; B 60 -213 640 515 ; +C 114 ; WX 500 ; N r ; B 84 0 582 515 ; +C 115 ; WX 540 ; N s ; B 32 -8 573 515 ; +C 116 ; WX 440 ; N t ; B 106 -8 488 658 ; +C 117 ; WX 680 ; N u ; B 83 -8 720 507 ; +C 118 ; WX 540 ; N v ; B 56 -8 572 515 ; +C 119 ; WX 860 ; N w ; B 56 -8 891 515 ; +C 120 ; WX 620 ; N x ; B 10 -8 654 515 ; +C 121 ; WX 600 ; N y ; B 25 -213 642 507 ; +C 122 ; WX 560 ; N z ; B 36 -8 586 515 ; +C 123 ; WX 300 ; N braceleft ; B 49 -123 413 742 ; +C 124 ; WX 620 ; N bar ; B 303 -250 422 750 ; +C 125 ; WX 300 ; N braceright ; B -8 -114 356 751 ; +C 126 ; WX 620 ; N asciitilde ; B 101 162 605 368 ; +C 161 ; WX 320 ; N exclamdown ; B 64 -191 344 515 ; +C 162 ; WX 680 ; N cent ; B 161 25 616 718 ; +C 163 ; WX 680 ; N sterling ; B 0 -17 787 698 ; +C 164 ; WX 120 ; N fraction ; B -144 0 382 681 ; +C 165 ; WX 680 ; N yen ; B 92 0 782 681 ; +C 166 ; WX 680 ; N florin ; B -28 -199 743 741 ; +C 167 ; WX 620 ; N section ; B 46 -137 638 698 ; +C 168 ; WX 680 ; N currency ; B 148 85 637 571 ; +C 169 ; WX 180 ; N quotesingle ; B 126 370 295 696 ; +C 170 ; WX 520 ; N quotedblleft ; B 156 420 545 698 ; +C 171 ; WX 380 ; N guillemotleft ; B 62 84 406 503 ; +C 172 ; WX 220 ; N guilsinglleft ; B 62 84 249 503 ; +C 173 ; WX 220 ; N guilsinglright ; B 62 84 249 503 ; +C 174 ; WX 820 ; N fi ; B -191 -213 850 741 ; +C 175 ; WX 820 ; N fl ; B -191 -213 850 741 ; +C 177 ; WX 500 ; N endash ; B 40 219 573 311 ; +C 178 ; WX 420 ; N dagger ; B 89 -137 466 698 ; +C 179 ; WX 420 ; N daggerdbl ; B 79 -137 486 698 ; +C 180 ; WX 340 ; N periodcentered ; B 126 173 316 358 ; +C 182 ; WX 680 ; N paragraph ; B 137 0 715 681 ; +C 183 ; WX 360 ; N bullet ; B 60 170 404 511 ; +C 184 ; WX 300 ; N quotesinglbase ; B 106 -112 284 166 ; +C 185 ; WX 520 ; N quotedblbase ; B 106 -112 495 166 ; +C 186 ; WX 520 ; N quotedblright ; B 171 420 560 698 ; +C 187 ; WX 380 ; N guillemotright ; B 62 84 406 503 ; +C 188 ; WX 1000 ; N ellipsis ; B 86 -8 942 177 ; +C 189 ; WX 1360 ; N perthousand ; B 106 -17 1333 698 ; +C 191 ; WX 620 ; N questiondown ; B 83 -189 606 515 ; +C 193 ; WX 380 ; N grave ; B 193 566 424 771 ; +C 194 ; WX 340 ; N acute ; B 176 566 407 771 ; +C 195 ; WX 480 ; N circumflex ; B 183 582 523 749 ; +C 196 ; WX 480 ; N tilde ; B 178 587 533 709 ; +C 197 ; WX 480 ; N macron ; B 177 603 531 691 ; +C 198 ; WX 460 ; N breve ; B 177 577 516 707 ; +C 199 ; WX 380 ; N dotaccent ; B 180 570 345 734 ; +C 200 ; WX 520 ; N dieresis ; B 180 570 569 734 ; +C 202 ; WX 360 ; N ring ; B 185 558 406 775 ; +C 203 ; WX 360 ; N cedilla ; B 68 -220 289 -8 ; +C 205 ; WX 560 ; N hungarumlaut ; B 181 560 616 775 ; +C 206 ; WX 320 ; N ogonek ; B 68 -182 253 0 ; +C 207 ; WX 480 ; N caron ; B 183 582 523 749 ; +C 208 ; WX 1000 ; N emdash ; B 40 219 1073 311 ; +C 225 ; WX 1140 ; N AE ; B -27 0 1207 681 ; +C 227 ; WX 440 ; N ordfeminine ; B 118 400 495 685 ; +C 232 ; WX 640 ; N Lslash ; B 14 0 724 681 ; +C 233 ; WX 760 ; N Oslash ; B 21 -29 847 725 ; +C 234 ; WX 1180 ; N OE ; B 94 -17 1245 698 ; +C 235 ; WX 440 ; N ordmasculine ; B 127 400 455 685 ; +C 241 ; WX 880 ; N ae ; B 39 -8 913 515 ; +C 245 ; WX 380 ; N dotlessi ; B 83 -8 420 507 ; +C 248 ; WX 380 ; N lslash ; B 63 -8 412 732 ; +C 249 ; WX 600 ; N oslash ; B 17 -54 661 571 ; +C 250 ; WX 920 ; N oe ; B 48 -8 961 515 ; +C 251 ; WX 660 ; N germandbls ; B -231 -213 702 741 ; +C -1 ; WX 560 ; N ecircumflex ; B 59 -8 596 749 ; +C -1 ; WX 560 ; N edieresis ; B 59 -8 596 734 ; +C -1 ; WX 680 ; N aacute ; B 84 -8 735 771 ; +C -1 ; WX 780 ; N registered ; B 83 -17 783 698 ; +C -1 ; WX 380 ; N icircumflex ; B 83 -8 433 749 ; +C -1 ; WX 680 ; N udieresis ; B 83 -8 720 734 ; +C -1 ; WX 600 ; N ograve ; B 59 -8 627 771 ; +C -1 ; WX 680 ; N uacute ; B 83 -8 720 771 ; +C -1 ; WX 680 ; N ucircumflex ; B 83 -8 720 749 ; +C -1 ; WX 720 ; N Aacute ; B -27 0 769 937 ; +C -1 ; WX 380 ; N igrave ; B 83 -8 424 771 ; +C -1 ; WX 380 ; N Icircumflex ; B 14 0 493 915 ; +C -1 ; WX 560 ; N ccedilla ; B 58 -220 597 515 ; +C -1 ; WX 680 ; N adieresis ; B 84 -8 735 734 ; +C -1 ; WX 720 ; N Ecircumflex ; B 14 0 777 915 ; +C -1 ; WX 540 ; N scaron ; B 32 -8 573 749 ; +C -1 ; WX 660 ; N thorn ; B -24 -213 682 732 ; +C -1 ; WX 940 ; N trademark ; B 42 277 982 681 ; +C -1 ; WX 560 ; N egrave ; B 59 -8 596 771 ; +C -1 ; WX 408 ; N threesuperior ; B 86 269 483 698 ; +C -1 ; WX 560 ; N zcaron ; B 36 -8 586 749 ; +C -1 ; WX 680 ; N atilde ; B 84 -8 735 709 ; +C -1 ; WX 680 ; N aring ; B 84 -8 735 775 ; +C -1 ; WX 600 ; N ocircumflex ; B 59 -8 627 749 ; +C -1 ; WX 720 ; N Edieresis ; B 14 0 777 900 ; +C -1 ; WX 1020 ; N threequarters ; B 86 0 1054 691 ; +C -1 ; WX 600 ; N ydieresis ; B 25 -213 642 734 ; +C -1 ; WX 600 ; N yacute ; B 25 -213 642 771 ; +C -1 ; WX 380 ; N iacute ; B 83 -8 420 771 ; +C -1 ; WX 720 ; N Acircumflex ; B -27 0 769 915 ; +C -1 ; WX 740 ; N Uacute ; B 112 -17 855 937 ; +C -1 ; WX 560 ; N eacute ; B 59 -8 596 771 ; +C -1 ; WX 760 ; N Ograve ; B 78 -17 806 937 ; +C -1 ; WX 680 ; N agrave ; B 84 -8 735 771 ; +C -1 ; WX 740 ; N Udieresis ; B 112 -17 855 900 ; +C -1 ; WX 680 ; N acircumflex ; B 84 -8 735 749 ; +C -1 ; WX 380 ; N Igrave ; B 14 0 485 937 ; +C -1 ; WX 408 ; N twosuperior ; B 91 279 485 698 ; +C -1 ; WX 740 ; N Ugrave ; B 112 -17 855 937 ; +C -1 ; WX 1020 ; N onequarter ; B 118 0 1054 681 ; +C -1 ; WX 740 ; N Ucircumflex ; B 112 -17 855 915 ; +C -1 ; WX 700 ; N Scaron ; B 59 -17 731 915 ; +C -1 ; WX 380 ; N Idieresis ; B 14 0 499 900 ; +C -1 ; WX 380 ; N idieresis ; B 83 -8 479 734 ; +C -1 ; WX 720 ; N Egrave ; B 14 0 777 937 ; +C -1 ; WX 760 ; N Oacute ; B 78 -17 806 937 ; +C -1 ; WX 600 ; N divide ; B 91 9 595 521 ; +C -1 ; WX 720 ; N Atilde ; B -27 0 769 875 ; +C -1 ; WX 720 ; N Aring ; B -27 0 769 941 ; +C -1 ; WX 760 ; N Odieresis ; B 78 -17 806 900 ; +C -1 ; WX 720 ; N Adieresis ; B -27 0 769 900 ; +C -1 ; WX 740 ; N Ntilde ; B 14 0 845 875 ; +C -1 ; WX 680 ; N Zcaron ; B 23 0 740 915 ; +C -1 ; WX 640 ; N Thorn ; B -6 0 701 681 ; +C -1 ; WX 380 ; N Iacute ; B 14 0 485 937 ; +C -1 ; WX 600 ; N plusminus ; B 91 0 595 514 ; +C -1 ; WX 600 ; N multiply ; B 91 10 595 514 ; +C -1 ; WX 720 ; N Eacute ; B 14 0 777 937 ; +C -1 ; WX 660 ; N Ydieresis ; B 72 0 817 900 ; +C -1 ; WX 408 ; N onesuperior ; B 118 279 406 688 ; +C -1 ; WX 680 ; N ugrave ; B 83 -8 720 771 ; +C -1 ; WX 620 ; N logicalnot ; B 81 129 585 421 ; +C -1 ; WX 680 ; N ntilde ; B 83 -8 715 709 ; +C -1 ; WX 760 ; N Otilde ; B 78 -17 806 875 ; +C -1 ; WX 600 ; N otilde ; B 59 -8 627 709 ; +C -1 ; WX 700 ; N Ccedilla ; B 78 -220 754 698 ; +C -1 ; WX 720 ; N Agrave ; B -27 0 769 937 ; +C -1 ; WX 1020 ; N onehalf ; B 118 0 1036 681 ; +C -1 ; WX 760 ; N Eth ; B 14 0 805 681 ; +C -1 ; WX 400 ; N degree ; B 130 398 430 698 ; +C -1 ; WX 660 ; N Yacute ; B 72 0 817 937 ; +C -1 ; WX 760 ; N Ocircumflex ; B 78 -17 806 915 ; +C -1 ; WX 600 ; N oacute ; B 59 -8 627 771 ; +C -1 ; WX 680 ; N mu ; B 54 -213 720 507 ; +C -1 ; WX 600 ; N minus ; B 91 207 595 323 ; +C -1 ; WX 600 ; N eth ; B 59 -8 662 741 ; +C -1 ; WX 600 ; N odieresis ; B 59 -8 627 734 ; +C -1 ; WX 780 ; N copyright ; B 83 -17 783 698 ; +C -1 ; WX 620 ; N brokenbar ; B 303 -175 422 675 ; +EndCharMetrics +StartKernData +StartKernPairs 92 + +KPX A y 20 +KPX A w 20 +KPX A v 20 +KPX A Y -25 +KPX A W -35 +KPX A V -40 +KPX A T -17 + +KPX F period -105 +KPX F comma -98 +KPX F A -35 + +KPX L y 62 +KPX L Y -5 +KPX L W -15 +KPX L V -19 +KPX L T -26 + +KPX P period -105 +KPX P comma -98 +KPX P A -31 + +KPX R y 27 +KPX R Y 4 +KPX R W -4 +KPX R V -8 +KPX R T -3 + +KPX T y 56 +KPX T w 69 +KPX T u 42 +KPX T semicolon 31 +KPX T s -1 +KPX T r 41 +KPX T period -107 +KPX T o -5 +KPX T i 42 +KPX T hyphen -20 +KPX T e -10 +KPX T comma -100 +KPX T colon 26 +KPX T c -8 +KPX T a -8 +KPX T A -42 + +KPX V y 17 +KPX V u -1 +KPX V semicolon -22 +KPX V r 2 +KPX V period -115 +KPX V o -50 +KPX V i 32 +KPX V hyphen -20 +KPX V e -50 +KPX V comma -137 +KPX V colon -28 +KPX V a -50 +KPX V A -50 + +KPX W y -51 +KPX W u -69 +KPX W semicolon -81 +KPX W r -66 +KPX W period -183 +KPX W o -100 +KPX W i -36 +KPX W hyphen -22 +KPX W e -100 +KPX W comma -201 +KPX W colon -86 +KPX W a -100 +KPX W A -77 + +KPX Y v 26 +KPX Y u -1 +KPX Y semicolon -4 +KPX Y q -43 +KPX Y period -113 +KPX Y o -41 +KPX Y i 20 +KPX Y hyphen -20 +KPX Y e -46 +KPX Y comma -106 +KPX Y colon -9 +KPX Y a -45 +KPX Y A -30 + +KPX f f 10 + +KPX r q -3 +KPX r period -120 +KPX r o -1 +KPX r n 39 +KPX r m 39 +KPX r hyphen -20 +KPX r h -35 +KPX r g -23 +KPX r f 42 +KPX r e -6 +KPX r d -3 +KPX r comma -113 +KPX r c -5 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 190 166 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 120 166 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 100 166 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 170 166 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 200 166 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 120 166 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 190 166 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 120 166 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 100 166 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 170 166 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 20 166 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -30 166 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -70 166 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 0 166 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 130 166 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 210 166 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 140 166 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 140 166 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 190 166 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 140 166 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 110 166 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 200 166 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 130 166 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 130 166 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 180 166 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 160 166 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 70 166 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 100 166 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 170 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 100 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 80 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 150 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 160 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 100 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 110 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 60 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 20 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 90 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -90 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -90 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 60 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 130 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 60 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 40 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 110 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 60 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 30 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 170 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 100 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 80 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 150 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 130 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 40 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 40 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkl8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkl8a.afm new file mode 100644 index 00000000..8b79ea71 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkl8a.afm @@ -0,0 +1,407 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Jan 21 16:15:53 1992 +Comment UniqueID 37833 +Comment VMusage 32321 39213 +FontName Bookman-Light +FullName ITC Bookman Light +FamilyName ITC Bookman +Weight Light +ItalicAngle 0 +IsFixedPitch false +FontBBox -188 -251 1266 908 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.004 +Notice Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved.ITC Bookman is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 484 +Ascender 717 +Descender -228 +StartCharMetrics 228 +C 32 ; WX 320 ; N space ; B 0 0 0 0 ; +C 33 ; WX 300 ; N exclam ; B 75 -8 219 698 ; +C 34 ; WX 380 ; N quotedbl ; B 56 458 323 698 ; +C 35 ; WX 620 ; N numbersign ; B 65 0 556 681 ; +C 36 ; WX 620 ; N dollar ; B 34 -109 593 791 ; +C 37 ; WX 900 ; N percent ; B 22 -8 873 698 ; +C 38 ; WX 800 ; N ampersand ; B 45 -17 787 698 ; +C 39 ; WX 220 ; N quoteright ; B 46 480 178 698 ; +C 40 ; WX 300 ; N parenleft ; B 76 -145 278 727 ; +C 41 ; WX 300 ; N parenright ; B 17 -146 219 727 ; +C 42 ; WX 440 ; N asterisk ; B 54 325 391 698 ; +C 43 ; WX 600 ; N plus ; B 51 8 555 513 ; +C 44 ; WX 320 ; N comma ; B 90 -114 223 114 ; +C 45 ; WX 400 ; N hyphen ; B 50 232 350 292 ; +C 46 ; WX 320 ; N period ; B 92 -8 220 123 ; +C 47 ; WX 600 ; N slash ; B 74 -149 532 717 ; +C 48 ; WX 620 ; N zero ; B 40 -17 586 698 ; +C 49 ; WX 620 ; N one ; B 160 0 501 681 ; +C 50 ; WX 620 ; N two ; B 42 0 576 698 ; +C 51 ; WX 620 ; N three ; B 40 -17 576 698 ; +C 52 ; WX 620 ; N four ; B 25 0 600 681 ; +C 53 ; WX 620 ; N five ; B 60 -17 584 717 ; +C 54 ; WX 620 ; N six ; B 45 -17 590 698 ; +C 55 ; WX 620 ; N seven ; B 60 0 586 681 ; +C 56 ; WX 620 ; N eight ; B 44 -17 583 698 ; +C 57 ; WX 620 ; N nine ; B 37 -17 576 698 ; +C 58 ; WX 320 ; N colon ; B 92 -8 220 494 ; +C 59 ; WX 320 ; N semicolon ; B 90 -114 223 494 ; +C 60 ; WX 600 ; N less ; B 49 -2 558 526 ; +C 61 ; WX 600 ; N equal ; B 51 126 555 398 ; +C 62 ; WX 600 ; N greater ; B 48 -2 557 526 ; +C 63 ; WX 540 ; N question ; B 27 -8 514 698 ; +C 64 ; WX 820 ; N at ; B 55 -17 755 698 ; +C 65 ; WX 680 ; N A ; B -37 0 714 681 ; +C 66 ; WX 740 ; N B ; B 31 0 702 681 ; +C 67 ; WX 740 ; N C ; B 44 -17 702 698 ; +C 68 ; WX 800 ; N D ; B 31 0 752 681 ; +C 69 ; WX 720 ; N E ; B 31 0 705 681 ; +C 70 ; WX 640 ; N F ; B 31 0 654 681 ; +C 71 ; WX 800 ; N G ; B 44 -17 778 698 ; +C 72 ; WX 800 ; N H ; B 31 0 769 681 ; +C 73 ; WX 340 ; N I ; B 31 0 301 681 ; +C 74 ; WX 600 ; N J ; B -23 -17 567 681 ; +C 75 ; WX 720 ; N K ; B 31 0 750 681 ; +C 76 ; WX 600 ; N L ; B 31 0 629 681 ; +C 77 ; WX 920 ; N M ; B 26 0 894 681 ; +C 78 ; WX 740 ; N N ; B 26 0 722 681 ; +C 79 ; WX 800 ; N O ; B 44 -17 758 698 ; +C 80 ; WX 620 ; N P ; B 31 0 613 681 ; +C 81 ; WX 820 ; N Q ; B 44 -189 769 698 ; +C 82 ; WX 720 ; N R ; B 31 0 757 681 ; +C 83 ; WX 660 ; N S ; B 28 -17 634 698 ; +C 84 ; WX 620 ; N T ; B -37 0 656 681 ; +C 85 ; WX 780 ; N U ; B 25 -17 754 681 ; +C 86 ; WX 700 ; N V ; B -30 0 725 681 ; +C 87 ; WX 960 ; N W ; B -30 0 984 681 ; +C 88 ; WX 720 ; N X ; B -30 0 755 681 ; +C 89 ; WX 640 ; N Y ; B -30 0 666 681 ; +C 90 ; WX 640 ; N Z ; B 10 0 656 681 ; +C 91 ; WX 300 ; N bracketleft ; B 92 -136 258 717 ; +C 92 ; WX 600 ; N backslash ; B 74 0 532 717 ; +C 93 ; WX 300 ; N bracketright ; B 41 -136 207 717 ; +C 94 ; WX 600 ; N asciicircum ; B 52 276 554 681 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 220 ; N quoteleft ; B 46 479 178 698 ; +C 97 ; WX 580 ; N a ; B 35 -8 587 494 ; +C 98 ; WX 620 ; N b ; B -2 -8 582 717 ; +C 99 ; WX 520 ; N c ; B 37 -8 498 494 ; +C 100 ; WX 620 ; N d ; B 37 -8 591 717 ; +C 101 ; WX 520 ; N e ; B 37 -8 491 494 ; +C 102 ; WX 320 ; N f ; B 20 0 414 734 ; L i fi ; L l fl ; +C 103 ; WX 540 ; N g ; B 17 -243 542 567 ; +C 104 ; WX 660 ; N h ; B 20 0 643 717 ; +C 105 ; WX 300 ; N i ; B 20 0 288 654 ; +C 106 ; WX 300 ; N j ; B -109 -251 214 654 ; +C 107 ; WX 620 ; N k ; B 20 0 628 717 ; +C 108 ; WX 300 ; N l ; B 20 0 286 717 ; +C 109 ; WX 940 ; N m ; B 17 0 928 494 ; +C 110 ; WX 660 ; N n ; B 20 0 649 494 ; +C 111 ; WX 560 ; N o ; B 37 -8 526 494 ; +C 112 ; WX 620 ; N p ; B 20 -228 583 494 ; +C 113 ; WX 580 ; N q ; B 37 -228 589 494 ; +C 114 ; WX 440 ; N r ; B 20 0 447 494 ; +C 115 ; WX 520 ; N s ; B 40 -8 487 494 ; +C 116 ; WX 380 ; N t ; B 20 -8 388 667 ; +C 117 ; WX 680 ; N u ; B 20 -8 653 484 ; +C 118 ; WX 520 ; N v ; B -23 0 534 484 ; +C 119 ; WX 780 ; N w ; B -19 0 804 484 ; +C 120 ; WX 560 ; N x ; B -16 0 576 484 ; +C 121 ; WX 540 ; N y ; B -23 -236 549 484 ; +C 122 ; WX 480 ; N z ; B 7 0 476 484 ; +C 123 ; WX 280 ; N braceleft ; B 21 -136 260 717 ; +C 124 ; WX 600 ; N bar ; B 264 -250 342 750 ; +C 125 ; WX 280 ; N braceright ; B 21 -136 260 717 ; +C 126 ; WX 600 ; N asciitilde ; B 52 173 556 352 ; +C 161 ; WX 300 ; N exclamdown ; B 75 -214 219 494 ; +C 162 ; WX 620 ; N cent ; B 116 20 511 651 ; +C 163 ; WX 620 ; N sterling ; B 8 -17 631 698 ; +C 164 ; WX 140 ; N fraction ; B -188 0 335 681 ; +C 165 ; WX 620 ; N yen ; B -22 0 647 681 ; +C 166 ; WX 620 ; N florin ; B -29 -155 633 749 ; +C 167 ; WX 520 ; N section ; B 33 -178 486 698 ; +C 168 ; WX 620 ; N currency ; B 58 89 563 591 ; +C 169 ; WX 220 ; N quotesingle ; B 67 458 153 698 ; +C 170 ; WX 400 ; N quotedblleft ; B 46 479 348 698 ; +C 171 ; WX 360 ; N guillemotleft ; B 51 89 312 437 ; +C 172 ; WX 240 ; N guilsinglleft ; B 51 89 189 437 ; +C 173 ; WX 240 ; N guilsinglright ; B 51 89 189 437 ; +C 174 ; WX 620 ; N fi ; B 20 0 608 734 ; +C 175 ; WX 620 ; N fl ; B 20 0 606 734 ; +C 177 ; WX 500 ; N endash ; B -15 232 515 292 ; +C 178 ; WX 540 ; N dagger ; B 79 -156 455 698 ; +C 179 ; WX 540 ; N daggerdbl ; B 79 -156 455 698 ; +C 180 ; WX 320 ; N periodcentered ; B 92 196 220 327 ; +C 182 ; WX 600 ; N paragraph ; B 14 0 577 681 ; +C 183 ; WX 460 ; N bullet ; B 60 170 404 511 ; +C 184 ; WX 220 ; N quotesinglbase ; B 46 -108 178 110 ; +C 185 ; WX 400 ; N quotedblbase ; B 46 -108 348 110 ; +C 186 ; WX 400 ; N quotedblright ; B 46 480 348 698 ; +C 187 ; WX 360 ; N guillemotright ; B 51 89 312 437 ; +C 188 ; WX 1000 ; N ellipsis ; B 101 -8 898 123 ; +C 189 ; WX 1280 ; N perthousand ; B 22 -8 1266 698 ; +C 191 ; WX 540 ; N questiondown ; B 23 -217 510 494 ; +C 193 ; WX 340 ; N grave ; B 68 571 274 689 ; +C 194 ; WX 340 ; N acute ; B 68 571 274 689 ; +C 195 ; WX 420 ; N circumflex ; B 68 567 352 685 ; +C 196 ; WX 440 ; N tilde ; B 68 572 375 661 ; +C 197 ; WX 440 ; N macron ; B 68 587 364 635 ; +C 198 ; WX 460 ; N breve ; B 68 568 396 687 ; +C 199 ; WX 260 ; N dotaccent ; B 68 552 186 672 ; +C 200 ; WX 420 ; N dieresis ; B 68 552 349 674 ; +C 202 ; WX 320 ; N ring ; B 68 546 252 731 ; +C 203 ; WX 320 ; N cedilla ; B 68 -200 257 0 ; +C 205 ; WX 380 ; N hungarumlaut ; B 68 538 311 698 ; +C 206 ; WX 320 ; N ogonek ; B 68 -145 245 0 ; +C 207 ; WX 420 ; N caron ; B 68 554 352 672 ; +C 208 ; WX 1000 ; N emdash ; B -15 232 1015 292 ; +C 225 ; WX 1260 ; N AE ; B -36 0 1250 681 ; +C 227 ; WX 420 ; N ordfeminine ; B 49 395 393 698 ; +C 232 ; WX 600 ; N Lslash ; B 31 0 629 681 ; +C 233 ; WX 800 ; N Oslash ; B 44 -53 758 733 ; +C 234 ; WX 1240 ; N OE ; B 44 -17 1214 698 ; +C 235 ; WX 420 ; N ordmasculine ; B 56 394 361 698 ; +C 241 ; WX 860 ; N ae ; B 35 -8 832 494 ; +C 245 ; WX 300 ; N dotlessi ; B 20 0 288 484 ; +C 248 ; WX 320 ; N lslash ; B 20 0 291 717 ; +C 249 ; WX 560 ; N oslash ; B 37 -40 526 534 ; +C 250 ; WX 900 ; N oe ; B 37 -8 876 494 ; +C 251 ; WX 660 ; N germandbls ; B -109 -110 614 698 ; +C -1 ; WX 520 ; N ecircumflex ; B 37 -8 491 685 ; +C -1 ; WX 520 ; N edieresis ; B 37 -8 491 674 ; +C -1 ; WX 580 ; N aacute ; B 35 -8 587 689 ; +C -1 ; WX 740 ; N registered ; B 23 -17 723 698 ; +C -1 ; WX 300 ; N icircumflex ; B 8 0 292 685 ; +C -1 ; WX 680 ; N udieresis ; B 20 -8 653 674 ; +C -1 ; WX 560 ; N ograve ; B 37 -8 526 689 ; +C -1 ; WX 680 ; N uacute ; B 20 -8 653 689 ; +C -1 ; WX 680 ; N ucircumflex ; B 20 -8 653 685 ; +C -1 ; WX 680 ; N Aacute ; B -37 0 714 866 ; +C -1 ; WX 300 ; N igrave ; B 20 0 288 689 ; +C -1 ; WX 340 ; N Icircumflex ; B 28 0 312 862 ; +C -1 ; WX 520 ; N ccedilla ; B 37 -200 498 494 ; +C -1 ; WX 580 ; N adieresis ; B 35 -8 587 674 ; +C -1 ; WX 720 ; N Ecircumflex ; B 31 0 705 862 ; +C -1 ; WX 520 ; N scaron ; B 40 -8 487 672 ; +C -1 ; WX 620 ; N thorn ; B 20 -228 583 717 ; +C -1 ; WX 980 ; N trademark ; B 34 277 930 681 ; +C -1 ; WX 520 ; N egrave ; B 37 -8 491 689 ; +C -1 ; WX 372 ; N threesuperior ; B 12 269 360 698 ; +C -1 ; WX 480 ; N zcaron ; B 7 0 476 672 ; +C -1 ; WX 580 ; N atilde ; B 35 -8 587 661 ; +C -1 ; WX 580 ; N aring ; B 35 -8 587 731 ; +C -1 ; WX 560 ; N ocircumflex ; B 37 -8 526 685 ; +C -1 ; WX 720 ; N Edieresis ; B 31 0 705 851 ; +C -1 ; WX 930 ; N threequarters ; B 52 0 889 691 ; +C -1 ; WX 540 ; N ydieresis ; B -23 -236 549 674 ; +C -1 ; WX 540 ; N yacute ; B -23 -236 549 689 ; +C -1 ; WX 300 ; N iacute ; B 20 0 288 689 ; +C -1 ; WX 680 ; N Acircumflex ; B -37 0 714 862 ; +C -1 ; WX 780 ; N Uacute ; B 25 -17 754 866 ; +C -1 ; WX 520 ; N eacute ; B 37 -8 491 689 ; +C -1 ; WX 800 ; N Ograve ; B 44 -17 758 866 ; +C -1 ; WX 580 ; N agrave ; B 35 -8 587 689 ; +C -1 ; WX 780 ; N Udieresis ; B 25 -17 754 851 ; +C -1 ; WX 580 ; N acircumflex ; B 35 -8 587 685 ; +C -1 ; WX 340 ; N Igrave ; B 31 0 301 866 ; +C -1 ; WX 372 ; N twosuperior ; B 20 279 367 698 ; +C -1 ; WX 780 ; N Ugrave ; B 25 -17 754 866 ; +C -1 ; WX 930 ; N onequarter ; B 80 0 869 681 ; +C -1 ; WX 780 ; N Ucircumflex ; B 25 -17 754 862 ; +C -1 ; WX 660 ; N Scaron ; B 28 -17 634 849 ; +C -1 ; WX 340 ; N Idieresis ; B 28 0 309 851 ; +C -1 ; WX 300 ; N idieresis ; B 8 0 289 674 ; +C -1 ; WX 720 ; N Egrave ; B 31 0 705 866 ; +C -1 ; WX 800 ; N Oacute ; B 44 -17 758 866 ; +C -1 ; WX 600 ; N divide ; B 51 10 555 514 ; +C -1 ; WX 680 ; N Atilde ; B -37 0 714 838 ; +C -1 ; WX 680 ; N Aring ; B -37 0 714 908 ; +C -1 ; WX 800 ; N Odieresis ; B 44 -17 758 851 ; +C -1 ; WX 680 ; N Adieresis ; B -37 0 714 851 ; +C -1 ; WX 740 ; N Ntilde ; B 26 0 722 838 ; +C -1 ; WX 640 ; N Zcaron ; B 10 0 656 849 ; +C -1 ; WX 620 ; N Thorn ; B 31 0 613 681 ; +C -1 ; WX 340 ; N Iacute ; B 31 0 301 866 ; +C -1 ; WX 600 ; N plusminus ; B 51 0 555 513 ; +C -1 ; WX 600 ; N multiply ; B 51 9 555 513 ; +C -1 ; WX 720 ; N Eacute ; B 31 0 705 866 ; +C -1 ; WX 640 ; N Ydieresis ; B -30 0 666 851 ; +C -1 ; WX 372 ; N onesuperior ; B 80 279 302 688 ; +C -1 ; WX 680 ; N ugrave ; B 20 -8 653 689 ; +C -1 ; WX 600 ; N logicalnot ; B 51 128 555 398 ; +C -1 ; WX 660 ; N ntilde ; B 20 0 649 661 ; +C -1 ; WX 800 ; N Otilde ; B 44 -17 758 838 ; +C -1 ; WX 560 ; N otilde ; B 37 -8 526 661 ; +C -1 ; WX 740 ; N Ccedilla ; B 44 -200 702 698 ; +C -1 ; WX 680 ; N Agrave ; B -37 0 714 866 ; +C -1 ; WX 930 ; N onehalf ; B 80 0 885 681 ; +C -1 ; WX 800 ; N Eth ; B 31 0 752 681 ; +C -1 ; WX 400 ; N degree ; B 50 398 350 698 ; +C -1 ; WX 640 ; N Yacute ; B -30 0 666 866 ; +C -1 ; WX 800 ; N Ocircumflex ; B 44 -17 758 862 ; +C -1 ; WX 560 ; N oacute ; B 37 -8 526 689 ; +C -1 ; WX 680 ; N mu ; B 20 -251 653 484 ; +C -1 ; WX 600 ; N minus ; B 51 224 555 300 ; +C -1 ; WX 560 ; N eth ; B 37 -8 526 734 ; +C -1 ; WX 560 ; N odieresis ; B 37 -8 526 674 ; +C -1 ; WX 740 ; N copyright ; B 24 -17 724 698 ; +C -1 ; WX 600 ; N brokenbar ; B 264 -175 342 675 ; +EndCharMetrics +StartKernData +StartKernPairs 82 + +KPX A y 32 +KPX A w 4 +KPX A v 7 +KPX A Y -35 +KPX A W -40 +KPX A V -56 +KPX A T 1 + +KPX F period -46 +KPX F comma -41 +KPX F A -21 + +KPX L y 79 +KPX L Y 13 +KPX L W 1 +KPX L V -4 +KPX L T 28 + +KPX P period -60 +KPX P comma -55 +KPX P A -8 + +KPX R y 59 +KPX R Y 26 +KPX R W 13 +KPX R V 8 +KPX R T 71 + +KPX T s 16 +KPX T r 38 +KPX T period -33 +KPX T o 15 +KPX T i 42 +KPX T hyphen 90 +KPX T e 13 +KPX T comma -28 +KPX T c 14 +KPX T a 17 +KPX T A 1 + +KPX V y 15 +KPX V u -38 +KPX V r -41 +KPX V period -40 +KPX V o -71 +KPX V i -20 +KPX V hyphen 11 +KPX V e -72 +KPX V comma -34 +KPX V a -69 +KPX V A -66 + +KPX W y 15 +KPX W u -38 +KPX W r -41 +KPX W period -40 +KPX W o -68 +KPX W i -20 +KPX W hyphen 11 +KPX W e -69 +KPX W comma -34 +KPX W a -66 +KPX W A -64 + +KPX Y v 15 +KPX Y u -38 +KPX Y q -55 +KPX Y period -40 +KPX Y p -31 +KPX Y o -57 +KPX Y i -37 +KPX Y hyphen 11 +KPX Y e -58 +KPX Y comma -34 +KPX Y a -54 +KPX Y A -53 + +KPX f f 29 + +KPX r q 9 +KPX r period -64 +KPX r o 8 +KPX r n 31 +KPX r m 31 +KPX r hyphen 70 +KPX r h -21 +KPX r g -4 +KPX r f 33 +KPX r e 7 +KPX r d 7 +KPX r comma -58 +KPX r c 7 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 200 177 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 130 177 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 130 177 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 140 177 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 180 177 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 120 177 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 220 177 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 150 177 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 150 177 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 160 177 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 20 177 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -40 177 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -40 177 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -20 177 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 150 177 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 260 177 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 190 177 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 190 177 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 200 177 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 180 177 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 120 177 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 250 177 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 180 177 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 180 177 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 190 177 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 150 177 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 110 177 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 110 177 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 120 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 80 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 80 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 120 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 130 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 70 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 90 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 50 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 50 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 90 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -20 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -60 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -60 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -20 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 110 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 110 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 70 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 70 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 110 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 60 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 50 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 170 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 130 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 130 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 170 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 100 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 60 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 30 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkli8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkli8a.afm new file mode 100644 index 00000000..419c319a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pbkli8a.afm @@ -0,0 +1,410 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Jan 21 16:12:06 1992 +Comment UniqueID 37830 +Comment VMusage 33139 40031 +FontName Bookman-LightItalic +FullName ITC Bookman Light Italic +FamilyName ITC Bookman +Weight Light +ItalicAngle -10 +IsFixedPitch false +FontBBox -228 -250 1269 883 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.004 +Notice Copyright (c) 1985, 1987, 1989, 1992 Adobe Systems Incorporated. All Rights Reserved.ITC Bookman is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 494 +Ascender 717 +Descender -212 +StartCharMetrics 228 +C 32 ; WX 300 ; N space ; B 0 0 0 0 ; +C 33 ; WX 320 ; N exclam ; B 103 -8 342 698 ; +C 34 ; WX 360 ; N quotedbl ; B 107 468 402 698 ; +C 35 ; WX 620 ; N numbersign ; B 107 0 598 681 ; +C 36 ; WX 620 ; N dollar ; B 78 -85 619 762 ; +C 37 ; WX 800 ; N percent ; B 56 -8 811 691 ; +C 38 ; WX 820 ; N ampersand ; B 65 -18 848 698 ; +C 39 ; WX 280 ; N quoteright ; B 148 470 288 698 ; +C 40 ; WX 280 ; N parenleft ; B 96 -146 383 727 ; +C 41 ; WX 280 ; N parenright ; B -8 -146 279 727 ; +C 42 ; WX 440 ; N asterisk ; B 139 324 505 698 ; +C 43 ; WX 600 ; N plus ; B 91 43 595 548 ; +C 44 ; WX 300 ; N comma ; B 88 -115 227 112 ; +C 45 ; WX 320 ; N hyphen ; B 78 269 336 325 ; +C 46 ; WX 300 ; N period ; B 96 -8 231 127 ; +C 47 ; WX 600 ; N slash ; B 104 -149 562 717 ; +C 48 ; WX 620 ; N zero ; B 86 -17 646 698 ; +C 49 ; WX 620 ; N one ; B 154 0 500 681 ; +C 50 ; WX 620 ; N two ; B 66 0 636 698 ; +C 51 ; WX 620 ; N three ; B 55 -17 622 698 ; +C 52 ; WX 620 ; N four ; B 69 0 634 681 ; +C 53 ; WX 620 ; N five ; B 70 -17 614 681 ; +C 54 ; WX 620 ; N six ; B 89 -17 657 698 ; +C 55 ; WX 620 ; N seven ; B 143 0 672 681 ; +C 56 ; WX 620 ; N eight ; B 61 -17 655 698 ; +C 57 ; WX 620 ; N nine ; B 77 -17 649 698 ; +C 58 ; WX 300 ; N colon ; B 96 -8 292 494 ; +C 59 ; WX 300 ; N semicolon ; B 88 -114 292 494 ; +C 60 ; WX 600 ; N less ; B 79 33 588 561 ; +C 61 ; WX 600 ; N equal ; B 91 161 595 433 ; +C 62 ; WX 600 ; N greater ; B 93 33 602 561 ; +C 63 ; WX 540 ; N question ; B 114 -8 604 698 ; +C 64 ; WX 780 ; N at ; B 102 -17 802 698 ; +C 65 ; WX 700 ; N A ; B -25 0 720 681 ; +C 66 ; WX 720 ; N B ; B 21 0 746 681 ; +C 67 ; WX 720 ; N C ; B 88 -17 746 698 ; +C 68 ; WX 740 ; N D ; B 21 0 782 681 ; +C 69 ; WX 680 ; N E ; B 21 0 736 681 ; +C 70 ; WX 620 ; N F ; B 21 0 743 681 ; +C 71 ; WX 760 ; N G ; B 88 -17 813 698 ; +C 72 ; WX 800 ; N H ; B 21 0 888 681 ; +C 73 ; WX 320 ; N I ; B 21 0 412 681 ; +C 74 ; WX 560 ; N J ; B -2 -17 666 681 ; +C 75 ; WX 720 ; N K ; B 21 0 804 681 ; +C 76 ; WX 580 ; N L ; B 21 0 656 681 ; +C 77 ; WX 860 ; N M ; B 18 0 956 681 ; +C 78 ; WX 720 ; N N ; B 18 0 823 681 ; +C 79 ; WX 760 ; N O ; B 88 -17 799 698 ; +C 80 ; WX 600 ; N P ; B 21 0 681 681 ; +C 81 ; WX 780 ; N Q ; B 61 -191 812 698 ; +C 82 ; WX 700 ; N R ; B 21 0 736 681 ; +C 83 ; WX 640 ; N S ; B 61 -17 668 698 ; +C 84 ; WX 600 ; N T ; B 50 0 725 681 ; +C 85 ; WX 720 ; N U ; B 118 -17 842 681 ; +C 86 ; WX 680 ; N V ; B 87 0 815 681 ; +C 87 ; WX 960 ; N W ; B 87 0 1095 681 ; +C 88 ; WX 700 ; N X ; B -25 0 815 681 ; +C 89 ; WX 660 ; N Y ; B 87 0 809 681 ; +C 90 ; WX 580 ; N Z ; B 8 0 695 681 ; +C 91 ; WX 260 ; N bracketleft ; B 56 -136 351 717 ; +C 92 ; WX 600 ; N backslash ; B 84 0 542 717 ; +C 93 ; WX 260 ; N bracketright ; B 15 -136 309 717 ; +C 94 ; WX 600 ; N asciicircum ; B 97 276 599 681 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 280 ; N quoteleft ; B 191 470 330 698 ; +C 97 ; WX 620 ; N a ; B 71 -8 686 494 ; +C 98 ; WX 600 ; N b ; B 88 -8 621 717 ; +C 99 ; WX 480 ; N c ; B 65 -8 522 494 ; +C 100 ; WX 640 ; N d ; B 65 -8 695 717 ; +C 101 ; WX 540 ; N e ; B 65 -8 575 494 ; +C 102 ; WX 340 ; N f ; B -160 -218 557 725 ; L i fi ; L l fl ; +C 103 ; WX 560 ; N g ; B 4 -221 581 494 ; +C 104 ; WX 620 ; N h ; B 88 -8 689 717 ; +C 105 ; WX 280 ; N i ; B 88 -8 351 663 ; +C 106 ; WX 280 ; N j ; B -200 -221 308 663 ; +C 107 ; WX 600 ; N k ; B 88 -8 657 717 ; +C 108 ; WX 280 ; N l ; B 100 -8 342 717 ; +C 109 ; WX 880 ; N m ; B 88 -8 952 494 ; +C 110 ; WX 620 ; N n ; B 88 -8 673 494 ; +C 111 ; WX 540 ; N o ; B 65 -8 572 494 ; +C 112 ; WX 600 ; N p ; B -24 -212 620 494 ; +C 113 ; WX 560 ; N q ; B 65 -212 584 494 ; +C 114 ; WX 400 ; N r ; B 88 0 481 494 ; +C 115 ; WX 540 ; N s ; B 65 -8 547 494 ; +C 116 ; WX 340 ; N t ; B 88 -8 411 664 ; +C 117 ; WX 620 ; N u ; B 88 -8 686 484 ; +C 118 ; WX 540 ; N v ; B 88 -8 562 494 ; +C 119 ; WX 880 ; N w ; B 88 -8 893 494 ; +C 120 ; WX 540 ; N x ; B 9 -8 626 494 ; +C 121 ; WX 600 ; N y ; B 60 -221 609 484 ; +C 122 ; WX 520 ; N z ; B 38 -8 561 494 ; +C 123 ; WX 360 ; N braceleft ; B 122 -191 442 717 ; +C 124 ; WX 600 ; N bar ; B 294 -250 372 750 ; +C 125 ; WX 380 ; N braceright ; B 13 -191 333 717 ; +C 126 ; WX 600 ; N asciitilde ; B 91 207 595 386 ; +C 161 ; WX 320 ; N exclamdown ; B 73 -213 301 494 ; +C 162 ; WX 620 ; N cent ; B 148 -29 596 715 ; +C 163 ; WX 620 ; N sterling ; B 4 -17 702 698 ; +C 164 ; WX 20 ; N fraction ; B -228 0 323 681 ; +C 165 ; WX 620 ; N yen ; B 71 0 735 681 ; +C 166 ; WX 620 ; N florin ; B -26 -218 692 725 ; +C 167 ; WX 620 ; N section ; B 38 -178 638 698 ; +C 168 ; WX 620 ; N currency ; B 100 89 605 591 ; +C 169 ; WX 200 ; N quotesingle ; B 99 473 247 698 ; +C 170 ; WX 440 ; N quotedblleft ; B 191 470 493 698 ; +C 171 ; WX 300 ; N guillemotleft ; B 70 129 313 434 ; +C 172 ; WX 180 ; N guilsinglleft ; B 75 129 208 434 ; +C 173 ; WX 180 ; N guilsinglright ; B 70 129 203 434 ; +C 174 ; WX 640 ; N fi ; B -159 -222 709 725 ; +C 175 ; WX 660 ; N fl ; B -159 -218 713 725 ; +C 177 ; WX 500 ; N endash ; B 33 269 561 325 ; +C 178 ; WX 620 ; N dagger ; B 192 -130 570 698 ; +C 179 ; WX 620 ; N daggerdbl ; B 144 -122 566 698 ; +C 180 ; WX 300 ; N periodcentered ; B 137 229 272 364 ; +C 182 ; WX 620 ; N paragraph ; B 112 0 718 681 ; +C 183 ; WX 460 ; N bullet ; B 100 170 444 511 ; +C 184 ; WX 320 ; N quotesinglbase ; B 87 -114 226 113 ; +C 185 ; WX 480 ; N quotedblbase ; B 87 -114 390 113 ; +C 186 ; WX 440 ; N quotedblright ; B 148 470 451 698 ; +C 187 ; WX 300 ; N guillemotright ; B 60 129 303 434 ; +C 188 ; WX 1000 ; N ellipsis ; B 99 -8 900 127 ; +C 189 ; WX 1180 ; N perthousand ; B 56 -8 1199 691 ; +C 191 ; WX 540 ; N questiondown ; B 18 -212 508 494 ; +C 193 ; WX 340 ; N grave ; B 182 551 377 706 ; +C 194 ; WX 320 ; N acute ; B 178 551 373 706 ; +C 195 ; WX 440 ; N circumflex ; B 176 571 479 685 ; +C 196 ; WX 440 ; N tilde ; B 180 586 488 671 ; +C 197 ; WX 440 ; N macron ; B 178 599 484 658 ; +C 198 ; WX 440 ; N breve ; B 191 577 500 680 ; +C 199 ; WX 260 ; N dotaccent ; B 169 543 290 664 ; +C 200 ; WX 420 ; N dieresis ; B 185 569 467 688 ; +C 202 ; WX 300 ; N ring ; B 178 551 334 706 ; +C 203 ; WX 320 ; N cedilla ; B 45 -178 240 0 ; +C 205 ; WX 340 ; N hungarumlaut ; B 167 547 402 738 ; +C 206 ; WX 260 ; N ogonek ; B 51 -173 184 0 ; +C 207 ; WX 440 ; N caron ; B 178 571 481 684 ; +C 208 ; WX 1000 ; N emdash ; B 33 269 1061 325 ; +C 225 ; WX 1220 ; N AE ; B -45 0 1269 681 ; +C 227 ; WX 440 ; N ordfeminine ; B 130 396 513 698 ; +C 232 ; WX 580 ; N Lslash ; B 21 0 656 681 ; +C 233 ; WX 760 ; N Oslash ; B 88 -95 799 777 ; +C 234 ; WX 1180 ; N OE ; B 88 -17 1237 698 ; +C 235 ; WX 400 ; N ordmasculine ; B 139 396 455 698 ; +C 241 ; WX 880 ; N ae ; B 71 -8 918 494 ; +C 245 ; WX 280 ; N dotlessi ; B 88 -8 351 484 ; +C 248 ; WX 340 ; N lslash ; B 50 -8 398 717 ; +C 249 ; WX 540 ; N oslash ; B 65 -49 571 532 ; +C 250 ; WX 900 ; N oe ; B 65 -8 948 494 ; +C 251 ; WX 620 ; N germandbls ; B -121 -111 653 698 ; +C -1 ; WX 540 ; N ecircumflex ; B 65 -8 575 685 ; +C -1 ; WX 540 ; N edieresis ; B 65 -8 575 688 ; +C -1 ; WX 620 ; N aacute ; B 71 -8 686 706 ; +C -1 ; WX 740 ; N registered ; B 84 -17 784 698 ; +C -1 ; WX 280 ; N icircumflex ; B 76 -8 379 685 ; +C -1 ; WX 620 ; N udieresis ; B 88 -8 686 688 ; +C -1 ; WX 540 ; N ograve ; B 65 -8 572 706 ; +C -1 ; WX 620 ; N uacute ; B 88 -8 686 706 ; +C -1 ; WX 620 ; N ucircumflex ; B 88 -8 686 685 ; +C -1 ; WX 700 ; N Aacute ; B -25 0 720 883 ; +C -1 ; WX 280 ; N igrave ; B 88 -8 351 706 ; +C -1 ; WX 320 ; N Icircumflex ; B 21 0 449 862 ; +C -1 ; WX 480 ; N ccedilla ; B 65 -178 522 494 ; +C -1 ; WX 620 ; N adieresis ; B 71 -8 686 688 ; +C -1 ; WX 680 ; N Ecircumflex ; B 21 0 736 862 ; +C -1 ; WX 540 ; N scaron ; B 65 -8 547 684 ; +C -1 ; WX 600 ; N thorn ; B -24 -212 620 717 ; +C -1 ; WX 980 ; N trademark ; B 69 277 965 681 ; +C -1 ; WX 540 ; N egrave ; B 65 -8 575 706 ; +C -1 ; WX 372 ; N threesuperior ; B 70 269 439 698 ; +C -1 ; WX 520 ; N zcaron ; B 38 -8 561 684 ; +C -1 ; WX 620 ; N atilde ; B 71 -8 686 671 ; +C -1 ; WX 620 ; N aring ; B 71 -8 686 706 ; +C -1 ; WX 540 ; N ocircumflex ; B 65 -8 572 685 ; +C -1 ; WX 680 ; N Edieresis ; B 21 0 736 865 ; +C -1 ; WX 930 ; N threequarters ; B 99 0 913 691 ; +C -1 ; WX 600 ; N ydieresis ; B 60 -221 609 688 ; +C -1 ; WX 600 ; N yacute ; B 60 -221 609 706 ; +C -1 ; WX 280 ; N iacute ; B 88 -8 351 706 ; +C -1 ; WX 700 ; N Acircumflex ; B -25 0 720 862 ; +C -1 ; WX 720 ; N Uacute ; B 118 -17 842 883 ; +C -1 ; WX 540 ; N eacute ; B 65 -8 575 706 ; +C -1 ; WX 760 ; N Ograve ; B 88 -17 799 883 ; +C -1 ; WX 620 ; N agrave ; B 71 -8 686 706 ; +C -1 ; WX 720 ; N Udieresis ; B 118 -17 842 865 ; +C -1 ; WX 620 ; N acircumflex ; B 71 -8 686 685 ; +C -1 ; WX 320 ; N Igrave ; B 21 0 412 883 ; +C -1 ; WX 372 ; N twosuperior ; B 68 279 439 698 ; +C -1 ; WX 720 ; N Ugrave ; B 118 -17 842 883 ; +C -1 ; WX 930 ; N onequarter ; B 91 0 913 681 ; +C -1 ; WX 720 ; N Ucircumflex ; B 118 -17 842 862 ; +C -1 ; WX 640 ; N Scaron ; B 61 -17 668 861 ; +C -1 ; WX 320 ; N Idieresis ; B 21 0 447 865 ; +C -1 ; WX 280 ; N idieresis ; B 88 -8 377 688 ; +C -1 ; WX 680 ; N Egrave ; B 21 0 736 883 ; +C -1 ; WX 760 ; N Oacute ; B 88 -17 799 883 ; +C -1 ; WX 600 ; N divide ; B 91 46 595 548 ; +C -1 ; WX 700 ; N Atilde ; B -25 0 720 848 ; +C -1 ; WX 700 ; N Aring ; B -25 0 720 883 ; +C -1 ; WX 760 ; N Odieresis ; B 88 -17 799 865 ; +C -1 ; WX 700 ; N Adieresis ; B -25 0 720 865 ; +C -1 ; WX 720 ; N Ntilde ; B 18 0 823 848 ; +C -1 ; WX 580 ; N Zcaron ; B 8 0 695 861 ; +C -1 ; WX 600 ; N Thorn ; B 21 0 656 681 ; +C -1 ; WX 320 ; N Iacute ; B 21 0 412 883 ; +C -1 ; WX 600 ; N plusminus ; B 91 0 595 548 ; +C -1 ; WX 600 ; N multiply ; B 91 44 595 548 ; +C -1 ; WX 680 ; N Eacute ; B 21 0 736 883 ; +C -1 ; WX 660 ; N Ydieresis ; B 87 0 809 865 ; +C -1 ; WX 372 ; N onesuperior ; B 114 279 339 688 ; +C -1 ; WX 620 ; N ugrave ; B 88 -8 686 706 ; +C -1 ; WX 600 ; N logicalnot ; B 91 163 595 433 ; +C -1 ; WX 620 ; N ntilde ; B 88 -8 673 671 ; +C -1 ; WX 760 ; N Otilde ; B 88 -17 799 848 ; +C -1 ; WX 540 ; N otilde ; B 65 -8 572 671 ; +C -1 ; WX 720 ; N Ccedilla ; B 88 -178 746 698 ; +C -1 ; WX 700 ; N Agrave ; B -25 0 720 883 ; +C -1 ; WX 930 ; N onehalf ; B 91 0 925 681 ; +C -1 ; WX 740 ; N Eth ; B 21 0 782 681 ; +C -1 ; WX 400 ; N degree ; B 120 398 420 698 ; +C -1 ; WX 660 ; N Yacute ; B 87 0 809 883 ; +C -1 ; WX 760 ; N Ocircumflex ; B 88 -17 799 862 ; +C -1 ; WX 540 ; N oacute ; B 65 -8 572 706 ; +C -1 ; WX 620 ; N mu ; B 53 -221 686 484 ; +C -1 ; WX 600 ; N minus ; B 91 259 595 335 ; +C -1 ; WX 540 ; N eth ; B 65 -8 642 725 ; +C -1 ; WX 540 ; N odieresis ; B 65 -8 572 688 ; +C -1 ; WX 740 ; N copyright ; B 84 -17 784 698 ; +C -1 ; WX 600 ; N brokenbar ; B 294 -175 372 675 ; +EndCharMetrics +StartKernData +StartKernPairs 85 + +KPX A Y -62 +KPX A W -73 +KPX A V -78 +KPX A T -5 + +KPX F period -97 +KPX F comma -98 +KPX F A -16 + +KPX L y 20 +KPX L Y 7 +KPX L W 9 +KPX L V 4 + +KPX P period -105 +KPX P comma -106 +KPX P A -30 + +KPX R Y 11 +KPX R W 2 +KPX R V 2 +KPX R T 65 + +KPX T semicolon 48 +KPX T s -7 +KPX T r 67 +KPX T period -78 +KPX T o 14 +KPX T i 71 +KPX T hyphen 20 +KPX T e 10 +KPX T comma -79 +KPX T colon 48 +KPX T c 16 +KPX T a 9 +KPX T A -14 + +KPX V y -14 +KPX V u -10 +KPX V semicolon -44 +KPX V r -20 +KPX V period -100 +KPX V o -70 +KPX V i 3 +KPX V hyphen 20 +KPX V e -70 +KPX V comma -109 +KPX V colon -35 +KPX V a -70 +KPX V A -70 + +KPX W y -14 +KPX W u -20 +KPX W semicolon -42 +KPX W r -30 +KPX W period -100 +KPX W o -60 +KPX W i 3 +KPX W hyphen 20 +KPX W e -60 +KPX W comma -109 +KPX W colon -35 +KPX W a -60 +KPX W A -60 + +KPX Y v -19 +KPX Y u -31 +KPX Y semicolon -40 +KPX Y q -72 +KPX Y period -100 +KPX Y p -37 +KPX Y o -75 +KPX Y i -11 +KPX Y hyphen 20 +KPX Y e -78 +KPX Y comma -109 +KPX Y colon -35 +KPX Y a -79 +KPX Y A -82 + +KPX f f -19 + +KPX r q -14 +KPX r period -134 +KPX r o -10 +KPX r n 38 +KPX r m 37 +KPX r hyphen 20 +KPX r h -20 +KPX r g -3 +KPX r f -9 +KPX r e -15 +KPX r d -9 +KPX r comma -143 +KPX r c -8 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 200 177 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 130 177 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 140 177 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 160 177 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 220 177 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 130 177 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 210 177 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 140 177 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 150 177 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 150 177 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 30 177 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -30 177 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -20 177 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -30 177 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 130 177 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 250 177 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 190 177 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 200 177 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 210 177 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 190 177 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 100 177 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 230 177 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 170 177 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 180 177 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 170 177 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 200 177 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 140 177 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 70 177 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 120 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 70 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 80 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 110 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 140 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 60 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 90 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 30 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 40 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 80 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -40 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -100 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -90 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -60 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 60 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 80 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 20 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 40 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 80 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 30 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 30 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 120 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 60 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 70 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 110 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 140 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 70 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 20 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrb8a.afm new file mode 100644 index 00000000..baf3a515 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrb8a.afm @@ -0,0 +1,344 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1990, 1991, Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Tue Sep 17 14:02:41 1991 +Comment UniqueID 36384 +Comment VMusage 31992 40360 +FontName Courier-Bold +FullName Courier Bold +FamilyName Courier +Weight Bold +ItalicAngle 0 +IsFixedPitch true +FontBBox -113 -250 749 801 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.004 +Notice Copyright (c) 1989, 1990, 1991, Adobe Systems Incorporated. All rights reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 439 +Ascender 626 +Descender -142 +StartCharMetrics 260 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 202 -15 398 572 ; +C 34 ; WX 600 ; N quotedbl ; B 135 277 465 562 ; +C 35 ; WX 600 ; N numbersign ; B 56 -45 544 651 ; +C 36 ; WX 600 ; N dollar ; B 82 -126 519 666 ; +C 37 ; WX 600 ; N percent ; B 5 -15 595 616 ; +C 38 ; WX 600 ; N ampersand ; B 36 -15 546 543 ; +C 39 ; WX 600 ; N quoteright ; B 171 277 423 562 ; +C 40 ; WX 600 ; N parenleft ; B 219 -102 461 616 ; +C 41 ; WX 600 ; N parenright ; B 139 -102 381 616 ; +C 42 ; WX 600 ; N asterisk ; B 91 219 509 601 ; +C 43 ; WX 600 ; N plus ; B 71 39 529 478 ; +C 44 ; WX 600 ; N comma ; B 123 -111 393 174 ; +C 45 ; WX 600 ; N hyphen ; B 100 203 500 313 ; +C 46 ; WX 600 ; N period ; B 192 -15 408 171 ; +C 47 ; WX 600 ; N slash ; B 98 -77 502 626 ; +C 48 ; WX 600 ; N zero ; B 87 -15 513 616 ; +C 49 ; WX 600 ; N one ; B 81 0 539 616 ; +C 50 ; WX 600 ; N two ; B 61 0 499 616 ; +C 51 ; WX 600 ; N three ; B 63 -15 501 616 ; +C 52 ; WX 600 ; N four ; B 53 0 507 616 ; +C 53 ; WX 600 ; N five ; B 70 -15 521 601 ; +C 54 ; WX 600 ; N six ; B 90 -15 521 616 ; +C 55 ; WX 600 ; N seven ; B 55 0 494 601 ; +C 56 ; WX 600 ; N eight ; B 83 -15 517 616 ; +C 57 ; WX 600 ; N nine ; B 79 -15 510 616 ; +C 58 ; WX 600 ; N colon ; B 191 -15 407 425 ; +C 59 ; WX 600 ; N semicolon ; B 123 -111 408 425 ; +C 60 ; WX 600 ; N less ; B 66 15 523 501 ; +C 61 ; WX 600 ; N equal ; B 71 118 529 398 ; +C 62 ; WX 600 ; N greater ; B 77 15 534 501 ; +C 63 ; WX 600 ; N question ; B 98 -14 501 580 ; +C 64 ; WX 600 ; N at ; B 16 -15 584 616 ; +C 65 ; WX 600 ; N A ; B -9 0 609 562 ; +C 66 ; WX 600 ; N B ; B 30 0 573 562 ; +C 67 ; WX 600 ; N C ; B 22 -18 560 580 ; +C 68 ; WX 600 ; N D ; B 30 0 594 562 ; +C 69 ; WX 600 ; N E ; B 25 0 560 562 ; +C 70 ; WX 600 ; N F ; B 39 0 570 562 ; +C 71 ; WX 600 ; N G ; B 22 -18 594 580 ; +C 72 ; WX 600 ; N H ; B 20 0 580 562 ; +C 73 ; WX 600 ; N I ; B 77 0 523 562 ; +C 74 ; WX 600 ; N J ; B 37 -18 601 562 ; +C 75 ; WX 600 ; N K ; B 21 0 599 562 ; +C 76 ; WX 600 ; N L ; B 39 0 578 562 ; +C 77 ; WX 600 ; N M ; B -2 0 602 562 ; +C 78 ; WX 600 ; N N ; B 8 -12 610 562 ; +C 79 ; WX 600 ; N O ; B 22 -18 578 580 ; +C 80 ; WX 600 ; N P ; B 48 0 559 562 ; +C 81 ; WX 600 ; N Q ; B 32 -138 578 580 ; +C 82 ; WX 600 ; N R ; B 24 0 599 562 ; +C 83 ; WX 600 ; N S ; B 47 -22 553 582 ; +C 84 ; WX 600 ; N T ; B 21 0 579 562 ; +C 85 ; WX 600 ; N U ; B 4 -18 596 562 ; +C 86 ; WX 600 ; N V ; B -13 0 613 562 ; +C 87 ; WX 600 ; N W ; B -18 0 618 562 ; +C 88 ; WX 600 ; N X ; B 12 0 588 562 ; +C 89 ; WX 600 ; N Y ; B 12 0 589 562 ; +C 90 ; WX 600 ; N Z ; B 62 0 539 562 ; +C 91 ; WX 600 ; N bracketleft ; B 245 -102 475 616 ; +C 92 ; WX 600 ; N backslash ; B 99 -77 503 626 ; +C 93 ; WX 600 ; N bracketright ; B 125 -102 355 616 ; +C 94 ; WX 600 ; N asciicircum ; B 108 250 492 616 ; +C 95 ; WX 600 ; N underscore ; B 0 -125 600 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 178 277 428 562 ; +C 97 ; WX 600 ; N a ; B 35 -15 570 454 ; +C 98 ; WX 600 ; N b ; B 0 -15 584 626 ; +C 99 ; WX 600 ; N c ; B 40 -15 545 459 ; +C 100 ; WX 600 ; N d ; B 20 -15 591 626 ; +C 101 ; WX 600 ; N e ; B 40 -15 563 454 ; +C 102 ; WX 600 ; N f ; B 83 0 547 626 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 30 -146 580 454 ; +C 104 ; WX 600 ; N h ; B 5 0 592 626 ; +C 105 ; WX 600 ; N i ; B 77 0 523 658 ; +C 106 ; WX 600 ; N j ; B 63 -146 440 658 ; +C 107 ; WX 600 ; N k ; B 20 0 585 626 ; +C 108 ; WX 600 ; N l ; B 77 0 523 626 ; +C 109 ; WX 600 ; N m ; B -22 0 626 454 ; +C 110 ; WX 600 ; N n ; B 18 0 592 454 ; +C 111 ; WX 600 ; N o ; B 30 -15 570 454 ; +C 112 ; WX 600 ; N p ; B -1 -142 570 454 ; +C 113 ; WX 600 ; N q ; B 20 -142 591 454 ; +C 114 ; WX 600 ; N r ; B 47 0 580 454 ; +C 115 ; WX 600 ; N s ; B 68 -17 535 459 ; +C 116 ; WX 600 ; N t ; B 47 -15 532 562 ; +C 117 ; WX 600 ; N u ; B -1 -15 569 439 ; +C 118 ; WX 600 ; N v ; B -1 0 601 439 ; +C 119 ; WX 600 ; N w ; B -18 0 618 439 ; +C 120 ; WX 600 ; N x ; B 6 0 594 439 ; +C 121 ; WX 600 ; N y ; B -4 -142 601 439 ; +C 122 ; WX 600 ; N z ; B 81 0 520 439 ; +C 123 ; WX 600 ; N braceleft ; B 160 -102 464 616 ; +C 124 ; WX 600 ; N bar ; B 255 -250 345 750 ; +C 125 ; WX 600 ; N braceright ; B 136 -102 440 616 ; +C 126 ; WX 600 ; N asciitilde ; B 71 153 530 356 ; +C 161 ; WX 600 ; N exclamdown ; B 202 -146 398 449 ; +C 162 ; WX 600 ; N cent ; B 66 -49 518 614 ; +C 163 ; WX 600 ; N sterling ; B 72 -28 558 611 ; +C 164 ; WX 600 ; N fraction ; B 25 -60 576 661 ; +C 165 ; WX 600 ; N yen ; B 10 0 590 562 ; +C 166 ; WX 600 ; N florin ; B -30 -131 572 616 ; +C 167 ; WX 600 ; N section ; B 83 -70 517 580 ; +C 168 ; WX 600 ; N currency ; B 54 49 546 517 ; +C 169 ; WX 600 ; N quotesingle ; B 227 277 373 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 71 277 535 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 8 70 553 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 141 70 459 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 141 70 459 446 ; +C 174 ; WX 600 ; N fi ; B 12 0 593 626 ; +C 175 ; WX 600 ; N fl ; B 12 0 593 626 ; +C 177 ; WX 600 ; N endash ; B 65 203 535 313 ; +C 178 ; WX 600 ; N dagger ; B 106 -70 494 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 106 -70 494 580 ; +C 180 ; WX 600 ; N periodcentered ; B 196 165 404 351 ; +C 182 ; WX 600 ; N paragraph ; B 6 -70 576 580 ; +C 183 ; WX 600 ; N bullet ; B 140 132 460 430 ; +C 184 ; WX 600 ; N quotesinglbase ; B 175 -142 427 143 ; +C 185 ; WX 600 ; N quotedblbase ; B 65 -142 529 143 ; +C 186 ; WX 600 ; N quotedblright ; B 61 277 525 562 ; +C 187 ; WX 600 ; N guillemotright ; B 47 70 592 446 ; +C 188 ; WX 600 ; N ellipsis ; B 26 -15 574 116 ; +C 189 ; WX 600 ; N perthousand ; B -113 -15 713 616 ; +C 191 ; WX 600 ; N questiondown ; B 99 -146 502 449 ; +C 193 ; WX 600 ; N grave ; B 132 508 395 661 ; +C 194 ; WX 600 ; N acute ; B 205 508 468 661 ; +C 195 ; WX 600 ; N circumflex ; B 103 483 497 657 ; +C 196 ; WX 600 ; N tilde ; B 89 493 512 636 ; +C 197 ; WX 600 ; N macron ; B 88 505 512 585 ; +C 198 ; WX 600 ; N breve ; B 83 468 517 631 ; +C 199 ; WX 600 ; N dotaccent ; B 230 485 370 625 ; +C 200 ; WX 600 ; N dieresis ; B 128 485 472 625 ; +C 202 ; WX 600 ; N ring ; B 198 481 402 678 ; +C 203 ; WX 600 ; N cedilla ; B 205 -206 387 0 ; +C 205 ; WX 600 ; N hungarumlaut ; B 68 488 588 661 ; +C 206 ; WX 600 ; N ogonek ; B 169 -199 367 0 ; +C 207 ; WX 600 ; N caron ; B 103 493 497 667 ; +C 208 ; WX 600 ; N emdash ; B -10 203 610 313 ; +C 225 ; WX 600 ; N AE ; B -29 0 602 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 147 196 453 580 ; +C 232 ; WX 600 ; N Lslash ; B 39 0 578 562 ; +C 233 ; WX 600 ; N Oslash ; B 22 -22 578 584 ; +C 234 ; WX 600 ; N OE ; B -25 0 595 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 147 196 453 580 ; +C 241 ; WX 600 ; N ae ; B -4 -15 601 454 ; +C 245 ; WX 600 ; N dotlessi ; B 77 0 523 439 ; +C 248 ; WX 600 ; N lslash ; B 77 0 523 626 ; +C 249 ; WX 600 ; N oslash ; B 30 -24 570 463 ; +C 250 ; WX 600 ; N oe ; B -18 -15 611 454 ; +C 251 ; WX 600 ; N germandbls ; B 22 -15 596 626 ; +C -1 ; WX 600 ; N Odieresis ; B 22 -18 578 748 ; +C -1 ; WX 600 ; N logicalnot ; B 71 103 529 413 ; +C -1 ; WX 600 ; N minus ; B 71 203 529 313 ; +C -1 ; WX 600 ; N merge ; B 137 -15 464 487 ; +C -1 ; WX 600 ; N degree ; B 86 243 474 616 ; +C -1 ; WX 600 ; N dectab ; B 8 0 592 320 ; +C -1 ; WX 600 ; N ll ; B -12 0 600 626 ; +C -1 ; WX 600 ; N IJ ; B -8 -18 622 562 ; +C -1 ; WX 600 ; N Eacute ; B 25 0 560 784 ; +C -1 ; WX 600 ; N Ocircumflex ; B 22 -18 578 780 ; +C -1 ; WX 600 ; N ucircumflex ; B -1 -15 569 657 ; +C -1 ; WX 600 ; N left ; B 65 44 535 371 ; +C -1 ; WX 600 ; N threesuperior ; B 138 222 433 616 ; +C -1 ; WX 600 ; N up ; B 136 0 463 447 ; +C -1 ; WX 600 ; N multiply ; B 81 39 520 478 ; +C -1 ; WX 600 ; N Scaron ; B 47 -22 553 790 ; +C -1 ; WX 600 ; N tab ; B 19 0 581 562 ; +C -1 ; WX 600 ; N Ucircumflex ; B 4 -18 596 780 ; +C -1 ; WX 600 ; N divide ; B 71 16 529 500 ; +C -1 ; WX 600 ; N Acircumflex ; B -9 0 609 780 ; +C -1 ; WX 600 ; N eacute ; B 40 -15 563 661 ; +C -1 ; WX 600 ; N uacute ; B -1 -15 569 661 ; +C -1 ; WX 600 ; N Aacute ; B -9 0 609 784 ; +C -1 ; WX 600 ; N copyright ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N twosuperior ; B 143 230 436 616 ; +C -1 ; WX 600 ; N Ecircumflex ; B 25 0 560 780 ; +C -1 ; WX 600 ; N ntilde ; B 18 0 592 636 ; +C -1 ; WX 600 ; N down ; B 137 -15 464 439 ; +C -1 ; WX 600 ; N center ; B 40 14 560 580 ; +C -1 ; WX 600 ; N onesuperior ; B 153 230 447 616 ; +C -1 ; WX 600 ; N ij ; B 6 -146 574 658 ; +C -1 ; WX 600 ; N edieresis ; B 40 -15 563 625 ; +C -1 ; WX 600 ; N graybox ; B 76 0 525 599 ; +C -1 ; WX 600 ; N odieresis ; B 30 -15 570 625 ; +C -1 ; WX 600 ; N Ograve ; B 22 -18 578 784 ; +C -1 ; WX 600 ; N threequarters ; B -47 -60 648 661 ; +C -1 ; WX 600 ; N plusminus ; B 71 24 529 515 ; +C -1 ; WX 600 ; N prescription ; B 24 -15 599 562 ; +C -1 ; WX 600 ; N eth ; B 58 -27 543 626 ; +C -1 ; WX 600 ; N largebullet ; B 248 229 352 333 ; +C -1 ; WX 600 ; N egrave ; B 40 -15 563 661 ; +C -1 ; WX 600 ; N ccedilla ; B 40 -206 545 459 ; +C -1 ; WX 600 ; N notegraphic ; B 77 -15 523 572 ; +C -1 ; WX 600 ; N Udieresis ; B 4 -18 596 748 ; +C -1 ; WX 600 ; N Gcaron ; B 22 -18 594 790 ; +C -1 ; WX 600 ; N arrowdown ; B 144 -15 456 608 ; +C -1 ; WX 600 ; N format ; B 5 -146 115 601 ; +C -1 ; WX 600 ; N Otilde ; B 22 -18 578 759 ; +C -1 ; WX 600 ; N Idieresis ; B 77 0 523 748 ; +C -1 ; WX 600 ; N adieresis ; B 35 -15 570 625 ; +C -1 ; WX 600 ; N ecircumflex ; B 40 -15 563 657 ; +C -1 ; WX 600 ; N Eth ; B 30 0 594 562 ; +C -1 ; WX 600 ; N onequarter ; B -56 -60 656 661 ; +C -1 ; WX 600 ; N LL ; B -45 0 645 562 ; +C -1 ; WX 600 ; N agrave ; B 35 -15 570 661 ; +C -1 ; WX 600 ; N Zcaron ; B 62 0 539 790 ; +C -1 ; WX 600 ; N Scedilla ; B 47 -206 553 582 ; +C -1 ; WX 600 ; N Idot ; B 77 0 523 748 ; +C -1 ; WX 600 ; N Iacute ; B 77 0 523 784 ; +C -1 ; WX 600 ; N indent ; B 65 45 535 372 ; +C -1 ; WX 600 ; N Ugrave ; B 4 -18 596 784 ; +C -1 ; WX 600 ; N scaron ; B 68 -17 535 667 ; +C -1 ; WX 600 ; N overscore ; B 0 579 600 629 ; +C -1 ; WX 600 ; N Aring ; B -9 0 609 801 ; +C -1 ; WX 600 ; N Ccedilla ; B 22 -206 560 580 ; +C -1 ; WX 600 ; N Igrave ; B 77 0 523 784 ; +C -1 ; WX 600 ; N brokenbar ; B 255 -175 345 675 ; +C -1 ; WX 600 ; N Oacute ; B 22 -18 578 784 ; +C -1 ; WX 600 ; N otilde ; B 30 -15 570 636 ; +C -1 ; WX 600 ; N Yacute ; B 12 0 589 784 ; +C -1 ; WX 600 ; N lira ; B 72 -28 558 611 ; +C -1 ; WX 600 ; N Icircumflex ; B 77 0 523 780 ; +C -1 ; WX 600 ; N Atilde ; B -9 0 609 759 ; +C -1 ; WX 600 ; N Uacute ; B 4 -18 596 784 ; +C -1 ; WX 600 ; N Ydieresis ; B 12 0 589 748 ; +C -1 ; WX 600 ; N ydieresis ; B -4 -142 601 625 ; +C -1 ; WX 600 ; N idieresis ; B 77 0 523 625 ; +C -1 ; WX 600 ; N Adieresis ; B -9 0 609 748 ; +C -1 ; WX 600 ; N mu ; B -1 -142 569 439 ; +C -1 ; WX 600 ; N trademark ; B -9 230 749 562 ; +C -1 ; WX 600 ; N oacute ; B 30 -15 570 661 ; +C -1 ; WX 600 ; N acircumflex ; B 35 -15 570 657 ; +C -1 ; WX 600 ; N Agrave ; B -9 0 609 784 ; +C -1 ; WX 600 ; N return ; B 19 0 581 562 ; +C -1 ; WX 600 ; N atilde ; B 35 -15 570 636 ; +C -1 ; WX 600 ; N square ; B 19 0 581 562 ; +C -1 ; WX 600 ; N registered ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N stop ; B 19 0 581 562 ; +C -1 ; WX 600 ; N udieresis ; B -1 -15 569 625 ; +C -1 ; WX 600 ; N arrowup ; B 144 3 456 626 ; +C -1 ; WX 600 ; N igrave ; B 77 0 523 661 ; +C -1 ; WX 600 ; N Edieresis ; B 25 0 560 748 ; +C -1 ; WX 600 ; N zcaron ; B 81 0 520 667 ; +C -1 ; WX 600 ; N arrowboth ; B -24 143 624 455 ; +C -1 ; WX 600 ; N gcaron ; B 30 -146 580 667 ; +C -1 ; WX 600 ; N arrowleft ; B -24 143 634 455 ; +C -1 ; WX 600 ; N aacute ; B 35 -15 570 661 ; +C -1 ; WX 600 ; N ocircumflex ; B 30 -15 570 657 ; +C -1 ; WX 600 ; N scedilla ; B 68 -206 535 459 ; +C -1 ; WX 600 ; N ograve ; B 30 -15 570 661 ; +C -1 ; WX 600 ; N onehalf ; B -47 -60 648 661 ; +C -1 ; WX 600 ; N ugrave ; B -1 -15 569 661 ; +C -1 ; WX 600 ; N Ntilde ; B 8 -12 610 759 ; +C -1 ; WX 600 ; N iacute ; B 77 0 523 661 ; +C -1 ; WX 600 ; N arrowright ; B -34 143 624 455 ; +C -1 ; WX 600 ; N Thorn ; B 48 0 557 562 ; +C -1 ; WX 600 ; N Egrave ; B 25 0 560 784 ; +C -1 ; WX 600 ; N thorn ; B -14 -142 570 626 ; +C -1 ; WX 600 ; N aring ; B 35 -15 570 678 ; +C -1 ; WX 600 ; N yacute ; B -4 -142 601 661 ; +C -1 ; WX 600 ; N icircumflex ; B 63 0 523 657 ; +EndCharMetrics +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 30 123 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex -30 123 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis -20 123 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave -50 123 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring -10 123 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde -30 123 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 30 123 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 0 123 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 0 123 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 0 123 ; +CC Gcaron 2 ; PCC G 0 0 ; PCC caron 10 123 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 0 123 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 0 123 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 0 123 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 0 123 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 0 123 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 0 123 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 0 123 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 0 123 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 0 123 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 0 123 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 0 123 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 30 123 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 0 123 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 0 123 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave -30 123 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 30 123 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 0 123 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 0 123 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 0 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex -20 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis -10 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave -30 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 0 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 0 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 0 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 0 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 0 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 0 0 ; +CC gcaron 2 ; PCC g 0 0 ; PCC caron -40 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -40 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -40 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 0 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 0 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 0 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 0 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 0 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 0 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 0 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 0 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex -20 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis -20 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave -30 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 30 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 10 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 0 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrbo8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrbo8a.afm new file mode 100644 index 00000000..6e2c7422 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrbo8a.afm @@ -0,0 +1,344 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1990, 1991, Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Tue Sep 17 14:13:24 1991 +Comment UniqueID 36389 +Comment VMusage 10055 54684 +FontName Courier-BoldOblique +FullName Courier Bold Oblique +FamilyName Courier +Weight Bold +ItalicAngle -12 +IsFixedPitch true +FontBBox -56 -250 868 801 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.004 +Notice Copyright (c) 1989, 1990, 1991, Adobe Systems Incorporated. All rights reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 439 +Ascender 626 +Descender -142 +StartCharMetrics 260 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 216 -15 495 572 ; +C 34 ; WX 600 ; N quotedbl ; B 212 277 584 562 ; +C 35 ; WX 600 ; N numbersign ; B 88 -45 640 651 ; +C 36 ; WX 600 ; N dollar ; B 87 -126 629 666 ; +C 37 ; WX 600 ; N percent ; B 102 -15 624 616 ; +C 38 ; WX 600 ; N ampersand ; B 62 -15 594 543 ; +C 39 ; WX 600 ; N quoteright ; B 230 277 542 562 ; +C 40 ; WX 600 ; N parenleft ; B 266 -102 592 616 ; +C 41 ; WX 600 ; N parenright ; B 117 -102 444 616 ; +C 42 ; WX 600 ; N asterisk ; B 179 219 597 601 ; +C 43 ; WX 600 ; N plus ; B 114 39 596 478 ; +C 44 ; WX 600 ; N comma ; B 99 -111 430 174 ; +C 45 ; WX 600 ; N hyphen ; B 143 203 567 313 ; +C 46 ; WX 600 ; N period ; B 207 -15 426 171 ; +C 47 ; WX 600 ; N slash ; B 91 -77 626 626 ; +C 48 ; WX 600 ; N zero ; B 136 -15 592 616 ; +C 49 ; WX 600 ; N one ; B 93 0 561 616 ; +C 50 ; WX 600 ; N two ; B 61 0 593 616 ; +C 51 ; WX 600 ; N three ; B 72 -15 571 616 ; +C 52 ; WX 600 ; N four ; B 82 0 558 616 ; +C 53 ; WX 600 ; N five ; B 77 -15 621 601 ; +C 54 ; WX 600 ; N six ; B 136 -15 652 616 ; +C 55 ; WX 600 ; N seven ; B 147 0 622 601 ; +C 56 ; WX 600 ; N eight ; B 115 -15 604 616 ; +C 57 ; WX 600 ; N nine ; B 76 -15 592 616 ; +C 58 ; WX 600 ; N colon ; B 206 -15 479 425 ; +C 59 ; WX 600 ; N semicolon ; B 99 -111 480 425 ; +C 60 ; WX 600 ; N less ; B 121 15 612 501 ; +C 61 ; WX 600 ; N equal ; B 96 118 614 398 ; +C 62 ; WX 600 ; N greater ; B 97 15 589 501 ; +C 63 ; WX 600 ; N question ; B 183 -14 591 580 ; +C 64 ; WX 600 ; N at ; B 66 -15 641 616 ; +C 65 ; WX 600 ; N A ; B -9 0 631 562 ; +C 66 ; WX 600 ; N B ; B 30 0 629 562 ; +C 67 ; WX 600 ; N C ; B 75 -18 674 580 ; +C 68 ; WX 600 ; N D ; B 30 0 664 562 ; +C 69 ; WX 600 ; N E ; B 25 0 669 562 ; +C 70 ; WX 600 ; N F ; B 39 0 683 562 ; +C 71 ; WX 600 ; N G ; B 75 -18 674 580 ; +C 72 ; WX 600 ; N H ; B 20 0 699 562 ; +C 73 ; WX 600 ; N I ; B 77 0 642 562 ; +C 74 ; WX 600 ; N J ; B 59 -18 720 562 ; +C 75 ; WX 600 ; N K ; B 21 0 691 562 ; +C 76 ; WX 600 ; N L ; B 39 0 635 562 ; +C 77 ; WX 600 ; N M ; B -2 0 721 562 ; +C 78 ; WX 600 ; N N ; B 8 -12 729 562 ; +C 79 ; WX 600 ; N O ; B 74 -18 645 580 ; +C 80 ; WX 600 ; N P ; B 48 0 642 562 ; +C 81 ; WX 600 ; N Q ; B 84 -138 636 580 ; +C 82 ; WX 600 ; N R ; B 24 0 617 562 ; +C 83 ; WX 600 ; N S ; B 54 -22 672 582 ; +C 84 ; WX 600 ; N T ; B 86 0 678 562 ; +C 85 ; WX 600 ; N U ; B 101 -18 715 562 ; +C 86 ; WX 600 ; N V ; B 84 0 732 562 ; +C 87 ; WX 600 ; N W ; B 84 0 737 562 ; +C 88 ; WX 600 ; N X ; B 12 0 689 562 ; +C 89 ; WX 600 ; N Y ; B 109 0 708 562 ; +C 90 ; WX 600 ; N Z ; B 62 0 636 562 ; +C 91 ; WX 600 ; N bracketleft ; B 223 -102 606 616 ; +C 92 ; WX 600 ; N backslash ; B 223 -77 496 626 ; +C 93 ; WX 600 ; N bracketright ; B 103 -102 486 616 ; +C 94 ; WX 600 ; N asciicircum ; B 171 250 555 616 ; +C 95 ; WX 600 ; N underscore ; B -27 -125 584 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 297 277 487 562 ; +C 97 ; WX 600 ; N a ; B 62 -15 592 454 ; +C 98 ; WX 600 ; N b ; B 13 -15 636 626 ; +C 99 ; WX 600 ; N c ; B 81 -15 631 459 ; +C 100 ; WX 600 ; N d ; B 61 -15 644 626 ; +C 101 ; WX 600 ; N e ; B 81 -15 604 454 ; +C 102 ; WX 600 ; N f ; B 83 0 677 626 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 41 -146 673 454 ; +C 104 ; WX 600 ; N h ; B 18 0 614 626 ; +C 105 ; WX 600 ; N i ; B 77 0 545 658 ; +C 106 ; WX 600 ; N j ; B 37 -146 580 658 ; +C 107 ; WX 600 ; N k ; B 33 0 642 626 ; +C 108 ; WX 600 ; N l ; B 77 0 545 626 ; +C 109 ; WX 600 ; N m ; B -22 0 648 454 ; +C 110 ; WX 600 ; N n ; B 18 0 614 454 ; +C 111 ; WX 600 ; N o ; B 71 -15 622 454 ; +C 112 ; WX 600 ; N p ; B -31 -142 622 454 ; +C 113 ; WX 600 ; N q ; B 61 -142 684 454 ; +C 114 ; WX 600 ; N r ; B 47 0 654 454 ; +C 115 ; WX 600 ; N s ; B 67 -17 607 459 ; +C 116 ; WX 600 ; N t ; B 118 -15 566 562 ; +C 117 ; WX 600 ; N u ; B 70 -15 591 439 ; +C 118 ; WX 600 ; N v ; B 70 0 694 439 ; +C 119 ; WX 600 ; N w ; B 53 0 711 439 ; +C 120 ; WX 600 ; N x ; B 6 0 670 439 ; +C 121 ; WX 600 ; N y ; B -20 -142 694 439 ; +C 122 ; WX 600 ; N z ; B 81 0 613 439 ; +C 123 ; WX 600 ; N braceleft ; B 204 -102 595 616 ; +C 124 ; WX 600 ; N bar ; B 202 -250 504 750 ; +C 125 ; WX 600 ; N braceright ; B 114 -102 506 616 ; +C 126 ; WX 600 ; N asciitilde ; B 120 153 589 356 ; +C 161 ; WX 600 ; N exclamdown ; B 197 -146 477 449 ; +C 162 ; WX 600 ; N cent ; B 121 -49 604 614 ; +C 163 ; WX 600 ; N sterling ; B 107 -28 650 611 ; +C 164 ; WX 600 ; N fraction ; B 22 -60 707 661 ; +C 165 ; WX 600 ; N yen ; B 98 0 709 562 ; +C 166 ; WX 600 ; N florin ; B -56 -131 701 616 ; +C 167 ; WX 600 ; N section ; B 74 -70 619 580 ; +C 168 ; WX 600 ; N currency ; B 77 49 643 517 ; +C 169 ; WX 600 ; N quotesingle ; B 304 277 492 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 190 277 594 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 63 70 638 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 196 70 544 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 166 70 514 446 ; +C 174 ; WX 600 ; N fi ; B 12 0 643 626 ; +C 175 ; WX 600 ; N fl ; B 12 0 643 626 ; +C 177 ; WX 600 ; N endash ; B 108 203 602 313 ; +C 178 ; WX 600 ; N dagger ; B 176 -70 586 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 122 -70 586 580 ; +C 180 ; WX 600 ; N periodcentered ; B 249 165 461 351 ; +C 182 ; WX 600 ; N paragraph ; B 61 -70 699 580 ; +C 183 ; WX 600 ; N bullet ; B 197 132 523 430 ; +C 184 ; WX 600 ; N quotesinglbase ; B 145 -142 457 143 ; +C 185 ; WX 600 ; N quotedblbase ; B 35 -142 559 143 ; +C 186 ; WX 600 ; N quotedblright ; B 120 277 644 562 ; +C 187 ; WX 600 ; N guillemotright ; B 72 70 647 446 ; +C 188 ; WX 600 ; N ellipsis ; B 35 -15 586 116 ; +C 189 ; WX 600 ; N perthousand ; B -44 -15 742 616 ; +C 191 ; WX 600 ; N questiondown ; B 101 -146 509 449 ; +C 193 ; WX 600 ; N grave ; B 272 508 503 661 ; +C 194 ; WX 600 ; N acute ; B 313 508 608 661 ; +C 195 ; WX 600 ; N circumflex ; B 212 483 606 657 ; +C 196 ; WX 600 ; N tilde ; B 200 493 642 636 ; +C 197 ; WX 600 ; N macron ; B 195 505 636 585 ; +C 198 ; WX 600 ; N breve ; B 217 468 651 631 ; +C 199 ; WX 600 ; N dotaccent ; B 346 485 490 625 ; +C 200 ; WX 600 ; N dieresis ; B 244 485 592 625 ; +C 202 ; WX 600 ; N ring ; B 319 481 528 678 ; +C 203 ; WX 600 ; N cedilla ; B 169 -206 367 0 ; +C 205 ; WX 600 ; N hungarumlaut ; B 172 488 728 661 ; +C 206 ; WX 600 ; N ogonek ; B 144 -199 350 0 ; +C 207 ; WX 600 ; N caron ; B 238 493 632 667 ; +C 208 ; WX 600 ; N emdash ; B 33 203 677 313 ; +C 225 ; WX 600 ; N AE ; B -29 0 707 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 189 196 526 580 ; +C 232 ; WX 600 ; N Lslash ; B 39 0 635 562 ; +C 233 ; WX 600 ; N Oslash ; B 48 -22 672 584 ; +C 234 ; WX 600 ; N OE ; B 26 0 700 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 189 196 542 580 ; +C 241 ; WX 600 ; N ae ; B 21 -15 651 454 ; +C 245 ; WX 600 ; N dotlessi ; B 77 0 545 439 ; +C 248 ; WX 600 ; N lslash ; B 77 0 578 626 ; +C 249 ; WX 600 ; N oslash ; B 55 -24 637 463 ; +C 250 ; WX 600 ; N oe ; B 19 -15 661 454 ; +C 251 ; WX 600 ; N germandbls ; B 22 -15 628 626 ; +C -1 ; WX 600 ; N Odieresis ; B 74 -18 645 748 ; +C -1 ; WX 600 ; N logicalnot ; B 135 103 617 413 ; +C -1 ; WX 600 ; N minus ; B 114 203 596 313 ; +C -1 ; WX 600 ; N merge ; B 168 -15 533 487 ; +C -1 ; WX 600 ; N degree ; B 173 243 569 616 ; +C -1 ; WX 600 ; N dectab ; B 8 0 615 320 ; +C -1 ; WX 600 ; N ll ; B 1 0 653 626 ; +C -1 ; WX 600 ; N IJ ; B -8 -18 741 562 ; +C -1 ; WX 600 ; N Eacute ; B 25 0 669 784 ; +C -1 ; WX 600 ; N Ocircumflex ; B 74 -18 645 780 ; +C -1 ; WX 600 ; N ucircumflex ; B 70 -15 591 657 ; +C -1 ; WX 600 ; N left ; B 109 44 589 371 ; +C -1 ; WX 600 ; N threesuperior ; B 193 222 525 616 ; +C -1 ; WX 600 ; N up ; B 196 0 523 447 ; +C -1 ; WX 600 ; N multiply ; B 105 39 606 478 ; +C -1 ; WX 600 ; N Scaron ; B 54 -22 672 790 ; +C -1 ; WX 600 ; N tab ; B 19 0 641 562 ; +C -1 ; WX 600 ; N Ucircumflex ; B 101 -18 715 780 ; +C -1 ; WX 600 ; N divide ; B 114 16 596 500 ; +C -1 ; WX 600 ; N Acircumflex ; B -9 0 631 780 ; +C -1 ; WX 600 ; N eacute ; B 81 -15 608 661 ; +C -1 ; WX 600 ; N uacute ; B 70 -15 608 661 ; +C -1 ; WX 600 ; N Aacute ; B -9 0 665 784 ; +C -1 ; WX 600 ; N copyright ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N twosuperior ; B 192 230 541 616 ; +C -1 ; WX 600 ; N Ecircumflex ; B 25 0 669 780 ; +C -1 ; WX 600 ; N ntilde ; B 18 0 642 636 ; +C -1 ; WX 600 ; N down ; B 168 -15 496 439 ; +C -1 ; WX 600 ; N center ; B 103 14 623 580 ; +C -1 ; WX 600 ; N onesuperior ; B 213 230 514 616 ; +C -1 ; WX 600 ; N ij ; B 6 -146 714 658 ; +C -1 ; WX 600 ; N edieresis ; B 81 -15 604 625 ; +C -1 ; WX 600 ; N graybox ; B 76 0 652 599 ; +C -1 ; WX 600 ; N odieresis ; B 71 -15 622 625 ; +C -1 ; WX 600 ; N Ograve ; B 74 -18 645 784 ; +C -1 ; WX 600 ; N threequarters ; B 8 -60 698 661 ; +C -1 ; WX 600 ; N plusminus ; B 76 24 614 515 ; +C -1 ; WX 600 ; N prescription ; B 24 -15 632 562 ; +C -1 ; WX 600 ; N eth ; B 93 -27 661 626 ; +C -1 ; WX 600 ; N largebullet ; B 307 229 413 333 ; +C -1 ; WX 600 ; N egrave ; B 81 -15 604 661 ; +C -1 ; WX 600 ; N ccedilla ; B 81 -206 631 459 ; +C -1 ; WX 600 ; N notegraphic ; B 91 -15 619 572 ; +C -1 ; WX 600 ; N Udieresis ; B 101 -18 715 748 ; +C -1 ; WX 600 ; N Gcaron ; B 75 -18 674 790 ; +C -1 ; WX 600 ; N arrowdown ; B 174 -15 486 608 ; +C -1 ; WX 600 ; N format ; B -26 -146 243 601 ; +C -1 ; WX 600 ; N Otilde ; B 74 -18 668 759 ; +C -1 ; WX 600 ; N Idieresis ; B 77 0 642 748 ; +C -1 ; WX 600 ; N adieresis ; B 62 -15 592 625 ; +C -1 ; WX 600 ; N ecircumflex ; B 81 -15 606 657 ; +C -1 ; WX 600 ; N Eth ; B 30 0 664 562 ; +C -1 ; WX 600 ; N onequarter ; B 14 -60 706 661 ; +C -1 ; WX 600 ; N LL ; B -45 0 694 562 ; +C -1 ; WX 600 ; N agrave ; B 62 -15 592 661 ; +C -1 ; WX 600 ; N Zcaron ; B 62 0 659 790 ; +C -1 ; WX 600 ; N Scedilla ; B 54 -206 672 582 ; +C -1 ; WX 600 ; N Idot ; B 77 0 642 748 ; +C -1 ; WX 600 ; N Iacute ; B 77 0 642 784 ; +C -1 ; WX 600 ; N indent ; B 99 45 579 372 ; +C -1 ; WX 600 ; N Ugrave ; B 101 -18 715 784 ; +C -1 ; WX 600 ; N scaron ; B 67 -17 632 667 ; +C -1 ; WX 600 ; N overscore ; B 123 579 734 629 ; +C -1 ; WX 600 ; N Aring ; B -9 0 631 801 ; +C -1 ; WX 600 ; N Ccedilla ; B 74 -206 674 580 ; +C -1 ; WX 600 ; N Igrave ; B 77 0 642 784 ; +C -1 ; WX 600 ; N brokenbar ; B 218 -175 488 675 ; +C -1 ; WX 600 ; N Oacute ; B 74 -18 645 784 ; +C -1 ; WX 600 ; N otilde ; B 71 -15 642 636 ; +C -1 ; WX 600 ; N Yacute ; B 109 0 708 784 ; +C -1 ; WX 600 ; N lira ; B 107 -28 650 611 ; +C -1 ; WX 600 ; N Icircumflex ; B 77 0 642 780 ; +C -1 ; WX 600 ; N Atilde ; B -9 0 638 759 ; +C -1 ; WX 600 ; N Uacute ; B 101 -18 715 784 ; +C -1 ; WX 600 ; N Ydieresis ; B 109 0 708 748 ; +C -1 ; WX 600 ; N ydieresis ; B -20 -142 694 625 ; +C -1 ; WX 600 ; N idieresis ; B 77 0 552 625 ; +C -1 ; WX 600 ; N Adieresis ; B -9 0 631 748 ; +C -1 ; WX 600 ; N mu ; B 50 -142 591 439 ; +C -1 ; WX 600 ; N trademark ; B 86 230 868 562 ; +C -1 ; WX 600 ; N oacute ; B 71 -15 622 661 ; +C -1 ; WX 600 ; N acircumflex ; B 62 -15 592 657 ; +C -1 ; WX 600 ; N Agrave ; B -9 0 631 784 ; +C -1 ; WX 600 ; N return ; B 79 0 700 562 ; +C -1 ; WX 600 ; N atilde ; B 62 -15 642 636 ; +C -1 ; WX 600 ; N square ; B 19 0 700 562 ; +C -1 ; WX 600 ; N registered ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N stop ; B 19 0 700 562 ; +C -1 ; WX 600 ; N udieresis ; B 70 -15 591 625 ; +C -1 ; WX 600 ; N arrowup ; B 244 3 556 626 ; +C -1 ; WX 600 ; N igrave ; B 77 0 545 661 ; +C -1 ; WX 600 ; N Edieresis ; B 25 0 669 748 ; +C -1 ; WX 600 ; N zcaron ; B 81 0 632 667 ; +C -1 ; WX 600 ; N arrowboth ; B 40 143 688 455 ; +C -1 ; WX 600 ; N gcaron ; B 41 -146 673 667 ; +C -1 ; WX 600 ; N arrowleft ; B 40 143 708 455 ; +C -1 ; WX 600 ; N aacute ; B 62 -15 608 661 ; +C -1 ; WX 600 ; N ocircumflex ; B 71 -15 622 657 ; +C -1 ; WX 600 ; N scedilla ; B 67 -206 607 459 ; +C -1 ; WX 600 ; N ograve ; B 71 -15 622 661 ; +C -1 ; WX 600 ; N onehalf ; B 23 -60 715 661 ; +C -1 ; WX 600 ; N ugrave ; B 70 -15 591 661 ; +C -1 ; WX 600 ; N Ntilde ; B 8 -12 729 759 ; +C -1 ; WX 600 ; N iacute ; B 77 0 608 661 ; +C -1 ; WX 600 ; N arrowright ; B 20 143 688 455 ; +C -1 ; WX 600 ; N Thorn ; B 48 0 619 562 ; +C -1 ; WX 600 ; N Egrave ; B 25 0 669 784 ; +C -1 ; WX 600 ; N thorn ; B -31 -142 622 626 ; +C -1 ; WX 600 ; N aring ; B 62 -15 592 678 ; +C -1 ; WX 600 ; N yacute ; B -20 -142 694 661 ; +C -1 ; WX 600 ; N icircumflex ; B 77 0 566 657 ; +EndCharMetrics +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 56 123 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex -4 123 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 6 123 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave -24 123 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 16 123 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde -4 123 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 56 123 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 26 123 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 26 123 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 26 123 ; +CC Gcaron 2 ; PCC G 0 0 ; PCC caron 36 123 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 26 123 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 26 123 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 26 123 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 26 123 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 26 123 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 26 123 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 26 123 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 26 123 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 26 123 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 26 123 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 26 123 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 56 123 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 26 123 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 26 123 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave -4 123 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 56 123 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 26 123 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 26 123 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 0 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex -20 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis -10 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave -30 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 0 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 0 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 0 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 0 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 0 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 0 0 ; +CC gcaron 2 ; PCC g 0 0 ; PCC caron -40 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -40 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -40 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 0 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 0 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 0 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 0 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 0 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 0 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 0 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 0 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex -20 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis -20 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave -30 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 30 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 10 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 0 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrr8a.afm new file mode 100644 index 00000000..f60ec943 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrr8a.afm @@ -0,0 +1,344 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1990, 1991 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Tue Sep 17 07:47:21 1991 +Comment UniqueID 36347 +Comment VMusage 31037 39405 +FontName Courier +FullName Courier +FamilyName Courier +Weight Medium +ItalicAngle 0 +IsFixedPitch true +FontBBox -28 -250 628 805 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.004 +Notice Copyright (c) 1989, 1990, 1991 Adobe Systems Incorporated. All rights reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 426 +Ascender 629 +Descender -157 +StartCharMetrics 260 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 236 -15 364 572 ; +C 34 ; WX 600 ; N quotedbl ; B 187 328 413 562 ; +C 35 ; WX 600 ; N numbersign ; B 93 -32 507 639 ; +C 36 ; WX 600 ; N dollar ; B 105 -126 496 662 ; +C 37 ; WX 600 ; N percent ; B 81 -15 518 622 ; +C 38 ; WX 600 ; N ampersand ; B 63 -15 538 543 ; +C 39 ; WX 600 ; N quoteright ; B 213 328 376 562 ; +C 40 ; WX 600 ; N parenleft ; B 269 -108 440 622 ; +C 41 ; WX 600 ; N parenright ; B 160 -108 331 622 ; +C 42 ; WX 600 ; N asterisk ; B 116 257 484 607 ; +C 43 ; WX 600 ; N plus ; B 80 44 520 470 ; +C 44 ; WX 600 ; N comma ; B 181 -112 344 122 ; +C 45 ; WX 600 ; N hyphen ; B 103 231 497 285 ; +C 46 ; WX 600 ; N period ; B 229 -15 371 109 ; +C 47 ; WX 600 ; N slash ; B 125 -80 475 629 ; +C 48 ; WX 600 ; N zero ; B 106 -15 494 622 ; +C 49 ; WX 600 ; N one ; B 96 0 505 622 ; +C 50 ; WX 600 ; N two ; B 70 0 471 622 ; +C 51 ; WX 600 ; N three ; B 75 -15 466 622 ; +C 52 ; WX 600 ; N four ; B 78 0 500 622 ; +C 53 ; WX 600 ; N five ; B 92 -15 497 607 ; +C 54 ; WX 600 ; N six ; B 111 -15 497 622 ; +C 55 ; WX 600 ; N seven ; B 82 0 483 607 ; +C 56 ; WX 600 ; N eight ; B 102 -15 498 622 ; +C 57 ; WX 600 ; N nine ; B 96 -15 489 622 ; +C 58 ; WX 600 ; N colon ; B 229 -15 371 385 ; +C 59 ; WX 600 ; N semicolon ; B 181 -112 371 385 ; +C 60 ; WX 600 ; N less ; B 41 42 519 472 ; +C 61 ; WX 600 ; N equal ; B 80 138 520 376 ; +C 62 ; WX 600 ; N greater ; B 66 42 544 472 ; +C 63 ; WX 600 ; N question ; B 129 -15 492 572 ; +C 64 ; WX 600 ; N at ; B 77 -15 533 622 ; +C 65 ; WX 600 ; N A ; B 3 0 597 562 ; +C 66 ; WX 600 ; N B ; B 43 0 559 562 ; +C 67 ; WX 600 ; N C ; B 41 -18 540 580 ; +C 68 ; WX 600 ; N D ; B 43 0 574 562 ; +C 69 ; WX 600 ; N E ; B 53 0 550 562 ; +C 70 ; WX 600 ; N F ; B 53 0 545 562 ; +C 71 ; WX 600 ; N G ; B 31 -18 575 580 ; +C 72 ; WX 600 ; N H ; B 32 0 568 562 ; +C 73 ; WX 600 ; N I ; B 96 0 504 562 ; +C 74 ; WX 600 ; N J ; B 34 -18 566 562 ; +C 75 ; WX 600 ; N K ; B 38 0 582 562 ; +C 76 ; WX 600 ; N L ; B 47 0 554 562 ; +C 77 ; WX 600 ; N M ; B 4 0 596 562 ; +C 78 ; WX 600 ; N N ; B 7 -13 593 562 ; +C 79 ; WX 600 ; N O ; B 43 -18 557 580 ; +C 80 ; WX 600 ; N P ; B 79 0 558 562 ; +C 81 ; WX 600 ; N Q ; B 43 -138 557 580 ; +C 82 ; WX 600 ; N R ; B 38 0 588 562 ; +C 83 ; WX 600 ; N S ; B 72 -20 529 580 ; +C 84 ; WX 600 ; N T ; B 38 0 563 562 ; +C 85 ; WX 600 ; N U ; B 17 -18 583 562 ; +C 86 ; WX 600 ; N V ; B -4 -13 604 562 ; +C 87 ; WX 600 ; N W ; B -3 -13 603 562 ; +C 88 ; WX 600 ; N X ; B 23 0 577 562 ; +C 89 ; WX 600 ; N Y ; B 24 0 576 562 ; +C 90 ; WX 600 ; N Z ; B 86 0 514 562 ; +C 91 ; WX 600 ; N bracketleft ; B 269 -108 442 622 ; +C 92 ; WX 600 ; N backslash ; B 118 -80 482 629 ; +C 93 ; WX 600 ; N bracketright ; B 158 -108 331 622 ; +C 94 ; WX 600 ; N asciicircum ; B 94 354 506 622 ; +C 95 ; WX 600 ; N underscore ; B 0 -125 600 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 224 328 387 562 ; +C 97 ; WX 600 ; N a ; B 53 -15 559 441 ; +C 98 ; WX 600 ; N b ; B 14 -15 575 629 ; +C 99 ; WX 600 ; N c ; B 66 -15 529 441 ; +C 100 ; WX 600 ; N d ; B 45 -15 591 629 ; +C 101 ; WX 600 ; N e ; B 66 -15 548 441 ; +C 102 ; WX 600 ; N f ; B 114 0 531 629 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 45 -157 566 441 ; +C 104 ; WX 600 ; N h ; B 18 0 582 629 ; +C 105 ; WX 600 ; N i ; B 95 0 505 657 ; +C 106 ; WX 600 ; N j ; B 82 -157 410 657 ; +C 107 ; WX 600 ; N k ; B 43 0 580 629 ; +C 108 ; WX 600 ; N l ; B 95 0 505 629 ; +C 109 ; WX 600 ; N m ; B -5 0 605 441 ; +C 110 ; WX 600 ; N n ; B 26 0 575 441 ; +C 111 ; WX 600 ; N o ; B 62 -15 538 441 ; +C 112 ; WX 600 ; N p ; B 9 -157 555 441 ; +C 113 ; WX 600 ; N q ; B 45 -157 591 441 ; +C 114 ; WX 600 ; N r ; B 60 0 559 441 ; +C 115 ; WX 600 ; N s ; B 80 -15 513 441 ; +C 116 ; WX 600 ; N t ; B 87 -15 530 561 ; +C 117 ; WX 600 ; N u ; B 21 -15 562 426 ; +C 118 ; WX 600 ; N v ; B 10 -10 590 426 ; +C 119 ; WX 600 ; N w ; B -4 -10 604 426 ; +C 120 ; WX 600 ; N x ; B 20 0 580 426 ; +C 121 ; WX 600 ; N y ; B 7 -157 592 426 ; +C 122 ; WX 600 ; N z ; B 99 0 502 426 ; +C 123 ; WX 600 ; N braceleft ; B 182 -108 437 622 ; +C 124 ; WX 600 ; N bar ; B 275 -250 326 750 ; +C 125 ; WX 600 ; N braceright ; B 163 -108 418 622 ; +C 126 ; WX 600 ; N asciitilde ; B 63 197 540 320 ; +C 161 ; WX 600 ; N exclamdown ; B 236 -157 364 430 ; +C 162 ; WX 600 ; N cent ; B 96 -49 500 614 ; +C 163 ; WX 600 ; N sterling ; B 84 -21 521 611 ; +C 164 ; WX 600 ; N fraction ; B 92 -57 509 665 ; +C 165 ; WX 600 ; N yen ; B 26 0 574 562 ; +C 166 ; WX 600 ; N florin ; B 4 -143 539 622 ; +C 167 ; WX 600 ; N section ; B 113 -78 488 580 ; +C 168 ; WX 600 ; N currency ; B 73 58 527 506 ; +C 169 ; WX 600 ; N quotesingle ; B 259 328 341 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 143 328 471 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 37 70 563 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 149 70 451 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 149 70 451 446 ; +C 174 ; WX 600 ; N fi ; B 3 0 597 629 ; +C 175 ; WX 600 ; N fl ; B 3 0 597 629 ; +C 177 ; WX 600 ; N endash ; B 75 231 525 285 ; +C 178 ; WX 600 ; N dagger ; B 141 -78 459 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 141 -78 459 580 ; +C 180 ; WX 600 ; N periodcentered ; B 222 189 378 327 ; +C 182 ; WX 600 ; N paragraph ; B 50 -78 511 562 ; +C 183 ; WX 600 ; N bullet ; B 172 130 428 383 ; +C 184 ; WX 600 ; N quotesinglbase ; B 213 -134 376 100 ; +C 185 ; WX 600 ; N quotedblbase ; B 143 -134 457 100 ; +C 186 ; WX 600 ; N quotedblright ; B 143 328 457 562 ; +C 187 ; WX 600 ; N guillemotright ; B 37 70 563 446 ; +C 188 ; WX 600 ; N ellipsis ; B 37 -15 563 111 ; +C 189 ; WX 600 ; N perthousand ; B 3 -15 600 622 ; +C 191 ; WX 600 ; N questiondown ; B 108 -157 471 430 ; +C 193 ; WX 600 ; N grave ; B 151 497 378 672 ; +C 194 ; WX 600 ; N acute ; B 242 497 469 672 ; +C 195 ; WX 600 ; N circumflex ; B 124 477 476 654 ; +C 196 ; WX 600 ; N tilde ; B 105 489 503 606 ; +C 197 ; WX 600 ; N macron ; B 120 525 480 565 ; +C 198 ; WX 600 ; N breve ; B 153 501 447 609 ; +C 199 ; WX 600 ; N dotaccent ; B 249 477 352 580 ; +C 200 ; WX 600 ; N dieresis ; B 148 492 453 595 ; +C 202 ; WX 600 ; N ring ; B 218 463 382 627 ; +C 203 ; WX 600 ; N cedilla ; B 224 -151 362 10 ; +C 205 ; WX 600 ; N hungarumlaut ; B 133 497 540 672 ; +C 206 ; WX 600 ; N ogonek ; B 227 -151 370 0 ; +C 207 ; WX 600 ; N caron ; B 124 492 476 669 ; +C 208 ; WX 600 ; N emdash ; B 0 231 600 285 ; +C 225 ; WX 600 ; N AE ; B 3 0 550 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 156 249 442 580 ; +C 232 ; WX 600 ; N Lslash ; B 47 0 554 562 ; +C 233 ; WX 600 ; N Oslash ; B 43 -80 557 629 ; +C 234 ; WX 600 ; N OE ; B 7 0 567 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 157 249 443 580 ; +C 241 ; WX 600 ; N ae ; B 19 -15 570 441 ; +C 245 ; WX 600 ; N dotlessi ; B 95 0 505 426 ; +C 248 ; WX 600 ; N lslash ; B 95 0 505 629 ; +C 249 ; WX 600 ; N oslash ; B 62 -80 538 506 ; +C 250 ; WX 600 ; N oe ; B 19 -15 559 441 ; +C 251 ; WX 600 ; N germandbls ; B 48 -15 588 629 ; +C -1 ; WX 600 ; N Odieresis ; B 43 -18 557 731 ; +C -1 ; WX 600 ; N logicalnot ; B 87 108 513 369 ; +C -1 ; WX 600 ; N minus ; B 80 232 520 283 ; +C -1 ; WX 600 ; N merge ; B 160 -15 440 436 ; +C -1 ; WX 600 ; N degree ; B 123 269 477 622 ; +C -1 ; WX 600 ; N dectab ; B 18 0 582 227 ; +C -1 ; WX 600 ; N ll ; B 18 0 567 629 ; +C -1 ; WX 600 ; N IJ ; B 32 -18 583 562 ; +C -1 ; WX 600 ; N Eacute ; B 53 0 550 793 ; +C -1 ; WX 600 ; N Ocircumflex ; B 43 -18 557 775 ; +C -1 ; WX 600 ; N ucircumflex ; B 21 -15 562 654 ; +C -1 ; WX 600 ; N left ; B 70 68 530 348 ; +C -1 ; WX 600 ; N threesuperior ; B 155 240 406 622 ; +C -1 ; WX 600 ; N up ; B 160 0 440 437 ; +C -1 ; WX 600 ; N multiply ; B 87 43 515 470 ; +C -1 ; WX 600 ; N Scaron ; B 72 -20 529 805 ; +C -1 ; WX 600 ; N tab ; B 19 0 581 562 ; +C -1 ; WX 600 ; N Ucircumflex ; B 17 -18 583 775 ; +C -1 ; WX 600 ; N divide ; B 87 48 513 467 ; +C -1 ; WX 600 ; N Acircumflex ; B 3 0 597 775 ; +C -1 ; WX 600 ; N eacute ; B 66 -15 548 672 ; +C -1 ; WX 600 ; N uacute ; B 21 -15 562 672 ; +C -1 ; WX 600 ; N Aacute ; B 3 0 597 793 ; +C -1 ; WX 600 ; N copyright ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N twosuperior ; B 177 249 424 622 ; +C -1 ; WX 600 ; N Ecircumflex ; B 53 0 550 775 ; +C -1 ; WX 600 ; N ntilde ; B 26 0 575 606 ; +C -1 ; WX 600 ; N down ; B 160 -15 440 426 ; +C -1 ; WX 600 ; N center ; B 40 14 560 580 ; +C -1 ; WX 600 ; N onesuperior ; B 172 249 428 622 ; +C -1 ; WX 600 ; N ij ; B 37 -157 490 657 ; +C -1 ; WX 600 ; N edieresis ; B 66 -15 548 595 ; +C -1 ; WX 600 ; N graybox ; B 76 0 525 599 ; +C -1 ; WX 600 ; N odieresis ; B 62 -15 538 595 ; +C -1 ; WX 600 ; N Ograve ; B 43 -18 557 793 ; +C -1 ; WX 600 ; N threequarters ; B 8 -56 593 666 ; +C -1 ; WX 600 ; N plusminus ; B 87 44 513 558 ; +C -1 ; WX 600 ; N prescription ; B 27 -15 577 562 ; +C -1 ; WX 600 ; N eth ; B 62 -15 538 629 ; +C -1 ; WX 600 ; N largebullet ; B 261 220 339 297 ; +C -1 ; WX 600 ; N egrave ; B 66 -15 548 672 ; +C -1 ; WX 600 ; N ccedilla ; B 66 -151 529 441 ; +C -1 ; WX 600 ; N notegraphic ; B 136 -15 464 572 ; +C -1 ; WX 600 ; N Udieresis ; B 17 -18 583 731 ; +C -1 ; WX 600 ; N Gcaron ; B 31 -18 575 805 ; +C -1 ; WX 600 ; N arrowdown ; B 116 -15 484 608 ; +C -1 ; WX 600 ; N format ; B 5 -157 56 607 ; +C -1 ; WX 600 ; N Otilde ; B 43 -18 557 732 ; +C -1 ; WX 600 ; N Idieresis ; B 96 0 504 731 ; +C -1 ; WX 600 ; N adieresis ; B 53 -15 559 595 ; +C -1 ; WX 600 ; N ecircumflex ; B 66 -15 548 654 ; +C -1 ; WX 600 ; N Eth ; B 30 0 574 562 ; +C -1 ; WX 600 ; N onequarter ; B 0 -57 600 665 ; +C -1 ; WX 600 ; N LL ; B 8 0 592 562 ; +C -1 ; WX 600 ; N agrave ; B 53 -15 559 672 ; +C -1 ; WX 600 ; N Zcaron ; B 86 0 514 805 ; +C -1 ; WX 600 ; N Scedilla ; B 72 -151 529 580 ; +C -1 ; WX 600 ; N Idot ; B 96 0 504 716 ; +C -1 ; WX 600 ; N Iacute ; B 96 0 504 793 ; +C -1 ; WX 600 ; N indent ; B 70 68 530 348 ; +C -1 ; WX 600 ; N Ugrave ; B 17 -18 583 793 ; +C -1 ; WX 600 ; N scaron ; B 80 -15 513 669 ; +C -1 ; WX 600 ; N overscore ; B 0 579 600 629 ; +C -1 ; WX 600 ; N Aring ; B 3 0 597 753 ; +C -1 ; WX 600 ; N Ccedilla ; B 41 -151 540 580 ; +C -1 ; WX 600 ; N Igrave ; B 96 0 504 793 ; +C -1 ; WX 600 ; N brokenbar ; B 275 -175 326 675 ; +C -1 ; WX 600 ; N Oacute ; B 43 -18 557 793 ; +C -1 ; WX 600 ; N otilde ; B 62 -15 538 606 ; +C -1 ; WX 600 ; N Yacute ; B 24 0 576 793 ; +C -1 ; WX 600 ; N lira ; B 73 -21 521 611 ; +C -1 ; WX 600 ; N Icircumflex ; B 96 0 504 775 ; +C -1 ; WX 600 ; N Atilde ; B 3 0 597 732 ; +C -1 ; WX 600 ; N Uacute ; B 17 -18 583 793 ; +C -1 ; WX 600 ; N Ydieresis ; B 24 0 576 731 ; +C -1 ; WX 600 ; N ydieresis ; B 7 -157 592 595 ; +C -1 ; WX 600 ; N idieresis ; B 95 0 505 595 ; +C -1 ; WX 600 ; N Adieresis ; B 3 0 597 731 ; +C -1 ; WX 600 ; N mu ; B 21 -157 562 426 ; +C -1 ; WX 600 ; N trademark ; B -23 263 623 562 ; +C -1 ; WX 600 ; N oacute ; B 62 -15 538 672 ; +C -1 ; WX 600 ; N acircumflex ; B 53 -15 559 654 ; +C -1 ; WX 600 ; N Agrave ; B 3 0 597 793 ; +C -1 ; WX 600 ; N return ; B 19 0 581 562 ; +C -1 ; WX 600 ; N atilde ; B 53 -15 559 606 ; +C -1 ; WX 600 ; N square ; B 19 0 581 562 ; +C -1 ; WX 600 ; N registered ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N stop ; B 19 0 581 562 ; +C -1 ; WX 600 ; N udieresis ; B 21 -15 562 595 ; +C -1 ; WX 600 ; N arrowup ; B 116 0 484 623 ; +C -1 ; WX 600 ; N igrave ; B 95 0 505 672 ; +C -1 ; WX 600 ; N Edieresis ; B 53 0 550 731 ; +C -1 ; WX 600 ; N zcaron ; B 99 0 502 669 ; +C -1 ; WX 600 ; N arrowboth ; B -28 115 628 483 ; +C -1 ; WX 600 ; N gcaron ; B 45 -157 566 669 ; +C -1 ; WX 600 ; N arrowleft ; B -24 115 624 483 ; +C -1 ; WX 600 ; N aacute ; B 53 -15 559 672 ; +C -1 ; WX 600 ; N ocircumflex ; B 62 -15 538 654 ; +C -1 ; WX 600 ; N scedilla ; B 80 -151 513 441 ; +C -1 ; WX 600 ; N ograve ; B 62 -15 538 672 ; +C -1 ; WX 600 ; N onehalf ; B 0 -57 611 665 ; +C -1 ; WX 600 ; N ugrave ; B 21 -15 562 672 ; +C -1 ; WX 600 ; N Ntilde ; B 7 -13 593 732 ; +C -1 ; WX 600 ; N iacute ; B 95 0 505 672 ; +C -1 ; WX 600 ; N arrowright ; B -24 115 624 483 ; +C -1 ; WX 600 ; N Thorn ; B 79 0 538 562 ; +C -1 ; WX 600 ; N Egrave ; B 53 0 550 793 ; +C -1 ; WX 600 ; N thorn ; B -6 -157 555 629 ; +C -1 ; WX 600 ; N aring ; B 53 -15 559 627 ; +C -1 ; WX 600 ; N yacute ; B 7 -157 592 672 ; +C -1 ; WX 600 ; N icircumflex ; B 94 0 505 654 ; +EndCharMetrics +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 20 121 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex -30 121 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis -30 136 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave -30 121 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring -15 126 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 0 126 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 30 121 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 0 121 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 0 136 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 0 121 ; +CC Gcaron 2 ; PCC G 0 0 ; PCC caron 0 136 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 0 121 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 0 121 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 0 136 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 0 121 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 0 126 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 0 121 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 0 121 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 0 136 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 0 121 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 0 126 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 30 136 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 30 121 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 0 121 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 0 136 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave -30 121 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 30 121 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 0 136 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 0 136 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 0 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 0 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 0 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 0 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 0 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 0 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 0 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 0 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 0 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 0 0 ; +CC gcaron 2 ; PCC g 0 0 ; PCC caron -30 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -30 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -30 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -30 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 0 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 0 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 0 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 0 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 0 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 0 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 0 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute -10 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex -10 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 0 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave -30 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute -20 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis -10 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 10 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrro8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrro8a.afm new file mode 100644 index 00000000..b053a4ca --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pcrro8a.afm @@ -0,0 +1,344 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1990, 1991 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Tue Sep 17 09:42:19 1991 +Comment UniqueID 36350 +Comment VMusage 9174 52297 +FontName Courier-Oblique +FullName Courier Oblique +FamilyName Courier +Weight Medium +ItalicAngle -12 +IsFixedPitch true +FontBBox -28 -250 742 805 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.004 +Notice Copyright (c) 1989, 1990, 1991 Adobe Systems Incorporated. All rights reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 426 +Ascender 629 +Descender -157 +StartCharMetrics 260 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 243 -15 464 572 ; +C 34 ; WX 600 ; N quotedbl ; B 273 328 532 562 ; +C 35 ; WX 600 ; N numbersign ; B 133 -32 596 639 ; +C 36 ; WX 600 ; N dollar ; B 108 -126 596 662 ; +C 37 ; WX 600 ; N percent ; B 134 -15 599 622 ; +C 38 ; WX 600 ; N ampersand ; B 87 -15 580 543 ; +C 39 ; WX 600 ; N quoteright ; B 283 328 495 562 ; +C 40 ; WX 600 ; N parenleft ; B 313 -108 572 622 ; +C 41 ; WX 600 ; N parenright ; B 137 -108 396 622 ; +C 42 ; WX 600 ; N asterisk ; B 212 257 580 607 ; +C 43 ; WX 600 ; N plus ; B 129 44 580 470 ; +C 44 ; WX 600 ; N comma ; B 157 -112 370 122 ; +C 45 ; WX 600 ; N hyphen ; B 152 231 558 285 ; +C 46 ; WX 600 ; N period ; B 238 -15 382 109 ; +C 47 ; WX 600 ; N slash ; B 112 -80 604 629 ; +C 48 ; WX 600 ; N zero ; B 154 -15 575 622 ; +C 49 ; WX 600 ; N one ; B 98 0 515 622 ; +C 50 ; WX 600 ; N two ; B 70 0 568 622 ; +C 51 ; WX 600 ; N three ; B 82 -15 538 622 ; +C 52 ; WX 600 ; N four ; B 108 0 541 622 ; +C 53 ; WX 600 ; N five ; B 99 -15 589 607 ; +C 54 ; WX 600 ; N six ; B 155 -15 629 622 ; +C 55 ; WX 600 ; N seven ; B 182 0 612 607 ; +C 56 ; WX 600 ; N eight ; B 132 -15 588 622 ; +C 57 ; WX 600 ; N nine ; B 93 -15 574 622 ; +C 58 ; WX 600 ; N colon ; B 238 -15 441 385 ; +C 59 ; WX 600 ; N semicolon ; B 157 -112 441 385 ; +C 60 ; WX 600 ; N less ; B 96 42 610 472 ; +C 61 ; WX 600 ; N equal ; B 109 138 600 376 ; +C 62 ; WX 600 ; N greater ; B 85 42 599 472 ; +C 63 ; WX 600 ; N question ; B 222 -15 583 572 ; +C 64 ; WX 600 ; N at ; B 127 -15 582 622 ; +C 65 ; WX 600 ; N A ; B 3 0 607 562 ; +C 66 ; WX 600 ; N B ; B 43 0 616 562 ; +C 67 ; WX 600 ; N C ; B 93 -18 655 580 ; +C 68 ; WX 600 ; N D ; B 43 0 645 562 ; +C 69 ; WX 600 ; N E ; B 53 0 660 562 ; +C 70 ; WX 600 ; N F ; B 53 0 660 562 ; +C 71 ; WX 600 ; N G ; B 83 -18 645 580 ; +C 72 ; WX 600 ; N H ; B 32 0 687 562 ; +C 73 ; WX 600 ; N I ; B 96 0 623 562 ; +C 74 ; WX 600 ; N J ; B 52 -18 685 562 ; +C 75 ; WX 600 ; N K ; B 38 0 671 562 ; +C 76 ; WX 600 ; N L ; B 47 0 607 562 ; +C 77 ; WX 600 ; N M ; B 4 0 715 562 ; +C 78 ; WX 600 ; N N ; B 7 -13 712 562 ; +C 79 ; WX 600 ; N O ; B 94 -18 625 580 ; +C 80 ; WX 600 ; N P ; B 79 0 644 562 ; +C 81 ; WX 600 ; N Q ; B 95 -138 625 580 ; +C 82 ; WX 600 ; N R ; B 38 0 598 562 ; +C 83 ; WX 600 ; N S ; B 76 -20 650 580 ; +C 84 ; WX 600 ; N T ; B 108 0 665 562 ; +C 85 ; WX 600 ; N U ; B 125 -18 702 562 ; +C 86 ; WX 600 ; N V ; B 105 -13 723 562 ; +C 87 ; WX 600 ; N W ; B 106 -13 722 562 ; +C 88 ; WX 600 ; N X ; B 23 0 675 562 ; +C 89 ; WX 600 ; N Y ; B 133 0 695 562 ; +C 90 ; WX 600 ; N Z ; B 86 0 610 562 ; +C 91 ; WX 600 ; N bracketleft ; B 246 -108 574 622 ; +C 92 ; WX 600 ; N backslash ; B 249 -80 468 629 ; +C 93 ; WX 600 ; N bracketright ; B 135 -108 463 622 ; +C 94 ; WX 600 ; N asciicircum ; B 175 354 587 622 ; +C 95 ; WX 600 ; N underscore ; B -27 -125 584 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 343 328 457 562 ; +C 97 ; WX 600 ; N a ; B 76 -15 569 441 ; +C 98 ; WX 600 ; N b ; B 29 -15 625 629 ; +C 99 ; WX 600 ; N c ; B 106 -15 608 441 ; +C 100 ; WX 600 ; N d ; B 85 -15 640 629 ; +C 101 ; WX 600 ; N e ; B 106 -15 598 441 ; +C 102 ; WX 600 ; N f ; B 114 0 662 629 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 61 -157 657 441 ; +C 104 ; WX 600 ; N h ; B 33 0 592 629 ; +C 105 ; WX 600 ; N i ; B 95 0 515 657 ; +C 106 ; WX 600 ; N j ; B 52 -157 550 657 ; +C 107 ; WX 600 ; N k ; B 58 0 633 629 ; +C 108 ; WX 600 ; N l ; B 95 0 515 629 ; +C 109 ; WX 600 ; N m ; B -5 0 615 441 ; +C 110 ; WX 600 ; N n ; B 26 0 585 441 ; +C 111 ; WX 600 ; N o ; B 102 -15 588 441 ; +C 112 ; WX 600 ; N p ; B -24 -157 605 441 ; +C 113 ; WX 600 ; N q ; B 85 -157 682 441 ; +C 114 ; WX 600 ; N r ; B 60 0 636 441 ; +C 115 ; WX 600 ; N s ; B 78 -15 584 441 ; +C 116 ; WX 600 ; N t ; B 167 -15 561 561 ; +C 117 ; WX 600 ; N u ; B 101 -15 572 426 ; +C 118 ; WX 600 ; N v ; B 90 -10 681 426 ; +C 119 ; WX 600 ; N w ; B 76 -10 695 426 ; +C 120 ; WX 600 ; N x ; B 20 0 655 426 ; +C 121 ; WX 600 ; N y ; B -4 -157 683 426 ; +C 122 ; WX 600 ; N z ; B 99 0 593 426 ; +C 123 ; WX 600 ; N braceleft ; B 233 -108 569 622 ; +C 124 ; WX 600 ; N bar ; B 222 -250 485 750 ; +C 125 ; WX 600 ; N braceright ; B 140 -108 477 622 ; +C 126 ; WX 600 ; N asciitilde ; B 116 197 600 320 ; +C 161 ; WX 600 ; N exclamdown ; B 225 -157 445 430 ; +C 162 ; WX 600 ; N cent ; B 151 -49 588 614 ; +C 163 ; WX 600 ; N sterling ; B 124 -21 621 611 ; +C 164 ; WX 600 ; N fraction ; B 84 -57 646 665 ; +C 165 ; WX 600 ; N yen ; B 120 0 693 562 ; +C 166 ; WX 600 ; N florin ; B -26 -143 671 622 ; +C 167 ; WX 600 ; N section ; B 104 -78 590 580 ; +C 168 ; WX 600 ; N currency ; B 94 58 628 506 ; +C 169 ; WX 600 ; N quotesingle ; B 345 328 460 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 262 328 541 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 92 70 652 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 204 70 540 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 170 70 506 446 ; +C 174 ; WX 600 ; N fi ; B 3 0 619 629 ; +C 175 ; WX 600 ; N fl ; B 3 0 619 629 ; +C 177 ; WX 600 ; N endash ; B 124 231 586 285 ; +C 178 ; WX 600 ; N dagger ; B 217 -78 546 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 163 -78 546 580 ; +C 180 ; WX 600 ; N periodcentered ; B 275 189 434 327 ; +C 182 ; WX 600 ; N paragraph ; B 100 -78 630 562 ; +C 183 ; WX 600 ; N bullet ; B 224 130 485 383 ; +C 184 ; WX 600 ; N quotesinglbase ; B 185 -134 397 100 ; +C 185 ; WX 600 ; N quotedblbase ; B 115 -134 478 100 ; +C 186 ; WX 600 ; N quotedblright ; B 213 328 576 562 ; +C 187 ; WX 600 ; N guillemotright ; B 58 70 618 446 ; +C 188 ; WX 600 ; N ellipsis ; B 46 -15 575 111 ; +C 189 ; WX 600 ; N perthousand ; B 59 -15 627 622 ; +C 191 ; WX 600 ; N questiondown ; B 105 -157 466 430 ; +C 193 ; WX 600 ; N grave ; B 294 497 484 672 ; +C 194 ; WX 600 ; N acute ; B 348 497 612 672 ; +C 195 ; WX 600 ; N circumflex ; B 229 477 581 654 ; +C 196 ; WX 600 ; N tilde ; B 212 489 629 606 ; +C 197 ; WX 600 ; N macron ; B 232 525 600 565 ; +C 198 ; WX 600 ; N breve ; B 279 501 576 609 ; +C 199 ; WX 600 ; N dotaccent ; B 360 477 466 580 ; +C 200 ; WX 600 ; N dieresis ; B 262 492 570 595 ; +C 202 ; WX 600 ; N ring ; B 332 463 500 627 ; +C 203 ; WX 600 ; N cedilla ; B 197 -151 344 10 ; +C 205 ; WX 600 ; N hungarumlaut ; B 239 497 683 672 ; +C 206 ; WX 600 ; N ogonek ; B 207 -151 348 0 ; +C 207 ; WX 600 ; N caron ; B 262 492 614 669 ; +C 208 ; WX 600 ; N emdash ; B 49 231 661 285 ; +C 225 ; WX 600 ; N AE ; B 3 0 655 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 209 249 512 580 ; +C 232 ; WX 600 ; N Lslash ; B 47 0 607 562 ; +C 233 ; WX 600 ; N Oslash ; B 94 -80 625 629 ; +C 234 ; WX 600 ; N OE ; B 59 0 672 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 210 249 535 580 ; +C 241 ; WX 600 ; N ae ; B 41 -15 626 441 ; +C 245 ; WX 600 ; N dotlessi ; B 95 0 515 426 ; +C 248 ; WX 600 ; N lslash ; B 95 0 583 629 ; +C 249 ; WX 600 ; N oslash ; B 102 -80 588 506 ; +C 250 ; WX 600 ; N oe ; B 54 -15 615 441 ; +C 251 ; WX 600 ; N germandbls ; B 48 -15 617 629 ; +C -1 ; WX 600 ; N Odieresis ; B 94 -18 625 731 ; +C -1 ; WX 600 ; N logicalnot ; B 155 108 591 369 ; +C -1 ; WX 600 ; N minus ; B 129 232 580 283 ; +C -1 ; WX 600 ; N merge ; B 187 -15 503 436 ; +C -1 ; WX 600 ; N degree ; B 214 269 576 622 ; +C -1 ; WX 600 ; N dectab ; B 18 0 593 227 ; +C -1 ; WX 600 ; N ll ; B 33 0 616 629 ; +C -1 ; WX 600 ; N IJ ; B 32 -18 702 562 ; +C -1 ; WX 600 ; N Eacute ; B 53 0 668 793 ; +C -1 ; WX 600 ; N Ocircumflex ; B 94 -18 625 775 ; +C -1 ; WX 600 ; N ucircumflex ; B 101 -15 572 654 ; +C -1 ; WX 600 ; N left ; B 114 68 580 348 ; +C -1 ; WX 600 ; N threesuperior ; B 213 240 501 622 ; +C -1 ; WX 600 ; N up ; B 223 0 503 437 ; +C -1 ; WX 600 ; N multiply ; B 103 43 607 470 ; +C -1 ; WX 600 ; N Scaron ; B 76 -20 673 805 ; +C -1 ; WX 600 ; N tab ; B 19 0 641 562 ; +C -1 ; WX 600 ; N Ucircumflex ; B 125 -18 702 775 ; +C -1 ; WX 600 ; N divide ; B 136 48 573 467 ; +C -1 ; WX 600 ; N Acircumflex ; B 3 0 607 775 ; +C -1 ; WX 600 ; N eacute ; B 106 -15 612 672 ; +C -1 ; WX 600 ; N uacute ; B 101 -15 602 672 ; +C -1 ; WX 600 ; N Aacute ; B 3 0 658 793 ; +C -1 ; WX 600 ; N copyright ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N twosuperior ; B 230 249 535 622 ; +C -1 ; WX 600 ; N Ecircumflex ; B 53 0 660 775 ; +C -1 ; WX 600 ; N ntilde ; B 26 0 629 606 ; +C -1 ; WX 600 ; N down ; B 187 -15 467 426 ; +C -1 ; WX 600 ; N center ; B 103 14 623 580 ; +C -1 ; WX 600 ; N onesuperior ; B 231 249 491 622 ; +C -1 ; WX 600 ; N ij ; B 37 -157 630 657 ; +C -1 ; WX 600 ; N edieresis ; B 106 -15 598 595 ; +C -1 ; WX 600 ; N graybox ; B 76 0 652 599 ; +C -1 ; WX 600 ; N odieresis ; B 102 -15 588 595 ; +C -1 ; WX 600 ; N Ograve ; B 94 -18 625 793 ; +C -1 ; WX 600 ; N threequarters ; B 73 -56 659 666 ; +C -1 ; WX 600 ; N plusminus ; B 96 44 594 558 ; +C -1 ; WX 600 ; N prescription ; B 27 -15 617 562 ; +C -1 ; WX 600 ; N eth ; B 102 -15 639 629 ; +C -1 ; WX 600 ; N largebullet ; B 315 220 395 297 ; +C -1 ; WX 600 ; N egrave ; B 106 -15 598 672 ; +C -1 ; WX 600 ; N ccedilla ; B 106 -151 614 441 ; +C -1 ; WX 600 ; N notegraphic ; B 143 -15 564 572 ; +C -1 ; WX 600 ; N Udieresis ; B 125 -18 702 731 ; +C -1 ; WX 600 ; N Gcaron ; B 83 -18 645 805 ; +C -1 ; WX 600 ; N arrowdown ; B 152 -15 520 608 ; +C -1 ; WX 600 ; N format ; B -28 -157 185 607 ; +C -1 ; WX 600 ; N Otilde ; B 94 -18 656 732 ; +C -1 ; WX 600 ; N Idieresis ; B 96 0 623 731 ; +C -1 ; WX 600 ; N adieresis ; B 76 -15 570 595 ; +C -1 ; WX 600 ; N ecircumflex ; B 106 -15 598 654 ; +C -1 ; WX 600 ; N Eth ; B 43 0 645 562 ; +C -1 ; WX 600 ; N onequarter ; B 65 -57 674 665 ; +C -1 ; WX 600 ; N LL ; B 8 0 647 562 ; +C -1 ; WX 600 ; N agrave ; B 76 -15 569 672 ; +C -1 ; WX 600 ; N Zcaron ; B 86 0 643 805 ; +C -1 ; WX 600 ; N Scedilla ; B 76 -151 650 580 ; +C -1 ; WX 600 ; N Idot ; B 96 0 623 716 ; +C -1 ; WX 600 ; N Iacute ; B 96 0 638 793 ; +C -1 ; WX 600 ; N indent ; B 108 68 574 348 ; +C -1 ; WX 600 ; N Ugrave ; B 125 -18 702 793 ; +C -1 ; WX 600 ; N scaron ; B 78 -15 614 669 ; +C -1 ; WX 600 ; N overscore ; B 123 579 734 629 ; +C -1 ; WX 600 ; N Aring ; B 3 0 607 753 ; +C -1 ; WX 600 ; N Ccedilla ; B 93 -151 658 580 ; +C -1 ; WX 600 ; N Igrave ; B 96 0 623 793 ; +C -1 ; WX 600 ; N brokenbar ; B 238 -175 469 675 ; +C -1 ; WX 600 ; N Oacute ; B 94 -18 638 793 ; +C -1 ; WX 600 ; N otilde ; B 102 -15 629 606 ; +C -1 ; WX 600 ; N Yacute ; B 133 0 695 793 ; +C -1 ; WX 600 ; N lira ; B 118 -21 621 611 ; +C -1 ; WX 600 ; N Icircumflex ; B 96 0 623 775 ; +C -1 ; WX 600 ; N Atilde ; B 3 0 656 732 ; +C -1 ; WX 600 ; N Uacute ; B 125 -18 702 793 ; +C -1 ; WX 600 ; N Ydieresis ; B 133 0 695 731 ; +C -1 ; WX 600 ; N ydieresis ; B -4 -157 683 595 ; +C -1 ; WX 600 ; N idieresis ; B 95 0 540 595 ; +C -1 ; WX 600 ; N Adieresis ; B 3 0 607 731 ; +C -1 ; WX 600 ; N mu ; B 72 -157 572 426 ; +C -1 ; WX 600 ; N trademark ; B 75 263 742 562 ; +C -1 ; WX 600 ; N oacute ; B 102 -15 612 672 ; +C -1 ; WX 600 ; N acircumflex ; B 76 -15 581 654 ; +C -1 ; WX 600 ; N Agrave ; B 3 0 607 793 ; +C -1 ; WX 600 ; N return ; B 79 0 700 562 ; +C -1 ; WX 600 ; N atilde ; B 76 -15 629 606 ; +C -1 ; WX 600 ; N square ; B 19 0 700 562 ; +C -1 ; WX 600 ; N registered ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N stop ; B 19 0 700 562 ; +C -1 ; WX 600 ; N udieresis ; B 101 -15 572 595 ; +C -1 ; WX 600 ; N arrowup ; B 209 0 577 623 ; +C -1 ; WX 600 ; N igrave ; B 95 0 515 672 ; +C -1 ; WX 600 ; N Edieresis ; B 53 0 660 731 ; +C -1 ; WX 600 ; N zcaron ; B 99 0 624 669 ; +C -1 ; WX 600 ; N arrowboth ; B 36 115 692 483 ; +C -1 ; WX 600 ; N gcaron ; B 61 -157 657 669 ; +C -1 ; WX 600 ; N arrowleft ; B 40 115 693 483 ; +C -1 ; WX 600 ; N aacute ; B 76 -15 612 672 ; +C -1 ; WX 600 ; N ocircumflex ; B 102 -15 588 654 ; +C -1 ; WX 600 ; N scedilla ; B 78 -151 584 441 ; +C -1 ; WX 600 ; N ograve ; B 102 -15 588 672 ; +C -1 ; WX 600 ; N onehalf ; B 65 -57 669 665 ; +C -1 ; WX 600 ; N ugrave ; B 101 -15 572 672 ; +C -1 ; WX 600 ; N Ntilde ; B 7 -13 712 732 ; +C -1 ; WX 600 ; N iacute ; B 95 0 612 672 ; +C -1 ; WX 600 ; N arrowright ; B 34 115 688 483 ; +C -1 ; WX 600 ; N Thorn ; B 79 0 606 562 ; +C -1 ; WX 600 ; N Egrave ; B 53 0 660 793 ; +C -1 ; WX 600 ; N thorn ; B -24 -157 605 629 ; +C -1 ; WX 600 ; N aring ; B 76 -15 569 627 ; +C -1 ; WX 600 ; N yacute ; B -4 -157 683 672 ; +C -1 ; WX 600 ; N icircumflex ; B 95 0 551 654 ; +EndCharMetrics +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 46 121 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex -4 121 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis -1 136 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave -4 121 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 12 126 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 27 126 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 56 121 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 26 121 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 29 136 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 26 121 ; +CC Gcaron 2 ; PCC G 0 0 ; PCC caron 29 136 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 26 121 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 26 121 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 29 136 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 26 121 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 27 126 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 26 121 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 26 121 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 29 136 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 26 121 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 27 126 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 59 136 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 56 121 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 26 121 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 29 136 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave -4 121 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 56 121 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 29 136 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 29 136 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 0 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 0 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 0 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 0 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 0 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 0 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 0 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 0 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 0 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 0 0 ; +CC gcaron 2 ; PCC g 0 0 ; PCC caron -30 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -30 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -30 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -30 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 0 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 0 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 0 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 0 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 0 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 0 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 0 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute -10 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex -10 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 0 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave -30 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute -20 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis -10 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 10 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8a.afm new file mode 100644 index 00000000..a1e1b33c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8a.afm @@ -0,0 +1,570 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu Mar 15 09:43:00 1990 +Comment UniqueID 28357 +Comment VMusage 26878 33770 +FontName Helvetica-Bold +FullName Helvetica Bold +FamilyName Helvetica +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -170 -228 1003 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 90 0 244 718 ; +C 34 ; WX 474 ; N quotedbl ; B 98 447 376 718 ; +C 35 ; WX 556 ; N numbersign ; B 18 0 538 698 ; +C 36 ; WX 556 ; N dollar ; B 30 -115 523 775 ; +C 37 ; WX 889 ; N percent ; B 28 -19 861 710 ; +C 38 ; WX 722 ; N ampersand ; B 54 -19 701 718 ; +C 39 ; WX 278 ; N quoteright ; B 69 445 209 718 ; +C 40 ; WX 333 ; N parenleft ; B 35 -208 314 734 ; +C 41 ; WX 333 ; N parenright ; B 19 -208 298 734 ; +C 42 ; WX 389 ; N asterisk ; B 27 387 362 718 ; +C 43 ; WX 584 ; N plus ; B 40 0 544 506 ; +C 44 ; WX 278 ; N comma ; B 64 -168 214 146 ; +C 45 ; WX 333 ; N hyphen ; B 27 215 306 345 ; +C 46 ; WX 278 ; N period ; B 64 0 214 146 ; +C 47 ; WX 278 ; N slash ; B -33 -19 311 737 ; +C 48 ; WX 556 ; N zero ; B 32 -19 524 710 ; +C 49 ; WX 556 ; N one ; B 69 0 378 710 ; +C 50 ; WX 556 ; N two ; B 26 0 511 710 ; +C 51 ; WX 556 ; N three ; B 27 -19 516 710 ; +C 52 ; WX 556 ; N four ; B 27 0 526 710 ; +C 53 ; WX 556 ; N five ; B 27 -19 516 698 ; +C 54 ; WX 556 ; N six ; B 31 -19 520 710 ; +C 55 ; WX 556 ; N seven ; B 25 0 528 698 ; +C 56 ; WX 556 ; N eight ; B 32 -19 524 710 ; +C 57 ; WX 556 ; N nine ; B 30 -19 522 710 ; +C 58 ; WX 333 ; N colon ; B 92 0 242 512 ; +C 59 ; WX 333 ; N semicolon ; B 92 -168 242 512 ; +C 60 ; WX 584 ; N less ; B 38 -8 546 514 ; +C 61 ; WX 584 ; N equal ; B 40 87 544 419 ; +C 62 ; WX 584 ; N greater ; B 38 -8 546 514 ; +C 63 ; WX 611 ; N question ; B 60 0 556 727 ; +C 64 ; WX 975 ; N at ; B 118 -19 856 737 ; +C 65 ; WX 722 ; N A ; B 20 0 702 718 ; +C 66 ; WX 722 ; N B ; B 76 0 669 718 ; +C 67 ; WX 722 ; N C ; B 44 -19 684 737 ; +C 68 ; WX 722 ; N D ; B 76 0 685 718 ; +C 69 ; WX 667 ; N E ; B 76 0 621 718 ; +C 70 ; WX 611 ; N F ; B 76 0 587 718 ; +C 71 ; WX 778 ; N G ; B 44 -19 713 737 ; +C 72 ; WX 722 ; N H ; B 71 0 651 718 ; +C 73 ; WX 278 ; N I ; B 64 0 214 718 ; +C 74 ; WX 556 ; N J ; B 22 -18 484 718 ; +C 75 ; WX 722 ; N K ; B 87 0 722 718 ; +C 76 ; WX 611 ; N L ; B 76 0 583 718 ; +C 77 ; WX 833 ; N M ; B 69 0 765 718 ; +C 78 ; WX 722 ; N N ; B 69 0 654 718 ; +C 79 ; WX 778 ; N O ; B 44 -19 734 737 ; +C 80 ; WX 667 ; N P ; B 76 0 627 718 ; +C 81 ; WX 778 ; N Q ; B 44 -52 737 737 ; +C 82 ; WX 722 ; N R ; B 76 0 677 718 ; +C 83 ; WX 667 ; N S ; B 39 -19 629 737 ; +C 84 ; WX 611 ; N T ; B 14 0 598 718 ; +C 85 ; WX 722 ; N U ; B 72 -19 651 718 ; +C 86 ; WX 667 ; N V ; B 19 0 648 718 ; +C 87 ; WX 944 ; N W ; B 16 0 929 718 ; +C 88 ; WX 667 ; N X ; B 14 0 653 718 ; +C 89 ; WX 667 ; N Y ; B 15 0 653 718 ; +C 90 ; WX 611 ; N Z ; B 25 0 586 718 ; +C 91 ; WX 333 ; N bracketleft ; B 63 -196 309 722 ; +C 92 ; WX 278 ; N backslash ; B -33 -19 311 737 ; +C 93 ; WX 333 ; N bracketright ; B 24 -196 270 722 ; +C 94 ; WX 584 ; N asciicircum ; B 62 323 522 698 ; +C 95 ; WX 556 ; N underscore ; B 0 -125 556 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 69 454 209 727 ; +C 97 ; WX 556 ; N a ; B 29 -14 527 546 ; +C 98 ; WX 611 ; N b ; B 61 -14 578 718 ; +C 99 ; WX 556 ; N c ; B 34 -14 524 546 ; +C 100 ; WX 611 ; N d ; B 34 -14 551 718 ; +C 101 ; WX 556 ; N e ; B 23 -14 528 546 ; +C 102 ; WX 333 ; N f ; B 10 0 318 727 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 40 -217 553 546 ; +C 104 ; WX 611 ; N h ; B 65 0 546 718 ; +C 105 ; WX 278 ; N i ; B 69 0 209 725 ; +C 106 ; WX 278 ; N j ; B 3 -214 209 725 ; +C 107 ; WX 556 ; N k ; B 69 0 562 718 ; +C 108 ; WX 278 ; N l ; B 69 0 209 718 ; +C 109 ; WX 889 ; N m ; B 64 0 826 546 ; +C 110 ; WX 611 ; N n ; B 65 0 546 546 ; +C 111 ; WX 611 ; N o ; B 34 -14 578 546 ; +C 112 ; WX 611 ; N p ; B 62 -207 578 546 ; +C 113 ; WX 611 ; N q ; B 34 -207 552 546 ; +C 114 ; WX 389 ; N r ; B 64 0 373 546 ; +C 115 ; WX 556 ; N s ; B 30 -14 519 546 ; +C 116 ; WX 333 ; N t ; B 10 -6 309 676 ; +C 117 ; WX 611 ; N u ; B 66 -14 545 532 ; +C 118 ; WX 556 ; N v ; B 13 0 543 532 ; +C 119 ; WX 778 ; N w ; B 10 0 769 532 ; +C 120 ; WX 556 ; N x ; B 15 0 541 532 ; +C 121 ; WX 556 ; N y ; B 10 -214 539 532 ; +C 122 ; WX 500 ; N z ; B 20 0 480 532 ; +C 123 ; WX 389 ; N braceleft ; B 48 -196 365 722 ; +C 124 ; WX 280 ; N bar ; B 84 -19 196 737 ; +C 125 ; WX 389 ; N braceright ; B 24 -196 341 722 ; +C 126 ; WX 584 ; N asciitilde ; B 61 163 523 343 ; +C 161 ; WX 333 ; N exclamdown ; B 90 -186 244 532 ; +C 162 ; WX 556 ; N cent ; B 34 -118 524 628 ; +C 163 ; WX 556 ; N sterling ; B 28 -16 541 718 ; +C 164 ; WX 167 ; N fraction ; B -170 -19 336 710 ; +C 165 ; WX 556 ; N yen ; B -9 0 565 698 ; +C 166 ; WX 556 ; N florin ; B -10 -210 516 737 ; +C 167 ; WX 556 ; N section ; B 34 -184 522 727 ; +C 168 ; WX 556 ; N currency ; B -3 76 559 636 ; +C 169 ; WX 238 ; N quotesingle ; B 70 447 168 718 ; +C 170 ; WX 500 ; N quotedblleft ; B 64 454 436 727 ; +C 171 ; WX 556 ; N guillemotleft ; B 88 76 468 484 ; +C 172 ; WX 333 ; N guilsinglleft ; B 83 76 250 484 ; +C 173 ; WX 333 ; N guilsinglright ; B 83 76 250 484 ; +C 174 ; WX 611 ; N fi ; B 10 0 542 727 ; +C 175 ; WX 611 ; N fl ; B 10 0 542 727 ; +C 177 ; WX 556 ; N endash ; B 0 227 556 333 ; +C 178 ; WX 556 ; N dagger ; B 36 -171 520 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 36 -171 520 718 ; +C 180 ; WX 278 ; N periodcentered ; B 58 172 220 334 ; +C 182 ; WX 556 ; N paragraph ; B -8 -191 539 700 ; +C 183 ; WX 350 ; N bullet ; B 10 194 340 524 ; +C 184 ; WX 278 ; N quotesinglbase ; B 69 -146 209 127 ; +C 185 ; WX 500 ; N quotedblbase ; B 64 -146 436 127 ; +C 186 ; WX 500 ; N quotedblright ; B 64 445 436 718 ; +C 187 ; WX 556 ; N guillemotright ; B 88 76 468 484 ; +C 188 ; WX 1000 ; N ellipsis ; B 92 0 908 146 ; +C 189 ; WX 1000 ; N perthousand ; B -3 -19 1003 710 ; +C 191 ; WX 611 ; N questiondown ; B 55 -195 551 532 ; +C 193 ; WX 333 ; N grave ; B -23 604 225 750 ; +C 194 ; WX 333 ; N acute ; B 108 604 356 750 ; +C 195 ; WX 333 ; N circumflex ; B -10 604 343 750 ; +C 196 ; WX 333 ; N tilde ; B -17 610 350 737 ; +C 197 ; WX 333 ; N macron ; B -6 604 339 678 ; +C 198 ; WX 333 ; N breve ; B -2 604 335 750 ; +C 199 ; WX 333 ; N dotaccent ; B 104 614 230 729 ; +C 200 ; WX 333 ; N dieresis ; B 6 614 327 729 ; +C 202 ; WX 333 ; N ring ; B 59 568 275 776 ; +C 203 ; WX 333 ; N cedilla ; B 6 -228 245 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 9 604 486 750 ; +C 206 ; WX 333 ; N ogonek ; B 71 -228 304 0 ; +C 207 ; WX 333 ; N caron ; B -10 604 343 750 ; +C 208 ; WX 1000 ; N emdash ; B 0 227 1000 333 ; +C 225 ; WX 1000 ; N AE ; B 5 0 954 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 22 276 347 737 ; +C 232 ; WX 611 ; N Lslash ; B -20 0 583 718 ; +C 233 ; WX 778 ; N Oslash ; B 33 -27 744 745 ; +C 234 ; WX 1000 ; N OE ; B 37 -19 961 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 6 276 360 737 ; +C 241 ; WX 889 ; N ae ; B 29 -14 858 546 ; +C 245 ; WX 278 ; N dotlessi ; B 69 0 209 532 ; +C 248 ; WX 278 ; N lslash ; B -18 0 296 718 ; +C 249 ; WX 611 ; N oslash ; B 22 -29 589 560 ; +C 250 ; WX 944 ; N oe ; B 34 -14 912 546 ; +C 251 ; WX 611 ; N germandbls ; B 69 -14 579 731 ; +C -1 ; WX 611 ; N Zcaron ; B 25 0 586 936 ; +C -1 ; WX 556 ; N ccedilla ; B 34 -228 524 546 ; +C -1 ; WX 556 ; N ydieresis ; B 10 -214 539 729 ; +C -1 ; WX 556 ; N atilde ; B 29 -14 527 737 ; +C -1 ; WX 278 ; N icircumflex ; B -37 0 316 750 ; +C -1 ; WX 333 ; N threesuperior ; B 8 271 326 710 ; +C -1 ; WX 556 ; N ecircumflex ; B 23 -14 528 750 ; +C -1 ; WX 611 ; N thorn ; B 62 -208 578 718 ; +C -1 ; WX 556 ; N egrave ; B 23 -14 528 750 ; +C -1 ; WX 333 ; N twosuperior ; B 9 283 324 710 ; +C -1 ; WX 556 ; N eacute ; B 23 -14 528 750 ; +C -1 ; WX 611 ; N otilde ; B 34 -14 578 737 ; +C -1 ; WX 722 ; N Aacute ; B 20 0 702 936 ; +C -1 ; WX 611 ; N ocircumflex ; B 34 -14 578 750 ; +C -1 ; WX 556 ; N yacute ; B 10 -214 539 750 ; +C -1 ; WX 611 ; N udieresis ; B 66 -14 545 729 ; +C -1 ; WX 834 ; N threequarters ; B 16 -19 799 710 ; +C -1 ; WX 556 ; N acircumflex ; B 29 -14 527 750 ; +C -1 ; WX 722 ; N Eth ; B -5 0 685 718 ; +C -1 ; WX 556 ; N edieresis ; B 23 -14 528 729 ; +C -1 ; WX 611 ; N ugrave ; B 66 -14 545 750 ; +C -1 ; WX 1000 ; N trademark ; B 44 306 956 718 ; +C -1 ; WX 611 ; N ograve ; B 34 -14 578 750 ; +C -1 ; WX 556 ; N scaron ; B 30 -14 519 750 ; +C -1 ; WX 278 ; N Idieresis ; B -21 0 300 915 ; +C -1 ; WX 611 ; N uacute ; B 66 -14 545 750 ; +C -1 ; WX 556 ; N agrave ; B 29 -14 527 750 ; +C -1 ; WX 611 ; N ntilde ; B 65 0 546 737 ; +C -1 ; WX 556 ; N aring ; B 29 -14 527 776 ; +C -1 ; WX 500 ; N zcaron ; B 20 0 480 750 ; +C -1 ; WX 278 ; N Icircumflex ; B -37 0 316 936 ; +C -1 ; WX 722 ; N Ntilde ; B 69 0 654 923 ; +C -1 ; WX 611 ; N ucircumflex ; B 66 -14 545 750 ; +C -1 ; WX 667 ; N Ecircumflex ; B 76 0 621 936 ; +C -1 ; WX 278 ; N Iacute ; B 64 0 329 936 ; +C -1 ; WX 722 ; N Ccedilla ; B 44 -228 684 737 ; +C -1 ; WX 778 ; N Odieresis ; B 44 -19 734 915 ; +C -1 ; WX 667 ; N Scaron ; B 39 -19 629 936 ; +C -1 ; WX 667 ; N Edieresis ; B 76 0 621 915 ; +C -1 ; WX 278 ; N Igrave ; B -50 0 214 936 ; +C -1 ; WX 556 ; N adieresis ; B 29 -14 527 729 ; +C -1 ; WX 778 ; N Ograve ; B 44 -19 734 936 ; +C -1 ; WX 667 ; N Egrave ; B 76 0 621 936 ; +C -1 ; WX 667 ; N Ydieresis ; B 15 0 653 915 ; +C -1 ; WX 737 ; N registered ; B -11 -19 748 737 ; +C -1 ; WX 778 ; N Otilde ; B 44 -19 734 923 ; +C -1 ; WX 834 ; N onequarter ; B 26 -19 766 710 ; +C -1 ; WX 722 ; N Ugrave ; B 72 -19 651 936 ; +C -1 ; WX 722 ; N Ucircumflex ; B 72 -19 651 936 ; +C -1 ; WX 667 ; N Thorn ; B 76 0 627 718 ; +C -1 ; WX 584 ; N divide ; B 40 -42 544 548 ; +C -1 ; WX 722 ; N Atilde ; B 20 0 702 923 ; +C -1 ; WX 722 ; N Uacute ; B 72 -19 651 936 ; +C -1 ; WX 778 ; N Ocircumflex ; B 44 -19 734 936 ; +C -1 ; WX 584 ; N logicalnot ; B 40 108 544 419 ; +C -1 ; WX 722 ; N Aring ; B 20 0 702 962 ; +C -1 ; WX 278 ; N idieresis ; B -21 0 300 729 ; +C -1 ; WX 278 ; N iacute ; B 69 0 329 750 ; +C -1 ; WX 556 ; N aacute ; B 29 -14 527 750 ; +C -1 ; WX 584 ; N plusminus ; B 40 0 544 506 ; +C -1 ; WX 584 ; N multiply ; B 40 1 545 505 ; +C -1 ; WX 722 ; N Udieresis ; B 72 -19 651 915 ; +C -1 ; WX 584 ; N minus ; B 40 197 544 309 ; +C -1 ; WX 333 ; N onesuperior ; B 26 283 237 710 ; +C -1 ; WX 667 ; N Eacute ; B 76 0 621 936 ; +C -1 ; WX 722 ; N Acircumflex ; B 20 0 702 936 ; +C -1 ; WX 737 ; N copyright ; B -11 -19 749 737 ; +C -1 ; WX 722 ; N Agrave ; B 20 0 702 936 ; +C -1 ; WX 611 ; N odieresis ; B 34 -14 578 729 ; +C -1 ; WX 611 ; N oacute ; B 34 -14 578 750 ; +C -1 ; WX 400 ; N degree ; B 57 426 343 712 ; +C -1 ; WX 278 ; N igrave ; B -50 0 209 750 ; +C -1 ; WX 611 ; N mu ; B 66 -207 545 532 ; +C -1 ; WX 778 ; N Oacute ; B 44 -19 734 936 ; +C -1 ; WX 611 ; N eth ; B 34 -14 578 737 ; +C -1 ; WX 722 ; N Adieresis ; B 20 0 702 915 ; +C -1 ; WX 667 ; N Yacute ; B 15 0 653 936 ; +C -1 ; WX 280 ; N brokenbar ; B 84 -19 196 737 ; +C -1 ; WX 834 ; N onehalf ; B 26 -19 794 710 ; +EndCharMetrics +StartKernData +StartKernPairs 209 + +KPX A y -30 +KPX A w -30 +KPX A v -40 +KPX A u -30 +KPX A Y -110 +KPX A W -60 +KPX A V -80 +KPX A U -50 +KPX A T -90 +KPX A Q -40 +KPX A O -40 +KPX A G -50 +KPX A C -40 + +KPX B U -10 +KPX B A -30 + +KPX D period -30 +KPX D comma -30 +KPX D Y -70 +KPX D W -40 +KPX D V -40 +KPX D A -40 + +KPX F period -100 +KPX F comma -100 +KPX F a -20 +KPX F A -80 + +KPX J u -20 +KPX J period -20 +KPX J comma -20 +KPX J A -20 + +KPX K y -40 +KPX K u -30 +KPX K o -35 +KPX K e -15 +KPX K O -30 + +KPX L y -30 +KPX L quoteright -140 +KPX L quotedblright -140 +KPX L Y -120 +KPX L W -80 +KPX L V -110 +KPX L T -90 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -50 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -50 + +KPX P period -120 +KPX P o -40 +KPX P e -30 +KPX P comma -120 +KPX P a -30 +KPX P A -100 + +KPX Q period 20 +KPX Q comma 20 +KPX Q U -10 + +KPX R Y -50 +KPX R W -40 +KPX R V -50 +KPX R U -20 +KPX R T -20 +KPX R O -20 + +KPX T y -60 +KPX T w -60 +KPX T u -90 +KPX T semicolon -40 +KPX T r -80 +KPX T period -80 +KPX T o -80 +KPX T hyphen -120 +KPX T e -60 +KPX T comma -80 +KPX T colon -40 +KPX T a -80 +KPX T O -40 +KPX T A -90 + +KPX U period -30 +KPX U comma -30 +KPX U A -50 + +KPX V u -60 +KPX V semicolon -40 +KPX V period -120 +KPX V o -90 +KPX V hyphen -80 +KPX V e -50 +KPX V comma -120 +KPX V colon -40 +KPX V a -60 +KPX V O -50 +KPX V G -50 +KPX V A -80 + +KPX W y -20 +KPX W u -45 +KPX W semicolon -10 +KPX W period -80 +KPX W o -60 +KPX W hyphen -40 +KPX W e -35 +KPX W comma -80 +KPX W colon -10 +KPX W a -40 +KPX W O -20 +KPX W A -60 + +KPX Y u -100 +KPX Y semicolon -50 +KPX Y period -100 +KPX Y o -100 +KPX Y e -80 +KPX Y comma -100 +KPX Y colon -50 +KPX Y a -90 +KPX Y O -70 +KPX Y A -110 + +KPX a y -20 +KPX a w -15 +KPX a v -15 +KPX a g -10 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b l -10 + +KPX c y -10 +KPX c l -20 +KPX c k -20 +KPX c h -10 + +KPX colon space -40 + +KPX comma space -40 +KPX comma quoteright -120 +KPX comma quotedblright -120 + +KPX d y -15 +KPX d w -15 +KPX d v -15 +KPX d d -10 + +KPX e y -15 +KPX e x -15 +KPX e w -15 +KPX e v -15 +KPX e period 20 +KPX e comma 10 + +KPX f quoteright 30 +KPX f quotedblright 30 +KPX f period -10 +KPX f o -20 +KPX f e -10 +KPX f comma -10 + +KPX g g -10 +KPX g e 10 + +KPX h y -20 + +KPX k o -15 + +KPX l y -15 +KPX l w -15 + +KPX m y -30 +KPX m u -20 + +KPX n y -20 +KPX n v -40 +KPX n u -10 + +KPX o y -20 +KPX o x -30 +KPX o w -15 +KPX o v -20 + +KPX p y -15 + +KPX period space -40 +KPX period quoteright -120 +KPX period quotedblright -120 + +KPX quotedblright space -80 + +KPX quoteleft quoteleft -46 + +KPX quoteright v -20 +KPX quoteright space -80 +KPX quoteright s -60 +KPX quoteright r -40 +KPX quoteright quoteright -46 +KPX quoteright l -20 +KPX quoteright d -80 + +KPX r y 10 +KPX r v 10 +KPX r t 20 +KPX r s -15 +KPX r q -20 +KPX r period -60 +KPX r o -20 +KPX r hyphen -20 +KPX r g -15 +KPX r d -20 +KPX r comma -60 +KPX r c -20 + +KPX s w -15 + +KPX semicolon space -40 + +KPX space quoteleft -60 +KPX space quotedblleft -80 +KPX space Y -120 +KPX space W -80 +KPX space V -80 +KPX space T -100 + +KPX v period -80 +KPX v o -30 +KPX v comma -80 +KPX v a -20 + +KPX w period -40 +KPX w o -20 +KPX w comma -40 + +KPX x e -10 + +KPX y period -80 +KPX y o -25 +KPX y e -10 +KPX y comma -80 +KPX y a -30 + +KPX z e 10 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 195 186 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 195 186 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 195 186 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 195 186 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 195 186 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 195 186 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 215 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 167 186 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 167 186 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 167 186 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 167 186 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -27 186 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -27 186 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -27 186 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -27 186 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 195 186 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 223 186 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 223 186 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 223 186 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 223 186 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 223 186 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 167 186 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 195 186 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 195 186 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 195 186 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 195 186 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 167 186 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 167 186 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 186 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 112 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 112 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 132 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 112 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 112 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 112 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 112 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 139 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 139 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 139 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 139 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 139 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 139 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 112 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 139 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 139 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 139 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 139 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 112 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 112 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8an.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8an.afm new file mode 100644 index 00000000..b7c69698 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvb8an.afm @@ -0,0 +1,570 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu Mar 15 11:47:27 1990 +Comment UniqueID 28398 +Comment VMusage 7614 43068 +FontName Helvetica-Narrow-Bold +FullName Helvetica Narrow Bold +FamilyName Helvetica +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -139 -228 822 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 228 ; N space ; B 0 0 0 0 ; +C 33 ; WX 273 ; N exclam ; B 74 0 200 718 ; +C 34 ; WX 389 ; N quotedbl ; B 80 447 308 718 ; +C 35 ; WX 456 ; N numbersign ; B 15 0 441 698 ; +C 36 ; WX 456 ; N dollar ; B 25 -115 429 775 ; +C 37 ; WX 729 ; N percent ; B 23 -19 706 710 ; +C 38 ; WX 592 ; N ampersand ; B 44 -19 575 718 ; +C 39 ; WX 228 ; N quoteright ; B 57 445 171 718 ; +C 40 ; WX 273 ; N parenleft ; B 29 -208 257 734 ; +C 41 ; WX 273 ; N parenright ; B 16 -208 244 734 ; +C 42 ; WX 319 ; N asterisk ; B 22 387 297 718 ; +C 43 ; WX 479 ; N plus ; B 33 0 446 506 ; +C 44 ; WX 228 ; N comma ; B 52 -168 175 146 ; +C 45 ; WX 273 ; N hyphen ; B 22 215 251 345 ; +C 46 ; WX 228 ; N period ; B 52 0 175 146 ; +C 47 ; WX 228 ; N slash ; B -27 -19 255 737 ; +C 48 ; WX 456 ; N zero ; B 26 -19 430 710 ; +C 49 ; WX 456 ; N one ; B 57 0 310 710 ; +C 50 ; WX 456 ; N two ; B 21 0 419 710 ; +C 51 ; WX 456 ; N three ; B 22 -19 423 710 ; +C 52 ; WX 456 ; N four ; B 22 0 431 710 ; +C 53 ; WX 456 ; N five ; B 22 -19 423 698 ; +C 54 ; WX 456 ; N six ; B 25 -19 426 710 ; +C 55 ; WX 456 ; N seven ; B 20 0 433 698 ; +C 56 ; WX 456 ; N eight ; B 26 -19 430 710 ; +C 57 ; WX 456 ; N nine ; B 25 -19 428 710 ; +C 58 ; WX 273 ; N colon ; B 75 0 198 512 ; +C 59 ; WX 273 ; N semicolon ; B 75 -168 198 512 ; +C 60 ; WX 479 ; N less ; B 31 -8 448 514 ; +C 61 ; WX 479 ; N equal ; B 33 87 446 419 ; +C 62 ; WX 479 ; N greater ; B 31 -8 448 514 ; +C 63 ; WX 501 ; N question ; B 49 0 456 727 ; +C 64 ; WX 800 ; N at ; B 97 -19 702 737 ; +C 65 ; WX 592 ; N A ; B 16 0 576 718 ; +C 66 ; WX 592 ; N B ; B 62 0 549 718 ; +C 67 ; WX 592 ; N C ; B 36 -19 561 737 ; +C 68 ; WX 592 ; N D ; B 62 0 562 718 ; +C 69 ; WX 547 ; N E ; B 62 0 509 718 ; +C 70 ; WX 501 ; N F ; B 62 0 481 718 ; +C 71 ; WX 638 ; N G ; B 36 -19 585 737 ; +C 72 ; WX 592 ; N H ; B 58 0 534 718 ; +C 73 ; WX 228 ; N I ; B 52 0 175 718 ; +C 74 ; WX 456 ; N J ; B 18 -18 397 718 ; +C 75 ; WX 592 ; N K ; B 71 0 592 718 ; +C 76 ; WX 501 ; N L ; B 62 0 478 718 ; +C 77 ; WX 683 ; N M ; B 57 0 627 718 ; +C 78 ; WX 592 ; N N ; B 57 0 536 718 ; +C 79 ; WX 638 ; N O ; B 36 -19 602 737 ; +C 80 ; WX 547 ; N P ; B 62 0 514 718 ; +C 81 ; WX 638 ; N Q ; B 36 -52 604 737 ; +C 82 ; WX 592 ; N R ; B 62 0 555 718 ; +C 83 ; WX 547 ; N S ; B 32 -19 516 737 ; +C 84 ; WX 501 ; N T ; B 11 0 490 718 ; +C 85 ; WX 592 ; N U ; B 59 -19 534 718 ; +C 86 ; WX 547 ; N V ; B 16 0 531 718 ; +C 87 ; WX 774 ; N W ; B 13 0 762 718 ; +C 88 ; WX 547 ; N X ; B 11 0 535 718 ; +C 89 ; WX 547 ; N Y ; B 12 0 535 718 ; +C 90 ; WX 501 ; N Z ; B 20 0 481 718 ; +C 91 ; WX 273 ; N bracketleft ; B 52 -196 253 722 ; +C 92 ; WX 228 ; N backslash ; B -27 -19 255 737 ; +C 93 ; WX 273 ; N bracketright ; B 20 -196 221 722 ; +C 94 ; WX 479 ; N asciicircum ; B 51 323 428 698 ; +C 95 ; WX 456 ; N underscore ; B 0 -125 456 -75 ; +C 96 ; WX 228 ; N quoteleft ; B 57 454 171 727 ; +C 97 ; WX 456 ; N a ; B 24 -14 432 546 ; +C 98 ; WX 501 ; N b ; B 50 -14 474 718 ; +C 99 ; WX 456 ; N c ; B 28 -14 430 546 ; +C 100 ; WX 501 ; N d ; B 28 -14 452 718 ; +C 101 ; WX 456 ; N e ; B 19 -14 433 546 ; +C 102 ; WX 273 ; N f ; B 8 0 261 727 ; L i fi ; L l fl ; +C 103 ; WX 501 ; N g ; B 33 -217 453 546 ; +C 104 ; WX 501 ; N h ; B 53 0 448 718 ; +C 105 ; WX 228 ; N i ; B 57 0 171 725 ; +C 106 ; WX 228 ; N j ; B 2 -214 171 725 ; +C 107 ; WX 456 ; N k ; B 57 0 461 718 ; +C 108 ; WX 228 ; N l ; B 57 0 171 718 ; +C 109 ; WX 729 ; N m ; B 52 0 677 546 ; +C 110 ; WX 501 ; N n ; B 53 0 448 546 ; +C 111 ; WX 501 ; N o ; B 28 -14 474 546 ; +C 112 ; WX 501 ; N p ; B 51 -207 474 546 ; +C 113 ; WX 501 ; N q ; B 28 -207 453 546 ; +C 114 ; WX 319 ; N r ; B 52 0 306 546 ; +C 115 ; WX 456 ; N s ; B 25 -14 426 546 ; +C 116 ; WX 273 ; N t ; B 8 -6 253 676 ; +C 117 ; WX 501 ; N u ; B 54 -14 447 532 ; +C 118 ; WX 456 ; N v ; B 11 0 445 532 ; +C 119 ; WX 638 ; N w ; B 8 0 631 532 ; +C 120 ; WX 456 ; N x ; B 12 0 444 532 ; +C 121 ; WX 456 ; N y ; B 8 -214 442 532 ; +C 122 ; WX 410 ; N z ; B 16 0 394 532 ; +C 123 ; WX 319 ; N braceleft ; B 39 -196 299 722 ; +C 124 ; WX 230 ; N bar ; B 69 -19 161 737 ; +C 125 ; WX 319 ; N braceright ; B 20 -196 280 722 ; +C 126 ; WX 479 ; N asciitilde ; B 50 163 429 343 ; +C 161 ; WX 273 ; N exclamdown ; B 74 -186 200 532 ; +C 162 ; WX 456 ; N cent ; B 28 -118 430 628 ; +C 163 ; WX 456 ; N sterling ; B 23 -16 444 718 ; +C 164 ; WX 137 ; N fraction ; B -139 -19 276 710 ; +C 165 ; WX 456 ; N yen ; B -7 0 463 698 ; +C 166 ; WX 456 ; N florin ; B -8 -210 423 737 ; +C 167 ; WX 456 ; N section ; B 28 -184 428 727 ; +C 168 ; WX 456 ; N currency ; B -2 76 458 636 ; +C 169 ; WX 195 ; N quotesingle ; B 57 447 138 718 ; +C 170 ; WX 410 ; N quotedblleft ; B 52 454 358 727 ; +C 171 ; WX 456 ; N guillemotleft ; B 72 76 384 484 ; +C 172 ; WX 273 ; N guilsinglleft ; B 68 76 205 484 ; +C 173 ; WX 273 ; N guilsinglright ; B 68 76 205 484 ; +C 174 ; WX 501 ; N fi ; B 8 0 444 727 ; +C 175 ; WX 501 ; N fl ; B 8 0 444 727 ; +C 177 ; WX 456 ; N endash ; B 0 227 456 333 ; +C 178 ; WX 456 ; N dagger ; B 30 -171 426 718 ; +C 179 ; WX 456 ; N daggerdbl ; B 30 -171 426 718 ; +C 180 ; WX 228 ; N periodcentered ; B 48 172 180 334 ; +C 182 ; WX 456 ; N paragraph ; B -7 -191 442 700 ; +C 183 ; WX 287 ; N bullet ; B 8 194 279 524 ; +C 184 ; WX 228 ; N quotesinglbase ; B 57 -146 171 127 ; +C 185 ; WX 410 ; N quotedblbase ; B 52 -146 358 127 ; +C 186 ; WX 410 ; N quotedblright ; B 52 445 358 718 ; +C 187 ; WX 456 ; N guillemotright ; B 72 76 384 484 ; +C 188 ; WX 820 ; N ellipsis ; B 75 0 745 146 ; +C 189 ; WX 820 ; N perthousand ; B -2 -19 822 710 ; +C 191 ; WX 501 ; N questiondown ; B 45 -195 452 532 ; +C 193 ; WX 273 ; N grave ; B -19 604 184 750 ; +C 194 ; WX 273 ; N acute ; B 89 604 292 750 ; +C 195 ; WX 273 ; N circumflex ; B -8 604 281 750 ; +C 196 ; WX 273 ; N tilde ; B -14 610 287 737 ; +C 197 ; WX 273 ; N macron ; B -5 604 278 678 ; +C 198 ; WX 273 ; N breve ; B -2 604 275 750 ; +C 199 ; WX 273 ; N dotaccent ; B 85 614 189 729 ; +C 200 ; WX 273 ; N dieresis ; B 5 614 268 729 ; +C 202 ; WX 273 ; N ring ; B 48 568 225 776 ; +C 203 ; WX 273 ; N cedilla ; B 5 -228 201 0 ; +C 205 ; WX 273 ; N hungarumlaut ; B 7 604 399 750 ; +C 206 ; WX 273 ; N ogonek ; B 58 -228 249 0 ; +C 207 ; WX 273 ; N caron ; B -8 604 281 750 ; +C 208 ; WX 820 ; N emdash ; B 0 227 820 333 ; +C 225 ; WX 820 ; N AE ; B 4 0 782 718 ; +C 227 ; WX 303 ; N ordfeminine ; B 18 276 285 737 ; +C 232 ; WX 501 ; N Lslash ; B -16 0 478 718 ; +C 233 ; WX 638 ; N Oslash ; B 27 -27 610 745 ; +C 234 ; WX 820 ; N OE ; B 30 -19 788 737 ; +C 235 ; WX 299 ; N ordmasculine ; B 5 276 295 737 ; +C 241 ; WX 729 ; N ae ; B 24 -14 704 546 ; +C 245 ; WX 228 ; N dotlessi ; B 57 0 171 532 ; +C 248 ; WX 228 ; N lslash ; B -15 0 243 718 ; +C 249 ; WX 501 ; N oslash ; B 18 -29 483 560 ; +C 250 ; WX 774 ; N oe ; B 28 -14 748 546 ; +C 251 ; WX 501 ; N germandbls ; B 57 -14 475 731 ; +C -1 ; WX 501 ; N Zcaron ; B 20 0 481 936 ; +C -1 ; WX 456 ; N ccedilla ; B 28 -228 430 546 ; +C -1 ; WX 456 ; N ydieresis ; B 8 -214 442 729 ; +C -1 ; WX 456 ; N atilde ; B 24 -14 432 737 ; +C -1 ; WX 228 ; N icircumflex ; B -30 0 259 750 ; +C -1 ; WX 273 ; N threesuperior ; B 7 271 267 710 ; +C -1 ; WX 456 ; N ecircumflex ; B 19 -14 433 750 ; +C -1 ; WX 501 ; N thorn ; B 51 -208 474 718 ; +C -1 ; WX 456 ; N egrave ; B 19 -14 433 750 ; +C -1 ; WX 273 ; N twosuperior ; B 7 283 266 710 ; +C -1 ; WX 456 ; N eacute ; B 19 -14 433 750 ; +C -1 ; WX 501 ; N otilde ; B 28 -14 474 737 ; +C -1 ; WX 592 ; N Aacute ; B 16 0 576 936 ; +C -1 ; WX 501 ; N ocircumflex ; B 28 -14 474 750 ; +C -1 ; WX 456 ; N yacute ; B 8 -214 442 750 ; +C -1 ; WX 501 ; N udieresis ; B 54 -14 447 729 ; +C -1 ; WX 684 ; N threequarters ; B 13 -19 655 710 ; +C -1 ; WX 456 ; N acircumflex ; B 24 -14 432 750 ; +C -1 ; WX 592 ; N Eth ; B -4 0 562 718 ; +C -1 ; WX 456 ; N edieresis ; B 19 -14 433 729 ; +C -1 ; WX 501 ; N ugrave ; B 54 -14 447 750 ; +C -1 ; WX 820 ; N trademark ; B 36 306 784 718 ; +C -1 ; WX 501 ; N ograve ; B 28 -14 474 750 ; +C -1 ; WX 456 ; N scaron ; B 25 -14 426 750 ; +C -1 ; WX 228 ; N Idieresis ; B -17 0 246 915 ; +C -1 ; WX 501 ; N uacute ; B 54 -14 447 750 ; +C -1 ; WX 456 ; N agrave ; B 24 -14 432 750 ; +C -1 ; WX 501 ; N ntilde ; B 53 0 448 737 ; +C -1 ; WX 456 ; N aring ; B 24 -14 432 776 ; +C -1 ; WX 410 ; N zcaron ; B 16 0 394 750 ; +C -1 ; WX 228 ; N Icircumflex ; B -30 0 259 936 ; +C -1 ; WX 592 ; N Ntilde ; B 57 0 536 923 ; +C -1 ; WX 501 ; N ucircumflex ; B 54 -14 447 750 ; +C -1 ; WX 547 ; N Ecircumflex ; B 62 0 509 936 ; +C -1 ; WX 228 ; N Iacute ; B 52 0 270 936 ; +C -1 ; WX 592 ; N Ccedilla ; B 36 -228 561 737 ; +C -1 ; WX 638 ; N Odieresis ; B 36 -19 602 915 ; +C -1 ; WX 547 ; N Scaron ; B 32 -19 516 936 ; +C -1 ; WX 547 ; N Edieresis ; B 62 0 509 915 ; +C -1 ; WX 228 ; N Igrave ; B -41 0 175 936 ; +C -1 ; WX 456 ; N adieresis ; B 24 -14 432 729 ; +C -1 ; WX 638 ; N Ograve ; B 36 -19 602 936 ; +C -1 ; WX 547 ; N Egrave ; B 62 0 509 936 ; +C -1 ; WX 547 ; N Ydieresis ; B 12 0 535 915 ; +C -1 ; WX 604 ; N registered ; B -9 -19 613 737 ; +C -1 ; WX 638 ; N Otilde ; B 36 -19 602 923 ; +C -1 ; WX 684 ; N onequarter ; B 21 -19 628 710 ; +C -1 ; WX 592 ; N Ugrave ; B 59 -19 534 936 ; +C -1 ; WX 592 ; N Ucircumflex ; B 59 -19 534 936 ; +C -1 ; WX 547 ; N Thorn ; B 62 0 514 718 ; +C -1 ; WX 479 ; N divide ; B 33 -42 446 548 ; +C -1 ; WX 592 ; N Atilde ; B 16 0 576 923 ; +C -1 ; WX 592 ; N Uacute ; B 59 -19 534 936 ; +C -1 ; WX 638 ; N Ocircumflex ; B 36 -19 602 936 ; +C -1 ; WX 479 ; N logicalnot ; B 33 108 446 419 ; +C -1 ; WX 592 ; N Aring ; B 16 0 576 962 ; +C -1 ; WX 228 ; N idieresis ; B -17 0 246 729 ; +C -1 ; WX 228 ; N iacute ; B 57 0 270 750 ; +C -1 ; WX 456 ; N aacute ; B 24 -14 432 750 ; +C -1 ; WX 479 ; N plusminus ; B 33 0 446 506 ; +C -1 ; WX 479 ; N multiply ; B 33 1 447 505 ; +C -1 ; WX 592 ; N Udieresis ; B 59 -19 534 915 ; +C -1 ; WX 479 ; N minus ; B 33 197 446 309 ; +C -1 ; WX 273 ; N onesuperior ; B 21 283 194 710 ; +C -1 ; WX 547 ; N Eacute ; B 62 0 509 936 ; +C -1 ; WX 592 ; N Acircumflex ; B 16 0 576 936 ; +C -1 ; WX 604 ; N copyright ; B -9 -19 614 737 ; +C -1 ; WX 592 ; N Agrave ; B 16 0 576 936 ; +C -1 ; WX 501 ; N odieresis ; B 28 -14 474 729 ; +C -1 ; WX 501 ; N oacute ; B 28 -14 474 750 ; +C -1 ; WX 328 ; N degree ; B 47 426 281 712 ; +C -1 ; WX 228 ; N igrave ; B -41 0 171 750 ; +C -1 ; WX 501 ; N mu ; B 54 -207 447 532 ; +C -1 ; WX 638 ; N Oacute ; B 36 -19 602 936 ; +C -1 ; WX 501 ; N eth ; B 28 -14 474 737 ; +C -1 ; WX 592 ; N Adieresis ; B 16 0 576 915 ; +C -1 ; WX 547 ; N Yacute ; B 12 0 535 936 ; +C -1 ; WX 230 ; N brokenbar ; B 69 -19 161 737 ; +C -1 ; WX 684 ; N onehalf ; B 21 -19 651 710 ; +EndCharMetrics +StartKernData +StartKernPairs 209 + +KPX A y -24 +KPX A w -24 +KPX A v -32 +KPX A u -24 +KPX A Y -89 +KPX A W -48 +KPX A V -65 +KPX A U -40 +KPX A T -73 +KPX A Q -32 +KPX A O -32 +KPX A G -40 +KPX A C -32 + +KPX B U -7 +KPX B A -24 + +KPX D period -24 +KPX D comma -24 +KPX D Y -56 +KPX D W -32 +KPX D V -32 +KPX D A -32 + +KPX F period -81 +KPX F comma -81 +KPX F a -15 +KPX F A -65 + +KPX J u -15 +KPX J period -15 +KPX J comma -15 +KPX J A -15 + +KPX K y -32 +KPX K u -24 +KPX K o -28 +KPX K e -11 +KPX K O -24 + +KPX L y -24 +KPX L quoteright -114 +KPX L quotedblright -114 +KPX L Y -97 +KPX L W -65 +KPX L V -89 +KPX L T -73 + +KPX O period -32 +KPX O comma -32 +KPX O Y -56 +KPX O X -40 +KPX O W -40 +KPX O V -40 +KPX O T -32 +KPX O A -40 + +KPX P period -97 +KPX P o -32 +KPX P e -24 +KPX P comma -97 +KPX P a -24 +KPX P A -81 + +KPX Q period 16 +KPX Q comma 16 +KPX Q U -7 + +KPX R Y -40 +KPX R W -32 +KPX R V -40 +KPX R U -15 +KPX R T -15 +KPX R O -15 + +KPX T y -48 +KPX T w -48 +KPX T u -73 +KPX T semicolon -32 +KPX T r -65 +KPX T period -65 +KPX T o -65 +KPX T hyphen -97 +KPX T e -48 +KPX T comma -65 +KPX T colon -32 +KPX T a -65 +KPX T O -32 +KPX T A -73 + +KPX U period -24 +KPX U comma -24 +KPX U A -40 + +KPX V u -48 +KPX V semicolon -32 +KPX V period -97 +KPX V o -73 +KPX V hyphen -65 +KPX V e -40 +KPX V comma -97 +KPX V colon -32 +KPX V a -48 +KPX V O -40 +KPX V G -40 +KPX V A -65 + +KPX W y -15 +KPX W u -36 +KPX W semicolon -7 +KPX W period -65 +KPX W o -48 +KPX W hyphen -32 +KPX W e -28 +KPX W comma -65 +KPX W colon -7 +KPX W a -32 +KPX W O -15 +KPX W A -48 + +KPX Y u -81 +KPX Y semicolon -40 +KPX Y period -81 +KPX Y o -81 +KPX Y e -65 +KPX Y comma -81 +KPX Y colon -40 +KPX Y a -73 +KPX Y O -56 +KPX Y A -89 + +KPX a y -15 +KPX a w -11 +KPX a v -11 +KPX a g -7 + +KPX b y -15 +KPX b v -15 +KPX b u -15 +KPX b l -7 + +KPX c y -7 +KPX c l -15 +KPX c k -15 +KPX c h -7 + +KPX colon space -32 + +KPX comma space -32 +KPX comma quoteright -97 +KPX comma quotedblright -97 + +KPX d y -11 +KPX d w -11 +KPX d v -11 +KPX d d -7 + +KPX e y -11 +KPX e x -11 +KPX e w -11 +KPX e v -11 +KPX e period 16 +KPX e comma 8 + +KPX f quoteright 25 +KPX f quotedblright 25 +KPX f period -7 +KPX f o -15 +KPX f e -7 +KPX f comma -7 + +KPX g g -7 +KPX g e 8 + +KPX h y -15 + +KPX k o -11 + +KPX l y -11 +KPX l w -11 + +KPX m y -24 +KPX m u -15 + +KPX n y -15 +KPX n v -32 +KPX n u -7 + +KPX o y -15 +KPX o x -24 +KPX o w -11 +KPX o v -15 + +KPX p y -11 + +KPX period space -32 +KPX period quoteright -97 +KPX period quotedblright -97 + +KPX quotedblright space -65 + +KPX quoteleft quoteleft -37 + +KPX quoteright v -15 +KPX quoteright space -65 +KPX quoteright s -48 +KPX quoteright r -32 +KPX quoteright quoteright -37 +KPX quoteright l -15 +KPX quoteright d -65 + +KPX r y 8 +KPX r v 8 +KPX r t 16 +KPX r s -11 +KPX r q -15 +KPX r period -48 +KPX r o -15 +KPX r hyphen -15 +KPX r g -11 +KPX r d -15 +KPX r comma -48 +KPX r c -15 + +KPX s w -11 + +KPX semicolon space -32 + +KPX space quoteleft -48 +KPX space quotedblleft -65 +KPX space Y -97 +KPX space W -65 +KPX space V -65 +KPX space T -81 + +KPX v period -65 +KPX v o -24 +KPX v comma -65 +KPX v a -15 + +KPX w period -32 +KPX w o -15 +KPX w comma -32 + +KPX x e -7 + +KPX y period -65 +KPX y o -20 +KPX y e -7 +KPX y comma -65 +KPX y a -24 + +KPX z e 8 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 186 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 160 186 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 160 186 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 160 186 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 160 186 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 160 186 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 176 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 137 186 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 137 186 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 137 186 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 137 186 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -22 186 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -22 186 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -22 186 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -22 186 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 160 186 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 183 186 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 183 186 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 183 186 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 183 186 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 183 186 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 137 186 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 160 186 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 160 186 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 160 186 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 160 186 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 137 186 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 137 186 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 114 186 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 92 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 92 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 92 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 92 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 92 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 92 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 108 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 92 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 92 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 92 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 92 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -22 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -22 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -22 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -22 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 114 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 114 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 114 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 114 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 114 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 114 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 92 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 114 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 114 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 114 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 114 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 92 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 92 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 69 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8a.afm new file mode 100644 index 00000000..b6cff415 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8a.afm @@ -0,0 +1,570 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu Mar 15 10:44:33 1990 +Comment UniqueID 28371 +Comment VMusage 7614 43068 +FontName Helvetica-BoldOblique +FullName Helvetica Bold Oblique +FamilyName Helvetica +Weight Bold +ItalicAngle -12 +IsFixedPitch false +FontBBox -174 -228 1114 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 94 0 397 718 ; +C 34 ; WX 474 ; N quotedbl ; B 193 447 529 718 ; +C 35 ; WX 556 ; N numbersign ; B 60 0 644 698 ; +C 36 ; WX 556 ; N dollar ; B 67 -115 622 775 ; +C 37 ; WX 889 ; N percent ; B 136 -19 901 710 ; +C 38 ; WX 722 ; N ampersand ; B 89 -19 732 718 ; +C 39 ; WX 278 ; N quoteright ; B 167 445 362 718 ; +C 40 ; WX 333 ; N parenleft ; B 76 -208 470 734 ; +C 41 ; WX 333 ; N parenright ; B -25 -208 369 734 ; +C 42 ; WX 389 ; N asterisk ; B 146 387 481 718 ; +C 43 ; WX 584 ; N plus ; B 82 0 610 506 ; +C 44 ; WX 278 ; N comma ; B 28 -168 245 146 ; +C 45 ; WX 333 ; N hyphen ; B 73 215 379 345 ; +C 46 ; WX 278 ; N period ; B 64 0 245 146 ; +C 47 ; WX 278 ; N slash ; B -37 -19 468 737 ; +C 48 ; WX 556 ; N zero ; B 86 -19 617 710 ; +C 49 ; WX 556 ; N one ; B 173 0 529 710 ; +C 50 ; WX 556 ; N two ; B 26 0 619 710 ; +C 51 ; WX 556 ; N three ; B 65 -19 608 710 ; +C 52 ; WX 556 ; N four ; B 60 0 598 710 ; +C 53 ; WX 556 ; N five ; B 64 -19 636 698 ; +C 54 ; WX 556 ; N six ; B 85 -19 619 710 ; +C 55 ; WX 556 ; N seven ; B 125 0 676 698 ; +C 56 ; WX 556 ; N eight ; B 69 -19 616 710 ; +C 57 ; WX 556 ; N nine ; B 78 -19 615 710 ; +C 58 ; WX 333 ; N colon ; B 92 0 351 512 ; +C 59 ; WX 333 ; N semicolon ; B 56 -168 351 512 ; +C 60 ; WX 584 ; N less ; B 82 -8 655 514 ; +C 61 ; WX 584 ; N equal ; B 58 87 633 419 ; +C 62 ; WX 584 ; N greater ; B 36 -8 609 514 ; +C 63 ; WX 611 ; N question ; B 165 0 671 727 ; +C 64 ; WX 975 ; N at ; B 186 -19 954 737 ; +C 65 ; WX 722 ; N A ; B 20 0 702 718 ; +C 66 ; WX 722 ; N B ; B 76 0 764 718 ; +C 67 ; WX 722 ; N C ; B 107 -19 789 737 ; +C 68 ; WX 722 ; N D ; B 76 0 777 718 ; +C 69 ; WX 667 ; N E ; B 76 0 757 718 ; +C 70 ; WX 611 ; N F ; B 76 0 740 718 ; +C 71 ; WX 778 ; N G ; B 108 -19 817 737 ; +C 72 ; WX 722 ; N H ; B 71 0 804 718 ; +C 73 ; WX 278 ; N I ; B 64 0 367 718 ; +C 74 ; WX 556 ; N J ; B 60 -18 637 718 ; +C 75 ; WX 722 ; N K ; B 87 0 858 718 ; +C 76 ; WX 611 ; N L ; B 76 0 611 718 ; +C 77 ; WX 833 ; N M ; B 69 0 918 718 ; +C 78 ; WX 722 ; N N ; B 69 0 807 718 ; +C 79 ; WX 778 ; N O ; B 107 -19 823 737 ; +C 80 ; WX 667 ; N P ; B 76 0 738 718 ; +C 81 ; WX 778 ; N Q ; B 107 -52 823 737 ; +C 82 ; WX 722 ; N R ; B 76 0 778 718 ; +C 83 ; WX 667 ; N S ; B 81 -19 718 737 ; +C 84 ; WX 611 ; N T ; B 140 0 751 718 ; +C 85 ; WX 722 ; N U ; B 116 -19 804 718 ; +C 86 ; WX 667 ; N V ; B 172 0 801 718 ; +C 87 ; WX 944 ; N W ; B 169 0 1082 718 ; +C 88 ; WX 667 ; N X ; B 14 0 791 718 ; +C 89 ; WX 667 ; N Y ; B 168 0 806 718 ; +C 90 ; WX 611 ; N Z ; B 25 0 737 718 ; +C 91 ; WX 333 ; N bracketleft ; B 21 -196 462 722 ; +C 92 ; WX 278 ; N backslash ; B 124 -19 307 737 ; +C 93 ; WX 333 ; N bracketright ; B -18 -196 423 722 ; +C 94 ; WX 584 ; N asciicircum ; B 131 323 591 698 ; +C 95 ; WX 556 ; N underscore ; B -27 -125 540 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 165 454 361 727 ; +C 97 ; WX 556 ; N a ; B 55 -14 583 546 ; +C 98 ; WX 611 ; N b ; B 61 -14 645 718 ; +C 99 ; WX 556 ; N c ; B 79 -14 599 546 ; +C 100 ; WX 611 ; N d ; B 82 -14 704 718 ; +C 101 ; WX 556 ; N e ; B 70 -14 593 546 ; +C 102 ; WX 333 ; N f ; B 87 0 469 727 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 38 -217 666 546 ; +C 104 ; WX 611 ; N h ; B 65 0 629 718 ; +C 105 ; WX 278 ; N i ; B 69 0 363 725 ; +C 106 ; WX 278 ; N j ; B -42 -214 363 725 ; +C 107 ; WX 556 ; N k ; B 69 0 670 718 ; +C 108 ; WX 278 ; N l ; B 69 0 362 718 ; +C 109 ; WX 889 ; N m ; B 64 0 909 546 ; +C 110 ; WX 611 ; N n ; B 65 0 629 546 ; +C 111 ; WX 611 ; N o ; B 82 -14 643 546 ; +C 112 ; WX 611 ; N p ; B 18 -207 645 546 ; +C 113 ; WX 611 ; N q ; B 80 -207 665 546 ; +C 114 ; WX 389 ; N r ; B 64 0 489 546 ; +C 115 ; WX 556 ; N s ; B 63 -14 584 546 ; +C 116 ; WX 333 ; N t ; B 100 -6 422 676 ; +C 117 ; WX 611 ; N u ; B 98 -14 658 532 ; +C 118 ; WX 556 ; N v ; B 126 0 656 532 ; +C 119 ; WX 778 ; N w ; B 123 0 882 532 ; +C 120 ; WX 556 ; N x ; B 15 0 648 532 ; +C 121 ; WX 556 ; N y ; B 42 -214 652 532 ; +C 122 ; WX 500 ; N z ; B 20 0 583 532 ; +C 123 ; WX 389 ; N braceleft ; B 94 -196 518 722 ; +C 124 ; WX 280 ; N bar ; B 80 -19 353 737 ; +C 125 ; WX 389 ; N braceright ; B -18 -196 407 722 ; +C 126 ; WX 584 ; N asciitilde ; B 115 163 577 343 ; +C 161 ; WX 333 ; N exclamdown ; B 50 -186 353 532 ; +C 162 ; WX 556 ; N cent ; B 79 -118 599 628 ; +C 163 ; WX 556 ; N sterling ; B 50 -16 635 718 ; +C 164 ; WX 167 ; N fraction ; B -174 -19 487 710 ; +C 165 ; WX 556 ; N yen ; B 60 0 713 698 ; +C 166 ; WX 556 ; N florin ; B -50 -210 669 737 ; +C 167 ; WX 556 ; N section ; B 61 -184 598 727 ; +C 168 ; WX 556 ; N currency ; B 27 76 680 636 ; +C 169 ; WX 238 ; N quotesingle ; B 165 447 321 718 ; +C 170 ; WX 500 ; N quotedblleft ; B 160 454 588 727 ; +C 171 ; WX 556 ; N guillemotleft ; B 135 76 571 484 ; +C 172 ; WX 333 ; N guilsinglleft ; B 130 76 353 484 ; +C 173 ; WX 333 ; N guilsinglright ; B 99 76 322 484 ; +C 174 ; WX 611 ; N fi ; B 87 0 696 727 ; +C 175 ; WX 611 ; N fl ; B 87 0 695 727 ; +C 177 ; WX 556 ; N endash ; B 48 227 627 333 ; +C 178 ; WX 556 ; N dagger ; B 118 -171 626 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 46 -171 628 718 ; +C 180 ; WX 278 ; N periodcentered ; B 110 172 276 334 ; +C 182 ; WX 556 ; N paragraph ; B 98 -191 688 700 ; +C 183 ; WX 350 ; N bullet ; B 83 194 420 524 ; +C 184 ; WX 278 ; N quotesinglbase ; B 41 -146 236 127 ; +C 185 ; WX 500 ; N quotedblbase ; B 36 -146 463 127 ; +C 186 ; WX 500 ; N quotedblright ; B 162 445 589 718 ; +C 187 ; WX 556 ; N guillemotright ; B 104 76 540 484 ; +C 188 ; WX 1000 ; N ellipsis ; B 92 0 939 146 ; +C 189 ; WX 1000 ; N perthousand ; B 76 -19 1038 710 ; +C 191 ; WX 611 ; N questiondown ; B 53 -195 559 532 ; +C 193 ; WX 333 ; N grave ; B 136 604 353 750 ; +C 194 ; WX 333 ; N acute ; B 236 604 515 750 ; +C 195 ; WX 333 ; N circumflex ; B 118 604 471 750 ; +C 196 ; WX 333 ; N tilde ; B 113 610 507 737 ; +C 197 ; WX 333 ; N macron ; B 122 604 483 678 ; +C 198 ; WX 333 ; N breve ; B 156 604 494 750 ; +C 199 ; WX 333 ; N dotaccent ; B 235 614 385 729 ; +C 200 ; WX 333 ; N dieresis ; B 137 614 482 729 ; +C 202 ; WX 333 ; N ring ; B 200 568 420 776 ; +C 203 ; WX 333 ; N cedilla ; B -37 -228 220 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 137 604 645 750 ; +C 206 ; WX 333 ; N ogonek ; B 41 -228 264 0 ; +C 207 ; WX 333 ; N caron ; B 149 604 502 750 ; +C 208 ; WX 1000 ; N emdash ; B 48 227 1071 333 ; +C 225 ; WX 1000 ; N AE ; B 5 0 1100 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 92 276 465 737 ; +C 232 ; WX 611 ; N Lslash ; B 34 0 611 718 ; +C 233 ; WX 778 ; N Oslash ; B 35 -27 894 745 ; +C 234 ; WX 1000 ; N OE ; B 99 -19 1114 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 92 276 485 737 ; +C 241 ; WX 889 ; N ae ; B 56 -14 923 546 ; +C 245 ; WX 278 ; N dotlessi ; B 69 0 322 532 ; +C 248 ; WX 278 ; N lslash ; B 40 0 407 718 ; +C 249 ; WX 611 ; N oslash ; B 22 -29 701 560 ; +C 250 ; WX 944 ; N oe ; B 82 -14 977 546 ; +C 251 ; WX 611 ; N germandbls ; B 69 -14 657 731 ; +C -1 ; WX 611 ; N Zcaron ; B 25 0 737 936 ; +C -1 ; WX 556 ; N ccedilla ; B 79 -228 599 546 ; +C -1 ; WX 556 ; N ydieresis ; B 42 -214 652 729 ; +C -1 ; WX 556 ; N atilde ; B 55 -14 619 737 ; +C -1 ; WX 278 ; N icircumflex ; B 69 0 444 750 ; +C -1 ; WX 333 ; N threesuperior ; B 91 271 441 710 ; +C -1 ; WX 556 ; N ecircumflex ; B 70 -14 593 750 ; +C -1 ; WX 611 ; N thorn ; B 18 -208 645 718 ; +C -1 ; WX 556 ; N egrave ; B 70 -14 593 750 ; +C -1 ; WX 333 ; N twosuperior ; B 69 283 449 710 ; +C -1 ; WX 556 ; N eacute ; B 70 -14 627 750 ; +C -1 ; WX 611 ; N otilde ; B 82 -14 646 737 ; +C -1 ; WX 722 ; N Aacute ; B 20 0 750 936 ; +C -1 ; WX 611 ; N ocircumflex ; B 82 -14 643 750 ; +C -1 ; WX 556 ; N yacute ; B 42 -214 652 750 ; +C -1 ; WX 611 ; N udieresis ; B 98 -14 658 729 ; +C -1 ; WX 834 ; N threequarters ; B 99 -19 839 710 ; +C -1 ; WX 556 ; N acircumflex ; B 55 -14 583 750 ; +C -1 ; WX 722 ; N Eth ; B 62 0 777 718 ; +C -1 ; WX 556 ; N edieresis ; B 70 -14 594 729 ; +C -1 ; WX 611 ; N ugrave ; B 98 -14 658 750 ; +C -1 ; WX 1000 ; N trademark ; B 179 306 1109 718 ; +C -1 ; WX 611 ; N ograve ; B 82 -14 643 750 ; +C -1 ; WX 556 ; N scaron ; B 63 -14 614 750 ; +C -1 ; WX 278 ; N Idieresis ; B 64 0 494 915 ; +C -1 ; WX 611 ; N uacute ; B 98 -14 658 750 ; +C -1 ; WX 556 ; N agrave ; B 55 -14 583 750 ; +C -1 ; WX 611 ; N ntilde ; B 65 0 646 737 ; +C -1 ; WX 556 ; N aring ; B 55 -14 583 776 ; +C -1 ; WX 500 ; N zcaron ; B 20 0 586 750 ; +C -1 ; WX 278 ; N Icircumflex ; B 64 0 484 936 ; +C -1 ; WX 722 ; N Ntilde ; B 69 0 807 923 ; +C -1 ; WX 611 ; N ucircumflex ; B 98 -14 658 750 ; +C -1 ; WX 667 ; N Ecircumflex ; B 76 0 757 936 ; +C -1 ; WX 278 ; N Iacute ; B 64 0 528 936 ; +C -1 ; WX 722 ; N Ccedilla ; B 107 -228 789 737 ; +C -1 ; WX 778 ; N Odieresis ; B 107 -19 823 915 ; +C -1 ; WX 667 ; N Scaron ; B 81 -19 718 936 ; +C -1 ; WX 667 ; N Edieresis ; B 76 0 757 915 ; +C -1 ; WX 278 ; N Igrave ; B 64 0 367 936 ; +C -1 ; WX 556 ; N adieresis ; B 55 -14 594 729 ; +C -1 ; WX 778 ; N Ograve ; B 107 -19 823 936 ; +C -1 ; WX 667 ; N Egrave ; B 76 0 757 936 ; +C -1 ; WX 667 ; N Ydieresis ; B 168 0 806 915 ; +C -1 ; WX 737 ; N registered ; B 55 -19 834 737 ; +C -1 ; WX 778 ; N Otilde ; B 107 -19 823 923 ; +C -1 ; WX 834 ; N onequarter ; B 132 -19 806 710 ; +C -1 ; WX 722 ; N Ugrave ; B 116 -19 804 936 ; +C -1 ; WX 722 ; N Ucircumflex ; B 116 -19 804 936 ; +C -1 ; WX 667 ; N Thorn ; B 76 0 716 718 ; +C -1 ; WX 584 ; N divide ; B 82 -42 610 548 ; +C -1 ; WX 722 ; N Atilde ; B 20 0 741 923 ; +C -1 ; WX 722 ; N Uacute ; B 116 -19 804 936 ; +C -1 ; WX 778 ; N Ocircumflex ; B 107 -19 823 936 ; +C -1 ; WX 584 ; N logicalnot ; B 105 108 633 419 ; +C -1 ; WX 722 ; N Aring ; B 20 0 702 962 ; +C -1 ; WX 278 ; N idieresis ; B 69 0 455 729 ; +C -1 ; WX 278 ; N iacute ; B 69 0 488 750 ; +C -1 ; WX 556 ; N aacute ; B 55 -14 627 750 ; +C -1 ; WX 584 ; N plusminus ; B 40 0 625 506 ; +C -1 ; WX 584 ; N multiply ; B 57 1 635 505 ; +C -1 ; WX 722 ; N Udieresis ; B 116 -19 804 915 ; +C -1 ; WX 584 ; N minus ; B 82 197 610 309 ; +C -1 ; WX 333 ; N onesuperior ; B 148 283 388 710 ; +C -1 ; WX 667 ; N Eacute ; B 76 0 757 936 ; +C -1 ; WX 722 ; N Acircumflex ; B 20 0 706 936 ; +C -1 ; WX 737 ; N copyright ; B 56 -19 835 737 ; +C -1 ; WX 722 ; N Agrave ; B 20 0 702 936 ; +C -1 ; WX 611 ; N odieresis ; B 82 -14 643 729 ; +C -1 ; WX 611 ; N oacute ; B 82 -14 654 750 ; +C -1 ; WX 400 ; N degree ; B 175 426 467 712 ; +C -1 ; WX 278 ; N igrave ; B 69 0 326 750 ; +C -1 ; WX 611 ; N mu ; B 22 -207 658 532 ; +C -1 ; WX 778 ; N Oacute ; B 107 -19 823 936 ; +C -1 ; WX 611 ; N eth ; B 82 -14 670 737 ; +C -1 ; WX 722 ; N Adieresis ; B 20 0 716 915 ; +C -1 ; WX 667 ; N Yacute ; B 168 0 806 936 ; +C -1 ; WX 280 ; N brokenbar ; B 80 -19 353 737 ; +C -1 ; WX 834 ; N onehalf ; B 132 -19 858 710 ; +EndCharMetrics +StartKernData +StartKernPairs 209 + +KPX A y -30 +KPX A w -30 +KPX A v -40 +KPX A u -30 +KPX A Y -110 +KPX A W -60 +KPX A V -80 +KPX A U -50 +KPX A T -90 +KPX A Q -40 +KPX A O -40 +KPX A G -50 +KPX A C -40 + +KPX B U -10 +KPX B A -30 + +KPX D period -30 +KPX D comma -30 +KPX D Y -70 +KPX D W -40 +KPX D V -40 +KPX D A -40 + +KPX F period -100 +KPX F comma -100 +KPX F a -20 +KPX F A -80 + +KPX J u -20 +KPX J period -20 +KPX J comma -20 +KPX J A -20 + +KPX K y -40 +KPX K u -30 +KPX K o -35 +KPX K e -15 +KPX K O -30 + +KPX L y -30 +KPX L quoteright -140 +KPX L quotedblright -140 +KPX L Y -120 +KPX L W -80 +KPX L V -110 +KPX L T -90 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -50 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -50 + +KPX P period -120 +KPX P o -40 +KPX P e -30 +KPX P comma -120 +KPX P a -30 +KPX P A -100 + +KPX Q period 20 +KPX Q comma 20 +KPX Q U -10 + +KPX R Y -50 +KPX R W -40 +KPX R V -50 +KPX R U -20 +KPX R T -20 +KPX R O -20 + +KPX T y -60 +KPX T w -60 +KPX T u -90 +KPX T semicolon -40 +KPX T r -80 +KPX T period -80 +KPX T o -80 +KPX T hyphen -120 +KPX T e -60 +KPX T comma -80 +KPX T colon -40 +KPX T a -80 +KPX T O -40 +KPX T A -90 + +KPX U period -30 +KPX U comma -30 +KPX U A -50 + +KPX V u -60 +KPX V semicolon -40 +KPX V period -120 +KPX V o -90 +KPX V hyphen -80 +KPX V e -50 +KPX V comma -120 +KPX V colon -40 +KPX V a -60 +KPX V O -50 +KPX V G -50 +KPX V A -80 + +KPX W y -20 +KPX W u -45 +KPX W semicolon -10 +KPX W period -80 +KPX W o -60 +KPX W hyphen -40 +KPX W e -35 +KPX W comma -80 +KPX W colon -10 +KPX W a -40 +KPX W O -20 +KPX W A -60 + +KPX Y u -100 +KPX Y semicolon -50 +KPX Y period -100 +KPX Y o -100 +KPX Y e -80 +KPX Y comma -100 +KPX Y colon -50 +KPX Y a -90 +KPX Y O -70 +KPX Y A -110 + +KPX a y -20 +KPX a w -15 +KPX a v -15 +KPX a g -10 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b l -10 + +KPX c y -10 +KPX c l -20 +KPX c k -20 +KPX c h -10 + +KPX colon space -40 + +KPX comma space -40 +KPX comma quoteright -120 +KPX comma quotedblright -120 + +KPX d y -15 +KPX d w -15 +KPX d v -15 +KPX d d -10 + +KPX e y -15 +KPX e x -15 +KPX e w -15 +KPX e v -15 +KPX e period 20 +KPX e comma 10 + +KPX f quoteright 30 +KPX f quotedblright 30 +KPX f period -10 +KPX f o -20 +KPX f e -10 +KPX f comma -10 + +KPX g g -10 +KPX g e 10 + +KPX h y -20 + +KPX k o -15 + +KPX l y -15 +KPX l w -15 + +KPX m y -30 +KPX m u -20 + +KPX n y -20 +KPX n v -40 +KPX n u -10 + +KPX o y -20 +KPX o x -30 +KPX o w -15 +KPX o v -20 + +KPX p y -15 + +KPX period space -40 +KPX period quoteright -120 +KPX period quotedblright -120 + +KPX quotedblright space -80 + +KPX quoteleft quoteleft -46 + +KPX quoteright v -20 +KPX quoteright space -80 +KPX quoteright s -60 +KPX quoteright r -40 +KPX quoteright quoteright -46 +KPX quoteright l -20 +KPX quoteright d -80 + +KPX r y 10 +KPX r v 10 +KPX r t 20 +KPX r s -15 +KPX r q -20 +KPX r period -60 +KPX r o -20 +KPX r hyphen -20 +KPX r g -15 +KPX r d -20 +KPX r comma -60 +KPX r c -20 + +KPX s w -15 + +KPX semicolon space -40 + +KPX space quoteleft -60 +KPX space quotedblleft -80 +KPX space Y -120 +KPX space W -80 +KPX space V -80 +KPX space T -100 + +KPX v period -80 +KPX v o -30 +KPX v comma -80 +KPX v a -20 + +KPX w period -40 +KPX w o -20 +KPX w comma -40 + +KPX x e -10 + +KPX y period -80 +KPX y o -25 +KPX y e -10 +KPX y comma -80 +KPX y a -30 + +KPX z e 10 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 235 186 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 235 186 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 235 186 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 235 186 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 235 186 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 235 186 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 215 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 207 186 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 207 186 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 207 186 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 207 186 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 13 186 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 13 186 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 13 186 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 13 186 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 235 186 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 263 186 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 263 186 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 263 186 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 263 186 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 263 186 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 207 186 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 235 186 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 235 186 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 235 186 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 235 186 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 207 186 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 207 186 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 179 186 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 112 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 112 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 132 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 112 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 112 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 112 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 112 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 139 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 139 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 139 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 139 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 139 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 139 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 112 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 139 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 139 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 139 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 139 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 112 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 112 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8an.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8an.afm new file mode 100644 index 00000000..1a380019 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvbo8an.afm @@ -0,0 +1,570 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu Mar 15 12:08:57 1990 +Comment UniqueID 28407 +Comment VMusage 7614 43068 +FontName Helvetica-Narrow-BoldOblique +FullName Helvetica Narrow Bold Oblique +FamilyName Helvetica +Weight Bold +ItalicAngle -12 +IsFixedPitch false +FontBBox -143 -228 913 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 228 ; N space ; B 0 0 0 0 ; +C 33 ; WX 273 ; N exclam ; B 77 0 325 718 ; +C 34 ; WX 389 ; N quotedbl ; B 158 447 433 718 ; +C 35 ; WX 456 ; N numbersign ; B 49 0 528 698 ; +C 36 ; WX 456 ; N dollar ; B 55 -115 510 775 ; +C 37 ; WX 729 ; N percent ; B 112 -19 739 710 ; +C 38 ; WX 592 ; N ampersand ; B 73 -19 600 718 ; +C 39 ; WX 228 ; N quoteright ; B 137 445 297 718 ; +C 40 ; WX 273 ; N parenleft ; B 62 -208 385 734 ; +C 41 ; WX 273 ; N parenright ; B -21 -208 302 734 ; +C 42 ; WX 319 ; N asterisk ; B 120 387 394 718 ; +C 43 ; WX 479 ; N plus ; B 67 0 500 506 ; +C 44 ; WX 228 ; N comma ; B 23 -168 201 146 ; +C 45 ; WX 273 ; N hyphen ; B 60 215 311 345 ; +C 46 ; WX 228 ; N period ; B 52 0 201 146 ; +C 47 ; WX 228 ; N slash ; B -30 -19 383 737 ; +C 48 ; WX 456 ; N zero ; B 71 -19 506 710 ; +C 49 ; WX 456 ; N one ; B 142 0 434 710 ; +C 50 ; WX 456 ; N two ; B 21 0 508 710 ; +C 51 ; WX 456 ; N three ; B 54 -19 499 710 ; +C 52 ; WX 456 ; N four ; B 50 0 490 710 ; +C 53 ; WX 456 ; N five ; B 53 -19 522 698 ; +C 54 ; WX 456 ; N six ; B 70 -19 507 710 ; +C 55 ; WX 456 ; N seven ; B 102 0 555 698 ; +C 56 ; WX 456 ; N eight ; B 57 -19 505 710 ; +C 57 ; WX 456 ; N nine ; B 64 -19 504 710 ; +C 58 ; WX 273 ; N colon ; B 75 0 288 512 ; +C 59 ; WX 273 ; N semicolon ; B 46 -168 288 512 ; +C 60 ; WX 479 ; N less ; B 67 -8 537 514 ; +C 61 ; WX 479 ; N equal ; B 48 87 519 419 ; +C 62 ; WX 479 ; N greater ; B 30 -8 500 514 ; +C 63 ; WX 501 ; N question ; B 135 0 550 727 ; +C 64 ; WX 800 ; N at ; B 152 -19 782 737 ; +C 65 ; WX 592 ; N A ; B 16 0 576 718 ; +C 66 ; WX 592 ; N B ; B 62 0 626 718 ; +C 67 ; WX 592 ; N C ; B 88 -19 647 737 ; +C 68 ; WX 592 ; N D ; B 62 0 637 718 ; +C 69 ; WX 547 ; N E ; B 62 0 620 718 ; +C 70 ; WX 501 ; N F ; B 62 0 606 718 ; +C 71 ; WX 638 ; N G ; B 89 -19 670 737 ; +C 72 ; WX 592 ; N H ; B 58 0 659 718 ; +C 73 ; WX 228 ; N I ; B 52 0 301 718 ; +C 74 ; WX 456 ; N J ; B 49 -18 522 718 ; +C 75 ; WX 592 ; N K ; B 71 0 703 718 ; +C 76 ; WX 501 ; N L ; B 62 0 501 718 ; +C 77 ; WX 683 ; N M ; B 57 0 752 718 ; +C 78 ; WX 592 ; N N ; B 57 0 661 718 ; +C 79 ; WX 638 ; N O ; B 88 -19 675 737 ; +C 80 ; WX 547 ; N P ; B 62 0 605 718 ; +C 81 ; WX 638 ; N Q ; B 88 -52 675 737 ; +C 82 ; WX 592 ; N R ; B 62 0 638 718 ; +C 83 ; WX 547 ; N S ; B 66 -19 588 737 ; +C 84 ; WX 501 ; N T ; B 114 0 615 718 ; +C 85 ; WX 592 ; N U ; B 96 -19 659 718 ; +C 86 ; WX 547 ; N V ; B 141 0 656 718 ; +C 87 ; WX 774 ; N W ; B 138 0 887 718 ; +C 88 ; WX 547 ; N X ; B 11 0 648 718 ; +C 89 ; WX 547 ; N Y ; B 137 0 661 718 ; +C 90 ; WX 501 ; N Z ; B 20 0 604 718 ; +C 91 ; WX 273 ; N bracketleft ; B 17 -196 379 722 ; +C 92 ; WX 228 ; N backslash ; B 101 -19 252 737 ; +C 93 ; WX 273 ; N bracketright ; B -14 -196 347 722 ; +C 94 ; WX 479 ; N asciicircum ; B 107 323 484 698 ; +C 95 ; WX 456 ; N underscore ; B -22 -125 443 -75 ; +C 96 ; WX 228 ; N quoteleft ; B 136 454 296 727 ; +C 97 ; WX 456 ; N a ; B 45 -14 478 546 ; +C 98 ; WX 501 ; N b ; B 50 -14 529 718 ; +C 99 ; WX 456 ; N c ; B 65 -14 491 546 ; +C 100 ; WX 501 ; N d ; B 67 -14 577 718 ; +C 101 ; WX 456 ; N e ; B 58 -14 486 546 ; +C 102 ; WX 273 ; N f ; B 71 0 385 727 ; L i fi ; L l fl ; +C 103 ; WX 501 ; N g ; B 31 -217 546 546 ; +C 104 ; WX 501 ; N h ; B 53 0 516 718 ; +C 105 ; WX 228 ; N i ; B 57 0 298 725 ; +C 106 ; WX 228 ; N j ; B -35 -214 298 725 ; +C 107 ; WX 456 ; N k ; B 57 0 549 718 ; +C 108 ; WX 228 ; N l ; B 57 0 297 718 ; +C 109 ; WX 729 ; N m ; B 52 0 746 546 ; +C 110 ; WX 501 ; N n ; B 53 0 516 546 ; +C 111 ; WX 501 ; N o ; B 67 -14 527 546 ; +C 112 ; WX 501 ; N p ; B 15 -207 529 546 ; +C 113 ; WX 501 ; N q ; B 66 -207 545 546 ; +C 114 ; WX 319 ; N r ; B 52 0 401 546 ; +C 115 ; WX 456 ; N s ; B 52 -14 479 546 ; +C 116 ; WX 273 ; N t ; B 82 -6 346 676 ; +C 117 ; WX 501 ; N u ; B 80 -14 540 532 ; +C 118 ; WX 456 ; N v ; B 103 0 538 532 ; +C 119 ; WX 638 ; N w ; B 101 0 723 532 ; +C 120 ; WX 456 ; N x ; B 12 0 531 532 ; +C 121 ; WX 456 ; N y ; B 34 -214 535 532 ; +C 122 ; WX 410 ; N z ; B 16 0 478 532 ; +C 123 ; WX 319 ; N braceleft ; B 77 -196 425 722 ; +C 124 ; WX 230 ; N bar ; B 66 -19 289 737 ; +C 125 ; WX 319 ; N braceright ; B -14 -196 333 722 ; +C 126 ; WX 479 ; N asciitilde ; B 94 163 473 343 ; +C 161 ; WX 273 ; N exclamdown ; B 41 -186 290 532 ; +C 162 ; WX 456 ; N cent ; B 65 -118 491 628 ; +C 163 ; WX 456 ; N sterling ; B 41 -16 520 718 ; +C 164 ; WX 137 ; N fraction ; B -143 -19 399 710 ; +C 165 ; WX 456 ; N yen ; B 49 0 585 698 ; +C 166 ; WX 456 ; N florin ; B -41 -210 548 737 ; +C 167 ; WX 456 ; N section ; B 50 -184 491 727 ; +C 168 ; WX 456 ; N currency ; B 22 76 558 636 ; +C 169 ; WX 195 ; N quotesingle ; B 135 447 263 718 ; +C 170 ; WX 410 ; N quotedblleft ; B 132 454 482 727 ; +C 171 ; WX 456 ; N guillemotleft ; B 111 76 468 484 ; +C 172 ; WX 273 ; N guilsinglleft ; B 106 76 289 484 ; +C 173 ; WX 273 ; N guilsinglright ; B 81 76 264 484 ; +C 174 ; WX 501 ; N fi ; B 71 0 571 727 ; +C 175 ; WX 501 ; N fl ; B 71 0 570 727 ; +C 177 ; WX 456 ; N endash ; B 40 227 514 333 ; +C 178 ; WX 456 ; N dagger ; B 97 -171 513 718 ; +C 179 ; WX 456 ; N daggerdbl ; B 38 -171 515 718 ; +C 180 ; WX 228 ; N periodcentered ; B 90 172 226 334 ; +C 182 ; WX 456 ; N paragraph ; B 80 -191 564 700 ; +C 183 ; WX 287 ; N bullet ; B 68 194 345 524 ; +C 184 ; WX 228 ; N quotesinglbase ; B 34 -146 194 127 ; +C 185 ; WX 410 ; N quotedblbase ; B 29 -146 380 127 ; +C 186 ; WX 410 ; N quotedblright ; B 132 445 483 718 ; +C 187 ; WX 456 ; N guillemotright ; B 85 76 443 484 ; +C 188 ; WX 820 ; N ellipsis ; B 75 0 770 146 ; +C 189 ; WX 820 ; N perthousand ; B 62 -19 851 710 ; +C 191 ; WX 501 ; N questiondown ; B 44 -195 459 532 ; +C 193 ; WX 273 ; N grave ; B 112 604 290 750 ; +C 194 ; WX 273 ; N acute ; B 194 604 423 750 ; +C 195 ; WX 273 ; N circumflex ; B 97 604 387 750 ; +C 196 ; WX 273 ; N tilde ; B 92 610 415 737 ; +C 197 ; WX 273 ; N macron ; B 100 604 396 678 ; +C 198 ; WX 273 ; N breve ; B 128 604 405 750 ; +C 199 ; WX 273 ; N dotaccent ; B 192 614 316 729 ; +C 200 ; WX 273 ; N dieresis ; B 112 614 395 729 ; +C 202 ; WX 273 ; N ring ; B 164 568 344 776 ; +C 203 ; WX 273 ; N cedilla ; B -30 -228 180 0 ; +C 205 ; WX 273 ; N hungarumlaut ; B 113 604 529 750 ; +C 206 ; WX 273 ; N ogonek ; B 33 -228 216 0 ; +C 207 ; WX 273 ; N caron ; B 123 604 412 750 ; +C 208 ; WX 820 ; N emdash ; B 40 227 878 333 ; +C 225 ; WX 820 ; N AE ; B 4 0 902 718 ; +C 227 ; WX 303 ; N ordfeminine ; B 75 276 381 737 ; +C 232 ; WX 501 ; N Lslash ; B 28 0 501 718 ; +C 233 ; WX 638 ; N Oslash ; B 29 -27 733 745 ; +C 234 ; WX 820 ; N OE ; B 81 -19 913 737 ; +C 235 ; WX 299 ; N ordmasculine ; B 75 276 398 737 ; +C 241 ; WX 729 ; N ae ; B 46 -14 757 546 ; +C 245 ; WX 228 ; N dotlessi ; B 57 0 264 532 ; +C 248 ; WX 228 ; N lslash ; B 33 0 334 718 ; +C 249 ; WX 501 ; N oslash ; B 18 -29 575 560 ; +C 250 ; WX 774 ; N oe ; B 67 -14 801 546 ; +C 251 ; WX 501 ; N germandbls ; B 57 -14 539 731 ; +C -1 ; WX 501 ; N Zcaron ; B 20 0 604 936 ; +C -1 ; WX 456 ; N ccedilla ; B 65 -228 491 546 ; +C -1 ; WX 456 ; N ydieresis ; B 34 -214 535 729 ; +C -1 ; WX 456 ; N atilde ; B 45 -14 507 737 ; +C -1 ; WX 228 ; N icircumflex ; B 57 0 364 750 ; +C -1 ; WX 273 ; N threesuperior ; B 75 271 361 710 ; +C -1 ; WX 456 ; N ecircumflex ; B 58 -14 486 750 ; +C -1 ; WX 501 ; N thorn ; B 15 -208 529 718 ; +C -1 ; WX 456 ; N egrave ; B 58 -14 486 750 ; +C -1 ; WX 273 ; N twosuperior ; B 57 283 368 710 ; +C -1 ; WX 456 ; N eacute ; B 58 -14 514 750 ; +C -1 ; WX 501 ; N otilde ; B 67 -14 529 737 ; +C -1 ; WX 592 ; N Aacute ; B 16 0 615 936 ; +C -1 ; WX 501 ; N ocircumflex ; B 67 -14 527 750 ; +C -1 ; WX 456 ; N yacute ; B 34 -214 535 750 ; +C -1 ; WX 501 ; N udieresis ; B 80 -14 540 729 ; +C -1 ; WX 684 ; N threequarters ; B 82 -19 688 710 ; +C -1 ; WX 456 ; N acircumflex ; B 45 -14 478 750 ; +C -1 ; WX 592 ; N Eth ; B 51 0 637 718 ; +C -1 ; WX 456 ; N edieresis ; B 58 -14 487 729 ; +C -1 ; WX 501 ; N ugrave ; B 80 -14 540 750 ; +C -1 ; WX 820 ; N trademark ; B 146 306 909 718 ; +C -1 ; WX 501 ; N ograve ; B 67 -14 527 750 ; +C -1 ; WX 456 ; N scaron ; B 52 -14 504 750 ; +C -1 ; WX 228 ; N Idieresis ; B 52 0 405 915 ; +C -1 ; WX 501 ; N uacute ; B 80 -14 540 750 ; +C -1 ; WX 456 ; N agrave ; B 45 -14 478 750 ; +C -1 ; WX 501 ; N ntilde ; B 53 0 529 737 ; +C -1 ; WX 456 ; N aring ; B 45 -14 478 776 ; +C -1 ; WX 410 ; N zcaron ; B 16 0 481 750 ; +C -1 ; WX 228 ; N Icircumflex ; B 52 0 397 936 ; +C -1 ; WX 592 ; N Ntilde ; B 57 0 661 923 ; +C -1 ; WX 501 ; N ucircumflex ; B 80 -14 540 750 ; +C -1 ; WX 547 ; N Ecircumflex ; B 62 0 620 936 ; +C -1 ; WX 228 ; N Iacute ; B 52 0 433 936 ; +C -1 ; WX 592 ; N Ccedilla ; B 88 -228 647 737 ; +C -1 ; WX 638 ; N Odieresis ; B 88 -19 675 915 ; +C -1 ; WX 547 ; N Scaron ; B 66 -19 588 936 ; +C -1 ; WX 547 ; N Edieresis ; B 62 0 620 915 ; +C -1 ; WX 228 ; N Igrave ; B 52 0 301 936 ; +C -1 ; WX 456 ; N adieresis ; B 45 -14 487 729 ; +C -1 ; WX 638 ; N Ograve ; B 88 -19 675 936 ; +C -1 ; WX 547 ; N Egrave ; B 62 0 620 936 ; +C -1 ; WX 547 ; N Ydieresis ; B 137 0 661 915 ; +C -1 ; WX 604 ; N registered ; B 45 -19 684 737 ; +C -1 ; WX 638 ; N Otilde ; B 88 -19 675 923 ; +C -1 ; WX 684 ; N onequarter ; B 108 -19 661 710 ; +C -1 ; WX 592 ; N Ugrave ; B 96 -19 659 936 ; +C -1 ; WX 592 ; N Ucircumflex ; B 96 -19 659 936 ; +C -1 ; WX 547 ; N Thorn ; B 62 0 588 718 ; +C -1 ; WX 479 ; N divide ; B 67 -42 500 548 ; +C -1 ; WX 592 ; N Atilde ; B 16 0 608 923 ; +C -1 ; WX 592 ; N Uacute ; B 96 -19 659 936 ; +C -1 ; WX 638 ; N Ocircumflex ; B 88 -19 675 936 ; +C -1 ; WX 479 ; N logicalnot ; B 86 108 519 419 ; +C -1 ; WX 592 ; N Aring ; B 16 0 576 962 ; +C -1 ; WX 228 ; N idieresis ; B 57 0 373 729 ; +C -1 ; WX 228 ; N iacute ; B 57 0 400 750 ; +C -1 ; WX 456 ; N aacute ; B 45 -14 514 750 ; +C -1 ; WX 479 ; N plusminus ; B 33 0 512 506 ; +C -1 ; WX 479 ; N multiply ; B 47 1 520 505 ; +C -1 ; WX 592 ; N Udieresis ; B 96 -19 659 915 ; +C -1 ; WX 479 ; N minus ; B 67 197 500 309 ; +C -1 ; WX 273 ; N onesuperior ; B 121 283 318 710 ; +C -1 ; WX 547 ; N Eacute ; B 62 0 620 936 ; +C -1 ; WX 592 ; N Acircumflex ; B 16 0 579 936 ; +C -1 ; WX 604 ; N copyright ; B 46 -19 685 737 ; +C -1 ; WX 592 ; N Agrave ; B 16 0 576 936 ; +C -1 ; WX 501 ; N odieresis ; B 67 -14 527 729 ; +C -1 ; WX 501 ; N oacute ; B 67 -14 537 750 ; +C -1 ; WX 328 ; N degree ; B 143 426 383 712 ; +C -1 ; WX 228 ; N igrave ; B 57 0 268 750 ; +C -1 ; WX 501 ; N mu ; B 18 -207 540 532 ; +C -1 ; WX 638 ; N Oacute ; B 88 -19 675 936 ; +C -1 ; WX 501 ; N eth ; B 67 -14 549 737 ; +C -1 ; WX 592 ; N Adieresis ; B 16 0 588 915 ; +C -1 ; WX 547 ; N Yacute ; B 137 0 661 936 ; +C -1 ; WX 230 ; N brokenbar ; B 66 -19 289 737 ; +C -1 ; WX 684 ; N onehalf ; B 108 -19 704 710 ; +EndCharMetrics +StartKernData +StartKernPairs 209 + +KPX A y -30 +KPX A w -30 +KPX A v -40 +KPX A u -30 +KPX A Y -110 +KPX A W -60 +KPX A V -80 +KPX A U -50 +KPX A T -90 +KPX A Q -40 +KPX A O -40 +KPX A G -50 +KPX A C -40 + +KPX B U -10 +KPX B A -30 + +KPX D period -30 +KPX D comma -30 +KPX D Y -70 +KPX D W -40 +KPX D V -40 +KPX D A -40 + +KPX F period -100 +KPX F comma -100 +KPX F a -20 +KPX F A -80 + +KPX J u -20 +KPX J period -20 +KPX J comma -20 +KPX J A -20 + +KPX K y -40 +KPX K u -30 +KPX K o -35 +KPX K e -15 +KPX K O -30 + +KPX L y -30 +KPX L quoteright -140 +KPX L quotedblright -140 +KPX L Y -120 +KPX L W -80 +KPX L V -110 +KPX L T -90 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -50 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -50 + +KPX P period -120 +KPX P o -40 +KPX P e -30 +KPX P comma -120 +KPX P a -30 +KPX P A -100 + +KPX Q period 20 +KPX Q comma 20 +KPX Q U -10 + +KPX R Y -50 +KPX R W -40 +KPX R V -50 +KPX R U -20 +KPX R T -20 +KPX R O -20 + +KPX T y -60 +KPX T w -60 +KPX T u -90 +KPX T semicolon -40 +KPX T r -80 +KPX T period -80 +KPX T o -80 +KPX T hyphen -120 +KPX T e -60 +KPX T comma -80 +KPX T colon -40 +KPX T a -80 +KPX T O -40 +KPX T A -90 + +KPX U period -30 +KPX U comma -30 +KPX U A -50 + +KPX V u -60 +KPX V semicolon -40 +KPX V period -120 +KPX V o -90 +KPX V hyphen -80 +KPX V e -50 +KPX V comma -120 +KPX V colon -40 +KPX V a -60 +KPX V O -50 +KPX V G -50 +KPX V A -80 + +KPX W y -20 +KPX W u -45 +KPX W semicolon -10 +KPX W period -80 +KPX W o -60 +KPX W hyphen -40 +KPX W e -35 +KPX W comma -80 +KPX W colon -10 +KPX W a -40 +KPX W O -20 +KPX W A -60 + +KPX Y u -100 +KPX Y semicolon -50 +KPX Y period -100 +KPX Y o -100 +KPX Y e -80 +KPX Y comma -100 +KPX Y colon -50 +KPX Y a -90 +KPX Y O -70 +KPX Y A -110 + +KPX a y -20 +KPX a w -15 +KPX a v -15 +KPX a g -10 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b l -10 + +KPX c y -10 +KPX c l -20 +KPX c k -20 +KPX c h -10 + +KPX colon space -40 + +KPX comma space -40 +KPX comma quoteright -120 +KPX comma quotedblright -120 + +KPX d y -15 +KPX d w -15 +KPX d v -15 +KPX d d -10 + +KPX e y -15 +KPX e x -15 +KPX e w -15 +KPX e v -15 +KPX e period 20 +KPX e comma 10 + +KPX f quoteright 30 +KPX f quotedblright 30 +KPX f period -10 +KPX f o -20 +KPX f e -10 +KPX f comma -10 + +KPX g g -10 +KPX g e 10 + +KPX h y -20 + +KPX k o -15 + +KPX l y -15 +KPX l w -15 + +KPX m y -30 +KPX m u -20 + +KPX n y -20 +KPX n v -40 +KPX n u -10 + +KPX o y -20 +KPX o x -30 +KPX o w -15 +KPX o v -20 + +KPX p y -15 + +KPX period space -40 +KPX period quoteright -120 +KPX period quotedblright -120 + +KPX quotedblright space -80 + +KPX quoteleft quoteleft -46 + +KPX quoteright v -20 +KPX quoteright space -80 +KPX quoteright s -60 +KPX quoteright r -40 +KPX quoteright quoteright -46 +KPX quoteright l -20 +KPX quoteright d -80 + +KPX r y 10 +KPX r v 10 +KPX r t 20 +KPX r s -15 +KPX r q -20 +KPX r period -60 +KPX r o -20 +KPX r hyphen -20 +KPX r g -15 +KPX r d -20 +KPX r comma -60 +KPX r c -20 + +KPX s w -15 + +KPX semicolon space -40 + +KPX space quoteleft -60 +KPX space quotedblleft -80 +KPX space Y -120 +KPX space W -80 +KPX space V -80 +KPX space T -100 + +KPX v period -80 +KPX v o -30 +KPX v comma -80 +KPX v a -20 + +KPX w period -40 +KPX w o -20 +KPX w comma -40 + +KPX x e -10 + +KPX y period -80 +KPX y o -25 +KPX y e -10 +KPX y comma -80 +KPX y a -30 + +KPX z e 10 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 192 186 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 192 186 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 192 186 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 192 186 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 192 186 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 192 186 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 176 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 169 186 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 169 186 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 169 186 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 169 186 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 10 186 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 10 186 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 10 186 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 10 186 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 192 186 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 215 186 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 215 186 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 215 186 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 215 186 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 215 186 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 169 186 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 192 186 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 192 186 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 192 186 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 192 186 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 169 186 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 169 186 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 146 186 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 92 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 92 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 92 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 92 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 92 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 92 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 108 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 92 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 92 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 92 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 92 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -22 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -22 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -22 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -22 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 114 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 114 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 114 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 114 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 114 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 114 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 92 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 114 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 114 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 114 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 114 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 92 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 92 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 69 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvl8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvl8a.afm new file mode 100644 index 00000000..b02ffacb --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvl8a.afm @@ -0,0 +1,445 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1988 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date:Mon Jan 11 16:46:06 PST 1988 +FontName Helvetica-Light +EncodingScheme AdobeStandardEncoding +FullName Helvetica Light +FamilyName Helvetica +Weight Light +ItalicAngle 0.0 +IsFixedPitch false +UnderlinePosition -90 +UnderlineThickness 58 +Version 001.002 +Notice Copyright (c) 1985, 1987, 1988 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype Company. +FontBBox -164 -212 1000 979 +CapHeight 720 +XHeight 518 +Descender -204 +Ascender 720 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 130 0 203 720 ; +C 34 ; WX 278 ; N quotedbl ; B 57 494 220 720 ; +C 35 ; WX 556 ; N numbersign ; B 27 0 530 698 ; +C 36 ; WX 556 ; N dollar ; B 37 -95 518 766 ; +C 37 ; WX 889 ; N percent ; B 67 -14 821 705 ; +C 38 ; WX 667 ; N ampersand ; B 41 -19 644 720 ; +C 39 ; WX 222 ; N quoteright ; B 80 495 153 720 ; +C 40 ; WX 333 ; N parenleft ; B 55 -191 277 739 ; +C 41 ; WX 333 ; N parenright ; B 56 -191 278 739 ; +C 42 ; WX 389 ; N asterisk ; B 44 434 344 720 ; +C 43 ; WX 660 ; N plus ; B 80 0 580 500 ; +C 44 ; WX 278 ; N comma ; B 102 -137 175 88 ; +C 45 ; WX 333 ; N hyphen ; B 40 229 293 291 ; +C 46 ; WX 278 ; N period ; B 102 0 175 88 ; +C 47 ; WX 278 ; N slash ; B -3 -90 288 739 ; +C 48 ; WX 556 ; N zero ; B 39 -14 516 705 ; +C 49 ; WX 556 ; N one ; B 120 0 366 705 ; +C 50 ; WX 556 ; N two ; B 48 0 515 705 ; +C 51 ; WX 556 ; N three ; B 34 -14 512 705 ; +C 52 ; WX 556 ; N four ; B 36 0 520 698 ; +C 53 ; WX 556 ; N five ; B 35 -14 506 698 ; +C 54 ; WX 556 ; N six ; B 41 -14 514 705 ; +C 55 ; WX 556 ; N seven ; B 59 0 508 698 ; +C 56 ; WX 556 ; N eight ; B 44 -14 512 705 ; +C 57 ; WX 556 ; N nine ; B 41 -14 515 705 ; +C 58 ; WX 278 ; N colon ; B 102 0 175 492 ; +C 59 ; WX 278 ; N semicolon ; B 102 -137 175 492 ; +C 60 ; WX 660 ; N less ; B 80 -6 580 505 ; +C 61 ; WX 660 ; N equal ; B 80 124 580 378 ; +C 62 ; WX 660 ; N greater ; B 80 -6 580 505 ; +C 63 ; WX 500 ; N question ; B 37 0 472 739 ; +C 64 ; WX 800 ; N at ; B 40 -19 760 739 ; +C 65 ; WX 667 ; N A ; B 15 0 651 720 ; +C 66 ; WX 667 ; N B ; B 81 0 610 720 ; +C 67 ; WX 722 ; N C ; B 48 -19 670 739 ; +C 68 ; WX 722 ; N D ; B 81 0 669 720 ; +C 69 ; WX 611 ; N E ; B 81 0 570 720 ; +C 70 ; WX 556 ; N F ; B 74 0 538 720 ; +C 71 ; WX 778 ; N G ; B 53 -19 695 739 ; +C 72 ; WX 722 ; N H ; B 80 0 642 720 ; +C 73 ; WX 278 ; N I ; B 105 0 173 720 ; +C 74 ; WX 500 ; N J ; B 22 -19 415 720 ; +C 75 ; WX 667 ; N K ; B 85 0 649 720 ; +C 76 ; WX 556 ; N L ; B 81 0 535 720 ; +C 77 ; WX 833 ; N M ; B 78 0 755 720 ; +C 78 ; WX 722 ; N N ; B 79 0 642 720 ; +C 79 ; WX 778 ; N O ; B 53 -19 724 739 ; +C 80 ; WX 611 ; N P ; B 78 0 576 720 ; +C 81 ; WX 778 ; N Q ; B 48 -52 719 739 ; +C 82 ; WX 667 ; N R ; B 80 0 612 720 ; +C 83 ; WX 611 ; N S ; B 43 -19 567 739 ; +C 84 ; WX 556 ; N T ; B 16 0 540 720 ; +C 85 ; WX 722 ; N U ; B 82 -19 640 720 ; +C 86 ; WX 611 ; N V ; B 18 0 593 720 ; +C 87 ; WX 889 ; N W ; B 14 0 875 720 ; +C 88 ; WX 611 ; N X ; B 18 0 592 720 ; +C 89 ; WX 611 ; N Y ; B 12 0 598 720 ; +C 90 ; WX 611 ; N Z ; B 31 0 579 720 ; +C 91 ; WX 333 ; N bracketleft ; B 91 -191 282 739 ; +C 92 ; WX 278 ; N backslash ; B -46 0 324 739 ; +C 93 ; WX 333 ; N bracketright ; B 51 -191 242 739 ; +C 94 ; WX 660 ; N asciicircum ; B 73 245 586 698 ; +C 95 ; WX 500 ; N underscore ; B 0 -119 500 -61 ; +C 96 ; WX 222 ; N quoteleft ; B 69 495 142 720 ; +C 97 ; WX 556 ; N a ; B 46 -14 534 532 ; +C 98 ; WX 611 ; N b ; B 79 -14 555 720 ; +C 99 ; WX 556 ; N c ; B 47 -14 508 532 ; +C 100 ; WX 611 ; N d ; B 56 -14 532 720 ; +C 101 ; WX 556 ; N e ; B 45 -14 511 532 ; +C 102 ; WX 278 ; N f ; B 20 0 257 734 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 56 -212 532 532 ; +C 104 ; WX 556 ; N h ; B 72 0 483 720 ; +C 105 ; WX 222 ; N i ; B 78 0 144 720 ; +C 106 ; WX 222 ; N j ; B 5 -204 151 720 ; +C 107 ; WX 500 ; N k ; B 68 0 487 720 ; +C 108 ; WX 222 ; N l ; B 81 0 141 720 ; +C 109 ; WX 833 ; N m ; B 64 0 768 532 ; +C 110 ; WX 556 ; N n ; B 72 0 483 532 ; +C 111 ; WX 556 ; N o ; B 38 -14 518 532 ; +C 112 ; WX 611 ; N p ; B 79 -204 555 532 ; +C 113 ; WX 611 ; N q ; B 56 -204 532 532 ; +C 114 ; WX 333 ; N r ; B 75 0 306 532 ; +C 115 ; WX 500 ; N s ; B 46 -14 454 532 ; +C 116 ; WX 278 ; N t ; B 20 -14 254 662 ; +C 117 ; WX 556 ; N u ; B 72 -14 483 518 ; +C 118 ; WX 500 ; N v ; B 17 0 483 518 ; +C 119 ; WX 722 ; N w ; B 15 0 707 518 ; +C 120 ; WX 500 ; N x ; B 18 0 481 518 ; +C 121 ; WX 500 ; N y ; B 18 -204 482 518 ; +C 122 ; WX 500 ; N z ; B 33 0 467 518 ; +C 123 ; WX 333 ; N braceleft ; B 45 -191 279 739 ; +C 124 ; WX 222 ; N bar ; B 81 0 141 739 ; +C 125 ; WX 333 ; N braceright ; B 51 -187 285 743 ; +C 126 ; WX 660 ; N asciitilde ; B 80 174 580 339 ; +C 161 ; WX 333 ; N exclamdown ; B 130 -187 203 532 ; +C 162 ; WX 556 ; N cent ; B 45 -141 506 647 ; +C 163 ; WX 556 ; N sterling ; B 25 -14 530 705 ; +C 164 ; WX 167 ; N fraction ; B -164 -14 331 705 ; +C 165 ; WX 556 ; N yen ; B 4 0 552 720 ; +C 166 ; WX 556 ; N florin ; B 13 -196 539 734 ; +C 167 ; WX 556 ; N section ; B 48 -181 508 739 ; +C 168 ; WX 556 ; N currency ; B 27 50 529 553 ; +C 169 ; WX 222 ; N quotesingle ; B 85 494 137 720 ; +C 170 ; WX 389 ; N quotedblleft ; B 86 495 310 720 ; +C 171 ; WX 556 ; N guillemotleft ; B 113 117 443 404 ; +C 172 ; WX 389 ; N guilsinglleft ; B 121 117 267 404 ; +C 173 ; WX 389 ; N guilsinglright ; B 122 117 268 404 ; +C 174 ; WX 500 ; N fi ; B 13 0 435 734 ; +C 175 ; WX 500 ; N fl ; B 13 0 432 734 ; +C 177 ; WX 500 ; N endash ; B 0 238 500 282 ; +C 178 ; WX 556 ; N dagger ; B 37 -166 519 720 ; +C 179 ; WX 556 ; N daggerdbl ; B 37 -166 519 720 ; +C 180 ; WX 278 ; N periodcentered ; B 90 301 187 398 ; +C 182 ; WX 650 ; N paragraph ; B 66 -146 506 720 ; +C 183 ; WX 500 ; N bullet ; B 70 180 430 540 ; +C 184 ; WX 222 ; N quotesinglbase ; B 80 -137 153 88 ; +C 185 ; WX 389 ; N quotedblbase ; B 79 -137 303 88 ; +C 186 ; WX 389 ; N quotedblright ; B 79 495 303 720 ; +C 187 ; WX 556 ; N guillemotright ; B 113 117 443 404 ; +C 188 ; WX 1000 ; N ellipsis ; B 131 0 870 88 ; +C 189 ; WX 1000 ; N perthousand ; B 14 -14 985 705 ; +C 191 ; WX 500 ; N questiondown ; B 28 -207 463 532 ; +C 193 ; WX 333 ; N grave ; B 45 574 234 713 ; +C 194 ; WX 333 ; N acute ; B 109 574 297 713 ; +C 195 ; WX 333 ; N circumflex ; B 24 574 318 713 ; +C 196 ; WX 333 ; N tilde ; B 16 586 329 688 ; +C 197 ; WX 333 ; N macron ; B 23 612 319 657 ; +C 198 ; WX 333 ; N breve ; B 28 580 316 706 ; +C 199 ; WX 333 ; N dotaccent ; B 134 584 199 686 ; +C 200 ; WX 333 ; N dieresis ; B 60 584 284 686 ; +C 202 ; WX 333 ; N ring ; B 67 578 266 777 ; +C 203 ; WX 333 ; N cedilla ; B 54 -207 257 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 109 574 459 713 ; +C 206 ; WX 333 ; N ogonek ; B 74 -190 228 0 ; +C 207 ; WX 333 ; N caron ; B 24 574 318 713 ; +C 208 ; WX 1000 ; N emdash ; B 0 238 1000 282 ; +C 225 ; WX 1000 ; N AE ; B 5 0 960 720 ; +C 227 ; WX 334 ; N ordfeminine ; B 8 307 325 739 ; +C 232 ; WX 556 ; N Lslash ; B 0 0 535 720 ; +C 233 ; WX 778 ; N Oslash ; B 42 -37 736 747 ; +C 234 ; WX 1000 ; N OE ; B 41 -19 967 739 ; +C 235 ; WX 334 ; N ordmasculine ; B 11 307 323 739 ; +C 241 ; WX 889 ; N ae ; B 39 -14 847 532 ; +C 245 ; WX 222 ; N dotlessi ; B 78 0 138 518 ; +C 248 ; WX 222 ; N lslash ; B 10 0 212 720 ; +C 249 ; WX 556 ; N oslash ; B 35 -23 521 541 ; +C 250 ; WX 944 ; N oe ; B 36 -14 904 532 ; +C 251 ; WX 500 ; N germandbls ; B 52 -14 459 734 ; +C -1 ; WX 667 ; N Aacute ; B 15 0 651 915 ; +C -1 ; WX 667 ; N Acircumflex ; B 15 0 651 915 ; +C -1 ; WX 667 ; N Adieresis ; B 15 0 651 888 ; +C -1 ; WX 667 ; N Agrave ; B 15 0 651 915 ; +C -1 ; WX 667 ; N Aring ; B 15 0 651 979 ; +C -1 ; WX 667 ; N Atilde ; B 15 0 651 890 ; +C -1 ; WX 722 ; N Ccedilla ; B 48 -207 670 739 ; +C -1 ; WX 611 ; N Eacute ; B 81 0 570 915 ; +C -1 ; WX 611 ; N Ecircumflex ; B 81 0 570 915 ; +C -1 ; WX 611 ; N Edieresis ; B 81 0 570 888 ; +C -1 ; WX 611 ; N Egrave ; B 81 0 570 915 ; +C -1 ; WX 722 ; N Eth ; B 10 0 669 720 ; +C -1 ; WX 278 ; N Iacute ; B 62 0 250 915 ; +C -1 ; WX 278 ; N Icircumflex ; B -23 0 271 915 ; +C -1 ; WX 278 ; N Idieresis ; B 13 0 237 888 ; +C -1 ; WX 278 ; N Igrave ; B 18 0 207 915 ; +C -1 ; WX 722 ; N Ntilde ; B 79 0 642 890 ; +C -1 ; WX 778 ; N Oacute ; B 53 -19 724 915 ; +C -1 ; WX 778 ; N Ocircumflex ; B 53 -19 724 915 ; +C -1 ; WX 778 ; N Odieresis ; B 53 -19 724 888 ; +C -1 ; WX 778 ; N Ograve ; B 53 -19 724 915 ; +C -1 ; WX 778 ; N Otilde ; B 53 -19 724 890 ; +C -1 ; WX 611 ; N Scaron ; B 43 -19 567 915 ; +C -1 ; WX 611 ; N Thorn ; B 78 0 576 720 ; +C -1 ; WX 722 ; N Uacute ; B 82 -19 640 915 ; +C -1 ; WX 722 ; N Ucircumflex ; B 82 -19 640 915 ; +C -1 ; WX 722 ; N Udieresis ; B 82 -19 640 888 ; +C -1 ; WX 722 ; N Ugrave ; B 82 -19 640 915 ; +C -1 ; WX 611 ; N Yacute ; B 12 0 598 915 ; +C -1 ; WX 611 ; N Ydieresis ; B 12 0 598 888 ; +C -1 ; WX 611 ; N Zcaron ; B 31 0 579 915 ; +C -1 ; WX 556 ; N aacute ; B 46 -14 534 713 ; +C -1 ; WX 556 ; N acircumflex ; B 46 -14 534 713 ; +C -1 ; WX 556 ; N adieresis ; B 46 -14 534 686 ; +C -1 ; WX 556 ; N agrave ; B 46 -14 534 713 ; +C -1 ; WX 556 ; N aring ; B 46 -14 534 777 ; +C -1 ; WX 556 ; N atilde ; B 46 -14 534 688 ; +C -1 ; WX 222 ; N brokenbar ; B 81 0 141 739 ; +C -1 ; WX 556 ; N ccedilla ; B 47 -207 508 532 ; +C -1 ; WX 800 ; N copyright ; B 21 -19 779 739 ; +C -1 ; WX 400 ; N degree ; B 50 405 350 705 ; +C -1 ; WX 660 ; N divide ; B 80 0 580 500 ; +C -1 ; WX 556 ; N eacute ; B 45 -14 511 713 ; +C -1 ; WX 556 ; N ecircumflex ; B 45 -14 511 713 ; +C -1 ; WX 556 ; N edieresis ; B 45 -14 511 686 ; +C -1 ; WX 556 ; N egrave ; B 45 -14 511 713 ; +C -1 ; WX 556 ; N eth ; B 38 -14 518 739 ; +C -1 ; WX 222 ; N iacute ; B 34 0 222 713 ; +C -1 ; WX 222 ; N icircumflex ; B -51 0 243 713 ; +C -1 ; WX 222 ; N idieresis ; B -15 0 209 686 ; +C -1 ; WX 222 ; N igrave ; B -10 0 179 713 ; +C -1 ; WX 660 ; N logicalnot ; B 80 112 580 378 ; +C -1 ; WX 660 ; N minus ; B 80 220 580 280 ; +C -1 ; WX 556 ; N mu ; B 72 -204 483 518 ; +C -1 ; WX 660 ; N multiply ; B 83 6 578 500 ; +C -1 ; WX 556 ; N ntilde ; B 72 0 483 688 ; +C -1 ; WX 556 ; N oacute ; B 38 -14 518 713 ; +C -1 ; WX 556 ; N ocircumflex ; B 38 -14 518 713 ; +C -1 ; WX 556 ; N odieresis ; B 38 -14 518 686 ; +C -1 ; WX 556 ; N ograve ; B 38 -14 518 713 ; +C -1 ; WX 834 ; N onehalf ; B 40 -14 794 739 ; +C -1 ; WX 834 ; N onequarter ; B 40 -14 794 739 ; +C -1 ; WX 333 ; N onesuperior ; B 87 316 247 739 ; +C -1 ; WX 556 ; N otilde ; B 38 -14 518 688 ; +C -1 ; WX 660 ; N plusminus ; B 80 0 580 500 ; +C -1 ; WX 800 ; N registered ; B 21 -19 779 739 ; +C -1 ; WX 500 ; N scaron ; B 46 -14 454 713 ; +C -1 ; WX 611 ; N thorn ; B 79 -204 555 720 ; +C -1 ; WX 834 ; N threequarters ; B 40 -14 794 739 ; +C -1 ; WX 333 ; N threesuperior ; B 11 308 322 739 ; +C -1 ; WX 940 ; N trademark ; B 29 299 859 720 ; +C -1 ; WX 333 ; N twosuperior ; B 15 316 318 739 ; +C -1 ; WX 556 ; N uacute ; B 72 -14 483 713 ; +C -1 ; WX 556 ; N ucircumflex ; B 72 -14 483 713 ; +C -1 ; WX 556 ; N udieresis ; B 72 -14 483 686 ; +C -1 ; WX 556 ; N ugrave ; B 72 -14 483 713 ; +C -1 ; WX 500 ; N yacute ; B 18 -204 482 713 ; +C -1 ; WX 500 ; N ydieresis ; B 18 -204 482 686 ; +C -1 ; WX 500 ; N zcaron ; B 33 0 467 713 ; +EndCharMetrics +StartKernData +StartKernPairs 115 + +KPX A y -18 +KPX A w -18 +KPX A v -18 +KPX A quoteright -74 +KPX A Y -74 +KPX A W -37 +KPX A V -74 +KPX A T -92 + +KPX F period -129 +KPX F comma -129 +KPX F A -55 + +KPX L y -37 +KPX L quoteright -74 +KPX L Y -111 +KPX L W -55 +KPX L V -92 +KPX L T -92 + +KPX P period -129 +KPX P comma -129 +KPX P A -74 + +KPX R y 0 +KPX R Y -37 +KPX R W -18 +KPX R V -18 +KPX R T -18 + +KPX T y -84 +KPX T w -84 +KPX T u -92 +KPX T semicolon -111 +KPX T s -111 +KPX T r -92 +KPX T period -111 +KPX T o -111 +KPX T i 0 +KPX T hyphen -129 +KPX T e -111 +KPX T comma -111 +KPX T colon -111 +KPX T c -111 +KPX T a -111 +KPX T A -92 + +KPX V y -18 +KPX V u -37 +KPX V semicolon -74 +KPX V r -37 +KPX V period -129 +KPX V o -55 +KPX V i -18 +KPX V hyphen -55 +KPX V e -55 +KPX V comma -129 +KPX V colon -74 +KPX V a -55 +KPX V A -74 + +KPX W y 0 +KPX W u -18 +KPX W semicolon -18 +KPX W r -18 +KPX W period -74 +KPX W o -18 +KPX W i 0 +KPX W hyphen 0 +KPX W e -18 +KPX W comma -74 +KPX W colon -18 +KPX W a -37 +KPX W A -37 + +KPX Y v -40 +KPX Y u -37 +KPX Y semicolon -92 +KPX Y q -92 +KPX Y period -111 +KPX Y p -37 +KPX Y o -92 +KPX Y i -20 +KPX Y hyphen -111 +KPX Y e -92 +KPX Y comma -111 +KPX Y colon -92 +KPX Y a -92 +KPX Y A -74 + +KPX f quoteright 18 +KPX f f -18 + +KPX quoteleft quoteleft -18 + +KPX quoteright t -18 +KPX quoteright s -74 +KPX quoteright quoteright -18 + +KPX r z 0 +KPX r y 18 +KPX r x 0 +KPX r w 0 +KPX r v 0 +KPX r u 0 +KPX r t 18 +KPX r r 0 +KPX r quoteright 0 +KPX r q -18 +KPX r period -92 +KPX r o -18 +KPX r n 18 +KPX r m 18 +KPX r hyphen -55 +KPX r h 0 +KPX r g 0 +KPX r f 18 +KPX r e -18 +KPX r d -18 +KPX r comma -92 +KPX r c -18 + +KPX v period -74 +KPX v comma -74 + +KPX w period -55 +KPX w comma -55 + +KPX y period -92 +KPX y comma -92 +EndKernPairs +EndKernData +StartComposites 58 +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 202 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 83 0 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 139 202 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 83 0 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 194 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 111 0 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 139 202 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 83 0 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 139 202 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 83 0 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 194 202 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 194 202 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 194 202 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 194 202 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 111 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 111 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 111 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 111 0 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -47 202 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -47 202 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -47 202 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -27 202 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -75 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -75 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -75 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -55 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 202 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 202 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 202 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 202 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 111 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 111 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 111 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 111 0 ; +CC Aacute 2 ; PCC A 0 0 ; PCC acute 167 202 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 167 202 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 167 202 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 167 202 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 111 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 111 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 111 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 111 0 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 222 202 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 222 202 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 222 202 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 222 202 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 111 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 111 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 111 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 111 0 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 167 202 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 111 0 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 194 202 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 111 0 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 222 202 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 111 0 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 187 202 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 111 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvlo8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvlo8a.afm new file mode 100644 index 00000000..96612d12 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvlo8a.afm @@ -0,0 +1,445 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1988 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date:Mon Jan 11 17:38:44 PST 1988 +FontName Helvetica-LightOblique +EncodingScheme AdobeStandardEncoding +FullName Helvetica Light Oblique +FamilyName Helvetica +Weight Light +ItalicAngle -12.0 +IsFixedPitch false +UnderlinePosition -90 +UnderlineThickness 58 +Version 001.002 +Notice Copyright (c) 1985, 1987, 1988 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype Company. +FontBBox -167 -212 1110 979 +CapHeight 720 +XHeight 518 +Descender -204 +Ascender 720 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 130 0 356 720 ; +C 34 ; WX 278 ; N quotedbl ; B 162 494 373 720 ; +C 35 ; WX 556 ; N numbersign ; B 75 0 633 698 ; +C 36 ; WX 556 ; N dollar ; B 75 -95 613 766 ; +C 37 ; WX 889 ; N percent ; B 176 -14 860 705 ; +C 38 ; WX 667 ; N ampersand ; B 77 -19 646 720 ; +C 39 ; WX 222 ; N quoteright ; B 185 495 306 720 ; +C 40 ; WX 333 ; N parenleft ; B 97 -191 434 739 ; +C 41 ; WX 333 ; N parenright ; B 15 -191 353 739 ; +C 42 ; WX 389 ; N asterisk ; B 172 434 472 720 ; +C 43 ; WX 660 ; N plus ; B 127 0 640 500 ; +C 44 ; WX 278 ; N comma ; B 73 -137 194 88 ; +C 45 ; WX 333 ; N hyphen ; B 89 229 355 291 ; +C 46 ; WX 278 ; N period ; B 102 0 194 88 ; +C 47 ; WX 278 ; N slash ; B -22 -90 445 739 ; +C 48 ; WX 556 ; N zero ; B 93 -14 609 705 ; +C 49 ; WX 556 ; N one ; B 231 0 516 705 ; +C 50 ; WX 556 ; N two ; B 48 0 628 705 ; +C 51 ; WX 556 ; N three ; B 74 -14 605 705 ; +C 52 ; WX 556 ; N four ; B 73 0 570 698 ; +C 53 ; WX 556 ; N five ; B 71 -14 616 698 ; +C 54 ; WX 556 ; N six ; B 94 -14 617 705 ; +C 55 ; WX 556 ; N seven ; B 152 0 656 698 ; +C 56 ; WX 556 ; N eight ; B 80 -14 601 705 ; +C 57 ; WX 556 ; N nine ; B 84 -14 607 705 ; +C 58 ; WX 278 ; N colon ; B 102 0 280 492 ; +C 59 ; WX 278 ; N semicolon ; B 73 -137 280 492 ; +C 60 ; WX 660 ; N less ; B 129 -6 687 505 ; +C 61 ; WX 660 ; N equal ; B 106 124 660 378 ; +C 62 ; WX 660 ; N greater ; B 79 -6 640 505 ; +C 63 ; WX 500 ; N question ; B 148 0 594 739 ; +C 64 ; WX 800 ; N at ; B 108 -19 857 739 ; +C 65 ; WX 667 ; N A ; B 15 0 651 720 ; +C 66 ; WX 667 ; N B ; B 81 0 697 720 ; +C 67 ; WX 722 ; N C ; B 111 -19 771 739 ; +C 68 ; WX 722 ; N D ; B 81 0 758 720 ; +C 69 ; WX 611 ; N E ; B 81 0 713 720 ; +C 70 ; WX 556 ; N F ; B 74 0 691 720 ; +C 71 ; WX 778 ; N G ; B 116 -19 796 739 ; +C 72 ; WX 722 ; N H ; B 80 0 795 720 ; +C 73 ; WX 278 ; N I ; B 105 0 326 720 ; +C 74 ; WX 500 ; N J ; B 58 -19 568 720 ; +C 75 ; WX 667 ; N K ; B 85 0 752 720 ; +C 76 ; WX 556 ; N L ; B 81 0 547 720 ; +C 77 ; WX 833 ; N M ; B 78 0 908 720 ; +C 78 ; WX 722 ; N N ; B 79 0 795 720 ; +C 79 ; WX 778 ; N O ; B 117 -19 812 739 ; +C 80 ; WX 611 ; N P ; B 78 0 693 720 ; +C 81 ; WX 778 ; N Q ; B 112 -52 808 739 ; +C 82 ; WX 667 ; N R ; B 80 0 726 720 ; +C 83 ; WX 611 ; N S ; B 82 -19 663 739 ; +C 84 ; WX 556 ; N T ; B 157 0 693 720 ; +C 85 ; WX 722 ; N U ; B 129 -19 793 720 ; +C 86 ; WX 611 ; N V ; B 171 0 746 720 ; +C 87 ; WX 889 ; N W ; B 167 0 1028 720 ; +C 88 ; WX 611 ; N X ; B 18 0 734 720 ; +C 89 ; WX 611 ; N Y ; B 165 0 751 720 ; +C 90 ; WX 611 ; N Z ; B 31 0 729 720 ; +C 91 ; WX 333 ; N bracketleft ; B 50 -191 439 739 ; +C 92 ; WX 278 ; N backslash ; B 111 0 324 739 ; +C 93 ; WX 333 ; N bracketright ; B 10 -191 399 739 ; +C 94 ; WX 660 ; N asciicircum ; B 125 245 638 698 ; +C 95 ; WX 500 ; N underscore ; B -25 -119 487 -61 ; +C 96 ; WX 222 ; N quoteleft ; B 174 495 295 720 ; +C 97 ; WX 556 ; N a ; B 71 -14 555 532 ; +C 98 ; WX 611 ; N b ; B 79 -14 619 720 ; +C 99 ; WX 556 ; N c ; B 92 -14 576 532 ; +C 100 ; WX 611 ; N d ; B 101 -14 685 720 ; +C 101 ; WX 556 ; N e ; B 90 -14 575 532 ; +C 102 ; WX 278 ; N f ; B 97 0 412 734 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 56 -212 642 532 ; +C 104 ; WX 556 ; N h ; B 72 0 565 720 ; +C 105 ; WX 222 ; N i ; B 81 0 297 720 ; +C 106 ; WX 222 ; N j ; B -38 -204 304 720 ; +C 107 ; WX 500 ; N k ; B 68 0 574 720 ; +C 108 ; WX 222 ; N l ; B 81 0 294 720 ; +C 109 ; WX 833 ; N m ; B 64 0 848 532 ; +C 110 ; WX 556 ; N n ; B 72 0 565 532 ; +C 111 ; WX 556 ; N o ; B 84 -14 582 532 ; +C 112 ; WX 611 ; N p ; B 36 -204 620 532 ; +C 113 ; WX 611 ; N q ; B 102 -204 642 532 ; +C 114 ; WX 333 ; N r ; B 75 0 419 532 ; +C 115 ; WX 500 ; N s ; B 78 -14 519 532 ; +C 116 ; WX 278 ; N t ; B 108 -14 360 662 ; +C 117 ; WX 556 ; N u ; B 103 -14 593 518 ; +C 118 ; WX 500 ; N v ; B 127 0 593 518 ; +C 119 ; WX 722 ; N w ; B 125 0 817 518 ; +C 120 ; WX 500 ; N x ; B 18 0 584 518 ; +C 121 ; WX 500 ; N y ; B 26 -204 592 518 ; +C 122 ; WX 500 ; N z ; B 33 0 564 518 ; +C 123 ; WX 333 ; N braceleft ; B 103 -191 436 739 ; +C 124 ; WX 222 ; N bar ; B 81 0 298 739 ; +C 125 ; WX 333 ; N braceright ; B 12 -187 344 743 ; +C 126 ; WX 660 ; N asciitilde ; B 127 174 645 339 ; +C 161 ; WX 333 ; N exclamdown ; B 90 -187 316 532 ; +C 162 ; WX 556 ; N cent ; B 90 -141 574 647 ; +C 163 ; WX 556 ; N sterling ; B 51 -14 613 705 ; +C 164 ; WX 167 ; N fraction ; B -167 -14 481 705 ; +C 165 ; WX 556 ; N yen ; B 110 0 705 720 ; +C 166 ; WX 556 ; N florin ; B -26 -196 691 734 ; +C 167 ; WX 556 ; N section ; B 91 -181 581 739 ; +C 168 ; WX 556 ; N currency ; B 55 50 629 553 ; +C 169 ; WX 222 ; N quotesingle ; B 190 494 290 720 ; +C 170 ; WX 389 ; N quotedblleft ; B 191 495 463 720 ; +C 171 ; WX 556 ; N guillemotleft ; B 161 117 529 404 ; +C 172 ; WX 389 ; N guilsinglleft ; B 169 117 353 404 ; +C 173 ; WX 389 ; N guilsinglright ; B 147 117 330 404 ; +C 174 ; WX 500 ; N fi ; B 92 0 588 734 ; +C 175 ; WX 500 ; N fl ; B 92 0 585 734 ; +C 177 ; WX 500 ; N endash ; B 51 238 560 282 ; +C 178 ; WX 556 ; N dagger ; B 130 -166 623 720 ; +C 179 ; WX 556 ; N daggerdbl ; B 49 -166 625 720 ; +C 180 ; WX 278 ; N periodcentered ; B 163 301 262 398 ; +C 182 ; WX 650 ; N paragraph ; B 174 -146 659 720 ; +C 183 ; WX 500 ; N bullet ; B 142 180 510 540 ; +C 184 ; WX 222 ; N quotesinglbase ; B 51 -137 172 88 ; +C 185 ; WX 389 ; N quotedblbase ; B 50 -137 322 88 ; +C 186 ; WX 389 ; N quotedblright ; B 184 495 456 720 ; +C 187 ; WX 556 ; N guillemotright ; B 138 117 505 404 ; +C 188 ; WX 1000 ; N ellipsis ; B 131 0 889 88 ; +C 189 ; WX 1000 ; N perthousand ; B 83 -14 1020 705 ; +C 191 ; WX 500 ; N questiondown ; B 19 -207 465 532 ; +C 193 ; WX 333 ; N grave ; B 197 574 356 713 ; +C 194 ; WX 333 ; N acute ; B 231 574 449 713 ; +C 195 ; WX 333 ; N circumflex ; B 146 574 440 713 ; +C 196 ; WX 333 ; N tilde ; B 141 586 475 688 ; +C 197 ; WX 333 ; N macron ; B 153 612 459 657 ; +C 198 ; WX 333 ; N breve ; B 177 580 466 706 ; +C 199 ; WX 333 ; N dotaccent ; B 258 584 345 686 ; +C 200 ; WX 333 ; N dieresis ; B 184 584 430 686 ; +C 202 ; WX 333 ; N ring ; B 209 578 412 777 ; +C 203 ; WX 333 ; N cedilla ; B 14 -207 233 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 231 574 611 713 ; +C 206 ; WX 333 ; N ogonek ; B 50 -190 199 0 ; +C 207 ; WX 333 ; N caron ; B 176 574 470 713 ; +C 208 ; WX 1000 ; N emdash ; B 51 238 1060 282 ; +C 225 ; WX 1000 ; N AE ; B 5 0 1101 720 ; +C 227 ; WX 334 ; N ordfeminine ; B 73 307 423 739 ; +C 232 ; WX 556 ; N Lslash ; B 68 0 547 720 ; +C 233 ; WX 778 ; N Oslash ; B 41 -37 887 747 ; +C 234 ; WX 1000 ; N OE ; B 104 -19 1110 739 ; +C 235 ; WX 334 ; N ordmasculine ; B 76 307 450 739 ; +C 241 ; WX 889 ; N ae ; B 63 -14 913 532 ; +C 245 ; WX 222 ; N dotlessi ; B 78 0 248 518 ; +C 248 ; WX 222 ; N lslash ; B 74 0 316 720 ; +C 249 ; WX 556 ; N oslash ; B 36 -23 629 541 ; +C 250 ; WX 944 ; N oe ; B 82 -14 970 532 ; +C 251 ; WX 500 ; N germandbls ; B 52 -14 554 734 ; +C -1 ; WX 667 ; N Aacute ; B 15 0 659 915 ; +C -1 ; WX 667 ; N Acircumflex ; B 15 0 651 915 ; +C -1 ; WX 667 ; N Adieresis ; B 15 0 651 888 ; +C -1 ; WX 667 ; N Agrave ; B 15 0 651 915 ; +C -1 ; WX 667 ; N Aring ; B 15 0 651 979 ; +C -1 ; WX 667 ; N Atilde ; B 15 0 685 890 ; +C -1 ; WX 722 ; N Ccedilla ; B 111 -207 771 739 ; +C -1 ; WX 611 ; N Eacute ; B 81 0 713 915 ; +C -1 ; WX 611 ; N Ecircumflex ; B 81 0 713 915 ; +C -1 ; WX 611 ; N Edieresis ; B 81 0 713 888 ; +C -1 ; WX 611 ; N Egrave ; B 81 0 713 915 ; +C -1 ; WX 722 ; N Eth ; B 81 0 758 720 ; +C -1 ; WX 278 ; N Iacute ; B 105 0 445 915 ; +C -1 ; WX 278 ; N Icircumflex ; B 105 0 436 915 ; +C -1 ; WX 278 ; N Idieresis ; B 105 0 426 888 ; +C -1 ; WX 278 ; N Igrave ; B 105 0 372 915 ; +C -1 ; WX 722 ; N Ntilde ; B 79 0 795 890 ; +C -1 ; WX 778 ; N Oacute ; B 117 -19 812 915 ; +C -1 ; WX 778 ; N Ocircumflex ; B 117 -19 812 915 ; +C -1 ; WX 778 ; N Odieresis ; B 117 -19 812 888 ; +C -1 ; WX 778 ; N Ograve ; B 117 -19 812 915 ; +C -1 ; WX 778 ; N Otilde ; B 117 -19 812 890 ; +C -1 ; WX 611 ; N Scaron ; B 82 -19 663 915 ; +C -1 ; WX 611 ; N Thorn ; B 78 0 661 720 ; +C -1 ; WX 722 ; N Uacute ; B 129 -19 793 915 ; +C -1 ; WX 722 ; N Ucircumflex ; B 129 -19 793 915 ; +C -1 ; WX 722 ; N Udieresis ; B 129 -19 793 888 ; +C -1 ; WX 722 ; N Ugrave ; B 129 -19 793 915 ; +C -1 ; WX 611 ; N Yacute ; B 165 0 751 915 ; +C -1 ; WX 611 ; N Ydieresis ; B 165 0 751 888 ; +C -1 ; WX 611 ; N Zcaron ; B 31 0 729 915 ; +C -1 ; WX 556 ; N aacute ; B 71 -14 561 713 ; +C -1 ; WX 556 ; N acircumflex ; B 71 -14 555 713 ; +C -1 ; WX 556 ; N adieresis ; B 71 -14 555 686 ; +C -1 ; WX 556 ; N agrave ; B 71 -14 555 713 ; +C -1 ; WX 556 ; N aring ; B 71 -14 555 777 ; +C -1 ; WX 556 ; N atilde ; B 71 -14 587 688 ; +C -1 ; WX 222 ; N brokenbar ; B 81 0 298 739 ; +C -1 ; WX 556 ; N ccedilla ; B 92 -207 576 532 ; +C -1 ; WX 800 ; N copyright ; B 89 -19 864 739 ; +C -1 ; WX 400 ; N degree ; B 165 405 471 705 ; +C -1 ; WX 660 ; N divide ; B 127 0 640 500 ; +C -1 ; WX 556 ; N eacute ; B 90 -14 575 713 ; +C -1 ; WX 556 ; N ecircumflex ; B 90 -14 575 713 ; +C -1 ; WX 556 ; N edieresis ; B 90 -14 575 686 ; +C -1 ; WX 556 ; N egrave ; B 90 -14 575 713 ; +C -1 ; WX 556 ; N eth ; B 84 -14 582 739 ; +C -1 ; WX 222 ; N iacute ; B 78 0 374 713 ; +C -1 ; WX 222 ; N icircumflex ; B 71 0 365 713 ; +C -1 ; WX 222 ; N idieresis ; B 78 0 355 686 ; +C -1 ; WX 222 ; N igrave ; B 78 0 301 713 ; +C -1 ; WX 660 ; N logicalnot ; B 148 112 660 378 ; +C -1 ; WX 660 ; N minus ; B 127 220 640 280 ; +C -1 ; WX 556 ; N mu ; B 29 -204 593 518 ; +C -1 ; WX 660 ; N multiply ; B 92 6 677 500 ; +C -1 ; WX 556 ; N ntilde ; B 72 0 587 688 ; +C -1 ; WX 556 ; N oacute ; B 84 -14 582 713 ; +C -1 ; WX 556 ; N ocircumflex ; B 84 -14 582 713 ; +C -1 ; WX 556 ; N odieresis ; B 84 -14 582 686 ; +C -1 ; WX 556 ; N ograve ; B 84 -14 582 713 ; +C -1 ; WX 834 ; N onehalf ; B 125 -14 862 739 ; +C -1 ; WX 834 ; N onequarter ; B 165 -14 823 739 ; +C -1 ; WX 333 ; N onesuperior ; B 221 316 404 739 ; +C -1 ; WX 556 ; N otilde ; B 84 -14 587 688 ; +C -1 ; WX 660 ; N plusminus ; B 80 0 650 500 ; +C -1 ; WX 800 ; N registered ; B 89 -19 864 739 ; +C -1 ; WX 500 ; N scaron ; B 78 -14 554 713 ; +C -1 ; WX 611 ; N thorn ; B 36 -204 620 720 ; +C -1 ; WX 834 ; N threequarters ; B 131 -14 853 739 ; +C -1 ; WX 333 ; N threesuperior ; B 102 308 444 739 ; +C -1 ; WX 940 ; N trademark ; B 174 299 1012 720 ; +C -1 ; WX 333 ; N twosuperior ; B 82 316 453 739 ; +C -1 ; WX 556 ; N uacute ; B 103 -14 593 713 ; +C -1 ; WX 556 ; N ucircumflex ; B 103 -14 593 713 ; +C -1 ; WX 556 ; N udieresis ; B 103 -14 593 686 ; +C -1 ; WX 556 ; N ugrave ; B 103 -14 593 713 ; +C -1 ; WX 500 ; N yacute ; B 26 -204 592 713 ; +C -1 ; WX 500 ; N ydieresis ; B 26 -204 592 686 ; +C -1 ; WX 500 ; N zcaron ; B 33 0 564 713 ; +EndCharMetrics +StartKernData +StartKernPairs 115 + +KPX A y -18 +KPX A w -18 +KPX A v -18 +KPX A quoteright -74 +KPX A Y -74 +KPX A W -37 +KPX A V -74 +KPX A T -92 + +KPX F period -129 +KPX F comma -129 +KPX F A -55 + +KPX L y -37 +KPX L quoteright -74 +KPX L Y -111 +KPX L W -55 +KPX L V -92 +KPX L T -92 + +KPX P period -129 +KPX P comma -129 +KPX P A -74 + +KPX R y 0 +KPX R Y -37 +KPX R W -18 +KPX R V -18 +KPX R T -18 + +KPX T y -84 +KPX T w -84 +KPX T u -92 +KPX T semicolon -111 +KPX T s -111 +KPX T r -92 +KPX T period -111 +KPX T o -111 +KPX T i 0 +KPX T hyphen -129 +KPX T e -111 +KPX T comma -111 +KPX T colon -111 +KPX T c -111 +KPX T a -111 +KPX T A -92 + +KPX V y -18 +KPX V u -37 +KPX V semicolon -74 +KPX V r -37 +KPX V period -129 +KPX V o -55 +KPX V i -18 +KPX V hyphen -55 +KPX V e -55 +KPX V comma -129 +KPX V colon -74 +KPX V a -55 +KPX V A -74 + +KPX W y 0 +KPX W u -18 +KPX W semicolon -18 +KPX W r -18 +KPX W period -74 +KPX W o -18 +KPX W i 0 +KPX W hyphen 0 +KPX W e -18 +KPX W comma -74 +KPX W colon -18 +KPX W a -37 +KPX W A -37 + +KPX Y v -40 +KPX Y u -37 +KPX Y semicolon -92 +KPX Y q -92 +KPX Y period -111 +KPX Y p -37 +KPX Y o -92 +KPX Y i -20 +KPX Y hyphen -111 +KPX Y e -92 +KPX Y comma -111 +KPX Y colon -92 +KPX Y a -92 +KPX Y A -74 + +KPX f quoteright 18 +KPX f f -18 + +KPX quoteleft quoteleft -18 + +KPX quoteright t -18 +KPX quoteright s -74 +KPX quoteright quoteright -18 + +KPX r z 0 +KPX r y 18 +KPX r x 0 +KPX r w 0 +KPX r v 0 +KPX r u 0 +KPX r t 18 +KPX r r 0 +KPX r quoteright 0 +KPX r q -18 +KPX r period -92 +KPX r o -18 +KPX r n 18 +KPX r m 18 +KPX r hyphen -55 +KPX r h 0 +KPX r g 0 +KPX r f 18 +KPX r e -18 +KPX r d -18 +KPX r comma -92 +KPX r c -18 + +KPX v period -74 +KPX v comma -74 + +KPX w period -55 +KPX w comma -55 + +KPX y period -92 +KPX y comma -92 +EndKernPairs +EndKernData +StartComposites 58 +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 202 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 83 0 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 139 202 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 83 0 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 194 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 111 0 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 139 202 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 83 0 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 139 202 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 83 0 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 194 202 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 194 202 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 194 202 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 194 202 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 111 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 111 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 111 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 111 0 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -47 202 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -47 202 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -47 202 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -27 202 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -75 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -75 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -75 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -55 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 202 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 202 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 202 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 202 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 111 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 111 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 111 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 111 0 ; +CC Aacute 2 ; PCC A 0 0 ; PCC acute 167 202 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 167 202 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 167 202 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 167 202 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 111 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 111 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 111 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 111 0 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 222 202 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 222 202 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 222 202 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 222 202 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 111 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 111 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 111 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 111 0 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 167 202 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 111 0 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 194 202 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 111 0 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 222 202 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 111 0 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 187 202 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 111 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8a.afm new file mode 100644 index 00000000..1eb3b448 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8a.afm @@ -0,0 +1,612 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Thu Mar 15 08:58:00 1990 +Comment UniqueID 28352 +Comment VMusage 26389 33281 +FontName Helvetica +FullName Helvetica +FamilyName Helvetica +Weight Medium +ItalicAngle 0 +IsFixedPitch false +FontBBox -166 -225 1000 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 90 0 187 718 ; +C 34 ; WX 355 ; N quotedbl ; B 70 463 285 718 ; +C 35 ; WX 556 ; N numbersign ; B 28 0 529 688 ; +C 36 ; WX 556 ; N dollar ; B 32 -115 520 775 ; +C 37 ; WX 889 ; N percent ; B 39 -19 850 703 ; +C 38 ; WX 667 ; N ampersand ; B 44 -15 645 718 ; +C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ; +C 40 ; WX 333 ; N parenleft ; B 68 -207 299 733 ; +C 41 ; WX 333 ; N parenright ; B 34 -207 265 733 ; +C 42 ; WX 389 ; N asterisk ; B 39 431 349 718 ; +C 43 ; WX 584 ; N plus ; B 39 0 545 505 ; +C 44 ; WX 278 ; N comma ; B 87 -147 191 106 ; +C 45 ; WX 333 ; N hyphen ; B 44 232 289 322 ; +C 46 ; WX 278 ; N period ; B 87 0 191 106 ; +C 47 ; WX 278 ; N slash ; B -17 -19 295 737 ; +C 48 ; WX 556 ; N zero ; B 37 -19 519 703 ; +C 49 ; WX 556 ; N one ; B 101 0 359 703 ; +C 50 ; WX 556 ; N two ; B 26 0 507 703 ; +C 51 ; WX 556 ; N three ; B 34 -19 522 703 ; +C 52 ; WX 556 ; N four ; B 25 0 523 703 ; +C 53 ; WX 556 ; N five ; B 32 -19 514 688 ; +C 54 ; WX 556 ; N six ; B 38 -19 518 703 ; +C 55 ; WX 556 ; N seven ; B 37 0 523 688 ; +C 56 ; WX 556 ; N eight ; B 38 -19 517 703 ; +C 57 ; WX 556 ; N nine ; B 42 -19 514 703 ; +C 58 ; WX 278 ; N colon ; B 87 0 191 516 ; +C 59 ; WX 278 ; N semicolon ; B 87 -147 191 516 ; +C 60 ; WX 584 ; N less ; B 48 11 536 495 ; +C 61 ; WX 584 ; N equal ; B 39 115 545 390 ; +C 62 ; WX 584 ; N greater ; B 48 11 536 495 ; +C 63 ; WX 556 ; N question ; B 56 0 492 727 ; +C 64 ; WX 1015 ; N at ; B 147 -19 868 737 ; +C 65 ; WX 667 ; N A ; B 14 0 654 718 ; +C 66 ; WX 667 ; N B ; B 74 0 627 718 ; +C 67 ; WX 722 ; N C ; B 44 -19 681 737 ; +C 68 ; WX 722 ; N D ; B 81 0 674 718 ; +C 69 ; WX 667 ; N E ; B 86 0 616 718 ; +C 70 ; WX 611 ; N F ; B 86 0 583 718 ; +C 71 ; WX 778 ; N G ; B 48 -19 704 737 ; +C 72 ; WX 722 ; N H ; B 77 0 646 718 ; +C 73 ; WX 278 ; N I ; B 91 0 188 718 ; +C 74 ; WX 500 ; N J ; B 17 -19 428 718 ; +C 75 ; WX 667 ; N K ; B 76 0 663 718 ; +C 76 ; WX 556 ; N L ; B 76 0 537 718 ; +C 77 ; WX 833 ; N M ; B 73 0 761 718 ; +C 78 ; WX 722 ; N N ; B 76 0 646 718 ; +C 79 ; WX 778 ; N O ; B 39 -19 739 737 ; +C 80 ; WX 667 ; N P ; B 86 0 622 718 ; +C 81 ; WX 778 ; N Q ; B 39 -56 739 737 ; +C 82 ; WX 722 ; N R ; B 88 0 684 718 ; +C 83 ; WX 667 ; N S ; B 49 -19 620 737 ; +C 84 ; WX 611 ; N T ; B 14 0 597 718 ; +C 85 ; WX 722 ; N U ; B 79 -19 644 718 ; +C 86 ; WX 667 ; N V ; B 20 0 647 718 ; +C 87 ; WX 944 ; N W ; B 16 0 928 718 ; +C 88 ; WX 667 ; N X ; B 19 0 648 718 ; +C 89 ; WX 667 ; N Y ; B 14 0 653 718 ; +C 90 ; WX 611 ; N Z ; B 23 0 588 718 ; +C 91 ; WX 278 ; N bracketleft ; B 63 -196 250 722 ; +C 92 ; WX 278 ; N backslash ; B -17 -19 295 737 ; +C 93 ; WX 278 ; N bracketright ; B 28 -196 215 722 ; +C 94 ; WX 469 ; N asciicircum ; B -14 264 483 688 ; +C 95 ; WX 556 ; N underscore ; B 0 -125 556 -75 ; +C 96 ; WX 222 ; N quoteleft ; B 65 470 169 725 ; +C 97 ; WX 556 ; N a ; B 36 -15 530 538 ; +C 98 ; WX 556 ; N b ; B 58 -15 517 718 ; +C 99 ; WX 500 ; N c ; B 30 -15 477 538 ; +C 100 ; WX 556 ; N d ; B 35 -15 499 718 ; +C 101 ; WX 556 ; N e ; B 40 -15 516 538 ; +C 102 ; WX 278 ; N f ; B 14 0 262 728 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 40 -220 499 538 ; +C 104 ; WX 556 ; N h ; B 65 0 491 718 ; +C 105 ; WX 222 ; N i ; B 67 0 155 718 ; +C 106 ; WX 222 ; N j ; B -16 -210 155 718 ; +C 107 ; WX 500 ; N k ; B 67 0 501 718 ; +C 108 ; WX 222 ; N l ; B 67 0 155 718 ; +C 109 ; WX 833 ; N m ; B 65 0 769 538 ; +C 110 ; WX 556 ; N n ; B 65 0 491 538 ; +C 111 ; WX 556 ; N o ; B 35 -14 521 538 ; +C 112 ; WX 556 ; N p ; B 58 -207 517 538 ; +C 113 ; WX 556 ; N q ; B 35 -207 494 538 ; +C 114 ; WX 333 ; N r ; B 77 0 332 538 ; +C 115 ; WX 500 ; N s ; B 32 -15 464 538 ; +C 116 ; WX 278 ; N t ; B 14 -7 257 669 ; +C 117 ; WX 556 ; N u ; B 68 -15 489 523 ; +C 118 ; WX 500 ; N v ; B 8 0 492 523 ; +C 119 ; WX 722 ; N w ; B 14 0 709 523 ; +C 120 ; WX 500 ; N x ; B 11 0 490 523 ; +C 121 ; WX 500 ; N y ; B 11 -214 489 523 ; +C 122 ; WX 500 ; N z ; B 31 0 469 523 ; +C 123 ; WX 334 ; N braceleft ; B 42 -196 292 722 ; +C 124 ; WX 260 ; N bar ; B 94 -19 167 737 ; +C 125 ; WX 334 ; N braceright ; B 42 -196 292 722 ; +C 126 ; WX 584 ; N asciitilde ; B 61 180 523 326 ; +C 161 ; WX 333 ; N exclamdown ; B 118 -195 215 523 ; +C 162 ; WX 556 ; N cent ; B 51 -115 513 623 ; +C 163 ; WX 556 ; N sterling ; B 33 -16 539 718 ; +C 164 ; WX 167 ; N fraction ; B -166 -19 333 703 ; +C 165 ; WX 556 ; N yen ; B 3 0 553 688 ; +C 166 ; WX 556 ; N florin ; B -11 -207 501 737 ; +C 167 ; WX 556 ; N section ; B 43 -191 512 737 ; +C 168 ; WX 556 ; N currency ; B 28 99 528 603 ; +C 169 ; WX 191 ; N quotesingle ; B 59 463 132 718 ; +C 170 ; WX 333 ; N quotedblleft ; B 38 470 307 725 ; +C 171 ; WX 556 ; N guillemotleft ; B 97 108 459 446 ; +C 172 ; WX 333 ; N guilsinglleft ; B 88 108 245 446 ; +C 173 ; WX 333 ; N guilsinglright ; B 88 108 245 446 ; +C 174 ; WX 500 ; N fi ; B 14 0 434 728 ; +C 175 ; WX 500 ; N fl ; B 14 0 432 728 ; +C 177 ; WX 556 ; N endash ; B 0 240 556 313 ; +C 178 ; WX 556 ; N dagger ; B 43 -159 514 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 43 -159 514 718 ; +C 180 ; WX 278 ; N periodcentered ; B 77 190 202 315 ; +C 182 ; WX 537 ; N paragraph ; B 18 -173 497 718 ; +C 183 ; WX 350 ; N bullet ; B 18 202 333 517 ; +C 184 ; WX 222 ; N quotesinglbase ; B 53 -149 157 106 ; +C 185 ; WX 333 ; N quotedblbase ; B 26 -149 295 106 ; +C 186 ; WX 333 ; N quotedblright ; B 26 463 295 718 ; +C 187 ; WX 556 ; N guillemotright ; B 97 108 459 446 ; +C 188 ; WX 1000 ; N ellipsis ; B 115 0 885 106 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -19 994 703 ; +C 191 ; WX 611 ; N questiondown ; B 91 -201 527 525 ; +C 193 ; WX 333 ; N grave ; B 14 593 211 734 ; +C 194 ; WX 333 ; N acute ; B 122 593 319 734 ; +C 195 ; WX 333 ; N circumflex ; B 21 593 312 734 ; +C 196 ; WX 333 ; N tilde ; B -4 606 337 722 ; +C 197 ; WX 333 ; N macron ; B 10 627 323 684 ; +C 198 ; WX 333 ; N breve ; B 13 595 321 731 ; +C 199 ; WX 333 ; N dotaccent ; B 121 604 212 706 ; +C 200 ; WX 333 ; N dieresis ; B 40 604 293 706 ; +C 202 ; WX 333 ; N ring ; B 75 572 259 756 ; +C 203 ; WX 333 ; N cedilla ; B 45 -225 259 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 31 593 409 734 ; +C 206 ; WX 333 ; N ogonek ; B 73 -225 287 0 ; +C 207 ; WX 333 ; N caron ; B 21 593 312 734 ; +C 208 ; WX 1000 ; N emdash ; B 0 240 1000 313 ; +C 225 ; WX 1000 ; N AE ; B 8 0 951 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 24 304 346 737 ; +C 232 ; WX 556 ; N Lslash ; B -20 0 537 718 ; +C 233 ; WX 778 ; N Oslash ; B 39 -19 740 737 ; +C 234 ; WX 1000 ; N OE ; B 36 -19 965 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 25 304 341 737 ; +C 241 ; WX 889 ; N ae ; B 36 -15 847 538 ; +C 245 ; WX 278 ; N dotlessi ; B 95 0 183 523 ; +C 248 ; WX 222 ; N lslash ; B -20 0 242 718 ; +C 249 ; WX 611 ; N oslash ; B 28 -22 537 545 ; +C 250 ; WX 944 ; N oe ; B 35 -15 902 538 ; +C 251 ; WX 611 ; N germandbls ; B 67 -15 571 728 ; +C -1 ; WX 611 ; N Zcaron ; B 23 0 588 929 ; +C -1 ; WX 500 ; N ccedilla ; B 30 -225 477 538 ; +C -1 ; WX 500 ; N ydieresis ; B 11 -214 489 706 ; +C -1 ; WX 556 ; N atilde ; B 36 -15 530 722 ; +C -1 ; WX 278 ; N icircumflex ; B -6 0 285 734 ; +C -1 ; WX 333 ; N threesuperior ; B 5 270 325 703 ; +C -1 ; WX 556 ; N ecircumflex ; B 40 -15 516 734 ; +C -1 ; WX 556 ; N thorn ; B 58 -207 517 718 ; +C -1 ; WX 556 ; N egrave ; B 40 -15 516 734 ; +C -1 ; WX 333 ; N twosuperior ; B 4 281 323 703 ; +C -1 ; WX 556 ; N eacute ; B 40 -15 516 734 ; +C -1 ; WX 556 ; N otilde ; B 35 -14 521 722 ; +C -1 ; WX 667 ; N Aacute ; B 14 0 654 929 ; +C -1 ; WX 556 ; N ocircumflex ; B 35 -14 521 734 ; +C -1 ; WX 500 ; N yacute ; B 11 -214 489 734 ; +C -1 ; WX 556 ; N udieresis ; B 68 -15 489 706 ; +C -1 ; WX 834 ; N threequarters ; B 45 -19 810 703 ; +C -1 ; WX 556 ; N acircumflex ; B 36 -15 530 734 ; +C -1 ; WX 722 ; N Eth ; B 0 0 674 718 ; +C -1 ; WX 556 ; N edieresis ; B 40 -15 516 706 ; +C -1 ; WX 556 ; N ugrave ; B 68 -15 489 734 ; +C -1 ; WX 1000 ; N trademark ; B 46 306 903 718 ; +C -1 ; WX 556 ; N ograve ; B 35 -14 521 734 ; +C -1 ; WX 500 ; N scaron ; B 32 -15 464 734 ; +C -1 ; WX 278 ; N Idieresis ; B 13 0 266 901 ; +C -1 ; WX 556 ; N uacute ; B 68 -15 489 734 ; +C -1 ; WX 556 ; N agrave ; B 36 -15 530 734 ; +C -1 ; WX 556 ; N ntilde ; B 65 0 491 722 ; +C -1 ; WX 556 ; N aring ; B 36 -15 530 756 ; +C -1 ; WX 500 ; N zcaron ; B 31 0 469 734 ; +C -1 ; WX 278 ; N Icircumflex ; B -6 0 285 929 ; +C -1 ; WX 722 ; N Ntilde ; B 76 0 646 917 ; +C -1 ; WX 556 ; N ucircumflex ; B 68 -15 489 734 ; +C -1 ; WX 667 ; N Ecircumflex ; B 86 0 616 929 ; +C -1 ; WX 278 ; N Iacute ; B 91 0 292 929 ; +C -1 ; WX 722 ; N Ccedilla ; B 44 -225 681 737 ; +C -1 ; WX 778 ; N Odieresis ; B 39 -19 739 901 ; +C -1 ; WX 667 ; N Scaron ; B 49 -19 620 929 ; +C -1 ; WX 667 ; N Edieresis ; B 86 0 616 901 ; +C -1 ; WX 278 ; N Igrave ; B -13 0 188 929 ; +C -1 ; WX 556 ; N adieresis ; B 36 -15 530 706 ; +C -1 ; WX 778 ; N Ograve ; B 39 -19 739 929 ; +C -1 ; WX 667 ; N Egrave ; B 86 0 616 929 ; +C -1 ; WX 667 ; N Ydieresis ; B 14 0 653 901 ; +C -1 ; WX 737 ; N registered ; B -14 -19 752 737 ; +C -1 ; WX 778 ; N Otilde ; B 39 -19 739 917 ; +C -1 ; WX 834 ; N onequarter ; B 73 -19 756 703 ; +C -1 ; WX 722 ; N Ugrave ; B 79 -19 644 929 ; +C -1 ; WX 722 ; N Ucircumflex ; B 79 -19 644 929 ; +C -1 ; WX 667 ; N Thorn ; B 86 0 622 718 ; +C -1 ; WX 584 ; N divide ; B 39 -19 545 524 ; +C -1 ; WX 667 ; N Atilde ; B 14 0 654 917 ; +C -1 ; WX 722 ; N Uacute ; B 79 -19 644 929 ; +C -1 ; WX 778 ; N Ocircumflex ; B 39 -19 739 929 ; +C -1 ; WX 584 ; N logicalnot ; B 39 108 545 390 ; +C -1 ; WX 667 ; N Aring ; B 14 0 654 931 ; +C -1 ; WX 278 ; N idieresis ; B 13 0 266 706 ; +C -1 ; WX 278 ; N iacute ; B 95 0 292 734 ; +C -1 ; WX 556 ; N aacute ; B 36 -15 530 734 ; +C -1 ; WX 584 ; N plusminus ; B 39 0 545 506 ; +C -1 ; WX 584 ; N multiply ; B 39 0 545 506 ; +C -1 ; WX 722 ; N Udieresis ; B 79 -19 644 901 ; +C -1 ; WX 584 ; N minus ; B 39 216 545 289 ; +C -1 ; WX 333 ; N onesuperior ; B 43 281 222 703 ; +C -1 ; WX 667 ; N Eacute ; B 86 0 616 929 ; +C -1 ; WX 667 ; N Acircumflex ; B 14 0 654 929 ; +C -1 ; WX 737 ; N copyright ; B -14 -19 752 737 ; +C -1 ; WX 667 ; N Agrave ; B 14 0 654 929 ; +C -1 ; WX 556 ; N odieresis ; B 35 -14 521 706 ; +C -1 ; WX 556 ; N oacute ; B 35 -14 521 734 ; +C -1 ; WX 400 ; N degree ; B 54 411 346 703 ; +C -1 ; WX 278 ; N igrave ; B -13 0 184 734 ; +C -1 ; WX 556 ; N mu ; B 68 -207 489 523 ; +C -1 ; WX 778 ; N Oacute ; B 39 -19 739 929 ; +C -1 ; WX 556 ; N eth ; B 35 -15 522 737 ; +C -1 ; WX 667 ; N Adieresis ; B 14 0 654 901 ; +C -1 ; WX 667 ; N Yacute ; B 14 0 653 929 ; +C -1 ; WX 260 ; N brokenbar ; B 94 -19 167 737 ; +C -1 ; WX 834 ; N onehalf ; B 43 -19 773 703 ; +EndCharMetrics +StartKernData +StartKernPairs 250 + +KPX A y -40 +KPX A w -40 +KPX A v -40 +KPX A u -30 +KPX A Y -100 +KPX A W -50 +KPX A V -70 +KPX A U -50 +KPX A T -120 +KPX A Q -30 +KPX A O -30 +KPX A G -30 +KPX A C -30 + +KPX B period -20 +KPX B comma -20 +KPX B U -10 + +KPX C period -30 +KPX C comma -30 + +KPX D period -70 +KPX D comma -70 +KPX D Y -90 +KPX D W -40 +KPX D V -70 +KPX D A -40 + +KPX F r -45 +KPX F period -150 +KPX F o -30 +KPX F e -30 +KPX F comma -150 +KPX F a -50 +KPX F A -80 + +KPX J u -20 +KPX J period -30 +KPX J comma -30 +KPX J a -20 +KPX J A -20 + +KPX K y -50 +KPX K u -30 +KPX K o -40 +KPX K e -40 +KPX K O -50 + +KPX L y -30 +KPX L quoteright -160 +KPX L quotedblright -140 +KPX L Y -140 +KPX L W -70 +KPX L V -110 +KPX L T -110 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -60 +KPX O W -30 +KPX O V -50 +KPX O T -40 +KPX O A -20 + +KPX P period -180 +KPX P o -50 +KPX P e -50 +KPX P comma -180 +KPX P a -40 +KPX P A -120 + +KPX Q U -10 + +KPX R Y -50 +KPX R W -30 +KPX R V -50 +KPX R U -40 +KPX R T -30 +KPX R O -20 + +KPX S period -20 +KPX S comma -20 + +KPX T y -120 +KPX T w -120 +KPX T u -120 +KPX T semicolon -20 +KPX T r -120 +KPX T period -120 +KPX T o -120 +KPX T hyphen -140 +KPX T e -120 +KPX T comma -120 +KPX T colon -20 +KPX T a -120 +KPX T O -40 +KPX T A -120 + +KPX U period -40 +KPX U comma -40 +KPX U A -40 + +KPX V u -70 +KPX V semicolon -40 +KPX V period -125 +KPX V o -80 +KPX V hyphen -80 +KPX V e -80 +KPX V comma -125 +KPX V colon -40 +KPX V a -70 +KPX V O -40 +KPX V G -40 +KPX V A -80 + +KPX W y -20 +KPX W u -30 +KPX W period -80 +KPX W o -30 +KPX W hyphen -40 +KPX W e -30 +KPX W comma -80 +KPX W a -40 +KPX W O -20 +KPX W A -50 + +KPX Y u -110 +KPX Y semicolon -60 +KPX Y period -140 +KPX Y o -140 +KPX Y i -20 +KPX Y hyphen -140 +KPX Y e -140 +KPX Y comma -140 +KPX Y colon -60 +KPX Y a -140 +KPX Y O -85 +KPX Y A -110 + +KPX a y -30 +KPX a w -20 +KPX a v -20 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b period -40 +KPX b l -20 +KPX b comma -40 +KPX b b -10 + +KPX c k -20 +KPX c comma -15 + +KPX colon space -50 + +KPX comma quoteright -100 +KPX comma quotedblright -100 + +KPX e y -20 +KPX e x -30 +KPX e w -20 +KPX e v -30 +KPX e period -15 +KPX e comma -15 + +KPX f quoteright 50 +KPX f quotedblright 60 +KPX f period -30 +KPX f o -30 +KPX f e -30 +KPX f dotlessi -28 +KPX f comma -30 +KPX f a -30 + +KPX g r -10 + +KPX h y -30 + +KPX k o -20 +KPX k e -20 + +KPX m y -15 +KPX m u -10 + +KPX n y -15 +KPX n v -20 +KPX n u -10 + +KPX o y -30 +KPX o x -30 +KPX o w -15 +KPX o v -15 +KPX o period -40 +KPX o comma -40 + +KPX oslash z -55 +KPX oslash y -70 +KPX oslash x -85 +KPX oslash w -70 +KPX oslash v -70 +KPX oslash u -55 +KPX oslash t -55 +KPX oslash s -55 +KPX oslash r -55 +KPX oslash q -55 +KPX oslash period -95 +KPX oslash p -55 +KPX oslash o -55 +KPX oslash n -55 +KPX oslash m -55 +KPX oslash l -55 +KPX oslash k -55 +KPX oslash j -55 +KPX oslash i -55 +KPX oslash h -55 +KPX oslash g -55 +KPX oslash f -55 +KPX oslash e -55 +KPX oslash d -55 +KPX oslash comma -95 +KPX oslash c -55 +KPX oslash b -55 +KPX oslash a -55 + +KPX p y -30 +KPX p period -35 +KPX p comma -35 + +KPX period space -60 +KPX period quoteright -100 +KPX period quotedblright -100 + +KPX quotedblright space -40 + +KPX quoteleft quoteleft -57 + +KPX quoteright space -70 +KPX quoteright s -50 +KPX quoteright r -50 +KPX quoteright quoteright -57 +KPX quoteright d -50 + +KPX r y 30 +KPX r v 30 +KPX r u 15 +KPX r t 40 +KPX r semicolon 30 +KPX r period -50 +KPX r p 30 +KPX r n 25 +KPX r m 25 +KPX r l 15 +KPX r k 15 +KPX r i 15 +KPX r comma -50 +KPX r colon 30 +KPX r a -10 + +KPX s w -30 +KPX s period -15 +KPX s comma -15 + +KPX semicolon space -50 + +KPX space quoteleft -60 +KPX space quotedblleft -30 +KPX space Y -90 +KPX space W -40 +KPX space V -50 +KPX space T -50 + +KPX v period -80 +KPX v o -25 +KPX v e -25 +KPX v comma -80 +KPX v a -25 + +KPX w period -60 +KPX w o -10 +KPX w e -10 +KPX w comma -60 +KPX w a -15 + +KPX x e -30 + +KPX y period -100 +KPX y o -20 +KPX y e -20 +KPX y comma -100 +KPX y a -20 + +KPX z o -15 +KPX z e -15 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 167 195 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 167 195 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 167 195 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 167 195 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 167 175 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 167 195 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 195 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 167 195 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 167 195 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 167 195 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 167 195 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -27 195 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -27 195 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -27 195 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -27 195 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 205 195 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 223 195 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 223 195 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 223 195 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 223 195 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 223 195 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 167 195 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 195 195 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 195 195 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 195 195 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 195 195 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 167 195 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 167 195 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 195 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 112 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 102 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 84 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 112 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 112 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 112 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 112 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 102 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 112 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 112 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 112 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 112 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 112 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 84 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 112 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 112 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 112 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 112 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 84 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8an.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8an.afm new file mode 100644 index 00000000..5a08aa8c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvr8an.afm @@ -0,0 +1,612 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Thu Mar 15 11:04:57 1990 +Comment UniqueID 28380 +Comment VMusage 7572 42473 +FontName Helvetica-Narrow +FullName Helvetica Narrow +FamilyName Helvetica +Weight Medium +ItalicAngle 0 +IsFixedPitch false +FontBBox -136 -225 820 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 228 ; N space ; B 0 0 0 0 ; +C 33 ; WX 228 ; N exclam ; B 74 0 153 718 ; +C 34 ; WX 291 ; N quotedbl ; B 57 463 234 718 ; +C 35 ; WX 456 ; N numbersign ; B 23 0 434 688 ; +C 36 ; WX 456 ; N dollar ; B 26 -115 426 775 ; +C 37 ; WX 729 ; N percent ; B 32 -19 697 703 ; +C 38 ; WX 547 ; N ampersand ; B 36 -15 529 718 ; +C 39 ; WX 182 ; N quoteright ; B 43 463 129 718 ; +C 40 ; WX 273 ; N parenleft ; B 56 -207 245 733 ; +C 41 ; WX 273 ; N parenright ; B 28 -207 217 733 ; +C 42 ; WX 319 ; N asterisk ; B 32 431 286 718 ; +C 43 ; WX 479 ; N plus ; B 32 0 447 505 ; +C 44 ; WX 228 ; N comma ; B 71 -147 157 106 ; +C 45 ; WX 273 ; N hyphen ; B 36 232 237 322 ; +C 46 ; WX 228 ; N period ; B 71 0 157 106 ; +C 47 ; WX 228 ; N slash ; B -14 -19 242 737 ; +C 48 ; WX 456 ; N zero ; B 30 -19 426 703 ; +C 49 ; WX 456 ; N one ; B 83 0 294 703 ; +C 50 ; WX 456 ; N two ; B 21 0 416 703 ; +C 51 ; WX 456 ; N three ; B 28 -19 428 703 ; +C 52 ; WX 456 ; N four ; B 20 0 429 703 ; +C 53 ; WX 456 ; N five ; B 26 -19 421 688 ; +C 54 ; WX 456 ; N six ; B 31 -19 425 703 ; +C 55 ; WX 456 ; N seven ; B 30 0 429 688 ; +C 56 ; WX 456 ; N eight ; B 31 -19 424 703 ; +C 57 ; WX 456 ; N nine ; B 34 -19 421 703 ; +C 58 ; WX 228 ; N colon ; B 71 0 157 516 ; +C 59 ; WX 228 ; N semicolon ; B 71 -147 157 516 ; +C 60 ; WX 479 ; N less ; B 39 11 440 495 ; +C 61 ; WX 479 ; N equal ; B 32 115 447 390 ; +C 62 ; WX 479 ; N greater ; B 39 11 440 495 ; +C 63 ; WX 456 ; N question ; B 46 0 403 727 ; +C 64 ; WX 832 ; N at ; B 121 -19 712 737 ; +C 65 ; WX 547 ; N A ; B 11 0 536 718 ; +C 66 ; WX 547 ; N B ; B 61 0 514 718 ; +C 67 ; WX 592 ; N C ; B 36 -19 558 737 ; +C 68 ; WX 592 ; N D ; B 66 0 553 718 ; +C 69 ; WX 547 ; N E ; B 71 0 505 718 ; +C 70 ; WX 501 ; N F ; B 71 0 478 718 ; +C 71 ; WX 638 ; N G ; B 39 -19 577 737 ; +C 72 ; WX 592 ; N H ; B 63 0 530 718 ; +C 73 ; WX 228 ; N I ; B 75 0 154 718 ; +C 74 ; WX 410 ; N J ; B 14 -19 351 718 ; +C 75 ; WX 547 ; N K ; B 62 0 544 718 ; +C 76 ; WX 456 ; N L ; B 62 0 440 718 ; +C 77 ; WX 683 ; N M ; B 60 0 624 718 ; +C 78 ; WX 592 ; N N ; B 62 0 530 718 ; +C 79 ; WX 638 ; N O ; B 32 -19 606 737 ; +C 80 ; WX 547 ; N P ; B 71 0 510 718 ; +C 81 ; WX 638 ; N Q ; B 32 -56 606 737 ; +C 82 ; WX 592 ; N R ; B 72 0 561 718 ; +C 83 ; WX 547 ; N S ; B 40 -19 508 737 ; +C 84 ; WX 501 ; N T ; B 11 0 490 718 ; +C 85 ; WX 592 ; N U ; B 65 -19 528 718 ; +C 86 ; WX 547 ; N V ; B 16 0 531 718 ; +C 87 ; WX 774 ; N W ; B 13 0 761 718 ; +C 88 ; WX 547 ; N X ; B 16 0 531 718 ; +C 89 ; WX 547 ; N Y ; B 11 0 535 718 ; +C 90 ; WX 501 ; N Z ; B 19 0 482 718 ; +C 91 ; WX 228 ; N bracketleft ; B 52 -196 205 722 ; +C 92 ; WX 228 ; N backslash ; B -14 -19 242 737 ; +C 93 ; WX 228 ; N bracketright ; B 23 -196 176 722 ; +C 94 ; WX 385 ; N asciicircum ; B -11 264 396 688 ; +C 95 ; WX 456 ; N underscore ; B 0 -125 456 -75 ; +C 96 ; WX 182 ; N quoteleft ; B 53 470 139 725 ; +C 97 ; WX 456 ; N a ; B 30 -15 435 538 ; +C 98 ; WX 456 ; N b ; B 48 -15 424 718 ; +C 99 ; WX 410 ; N c ; B 25 -15 391 538 ; +C 100 ; WX 456 ; N d ; B 29 -15 409 718 ; +C 101 ; WX 456 ; N e ; B 33 -15 423 538 ; +C 102 ; WX 228 ; N f ; B 11 0 215 728 ; L i fi ; L l fl ; +C 103 ; WX 456 ; N g ; B 33 -220 409 538 ; +C 104 ; WX 456 ; N h ; B 53 0 403 718 ; +C 105 ; WX 182 ; N i ; B 55 0 127 718 ; +C 106 ; WX 182 ; N j ; B -13 -210 127 718 ; +C 107 ; WX 410 ; N k ; B 55 0 411 718 ; +C 108 ; WX 182 ; N l ; B 55 0 127 718 ; +C 109 ; WX 683 ; N m ; B 53 0 631 538 ; +C 110 ; WX 456 ; N n ; B 53 0 403 538 ; +C 111 ; WX 456 ; N o ; B 29 -14 427 538 ; +C 112 ; WX 456 ; N p ; B 48 -207 424 538 ; +C 113 ; WX 456 ; N q ; B 29 -207 405 538 ; +C 114 ; WX 273 ; N r ; B 63 0 272 538 ; +C 115 ; WX 410 ; N s ; B 26 -15 380 538 ; +C 116 ; WX 228 ; N t ; B 11 -7 211 669 ; +C 117 ; WX 456 ; N u ; B 56 -15 401 523 ; +C 118 ; WX 410 ; N v ; B 7 0 403 523 ; +C 119 ; WX 592 ; N w ; B 11 0 581 523 ; +C 120 ; WX 410 ; N x ; B 9 0 402 523 ; +C 121 ; WX 410 ; N y ; B 9 -214 401 523 ; +C 122 ; WX 410 ; N z ; B 25 0 385 523 ; +C 123 ; WX 274 ; N braceleft ; B 34 -196 239 722 ; +C 124 ; WX 213 ; N bar ; B 77 -19 137 737 ; +C 125 ; WX 274 ; N braceright ; B 34 -196 239 722 ; +C 126 ; WX 479 ; N asciitilde ; B 50 180 429 326 ; +C 161 ; WX 273 ; N exclamdown ; B 97 -195 176 523 ; +C 162 ; WX 456 ; N cent ; B 42 -115 421 623 ; +C 163 ; WX 456 ; N sterling ; B 27 -16 442 718 ; +C 164 ; WX 137 ; N fraction ; B -136 -19 273 703 ; +C 165 ; WX 456 ; N yen ; B 2 0 453 688 ; +C 166 ; WX 456 ; N florin ; B -9 -207 411 737 ; +C 167 ; WX 456 ; N section ; B 35 -191 420 737 ; +C 168 ; WX 456 ; N currency ; B 23 99 433 603 ; +C 169 ; WX 157 ; N quotesingle ; B 48 463 108 718 ; +C 170 ; WX 273 ; N quotedblleft ; B 31 470 252 725 ; +C 171 ; WX 456 ; N guillemotleft ; B 80 108 376 446 ; +C 172 ; WX 273 ; N guilsinglleft ; B 72 108 201 446 ; +C 173 ; WX 273 ; N guilsinglright ; B 72 108 201 446 ; +C 174 ; WX 410 ; N fi ; B 11 0 356 728 ; +C 175 ; WX 410 ; N fl ; B 11 0 354 728 ; +C 177 ; WX 456 ; N endash ; B 0 240 456 313 ; +C 178 ; WX 456 ; N dagger ; B 35 -159 421 718 ; +C 179 ; WX 456 ; N daggerdbl ; B 35 -159 421 718 ; +C 180 ; WX 228 ; N periodcentered ; B 63 190 166 315 ; +C 182 ; WX 440 ; N paragraph ; B 15 -173 408 718 ; +C 183 ; WX 287 ; N bullet ; B 15 202 273 517 ; +C 184 ; WX 182 ; N quotesinglbase ; B 43 -149 129 106 ; +C 185 ; WX 273 ; N quotedblbase ; B 21 -149 242 106 ; +C 186 ; WX 273 ; N quotedblright ; B 21 463 242 718 ; +C 187 ; WX 456 ; N guillemotright ; B 80 108 376 446 ; +C 188 ; WX 820 ; N ellipsis ; B 94 0 726 106 ; +C 189 ; WX 820 ; N perthousand ; B 6 -19 815 703 ; +C 191 ; WX 501 ; N questiondown ; B 75 -201 432 525 ; +C 193 ; WX 273 ; N grave ; B 11 593 173 734 ; +C 194 ; WX 273 ; N acute ; B 100 593 262 734 ; +C 195 ; WX 273 ; N circumflex ; B 17 593 256 734 ; +C 196 ; WX 273 ; N tilde ; B -3 606 276 722 ; +C 197 ; WX 273 ; N macron ; B 8 627 265 684 ; +C 198 ; WX 273 ; N breve ; B 11 595 263 731 ; +C 199 ; WX 273 ; N dotaccent ; B 99 604 174 706 ; +C 200 ; WX 273 ; N dieresis ; B 33 604 240 706 ; +C 202 ; WX 273 ; N ring ; B 61 572 212 756 ; +C 203 ; WX 273 ; N cedilla ; B 37 -225 212 0 ; +C 205 ; WX 273 ; N hungarumlaut ; B 25 593 335 734 ; +C 206 ; WX 273 ; N ogonek ; B 60 -225 235 0 ; +C 207 ; WX 273 ; N caron ; B 17 593 256 734 ; +C 208 ; WX 820 ; N emdash ; B 0 240 820 313 ; +C 225 ; WX 820 ; N AE ; B 7 0 780 718 ; +C 227 ; WX 303 ; N ordfeminine ; B 20 304 284 737 ; +C 232 ; WX 456 ; N Lslash ; B -16 0 440 718 ; +C 233 ; WX 638 ; N Oslash ; B 32 -19 607 737 ; +C 234 ; WX 820 ; N OE ; B 30 -19 791 737 ; +C 235 ; WX 299 ; N ordmasculine ; B 20 304 280 737 ; +C 241 ; WX 729 ; N ae ; B 30 -15 695 538 ; +C 245 ; WX 228 ; N dotlessi ; B 78 0 150 523 ; +C 248 ; WX 182 ; N lslash ; B -16 0 198 718 ; +C 249 ; WX 501 ; N oslash ; B 23 -22 440 545 ; +C 250 ; WX 774 ; N oe ; B 29 -15 740 538 ; +C 251 ; WX 501 ; N germandbls ; B 55 -15 468 728 ; +C -1 ; WX 501 ; N Zcaron ; B 19 0 482 929 ; +C -1 ; WX 410 ; N ccedilla ; B 25 -225 391 538 ; +C -1 ; WX 410 ; N ydieresis ; B 9 -214 401 706 ; +C -1 ; WX 456 ; N atilde ; B 30 -15 435 722 ; +C -1 ; WX 228 ; N icircumflex ; B -5 0 234 734 ; +C -1 ; WX 273 ; N threesuperior ; B 4 270 266 703 ; +C -1 ; WX 456 ; N ecircumflex ; B 33 -15 423 734 ; +C -1 ; WX 456 ; N thorn ; B 48 -207 424 718 ; +C -1 ; WX 456 ; N egrave ; B 33 -15 423 734 ; +C -1 ; WX 273 ; N twosuperior ; B 3 281 265 703 ; +C -1 ; WX 456 ; N eacute ; B 33 -15 423 734 ; +C -1 ; WX 456 ; N otilde ; B 29 -14 427 722 ; +C -1 ; WX 547 ; N Aacute ; B 11 0 536 929 ; +C -1 ; WX 456 ; N ocircumflex ; B 29 -14 427 734 ; +C -1 ; WX 410 ; N yacute ; B 9 -214 401 734 ; +C -1 ; WX 456 ; N udieresis ; B 56 -15 401 706 ; +C -1 ; WX 684 ; N threequarters ; B 37 -19 664 703 ; +C -1 ; WX 456 ; N acircumflex ; B 30 -15 435 734 ; +C -1 ; WX 592 ; N Eth ; B 0 0 553 718 ; +C -1 ; WX 456 ; N edieresis ; B 33 -15 423 706 ; +C -1 ; WX 456 ; N ugrave ; B 56 -15 401 734 ; +C -1 ; WX 820 ; N trademark ; B 38 306 740 718 ; +C -1 ; WX 456 ; N ograve ; B 29 -14 427 734 ; +C -1 ; WX 410 ; N scaron ; B 26 -15 380 734 ; +C -1 ; WX 228 ; N Idieresis ; B 11 0 218 901 ; +C -1 ; WX 456 ; N uacute ; B 56 -15 401 734 ; +C -1 ; WX 456 ; N agrave ; B 30 -15 435 734 ; +C -1 ; WX 456 ; N ntilde ; B 53 0 403 722 ; +C -1 ; WX 456 ; N aring ; B 30 -15 435 756 ; +C -1 ; WX 410 ; N zcaron ; B 25 0 385 734 ; +C -1 ; WX 228 ; N Icircumflex ; B -5 0 234 929 ; +C -1 ; WX 592 ; N Ntilde ; B 62 0 530 917 ; +C -1 ; WX 456 ; N ucircumflex ; B 56 -15 401 734 ; +C -1 ; WX 547 ; N Ecircumflex ; B 71 0 505 929 ; +C -1 ; WX 228 ; N Iacute ; B 75 0 239 929 ; +C -1 ; WX 592 ; N Ccedilla ; B 36 -225 558 737 ; +C -1 ; WX 638 ; N Odieresis ; B 32 -19 606 901 ; +C -1 ; WX 547 ; N Scaron ; B 40 -19 508 929 ; +C -1 ; WX 547 ; N Edieresis ; B 71 0 505 901 ; +C -1 ; WX 228 ; N Igrave ; B -11 0 154 929 ; +C -1 ; WX 456 ; N adieresis ; B 30 -15 435 706 ; +C -1 ; WX 638 ; N Ograve ; B 32 -19 606 929 ; +C -1 ; WX 547 ; N Egrave ; B 71 0 505 929 ; +C -1 ; WX 547 ; N Ydieresis ; B 11 0 535 901 ; +C -1 ; WX 604 ; N registered ; B -11 -19 617 737 ; +C -1 ; WX 638 ; N Otilde ; B 32 -19 606 917 ; +C -1 ; WX 684 ; N onequarter ; B 60 -19 620 703 ; +C -1 ; WX 592 ; N Ugrave ; B 65 -19 528 929 ; +C -1 ; WX 592 ; N Ucircumflex ; B 65 -19 528 929 ; +C -1 ; WX 547 ; N Thorn ; B 71 0 510 718 ; +C -1 ; WX 479 ; N divide ; B 32 -19 447 524 ; +C -1 ; WX 547 ; N Atilde ; B 11 0 536 917 ; +C -1 ; WX 592 ; N Uacute ; B 65 -19 528 929 ; +C -1 ; WX 638 ; N Ocircumflex ; B 32 -19 606 929 ; +C -1 ; WX 479 ; N logicalnot ; B 32 108 447 390 ; +C -1 ; WX 547 ; N Aring ; B 11 0 536 931 ; +C -1 ; WX 228 ; N idieresis ; B 11 0 218 706 ; +C -1 ; WX 228 ; N iacute ; B 78 0 239 734 ; +C -1 ; WX 456 ; N aacute ; B 30 -15 435 734 ; +C -1 ; WX 479 ; N plusminus ; B 32 0 447 506 ; +C -1 ; WX 479 ; N multiply ; B 32 0 447 506 ; +C -1 ; WX 592 ; N Udieresis ; B 65 -19 528 901 ; +C -1 ; WX 479 ; N minus ; B 32 216 447 289 ; +C -1 ; WX 273 ; N onesuperior ; B 35 281 182 703 ; +C -1 ; WX 547 ; N Eacute ; B 71 0 505 929 ; +C -1 ; WX 547 ; N Acircumflex ; B 11 0 536 929 ; +C -1 ; WX 604 ; N copyright ; B -11 -19 617 737 ; +C -1 ; WX 547 ; N Agrave ; B 11 0 536 929 ; +C -1 ; WX 456 ; N odieresis ; B 29 -14 427 706 ; +C -1 ; WX 456 ; N oacute ; B 29 -14 427 734 ; +C -1 ; WX 328 ; N degree ; B 44 411 284 703 ; +C -1 ; WX 228 ; N igrave ; B -11 0 151 734 ; +C -1 ; WX 456 ; N mu ; B 56 -207 401 523 ; +C -1 ; WX 638 ; N Oacute ; B 32 -19 606 929 ; +C -1 ; WX 456 ; N eth ; B 29 -15 428 737 ; +C -1 ; WX 547 ; N Adieresis ; B 11 0 536 901 ; +C -1 ; WX 547 ; N Yacute ; B 11 0 535 929 ; +C -1 ; WX 213 ; N brokenbar ; B 77 -19 137 737 ; +C -1 ; WX 684 ; N onehalf ; B 35 -19 634 703 ; +EndCharMetrics +StartKernData +StartKernPairs 250 + +KPX A y -32 +KPX A w -32 +KPX A v -32 +KPX A u -24 +KPX A Y -81 +KPX A W -40 +KPX A V -56 +KPX A U -40 +KPX A T -97 +KPX A Q -24 +KPX A O -24 +KPX A G -24 +KPX A C -24 + +KPX B period -15 +KPX B comma -15 +KPX B U -7 + +KPX C period -24 +KPX C comma -24 + +KPX D period -56 +KPX D comma -56 +KPX D Y -73 +KPX D W -32 +KPX D V -56 +KPX D A -32 + +KPX F r -36 +KPX F period -122 +KPX F o -24 +KPX F e -24 +KPX F comma -122 +KPX F a -40 +KPX F A -65 + +KPX J u -15 +KPX J period -24 +KPX J comma -24 +KPX J a -15 +KPX J A -15 + +KPX K y -40 +KPX K u -24 +KPX K o -32 +KPX K e -32 +KPX K O -40 + +KPX L y -24 +KPX L quoteright -130 +KPX L quotedblright -114 +KPX L Y -114 +KPX L W -56 +KPX L V -89 +KPX L T -89 + +KPX O period -32 +KPX O comma -32 +KPX O Y -56 +KPX O X -48 +KPX O W -24 +KPX O V -40 +KPX O T -32 +KPX O A -15 + +KPX P period -147 +KPX P o -40 +KPX P e -40 +KPX P comma -147 +KPX P a -32 +KPX P A -97 + +KPX Q U -7 + +KPX R Y -40 +KPX R W -24 +KPX R V -40 +KPX R U -32 +KPX R T -24 +KPX R O -15 + +KPX S period -15 +KPX S comma -15 + +KPX T y -97 +KPX T w -97 +KPX T u -97 +KPX T semicolon -15 +KPX T r -97 +KPX T period -97 +KPX T o -97 +KPX T hyphen -114 +KPX T e -97 +KPX T comma -97 +KPX T colon -15 +KPX T a -97 +KPX T O -32 +KPX T A -97 + +KPX U period -32 +KPX U comma -32 +KPX U A -32 + +KPX V u -56 +KPX V semicolon -32 +KPX V period -102 +KPX V o -65 +KPX V hyphen -65 +KPX V e -65 +KPX V comma -102 +KPX V colon -32 +KPX V a -56 +KPX V O -32 +KPX V G -32 +KPX V A -65 + +KPX W y -15 +KPX W u -24 +KPX W period -65 +KPX W o -24 +KPX W hyphen -32 +KPX W e -24 +KPX W comma -65 +KPX W a -32 +KPX W O -15 +KPX W A -40 + +KPX Y u -89 +KPX Y semicolon -48 +KPX Y period -114 +KPX Y o -114 +KPX Y i -15 +KPX Y hyphen -114 +KPX Y e -114 +KPX Y comma -114 +KPX Y colon -48 +KPX Y a -114 +KPX Y O -69 +KPX Y A -89 + +KPX a y -24 +KPX a w -15 +KPX a v -15 + +KPX b y -15 +KPX b v -15 +KPX b u -15 +KPX b period -32 +KPX b l -15 +KPX b comma -32 +KPX b b -7 + +KPX c k -15 +KPX c comma -11 + +KPX colon space -40 + +KPX comma quoteright -81 +KPX comma quotedblright -81 + +KPX e y -15 +KPX e x -24 +KPX e w -15 +KPX e v -24 +KPX e period -11 +KPX e comma -11 + +KPX f quoteright 41 +KPX f quotedblright 49 +KPX f period -24 +KPX f o -24 +KPX f e -24 +KPX f dotlessi -22 +KPX f comma -24 +KPX f a -24 + +KPX g r -7 + +KPX h y -24 + +KPX k o -15 +KPX k e -15 + +KPX m y -11 +KPX m u -7 + +KPX n y -11 +KPX n v -15 +KPX n u -7 + +KPX o y -24 +KPX o x -24 +KPX o w -11 +KPX o v -11 +KPX o period -32 +KPX o comma -32 + +KPX oslash z -44 +KPX oslash y -56 +KPX oslash x -69 +KPX oslash w -56 +KPX oslash v -56 +KPX oslash u -44 +KPX oslash t -44 +KPX oslash s -44 +KPX oslash r -44 +KPX oslash q -44 +KPX oslash period -77 +KPX oslash p -44 +KPX oslash o -44 +KPX oslash n -44 +KPX oslash m -44 +KPX oslash l -44 +KPX oslash k -44 +KPX oslash j -44 +KPX oslash i -44 +KPX oslash h -44 +KPX oslash g -44 +KPX oslash f -44 +KPX oslash e -44 +KPX oslash d -44 +KPX oslash comma -77 +KPX oslash c -44 +KPX oslash b -44 +KPX oslash a -44 + +KPX p y -24 +KPX p period -28 +KPX p comma -28 + +KPX period space -48 +KPX period quoteright -81 +KPX period quotedblright -81 + +KPX quotedblright space -32 + +KPX quoteleft quoteleft -46 + +KPX quoteright space -56 +KPX quoteright s -40 +KPX quoteright r -40 +KPX quoteright quoteright -46 +KPX quoteright d -40 + +KPX r y 25 +KPX r v 25 +KPX r u 12 +KPX r t 33 +KPX r semicolon 25 +KPX r period -40 +KPX r p 25 +KPX r n 21 +KPX r m 21 +KPX r l 12 +KPX r k 12 +KPX r i 12 +KPX r comma -40 +KPX r colon 25 +KPX r a -7 + +KPX s w -24 +KPX s period -11 +KPX s comma -11 + +KPX semicolon space -40 + +KPX space quoteleft -48 +KPX space quotedblleft -24 +KPX space Y -73 +KPX space W -32 +KPX space V -40 +KPX space T -40 + +KPX v period -65 +KPX v o -20 +KPX v e -20 +KPX v comma -65 +KPX v a -20 + +KPX w period -48 +KPX w o -7 +KPX w e -7 +KPX w comma -48 +KPX w a -11 + +KPX x e -24 + +KPX y period -81 +KPX y o -15 +KPX y e -15 +KPX y comma -81 +KPX y a -15 + +KPX z o -11 +KPX z e -11 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 137 195 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 137 195 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 137 195 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 137 195 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 137 175 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 137 195 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 160 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 137 195 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 137 195 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 137 195 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 137 195 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute -22 195 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -22 195 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -22 195 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -22 195 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 168 195 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 183 195 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 183 195 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 183 195 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 183 195 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 183 195 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 137 195 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 160 195 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 160 195 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 160 195 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 160 195 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 137 195 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 137 195 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 114 195 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 92 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 92 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 92 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 92 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 92 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 84 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 69 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 92 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 92 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 92 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 92 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -22 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -22 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -22 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -22 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 84 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 92 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 92 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 92 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 92 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 92 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 69 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 92 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 92 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 92 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 92 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 69 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 69 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 69 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8a.afm new file mode 100644 index 00000000..3d69eb7c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8a.afm @@ -0,0 +1,612 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Thu Mar 15 10:24:18 1990 +Comment UniqueID 28362 +Comment VMusage 7572 42473 +FontName Helvetica-Oblique +FullName Helvetica Oblique +FamilyName Helvetica +Weight Medium +ItalicAngle -12 +IsFixedPitch false +FontBBox -170 -225 1116 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 90 0 340 718 ; +C 34 ; WX 355 ; N quotedbl ; B 168 463 438 718 ; +C 35 ; WX 556 ; N numbersign ; B 73 0 631 688 ; +C 36 ; WX 556 ; N dollar ; B 69 -115 617 775 ; +C 37 ; WX 889 ; N percent ; B 147 -19 889 703 ; +C 38 ; WX 667 ; N ampersand ; B 77 -15 647 718 ; +C 39 ; WX 222 ; N quoteright ; B 151 463 310 718 ; +C 40 ; WX 333 ; N parenleft ; B 108 -207 454 733 ; +C 41 ; WX 333 ; N parenright ; B -9 -207 337 733 ; +C 42 ; WX 389 ; N asterisk ; B 165 431 475 718 ; +C 43 ; WX 584 ; N plus ; B 85 0 606 505 ; +C 44 ; WX 278 ; N comma ; B 56 -147 214 106 ; +C 45 ; WX 333 ; N hyphen ; B 93 232 357 322 ; +C 46 ; WX 278 ; N period ; B 87 0 214 106 ; +C 47 ; WX 278 ; N slash ; B -21 -19 452 737 ; +C 48 ; WX 556 ; N zero ; B 93 -19 608 703 ; +C 49 ; WX 556 ; N one ; B 207 0 508 703 ; +C 50 ; WX 556 ; N two ; B 26 0 617 703 ; +C 51 ; WX 556 ; N three ; B 75 -19 610 703 ; +C 52 ; WX 556 ; N four ; B 61 0 576 703 ; +C 53 ; WX 556 ; N five ; B 68 -19 621 688 ; +C 54 ; WX 556 ; N six ; B 91 -19 615 703 ; +C 55 ; WX 556 ; N seven ; B 137 0 669 688 ; +C 56 ; WX 556 ; N eight ; B 74 -19 607 703 ; +C 57 ; WX 556 ; N nine ; B 82 -19 609 703 ; +C 58 ; WX 278 ; N colon ; B 87 0 301 516 ; +C 59 ; WX 278 ; N semicolon ; B 56 -147 301 516 ; +C 60 ; WX 584 ; N less ; B 94 11 641 495 ; +C 61 ; WX 584 ; N equal ; B 63 115 628 390 ; +C 62 ; WX 584 ; N greater ; B 50 11 597 495 ; +C 63 ; WX 556 ; N question ; B 161 0 610 727 ; +C 64 ; WX 1015 ; N at ; B 215 -19 965 737 ; +C 65 ; WX 667 ; N A ; B 14 0 654 718 ; +C 66 ; WX 667 ; N B ; B 74 0 712 718 ; +C 67 ; WX 722 ; N C ; B 108 -19 782 737 ; +C 68 ; WX 722 ; N D ; B 81 0 764 718 ; +C 69 ; WX 667 ; N E ; B 86 0 762 718 ; +C 70 ; WX 611 ; N F ; B 86 0 736 718 ; +C 71 ; WX 778 ; N G ; B 111 -19 799 737 ; +C 72 ; WX 722 ; N H ; B 77 0 799 718 ; +C 73 ; WX 278 ; N I ; B 91 0 341 718 ; +C 74 ; WX 500 ; N J ; B 47 -19 581 718 ; +C 75 ; WX 667 ; N K ; B 76 0 808 718 ; +C 76 ; WX 556 ; N L ; B 76 0 555 718 ; +C 77 ; WX 833 ; N M ; B 73 0 914 718 ; +C 78 ; WX 722 ; N N ; B 76 0 799 718 ; +C 79 ; WX 778 ; N O ; B 105 -19 826 737 ; +C 80 ; WX 667 ; N P ; B 86 0 737 718 ; +C 81 ; WX 778 ; N Q ; B 105 -56 826 737 ; +C 82 ; WX 722 ; N R ; B 88 0 773 718 ; +C 83 ; WX 667 ; N S ; B 90 -19 713 737 ; +C 84 ; WX 611 ; N T ; B 148 0 750 718 ; +C 85 ; WX 722 ; N U ; B 123 -19 797 718 ; +C 86 ; WX 667 ; N V ; B 173 0 800 718 ; +C 87 ; WX 944 ; N W ; B 169 0 1081 718 ; +C 88 ; WX 667 ; N X ; B 19 0 790 718 ; +C 89 ; WX 667 ; N Y ; B 167 0 806 718 ; +C 90 ; WX 611 ; N Z ; B 23 0 741 718 ; +C 91 ; WX 278 ; N bracketleft ; B 21 -196 403 722 ; +C 92 ; WX 278 ; N backslash ; B 140 -19 291 737 ; +C 93 ; WX 278 ; N bracketright ; B -14 -196 368 722 ; +C 94 ; WX 469 ; N asciicircum ; B 42 264 539 688 ; +C 95 ; WX 556 ; N underscore ; B -27 -125 540 -75 ; +C 96 ; WX 222 ; N quoteleft ; B 165 470 323 725 ; +C 97 ; WX 556 ; N a ; B 61 -15 559 538 ; +C 98 ; WX 556 ; N b ; B 58 -15 584 718 ; +C 99 ; WX 500 ; N c ; B 74 -15 553 538 ; +C 100 ; WX 556 ; N d ; B 84 -15 652 718 ; +C 101 ; WX 556 ; N e ; B 84 -15 578 538 ; +C 102 ; WX 278 ; N f ; B 86 0 416 728 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 42 -220 610 538 ; +C 104 ; WX 556 ; N h ; B 65 0 573 718 ; +C 105 ; WX 222 ; N i ; B 67 0 308 718 ; +C 106 ; WX 222 ; N j ; B -60 -210 308 718 ; +C 107 ; WX 500 ; N k ; B 67 0 600 718 ; +C 108 ; WX 222 ; N l ; B 67 0 308 718 ; +C 109 ; WX 833 ; N m ; B 65 0 852 538 ; +C 110 ; WX 556 ; N n ; B 65 0 573 538 ; +C 111 ; WX 556 ; N o ; B 83 -14 585 538 ; +C 112 ; WX 556 ; N p ; B 14 -207 584 538 ; +C 113 ; WX 556 ; N q ; B 84 -207 605 538 ; +C 114 ; WX 333 ; N r ; B 77 0 446 538 ; +C 115 ; WX 500 ; N s ; B 63 -15 529 538 ; +C 116 ; WX 278 ; N t ; B 102 -7 368 669 ; +C 117 ; WX 556 ; N u ; B 94 -15 600 523 ; +C 118 ; WX 500 ; N v ; B 119 0 603 523 ; +C 119 ; WX 722 ; N w ; B 125 0 820 523 ; +C 120 ; WX 500 ; N x ; B 11 0 594 523 ; +C 121 ; WX 500 ; N y ; B 15 -214 600 523 ; +C 122 ; WX 500 ; N z ; B 31 0 571 523 ; +C 123 ; WX 334 ; N braceleft ; B 92 -196 445 722 ; +C 124 ; WX 260 ; N bar ; B 90 -19 324 737 ; +C 125 ; WX 334 ; N braceright ; B 0 -196 354 722 ; +C 126 ; WX 584 ; N asciitilde ; B 111 180 580 326 ; +C 161 ; WX 333 ; N exclamdown ; B 77 -195 326 523 ; +C 162 ; WX 556 ; N cent ; B 95 -115 584 623 ; +C 163 ; WX 556 ; N sterling ; B 49 -16 634 718 ; +C 164 ; WX 167 ; N fraction ; B -170 -19 482 703 ; +C 165 ; WX 556 ; N yen ; B 81 0 699 688 ; +C 166 ; WX 556 ; N florin ; B -52 -207 654 737 ; +C 167 ; WX 556 ; N section ; B 76 -191 584 737 ; +C 168 ; WX 556 ; N currency ; B 60 99 646 603 ; +C 169 ; WX 191 ; N quotesingle ; B 157 463 285 718 ; +C 170 ; WX 333 ; N quotedblleft ; B 138 470 461 725 ; +C 171 ; WX 556 ; N guillemotleft ; B 146 108 554 446 ; +C 172 ; WX 333 ; N guilsinglleft ; B 137 108 340 446 ; +C 173 ; WX 333 ; N guilsinglright ; B 111 108 314 446 ; +C 174 ; WX 500 ; N fi ; B 86 0 587 728 ; +C 175 ; WX 500 ; N fl ; B 86 0 585 728 ; +C 177 ; WX 556 ; N endash ; B 51 240 623 313 ; +C 178 ; WX 556 ; N dagger ; B 135 -159 622 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 52 -159 623 718 ; +C 180 ; WX 278 ; N periodcentered ; B 129 190 257 315 ; +C 182 ; WX 537 ; N paragraph ; B 126 -173 650 718 ; +C 183 ; WX 350 ; N bullet ; B 91 202 413 517 ; +C 184 ; WX 222 ; N quotesinglbase ; B 21 -149 180 106 ; +C 185 ; WX 333 ; N quotedblbase ; B -6 -149 318 106 ; +C 186 ; WX 333 ; N quotedblright ; B 124 463 448 718 ; +C 187 ; WX 556 ; N guillemotright ; B 120 108 528 446 ; +C 188 ; WX 1000 ; N ellipsis ; B 115 0 908 106 ; +C 189 ; WX 1000 ; N perthousand ; B 88 -19 1029 703 ; +C 191 ; WX 611 ; N questiondown ; B 85 -201 534 525 ; +C 193 ; WX 333 ; N grave ; B 170 593 337 734 ; +C 194 ; WX 333 ; N acute ; B 248 593 475 734 ; +C 195 ; WX 333 ; N circumflex ; B 147 593 438 734 ; +C 196 ; WX 333 ; N tilde ; B 125 606 490 722 ; +C 197 ; WX 333 ; N macron ; B 143 627 468 684 ; +C 198 ; WX 333 ; N breve ; B 167 595 476 731 ; +C 199 ; WX 333 ; N dotaccent ; B 249 604 362 706 ; +C 200 ; WX 333 ; N dieresis ; B 168 604 443 706 ; +C 202 ; WX 333 ; N ring ; B 214 572 402 756 ; +C 203 ; WX 333 ; N cedilla ; B 2 -225 232 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 157 593 565 734 ; +C 206 ; WX 333 ; N ogonek ; B 43 -225 249 0 ; +C 207 ; WX 333 ; N caron ; B 177 593 468 734 ; +C 208 ; WX 1000 ; N emdash ; B 51 240 1067 313 ; +C 225 ; WX 1000 ; N AE ; B 8 0 1097 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 100 304 449 737 ; +C 232 ; WX 556 ; N Lslash ; B 41 0 555 718 ; +C 233 ; WX 778 ; N Oslash ; B 43 -19 890 737 ; +C 234 ; WX 1000 ; N OE ; B 98 -19 1116 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 100 304 468 737 ; +C 241 ; WX 889 ; N ae ; B 61 -15 909 538 ; +C 245 ; WX 278 ; N dotlessi ; B 95 0 294 523 ; +C 248 ; WX 222 ; N lslash ; B 41 0 347 718 ; +C 249 ; WX 611 ; N oslash ; B 29 -22 647 545 ; +C 250 ; WX 944 ; N oe ; B 83 -15 964 538 ; +C 251 ; WX 611 ; N germandbls ; B 67 -15 658 728 ; +C -1 ; WX 611 ; N Zcaron ; B 23 0 741 929 ; +C -1 ; WX 500 ; N ccedilla ; B 74 -225 553 538 ; +C -1 ; WX 500 ; N ydieresis ; B 15 -214 600 706 ; +C -1 ; WX 556 ; N atilde ; B 61 -15 592 722 ; +C -1 ; WX 278 ; N icircumflex ; B 95 0 411 734 ; +C -1 ; WX 333 ; N threesuperior ; B 90 270 436 703 ; +C -1 ; WX 556 ; N ecircumflex ; B 84 -15 578 734 ; +C -1 ; WX 556 ; N thorn ; B 14 -207 584 718 ; +C -1 ; WX 556 ; N egrave ; B 84 -15 578 734 ; +C -1 ; WX 333 ; N twosuperior ; B 64 281 449 703 ; +C -1 ; WX 556 ; N eacute ; B 84 -15 587 734 ; +C -1 ; WX 556 ; N otilde ; B 83 -14 602 722 ; +C -1 ; WX 667 ; N Aacute ; B 14 0 683 929 ; +C -1 ; WX 556 ; N ocircumflex ; B 83 -14 585 734 ; +C -1 ; WX 500 ; N yacute ; B 15 -214 600 734 ; +C -1 ; WX 556 ; N udieresis ; B 94 -15 600 706 ; +C -1 ; WX 834 ; N threequarters ; B 130 -19 861 703 ; +C -1 ; WX 556 ; N acircumflex ; B 61 -15 559 734 ; +C -1 ; WX 722 ; N Eth ; B 69 0 764 718 ; +C -1 ; WX 556 ; N edieresis ; B 84 -15 578 706 ; +C -1 ; WX 556 ; N ugrave ; B 94 -15 600 734 ; +C -1 ; WX 1000 ; N trademark ; B 186 306 1056 718 ; +C -1 ; WX 556 ; N ograve ; B 83 -14 585 734 ; +C -1 ; WX 500 ; N scaron ; B 63 -15 552 734 ; +C -1 ; WX 278 ; N Idieresis ; B 91 0 458 901 ; +C -1 ; WX 556 ; N uacute ; B 94 -15 600 734 ; +C -1 ; WX 556 ; N agrave ; B 61 -15 559 734 ; +C -1 ; WX 556 ; N ntilde ; B 65 0 592 722 ; +C -1 ; WX 556 ; N aring ; B 61 -15 559 756 ; +C -1 ; WX 500 ; N zcaron ; B 31 0 571 734 ; +C -1 ; WX 278 ; N Icircumflex ; B 91 0 452 929 ; +C -1 ; WX 722 ; N Ntilde ; B 76 0 799 917 ; +C -1 ; WX 556 ; N ucircumflex ; B 94 -15 600 734 ; +C -1 ; WX 667 ; N Ecircumflex ; B 86 0 762 929 ; +C -1 ; WX 278 ; N Iacute ; B 91 0 489 929 ; +C -1 ; WX 722 ; N Ccedilla ; B 108 -225 782 737 ; +C -1 ; WX 778 ; N Odieresis ; B 105 -19 826 901 ; +C -1 ; WX 667 ; N Scaron ; B 90 -19 713 929 ; +C -1 ; WX 667 ; N Edieresis ; B 86 0 762 901 ; +C -1 ; WX 278 ; N Igrave ; B 91 0 351 929 ; +C -1 ; WX 556 ; N adieresis ; B 61 -15 559 706 ; +C -1 ; WX 778 ; N Ograve ; B 105 -19 826 929 ; +C -1 ; WX 667 ; N Egrave ; B 86 0 762 929 ; +C -1 ; WX 667 ; N Ydieresis ; B 167 0 806 901 ; +C -1 ; WX 737 ; N registered ; B 54 -19 837 737 ; +C -1 ; WX 778 ; N Otilde ; B 105 -19 826 917 ; +C -1 ; WX 834 ; N onequarter ; B 150 -19 802 703 ; +C -1 ; WX 722 ; N Ugrave ; B 123 -19 797 929 ; +C -1 ; WX 722 ; N Ucircumflex ; B 123 -19 797 929 ; +C -1 ; WX 667 ; N Thorn ; B 86 0 712 718 ; +C -1 ; WX 584 ; N divide ; B 85 -19 606 524 ; +C -1 ; WX 667 ; N Atilde ; B 14 0 699 917 ; +C -1 ; WX 722 ; N Uacute ; B 123 -19 797 929 ; +C -1 ; WX 778 ; N Ocircumflex ; B 105 -19 826 929 ; +C -1 ; WX 584 ; N logicalnot ; B 106 108 628 390 ; +C -1 ; WX 667 ; N Aring ; B 14 0 654 931 ; +C -1 ; WX 278 ; N idieresis ; B 95 0 416 706 ; +C -1 ; WX 278 ; N iacute ; B 95 0 448 734 ; +C -1 ; WX 556 ; N aacute ; B 61 -15 587 734 ; +C -1 ; WX 584 ; N plusminus ; B 39 0 618 506 ; +C -1 ; WX 584 ; N multiply ; B 50 0 642 506 ; +C -1 ; WX 722 ; N Udieresis ; B 123 -19 797 901 ; +C -1 ; WX 584 ; N minus ; B 85 216 606 289 ; +C -1 ; WX 333 ; N onesuperior ; B 166 281 371 703 ; +C -1 ; WX 667 ; N Eacute ; B 86 0 762 929 ; +C -1 ; WX 667 ; N Acircumflex ; B 14 0 654 929 ; +C -1 ; WX 737 ; N copyright ; B 54 -19 837 737 ; +C -1 ; WX 667 ; N Agrave ; B 14 0 654 929 ; +C -1 ; WX 556 ; N odieresis ; B 83 -14 585 706 ; +C -1 ; WX 556 ; N oacute ; B 83 -14 587 734 ; +C -1 ; WX 400 ; N degree ; B 169 411 468 703 ; +C -1 ; WX 278 ; N igrave ; B 95 0 310 734 ; +C -1 ; WX 556 ; N mu ; B 24 -207 600 523 ; +C -1 ; WX 778 ; N Oacute ; B 105 -19 826 929 ; +C -1 ; WX 556 ; N eth ; B 81 -15 617 737 ; +C -1 ; WX 667 ; N Adieresis ; B 14 0 654 901 ; +C -1 ; WX 667 ; N Yacute ; B 167 0 806 929 ; +C -1 ; WX 260 ; N brokenbar ; B 90 -19 324 737 ; +C -1 ; WX 834 ; N onehalf ; B 114 -19 839 703 ; +EndCharMetrics +StartKernData +StartKernPairs 250 + +KPX A y -40 +KPX A w -40 +KPX A v -40 +KPX A u -30 +KPX A Y -100 +KPX A W -50 +KPX A V -70 +KPX A U -50 +KPX A T -120 +KPX A Q -30 +KPX A O -30 +KPX A G -30 +KPX A C -30 + +KPX B period -20 +KPX B comma -20 +KPX B U -10 + +KPX C period -30 +KPX C comma -30 + +KPX D period -70 +KPX D comma -70 +KPX D Y -90 +KPX D W -40 +KPX D V -70 +KPX D A -40 + +KPX F r -45 +KPX F period -150 +KPX F o -30 +KPX F e -30 +KPX F comma -150 +KPX F a -50 +KPX F A -80 + +KPX J u -20 +KPX J period -30 +KPX J comma -30 +KPX J a -20 +KPX J A -20 + +KPX K y -50 +KPX K u -30 +KPX K o -40 +KPX K e -40 +KPX K O -50 + +KPX L y -30 +KPX L quoteright -160 +KPX L quotedblright -140 +KPX L Y -140 +KPX L W -70 +KPX L V -110 +KPX L T -110 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -60 +KPX O W -30 +KPX O V -50 +KPX O T -40 +KPX O A -20 + +KPX P period -180 +KPX P o -50 +KPX P e -50 +KPX P comma -180 +KPX P a -40 +KPX P A -120 + +KPX Q U -10 + +KPX R Y -50 +KPX R W -30 +KPX R V -50 +KPX R U -40 +KPX R T -30 +KPX R O -20 + +KPX S period -20 +KPX S comma -20 + +KPX T y -120 +KPX T w -120 +KPX T u -120 +KPX T semicolon -20 +KPX T r -120 +KPX T period -120 +KPX T o -120 +KPX T hyphen -140 +KPX T e -120 +KPX T comma -120 +KPX T colon -20 +KPX T a -120 +KPX T O -40 +KPX T A -120 + +KPX U period -40 +KPX U comma -40 +KPX U A -40 + +KPX V u -70 +KPX V semicolon -40 +KPX V period -125 +KPX V o -80 +KPX V hyphen -80 +KPX V e -80 +KPX V comma -125 +KPX V colon -40 +KPX V a -70 +KPX V O -40 +KPX V G -40 +KPX V A -80 + +KPX W y -20 +KPX W u -30 +KPX W period -80 +KPX W o -30 +KPX W hyphen -40 +KPX W e -30 +KPX W comma -80 +KPX W a -40 +KPX W O -20 +KPX W A -50 + +KPX Y u -110 +KPX Y semicolon -60 +KPX Y period -140 +KPX Y o -140 +KPX Y i -20 +KPX Y hyphen -140 +KPX Y e -140 +KPX Y comma -140 +KPX Y colon -60 +KPX Y a -140 +KPX Y O -85 +KPX Y A -110 + +KPX a y -30 +KPX a w -20 +KPX a v -20 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b period -40 +KPX b l -20 +KPX b comma -40 +KPX b b -10 + +KPX c k -20 +KPX c comma -15 + +KPX colon space -50 + +KPX comma quoteright -100 +KPX comma quotedblright -100 + +KPX e y -20 +KPX e x -30 +KPX e w -20 +KPX e v -30 +KPX e period -15 +KPX e comma -15 + +KPX f quoteright 50 +KPX f quotedblright 60 +KPX f period -30 +KPX f o -30 +KPX f e -30 +KPX f dotlessi -28 +KPX f comma -30 +KPX f a -30 + +KPX g r -10 + +KPX h y -30 + +KPX k o -20 +KPX k e -20 + +KPX m y -15 +KPX m u -10 + +KPX n y -15 +KPX n v -20 +KPX n u -10 + +KPX o y -30 +KPX o x -30 +KPX o w -15 +KPX o v -15 +KPX o period -40 +KPX o comma -40 + +KPX oslash z -55 +KPX oslash y -70 +KPX oslash x -85 +KPX oslash w -70 +KPX oslash v -70 +KPX oslash u -55 +KPX oslash t -55 +KPX oslash s -55 +KPX oslash r -55 +KPX oslash q -55 +KPX oslash period -95 +KPX oslash p -55 +KPX oslash o -55 +KPX oslash n -55 +KPX oslash m -55 +KPX oslash l -55 +KPX oslash k -55 +KPX oslash j -55 +KPX oslash i -55 +KPX oslash h -55 +KPX oslash g -55 +KPX oslash f -55 +KPX oslash e -55 +KPX oslash d -55 +KPX oslash comma -95 +KPX oslash c -55 +KPX oslash b -55 +KPX oslash a -55 + +KPX p y -30 +KPX p period -35 +KPX p comma -35 + +KPX period space -60 +KPX period quoteright -100 +KPX period quotedblright -100 + +KPX quotedblright space -40 + +KPX quoteleft quoteleft -57 + +KPX quoteright space -70 +KPX quoteright s -50 +KPX quoteright r -50 +KPX quoteright quoteright -57 +KPX quoteright d -50 + +KPX r y 30 +KPX r v 30 +KPX r u 15 +KPX r t 40 +KPX r semicolon 30 +KPX r period -50 +KPX r p 30 +KPX r n 25 +KPX r m 25 +KPX r l 15 +KPX r k 15 +KPX r i 15 +KPX r comma -50 +KPX r colon 30 +KPX r a -10 + +KPX s w -30 +KPX s period -15 +KPX s comma -15 + +KPX semicolon space -50 + +KPX space quoteleft -60 +KPX space quotedblleft -30 +KPX space Y -90 +KPX space W -40 +KPX space V -50 +KPX space T -50 + +KPX v period -80 +KPX v o -25 +KPX v e -25 +KPX v comma -80 +KPX v a -25 + +KPX w period -60 +KPX w o -10 +KPX w e -10 +KPX w comma -60 +KPX w a -15 + +KPX x e -30 + +KPX y period -100 +KPX y o -20 +KPX y e -20 +KPX y comma -100 +KPX y a -20 + +KPX z o -15 +KPX z e -15 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 208 195 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 208 195 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 208 195 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 208 195 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 204 175 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 208 195 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 195 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 208 195 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 208 195 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 208 195 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 208 195 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 14 195 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 14 195 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 14 195 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 14 195 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 246 195 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 264 195 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 264 195 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 264 195 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 264 195 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 264 195 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 208 195 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 236 195 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 236 195 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 236 195 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 236 195 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 208 195 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 208 195 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 180 195 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 112 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 102 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 84 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 112 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 112 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 112 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 112 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 102 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 112 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 112 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 112 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 112 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 112 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 84 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 112 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 112 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 112 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 112 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 84 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8an.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8an.afm new file mode 100644 index 00000000..f757319a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/phvro8an.afm @@ -0,0 +1,612 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Thu Mar 15 11:25:48 1990 +Comment UniqueID 28389 +Comment VMusage 7572 42473 +FontName Helvetica-Narrow-Oblique +FullName Helvetica Narrow Oblique +FamilyName Helvetica +Weight Medium +ItalicAngle -12 +IsFixedPitch false +FontBBox -139 -225 915 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved.Helvetica is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StartCharMetrics 228 +C 32 ; WX 228 ; N space ; B 0 0 0 0 ; +C 33 ; WX 228 ; N exclam ; B 74 0 278 718 ; +C 34 ; WX 291 ; N quotedbl ; B 138 463 359 718 ; +C 35 ; WX 456 ; N numbersign ; B 60 0 517 688 ; +C 36 ; WX 456 ; N dollar ; B 57 -115 506 775 ; +C 37 ; WX 729 ; N percent ; B 120 -19 729 703 ; +C 38 ; WX 547 ; N ampersand ; B 63 -15 530 718 ; +C 39 ; WX 182 ; N quoteright ; B 124 463 254 718 ; +C 40 ; WX 273 ; N parenleft ; B 89 -207 372 733 ; +C 41 ; WX 273 ; N parenright ; B -7 -207 276 733 ; +C 42 ; WX 319 ; N asterisk ; B 135 431 389 718 ; +C 43 ; WX 479 ; N plus ; B 70 0 497 505 ; +C 44 ; WX 228 ; N comma ; B 46 -147 175 106 ; +C 45 ; WX 273 ; N hyphen ; B 77 232 293 322 ; +C 46 ; WX 228 ; N period ; B 71 0 175 106 ; +C 47 ; WX 228 ; N slash ; B -17 -19 370 737 ; +C 48 ; WX 456 ; N zero ; B 77 -19 499 703 ; +C 49 ; WX 456 ; N one ; B 170 0 417 703 ; +C 50 ; WX 456 ; N two ; B 21 0 506 703 ; +C 51 ; WX 456 ; N three ; B 61 -19 500 703 ; +C 52 ; WX 456 ; N four ; B 50 0 472 703 ; +C 53 ; WX 456 ; N five ; B 55 -19 509 688 ; +C 54 ; WX 456 ; N six ; B 74 -19 504 703 ; +C 55 ; WX 456 ; N seven ; B 112 0 549 688 ; +C 56 ; WX 456 ; N eight ; B 60 -19 497 703 ; +C 57 ; WX 456 ; N nine ; B 67 -19 499 703 ; +C 58 ; WX 228 ; N colon ; B 71 0 247 516 ; +C 59 ; WX 228 ; N semicolon ; B 46 -147 247 516 ; +C 60 ; WX 479 ; N less ; B 77 11 526 495 ; +C 61 ; WX 479 ; N equal ; B 52 115 515 390 ; +C 62 ; WX 479 ; N greater ; B 41 11 490 495 ; +C 63 ; WX 456 ; N question ; B 132 0 500 727 ; +C 64 ; WX 832 ; N at ; B 176 -19 791 737 ; +C 65 ; WX 547 ; N A ; B 11 0 536 718 ; +C 66 ; WX 547 ; N B ; B 61 0 583 718 ; +C 67 ; WX 592 ; N C ; B 88 -19 640 737 ; +C 68 ; WX 592 ; N D ; B 66 0 626 718 ; +C 69 ; WX 547 ; N E ; B 71 0 625 718 ; +C 70 ; WX 501 ; N F ; B 71 0 603 718 ; +C 71 ; WX 638 ; N G ; B 91 -19 655 737 ; +C 72 ; WX 592 ; N H ; B 63 0 655 718 ; +C 73 ; WX 228 ; N I ; B 75 0 279 718 ; +C 74 ; WX 410 ; N J ; B 39 -19 476 718 ; +C 75 ; WX 547 ; N K ; B 62 0 662 718 ; +C 76 ; WX 456 ; N L ; B 62 0 455 718 ; +C 77 ; WX 683 ; N M ; B 60 0 749 718 ; +C 78 ; WX 592 ; N N ; B 62 0 655 718 ; +C 79 ; WX 638 ; N O ; B 86 -19 677 737 ; +C 80 ; WX 547 ; N P ; B 71 0 604 718 ; +C 81 ; WX 638 ; N Q ; B 86 -56 677 737 ; +C 82 ; WX 592 ; N R ; B 72 0 634 718 ; +C 83 ; WX 547 ; N S ; B 74 -19 584 737 ; +C 84 ; WX 501 ; N T ; B 122 0 615 718 ; +C 85 ; WX 592 ; N U ; B 101 -19 653 718 ; +C 86 ; WX 547 ; N V ; B 142 0 656 718 ; +C 87 ; WX 774 ; N W ; B 138 0 886 718 ; +C 88 ; WX 547 ; N X ; B 16 0 647 718 ; +C 89 ; WX 547 ; N Y ; B 137 0 661 718 ; +C 90 ; WX 501 ; N Z ; B 19 0 607 718 ; +C 91 ; WX 228 ; N bracketleft ; B 17 -196 331 722 ; +C 92 ; WX 228 ; N backslash ; B 115 -19 239 737 ; +C 93 ; WX 228 ; N bracketright ; B -11 -196 302 722 ; +C 94 ; WX 385 ; N asciicircum ; B 35 264 442 688 ; +C 95 ; WX 456 ; N underscore ; B -22 -125 443 -75 ; +C 96 ; WX 182 ; N quoteleft ; B 135 470 265 725 ; +C 97 ; WX 456 ; N a ; B 50 -15 458 538 ; +C 98 ; WX 456 ; N b ; B 48 -15 479 718 ; +C 99 ; WX 410 ; N c ; B 61 -15 454 538 ; +C 100 ; WX 456 ; N d ; B 69 -15 534 718 ; +C 101 ; WX 456 ; N e ; B 69 -15 474 538 ; +C 102 ; WX 228 ; N f ; B 71 0 341 728 ; L i fi ; L l fl ; +C 103 ; WX 456 ; N g ; B 34 -220 500 538 ; +C 104 ; WX 456 ; N h ; B 53 0 470 718 ; +C 105 ; WX 182 ; N i ; B 55 0 252 718 ; +C 106 ; WX 182 ; N j ; B -49 -210 252 718 ; +C 107 ; WX 410 ; N k ; B 55 0 492 718 ; +C 108 ; WX 182 ; N l ; B 55 0 252 718 ; +C 109 ; WX 683 ; N m ; B 53 0 699 538 ; +C 110 ; WX 456 ; N n ; B 53 0 470 538 ; +C 111 ; WX 456 ; N o ; B 68 -14 479 538 ; +C 112 ; WX 456 ; N p ; B 11 -207 479 538 ; +C 113 ; WX 456 ; N q ; B 69 -207 496 538 ; +C 114 ; WX 273 ; N r ; B 63 0 365 538 ; +C 115 ; WX 410 ; N s ; B 52 -15 434 538 ; +C 116 ; WX 228 ; N t ; B 84 -7 302 669 ; +C 117 ; WX 456 ; N u ; B 77 -15 492 523 ; +C 118 ; WX 410 ; N v ; B 98 0 495 523 ; +C 119 ; WX 592 ; N w ; B 103 0 673 523 ; +C 120 ; WX 410 ; N x ; B 9 0 487 523 ; +C 121 ; WX 410 ; N y ; B 12 -214 492 523 ; +C 122 ; WX 410 ; N z ; B 25 0 468 523 ; +C 123 ; WX 274 ; N braceleft ; B 75 -196 365 722 ; +C 124 ; WX 213 ; N bar ; B 74 -19 265 737 ; +C 125 ; WX 274 ; N braceright ; B 0 -196 291 722 ; +C 126 ; WX 479 ; N asciitilde ; B 91 180 476 326 ; +C 161 ; WX 273 ; N exclamdown ; B 63 -195 267 523 ; +C 162 ; WX 456 ; N cent ; B 78 -115 479 623 ; +C 163 ; WX 456 ; N sterling ; B 40 -16 520 718 ; +C 164 ; WX 137 ; N fraction ; B -139 -19 396 703 ; +C 165 ; WX 456 ; N yen ; B 67 0 573 688 ; +C 166 ; WX 456 ; N florin ; B -43 -207 537 737 ; +C 167 ; WX 456 ; N section ; B 63 -191 479 737 ; +C 168 ; WX 456 ; N currency ; B 49 99 530 603 ; +C 169 ; WX 157 ; N quotesingle ; B 129 463 233 718 ; +C 170 ; WX 273 ; N quotedblleft ; B 113 470 378 725 ; +C 171 ; WX 456 ; N guillemotleft ; B 120 108 454 446 ; +C 172 ; WX 273 ; N guilsinglleft ; B 112 108 279 446 ; +C 173 ; WX 273 ; N guilsinglright ; B 91 108 257 446 ; +C 174 ; WX 410 ; N fi ; B 71 0 481 728 ; +C 175 ; WX 410 ; N fl ; B 71 0 479 728 ; +C 177 ; WX 456 ; N endash ; B 42 240 510 313 ; +C 178 ; WX 456 ; N dagger ; B 110 -159 510 718 ; +C 179 ; WX 456 ; N daggerdbl ; B 43 -159 511 718 ; +C 180 ; WX 228 ; N periodcentered ; B 106 190 211 315 ; +C 182 ; WX 440 ; N paragraph ; B 103 -173 533 718 ; +C 183 ; WX 287 ; N bullet ; B 74 202 339 517 ; +C 184 ; WX 182 ; N quotesinglbase ; B 17 -149 147 106 ; +C 185 ; WX 273 ; N quotedblbase ; B -5 -149 260 106 ; +C 186 ; WX 273 ; N quotedblright ; B 102 463 367 718 ; +C 187 ; WX 456 ; N guillemotright ; B 98 108 433 446 ; +C 188 ; WX 820 ; N ellipsis ; B 94 0 744 106 ; +C 189 ; WX 820 ; N perthousand ; B 72 -19 844 703 ; +C 191 ; WX 501 ; N questiondown ; B 70 -201 438 525 ; +C 193 ; WX 273 ; N grave ; B 139 593 276 734 ; +C 194 ; WX 273 ; N acute ; B 203 593 390 734 ; +C 195 ; WX 273 ; N circumflex ; B 121 593 359 734 ; +C 196 ; WX 273 ; N tilde ; B 102 606 402 722 ; +C 197 ; WX 273 ; N macron ; B 117 627 384 684 ; +C 198 ; WX 273 ; N breve ; B 137 595 391 731 ; +C 199 ; WX 273 ; N dotaccent ; B 204 604 297 706 ; +C 200 ; WX 273 ; N dieresis ; B 138 604 363 706 ; +C 202 ; WX 273 ; N ring ; B 175 572 330 756 ; +C 203 ; WX 273 ; N cedilla ; B 2 -225 191 0 ; +C 205 ; WX 273 ; N hungarumlaut ; B 129 593 463 734 ; +C 206 ; WX 273 ; N ogonek ; B 35 -225 204 0 ; +C 207 ; WX 273 ; N caron ; B 145 593 384 734 ; +C 208 ; WX 820 ; N emdash ; B 42 240 875 313 ; +C 225 ; WX 820 ; N AE ; B 7 0 899 718 ; +C 227 ; WX 303 ; N ordfeminine ; B 82 304 368 737 ; +C 232 ; WX 456 ; N Lslash ; B 34 0 455 718 ; +C 233 ; WX 638 ; N Oslash ; B 35 -19 730 737 ; +C 234 ; WX 820 ; N OE ; B 80 -19 915 737 ; +C 235 ; WX 299 ; N ordmasculine ; B 82 304 384 737 ; +C 241 ; WX 729 ; N ae ; B 50 -15 746 538 ; +C 245 ; WX 228 ; N dotlessi ; B 78 0 241 523 ; +C 248 ; WX 182 ; N lslash ; B 34 0 284 718 ; +C 249 ; WX 501 ; N oslash ; B 24 -22 531 545 ; +C 250 ; WX 774 ; N oe ; B 68 -15 791 538 ; +C 251 ; WX 501 ; N germandbls ; B 55 -15 539 728 ; +C -1 ; WX 501 ; N Zcaron ; B 19 0 607 929 ; +C -1 ; WX 410 ; N ccedilla ; B 61 -225 454 538 ; +C -1 ; WX 410 ; N ydieresis ; B 12 -214 492 706 ; +C -1 ; WX 456 ; N atilde ; B 50 -15 486 722 ; +C -1 ; WX 228 ; N icircumflex ; B 78 0 337 734 ; +C -1 ; WX 273 ; N threesuperior ; B 74 270 358 703 ; +C -1 ; WX 456 ; N ecircumflex ; B 69 -15 474 734 ; +C -1 ; WX 456 ; N thorn ; B 11 -207 479 718 ; +C -1 ; WX 456 ; N egrave ; B 69 -15 474 734 ; +C -1 ; WX 273 ; N twosuperior ; B 52 281 368 703 ; +C -1 ; WX 456 ; N eacute ; B 69 -15 481 734 ; +C -1 ; WX 456 ; N otilde ; B 68 -14 494 722 ; +C -1 ; WX 547 ; N Aacute ; B 11 0 560 929 ; +C -1 ; WX 456 ; N ocircumflex ; B 68 -14 479 734 ; +C -1 ; WX 410 ; N yacute ; B 12 -214 492 734 ; +C -1 ; WX 456 ; N udieresis ; B 77 -15 492 706 ; +C -1 ; WX 684 ; N threequarters ; B 106 -19 706 703 ; +C -1 ; WX 456 ; N acircumflex ; B 50 -15 458 734 ; +C -1 ; WX 592 ; N Eth ; B 57 0 626 718 ; +C -1 ; WX 456 ; N edieresis ; B 69 -15 474 706 ; +C -1 ; WX 456 ; N ugrave ; B 77 -15 492 734 ; +C -1 ; WX 820 ; N trademark ; B 152 306 866 718 ; +C -1 ; WX 456 ; N ograve ; B 68 -14 479 734 ; +C -1 ; WX 410 ; N scaron ; B 52 -15 453 734 ; +C -1 ; WX 228 ; N Idieresis ; B 75 0 375 901 ; +C -1 ; WX 456 ; N uacute ; B 77 -15 492 734 ; +C -1 ; WX 456 ; N agrave ; B 50 -15 458 734 ; +C -1 ; WX 456 ; N ntilde ; B 53 0 486 722 ; +C -1 ; WX 456 ; N aring ; B 50 -15 458 756 ; +C -1 ; WX 410 ; N zcaron ; B 25 0 468 734 ; +C -1 ; WX 228 ; N Icircumflex ; B 75 0 371 929 ; +C -1 ; WX 592 ; N Ntilde ; B 62 0 655 917 ; +C -1 ; WX 456 ; N ucircumflex ; B 77 -15 492 734 ; +C -1 ; WX 547 ; N Ecircumflex ; B 71 0 625 929 ; +C -1 ; WX 228 ; N Iacute ; B 75 0 401 929 ; +C -1 ; WX 592 ; N Ccedilla ; B 88 -225 640 737 ; +C -1 ; WX 638 ; N Odieresis ; B 86 -19 677 901 ; +C -1 ; WX 547 ; N Scaron ; B 74 -19 584 929 ; +C -1 ; WX 547 ; N Edieresis ; B 71 0 625 901 ; +C -1 ; WX 228 ; N Igrave ; B 75 0 288 929 ; +C -1 ; WX 456 ; N adieresis ; B 50 -15 458 706 ; +C -1 ; WX 638 ; N Ograve ; B 86 -19 677 929 ; +C -1 ; WX 547 ; N Egrave ; B 71 0 625 929 ; +C -1 ; WX 547 ; N Ydieresis ; B 137 0 661 901 ; +C -1 ; WX 604 ; N registered ; B 44 -19 687 737 ; +C -1 ; WX 638 ; N Otilde ; B 86 -19 677 917 ; +C -1 ; WX 684 ; N onequarter ; B 123 -19 658 703 ; +C -1 ; WX 592 ; N Ugrave ; B 101 -19 653 929 ; +C -1 ; WX 592 ; N Ucircumflex ; B 101 -19 653 929 ; +C -1 ; WX 547 ; N Thorn ; B 71 0 584 718 ; +C -1 ; WX 479 ; N divide ; B 70 -19 497 524 ; +C -1 ; WX 547 ; N Atilde ; B 11 0 573 917 ; +C -1 ; WX 592 ; N Uacute ; B 101 -19 653 929 ; +C -1 ; WX 638 ; N Ocircumflex ; B 86 -19 677 929 ; +C -1 ; WX 479 ; N logicalnot ; B 87 108 515 390 ; +C -1 ; WX 547 ; N Aring ; B 11 0 536 931 ; +C -1 ; WX 228 ; N idieresis ; B 78 0 341 706 ; +C -1 ; WX 228 ; N iacute ; B 78 0 367 734 ; +C -1 ; WX 456 ; N aacute ; B 50 -15 481 734 ; +C -1 ; WX 479 ; N plusminus ; B 32 0 507 506 ; +C -1 ; WX 479 ; N multiply ; B 41 0 526 506 ; +C -1 ; WX 592 ; N Udieresis ; B 101 -19 653 901 ; +C -1 ; WX 479 ; N minus ; B 70 216 497 289 ; +C -1 ; WX 273 ; N onesuperior ; B 136 281 305 703 ; +C -1 ; WX 547 ; N Eacute ; B 71 0 625 929 ; +C -1 ; WX 547 ; N Acircumflex ; B 11 0 536 929 ; +C -1 ; WX 604 ; N copyright ; B 44 -19 687 737 ; +C -1 ; WX 547 ; N Agrave ; B 11 0 536 929 ; +C -1 ; WX 456 ; N odieresis ; B 68 -14 479 706 ; +C -1 ; WX 456 ; N oacute ; B 68 -14 481 734 ; +C -1 ; WX 328 ; N degree ; B 138 411 384 703 ; +C -1 ; WX 228 ; N igrave ; B 78 0 254 734 ; +C -1 ; WX 456 ; N mu ; B 20 -207 492 523 ; +C -1 ; WX 638 ; N Oacute ; B 86 -19 677 929 ; +C -1 ; WX 456 ; N eth ; B 67 -15 506 737 ; +C -1 ; WX 547 ; N Adieresis ; B 11 0 536 901 ; +C -1 ; WX 547 ; N Yacute ; B 137 0 661 929 ; +C -1 ; WX 213 ; N brokenbar ; B 74 -19 265 737 ; +C -1 ; WX 684 ; N onehalf ; B 93 -19 688 703 ; +EndCharMetrics +StartKernData +StartKernPairs 250 + +KPX A y -40 +KPX A w -40 +KPX A v -40 +KPX A u -30 +KPX A Y -100 +KPX A W -50 +KPX A V -70 +KPX A U -50 +KPX A T -120 +KPX A Q -30 +KPX A O -30 +KPX A G -30 +KPX A C -30 + +KPX B period -20 +KPX B comma -20 +KPX B U -10 + +KPX C period -30 +KPX C comma -30 + +KPX D period -70 +KPX D comma -70 +KPX D Y -90 +KPX D W -40 +KPX D V -70 +KPX D A -40 + +KPX F r -45 +KPX F period -150 +KPX F o -30 +KPX F e -30 +KPX F comma -150 +KPX F a -50 +KPX F A -80 + +KPX J u -20 +KPX J period -30 +KPX J comma -30 +KPX J a -20 +KPX J A -20 + +KPX K y -50 +KPX K u -30 +KPX K o -40 +KPX K e -40 +KPX K O -50 + +KPX L y -30 +KPX L quoteright -160 +KPX L quotedblright -140 +KPX L Y -140 +KPX L W -70 +KPX L V -110 +KPX L T -110 + +KPX O period -40 +KPX O comma -40 +KPX O Y -70 +KPX O X -60 +KPX O W -30 +KPX O V -50 +KPX O T -40 +KPX O A -20 + +KPX P period -180 +KPX P o -50 +KPX P e -50 +KPX P comma -180 +KPX P a -40 +KPX P A -120 + +KPX Q U -10 + +KPX R Y -50 +KPX R W -30 +KPX R V -50 +KPX R U -40 +KPX R T -30 +KPX R O -20 + +KPX S period -20 +KPX S comma -20 + +KPX T y -120 +KPX T w -120 +KPX T u -120 +KPX T semicolon -20 +KPX T r -120 +KPX T period -120 +KPX T o -120 +KPX T hyphen -140 +KPX T e -120 +KPX T comma -120 +KPX T colon -20 +KPX T a -120 +KPX T O -40 +KPX T A -120 + +KPX U period -40 +KPX U comma -40 +KPX U A -40 + +KPX V u -70 +KPX V semicolon -40 +KPX V period -125 +KPX V o -80 +KPX V hyphen -80 +KPX V e -80 +KPX V comma -125 +KPX V colon -40 +KPX V a -70 +KPX V O -40 +KPX V G -40 +KPX V A -80 + +KPX W y -20 +KPX W u -30 +KPX W period -80 +KPX W o -30 +KPX W hyphen -40 +KPX W e -30 +KPX W comma -80 +KPX W a -40 +KPX W O -20 +KPX W A -50 + +KPX Y u -110 +KPX Y semicolon -60 +KPX Y period -140 +KPX Y o -140 +KPX Y i -20 +KPX Y hyphen -140 +KPX Y e -140 +KPX Y comma -140 +KPX Y colon -60 +KPX Y a -140 +KPX Y O -85 +KPX Y A -110 + +KPX a y -30 +KPX a w -20 +KPX a v -20 + +KPX b y -20 +KPX b v -20 +KPX b u -20 +KPX b period -40 +KPX b l -20 +KPX b comma -40 +KPX b b -10 + +KPX c k -20 +KPX c comma -15 + +KPX colon space -50 + +KPX comma quoteright -100 +KPX comma quotedblright -100 + +KPX e y -20 +KPX e x -30 +KPX e w -20 +KPX e v -30 +KPX e period -15 +KPX e comma -15 + +KPX f quoteright 50 +KPX f quotedblright 60 +KPX f period -30 +KPX f o -30 +KPX f e -30 +KPX f dotlessi -28 +KPX f comma -30 +KPX f a -30 + +KPX g r -10 + +KPX h y -30 + +KPX k o -20 +KPX k e -20 + +KPX m y -15 +KPX m u -10 + +KPX n y -15 +KPX n v -20 +KPX n u -10 + +KPX o y -30 +KPX o x -30 +KPX o w -15 +KPX o v -15 +KPX o period -40 +KPX o comma -40 + +KPX oslash z -55 +KPX oslash y -70 +KPX oslash x -85 +KPX oslash w -70 +KPX oslash v -70 +KPX oslash u -55 +KPX oslash t -55 +KPX oslash s -55 +KPX oslash r -55 +KPX oslash q -55 +KPX oslash period -95 +KPX oslash p -55 +KPX oslash o -55 +KPX oslash n -55 +KPX oslash m -55 +KPX oslash l -55 +KPX oslash k -55 +KPX oslash j -55 +KPX oslash i -55 +KPX oslash h -55 +KPX oslash g -55 +KPX oslash f -55 +KPX oslash e -55 +KPX oslash d -55 +KPX oslash comma -95 +KPX oslash c -55 +KPX oslash b -55 +KPX oslash a -55 + +KPX p y -30 +KPX p period -35 +KPX p comma -35 + +KPX period space -60 +KPX period quoteright -100 +KPX period quotedblright -100 + +KPX quotedblright space -40 + +KPX quoteleft quoteleft -57 + +KPX quoteright space -70 +KPX quoteright s -50 +KPX quoteright r -50 +KPX quoteright quoteright -57 +KPX quoteright d -50 + +KPX r y 30 +KPX r v 30 +KPX r u 15 +KPX r t 40 +KPX r semicolon 30 +KPX r period -50 +KPX r p 30 +KPX r n 25 +KPX r m 25 +KPX r l 15 +KPX r k 15 +KPX r i 15 +KPX r comma -50 +KPX r colon 30 +KPX r a -10 + +KPX s w -30 +KPX s period -15 +KPX s comma -15 + +KPX semicolon space -50 + +KPX space quoteleft -60 +KPX space quotedblleft -30 +KPX space Y -90 +KPX space W -40 +KPX space V -50 +KPX space T -50 + +KPX v period -80 +KPX v o -25 +KPX v e -25 +KPX v comma -80 +KPX v a -25 + +KPX w period -60 +KPX w o -10 +KPX w e -10 +KPX w comma -60 +KPX w a -15 + +KPX x e -30 + +KPX y period -100 +KPX y o -20 +KPX y e -20 +KPX y comma -100 +KPX y a -20 + +KPX z o -15 +KPX z e -15 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 171 195 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 171 195 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 171 195 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 171 195 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 167 175 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 171 195 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 160 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 171 195 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 171 195 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 171 195 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 171 195 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 12 195 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 12 195 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 12 195 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 12 195 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 202 195 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 217 195 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 217 195 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 217 195 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 217 195 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 217 195 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 171 195 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 194 195 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 194 195 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 194 195 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 194 195 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 171 195 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 171 195 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 148 195 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 92 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 92 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 92 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 92 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 92 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 84 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 69 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 92 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 92 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 92 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 92 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -22 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -22 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -22 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -22 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 84 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 92 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 92 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 92 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 92 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 92 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 69 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 92 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 92 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 92 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 92 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 69 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 69 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 69 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncb8a.afm new file mode 100644 index 00000000..ba1fed6d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncb8a.afm @@ -0,0 +1,472 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1988, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue May 28 16:48:12 1991 +Comment UniqueID 35031 +Comment VMusage 30773 37665 +FontName NewCenturySchlbk-Bold +FullName New Century Schoolbook Bold +FamilyName New Century Schoolbook +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -165 -250 1000 988 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.009 +Notice Copyright (c) 1985, 1987, 1988, 1991 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 722 +XHeight 475 +Ascender 737 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 287 ; N space ; B 0 0 0 0 ; +C 33 ; WX 296 ; N exclam ; B 53 -15 243 737 ; +C 34 ; WX 333 ; N quotedbl ; B 0 378 333 737 ; +C 35 ; WX 574 ; N numbersign ; B 36 0 538 690 ; +C 36 ; WX 574 ; N dollar ; B 25 -141 549 810 ; +C 37 ; WX 833 ; N percent ; B 14 -15 819 705 ; +C 38 ; WX 852 ; N ampersand ; B 34 -15 818 737 ; +C 39 ; WX 241 ; N quoteright ; B 22 378 220 737 ; +C 40 ; WX 389 ; N parenleft ; B 77 -117 345 745 ; +C 41 ; WX 389 ; N parenright ; B 44 -117 312 745 ; +C 42 ; WX 500 ; N asterisk ; B 54 302 446 737 ; +C 43 ; WX 606 ; N plus ; B 50 0 556 506 ; +C 44 ; WX 278 ; N comma ; B 40 -184 238 175 ; +C 45 ; WX 333 ; N hyphen ; B 42 174 291 302 ; +C 46 ; WX 278 ; N period ; B 44 -15 234 175 ; +C 47 ; WX 278 ; N slash ; B -42 -15 320 737 ; +C 48 ; WX 574 ; N zero ; B 27 -15 547 705 ; +C 49 ; WX 574 ; N one ; B 83 0 491 705 ; +C 50 ; WX 574 ; N two ; B 19 0 531 705 ; +C 51 ; WX 574 ; N three ; B 23 -15 531 705 ; +C 52 ; WX 574 ; N four ; B 19 0 547 705 ; +C 53 ; WX 574 ; N five ; B 32 -15 534 705 ; +C 54 ; WX 574 ; N six ; B 27 -15 547 705 ; +C 55 ; WX 574 ; N seven ; B 45 -15 547 705 ; +C 56 ; WX 574 ; N eight ; B 27 -15 548 705 ; +C 57 ; WX 574 ; N nine ; B 27 -15 547 705 ; +C 58 ; WX 278 ; N colon ; B 44 -15 234 485 ; +C 59 ; WX 278 ; N semicolon ; B 40 -184 238 485 ; +C 60 ; WX 606 ; N less ; B 50 -9 556 515 ; +C 61 ; WX 606 ; N equal ; B 50 103 556 403 ; +C 62 ; WX 606 ; N greater ; B 50 -9 556 515 ; +C 63 ; WX 500 ; N question ; B 23 -15 477 737 ; +C 64 ; WX 747 ; N at ; B -2 -15 750 737 ; +C 65 ; WX 759 ; N A ; B -19 0 778 737 ; +C 66 ; WX 778 ; N B ; B 19 0 739 722 ; +C 67 ; WX 778 ; N C ; B 39 -15 723 737 ; +C 68 ; WX 833 ; N D ; B 19 0 794 722 ; +C 69 ; WX 759 ; N E ; B 19 0 708 722 ; +C 70 ; WX 722 ; N F ; B 19 0 697 722 ; +C 71 ; WX 833 ; N G ; B 39 -15 818 737 ; +C 72 ; WX 870 ; N H ; B 19 0 851 722 ; +C 73 ; WX 444 ; N I ; B 29 0 415 722 ; +C 74 ; WX 648 ; N J ; B 6 -15 642 722 ; +C 75 ; WX 815 ; N K ; B 19 0 822 722 ; +C 76 ; WX 722 ; N L ; B 19 0 703 722 ; +C 77 ; WX 981 ; N M ; B 10 0 971 722 ; +C 78 ; WX 833 ; N N ; B 5 -10 828 722 ; +C 79 ; WX 833 ; N O ; B 39 -15 794 737 ; +C 80 ; WX 759 ; N P ; B 24 0 735 722 ; +C 81 ; WX 833 ; N Q ; B 39 -189 808 737 ; +C 82 ; WX 815 ; N R ; B 19 -15 815 722 ; +C 83 ; WX 667 ; N S ; B 51 -15 634 737 ; +C 84 ; WX 722 ; N T ; B 16 0 706 722 ; +C 85 ; WX 833 ; N U ; B 14 -15 825 722 ; +C 86 ; WX 759 ; N V ; B -19 -10 778 722 ; +C 87 ; WX 981 ; N W ; B 7 -10 974 722 ; +C 88 ; WX 722 ; N X ; B -12 0 734 722 ; +C 89 ; WX 722 ; N Y ; B -12 0 734 722 ; +C 90 ; WX 667 ; N Z ; B 28 0 639 722 ; +C 91 ; WX 389 ; N bracketleft ; B 84 -109 339 737 ; +C 92 ; WX 606 ; N backslash ; B 122 -15 484 737 ; +C 93 ; WX 389 ; N bracketright ; B 50 -109 305 737 ; +C 94 ; WX 606 ; N asciicircum ; B 66 325 540 690 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 241 ; N quoteleft ; B 22 378 220 737 ; +C 97 ; WX 611 ; N a ; B 40 -15 601 485 ; +C 98 ; WX 648 ; N b ; B 4 -15 616 737 ; +C 99 ; WX 556 ; N c ; B 32 -15 524 485 ; +C 100 ; WX 667 ; N d ; B 32 -15 644 737 ; +C 101 ; WX 574 ; N e ; B 32 -15 542 485 ; +C 102 ; WX 389 ; N f ; B 11 0 461 737 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 30 -205 623 535 ; +C 104 ; WX 685 ; N h ; B 17 0 662 737 ; +C 105 ; WX 370 ; N i ; B 26 0 338 737 ; +C 106 ; WX 352 ; N j ; B -86 -205 271 737 ; +C 107 ; WX 667 ; N k ; B 17 0 662 737 ; +C 108 ; WX 352 ; N l ; B 17 0 329 737 ; +C 109 ; WX 963 ; N m ; B 17 0 940 485 ; +C 110 ; WX 685 ; N n ; B 17 0 662 485 ; +C 111 ; WX 611 ; N o ; B 32 -15 579 485 ; +C 112 ; WX 667 ; N p ; B 17 -205 629 485 ; +C 113 ; WX 648 ; N q ; B 32 -205 638 485 ; +C 114 ; WX 519 ; N r ; B 17 0 516 485 ; +C 115 ; WX 500 ; N s ; B 48 -15 476 485 ; +C 116 ; WX 426 ; N t ; B 21 -15 405 675 ; +C 117 ; WX 685 ; N u ; B 17 -15 668 475 ; +C 118 ; WX 611 ; N v ; B 12 -10 599 475 ; +C 119 ; WX 889 ; N w ; B 16 -10 873 475 ; +C 120 ; WX 611 ; N x ; B 12 0 599 475 ; +C 121 ; WX 611 ; N y ; B 12 -205 599 475 ; +C 122 ; WX 537 ; N z ; B 38 0 499 475 ; +C 123 ; WX 389 ; N braceleft ; B 36 -109 313 737 ; +C 124 ; WX 606 ; N bar ; B 249 -250 357 750 ; +C 125 ; WX 389 ; N braceright ; B 76 -109 353 737 ; +C 126 ; WX 606 ; N asciitilde ; B 72 160 534 346 ; +C 161 ; WX 296 ; N exclamdown ; B 53 -205 243 547 ; +C 162 ; WX 574 ; N cent ; B 32 -102 528 572 ; +C 163 ; WX 574 ; N sterling ; B 16 -15 558 705 ; +C 164 ; WX 167 ; N fraction ; B -165 -15 332 705 ; +C 165 ; WX 574 ; N yen ; B -10 0 584 690 ; +C 166 ; WX 574 ; N florin ; B 14 -205 548 737 ; +C 167 ; WX 500 ; N section ; B 62 -86 438 737 ; +C 168 ; WX 574 ; N currency ; B 27 84 547 605 ; +C 169 ; WX 241 ; N quotesingle ; B 53 378 189 737 ; +C 170 ; WX 481 ; N quotedblleft ; B 22 378 459 737 ; +C 171 ; WX 500 ; N guillemotleft ; B 46 79 454 397 ; +C 172 ; WX 333 ; N guilsinglleft ; B 62 79 271 397 ; +C 173 ; WX 333 ; N guilsinglright ; B 62 79 271 397 ; +C 174 ; WX 685 ; N fi ; B 11 0 666 737 ; +C 175 ; WX 685 ; N fl ; B 11 0 666 737 ; +C 177 ; WX 500 ; N endash ; B 0 184 500 292 ; +C 178 ; WX 500 ; N dagger ; B 39 -101 461 737 ; +C 179 ; WX 500 ; N daggerdbl ; B 39 -89 461 737 ; +C 180 ; WX 278 ; N periodcentered ; B 53 200 225 372 ; +C 182 ; WX 747 ; N paragraph ; B 96 -71 631 722 ; +C 183 ; WX 606 ; N bullet ; B 122 180 484 542 ; +C 184 ; WX 241 ; N quotesinglbase ; B 22 -184 220 175 ; +C 185 ; WX 481 ; N quotedblbase ; B 22 -184 459 175 ; +C 186 ; WX 481 ; N quotedblright ; B 22 378 459 737 ; +C 187 ; WX 500 ; N guillemotright ; B 46 79 454 397 ; +C 188 ; WX 1000 ; N ellipsis ; B 72 -15 928 175 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -15 993 705 ; +C 191 ; WX 500 ; N questiondown ; B 23 -205 477 547 ; +C 193 ; WX 333 ; N grave ; B 2 547 249 737 ; +C 194 ; WX 333 ; N acute ; B 84 547 331 737 ; +C 195 ; WX 333 ; N circumflex ; B -10 547 344 725 ; +C 196 ; WX 333 ; N tilde ; B -24 563 357 705 ; +C 197 ; WX 333 ; N macron ; B -6 582 339 664 ; +C 198 ; WX 333 ; N breve ; B 9 547 324 714 ; +C 199 ; WX 333 ; N dotaccent ; B 95 552 237 694 ; +C 200 ; WX 333 ; N dieresis ; B -12 552 345 694 ; +C 202 ; WX 333 ; N ring ; B 58 545 274 761 ; +C 203 ; WX 333 ; N cedilla ; B 17 -224 248 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -16 547 431 737 ; +C 206 ; WX 333 ; N ogonek ; B 168 -163 346 3 ; +C 207 ; WX 333 ; N caron ; B -10 547 344 725 ; +C 208 ; WX 1000 ; N emdash ; B 0 184 1000 292 ; +C 225 ; WX 981 ; N AE ; B -29 0 963 722 ; +C 227 ; WX 367 ; N ordfeminine ; B 1 407 393 705 ; +C 232 ; WX 722 ; N Lslash ; B 19 0 703 722 ; +C 233 ; WX 833 ; N Oslash ; B 39 -53 794 775 ; +C 234 ; WX 1000 ; N OE ; B 0 0 982 722 ; +C 235 ; WX 367 ; N ordmasculine ; B 1 407 366 705 ; +C 241 ; WX 870 ; N ae ; B 32 -15 838 485 ; +C 245 ; WX 370 ; N dotlessi ; B 26 0 338 475 ; +C 248 ; WX 352 ; N lslash ; B 17 0 329 737 ; +C 249 ; WX 611 ; N oslash ; B 32 -103 579 573 ; +C 250 ; WX 907 ; N oe ; B 32 -15 875 485 ; +C 251 ; WX 611 ; N germandbls ; B -2 -15 580 737 ; +C -1 ; WX 574 ; N ecircumflex ; B 32 -15 542 725 ; +C -1 ; WX 574 ; N edieresis ; B 32 -15 542 694 ; +C -1 ; WX 611 ; N aacute ; B 40 -15 601 737 ; +C -1 ; WX 747 ; N registered ; B -2 -15 750 737 ; +C -1 ; WX 370 ; N icircumflex ; B 9 0 363 725 ; +C -1 ; WX 685 ; N udieresis ; B 17 -15 668 694 ; +C -1 ; WX 611 ; N ograve ; B 32 -15 579 737 ; +C -1 ; WX 685 ; N uacute ; B 17 -15 668 737 ; +C -1 ; WX 685 ; N ucircumflex ; B 17 -15 668 725 ; +C -1 ; WX 759 ; N Aacute ; B -19 0 778 964 ; +C -1 ; WX 370 ; N igrave ; B 21 0 338 737 ; +C -1 ; WX 444 ; N Icircumflex ; B 29 0 415 952 ; +C -1 ; WX 556 ; N ccedilla ; B 32 -224 524 485 ; +C -1 ; WX 611 ; N adieresis ; B 40 -15 601 694 ; +C -1 ; WX 759 ; N Ecircumflex ; B 19 0 708 952 ; +C -1 ; WX 500 ; N scaron ; B 48 -15 476 725 ; +C -1 ; WX 667 ; N thorn ; B 17 -205 629 737 ; +C -1 ; WX 1000 ; N trademark ; B 6 317 982 722 ; +C -1 ; WX 574 ; N egrave ; B 32 -15 542 737 ; +C -1 ; WX 344 ; N threesuperior ; B -3 273 355 705 ; +C -1 ; WX 537 ; N zcaron ; B 38 0 499 725 ; +C -1 ; WX 611 ; N atilde ; B 40 -15 601 705 ; +C -1 ; WX 611 ; N aring ; B 40 -15 601 761 ; +C -1 ; WX 611 ; N ocircumflex ; B 32 -15 579 725 ; +C -1 ; WX 759 ; N Edieresis ; B 19 0 708 921 ; +C -1 ; WX 861 ; N threequarters ; B 15 -15 838 705 ; +C -1 ; WX 611 ; N ydieresis ; B 12 -205 599 694 ; +C -1 ; WX 611 ; N yacute ; B 12 -205 599 737 ; +C -1 ; WX 370 ; N iacute ; B 26 0 350 737 ; +C -1 ; WX 759 ; N Acircumflex ; B -19 0 778 952 ; +C -1 ; WX 833 ; N Uacute ; B 14 -15 825 964 ; +C -1 ; WX 574 ; N eacute ; B 32 -15 542 737 ; +C -1 ; WX 833 ; N Ograve ; B 39 -15 794 964 ; +C -1 ; WX 611 ; N agrave ; B 40 -15 601 737 ; +C -1 ; WX 833 ; N Udieresis ; B 14 -15 825 921 ; +C -1 ; WX 611 ; N acircumflex ; B 40 -15 601 725 ; +C -1 ; WX 444 ; N Igrave ; B 29 0 415 964 ; +C -1 ; WX 344 ; N twosuperior ; B -3 282 350 705 ; +C -1 ; WX 833 ; N Ugrave ; B 14 -15 825 964 ; +C -1 ; WX 861 ; N onequarter ; B 31 -15 838 705 ; +C -1 ; WX 833 ; N Ucircumflex ; B 14 -15 825 952 ; +C -1 ; WX 667 ; N Scaron ; B 51 -15 634 952 ; +C -1 ; WX 444 ; N Idieresis ; B 29 0 415 921 ; +C -1 ; WX 370 ; N idieresis ; B 7 0 364 694 ; +C -1 ; WX 759 ; N Egrave ; B 19 0 708 964 ; +C -1 ; WX 833 ; N Oacute ; B 39 -15 794 964 ; +C -1 ; WX 606 ; N divide ; B 50 -40 556 546 ; +C -1 ; WX 759 ; N Atilde ; B -19 0 778 932 ; +C -1 ; WX 759 ; N Aring ; B -19 0 778 988 ; +C -1 ; WX 833 ; N Odieresis ; B 39 -15 794 921 ; +C -1 ; WX 759 ; N Adieresis ; B -19 0 778 921 ; +C -1 ; WX 833 ; N Ntilde ; B 5 -10 828 932 ; +C -1 ; WX 667 ; N Zcaron ; B 28 0 639 952 ; +C -1 ; WX 759 ; N Thorn ; B 24 0 735 722 ; +C -1 ; WX 444 ; N Iacute ; B 29 0 415 964 ; +C -1 ; WX 606 ; N plusminus ; B 50 0 556 506 ; +C -1 ; WX 606 ; N multiply ; B 65 15 541 491 ; +C -1 ; WX 759 ; N Eacute ; B 19 0 708 964 ; +C -1 ; WX 722 ; N Ydieresis ; B -12 0 734 921 ; +C -1 ; WX 344 ; N onesuperior ; B 31 282 309 705 ; +C -1 ; WX 685 ; N ugrave ; B 17 -15 668 737 ; +C -1 ; WX 606 ; N logicalnot ; B 50 103 556 403 ; +C -1 ; WX 685 ; N ntilde ; B 17 0 662 705 ; +C -1 ; WX 833 ; N Otilde ; B 39 -15 794 932 ; +C -1 ; WX 611 ; N otilde ; B 32 -15 579 705 ; +C -1 ; WX 778 ; N Ccedilla ; B 39 -224 723 737 ; +C -1 ; WX 759 ; N Agrave ; B -19 0 778 964 ; +C -1 ; WX 861 ; N onehalf ; B 31 -15 838 705 ; +C -1 ; WX 833 ; N Eth ; B 19 0 794 722 ; +C -1 ; WX 400 ; N degree ; B 57 419 343 705 ; +C -1 ; WX 722 ; N Yacute ; B -12 0 734 964 ; +C -1 ; WX 833 ; N Ocircumflex ; B 39 -15 794 952 ; +C -1 ; WX 611 ; N oacute ; B 32 -15 579 737 ; +C -1 ; WX 685 ; N mu ; B 17 -205 668 475 ; +C -1 ; WX 606 ; N minus ; B 50 199 556 307 ; +C -1 ; WX 611 ; N eth ; B 32 -15 579 737 ; +C -1 ; WX 611 ; N odieresis ; B 32 -15 579 694 ; +C -1 ; WX 747 ; N copyright ; B -2 -15 750 737 ; +C -1 ; WX 606 ; N brokenbar ; B 249 -175 357 675 ; +EndCharMetrics +StartKernData +StartKernPairs 128 + +KPX A y -18 +KPX A w -18 +KPX A v -18 +KPX A quoteright -74 +KPX A quotedblright -74 +KPX A Y -91 +KPX A W -74 +KPX A V -74 +KPX A U -18 +KPX A T -55 + +KPX C period -18 +KPX C comma -18 + +KPX D period -25 +KPX D comma -25 + +KPX F r -18 +KPX F period -125 +KPX F o -55 +KPX F i -18 +KPX F e -55 +KPX F comma -125 +KPX F a -74 + +KPX J u -18 +KPX J period -55 +KPX J o -18 +KPX J e -18 +KPX J comma -55 +KPX J a -18 +KPX J A -18 + +KPX K y -25 +KPX K u -18 + +KPX L y -25 +KPX L quoteright -100 +KPX L quotedblright -100 +KPX L Y -74 +KPX L W -74 +KPX L V -100 +KPX L T -100 + +KPX N period -18 +KPX N comma -18 + +KPX O period -25 +KPX O comma -25 +KPX O T 10 + +KPX P period -150 +KPX P o -55 +KPX P e -55 +KPX P comma -150 +KPX P a -55 +KPX P A -74 + +KPX S period -18 +KPX S comma -18 + +KPX T u -18 +KPX T r -18 +KPX T period -100 +KPX T o -74 +KPX T i -18 +KPX T hyphen -125 +KPX T e -74 +KPX T comma -100 +KPX T a -74 +KPX T O 10 +KPX T A -55 + +KPX U period -25 +KPX U comma -25 +KPX U A -18 + +KPX V u -55 +KPX V semicolon -37 +KPX V period -125 +KPX V o -74 +KPX V i -18 +KPX V hyphen -100 +KPX V e -74 +KPX V comma -125 +KPX V colon -37 +KPX V a -74 +KPX V A -74 + +KPX W y -25 +KPX W u -37 +KPX W semicolon -55 +KPX W period -100 +KPX W o -74 +KPX W i -18 +KPX W hyphen -100 +KPX W e -74 +KPX W comma -100 +KPX W colon -55 +KPX W a -74 +KPX W A -74 + +KPX Y u -55 +KPX Y semicolon -25 +KPX Y period -100 +KPX Y o -100 +KPX Y i -18 +KPX Y hyphen -125 +KPX Y e -100 +KPX Y comma -100 +KPX Y colon -25 +KPX Y a -100 +KPX Y A -91 + +KPX colon space -18 + +KPX comma space -18 +KPX comma quoteright -18 +KPX comma quotedblright -18 + +KPX f quoteright 75 +KPX f quotedblright 75 + +KPX period space -18 +KPX period quoteright -18 +KPX period quotedblright -18 + +KPX quotedblleft A -74 + +KPX quotedblright space -18 + +KPX quoteleft A -74 + +KPX quoteright s -25 +KPX quoteright d -25 + +KPX r period -74 +KPX r comma -74 + +KPX semicolon space -18 + +KPX space quoteleft -18 +KPX space quotedblleft -18 +KPX space Y -18 +KPX space W -18 +KPX space V -18 +KPX space T -18 +KPX space A -18 + +KPX v period -100 +KPX v comma -100 + +KPX w period -100 +KPX w comma -100 + +KPX y period -100 +KPX y comma -100 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 213 227 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 213 227 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 213 227 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 213 227 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 213 227 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 213 227 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 213 227 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 213 227 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 213 227 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 213 227 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 56 227 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 56 227 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 56 227 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 56 227 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 250 227 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 250 227 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 250 227 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 250 227 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 250 227 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 250 227 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 167 227 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 250 227 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 250 227 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 250 227 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 250 227 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 195 227 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 195 227 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 167 227 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 139 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 139 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 139 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 139 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 139 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 139 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 121 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 121 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 121 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 121 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 19 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex 19 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis 19 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 19 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 176 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 139 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 139 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 139 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 139 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 139 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 84 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 176 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 176 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 176 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 176 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 139 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 139 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 102 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncbi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncbi8a.afm new file mode 100644 index 00000000..7871147e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncbi8a.afm @@ -0,0 +1,602 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue May 28 16:56:07 1991 +Comment UniqueID 35034 +Comment VMusage 31030 37922 +FontName NewCenturySchlbk-BoldItalic +FullName New Century Schoolbook Bold Italic +FamilyName New Century Schoolbook +Weight Bold +ItalicAngle -16 +IsFixedPitch false +FontBBox -205 -250 1147 991 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 722 +XHeight 477 +Ascender 737 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 287 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 0 -15 333 737 ; +C 34 ; WX 400 ; N quotedbl ; B 66 388 428 737 ; +C 35 ; WX 574 ; N numbersign ; B 30 0 544 690 ; +C 36 ; WX 574 ; N dollar ; B 9 -120 565 810 ; +C 37 ; WX 889 ; N percent ; B 54 -28 835 727 ; +C 38 ; WX 889 ; N ampersand ; B 32 -15 823 737 ; +C 39 ; WX 259 ; N quoteright ; B 48 388 275 737 ; +C 40 ; WX 407 ; N parenleft ; B 72 -117 454 745 ; +C 41 ; WX 407 ; N parenright ; B -70 -117 310 745 ; +C 42 ; WX 500 ; N asterisk ; B 58 301 498 737 ; +C 43 ; WX 606 ; N plus ; B 50 0 556 506 ; +C 44 ; WX 287 ; N comma ; B -57 -192 170 157 ; +C 45 ; WX 333 ; N hyphen ; B 2 177 263 299 ; +C 46 ; WX 287 ; N period ; B -20 -15 152 157 ; +C 47 ; WX 278 ; N slash ; B -41 -15 320 737 ; +C 48 ; WX 574 ; N zero ; B 21 -15 553 705 ; +C 49 ; WX 574 ; N one ; B 25 0 489 705 ; +C 50 ; WX 574 ; N two ; B -38 -3 538 705 ; +C 51 ; WX 574 ; N three ; B -7 -15 536 705 ; +C 52 ; WX 574 ; N four ; B -13 0 544 705 ; +C 53 ; WX 574 ; N five ; B 0 -15 574 705 ; +C 54 ; WX 574 ; N six ; B 31 -15 574 705 ; +C 55 ; WX 574 ; N seven ; B 64 -15 593 705 ; +C 56 ; WX 574 ; N eight ; B 0 -15 552 705 ; +C 57 ; WX 574 ; N nine ; B 0 -15 543 705 ; +C 58 ; WX 287 ; N colon ; B -20 -15 237 477 ; +C 59 ; WX 287 ; N semicolon ; B -57 -192 237 477 ; +C 60 ; WX 606 ; N less ; B 50 -9 556 515 ; +C 61 ; WX 606 ; N equal ; B 50 103 556 403 ; +C 62 ; WX 606 ; N greater ; B 50 -8 556 514 ; +C 63 ; WX 481 ; N question ; B 79 -15 451 737 ; +C 64 ; WX 747 ; N at ; B -4 -15 751 737 ; +C 65 ; WX 741 ; N A ; B -75 0 716 737 ; +C 66 ; WX 759 ; N B ; B -50 0 721 722 ; +C 67 ; WX 759 ; N C ; B 37 -15 759 737 ; +C 68 ; WX 833 ; N D ; B -47 0 796 722 ; +C 69 ; WX 741 ; N E ; B -41 0 730 722 ; +C 70 ; WX 704 ; N F ; B -41 0 730 722 ; +C 71 ; WX 815 ; N G ; B 37 -15 805 737 ; +C 72 ; WX 870 ; N H ; B -41 0 911 722 ; +C 73 ; WX 444 ; N I ; B -41 0 485 722 ; +C 74 ; WX 667 ; N J ; B -20 -15 708 722 ; +C 75 ; WX 778 ; N K ; B -41 0 832 722 ; +C 76 ; WX 704 ; N L ; B -41 0 670 722 ; +C 77 ; WX 944 ; N M ; B -44 0 988 722 ; +C 78 ; WX 852 ; N N ; B -61 -10 913 722 ; +C 79 ; WX 833 ; N O ; B 37 -15 796 737 ; +C 80 ; WX 741 ; N P ; B -41 0 730 722 ; +C 81 ; WX 833 ; N Q ; B 37 -189 796 737 ; +C 82 ; WX 796 ; N R ; B -41 -15 749 722 ; +C 83 ; WX 685 ; N S ; B 1 -15 666 737 ; +C 84 ; WX 722 ; N T ; B 41 0 759 722 ; +C 85 ; WX 833 ; N U ; B 88 -15 900 722 ; +C 86 ; WX 741 ; N V ; B 32 -10 802 722 ; +C 87 ; WX 944 ; N W ; B 40 -10 1000 722 ; +C 88 ; WX 741 ; N X ; B -82 0 801 722 ; +C 89 ; WX 704 ; N Y ; B 13 0 775 722 ; +C 90 ; WX 704 ; N Z ; B -33 0 711 722 ; +C 91 ; WX 407 ; N bracketleft ; B 1 -109 464 737 ; +C 92 ; WX 606 ; N backslash ; B 161 -15 445 737 ; +C 93 ; WX 407 ; N bracketright ; B -101 -109 362 737 ; +C 94 ; WX 606 ; N asciicircum ; B 66 325 540 690 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 259 ; N quoteleft ; B 47 388 274 737 ; +C 97 ; WX 667 ; N a ; B 6 -15 636 477 ; +C 98 ; WX 611 ; N b ; B 29 -15 557 737 ; +C 99 ; WX 537 ; N c ; B 0 -15 482 477 ; +C 100 ; WX 667 ; N d ; B 0 -15 660 737 ; +C 101 ; WX 519 ; N e ; B 0 -15 479 477 ; +C 102 ; WX 389 ; N f ; B -48 -205 550 737 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B -63 -205 604 528 ; +C 104 ; WX 685 ; N h ; B 0 -15 639 737 ; +C 105 ; WX 389 ; N i ; B 32 -15 345 737 ; +C 106 ; WX 370 ; N j ; B -205 -205 347 737 ; +C 107 ; WX 648 ; N k ; B -11 -15 578 737 ; +C 108 ; WX 389 ; N l ; B 32 -15 375 737 ; +C 109 ; WX 944 ; N m ; B 0 -15 909 477 ; +C 110 ; WX 685 ; N n ; B 0 -15 639 477 ; +C 111 ; WX 574 ; N o ; B 0 -15 530 477 ; +C 112 ; WX 648 ; N p ; B -119 -205 590 477 ; +C 113 ; WX 630 ; N q ; B 0 -205 587 477 ; +C 114 ; WX 519 ; N r ; B 0 0 527 486 ; +C 115 ; WX 481 ; N s ; B 0 -15 435 477 ; +C 116 ; WX 407 ; N t ; B 24 -15 403 650 ; +C 117 ; WX 685 ; N u ; B 30 -15 635 477 ; +C 118 ; WX 556 ; N v ; B 30 -15 496 477 ; +C 119 ; WX 833 ; N w ; B 30 -15 773 477 ; +C 120 ; WX 574 ; N x ; B -46 -15 574 477 ; +C 121 ; WX 519 ; N y ; B -66 -205 493 477 ; +C 122 ; WX 519 ; N z ; B -19 -15 473 477 ; +C 123 ; WX 407 ; N braceleft ; B 52 -109 408 737 ; +C 124 ; WX 606 ; N bar ; B 249 -250 357 750 ; +C 125 ; WX 407 ; N braceright ; B -25 -109 331 737 ; +C 126 ; WX 606 ; N asciitilde ; B 72 160 534 346 ; +C 161 ; WX 333 ; N exclamdown ; B -44 -205 289 547 ; +C 162 ; WX 574 ; N cent ; B 30 -144 512 578 ; +C 163 ; WX 574 ; N sterling ; B -18 -15 566 705 ; +C 164 ; WX 167 ; N fraction ; B -166 -15 333 705 ; +C 165 ; WX 574 ; N yen ; B 17 0 629 690 ; +C 166 ; WX 574 ; N florin ; B -43 -205 575 737 ; +C 167 ; WX 500 ; N section ; B -30 -146 515 737 ; +C 168 ; WX 574 ; N currency ; B 27 84 547 605 ; +C 169 ; WX 287 ; N quotesingle ; B 112 388 250 737 ; +C 170 ; WX 481 ; N quotedblleft ; B 54 388 521 737 ; +C 171 ; WX 481 ; N guillemotleft ; B -35 69 449 407 ; +C 172 ; WX 278 ; N guilsinglleft ; B -25 69 244 407 ; +C 173 ; WX 278 ; N guilsinglright ; B -26 69 243 407 ; +C 174 ; WX 685 ; N fi ; B -70 -205 641 737 ; +C 175 ; WX 685 ; N fl ; B -70 -205 671 737 ; +C 177 ; WX 500 ; N endash ; B -47 189 479 287 ; +C 178 ; WX 500 ; N dagger ; B 48 -146 508 737 ; +C 179 ; WX 500 ; N daggerdbl ; B -60 -150 508 737 ; +C 180 ; WX 287 ; N periodcentered ; B 57 200 229 372 ; +C 182 ; WX 650 ; N paragraph ; B 25 -131 681 722 ; +C 183 ; WX 606 ; N bullet ; B 122 180 484 542 ; +C 184 ; WX 259 ; N quotesinglbase ; B -57 -192 170 157 ; +C 185 ; WX 481 ; N quotedblbase ; B -57 -192 412 157 ; +C 186 ; WX 481 ; N quotedblright ; B 43 388 510 737 ; +C 187 ; WX 481 ; N guillemotright ; B -31 69 453 407 ; +C 188 ; WX 1000 ; N ellipsis ; B 81 -15 919 157 ; +C 189 ; WX 1167 ; N perthousand ; B 20 -28 1147 727 ; +C 191 ; WX 481 ; N questiondown ; B 0 -205 372 547 ; +C 193 ; WX 333 ; N grave ; B 74 538 294 722 ; +C 194 ; WX 333 ; N acute ; B 123 538 372 722 ; +C 195 ; WX 333 ; N circumflex ; B 23 533 365 705 ; +C 196 ; WX 333 ; N tilde ; B 28 561 398 690 ; +C 197 ; WX 333 ; N macron ; B 47 573 404 649 ; +C 198 ; WX 333 ; N breve ; B 67 535 390 698 ; +C 199 ; WX 333 ; N dotaccent ; B 145 546 289 690 ; +C 200 ; WX 333 ; N dieresis ; B 33 546 393 690 ; +C 202 ; WX 333 ; N ring ; B 111 522 335 746 ; +C 203 ; WX 333 ; N cedilla ; B -21 -220 225 3 ; +C 205 ; WX 333 ; N hungarumlaut ; B 15 538 480 722 ; +C 206 ; WX 333 ; N ogonek ; B 68 -155 246 -10 ; +C 207 ; WX 333 ; N caron ; B 60 531 403 705 ; +C 208 ; WX 1000 ; N emdash ; B -47 189 979 287 ; +C 225 ; WX 889 ; N AE ; B -86 0 915 722 ; +C 227 ; WX 412 ; N ordfeminine ; B 47 407 460 705 ; +C 232 ; WX 704 ; N Lslash ; B -41 0 670 722 ; +C 233 ; WX 833 ; N Oslash ; B 35 -68 798 790 ; +C 234 ; WX 963 ; N OE ; B 29 0 989 722 ; +C 235 ; WX 356 ; N ordmasculine ; B 42 407 394 705 ; +C 241 ; WX 815 ; N ae ; B -18 -15 775 477 ; +C 245 ; WX 389 ; N dotlessi ; B 32 -15 345 477 ; +C 248 ; WX 389 ; N lslash ; B 5 -15 390 737 ; +C 249 ; WX 574 ; N oslash ; B 0 -121 530 583 ; +C 250 ; WX 852 ; N oe ; B -6 -15 812 477 ; +C 251 ; WX 574 ; N germandbls ; B -91 -205 540 737 ; +C -1 ; WX 519 ; N ecircumflex ; B 0 -15 479 705 ; +C -1 ; WX 519 ; N edieresis ; B 0 -15 486 690 ; +C -1 ; WX 667 ; N aacute ; B 6 -15 636 722 ; +C -1 ; WX 747 ; N registered ; B -2 -15 750 737 ; +C -1 ; WX 389 ; N icircumflex ; B 21 -15 363 698 ; +C -1 ; WX 685 ; N udieresis ; B 30 -15 635 690 ; +C -1 ; WX 574 ; N ograve ; B 0 -15 530 722 ; +C -1 ; WX 685 ; N uacute ; B 30 -15 635 722 ; +C -1 ; WX 685 ; N ucircumflex ; B 30 -15 635 705 ; +C -1 ; WX 741 ; N Aacute ; B -75 0 716 947 ; +C -1 ; WX 389 ; N igrave ; B 32 -15 345 715 ; +C -1 ; WX 444 ; N Icircumflex ; B -41 0 485 930 ; +C -1 ; WX 537 ; N ccedilla ; B 0 -220 482 477 ; +C -1 ; WX 667 ; N adieresis ; B 6 -15 636 690 ; +C -1 ; WX 741 ; N Ecircumflex ; B -41 0 730 930 ; +C -1 ; WX 481 ; N scaron ; B 0 -15 477 705 ; +C -1 ; WX 648 ; N thorn ; B -119 -205 590 737 ; +C -1 ; WX 950 ; N trademark ; B 42 317 1017 722 ; +C -1 ; WX 519 ; N egrave ; B 0 -15 479 722 ; +C -1 ; WX 344 ; N threesuperior ; B 3 273 361 705 ; +C -1 ; WX 519 ; N zcaron ; B -19 -15 473 695 ; +C -1 ; WX 667 ; N atilde ; B 6 -15 636 690 ; +C -1 ; WX 667 ; N aring ; B 6 -15 636 746 ; +C -1 ; WX 574 ; N ocircumflex ; B 0 -15 530 705 ; +C -1 ; WX 741 ; N Edieresis ; B -41 0 730 915 ; +C -1 ; WX 861 ; N threequarters ; B 35 -15 789 705 ; +C -1 ; WX 519 ; N ydieresis ; B -66 -205 493 690 ; +C -1 ; WX 519 ; N yacute ; B -66 -205 493 722 ; +C -1 ; WX 389 ; N iacute ; B 32 -15 370 715 ; +C -1 ; WX 741 ; N Acircumflex ; B -75 0 716 930 ; +C -1 ; WX 833 ; N Uacute ; B 88 -15 900 947 ; +C -1 ; WX 519 ; N eacute ; B 0 -15 479 722 ; +C -1 ; WX 833 ; N Ograve ; B 37 -15 796 947 ; +C -1 ; WX 667 ; N agrave ; B 6 -15 636 722 ; +C -1 ; WX 833 ; N Udieresis ; B 88 -15 900 915 ; +C -1 ; WX 667 ; N acircumflex ; B 6 -15 636 705 ; +C -1 ; WX 444 ; N Igrave ; B -41 0 485 947 ; +C -1 ; WX 344 ; N twosuperior ; B -17 280 362 705 ; +C -1 ; WX 833 ; N Ugrave ; B 88 -15 900 947 ; +C -1 ; WX 861 ; N onequarter ; B 17 -15 789 705 ; +C -1 ; WX 833 ; N Ucircumflex ; B 88 -15 900 930 ; +C -1 ; WX 685 ; N Scaron ; B 1 -15 666 930 ; +C -1 ; WX 444 ; N Idieresis ; B -41 0 509 915 ; +C -1 ; WX 389 ; N idieresis ; B 31 -15 391 683 ; +C -1 ; WX 741 ; N Egrave ; B -41 0 730 947 ; +C -1 ; WX 833 ; N Oacute ; B 37 -15 796 947 ; +C -1 ; WX 606 ; N divide ; B 50 -40 556 546 ; +C -1 ; WX 741 ; N Atilde ; B -75 0 716 915 ; +C -1 ; WX 741 ; N Aring ; B -75 0 716 991 ; +C -1 ; WX 833 ; N Odieresis ; B 37 -15 796 915 ; +C -1 ; WX 741 ; N Adieresis ; B -75 0 716 915 ; +C -1 ; WX 852 ; N Ntilde ; B -61 -10 913 915 ; +C -1 ; WX 704 ; N Zcaron ; B -33 0 711 930 ; +C -1 ; WX 741 ; N Thorn ; B -41 0 690 722 ; +C -1 ; WX 444 ; N Iacute ; B -41 0 488 947 ; +C -1 ; WX 606 ; N plusminus ; B 50 0 556 506 ; +C -1 ; WX 606 ; N multiply ; B 65 15 541 491 ; +C -1 ; WX 741 ; N Eacute ; B -41 0 730 947 ; +C -1 ; WX 704 ; N Ydieresis ; B 13 0 775 915 ; +C -1 ; WX 344 ; N onesuperior ; B 19 282 326 705 ; +C -1 ; WX 685 ; N ugrave ; B 30 -15 635 722 ; +C -1 ; WX 606 ; N logicalnot ; B 50 103 556 403 ; +C -1 ; WX 685 ; N ntilde ; B 0 -15 639 690 ; +C -1 ; WX 833 ; N Otilde ; B 37 -15 796 915 ; +C -1 ; WX 574 ; N otilde ; B 0 -15 530 690 ; +C -1 ; WX 759 ; N Ccedilla ; B 37 -220 759 737 ; +C -1 ; WX 741 ; N Agrave ; B -75 0 716 947 ; +C -1 ; WX 861 ; N onehalf ; B 17 -15 798 705 ; +C -1 ; WX 833 ; N Eth ; B -47 0 796 722 ; +C -1 ; WX 400 ; N degree ; B 86 419 372 705 ; +C -1 ; WX 704 ; N Yacute ; B 13 0 775 947 ; +C -1 ; WX 833 ; N Ocircumflex ; B 37 -15 796 930 ; +C -1 ; WX 574 ; N oacute ; B 0 -15 530 722 ; +C -1 ; WX 685 ; N mu ; B -89 -205 635 477 ; +C -1 ; WX 606 ; N minus ; B 50 199 556 307 ; +C -1 ; WX 574 ; N eth ; B 0 -15 530 752 ; +C -1 ; WX 574 ; N odieresis ; B 0 -15 530 690 ; +C -1 ; WX 747 ; N copyright ; B -2 -15 750 737 ; +C -1 ; WX 606 ; N brokenbar ; B 249 -175 357 675 ; +EndCharMetrics +StartKernData +StartKernPairs 239 + +KPX A y -33 +KPX A w -25 +KPX A v -10 +KPX A u -15 +KPX A quoteright -95 +KPX A quotedblright -95 +KPX A Y -70 +KPX A W -84 +KPX A V -100 +KPX A U -32 +KPX A T 5 +KPX A Q 5 +KPX A O 5 +KPX A G 5 +KPX A C 5 + +KPX B period 15 +KPX B comma 15 +KPX B U 15 +KPX B A -11 + +KPX C A -5 + +KPX D period -11 +KPX D comma -11 +KPX D Y 6 +KPX D W -11 +KPX D V -18 + +KPX F r -27 +KPX F period -91 +KPX F o -47 +KPX F i -41 +KPX F e -41 +KPX F comma -91 +KPX F a -47 +KPX F A -79 + +KPX J u -39 +KPX J period -74 +KPX J o -40 +KPX J e -33 +KPX J comma -74 +KPX J a -40 +KPX J A -30 + +KPX K y -48 +KPX K u -4 +KPX K o -4 +KPX K e 18 + +KPX L y -30 +KPX L quoteright -100 +KPX L quotedblright -100 +KPX L Y -55 +KPX L W -69 +KPX L V -97 +KPX L T -75 + +KPX N period -49 +KPX N comma -49 + +KPX O period -18 +KPX O comma -18 +KPX O X -18 +KPX O W -15 +KPX O V -24 +KPX O A -5 + +KPX P period -100 +KPX P o -40 +KPX P e -33 +KPX P comma -100 +KPX P a -40 +KPX P A -80 + +KPX R W -14 +KPX R V -24 + +KPX S period -18 +KPX S comma -18 + +KPX T y -30 +KPX T w -30 +KPX T u -22 +KPX T r -9 +KPX T period -55 +KPX T o -40 +KPX T i -22 +KPX T hyphen -75 +KPX T h -9 +KPX T e -33 +KPX T comma -55 +KPX T a -40 +KPX T O 11 +KPX T A -60 + +KPX U period -25 +KPX U comma -25 +KPX U A -42 + +KPX V u -70 +KPX V semicolon 6 +KPX V period -94 +KPX V o -71 +KPX V i -35 +KPX V hyphen -94 +KPX V e -66 +KPX V comma -94 +KPX V colon -49 +KPX V a -55 +KPX V O -19 +KPX V G -12 +KPX V A -100 + +KPX W y -41 +KPX W u -25 +KPX W semicolon -22 +KPX W period -86 +KPX W o -33 +KPX W i -27 +KPX W hyphen -61 +KPX W h 5 +KPX W e -39 +KPX W comma -86 +KPX W colon -22 +KPX W a -33 +KPX W O -11 +KPX W A -66 + +KPX Y u -58 +KPX Y semicolon -55 +KPX Y period -91 +KPX Y o -77 +KPX Y i -22 +KPX Y hyphen -91 +KPX Y e -71 +KPX Y comma -91 +KPX Y colon -55 +KPX Y a -77 +KPX Y A -79 + +KPX a y -8 +KPX a w -8 +KPX a v 6 + +KPX b y -6 +KPX b v 8 +KPX b period 6 +KPX b comma 6 + +KPX c y -20 +KPX c period -8 +KPX c l -13 +KPX c k -8 +KPX c h -18 +KPX c comma -8 + +KPX colon space -18 + +KPX comma space -18 +KPX comma quoteright -18 +KPX comma quotedblright -18 + +KPX d y -15 +KPX d w -15 + +KPX e y -15 +KPX e x -5 +KPX e w -15 +KPX e p -11 +KPX e g -4 +KPX e b -8 + +KPX f quoteright 105 +KPX f quotedblright 105 +KPX f period -28 +KPX f o 7 +KPX f l 7 +KPX f i 7 +KPX f e 14 +KPX f dotlessi 7 +KPX f comma -28 +KPX f a 8 + +KPX g y -11 +KPX g r 11 +KPX g period -5 +KPX g comma -5 + +KPX h y -20 + +KPX i v 7 + +KPX k y -15 +KPX k o -22 +KPX k e -16 + +KPX l y -7 +KPX l w -7 + +KPX m y -20 +KPX m u -11 + +KPX n y -20 +KPX n v -7 +KPX n u -11 + +KPX o y -11 +KPX o w -8 +KPX o v 6 + +KPX p y -4 +KPX p period 8 +KPX p comma 8 + +KPX period space -18 +KPX period quoteright -18 +KPX period quotedblright -18 + +KPX quotedblleft quoteleft 20 +KPX quotedblleft A -60 + +KPX quotedblright space -18 + +KPX quoteleft A -80 + +KPX quoteright v -16 +KPX quoteright t -22 +KPX quoteright s -46 +KPX quoteright r -9 +KPX quoteright l -22 +KPX quoteright d -41 + +KPX r y -20 +KPX r v -7 +KPX r u -11 +KPX r t -11 +KPX r semicolon 9 +KPX r s -20 +KPX r quoteright 9 +KPX r period -90 +KPX r p -17 +KPX r o -11 +KPX r l -14 +KPX r k 9 +KPX r i -14 +KPX r hyphen -16 +KPX r g -11 +KPX r e -7 +KPX r d -7 +KPX r comma -90 +KPX r colon 9 +KPX r a -11 + +KPX s period 11 +KPX s comma 11 + +KPX semicolon space -18 + +KPX space quotedblleft -18 +KPX space Y -18 +KPX space W -33 +KPX space V -24 +KPX space T -18 +KPX space A -22 + +KPX v period -11 +KPX v o -6 +KPX v comma -11 +KPX v a -6 + +KPX w period -17 +KPX w o -14 +KPX w e -8 +KPX w comma -17 +KPX w a -14 + +KPX x e 5 + +KPX y period -25 +KPX y o 8 +KPX y e 15 +KPX y comma -25 +KPX y a 8 + +KPX z e 4 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 259 225 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 259 225 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 259 225 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 259 225 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 229 245 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 259 225 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 296 225 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 296 225 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 296 225 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 296 225 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 116 225 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 116 225 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 116 225 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 116 225 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 326 225 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 315 225 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 315 225 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 315 225 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 315 225 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 315 225 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 206 225 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 340 225 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 340 225 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 340 225 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 340 225 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 246 225 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 236 225 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 226 225 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 167 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 167 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 167 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 167 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 167 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 167 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 93 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 93 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 93 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 93 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -2 -7 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -2 -7 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -2 -7 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -2 -7 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 176 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 121 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 121 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 121 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 121 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 121 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 74 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 176 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 176 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 176 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 176 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 93 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 93 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 63 -10 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncr8a.afm new file mode 100644 index 00000000..b9f616cb --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncr8a.afm @@ -0,0 +1,524 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue May 28 16:31:51 1991 +Comment UniqueID 35025 +Comment VMusage 30420 37312 +FontName NewCenturySchlbk-Roman +FullName New Century Schoolbook Roman +FamilyName New Century Schoolbook +Weight Roman +ItalicAngle 0 +IsFixedPitch false +FontBBox -195 -250 1000 965 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 722 +XHeight 464 +Ascender 737 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 296 ; N exclam ; B 86 -15 210 737 ; +C 34 ; WX 389 ; N quotedbl ; B 61 443 328 737 ; +C 35 ; WX 556 ; N numbersign ; B 28 0 528 690 ; +C 36 ; WX 556 ; N dollar ; B 45 -138 511 813 ; +C 37 ; WX 833 ; N percent ; B 43 -15 790 705 ; +C 38 ; WX 815 ; N ampersand ; B 51 -15 775 737 ; +C 39 ; WX 204 ; N quoteright ; B 25 443 179 737 ; +C 40 ; WX 333 ; N parenleft ; B 40 -117 279 745 ; +C 41 ; WX 333 ; N parenright ; B 54 -117 293 745 ; +C 42 ; WX 500 ; N asterisk ; B 57 306 443 737 ; +C 43 ; WX 606 ; N plus ; B 50 0 556 506 ; +C 44 ; WX 278 ; N comma ; B 62 -185 216 109 ; +C 45 ; WX 333 ; N hyphen ; B 42 199 291 277 ; +C 46 ; WX 278 ; N period ; B 77 -15 201 109 ; +C 47 ; WX 278 ; N slash ; B -32 -15 310 737 ; +C 48 ; WX 556 ; N zero ; B 42 -15 514 705 ; +C 49 ; WX 556 ; N one ; B 100 0 496 705 ; +C 50 ; WX 556 ; N two ; B 35 0 505 705 ; +C 51 ; WX 556 ; N three ; B 42 -15 498 705 ; +C 52 ; WX 556 ; N four ; B 28 0 528 705 ; +C 53 ; WX 556 ; N five ; B 46 -15 502 705 ; +C 54 ; WX 556 ; N six ; B 41 -15 515 705 ; +C 55 ; WX 556 ; N seven ; B 59 -15 508 705 ; +C 56 ; WX 556 ; N eight ; B 42 -15 514 705 ; +C 57 ; WX 556 ; N nine ; B 41 -15 515 705 ; +C 58 ; WX 278 ; N colon ; B 77 -15 201 474 ; +C 59 ; WX 278 ; N semicolon ; B 62 -185 216 474 ; +C 60 ; WX 606 ; N less ; B 50 -8 556 514 ; +C 61 ; WX 606 ; N equal ; B 50 117 556 389 ; +C 62 ; WX 606 ; N greater ; B 50 -8 556 514 ; +C 63 ; WX 444 ; N question ; B 29 -15 415 737 ; +C 64 ; WX 737 ; N at ; B -8 -15 744 737 ; +C 65 ; WX 722 ; N A ; B -8 0 730 737 ; +C 66 ; WX 722 ; N B ; B 29 0 669 722 ; +C 67 ; WX 722 ; N C ; B 45 -15 668 737 ; +C 68 ; WX 778 ; N D ; B 29 0 733 722 ; +C 69 ; WX 722 ; N E ; B 29 0 663 722 ; +C 70 ; WX 667 ; N F ; B 29 0 638 722 ; +C 71 ; WX 778 ; N G ; B 45 -15 775 737 ; +C 72 ; WX 833 ; N H ; B 29 0 804 722 ; +C 73 ; WX 407 ; N I ; B 38 0 369 722 ; +C 74 ; WX 556 ; N J ; B 5 -15 540 722 ; +C 75 ; WX 778 ; N K ; B 29 0 803 722 ; +C 76 ; WX 667 ; N L ; B 29 0 644 722 ; +C 77 ; WX 944 ; N M ; B 29 0 915 722 ; +C 78 ; WX 815 ; N N ; B 24 -15 791 722 ; +C 79 ; WX 778 ; N O ; B 45 -15 733 737 ; +C 80 ; WX 667 ; N P ; B 29 0 650 722 ; +C 81 ; WX 778 ; N Q ; B 45 -190 748 737 ; +C 82 ; WX 722 ; N R ; B 29 -15 713 722 ; +C 83 ; WX 630 ; N S ; B 47 -15 583 737 ; +C 84 ; WX 667 ; N T ; B 19 0 648 722 ; +C 85 ; WX 815 ; N U ; B 16 -15 799 722 ; +C 86 ; WX 722 ; N V ; B -8 -10 730 722 ; +C 87 ; WX 981 ; N W ; B 5 -10 976 722 ; +C 88 ; WX 704 ; N X ; B -8 0 712 722 ; +C 89 ; WX 704 ; N Y ; B -11 0 715 722 ; +C 90 ; WX 611 ; N Z ; B 24 0 576 722 ; +C 91 ; WX 333 ; N bracketleft ; B 126 -109 315 737 ; +C 92 ; WX 606 ; N backslash ; B 132 -15 474 737 ; +C 93 ; WX 333 ; N bracketright ; B 18 -109 207 737 ; +C 94 ; WX 606 ; N asciicircum ; B 89 325 517 690 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 204 ; N quoteleft ; B 25 443 179 737 ; +C 97 ; WX 556 ; N a ; B 44 -15 542 479 ; +C 98 ; WX 556 ; N b ; B 10 -15 522 737 ; +C 99 ; WX 444 ; N c ; B 34 -15 426 479 ; +C 100 ; WX 574 ; N d ; B 34 -15 552 737 ; +C 101 ; WX 500 ; N e ; B 34 -15 466 479 ; +C 102 ; WX 333 ; N f ; B 18 0 437 737 ; L i fi ; L l fl ; +C 103 ; WX 537 ; N g ; B 23 -205 542 494 ; +C 104 ; WX 611 ; N h ; B 7 0 592 737 ; +C 105 ; WX 315 ; N i ; B 18 0 286 722 ; +C 106 ; WX 296 ; N j ; B -86 -205 216 722 ; +C 107 ; WX 593 ; N k ; B 10 0 589 737 ; +C 108 ; WX 315 ; N l ; B 18 0 286 737 ; +C 109 ; WX 889 ; N m ; B 26 0 863 479 ; +C 110 ; WX 611 ; N n ; B 22 0 589 479 ; +C 111 ; WX 500 ; N o ; B 34 -15 466 479 ; +C 112 ; WX 574 ; N p ; B 22 -205 540 479 ; +C 113 ; WX 556 ; N q ; B 34 -205 552 479 ; +C 114 ; WX 444 ; N r ; B 18 0 434 479 ; +C 115 ; WX 463 ; N s ; B 46 -15 417 479 ; +C 116 ; WX 389 ; N t ; B 18 -15 371 666 ; +C 117 ; WX 611 ; N u ; B 22 -15 589 464 ; +C 118 ; WX 537 ; N v ; B -6 -10 515 464 ; +C 119 ; WX 778 ; N w ; B 1 -10 749 464 ; +C 120 ; WX 537 ; N x ; B 8 0 529 464 ; +C 121 ; WX 537 ; N y ; B 4 -205 533 464 ; +C 122 ; WX 481 ; N z ; B 42 0 439 464 ; +C 123 ; WX 333 ; N braceleft ; B 54 -109 279 737 ; +C 124 ; WX 606 ; N bar ; B 267 -250 339 750 ; +C 125 ; WX 333 ; N braceright ; B 54 -109 279 737 ; +C 126 ; WX 606 ; N asciitilde ; B 72 184 534 322 ; +C 161 ; WX 296 ; N exclamdown ; B 86 -205 210 547 ; +C 162 ; WX 556 ; N cent ; B 74 -141 482 584 ; +C 163 ; WX 556 ; N sterling ; B 18 -15 538 705 ; +C 164 ; WX 167 ; N fraction ; B -195 -15 362 705 ; +C 165 ; WX 556 ; N yen ; B -1 0 557 690 ; +C 166 ; WX 556 ; N florin ; B 0 -205 538 737 ; +C 167 ; WX 500 ; N section ; B 55 -147 445 737 ; +C 168 ; WX 556 ; N currency ; B 26 93 530 597 ; +C 169 ; WX 204 ; N quotesingle ; B 59 443 145 737 ; +C 170 ; WX 389 ; N quotedblleft ; B 25 443 364 737 ; +C 171 ; WX 426 ; N guillemotleft ; B 39 78 387 398 ; +C 172 ; WX 259 ; N guilsinglleft ; B 39 78 220 398 ; +C 173 ; WX 259 ; N guilsinglright ; B 39 78 220 398 ; +C 174 ; WX 611 ; N fi ; B 18 0 582 737 ; +C 175 ; WX 611 ; N fl ; B 18 0 582 737 ; +C 177 ; WX 556 ; N endash ; B 0 208 556 268 ; +C 178 ; WX 500 ; N dagger ; B 42 -147 458 737 ; +C 179 ; WX 500 ; N daggerdbl ; B 42 -149 458 737 ; +C 180 ; WX 278 ; N periodcentered ; B 71 238 207 374 ; +C 182 ; WX 606 ; N paragraph ; B 60 -132 546 722 ; +C 183 ; WX 606 ; N bullet ; B 122 180 484 542 ; +C 184 ; WX 204 ; N quotesinglbase ; B 25 -185 179 109 ; +C 185 ; WX 389 ; N quotedblbase ; B 25 -185 364 109 ; +C 186 ; WX 389 ; N quotedblright ; B 25 443 364 737 ; +C 187 ; WX 426 ; N guillemotright ; B 39 78 387 398 ; +C 188 ; WX 1000 ; N ellipsis ; B 105 -15 895 109 ; +C 189 ; WX 1000 ; N perthousand ; B 6 -15 994 705 ; +C 191 ; WX 444 ; N questiondown ; B 29 -205 415 547 ; +C 193 ; WX 333 ; N grave ; B 17 528 242 699 ; +C 194 ; WX 333 ; N acute ; B 91 528 316 699 ; +C 195 ; WX 333 ; N circumflex ; B 10 528 323 695 ; +C 196 ; WX 333 ; N tilde ; B 1 553 332 655 ; +C 197 ; WX 333 ; N macron ; B 10 568 323 623 ; +C 198 ; WX 333 ; N breve ; B 25 528 308 685 ; +C 199 ; WX 333 ; N dotaccent ; B 116 543 218 645 ; +C 200 ; WX 333 ; N dieresis ; B 16 543 317 645 ; +C 202 ; WX 333 ; N ring ; B 66 522 266 722 ; +C 203 ; WX 333 ; N cedilla ; B 29 -215 237 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -9 528 416 699 ; +C 206 ; WX 333 ; N ogonek ; B 68 -215 254 0 ; +C 207 ; WX 333 ; N caron ; B 10 528 323 695 ; +C 208 ; WX 1000 ; N emdash ; B 0 208 1000 268 ; +C 225 ; WX 1000 ; N AE ; B 0 0 962 722 ; +C 227 ; WX 334 ; N ordfeminine ; B -4 407 338 705 ; +C 232 ; WX 667 ; N Lslash ; B 29 0 644 722 ; +C 233 ; WX 778 ; N Oslash ; B 45 -56 733 778 ; +C 234 ; WX 1000 ; N OE ; B 21 0 979 722 ; +C 235 ; WX 300 ; N ordmasculine ; B 4 407 296 705 ; +C 241 ; WX 796 ; N ae ; B 34 -15 762 479 ; +C 245 ; WX 315 ; N dotlessi ; B 18 0 286 464 ; +C 248 ; WX 315 ; N lslash ; B 18 0 286 737 ; +C 249 ; WX 500 ; N oslash ; B 34 -97 466 561 ; +C 250 ; WX 833 ; N oe ; B 34 -15 799 479 ; +C 251 ; WX 574 ; N germandbls ; B 30 -15 537 737 ; +C -1 ; WX 500 ; N ecircumflex ; B 34 -15 466 695 ; +C -1 ; WX 500 ; N edieresis ; B 34 -15 466 645 ; +C -1 ; WX 556 ; N aacute ; B 44 -15 542 699 ; +C -1 ; WX 737 ; N registered ; B -8 -15 744 737 ; +C -1 ; WX 315 ; N icircumflex ; B 1 0 314 695 ; +C -1 ; WX 611 ; N udieresis ; B 22 -15 589 645 ; +C -1 ; WX 500 ; N ograve ; B 34 -15 466 699 ; +C -1 ; WX 611 ; N uacute ; B 22 -15 589 699 ; +C -1 ; WX 611 ; N ucircumflex ; B 22 -15 589 695 ; +C -1 ; WX 722 ; N Aacute ; B -8 0 730 937 ; +C -1 ; WX 315 ; N igrave ; B 8 0 286 699 ; +C -1 ; WX 407 ; N Icircumflex ; B 38 0 369 933 ; +C -1 ; WX 444 ; N ccedilla ; B 34 -215 426 479 ; +C -1 ; WX 556 ; N adieresis ; B 44 -15 542 645 ; +C -1 ; WX 722 ; N Ecircumflex ; B 29 0 663 933 ; +C -1 ; WX 463 ; N scaron ; B 46 -15 417 695 ; +C -1 ; WX 574 ; N thorn ; B 22 -205 540 737 ; +C -1 ; WX 1000 ; N trademark ; B 32 318 968 722 ; +C -1 ; WX 500 ; N egrave ; B 34 -15 466 699 ; +C -1 ; WX 333 ; N threesuperior ; B 18 273 315 705 ; +C -1 ; WX 481 ; N zcaron ; B 42 0 439 695 ; +C -1 ; WX 556 ; N atilde ; B 44 -15 542 655 ; +C -1 ; WX 556 ; N aring ; B 44 -15 542 732 ; +C -1 ; WX 500 ; N ocircumflex ; B 34 -15 466 695 ; +C -1 ; WX 722 ; N Edieresis ; B 29 0 663 883 ; +C -1 ; WX 834 ; N threequarters ; B 28 -15 795 705 ; +C -1 ; WX 537 ; N ydieresis ; B 4 -205 533 645 ; +C -1 ; WX 537 ; N yacute ; B 4 -205 533 699 ; +C -1 ; WX 315 ; N iacute ; B 18 0 307 699 ; +C -1 ; WX 722 ; N Acircumflex ; B -8 0 730 933 ; +C -1 ; WX 815 ; N Uacute ; B 16 -15 799 937 ; +C -1 ; WX 500 ; N eacute ; B 34 -15 466 699 ; +C -1 ; WX 778 ; N Ograve ; B 45 -15 733 937 ; +C -1 ; WX 556 ; N agrave ; B 44 -15 542 699 ; +C -1 ; WX 815 ; N Udieresis ; B 16 -15 799 883 ; +C -1 ; WX 556 ; N acircumflex ; B 44 -15 542 695 ; +C -1 ; WX 407 ; N Igrave ; B 38 0 369 937 ; +C -1 ; WX 333 ; N twosuperior ; B 14 282 319 705 ; +C -1 ; WX 815 ; N Ugrave ; B 16 -15 799 937 ; +C -1 ; WX 834 ; N onequarter ; B 39 -15 795 705 ; +C -1 ; WX 815 ; N Ucircumflex ; B 16 -15 799 933 ; +C -1 ; WX 630 ; N Scaron ; B 47 -15 583 933 ; +C -1 ; WX 407 ; N Idieresis ; B 38 0 369 883 ; +C -1 ; WX 315 ; N idieresis ; B 7 0 308 645 ; +C -1 ; WX 722 ; N Egrave ; B 29 0 663 937 ; +C -1 ; WX 778 ; N Oacute ; B 45 -15 733 937 ; +C -1 ; WX 606 ; N divide ; B 50 -22 556 528 ; +C -1 ; WX 722 ; N Atilde ; B -8 0 730 893 ; +C -1 ; WX 722 ; N Aring ; B -8 0 730 965 ; +C -1 ; WX 778 ; N Odieresis ; B 45 -15 733 883 ; +C -1 ; WX 722 ; N Adieresis ; B -8 0 730 883 ; +C -1 ; WX 815 ; N Ntilde ; B 24 -15 791 893 ; +C -1 ; WX 611 ; N Zcaron ; B 24 0 576 933 ; +C -1 ; WX 667 ; N Thorn ; B 29 0 650 722 ; +C -1 ; WX 407 ; N Iacute ; B 38 0 369 937 ; +C -1 ; WX 606 ; N plusminus ; B 50 0 556 506 ; +C -1 ; WX 606 ; N multiply ; B 74 24 532 482 ; +C -1 ; WX 722 ; N Eacute ; B 29 0 663 937 ; +C -1 ; WX 704 ; N Ydieresis ; B -11 0 715 883 ; +C -1 ; WX 333 ; N onesuperior ; B 39 282 294 705 ; +C -1 ; WX 611 ; N ugrave ; B 22 -15 589 699 ; +C -1 ; WX 606 ; N logicalnot ; B 50 108 556 389 ; +C -1 ; WX 611 ; N ntilde ; B 22 0 589 655 ; +C -1 ; WX 778 ; N Otilde ; B 45 -15 733 893 ; +C -1 ; WX 500 ; N otilde ; B 34 -15 466 655 ; +C -1 ; WX 722 ; N Ccedilla ; B 45 -215 668 737 ; +C -1 ; WX 722 ; N Agrave ; B -8 0 730 937 ; +C -1 ; WX 834 ; N onehalf ; B 39 -15 820 705 ; +C -1 ; WX 778 ; N Eth ; B 29 0 733 722 ; +C -1 ; WX 400 ; N degree ; B 57 419 343 705 ; +C -1 ; WX 704 ; N Yacute ; B -11 0 715 937 ; +C -1 ; WX 778 ; N Ocircumflex ; B 45 -15 733 933 ; +C -1 ; WX 500 ; N oacute ; B 34 -15 466 699 ; +C -1 ; WX 611 ; N mu ; B 22 -205 589 464 ; +C -1 ; WX 606 ; N minus ; B 50 217 556 289 ; +C -1 ; WX 500 ; N eth ; B 34 -15 466 752 ; +C -1 ; WX 500 ; N odieresis ; B 34 -15 466 645 ; +C -1 ; WX 737 ; N copyright ; B -8 -15 744 737 ; +C -1 ; WX 606 ; N brokenbar ; B 267 -175 339 675 ; +EndCharMetrics +StartKernData +StartKernPairs 169 + +KPX A y -37 +KPX A w -25 +KPX A v -37 +KPX A quoteright -74 +KPX A quotedblright -74 +KPX A Y -75 +KPX A W -50 +KPX A V -75 +KPX A U -30 +KPX A T -18 + +KPX B period -37 +KPX B comma -37 +KPX B A -18 + +KPX C period -37 +KPX C comma -37 +KPX C A -18 + +KPX D period -37 +KPX D comma -37 +KPX D Y -18 +KPX D V -18 + +KPX F r -10 +KPX F period -125 +KPX F o -55 +KPX F i -10 +KPX F e -55 +KPX F comma -125 +KPX F a -65 +KPX F A -50 + +KPX G period -37 +KPX G comma -37 + +KPX J u -25 +KPX J period -74 +KPX J o -25 +KPX J e -25 +KPX J comma -74 +KPX J a -25 +KPX J A -18 + +KPX K y -25 +KPX K o 10 +KPX K e 10 + +KPX L y -25 +KPX L quoteright -100 +KPX L quotedblright -100 +KPX L Y -74 +KPX L W -74 +KPX L V -91 +KPX L T -75 + +KPX N period -55 +KPX N comma -55 + +KPX O period -37 +KPX O comma -37 +KPX O Y -18 +KPX O V -18 +KPX O T 10 + +KPX P period -125 +KPX P o -37 +KPX P e -37 +KPX P comma -125 +KPX P a -37 +KPX P A -55 + +KPX Q period -25 +KPX Q comma -25 + +KPX S period -37 +KPX S comma -37 + +KPX T semicolon -37 +KPX T period -125 +KPX T o -55 +KPX T hyphen -100 +KPX T e -55 +KPX T comma -125 +KPX T colon -37 +KPX T a -55 +KPX T O 10 +KPX T A -18 + +KPX U period -100 +KPX U comma -100 +KPX U A -30 + +KPX V u -75 +KPX V semicolon -75 +KPX V period -125 +KPX V o -75 +KPX V i -18 +KPX V hyphen -100 +KPX V e -75 +KPX V comma -125 +KPX V colon -75 +KPX V a -85 +KPX V O -18 +KPX V A -74 + +KPX W y -55 +KPX W u -55 +KPX W semicolon -100 +KPX W period -125 +KPX W o -60 +KPX W i -18 +KPX W hyphen -100 +KPX W e -60 +KPX W comma -125 +KPX W colon -100 +KPX W a -75 +KPX W A -50 + +KPX Y u -91 +KPX Y semicolon -75 +KPX Y period -100 +KPX Y o -100 +KPX Y i -18 +KPX Y hyphen -125 +KPX Y e -100 +KPX Y comma -100 +KPX Y colon -75 +KPX Y a -100 +KPX Y O -18 +KPX Y A -75 + +KPX a y -10 +KPX a w -10 +KPX a v -10 + +KPX b period -18 +KPX b comma -18 + +KPX c period -18 +KPX c l -7 +KPX c k -7 +KPX c h -7 +KPX c comma -18 + +KPX colon space -37 + +KPX comma space -37 +KPX comma quoteright -37 +KPX comma quotedblright -37 + +KPX e period -18 +KPX e comma -18 + +KPX f quoteright 100 +KPX f quotedblright 100 +KPX f period -37 +KPX f comma -37 + +KPX g period -25 +KPX g comma -25 + +KPX o period -18 +KPX o comma -18 + +KPX p period -18 +KPX p comma -18 + +KPX period space -37 +KPX period quoteright -37 +KPX period quotedblright -37 + +KPX quotedblleft A -74 + +KPX quotedblright space -37 + +KPX quoteleft quoteleft -25 +KPX quoteleft A -74 + +KPX quoteright s -25 +KPX quoteright quoteright -25 +KPX quoteright d -37 + +KPX r period -100 +KPX r hyphen -37 +KPX r comma -100 + +KPX s period -25 +KPX s comma -25 + +KPX semicolon space -37 + +KPX space quoteleft -37 +KPX space quotedblleft -37 +KPX space Y -37 +KPX space W -37 +KPX space V -37 +KPX space T -37 +KPX space A -37 + +KPX v period -125 +KPX v comma -125 + +KPX w period -125 +KPX w comma -125 +KPX w a -18 + +KPX y period -125 +KPX y comma -125 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 195 238 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 195 238 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 195 238 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 195 238 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 195 243 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 195 238 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 195 238 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 195 238 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 195 238 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 195 238 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 37 238 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 37 238 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 37 238 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 37 238 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 241 238 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 223 238 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 223 238 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 223 238 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 223 238 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 223 238 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 149 238 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 241 238 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 241 238 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 241 238 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 241 238 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 216 238 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 186 238 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 238 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 112 10 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 112 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 84 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 84 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 84 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 84 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -9 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -9 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -9 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -9 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 139 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 84 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 84 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 84 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 84 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 65 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 139 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 139 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 139 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 139 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 102 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 102 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 74 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncri8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncri8a.afm new file mode 100644 index 00000000..6dfd6a25 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pncri8a.afm @@ -0,0 +1,536 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue May 28 16:40:04 1991 +Comment UniqueID 35028 +Comment VMusage 31423 38315 +FontName NewCenturySchlbk-Italic +FullName New Century Schoolbook Italic +FamilyName New Century Schoolbook +Weight Medium +ItalicAngle -16 +IsFixedPitch false +FontBBox -166 -250 994 958 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.006 +Notice Copyright (c) 1985, 1987, 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 722 +XHeight 466 +Ascender 737 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 17 -15 303 737 ; +C 34 ; WX 400 ; N quotedbl ; B 127 463 363 737 ; +C 35 ; WX 556 ; N numbersign ; B 28 0 528 690 ; +C 36 ; WX 556 ; N dollar ; B 4 -142 536 808 ; +C 37 ; WX 833 ; N percent ; B 43 -15 790 705 ; +C 38 ; WX 852 ; N ampersand ; B 24 -15 773 737 ; +C 39 ; WX 204 ; N quoteright ; B 39 463 229 737 ; +C 40 ; WX 333 ; N parenleft ; B 53 -117 411 745 ; +C 41 ; WX 333 ; N parenright ; B -93 -117 265 745 ; +C 42 ; WX 500 ; N asterisk ; B 80 318 500 737 ; +C 43 ; WX 606 ; N plus ; B 50 0 556 506 ; +C 44 ; WX 278 ; N comma ; B -39 -165 151 109 ; +C 45 ; WX 333 ; N hyphen ; B 32 202 259 274 ; +C 46 ; WX 278 ; N period ; B 17 -15 141 109 ; +C 47 ; WX 606 ; N slash ; B 132 -15 474 737 ; +C 48 ; WX 556 ; N zero ; B 30 -15 526 705 ; +C 49 ; WX 556 ; N one ; B 50 0 459 705 ; +C 50 ; WX 556 ; N two ; B -37 0 506 705 ; +C 51 ; WX 556 ; N three ; B -2 -15 506 705 ; +C 52 ; WX 556 ; N four ; B -8 0 512 705 ; +C 53 ; WX 556 ; N five ; B 4 -15 540 705 ; +C 54 ; WX 556 ; N six ; B 36 -15 548 705 ; +C 55 ; WX 556 ; N seven ; B 69 -15 561 705 ; +C 56 ; WX 556 ; N eight ; B 6 -15 526 705 ; +C 57 ; WX 556 ; N nine ; B 8 -15 520 705 ; +C 58 ; WX 278 ; N colon ; B 17 -15 229 466 ; +C 59 ; WX 278 ; N semicolon ; B -39 -165 229 466 ; +C 60 ; WX 606 ; N less ; B 36 -8 542 514 ; +C 61 ; WX 606 ; N equal ; B 50 117 556 389 ; +C 62 ; WX 606 ; N greater ; B 64 -8 570 514 ; +C 63 ; WX 444 ; N question ; B 102 -15 417 737 ; +C 64 ; WX 747 ; N at ; B -2 -15 750 737 ; +C 65 ; WX 704 ; N A ; B -87 0 668 737 ; +C 66 ; WX 722 ; N B ; B -33 0 670 722 ; +C 67 ; WX 722 ; N C ; B 40 -15 712 737 ; +C 68 ; WX 778 ; N D ; B -33 0 738 722 ; +C 69 ; WX 722 ; N E ; B -33 0 700 722 ; +C 70 ; WX 667 ; N F ; B -33 0 700 722 ; +C 71 ; WX 778 ; N G ; B 40 -15 763 737 ; +C 72 ; WX 833 ; N H ; B -33 0 866 722 ; +C 73 ; WX 407 ; N I ; B -33 0 435 722 ; +C 74 ; WX 611 ; N J ; B -14 -15 651 722 ; +C 75 ; WX 741 ; N K ; B -33 0 816 722 ; +C 76 ; WX 667 ; N L ; B -33 0 627 722 ; +C 77 ; WX 944 ; N M ; B -33 0 977 722 ; +C 78 ; WX 815 ; N N ; B -51 -15 866 722 ; +C 79 ; WX 778 ; N O ; B 40 -15 738 737 ; +C 80 ; WX 667 ; N P ; B -33 0 667 722 ; +C 81 ; WX 778 ; N Q ; B 40 -190 738 737 ; +C 82 ; WX 741 ; N R ; B -45 -15 692 722 ; +C 83 ; WX 667 ; N S ; B -6 -15 638 737 ; +C 84 ; WX 685 ; N T ; B 40 0 725 722 ; +C 85 ; WX 815 ; N U ; B 93 -15 867 722 ; +C 86 ; WX 704 ; N V ; B 36 -10 779 722 ; +C 87 ; WX 926 ; N W ; B 53 -10 978 722 ; +C 88 ; WX 704 ; N X ; B -75 0 779 722 ; +C 89 ; WX 685 ; N Y ; B 31 0 760 722 ; +C 90 ; WX 667 ; N Z ; B -25 0 667 722 ; +C 91 ; WX 333 ; N bracketleft ; B -55 -109 388 737 ; +C 92 ; WX 606 ; N backslash ; B 132 -15 474 737 ; +C 93 ; WX 333 ; N bracketright ; B -77 -109 366 737 ; +C 94 ; WX 606 ; N asciicircum ; B 89 325 517 690 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 204 ; N quoteleft ; B 39 463 229 737 ; +C 97 ; WX 574 ; N a ; B 2 -15 524 466 ; +C 98 ; WX 556 ; N b ; B 32 -15 488 737 ; +C 99 ; WX 444 ; N c ; B 2 -15 394 466 ; +C 100 ; WX 611 ; N d ; B 2 -15 585 737 ; +C 101 ; WX 444 ; N e ; B -6 -15 388 466 ; +C 102 ; WX 333 ; N f ; B -68 -205 470 737 ; L i fi ; L l fl ; +C 103 ; WX 537 ; N g ; B -79 -205 523 497 ; +C 104 ; WX 611 ; N h ; B 14 -15 562 737 ; +C 105 ; WX 333 ; N i ; B 29 -15 282 715 ; +C 106 ; WX 315 ; N j ; B -166 -205 318 715 ; +C 107 ; WX 556 ; N k ; B 0 -15 497 737 ; +C 108 ; WX 333 ; N l ; B 14 -15 292 737 ; +C 109 ; WX 889 ; N m ; B 14 -15 840 466 ; +C 110 ; WX 611 ; N n ; B 14 -15 562 466 ; +C 111 ; WX 500 ; N o ; B 2 -15 450 466 ; +C 112 ; WX 574 ; N p ; B -101 -205 506 466 ; +C 113 ; WX 556 ; N q ; B 2 -205 500 466 ; +C 114 ; WX 444 ; N r ; B 10 0 434 466 ; +C 115 ; WX 444 ; N s ; B 2 -15 394 466 ; +C 116 ; WX 352 ; N t ; B 24 -15 328 619 ; +C 117 ; WX 611 ; N u ; B 44 -15 556 466 ; +C 118 ; WX 519 ; N v ; B 31 -15 447 466 ; +C 119 ; WX 778 ; N w ; B 31 -15 706 466 ; +C 120 ; WX 500 ; N x ; B -33 -15 471 466 ; +C 121 ; WX 500 ; N y ; B -83 -205 450 466 ; +C 122 ; WX 463 ; N z ; B -33 -15 416 466 ; +C 123 ; WX 333 ; N braceleft ; B 38 -109 394 737 ; +C 124 ; WX 606 ; N bar ; B 267 -250 339 750 ; +C 125 ; WX 333 ; N braceright ; B -87 -109 269 737 ; +C 126 ; WX 606 ; N asciitilde ; B 72 184 534 322 ; +C 161 ; WX 333 ; N exclamdown ; B -22 -205 264 547 ; +C 162 ; WX 556 ; N cent ; B 62 -144 486 580 ; +C 163 ; WX 556 ; N sterling ; B -13 -15 544 705 ; +C 164 ; WX 167 ; N fraction ; B -134 -15 301 705 ; +C 165 ; WX 556 ; N yen ; B 40 0 624 690 ; +C 166 ; WX 556 ; N florin ; B -58 -205 569 737 ; +C 167 ; WX 500 ; N section ; B -10 -147 480 737 ; +C 168 ; WX 556 ; N currency ; B 26 93 530 597 ; +C 169 ; WX 278 ; N quotesingle ; B 151 463 237 737 ; +C 170 ; WX 389 ; N quotedblleft ; B 39 463 406 737 ; +C 171 ; WX 426 ; N guillemotleft ; B -15 74 402 402 ; +C 172 ; WX 333 ; N guilsinglleft ; B 40 74 259 402 ; +C 173 ; WX 333 ; N guilsinglright ; B 40 74 259 402 ; +C 174 ; WX 611 ; N fi ; B -68 -205 555 737 ; +C 175 ; WX 611 ; N fl ; B -68 -205 587 737 ; +C 177 ; WX 500 ; N endash ; B -27 208 487 268 ; +C 178 ; WX 500 ; N dagger ; B 51 -147 506 737 ; +C 179 ; WX 500 ; N daggerdbl ; B -54 -147 506 737 ; +C 180 ; WX 278 ; N periodcentered ; B 71 238 207 374 ; +C 182 ; WX 650 ; N paragraph ; B 48 -132 665 722 ; +C 183 ; WX 606 ; N bullet ; B 122 180 484 542 ; +C 184 ; WX 204 ; N quotesinglbase ; B -78 -165 112 109 ; +C 185 ; WX 389 ; N quotedblbase ; B -78 -165 289 109 ; +C 186 ; WX 389 ; N quotedblright ; B 39 463 406 737 ; +C 187 ; WX 426 ; N guillemotright ; B -15 74 402 402 ; +C 188 ; WX 1000 ; N ellipsis ; B 59 -15 849 109 ; +C 189 ; WX 1000 ; N perthousand ; B 6 -15 994 705 ; +C 191 ; WX 444 ; N questiondown ; B -3 -205 312 547 ; +C 193 ; WX 333 ; N grave ; B 71 518 262 690 ; +C 194 ; WX 333 ; N acute ; B 132 518 355 690 ; +C 195 ; WX 333 ; N circumflex ; B 37 518 331 690 ; +C 196 ; WX 333 ; N tilde ; B 52 547 383 649 ; +C 197 ; WX 333 ; N macron ; B 52 560 363 610 ; +C 198 ; WX 333 ; N breve ; B 69 518 370 677 ; +C 199 ; WX 333 ; N dotaccent ; B 146 544 248 646 ; +C 200 ; WX 333 ; N dieresis ; B 59 544 359 646 ; +C 202 ; WX 333 ; N ring ; B 114 512 314 712 ; +C 203 ; WX 333 ; N cedilla ; B 3 -215 215 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 32 518 455 690 ; +C 206 ; WX 333 ; N ogonek ; B 68 -215 254 0 ; +C 207 ; WX 333 ; N caron ; B 73 518 378 690 ; +C 208 ; WX 1000 ; N emdash ; B -27 208 987 268 ; +C 225 ; WX 870 ; N AE ; B -87 0 888 722 ; +C 227 ; WX 422 ; N ordfeminine ; B 72 416 420 705 ; +C 232 ; WX 667 ; N Lslash ; B -33 0 627 722 ; +C 233 ; WX 778 ; N Oslash ; B 16 -68 748 780 ; +C 234 ; WX 981 ; N OE ; B 40 0 975 722 ; +C 235 ; WX 372 ; N ordmasculine ; B 66 416 370 705 ; +C 241 ; WX 722 ; N ae ; B -18 -15 666 466 ; +C 245 ; WX 333 ; N dotlessi ; B 29 -15 282 466 ; +C 248 ; WX 333 ; N lslash ; B -25 -15 340 737 ; +C 249 ; WX 500 ; N oslash ; B 2 -121 450 549 ; +C 250 ; WX 778 ; N oe ; B 2 -15 722 466 ; +C 251 ; WX 556 ; N germandbls ; B -76 -205 525 737 ; +C -1 ; WX 444 ; N ecircumflex ; B -6 -15 388 690 ; +C -1 ; WX 444 ; N edieresis ; B -6 -15 415 646 ; +C -1 ; WX 574 ; N aacute ; B 2 -15 524 690 ; +C -1 ; WX 747 ; N registered ; B -2 -15 750 737 ; +C -1 ; WX 333 ; N icircumflex ; B 29 -15 331 690 ; +C -1 ; WX 611 ; N udieresis ; B 44 -15 556 646 ; +C -1 ; WX 500 ; N ograve ; B 2 -15 450 690 ; +C -1 ; WX 611 ; N uacute ; B 44 -15 556 690 ; +C -1 ; WX 611 ; N ucircumflex ; B 44 -15 556 690 ; +C -1 ; WX 704 ; N Aacute ; B -87 0 668 946 ; +C -1 ; WX 333 ; N igrave ; B 29 -15 282 690 ; +C -1 ; WX 407 ; N Icircumflex ; B -33 0 435 946 ; +C -1 ; WX 444 ; N ccedilla ; B 2 -215 394 466 ; +C -1 ; WX 574 ; N adieresis ; B 2 -15 524 646 ; +C -1 ; WX 722 ; N Ecircumflex ; B -33 0 700 946 ; +C -1 ; WX 444 ; N scaron ; B 2 -15 434 690 ; +C -1 ; WX 574 ; N thorn ; B -101 -205 506 737 ; +C -1 ; WX 950 ; N trademark ; B 32 318 968 722 ; +C -1 ; WX 444 ; N egrave ; B -6 -15 388 690 ; +C -1 ; WX 333 ; N threesuperior ; B 22 273 359 705 ; +C -1 ; WX 463 ; N zcaron ; B -33 -15 443 690 ; +C -1 ; WX 574 ; N atilde ; B 2 -15 524 649 ; +C -1 ; WX 574 ; N aring ; B 2 -15 524 712 ; +C -1 ; WX 500 ; N ocircumflex ; B 2 -15 450 690 ; +C -1 ; WX 722 ; N Edieresis ; B -33 0 700 902 ; +C -1 ; WX 834 ; N threequarters ; B 22 -15 782 705 ; +C -1 ; WX 500 ; N ydieresis ; B -83 -205 450 646 ; +C -1 ; WX 500 ; N yacute ; B -83 -205 450 690 ; +C -1 ; WX 333 ; N iacute ; B 29 -15 355 690 ; +C -1 ; WX 704 ; N Acircumflex ; B -87 0 668 946 ; +C -1 ; WX 815 ; N Uacute ; B 93 -15 867 946 ; +C -1 ; WX 444 ; N eacute ; B -6 -15 411 690 ; +C -1 ; WX 778 ; N Ograve ; B 40 -15 738 946 ; +C -1 ; WX 574 ; N agrave ; B 2 -15 524 690 ; +C -1 ; WX 815 ; N Udieresis ; B 93 -15 867 902 ; +C -1 ; WX 574 ; N acircumflex ; B 2 -15 524 690 ; +C -1 ; WX 407 ; N Igrave ; B -33 0 435 946 ; +C -1 ; WX 333 ; N twosuperior ; B 0 282 359 705 ; +C -1 ; WX 815 ; N Ugrave ; B 93 -15 867 946 ; +C -1 ; WX 834 ; N onequarter ; B 34 -15 782 705 ; +C -1 ; WX 815 ; N Ucircumflex ; B 93 -15 867 946 ; +C -1 ; WX 667 ; N Scaron ; B -6 -15 638 946 ; +C -1 ; WX 407 ; N Idieresis ; B -33 0 456 902 ; +C -1 ; WX 333 ; N idieresis ; B 29 -15 359 646 ; +C -1 ; WX 722 ; N Egrave ; B -33 0 700 946 ; +C -1 ; WX 778 ; N Oacute ; B 40 -15 738 946 ; +C -1 ; WX 606 ; N divide ; B 50 -22 556 528 ; +C -1 ; WX 704 ; N Atilde ; B -87 0 668 905 ; +C -1 ; WX 704 ; N Aring ; B -87 0 668 958 ; +C -1 ; WX 778 ; N Odieresis ; B 40 -15 738 902 ; +C -1 ; WX 704 ; N Adieresis ; B -87 0 668 902 ; +C -1 ; WX 815 ; N Ntilde ; B -51 -15 866 905 ; +C -1 ; WX 667 ; N Zcaron ; B -25 0 667 946 ; +C -1 ; WX 667 ; N Thorn ; B -33 0 627 722 ; +C -1 ; WX 407 ; N Iacute ; B -33 0 452 946 ; +C -1 ; WX 606 ; N plusminus ; B 50 0 556 506 ; +C -1 ; WX 606 ; N multiply ; B 74 24 532 482 ; +C -1 ; WX 722 ; N Eacute ; B -33 0 700 946 ; +C -1 ; WX 685 ; N Ydieresis ; B 31 0 760 902 ; +C -1 ; WX 333 ; N onesuperior ; B 34 282 311 705 ; +C -1 ; WX 611 ; N ugrave ; B 44 -15 556 690 ; +C -1 ; WX 606 ; N logicalnot ; B 50 108 556 389 ; +C -1 ; WX 611 ; N ntilde ; B 14 -15 562 649 ; +C -1 ; WX 778 ; N Otilde ; B 40 -15 738 905 ; +C -1 ; WX 500 ; N otilde ; B 2 -15 467 649 ; +C -1 ; WX 722 ; N Ccedilla ; B 40 -215 712 737 ; +C -1 ; WX 704 ; N Agrave ; B -87 0 668 946 ; +C -1 ; WX 834 ; N onehalf ; B 34 -15 776 705 ; +C -1 ; WX 778 ; N Eth ; B -33 0 738 722 ; +C -1 ; WX 400 ; N degree ; B 86 419 372 705 ; +C -1 ; WX 685 ; N Yacute ; B 31 0 760 946 ; +C -1 ; WX 778 ; N Ocircumflex ; B 40 -15 738 946 ; +C -1 ; WX 500 ; N oacute ; B 2 -15 450 690 ; +C -1 ; WX 611 ; N mu ; B -60 -205 556 466 ; +C -1 ; WX 606 ; N minus ; B 50 217 556 289 ; +C -1 ; WX 500 ; N eth ; B 2 -15 450 737 ; +C -1 ; WX 500 ; N odieresis ; B 2 -15 450 646 ; +C -1 ; WX 747 ; N copyright ; B -2 -15 750 737 ; +C -1 ; WX 606 ; N brokenbar ; B 267 -175 339 675 ; +EndCharMetrics +StartKernData +StartKernPairs 181 + +KPX A y -55 +KPX A w -18 +KPX A v -18 +KPX A u -18 +KPX A quoteright -125 +KPX A quotedblright -125 +KPX A Y -55 +KPX A W -74 +KPX A V -74 +KPX A U -37 +KPX A T -30 +KPX A Q -18 +KPX A O -18 +KPX A G -18 +KPX A C -18 + +KPX B period -50 +KPX B comma -50 + +KPX C period -50 +KPX C comma -50 + +KPX D period -50 +KPX D comma -50 +KPX D Y -18 +KPX D W -18 +KPX D V -18 + +KPX F r -55 +KPX F period -125 +KPX F o -55 +KPX F i -10 +KPX F e -55 +KPX F comma -125 +KPX F a -55 +KPX F A -35 + +KPX G period -50 +KPX G comma -50 + +KPX J u -18 +KPX J period -100 +KPX J o -37 +KPX J e -37 +KPX J comma -100 +KPX J a -37 +KPX J A -18 + +KPX L y -50 +KPX L quoteright -125 +KPX L quotedblright -125 +KPX L Y -100 +KPX L W -100 +KPX L V -100 +KPX L T -100 + +KPX N period -60 +KPX N comma -60 + +KPX O period -50 +KPX O comma -50 +KPX O Y -18 +KPX O X -18 +KPX O V -18 +KPX O T 18 + +KPX P period -125 +KPX P o -55 +KPX P e -55 +KPX P comma -125 +KPX P a -55 +KPX P A -50 + +KPX Q period -20 +KPX Q comma -20 + +KPX R Y -18 +KPX R W -18 +KPX R V -18 +KPX R U -18 + +KPX S period -50 +KPX S comma -50 + +KPX T y -50 +KPX T w -50 +KPX T u -50 +KPX T semicolon -50 +KPX T r -50 +KPX T period -100 +KPX T o -74 +KPX T i -18 +KPX T hyphen -100 +KPX T h -25 +KPX T e -74 +KPX T comma -100 +KPX T colon -50 +KPX T a -74 +KPX T O 18 + +KPX U period -100 +KPX U comma -100 +KPX U A -18 + +KPX V u -75 +KPX V semicolon -75 +KPX V period -100 +KPX V o -75 +KPX V i -50 +KPX V hyphen -100 +KPX V e -75 +KPX V comma -100 +KPX V colon -75 +KPX V a -75 +KPX V A -37 + +KPX W y -55 +KPX W u -55 +KPX W semicolon -75 +KPX W period -100 +KPX W o -55 +KPX W i -20 +KPX W hyphen -75 +KPX W h -20 +KPX W e -55 +KPX W comma -100 +KPX W colon -75 +KPX W a -55 +KPX W A -55 + +KPX Y u -100 +KPX Y semicolon -75 +KPX Y period -100 +KPX Y o -100 +KPX Y i -25 +KPX Y hyphen -100 +KPX Y e -100 +KPX Y comma -100 +KPX Y colon -75 +KPX Y a -100 +KPX Y A -55 + +KPX b period -50 +KPX b comma -50 +KPX b b -10 + +KPX c period -50 +KPX c k -18 +KPX c h -18 +KPX c comma -50 + +KPX colon space -37 + +KPX comma space -37 +KPX comma quoteright -37 +KPX comma quotedblright -37 + +KPX e period -37 +KPX e comma -37 + +KPX f quoteright 75 +KPX f quotedblright 75 +KPX f period -75 +KPX f o -10 +KPX f comma -75 + +KPX g period -50 +KPX g comma -50 + +KPX l y -10 + +KPX o period -50 +KPX o comma -50 + +KPX p period -50 +KPX p comma -50 + +KPX period space -37 +KPX period quoteright -37 +KPX period quotedblright -37 + +KPX quotedblleft A -75 + +KPX quotedblright space -37 + +KPX quoteleft quoteleft -37 +KPX quoteleft A -75 + +KPX quoteright s -25 +KPX quoteright quoteright -37 +KPX quoteright d -37 + +KPX r semicolon -25 +KPX r s -10 +KPX r period -125 +KPX r k -18 +KPX r hyphen -75 +KPX r comma -125 +KPX r colon -25 + +KPX s period -50 +KPX s comma -50 + +KPX semicolon space -37 + +KPX space quoteleft -37 +KPX space quotedblleft -37 +KPX space Y -37 +KPX space W -37 +KPX space V -37 +KPX space T -37 +KPX space A -37 + +KPX v period -75 +KPX v comma -75 + +KPX w period -75 +KPX w comma -75 + +KPX y period -75 +KPX y comma -75 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 246 256 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 246 256 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 231 256 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 246 256 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 216 246 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 231 256 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 255 256 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 255 256 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 255 256 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 255 256 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 97 256 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 97 256 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 97 256 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 97 256 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 301 256 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 283 256 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 283 256 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 283 256 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 283 256 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 283 256 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 227 256 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 301 256 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 301 256 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 301 256 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 301 256 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 256 256 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 236 256 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 227 256 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 121 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 121 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 121 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 121 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 121 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 121 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 56 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 56 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 56 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 56 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex 0 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis 0 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 139 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 84 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 84 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 84 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 84 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 56 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 139 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 139 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 139 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 139 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 84 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 65 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplb8a.afm new file mode 100644 index 00000000..de7698d2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplb8a.afm @@ -0,0 +1,434 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jul 2 22:26:30 1990 +Comment UniqueID 31793 +Comment VMusage 36031 46923 +FontName Palatino-Bold +FullName Palatino Bold +FamilyName Palatino +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -152 -266 1000 924 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.005 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Palatino is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 471 +Ascender 720 +Descender -258 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 63 -12 219 688 ; +C 34 ; WX 402 ; N quotedbl ; B 22 376 380 695 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 496 673 ; +C 36 ; WX 500 ; N dollar ; B 28 -114 472 721 ; +C 37 ; WX 889 ; N percent ; B 61 -9 828 714 ; +C 38 ; WX 833 ; N ampersand ; B 52 -17 813 684 ; +C 39 ; WX 278 ; N quoteright ; B 29 405 249 695 ; +C 40 ; WX 333 ; N parenleft ; B 65 -104 305 723 ; +C 41 ; WX 333 ; N parenright ; B 28 -104 268 723 ; +C 42 ; WX 444 ; N asterisk ; B 44 332 399 695 ; +C 43 ; WX 606 ; N plus ; B 51 0 555 505 ; +C 44 ; WX 250 ; N comma ; B -6 -166 227 141 ; +C 45 ; WX 333 ; N hyphen ; B 16 195 317 305 ; +C 46 ; WX 250 ; N period ; B 47 -12 203 144 ; +C 47 ; WX 296 ; N slash ; B -9 -17 305 720 ; +C 48 ; WX 500 ; N zero ; B 33 -17 468 660 ; +C 49 ; WX 500 ; N one ; B 35 -3 455 670 ; +C 50 ; WX 500 ; N two ; B 25 -3 472 660 ; +C 51 ; WX 500 ; N three ; B 22 -17 458 660 ; +C 52 ; WX 500 ; N four ; B 12 -3 473 672 ; +C 53 ; WX 500 ; N five ; B 42 -17 472 656 ; +C 54 ; WX 500 ; N six ; B 37 -17 469 660 ; +C 55 ; WX 500 ; N seven ; B 46 -3 493 656 ; +C 56 ; WX 500 ; N eight ; B 34 -17 467 660 ; +C 57 ; WX 500 ; N nine ; B 31 -17 463 660 ; +C 58 ; WX 250 ; N colon ; B 47 -12 203 454 ; +C 59 ; WX 250 ; N semicolon ; B -6 -166 227 454 ; +C 60 ; WX 606 ; N less ; B 49 -15 558 519 ; +C 61 ; WX 606 ; N equal ; B 51 114 555 396 ; +C 62 ; WX 606 ; N greater ; B 49 -15 558 519 ; +C 63 ; WX 444 ; N question ; B 43 -12 411 687 ; +C 64 ; WX 747 ; N at ; B 42 -12 704 681 ; +C 65 ; WX 778 ; N A ; B 24 -3 757 686 ; +C 66 ; WX 667 ; N B ; B 39 -3 611 681 ; +C 67 ; WX 722 ; N C ; B 44 -17 695 695 ; +C 68 ; WX 833 ; N D ; B 35 -3 786 681 ; +C 69 ; WX 611 ; N E ; B 39 -4 577 681 ; +C 70 ; WX 556 ; N F ; B 28 -3 539 681 ; +C 71 ; WX 833 ; N G ; B 47 -17 776 695 ; +C 72 ; WX 833 ; N H ; B 36 -3 796 681 ; +C 73 ; WX 389 ; N I ; B 39 -3 350 681 ; +C 74 ; WX 389 ; N J ; B -11 -213 350 681 ; +C 75 ; WX 778 ; N K ; B 39 -3 763 681 ; +C 76 ; WX 611 ; N L ; B 39 -4 577 681 ; +C 77 ; WX 1000 ; N M ; B 32 -10 968 681 ; +C 78 ; WX 833 ; N N ; B 35 -16 798 681 ; +C 79 ; WX 833 ; N O ; B 47 -17 787 695 ; +C 80 ; WX 611 ; N P ; B 39 -3 594 681 ; +C 81 ; WX 833 ; N Q ; B 47 -184 787 695 ; +C 82 ; WX 722 ; N R ; B 39 -3 708 681 ; +C 83 ; WX 611 ; N S ; B 57 -17 559 695 ; +C 84 ; WX 667 ; N T ; B 17 -3 650 681 ; +C 85 ; WX 778 ; N U ; B 26 -17 760 681 ; +C 86 ; WX 778 ; N V ; B 20 -3 763 681 ; +C 87 ; WX 1000 ; N W ; B 17 -3 988 686 ; +C 88 ; WX 667 ; N X ; B 17 -3 650 695 ; +C 89 ; WX 667 ; N Y ; B 15 -3 660 695 ; +C 90 ; WX 667 ; N Z ; B 24 -3 627 681 ; +C 91 ; WX 333 ; N bracketleft ; B 73 -104 291 720 ; +C 92 ; WX 606 ; N backslash ; B 72 0 534 720 ; +C 93 ; WX 333 ; N bracketright ; B 42 -104 260 720 ; +C 94 ; WX 606 ; N asciicircum ; B 52 275 554 678 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 29 405 249 695 ; +C 97 ; WX 500 ; N a ; B 40 -17 478 471 ; +C 98 ; WX 611 ; N b ; B 10 -17 556 720 ; +C 99 ; WX 444 ; N c ; B 37 -17 414 471 ; +C 100 ; WX 611 ; N d ; B 42 -17 577 720 ; +C 101 ; WX 500 ; N e ; B 42 -17 461 471 ; +C 102 ; WX 389 ; N f ; B 34 -3 381 720 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 26 -266 535 471 ; +C 104 ; WX 611 ; N h ; B 24 -3 587 720 ; +C 105 ; WX 333 ; N i ; B 34 -3 298 706 ; +C 106 ; WX 333 ; N j ; B 3 -266 241 706 ; +C 107 ; WX 611 ; N k ; B 21 -3 597 720 ; +C 108 ; WX 333 ; N l ; B 24 -3 296 720 ; +C 109 ; WX 889 ; N m ; B 24 -3 864 471 ; +C 110 ; WX 611 ; N n ; B 24 -3 587 471 ; +C 111 ; WX 556 ; N o ; B 40 -17 517 471 ; +C 112 ; WX 611 ; N p ; B 29 -258 567 471 ; +C 113 ; WX 611 ; N q ; B 52 -258 589 471 ; +C 114 ; WX 389 ; N r ; B 30 -3 389 471 ; +C 115 ; WX 444 ; N s ; B 39 -17 405 471 ; +C 116 ; WX 333 ; N t ; B 22 -17 324 632 ; +C 117 ; WX 611 ; N u ; B 25 -17 583 471 ; +C 118 ; WX 556 ; N v ; B 11 -3 545 459 ; +C 119 ; WX 833 ; N w ; B 13 -3 820 471 ; +C 120 ; WX 500 ; N x ; B 20 -3 483 471 ; +C 121 ; WX 556 ; N y ; B 10 -266 546 459 ; +C 122 ; WX 500 ; N z ; B 16 -3 464 459 ; +C 123 ; WX 310 ; N braceleft ; B 5 -117 288 725 ; +C 124 ; WX 606 ; N bar ; B 260 0 346 720 ; +C 125 ; WX 310 ; N braceright ; B 22 -117 305 725 ; +C 126 ; WX 606 ; N asciitilde ; B 51 155 555 342 ; +C 161 ; WX 278 ; N exclamdown ; B 59 -227 215 471 ; +C 162 ; WX 500 ; N cent ; B 73 -106 450 554 ; +C 163 ; WX 500 ; N sterling ; B -2 -19 501 676 ; +C 164 ; WX 167 ; N fraction ; B -152 0 320 660 ; +C 165 ; WX 500 ; N yen ; B 17 -3 483 695 ; +C 166 ; WX 500 ; N florin ; B 11 -242 490 703 ; +C 167 ; WX 500 ; N section ; B 30 -217 471 695 ; +C 168 ; WX 500 ; N currency ; B 32 96 468 533 ; +C 169 ; WX 227 ; N quotesingle ; B 45 376 181 695 ; +C 170 ; WX 500 ; N quotedblleft ; B 34 405 466 695 ; +C 171 ; WX 500 ; N guillemotleft ; B 36 44 463 438 ; +C 172 ; WX 389 ; N guilsinglleft ; B 82 44 307 438 ; +C 173 ; WX 389 ; N guilsinglright ; B 82 44 307 438 ; +C 174 ; WX 611 ; N fi ; B 10 -3 595 720 ; +C 175 ; WX 611 ; N fl ; B 17 -3 593 720 ; +C 177 ; WX 500 ; N endash ; B 0 208 500 291 ; +C 178 ; WX 500 ; N dagger ; B 29 -6 472 682 ; +C 179 ; WX 500 ; N daggerdbl ; B 32 -245 468 682 ; +C 180 ; WX 250 ; N periodcentered ; B 47 179 203 335 ; +C 182 ; WX 641 ; N paragraph ; B 19 -161 599 683 ; +C 183 ; WX 606 ; N bullet ; B 131 172 475 516 ; +C 184 ; WX 333 ; N quotesinglbase ; B 56 -160 276 130 ; +C 185 ; WX 500 ; N quotedblbase ; B 34 -160 466 130 ; +C 186 ; WX 500 ; N quotedblright ; B 34 405 466 695 ; +C 187 ; WX 500 ; N guillemotright ; B 37 44 464 438 ; +C 188 ; WX 1000 ; N ellipsis ; B 89 -12 911 144 ; +C 189 ; WX 1000 ; N perthousand ; B 33 -9 982 724 ; +C 191 ; WX 444 ; N questiondown ; B 33 -231 401 471 ; +C 193 ; WX 333 ; N grave ; B 18 506 256 691 ; +C 194 ; WX 333 ; N acute ; B 78 506 316 691 ; +C 195 ; WX 333 ; N circumflex ; B -2 506 335 681 ; +C 196 ; WX 333 ; N tilde ; B -16 535 349 661 ; +C 197 ; WX 333 ; N macron ; B 1 538 332 609 ; +C 198 ; WX 333 ; N breve ; B 15 506 318 669 ; +C 199 ; WX 333 ; N dotaccent ; B 100 537 234 671 ; +C 200 ; WX 333 ; N dieresis ; B -8 537 341 671 ; +C 202 ; WX 333 ; N ring ; B 67 500 267 700 ; +C 203 ; WX 333 ; N cedilla ; B 73 -225 300 -7 ; +C 205 ; WX 333 ; N hungarumlaut ; B -56 506 390 691 ; +C 206 ; WX 333 ; N ogonek ; B 60 -246 274 -17 ; +C 207 ; WX 333 ; N caron ; B -2 510 335 685 ; +C 208 ; WX 1000 ; N emdash ; B 0 208 1000 291 ; +C 225 ; WX 1000 ; N AE ; B 12 -4 954 681 ; +C 227 ; WX 438 ; N ordfeminine ; B 77 367 361 660 ; +C 232 ; WX 611 ; N Lslash ; B 16 -4 577 681 ; +C 233 ; WX 833 ; N Oslash ; B 32 -20 808 698 ; +C 234 ; WX 1000 ; N OE ; B 43 -17 985 695 ; +C 235 ; WX 488 ; N ordmasculine ; B 89 367 399 660 ; +C 241 ; WX 778 ; N ae ; B 46 -17 731 471 ; +C 245 ; WX 333 ; N dotlessi ; B 34 -3 298 471 ; +C 248 ; WX 333 ; N lslash ; B -4 -3 334 720 ; +C 249 ; WX 556 ; N oslash ; B 23 -18 534 471 ; +C 250 ; WX 833 ; N oe ; B 48 -17 799 471 ; +C 251 ; WX 611 ; N germandbls ; B 30 -17 565 720 ; +C -1 ; WX 667 ; N Zcaron ; B 24 -3 627 909 ; +C -1 ; WX 444 ; N ccedilla ; B 37 -225 414 471 ; +C -1 ; WX 556 ; N ydieresis ; B 10 -266 546 691 ; +C -1 ; WX 500 ; N atilde ; B 40 -17 478 673 ; +C -1 ; WX 333 ; N icircumflex ; B -2 -3 335 701 ; +C -1 ; WX 300 ; N threesuperior ; B 9 261 292 667 ; +C -1 ; WX 500 ; N ecircumflex ; B 42 -17 461 701 ; +C -1 ; WX 611 ; N thorn ; B 17 -258 563 720 ; +C -1 ; WX 500 ; N egrave ; B 42 -17 461 711 ; +C -1 ; WX 300 ; N twosuperior ; B 5 261 295 660 ; +C -1 ; WX 500 ; N eacute ; B 42 -17 461 711 ; +C -1 ; WX 556 ; N otilde ; B 40 -17 517 673 ; +C -1 ; WX 778 ; N Aacute ; B 24 -3 757 915 ; +C -1 ; WX 556 ; N ocircumflex ; B 40 -17 517 701 ; +C -1 ; WX 556 ; N yacute ; B 10 -266 546 711 ; +C -1 ; WX 611 ; N udieresis ; B 25 -17 583 691 ; +C -1 ; WX 750 ; N threequarters ; B 15 -2 735 667 ; +C -1 ; WX 500 ; N acircumflex ; B 40 -17 478 701 ; +C -1 ; WX 833 ; N Eth ; B 10 -3 786 681 ; +C -1 ; WX 500 ; N edieresis ; B 42 -17 461 691 ; +C -1 ; WX 611 ; N ugrave ; B 25 -17 583 711 ; +C -1 ; WX 998 ; N trademark ; B 38 274 961 678 ; +C -1 ; WX 556 ; N ograve ; B 40 -17 517 711 ; +C -1 ; WX 444 ; N scaron ; B 39 -17 405 693 ; +C -1 ; WX 389 ; N Idieresis ; B 20 -3 369 895 ; +C -1 ; WX 611 ; N uacute ; B 25 -17 583 711 ; +C -1 ; WX 500 ; N agrave ; B 40 -17 478 711 ; +C -1 ; WX 611 ; N ntilde ; B 24 -3 587 673 ; +C -1 ; WX 500 ; N aring ; B 40 -17 478 700 ; +C -1 ; WX 500 ; N zcaron ; B 16 -3 464 693 ; +C -1 ; WX 389 ; N Icircumflex ; B 26 -3 363 905 ; +C -1 ; WX 833 ; N Ntilde ; B 35 -16 798 885 ; +C -1 ; WX 611 ; N ucircumflex ; B 25 -17 583 701 ; +C -1 ; WX 611 ; N Ecircumflex ; B 39 -4 577 905 ; +C -1 ; WX 389 ; N Iacute ; B 39 -3 350 915 ; +C -1 ; WX 722 ; N Ccedilla ; B 44 -225 695 695 ; +C -1 ; WX 833 ; N Odieresis ; B 47 -17 787 895 ; +C -1 ; WX 611 ; N Scaron ; B 57 -17 559 909 ; +C -1 ; WX 611 ; N Edieresis ; B 39 -4 577 895 ; +C -1 ; WX 389 ; N Igrave ; B 39 -3 350 915 ; +C -1 ; WX 500 ; N adieresis ; B 40 -17 478 691 ; +C -1 ; WX 833 ; N Ograve ; B 47 -17 787 915 ; +C -1 ; WX 611 ; N Egrave ; B 39 -4 577 915 ; +C -1 ; WX 667 ; N Ydieresis ; B 15 -3 660 895 ; +C -1 ; WX 747 ; N registered ; B 26 -17 720 695 ; +C -1 ; WX 833 ; N Otilde ; B 47 -17 787 885 ; +C -1 ; WX 750 ; N onequarter ; B 19 -2 735 665 ; +C -1 ; WX 778 ; N Ugrave ; B 26 -17 760 915 ; +C -1 ; WX 778 ; N Ucircumflex ; B 26 -17 760 905 ; +C -1 ; WX 611 ; N Thorn ; B 39 -3 574 681 ; +C -1 ; WX 606 ; N divide ; B 51 0 555 510 ; +C -1 ; WX 778 ; N Atilde ; B 24 -3 757 885 ; +C -1 ; WX 778 ; N Uacute ; B 26 -17 760 915 ; +C -1 ; WX 833 ; N Ocircumflex ; B 47 -17 787 905 ; +C -1 ; WX 606 ; N logicalnot ; B 51 114 555 396 ; +C -1 ; WX 778 ; N Aring ; B 24 -3 757 924 ; +C -1 ; WX 333 ; N idieresis ; B -8 -3 341 691 ; +C -1 ; WX 333 ; N iacute ; B 34 -3 316 711 ; +C -1 ; WX 500 ; N aacute ; B 40 -17 478 711 ; +C -1 ; WX 606 ; N plusminus ; B 51 0 555 505 ; +C -1 ; WX 606 ; N multiply ; B 72 21 534 483 ; +C -1 ; WX 778 ; N Udieresis ; B 26 -17 760 895 ; +C -1 ; WX 606 ; N minus ; B 51 212 555 298 ; +C -1 ; WX 300 ; N onesuperior ; B 14 261 287 665 ; +C -1 ; WX 611 ; N Eacute ; B 39 -4 577 915 ; +C -1 ; WX 778 ; N Acircumflex ; B 24 -3 757 905 ; +C -1 ; WX 747 ; N copyright ; B 26 -17 720 695 ; +C -1 ; WX 778 ; N Agrave ; B 24 -3 757 915 ; +C -1 ; WX 556 ; N odieresis ; B 40 -17 517 691 ; +C -1 ; WX 556 ; N oacute ; B 40 -17 517 711 ; +C -1 ; WX 400 ; N degree ; B 50 360 350 660 ; +C -1 ; WX 333 ; N igrave ; B 18 -3 298 711 ; +C -1 ; WX 611 ; N mu ; B 25 -225 583 471 ; +C -1 ; WX 833 ; N Oacute ; B 47 -17 787 915 ; +C -1 ; WX 556 ; N eth ; B 40 -17 517 720 ; +C -1 ; WX 778 ; N Adieresis ; B 24 -3 757 895 ; +C -1 ; WX 667 ; N Yacute ; B 15 -3 660 915 ; +C -1 ; WX 606 ; N brokenbar ; B 260 0 346 720 ; +C -1 ; WX 750 ; N onehalf ; B 9 -2 745 665 ; +EndCharMetrics +StartKernData +StartKernPairs 101 + +KPX A y -70 +KPX A w -70 +KPX A v -70 +KPX A space -18 +KPX A quoteright -92 +KPX A Y -111 +KPX A W -90 +KPX A V -129 +KPX A T -92 + +KPX F period -111 +KPX F comma -111 +KPX F A -55 + +KPX L y -74 +KPX L space -18 +KPX L quoteright -74 +KPX L Y -92 +KPX L W -92 +KPX L V -92 +KPX L T -74 + +KPX P period -129 +KPX P comma -129 +KPX P A -74 + +KPX R y -30 +KPX R Y -55 +KPX R W -37 +KPX R V -74 +KPX R T -55 + +KPX T y -90 +KPX T w -90 +KPX T u -129 +KPX T semicolon -74 +KPX T s -111 +KPX T r -111 +KPX T period -92 +KPX T o -111 +KPX T i -55 +KPX T hyphen -92 +KPX T e -111 +KPX T comma -92 +KPX T colon -74 +KPX T c -129 +KPX T a -111 +KPX T A -92 + +KPX V y -90 +KPX V u -92 +KPX V semicolon -74 +KPX V r -111 +KPX V period -129 +KPX V o -111 +KPX V i -55 +KPX V hyphen -92 +KPX V e -111 +KPX V comma -129 +KPX V colon -74 +KPX V a -111 +KPX V A -129 + +KPX W y -74 +KPX W u -74 +KPX W semicolon -37 +KPX W r -74 +KPX W period -37 +KPX W o -74 +KPX W i -37 +KPX W hyphen -37 +KPX W e -74 +KPX W comma -92 +KPX W colon -37 +KPX W a -74 +KPX W A -90 + +KPX Y v -74 +KPX Y u -74 +KPX Y semicolon -55 +KPX Y q -92 +KPX Y period -74 +KPX Y p -74 +KPX Y o -74 +KPX Y i -55 +KPX Y hyphen -74 +KPX Y e -74 +KPX Y comma -74 +KPX Y colon -55 +KPX Y a -74 +KPX Y A -55 + +KPX f quoteright 37 +KPX f f -18 + +KPX one one -37 + +KPX quoteleft quoteleft -55 + +KPX quoteright t -18 +KPX quoteright space -55 +KPX quoteright s -55 +KPX quoteright quoteright -55 + +KPX r quoteright 55 +KPX r period -55 +KPX r hyphen -18 +KPX r comma -55 + +KPX v period -111 +KPX v comma -111 + +KPX w period -92 +KPX w comma -92 + +KPX y period -92 +KPX y comma -92 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 223 224 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 211 224 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 223 224 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 215 224 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 223 224 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 223 224 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 195 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 224 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 224 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 224 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 224 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 28 224 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 28 224 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 28 224 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 28 224 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 250 224 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 250 224 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 250 224 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 250 224 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 250 224 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 250 224 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 139 224 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 235 224 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 235 224 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 235 224 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 223 224 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 211 224 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 199 224 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 167 224 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 84 20 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 84 20 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 84 20 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 84 20 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 84 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 84 12 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 84 20 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 96 20 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 92 20 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 84 20 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 20 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex 0 20 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis 0 20 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 20 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 139 12 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 112 20 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 112 20 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 112 20 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 112 20 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 112 12 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 56 8 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 151 20 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 139 20 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 139 20 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 131 20 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 144 20 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 124 20 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 8 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplbi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplbi8a.afm new file mode 100644 index 00000000..e161d049 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplbi8a.afm @@ -0,0 +1,441 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jul 2 22:48:39 1990 +Comment UniqueID 31799 +Comment VMusage 37656 48548 +FontName Palatino-BoldItalic +FullName Palatino Bold Italic +FamilyName Palatino +Weight Bold +ItalicAngle -10 +IsFixedPitch false +FontBBox -170 -271 1073 926 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.005 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Palatino is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 681 +XHeight 469 +Ascender 726 +Descender -271 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 58 -17 322 695 ; +C 34 ; WX 500 ; N quotedbl ; B 137 467 493 720 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 496 673 ; +C 36 ; WX 500 ; N dollar ; B 20 -108 477 737 ; +C 37 ; WX 889 ; N percent ; B 56 -17 790 697 ; +C 38 ; WX 833 ; N ampersand ; B 74 -17 811 695 ; +C 39 ; WX 278 ; N quoteright ; B 76 431 302 720 ; +C 40 ; WX 333 ; N parenleft ; B 58 -129 368 723 ; +C 41 ; WX 333 ; N parenright ; B -12 -129 298 723 ; +C 42 ; WX 444 ; N asterisk ; B 84 332 439 695 ; +C 43 ; WX 606 ; N plus ; B 50 -5 556 501 ; +C 44 ; WX 250 ; N comma ; B -33 -164 208 147 ; +C 45 ; WX 389 ; N hyphen ; B 37 198 362 300 ; +C 46 ; WX 250 ; N period ; B 48 -17 187 135 ; +C 47 ; WX 315 ; N slash ; B 1 -17 315 720 ; +C 48 ; WX 500 ; N zero ; B 42 -17 490 683 ; +C 49 ; WX 500 ; N one ; B 41 -3 434 678 ; +C 50 ; WX 500 ; N two ; B 1 -3 454 683 ; +C 51 ; WX 500 ; N three ; B 8 -17 450 683 ; +C 52 ; WX 500 ; N four ; B 3 -3 487 683 ; +C 53 ; WX 500 ; N five ; B 14 -17 481 675 ; +C 54 ; WX 500 ; N six ; B 39 -17 488 683 ; +C 55 ; WX 500 ; N seven ; B 69 -3 544 674 ; +C 56 ; WX 500 ; N eight ; B 26 -17 484 683 ; +C 57 ; WX 500 ; N nine ; B 27 -17 491 683 ; +C 58 ; WX 250 ; N colon ; B 38 -17 236 452 ; +C 59 ; WX 250 ; N semicolon ; B -33 -164 247 452 ; +C 60 ; WX 606 ; N less ; B 49 -21 558 517 ; +C 61 ; WX 606 ; N equal ; B 51 106 555 390 ; +C 62 ; WX 606 ; N greater ; B 48 -21 557 517 ; +C 63 ; WX 444 ; N question ; B 91 -17 450 695 ; +C 64 ; WX 833 ; N at ; B 82 -12 744 681 ; +C 65 ; WX 722 ; N A ; B -35 -3 685 683 ; +C 66 ; WX 667 ; N B ; B 8 -3 629 681 ; +C 67 ; WX 685 ; N C ; B 69 -17 695 695 ; +C 68 ; WX 778 ; N D ; B 0 -3 747 682 ; +C 69 ; WX 611 ; N E ; B 11 -3 606 681 ; +C 70 ; WX 556 ; N F ; B -6 -3 593 681 ; +C 71 ; WX 778 ; N G ; B 72 -17 750 695 ; +C 72 ; WX 778 ; N H ; B -12 -3 826 681 ; +C 73 ; WX 389 ; N I ; B -1 -3 412 681 ; +C 74 ; WX 389 ; N J ; B -29 -207 417 681 ; +C 75 ; WX 722 ; N K ; B -10 -3 746 681 ; +C 76 ; WX 611 ; N L ; B 26 -3 578 681 ; +C 77 ; WX 944 ; N M ; B -23 -17 985 681 ; +C 78 ; WX 778 ; N N ; B -2 -3 829 681 ; +C 79 ; WX 833 ; N O ; B 76 -17 794 695 ; +C 80 ; WX 667 ; N P ; B 11 -3 673 681 ; +C 81 ; WX 833 ; N Q ; B 76 -222 794 695 ; +C 82 ; WX 722 ; N R ; B 4 -3 697 681 ; +C 83 ; WX 556 ; N S ; B 50 -17 517 695 ; +C 84 ; WX 611 ; N T ; B 56 -3 674 681 ; +C 85 ; WX 778 ; N U ; B 83 -17 825 681 ; +C 86 ; WX 667 ; N V ; B 67 -3 745 681 ; +C 87 ; WX 1000 ; N W ; B 67 -3 1073 689 ; +C 88 ; WX 722 ; N X ; B -9 -3 772 681 ; +C 89 ; WX 611 ; N Y ; B 54 -3 675 695 ; +C 90 ; WX 667 ; N Z ; B 1 -3 676 681 ; +C 91 ; WX 333 ; N bracketleft ; B 45 -102 381 723 ; +C 92 ; WX 606 ; N backslash ; B 72 0 534 720 ; +C 93 ; WX 333 ; N bracketright ; B -21 -102 315 723 ; +C 94 ; WX 606 ; N asciicircum ; B 63 275 543 678 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 65 431 291 720 ; +C 97 ; WX 556 ; N a ; B 44 -17 519 470 ; +C 98 ; WX 537 ; N b ; B 44 -17 494 726 ; +C 99 ; WX 444 ; N c ; B 32 -17 436 469 ; +C 100 ; WX 556 ; N d ; B 38 -17 550 726 ; +C 101 ; WX 444 ; N e ; B 28 -17 418 469 ; +C 102 ; WX 333 ; N f ; B -130 -271 449 726 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B -50 -271 529 469 ; +C 104 ; WX 556 ; N h ; B 22 -17 522 726 ; +C 105 ; WX 333 ; N i ; B 26 -17 312 695 ; +C 106 ; WX 333 ; N j ; B -64 -271 323 695 ; +C 107 ; WX 556 ; N k ; B 34 -17 528 726 ; +C 108 ; WX 333 ; N l ; B 64 -17 318 726 ; +C 109 ; WX 833 ; N m ; B 19 -17 803 469 ; +C 110 ; WX 556 ; N n ; B 17 -17 521 469 ; +C 111 ; WX 556 ; N o ; B 48 -17 502 469 ; +C 112 ; WX 556 ; N p ; B -21 -271 516 469 ; +C 113 ; WX 537 ; N q ; B 32 -271 513 469 ; +C 114 ; WX 389 ; N r ; B 20 -17 411 469 ; +C 115 ; WX 444 ; N s ; B 25 -17 406 469 ; +C 116 ; WX 389 ; N t ; B 42 -17 409 636 ; +C 117 ; WX 556 ; N u ; B 22 -17 521 469 ; +C 118 ; WX 556 ; N v ; B 19 -17 513 469 ; +C 119 ; WX 833 ; N w ; B 27 -17 802 469 ; +C 120 ; WX 500 ; N x ; B -8 -17 500 469 ; +C 121 ; WX 556 ; N y ; B 13 -271 541 469 ; +C 122 ; WX 500 ; N z ; B 31 -17 470 469 ; +C 123 ; WX 333 ; N braceleft ; B 18 -105 334 720 ; +C 124 ; WX 606 ; N bar ; B 259 0 347 720 ; +C 125 ; WX 333 ; N braceright ; B -1 -105 315 720 ; +C 126 ; WX 606 ; N asciitilde ; B 51 151 555 346 ; +C 161 ; WX 333 ; N exclamdown ; B 2 -225 259 479 ; +C 162 ; WX 500 ; N cent ; B 52 -105 456 547 ; +C 163 ; WX 500 ; N sterling ; B 21 -5 501 683 ; +C 164 ; WX 167 ; N fraction ; B -170 0 338 683 ; +C 165 ; WX 500 ; N yen ; B 11 -3 538 695 ; +C 166 ; WX 500 ; N florin ; B 8 -242 479 690 ; +C 167 ; WX 556 ; N section ; B 47 -151 497 695 ; +C 168 ; WX 500 ; N currency ; B 32 96 468 533 ; +C 169 ; WX 250 ; N quotesingle ; B 127 467 293 720 ; +C 170 ; WX 500 ; N quotedblleft ; B 65 431 511 720 ; +C 171 ; WX 500 ; N guillemotleft ; B 35 43 458 446 ; +C 172 ; WX 333 ; N guilsinglleft ; B 60 43 292 446 ; +C 173 ; WX 333 ; N guilsinglright ; B 35 40 267 443 ; +C 174 ; WX 611 ; N fi ; B -130 -271 588 726 ; +C 175 ; WX 611 ; N fl ; B -130 -271 631 726 ; +C 177 ; WX 500 ; N endash ; B -12 214 512 282 ; +C 178 ; WX 556 ; N dagger ; B 67 -3 499 685 ; +C 179 ; WX 556 ; N daggerdbl ; B 33 -153 537 693 ; +C 180 ; WX 250 ; N periodcentered ; B 67 172 206 324 ; +C 182 ; WX 556 ; N paragraph ; B 14 -204 629 681 ; +C 183 ; WX 606 ; N bullet ; B 131 172 475 516 ; +C 184 ; WX 250 ; N quotesinglbase ; B -3 -144 220 145 ; +C 185 ; WX 500 ; N quotedblbase ; B -18 -144 424 145 ; +C 186 ; WX 500 ; N quotedblright ; B 73 431 519 720 ; +C 187 ; WX 500 ; N guillemotright ; B 35 40 458 443 ; +C 188 ; WX 1000 ; N ellipsis ; B 91 -17 896 135 ; +C 189 ; WX 1000 ; N perthousand ; B 65 -17 912 691 ; +C 191 ; WX 444 ; N questiondown ; B -12 -226 347 479 ; +C 193 ; WX 333 ; N grave ; B 110 518 322 699 ; +C 194 ; WX 333 ; N acute ; B 153 518 392 699 ; +C 195 ; WX 333 ; N circumflex ; B 88 510 415 684 ; +C 196 ; WX 333 ; N tilde ; B 82 535 441 654 ; +C 197 ; WX 333 ; N macron ; B 76 538 418 608 ; +C 198 ; WX 333 ; N breve ; B 96 518 412 680 ; +C 199 ; WX 333 ; N dotaccent ; B 202 537 325 668 ; +C 200 ; WX 333 ; N dieresis ; B 90 537 426 668 ; +C 202 ; WX 556 ; N ring ; B 277 514 477 714 ; +C 203 ; WX 333 ; N cedilla ; B 12 -218 248 5 ; +C 205 ; WX 333 ; N hungarumlaut ; B -28 518 409 699 ; +C 206 ; WX 333 ; N ogonek ; B 32 -206 238 -17 ; +C 207 ; WX 333 ; N caron ; B 113 510 445 684 ; +C 208 ; WX 1000 ; N emdash ; B -12 214 1012 282 ; +C 225 ; WX 944 ; N AE ; B -29 -3 927 681 ; +C 227 ; WX 333 ; N ordfeminine ; B 47 391 355 684 ; +C 232 ; WX 611 ; N Lslash ; B 6 -3 578 681 ; +C 233 ; WX 833 ; N Oslash ; B 57 -54 797 730 ; +C 234 ; WX 944 ; N OE ; B 39 -17 961 695 ; +C 235 ; WX 333 ; N ordmasculine ; B 51 391 346 683 ; +C 241 ; WX 738 ; N ae ; B 44 -17 711 469 ; +C 245 ; WX 333 ; N dotlessi ; B 26 -17 293 469 ; +C 248 ; WX 333 ; N lslash ; B 13 -17 365 726 ; +C 249 ; WX 556 ; N oslash ; B 14 -50 522 506 ; +C 250 ; WX 778 ; N oe ; B 48 -17 755 469 ; +C 251 ; WX 556 ; N germandbls ; B -131 -271 549 726 ; +C -1 ; WX 667 ; N Zcaron ; B 1 -3 676 896 ; +C -1 ; WX 444 ; N ccedilla ; B 32 -218 436 469 ; +C -1 ; WX 556 ; N ydieresis ; B 13 -271 541 688 ; +C -1 ; WX 556 ; N atilde ; B 44 -17 553 666 ; +C -1 ; WX 333 ; N icircumflex ; B 26 -17 403 704 ; +C -1 ; WX 300 ; N threesuperior ; B 23 263 310 683 ; +C -1 ; WX 444 ; N ecircumflex ; B 28 -17 471 704 ; +C -1 ; WX 556 ; N thorn ; B -21 -271 516 726 ; +C -1 ; WX 444 ; N egrave ; B 28 -17 418 719 ; +C -1 ; WX 300 ; N twosuperior ; B 26 271 321 683 ; +C -1 ; WX 444 ; N eacute ; B 28 -17 448 719 ; +C -1 ; WX 556 ; N otilde ; B 48 -17 553 666 ; +C -1 ; WX 722 ; N Aacute ; B -35 -3 685 911 ; +C -1 ; WX 556 ; N ocircumflex ; B 48 -17 515 704 ; +C -1 ; WX 556 ; N yacute ; B 13 -271 541 719 ; +C -1 ; WX 556 ; N udieresis ; B 22 -17 538 688 ; +C -1 ; WX 750 ; N threequarters ; B 18 -2 732 683 ; +C -1 ; WX 556 ; N acircumflex ; B 44 -17 527 704 ; +C -1 ; WX 778 ; N Eth ; B 0 -3 747 682 ; +C -1 ; WX 444 ; N edieresis ; B 28 -17 482 688 ; +C -1 ; WX 556 ; N ugrave ; B 22 -17 521 719 ; +C -1 ; WX 1000 ; N trademark ; B 38 274 961 678 ; +C -1 ; WX 556 ; N ograve ; B 48 -17 502 719 ; +C -1 ; WX 444 ; N scaron ; B 25 -17 489 692 ; +C -1 ; WX 389 ; N Idieresis ; B -1 -3 454 880 ; +C -1 ; WX 556 ; N uacute ; B 22 -17 521 719 ; +C -1 ; WX 556 ; N agrave ; B 44 -17 519 719 ; +C -1 ; WX 556 ; N ntilde ; B 17 -17 553 666 ; +C -1 ; WX 556 ; N aring ; B 44 -17 519 714 ; +C -1 ; WX 500 ; N zcaron ; B 31 -17 517 692 ; +C -1 ; WX 389 ; N Icircumflex ; B -1 -3 443 896 ; +C -1 ; WX 778 ; N Ntilde ; B -2 -3 829 866 ; +C -1 ; WX 556 ; N ucircumflex ; B 22 -17 521 704 ; +C -1 ; WX 611 ; N Ecircumflex ; B 11 -3 606 896 ; +C -1 ; WX 389 ; N Iacute ; B -1 -3 420 911 ; +C -1 ; WX 685 ; N Ccedilla ; B 69 -218 695 695 ; +C -1 ; WX 833 ; N Odieresis ; B 76 -17 794 880 ; +C -1 ; WX 556 ; N Scaron ; B 50 -17 557 896 ; +C -1 ; WX 611 ; N Edieresis ; B 11 -3 606 880 ; +C -1 ; WX 389 ; N Igrave ; B -1 -3 412 911 ; +C -1 ; WX 556 ; N adieresis ; B 44 -17 538 688 ; +C -1 ; WX 833 ; N Ograve ; B 76 -17 794 911 ; +C -1 ; WX 611 ; N Egrave ; B 11 -3 606 911 ; +C -1 ; WX 611 ; N Ydieresis ; B 54 -3 675 880 ; +C -1 ; WX 747 ; N registered ; B 26 -17 720 695 ; +C -1 ; WX 833 ; N Otilde ; B 76 -17 794 866 ; +C -1 ; WX 750 ; N onequarter ; B 18 -2 732 683 ; +C -1 ; WX 778 ; N Ugrave ; B 83 -17 825 911 ; +C -1 ; WX 778 ; N Ucircumflex ; B 83 -17 825 896 ; +C -1 ; WX 667 ; N Thorn ; B 11 -3 644 681 ; +C -1 ; WX 606 ; N divide ; B 50 -5 556 501 ; +C -1 ; WX 722 ; N Atilde ; B -35 -3 685 866 ; +C -1 ; WX 778 ; N Uacute ; B 83 -17 825 911 ; +C -1 ; WX 833 ; N Ocircumflex ; B 76 -17 794 896 ; +C -1 ; WX 606 ; N logicalnot ; B 51 107 555 390 ; +C -1 ; WX 722 ; N Aring ; B -35 -3 685 926 ; +C -1 ; WX 333 ; N idieresis ; B 26 -17 426 688 ; +C -1 ; WX 333 ; N iacute ; B 26 -17 392 719 ; +C -1 ; WX 556 ; N aacute ; B 44 -17 519 719 ; +C -1 ; WX 606 ; N plusminus ; B 50 0 556 501 ; +C -1 ; WX 606 ; N multiply ; B 72 17 534 479 ; +C -1 ; WX 778 ; N Udieresis ; B 83 -17 825 880 ; +C -1 ; WX 606 ; N minus ; B 51 204 555 292 ; +C -1 ; WX 300 ; N onesuperior ; B 41 271 298 680 ; +C -1 ; WX 611 ; N Eacute ; B 11 -3 606 911 ; +C -1 ; WX 722 ; N Acircumflex ; B -35 -3 685 896 ; +C -1 ; WX 747 ; N copyright ; B 26 -17 720 695 ; +C -1 ; WX 722 ; N Agrave ; B -35 -3 685 911 ; +C -1 ; WX 556 ; N odieresis ; B 48 -17 538 688 ; +C -1 ; WX 556 ; N oacute ; B 48 -17 504 719 ; +C -1 ; WX 400 ; N degree ; B 50 383 350 683 ; +C -1 ; WX 333 ; N igrave ; B 26 -17 322 719 ; +C -1 ; WX 556 ; N mu ; B -15 -232 521 469 ; +C -1 ; WX 833 ; N Oacute ; B 76 -17 794 911 ; +C -1 ; WX 556 ; N eth ; B 48 -17 546 726 ; +C -1 ; WX 722 ; N Adieresis ; B -35 -3 685 880 ; +C -1 ; WX 611 ; N Yacute ; B 54 -3 675 911 ; +C -1 ; WX 606 ; N brokenbar ; B 259 0 347 720 ; +C -1 ; WX 750 ; N onehalf ; B 14 -2 736 683 ; +EndCharMetrics +StartKernData +StartKernPairs 108 + +KPX A y -55 +KPX A w -37 +KPX A v -55 +KPX A space -55 +KPX A quoteright -55 +KPX A Y -74 +KPX A W -74 +KPX A V -74 +KPX A T -55 + +KPX F space -18 +KPX F period -111 +KPX F comma -111 +KPX F A -74 + +KPX L y -37 +KPX L space -18 +KPX L quoteright -55 +KPX L Y -74 +KPX L W -74 +KPX L V -74 +KPX L T -74 + +KPX P space -55 +KPX P period -129 +KPX P comma -129 +KPX P A -92 + +KPX R y -20 +KPX R Y -37 +KPX R W -55 +KPX R V -55 +KPX R T -37 + +KPX T y -80 +KPX T w -50 +KPX T u -92 +KPX T semicolon -55 +KPX T s -92 +KPX T r -92 +KPX T period -55 +KPX T o -111 +KPX T i -74 +KPX T hyphen -92 +KPX T e -111 +KPX T comma -55 +KPX T colon -55 +KPX T c -92 +KPX T a -111 +KPX T O -18 +KPX T A -55 + +KPX V y -50 +KPX V u -50 +KPX V semicolon -37 +KPX V r -74 +KPX V period -111 +KPX V o -74 +KPX V i -50 +KPX V hyphen -37 +KPX V e -74 +KPX V comma -111 +KPX V colon -37 +KPX V a -92 +KPX V A -74 + +KPX W y -30 +KPX W u -30 +KPX W semicolon -18 +KPX W r -30 +KPX W period -55 +KPX W o -55 +KPX W i -30 +KPX W e -55 +KPX W comma -55 +KPX W colon -28 +KPX W a -74 +KPX W A -74 + +KPX Y v -30 +KPX Y u -50 +KPX Y semicolon -55 +KPX Y q -92 +KPX Y period -55 +KPX Y p -74 +KPX Y o -111 +KPX Y i -54 +KPX Y hyphen -55 +KPX Y e -92 +KPX Y comma -55 +KPX Y colon -55 +KPX Y a -111 +KPX Y A -55 + +KPX f quoteright 37 +KPX f f -37 + +KPX one one -55 + +KPX quoteleft quoteleft -55 + +KPX quoteright t -18 +KPX quoteright space -37 +KPX quoteright s -37 +KPX quoteright quoteright -55 + +KPX r quoteright 55 +KPX r q -18 +KPX r period -55 +KPX r o -18 +KPX r h -18 +KPX r g -18 +KPX r e -18 +KPX r comma -55 +KPX r c -18 + +KPX v period -55 +KPX v comma -55 + +KPX w period -55 +KPX w comma -55 + +KPX y period -37 +KPX y comma -37 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 195 212 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 195 212 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 195 212 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 195 212 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 83 212 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 195 212 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 176 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 212 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 212 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 212 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 212 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 28 212 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 28 212 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 28 212 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 28 212 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 223 212 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 250 212 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 250 212 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 250 212 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 250 212 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 250 212 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 112 212 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 223 212 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 223 212 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 223 212 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 211 212 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 151 212 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 139 212 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 167 212 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 112 20 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 112 20 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 112 20 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 112 20 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 0 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 112 12 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 56 20 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 56 20 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 56 20 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 56 20 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute 0 20 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -12 20 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis 0 20 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave 0 20 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 112 12 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 112 20 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 100 20 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 112 20 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 112 20 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 112 12 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 44 8 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 112 20 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 100 20 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 112 20 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 112 20 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 112 20 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 112 20 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 72 8 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplr8a.afm new file mode 100644 index 00000000..6566b16e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplr8a.afm @@ -0,0 +1,445 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jul 2 22:14:17 1990 +Comment UniqueID 31790 +Comment VMusage 36445 47337 +FontName Palatino-Roman +FullName Palatino Roman +FamilyName Palatino +Weight Roman +ItalicAngle 0 +IsFixedPitch false +FontBBox -166 -283 1021 927 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.005 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Palatino is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 469 +Ascender 726 +Descender -281 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 81 -5 197 694 ; +C 34 ; WX 371 ; N quotedbl ; B 52 469 319 709 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 495 684 ; +C 36 ; WX 500 ; N dollar ; B 30 -116 471 731 ; +C 37 ; WX 840 ; N percent ; B 39 -20 802 709 ; +C 38 ; WX 778 ; N ampersand ; B 43 -20 753 689 ; +C 39 ; WX 278 ; N quoteright ; B 45 446 233 709 ; +C 40 ; WX 333 ; N parenleft ; B 60 -215 301 726 ; +C 41 ; WX 333 ; N parenright ; B 32 -215 273 726 ; +C 42 ; WX 389 ; N asterisk ; B 32 342 359 689 ; +C 43 ; WX 606 ; N plus ; B 51 7 555 512 ; +C 44 ; WX 250 ; N comma ; B 16 -155 218 123 ; +C 45 ; WX 333 ; N hyphen ; B 17 215 312 287 ; +C 46 ; WX 250 ; N period ; B 67 -5 183 111 ; +C 47 ; WX 606 ; N slash ; B 87 -119 519 726 ; +C 48 ; WX 500 ; N zero ; B 29 -20 465 689 ; +C 49 ; WX 500 ; N one ; B 60 -3 418 694 ; +C 50 ; WX 500 ; N two ; B 16 -3 468 689 ; +C 51 ; WX 500 ; N three ; B 15 -20 462 689 ; +C 52 ; WX 500 ; N four ; B 2 -3 472 694 ; +C 53 ; WX 500 ; N five ; B 13 -20 459 689 ; +C 54 ; WX 500 ; N six ; B 32 -20 468 689 ; +C 55 ; WX 500 ; N seven ; B 44 -3 497 689 ; +C 56 ; WX 500 ; N eight ; B 30 -20 464 689 ; +C 57 ; WX 500 ; N nine ; B 20 -20 457 689 ; +C 58 ; WX 250 ; N colon ; B 66 -5 182 456 ; +C 59 ; WX 250 ; N semicolon ; B 16 -153 218 456 ; +C 60 ; WX 606 ; N less ; B 57 0 558 522 ; +C 61 ; WX 606 ; N equal ; B 51 136 555 386 ; +C 62 ; WX 606 ; N greater ; B 48 0 549 522 ; +C 63 ; WX 444 ; N question ; B 43 -5 395 694 ; +C 64 ; WX 747 ; N at ; B 24 -20 724 694 ; +C 65 ; WX 778 ; N A ; B 15 -3 756 700 ; +C 66 ; WX 611 ; N B ; B 26 -3 576 692 ; +C 67 ; WX 709 ; N C ; B 22 -20 670 709 ; +C 68 ; WX 774 ; N D ; B 22 -3 751 692 ; +C 69 ; WX 611 ; N E ; B 22 -3 572 692 ; +C 70 ; WX 556 ; N F ; B 22 -3 536 692 ; +C 71 ; WX 763 ; N G ; B 22 -20 728 709 ; +C 72 ; WX 832 ; N H ; B 22 -3 810 692 ; +C 73 ; WX 337 ; N I ; B 22 -3 315 692 ; +C 74 ; WX 333 ; N J ; B -15 -194 311 692 ; +C 75 ; WX 726 ; N K ; B 22 -3 719 692 ; +C 76 ; WX 611 ; N L ; B 22 -3 586 692 ; +C 77 ; WX 946 ; N M ; B 16 -13 926 692 ; +C 78 ; WX 831 ; N N ; B 17 -20 813 692 ; +C 79 ; WX 786 ; N O ; B 22 -20 764 709 ; +C 80 ; WX 604 ; N P ; B 22 -3 580 692 ; +C 81 ; WX 786 ; N Q ; B 22 -176 764 709 ; +C 82 ; WX 668 ; N R ; B 22 -3 669 692 ; +C 83 ; WX 525 ; N S ; B 24 -20 503 709 ; +C 84 ; WX 613 ; N T ; B 18 -3 595 692 ; +C 85 ; WX 778 ; N U ; B 12 -20 759 692 ; +C 86 ; WX 722 ; N V ; B 8 -9 706 692 ; +C 87 ; WX 1000 ; N W ; B 8 -9 984 700 ; +C 88 ; WX 667 ; N X ; B 14 -3 648 700 ; +C 89 ; WX 667 ; N Y ; B 9 -3 654 704 ; +C 90 ; WX 667 ; N Z ; B 15 -3 638 692 ; +C 91 ; WX 333 ; N bracketleft ; B 79 -184 288 726 ; +C 92 ; WX 606 ; N backslash ; B 81 0 512 726 ; +C 93 ; WX 333 ; N bracketright ; B 45 -184 254 726 ; +C 94 ; WX 606 ; N asciicircum ; B 51 283 554 689 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 45 446 233 709 ; +C 97 ; WX 500 ; N a ; B 32 -12 471 469 ; +C 98 ; WX 553 ; N b ; B -15 -12 508 726 ; +C 99 ; WX 444 ; N c ; B 26 -20 413 469 ; +C 100 ; WX 611 ; N d ; B 35 -12 579 726 ; +C 101 ; WX 479 ; N e ; B 26 -20 448 469 ; +C 102 ; WX 333 ; N f ; B 23 -3 341 728 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 32 -283 544 469 ; +C 104 ; WX 582 ; N h ; B 6 -3 572 726 ; +C 105 ; WX 291 ; N i ; B 21 -3 271 687 ; +C 106 ; WX 234 ; N j ; B -40 -283 167 688 ; +C 107 ; WX 556 ; N k ; B 21 -12 549 726 ; +C 108 ; WX 291 ; N l ; B 21 -3 271 726 ; +C 109 ; WX 883 ; N m ; B 16 -3 869 469 ; +C 110 ; WX 582 ; N n ; B 6 -3 572 469 ; +C 111 ; WX 546 ; N o ; B 32 -20 514 469 ; +C 112 ; WX 601 ; N p ; B 8 -281 554 469 ; +C 113 ; WX 560 ; N q ; B 35 -281 560 469 ; +C 114 ; WX 395 ; N r ; B 21 -3 374 469 ; +C 115 ; WX 424 ; N s ; B 30 -20 391 469 ; +C 116 ; WX 326 ; N t ; B 22 -12 319 621 ; +C 117 ; WX 603 ; N u ; B 18 -12 581 469 ; +C 118 ; WX 565 ; N v ; B 6 -7 539 459 ; +C 119 ; WX 834 ; N w ; B 6 -7 808 469 ; +C 120 ; WX 516 ; N x ; B 20 -3 496 469 ; +C 121 ; WX 556 ; N y ; B 12 -283 544 459 ; +C 122 ; WX 500 ; N z ; B 16 -3 466 462 ; +C 123 ; WX 333 ; N braceleft ; B 58 -175 289 726 ; +C 124 ; WX 606 ; N bar ; B 275 0 331 726 ; +C 125 ; WX 333 ; N braceright ; B 44 -175 275 726 ; +C 126 ; WX 606 ; N asciitilde ; B 51 176 555 347 ; +C 161 ; WX 278 ; N exclamdown ; B 81 -225 197 469 ; +C 162 ; WX 500 ; N cent ; B 61 -101 448 562 ; +C 163 ; WX 500 ; N sterling ; B 12 -13 478 694 ; +C 164 ; WX 167 ; N fraction ; B -166 0 337 689 ; +C 165 ; WX 500 ; N yen ; B 5 -3 496 701 ; +C 166 ; WX 500 ; N florin ; B 0 -262 473 706 ; +C 167 ; WX 500 ; N section ; B 26 -219 465 709 ; +C 168 ; WX 500 ; N currency ; B 30 96 470 531 ; +C 169 ; WX 208 ; N quotesingle ; B 61 469 147 709 ; +C 170 ; WX 500 ; N quotedblleft ; B 51 446 449 709 ; +C 171 ; WX 500 ; N guillemotleft ; B 50 71 450 428 ; +C 172 ; WX 331 ; N guilsinglleft ; B 66 71 265 428 ; +C 173 ; WX 331 ; N guilsinglright ; B 66 71 265 428 ; +C 174 ; WX 605 ; N fi ; B 23 -3 587 728 ; +C 175 ; WX 608 ; N fl ; B 23 -3 590 728 ; +C 177 ; WX 500 ; N endash ; B 0 219 500 277 ; +C 178 ; WX 500 ; N dagger ; B 34 -5 466 694 ; +C 179 ; WX 500 ; N daggerdbl ; B 34 -249 466 694 ; +C 180 ; WX 250 ; N periodcentered ; B 67 203 183 319 ; +C 182 ; WX 628 ; N paragraph ; B 39 -150 589 694 ; +C 183 ; WX 606 ; N bullet ; B 131 172 475 516 ; +C 184 ; WX 278 ; N quotesinglbase ; B 22 -153 210 110 ; +C 185 ; WX 500 ; N quotedblbase ; B 51 -153 449 110 ; +C 186 ; WX 500 ; N quotedblright ; B 51 446 449 709 ; +C 187 ; WX 500 ; N guillemotright ; B 50 71 450 428 ; +C 188 ; WX 1000 ; N ellipsis ; B 109 -5 891 111 ; +C 189 ; WX 1144 ; N perthousand ; B 123 -20 1021 709 ; +C 191 ; WX 444 ; N questiondown ; B 43 -231 395 469 ; +C 193 ; WX 333 ; N grave ; B 31 506 255 677 ; +C 194 ; WX 333 ; N acute ; B 78 506 302 677 ; +C 195 ; WX 333 ; N circumflex ; B 11 510 323 677 ; +C 196 ; WX 333 ; N tilde ; B 2 535 332 640 ; +C 197 ; WX 333 ; N macron ; B 11 538 323 591 ; +C 198 ; WX 333 ; N breve ; B 26 506 308 664 ; +C 199 ; WX 250 ; N dotaccent ; B 75 537 175 637 ; +C 200 ; WX 333 ; N dieresis ; B 17 537 316 637 ; +C 202 ; WX 333 ; N ring ; B 67 496 267 696 ; +C 203 ; WX 333 ; N cedilla ; B 96 -225 304 -10 ; +C 205 ; WX 380 ; N hungarumlaut ; B 3 506 377 687 ; +C 206 ; WX 313 ; N ogonek ; B 68 -165 245 -20 ; +C 207 ; WX 333 ; N caron ; B 11 510 323 677 ; +C 208 ; WX 1000 ; N emdash ; B 0 219 1000 277 ; +C 225 ; WX 944 ; N AE ; B -10 -3 908 692 ; +C 227 ; WX 333 ; N ordfeminine ; B 24 422 310 709 ; +C 232 ; WX 611 ; N Lslash ; B 6 -3 586 692 ; +C 233 ; WX 833 ; N Oslash ; B 30 -20 797 709 ; +C 234 ; WX 998 ; N OE ; B 22 -20 962 709 ; +C 235 ; WX 333 ; N ordmasculine ; B 10 416 323 709 ; +C 241 ; WX 758 ; N ae ; B 30 -20 732 469 ; +C 245 ; WX 287 ; N dotlessi ; B 21 -3 271 469 ; +C 248 ; WX 291 ; N lslash ; B -14 -3 306 726 ; +C 249 ; WX 556 ; N oslash ; B 16 -23 530 474 ; +C 250 ; WX 827 ; N oe ; B 32 -20 800 469 ; +C 251 ; WX 556 ; N germandbls ; B 23 -9 519 731 ; +C -1 ; WX 667 ; N Zcaron ; B 15 -3 638 908 ; +C -1 ; WX 444 ; N ccedilla ; B 26 -225 413 469 ; +C -1 ; WX 556 ; N ydieresis ; B 12 -283 544 657 ; +C -1 ; WX 500 ; N atilde ; B 32 -12 471 652 ; +C -1 ; WX 287 ; N icircumflex ; B -12 -3 300 697 ; +C -1 ; WX 300 ; N threesuperior ; B 1 266 299 689 ; +C -1 ; WX 479 ; N ecircumflex ; B 26 -20 448 697 ; +C -1 ; WX 601 ; N thorn ; B -2 -281 544 726 ; +C -1 ; WX 479 ; N egrave ; B 26 -20 448 697 ; +C -1 ; WX 300 ; N twosuperior ; B 0 273 301 689 ; +C -1 ; WX 479 ; N eacute ; B 26 -20 448 697 ; +C -1 ; WX 546 ; N otilde ; B 32 -20 514 652 ; +C -1 ; WX 778 ; N Aacute ; B 15 -3 756 908 ; +C -1 ; WX 546 ; N ocircumflex ; B 32 -20 514 697 ; +C -1 ; WX 556 ; N yacute ; B 12 -283 544 697 ; +C -1 ; WX 603 ; N udieresis ; B 18 -12 581 657 ; +C -1 ; WX 750 ; N threequarters ; B 15 -3 735 689 ; +C -1 ; WX 500 ; N acircumflex ; B 32 -12 471 697 ; +C -1 ; WX 774 ; N Eth ; B 14 -3 751 692 ; +C -1 ; WX 479 ; N edieresis ; B 26 -20 448 657 ; +C -1 ; WX 603 ; N ugrave ; B 18 -12 581 697 ; +C -1 ; WX 979 ; N trademark ; B 40 285 939 689 ; +C -1 ; WX 546 ; N ograve ; B 32 -20 514 697 ; +C -1 ; WX 424 ; N scaron ; B 30 -20 391 685 ; +C -1 ; WX 337 ; N Idieresis ; B 19 -3 318 868 ; +C -1 ; WX 603 ; N uacute ; B 18 -12 581 697 ; +C -1 ; WX 500 ; N agrave ; B 32 -12 471 697 ; +C -1 ; WX 582 ; N ntilde ; B 6 -3 572 652 ; +C -1 ; WX 500 ; N aring ; B 32 -12 471 716 ; +C -1 ; WX 500 ; N zcaron ; B 16 -3 466 685 ; +C -1 ; WX 337 ; N Icircumflex ; B 13 -3 325 908 ; +C -1 ; WX 831 ; N Ntilde ; B 17 -20 813 871 ; +C -1 ; WX 603 ; N ucircumflex ; B 18 -12 581 697 ; +C -1 ; WX 611 ; N Ecircumflex ; B 22 -3 572 908 ; +C -1 ; WX 337 ; N Iacute ; B 22 -3 315 908 ; +C -1 ; WX 709 ; N Ccedilla ; B 22 -225 670 709 ; +C -1 ; WX 786 ; N Odieresis ; B 22 -20 764 868 ; +C -1 ; WX 525 ; N Scaron ; B 24 -20 503 908 ; +C -1 ; WX 611 ; N Edieresis ; B 22 -3 572 868 ; +C -1 ; WX 337 ; N Igrave ; B 22 -3 315 908 ; +C -1 ; WX 500 ; N adieresis ; B 32 -12 471 657 ; +C -1 ; WX 786 ; N Ograve ; B 22 -20 764 908 ; +C -1 ; WX 611 ; N Egrave ; B 22 -3 572 908 ; +C -1 ; WX 667 ; N Ydieresis ; B 9 -3 654 868 ; +C -1 ; WX 747 ; N registered ; B 11 -18 736 706 ; +C -1 ; WX 786 ; N Otilde ; B 22 -20 764 883 ; +C -1 ; WX 750 ; N onequarter ; B 30 -3 727 692 ; +C -1 ; WX 778 ; N Ugrave ; B 12 -20 759 908 ; +C -1 ; WX 778 ; N Ucircumflex ; B 12 -20 759 908 ; +C -1 ; WX 604 ; N Thorn ; B 32 -3 574 692 ; +C -1 ; WX 606 ; N divide ; B 51 10 555 512 ; +C -1 ; WX 778 ; N Atilde ; B 15 -3 756 871 ; +C -1 ; WX 778 ; N Uacute ; B 12 -20 759 908 ; +C -1 ; WX 786 ; N Ocircumflex ; B 22 -20 764 908 ; +C -1 ; WX 606 ; N logicalnot ; B 51 120 551 386 ; +C -1 ; WX 778 ; N Aring ; B 15 -3 756 927 ; +C -1 ; WX 287 ; N idieresis ; B -6 -3 293 657 ; +C -1 ; WX 287 ; N iacute ; B 21 -3 279 697 ; +C -1 ; WX 500 ; N aacute ; B 32 -12 471 697 ; +C -1 ; WX 606 ; N plusminus ; B 51 0 555 512 ; +C -1 ; WX 606 ; N multiply ; B 83 36 523 474 ; +C -1 ; WX 778 ; N Udieresis ; B 12 -20 759 868 ; +C -1 ; WX 606 ; N minus ; B 51 233 555 289 ; +C -1 ; WX 300 ; N onesuperior ; B 31 273 269 692 ; +C -1 ; WX 611 ; N Eacute ; B 22 -3 572 908 ; +C -1 ; WX 778 ; N Acircumflex ; B 15 -3 756 908 ; +C -1 ; WX 747 ; N copyright ; B 11 -18 736 706 ; +C -1 ; WX 778 ; N Agrave ; B 15 -3 756 908 ; +C -1 ; WX 546 ; N odieresis ; B 32 -20 514 657 ; +C -1 ; WX 546 ; N oacute ; B 32 -20 514 697 ; +C -1 ; WX 400 ; N degree ; B 50 389 350 689 ; +C -1 ; WX 287 ; N igrave ; B 8 -3 271 697 ; +C -1 ; WX 603 ; N mu ; B 18 -236 581 469 ; +C -1 ; WX 786 ; N Oacute ; B 22 -20 764 908 ; +C -1 ; WX 546 ; N eth ; B 32 -20 504 728 ; +C -1 ; WX 778 ; N Adieresis ; B 15 -3 756 868 ; +C -1 ; WX 667 ; N Yacute ; B 9 -3 654 908 ; +C -1 ; WX 606 ; N brokenbar ; B 275 0 331 726 ; +C -1 ; WX 750 ; N onehalf ; B 15 -3 735 692 ; +EndCharMetrics +StartKernData +StartKernPairs 111 + +KPX A y -74 +KPX A w -74 +KPX A v -92 +KPX A space -55 +KPX A quoteright -74 +KPX A Y -111 +KPX A W -74 +KPX A V -111 +KPX A T -74 + +KPX F period -92 +KPX F comma -92 +KPX F A -74 + +KPX L y -55 +KPX L space -37 +KPX L quoteright -74 +KPX L Y -92 +KPX L W -74 +KPX L V -92 +KPX L T -74 + +KPX P space -18 +KPX P period -129 +KPX P comma -129 +KPX P A -92 + +KPX R y -37 +KPX R Y -37 +KPX R W -37 +KPX R V -55 +KPX R T -37 + +KPX T y -90 +KPX T w -90 +KPX T u -90 +KPX T semicolon -55 +KPX T s -90 +KPX T r -90 +KPX T period -74 +KPX T o -92 +KPX T i -55 +KPX T hyphen -55 +KPX T e -92 +KPX T comma -74 +KPX T colon -55 +KPX T c -111 +KPX T a -92 +KPX T O -18 +KPX T A -74 + +KPX V y -92 +KPX V u -92 +KPX V semicolon -55 +KPX V r -92 +KPX V period -129 +KPX V o -111 +KPX V i -55 +KPX V hyphen -74 +KPX V e -111 +KPX V comma -129 +KPX V colon -55 +KPX V a -92 +KPX V A -111 + +KPX W y -50 +KPX W u -50 +KPX W semicolon -18 +KPX W r -74 +KPX W period -92 +KPX W o -92 +KPX W i -55 +KPX W hyphen -55 +KPX W e -92 +KPX W comma -92 +KPX W colon -18 +KPX W a -92 +KPX W A -92 + +KPX Y v -90 +KPX Y u -90 +KPX Y space -18 +KPX Y semicolon -74 +KPX Y q -90 +KPX Y period -111 +KPX Y p -111 +KPX Y o -92 +KPX Y i -55 +KPX Y hyphen -92 +KPX Y e -92 +KPX Y comma -111 +KPX Y colon -74 +KPX Y a -92 +KPX Y A -92 + +KPX f quoteright 55 +KPX f f -18 + +KPX one one -55 + +KPX quoteleft quoteleft -37 + +KPX quoteright quoteright -37 + +KPX r u -8 +KPX r quoteright 74 +KPX r q -18 +KPX r period -74 +KPX r o -18 +KPX r hyphen -18 +KPX r h -18 +KPX r g -18 +KPX r e -18 +KPX r d -18 +KPX r comma -74 +KPX r c -18 + +KPX space Y -18 +KPX space A -37 + +KPX v period -111 +KPX v comma -111 + +KPX w period -92 +KPX w comma -92 + +KPX y period -111 +KPX y comma -111 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 229 231 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 223 231 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 223 231 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 215 231 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 223 231 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 223 231 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 188 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 231 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 231 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 231 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 231 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 2 231 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 2 231 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 2 231 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 2 231 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 249 231 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 227 231 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 227 231 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 227 231 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 227 231 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 227 243 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 96 231 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 255 231 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 247 231 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 223 231 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 223 231 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 203 231 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 191 231 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 179 231 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 84 20 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 72 20 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 72 20 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 60 20 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 72 20 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 72 12 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 97 20 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 85 20 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 73 20 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 73 20 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -23 20 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -23 20 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -23 20 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -23 20 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 113 12 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 107 20 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 107 20 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 107 20 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 95 20 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 107 12 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 46 8 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 159 20 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 135 20 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 135 20 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 111 20 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 144 20 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 112 20 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 84 8 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplri8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplri8a.afm new file mode 100644 index 00000000..01bdcf05 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pplri8a.afm @@ -0,0 +1,439 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jul 2 22:37:33 1990 +Comment UniqueID 31796 +Comment VMusage 37415 48307 +FontName Palatino-Italic +FullName Palatino Italic +FamilyName Palatino +Weight Medium +ItalicAngle -10 +IsFixedPitch false +FontBBox -170 -276 1010 918 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.005 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Palatino is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 482 +Ascender 733 +Descender -276 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 76 -8 292 733 ; +C 34 ; WX 500 ; N quotedbl ; B 140 508 455 733 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 495 692 ; +C 36 ; WX 500 ; N dollar ; B 15 -113 452 733 ; +C 37 ; WX 889 ; N percent ; B 74 -7 809 710 ; +C 38 ; WX 778 ; N ampersand ; B 47 -18 766 692 ; +C 39 ; WX 278 ; N quoteright ; B 78 488 258 733 ; +C 40 ; WX 333 ; N parenleft ; B 54 -106 331 733 ; +C 41 ; WX 333 ; N parenright ; B 2 -106 279 733 ; +C 42 ; WX 389 ; N asterisk ; B 76 368 400 706 ; +C 43 ; WX 606 ; N plus ; B 51 0 555 504 ; +C 44 ; WX 250 ; N comma ; B 8 -143 203 123 ; +C 45 ; WX 333 ; N hyphen ; B 19 223 304 281 ; +C 46 ; WX 250 ; N period ; B 53 -5 158 112 ; +C 47 ; WX 296 ; N slash ; B -40 -119 392 733 ; +C 48 ; WX 500 ; N zero ; B 36 -11 480 699 ; +C 49 ; WX 500 ; N one ; B 54 -3 398 699 ; +C 50 ; WX 500 ; N two ; B 12 -3 437 699 ; +C 51 ; WX 500 ; N three ; B 22 -11 447 699 ; +C 52 ; WX 500 ; N four ; B 15 -3 478 699 ; +C 53 ; WX 500 ; N five ; B 14 -11 491 693 ; +C 54 ; WX 500 ; N six ; B 49 -11 469 699 ; +C 55 ; WX 500 ; N seven ; B 53 -3 502 692 ; +C 56 ; WX 500 ; N eight ; B 36 -11 469 699 ; +C 57 ; WX 500 ; N nine ; B 32 -11 468 699 ; +C 58 ; WX 250 ; N colon ; B 44 -5 207 458 ; +C 59 ; WX 250 ; N semicolon ; B -9 -146 219 456 ; +C 60 ; WX 606 ; N less ; B 53 -6 554 516 ; +C 61 ; WX 606 ; N equal ; B 51 126 555 378 ; +C 62 ; WX 606 ; N greater ; B 53 -6 554 516 ; +C 63 ; WX 500 ; N question ; B 114 -8 427 706 ; +C 64 ; WX 747 ; N at ; B 27 -18 718 706 ; +C 65 ; WX 722 ; N A ; B -19 -3 677 705 ; +C 66 ; WX 611 ; N B ; B 26 -6 559 692 ; +C 67 ; WX 667 ; N C ; B 45 -18 651 706 ; +C 68 ; WX 778 ; N D ; B 28 -3 741 692 ; +C 69 ; WX 611 ; N E ; B 30 -3 570 692 ; +C 70 ; WX 556 ; N F ; B 0 -3 548 692 ; +C 71 ; WX 722 ; N G ; B 50 -18 694 706 ; +C 72 ; WX 778 ; N H ; B -3 -3 800 692 ; +C 73 ; WX 333 ; N I ; B 7 -3 354 692 ; +C 74 ; WX 333 ; N J ; B -35 -206 358 692 ; +C 75 ; WX 667 ; N K ; B 13 -3 683 692 ; +C 76 ; WX 556 ; N L ; B 16 -3 523 692 ; +C 77 ; WX 944 ; N M ; B -19 -18 940 692 ; +C 78 ; WX 778 ; N N ; B 2 -11 804 692 ; +C 79 ; WX 778 ; N O ; B 53 -18 748 706 ; +C 80 ; WX 611 ; N P ; B 9 -3 594 692 ; +C 81 ; WX 778 ; N Q ; B 53 -201 748 706 ; +C 82 ; WX 667 ; N R ; B 9 -3 639 692 ; +C 83 ; WX 556 ; N S ; B 42 -18 506 706 ; +C 84 ; WX 611 ; N T ; B 53 -3 635 692 ; +C 85 ; WX 778 ; N U ; B 88 -18 798 692 ; +C 86 ; WX 722 ; N V ; B 75 -8 754 692 ; +C 87 ; WX 944 ; N W ; B 71 -8 980 700 ; +C 88 ; WX 722 ; N X ; B 20 -3 734 692 ; +C 89 ; WX 667 ; N Y ; B 52 -3 675 705 ; +C 90 ; WX 667 ; N Z ; B 20 -3 637 692 ; +C 91 ; WX 333 ; N bracketleft ; B 18 -100 326 733 ; +C 92 ; WX 606 ; N backslash ; B 81 0 513 733 ; +C 93 ; WX 333 ; N bracketright ; B 7 -100 315 733 ; +C 94 ; WX 606 ; N asciicircum ; B 51 283 554 689 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 78 488 258 733 ; +C 97 ; WX 444 ; N a ; B 4 -11 406 482 ; +C 98 ; WX 463 ; N b ; B 37 -11 433 733 ; +C 99 ; WX 407 ; N c ; B 25 -11 389 482 ; +C 100 ; WX 500 ; N d ; B 17 -11 483 733 ; +C 101 ; WX 389 ; N e ; B 15 -11 374 482 ; +C 102 ; WX 278 ; N f ; B -162 -276 413 733 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B -37 -276 498 482 ; +C 104 ; WX 500 ; N h ; B 10 -9 471 733 ; +C 105 ; WX 278 ; N i ; B 34 -9 264 712 ; +C 106 ; WX 278 ; N j ; B -70 -276 265 712 ; +C 107 ; WX 444 ; N k ; B 8 -9 449 733 ; +C 108 ; WX 278 ; N l ; B 36 -9 251 733 ; +C 109 ; WX 778 ; N m ; B 24 -9 740 482 ; +C 110 ; WX 556 ; N n ; B 24 -9 514 482 ; +C 111 ; WX 444 ; N o ; B 17 -11 411 482 ; +C 112 ; WX 500 ; N p ; B -7 -276 465 482 ; +C 113 ; WX 463 ; N q ; B 24 -276 432 482 ; +C 114 ; WX 389 ; N r ; B 26 -9 384 482 ; +C 115 ; WX 389 ; N s ; B 9 -11 345 482 ; +C 116 ; WX 333 ; N t ; B 41 -9 310 646 ; +C 117 ; WX 556 ; N u ; B 32 -11 512 482 ; +C 118 ; WX 500 ; N v ; B 21 -11 477 482 ; +C 119 ; WX 722 ; N w ; B 21 -11 699 482 ; +C 120 ; WX 500 ; N x ; B 9 -11 484 482 ; +C 121 ; WX 500 ; N y ; B -8 -276 490 482 ; +C 122 ; WX 444 ; N z ; B -1 -11 416 482 ; +C 123 ; WX 333 ; N braceleft ; B 15 -100 319 733 ; +C 124 ; WX 606 ; N bar ; B 275 0 331 733 ; +C 125 ; WX 333 ; N braceright ; B 14 -100 318 733 ; +C 126 ; WX 606 ; N asciitilde ; B 51 168 555 339 ; +C 161 ; WX 333 ; N exclamdown ; B 15 -276 233 467 ; +C 162 ; WX 500 ; N cent ; B 56 -96 418 551 ; +C 163 ; WX 500 ; N sterling ; B 2 -18 479 708 ; +C 164 ; WX 167 ; N fraction ; B -170 0 337 699 ; +C 165 ; WX 500 ; N yen ; B 35 -3 512 699 ; +C 166 ; WX 500 ; N florin ; B 5 -276 470 708 ; +C 167 ; WX 500 ; N section ; B 14 -220 463 706 ; +C 168 ; WX 500 ; N currency ; B 14 115 486 577 ; +C 169 ; WX 333 ; N quotesingle ; B 140 508 288 733 ; +C 170 ; WX 500 ; N quotedblleft ; B 98 488 475 733 ; +C 171 ; WX 500 ; N guillemotleft ; B 57 70 437 440 ; +C 172 ; WX 333 ; N guilsinglleft ; B 57 70 270 440 ; +C 173 ; WX 333 ; N guilsinglright ; B 63 70 276 440 ; +C 174 ; WX 528 ; N fi ; B -162 -276 502 733 ; +C 175 ; WX 545 ; N fl ; B -162 -276 520 733 ; +C 177 ; WX 500 ; N endash ; B -10 228 510 278 ; +C 178 ; WX 500 ; N dagger ; B 48 0 469 692 ; +C 179 ; WX 500 ; N daggerdbl ; B 10 -162 494 692 ; +C 180 ; WX 250 ; N periodcentered ; B 53 195 158 312 ; +C 182 ; WX 500 ; N paragraph ; B 33 -224 611 692 ; +C 183 ; WX 500 ; N bullet ; B 86 182 430 526 ; +C 184 ; WX 278 ; N quotesinglbase ; B 27 -122 211 120 ; +C 185 ; WX 500 ; N quotedblbase ; B 43 -122 424 120 ; +C 186 ; WX 500 ; N quotedblright ; B 98 488 475 733 ; +C 187 ; WX 500 ; N guillemotright ; B 63 70 443 440 ; +C 188 ; WX 1000 ; N ellipsis ; B 102 -5 873 112 ; +C 189 ; WX 1000 ; N perthousand ; B 72 -6 929 717 ; +C 191 ; WX 500 ; N questiondown ; B 57 -246 370 467 ; +C 193 ; WX 333 ; N grave ; B 86 518 310 687 ; +C 194 ; WX 333 ; N acute ; B 122 518 346 687 ; +C 195 ; WX 333 ; N circumflex ; B 56 510 350 679 ; +C 196 ; WX 333 ; N tilde ; B 63 535 390 638 ; +C 197 ; WX 333 ; N macron ; B 74 538 386 589 ; +C 198 ; WX 333 ; N breve ; B 92 518 393 677 ; +C 199 ; WX 333 ; N dotaccent ; B 175 537 283 645 ; +C 200 ; WX 333 ; N dieresis ; B 78 537 378 637 ; +C 202 ; WX 333 ; N ring ; B 159 508 359 708 ; +C 203 ; WX 333 ; N cedilla ; B -9 -216 202 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 46 518 385 730 ; +C 206 ; WX 333 ; N ogonek ; B 38 -207 196 -18 ; +C 207 ; WX 333 ; N caron ; B 104 510 409 679 ; +C 208 ; WX 1000 ; N emdash ; B -10 228 1010 278 ; +C 225 ; WX 941 ; N AE ; B -4 -3 902 692 ; +C 227 ; WX 333 ; N ordfeminine ; B 60 404 321 699 ; +C 232 ; WX 556 ; N Lslash ; B -16 -3 523 692 ; +C 233 ; WX 778 ; N Oslash ; B 32 -39 762 721 ; +C 234 ; WX 1028 ; N OE ; B 56 -18 989 706 ; +C 235 ; WX 333 ; N ordmasculine ; B 66 404 322 699 ; +C 241 ; WX 638 ; N ae ; B 1 -11 623 482 ; +C 245 ; WX 278 ; N dotlessi ; B 34 -9 241 482 ; +C 248 ; WX 278 ; N lslash ; B -10 -9 302 733 ; +C 249 ; WX 444 ; N oslash ; B -18 -24 460 510 ; +C 250 ; WX 669 ; N oe ; B 17 -11 654 482 ; +C 251 ; WX 500 ; N germandbls ; B -160 -276 488 733 ; +C -1 ; WX 667 ; N Zcaron ; B 20 -3 637 907 ; +C -1 ; WX 407 ; N ccedilla ; B 25 -216 389 482 ; +C -1 ; WX 500 ; N ydieresis ; B -8 -276 490 657 ; +C -1 ; WX 444 ; N atilde ; B 4 -11 446 650 ; +C -1 ; WX 278 ; N icircumflex ; B 29 -9 323 699 ; +C -1 ; WX 300 ; N threesuperior ; B 28 273 304 699 ; +C -1 ; WX 389 ; N ecircumflex ; B 15 -11 398 699 ; +C -1 ; WX 500 ; N thorn ; B -39 -276 433 733 ; +C -1 ; WX 389 ; N egrave ; B 15 -11 374 707 ; +C -1 ; WX 300 ; N twosuperior ; B 13 278 290 699 ; +C -1 ; WX 389 ; N eacute ; B 15 -11 394 707 ; +C -1 ; WX 444 ; N otilde ; B 17 -11 446 650 ; +C -1 ; WX 722 ; N Aacute ; B -19 -3 677 897 ; +C -1 ; WX 444 ; N ocircumflex ; B 17 -11 411 699 ; +C -1 ; WX 500 ; N yacute ; B -8 -276 490 707 ; +C -1 ; WX 556 ; N udieresis ; B 32 -11 512 657 ; +C -1 ; WX 750 ; N threequarters ; B 35 -2 715 699 ; +C -1 ; WX 444 ; N acircumflex ; B 4 -11 406 699 ; +C -1 ; WX 778 ; N Eth ; B 19 -3 741 692 ; +C -1 ; WX 389 ; N edieresis ; B 15 -11 406 657 ; +C -1 ; WX 556 ; N ugrave ; B 32 -11 512 707 ; +C -1 ; WX 1000 ; N trademark ; B 52 285 951 689 ; +C -1 ; WX 444 ; N ograve ; B 17 -11 411 707 ; +C -1 ; WX 389 ; N scaron ; B 9 -11 419 687 ; +C -1 ; WX 333 ; N Idieresis ; B 7 -3 418 847 ; +C -1 ; WX 556 ; N uacute ; B 32 -11 512 707 ; +C -1 ; WX 444 ; N agrave ; B 4 -11 406 707 ; +C -1 ; WX 556 ; N ntilde ; B 24 -9 514 650 ; +C -1 ; WX 444 ; N aring ; B 4 -11 406 728 ; +C -1 ; WX 444 ; N zcaron ; B -1 -11 447 687 ; +C -1 ; WX 333 ; N Icircumflex ; B 7 -3 390 889 ; +C -1 ; WX 778 ; N Ntilde ; B 2 -11 804 866 ; +C -1 ; WX 556 ; N ucircumflex ; B 32 -11 512 699 ; +C -1 ; WX 611 ; N Ecircumflex ; B 30 -3 570 889 ; +C -1 ; WX 333 ; N Iacute ; B 7 -3 406 897 ; +C -1 ; WX 667 ; N Ccedilla ; B 45 -216 651 706 ; +C -1 ; WX 778 ; N Odieresis ; B 53 -18 748 847 ; +C -1 ; WX 556 ; N Scaron ; B 42 -18 539 907 ; +C -1 ; WX 611 ; N Edieresis ; B 30 -3 570 847 ; +C -1 ; WX 333 ; N Igrave ; B 7 -3 354 897 ; +C -1 ; WX 444 ; N adieresis ; B 4 -11 434 657 ; +C -1 ; WX 778 ; N Ograve ; B 53 -18 748 897 ; +C -1 ; WX 611 ; N Egrave ; B 30 -3 570 897 ; +C -1 ; WX 667 ; N Ydieresis ; B 52 -3 675 847 ; +C -1 ; WX 747 ; N registered ; B 11 -18 736 706 ; +C -1 ; WX 778 ; N Otilde ; B 53 -18 748 866 ; +C -1 ; WX 750 ; N onequarter ; B 31 -2 715 699 ; +C -1 ; WX 778 ; N Ugrave ; B 88 -18 798 897 ; +C -1 ; WX 778 ; N Ucircumflex ; B 88 -18 798 889 ; +C -1 ; WX 611 ; N Thorn ; B 9 -3 570 692 ; +C -1 ; WX 606 ; N divide ; B 51 0 555 504 ; +C -1 ; WX 722 ; N Atilde ; B -19 -3 677 866 ; +C -1 ; WX 778 ; N Uacute ; B 88 -18 798 897 ; +C -1 ; WX 778 ; N Ocircumflex ; B 53 -18 748 889 ; +C -1 ; WX 606 ; N logicalnot ; B 51 118 555 378 ; +C -1 ; WX 722 ; N Aring ; B -19 -3 677 918 ; +C -1 ; WX 278 ; N idieresis ; B 34 -9 351 657 ; +C -1 ; WX 278 ; N iacute ; B 34 -9 331 707 ; +C -1 ; WX 444 ; N aacute ; B 4 -11 414 707 ; +C -1 ; WX 606 ; N plusminus ; B 51 0 555 504 ; +C -1 ; WX 606 ; N multiply ; B 83 36 523 474 ; +C -1 ; WX 778 ; N Udieresis ; B 88 -18 798 847 ; +C -1 ; WX 606 ; N minus ; B 51 224 555 280 ; +C -1 ; WX 300 ; N onesuperior ; B 61 278 285 699 ; +C -1 ; WX 611 ; N Eacute ; B 30 -3 570 897 ; +C -1 ; WX 722 ; N Acircumflex ; B -19 -3 677 889 ; +C -1 ; WX 747 ; N copyright ; B 11 -18 736 706 ; +C -1 ; WX 722 ; N Agrave ; B -19 -3 677 897 ; +C -1 ; WX 444 ; N odieresis ; B 17 -11 434 657 ; +C -1 ; WX 444 ; N oacute ; B 17 -11 414 707 ; +C -1 ; WX 400 ; N degree ; B 90 389 390 689 ; +C -1 ; WX 278 ; N igrave ; B 34 -9 271 707 ; +C -1 ; WX 556 ; N mu ; B 15 -226 512 482 ; +C -1 ; WX 778 ; N Oacute ; B 53 -18 748 897 ; +C -1 ; WX 444 ; N eth ; B 17 -11 478 733 ; +C -1 ; WX 722 ; N Adieresis ; B -19 -3 677 847 ; +C -1 ; WX 667 ; N Yacute ; B 52 -3 675 897 ; +C -1 ; WX 606 ; N brokenbar ; B 275 0 331 733 ; +C -1 ; WX 750 ; N onehalf ; B 31 -2 721 699 ; +EndCharMetrics +StartKernData +StartKernPairs 106 + +KPX A y -55 +KPX A w -37 +KPX A v -37 +KPX A space -37 +KPX A quoteright -55 +KPX A Y -55 +KPX A W -55 +KPX A V -74 +KPX A T -55 + +KPX F period -111 +KPX F comma -111 +KPX F A -111 + +KPX L y -37 +KPX L space -18 +KPX L quoteright -37 +KPX L Y -74 +KPX L W -74 +KPX L V -74 +KPX L T -74 + +KPX P period -129 +KPX P comma -129 +KPX P A -129 + +KPX R y -37 +KPX R Y -55 +KPX R W -55 +KPX R V -74 +KPX R T -55 + +KPX T y -92 +KPX T w -92 +KPX T u -111 +KPX T semicolon -74 +KPX T s -111 +KPX T r -111 +KPX T period -74 +KPX T o -111 +KPX T i -55 +KPX T hyphen -55 +KPX T e -111 +KPX T comma -74 +KPX T colon -74 +KPX T c -111 +KPX T a -111 +KPX T O -18 +KPX T A -92 + +KPX V y -74 +KPX V u -74 +KPX V semicolon -37 +KPX V r -92 +KPX V period -129 +KPX V o -74 +KPX V i -74 +KPX V hyphen -55 +KPX V e -92 +KPX V comma -129 +KPX V colon -37 +KPX V a -74 +KPX V A -210 + +KPX W y -20 +KPX W u -20 +KPX W semicolon -18 +KPX W r -20 +KPX W period -55 +KPX W o -20 +KPX W i -20 +KPX W hyphen -18 +KPX W e -20 +KPX W comma -55 +KPX W colon -18 +KPX W a -20 +KPX W A -92 + +KPX Y v -74 +KPX Y u -92 +KPX Y semicolon -74 +KPX Y q -92 +KPX Y period -92 +KPX Y p -74 +KPX Y o -111 +KPX Y i -55 +KPX Y hyphen -74 +KPX Y e -111 +KPX Y comma -92 +KPX Y colon -74 +KPX Y a -92 +KPX Y A -92 + +KPX f quoteright 55 + +KPX one one -55 + +KPX quoteleft quoteleft -74 + +KPX quoteright t -37 +KPX quoteright space -55 +KPX quoteright s -55 +KPX quoteright quoteright -74 + +KPX r quoteright 37 +KPX r q -18 +KPX r period -74 +KPX r o -18 +KPX r h -18 +KPX r g -18 +KPX r e -18 +KPX r comma -74 +KPX r c -18 + +KPX v period -55 +KPX v comma -55 + +KPX w period -55 +KPX w comma -55 + +KPX y period -37 +KPX y comma -37 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 271 210 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 261 210 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 255 210 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 235 210 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 235 210 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 255 228 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 207 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 199 210 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 179 210 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 179 210 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 167 210 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 60 210 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 40 210 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 40 210 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 28 210 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 263 228 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 283 210 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 263 210 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 255 210 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 251 210 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 263 228 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 130 228 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 277 210 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 255 210 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 235 210 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 235 210 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 227 210 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 187 210 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 179 228 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 68 20 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 56 20 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 56 20 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 44 20 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 36 20 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 56 12 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 37 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 48 20 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 48 20 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 28 20 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 16 20 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -15 20 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 20 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 20 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -39 20 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 112 12 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 68 20 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 56 20 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 56 20 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 36 20 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 56 12 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 10 8 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 124 20 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 112 20 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 112 20 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 100 20 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 96 20 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 20 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 38 8 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/psyr.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/psyr.afm new file mode 100644 index 00000000..1cdbdae6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/psyr.afm @@ -0,0 +1,209 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Wed Jan 17 21:48:26 1990 +Comment UniqueID 27004 +Comment VMusage 28489 37622 +FontName Symbol +FullName Symbol +FamilyName Symbol +Weight Medium +ItalicAngle 0 +IsFixedPitch false +FontBBox -180 -293 1090 1010 +UnderlinePosition -98 +UnderlineThickness 54 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All rights reserved. +EncodingScheme FontSpecific +StartCharMetrics 189 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 128 -17 240 672 ; +C 34 ; WX 713 ; N universal ; B 31 0 681 705 ; +C 35 ; WX 500 ; N numbersign ; B 20 -16 481 673 ; +C 36 ; WX 549 ; N existential ; B 25 0 478 707 ; +C 37 ; WX 833 ; N percent ; B 63 -36 771 655 ; +C 38 ; WX 778 ; N ampersand ; B 41 -18 750 661 ; +C 39 ; WX 439 ; N suchthat ; B 48 -17 414 500 ; +C 40 ; WX 333 ; N parenleft ; B 53 -191 300 673 ; +C 41 ; WX 333 ; N parenright ; B 30 -191 277 673 ; +C 42 ; WX 500 ; N asteriskmath ; B 65 134 427 551 ; +C 43 ; WX 549 ; N plus ; B 10 0 539 533 ; +C 44 ; WX 250 ; N comma ; B 56 -152 194 104 ; +C 45 ; WX 549 ; N minus ; B 11 233 535 288 ; +C 46 ; WX 250 ; N period ; B 69 -17 181 95 ; +C 47 ; WX 278 ; N slash ; B 0 -18 254 646 ; +C 48 ; WX 500 ; N zero ; B 23 -17 471 685 ; +C 49 ; WX 500 ; N one ; B 117 0 390 673 ; +C 50 ; WX 500 ; N two ; B 25 0 475 686 ; +C 51 ; WX 500 ; N three ; B 39 -17 435 685 ; +C 52 ; WX 500 ; N four ; B 16 0 469 685 ; +C 53 ; WX 500 ; N five ; B 29 -17 443 685 ; +C 54 ; WX 500 ; N six ; B 36 -17 467 685 ; +C 55 ; WX 500 ; N seven ; B 24 -16 448 673 ; +C 56 ; WX 500 ; N eight ; B 54 -18 440 685 ; +C 57 ; WX 500 ; N nine ; B 31 -18 460 685 ; +C 58 ; WX 278 ; N colon ; B 81 -17 193 460 ; +C 59 ; WX 278 ; N semicolon ; B 83 -152 221 460 ; +C 60 ; WX 549 ; N less ; B 26 0 523 522 ; +C 61 ; WX 549 ; N equal ; B 11 141 537 390 ; +C 62 ; WX 549 ; N greater ; B 26 0 523 522 ; +C 63 ; WX 444 ; N question ; B 70 -17 412 686 ; +C 64 ; WX 549 ; N congruent ; B 11 0 537 475 ; +C 65 ; WX 722 ; N Alpha ; B 4 0 684 673 ; +C 66 ; WX 667 ; N Beta ; B 29 0 592 673 ; +C 67 ; WX 722 ; N Chi ; B -9 0 704 673 ; +C 68 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C 69 ; WX 611 ; N Epsilon ; B 32 0 617 673 ; +C 70 ; WX 763 ; N Phi ; B 26 0 741 673 ; +C 71 ; WX 603 ; N Gamma ; B 24 0 609 673 ; +C 72 ; WX 722 ; N Eta ; B 39 0 729 673 ; +C 73 ; WX 333 ; N Iota ; B 32 0 316 673 ; +C 74 ; WX 631 ; N theta1 ; B 18 -18 623 689 ; +C 75 ; WX 722 ; N Kappa ; B 35 0 722 673 ; +C 76 ; WX 686 ; N Lambda ; B 6 0 680 688 ; +C 77 ; WX 889 ; N Mu ; B 28 0 887 673 ; +C 78 ; WX 722 ; N Nu ; B 29 -8 720 673 ; +C 79 ; WX 722 ; N Omicron ; B 41 -17 715 685 ; +C 80 ; WX 768 ; N Pi ; B 25 0 745 673 ; +C 81 ; WX 741 ; N Theta ; B 41 -17 715 685 ; +C 82 ; WX 556 ; N Rho ; B 28 0 563 673 ; +C 83 ; WX 592 ; N Sigma ; B 5 0 589 673 ; +C 84 ; WX 611 ; N Tau ; B 33 0 607 673 ; +C 85 ; WX 690 ; N Upsilon ; B -8 0 694 673 ; +C 86 ; WX 439 ; N sigma1 ; B 40 -233 436 500 ; +C 87 ; WX 768 ; N Omega ; B 34 0 736 688 ; +C 88 ; WX 645 ; N Xi ; B 40 0 599 673 ; +C 89 ; WX 795 ; N Psi ; B 15 0 781 684 ; +C 90 ; WX 611 ; N Zeta ; B 44 0 636 673 ; +C 91 ; WX 333 ; N bracketleft ; B 86 -155 299 674 ; +C 92 ; WX 863 ; N therefore ; B 163 0 701 478 ; +C 93 ; WX 333 ; N bracketright ; B 33 -155 246 674 ; +C 94 ; WX 658 ; N perpendicular ; B 15 0 652 674 ; +C 95 ; WX 500 ; N underscore ; B -2 -252 502 -206 ; +C 96 ; WX 500 ; N radicalex ; B 480 881 1090 917 ; +C 97 ; WX 631 ; N alpha ; B 41 -18 622 500 ; +C 98 ; WX 549 ; N beta ; B 61 -223 515 741 ; +C 99 ; WX 549 ; N chi ; B 12 -231 522 499 ; +C 100 ; WX 494 ; N delta ; B 40 -19 481 740 ; +C 101 ; WX 439 ; N epsilon ; B 22 -19 427 502 ; +C 102 ; WX 521 ; N phi ; B 27 -224 490 671 ; +C 103 ; WX 411 ; N gamma ; B 5 -225 484 499 ; +C 104 ; WX 603 ; N eta ; B 0 -202 527 514 ; +C 105 ; WX 329 ; N iota ; B 0 -17 301 503 ; +C 106 ; WX 603 ; N phi1 ; B 36 -224 587 499 ; +C 107 ; WX 549 ; N kappa ; B 33 0 558 501 ; +C 108 ; WX 549 ; N lambda ; B 24 -17 548 739 ; +C 109 ; WX 576 ; N mu ; B 33 -223 567 500 ; +C 110 ; WX 521 ; N nu ; B -9 -16 475 507 ; +C 111 ; WX 549 ; N omicron ; B 35 -19 501 499 ; +C 112 ; WX 549 ; N pi ; B 10 -19 530 487 ; +C 113 ; WX 521 ; N theta ; B 43 -17 485 690 ; +C 114 ; WX 549 ; N rho ; B 50 -230 490 499 ; +C 115 ; WX 603 ; N sigma ; B 30 -21 588 500 ; +C 116 ; WX 439 ; N tau ; B 10 -19 418 500 ; +C 117 ; WX 576 ; N upsilon ; B 7 -18 535 507 ; +C 118 ; WX 713 ; N omega1 ; B 12 -18 671 583 ; +C 119 ; WX 686 ; N omega ; B 42 -17 684 500 ; +C 120 ; WX 493 ; N xi ; B 27 -224 469 766 ; +C 121 ; WX 686 ; N psi ; B 12 -228 701 500 ; +C 122 ; WX 494 ; N zeta ; B 60 -225 467 756 ; +C 123 ; WX 480 ; N braceleft ; B 58 -183 397 673 ; +C 124 ; WX 200 ; N bar ; B 65 -177 135 673 ; +C 125 ; WX 480 ; N braceright ; B 79 -183 418 673 ; +C 126 ; WX 549 ; N similar ; B 17 203 529 307 ; +C 161 ; WX 620 ; N Upsilon1 ; B -2 0 610 685 ; +C 162 ; WX 247 ; N minute ; B 27 459 228 735 ; +C 163 ; WX 549 ; N lessequal ; B 29 0 526 639 ; +C 164 ; WX 167 ; N fraction ; B -180 -12 340 677 ; +C 165 ; WX 713 ; N infinity ; B 26 124 688 404 ; +C 166 ; WX 500 ; N florin ; B 2 -193 494 686 ; +C 167 ; WX 753 ; N club ; B 86 -26 660 533 ; +C 168 ; WX 753 ; N diamond ; B 142 -36 600 550 ; +C 169 ; WX 753 ; N heart ; B 117 -33 631 532 ; +C 170 ; WX 753 ; N spade ; B 113 -36 629 548 ; +C 171 ; WX 1042 ; N arrowboth ; B 24 -15 1024 511 ; +C 172 ; WX 987 ; N arrowleft ; B 32 -15 942 511 ; +C 173 ; WX 603 ; N arrowup ; B 45 0 571 910 ; +C 174 ; WX 987 ; N arrowright ; B 49 -15 959 511 ; +C 175 ; WX 603 ; N arrowdown ; B 45 -22 571 888 ; +C 176 ; WX 400 ; N degree ; B 50 385 350 685 ; +C 177 ; WX 549 ; N plusminus ; B 10 0 539 645 ; +C 178 ; WX 411 ; N second ; B 20 459 413 737 ; +C 179 ; WX 549 ; N greaterequal ; B 29 0 526 639 ; +C 180 ; WX 549 ; N multiply ; B 17 8 533 524 ; +C 181 ; WX 713 ; N proportional ; B 27 123 639 404 ; +C 182 ; WX 494 ; N partialdiff ; B 26 -20 462 746 ; +C 183 ; WX 460 ; N bullet ; B 50 113 410 473 ; +C 184 ; WX 549 ; N divide ; B 10 71 536 456 ; +C 185 ; WX 549 ; N notequal ; B 15 -25 540 549 ; +C 186 ; WX 549 ; N equivalence ; B 14 82 538 443 ; +C 187 ; WX 549 ; N approxequal ; B 14 135 527 394 ; +C 188 ; WX 1000 ; N ellipsis ; B 111 -17 889 95 ; +C 189 ; WX 603 ; N arrowvertex ; B 280 -120 336 1010 ; +C 190 ; WX 1000 ; N arrowhorizex ; B -60 220 1050 276 ; +C 191 ; WX 658 ; N carriagereturn ; B 15 -16 602 629 ; +C 192 ; WX 823 ; N aleph ; B 175 -18 661 658 ; +C 193 ; WX 686 ; N Ifraktur ; B 10 -53 578 740 ; +C 194 ; WX 795 ; N Rfraktur ; B 26 -15 759 734 ; +C 195 ; WX 987 ; N weierstrass ; B 159 -211 870 573 ; +C 196 ; WX 768 ; N circlemultiply ; B 43 -17 733 673 ; +C 197 ; WX 768 ; N circleplus ; B 43 -15 733 675 ; +C 198 ; WX 823 ; N emptyset ; B 39 -24 781 719 ; +C 199 ; WX 768 ; N intersection ; B 40 0 732 509 ; +C 200 ; WX 768 ; N union ; B 40 -17 732 492 ; +C 201 ; WX 713 ; N propersuperset ; B 20 0 673 470 ; +C 202 ; WX 713 ; N reflexsuperset ; B 20 -125 673 470 ; +C 203 ; WX 713 ; N notsubset ; B 36 -70 690 540 ; +C 204 ; WX 713 ; N propersubset ; B 37 0 690 470 ; +C 205 ; WX 713 ; N reflexsubset ; B 37 -125 690 470 ; +C 206 ; WX 713 ; N element ; B 45 0 505 468 ; +C 207 ; WX 713 ; N notelement ; B 45 -58 505 555 ; +C 208 ; WX 768 ; N angle ; B 26 0 738 673 ; +C 209 ; WX 713 ; N gradient ; B 36 -19 681 718 ; +C 210 ; WX 790 ; N registerserif ; B 50 -17 740 673 ; +C 211 ; WX 790 ; N copyrightserif ; B 51 -15 741 675 ; +C 212 ; WX 890 ; N trademarkserif ; B 18 293 855 673 ; +C 213 ; WX 823 ; N product ; B 25 -101 803 751 ; +C 214 ; WX 549 ; N radical ; B 10 -38 515 917 ; +C 215 ; WX 250 ; N dotmath ; B 69 210 169 310 ; +C 216 ; WX 713 ; N logicalnot ; B 15 0 680 288 ; +C 217 ; WX 603 ; N logicaland ; B 23 0 583 454 ; +C 218 ; WX 603 ; N logicalor ; B 30 0 578 477 ; +C 219 ; WX 1042 ; N arrowdblboth ; B 27 -20 1023 510 ; +C 220 ; WX 987 ; N arrowdblleft ; B 30 -15 939 513 ; +C 221 ; WX 603 ; N arrowdblup ; B 39 2 567 911 ; +C 222 ; WX 987 ; N arrowdblright ; B 45 -20 954 508 ; +C 223 ; WX 603 ; N arrowdbldown ; B 44 -19 572 890 ; +C 224 ; WX 494 ; N lozenge ; B 18 0 466 745 ; +C 225 ; WX 329 ; N angleleft ; B 25 -198 306 746 ; +C 226 ; WX 790 ; N registersans ; B 50 -20 740 670 ; +C 227 ; WX 790 ; N copyrightsans ; B 49 -15 739 675 ; +C 228 ; WX 786 ; N trademarksans ; B 5 293 725 673 ; +C 229 ; WX 713 ; N summation ; B 14 -108 695 752 ; +C 230 ; WX 384 ; N parenlefttp ; B 40 -293 436 926 ; +C 231 ; WX 384 ; N parenleftex ; B 40 -85 92 925 ; +C 232 ; WX 384 ; N parenleftbt ; B 40 -293 436 926 ; +C 233 ; WX 384 ; N bracketlefttp ; B 0 -80 341 926 ; +C 234 ; WX 384 ; N bracketleftex ; B 0 -79 55 925 ; +C 235 ; WX 384 ; N bracketleftbt ; B 0 -80 340 926 ; +C 236 ; WX 494 ; N bracelefttp ; B 201 -75 439 926 ; +C 237 ; WX 494 ; N braceleftmid ; B 14 -85 255 935 ; +C 238 ; WX 494 ; N braceleftbt ; B 201 -70 439 926 ; +C 239 ; WX 494 ; N braceex ; B 201 -80 255 935 ; +C 241 ; WX 329 ; N angleright ; B 21 -198 302 746 ; +C 242 ; WX 274 ; N integral ; B 2 -107 291 916 ; +C 243 ; WX 686 ; N integraltp ; B 332 -83 715 921 ; +C 244 ; WX 686 ; N integralex ; B 332 -88 415 975 ; +C 245 ; WX 686 ; N integralbt ; B 39 -81 415 921 ; +C 246 ; WX 384 ; N parenrighttp ; B 54 -293 450 926 ; +C 247 ; WX 384 ; N parenrightex ; B 398 -85 450 925 ; +C 248 ; WX 384 ; N parenrightbt ; B 54 -293 450 926 ; +C 249 ; WX 384 ; N bracketrighttp ; B 22 -80 360 926 ; +C 250 ; WX 384 ; N bracketrightex ; B 305 -79 360 925 ; +C 251 ; WX 384 ; N bracketrightbt ; B 20 -80 360 926 ; +C 252 ; WX 494 ; N bracerighttp ; B 17 -75 255 926 ; +C 253 ; WX 494 ; N bracerightmid ; B 201 -85 442 935 ; +C 254 ; WX 494 ; N bracerightbt ; B 17 -70 255 926 ; +C -1 ; WX 790 ; N apple ; B 56 -3 733 808 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmb8a.afm new file mode 100644 index 00000000..55207f94 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmb8a.afm @@ -0,0 +1,648 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Mar 20 12:17:14 1990 +Comment UniqueID 28417 +Comment VMusage 30458 37350 +FontName Times-Bold +FullName Times Bold +FamilyName Times +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -168 -218 1000 935 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 676 +XHeight 461 +Ascender 676 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 81 -13 251 691 ; +C 34 ; WX 555 ; N quotedbl ; B 83 404 472 691 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 496 700 ; +C 36 ; WX 500 ; N dollar ; B 29 -99 472 750 ; +C 37 ; WX 1000 ; N percent ; B 124 -14 877 692 ; +C 38 ; WX 833 ; N ampersand ; B 62 -16 787 691 ; +C 39 ; WX 333 ; N quoteright ; B 79 356 263 691 ; +C 40 ; WX 333 ; N parenleft ; B 46 -168 306 694 ; +C 41 ; WX 333 ; N parenright ; B 27 -168 287 694 ; +C 42 ; WX 500 ; N asterisk ; B 56 255 447 691 ; +C 43 ; WX 570 ; N plus ; B 33 0 537 506 ; +C 44 ; WX 250 ; N comma ; B 39 -180 223 155 ; +C 45 ; WX 333 ; N hyphen ; B 44 171 287 287 ; +C 46 ; WX 250 ; N period ; B 41 -13 210 156 ; +C 47 ; WX 278 ; N slash ; B -24 -19 302 691 ; +C 48 ; WX 500 ; N zero ; B 24 -13 476 688 ; +C 49 ; WX 500 ; N one ; B 65 0 442 688 ; +C 50 ; WX 500 ; N two ; B 17 0 478 688 ; +C 51 ; WX 500 ; N three ; B 16 -14 468 688 ; +C 52 ; WX 500 ; N four ; B 19 0 475 688 ; +C 53 ; WX 500 ; N five ; B 22 -8 470 676 ; +C 54 ; WX 500 ; N six ; B 28 -13 475 688 ; +C 55 ; WX 500 ; N seven ; B 17 0 477 676 ; +C 56 ; WX 500 ; N eight ; B 28 -13 472 688 ; +C 57 ; WX 500 ; N nine ; B 26 -13 473 688 ; +C 58 ; WX 333 ; N colon ; B 82 -13 251 472 ; +C 59 ; WX 333 ; N semicolon ; B 82 -180 266 472 ; +C 60 ; WX 570 ; N less ; B 31 -8 539 514 ; +C 61 ; WX 570 ; N equal ; B 33 107 537 399 ; +C 62 ; WX 570 ; N greater ; B 31 -8 539 514 ; +C 63 ; WX 500 ; N question ; B 57 -13 445 689 ; +C 64 ; WX 930 ; N at ; B 108 -19 822 691 ; +C 65 ; WX 722 ; N A ; B 9 0 689 690 ; +C 66 ; WX 667 ; N B ; B 16 0 619 676 ; +C 67 ; WX 722 ; N C ; B 49 -19 687 691 ; +C 68 ; WX 722 ; N D ; B 14 0 690 676 ; +C 69 ; WX 667 ; N E ; B 16 0 641 676 ; +C 70 ; WX 611 ; N F ; B 16 0 583 676 ; +C 71 ; WX 778 ; N G ; B 37 -19 755 691 ; +C 72 ; WX 778 ; N H ; B 21 0 759 676 ; +C 73 ; WX 389 ; N I ; B 20 0 370 676 ; +C 74 ; WX 500 ; N J ; B 3 -96 479 676 ; +C 75 ; WX 778 ; N K ; B 30 0 769 676 ; +C 76 ; WX 667 ; N L ; B 19 0 638 676 ; +C 77 ; WX 944 ; N M ; B 14 0 921 676 ; +C 78 ; WX 722 ; N N ; B 16 -18 701 676 ; +C 79 ; WX 778 ; N O ; B 35 -19 743 691 ; +C 80 ; WX 611 ; N P ; B 16 0 600 676 ; +C 81 ; WX 778 ; N Q ; B 35 -176 743 691 ; +C 82 ; WX 722 ; N R ; B 26 0 715 676 ; +C 83 ; WX 556 ; N S ; B 35 -19 513 692 ; +C 84 ; WX 667 ; N T ; B 31 0 636 676 ; +C 85 ; WX 722 ; N U ; B 16 -19 701 676 ; +C 86 ; WX 722 ; N V ; B 16 -18 701 676 ; +C 87 ; WX 1000 ; N W ; B 19 -15 981 676 ; +C 88 ; WX 722 ; N X ; B 16 0 699 676 ; +C 89 ; WX 722 ; N Y ; B 15 0 699 676 ; +C 90 ; WX 667 ; N Z ; B 28 0 634 676 ; +C 91 ; WX 333 ; N bracketleft ; B 67 -149 301 678 ; +C 92 ; WX 278 ; N backslash ; B -25 -19 303 691 ; +C 93 ; WX 333 ; N bracketright ; B 32 -149 266 678 ; +C 94 ; WX 581 ; N asciicircum ; B 73 311 509 676 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 70 356 254 691 ; +C 97 ; WX 500 ; N a ; B 25 -14 488 473 ; +C 98 ; WX 556 ; N b ; B 17 -14 521 676 ; +C 99 ; WX 444 ; N c ; B 25 -14 430 473 ; +C 100 ; WX 556 ; N d ; B 25 -14 534 676 ; +C 101 ; WX 444 ; N e ; B 25 -14 426 473 ; +C 102 ; WX 333 ; N f ; B 14 0 389 691 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 28 -206 483 473 ; +C 104 ; WX 556 ; N h ; B 16 0 534 676 ; +C 105 ; WX 278 ; N i ; B 16 0 255 691 ; +C 106 ; WX 333 ; N j ; B -57 -203 263 691 ; +C 107 ; WX 556 ; N k ; B 22 0 543 676 ; +C 108 ; WX 278 ; N l ; B 16 0 255 676 ; +C 109 ; WX 833 ; N m ; B 16 0 814 473 ; +C 110 ; WX 556 ; N n ; B 21 0 539 473 ; +C 111 ; WX 500 ; N o ; B 25 -14 476 473 ; +C 112 ; WX 556 ; N p ; B 19 -205 524 473 ; +C 113 ; WX 556 ; N q ; B 34 -205 536 473 ; +C 114 ; WX 444 ; N r ; B 29 0 434 473 ; +C 115 ; WX 389 ; N s ; B 25 -14 361 473 ; +C 116 ; WX 333 ; N t ; B 20 -12 332 630 ; +C 117 ; WX 556 ; N u ; B 16 -14 537 461 ; +C 118 ; WX 500 ; N v ; B 21 -14 485 461 ; +C 119 ; WX 722 ; N w ; B 23 -14 707 461 ; +C 120 ; WX 500 ; N x ; B 12 0 484 461 ; +C 121 ; WX 500 ; N y ; B 16 -205 480 461 ; +C 122 ; WX 444 ; N z ; B 21 0 420 461 ; +C 123 ; WX 394 ; N braceleft ; B 22 -175 340 698 ; +C 124 ; WX 220 ; N bar ; B 66 -19 154 691 ; +C 125 ; WX 394 ; N braceright ; B 54 -175 372 698 ; +C 126 ; WX 520 ; N asciitilde ; B 29 173 491 333 ; +C 161 ; WX 333 ; N exclamdown ; B 82 -203 252 501 ; +C 162 ; WX 500 ; N cent ; B 53 -140 458 588 ; +C 163 ; WX 500 ; N sterling ; B 21 -14 477 684 ; +C 164 ; WX 167 ; N fraction ; B -168 -12 329 688 ; +C 165 ; WX 500 ; N yen ; B -64 0 547 676 ; +C 166 ; WX 500 ; N florin ; B 0 -155 498 706 ; +C 167 ; WX 500 ; N section ; B 57 -132 443 691 ; +C 168 ; WX 500 ; N currency ; B -26 61 526 613 ; +C 169 ; WX 278 ; N quotesingle ; B 75 404 204 691 ; +C 170 ; WX 500 ; N quotedblleft ; B 32 356 486 691 ; +C 171 ; WX 500 ; N guillemotleft ; B 23 36 473 415 ; +C 172 ; WX 333 ; N guilsinglleft ; B 51 36 305 415 ; +C 173 ; WX 333 ; N guilsinglright ; B 28 36 282 415 ; +C 174 ; WX 556 ; N fi ; B 14 0 536 691 ; +C 175 ; WX 556 ; N fl ; B 14 0 536 691 ; +C 177 ; WX 500 ; N endash ; B 0 181 500 271 ; +C 178 ; WX 500 ; N dagger ; B 47 -134 453 691 ; +C 179 ; WX 500 ; N daggerdbl ; B 45 -132 456 691 ; +C 180 ; WX 250 ; N periodcentered ; B 41 248 210 417 ; +C 182 ; WX 540 ; N paragraph ; B 0 -186 519 676 ; +C 183 ; WX 350 ; N bullet ; B 35 198 315 478 ; +C 184 ; WX 333 ; N quotesinglbase ; B 79 -180 263 155 ; +C 185 ; WX 500 ; N quotedblbase ; B 14 -180 468 155 ; +C 186 ; WX 500 ; N quotedblright ; B 14 356 468 691 ; +C 187 ; WX 500 ; N guillemotright ; B 27 36 477 415 ; +C 188 ; WX 1000 ; N ellipsis ; B 82 -13 917 156 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -29 995 706 ; +C 191 ; WX 500 ; N questiondown ; B 55 -201 443 501 ; +C 193 ; WX 333 ; N grave ; B 8 528 246 713 ; +C 194 ; WX 333 ; N acute ; B 86 528 324 713 ; +C 195 ; WX 333 ; N circumflex ; B -2 528 335 704 ; +C 196 ; WX 333 ; N tilde ; B -16 547 349 674 ; +C 197 ; WX 333 ; N macron ; B 1 565 331 637 ; +C 198 ; WX 333 ; N breve ; B 15 528 318 691 ; +C 199 ; WX 333 ; N dotaccent ; B 103 537 230 667 ; +C 200 ; WX 333 ; N dieresis ; B -2 537 335 667 ; +C 202 ; WX 333 ; N ring ; B 60 527 273 740 ; +C 203 ; WX 333 ; N cedilla ; B 68 -218 294 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -13 528 425 713 ; +C 206 ; WX 333 ; N ogonek ; B 90 -173 319 44 ; +C 207 ; WX 333 ; N caron ; B -2 528 335 704 ; +C 208 ; WX 1000 ; N emdash ; B 0 181 1000 271 ; +C 225 ; WX 1000 ; N AE ; B 4 0 951 676 ; +C 227 ; WX 300 ; N ordfeminine ; B -1 397 301 688 ; +C 232 ; WX 667 ; N Lslash ; B 19 0 638 676 ; +C 233 ; WX 778 ; N Oslash ; B 35 -74 743 737 ; +C 234 ; WX 1000 ; N OE ; B 22 -5 981 684 ; +C 235 ; WX 330 ; N ordmasculine ; B 18 397 312 688 ; +C 241 ; WX 722 ; N ae ; B 33 -14 693 473 ; +C 245 ; WX 278 ; N dotlessi ; B 16 0 255 461 ; +C 248 ; WX 278 ; N lslash ; B -22 0 303 676 ; +C 249 ; WX 500 ; N oslash ; B 25 -92 476 549 ; +C 250 ; WX 722 ; N oe ; B 22 -14 696 473 ; +C 251 ; WX 556 ; N germandbls ; B 19 -12 517 691 ; +C -1 ; WX 667 ; N Zcaron ; B 28 0 634 914 ; +C -1 ; WX 444 ; N ccedilla ; B 25 -218 430 473 ; +C -1 ; WX 500 ; N ydieresis ; B 16 -205 480 667 ; +C -1 ; WX 500 ; N atilde ; B 25 -14 488 674 ; +C -1 ; WX 278 ; N icircumflex ; B -36 0 301 704 ; +C -1 ; WX 300 ; N threesuperior ; B 3 268 297 688 ; +C -1 ; WX 444 ; N ecircumflex ; B 25 -14 426 704 ; +C -1 ; WX 556 ; N thorn ; B 19 -205 524 676 ; +C -1 ; WX 444 ; N egrave ; B 25 -14 426 713 ; +C -1 ; WX 300 ; N twosuperior ; B 0 275 300 688 ; +C -1 ; WX 444 ; N eacute ; B 25 -14 426 713 ; +C -1 ; WX 500 ; N otilde ; B 25 -14 476 674 ; +C -1 ; WX 722 ; N Aacute ; B 9 0 689 923 ; +C -1 ; WX 500 ; N ocircumflex ; B 25 -14 476 704 ; +C -1 ; WX 500 ; N yacute ; B 16 -205 480 713 ; +C -1 ; WX 556 ; N udieresis ; B 16 -14 537 667 ; +C -1 ; WX 750 ; N threequarters ; B 23 -12 733 688 ; +C -1 ; WX 500 ; N acircumflex ; B 25 -14 488 704 ; +C -1 ; WX 722 ; N Eth ; B 6 0 690 676 ; +C -1 ; WX 444 ; N edieresis ; B 25 -14 426 667 ; +C -1 ; WX 556 ; N ugrave ; B 16 -14 537 713 ; +C -1 ; WX 1000 ; N trademark ; B 24 271 977 676 ; +C -1 ; WX 500 ; N ograve ; B 25 -14 476 713 ; +C -1 ; WX 389 ; N scaron ; B 25 -14 363 704 ; +C -1 ; WX 389 ; N Idieresis ; B 20 0 370 877 ; +C -1 ; WX 556 ; N uacute ; B 16 -14 537 713 ; +C -1 ; WX 500 ; N agrave ; B 25 -14 488 713 ; +C -1 ; WX 556 ; N ntilde ; B 21 0 539 674 ; +C -1 ; WX 500 ; N aring ; B 25 -14 488 740 ; +C -1 ; WX 444 ; N zcaron ; B 21 0 420 704 ; +C -1 ; WX 389 ; N Icircumflex ; B 20 0 370 914 ; +C -1 ; WX 722 ; N Ntilde ; B 16 -18 701 884 ; +C -1 ; WX 556 ; N ucircumflex ; B 16 -14 537 704 ; +C -1 ; WX 667 ; N Ecircumflex ; B 16 0 641 914 ; +C -1 ; WX 389 ; N Iacute ; B 20 0 370 923 ; +C -1 ; WX 722 ; N Ccedilla ; B 49 -218 687 691 ; +C -1 ; WX 778 ; N Odieresis ; B 35 -19 743 877 ; +C -1 ; WX 556 ; N Scaron ; B 35 -19 513 914 ; +C -1 ; WX 667 ; N Edieresis ; B 16 0 641 877 ; +C -1 ; WX 389 ; N Igrave ; B 20 0 370 923 ; +C -1 ; WX 500 ; N adieresis ; B 25 -14 488 667 ; +C -1 ; WX 778 ; N Ograve ; B 35 -19 743 923 ; +C -1 ; WX 667 ; N Egrave ; B 16 0 641 923 ; +C -1 ; WX 722 ; N Ydieresis ; B 15 0 699 877 ; +C -1 ; WX 747 ; N registered ; B 26 -19 721 691 ; +C -1 ; WX 778 ; N Otilde ; B 35 -19 743 884 ; +C -1 ; WX 750 ; N onequarter ; B 28 -12 743 688 ; +C -1 ; WX 722 ; N Ugrave ; B 16 -19 701 923 ; +C -1 ; WX 722 ; N Ucircumflex ; B 16 -19 701 914 ; +C -1 ; WX 611 ; N Thorn ; B 16 0 600 676 ; +C -1 ; WX 570 ; N divide ; B 33 -31 537 537 ; +C -1 ; WX 722 ; N Atilde ; B 9 0 689 884 ; +C -1 ; WX 722 ; N Uacute ; B 16 -19 701 923 ; +C -1 ; WX 778 ; N Ocircumflex ; B 35 -19 743 914 ; +C -1 ; WX 570 ; N logicalnot ; B 33 108 537 399 ; +C -1 ; WX 722 ; N Aring ; B 9 0 689 935 ; +C -1 ; WX 278 ; N idieresis ; B -36 0 301 667 ; +C -1 ; WX 278 ; N iacute ; B 16 0 290 713 ; +C -1 ; WX 500 ; N aacute ; B 25 -14 488 713 ; +C -1 ; WX 570 ; N plusminus ; B 33 0 537 506 ; +C -1 ; WX 570 ; N multiply ; B 48 16 522 490 ; +C -1 ; WX 722 ; N Udieresis ; B 16 -19 701 877 ; +C -1 ; WX 570 ; N minus ; B 33 209 537 297 ; +C -1 ; WX 300 ; N onesuperior ; B 28 275 273 688 ; +C -1 ; WX 667 ; N Eacute ; B 16 0 641 923 ; +C -1 ; WX 722 ; N Acircumflex ; B 9 0 689 914 ; +C -1 ; WX 747 ; N copyright ; B 26 -19 721 691 ; +C -1 ; WX 722 ; N Agrave ; B 9 0 689 923 ; +C -1 ; WX 500 ; N odieresis ; B 25 -14 476 667 ; +C -1 ; WX 500 ; N oacute ; B 25 -14 476 713 ; +C -1 ; WX 400 ; N degree ; B 57 402 343 688 ; +C -1 ; WX 278 ; N igrave ; B -26 0 255 713 ; +C -1 ; WX 556 ; N mu ; B 33 -206 536 461 ; +C -1 ; WX 778 ; N Oacute ; B 35 -19 743 923 ; +C -1 ; WX 500 ; N eth ; B 25 -14 476 691 ; +C -1 ; WX 722 ; N Adieresis ; B 9 0 689 877 ; +C -1 ; WX 722 ; N Yacute ; B 15 0 699 928 ; +C -1 ; WX 220 ; N brokenbar ; B 66 -19 154 691 ; +C -1 ; WX 750 ; N onehalf ; B -7 -12 775 688 ; +EndCharMetrics +StartKernData +StartKernPairs 283 + +KPX A y -74 +KPX A w -90 +KPX A v -100 +KPX A u -50 +KPX A quoteright -74 +KPX A quotedblright 0 +KPX A p -25 +KPX A Y -100 +KPX A W -130 +KPX A V -145 +KPX A U -50 +KPX A T -95 +KPX A Q -45 +KPX A O -45 +KPX A G -55 +KPX A C -55 + +KPX B period 0 +KPX B comma 0 +KPX B U -10 +KPX B A -30 + +KPX D period -20 +KPX D comma 0 +KPX D Y -40 +KPX D W -40 +KPX D V -40 +KPX D A -35 + +KPX F r 0 +KPX F period -110 +KPX F o -25 +KPX F i 0 +KPX F e -25 +KPX F comma -92 +KPX F a -25 +KPX F A -90 + +KPX G period 0 +KPX G comma 0 + +KPX J u -15 +KPX J period -20 +KPX J o -15 +KPX J e -15 +KPX J comma 0 +KPX J a -15 +KPX J A -30 + +KPX K y -45 +KPX K u -15 +KPX K o -25 +KPX K e -25 +KPX K O -30 + +KPX L y -55 +KPX L quoteright -110 +KPX L quotedblright -20 +KPX L Y -92 +KPX L W -92 +KPX L V -92 +KPX L T -92 + +KPX N period 0 +KPX N comma 0 +KPX N A -20 + +KPX O period 0 +KPX O comma 0 +KPX O Y -50 +KPX O X -40 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -40 + +KPX P period -110 +KPX P o -20 +KPX P e -20 +KPX P comma -92 +KPX P a -10 +KPX P A -74 + +KPX Q period -20 +KPX Q comma 0 +KPX Q U -10 + +KPX R Y -35 +KPX R W -35 +KPX R V -55 +KPX R U -30 +KPX R T -40 +KPX R O -30 + +KPX S period 0 +KPX S comma 0 + +KPX T y -74 +KPX T w -74 +KPX T u -92 +KPX T semicolon -74 +KPX T r -74 +KPX T period -90 +KPX T o -92 +KPX T i -18 +KPX T hyphen -92 +KPX T h 0 +KPX T e -92 +KPX T comma -74 +KPX T colon -74 +KPX T a -92 +KPX T O -18 +KPX T A -90 + +KPX U period -50 +KPX U comma -50 +KPX U A -60 + +KPX V u -92 +KPX V semicolon -92 +KPX V period -145 +KPX V o -100 +KPX V i -37 +KPX V hyphen -74 +KPX V e -100 +KPX V comma -129 +KPX V colon -92 +KPX V a -92 +KPX V O -45 +KPX V G -30 +KPX V A -135 + +KPX W y -60 +KPX W u -50 +KPX W semicolon -55 +KPX W period -92 +KPX W o -75 +KPX W i -18 +KPX W hyphen -37 +KPX W h 0 +KPX W e -65 +KPX W comma -92 +KPX W colon -55 +KPX W a -65 +KPX W O -10 +KPX W A -120 + +KPX Y u -92 +KPX Y semicolon -92 +KPX Y period -92 +KPX Y o -111 +KPX Y i -37 +KPX Y hyphen -92 +KPX Y e -111 +KPX Y comma -92 +KPX Y colon -92 +KPX Y a -85 +KPX Y O -35 +KPX Y A -110 + +KPX a y 0 +KPX a w 0 +KPX a v -25 +KPX a t 0 +KPX a p 0 +KPX a g 0 +KPX a b 0 + +KPX b y 0 +KPX b v -15 +KPX b u -20 +KPX b period -40 +KPX b l 0 +KPX b comma 0 +KPX b b -10 + +KPX c y 0 +KPX c period 0 +KPX c l 0 +KPX c k 0 +KPX c h 0 +KPX c comma 0 + +KPX colon space 0 + +KPX comma space 0 +KPX comma quoteright -55 +KPX comma quotedblright -45 + +KPX d y 0 +KPX d w -15 +KPX d v 0 +KPX d period 0 +KPX d d 0 +KPX d comma 0 + +KPX e y 0 +KPX e x 0 +KPX e w 0 +KPX e v -15 +KPX e period 0 +KPX e p 0 +KPX e g 0 +KPX e comma 0 +KPX e b 0 + +KPX f quoteright 55 +KPX f quotedblright 50 +KPX f period -15 +KPX f o -25 +KPX f l 0 +KPX f i -25 +KPX f f 0 +KPX f e 0 +KPX f dotlessi -35 +KPX f comma -15 +KPX f a 0 + +KPX g y 0 +KPX g r 0 +KPX g period -15 +KPX g o 0 +KPX g i 0 +KPX g g 0 +KPX g e 0 +KPX g comma 0 +KPX g a 0 + +KPX h y -15 + +KPX i v -10 + +KPX k y -15 +KPX k o -15 +KPX k e -10 + +KPX l y 0 +KPX l w 0 + +KPX m y 0 +KPX m u 0 + +KPX n y 0 +KPX n v -40 +KPX n u 0 + +KPX o y 0 +KPX o x 0 +KPX o w -10 +KPX o v -10 +KPX o g 0 + +KPX p y 0 + +KPX period quoteright -55 +KPX period quotedblright -55 + +KPX quotedblleft quoteleft 0 +KPX quotedblleft A -10 + +KPX quotedblright space 0 + +KPX quoteleft quoteleft -63 +KPX quoteleft A -10 + +KPX quoteright v -20 +KPX quoteright t 0 +KPX quoteright space -74 +KPX quoteright s -37 +KPX quoteright r -20 +KPX quoteright quoteright -63 +KPX quoteright quotedblright 0 +KPX quoteright l 0 +KPX quoteright d -20 + +KPX r y 0 +KPX r v -10 +KPX r u 0 +KPX r t 0 +KPX r s 0 +KPX r r 0 +KPX r q -18 +KPX r period -100 +KPX r p -10 +KPX r o -18 +KPX r n -15 +KPX r m 0 +KPX r l 0 +KPX r k 0 +KPX r i 0 +KPX r hyphen -37 +KPX r g -10 +KPX r e -18 +KPX r d 0 +KPX r comma -92 +KPX r c -18 +KPX r a 0 + +KPX s w 0 + +KPX space quoteleft 0 +KPX space quotedblleft 0 +KPX space Y -55 +KPX space W -30 +KPX space V -45 +KPX space T -30 +KPX space A -55 + +KPX v period -70 +KPX v o -10 +KPX v e -10 +KPX v comma -55 +KPX v a -10 + +KPX w period -70 +KPX w o -10 +KPX w h 0 +KPX w e 0 +KPX w comma -55 +KPX w a 0 + +KPX x e 0 + +KPX y period -70 +KPX y o -25 +KPX y e -10 +KPX y comma -55 +KPX y a 0 + +KPX z o 0 +KPX z e 0 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 188 210 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 188 210 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 188 210 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 188 210 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 180 195 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 188 210 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 208 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 174 210 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 174 210 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 174 210 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 174 210 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 28 210 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 28 210 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 28 210 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 28 210 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 195 210 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 223 210 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 223 210 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 223 210 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 223 210 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 223 210 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 112 210 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 222 210 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 222 210 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 222 210 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 222 210 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 210 215 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 215 210 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 167 210 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 77 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 77 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 77 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 77 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 77 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 77 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 69 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 62 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 62 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 62 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 62 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -34 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -34 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -34 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -34 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 112 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 84 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 84 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 84 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 84 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 28 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 105 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 105 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 105 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 105 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 84 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 56 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmbi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmbi8a.afm new file mode 100644 index 00000000..25ab54ea --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmbi8a.afm @@ -0,0 +1,648 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Mar 20 13:14:55 1990 +Comment UniqueID 28425 +Comment VMusage 32721 39613 +FontName Times-BoldItalic +FullName Times Bold Italic +FamilyName Times +Weight Bold +ItalicAngle -15 +IsFixedPitch false +FontBBox -200 -218 996 921 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.009 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 669 +XHeight 462 +Ascender 699 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 389 ; N exclam ; B 67 -13 370 684 ; +C 34 ; WX 555 ; N quotedbl ; B 136 398 536 685 ; +C 35 ; WX 500 ; N numbersign ; B -33 0 533 700 ; +C 36 ; WX 500 ; N dollar ; B -20 -100 497 733 ; +C 37 ; WX 833 ; N percent ; B 39 -10 793 692 ; +C 38 ; WX 778 ; N ampersand ; B 5 -19 699 682 ; +C 39 ; WX 333 ; N quoteright ; B 98 369 302 685 ; +C 40 ; WX 333 ; N parenleft ; B 28 -179 344 685 ; +C 41 ; WX 333 ; N parenright ; B -44 -179 271 685 ; +C 42 ; WX 500 ; N asterisk ; B 65 249 456 685 ; +C 43 ; WX 570 ; N plus ; B 33 0 537 506 ; +C 44 ; WX 250 ; N comma ; B -60 -182 144 134 ; +C 45 ; WX 333 ; N hyphen ; B 2 166 271 282 ; +C 46 ; WX 250 ; N period ; B -9 -13 139 135 ; +C 47 ; WX 278 ; N slash ; B -64 -18 342 685 ; +C 48 ; WX 500 ; N zero ; B 17 -14 477 683 ; +C 49 ; WX 500 ; N one ; B 5 0 419 683 ; +C 50 ; WX 500 ; N two ; B -27 0 446 683 ; +C 51 ; WX 500 ; N three ; B -15 -13 450 683 ; +C 52 ; WX 500 ; N four ; B -15 0 503 683 ; +C 53 ; WX 500 ; N five ; B -11 -13 487 669 ; +C 54 ; WX 500 ; N six ; B 23 -15 509 679 ; +C 55 ; WX 500 ; N seven ; B 52 0 525 669 ; +C 56 ; WX 500 ; N eight ; B 3 -13 476 683 ; +C 57 ; WX 500 ; N nine ; B -12 -10 475 683 ; +C 58 ; WX 333 ; N colon ; B 23 -13 264 459 ; +C 59 ; WX 333 ; N semicolon ; B -25 -183 264 459 ; +C 60 ; WX 570 ; N less ; B 31 -8 539 514 ; +C 61 ; WX 570 ; N equal ; B 33 107 537 399 ; +C 62 ; WX 570 ; N greater ; B 31 -8 539 514 ; +C 63 ; WX 500 ; N question ; B 79 -13 470 684 ; +C 64 ; WX 832 ; N at ; B 63 -18 770 685 ; +C 65 ; WX 667 ; N A ; B -67 0 593 683 ; +C 66 ; WX 667 ; N B ; B -24 0 624 669 ; +C 67 ; WX 667 ; N C ; B 32 -18 677 685 ; +C 68 ; WX 722 ; N D ; B -46 0 685 669 ; +C 69 ; WX 667 ; N E ; B -27 0 653 669 ; +C 70 ; WX 667 ; N F ; B -13 0 660 669 ; +C 71 ; WX 722 ; N G ; B 21 -18 706 685 ; +C 72 ; WX 778 ; N H ; B -24 0 799 669 ; +C 73 ; WX 389 ; N I ; B -32 0 406 669 ; +C 74 ; WX 500 ; N J ; B -46 -99 524 669 ; +C 75 ; WX 667 ; N K ; B -21 0 702 669 ; +C 76 ; WX 611 ; N L ; B -22 0 590 669 ; +C 77 ; WX 889 ; N M ; B -29 -12 917 669 ; +C 78 ; WX 722 ; N N ; B -27 -15 748 669 ; +C 79 ; WX 722 ; N O ; B 27 -18 691 685 ; +C 80 ; WX 611 ; N P ; B -27 0 613 669 ; +C 81 ; WX 722 ; N Q ; B 27 -208 691 685 ; +C 82 ; WX 667 ; N R ; B -29 0 623 669 ; +C 83 ; WX 556 ; N S ; B 2 -18 526 685 ; +C 84 ; WX 611 ; N T ; B 50 0 650 669 ; +C 85 ; WX 722 ; N U ; B 67 -18 744 669 ; +C 86 ; WX 667 ; N V ; B 65 -18 715 669 ; +C 87 ; WX 889 ; N W ; B 65 -18 940 669 ; +C 88 ; WX 667 ; N X ; B -24 0 694 669 ; +C 89 ; WX 611 ; N Y ; B 73 0 659 669 ; +C 90 ; WX 611 ; N Z ; B -11 0 590 669 ; +C 91 ; WX 333 ; N bracketleft ; B -37 -159 362 674 ; +C 92 ; WX 278 ; N backslash ; B -1 -18 279 685 ; +C 93 ; WX 333 ; N bracketright ; B -56 -157 343 674 ; +C 94 ; WX 570 ; N asciicircum ; B 67 304 503 669 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 128 369 332 685 ; +C 97 ; WX 500 ; N a ; B -21 -14 455 462 ; +C 98 ; WX 500 ; N b ; B -14 -13 444 699 ; +C 99 ; WX 444 ; N c ; B -5 -13 392 462 ; +C 100 ; WX 500 ; N d ; B -21 -13 517 699 ; +C 101 ; WX 444 ; N e ; B 5 -13 398 462 ; +C 102 ; WX 333 ; N f ; B -169 -205 446 698 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B -52 -203 478 462 ; +C 104 ; WX 556 ; N h ; B -13 -9 498 699 ; +C 105 ; WX 278 ; N i ; B 2 -9 263 684 ; +C 106 ; WX 278 ; N j ; B -189 -207 279 684 ; +C 107 ; WX 500 ; N k ; B -23 -8 483 699 ; +C 108 ; WX 278 ; N l ; B 2 -9 290 699 ; +C 109 ; WX 778 ; N m ; B -14 -9 722 462 ; +C 110 ; WX 556 ; N n ; B -6 -9 493 462 ; +C 111 ; WX 500 ; N o ; B -3 -13 441 462 ; +C 112 ; WX 500 ; N p ; B -120 -205 446 462 ; +C 113 ; WX 500 ; N q ; B 1 -205 471 462 ; +C 114 ; WX 389 ; N r ; B -21 0 389 462 ; +C 115 ; WX 389 ; N s ; B -19 -13 333 462 ; +C 116 ; WX 278 ; N t ; B -11 -9 281 594 ; +C 117 ; WX 556 ; N u ; B 15 -9 492 462 ; +C 118 ; WX 444 ; N v ; B 16 -13 401 462 ; +C 119 ; WX 667 ; N w ; B 16 -13 614 462 ; +C 120 ; WX 500 ; N x ; B -46 -13 469 462 ; +C 121 ; WX 444 ; N y ; B -94 -205 392 462 ; +C 122 ; WX 389 ; N z ; B -43 -78 368 449 ; +C 123 ; WX 348 ; N braceleft ; B 5 -187 436 686 ; +C 124 ; WX 220 ; N bar ; B 66 -18 154 685 ; +C 125 ; WX 348 ; N braceright ; B -129 -187 302 686 ; +C 126 ; WX 570 ; N asciitilde ; B 54 173 516 333 ; +C 161 ; WX 389 ; N exclamdown ; B 19 -205 322 492 ; +C 162 ; WX 500 ; N cent ; B 42 -143 439 576 ; +C 163 ; WX 500 ; N sterling ; B -32 -12 510 683 ; +C 164 ; WX 167 ; N fraction ; B -169 -14 324 683 ; +C 165 ; WX 500 ; N yen ; B 33 0 628 669 ; +C 166 ; WX 500 ; N florin ; B -87 -156 537 707 ; +C 167 ; WX 500 ; N section ; B 36 -143 459 685 ; +C 168 ; WX 500 ; N currency ; B -26 34 526 586 ; +C 169 ; WX 278 ; N quotesingle ; B 128 398 268 685 ; +C 170 ; WX 500 ; N quotedblleft ; B 53 369 513 685 ; +C 171 ; WX 500 ; N guillemotleft ; B 12 32 468 415 ; +C 172 ; WX 333 ; N guilsinglleft ; B 32 32 303 415 ; +C 173 ; WX 333 ; N guilsinglright ; B 10 32 281 415 ; +C 174 ; WX 556 ; N fi ; B -188 -205 514 703 ; +C 175 ; WX 556 ; N fl ; B -186 -205 553 704 ; +C 177 ; WX 500 ; N endash ; B -40 178 477 269 ; +C 178 ; WX 500 ; N dagger ; B 91 -145 494 685 ; +C 179 ; WX 500 ; N daggerdbl ; B 10 -139 493 685 ; +C 180 ; WX 250 ; N periodcentered ; B 51 257 199 405 ; +C 182 ; WX 500 ; N paragraph ; B -57 -193 562 669 ; +C 183 ; WX 350 ; N bullet ; B 0 175 350 525 ; +C 184 ; WX 333 ; N quotesinglbase ; B -5 -182 199 134 ; +C 185 ; WX 500 ; N quotedblbase ; B -57 -182 403 134 ; +C 186 ; WX 500 ; N quotedblright ; B 53 369 513 685 ; +C 187 ; WX 500 ; N guillemotright ; B 12 32 468 415 ; +C 188 ; WX 1000 ; N ellipsis ; B 40 -13 852 135 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -29 996 706 ; +C 191 ; WX 500 ; N questiondown ; B 30 -205 421 492 ; +C 193 ; WX 333 ; N grave ; B 85 516 297 697 ; +C 194 ; WX 333 ; N acute ; B 139 516 379 697 ; +C 195 ; WX 333 ; N circumflex ; B 40 516 367 690 ; +C 196 ; WX 333 ; N tilde ; B 48 536 407 655 ; +C 197 ; WX 333 ; N macron ; B 51 553 393 623 ; +C 198 ; WX 333 ; N breve ; B 71 516 387 678 ; +C 199 ; WX 333 ; N dotaccent ; B 163 525 293 655 ; +C 200 ; WX 333 ; N dieresis ; B 55 525 397 655 ; +C 202 ; WX 333 ; N ring ; B 127 516 340 729 ; +C 203 ; WX 333 ; N cedilla ; B -80 -218 156 5 ; +C 205 ; WX 333 ; N hungarumlaut ; B 69 516 498 697 ; +C 206 ; WX 333 ; N ogonek ; B -40 -173 189 44 ; +C 207 ; WX 333 ; N caron ; B 79 516 411 690 ; +C 208 ; WX 1000 ; N emdash ; B -40 178 977 269 ; +C 225 ; WX 944 ; N AE ; B -64 0 918 669 ; +C 227 ; WX 266 ; N ordfeminine ; B 16 399 330 685 ; +C 232 ; WX 611 ; N Lslash ; B -22 0 590 669 ; +C 233 ; WX 722 ; N Oslash ; B 27 -125 691 764 ; +C 234 ; WX 944 ; N OE ; B 23 -8 946 677 ; +C 235 ; WX 300 ; N ordmasculine ; B 56 400 347 685 ; +C 241 ; WX 722 ; N ae ; B -5 -13 673 462 ; +C 245 ; WX 278 ; N dotlessi ; B 2 -9 238 462 ; +C 248 ; WX 278 ; N lslash ; B -13 -9 301 699 ; +C 249 ; WX 500 ; N oslash ; B -3 -119 441 560 ; +C 250 ; WX 722 ; N oe ; B 6 -13 674 462 ; +C 251 ; WX 500 ; N germandbls ; B -200 -200 473 705 ; +C -1 ; WX 611 ; N Zcaron ; B -11 0 590 897 ; +C -1 ; WX 444 ; N ccedilla ; B -24 -218 392 462 ; +C -1 ; WX 444 ; N ydieresis ; B -94 -205 438 655 ; +C -1 ; WX 500 ; N atilde ; B -21 -14 491 655 ; +C -1 ; WX 278 ; N icircumflex ; B -2 -9 325 690 ; +C -1 ; WX 300 ; N threesuperior ; B 17 265 321 683 ; +C -1 ; WX 444 ; N ecircumflex ; B 5 -13 423 690 ; +C -1 ; WX 500 ; N thorn ; B -120 -205 446 699 ; +C -1 ; WX 444 ; N egrave ; B 5 -13 398 697 ; +C -1 ; WX 300 ; N twosuperior ; B 2 274 313 683 ; +C -1 ; WX 444 ; N eacute ; B 5 -13 435 697 ; +C -1 ; WX 500 ; N otilde ; B -3 -13 491 655 ; +C -1 ; WX 667 ; N Aacute ; B -67 0 593 904 ; +C -1 ; WX 500 ; N ocircumflex ; B -3 -13 451 690 ; +C -1 ; WX 444 ; N yacute ; B -94 -205 435 697 ; +C -1 ; WX 556 ; N udieresis ; B 15 -9 494 655 ; +C -1 ; WX 750 ; N threequarters ; B 7 -14 726 683 ; +C -1 ; WX 500 ; N acircumflex ; B -21 -14 455 690 ; +C -1 ; WX 722 ; N Eth ; B -31 0 700 669 ; +C -1 ; WX 444 ; N edieresis ; B 5 -13 443 655 ; +C -1 ; WX 556 ; N ugrave ; B 15 -9 492 697 ; +C -1 ; WX 1000 ; N trademark ; B 32 263 968 669 ; +C -1 ; WX 500 ; N ograve ; B -3 -13 441 697 ; +C -1 ; WX 389 ; N scaron ; B -19 -13 439 690 ; +C -1 ; WX 389 ; N Idieresis ; B -32 0 445 862 ; +C -1 ; WX 556 ; N uacute ; B 15 -9 492 697 ; +C -1 ; WX 500 ; N agrave ; B -21 -14 455 697 ; +C -1 ; WX 556 ; N ntilde ; B -6 -9 504 655 ; +C -1 ; WX 500 ; N aring ; B -21 -14 455 729 ; +C -1 ; WX 389 ; N zcaron ; B -43 -78 424 690 ; +C -1 ; WX 389 ; N Icircumflex ; B -32 0 420 897 ; +C -1 ; WX 722 ; N Ntilde ; B -27 -15 748 862 ; +C -1 ; WX 556 ; N ucircumflex ; B 15 -9 492 690 ; +C -1 ; WX 667 ; N Ecircumflex ; B -27 0 653 897 ; +C -1 ; WX 389 ; N Iacute ; B -32 0 412 904 ; +C -1 ; WX 667 ; N Ccedilla ; B 32 -218 677 685 ; +C -1 ; WX 722 ; N Odieresis ; B 27 -18 691 862 ; +C -1 ; WX 556 ; N Scaron ; B 2 -18 526 897 ; +C -1 ; WX 667 ; N Edieresis ; B -27 0 653 862 ; +C -1 ; WX 389 ; N Igrave ; B -32 0 406 904 ; +C -1 ; WX 500 ; N adieresis ; B -21 -14 471 655 ; +C -1 ; WX 722 ; N Ograve ; B 27 -18 691 904 ; +C -1 ; WX 667 ; N Egrave ; B -27 0 653 904 ; +C -1 ; WX 611 ; N Ydieresis ; B 73 0 659 862 ; +C -1 ; WX 747 ; N registered ; B 30 -18 718 685 ; +C -1 ; WX 722 ; N Otilde ; B 27 -18 691 862 ; +C -1 ; WX 750 ; N onequarter ; B 7 -14 721 683 ; +C -1 ; WX 722 ; N Ugrave ; B 67 -18 744 904 ; +C -1 ; WX 722 ; N Ucircumflex ; B 67 -18 744 897 ; +C -1 ; WX 611 ; N Thorn ; B -27 0 573 669 ; +C -1 ; WX 570 ; N divide ; B 33 -29 537 535 ; +C -1 ; WX 667 ; N Atilde ; B -67 0 593 862 ; +C -1 ; WX 722 ; N Uacute ; B 67 -18 744 904 ; +C -1 ; WX 722 ; N Ocircumflex ; B 27 -18 691 897 ; +C -1 ; WX 606 ; N logicalnot ; B 51 108 555 399 ; +C -1 ; WX 667 ; N Aring ; B -67 0 593 921 ; +C -1 ; WX 278 ; N idieresis ; B 2 -9 360 655 ; +C -1 ; WX 278 ; N iacute ; B 2 -9 352 697 ; +C -1 ; WX 500 ; N aacute ; B -21 -14 463 697 ; +C -1 ; WX 570 ; N plusminus ; B 33 0 537 506 ; +C -1 ; WX 570 ; N multiply ; B 48 16 522 490 ; +C -1 ; WX 722 ; N Udieresis ; B 67 -18 744 862 ; +C -1 ; WX 606 ; N minus ; B 51 209 555 297 ; +C -1 ; WX 300 ; N onesuperior ; B 30 274 301 683 ; +C -1 ; WX 667 ; N Eacute ; B -27 0 653 904 ; +C -1 ; WX 667 ; N Acircumflex ; B -67 0 593 897 ; +C -1 ; WX 747 ; N copyright ; B 30 -18 718 685 ; +C -1 ; WX 667 ; N Agrave ; B -67 0 593 904 ; +C -1 ; WX 500 ; N odieresis ; B -3 -13 466 655 ; +C -1 ; WX 500 ; N oacute ; B -3 -13 463 697 ; +C -1 ; WX 400 ; N degree ; B 83 397 369 683 ; +C -1 ; WX 278 ; N igrave ; B 2 -9 260 697 ; +C -1 ; WX 576 ; N mu ; B -60 -207 516 449 ; +C -1 ; WX 722 ; N Oacute ; B 27 -18 691 904 ; +C -1 ; WX 500 ; N eth ; B -3 -13 454 699 ; +C -1 ; WX 667 ; N Adieresis ; B -67 0 593 862 ; +C -1 ; WX 611 ; N Yacute ; B 73 0 659 904 ; +C -1 ; WX 220 ; N brokenbar ; B 66 -18 154 685 ; +C -1 ; WX 750 ; N onehalf ; B -9 -14 723 683 ; +EndCharMetrics +StartKernData +StartKernPairs 283 + +KPX A y -74 +KPX A w -74 +KPX A v -74 +KPX A u -30 +KPX A quoteright -74 +KPX A quotedblright 0 +KPX A p 0 +KPX A Y -70 +KPX A W -100 +KPX A V -95 +KPX A U -50 +KPX A T -55 +KPX A Q -55 +KPX A O -50 +KPX A G -60 +KPX A C -65 + +KPX B period 0 +KPX B comma 0 +KPX B U -10 +KPX B A -25 + +KPX D period 0 +KPX D comma 0 +KPX D Y -50 +KPX D W -40 +KPX D V -50 +KPX D A -25 + +KPX F r -50 +KPX F period -129 +KPX F o -70 +KPX F i -40 +KPX F e -100 +KPX F comma -129 +KPX F a -95 +KPX F A -100 + +KPX G period 0 +KPX G comma 0 + +KPX J u -40 +KPX J period -10 +KPX J o -40 +KPX J e -40 +KPX J comma -10 +KPX J a -40 +KPX J A -25 + +KPX K y -20 +KPX K u -20 +KPX K o -25 +KPX K e -25 +KPX K O -30 + +KPX L y -37 +KPX L quoteright -55 +KPX L quotedblright 0 +KPX L Y -37 +KPX L W -37 +KPX L V -37 +KPX L T -18 + +KPX N period 0 +KPX N comma 0 +KPX N A -30 + +KPX O period 0 +KPX O comma 0 +KPX O Y -50 +KPX O X -40 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -40 + +KPX P period -129 +KPX P o -55 +KPX P e -50 +KPX P comma -129 +KPX P a -40 +KPX P A -85 + +KPX Q period 0 +KPX Q comma 0 +KPX Q U -10 + +KPX R Y -18 +KPX R W -18 +KPX R V -18 +KPX R U -40 +KPX R T -30 +KPX R O -40 + +KPX S period 0 +KPX S comma 0 + +KPX T y -37 +KPX T w -37 +KPX T u -37 +KPX T semicolon -74 +KPX T r -37 +KPX T period -92 +KPX T o -95 +KPX T i -37 +KPX T hyphen -92 +KPX T h 0 +KPX T e -92 +KPX T comma -92 +KPX T colon -74 +KPX T a -92 +KPX T O -18 +KPX T A -55 + +KPX U period 0 +KPX U comma 0 +KPX U A -45 + +KPX V u -55 +KPX V semicolon -74 +KPX V period -129 +KPX V o -111 +KPX V i -55 +KPX V hyphen -70 +KPX V e -111 +KPX V comma -129 +KPX V colon -74 +KPX V a -111 +KPX V O -30 +KPX V G -10 +KPX V A -85 + +KPX W y -55 +KPX W u -55 +KPX W semicolon -55 +KPX W period -74 +KPX W o -80 +KPX W i -37 +KPX W hyphen -50 +KPX W h 0 +KPX W e -90 +KPX W comma -74 +KPX W colon -55 +KPX W a -85 +KPX W O -15 +KPX W A -74 + +KPX Y u -92 +KPX Y semicolon -92 +KPX Y period -74 +KPX Y o -111 +KPX Y i -55 +KPX Y hyphen -92 +KPX Y e -111 +KPX Y comma -92 +KPX Y colon -92 +KPX Y a -92 +KPX Y O -25 +KPX Y A -74 + +KPX a y 0 +KPX a w 0 +KPX a v 0 +KPX a t 0 +KPX a p 0 +KPX a g 0 +KPX a b 0 + +KPX b y 0 +KPX b v 0 +KPX b u -20 +KPX b period -40 +KPX b l 0 +KPX b comma 0 +KPX b b -10 + +KPX c y 0 +KPX c period 0 +KPX c l 0 +KPX c k -10 +KPX c h -10 +KPX c comma 0 + +KPX colon space 0 + +KPX comma space 0 +KPX comma quoteright -95 +KPX comma quotedblright -95 + +KPX d y 0 +KPX d w 0 +KPX d v 0 +KPX d period 0 +KPX d d 0 +KPX d comma 0 + +KPX e y 0 +KPX e x 0 +KPX e w 0 +KPX e v 0 +KPX e period 0 +KPX e p 0 +KPX e g 0 +KPX e comma 0 +KPX e b -10 + +KPX f quoteright 55 +KPX f quotedblright 0 +KPX f period -10 +KPX f o -10 +KPX f l 0 +KPX f i 0 +KPX f f -18 +KPX f e -10 +KPX f dotlessi -30 +KPX f comma -10 +KPX f a 0 + +KPX g y 0 +KPX g r 0 +KPX g period 0 +KPX g o 0 +KPX g i 0 +KPX g g 0 +KPX g e 0 +KPX g comma 0 +KPX g a 0 + +KPX h y 0 + +KPX i v 0 + +KPX k y 0 +KPX k o -10 +KPX k e -30 + +KPX l y 0 +KPX l w 0 + +KPX m y 0 +KPX m u 0 + +KPX n y 0 +KPX n v -40 +KPX n u 0 + +KPX o y -10 +KPX o x -10 +KPX o w -25 +KPX o v -15 +KPX o g 0 + +KPX p y 0 + +KPX period quoteright -95 +KPX period quotedblright -95 + +KPX quotedblleft quoteleft 0 +KPX quotedblleft A 0 + +KPX quotedblright space 0 + +KPX quoteleft quoteleft -74 +KPX quoteleft A 0 + +KPX quoteright v -15 +KPX quoteright t -37 +KPX quoteright space -74 +KPX quoteright s -74 +KPX quoteright r -15 +KPX quoteright quoteright -74 +KPX quoteright quotedblright 0 +KPX quoteright l 0 +KPX quoteright d -15 + +KPX r y 0 +KPX r v 0 +KPX r u 0 +KPX r t 0 +KPX r s 0 +KPX r r 0 +KPX r q 0 +KPX r period -65 +KPX r p 0 +KPX r o 0 +KPX r n 0 +KPX r m 0 +KPX r l 0 +KPX r k 0 +KPX r i 0 +KPX r hyphen 0 +KPX r g 0 +KPX r e 0 +KPX r d 0 +KPX r comma -65 +KPX r c 0 +KPX r a 0 + +KPX s w 0 + +KPX space quoteleft 0 +KPX space quotedblleft 0 +KPX space Y -70 +KPX space W -70 +KPX space V -70 +KPX space T 0 +KPX space A -37 + +KPX v period -37 +KPX v o -15 +KPX v e -15 +KPX v comma -37 +KPX v a 0 + +KPX w period -37 +KPX w o -15 +KPX w h 0 +KPX w e -10 +KPX w comma -37 +KPX w a -10 + +KPX x e -10 + +KPX y period -37 +KPX y o 0 +KPX y e 0 +KPX y comma -37 +KPX y a 0 + +KPX z o 0 +KPX z e 0 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 172 207 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 187 207 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 167 207 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 172 207 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 157 192 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 167 207 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 167 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 172 207 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 187 207 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 187 207 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 172 207 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 33 207 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 53 207 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 48 207 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 33 207 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 210 207 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 200 207 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 230 207 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 215 207 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 200 207 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 215 207 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 112 207 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 210 207 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 230 207 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 230 207 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 200 207 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 154 207 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 169 207 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 207 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 84 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 84 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 74 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 74 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 84 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 84 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 56 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 56 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 46 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 46 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -42 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -37 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -37 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 97 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 84 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 69 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 74 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 84 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 28 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 112 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 112 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 97 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 102 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 56 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 41 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 13 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmr8a.afm new file mode 100644 index 00000000..e5092b5c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmr8a.afm @@ -0,0 +1,648 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Mar 20 12:15:44 1990 +Comment UniqueID 28416 +Comment VMusage 30487 37379 +FontName Times-Roman +FullName Times Roman +FamilyName Times +Weight Roman +ItalicAngle 0 +IsFixedPitch false +FontBBox -168 -218 1000 898 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 662 +XHeight 450 +Ascender 683 +Descender -217 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 130 -9 238 676 ; +C 34 ; WX 408 ; N quotedbl ; B 77 431 331 676 ; +C 35 ; WX 500 ; N numbersign ; B 5 0 496 662 ; +C 36 ; WX 500 ; N dollar ; B 44 -87 457 727 ; +C 37 ; WX 833 ; N percent ; B 61 -13 772 676 ; +C 38 ; WX 778 ; N ampersand ; B 42 -13 750 676 ; +C 39 ; WX 333 ; N quoteright ; B 79 433 218 676 ; +C 40 ; WX 333 ; N parenleft ; B 48 -177 304 676 ; +C 41 ; WX 333 ; N parenright ; B 29 -177 285 676 ; +C 42 ; WX 500 ; N asterisk ; B 69 265 432 676 ; +C 43 ; WX 564 ; N plus ; B 30 0 534 506 ; +C 44 ; WX 250 ; N comma ; B 56 -141 195 102 ; +C 45 ; WX 333 ; N hyphen ; B 39 194 285 257 ; +C 46 ; WX 250 ; N period ; B 70 -11 181 100 ; +C 47 ; WX 278 ; N slash ; B -9 -14 287 676 ; +C 48 ; WX 500 ; N zero ; B 24 -14 476 676 ; +C 49 ; WX 500 ; N one ; B 111 0 394 676 ; +C 50 ; WX 500 ; N two ; B 30 0 475 676 ; +C 51 ; WX 500 ; N three ; B 43 -14 431 676 ; +C 52 ; WX 500 ; N four ; B 12 0 472 676 ; +C 53 ; WX 500 ; N five ; B 32 -14 438 688 ; +C 54 ; WX 500 ; N six ; B 34 -14 468 684 ; +C 55 ; WX 500 ; N seven ; B 20 -8 449 662 ; +C 56 ; WX 500 ; N eight ; B 56 -14 445 676 ; +C 57 ; WX 500 ; N nine ; B 30 -22 459 676 ; +C 58 ; WX 278 ; N colon ; B 81 -11 192 459 ; +C 59 ; WX 278 ; N semicolon ; B 80 -141 219 459 ; +C 60 ; WX 564 ; N less ; B 28 -8 536 514 ; +C 61 ; WX 564 ; N equal ; B 30 120 534 386 ; +C 62 ; WX 564 ; N greater ; B 28 -8 536 514 ; +C 63 ; WX 444 ; N question ; B 68 -8 414 676 ; +C 64 ; WX 921 ; N at ; B 116 -14 809 676 ; +C 65 ; WX 722 ; N A ; B 15 0 706 674 ; +C 66 ; WX 667 ; N B ; B 17 0 593 662 ; +C 67 ; WX 667 ; N C ; B 28 -14 633 676 ; +C 68 ; WX 722 ; N D ; B 16 0 685 662 ; +C 69 ; WX 611 ; N E ; B 12 0 597 662 ; +C 70 ; WX 556 ; N F ; B 12 0 546 662 ; +C 71 ; WX 722 ; N G ; B 32 -14 709 676 ; +C 72 ; WX 722 ; N H ; B 19 0 702 662 ; +C 73 ; WX 333 ; N I ; B 18 0 315 662 ; +C 74 ; WX 389 ; N J ; B 10 -14 370 662 ; +C 75 ; WX 722 ; N K ; B 34 0 723 662 ; +C 76 ; WX 611 ; N L ; B 12 0 598 662 ; +C 77 ; WX 889 ; N M ; B 12 0 863 662 ; +C 78 ; WX 722 ; N N ; B 12 -11 707 662 ; +C 79 ; WX 722 ; N O ; B 34 -14 688 676 ; +C 80 ; WX 556 ; N P ; B 16 0 542 662 ; +C 81 ; WX 722 ; N Q ; B 34 -178 701 676 ; +C 82 ; WX 667 ; N R ; B 17 0 659 662 ; +C 83 ; WX 556 ; N S ; B 42 -14 491 676 ; +C 84 ; WX 611 ; N T ; B 17 0 593 662 ; +C 85 ; WX 722 ; N U ; B 14 -14 705 662 ; +C 86 ; WX 722 ; N V ; B 16 -11 697 662 ; +C 87 ; WX 944 ; N W ; B 5 -11 932 662 ; +C 88 ; WX 722 ; N X ; B 10 0 704 662 ; +C 89 ; WX 722 ; N Y ; B 22 0 703 662 ; +C 90 ; WX 611 ; N Z ; B 9 0 597 662 ; +C 91 ; WX 333 ; N bracketleft ; B 88 -156 299 662 ; +C 92 ; WX 278 ; N backslash ; B -9 -14 287 676 ; +C 93 ; WX 333 ; N bracketright ; B 34 -156 245 662 ; +C 94 ; WX 469 ; N asciicircum ; B 24 297 446 662 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 115 433 254 676 ; +C 97 ; WX 444 ; N a ; B 37 -10 442 460 ; +C 98 ; WX 500 ; N b ; B 3 -10 468 683 ; +C 99 ; WX 444 ; N c ; B 25 -10 412 460 ; +C 100 ; WX 500 ; N d ; B 27 -10 491 683 ; +C 101 ; WX 444 ; N e ; B 25 -10 424 460 ; +C 102 ; WX 333 ; N f ; B 20 0 383 683 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 28 -218 470 460 ; +C 104 ; WX 500 ; N h ; B 9 0 487 683 ; +C 105 ; WX 278 ; N i ; B 16 0 253 683 ; +C 106 ; WX 278 ; N j ; B -70 -218 194 683 ; +C 107 ; WX 500 ; N k ; B 7 0 505 683 ; +C 108 ; WX 278 ; N l ; B 19 0 257 683 ; +C 109 ; WX 778 ; N m ; B 16 0 775 460 ; +C 110 ; WX 500 ; N n ; B 16 0 485 460 ; +C 111 ; WX 500 ; N o ; B 29 -10 470 460 ; +C 112 ; WX 500 ; N p ; B 5 -217 470 460 ; +C 113 ; WX 500 ; N q ; B 24 -217 488 460 ; +C 114 ; WX 333 ; N r ; B 5 0 335 460 ; +C 115 ; WX 389 ; N s ; B 51 -10 348 460 ; +C 116 ; WX 278 ; N t ; B 13 -10 279 579 ; +C 117 ; WX 500 ; N u ; B 9 -10 479 450 ; +C 118 ; WX 500 ; N v ; B 19 -14 477 450 ; +C 119 ; WX 722 ; N w ; B 21 -14 694 450 ; +C 120 ; WX 500 ; N x ; B 17 0 479 450 ; +C 121 ; WX 500 ; N y ; B 14 -218 475 450 ; +C 122 ; WX 444 ; N z ; B 27 0 418 450 ; +C 123 ; WX 480 ; N braceleft ; B 100 -181 350 680 ; +C 124 ; WX 200 ; N bar ; B 67 -14 133 676 ; +C 125 ; WX 480 ; N braceright ; B 130 -181 380 680 ; +C 126 ; WX 541 ; N asciitilde ; B 40 183 502 323 ; +C 161 ; WX 333 ; N exclamdown ; B 97 -218 205 467 ; +C 162 ; WX 500 ; N cent ; B 53 -138 448 579 ; +C 163 ; WX 500 ; N sterling ; B 12 -8 490 676 ; +C 164 ; WX 167 ; N fraction ; B -168 -14 331 676 ; +C 165 ; WX 500 ; N yen ; B -53 0 512 662 ; +C 166 ; WX 500 ; N florin ; B 7 -189 490 676 ; +C 167 ; WX 500 ; N section ; B 70 -148 426 676 ; +C 168 ; WX 500 ; N currency ; B -22 58 522 602 ; +C 169 ; WX 180 ; N quotesingle ; B 48 431 133 676 ; +C 170 ; WX 444 ; N quotedblleft ; B 43 433 414 676 ; +C 171 ; WX 500 ; N guillemotleft ; B 42 33 456 416 ; +C 172 ; WX 333 ; N guilsinglleft ; B 63 33 285 416 ; +C 173 ; WX 333 ; N guilsinglright ; B 48 33 270 416 ; +C 174 ; WX 556 ; N fi ; B 31 0 521 683 ; +C 175 ; WX 556 ; N fl ; B 32 0 521 683 ; +C 177 ; WX 500 ; N endash ; B 0 201 500 250 ; +C 178 ; WX 500 ; N dagger ; B 59 -149 442 676 ; +C 179 ; WX 500 ; N daggerdbl ; B 58 -153 442 676 ; +C 180 ; WX 250 ; N periodcentered ; B 70 199 181 310 ; +C 182 ; WX 453 ; N paragraph ; B -22 -154 450 662 ; +C 183 ; WX 350 ; N bullet ; B 40 196 310 466 ; +C 184 ; WX 333 ; N quotesinglbase ; B 79 -141 218 102 ; +C 185 ; WX 444 ; N quotedblbase ; B 45 -141 416 102 ; +C 186 ; WX 444 ; N quotedblright ; B 30 433 401 676 ; +C 187 ; WX 500 ; N guillemotright ; B 44 33 458 416 ; +C 188 ; WX 1000 ; N ellipsis ; B 111 -11 888 100 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -19 994 706 ; +C 191 ; WX 444 ; N questiondown ; B 30 -218 376 466 ; +C 193 ; WX 333 ; N grave ; B 19 507 242 678 ; +C 194 ; WX 333 ; N acute ; B 93 507 317 678 ; +C 195 ; WX 333 ; N circumflex ; B 11 507 322 674 ; +C 196 ; WX 333 ; N tilde ; B 1 532 331 638 ; +C 197 ; WX 333 ; N macron ; B 11 547 322 601 ; +C 198 ; WX 333 ; N breve ; B 26 507 307 664 ; +C 199 ; WX 333 ; N dotaccent ; B 118 523 216 623 ; +C 200 ; WX 333 ; N dieresis ; B 18 523 315 623 ; +C 202 ; WX 333 ; N ring ; B 67 512 266 711 ; +C 203 ; WX 333 ; N cedilla ; B 52 -215 261 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -3 507 377 678 ; +C 206 ; WX 333 ; N ogonek ; B 64 -165 249 0 ; +C 207 ; WX 333 ; N caron ; B 11 507 322 674 ; +C 208 ; WX 1000 ; N emdash ; B 0 201 1000 250 ; +C 225 ; WX 889 ; N AE ; B 0 0 863 662 ; +C 227 ; WX 276 ; N ordfeminine ; B 4 394 270 676 ; +C 232 ; WX 611 ; N Lslash ; B 12 0 598 662 ; +C 233 ; WX 722 ; N Oslash ; B 34 -80 688 734 ; +C 234 ; WX 889 ; N OE ; B 30 -6 885 668 ; +C 235 ; WX 310 ; N ordmasculine ; B 6 394 304 676 ; +C 241 ; WX 667 ; N ae ; B 38 -10 632 460 ; +C 245 ; WX 278 ; N dotlessi ; B 16 0 253 460 ; +C 248 ; WX 278 ; N lslash ; B 19 0 259 683 ; +C 249 ; WX 500 ; N oslash ; B 29 -112 470 551 ; +C 250 ; WX 722 ; N oe ; B 30 -10 690 460 ; +C 251 ; WX 500 ; N germandbls ; B 12 -9 468 683 ; +C -1 ; WX 611 ; N Zcaron ; B 9 0 597 886 ; +C -1 ; WX 444 ; N ccedilla ; B 25 -215 412 460 ; +C -1 ; WX 500 ; N ydieresis ; B 14 -218 475 623 ; +C -1 ; WX 444 ; N atilde ; B 37 -10 442 638 ; +C -1 ; WX 278 ; N icircumflex ; B -16 0 295 674 ; +C -1 ; WX 300 ; N threesuperior ; B 15 262 291 676 ; +C -1 ; WX 444 ; N ecircumflex ; B 25 -10 424 674 ; +C -1 ; WX 500 ; N thorn ; B 5 -217 470 683 ; +C -1 ; WX 444 ; N egrave ; B 25 -10 424 678 ; +C -1 ; WX 300 ; N twosuperior ; B 1 270 296 676 ; +C -1 ; WX 444 ; N eacute ; B 25 -10 424 678 ; +C -1 ; WX 500 ; N otilde ; B 29 -10 470 638 ; +C -1 ; WX 722 ; N Aacute ; B 15 0 706 890 ; +C -1 ; WX 500 ; N ocircumflex ; B 29 -10 470 674 ; +C -1 ; WX 500 ; N yacute ; B 14 -218 475 678 ; +C -1 ; WX 500 ; N udieresis ; B 9 -10 479 623 ; +C -1 ; WX 750 ; N threequarters ; B 15 -14 718 676 ; +C -1 ; WX 444 ; N acircumflex ; B 37 -10 442 674 ; +C -1 ; WX 722 ; N Eth ; B 16 0 685 662 ; +C -1 ; WX 444 ; N edieresis ; B 25 -10 424 623 ; +C -1 ; WX 500 ; N ugrave ; B 9 -10 479 678 ; +C -1 ; WX 980 ; N trademark ; B 30 256 957 662 ; +C -1 ; WX 500 ; N ograve ; B 29 -10 470 678 ; +C -1 ; WX 389 ; N scaron ; B 39 -10 350 674 ; +C -1 ; WX 333 ; N Idieresis ; B 18 0 315 835 ; +C -1 ; WX 500 ; N uacute ; B 9 -10 479 678 ; +C -1 ; WX 444 ; N agrave ; B 37 -10 442 678 ; +C -1 ; WX 500 ; N ntilde ; B 16 0 485 638 ; +C -1 ; WX 444 ; N aring ; B 37 -10 442 711 ; +C -1 ; WX 444 ; N zcaron ; B 27 0 418 674 ; +C -1 ; WX 333 ; N Icircumflex ; B 11 0 322 886 ; +C -1 ; WX 722 ; N Ntilde ; B 12 -11 707 850 ; +C -1 ; WX 500 ; N ucircumflex ; B 9 -10 479 674 ; +C -1 ; WX 611 ; N Ecircumflex ; B 12 0 597 886 ; +C -1 ; WX 333 ; N Iacute ; B 18 0 317 890 ; +C -1 ; WX 667 ; N Ccedilla ; B 28 -215 633 676 ; +C -1 ; WX 722 ; N Odieresis ; B 34 -14 688 835 ; +C -1 ; WX 556 ; N Scaron ; B 42 -14 491 886 ; +C -1 ; WX 611 ; N Edieresis ; B 12 0 597 835 ; +C -1 ; WX 333 ; N Igrave ; B 18 0 315 890 ; +C -1 ; WX 444 ; N adieresis ; B 37 -10 442 623 ; +C -1 ; WX 722 ; N Ograve ; B 34 -14 688 890 ; +C -1 ; WX 611 ; N Egrave ; B 12 0 597 890 ; +C -1 ; WX 722 ; N Ydieresis ; B 22 0 703 835 ; +C -1 ; WX 760 ; N registered ; B 38 -14 722 676 ; +C -1 ; WX 722 ; N Otilde ; B 34 -14 688 850 ; +C -1 ; WX 750 ; N onequarter ; B 37 -14 718 676 ; +C -1 ; WX 722 ; N Ugrave ; B 14 -14 705 890 ; +C -1 ; WX 722 ; N Ucircumflex ; B 14 -14 705 886 ; +C -1 ; WX 556 ; N Thorn ; B 16 0 542 662 ; +C -1 ; WX 564 ; N divide ; B 30 -10 534 516 ; +C -1 ; WX 722 ; N Atilde ; B 15 0 706 850 ; +C -1 ; WX 722 ; N Uacute ; B 14 -14 705 890 ; +C -1 ; WX 722 ; N Ocircumflex ; B 34 -14 688 886 ; +C -1 ; WX 564 ; N logicalnot ; B 30 108 534 386 ; +C -1 ; WX 722 ; N Aring ; B 15 0 706 898 ; +C -1 ; WX 278 ; N idieresis ; B -9 0 288 623 ; +C -1 ; WX 278 ; N iacute ; B 16 0 290 678 ; +C -1 ; WX 444 ; N aacute ; B 37 -10 442 678 ; +C -1 ; WX 564 ; N plusminus ; B 30 0 534 506 ; +C -1 ; WX 564 ; N multiply ; B 38 8 527 497 ; +C -1 ; WX 722 ; N Udieresis ; B 14 -14 705 835 ; +C -1 ; WX 564 ; N minus ; B 30 220 534 286 ; +C -1 ; WX 300 ; N onesuperior ; B 57 270 248 676 ; +C -1 ; WX 611 ; N Eacute ; B 12 0 597 890 ; +C -1 ; WX 722 ; N Acircumflex ; B 15 0 706 886 ; +C -1 ; WX 760 ; N copyright ; B 38 -14 722 676 ; +C -1 ; WX 722 ; N Agrave ; B 15 0 706 890 ; +C -1 ; WX 500 ; N odieresis ; B 29 -10 470 623 ; +C -1 ; WX 500 ; N oacute ; B 29 -10 470 678 ; +C -1 ; WX 400 ; N degree ; B 57 390 343 676 ; +C -1 ; WX 278 ; N igrave ; B -8 0 253 678 ; +C -1 ; WX 500 ; N mu ; B 36 -218 512 450 ; +C -1 ; WX 722 ; N Oacute ; B 34 -14 688 890 ; +C -1 ; WX 500 ; N eth ; B 29 -10 471 686 ; +C -1 ; WX 722 ; N Adieresis ; B 15 0 706 835 ; +C -1 ; WX 722 ; N Yacute ; B 22 0 703 890 ; +C -1 ; WX 200 ; N brokenbar ; B 67 -14 133 676 ; +C -1 ; WX 750 ; N onehalf ; B 31 -14 746 676 ; +EndCharMetrics +StartKernData +StartKernPairs 283 + +KPX A y -92 +KPX A w -92 +KPX A v -74 +KPX A u 0 +KPX A quoteright -111 +KPX A quotedblright 0 +KPX A p 0 +KPX A Y -105 +KPX A W -90 +KPX A V -135 +KPX A U -55 +KPX A T -111 +KPX A Q -55 +KPX A O -55 +KPX A G -40 +KPX A C -40 + +KPX B period 0 +KPX B comma 0 +KPX B U -10 +KPX B A -35 + +KPX D period 0 +KPX D comma 0 +KPX D Y -55 +KPX D W -30 +KPX D V -40 +KPX D A -40 + +KPX F r 0 +KPX F period -80 +KPX F o -15 +KPX F i 0 +KPX F e 0 +KPX F comma -80 +KPX F a -15 +KPX F A -74 + +KPX G period 0 +KPX G comma 0 + +KPX J u 0 +KPX J period 0 +KPX J o 0 +KPX J e 0 +KPX J comma 0 +KPX J a 0 +KPX J A -60 + +KPX K y -25 +KPX K u -15 +KPX K o -35 +KPX K e -25 +KPX K O -30 + +KPX L y -55 +KPX L quoteright -92 +KPX L quotedblright 0 +KPX L Y -100 +KPX L W -74 +KPX L V -100 +KPX L T -92 + +KPX N period 0 +KPX N comma 0 +KPX N A -35 + +KPX O period 0 +KPX O comma 0 +KPX O Y -50 +KPX O X -40 +KPX O W -35 +KPX O V -50 +KPX O T -40 +KPX O A -35 + +KPX P period -111 +KPX P o 0 +KPX P e 0 +KPX P comma -111 +KPX P a -15 +KPX P A -92 + +KPX Q period 0 +KPX Q comma 0 +KPX Q U -10 + +KPX R Y -65 +KPX R W -55 +KPX R V -80 +KPX R U -40 +KPX R T -60 +KPX R O -40 + +KPX S period 0 +KPX S comma 0 + +KPX T y -80 +KPX T w -80 +KPX T u -45 +KPX T semicolon -55 +KPX T r -35 +KPX T period -74 +KPX T o -80 +KPX T i -35 +KPX T hyphen -92 +KPX T h 0 +KPX T e -70 +KPX T comma -74 +KPX T colon -50 +KPX T a -80 +KPX T O -18 +KPX T A -93 + +KPX U period 0 +KPX U comma 0 +KPX U A -40 + +KPX V u -75 +KPX V semicolon -74 +KPX V period -129 +KPX V o -129 +KPX V i -60 +KPX V hyphen -100 +KPX V e -111 +KPX V comma -129 +KPX V colon -74 +KPX V a -111 +KPX V O -40 +KPX V G -15 +KPX V A -135 + +KPX W y -73 +KPX W u -50 +KPX W semicolon -37 +KPX W period -92 +KPX W o -80 +KPX W i -40 +KPX W hyphen -65 +KPX W h 0 +KPX W e -80 +KPX W comma -92 +KPX W colon -37 +KPX W a -80 +KPX W O -10 +KPX W A -120 + +KPX Y u -111 +KPX Y semicolon -92 +KPX Y period -129 +KPX Y o -110 +KPX Y i -55 +KPX Y hyphen -111 +KPX Y e -100 +KPX Y comma -129 +KPX Y colon -92 +KPX Y a -100 +KPX Y O -30 +KPX Y A -120 + +KPX a y 0 +KPX a w -15 +KPX a v -20 +KPX a t 0 +KPX a p 0 +KPX a g 0 +KPX a b 0 + +KPX b y 0 +KPX b v -15 +KPX b u -20 +KPX b period -40 +KPX b l 0 +KPX b comma 0 +KPX b b 0 + +KPX c y -15 +KPX c period 0 +KPX c l 0 +KPX c k 0 +KPX c h 0 +KPX c comma 0 + +KPX colon space 0 + +KPX comma space 0 +KPX comma quoteright -70 +KPX comma quotedblright -70 + +KPX d y 0 +KPX d w 0 +KPX d v 0 +KPX d period 0 +KPX d d 0 +KPX d comma 0 + +KPX e y -15 +KPX e x -15 +KPX e w -25 +KPX e v -25 +KPX e period 0 +KPX e p 0 +KPX e g -15 +KPX e comma 0 +KPX e b 0 + +KPX f quoteright 55 +KPX f quotedblright 0 +KPX f period 0 +KPX f o 0 +KPX f l 0 +KPX f i -20 +KPX f f -25 +KPX f e 0 +KPX f dotlessi -50 +KPX f comma 0 +KPX f a -10 + +KPX g y 0 +KPX g r 0 +KPX g period 0 +KPX g o 0 +KPX g i 0 +KPX g g 0 +KPX g e 0 +KPX g comma 0 +KPX g a -5 + +KPX h y -5 + +KPX i v -25 + +KPX k y -15 +KPX k o -10 +KPX k e -10 + +KPX l y 0 +KPX l w -10 + +KPX m y 0 +KPX m u 0 + +KPX n y -15 +KPX n v -40 +KPX n u 0 + +KPX o y -10 +KPX o x 0 +KPX o w -25 +KPX o v -15 +KPX o g 0 + +KPX p y -10 + +KPX period quoteright -70 +KPX period quotedblright -70 + +KPX quotedblleft quoteleft 0 +KPX quotedblleft A -80 + +KPX quotedblright space 0 + +KPX quoteleft quoteleft -74 +KPX quoteleft A -80 + +KPX quoteright v -50 +KPX quoteright t -18 +KPX quoteright space -74 +KPX quoteright s -55 +KPX quoteright r -50 +KPX quoteright quoteright -74 +KPX quoteright quotedblright 0 +KPX quoteright l -10 +KPX quoteright d -50 + +KPX r y 0 +KPX r v 0 +KPX r u 0 +KPX r t 0 +KPX r s 0 +KPX r r 0 +KPX r q 0 +KPX r period -55 +KPX r p 0 +KPX r o 0 +KPX r n 0 +KPX r m 0 +KPX r l 0 +KPX r k 0 +KPX r i 0 +KPX r hyphen -20 +KPX r g -18 +KPX r e 0 +KPX r d 0 +KPX r comma -40 +KPX r c 0 +KPX r a 0 + +KPX s w 0 + +KPX space quoteleft 0 +KPX space quotedblleft 0 +KPX space Y -90 +KPX space W -30 +KPX space V -50 +KPX space T -18 +KPX space A -55 + +KPX v period -65 +KPX v o -20 +KPX v e -15 +KPX v comma -65 +KPX v a -25 + +KPX w period -65 +KPX w o -10 +KPX w h 0 +KPX w e 0 +KPX w comma -65 +KPX w a -10 + +KPX x e -15 + +KPX y period -65 +KPX y o 0 +KPX y e 0 +KPX y comma -65 +KPX y a 0 + +KPX z o 0 +KPX z e 0 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 195 212 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 195 212 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 195 212 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 195 212 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 185 187 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 195 212 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 167 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 139 212 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 139 212 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 139 212 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 139 212 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 0 212 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 0 212 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 0 212 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 0 212 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 195 212 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 195 212 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 195 212 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 195 212 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 195 212 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 195 212 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 112 212 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 195 212 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 195 212 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 195 212 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 195 212 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 195 212 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 195 212 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 139 212 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 56 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 56 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 56 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 56 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 56 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 56 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 56 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 56 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 56 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 56 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -27 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -27 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -27 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 84 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 84 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 84 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 84 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 84 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 28 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 84 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 84 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 84 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 84 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 84 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 84 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 56 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmri8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmri8a.afm new file mode 100644 index 00000000..6d7a003b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/ptmri8a.afm @@ -0,0 +1,648 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Tue Mar 20 13:14:56 1990 +Comment UniqueID 28427 +Comment VMusage 32912 39804 +FontName Times-Italic +FullName Times Italic +FamilyName Times +Weight Medium +ItalicAngle -15.5 +IsFixedPitch false +FontBBox -169 -217 1010 883 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 653 +XHeight 441 +Ascender 683 +Descender -205 +StartCharMetrics 228 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 39 -11 302 667 ; +C 34 ; WX 420 ; N quotedbl ; B 144 421 432 666 ; +C 35 ; WX 500 ; N numbersign ; B 2 0 540 676 ; +C 36 ; WX 500 ; N dollar ; B 31 -89 497 731 ; +C 37 ; WX 833 ; N percent ; B 79 -13 790 676 ; +C 38 ; WX 778 ; N ampersand ; B 76 -18 723 666 ; +C 39 ; WX 333 ; N quoteright ; B 151 436 290 666 ; +C 40 ; WX 333 ; N parenleft ; B 42 -181 315 669 ; +C 41 ; WX 333 ; N parenright ; B 16 -180 289 669 ; +C 42 ; WX 500 ; N asterisk ; B 128 255 492 666 ; +C 43 ; WX 675 ; N plus ; B 86 0 590 506 ; +C 44 ; WX 250 ; N comma ; B -4 -129 135 101 ; +C 45 ; WX 333 ; N hyphen ; B 49 192 282 255 ; +C 46 ; WX 250 ; N period ; B 27 -11 138 100 ; +C 47 ; WX 278 ; N slash ; B -65 -18 386 666 ; +C 48 ; WX 500 ; N zero ; B 32 -7 497 676 ; +C 49 ; WX 500 ; N one ; B 49 0 409 676 ; +C 50 ; WX 500 ; N two ; B 12 0 452 676 ; +C 51 ; WX 500 ; N three ; B 15 -7 465 676 ; +C 52 ; WX 500 ; N four ; B 1 0 479 676 ; +C 53 ; WX 500 ; N five ; B 15 -7 491 666 ; +C 54 ; WX 500 ; N six ; B 30 -7 521 686 ; +C 55 ; WX 500 ; N seven ; B 75 -8 537 666 ; +C 56 ; WX 500 ; N eight ; B 30 -7 493 676 ; +C 57 ; WX 500 ; N nine ; B 23 -17 492 676 ; +C 58 ; WX 333 ; N colon ; B 50 -11 261 441 ; +C 59 ; WX 333 ; N semicolon ; B 27 -129 261 441 ; +C 60 ; WX 675 ; N less ; B 84 -8 592 514 ; +C 61 ; WX 675 ; N equal ; B 86 120 590 386 ; +C 62 ; WX 675 ; N greater ; B 84 -8 592 514 ; +C 63 ; WX 500 ; N question ; B 132 -12 472 664 ; +C 64 ; WX 920 ; N at ; B 118 -18 806 666 ; +C 65 ; WX 611 ; N A ; B -51 0 564 668 ; +C 66 ; WX 611 ; N B ; B -8 0 588 653 ; +C 67 ; WX 667 ; N C ; B 66 -18 689 666 ; +C 68 ; WX 722 ; N D ; B -8 0 700 653 ; +C 69 ; WX 611 ; N E ; B -1 0 634 653 ; +C 70 ; WX 611 ; N F ; B 8 0 645 653 ; +C 71 ; WX 722 ; N G ; B 52 -18 722 666 ; +C 72 ; WX 722 ; N H ; B -8 0 767 653 ; +C 73 ; WX 333 ; N I ; B -8 0 384 653 ; +C 74 ; WX 444 ; N J ; B -6 -18 491 653 ; +C 75 ; WX 667 ; N K ; B 7 0 722 653 ; +C 76 ; WX 556 ; N L ; B -8 0 559 653 ; +C 77 ; WX 833 ; N M ; B -18 0 873 653 ; +C 78 ; WX 667 ; N N ; B -20 -15 727 653 ; +C 79 ; WX 722 ; N O ; B 60 -18 699 666 ; +C 80 ; WX 611 ; N P ; B 0 0 605 653 ; +C 81 ; WX 722 ; N Q ; B 59 -182 699 666 ; +C 82 ; WX 611 ; N R ; B -13 0 588 653 ; +C 83 ; WX 500 ; N S ; B 17 -18 508 667 ; +C 84 ; WX 556 ; N T ; B 59 0 633 653 ; +C 85 ; WX 722 ; N U ; B 102 -18 765 653 ; +C 86 ; WX 611 ; N V ; B 76 -18 688 653 ; +C 87 ; WX 833 ; N W ; B 71 -18 906 653 ; +C 88 ; WX 611 ; N X ; B -29 0 655 653 ; +C 89 ; WX 556 ; N Y ; B 78 0 633 653 ; +C 90 ; WX 556 ; N Z ; B -6 0 606 653 ; +C 91 ; WX 389 ; N bracketleft ; B 21 -153 391 663 ; +C 92 ; WX 278 ; N backslash ; B -41 -18 319 666 ; +C 93 ; WX 389 ; N bracketright ; B 12 -153 382 663 ; +C 94 ; WX 422 ; N asciicircum ; B 0 301 422 666 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 171 436 310 666 ; +C 97 ; WX 500 ; N a ; B 17 -11 476 441 ; +C 98 ; WX 500 ; N b ; B 23 -11 473 683 ; +C 99 ; WX 444 ; N c ; B 30 -11 425 441 ; +C 100 ; WX 500 ; N d ; B 15 -13 527 683 ; +C 101 ; WX 444 ; N e ; B 31 -11 412 441 ; +C 102 ; WX 278 ; N f ; B -147 -207 424 678 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 8 -206 472 441 ; +C 104 ; WX 500 ; N h ; B 19 -9 478 683 ; +C 105 ; WX 278 ; N i ; B 49 -11 264 654 ; +C 106 ; WX 278 ; N j ; B -124 -207 276 654 ; +C 107 ; WX 444 ; N k ; B 14 -11 461 683 ; +C 108 ; WX 278 ; N l ; B 41 -11 279 683 ; +C 109 ; WX 722 ; N m ; B 12 -9 704 441 ; +C 110 ; WX 500 ; N n ; B 14 -9 474 441 ; +C 111 ; WX 500 ; N o ; B 27 -11 468 441 ; +C 112 ; WX 500 ; N p ; B -75 -205 469 441 ; +C 113 ; WX 500 ; N q ; B 25 -209 483 441 ; +C 114 ; WX 389 ; N r ; B 45 0 412 441 ; +C 115 ; WX 389 ; N s ; B 16 -13 366 442 ; +C 116 ; WX 278 ; N t ; B 37 -11 296 546 ; +C 117 ; WX 500 ; N u ; B 42 -11 475 441 ; +C 118 ; WX 444 ; N v ; B 21 -18 426 441 ; +C 119 ; WX 667 ; N w ; B 16 -18 648 441 ; +C 120 ; WX 444 ; N x ; B -27 -11 447 441 ; +C 121 ; WX 444 ; N y ; B -24 -206 426 441 ; +C 122 ; WX 389 ; N z ; B -2 -81 380 428 ; +C 123 ; WX 400 ; N braceleft ; B 51 -177 407 687 ; +C 124 ; WX 275 ; N bar ; B 105 -18 171 666 ; +C 125 ; WX 400 ; N braceright ; B -7 -177 349 687 ; +C 126 ; WX 541 ; N asciitilde ; B 40 183 502 323 ; +C 161 ; WX 389 ; N exclamdown ; B 59 -205 322 473 ; +C 162 ; WX 500 ; N cent ; B 77 -143 472 560 ; +C 163 ; WX 500 ; N sterling ; B 10 -6 517 670 ; +C 164 ; WX 167 ; N fraction ; B -169 -10 337 676 ; +C 165 ; WX 500 ; N yen ; B 27 0 603 653 ; +C 166 ; WX 500 ; N florin ; B 25 -182 507 682 ; +C 167 ; WX 500 ; N section ; B 53 -162 461 666 ; +C 168 ; WX 500 ; N currency ; B -22 53 522 597 ; +C 169 ; WX 214 ; N quotesingle ; B 132 421 241 666 ; +C 170 ; WX 556 ; N quotedblleft ; B 166 436 514 666 ; +C 171 ; WX 500 ; N guillemotleft ; B 53 37 445 403 ; +C 172 ; WX 333 ; N guilsinglleft ; B 51 37 281 403 ; +C 173 ; WX 333 ; N guilsinglright ; B 52 37 282 403 ; +C 174 ; WX 500 ; N fi ; B -141 -207 481 681 ; +C 175 ; WX 500 ; N fl ; B -141 -204 518 682 ; +C 177 ; WX 500 ; N endash ; B -6 197 505 243 ; +C 178 ; WX 500 ; N dagger ; B 101 -159 488 666 ; +C 179 ; WX 500 ; N daggerdbl ; B 22 -143 491 666 ; +C 180 ; WX 250 ; N periodcentered ; B 70 199 181 310 ; +C 182 ; WX 523 ; N paragraph ; B 55 -123 616 653 ; +C 183 ; WX 350 ; N bullet ; B 40 191 310 461 ; +C 184 ; WX 333 ; N quotesinglbase ; B 44 -129 183 101 ; +C 185 ; WX 556 ; N quotedblbase ; B 57 -129 405 101 ; +C 186 ; WX 556 ; N quotedblright ; B 151 436 499 666 ; +C 187 ; WX 500 ; N guillemotright ; B 55 37 447 403 ; +C 188 ; WX 889 ; N ellipsis ; B 57 -11 762 100 ; +C 189 ; WX 1000 ; N perthousand ; B 25 -19 1010 706 ; +C 191 ; WX 500 ; N questiondown ; B 28 -205 368 471 ; +C 193 ; WX 333 ; N grave ; B 121 492 311 664 ; +C 194 ; WX 333 ; N acute ; B 180 494 403 664 ; +C 195 ; WX 333 ; N circumflex ; B 91 492 385 661 ; +C 196 ; WX 333 ; N tilde ; B 100 517 427 624 ; +C 197 ; WX 333 ; N macron ; B 99 532 411 583 ; +C 198 ; WX 333 ; N breve ; B 117 492 418 650 ; +C 199 ; WX 333 ; N dotaccent ; B 207 508 305 606 ; +C 200 ; WX 333 ; N dieresis ; B 107 508 405 606 ; +C 202 ; WX 333 ; N ring ; B 155 492 355 691 ; +C 203 ; WX 333 ; N cedilla ; B -30 -217 182 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 93 494 486 664 ; +C 206 ; WX 333 ; N ogonek ; B -20 -169 200 40 ; +C 207 ; WX 333 ; N caron ; B 121 492 426 661 ; +C 208 ; WX 889 ; N emdash ; B -6 197 894 243 ; +C 225 ; WX 889 ; N AE ; B -27 0 911 653 ; +C 227 ; WX 276 ; N ordfeminine ; B 42 406 352 676 ; +C 232 ; WX 556 ; N Lslash ; B -8 0 559 653 ; +C 233 ; WX 722 ; N Oslash ; B 60 -105 699 722 ; +C 234 ; WX 944 ; N OE ; B 49 -8 964 666 ; +C 235 ; WX 310 ; N ordmasculine ; B 67 406 362 676 ; +C 241 ; WX 667 ; N ae ; B 23 -11 640 441 ; +C 245 ; WX 278 ; N dotlessi ; B 49 -11 235 441 ; +C 248 ; WX 278 ; N lslash ; B 37 -11 307 683 ; +C 249 ; WX 500 ; N oslash ; B 28 -135 469 554 ; +C 250 ; WX 667 ; N oe ; B 20 -12 646 441 ; +C 251 ; WX 500 ; N germandbls ; B -168 -207 493 679 ; +C -1 ; WX 556 ; N Zcaron ; B -6 0 606 873 ; +C -1 ; WX 444 ; N ccedilla ; B 26 -217 425 441 ; +C -1 ; WX 444 ; N ydieresis ; B -24 -206 441 606 ; +C -1 ; WX 500 ; N atilde ; B 17 -11 511 624 ; +C -1 ; WX 278 ; N icircumflex ; B 34 -11 328 661 ; +C -1 ; WX 300 ; N threesuperior ; B 43 268 339 676 ; +C -1 ; WX 444 ; N ecircumflex ; B 31 -11 441 661 ; +C -1 ; WX 500 ; N thorn ; B -75 -205 469 683 ; +C -1 ; WX 444 ; N egrave ; B 31 -11 412 664 ; +C -1 ; WX 300 ; N twosuperior ; B 33 271 324 676 ; +C -1 ; WX 444 ; N eacute ; B 31 -11 459 664 ; +C -1 ; WX 500 ; N otilde ; B 27 -11 496 624 ; +C -1 ; WX 611 ; N Aacute ; B -51 0 564 876 ; +C -1 ; WX 500 ; N ocircumflex ; B 27 -11 468 661 ; +C -1 ; WX 444 ; N yacute ; B -24 -206 459 664 ; +C -1 ; WX 500 ; N udieresis ; B 42 -11 479 606 ; +C -1 ; WX 750 ; N threequarters ; B 23 -10 736 676 ; +C -1 ; WX 500 ; N acircumflex ; B 17 -11 476 661 ; +C -1 ; WX 722 ; N Eth ; B -8 0 700 653 ; +C -1 ; WX 444 ; N edieresis ; B 31 -11 451 606 ; +C -1 ; WX 500 ; N ugrave ; B 42 -11 475 664 ; +C -1 ; WX 980 ; N trademark ; B 30 247 957 653 ; +C -1 ; WX 500 ; N ograve ; B 27 -11 468 664 ; +C -1 ; WX 389 ; N scaron ; B 16 -13 454 661 ; +C -1 ; WX 333 ; N Idieresis ; B -8 0 435 818 ; +C -1 ; WX 500 ; N uacute ; B 42 -11 477 664 ; +C -1 ; WX 500 ; N agrave ; B 17 -11 476 664 ; +C -1 ; WX 500 ; N ntilde ; B 14 -9 476 624 ; +C -1 ; WX 500 ; N aring ; B 17 -11 476 691 ; +C -1 ; WX 389 ; N zcaron ; B -2 -81 434 661 ; +C -1 ; WX 333 ; N Icircumflex ; B -8 0 425 873 ; +C -1 ; WX 667 ; N Ntilde ; B -20 -15 727 836 ; +C -1 ; WX 500 ; N ucircumflex ; B 42 -11 475 661 ; +C -1 ; WX 611 ; N Ecircumflex ; B -1 0 634 873 ; +C -1 ; WX 333 ; N Iacute ; B -8 0 413 876 ; +C -1 ; WX 667 ; N Ccedilla ; B 66 -217 689 666 ; +C -1 ; WX 722 ; N Odieresis ; B 60 -18 699 818 ; +C -1 ; WX 500 ; N Scaron ; B 17 -18 520 873 ; +C -1 ; WX 611 ; N Edieresis ; B -1 0 634 818 ; +C -1 ; WX 333 ; N Igrave ; B -8 0 384 876 ; +C -1 ; WX 500 ; N adieresis ; B 17 -11 489 606 ; +C -1 ; WX 722 ; N Ograve ; B 60 -18 699 876 ; +C -1 ; WX 611 ; N Egrave ; B -1 0 634 876 ; +C -1 ; WX 556 ; N Ydieresis ; B 78 0 633 818 ; +C -1 ; WX 760 ; N registered ; B 41 -18 719 666 ; +C -1 ; WX 722 ; N Otilde ; B 60 -18 699 836 ; +C -1 ; WX 750 ; N onequarter ; B 33 -10 736 676 ; +C -1 ; WX 722 ; N Ugrave ; B 102 -18 765 876 ; +C -1 ; WX 722 ; N Ucircumflex ; B 102 -18 765 873 ; +C -1 ; WX 611 ; N Thorn ; B 0 0 569 653 ; +C -1 ; WX 675 ; N divide ; B 86 -11 590 517 ; +C -1 ; WX 611 ; N Atilde ; B -51 0 566 836 ; +C -1 ; WX 722 ; N Uacute ; B 102 -18 765 876 ; +C -1 ; WX 722 ; N Ocircumflex ; B 60 -18 699 873 ; +C -1 ; WX 675 ; N logicalnot ; B 86 108 590 386 ; +C -1 ; WX 611 ; N Aring ; B -51 0 564 883 ; +C -1 ; WX 278 ; N idieresis ; B 49 -11 353 606 ; +C -1 ; WX 278 ; N iacute ; B 49 -11 356 664 ; +C -1 ; WX 500 ; N aacute ; B 17 -11 487 664 ; +C -1 ; WX 675 ; N plusminus ; B 86 0 590 506 ; +C -1 ; WX 675 ; N multiply ; B 93 8 582 497 ; +C -1 ; WX 722 ; N Udieresis ; B 102 -18 765 818 ; +C -1 ; WX 675 ; N minus ; B 86 220 590 286 ; +C -1 ; WX 300 ; N onesuperior ; B 43 271 284 676 ; +C -1 ; WX 611 ; N Eacute ; B -1 0 634 876 ; +C -1 ; WX 611 ; N Acircumflex ; B -51 0 564 873 ; +C -1 ; WX 760 ; N copyright ; B 41 -18 719 666 ; +C -1 ; WX 611 ; N Agrave ; B -51 0 564 876 ; +C -1 ; WX 500 ; N odieresis ; B 27 -11 489 606 ; +C -1 ; WX 500 ; N oacute ; B 27 -11 487 664 ; +C -1 ; WX 400 ; N degree ; B 101 390 387 676 ; +C -1 ; WX 278 ; N igrave ; B 49 -11 284 664 ; +C -1 ; WX 500 ; N mu ; B -30 -209 497 428 ; +C -1 ; WX 722 ; N Oacute ; B 60 -18 699 876 ; +C -1 ; WX 500 ; N eth ; B 27 -11 482 683 ; +C -1 ; WX 611 ; N Adieresis ; B -51 0 564 818 ; +C -1 ; WX 556 ; N Yacute ; B 78 0 633 876 ; +C -1 ; WX 275 ; N brokenbar ; B 105 -18 171 666 ; +C -1 ; WX 750 ; N onehalf ; B 34 -10 749 676 ; +EndCharMetrics +StartKernData +StartKernPairs 283 + +KPX A y -55 +KPX A w -55 +KPX A v -55 +KPX A u -20 +KPX A quoteright -37 +KPX A quotedblright 0 +KPX A p 0 +KPX A Y -55 +KPX A W -95 +KPX A V -105 +KPX A U -50 +KPX A T -37 +KPX A Q -40 +KPX A O -40 +KPX A G -35 +KPX A C -30 + +KPX B period 0 +KPX B comma 0 +KPX B U -10 +KPX B A -25 + +KPX D period 0 +KPX D comma 0 +KPX D Y -40 +KPX D W -40 +KPX D V -40 +KPX D A -35 + +KPX F r -55 +KPX F period -135 +KPX F o -105 +KPX F i -45 +KPX F e -75 +KPX F comma -135 +KPX F a -75 +KPX F A -115 + +KPX G period 0 +KPX G comma 0 + +KPX J u -35 +KPX J period -25 +KPX J o -25 +KPX J e -25 +KPX J comma -25 +KPX J a -35 +KPX J A -40 + +KPX K y -40 +KPX K u -40 +KPX K o -40 +KPX K e -35 +KPX K O -50 + +KPX L y -30 +KPX L quoteright -37 +KPX L quotedblright 0 +KPX L Y -20 +KPX L W -55 +KPX L V -55 +KPX L T -20 + +KPX N period 0 +KPX N comma 0 +KPX N A -27 + +KPX O period 0 +KPX O comma 0 +KPX O Y -50 +KPX O X -40 +KPX O W -50 +KPX O V -50 +KPX O T -40 +KPX O A -55 + +KPX P period -135 +KPX P o -80 +KPX P e -80 +KPX P comma -135 +KPX P a -80 +KPX P A -90 + +KPX Q period 0 +KPX Q comma 0 +KPX Q U -10 + +KPX R Y -18 +KPX R W -18 +KPX R V -18 +KPX R U -40 +KPX R T 0 +KPX R O -40 + +KPX S period 0 +KPX S comma 0 + +KPX T y -74 +KPX T w -74 +KPX T u -55 +KPX T semicolon -65 +KPX T r -55 +KPX T period -74 +KPX T o -92 +KPX T i -55 +KPX T hyphen -74 +KPX T h 0 +KPX T e -92 +KPX T comma -74 +KPX T colon -55 +KPX T a -92 +KPX T O -18 +KPX T A -50 + +KPX U period -25 +KPX U comma -25 +KPX U A -40 + +KPX V u -74 +KPX V semicolon -74 +KPX V period -129 +KPX V o -111 +KPX V i -74 +KPX V hyphen -55 +KPX V e -111 +KPX V comma -129 +KPX V colon -65 +KPX V a -111 +KPX V O -30 +KPX V G 0 +KPX V A -60 + +KPX W y -70 +KPX W u -55 +KPX W semicolon -65 +KPX W period -92 +KPX W o -92 +KPX W i -55 +KPX W hyphen -37 +KPX W h 0 +KPX W e -92 +KPX W comma -92 +KPX W colon -65 +KPX W a -92 +KPX W O -25 +KPX W A -60 + +KPX Y u -92 +KPX Y semicolon -65 +KPX Y period -92 +KPX Y o -92 +KPX Y i -74 +KPX Y hyphen -74 +KPX Y e -92 +KPX Y comma -92 +KPX Y colon -65 +KPX Y a -92 +KPX Y O -15 +KPX Y A -50 + +KPX a y 0 +KPX a w 0 +KPX a v 0 +KPX a t 0 +KPX a p 0 +KPX a g -10 +KPX a b 0 + +KPX b y 0 +KPX b v 0 +KPX b u -20 +KPX b period -40 +KPX b l 0 +KPX b comma 0 +KPX b b 0 + +KPX c y 0 +KPX c period 0 +KPX c l 0 +KPX c k -20 +KPX c h -15 +KPX c comma 0 + +KPX colon space 0 + +KPX comma space 0 +KPX comma quoteright -140 +KPX comma quotedblright -140 + +KPX d y 0 +KPX d w 0 +KPX d v 0 +KPX d period 0 +KPX d d 0 +KPX d comma 0 + +KPX e y -30 +KPX e x -20 +KPX e w -15 +KPX e v -15 +KPX e period -15 +KPX e p 0 +KPX e g -40 +KPX e comma -10 +KPX e b 0 + +KPX f quoteright 92 +KPX f quotedblright 0 +KPX f period -15 +KPX f o 0 +KPX f l 0 +KPX f i -20 +KPX f f -18 +KPX f e 0 +KPX f dotlessi -60 +KPX f comma -10 +KPX f a 0 + +KPX g y 0 +KPX g r 0 +KPX g period -15 +KPX g o 0 +KPX g i 0 +KPX g g -10 +KPX g e -10 +KPX g comma -10 +KPX g a 0 + +KPX h y 0 + +KPX i v 0 + +KPX k y -10 +KPX k o -10 +KPX k e -10 + +KPX l y 0 +KPX l w 0 + +KPX m y 0 +KPX m u 0 + +KPX n y 0 +KPX n v -40 +KPX n u 0 + +KPX o y 0 +KPX o x 0 +KPX o w 0 +KPX o v -10 +KPX o g -10 + +KPX p y 0 + +KPX period quoteright -140 +KPX period quotedblright -140 + +KPX quotedblleft quoteleft 0 +KPX quotedblleft A 0 + +KPX quotedblright space 0 + +KPX quoteleft quoteleft -111 +KPX quoteleft A 0 + +KPX quoteright v -10 +KPX quoteright t -30 +KPX quoteright space -111 +KPX quoteright s -40 +KPX quoteright r -25 +KPX quoteright quoteright -111 +KPX quoteright quotedblright 0 +KPX quoteright l 0 +KPX quoteright d -25 + +KPX r y 0 +KPX r v 0 +KPX r u 0 +KPX r t 0 +KPX r s -10 +KPX r r 0 +KPX r q -37 +KPX r period -111 +KPX r p 0 +KPX r o -45 +KPX r n 0 +KPX r m 0 +KPX r l 0 +KPX r k 0 +KPX r i 0 +KPX r hyphen -20 +KPX r g -37 +KPX r e -37 +KPX r d -37 +KPX r comma -111 +KPX r c -37 +KPX r a -15 + +KPX s w 0 + +KPX space quoteleft 0 +KPX space quotedblleft 0 +KPX space Y -75 +KPX space W -40 +KPX space V -35 +KPX space T -18 +KPX space A -18 + +KPX v period -74 +KPX v o 0 +KPX v e 0 +KPX v comma -74 +KPX v a 0 + +KPX w period -74 +KPX w o 0 +KPX w h 0 +KPX w e 0 +KPX w comma -74 +KPX w a 0 + +KPX x e 0 + +KPX y period -55 +KPX y o 0 +KPX y e 0 +KPX y comma -55 +KPX y a 0 + +KPX z o 0 +KPX z e 0 +EndKernPairs +EndKernData +StartComposites 58 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 139 212 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 144 212 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 139 212 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 149 212 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 129 192 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 139 212 ; +CC Ccedilla 2 ; PCC C 0 0 ; PCC cedilla 167 0 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 149 212 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 169 212 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 159 212 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 149 212 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 10 212 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 40 212 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 30 212 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 10 212 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 177 212 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 195 212 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 230 212 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 230 212 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 205 212 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 215 212 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 94 212 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 195 212 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 215 212 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 225 212 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 215 212 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 132 212 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 142 212 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 112 212 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 84 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 84 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 84 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 84 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 84 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 84 0 ; +CC ccedilla 2 ; PCC c 0 0 ; PCC cedilla 56 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 56 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 56 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 46 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 56 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -47 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -57 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -52 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -27 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 49 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 84 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 74 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 84 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 84 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 69 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 28 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 74 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 74 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 74 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 84 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 56 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 36 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 8 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putb8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putb8a.afm new file mode 100644 index 00000000..2eaa540d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putb8a.afm @@ -0,0 +1,1005 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Fri Jan 17 15:08:52 1992 +Comment UniqueID 37705 +Comment VMusage 33078 39970 +FontName Utopia-Bold +FullName Utopia Bold +FamilyName Utopia +Weight Bold +ItalicAngle 0 +IsFixedPitch false +FontBBox -155 -250 1249 916 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.002 +Notice Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved.Utopia is a registered trademark of Adobe Systems Incorporated. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 490 +Ascender 742 +Descender -230 +StartCharMetrics 228 +C 32 ; WX 210 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 47 -12 231 707 ; +C 34 ; WX 473 ; N quotedbl ; B 71 407 402 707 ; +C 35 ; WX 560 ; N numbersign ; B 14 0 547 668 ; +C 36 ; WX 560 ; N dollar ; B 38 -104 524 748 ; +C 37 ; WX 887 ; N percent ; B 40 -31 847 701 ; +C 38 ; WX 748 ; N ampersand ; B 45 -12 734 680 ; +C 39 ; WX 252 ; N quoteright ; B 40 387 212 707 ; +C 40 ; WX 365 ; N parenleft ; B 99 -135 344 699 ; +C 41 ; WX 365 ; N parenright ; B 21 -135 266 699 ; +C 42 ; WX 442 ; N asterisk ; B 40 315 402 707 ; +C 43 ; WX 600 ; N plus ; B 58 0 542 490 ; +C 44 ; WX 280 ; N comma ; B 40 -167 226 180 ; +C 45 ; WX 392 ; N hyphen ; B 65 203 328 298 ; +C 46 ; WX 280 ; N period ; B 48 -12 232 174 ; +C 47 ; WX 378 ; N slash ; B 34 -15 344 707 ; +C 48 ; WX 560 ; N zero ; B 31 -12 530 680 ; +C 49 ; WX 560 ; N one ; B 102 0 459 680 ; +C 50 ; WX 560 ; N two ; B 30 0 539 680 ; +C 51 ; WX 560 ; N three ; B 27 -12 519 680 ; +C 52 ; WX 560 ; N four ; B 19 0 533 668 ; +C 53 ; WX 560 ; N five ; B 43 -12 519 668 ; +C 54 ; WX 560 ; N six ; B 30 -12 537 680 ; +C 55 ; WX 560 ; N seven ; B 34 -12 530 668 ; +C 56 ; WX 560 ; N eight ; B 27 -12 533 680 ; +C 57 ; WX 560 ; N nine ; B 34 -12 523 680 ; +C 58 ; WX 280 ; N colon ; B 48 -12 232 490 ; +C 59 ; WX 280 ; N semicolon ; B 40 -167 232 490 ; +C 60 ; WX 600 ; N less ; B 61 5 539 493 ; +C 61 ; WX 600 ; N equal ; B 58 103 542 397 ; +C 62 ; WX 600 ; N greater ; B 61 5 539 493 ; +C 63 ; WX 456 ; N question ; B 20 -12 433 707 ; +C 64 ; WX 833 ; N at ; B 45 -15 797 707 ; +C 65 ; WX 644 ; N A ; B -28 0 663 692 ; +C 66 ; WX 683 ; N B ; B 33 0 645 692 ; +C 67 ; WX 689 ; N C ; B 42 -15 654 707 ; +C 68 ; WX 777 ; N D ; B 33 0 735 692 ; +C 69 ; WX 629 ; N E ; B 33 0 604 692 ; +C 70 ; WX 593 ; N F ; B 37 0 568 692 ; +C 71 ; WX 726 ; N G ; B 42 -15 709 707 ; +C 72 ; WX 807 ; N H ; B 33 0 774 692 ; +C 73 ; WX 384 ; N I ; B 33 0 351 692 ; +C 74 ; WX 386 ; N J ; B 6 -114 361 692 ; +C 75 ; WX 707 ; N K ; B 33 -6 719 692 ; +C 76 ; WX 585 ; N L ; B 33 0 584 692 ; +C 77 ; WX 918 ; N M ; B 23 0 885 692 ; +C 78 ; WX 739 ; N N ; B 25 0 719 692 ; +C 79 ; WX 768 ; N O ; B 42 -15 726 707 ; +C 80 ; WX 650 ; N P ; B 33 0 623 692 ; +C 81 ; WX 768 ; N Q ; B 42 -193 726 707 ; +C 82 ; WX 684 ; N R ; B 33 0 686 692 ; +C 83 ; WX 561 ; N S ; B 42 -15 533 707 ; +C 84 ; WX 624 ; N T ; B 15 0 609 692 ; +C 85 ; WX 786 ; N U ; B 29 -15 757 692 ; +C 86 ; WX 645 ; N V ; B -16 0 679 692 ; +C 87 ; WX 933 ; N W ; B -10 0 960 692 ; +C 88 ; WX 634 ; N X ; B -19 0 671 692 ; +C 89 ; WX 617 ; N Y ; B -12 0 655 692 ; +C 90 ; WX 614 ; N Z ; B 0 0 606 692 ; +C 91 ; WX 335 ; N bracketleft ; B 123 -128 308 692 ; +C 92 ; WX 379 ; N backslash ; B 34 -15 345 707 ; +C 93 ; WX 335 ; N bracketright ; B 27 -128 212 692 ; +C 94 ; WX 600 ; N asciicircum ; B 56 215 544 668 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 252 ; N quoteleft ; B 40 399 212 719 ; +C 97 ; WX 544 ; N a ; B 41 -12 561 502 ; +C 98 ; WX 605 ; N b ; B 15 -12 571 742 ; +C 99 ; WX 494 ; N c ; B 34 -12 484 502 ; +C 100 ; WX 605 ; N d ; B 34 -12 596 742 ; +C 101 ; WX 519 ; N e ; B 34 -12 505 502 ; +C 102 ; WX 342 ; N f ; B 27 0 421 742 ; L i fi ; L l fl ; +C 103 ; WX 533 ; N g ; B 25 -242 546 512 ; +C 104 ; WX 631 ; N h ; B 19 0 622 742 ; +C 105 ; WX 316 ; N i ; B 26 0 307 720 ; +C 106 ; WX 316 ; N j ; B -12 -232 260 720 ; +C 107 ; WX 582 ; N k ; B 19 0 595 742 ; +C 108 ; WX 309 ; N l ; B 19 0 300 742 ; +C 109 ; WX 948 ; N m ; B 26 0 939 502 ; +C 110 ; WX 638 ; N n ; B 26 0 629 502 ; +C 111 ; WX 585 ; N o ; B 34 -12 551 502 ; +C 112 ; WX 615 ; N p ; B 19 -230 581 502 ; +C 113 ; WX 597 ; N q ; B 34 -230 596 502 ; +C 114 ; WX 440 ; N r ; B 26 0 442 502 ; +C 115 ; WX 446 ; N s ; B 38 -12 425 502 ; +C 116 ; WX 370 ; N t ; B 32 -12 373 616 ; +C 117 ; WX 629 ; N u ; B 23 -12 620 502 ; +C 118 ; WX 520 ; N v ; B -8 0 546 490 ; +C 119 ; WX 774 ; N w ; B -10 0 802 490 ; +C 120 ; WX 522 ; N x ; B -15 0 550 490 ; +C 121 ; WX 524 ; N y ; B -12 -242 557 490 ; +C 122 ; WX 483 ; N z ; B -1 0 480 490 ; +C 123 ; WX 365 ; N braceleft ; B 74 -128 325 692 ; +C 124 ; WX 284 ; N bar ; B 94 -250 190 750 ; +C 125 ; WX 365 ; N braceright ; B 40 -128 291 692 ; +C 126 ; WX 600 ; N asciitilde ; B 50 158 551 339 ; +C 161 ; WX 278 ; N exclamdown ; B 47 -217 231 502 ; +C 162 ; WX 560 ; N cent ; B 39 -15 546 678 ; +C 163 ; WX 560 ; N sterling ; B 21 0 555 679 ; +C 164 ; WX 100 ; N fraction ; B -155 -27 255 695 ; +C 165 ; WX 560 ; N yen ; B 3 0 562 668 ; +C 166 ; WX 560 ; N florin ; B -40 -135 562 691 ; +C 167 ; WX 566 ; N section ; B 35 -115 531 707 ; +C 168 ; WX 560 ; N currency ; B 21 73 539 596 ; +C 169 ; WX 252 ; N quotesingle ; B 57 407 196 707 ; +C 170 ; WX 473 ; N quotedblleft ; B 40 399 433 719 ; +C 171 ; WX 487 ; N guillemotleft ; B 40 37 452 464 ; +C 172 ; WX 287 ; N guilsinglleft ; B 40 37 252 464 ; +C 173 ; WX 287 ; N guilsinglright ; B 35 37 247 464 ; +C 174 ; WX 639 ; N fi ; B 27 0 630 742 ; +C 175 ; WX 639 ; N fl ; B 27 0 630 742 ; +C 177 ; WX 500 ; N endash ; B 0 209 500 292 ; +C 178 ; WX 510 ; N dagger ; B 35 -125 475 707 ; +C 179 ; WX 486 ; N daggerdbl ; B 35 -119 451 707 ; +C 180 ; WX 280 ; N periodcentered ; B 48 156 232 342 ; +C 182 ; WX 552 ; N paragraph ; B 35 -101 527 692 ; +C 183 ; WX 455 ; N bullet ; B 50 174 405 529 ; +C 184 ; WX 252 ; N quotesinglbase ; B 40 -153 212 167 ; +C 185 ; WX 473 ; N quotedblbase ; B 40 -153 433 167 ; +C 186 ; WX 473 ; N quotedblright ; B 40 387 433 707 ; +C 187 ; WX 487 ; N guillemotright ; B 35 37 447 464 ; +C 188 ; WX 1000 ; N ellipsis ; B 75 -12 925 174 ; +C 189 ; WX 1289 ; N perthousand ; B 40 -31 1249 701 ; +C 191 ; WX 456 ; N questiondown ; B 23 -217 436 502 ; +C 193 ; WX 430 ; N grave ; B 40 511 312 740 ; +C 194 ; WX 430 ; N acute ; B 119 511 391 740 ; +C 195 ; WX 430 ; N circumflex ; B 28 520 402 747 ; +C 196 ; WX 430 ; N tilde ; B 2 553 427 706 ; +C 197 ; WX 430 ; N macron ; B 60 587 371 674 ; +C 198 ; WX 430 ; N breve ; B 56 556 375 716 ; +C 199 ; WX 430 ; N dotaccent ; B 136 561 294 710 ; +C 200 ; WX 430 ; N dieresis ; B 16 561 414 710 ; +C 202 ; WX 430 ; N ring ; B 96 540 334 762 ; +C 203 ; WX 430 ; N cedilla ; B 136 -246 335 0 ; +C 205 ; WX 430 ; N hungarumlaut ; B 64 521 446 751 ; +C 206 ; WX 430 ; N ogonek ; B 105 -246 325 0 ; +C 207 ; WX 430 ; N caron ; B 28 520 402 747 ; +C 208 ; WX 1000 ; N emdash ; B 0 209 1000 292 ; +C 225 ; WX 879 ; N AE ; B -77 0 854 692 ; +C 227 ; WX 405 ; N ordfeminine ; B 28 265 395 590 ; +C 232 ; WX 591 ; N Lslash ; B 30 0 590 692 ; +C 233 ; WX 768 ; N Oslash ; B 42 -61 726 747 ; +C 234 ; WX 1049 ; N OE ; B 42 0 1024 692 ; +C 235 ; WX 427 ; N ordmasculine ; B 28 265 399 590 ; +C 241 ; WX 806 ; N ae ; B 41 -12 792 502 ; +C 245 ; WX 316 ; N dotlessi ; B 26 0 307 502 ; +C 248 ; WX 321 ; N lslash ; B 16 0 332 742 ; +C 249 ; WX 585 ; N oslash ; B 34 -51 551 535 ; +C 250 ; WX 866 ; N oe ; B 34 -12 852 502 ; +C 251 ; WX 662 ; N germandbls ; B 29 -12 647 742 ; +C -1 ; WX 402 ; N onesuperior ; B 71 272 324 680 ; +C -1 ; WX 600 ; N minus ; B 58 210 542 290 ; +C -1 ; WX 396 ; N degree ; B 35 360 361 680 ; +C -1 ; WX 585 ; N oacute ; B 34 -12 551 755 ; +C -1 ; WX 768 ; N Odieresis ; B 42 -15 726 881 ; +C -1 ; WX 585 ; N odieresis ; B 34 -12 551 710 ; +C -1 ; WX 629 ; N Eacute ; B 33 0 604 904 ; +C -1 ; WX 629 ; N ucircumflex ; B 23 -12 620 747 ; +C -1 ; WX 900 ; N onequarter ; B 73 -27 814 695 ; +C -1 ; WX 600 ; N logicalnot ; B 58 95 542 397 ; +C -1 ; WX 629 ; N Ecircumflex ; B 33 0 604 905 ; +C -1 ; WX 900 ; N onehalf ; B 53 -27 849 695 ; +C -1 ; WX 768 ; N Otilde ; B 42 -15 726 876 ; +C -1 ; WX 629 ; N uacute ; B 23 -12 620 740 ; +C -1 ; WX 519 ; N eacute ; B 34 -12 505 755 ; +C -1 ; WX 316 ; N iacute ; B 26 0 369 740 ; +C -1 ; WX 629 ; N Egrave ; B 33 0 604 904 ; +C -1 ; WX 316 ; N icircumflex ; B -28 0 346 747 ; +C -1 ; WX 629 ; N mu ; B 23 -242 620 502 ; +C -1 ; WX 284 ; N brokenbar ; B 94 -175 190 675 ; +C -1 ; WX 609 ; N thorn ; B 13 -230 575 722 ; +C -1 ; WX 644 ; N Aring ; B -28 0 663 872 ; +C -1 ; WX 524 ; N yacute ; B -12 -242 557 740 ; +C -1 ; WX 617 ; N Ydieresis ; B -12 0 655 881 ; +C -1 ; WX 1090 ; N trademark ; B 38 277 1028 692 ; +C -1 ; WX 800 ; N registered ; B 36 -15 764 707 ; +C -1 ; WX 585 ; N ocircumflex ; B 34 -12 551 747 ; +C -1 ; WX 644 ; N Agrave ; B -28 0 663 904 ; +C -1 ; WX 561 ; N Scaron ; B 42 -15 533 916 ; +C -1 ; WX 786 ; N Ugrave ; B 29 -15 757 904 ; +C -1 ; WX 629 ; N Edieresis ; B 33 0 604 881 ; +C -1 ; WX 786 ; N Uacute ; B 29 -15 757 904 ; +C -1 ; WX 585 ; N otilde ; B 34 -12 551 706 ; +C -1 ; WX 638 ; N ntilde ; B 26 0 629 706 ; +C -1 ; WX 524 ; N ydieresis ; B -12 -242 557 710 ; +C -1 ; WX 644 ; N Aacute ; B -28 0 663 904 ; +C -1 ; WX 585 ; N eth ; B 34 -12 551 742 ; +C -1 ; WX 544 ; N acircumflex ; B 41 -12 561 747 ; +C -1 ; WX 544 ; N aring ; B 41 -12 561 762 ; +C -1 ; WX 768 ; N Ograve ; B 42 -15 726 904 ; +C -1 ; WX 494 ; N ccedilla ; B 34 -246 484 502 ; +C -1 ; WX 600 ; N multiply ; B 75 20 525 476 ; +C -1 ; WX 600 ; N divide ; B 58 6 542 494 ; +C -1 ; WX 402 ; N twosuperior ; B 29 272 382 680 ; +C -1 ; WX 739 ; N Ntilde ; B 25 0 719 876 ; +C -1 ; WX 629 ; N ugrave ; B 23 -12 620 740 ; +C -1 ; WX 786 ; N Ucircumflex ; B 29 -15 757 905 ; +C -1 ; WX 644 ; N Atilde ; B -28 0 663 876 ; +C -1 ; WX 483 ; N zcaron ; B -1 0 480 747 ; +C -1 ; WX 316 ; N idieresis ; B -37 0 361 710 ; +C -1 ; WX 644 ; N Acircumflex ; B -28 0 663 905 ; +C -1 ; WX 384 ; N Icircumflex ; B 4 0 380 905 ; +C -1 ; WX 617 ; N Yacute ; B -12 0 655 904 ; +C -1 ; WX 768 ; N Oacute ; B 42 -15 726 904 ; +C -1 ; WX 644 ; N Adieresis ; B -28 0 663 881 ; +C -1 ; WX 614 ; N Zcaron ; B 0 0 606 916 ; +C -1 ; WX 544 ; N agrave ; B 41 -12 561 755 ; +C -1 ; WX 402 ; N threesuperior ; B 30 265 368 680 ; +C -1 ; WX 585 ; N ograve ; B 34 -12 551 755 ; +C -1 ; WX 900 ; N threequarters ; B 40 -27 842 695 ; +C -1 ; WX 783 ; N Eth ; B 35 0 741 692 ; +C -1 ; WX 600 ; N plusminus ; B 58 0 542 549 ; +C -1 ; WX 629 ; N udieresis ; B 23 -12 620 710 ; +C -1 ; WX 519 ; N edieresis ; B 34 -12 505 710 ; +C -1 ; WX 544 ; N aacute ; B 41 -12 561 755 ; +C -1 ; WX 316 ; N igrave ; B -47 0 307 740 ; +C -1 ; WX 384 ; N Idieresis ; B -13 0 397 881 ; +C -1 ; WX 544 ; N adieresis ; B 41 -12 561 710 ; +C -1 ; WX 384 ; N Iacute ; B 33 0 423 904 ; +C -1 ; WX 800 ; N copyright ; B 36 -15 764 707 ; +C -1 ; WX 384 ; N Igrave ; B -31 0 351 904 ; +C -1 ; WX 689 ; N Ccedilla ; B 42 -246 654 707 ; +C -1 ; WX 446 ; N scaron ; B 38 -12 425 747 ; +C -1 ; WX 519 ; N egrave ; B 34 -12 505 755 ; +C -1 ; WX 768 ; N Ocircumflex ; B 42 -15 726 905 ; +C -1 ; WX 640 ; N Thorn ; B 33 0 622 692 ; +C -1 ; WX 544 ; N atilde ; B 41 -12 561 706 ; +C -1 ; WX 786 ; N Udieresis ; B 29 -15 757 881 ; +C -1 ; WX 519 ; N ecircumflex ; B 34 -12 505 747 ; +EndCharMetrics +StartKernData +StartKernPairs 685 + +KPX A z 25 +KPX A y -40 +KPX A w -42 +KPX A v -48 +KPX A u -18 +KPX A t -12 +KPX A s 6 +KPX A quoteright -110 +KPX A quotedblright -80 +KPX A q -6 +KPX A p -18 +KPX A o -12 +KPX A e -6 +KPX A d -12 +KPX A c -12 +KPX A b -12 +KPX A a -6 +KPX A Y -64 +KPX A X -18 +KPX A W -54 +KPX A V -70 +KPX A U -40 +KPX A T -58 +KPX A Q -18 +KPX A O -18 +KPX A G -18 +KPX A C -18 + +KPX B y -18 +KPX B u -12 +KPX B r -12 +KPX B o -6 +KPX B l -15 +KPX B k -15 +KPX B i -12 +KPX B h -15 +KPX B e -6 +KPX B b -10 +KPX B a -12 +KPX B W -20 +KPX B V -20 +KPX B U -25 +KPX B T -20 + +KPX C z -5 +KPX C y -24 +KPX C u -18 +KPX C r -6 +KPX C o -12 +KPX C e -12 +KPX C a -16 +KPX C Q -6 +KPX C O -6 +KPX C G -6 +KPX C C -6 + +KPX D u -12 +KPX D r -12 +KPX D period -40 +KPX D o -5 +KPX D i -12 +KPX D h -18 +KPX D e -5 +KPX D comma -40 +KPX D a -15 +KPX D Y -60 +KPX D W -40 +KPX D V -40 + +KPX E y -30 +KPX E w -24 +KPX E v -24 +KPX E u -12 +KPX E t -18 +KPX E s -12 +KPX E r -4 +KPX E q -6 +KPX E period 10 +KPX E p -18 +KPX E o -6 +KPX E n -4 +KPX E m -4 +KPX E j -6 +KPX E i -6 +KPX E g -6 +KPX E e -6 +KPX E d -6 +KPX E comma 10 +KPX E c -6 +KPX E b -5 +KPX E a -4 +KPX E Y -6 +KPX E W -6 +KPX E V -6 + +KPX F y -18 +KPX F u -12 +KPX F r -36 +KPX F quoteright 20 +KPX F quotedblright 20 +KPX F period -150 +KPX F o -36 +KPX F l -12 +KPX F i -22 +KPX F e -36 +KPX F comma -150 +KPX F a -48 +KPX F A -60 + +KPX G y -12 +KPX G u -12 +KPX G r -18 +KPX G quotedblright -20 +KPX G n -18 +KPX G l -6 +KPX G i -12 +KPX G h -12 +KPX G a -12 + +KPX H y -24 +KPX H u -26 +KPX H o -30 +KPX H i -18 +KPX H e -30 +KPX H a -25 + +KPX I z -6 +KPX I y -6 +KPX I x -6 +KPX I w -18 +KPX I v -24 +KPX I u -26 +KPX I t -24 +KPX I s -18 +KPX I r -12 +KPX I p -26 +KPX I o -30 +KPX I n -18 +KPX I m -18 +KPX I l -6 +KPX I k -6 +KPX I h -6 +KPX I g -6 +KPX I f -6 +KPX I e -30 +KPX I d -30 +KPX I c -30 +KPX I b -6 +KPX I a -24 + +KPX J y -20 +KPX J u -36 +KPX J o -35 +KPX J i -20 +KPX J e -35 +KPX J bracketright 15 +KPX J braceright 15 +KPX J a -36 + +KPX K y -70 +KPX K w -60 +KPX K v -80 +KPX K u -42 +KPX K o -30 +KPX K l 10 +KPX K i 6 +KPX K h 10 +KPX K e -18 +KPX K a -6 +KPX K Q -36 +KPX K O -36 +KPX K G -36 +KPX K C -36 +KPX K A 20 + +KPX L y -52 +KPX L w -58 +KPX L u -12 +KPX L quoteright -130 +KPX L quotedblright -130 +KPX L l 6 +KPX L j -6 +KPX L Y -70 +KPX L W -78 +KPX L V -95 +KPX L U -32 +KPX L T -80 +KPX L Q -12 +KPX L O -12 +KPX L G -12 +KPX L C -12 +KPX L A 30 + +KPX M y -24 +KPX M u -36 +KPX M o -30 +KPX M n -6 +KPX M j -12 +KPX M i -12 +KPX M e -30 +KPX M d -30 +KPX M c -30 +KPX M a -25 + +KPX N y -24 +KPX N u -30 +KPX N o -30 +KPX N i -24 +KPX N e -30 +KPX N a -30 + +KPX O z -6 +KPX O u -6 +KPX O t -6 +KPX O s -6 +KPX O r -10 +KPX O q -6 +KPX O period -40 +KPX O p -10 +KPX O o -6 +KPX O n -10 +KPX O m -10 +KPX O l -15 +KPX O k -15 +KPX O i -6 +KPX O h -15 +KPX O g -6 +KPX O e -6 +KPX O d -6 +KPX O comma -40 +KPX O c -6 +KPX O b -15 +KPX O a -12 +KPX O Y -50 +KPX O X -40 +KPX O W -35 +KPX O V -35 +KPX O T -40 +KPX O A -30 + +KPX P y 10 +KPX P u -18 +KPX P t -6 +KPX P s -30 +KPX P r -12 +KPX P quoteright 20 +KPX P quotedblright 20 +KPX P period -200 +KPX P o -36 +KPX P n -12 +KPX P l -15 +KPX P i -6 +KPX P hyphen -30 +KPX P h -15 +KPX P e -36 +KPX P comma -200 +KPX P a -36 +KPX P I -20 +KPX P H -20 +KPX P E -20 +KPX P A -85 + +KPX Q u -6 +KPX Q a -18 +KPX Q Y -50 +KPX Q X -40 +KPX Q W -35 +KPX Q V -35 +KPX Q U -25 +KPX Q T -40 +KPX Q A -30 + +KPX R y -20 +KPX R u -12 +KPX R t -25 +KPX R quoteright -10 +KPX R quotedblright -10 +KPX R o -12 +KPX R e -18 +KPX R a -6 +KPX R Y -32 +KPX R X 20 +KPX R W -18 +KPX R V -26 +KPX R U -30 +KPX R T -20 +KPX R Q -10 +KPX R O -10 +KPX R G -10 +KPX R C -10 + +KPX S y -35 +KPX S w -30 +KPX S v -40 +KPX S u -24 +KPX S t -24 +KPX S r -10 +KPX S quoteright -15 +KPX S quotedblright -15 +KPX S p -24 +KPX S n -24 +KPX S m -24 +KPX S l -18 +KPX S k -24 +KPX S j -30 +KPX S i -12 +KPX S h -12 +KPX S a -18 + +KPX T z -64 +KPX T y -74 +KPX T w -72 +KPX T u -74 +KPX T semicolon -50 +KPX T s -82 +KPX T r -74 +KPX T quoteright 24 +KPX T quotedblright 24 +KPX T period -95 +KPX T parenright 40 +KPX T o -90 +KPX T m -72 +KPX T i -28 +KPX T hyphen -110 +KPX T endash -40 +KPX T emdash -60 +KPX T e -80 +KPX T comma -95 +KPX T bracketright 40 +KPX T braceright 30 +KPX T a -90 +KPX T Y 12 +KPX T X 10 +KPX T W 15 +KPX T V 6 +KPX T T 30 +KPX T S -12 +KPX T Q -25 +KPX T O -25 +KPX T G -25 +KPX T C -25 +KPX T A -52 + +KPX U z -35 +KPX U y -30 +KPX U x -30 +KPX U v -30 +KPX U t -36 +KPX U s -45 +KPX U r -50 +KPX U p -50 +KPX U n -50 +KPX U m -50 +KPX U l -12 +KPX U k -12 +KPX U i -22 +KPX U h -6 +KPX U g -40 +KPX U f -20 +KPX U d -40 +KPX U c -40 +KPX U b -12 +KPX U a -50 +KPX U A -50 + +KPX V y -36 +KPX V u -50 +KPX V semicolon -45 +KPX V r -75 +KPX V quoteright 50 +KPX V quotedblright 36 +KPX V period -135 +KPX V parenright 80 +KPX V o -70 +KPX V i 20 +KPX V hyphen -90 +KPX V emdash -20 +KPX V e -70 +KPX V comma -135 +KPX V colon -45 +KPX V bracketright 80 +KPX V braceright 80 +KPX V a -70 +KPX V Q -20 +KPX V O -20 +KPX V G -20 +KPX V C -20 +KPX V A -60 + +KPX W y -50 +KPX W u -46 +KPX W t -30 +KPX W semicolon -40 +KPX W r -50 +KPX W quoteright 40 +KPX W quotedblright 24 +KPX W period -100 +KPX W parenright 80 +KPX W o -60 +KPX W m -50 +KPX W i 5 +KPX W hyphen -70 +KPX W h 20 +KPX W e -60 +KPX W d -60 +KPX W comma -100 +KPX W colon -40 +KPX W bracketright 80 +KPX W braceright 70 +KPX W a -75 +KPX W T 30 +KPX W Q -20 +KPX W O -20 +KPX W G -20 +KPX W C -20 +KPX W A -58 + +KPX X y -40 +KPX X u -24 +KPX X quoteright 15 +KPX X e -6 +KPX X a -6 +KPX X Q -24 +KPX X O -30 +KPX X G -30 +KPX X C -30 +KPX X A 20 + +KPX Y v -50 +KPX Y u -65 +KPX Y t -46 +KPX Y semicolon -37 +KPX Y quoteright 50 +KPX Y quotedblright 36 +KPX Y q -100 +KPX Y period -90 +KPX Y parenright 60 +KPX Y o -90 +KPX Y l 25 +KPX Y i 15 +KPX Y hyphen -100 +KPX Y endash -30 +KPX Y emdash -50 +KPX Y e -90 +KPX Y d -90 +KPX Y comma -90 +KPX Y colon -60 +KPX Y bracketright 80 +KPX Y braceright 64 +KPX Y a -80 +KPX Y Y 12 +KPX Y X 12 +KPX Y W 12 +KPX Y V 12 +KPX Y T 30 +KPX Y Q -40 +KPX Y O -40 +KPX Y G -40 +KPX Y C -40 +KPX Y A -55 + +KPX Z y -36 +KPX Z w -36 +KPX Z u -6 +KPX Z o -12 +KPX Z i -12 +KPX Z e -6 +KPX Z a -6 +KPX Z Q -18 +KPX Z O -18 +KPX Z G -18 +KPX Z C -18 +KPX Z A 25 + +KPX a quoteright -45 +KPX a quotedblright -40 + +KPX b y -15 +KPX b w -20 +KPX b v -20 +KPX b quoteright -45 +KPX b quotedblright -40 +KPX b period -10 +KPX b comma -10 + +KPX braceleft Y 64 +KPX braceleft W 64 +KPX braceleft V 64 +KPX braceleft T 25 +KPX braceleft J 50 + +KPX bracketleft Y 64 +KPX bracketleft W 64 +KPX bracketleft V 64 +KPX bracketleft T 35 +KPX bracketleft J 60 + +KPX c quoteright -5 + +KPX colon space -20 + +KPX comma space -40 +KPX comma quoteright -100 +KPX comma quotedblright -100 + +KPX d quoteright -24 +KPX d quotedblright -24 + +KPX e z -4 +KPX e quoteright -25 +KPX e quotedblright -20 + +KPX f quotesingle 70 +KPX f quoteright 68 +KPX f quotedblright 68 +KPX f period -10 +KPX f parenright 110 +KPX f comma -20 +KPX f bracketright 100 +KPX f braceright 80 + +KPX g y 20 +KPX g p 20 +KPX g f 20 +KPX g comma 10 + +KPX h quoteright -60 +KPX h quotedblright -60 + +KPX i quoteright -20 +KPX i quotedblright -20 + +KPX j quoteright -20 +KPX j quotedblright -20 +KPX j period -10 +KPX j comma -10 + +KPX k quoteright -30 +KPX k quotedblright -30 + +KPX l quoteright -24 +KPX l quotedblright -24 + +KPX m quoteright -60 +KPX m quotedblright -60 + +KPX n quoteright -60 +KPX n quotedblright -60 + +KPX o z -12 +KPX o y -25 +KPX o x -18 +KPX o w -30 +KPX o v -30 +KPX o quoteright -45 +KPX o quotedblright -40 +KPX o period -10 +KPX o comma -10 + +KPX p z -10 +KPX p y -15 +KPX p w -15 +KPX p quoteright -45 +KPX p quotedblright -60 +KPX p period -10 +KPX p comma -10 + +KPX parenleft Y 64 +KPX parenleft W 64 +KPX parenleft V 64 +KPX parenleft T 50 +KPX parenleft J 50 + +KPX period space -40 +KPX period quoteright -100 +KPX period quotedblright -100 + +KPX q quoteright -50 +KPX q quotedblright -50 +KPX q period -10 +KPX q comma -10 + +KPX quotedblleft z -26 +KPX quotedblleft w 10 +KPX quotedblleft u -40 +KPX quotedblleft t -40 +KPX quotedblleft s -32 +KPX quotedblleft r -40 +KPX quotedblleft q -70 +KPX quotedblleft p -40 +KPX quotedblleft o -70 +KPX quotedblleft n -40 +KPX quotedblleft m -40 +KPX quotedblleft g -50 +KPX quotedblleft f -30 +KPX quotedblleft e -70 +KPX quotedblleft d -70 +KPX quotedblleft c -70 +KPX quotedblleft a -60 +KPX quotedblleft Y 30 +KPX quotedblleft X 20 +KPX quotedblleft W 40 +KPX quotedblleft V 40 +KPX quotedblleft T 18 +KPX quotedblleft J -24 +KPX quotedblleft A -122 + +KPX quotedblright space -40 +KPX quotedblright period -100 +KPX quotedblright comma -100 + +KPX quoteleft z -26 +KPX quoteleft y -5 +KPX quoteleft x -5 +KPX quoteleft w 5 +KPX quoteleft v -5 +KPX quoteleft u -25 +KPX quoteleft t -25 +KPX quoteleft s -40 +KPX quoteleft r -40 +KPX quoteleft quoteleft -30 +KPX quoteleft q -70 +KPX quoteleft p -40 +KPX quoteleft o -70 +KPX quoteleft n -40 +KPX quoteleft m -40 +KPX quoteleft g -50 +KPX quoteleft f -10 +KPX quoteleft e -70 +KPX quoteleft d -70 +KPX quoteleft c -70 +KPX quoteleft a -60 +KPX quoteleft Y 35 +KPX quoteleft X 30 +KPX quoteleft W 35 +KPX quoteleft V 35 +KPX quoteleft T 35 +KPX quoteleft J -24 +KPX quoteleft A -122 + +KPX quoteright v -20 +KPX quoteright t -50 +KPX quoteright space -40 +KPX quoteright s -70 +KPX quoteright r -42 +KPX quoteright quoteright -30 +KPX quoteright period -100 +KPX quoteright m -42 +KPX quoteright l -6 +KPX quoteright d -100 +KPX quoteright comma -100 + +KPX r z 20 +KPX r y 18 +KPX r x 12 +KPX r w 30 +KPX r v 30 +KPX r u 8 +KPX r t 8 +KPX r semicolon 20 +KPX r quoteright -20 +KPX r quotedblright -10 +KPX r q -6 +KPX r period -60 +KPX r o -6 +KPX r n 8 +KPX r m 8 +KPX r l -10 +KPX r k -10 +KPX r i 8 +KPX r hyphen -60 +KPX r h -10 +KPX r g 5 +KPX r f 8 +KPX r emdash -20 +KPX r e -20 +KPX r d -20 +KPX r comma -80 +KPX r colon 20 +KPX r c -20 + +KPX s quoteright -40 +KPX s quotedblright -40 + +KPX semicolon space -20 + +KPX space quotesinglbase -100 +KPX space quoteleft -40 +KPX space quotedblleft -40 +KPX space quotedblbase -100 +KPX space Y -60 +KPX space W -60 +KPX space V -60 +KPX space T -40 + +KPX t period 15 +KPX t comma 10 + +KPX u quoteright -60 +KPX u quotedblright -60 + +KPX v semicolon 20 +KPX v quoteright 5 +KPX v quotedblright 10 +KPX v q -15 +KPX v period -75 +KPX v o -15 +KPX v e -15 +KPX v d -15 +KPX v comma -90 +KPX v colon 20 +KPX v c -15 +KPX v a -15 + +KPX w semicolon 20 +KPX w quoteright 15 +KPX w quotedblright 20 +KPX w q -10 +KPX w period -60 +KPX w o -10 +KPX w e -10 +KPX w d -10 +KPX w comma -68 +KPX w colon 20 +KPX w c -10 + +KPX x quoteright -25 +KPX x quotedblright -20 +KPX x q -6 +KPX x o -6 +KPX x e -12 +KPX x d -12 +KPX x c -12 + +KPX y semicolon 20 +KPX y quoteright 5 +KPX y quotedblright 10 +KPX y period -72 +KPX y hyphen -20 +KPX y comma -72 +KPX y colon 20 + +KPX z quoteright -20 +KPX z quotedblright -20 +KPX z o -6 +KPX z e -6 +KPX z d -6 +KPX z c -6 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putbi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putbi8a.afm new file mode 100644 index 00000000..5e838485 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putbi8a.afm @@ -0,0 +1,1017 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Fri Jan 17 15:47:44 1992 +Comment UniqueID 37716 +Comment VMusage 34427 41319 +FontName Utopia-BoldItalic +FullName Utopia Bold Italic +FamilyName Utopia +Weight Bold +ItalicAngle -13 +IsFixedPitch false +FontBBox -176 -250 1262 916 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.002 +Notice Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved.Utopia is a registered trademark of Adobe Systems Incorporated. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 502 +Ascender 742 +Descender -242 +StartCharMetrics 228 +C 32 ; WX 210 ; N space ; B 0 0 0 0 ; +C 33 ; WX 285 ; N exclam ; B 35 -12 336 707 ; +C 34 ; WX 455 ; N quotedbl ; B 142 407 496 707 ; +C 35 ; WX 560 ; N numbersign ; B 37 0 606 668 ; +C 36 ; WX 560 ; N dollar ; B 32 -104 588 748 ; +C 37 ; WX 896 ; N percent ; B 106 -31 861 702 ; +C 38 ; WX 752 ; N ampersand ; B 62 -12 736 680 ; +C 39 ; WX 246 ; N quoteright ; B 95 387 294 707 ; +C 40 ; WX 350 ; N parenleft ; B 87 -135 438 699 ; +C 41 ; WX 350 ; N parenright ; B -32 -135 319 699 ; +C 42 ; WX 500 ; N asterisk ; B 121 315 528 707 ; +C 43 ; WX 600 ; N plus ; B 83 0 567 490 ; +C 44 ; WX 280 ; N comma ; B -9 -167 207 180 ; +C 45 ; WX 392 ; N hyphen ; B 71 203 354 298 ; +C 46 ; WX 280 ; N period ; B 32 -12 212 166 ; +C 47 ; WX 260 ; N slash ; B -16 -15 370 707 ; +C 48 ; WX 560 ; N zero ; B 57 -12 583 680 ; +C 49 ; WX 560 ; N one ; B 72 0 470 680 ; +C 50 ; WX 560 ; N two ; B 4 0 578 680 ; +C 51 ; WX 560 ; N three ; B 21 -12 567 680 ; +C 52 ; WX 560 ; N four ; B 28 0 557 668 ; +C 53 ; WX 560 ; N five ; B 23 -12 593 668 ; +C 54 ; WX 560 ; N six ; B 56 -12 586 680 ; +C 55 ; WX 560 ; N seven ; B 112 -12 632 668 ; +C 56 ; WX 560 ; N eight ; B 37 -12 584 680 ; +C 57 ; WX 560 ; N nine ; B 48 -12 570 680 ; +C 58 ; WX 280 ; N colon ; B 32 -12 280 490 ; +C 59 ; WX 280 ; N semicolon ; B -9 -167 280 490 ; +C 60 ; WX 600 ; N less ; B 66 5 544 495 ; +C 61 ; WX 600 ; N equal ; B 83 103 567 397 ; +C 62 ; WX 600 ; N greater ; B 86 5 564 495 ; +C 63 ; WX 454 ; N question ; B 115 -12 515 707 ; +C 64 ; WX 828 ; N at ; B 90 -15 842 707 ; +C 65 ; WX 634 ; N A ; B -59 0 639 692 ; +C 66 ; WX 680 ; N B ; B 5 0 689 692 ; +C 67 ; WX 672 ; N C ; B 76 -15 742 707 ; +C 68 ; WX 774 ; N D ; B 5 0 784 692 ; +C 69 ; WX 622 ; N E ; B 5 0 687 692 ; +C 70 ; WX 585 ; N F ; B 5 0 683 692 ; +C 71 ; WX 726 ; N G ; B 76 -15 756 707 ; +C 72 ; WX 800 ; N H ; B 5 0 880 692 ; +C 73 ; WX 386 ; N I ; B 5 0 466 692 ; +C 74 ; WX 388 ; N J ; B -50 -114 477 692 ; +C 75 ; WX 688 ; N K ; B 5 -6 823 692 ; +C 76 ; WX 586 ; N L ; B 5 0 591 692 ; +C 77 ; WX 921 ; N M ; B 0 0 998 692 ; +C 78 ; WX 741 ; N N ; B -5 0 838 692 ; +C 79 ; WX 761 ; N O ; B 78 -15 768 707 ; +C 80 ; WX 660 ; N P ; B 5 0 694 692 ; +C 81 ; WX 761 ; N Q ; B 78 -193 768 707 ; +C 82 ; WX 681 ; N R ; B 5 0 696 692 ; +C 83 ; WX 551 ; N S ; B 31 -15 570 707 ; +C 84 ; WX 616 ; N T ; B 91 0 722 692 ; +C 85 ; WX 776 ; N U ; B 115 -15 867 692 ; +C 86 ; WX 630 ; N V ; B 92 0 783 692 ; +C 87 ; WX 920 ; N W ; B 80 0 1062 692 ; +C 88 ; WX 630 ; N X ; B -56 0 744 692 ; +C 89 ; WX 622 ; N Y ; B 92 0 765 692 ; +C 90 ; WX 618 ; N Z ; B -30 0 714 692 ; +C 91 ; WX 350 ; N bracketleft ; B 56 -128 428 692 ; +C 92 ; WX 460 ; N backslash ; B 114 -15 425 707 ; +C 93 ; WX 350 ; N bracketright ; B -22 -128 350 692 ; +C 94 ; WX 600 ; N asciicircum ; B 79 215 567 668 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 246 ; N quoteleft ; B 114 399 313 719 ; +C 97 ; WX 596 ; N a ; B 26 -12 612 502 ; +C 98 ; WX 586 ; N b ; B 34 -12 592 742 ; +C 99 ; WX 456 ; N c ; B 38 -12 498 502 ; +C 100 ; WX 609 ; N d ; B 29 -12 651 742 ; +C 101 ; WX 476 ; N e ; B 38 -12 497 502 ; +C 102 ; WX 348 ; N f ; B -129 -242 553 742 ; L i fi ; L l fl ; +C 103 ; WX 522 ; N g ; B -14 -242 609 512 ; +C 104 ; WX 629 ; N h ; B 44 -12 631 742 ; +C 105 ; WX 339 ; N i ; B 66 -12 357 720 ; +C 106 ; WX 333 ; N j ; B -120 -242 364 720 ; +C 107 ; WX 570 ; N k ; B 39 -12 604 742 ; +C 108 ; WX 327 ; N l ; B 62 -12 360 742 ; +C 109 ; WX 914 ; N m ; B 46 -12 917 502 ; +C 110 ; WX 635 ; N n ; B 45 -12 639 502 ; +C 111 ; WX 562 ; N o ; B 42 -12 556 502 ; +C 112 ; WX 606 ; N p ; B 0 -242 613 502 ; +C 113 ; WX 584 ; N q ; B 29 -242 604 513 ; +C 114 ; WX 440 ; N r ; B 51 -12 497 502 ; +C 115 ; WX 417 ; N s ; B 10 -12 432 502 ; +C 116 ; WX 359 ; N t ; B 68 -12 428 641 ; +C 117 ; WX 634 ; N u ; B 71 -12 643 502 ; +C 118 ; WX 518 ; N v ; B 68 -12 547 502 ; +C 119 ; WX 795 ; N w ; B 70 -12 826 502 ; +C 120 ; WX 516 ; N x ; B -26 -12 546 502 ; +C 121 ; WX 489 ; N y ; B -49 -242 532 502 ; +C 122 ; WX 466 ; N z ; B -17 -12 506 490 ; +C 123 ; WX 340 ; N braceleft ; B 90 -128 439 692 ; +C 124 ; WX 265 ; N bar ; B 117 -250 221 750 ; +C 125 ; WX 340 ; N braceright ; B -42 -128 307 692 ; +C 126 ; WX 600 ; N asciitilde ; B 70 157 571 338 ; +C 161 ; WX 285 ; N exclamdown ; B -13 -217 288 502 ; +C 162 ; WX 560 ; N cent ; B 80 -21 611 668 ; +C 163 ; WX 560 ; N sterling ; B -4 0 583 679 ; +C 164 ; WX 100 ; N fraction ; B -176 -27 370 695 ; +C 165 ; WX 560 ; N yen ; B 65 0 676 668 ; +C 166 ; WX 560 ; N florin ; B -16 -135 635 691 ; +C 167 ; WX 568 ; N section ; B 64 -115 559 707 ; +C 168 ; WX 560 ; N currency ; B 60 73 578 596 ; +C 169 ; WX 246 ; N quotesingle ; B 134 376 285 707 ; +C 170 ; WX 455 ; N quotedblleft ; B 114 399 522 719 ; +C 171 ; WX 560 ; N guillemotleft ; B 90 37 533 464 ; +C 172 ; WX 360 ; N guilsinglleft ; B 90 37 333 464 ; +C 173 ; WX 360 ; N guilsinglright ; B 58 37 301 464 ; +C 174 ; WX 651 ; N fi ; B -129 -242 655 742 ; +C 175 ; WX 652 ; N fl ; B -129 -242 685 742 ; +C 177 ; WX 500 ; N endash ; B 12 209 531 292 ; +C 178 ; WX 514 ; N dagger ; B 101 -125 545 707 ; +C 179 ; WX 490 ; N daggerdbl ; B 32 -119 528 707 ; +C 180 ; WX 280 ; N periodcentered ; B 67 161 247 339 ; +C 182 ; WX 580 ; N paragraph ; B 110 -101 653 692 ; +C 183 ; WX 465 ; N bullet ; B 99 174 454 529 ; +C 184 ; WX 246 ; N quotesinglbase ; B -17 -153 182 167 ; +C 185 ; WX 455 ; N quotedblbase ; B -17 -153 391 167 ; +C 186 ; WX 455 ; N quotedblright ; B 95 387 503 707 ; +C 187 ; WX 560 ; N guillemotright ; B 58 37 502 464 ; +C 188 ; WX 1000 ; N ellipsis ; B 85 -12 931 166 ; +C 189 ; WX 1297 ; N perthousand ; B 106 -31 1262 702 ; +C 191 ; WX 454 ; N questiondown ; B -10 -217 391 502 ; +C 193 ; WX 400 ; N grave ; B 109 511 381 740 ; +C 194 ; WX 400 ; N acute ; B 186 511 458 740 ; +C 195 ; WX 400 ; N circumflex ; B 93 520 471 747 ; +C 196 ; WX 400 ; N tilde ; B 94 549 502 697 ; +C 197 ; WX 400 ; N macron ; B 133 592 459 664 ; +C 198 ; WX 400 ; N breve ; B 146 556 469 714 ; +C 199 ; WX 402 ; N dotaccent ; B 220 561 378 710 ; +C 200 ; WX 400 ; N dieresis ; B 106 561 504 710 ; +C 202 ; WX 400 ; N ring ; B 166 529 423 762 ; +C 203 ; WX 400 ; N cedilla ; B 85 -246 292 0 ; +C 205 ; WX 400 ; N hungarumlaut ; B 158 546 482 750 ; +C 206 ; WX 350 ; N ogonek ; B 38 -246 253 0 ; +C 207 ; WX 400 ; N caron ; B 130 520 508 747 ; +C 208 ; WX 1000 ; N emdash ; B 12 209 1031 292 ; +C 225 ; WX 890 ; N AE ; B -107 0 958 692 ; +C 227 ; WX 444 ; N ordfeminine ; B 62 265 482 590 ; +C 232 ; WX 592 ; N Lslash ; B 11 0 597 692 ; +C 233 ; WX 761 ; N Oslash ; B 77 -51 769 734 ; +C 234 ; WX 1016 ; N OE ; B 76 0 1084 692 ; +C 235 ; WX 412 ; N ordmasculine ; B 86 265 446 590 ; +C 241 ; WX 789 ; N ae ; B 26 -12 810 509 ; +C 245 ; WX 339 ; N dotlessi ; B 66 -12 343 502 ; +C 248 ; WX 339 ; N lslash ; B 18 -12 420 742 ; +C 249 ; WX 562 ; N oslash ; B 42 -69 556 549 ; +C 250 ; WX 811 ; N oe ; B 42 -12 832 502 ; +C 251 ; WX 628 ; N germandbls ; B -129 -242 692 742 ; +C -1 ; WX 402 ; N onesuperior ; B 84 272 361 680 ; +C -1 ; WX 600 ; N minus ; B 83 210 567 290 ; +C -1 ; WX 375 ; N degree ; B 93 360 425 680 ; +C -1 ; WX 562 ; N oacute ; B 42 -12 572 755 ; +C -1 ; WX 761 ; N Odieresis ; B 78 -15 768 881 ; +C -1 ; WX 562 ; N odieresis ; B 42 -12 585 710 ; +C -1 ; WX 622 ; N Eacute ; B 5 0 687 904 ; +C -1 ; WX 634 ; N ucircumflex ; B 71 -12 643 747 ; +C -1 ; WX 940 ; N onequarter ; B 104 -27 849 695 ; +C -1 ; WX 600 ; N logicalnot ; B 83 95 567 397 ; +C -1 ; WX 622 ; N Ecircumflex ; B 5 0 687 905 ; +C -1 ; WX 940 ; N onehalf ; B 90 -27 898 695 ; +C -1 ; WX 761 ; N Otilde ; B 78 -15 768 876 ; +C -1 ; WX 634 ; N uacute ; B 71 -12 643 740 ; +C -1 ; WX 476 ; N eacute ; B 38 -12 545 755 ; +C -1 ; WX 339 ; N iacute ; B 66 -12 438 740 ; +C -1 ; WX 622 ; N Egrave ; B 5 0 687 904 ; +C -1 ; WX 339 ; N icircumflex ; B 38 -12 416 747 ; +C -1 ; WX 634 ; N mu ; B -3 -230 643 502 ; +C -1 ; WX 265 ; N brokenbar ; B 117 -175 221 675 ; +C -1 ; WX 600 ; N thorn ; B -6 -242 607 700 ; +C -1 ; WX 634 ; N Aring ; B -59 0 639 879 ; +C -1 ; WX 489 ; N yacute ; B -49 -242 553 740 ; +C -1 ; WX 622 ; N Ydieresis ; B 92 0 765 881 ; +C -1 ; WX 1100 ; N trademark ; B 103 277 1093 692 ; +C -1 ; WX 824 ; N registered ; B 91 -15 819 707 ; +C -1 ; WX 562 ; N ocircumflex ; B 42 -12 556 747 ; +C -1 ; WX 634 ; N Agrave ; B -59 0 639 904 ; +C -1 ; WX 551 ; N Scaron ; B 31 -15 612 916 ; +C -1 ; WX 776 ; N Ugrave ; B 115 -15 867 904 ; +C -1 ; WX 622 ; N Edieresis ; B 5 0 687 881 ; +C -1 ; WX 776 ; N Uacute ; B 115 -15 867 904 ; +C -1 ; WX 562 ; N otilde ; B 42 -12 583 697 ; +C -1 ; WX 635 ; N ntilde ; B 45 -12 639 697 ; +C -1 ; WX 489 ; N ydieresis ; B -49 -242 532 710 ; +C -1 ; WX 634 ; N Aacute ; B -59 0 678 904 ; +C -1 ; WX 562 ; N eth ; B 42 -12 558 742 ; +C -1 ; WX 596 ; N acircumflex ; B 26 -12 612 747 ; +C -1 ; WX 596 ; N aring ; B 26 -12 612 762 ; +C -1 ; WX 761 ; N Ograve ; B 78 -15 768 904 ; +C -1 ; WX 456 ; N ccedilla ; B 38 -246 498 502 ; +C -1 ; WX 600 ; N multiply ; B 110 22 560 478 ; +C -1 ; WX 600 ; N divide ; B 63 7 547 493 ; +C -1 ; WX 402 ; N twosuperior ; B 29 272 423 680 ; +C -1 ; WX 741 ; N Ntilde ; B -5 0 838 876 ; +C -1 ; WX 634 ; N ugrave ; B 71 -12 643 740 ; +C -1 ; WX 776 ; N Ucircumflex ; B 115 -15 867 905 ; +C -1 ; WX 634 ; N Atilde ; B -59 0 662 876 ; +C -1 ; WX 466 ; N zcaron ; B -17 -12 526 747 ; +C -1 ; WX 339 ; N idieresis ; B 46 -12 444 710 ; +C -1 ; WX 634 ; N Acircumflex ; B -59 0 639 905 ; +C -1 ; WX 386 ; N Icircumflex ; B 5 0 506 905 ; +C -1 ; WX 622 ; N Yacute ; B 92 0 765 904 ; +C -1 ; WX 761 ; N Oacute ; B 78 -15 768 904 ; +C -1 ; WX 634 ; N Adieresis ; B -59 0 652 881 ; +C -1 ; WX 618 ; N Zcaron ; B -30 0 714 916 ; +C -1 ; WX 596 ; N agrave ; B 26 -12 612 755 ; +C -1 ; WX 402 ; N threesuperior ; B 59 265 421 680 ; +C -1 ; WX 562 ; N ograve ; B 42 -12 556 755 ; +C -1 ; WX 940 ; N threequarters ; B 95 -27 876 695 ; +C -1 ; WX 780 ; N Eth ; B 11 0 790 692 ; +C -1 ; WX 600 ; N plusminus ; B 83 0 567 549 ; +C -1 ; WX 634 ; N udieresis ; B 71 -12 643 710 ; +C -1 ; WX 476 ; N edieresis ; B 38 -12 542 710 ; +C -1 ; WX 596 ; N aacute ; B 26 -12 621 755 ; +C -1 ; WX 339 ; N igrave ; B 39 -12 343 740 ; +C -1 ; WX 386 ; N Idieresis ; B 5 0 533 881 ; +C -1 ; WX 596 ; N adieresis ; B 26 -12 612 710 ; +C -1 ; WX 386 ; N Iacute ; B 5 0 549 904 ; +C -1 ; WX 824 ; N copyright ; B 91 -15 819 707 ; +C -1 ; WX 386 ; N Igrave ; B 5 0 466 904 ; +C -1 ; WX 672 ; N Ccedilla ; B 76 -246 742 707 ; +C -1 ; WX 417 ; N scaron ; B 10 -12 522 747 ; +C -1 ; WX 476 ; N egrave ; B 38 -12 497 755 ; +C -1 ; WX 761 ; N Ocircumflex ; B 78 -15 768 905 ; +C -1 ; WX 629 ; N Thorn ; B 5 0 660 692 ; +C -1 ; WX 596 ; N atilde ; B 26 -12 612 697 ; +C -1 ; WX 776 ; N Udieresis ; B 115 -15 867 881 ; +C -1 ; WX 476 ; N ecircumflex ; B 38 -12 524 747 ; +EndCharMetrics +StartKernData +StartKernPairs 697 + +KPX A z 18 +KPX A y -40 +KPX A x 16 +KPX A w -30 +KPX A v -30 +KPX A u -18 +KPX A t -6 +KPX A s 6 +KPX A r -6 +KPX A quoteright -92 +KPX A quotedblright -92 +KPX A p -6 +KPX A o -18 +KPX A n -12 +KPX A m -12 +KPX A l -18 +KPX A h -6 +KPX A d 4 +KPX A c -6 +KPX A b -6 +KPX A a 10 +KPX A Y -56 +KPX A X -8 +KPX A W -46 +KPX A V -75 +KPX A U -50 +KPX A T -60 +KPX A Q -30 +KPX A O -30 +KPX A G -30 +KPX A C -30 + +KPX B y -6 +KPX B u -12 +KPX B r -6 +KPX B quoteright -20 +KPX B quotedblright -32 +KPX B o 6 +KPX B l -20 +KPX B k -10 +KPX B i -12 +KPX B h -15 +KPX B e 4 +KPX B a 10 +KPX B W -30 +KPX B V -45 +KPX B U -30 +KPX B T -20 + +KPX C z -6 +KPX C y -18 +KPX C u -12 +KPX C r -12 +KPX C quoteright 12 +KPX C quotedblright 20 +KPX C i -6 +KPX C e -6 +KPX C a -6 +KPX C Q -12 +KPX C O -12 +KPX C G -12 +KPX C C -12 + +KPX D y 18 +KPX D quoteright -20 +KPX D quotedblright -20 +KPX D period -20 +KPX D o 6 +KPX D h -15 +KPX D e 6 +KPX D comma -20 +KPX D a 6 +KPX D Y -80 +KPX D W -40 +KPX D V -65 + +KPX E z -6 +KPX E y -24 +KPX E x 15 +KPX E w -30 +KPX E v -18 +KPX E u -24 +KPX E t -18 +KPX E s -6 +KPX E r -6 +KPX E quoteright 10 +KPX E q 10 +KPX E period 15 +KPX E p -12 +KPX E n -12 +KPX E m -12 +KPX E l -6 +KPX E j -6 +KPX E i -12 +KPX E g -12 +KPX E d 10 +KPX E comma 15 +KPX E a 10 + +KPX F y -12 +KPX F u -24 +KPX F r -12 +KPX F quoteright 40 +KPX F quotedblright 35 +KPX F period -120 +KPX F o -24 +KPX F i -6 +KPX F e -24 +KPX F comma -110 +KPX F a -30 +KPX F A -45 + +KPX G y -25 +KPX G u -22 +KPX G r -22 +KPX G quoteright -30 +KPX G quotedblright -30 +KPX G n -22 +KPX G l -24 +KPX G i -12 +KPX G h -18 +KPX G e 5 + +KPX H y -18 +KPX H u -30 +KPX H o -25 +KPX H i -25 +KPX H e -25 +KPX H a -25 + +KPX I z -20 +KPX I y -6 +KPX I x -6 +KPX I w -30 +KPX I v -30 +KPX I u -30 +KPX I t -18 +KPX I s -18 +KPX I r -12 +KPX I p -18 +KPX I o -25 +KPX I n -18 +KPX I m -18 +KPX I l -6 +KPX I k -6 +KPX I j -20 +KPX I i -10 +KPX I g -24 +KPX I f -6 +KPX I e -25 +KPX I d -15 +KPX I c -25 +KPX I b -6 +KPX I a -15 + +KPX J y -12 +KPX J u -32 +KPX J quoteright 6 +KPX J quotedblright 6 +KPX J o -36 +KPX J i -30 +KPX J e -30 +KPX J braceright 15 +KPX J a -36 + +KPX K y -70 +KPX K w -36 +KPX K v -30 +KPX K u -30 +KPX K r -24 +KPX K quoteright 36 +KPX K quotedblright 36 +KPX K o -30 +KPX K n -24 +KPX K l 10 +KPX K i -12 +KPX K h 15 +KPX K e -30 +KPX K a -12 +KPX K Q -50 +KPX K O -50 +KPX K G -50 +KPX K C -50 +KPX K A 15 + +KPX L y -70 +KPX L w -30 +KPX L u -18 +KPX L quoteright -110 +KPX L quotedblright -110 +KPX L l -16 +KPX L j -18 +KPX L i -18 +KPX L Y -80 +KPX L W -78 +KPX L V -110 +KPX L U -42 +KPX L T -100 +KPX L Q -48 +KPX L O -48 +KPX L G -48 +KPX L C -48 +KPX L A 40 + +KPX M y -18 +KPX M u -24 +KPX M quoteright 6 +KPX M quotedblright 6 +KPX M o -25 +KPX M n -20 +KPX M j -35 +KPX M i -20 +KPX M e -25 +KPX M d -20 +KPX M c -25 +KPX M a -20 + +KPX N y -18 +KPX N u -24 +KPX N o -18 +KPX N i -12 +KPX N e -16 +KPX N a -22 + +KPX O z -6 +KPX O y 12 +KPX O u -6 +KPX O t -6 +KPX O s -6 +KPX O r -6 +KPX O quoteright -20 +KPX O quotedblright -20 +KPX O q 6 +KPX O period -10 +KPX O p -6 +KPX O n -6 +KPX O m -6 +KPX O l -15 +KPX O k -10 +KPX O j -6 +KPX O h -10 +KPX O g -6 +KPX O e 6 +KPX O d 6 +KPX O comma -10 +KPX O a 6 +KPX O Y -70 +KPX O X -30 +KPX O W -35 +KPX O V -50 +KPX O T -42 +KPX O A -8 + +KPX P y 6 +KPX P u -18 +KPX P t -6 +KPX P s -24 +KPX P r -6 +KPX P quoteright -12 +KPX P period -170 +KPX P o -24 +KPX P n -12 +KPX P l -20 +KPX P h -20 +KPX P e -24 +KPX P comma -170 +KPX P a -40 +KPX P I -45 +KPX P H -45 +KPX P E -45 +KPX P A -70 + +KPX Q u -6 +KPX Q quoteright -20 +KPX Q quotedblright -38 +KPX Q a -6 +KPX Q Y -70 +KPX Q X -12 +KPX Q W -35 +KPX Q V -50 +KPX Q U -30 +KPX Q T -36 +KPX Q A -18 + +KPX R y -6 +KPX R u -12 +KPX R quoteright -22 +KPX R quotedblright -22 +KPX R o -20 +KPX R e -12 +KPX R Y -45 +KPX R X 15 +KPX R W -25 +KPX R V -35 +KPX R U -40 +KPX R T -18 +KPX R Q -8 +KPX R O -8 +KPX R G -8 +KPX R C -8 +KPX R A 15 + +KPX S y -30 +KPX S w -30 +KPX S v -20 +KPX S u -18 +KPX S t -18 +KPX S r -20 +KPX S quoteright -38 +KPX S quotedblright -50 +KPX S p -18 +KPX S n -24 +KPX S m -24 +KPX S l -20 +KPX S k -18 +KPX S j -25 +KPX S i -20 +KPX S h -12 +KPX S e -6 + +KPX T z -48 +KPX T y -52 +KPX T w -54 +KPX T u -54 +KPX T semicolon -6 +KPX T s -60 +KPX T r -54 +KPX T quoteright 36 +KPX T quotedblright 36 +KPX T period -70 +KPX T parenright 25 +KPX T o -78 +KPX T m -54 +KPX T i -22 +KPX T hyphen -100 +KPX T h 6 +KPX T endash -40 +KPX T emdash -40 +KPX T e -78 +KPX T comma -90 +KPX T bracketright 20 +KPX T braceright 30 +KPX T a -78 +KPX T Y 12 +KPX T X 18 +KPX T W 30 +KPX T V 20 +KPX T T 40 +KPX T Q -6 +KPX T O -6 +KPX T G -6 +KPX T C -6 +KPX T A -40 + +KPX U z -18 +KPX U x -30 +KPX U v -20 +KPX U t -24 +KPX U s -40 +KPX U r -30 +KPX U p -30 +KPX U n -30 +KPX U m -30 +KPX U l -12 +KPX U k -12 +KPX U i -24 +KPX U h -6 +KPX U g -30 +KPX U f -10 +KPX U d -30 +KPX U c -30 +KPX U b -6 +KPX U a -30 +KPX U A -40 + +KPX V y -34 +KPX V u -42 +KPX V semicolon -45 +KPX V r -55 +KPX V quoteright 46 +KPX V quotedblright 60 +KPX V period -110 +KPX V parenright 64 +KPX V o -55 +KPX V i 15 +KPX V hyphen -60 +KPX V endash -20 +KPX V emdash -20 +KPX V e -55 +KPX V comma -110 +KPX V colon -18 +KPX V bracketright 64 +KPX V braceright 64 +KPX V a -80 +KPX V T 12 +KPX V A -70 + +KPX W y -36 +KPX W u -30 +KPX W t -10 +KPX W semicolon -12 +KPX W r -30 +KPX W quoteright 42 +KPX W quotedblright 55 +KPX W period -80 +KPX W parenright 55 +KPX W o -55 +KPX W m -30 +KPX W i 5 +KPX W hyphen -40 +KPX W h 16 +KPX W e -55 +KPX W d -60 +KPX W comma -80 +KPX W colon -12 +KPX W bracketright 64 +KPX W braceright 64 +KPX W a -60 +KPX W T 30 +KPX W Q -5 +KPX W O -5 +KPX W G -5 +KPX W C -5 +KPX W A -45 + +KPX X y -40 +KPX X u -30 +KPX X r -6 +KPX X quoteright 24 +KPX X quotedblright 40 +KPX X i -6 +KPX X e -18 +KPX X a -6 +KPX X Y -6 +KPX X W -6 +KPX X Q -45 +KPX X O -45 +KPX X G -45 +KPX X C -45 + +KPX Y v -60 +KPX Y u -70 +KPX Y t -32 +KPX Y semicolon -20 +KPX Y quoteright 56 +KPX Y quotedblright 70 +KPX Y q -100 +KPX Y period -80 +KPX Y parenright 5 +KPX Y o -95 +KPX Y l 15 +KPX Y i 15 +KPX Y hyphen -110 +KPX Y endash -40 +KPX Y emdash -40 +KPX Y e -95 +KPX Y d -85 +KPX Y comma -80 +KPX Y colon -20 +KPX Y bracketright 64 +KPX Y braceright 64 +KPX Y a -85 +KPX Y Y 12 +KPX Y X 12 +KPX Y W 12 +KPX Y V 6 +KPX Y T 30 +KPX Y Q -25 +KPX Y O -25 +KPX Y G -25 +KPX Y C -25 +KPX Y A -40 + +KPX Z y -36 +KPX Z w -36 +KPX Z u -12 +KPX Z quoteright 18 +KPX Z quotedblright 18 +KPX Z o -6 +KPX Z i -12 +KPX Z e -6 +KPX Z a -6 +KPX Z Q -20 +KPX Z O -20 +KPX Z G -20 +KPX Z C -20 +KPX Z A 30 + +KPX a quoteright -54 +KPX a quotedblright -54 + +KPX b y -6 +KPX b w -5 +KPX b v -5 +KPX b quoteright -30 +KPX b quotedblright -30 +KPX b period -15 +KPX b comma -15 + +KPX braceleft Y 64 +KPX braceleft W 64 +KPX braceleft V 64 +KPX braceleft T 40 +KPX braceleft J 60 + +KPX bracketleft Y 60 +KPX bracketleft W 64 +KPX bracketleft V 64 +KPX bracketleft T 35 +KPX bracketleft J 30 + +KPX c quoteright 5 +KPX c quotedblright 5 + +KPX colon space -30 + +KPX comma space -40 +KPX comma quoteright -100 +KPX comma quotedblright -100 + +KPX d quoteright -12 +KPX d quotedblright -12 +KPX d period 15 +KPX d comma 15 + +KPX e y 6 +KPX e x -10 +KPX e w -10 +KPX e v -10 +KPX e quoteright -25 +KPX e quotedblright -25 + +KPX f quoteright 120 +KPX f quotedblright 120 +KPX f period -30 +KPX f parenright 100 +KPX f comma -30 +KPX f bracketright 110 +KPX f braceright 110 + +KPX g y 50 +KPX g quotedblright -20 +KPX g p 30 +KPX g f 42 +KPX g comma 20 + +KPX h quoteright -78 +KPX h quotedblright -78 + +KPX i quoteright -20 +KPX i quotedblright -20 + +KPX j quoteright -20 +KPX j quotedblright -20 +KPX j period -20 +KPX j comma -20 + +KPX k quoteright -38 +KPX k quotedblright -38 + +KPX l quoteright -12 +KPX l quotedblright -12 + +KPX m quoteright -78 +KPX m quotedblright -78 + +KPX n quoteright -88 +KPX n quotedblright -88 + +KPX o y -12 +KPX o x -20 +KPX o w -25 +KPX o v -25 +KPX o quoteright -50 +KPX o quotedblright -50 +KPX o period -10 +KPX o comma -10 + +KPX p w -6 +KPX p quoteright -30 +KPX p quotedblright -52 +KPX p period -15 +KPX p comma -15 + +KPX parenleft Y 64 +KPX parenleft W 64 +KPX parenleft V 64 +KPX parenleft T 30 +KPX parenleft J 50 + +KPX period space -40 +KPX period quoteright -100 +KPX period quotedblright -100 + +KPX q quoteright -40 +KPX q quotedblright -40 +KPX q period -10 +KPX q comma -5 + +KPX quotedblleft z -30 +KPX quotedblleft x -60 +KPX quotedblleft w -12 +KPX quotedblleft v -12 +KPX quotedblleft u -12 +KPX quotedblleft t 5 +KPX quotedblleft s -30 +KPX quotedblleft r -12 +KPX quotedblleft q -50 +KPX quotedblleft p -12 +KPX quotedblleft o -30 +KPX quotedblleft n -12 +KPX quotedblleft m -12 +KPX quotedblleft l 10 +KPX quotedblleft k 10 +KPX quotedblleft h 10 +KPX quotedblleft g -30 +KPX quotedblleft e -30 +KPX quotedblleft d -50 +KPX quotedblleft c -30 +KPX quotedblleft b 24 +KPX quotedblleft a -50 +KPX quotedblleft Y 30 +KPX quotedblleft X 45 +KPX quotedblleft W 55 +KPX quotedblleft V 40 +KPX quotedblleft T 36 +KPX quotedblleft A -100 + +KPX quotedblright space -50 +KPX quotedblright period -200 +KPX quotedblright comma -200 + +KPX quoteleft z -30 +KPX quoteleft y 30 +KPX quoteleft x -10 +KPX quoteleft w -12 +KPX quoteleft u -12 +KPX quoteleft t -30 +KPX quoteleft s -30 +KPX quoteleft r -12 +KPX quoteleft q -30 +KPX quoteleft p -12 +KPX quoteleft o -30 +KPX quoteleft n -12 +KPX quoteleft m -12 +KPX quoteleft l 10 +KPX quoteleft k 10 +KPX quoteleft h 10 +KPX quoteleft g -30 +KPX quoteleft e -30 +KPX quoteleft d -30 +KPX quoteleft c -30 +KPX quoteleft b 24 +KPX quoteleft a -30 +KPX quoteleft Y 12 +KPX quoteleft X 46 +KPX quoteleft W 46 +KPX quoteleft V 28 +KPX quoteleft T 36 +KPX quoteleft A -100 + +KPX quoteright v -20 +KPX quoteright space -50 +KPX quoteright s -45 +KPX quoteright r -12 +KPX quoteright period -140 +KPX quoteright m -12 +KPX quoteright l -12 +KPX quoteright d -65 +KPX quoteright comma -140 + +KPX r z 20 +KPX r y 18 +KPX r x 12 +KPX r w 6 +KPX r v 6 +KPX r t 8 +KPX r semicolon 20 +KPX r quoteright -6 +KPX r quotedblright -6 +KPX r q -24 +KPX r period -100 +KPX r o -6 +KPX r l -12 +KPX r k -12 +KPX r hyphen -40 +KPX r h -10 +KPX r f 8 +KPX r endash -20 +KPX r e -26 +KPX r d -25 +KPX r comma -100 +KPX r colon 20 +KPX r c -12 +KPX r a -25 + +KPX s quoteright -25 +KPX s quotedblright -30 + +KPX semicolon space -30 + +KPX space quotesinglbase -60 +KPX space quoteleft -60 +KPX space quotedblleft -60 +KPX space quotedblbase -60 +KPX space Y -70 +KPX space W -50 +KPX space V -70 +KPX space T -50 +KPX space A -50 + +KPX t quoteright 15 +KPX t quotedblright 15 +KPX t period 15 +KPX t comma 15 + +KPX u quoteright -65 +KPX u quotedblright -78 +KPX u period 20 +KPX u comma 20 + +KPX v quoteright -10 +KPX v quotedblright -10 +KPX v q -6 +KPX v period -62 +KPX v o -6 +KPX v e -6 +KPX v d -6 +KPX v comma -62 +KPX v c -6 +KPX v a -6 + +KPX w quoteright -10 +KPX w quotedblright -10 +KPX w period -40 +KPX w comma -50 + +KPX x y 12 +KPX x w -6 +KPX x quoteright -30 +KPX x quotedblright -30 +KPX x q -6 +KPX x o -6 +KPX x e -6 +KPX x d -6 +KPX x c -6 + +KPX y quoteright -10 +KPX y quotedblright -10 +KPX y q -10 +KPX y period -56 +KPX y d -10 +KPX y comma -56 + +KPX z quoteright -40 +KPX z quotedblright -40 +KPX z o -6 +KPX z e -6 +KPX z d -6 +KPX z c -6 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putr8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putr8a.afm new file mode 100644 index 00000000..be1bb781 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putr8a.afm @@ -0,0 +1,1029 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Fri Jan 17 13:38:17 1992 +Comment UniqueID 37674 +Comment VMusage 32991 39883 +FontName Utopia-Regular +FullName Utopia Regular +FamilyName Utopia +Weight Regular +ItalicAngle 0 +IsFixedPitch false +FontBBox -158 -250 1158 890 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.002 +Notice Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved.Utopia is a registered trademark of Adobe Systems Incorporated. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 490 +Ascender 742 +Descender -230 +StartCharMetrics 228 +C 32 ; WX 225 ; N space ; B 0 0 0 0 ; +C 33 ; WX 242 ; N exclam ; B 58 -12 184 707 ; +C 34 ; WX 458 ; N quotedbl ; B 101 464 358 742 ; +C 35 ; WX 530 ; N numbersign ; B 11 0 519 668 ; +C 36 ; WX 530 ; N dollar ; B 44 -102 487 743 ; +C 37 ; WX 838 ; N percent ; B 50 -25 788 700 ; +C 38 ; WX 706 ; N ampersand ; B 46 -12 692 680 ; +C 39 ; WX 278 ; N quoteright ; B 72 472 207 742 ; +C 40 ; WX 350 ; N parenleft ; B 105 -128 325 692 ; +C 41 ; WX 350 ; N parenright ; B 25 -128 245 692 ; +C 42 ; WX 412 ; N asterisk ; B 50 356 363 707 ; +C 43 ; WX 570 ; N plus ; B 43 0 527 490 ; +C 44 ; WX 265 ; N comma ; B 51 -141 193 141 ; +C 45 ; WX 392 ; N hyphen ; B 74 216 319 286 ; +C 46 ; WX 265 ; N period ; B 70 -12 196 116 ; +C 47 ; WX 460 ; N slash ; B 92 -15 369 707 ; +C 48 ; WX 530 ; N zero ; B 41 -12 489 680 ; +C 49 ; WX 530 ; N one ; B 109 0 437 680 ; +C 50 ; WX 530 ; N two ; B 27 0 485 680 ; +C 51 ; WX 530 ; N three ; B 27 -12 473 680 ; +C 52 ; WX 530 ; N four ; B 19 0 493 668 ; +C 53 ; WX 530 ; N five ; B 40 -12 480 668 ; +C 54 ; WX 530 ; N six ; B 44 -12 499 680 ; +C 55 ; WX 530 ; N seven ; B 41 -12 497 668 ; +C 56 ; WX 530 ; N eight ; B 42 -12 488 680 ; +C 57 ; WX 530 ; N nine ; B 36 -12 477 680 ; +C 58 ; WX 265 ; N colon ; B 70 -12 196 490 ; +C 59 ; WX 265 ; N semicolon ; B 51 -141 196 490 ; +C 60 ; WX 570 ; N less ; B 46 1 524 499 ; +C 61 ; WX 570 ; N equal ; B 43 111 527 389 ; +C 62 ; WX 570 ; N greater ; B 46 1 524 499 ; +C 63 ; WX 389 ; N question ; B 29 -12 359 707 ; +C 64 ; WX 793 ; N at ; B 46 -15 755 707 ; +C 65 ; WX 635 ; N A ; B -29 0 650 692 ; +C 66 ; WX 646 ; N B ; B 35 0 595 692 ; +C 67 ; WX 684 ; N C ; B 48 -15 649 707 ; +C 68 ; WX 779 ; N D ; B 35 0 731 692 ; +C 69 ; WX 606 ; N E ; B 35 0 577 692 ; +C 70 ; WX 580 ; N F ; B 35 0 543 692 ; +C 71 ; WX 734 ; N G ; B 48 -15 725 707 ; +C 72 ; WX 798 ; N H ; B 35 0 763 692 ; +C 73 ; WX 349 ; N I ; B 35 0 314 692 ; +C 74 ; WX 350 ; N J ; B 0 -114 323 692 ; +C 75 ; WX 658 ; N K ; B 35 -5 671 692 ; +C 76 ; WX 568 ; N L ; B 35 0 566 692 ; +C 77 ; WX 944 ; N M ; B 33 0 909 692 ; +C 78 ; WX 780 ; N N ; B 34 0 753 692 ; +C 79 ; WX 762 ; N O ; B 48 -15 714 707 ; +C 80 ; WX 600 ; N P ; B 35 0 574 692 ; +C 81 ; WX 762 ; N Q ; B 48 -193 714 707 ; +C 82 ; WX 644 ; N R ; B 35 0 638 692 ; +C 83 ; WX 541 ; N S ; B 50 -15 504 707 ; +C 84 ; WX 621 ; N T ; B 22 0 599 692 ; +C 85 ; WX 791 ; N U ; B 29 -15 762 692 ; +C 86 ; WX 634 ; N V ; B -18 0 678 692 ; +C 87 ; WX 940 ; N W ; B -13 0 977 692 ; +C 88 ; WX 624 ; N X ; B -19 0 657 692 ; +C 89 ; WX 588 ; N Y ; B -12 0 632 692 ; +C 90 ; WX 610 ; N Z ; B 9 0 594 692 ; +C 91 ; WX 330 ; N bracketleft ; B 133 -128 292 692 ; +C 92 ; WX 460 ; N backslash ; B 91 -15 369 707 ; +C 93 ; WX 330 ; N bracketright ; B 38 -128 197 692 ; +C 94 ; WX 570 ; N asciicircum ; B 56 228 514 668 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 72 478 207 748 ; +C 97 ; WX 523 ; N a ; B 49 -12 525 502 ; +C 98 ; WX 598 ; N b ; B 20 -12 549 742 ; +C 99 ; WX 496 ; N c ; B 49 -12 473 502 ; +C 100 ; WX 598 ; N d ; B 49 -12 583 742 ; +C 101 ; WX 514 ; N e ; B 49 -12 481 502 ; +C 102 ; WX 319 ; N f ; B 30 0 389 742 ; L i fi ; L l fl ; +C 103 ; WX 520 ; N g ; B 42 -242 525 512 ; +C 104 ; WX 607 ; N h ; B 21 0 592 742 ; +C 105 ; WX 291 ; N i ; B 32 0 276 715 ; +C 106 ; WX 280 ; N j ; B -33 -242 214 715 ; +C 107 ; WX 524 ; N k ; B 20 -5 538 742 ; +C 108 ; WX 279 ; N l ; B 20 0 264 742 ; +C 109 ; WX 923 ; N m ; B 32 0 908 502 ; +C 110 ; WX 619 ; N n ; B 32 0 604 502 ; +C 111 ; WX 577 ; N o ; B 49 -12 528 502 ; +C 112 ; WX 608 ; N p ; B 25 -230 559 502 ; +C 113 ; WX 591 ; N q ; B 49 -230 583 502 ; +C 114 ; WX 389 ; N r ; B 32 0 386 502 ; +C 115 ; WX 436 ; N s ; B 47 -12 400 502 ; +C 116 ; WX 344 ; N t ; B 31 -12 342 616 ; +C 117 ; WX 606 ; N u ; B 26 -12 591 502 ; +C 118 ; WX 504 ; N v ; B 1 0 529 490 ; +C 119 ; WX 768 ; N w ; B -2 0 792 490 ; +C 120 ; WX 486 ; N x ; B 1 0 509 490 ; +C 121 ; WX 506 ; N y ; B -5 -242 528 490 ; +C 122 ; WX 480 ; N z ; B 19 0 462 490 ; +C 123 ; WX 340 ; N braceleft ; B 79 -128 298 692 ; +C 124 ; WX 228 ; N bar ; B 80 -250 148 750 ; +C 125 ; WX 340 ; N braceright ; B 42 -128 261 692 ; +C 126 ; WX 570 ; N asciitilde ; B 73 175 497 317 ; +C 161 ; WX 242 ; N exclamdown ; B 58 -217 184 502 ; +C 162 ; WX 530 ; N cent ; B 37 -10 487 675 ; +C 163 ; WX 530 ; N sterling ; B 27 0 510 680 ; +C 164 ; WX 150 ; N fraction ; B -158 -27 308 695 ; +C 165 ; WX 530 ; N yen ; B -2 0 525 668 ; +C 166 ; WX 530 ; N florin ; B -2 -135 522 691 ; +C 167 ; WX 554 ; N section ; B 46 -115 507 707 ; +C 168 ; WX 530 ; N currency ; B 25 90 505 578 ; +C 169 ; WX 278 ; N quotesingle ; B 93 464 185 742 ; +C 170 ; WX 458 ; N quotedblleft ; B 72 478 387 748 ; +C 171 ; WX 442 ; N guillemotleft ; B 41 41 401 435 ; +C 172 ; WX 257 ; N guilsinglleft ; B 41 41 216 435 ; +C 173 ; WX 257 ; N guilsinglright ; B 41 41 216 435 ; +C 174 ; WX 610 ; N fi ; B 30 0 595 742 ; +C 175 ; WX 610 ; N fl ; B 30 0 595 742 ; +C 177 ; WX 500 ; N endash ; B 0 221 500 279 ; +C 178 ; WX 504 ; N dagger ; B 45 -125 459 717 ; +C 179 ; WX 488 ; N daggerdbl ; B 45 -119 443 717 ; +C 180 ; WX 265 ; N periodcentered ; B 70 188 196 316 ; +C 182 ; WX 555 ; N paragraph ; B 64 -101 529 692 ; +C 183 ; WX 409 ; N bullet ; B 45 192 364 512 ; +C 184 ; WX 278 ; N quotesinglbase ; B 72 -125 207 145 ; +C 185 ; WX 458 ; N quotedblbase ; B 72 -125 387 145 ; +C 186 ; WX 458 ; N quotedblright ; B 72 472 387 742 ; +C 187 ; WX 442 ; N guillemotright ; B 41 41 401 435 ; +C 188 ; WX 1000 ; N ellipsis ; B 104 -12 896 116 ; +C 189 ; WX 1208 ; N perthousand ; B 50 -25 1158 700 ; +C 191 ; WX 389 ; N questiondown ; B 30 -217 360 502 ; +C 193 ; WX 400 ; N grave ; B 49 542 271 723 ; +C 194 ; WX 400 ; N acute ; B 129 542 351 723 ; +C 195 ; WX 400 ; N circumflex ; B 47 541 353 720 ; +C 196 ; WX 400 ; N tilde ; B 22 563 377 682 ; +C 197 ; WX 400 ; N macron ; B 56 597 344 656 ; +C 198 ; WX 400 ; N breve ; B 63 568 337 704 ; +C 199 ; WX 400 ; N dotaccent ; B 140 570 260 683 ; +C 200 ; WX 400 ; N dieresis ; B 36 570 364 683 ; +C 202 ; WX 400 ; N ring ; B 92 550 308 752 ; +C 203 ; WX 400 ; N cedilla ; B 163 -230 329 0 ; +C 205 ; WX 400 ; N hungarumlaut ; B 101 546 380 750 ; +C 206 ; WX 400 ; N ogonek ; B 103 -230 295 0 ; +C 207 ; WX 400 ; N caron ; B 47 541 353 720 ; +C 208 ; WX 1000 ; N emdash ; B 0 221 1000 279 ; +C 225 ; WX 876 ; N AE ; B -63 0 847 692 ; +C 227 ; WX 390 ; N ordfeminine ; B 40 265 364 590 ; +C 232 ; WX 574 ; N Lslash ; B 36 0 572 692 ; +C 233 ; WX 762 ; N Oslash ; B 48 -53 714 739 ; +C 234 ; WX 1025 ; N OE ; B 48 0 996 692 ; +C 235 ; WX 398 ; N ordmasculine ; B 35 265 363 590 ; +C 241 ; WX 797 ; N ae ; B 49 -12 764 502 ; +C 245 ; WX 291 ; N dotlessi ; B 32 0 276 502 ; +C 248 ; WX 294 ; N lslash ; B 14 0 293 742 ; +C 249 ; WX 577 ; N oslash ; B 49 -41 528 532 ; +C 250 ; WX 882 ; N oe ; B 49 -12 849 502 ; +C 251 ; WX 601 ; N germandbls ; B 22 -12 573 742 ; +C -1 ; WX 380 ; N onesuperior ; B 81 272 307 680 ; +C -1 ; WX 570 ; N minus ; B 43 221 527 279 ; +C -1 ; WX 350 ; N degree ; B 37 404 313 680 ; +C -1 ; WX 577 ; N oacute ; B 49 -12 528 723 ; +C -1 ; WX 762 ; N Odieresis ; B 48 -15 714 841 ; +C -1 ; WX 577 ; N odieresis ; B 49 -12 528 683 ; +C -1 ; WX 606 ; N Eacute ; B 35 0 577 890 ; +C -1 ; WX 606 ; N ucircumflex ; B 26 -12 591 720 ; +C -1 ; WX 860 ; N onequarter ; B 65 -27 795 695 ; +C -1 ; WX 570 ; N logicalnot ; B 43 102 527 389 ; +C -1 ; WX 606 ; N Ecircumflex ; B 35 0 577 876 ; +C -1 ; WX 860 ; N onehalf ; B 58 -27 807 695 ; +C -1 ; WX 762 ; N Otilde ; B 48 -15 714 842 ; +C -1 ; WX 606 ; N uacute ; B 26 -12 591 723 ; +C -1 ; WX 514 ; N eacute ; B 49 -12 481 723 ; +C -1 ; WX 291 ; N iacute ; B 32 0 317 723 ; +C -1 ; WX 606 ; N Egrave ; B 35 0 577 890 ; +C -1 ; WX 291 ; N icircumflex ; B -3 0 304 720 ; +C -1 ; WX 606 ; N mu ; B 26 -246 591 502 ; +C -1 ; WX 228 ; N brokenbar ; B 80 -175 148 675 ; +C -1 ; WX 606 ; N thorn ; B 23 -230 557 722 ; +C -1 ; WX 627 ; N Aring ; B -32 0 647 861 ; +C -1 ; WX 506 ; N yacute ; B -5 -242 528 723 ; +C -1 ; WX 588 ; N Ydieresis ; B -12 0 632 841 ; +C -1 ; WX 1100 ; N trademark ; B 45 277 1048 692 ; +C -1 ; WX 818 ; N registered ; B 45 -15 773 707 ; +C -1 ; WX 577 ; N ocircumflex ; B 49 -12 528 720 ; +C -1 ; WX 635 ; N Agrave ; B -29 0 650 890 ; +C -1 ; WX 541 ; N Scaron ; B 50 -15 504 882 ; +C -1 ; WX 791 ; N Ugrave ; B 29 -15 762 890 ; +C -1 ; WX 606 ; N Edieresis ; B 35 0 577 841 ; +C -1 ; WX 791 ; N Uacute ; B 29 -15 762 890 ; +C -1 ; WX 577 ; N otilde ; B 49 -12 528 682 ; +C -1 ; WX 619 ; N ntilde ; B 32 0 604 682 ; +C -1 ; WX 506 ; N ydieresis ; B -5 -242 528 683 ; +C -1 ; WX 635 ; N Aacute ; B -29 0 650 890 ; +C -1 ; WX 577 ; N eth ; B 49 -12 528 742 ; +C -1 ; WX 523 ; N acircumflex ; B 49 -12 525 720 ; +C -1 ; WX 523 ; N aring ; B 49 -12 525 752 ; +C -1 ; WX 762 ; N Ograve ; B 48 -15 714 890 ; +C -1 ; WX 496 ; N ccedilla ; B 49 -230 473 502 ; +C -1 ; WX 570 ; N multiply ; B 63 22 507 478 ; +C -1 ; WX 570 ; N divide ; B 43 26 527 474 ; +C -1 ; WX 380 ; N twosuperior ; B 32 272 348 680 ; +C -1 ; WX 780 ; N Ntilde ; B 34 0 753 842 ; +C -1 ; WX 606 ; N ugrave ; B 26 -12 591 723 ; +C -1 ; WX 791 ; N Ucircumflex ; B 29 -15 762 876 ; +C -1 ; WX 635 ; N Atilde ; B -29 0 650 842 ; +C -1 ; WX 480 ; N zcaron ; B 19 0 462 720 ; +C -1 ; WX 291 ; N idieresis ; B -19 0 310 683 ; +C -1 ; WX 635 ; N Acircumflex ; B -29 0 650 876 ; +C -1 ; WX 349 ; N Icircumflex ; B 22 0 328 876 ; +C -1 ; WX 588 ; N Yacute ; B -12 0 632 890 ; +C -1 ; WX 762 ; N Oacute ; B 48 -15 714 890 ; +C -1 ; WX 635 ; N Adieresis ; B -29 0 650 841 ; +C -1 ; WX 610 ; N Zcaron ; B 9 0 594 882 ; +C -1 ; WX 523 ; N agrave ; B 49 -12 525 723 ; +C -1 ; WX 380 ; N threesuperior ; B 36 265 339 680 ; +C -1 ; WX 577 ; N ograve ; B 49 -12 528 723 ; +C -1 ; WX 860 ; N threequarters ; B 50 -27 808 695 ; +C -1 ; WX 785 ; N Eth ; B 20 0 737 692 ; +C -1 ; WX 570 ; N plusminus ; B 43 0 527 556 ; +C -1 ; WX 606 ; N udieresis ; B 26 -12 591 683 ; +C -1 ; WX 514 ; N edieresis ; B 49 -12 481 683 ; +C -1 ; WX 523 ; N aacute ; B 49 -12 525 723 ; +C -1 ; WX 291 ; N igrave ; B -35 0 276 723 ; +C -1 ; WX 349 ; N Idieresis ; B 13 0 337 841 ; +C -1 ; WX 523 ; N adieresis ; B 49 -12 525 683 ; +C -1 ; WX 349 ; N Iacute ; B 35 0 371 890 ; +C -1 ; WX 818 ; N copyright ; B 45 -15 773 707 ; +C -1 ; WX 349 ; N Igrave ; B -17 0 314 890 ; +C -1 ; WX 680 ; N Ccedilla ; B 48 -230 649 707 ; +C -1 ; WX 436 ; N scaron ; B 47 -12 400 720 ; +C -1 ; WX 514 ; N egrave ; B 49 -12 481 723 ; +C -1 ; WX 762 ; N Ocircumflex ; B 48 -15 714 876 ; +C -1 ; WX 593 ; N Thorn ; B 35 0 556 692 ; +C -1 ; WX 523 ; N atilde ; B 49 -12 525 682 ; +C -1 ; WX 791 ; N Udieresis ; B 29 -15 762 841 ; +C -1 ; WX 514 ; N ecircumflex ; B 49 -12 481 720 ; +EndCharMetrics +StartKernData +StartKernPairs 712 + +KPX A z 6 +KPX A y -50 +KPX A w -45 +KPX A v -60 +KPX A u -25 +KPX A t -12 +KPX A quoteright -120 +KPX A quotedblright -120 +KPX A q -6 +KPX A p -18 +KPX A o -12 +KPX A e -6 +KPX A d -12 +KPX A c -12 +KPX A b -12 +KPX A Y -70 +KPX A X -6 +KPX A W -58 +KPX A V -72 +KPX A U -50 +KPX A T -70 +KPX A Q -24 +KPX A O -24 +KPX A G -24 +KPX A C -24 + +KPX B y -18 +KPX B u -12 +KPX B r -12 +KPX B period -30 +KPX B o -6 +KPX B l -12 +KPX B i -12 +KPX B h -12 +KPX B e -6 +KPX B comma -20 +KPX B a -12 +KPX B W -25 +KPX B V -20 +KPX B U -20 +KPX B T -20 + +KPX C z -18 +KPX C y -24 +KPX C u -18 +KPX C r -6 +KPX C o -12 +KPX C e -12 +KPX C a -12 +KPX C Q -6 +KPX C O -6 +KPX C G -6 +KPX C C -6 + +KPX D y 6 +KPX D u -12 +KPX D r -12 +KPX D quoteright -20 +KPX D quotedblright -20 +KPX D period -60 +KPX D i -6 +KPX D h -12 +KPX D e -6 +KPX D comma -50 +KPX D a -6 +KPX D Y -45 +KPX D W -35 +KPX D V -35 + +KPX E z -6 +KPX E y -30 +KPX E x -6 +KPX E w -24 +KPX E v -24 +KPX E u -12 +KPX E t -18 +KPX E r -4 +KPX E q -6 +KPX E p -18 +KPX E o -6 +KPX E n -4 +KPX E m -4 +KPX E l 5 +KPX E k 5 +KPX E j -6 +KPX E i -6 +KPX E g -6 +KPX E f -12 +KPX E e -6 +KPX E d -6 +KPX E c -6 +KPX E b -12 +KPX E Y -6 +KPX E W -6 +KPX E V -6 + +KPX F y -18 +KPX F u -12 +KPX F r -20 +KPX F period -180 +KPX F o -36 +KPX F l -12 +KPX F i -10 +KPX F endash 20 +KPX F e -36 +KPX F comma -180 +KPX F a -48 +KPX F A -60 + +KPX G y -18 +KPX G u -12 +KPX G r -5 +KPX G o 5 +KPX G n -5 +KPX G l -6 +KPX G i -12 +KPX G h -12 +KPX G e 5 +KPX G a -12 + +KPX H y -24 +KPX H u -26 +KPX H o -30 +KPX H i -18 +KPX H e -30 +KPX H a -24 + +KPX I z -6 +KPX I y -6 +KPX I x -6 +KPX I w -18 +KPX I v -24 +KPX I u -26 +KPX I t -24 +KPX I s -18 +KPX I r -12 +KPX I p -26 +KPX I o -30 +KPX I n -18 +KPX I m -18 +KPX I l -6 +KPX I k -6 +KPX I h -6 +KPX I g -10 +KPX I f -6 +KPX I e -30 +KPX I d -30 +KPX I c -30 +KPX I b -6 +KPX I a -24 + +KPX J y -12 +KPX J u -36 +KPX J o -30 +KPX J i -20 +KPX J e -30 +KPX J bracketright 20 +KPX J braceright 20 +KPX J a -36 + +KPX K y -60 +KPX K w -70 +KPX K v -70 +KPX K u -42 +KPX K o -30 +KPX K i 6 +KPX K e -24 +KPX K a -12 +KPX K Q -42 +KPX K O -42 +KPX K G -42 +KPX K C -42 + +KPX L y -52 +KPX L w -58 +KPX L u -12 +KPX L quoteright -130 +KPX L quotedblright -50 +KPX L l 6 +KPX L j -6 +KPX L Y -70 +KPX L W -90 +KPX L V -100 +KPX L U -24 +KPX L T -100 +KPX L Q -18 +KPX L O -10 +KPX L G -18 +KPX L C -18 +KPX L A 12 + +KPX M y -24 +KPX M u -36 +KPX M o -30 +KPX M n -6 +KPX M j -12 +KPX M i -12 +KPX M e -30 +KPX M d -30 +KPX M c -30 +KPX M a -12 + +KPX N y -24 +KPX N u -30 +KPX N o -30 +KPX N i -24 +KPX N e -30 +KPX N a -30 + +KPX O z -6 +KPX O u -6 +KPX O t -6 +KPX O s -6 +KPX O q -6 +KPX O period -60 +KPX O p -6 +KPX O o -6 +KPX O n -5 +KPX O m -5 +KPX O l -6 +KPX O k -6 +KPX O i -5 +KPX O h -12 +KPX O g -6 +KPX O e -6 +KPX O d -6 +KPX O comma -50 +KPX O c -6 +KPX O a -12 +KPX O Y -55 +KPX O X -24 +KPX O W -30 +KPX O V -18 +KPX O T -30 +KPX O A -18 + +KPX P u -12 +KPX P t -6 +KPX P s -24 +KPX P r -12 +KPX P period -200 +KPX P o -30 +KPX P n -12 +KPX P l -6 +KPX P hyphen -40 +KPX P h -6 +KPX P e -30 +KPX P comma -200 +KPX P a -36 +KPX P I -6 +KPX P H -12 +KPX P E -6 +KPX P A -55 + +KPX Q u -6 +KPX Q a -18 +KPX Q Y -30 +KPX Q X -24 +KPX Q W -24 +KPX Q V -18 +KPX Q U -30 +KPX Q T -24 +KPX Q A -18 + +KPX R y -20 +KPX R u -12 +KPX R quoteright -20 +KPX R quotedblright -20 +KPX R o -20 +KPX R hyphen -30 +KPX R e -20 +KPX R d -20 +KPX R a -12 +KPX R Y -45 +KPX R W -24 +KPX R V -32 +KPX R U -30 +KPX R T -32 +KPX R Q -24 +KPX R O -24 +KPX R G -24 +KPX R C -24 + +KPX S y -25 +KPX S w -30 +KPX S v -30 +KPX S u -24 +KPX S t -24 +KPX S r -20 +KPX S quoteright -10 +KPX S quotedblright -10 +KPX S q -5 +KPX S p -24 +KPX S o -12 +KPX S n -20 +KPX S m -20 +KPX S l -18 +KPX S k -24 +KPX S j -12 +KPX S i -20 +KPX S h -12 +KPX S e -12 +KPX S a -18 + +KPX T z -64 +KPX T y -84 +KPX T w -100 +KPX T u -82 +KPX T semicolon -56 +KPX T s -82 +KPX T r -82 +KPX T quoteright 24 +KPX T period -110 +KPX T parenright 54 +KPX T o -100 +KPX T m -82 +KPX T i -34 +KPX T hyphen -100 +KPX T endash -50 +KPX T emdash -50 +KPX T e -100 +KPX T comma -110 +KPX T colon -50 +KPX T bracketright 54 +KPX T braceright 54 +KPX T a -100 +KPX T Y 12 +KPX T X 18 +KPX T W 6 +KPX T V 6 +KPX T T 12 +KPX T S -12 +KPX T Q -18 +KPX T O -18 +KPX T G -18 +KPX T C -18 +KPX T A -65 + +KPX U z -30 +KPX U y -20 +KPX U x -30 +KPX U v -20 +KPX U t -36 +KPX U s -40 +KPX U r -40 +KPX U p -42 +KPX U n -40 +KPX U m -40 +KPX U l -12 +KPX U k -12 +KPX U i -28 +KPX U h -6 +KPX U g -50 +KPX U f -12 +KPX U d -45 +KPX U c -45 +KPX U b -12 +KPX U a -40 +KPX U A -40 + +KPX V y -36 +KPX V u -40 +KPX V semicolon -45 +KPX V r -70 +KPX V quoteright 36 +KPX V quotedblright 20 +KPX V period -140 +KPX V parenright 85 +KPX V o -70 +KPX V i 6 +KPX V hyphen -60 +KPX V endash -20 +KPX V emdash -20 +KPX V e -70 +KPX V comma -140 +KPX V colon -45 +KPX V bracketright 64 +KPX V braceright 64 +KPX V a -60 +KPX V T 6 +KPX V Q -12 +KPX V O -12 +KPX V G -12 +KPX V C -12 +KPX V A -60 + +KPX W y -50 +KPX W u -46 +KPX W semicolon -40 +KPX W r -45 +KPX W quoteright 36 +KPX W quotedblright 20 +KPX W period -110 +KPX W parenright 85 +KPX W o -65 +KPX W m -45 +KPX W i -10 +KPX W hyphen -40 +KPX W e -65 +KPX W d -65 +KPX W comma -100 +KPX W colon -40 +KPX W bracketright 64 +KPX W braceright 64 +KPX W a -60 +KPX W T 18 +KPX W Q -6 +KPX W O -6 +KPX W G -6 +KPX W C -6 +KPX W A -48 + +KPX X y -18 +KPX X u -24 +KPX X quoteright 15 +KPX X e -6 +KPX X a -6 +KPX X Q -24 +KPX X O -30 +KPX X G -30 +KPX X C -30 +KPX X A 6 + +KPX Y v -50 +KPX Y u -54 +KPX Y t -46 +KPX Y semicolon -37 +KPX Y quoteright 36 +KPX Y quotedblright 20 +KPX Y q -100 +KPX Y period -90 +KPX Y parenright 60 +KPX Y o -90 +KPX Y l 10 +KPX Y hyphen -50 +KPX Y emdash -20 +KPX Y e -90 +KPX Y d -90 +KPX Y comma -90 +KPX Y colon -50 +KPX Y bracketright 64 +KPX Y braceright 64 +KPX Y a -68 +KPX Y Y 12 +KPX Y X 12 +KPX Y W 12 +KPX Y V 12 +KPX Y T 12 +KPX Y Q -18 +KPX Y O -18 +KPX Y G -18 +KPX Y C -18 +KPX Y A -32 + +KPX Z y -36 +KPX Z w -36 +KPX Z u -6 +KPX Z o -12 +KPX Z i -12 +KPX Z e -6 +KPX Z a -6 +KPX Z Q -20 +KPX Z O -20 +KPX Z G -30 +KPX Z C -20 +KPX Z A 20 + +KPX a quoteright -70 +KPX a quotedblright -80 + +KPX b y -25 +KPX b w -30 +KPX b v -35 +KPX b quoteright -70 +KPX b quotedblright -70 +KPX b period -40 +KPX b comma -40 + +KPX braceleft Y 64 +KPX braceleft W 64 +KPX braceleft V 64 +KPX braceleft T 54 +KPX braceleft J 80 + +KPX bracketleft Y 64 +KPX bracketleft W 64 +KPX bracketleft V 64 +KPX bracketleft T 54 +KPX bracketleft J 80 + +KPX c quoteright -28 +KPX c quotedblright -28 +KPX c period -10 + +KPX comma quoteright -50 +KPX comma quotedblright -50 + +KPX d quoteright -24 +KPX d quotedblright -24 + +KPX e z -4 +KPX e quoteright -60 +KPX e quotedblright -60 +KPX e period -20 +KPX e comma -20 + +KPX f quotesingle 30 +KPX f quoteright 65 +KPX f quotedblright 56 +KPX f quotedbl 30 +KPX f parenright 100 +KPX f bracketright 100 +KPX f braceright 100 + +KPX g quoteright -18 +KPX g quotedblright -10 + +KPX h quoteright -80 +KPX h quotedblright -80 + +KPX j quoteright -20 +KPX j quotedblright -20 +KPX j period -30 +KPX j comma -30 + +KPX k quoteright -40 +KPX k quotedblright -40 + +KPX l quoteright -10 +KPX l quotedblright -10 + +KPX m quoteright -80 +KPX m quotedblright -80 + +KPX n quoteright -80 +KPX n quotedblright -80 + +KPX o z -12 +KPX o y -30 +KPX o x -18 +KPX o w -30 +KPX o v -30 +KPX o quoteright -70 +KPX o quotedblright -70 +KPX o period -40 +KPX o comma -40 + +KPX p z -20 +KPX p y -25 +KPX p w -30 +KPX p quoteright -70 +KPX p quotedblright -70 +KPX p period -40 +KPX p comma -40 + +KPX parenleft Y 64 +KPX parenleft W 64 +KPX parenleft V 64 +KPX parenleft T 64 +KPX parenleft J 80 + +KPX period quoteright -50 +KPX period quotedblright -50 + +KPX q quoteright -50 +KPX q quotedblright -50 +KPX q period -20 +KPX q comma -10 + +KPX quotedblleft z -60 +KPX quotedblleft y -30 +KPX quotedblleft x -40 +KPX quotedblleft w -20 +KPX quotedblleft v -20 +KPX quotedblleft u -40 +KPX quotedblleft t -40 +KPX quotedblleft s -50 +KPX quotedblleft r -50 +KPX quotedblleft q -80 +KPX quotedblleft p -50 +KPX quotedblleft o -80 +KPX quotedblleft n -50 +KPX quotedblleft m -50 +KPX quotedblleft g -70 +KPX quotedblleft f -50 +KPX quotedblleft e -80 +KPX quotedblleft d -80 +KPX quotedblleft c -80 +KPX quotedblleft a -70 +KPX quotedblleft Z -20 +KPX quotedblleft Y 12 +KPX quotedblleft W 18 +KPX quotedblleft V 18 +KPX quotedblleft U -20 +KPX quotedblleft T 10 +KPX quotedblleft S -20 +KPX quotedblleft R -20 +KPX quotedblleft Q -20 +KPX quotedblleft P -20 +KPX quotedblleft O -30 +KPX quotedblleft N -20 +KPX quotedblleft M -20 +KPX quotedblleft L -20 +KPX quotedblleft K -20 +KPX quotedblleft J -40 +KPX quotedblleft I -20 +KPX quotedblleft H -20 +KPX quotedblleft G -30 +KPX quotedblleft F -20 +KPX quotedblleft E -20 +KPX quotedblleft D -20 +KPX quotedblleft C -30 +KPX quotedblleft B -20 +KPX quotedblleft A -130 + +KPX quotedblright period -130 +KPX quotedblright comma -130 + +KPX quoteleft z -40 +KPX quoteleft y -35 +KPX quoteleft x -30 +KPX quoteleft w -20 +KPX quoteleft v -20 +KPX quoteleft u -50 +KPX quoteleft t -40 +KPX quoteleft s -45 +KPX quoteleft r -50 +KPX quoteleft quoteleft -72 +KPX quoteleft q -70 +KPX quoteleft p -50 +KPX quoteleft o -70 +KPX quoteleft n -50 +KPX quoteleft m -50 +KPX quoteleft g -65 +KPX quoteleft f -40 +KPX quoteleft e -70 +KPX quoteleft d -70 +KPX quoteleft c -70 +KPX quoteleft a -60 +KPX quoteleft Z -20 +KPX quoteleft Y 18 +KPX quoteleft X 12 +KPX quoteleft W 18 +KPX quoteleft V 18 +KPX quoteleft U -20 +KPX quoteleft T 10 +KPX quoteleft R -20 +KPX quoteleft Q -20 +KPX quoteleft P -20 +KPX quoteleft O -30 +KPX quoteleft N -20 +KPX quoteleft M -20 +KPX quoteleft L -20 +KPX quoteleft K -20 +KPX quoteleft J -40 +KPX quoteleft I -20 +KPX quoteleft H -20 +KPX quoteleft G -40 +KPX quoteleft F -20 +KPX quoteleft E -20 +KPX quoteleft D -20 +KPX quoteleft C -30 +KPX quoteleft B -20 +KPX quoteleft A -130 + +KPX quoteright v -40 +KPX quoteright t -75 +KPX quoteright s -110 +KPX quoteright r -70 +KPX quoteright quoteright -72 +KPX quoteright period -130 +KPX quoteright m -70 +KPX quoteright l -6 +KPX quoteright d -120 +KPX quoteright comma -130 + +KPX r z 10 +KPX r y 18 +KPX r x 12 +KPX r w 18 +KPX r v 18 +KPX r u 8 +KPX r t 8 +KPX r semicolon 10 +KPX r quoteright -20 +KPX r quotedblright -20 +KPX r q -6 +KPX r period -60 +KPX r o -6 +KPX r n 8 +KPX r m 8 +KPX r k -6 +KPX r i 8 +KPX r hyphen -20 +KPX r h 6 +KPX r g -6 +KPX r f 8 +KPX r e -20 +KPX r d -20 +KPX r comma -60 +KPX r colon 10 +KPX r c -20 +KPX r a -10 + +KPX s quoteright -40 +KPX s quotedblright -40 +KPX s period -20 +KPX s comma -10 + +KPX space quotesinglbase -60 +KPX space quoteleft -40 +KPX space quotedblleft -40 +KPX space quotedblbase -60 +KPX space Y -60 +KPX space W -60 +KPX space V -60 +KPX space T -36 + +KPX t quoteright -18 +KPX t quotedblright -18 + +KPX u quoteright -30 +KPX u quotedblright -30 + +KPX v semicolon 10 +KPX v quoteright 20 +KPX v quotedblright 20 +KPX v q -10 +KPX v period -90 +KPX v o -5 +KPX v e -5 +KPX v d -10 +KPX v comma -90 +KPX v colon 10 +KPX v c -6 +KPX v a -6 + +KPX w semicolon 10 +KPX w quoteright 20 +KPX w quotedblright 20 +KPX w q -6 +KPX w period -80 +KPX w e -6 +KPX w d -6 +KPX w comma -75 +KPX w colon 10 +KPX w c -6 + +KPX x quoteright -10 +KPX x quotedblright -20 +KPX x q -6 +KPX x o -6 +KPX x d -12 +KPX x c -12 + +KPX y semicolon 10 +KPX y q -6 +KPX y period -95 +KPX y o -6 +KPX y hyphen -30 +KPX y e -6 +KPX y d -6 +KPX y comma -85 +KPX y colon 10 +KPX y c -6 + +KPX z quoteright -20 +KPX z quotedblright -30 +KPX z o -6 +KPX z e -6 +KPX z d -6 +KPX z c -6 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putri8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putri8a.afm new file mode 100644 index 00000000..b3dd45b5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/putri8a.afm @@ -0,0 +1,1008 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Fri Jan 17 13:15:45 1992 +Comment UniqueID 37666 +Comment VMusage 34143 41035 +FontName Utopia-Italic +FullName Utopia Italic +FamilyName Utopia +Weight Regular +ItalicAngle -13 +IsFixedPitch false +FontBBox -201 -250 1170 890 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.002 +Notice Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights Reserved.Utopia is a registered trademark of Adobe Systems Incorporated. +EncodingScheme AdobeStandardEncoding +CapHeight 692 +XHeight 502 +Ascender 742 +Descender -242 +StartCharMetrics 228 +C 32 ; WX 225 ; N space ; B 0 0 0 0 ; +C 33 ; WX 240 ; N exclam ; B 34 -12 290 707 ; +C 34 ; WX 402 ; N quotedbl ; B 171 469 454 742 ; +C 35 ; WX 530 ; N numbersign ; B 54 0 585 668 ; +C 36 ; WX 530 ; N dollar ; B 31 -109 551 743 ; +C 37 ; WX 826 ; N percent ; B 98 -25 795 702 ; +C 38 ; WX 725 ; N ampersand ; B 60 -12 703 680 ; +C 39 ; WX 216 ; N quoteright ; B 112 482 265 742 ; +C 40 ; WX 350 ; N parenleft ; B 106 -128 458 692 ; +C 41 ; WX 350 ; N parenright ; B -46 -128 306 692 ; +C 42 ; WX 412 ; N asterisk ; B 106 356 458 707 ; +C 43 ; WX 570 ; N plus ; B 58 0 542 490 ; +C 44 ; WX 265 ; N comma ; B 11 -134 173 142 ; +C 45 ; WX 392 ; N hyphen ; B 82 216 341 286 ; +C 46 ; WX 265 ; N period ; B 47 -12 169 113 ; +C 47 ; WX 270 ; N slash ; B 0 -15 341 707 ; +C 48 ; WX 530 ; N zero ; B 60 -12 541 680 ; +C 49 ; WX 530 ; N one ; B 74 0 429 680 ; +C 50 ; WX 530 ; N two ; B -2 0 538 680 ; +C 51 ; WX 530 ; N three ; B 19 -12 524 680 ; +C 52 ; WX 530 ; N four ; B 32 0 509 668 ; +C 53 ; WX 530 ; N five ; B 24 -12 550 668 ; +C 54 ; WX 530 ; N six ; B 56 -12 551 680 ; +C 55 ; WX 530 ; N seven ; B 130 -12 600 668 ; +C 56 ; WX 530 ; N eight ; B 46 -12 535 680 ; +C 57 ; WX 530 ; N nine ; B 51 -12 536 680 ; +C 58 ; WX 265 ; N colon ; B 47 -12 248 490 ; +C 59 ; WX 265 ; N semicolon ; B 11 -134 248 490 ; +C 60 ; WX 570 ; N less ; B 51 1 529 497 ; +C 61 ; WX 570 ; N equal ; B 58 111 542 389 ; +C 62 ; WX 570 ; N greater ; B 51 1 529 497 ; +C 63 ; WX 425 ; N question ; B 115 -12 456 707 ; +C 64 ; WX 794 ; N at ; B 88 -15 797 707 ; +C 65 ; WX 624 ; N A ; B -58 0 623 692 ; +C 66 ; WX 632 ; N B ; B 3 0 636 692 ; +C 67 ; WX 661 ; N C ; B 79 -15 723 707 ; +C 68 ; WX 763 ; N D ; B 5 0 767 692 ; +C 69 ; WX 596 ; N E ; B 3 0 657 692 ; +C 70 ; WX 571 ; N F ; B 3 0 660 692 ; +C 71 ; WX 709 ; N G ; B 79 -15 737 707 ; +C 72 ; WX 775 ; N H ; B 5 0 857 692 ; +C 73 ; WX 345 ; N I ; B 5 0 428 692 ; +C 74 ; WX 352 ; N J ; B -78 -119 436 692 ; +C 75 ; WX 650 ; N K ; B 5 -5 786 692 ; +C 76 ; WX 565 ; N L ; B 5 0 568 692 ; +C 77 ; WX 920 ; N M ; B -4 0 1002 692 ; +C 78 ; WX 763 ; N N ; B -4 0 855 692 ; +C 79 ; WX 753 ; N O ; B 79 -15 754 707 ; +C 80 ; WX 614 ; N P ; B 5 0 646 692 ; +C 81 ; WX 753 ; N Q ; B 79 -203 754 707 ; +C 82 ; WX 640 ; N R ; B 5 0 642 692 ; +C 83 ; WX 533 ; N S ; B 34 -15 542 707 ; +C 84 ; WX 606 ; N T ; B 102 0 708 692 ; +C 85 ; WX 794 ; N U ; B 131 -15 880 692 ; +C 86 ; WX 637 ; N V ; B 96 0 786 692 ; +C 87 ; WX 946 ; N W ; B 86 0 1075 692 ; +C 88 ; WX 632 ; N X ; B -36 0 735 692 ; +C 89 ; WX 591 ; N Y ; B 96 0 744 692 ; +C 90 ; WX 622 ; N Z ; B -20 0 703 692 ; +C 91 ; WX 330 ; N bracketleft ; B 69 -128 414 692 ; +C 92 ; WX 390 ; N backslash ; B 89 -15 371 707 ; +C 93 ; WX 330 ; N bracketright ; B -21 -128 324 692 ; +C 94 ; WX 570 ; N asciicircum ; B 83 228 547 668 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 216 ; N quoteleft ; B 130 488 283 748 ; +C 97 ; WX 561 ; N a ; B 31 -12 563 502 ; +C 98 ; WX 559 ; N b ; B 47 -12 557 742 ; +C 99 ; WX 441 ; N c ; B 46 -12 465 502 ; +C 100 ; WX 587 ; N d ; B 37 -12 612 742 ; +C 101 ; WX 453 ; N e ; B 45 -12 471 502 ; +C 102 ; WX 315 ; N f ; B -107 -242 504 742 ; L i fi ; L l fl ; +C 103 ; WX 499 ; N g ; B -5 -242 573 512 ; +C 104 ; WX 607 ; N h ; B 57 -12 588 742 ; +C 105 ; WX 317 ; N i ; B 79 -12 328 715 ; +C 106 ; WX 309 ; N j ; B -95 -242 330 715 ; +C 107 ; WX 545 ; N k ; B 57 -12 567 742 ; +C 108 ; WX 306 ; N l ; B 76 -12 331 742 ; +C 109 ; WX 912 ; N m ; B 63 -12 894 502 ; +C 110 ; WX 618 ; N n ; B 63 -12 600 502 ; +C 111 ; WX 537 ; N o ; B 49 -12 522 502 ; +C 112 ; WX 590 ; N p ; B 22 -242 586 502 ; +C 113 ; WX 559 ; N q ; B 38 -242 567 525 ; +C 114 ; WX 402 ; N r ; B 69 -12 448 502 ; +C 115 ; WX 389 ; N s ; B 19 -12 397 502 ; +C 116 ; WX 341 ; N t ; B 84 -12 404 616 ; +C 117 ; WX 618 ; N u ; B 89 -12 609 502 ; +C 118 ; WX 510 ; N v ; B 84 -12 528 502 ; +C 119 ; WX 785 ; N w ; B 87 -12 808 502 ; +C 120 ; WX 516 ; N x ; B -4 -12 531 502 ; +C 121 ; WX 468 ; N y ; B -40 -242 505 502 ; +C 122 ; WX 468 ; N z ; B 4 -12 483 490 ; +C 123 ; WX 340 ; N braceleft ; B 100 -128 423 692 ; +C 124 ; WX 270 ; N bar ; B 130 -250 198 750 ; +C 125 ; WX 340 ; N braceright ; B -20 -128 302 692 ; +C 126 ; WX 570 ; N asciitilde ; B 98 176 522 318 ; +C 161 ; WX 240 ; N exclamdown ; B -18 -217 238 502 ; +C 162 ; WX 530 ; N cent ; B 94 -21 563 669 ; +C 163 ; WX 530 ; N sterling ; B 9 0 549 680 ; +C 164 ; WX 100 ; N fraction ; B -201 -24 369 698 ; +C 165 ; WX 530 ; N yen ; B 72 0 645 668 ; +C 166 ; WX 530 ; N florin ; B 4 -135 588 691 ; +C 167 ; WX 530 ; N section ; B 55 -115 533 707 ; +C 168 ; WX 530 ; N currency ; B 56 90 536 578 ; +C 169 ; WX 216 ; N quotesingle ; B 161 469 274 742 ; +C 170 ; WX 402 ; N quotedblleft ; B 134 488 473 748 ; +C 171 ; WX 462 ; N guillemotleft ; B 79 41 470 435 ; +C 172 ; WX 277 ; N guilsinglleft ; B 71 41 267 435 ; +C 173 ; WX 277 ; N guilsinglright ; B 44 41 240 435 ; +C 174 ; WX 607 ; N fi ; B -107 -242 589 742 ; +C 175 ; WX 603 ; N fl ; B -107 -242 628 742 ; +C 177 ; WX 500 ; N endash ; B 12 221 524 279 ; +C 178 ; WX 500 ; N dagger ; B 101 -125 519 717 ; +C 179 ; WX 490 ; N daggerdbl ; B 39 -119 509 717 ; +C 180 ; WX 265 ; N periodcentered ; B 89 187 211 312 ; +C 182 ; WX 560 ; N paragraph ; B 109 -101 637 692 ; +C 183 ; WX 500 ; N bullet ; B 110 192 429 512 ; +C 184 ; WX 216 ; N quotesinglbase ; B -7 -109 146 151 ; +C 185 ; WX 402 ; N quotedblbase ; B -7 -109 332 151 ; +C 186 ; WX 402 ; N quotedblright ; B 107 484 446 744 ; +C 187 ; WX 462 ; N guillemotright ; B 29 41 420 435 ; +C 188 ; WX 1000 ; N ellipsis ; B 85 -12 873 113 ; +C 189 ; WX 1200 ; N perthousand ; B 98 -25 1170 702 ; +C 191 ; WX 425 ; N questiondown ; B 3 -217 344 502 ; +C 193 ; WX 400 ; N grave ; B 146 542 368 723 ; +C 194 ; WX 400 ; N acute ; B 214 542 436 723 ; +C 195 ; WX 400 ; N circumflex ; B 187 546 484 720 ; +C 196 ; WX 400 ; N tilde ; B 137 563 492 682 ; +C 197 ; WX 400 ; N macron ; B 193 597 489 656 ; +C 198 ; WX 400 ; N breve ; B 227 568 501 698 ; +C 199 ; WX 402 ; N dotaccent ; B 252 570 359 680 ; +C 200 ; WX 400 ; N dieresis ; B 172 572 487 682 ; +C 202 ; WX 400 ; N ring ; B 186 550 402 752 ; +C 203 ; WX 400 ; N cedilla ; B 62 -230 241 0 ; +C 205 ; WX 400 ; N hungarumlaut ; B 176 546 455 750 ; +C 206 ; WX 350 ; N ogonek ; B 68 -219 248 0 ; +C 207 ; WX 400 ; N caron ; B 213 557 510 731 ; +C 208 ; WX 1000 ; N emdash ; B 12 221 1024 279 ; +C 225 ; WX 880 ; N AE ; B -88 0 941 692 ; +C 227 ; WX 425 ; N ordfeminine ; B 77 265 460 590 ; +C 232 ; WX 571 ; N Lslash ; B 11 0 574 692 ; +C 233 ; WX 753 ; N Oslash ; B 79 -45 754 736 ; +C 234 ; WX 1020 ; N OE ; B 79 0 1081 692 ; +C 235 ; WX 389 ; N ordmasculine ; B 86 265 420 590 ; +C 241 ; WX 779 ; N ae ; B 34 -12 797 514 ; +C 245 ; WX 317 ; N dotlessi ; B 79 -12 299 502 ; +C 248 ; WX 318 ; N lslash ; B 45 -12 376 742 ; +C 249 ; WX 537 ; N oslash ; B 49 -39 522 529 ; +C 250 ; WX 806 ; N oe ; B 49 -12 824 502 ; +C 251 ; WX 577 ; N germandbls ; B -107 -242 630 742 ; +C -1 ; WX 370 ; N onesuperior ; B 90 272 326 680 ; +C -1 ; WX 570 ; N minus ; B 58 221 542 279 ; +C -1 ; WX 400 ; N degree ; B 152 404 428 680 ; +C -1 ; WX 537 ; N oacute ; B 49 -12 530 723 ; +C -1 ; WX 753 ; N Odieresis ; B 79 -15 754 848 ; +C -1 ; WX 537 ; N odieresis ; B 49 -12 532 682 ; +C -1 ; WX 596 ; N Eacute ; B 3 0 657 890 ; +C -1 ; WX 618 ; N ucircumflex ; B 89 -12 609 720 ; +C -1 ; WX 890 ; N onequarter ; B 97 -24 805 698 ; +C -1 ; WX 570 ; N logicalnot ; B 58 102 542 389 ; +C -1 ; WX 596 ; N Ecircumflex ; B 3 0 657 876 ; +C -1 ; WX 890 ; N onehalf ; B 71 -24 812 698 ; +C -1 ; WX 753 ; N Otilde ; B 79 -15 754 842 ; +C -1 ; WX 618 ; N uacute ; B 89 -12 609 723 ; +C -1 ; WX 453 ; N eacute ; B 45 -12 508 723 ; +C -1 ; WX 317 ; N iacute ; B 79 -12 398 723 ; +C -1 ; WX 596 ; N Egrave ; B 3 0 657 890 ; +C -1 ; WX 317 ; N icircumflex ; B 79 -12 383 720 ; +C -1 ; WX 618 ; N mu ; B 11 -232 609 502 ; +C -1 ; WX 270 ; N brokenbar ; B 130 -175 198 675 ; +C -1 ; WX 584 ; N thorn ; B 16 -242 580 700 ; +C -1 ; WX 624 ; N Aring ; B -58 0 623 861 ; +C -1 ; WX 468 ; N yacute ; B -40 -242 505 723 ; +C -1 ; WX 591 ; N Ydieresis ; B 96 0 744 848 ; +C -1 ; WX 1100 ; N trademark ; B 91 277 1094 692 ; +C -1 ; WX 836 ; N registered ; B 91 -15 819 707 ; +C -1 ; WX 537 ; N ocircumflex ; B 49 -12 522 720 ; +C -1 ; WX 624 ; N Agrave ; B -58 0 623 890 ; +C -1 ; WX 533 ; N Scaron ; B 34 -15 561 888 ; +C -1 ; WX 794 ; N Ugrave ; B 131 -15 880 890 ; +C -1 ; WX 596 ; N Edieresis ; B 3 0 657 848 ; +C -1 ; WX 794 ; N Uacute ; B 131 -15 880 890 ; +C -1 ; WX 537 ; N otilde ; B 49 -12 525 682 ; +C -1 ; WX 618 ; N ntilde ; B 63 -12 600 682 ; +C -1 ; WX 468 ; N ydieresis ; B -40 -242 513 682 ; +C -1 ; WX 624 ; N Aacute ; B -58 0 642 890 ; +C -1 ; WX 537 ; N eth ; B 47 -12 521 742 ; +C -1 ; WX 561 ; N acircumflex ; B 31 -12 563 720 ; +C -1 ; WX 561 ; N aring ; B 31 -12 563 752 ; +C -1 ; WX 753 ; N Ograve ; B 79 -15 754 890 ; +C -1 ; WX 441 ; N ccedilla ; B 46 -230 465 502 ; +C -1 ; WX 570 ; N multiply ; B 88 22 532 478 ; +C -1 ; WX 570 ; N divide ; B 58 25 542 475 ; +C -1 ; WX 370 ; N twosuperior ; B 35 272 399 680 ; +C -1 ; WX 763 ; N Ntilde ; B -4 0 855 842 ; +C -1 ; WX 618 ; N ugrave ; B 89 -12 609 723 ; +C -1 ; WX 794 ; N Ucircumflex ; B 131 -15 880 876 ; +C -1 ; WX 624 ; N Atilde ; B -58 0 623 842 ; +C -1 ; WX 468 ; N zcaron ; B 4 -12 484 731 ; +C -1 ; WX 317 ; N idieresis ; B 79 -12 398 682 ; +C -1 ; WX 624 ; N Acircumflex ; B -58 0 623 876 ; +C -1 ; WX 345 ; N Icircumflex ; B 5 0 453 876 ; +C -1 ; WX 591 ; N Yacute ; B 96 0 744 890 ; +C -1 ; WX 753 ; N Oacute ; B 79 -15 754 890 ; +C -1 ; WX 624 ; N Adieresis ; B -58 0 623 848 ; +C -1 ; WX 622 ; N Zcaron ; B -20 0 703 888 ; +C -1 ; WX 561 ; N agrave ; B 31 -12 563 723 ; +C -1 ; WX 370 ; N threesuperior ; B 59 265 389 680 ; +C -1 ; WX 537 ; N ograve ; B 49 -12 522 723 ; +C -1 ; WX 890 ; N threequarters ; B 105 -24 816 698 ; +C -1 ; WX 770 ; N Eth ; B 12 0 774 692 ; +C -1 ; WX 570 ; N plusminus ; B 58 0 542 556 ; +C -1 ; WX 618 ; N udieresis ; B 89 -12 609 682 ; +C -1 ; WX 453 ; N edieresis ; B 45 -12 490 682 ; +C -1 ; WX 561 ; N aacute ; B 31 -12 571 723 ; +C -1 ; WX 317 ; N igrave ; B 55 -12 299 723 ; +C -1 ; WX 345 ; N Idieresis ; B 5 0 461 848 ; +C -1 ; WX 561 ; N adieresis ; B 31 -12 563 682 ; +C -1 ; WX 345 ; N Iacute ; B 5 0 506 890 ; +C -1 ; WX 836 ; N copyright ; B 91 -15 819 707 ; +C -1 ; WX 345 ; N Igrave ; B 5 0 428 890 ; +C -1 ; WX 661 ; N Ccedilla ; B 79 -230 723 707 ; +C -1 ; WX 389 ; N scaron ; B 19 -12 457 731 ; +C -1 ; WX 453 ; N egrave ; B 45 -12 471 723 ; +C -1 ; WX 753 ; N Ocircumflex ; B 79 -15 754 876 ; +C -1 ; WX 604 ; N Thorn ; B 5 0 616 692 ; +C -1 ; WX 561 ; N atilde ; B 31 -12 563 682 ; +C -1 ; WX 794 ; N Udieresis ; B 131 -15 880 848 ; +C -1 ; WX 453 ; N ecircumflex ; B 45 -12 475 720 ; +EndCharMetrics +StartKernData +StartKernPairs 690 + +KPX A y -20 +KPX A x 10 +KPX A w -30 +KPX A v -30 +KPX A u -10 +KPX A t -6 +KPX A s 15 +KPX A r -12 +KPX A quoteright -110 +KPX A quotedblright -110 +KPX A q 10 +KPX A p -12 +KPX A o -10 +KPX A n -18 +KPX A m -18 +KPX A l -18 +KPX A j 6 +KPX A h -6 +KPX A d 10 +KPX A c -6 +KPX A b -6 +KPX A a 12 +KPX A Y -76 +KPX A X -8 +KPX A W -80 +KPX A V -90 +KPX A U -60 +KPX A T -72 +KPX A Q -30 +KPX A O -30 +KPX A G -30 +KPX A C -30 + +KPX B y -6 +KPX B u -20 +KPX B r -15 +KPX B quoteright -40 +KPX B quotedblright -30 +KPX B o 6 +KPX B l -20 +KPX B k -15 +KPX B i -12 +KPX B h -15 +KPX B e 6 +KPX B a 12 +KPX B W -20 +KPX B V -50 +KPX B U -50 +KPX B T -20 + +KPX C z -6 +KPX C y -18 +KPX C u -18 +KPX C quotedblright 20 +KPX C i -5 +KPX C e -6 +KPX C a -6 + +KPX D y 18 +KPX D u -10 +KPX D quoteright -40 +KPX D quotedblright -50 +KPX D period -30 +KPX D o 6 +KPX D i 6 +KPX D h -25 +KPX D e 6 +KPX D comma -20 +KPX D a 6 +KPX D Y -70 +KPX D W -50 +KPX D V -60 + +KPX E z -6 +KPX E y -18 +KPX E x 5 +KPX E w -20 +KPX E v -18 +KPX E u -24 +KPX E t -18 +KPX E s 5 +KPX E r -6 +KPX E quoteright 10 +KPX E quotedblright 10 +KPX E q 10 +KPX E period 10 +KPX E p -12 +KPX E o -6 +KPX E n -12 +KPX E m -12 +KPX E l -12 +KPX E k -10 +KPX E j -6 +KPX E i -12 +KPX E g -12 +KPX E e 5 +KPX E d 10 +KPX E comma 10 +KPX E b -6 + +KPX F y -12 +KPX F u -30 +KPX F r -18 +KPX F quoteright 15 +KPX F quotedblright 35 +KPX F period -180 +KPX F o -30 +KPX F l -6 +KPX F i -12 +KPX F e -30 +KPX F comma -170 +KPX F a -30 +KPX F A -45 + +KPX G y -16 +KPX G u -22 +KPX G r -22 +KPX G quoteright -20 +KPX G quotedblright -20 +KPX G o 10 +KPX G n -22 +KPX G l -24 +KPX G i -12 +KPX G h -18 +KPX G e 10 +KPX G a 5 + +KPX H y -18 +KPX H u -30 +KPX H quoteright 10 +KPX H quotedblright 10 +KPX H o -12 +KPX H i -12 +KPX H e -12 +KPX H a -12 + +KPX I z -20 +KPX I y -6 +KPX I x -6 +KPX I w -30 +KPX I v -30 +KPX I u -30 +KPX I t -18 +KPX I s -18 +KPX I r -12 +KPX I quoteright 10 +KPX I quotedblright 10 +KPX I p -18 +KPX I o -12 +KPX I n -18 +KPX I m -18 +KPX I l -6 +KPX I k -6 +KPX I g -12 +KPX I f -6 +KPX I d -6 +KPX I c -12 +KPX I b -6 +KPX I a -6 + +KPX J y -12 +KPX J u -36 +KPX J quoteright 6 +KPX J quotedblright 15 +KPX J o -36 +KPX J i -30 +KPX J e -36 +KPX J braceright 10 +KPX J a -36 + +KPX K y -40 +KPX K w -30 +KPX K v -20 +KPX K u -24 +KPX K r -12 +KPX K quoteright 25 +KPX K quotedblright 40 +KPX K o -24 +KPX K n -18 +KPX K i -6 +KPX K h 6 +KPX K e -12 +KPX K a -6 +KPX K Q -24 +KPX K O -24 +KPX K G -24 +KPX K C -24 + +KPX L y -55 +KPX L w -30 +KPX L u -18 +KPX L quoteright -110 +KPX L quotedblright -110 +KPX L l -16 +KPX L j -18 +KPX L i -18 +KPX L a 10 +KPX L Y -80 +KPX L W -90 +KPX L V -110 +KPX L U -42 +KPX L T -80 +KPX L Q -48 +KPX L O -48 +KPX L G -48 +KPX L C -48 +KPX L A 30 + +KPX M y -18 +KPX M u -24 +KPX M quoteright 6 +KPX M quotedblright 15 +KPX M o -25 +KPX M n -12 +KPX M j -18 +KPX M i -12 +KPX M e -20 +KPX M d -10 +KPX M c -20 +KPX M a -6 + +KPX N y -18 +KPX N u -24 +KPX N quoteright 10 +KPX N quotedblright 10 +KPX N o -25 +KPX N i -12 +KPX N e -20 +KPX N a -22 + +KPX O z -6 +KPX O y 12 +KPX O w -10 +KPX O v -10 +KPX O u -6 +KPX O t -6 +KPX O s -6 +KPX O r -6 +KPX O quoteright -40 +KPX O quotedblright -40 +KPX O q 5 +KPX O period -20 +KPX O p -6 +KPX O n -6 +KPX O m -6 +KPX O l -20 +KPX O k -10 +KPX O j -6 +KPX O h -10 +KPX O g -6 +KPX O e 5 +KPX O d 6 +KPX O comma -10 +KPX O c 5 +KPX O b -6 +KPX O a 5 +KPX O Y -75 +KPX O X -30 +KPX O W -40 +KPX O V -60 +KPX O T -48 +KPX O A -18 + +KPX P y 6 +KPX P u -18 +KPX P t -6 +KPX P s -24 +KPX P r -6 +KPX P period -220 +KPX P o -24 +KPX P n -12 +KPX P l -25 +KPX P h -15 +KPX P e -24 +KPX P comma -220 +KPX P a -24 +KPX P I -30 +KPX P H -30 +KPX P E -30 +KPX P A -75 + +KPX Q u -6 +KPX Q quoteright -40 +KPX Q quotedblright -50 +KPX Q a -6 +KPX Q Y -70 +KPX Q X -12 +KPX Q W -35 +KPX Q V -60 +KPX Q U -35 +KPX Q T -36 +KPX Q A -18 + +KPX R y -14 +KPX R u -12 +KPX R quoteright -30 +KPX R quotedblright -20 +KPX R o -12 +KPX R hyphen -20 +KPX R e -12 +KPX R Y -50 +KPX R W -30 +KPX R V -40 +KPX R U -40 +KPX R T -30 +KPX R Q -10 +KPX R O -10 +KPX R G -10 +KPX R C -10 +KPX R A -6 + +KPX S y -30 +KPX S w -30 +KPX S v -30 +KPX S u -18 +KPX S t -30 +KPX S r -20 +KPX S quoteright -38 +KPX S quotedblright -30 +KPX S p -18 +KPX S n -24 +KPX S m -24 +KPX S l -30 +KPX S k -24 +KPX S j -25 +KPX S i -30 +KPX S h -30 +KPX S e -6 + +KPX T z -70 +KPX T y -60 +KPX T w -64 +KPX T u -74 +KPX T semicolon -36 +KPX T s -72 +KPX T r -64 +KPX T quoteright 45 +KPX T quotedblright 50 +KPX T period -100 +KPX T parenright 54 +KPX T o -90 +KPX T m -64 +KPX T i -34 +KPX T hyphen -100 +KPX T endash -60 +KPX T emdash -60 +KPX T e -90 +KPX T comma -110 +KPX T colon -10 +KPX T bracketright 45 +KPX T braceright 54 +KPX T a -90 +KPX T Y 12 +KPX T X 18 +KPX T W 6 +KPX T T 18 +KPX T Q -12 +KPX T O -12 +KPX T G -12 +KPX T C -12 +KPX T A -56 + +KPX U z -30 +KPX U x -40 +KPX U t -24 +KPX U s -30 +KPX U r -30 +KPX U quoteright 10 +KPX U quotedblright 10 +KPX U p -40 +KPX U n -45 +KPX U m -45 +KPX U l -12 +KPX U k -12 +KPX U i -24 +KPX U h -6 +KPX U g -30 +KPX U d -40 +KPX U c -35 +KPX U b -6 +KPX U a -40 +KPX U A -45 + +KPX V y -46 +KPX V u -42 +KPX V semicolon -35 +KPX V r -50 +KPX V quoteright 75 +KPX V quotedblright 70 +KPX V period -130 +KPX V parenright 64 +KPX V o -62 +KPX V i -10 +KPX V hyphen -60 +KPX V endash -20 +KPX V emdash -20 +KPX V e -52 +KPX V comma -120 +KPX V colon -18 +KPX V bracketright 64 +KPX V braceright 64 +KPX V a -60 +KPX V T 6 +KPX V A -70 + +KPX W y -42 +KPX W u -56 +KPX W t -20 +KPX W semicolon -28 +KPX W r -40 +KPX W quoteright 55 +KPX W quotedblright 60 +KPX W period -108 +KPX W parenright 64 +KPX W o -60 +KPX W m -35 +KPX W i -10 +KPX W hyphen -40 +KPX W endash -2 +KPX W emdash -10 +KPX W e -54 +KPX W d -50 +KPX W comma -108 +KPX W colon -28 +KPX W bracketright 55 +KPX W braceright 64 +KPX W a -60 +KPX W T 12 +KPX W Q -10 +KPX W O -10 +KPX W G -10 +KPX W C -10 +KPX W A -58 + +KPX X y -35 +KPX X u -30 +KPX X r -6 +KPX X quoteright 35 +KPX X quotedblright 15 +KPX X i -6 +KPX X e -10 +KPX X a 5 +KPX X Y -6 +KPX X W -6 +KPX X Q -30 +KPX X O -30 +KPX X G -30 +KPX X C -30 +KPX X A -18 + +KPX Y v -50 +KPX Y u -58 +KPX Y t -32 +KPX Y semicolon -36 +KPX Y quoteright 65 +KPX Y quotedblright 70 +KPX Y q -100 +KPX Y period -90 +KPX Y parenright 60 +KPX Y o -72 +KPX Y l 10 +KPX Y hyphen -95 +KPX Y endash -20 +KPX Y emdash -20 +KPX Y e -72 +KPX Y d -80 +KPX Y comma -80 +KPX Y colon -36 +KPX Y bracketright 64 +KPX Y braceright 75 +KPX Y a -82 +KPX Y Y 12 +KPX Y X 12 +KPX Y W 12 +KPX Y V 6 +KPX Y T 25 +KPX Y Q -5 +KPX Y O -5 +KPX Y G -5 +KPX Y C -5 +KPX Y A -36 + +KPX Z y -36 +KPX Z w -36 +KPX Z u -12 +KPX Z quoteright 10 +KPX Z quotedblright 10 +KPX Z o -6 +KPX Z i -12 +KPX Z e -6 +KPX Z a -6 +KPX Z Q -30 +KPX Z O -30 +KPX Z G -30 +KPX Z C -30 +KPX Z A 12 + +KPX a quoteright -40 +KPX a quotedblright -40 + +KPX b y -6 +KPX b w -15 +KPX b v -15 +KPX b quoteright -50 +KPX b quotedblright -50 +KPX b period -40 +KPX b comma -30 + +KPX braceleft Y 64 +KPX braceleft W 64 +KPX braceleft V 64 +KPX braceleft T 54 +KPX braceleft J 80 + +KPX bracketleft Y 64 +KPX bracketleft W 64 +KPX bracketleft V 64 +KPX bracketleft T 54 +KPX bracketleft J 80 + +KPX c quoteright -20 +KPX c quotedblright -20 + +KPX colon space -30 + +KPX comma space -40 +KPX comma quoteright -80 +KPX comma quotedblright -80 + +KPX d quoteright -12 +KPX d quotedblright -12 + +KPX e x -10 +KPX e w -10 +KPX e quoteright -30 +KPX e quotedblright -30 + +KPX f quoteright 110 +KPX f quotedblright 110 +KPX f period -20 +KPX f parenright 100 +KPX f comma -20 +KPX f bracketright 90 +KPX f braceright 90 + +KPX g y 30 +KPX g p 12 +KPX g f 42 + +KPX h quoteright -80 +KPX h quotedblright -80 + +KPX j quoteright -20 +KPX j quotedblright -20 +KPX j period -35 +KPX j comma -20 + +KPX k quoteright -30 +KPX k quotedblright -50 + +KPX m quoteright -80 +KPX m quotedblright -80 + +KPX n quoteright -80 +KPX n quotedblright -80 + +KPX o z -10 +KPX o y -20 +KPX o x -20 +KPX o w -30 +KPX o v -35 +KPX o quoteright -60 +KPX o quotedblright -50 +KPX o period -30 +KPX o comma -20 + +KPX p z -10 +KPX p w -15 +KPX p quoteright -50 +KPX p quotedblright -70 +KPX p period -30 +KPX p comma -20 + +KPX parenleft Y 75 +KPX parenleft W 75 +KPX parenleft V 75 +KPX parenleft T 64 +KPX parenleft J 80 + +KPX period space -40 +KPX period quoteright -80 +KPX period quotedblright -80 + +KPX q quoteright -20 +KPX q quotedblright -30 +KPX q period -20 +KPX q comma -10 + +KPX quotedblleft z -30 +KPX quotedblleft x -40 +KPX quotedblleft w -12 +KPX quotedblleft v -12 +KPX quotedblleft u -12 +KPX quotedblleft t -12 +KPX quotedblleft s -30 +KPX quotedblleft r -12 +KPX quotedblleft q -40 +KPX quotedblleft p -12 +KPX quotedblleft o -30 +KPX quotedblleft n -12 +KPX quotedblleft m -12 +KPX quotedblleft l 10 +KPX quotedblleft k 10 +KPX quotedblleft h 10 +KPX quotedblleft g -30 +KPX quotedblleft e -40 +KPX quotedblleft d -40 +KPX quotedblleft c -40 +KPX quotedblleft b 24 +KPX quotedblleft a -60 +KPX quotedblleft Y 12 +KPX quotedblleft X 28 +KPX quotedblleft W 28 +KPX quotedblleft V 28 +KPX quotedblleft T 36 +KPX quotedblleft A -90 + +KPX quotedblright space -40 +KPX quotedblright period -100 +KPX quotedblright comma -100 + +KPX quoteleft z -30 +KPX quoteleft y -10 +KPX quoteleft x -40 +KPX quoteleft w -12 +KPX quoteleft v -12 +KPX quoteleft u -12 +KPX quoteleft t -12 +KPX quoteleft s -30 +KPX quoteleft r -12 +KPX quoteleft quoteleft -18 +KPX quoteleft q -30 +KPX quoteleft p -12 +KPX quoteleft o -30 +KPX quoteleft n -12 +KPX quoteleft m -12 +KPX quoteleft l 10 +KPX quoteleft k 10 +KPX quoteleft h 10 +KPX quoteleft g -30 +KPX quoteleft e -30 +KPX quoteleft d -30 +KPX quoteleft c -30 +KPX quoteleft b 24 +KPX quoteleft a -45 +KPX quoteleft Y 12 +KPX quoteleft X 28 +KPX quoteleft W 28 +KPX quoteleft V 28 +KPX quoteleft T 36 +KPX quoteleft A -90 + +KPX quoteright v -35 +KPX quoteright t -35 +KPX quoteright space -40 +KPX quoteright s -55 +KPX quoteright r -25 +KPX quoteright quoteright -18 +KPX quoteright period -100 +KPX quoteright m -25 +KPX quoteright l -12 +KPX quoteright d -70 +KPX quoteright comma -100 + +KPX r y 18 +KPX r w 6 +KPX r v 6 +KPX r t 8 +KPX r quotedblright -15 +KPX r q -24 +KPX r period -120 +KPX r o -6 +KPX r l -20 +KPX r k -20 +KPX r hyphen -30 +KPX r h -20 +KPX r f 8 +KPX r emdash -20 +KPX r e -26 +KPX r d -26 +KPX r comma -110 +KPX r c -12 +KPX r a -20 + +KPX s quoteright -40 +KPX s quotedblright -45 + +KPX semicolon space -30 + +KPX space quotesinglbase -30 +KPX space quoteleft -40 +KPX space quotedblleft -40 +KPX space quotedblbase -30 +KPX space Y -70 +KPX space W -70 +KPX space V -70 + +KPX t quoteright 10 +KPX t quotedblright -10 + +KPX u quoteright -55 +KPX u quotedblright -50 + +KPX v quoteright -20 +KPX v quotedblright -30 +KPX v q -6 +KPX v period -70 +KPX v o -6 +KPX v e -6 +KPX v d -6 +KPX v comma -70 +KPX v c -6 +KPX v a -6 + +KPX w quoteright -20 +KPX w quotedblright -30 +KPX w period -62 +KPX w comma -62 + +KPX x y 12 +KPX x w -6 +KPX x quoteright -40 +KPX x quotedblright -50 +KPX x q -6 +KPX x o -6 +KPX x e -6 +KPX x d -6 +KPX x c -6 + +KPX y quoteright -10 +KPX y quotedblright -20 +KPX y period -70 +KPX y emdash 40 +KPX y comma -60 + +KPX z quoteright -40 +KPX z quotedblright -50 +KPX z o -6 +KPX z e -6 +KPX z d -6 +KPX z c -6 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzcmi8a.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzcmi8a.afm new file mode 100644 index 00000000..6efb57ab --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzcmi8a.afm @@ -0,0 +1,480 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Fri Dec 28 16:35:46 1990 +Comment UniqueID 33936 +Comment VMusage 34559 41451 +FontName ZapfChancery-MediumItalic +FullName ITC Zapf Chancery Medium Italic +FamilyName ITC Zapf Chancery +Weight Medium +ItalicAngle -14 +IsFixedPitch false +FontBBox -181 -314 1065 831 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.007 +Notice Copyright (c) 1985, 1987, 1989, 1990 Adobe Systems Incorporated. All Rights Reserved.ITC Zapf Chancery is a registered trademark of International Typeface Corporation. +EncodingScheme AdobeStandardEncoding +CapHeight 708 +XHeight 438 +Ascender 714 +Descender -314 +StartCharMetrics 228 +C 32 ; WX 220 ; N space ; B 0 0 0 0 ; +C 33 ; WX 280 ; N exclam ; B 119 -14 353 610 ; +C 34 ; WX 220 ; N quotedbl ; B 120 343 333 610 ; +C 35 ; WX 440 ; N numbersign ; B 83 0 521 594 ; +C 36 ; WX 440 ; N dollar ; B 60 -144 508 709 ; +C 37 ; WX 680 ; N percent ; B 132 -160 710 700 ; +C 38 ; WX 780 ; N ampersand ; B 126 -16 915 610 ; +C 39 ; WX 240 ; N quoteright ; B 168 343 338 610 ; +C 40 ; WX 260 ; N parenleft ; B 96 -216 411 664 ; +C 41 ; WX 220 ; N parenright ; B -13 -216 302 664 ; +C 42 ; WX 420 ; N asterisk ; B 139 263 479 610 ; +C 43 ; WX 520 ; N plus ; B 117 0 543 426 ; +C 44 ; WX 220 ; N comma ; B 25 -140 213 148 ; +C 45 ; WX 280 ; N hyphen ; B 69 190 334 248 ; +C 46 ; WX 220 ; N period ; B 102 -14 228 128 ; +C 47 ; WX 340 ; N slash ; B 74 -16 458 610 ; +C 48 ; WX 440 ; N zero ; B 79 -16 538 610 ; +C 49 ; WX 440 ; N one ; B 41 0 428 610 ; +C 50 ; WX 440 ; N two ; B 17 -16 485 610 ; +C 51 ; WX 440 ; N three ; B 1 -16 485 610 ; +C 52 ; WX 440 ; N four ; B 77 -35 499 610 ; +C 53 ; WX 440 ; N five ; B 60 -16 595 679 ; +C 54 ; WX 440 ; N six ; B 90 -16 556 610 ; +C 55 ; WX 440 ; N seven ; B 157 -33 561 645 ; +C 56 ; WX 440 ; N eight ; B 65 -16 529 610 ; +C 57 ; WX 440 ; N nine ; B 32 -16 517 610 ; +C 58 ; WX 260 ; N colon ; B 98 -14 296 438 ; +C 59 ; WX 240 ; N semicolon ; B 29 -140 299 438 ; +C 60 ; WX 520 ; N less ; B 139 0 527 468 ; +C 61 ; WX 520 ; N equal ; B 117 86 543 340 ; +C 62 ; WX 520 ; N greater ; B 139 0 527 468 ; +C 63 ; WX 380 ; N question ; B 150 -14 455 610 ; +C 64 ; WX 700 ; N at ; B 127 -16 753 610 ; +C 65 ; WX 620 ; N A ; B 13 -16 697 632 ; +C 66 ; WX 600 ; N B ; B 85 -6 674 640 ; +C 67 ; WX 520 ; N C ; B 93 -16 631 610 ; +C 68 ; WX 700 ; N D ; B 86 -6 768 640 ; +C 69 ; WX 620 ; N E ; B 91 -12 709 618 ; +C 70 ; WX 580 ; N F ; B 120 -118 793 629 ; +C 71 ; WX 620 ; N G ; B 148 -242 709 610 ; +C 72 ; WX 680 ; N H ; B 18 -16 878 708 ; +C 73 ; WX 380 ; N I ; B 99 0 504 594 ; +C 74 ; WX 400 ; N J ; B -14 -147 538 594 ; +C 75 ; WX 660 ; N K ; B 53 -153 844 610 ; +C 76 ; WX 580 ; N L ; B 53 -16 657 610 ; +C 77 ; WX 840 ; N M ; B 58 -16 1020 722 ; +C 78 ; WX 700 ; N N ; B 85 -168 915 708 ; +C 79 ; WX 600 ; N O ; B 94 -16 660 610 ; +C 80 ; WX 540 ; N P ; B 42 0 658 628 ; +C 81 ; WX 600 ; N Q ; B 84 -177 775 610 ; +C 82 ; WX 600 ; N R ; B 58 -168 805 640 ; +C 83 ; WX 460 ; N S ; B 45 -81 558 610 ; +C 84 ; WX 500 ; N T ; B 63 0 744 667 ; +C 85 ; WX 740 ; N U ; B 126 -16 792 617 ; +C 86 ; WX 640 ; N V ; B 124 -16 810 714 ; +C 87 ; WX 880 ; N W ; B 94 -16 1046 723 ; +C 88 ; WX 560 ; N X ; B -30 -16 699 610 ; +C 89 ; WX 560 ; N Y ; B 41 -168 774 647 ; +C 90 ; WX 620 ; N Z ; B 42 -19 669 624 ; +C 91 ; WX 240 ; N bracketleft ; B -13 -207 405 655 ; +C 92 ; WX 480 ; N backslash ; B 140 -16 524 610 ; +C 93 ; WX 320 ; N bracketright ; B -27 -207 391 655 ; +C 94 ; WX 520 ; N asciicircum ; B 132 239 532 594 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 240 ; N quoteleft ; B 169 343 339 610 ; +C 97 ; WX 420 ; N a ; B 92 -15 485 438 ; +C 98 ; WX 420 ; N b ; B 82 -23 492 714 ; +C 99 ; WX 340 ; N c ; B 87 -14 406 438 ; +C 100 ; WX 440 ; N d ; B 102 -14 651 714 ; +C 101 ; WX 340 ; N e ; B 87 -14 403 438 ; +C 102 ; WX 320 ; N f ; B -119 -314 547 714 ; L i fi ; L l fl ; +C 103 ; WX 400 ; N g ; B -108 -314 503 438 ; +C 104 ; WX 440 ; N h ; B 55 -14 524 714 ; +C 105 ; WX 240 ; N i ; B 100 -14 341 635 ; +C 106 ; WX 220 ; N j ; B -112 -314 332 635 ; +C 107 ; WX 440 ; N k ; B 87 -184 628 714 ; +C 108 ; WX 240 ; N l ; B 102 -14 480 714 ; +C 109 ; WX 620 ; N m ; B 86 -14 704 438 ; +C 110 ; WX 460 ; N n ; B 101 -14 544 438 ; +C 111 ; WX 400 ; N o ; B 87 -14 449 438 ; +C 112 ; WX 440 ; N p ; B -23 -314 484 432 ; +C 113 ; WX 400 ; N q ; B 87 -300 490 510 ; +C 114 ; WX 300 ; N r ; B 101 -14 424 438 ; +C 115 ; WX 320 ; N s ; B 46 -14 403 438 ; +C 116 ; WX 320 ; N t ; B 106 -14 426 539 ; +C 117 ; WX 460 ; N u ; B 102 -14 528 438 ; +C 118 ; WX 440 ; N v ; B 87 -14 533 488 ; +C 119 ; WX 680 ; N w ; B 87 -14 782 488 ; +C 120 ; WX 420 ; N x ; B 70 -195 589 438 ; +C 121 ; WX 400 ; N y ; B -24 -314 483 438 ; +C 122 ; WX 440 ; N z ; B 26 -14 508 445 ; +C 123 ; WX 240 ; N braceleft ; B 55 -207 383 655 ; +C 124 ; WX 520 ; N bar ; B 320 -16 378 714 ; +C 125 ; WX 240 ; N braceright ; B -10 -207 318 655 ; +C 126 ; WX 520 ; N asciitilde ; B 123 186 539 320 ; +C 161 ; WX 280 ; N exclamdown ; B 72 -186 306 438 ; +C 162 ; WX 440 ; N cent ; B 122 -134 476 543 ; +C 163 ; WX 440 ; N sterling ; B -16 -52 506 610 ; +C 164 ; WX 60 ; N fraction ; B -181 -16 320 610 ; +C 165 ; WX 440 ; N yen ; B -1 -168 613 647 ; +C 166 ; WX 440 ; N florin ; B -64 -314 582 610 ; +C 167 ; WX 420 ; N section ; B 53 -215 514 610 ; +C 168 ; WX 440 ; N currency ; B 50 85 474 509 ; +C 169 ; WX 160 ; N quotesingle ; B 145 343 215 610 ; +C 170 ; WX 340 ; N quotedblleft ; B 169 343 464 610 ; +C 171 ; WX 340 ; N guillemotleft ; B 98 24 356 414 ; +C 172 ; WX 240 ; N guilsinglleft ; B 98 24 258 414 ; +C 173 ; WX 260 ; N guilsinglright ; B 106 24 266 414 ; +C 174 ; WX 520 ; N fi ; B -124 -314 605 714 ; +C 175 ; WX 520 ; N fl ; B -124 -314 670 714 ; +C 177 ; WX 500 ; N endash ; B 51 199 565 239 ; +C 178 ; WX 460 ; N dagger ; B 138 -37 568 610 ; +C 179 ; WX 480 ; N daggerdbl ; B 138 -59 533 610 ; +C 180 ; WX 220 ; N periodcentered ; B 139 208 241 310 ; +C 182 ; WX 500 ; N paragraph ; B 105 -199 638 594 ; +C 183 ; WX 600 ; N bullet ; B 228 149 524 445 ; +C 184 ; WX 180 ; N quotesinglbase ; B 21 -121 191 146 ; +C 185 ; WX 280 ; N quotedblbase ; B -14 -121 281 146 ; +C 186 ; WX 360 ; N quotedblright ; B 158 343 453 610 ; +C 187 ; WX 380 ; N guillemotright ; B 117 24 375 414 ; +C 188 ; WX 1000 ; N ellipsis ; B 124 -14 916 128 ; +C 189 ; WX 960 ; N perthousand ; B 112 -160 1005 700 ; +C 191 ; WX 400 ; N questiondown ; B 82 -186 387 438 ; +C 193 ; WX 220 ; N grave ; B 193 492 339 659 ; +C 194 ; WX 300 ; N acute ; B 265 492 422 659 ; +C 195 ; WX 340 ; N circumflex ; B 223 482 443 649 ; +C 196 ; WX 440 ; N tilde ; B 243 543 522 619 ; +C 197 ; WX 440 ; N macron ; B 222 544 465 578 ; +C 198 ; WX 440 ; N breve ; B 253 522 501 631 ; +C 199 ; WX 220 ; N dotaccent ; B 236 522 328 610 ; +C 200 ; WX 360 ; N dieresis ; B 243 522 469 610 ; +C 202 ; WX 300 ; N ring ; B 240 483 416 659 ; +C 203 ; WX 300 ; N cedilla ; B 12 -191 184 6 ; +C 205 ; WX 400 ; N hungarumlaut ; B 208 492 495 659 ; +C 206 ; WX 280 ; N ogonek ; B 38 -191 233 6 ; +C 207 ; WX 340 ; N caron ; B 254 492 474 659 ; +C 208 ; WX 1000 ; N emdash ; B 51 199 1065 239 ; +C 225 ; WX 740 ; N AE ; B -21 -16 799 594 ; +C 227 ; WX 260 ; N ordfeminine ; B 111 338 386 610 ; +C 232 ; WX 580 ; N Lslash ; B 49 -16 657 610 ; +C 233 ; WX 660 ; N Oslash ; B 83 -78 751 672 ; +C 234 ; WX 820 ; N OE ; B 63 -16 909 610 ; +C 235 ; WX 260 ; N ordmasculine ; B 128 339 373 610 ; +C 241 ; WX 540 ; N ae ; B 67 -14 624 468 ; +C 245 ; WX 240 ; N dotlessi ; B 100 -14 306 438 ; +C 248 ; WX 300 ; N lslash ; B 121 -14 515 714 ; +C 249 ; WX 440 ; N oslash ; B 46 -64 540 488 ; +C 250 ; WX 560 ; N oe ; B 78 -14 628 438 ; +C 251 ; WX 420 ; N germandbls ; B -127 -314 542 714 ; +C -1 ; WX 340 ; N ecircumflex ; B 87 -14 433 649 ; +C -1 ; WX 340 ; N edieresis ; B 87 -14 449 610 ; +C -1 ; WX 420 ; N aacute ; B 92 -15 492 659 ; +C -1 ; WX 740 ; N registered ; B 137 -16 763 610 ; +C -1 ; WX 240 ; N icircumflex ; B 100 -14 363 649 ; +C -1 ; WX 460 ; N udieresis ; B 102 -14 528 610 ; +C -1 ; WX 400 ; N ograve ; B 87 -14 449 659 ; +C -1 ; WX 460 ; N uacute ; B 102 -14 528 659 ; +C -1 ; WX 460 ; N ucircumflex ; B 102 -14 528 649 ; +C -1 ; WX 620 ; N Aacute ; B 13 -16 702 821 ; +C -1 ; WX 240 ; N igrave ; B 100 -14 306 659 ; +C -1 ; WX 380 ; N Icircumflex ; B 99 0 504 821 ; +C -1 ; WX 340 ; N ccedilla ; B 62 -191 406 438 ; +C -1 ; WX 420 ; N adieresis ; B 92 -15 485 610 ; +C -1 ; WX 620 ; N Ecircumflex ; B 91 -12 709 821 ; +C -1 ; WX 320 ; N scaron ; B 46 -14 464 659 ; +C -1 ; WX 440 ; N thorn ; B -38 -314 505 714 ; +C -1 ; WX 1000 ; N trademark ; B 127 187 1046 594 ; +C -1 ; WX 340 ; N egrave ; B 87 -14 403 659 ; +C -1 ; WX 264 ; N threesuperior ; B 59 234 348 610 ; +C -1 ; WX 440 ; N zcaron ; B 26 -14 514 659 ; +C -1 ; WX 420 ; N atilde ; B 92 -15 522 619 ; +C -1 ; WX 420 ; N aring ; B 92 -15 485 659 ; +C -1 ; WX 400 ; N ocircumflex ; B 87 -14 453 649 ; +C -1 ; WX 620 ; N Edieresis ; B 91 -12 709 762 ; +C -1 ; WX 660 ; N threequarters ; B 39 -16 706 610 ; +C -1 ; WX 400 ; N ydieresis ; B -24 -314 483 610 ; +C -1 ; WX 400 ; N yacute ; B -24 -314 483 659 ; +C -1 ; WX 240 ; N iacute ; B 100 -14 392 659 ; +C -1 ; WX 620 ; N Acircumflex ; B 13 -16 697 821 ; +C -1 ; WX 740 ; N Uacute ; B 126 -16 792 821 ; +C -1 ; WX 340 ; N eacute ; B 87 -14 462 659 ; +C -1 ; WX 600 ; N Ograve ; B 94 -16 660 821 ; +C -1 ; WX 420 ; N agrave ; B 92 -15 485 659 ; +C -1 ; WX 740 ; N Udieresis ; B 126 -16 792 762 ; +C -1 ; WX 420 ; N acircumflex ; B 92 -15 485 649 ; +C -1 ; WX 380 ; N Igrave ; B 99 0 504 821 ; +C -1 ; WX 264 ; N twosuperior ; B 72 234 354 610 ; +C -1 ; WX 740 ; N Ugrave ; B 126 -16 792 821 ; +C -1 ; WX 660 ; N onequarter ; B 56 -16 702 610 ; +C -1 ; WX 740 ; N Ucircumflex ; B 126 -16 792 821 ; +C -1 ; WX 460 ; N Scaron ; B 45 -81 594 831 ; +C -1 ; WX 380 ; N Idieresis ; B 99 0 519 762 ; +C -1 ; WX 240 ; N idieresis ; B 100 -14 369 610 ; +C -1 ; WX 620 ; N Egrave ; B 91 -12 709 821 ; +C -1 ; WX 600 ; N Oacute ; B 94 -16 660 821 ; +C -1 ; WX 520 ; N divide ; B 117 -14 543 440 ; +C -1 ; WX 620 ; N Atilde ; B 13 -16 702 771 ; +C -1 ; WX 620 ; N Aring ; B 13 -16 697 831 ; +C -1 ; WX 600 ; N Odieresis ; B 94 -16 660 762 ; +C -1 ; WX 620 ; N Adieresis ; B 13 -16 709 762 ; +C -1 ; WX 700 ; N Ntilde ; B 85 -168 915 761 ; +C -1 ; WX 620 ; N Zcaron ; B 42 -19 669 831 ; +C -1 ; WX 540 ; N Thorn ; B 52 0 647 623 ; +C -1 ; WX 380 ; N Iacute ; B 99 0 532 821 ; +C -1 ; WX 520 ; N plusminus ; B 117 0 543 436 ; +C -1 ; WX 520 ; N multiply ; B 133 16 527 410 ; +C -1 ; WX 620 ; N Eacute ; B 91 -12 709 821 ; +C -1 ; WX 560 ; N Ydieresis ; B 41 -168 774 762 ; +C -1 ; WX 264 ; N onesuperior ; B 83 244 311 610 ; +C -1 ; WX 460 ; N ugrave ; B 102 -14 528 659 ; +C -1 ; WX 520 ; N logicalnot ; B 117 86 543 340 ; +C -1 ; WX 460 ; N ntilde ; B 101 -14 544 619 ; +C -1 ; WX 600 ; N Otilde ; B 94 -16 660 761 ; +C -1 ; WX 400 ; N otilde ; B 87 -14 502 619 ; +C -1 ; WX 520 ; N Ccedilla ; B 93 -191 631 610 ; +C -1 ; WX 620 ; N Agrave ; B 13 -16 697 821 ; +C -1 ; WX 660 ; N onehalf ; B 56 -16 702 610 ; +C -1 ; WX 700 ; N Eth ; B 86 -6 768 640 ; +C -1 ; WX 400 ; N degree ; B 171 324 457 610 ; +C -1 ; WX 560 ; N Yacute ; B 41 -168 774 821 ; +C -1 ; WX 600 ; N Ocircumflex ; B 94 -16 660 821 ; +C -1 ; WX 400 ; N oacute ; B 87 -14 482 659 ; +C -1 ; WX 460 ; N mu ; B 7 -314 523 438 ; +C -1 ; WX 520 ; N minus ; B 117 184 543 242 ; +C -1 ; WX 400 ; N eth ; B 87 -14 522 714 ; +C -1 ; WX 400 ; N odieresis ; B 87 -14 479 610 ; +C -1 ; WX 740 ; N copyright ; B 137 -16 763 610 ; +C -1 ; WX 520 ; N brokenbar ; B 320 -16 378 714 ; +EndCharMetrics +StartKernData +StartKernPairs 131 + +KPX A quoteright -40 +KPX A quotedblright -40 +KPX A U -10 +KPX A T 10 +KPX A Q 10 +KPX A O 10 +KPX A G -30 +KPX A C 20 + +KPX D period -30 +KPX D comma -20 +KPX D Y 10 +KPX D A -10 + +KPX F period -40 +KPX F i 10 +KPX F comma -30 + +KPX G period -20 +KPX G comma -10 + +KPX J period -20 +KPX J comma -10 + +KPX K u -20 +KPX K o -20 +KPX K e -20 + +KPX L y -10 +KPX L quoteright -25 +KPX L quotedblright -25 +KPX L W -10 +KPX L V -20 + +KPX O period -20 +KPX O comma -10 +KPX O Y 10 +KPX O T 20 +KPX O A -20 + +KPX P period -50 +KPX P o -10 +KPX P e -10 +KPX P comma -40 +KPX P a -20 +KPX P A -10 + +KPX Q U -10 + +KPX R Y 10 +KPX R W 10 +KPX R T 20 + +KPX T o -20 +KPX T i 20 +KPX T hyphen -20 +KPX T h 20 +KPX T e -20 +KPX T a -20 +KPX T O 30 +KPX T A 10 + +KPX V period -100 +KPX V o -20 +KPX V e -20 +KPX V comma -90 +KPX V a -20 +KPX V O 10 +KPX V G -20 + +KPX W period -50 +KPX W o -20 +KPX W i 10 +KPX W h 10 +KPX W e -20 +KPX W comma -40 +KPX W a -20 +KPX W O 10 + +KPX Y u -20 +KPX Y period -50 +KPX Y o -50 +KPX Y i 10 +KPX Y e -40 +KPX Y comma -40 +KPX Y a -60 + +KPX b period -30 +KPX b l -20 +KPX b comma -20 +KPX b b -20 + +KPX c k -10 + +KPX comma quoteright -70 +KPX comma quotedblright -70 + +KPX d w -20 +KPX d v -10 +KPX d d -40 + +KPX e y 10 + +KPX f quoteright 30 +KPX f quotedblright 30 +KPX f period -50 +KPX f f -50 +KPX f e -10 +KPX f comma -40 +KPX f a -20 + +KPX g y 10 +KPX g period -30 +KPX g i 10 +KPX g e 10 +KPX g comma -20 +KPX g a 10 + +KPX k y 10 +KPX k o -10 +KPX k e -20 + +KPX m y 10 +KPX m u 10 + +KPX n y 20 + +KPX o period -30 +KPX o comma -20 + +KPX p period -30 +KPX p p -10 +KPX p comma -20 + +KPX period quoteright -80 +KPX period quotedblright -80 + +KPX quotedblleft quoteleft 20 +KPX quotedblleft A 10 + +KPX quoteleft quoteleft -115 +KPX quoteleft A 10 + +KPX quoteright v 30 +KPX quoteright t 20 +KPX quoteright s -25 +KPX quoteright r 30 +KPX quoteright quoteright -115 +KPX quoteright quotedblright 20 +KPX quoteright l 20 + +KPX r period -50 +KPX r i 10 +KPX r comma -40 + +KPX s period -20 +KPX s comma -10 + +KPX v period -30 +KPX v comma -20 + +KPX w period -30 +KPX w o 10 +KPX w h 20 +KPX w comma -20 +EndKernPairs +EndKernData +StartComposites 56 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 280 162 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 240 172 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 240 152 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 250 162 ; +CC Aring 2 ; PCC A 0 0 ; PCC ring 260 172 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 180 152 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 230 162 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 180 172 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 170 152 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 220 162 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 110 162 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex 60 172 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis 50 152 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave 100 162 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 210 142 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 160 162 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 130 172 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 120 152 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 150 162 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 90 142 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 120 172 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 310 162 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 260 172 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 260 152 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 270 162 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 220 162 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 170 152 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 130 172 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 70 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 20 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 10 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 80 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 60 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 0 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 40 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex -10 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis -20 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 30 0 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -30 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -80 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -100 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -40 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 10 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 60 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 10 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 10 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 60 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde -20 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron -10 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 70 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 30 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 20 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 50 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 60 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 0 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 40 0 ; +EndComposites +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzdr.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzdr.afm new file mode 100644 index 00000000..6b98e8d3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/afm/pzdr.afm @@ -0,0 +1,222 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 1985, 1987, 1988, 1989 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Fri Dec 1 12:57:42 1989 +Comment UniqueID 26200 +Comment VMusage 39281 49041 +FontName ZapfDingbats +FullName ITC Zapf Dingbats +FamilyName ITC Zapf Dingbats +Weight Medium +ItalicAngle 0 +IsFixedPitch false +FontBBox -1 -143 981 820 +UnderlinePosition -98 +UnderlineThickness 54 +Version 001.004 +Notice Copyright (c) 1985, 1987, 1988, 1989 Adobe Systems Incorporated. All rights reserved.ITC Zapf Dingbats is a registered trademark of International Typeface Corporation. +EncodingScheme FontSpecific +StartCharMetrics 202 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 974 ; N a1 ; B 35 72 939 621 ; +C 34 ; WX 961 ; N a2 ; B 35 81 927 611 ; +C 35 ; WX 974 ; N a202 ; B 35 72 939 621 ; +C 36 ; WX 980 ; N a3 ; B 35 0 945 692 ; +C 37 ; WX 719 ; N a4 ; B 34 139 685 566 ; +C 38 ; WX 789 ; N a5 ; B 35 -14 755 705 ; +C 39 ; WX 790 ; N a119 ; B 35 -14 755 705 ; +C 40 ; WX 791 ; N a118 ; B 35 -13 761 705 ; +C 41 ; WX 690 ; N a117 ; B 35 138 655 553 ; +C 42 ; WX 960 ; N a11 ; B 35 123 925 568 ; +C 43 ; WX 939 ; N a12 ; B 35 134 904 559 ; +C 44 ; WX 549 ; N a13 ; B 29 -11 516 705 ; +C 45 ; WX 855 ; N a14 ; B 34 59 820 632 ; +C 46 ; WX 911 ; N a15 ; B 35 50 876 642 ; +C 47 ; WX 933 ; N a16 ; B 35 139 899 550 ; +C 48 ; WX 911 ; N a105 ; B 35 50 876 642 ; +C 49 ; WX 945 ; N a17 ; B 35 139 909 553 ; +C 50 ; WX 974 ; N a18 ; B 35 104 938 587 ; +C 51 ; WX 755 ; N a19 ; B 34 -13 721 705 ; +C 52 ; WX 846 ; N a20 ; B 36 -14 811 705 ; +C 53 ; WX 762 ; N a21 ; B 35 0 727 692 ; +C 54 ; WX 761 ; N a22 ; B 35 0 727 692 ; +C 55 ; WX 571 ; N a23 ; B -1 -68 571 661 ; +C 56 ; WX 677 ; N a24 ; B 36 -13 642 705 ; +C 57 ; WX 763 ; N a25 ; B 35 0 728 692 ; +C 58 ; WX 760 ; N a26 ; B 35 0 726 692 ; +C 59 ; WX 759 ; N a27 ; B 35 0 725 692 ; +C 60 ; WX 754 ; N a28 ; B 35 0 720 692 ; +C 61 ; WX 494 ; N a6 ; B 35 0 460 692 ; +C 62 ; WX 552 ; N a7 ; B 35 0 517 692 ; +C 63 ; WX 537 ; N a8 ; B 35 0 503 692 ; +C 64 ; WX 577 ; N a9 ; B 35 96 542 596 ; +C 65 ; WX 692 ; N a10 ; B 35 -14 657 705 ; +C 66 ; WX 786 ; N a29 ; B 35 -14 751 705 ; +C 67 ; WX 788 ; N a30 ; B 35 -14 752 705 ; +C 68 ; WX 788 ; N a31 ; B 35 -14 753 705 ; +C 69 ; WX 790 ; N a32 ; B 35 -14 756 705 ; +C 70 ; WX 793 ; N a33 ; B 35 -13 759 705 ; +C 71 ; WX 794 ; N a34 ; B 35 -13 759 705 ; +C 72 ; WX 816 ; N a35 ; B 35 -14 782 705 ; +C 73 ; WX 823 ; N a36 ; B 35 -14 787 705 ; +C 74 ; WX 789 ; N a37 ; B 35 -14 754 705 ; +C 75 ; WX 841 ; N a38 ; B 35 -14 807 705 ; +C 76 ; WX 823 ; N a39 ; B 35 -14 789 705 ; +C 77 ; WX 833 ; N a40 ; B 35 -14 798 705 ; +C 78 ; WX 816 ; N a41 ; B 35 -13 782 705 ; +C 79 ; WX 831 ; N a42 ; B 35 -14 796 705 ; +C 80 ; WX 923 ; N a43 ; B 35 -14 888 705 ; +C 81 ; WX 744 ; N a44 ; B 35 0 710 692 ; +C 82 ; WX 723 ; N a45 ; B 35 0 688 692 ; +C 83 ; WX 749 ; N a46 ; B 35 0 714 692 ; +C 84 ; WX 790 ; N a47 ; B 34 -14 756 705 ; +C 85 ; WX 792 ; N a48 ; B 35 -14 758 705 ; +C 86 ; WX 695 ; N a49 ; B 35 -14 661 706 ; +C 87 ; WX 776 ; N a50 ; B 35 -6 741 699 ; +C 88 ; WX 768 ; N a51 ; B 35 -7 734 699 ; +C 89 ; WX 792 ; N a52 ; B 35 -14 757 705 ; +C 90 ; WX 759 ; N a53 ; B 35 0 725 692 ; +C 91 ; WX 707 ; N a54 ; B 35 -13 672 704 ; +C 92 ; WX 708 ; N a55 ; B 35 -14 672 705 ; +C 93 ; WX 682 ; N a56 ; B 35 -14 647 705 ; +C 94 ; WX 701 ; N a57 ; B 35 -14 666 705 ; +C 95 ; WX 826 ; N a58 ; B 35 -14 791 705 ; +C 96 ; WX 815 ; N a59 ; B 35 -14 780 705 ; +C 97 ; WX 789 ; N a60 ; B 35 -14 754 705 ; +C 98 ; WX 789 ; N a61 ; B 35 -14 754 705 ; +C 99 ; WX 707 ; N a62 ; B 34 -14 673 705 ; +C 100 ; WX 687 ; N a63 ; B 36 0 651 692 ; +C 101 ; WX 696 ; N a64 ; B 35 0 661 691 ; +C 102 ; WX 689 ; N a65 ; B 35 0 655 692 ; +C 103 ; WX 786 ; N a66 ; B 34 -14 751 705 ; +C 104 ; WX 787 ; N a67 ; B 35 -14 752 705 ; +C 105 ; WX 713 ; N a68 ; B 35 -14 678 705 ; +C 106 ; WX 791 ; N a69 ; B 35 -14 756 705 ; +C 107 ; WX 785 ; N a70 ; B 36 -14 751 705 ; +C 108 ; WX 791 ; N a71 ; B 35 -14 757 705 ; +C 109 ; WX 873 ; N a72 ; B 35 -14 838 705 ; +C 110 ; WX 761 ; N a73 ; B 35 0 726 692 ; +C 111 ; WX 762 ; N a74 ; B 35 0 727 692 ; +C 112 ; WX 762 ; N a203 ; B 35 0 727 692 ; +C 113 ; WX 759 ; N a75 ; B 35 0 725 692 ; +C 114 ; WX 759 ; N a204 ; B 35 0 725 692 ; +C 115 ; WX 892 ; N a76 ; B 35 0 858 705 ; +C 116 ; WX 892 ; N a77 ; B 35 -14 858 692 ; +C 117 ; WX 788 ; N a78 ; B 35 -14 754 705 ; +C 118 ; WX 784 ; N a79 ; B 35 -14 749 705 ; +C 119 ; WX 438 ; N a81 ; B 35 -14 403 705 ; +C 120 ; WX 138 ; N a82 ; B 35 0 104 692 ; +C 121 ; WX 277 ; N a83 ; B 35 0 242 692 ; +C 122 ; WX 415 ; N a84 ; B 35 0 380 692 ; +C 123 ; WX 392 ; N a97 ; B 35 263 357 705 ; +C 124 ; WX 392 ; N a98 ; B 34 263 357 705 ; +C 125 ; WX 668 ; N a99 ; B 35 263 633 705 ; +C 126 ; WX 668 ; N a100 ; B 36 263 634 705 ; +C 161 ; WX 732 ; N a101 ; B 35 -143 697 806 ; +C 162 ; WX 544 ; N a102 ; B 56 -14 488 706 ; +C 163 ; WX 544 ; N a103 ; B 34 -14 508 705 ; +C 164 ; WX 910 ; N a104 ; B 35 40 875 651 ; +C 165 ; WX 667 ; N a106 ; B 35 -14 633 705 ; +C 166 ; WX 760 ; N a107 ; B 35 -14 726 705 ; +C 167 ; WX 760 ; N a108 ; B 0 121 758 569 ; +C 168 ; WX 776 ; N a112 ; B 35 0 741 705 ; +C 169 ; WX 595 ; N a111 ; B 34 -14 560 705 ; +C 170 ; WX 694 ; N a110 ; B 35 -14 659 705 ; +C 171 ; WX 626 ; N a109 ; B 34 0 591 705 ; +C 172 ; WX 788 ; N a120 ; B 35 -14 754 705 ; +C 173 ; WX 788 ; N a121 ; B 35 -14 754 705 ; +C 174 ; WX 788 ; N a122 ; B 35 -14 754 705 ; +C 175 ; WX 788 ; N a123 ; B 35 -14 754 705 ; +C 176 ; WX 788 ; N a124 ; B 35 -14 754 705 ; +C 177 ; WX 788 ; N a125 ; B 35 -14 754 705 ; +C 178 ; WX 788 ; N a126 ; B 35 -14 754 705 ; +C 179 ; WX 788 ; N a127 ; B 35 -14 754 705 ; +C 180 ; WX 788 ; N a128 ; B 35 -14 754 705 ; +C 181 ; WX 788 ; N a129 ; B 35 -14 754 705 ; +C 182 ; WX 788 ; N a130 ; B 35 -14 754 705 ; +C 183 ; WX 788 ; N a131 ; B 35 -14 754 705 ; +C 184 ; WX 788 ; N a132 ; B 35 -14 754 705 ; +C 185 ; WX 788 ; N a133 ; B 35 -14 754 705 ; +C 186 ; WX 788 ; N a134 ; B 35 -14 754 705 ; +C 187 ; WX 788 ; N a135 ; B 35 -14 754 705 ; +C 188 ; WX 788 ; N a136 ; B 35 -14 754 705 ; +C 189 ; WX 788 ; N a137 ; B 35 -14 754 705 ; +C 190 ; WX 788 ; N a138 ; B 35 -14 754 705 ; +C 191 ; WX 788 ; N a139 ; B 35 -14 754 705 ; +C 192 ; WX 788 ; N a140 ; B 35 -14 754 705 ; +C 193 ; WX 788 ; N a141 ; B 35 -14 754 705 ; +C 194 ; WX 788 ; N a142 ; B 35 -14 754 705 ; +C 195 ; WX 788 ; N a143 ; B 35 -14 754 705 ; +C 196 ; WX 788 ; N a144 ; B 35 -14 754 705 ; +C 197 ; WX 788 ; N a145 ; B 35 -14 754 705 ; +C 198 ; WX 788 ; N a146 ; B 35 -14 754 705 ; +C 199 ; WX 788 ; N a147 ; B 35 -14 754 705 ; +C 200 ; WX 788 ; N a148 ; B 35 -14 754 705 ; +C 201 ; WX 788 ; N a149 ; B 35 -14 754 705 ; +C 202 ; WX 788 ; N a150 ; B 35 -14 754 705 ; +C 203 ; WX 788 ; N a151 ; B 35 -14 754 705 ; +C 204 ; WX 788 ; N a152 ; B 35 -14 754 705 ; +C 205 ; WX 788 ; N a153 ; B 35 -14 754 705 ; +C 206 ; WX 788 ; N a154 ; B 35 -14 754 705 ; +C 207 ; WX 788 ; N a155 ; B 35 -14 754 705 ; +C 208 ; WX 788 ; N a156 ; B 35 -14 754 705 ; +C 209 ; WX 788 ; N a157 ; B 35 -14 754 705 ; +C 210 ; WX 788 ; N a158 ; B 35 -14 754 705 ; +C 211 ; WX 788 ; N a159 ; B 35 -14 754 705 ; +C 212 ; WX 894 ; N a160 ; B 35 58 860 634 ; +C 213 ; WX 838 ; N a161 ; B 35 152 803 540 ; +C 214 ; WX 1016 ; N a163 ; B 34 152 981 540 ; +C 215 ; WX 458 ; N a164 ; B 35 -127 422 820 ; +C 216 ; WX 748 ; N a196 ; B 35 94 698 597 ; +C 217 ; WX 924 ; N a165 ; B 35 140 890 552 ; +C 218 ; WX 748 ; N a192 ; B 35 94 698 597 ; +C 219 ; WX 918 ; N a166 ; B 35 166 884 526 ; +C 220 ; WX 927 ; N a167 ; B 35 32 892 660 ; +C 221 ; WX 928 ; N a168 ; B 35 129 891 562 ; +C 222 ; WX 928 ; N a169 ; B 35 128 893 563 ; +C 223 ; WX 834 ; N a170 ; B 35 155 799 537 ; +C 224 ; WX 873 ; N a171 ; B 35 93 838 599 ; +C 225 ; WX 828 ; N a172 ; B 35 104 791 588 ; +C 226 ; WX 924 ; N a173 ; B 35 98 889 594 ; +C 227 ; WX 924 ; N a162 ; B 35 98 889 594 ; +C 228 ; WX 917 ; N a174 ; B 35 0 882 692 ; +C 229 ; WX 930 ; N a175 ; B 35 84 896 608 ; +C 230 ; WX 931 ; N a176 ; B 35 84 896 608 ; +C 231 ; WX 463 ; N a177 ; B 35 -99 429 791 ; +C 232 ; WX 883 ; N a178 ; B 35 71 848 623 ; +C 233 ; WX 836 ; N a179 ; B 35 44 802 648 ; +C 234 ; WX 836 ; N a193 ; B 35 44 802 648 ; +C 235 ; WX 867 ; N a180 ; B 35 101 832 591 ; +C 236 ; WX 867 ; N a199 ; B 35 101 832 591 ; +C 237 ; WX 696 ; N a181 ; B 35 44 661 648 ; +C 238 ; WX 696 ; N a200 ; B 35 44 661 648 ; +C 239 ; WX 874 ; N a182 ; B 35 77 840 619 ; +C 241 ; WX 874 ; N a201 ; B 35 73 840 615 ; +C 242 ; WX 760 ; N a183 ; B 35 0 725 692 ; +C 243 ; WX 946 ; N a184 ; B 35 160 911 533 ; +C 244 ; WX 771 ; N a197 ; B 34 37 736 655 ; +C 245 ; WX 865 ; N a185 ; B 35 207 830 481 ; +C 246 ; WX 771 ; N a194 ; B 34 37 736 655 ; +C 247 ; WX 888 ; N a198 ; B 34 -19 853 712 ; +C 248 ; WX 967 ; N a186 ; B 35 124 932 568 ; +C 249 ; WX 888 ; N a195 ; B 34 -19 853 712 ; +C 250 ; WX 831 ; N a187 ; B 35 113 796 579 ; +C 251 ; WX 873 ; N a188 ; B 36 118 838 578 ; +C 252 ; WX 927 ; N a189 ; B 35 150 891 542 ; +C 253 ; WX 970 ; N a190 ; B 35 76 931 616 ; +C 254 ; WX 918 ; N a191 ; B 34 99 884 593 ; +C -1 ; WX 410 ; N a86 ; B 35 0 375 692 ; +C -1 ; WX 509 ; N a85 ; B 35 0 475 692 ; +C -1 ; WX 334 ; N a95 ; B 35 0 299 692 ; +C -1 ; WX 509 ; N a205 ; B 35 0 475 692 ; +C -1 ; WX 390 ; N a89 ; B 35 -14 356 705 ; +C -1 ; WX 234 ; N a87 ; B 35 -14 199 705 ; +C -1 ; WX 276 ; N a91 ; B 35 0 242 692 ; +C -1 ; WX 390 ; N a90 ; B 35 -14 355 705 ; +C -1 ; WX 410 ; N a206 ; B 35 0 375 692 ; +C -1 ; WX 317 ; N a94 ; B 35 0 283 692 ; +C -1 ; WX 317 ; N a93 ; B 35 0 283 692 ; +C -1 ; WX 276 ; N a92 ; B 35 0 242 692 ; +C -1 ; WX 334 ; N a96 ; B 35 0 299 692 ; +C -1 ; WX 234 ; N a88 ; B 35 -14 199 705 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Bold.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Bold.afm new file mode 100644 index 00000000..eb80542b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Bold.afm @@ -0,0 +1,342 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jun 23 16:28:00 1997 +Comment UniqueID 43048 +Comment VMusage 41139 52164 +FontName Courier-Bold +FullName Courier Bold +FamilyName Courier +Weight Bold +ItalicAngle 0 +IsFixedPitch true +CharacterSet ExtendedRoman +FontBBox -113 -250 749 801 +UnderlinePosition -100 +UnderlineThickness 50 +Version 003.000 +Notice Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 439 +Ascender 629 +Descender -157 +StdHW 84 +StdVW 106 +StartCharMetrics 315 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 202 -15 398 572 ; +C 34 ; WX 600 ; N quotedbl ; B 135 277 465 562 ; +C 35 ; WX 600 ; N numbersign ; B 56 -45 544 651 ; +C 36 ; WX 600 ; N dollar ; B 82 -126 519 666 ; +C 37 ; WX 600 ; N percent ; B 5 -15 595 616 ; +C 38 ; WX 600 ; N ampersand ; B 36 -15 546 543 ; +C 39 ; WX 600 ; N quoteright ; B 171 277 423 562 ; +C 40 ; WX 600 ; N parenleft ; B 219 -102 461 616 ; +C 41 ; WX 600 ; N parenright ; B 139 -102 381 616 ; +C 42 ; WX 600 ; N asterisk ; B 91 219 509 601 ; +C 43 ; WX 600 ; N plus ; B 71 39 529 478 ; +C 44 ; WX 600 ; N comma ; B 123 -111 393 174 ; +C 45 ; WX 600 ; N hyphen ; B 100 203 500 313 ; +C 46 ; WX 600 ; N period ; B 192 -15 408 171 ; +C 47 ; WX 600 ; N slash ; B 98 -77 502 626 ; +C 48 ; WX 600 ; N zero ; B 87 -15 513 616 ; +C 49 ; WX 600 ; N one ; B 81 0 539 616 ; +C 50 ; WX 600 ; N two ; B 61 0 499 616 ; +C 51 ; WX 600 ; N three ; B 63 -15 501 616 ; +C 52 ; WX 600 ; N four ; B 53 0 507 616 ; +C 53 ; WX 600 ; N five ; B 70 -15 521 601 ; +C 54 ; WX 600 ; N six ; B 90 -15 521 616 ; +C 55 ; WX 600 ; N seven ; B 55 0 494 601 ; +C 56 ; WX 600 ; N eight ; B 83 -15 517 616 ; +C 57 ; WX 600 ; N nine ; B 79 -15 510 616 ; +C 58 ; WX 600 ; N colon ; B 191 -15 407 425 ; +C 59 ; WX 600 ; N semicolon ; B 123 -111 408 425 ; +C 60 ; WX 600 ; N less ; B 66 15 523 501 ; +C 61 ; WX 600 ; N equal ; B 71 118 529 398 ; +C 62 ; WX 600 ; N greater ; B 77 15 534 501 ; +C 63 ; WX 600 ; N question ; B 98 -14 501 580 ; +C 64 ; WX 600 ; N at ; B 16 -15 584 616 ; +C 65 ; WX 600 ; N A ; B -9 0 609 562 ; +C 66 ; WX 600 ; N B ; B 30 0 573 562 ; +C 67 ; WX 600 ; N C ; B 22 -18 560 580 ; +C 68 ; WX 600 ; N D ; B 30 0 594 562 ; +C 69 ; WX 600 ; N E ; B 25 0 560 562 ; +C 70 ; WX 600 ; N F ; B 39 0 570 562 ; +C 71 ; WX 600 ; N G ; B 22 -18 594 580 ; +C 72 ; WX 600 ; N H ; B 20 0 580 562 ; +C 73 ; WX 600 ; N I ; B 77 0 523 562 ; +C 74 ; WX 600 ; N J ; B 37 -18 601 562 ; +C 75 ; WX 600 ; N K ; B 21 0 599 562 ; +C 76 ; WX 600 ; N L ; B 39 0 578 562 ; +C 77 ; WX 600 ; N M ; B -2 0 602 562 ; +C 78 ; WX 600 ; N N ; B 8 -12 610 562 ; +C 79 ; WX 600 ; N O ; B 22 -18 578 580 ; +C 80 ; WX 600 ; N P ; B 48 0 559 562 ; +C 81 ; WX 600 ; N Q ; B 32 -138 578 580 ; +C 82 ; WX 600 ; N R ; B 24 0 599 562 ; +C 83 ; WX 600 ; N S ; B 47 -22 553 582 ; +C 84 ; WX 600 ; N T ; B 21 0 579 562 ; +C 85 ; WX 600 ; N U ; B 4 -18 596 562 ; +C 86 ; WX 600 ; N V ; B -13 0 613 562 ; +C 87 ; WX 600 ; N W ; B -18 0 618 562 ; +C 88 ; WX 600 ; N X ; B 12 0 588 562 ; +C 89 ; WX 600 ; N Y ; B 12 0 589 562 ; +C 90 ; WX 600 ; N Z ; B 62 0 539 562 ; +C 91 ; WX 600 ; N bracketleft ; B 245 -102 475 616 ; +C 92 ; WX 600 ; N backslash ; B 99 -77 503 626 ; +C 93 ; WX 600 ; N bracketright ; B 125 -102 355 616 ; +C 94 ; WX 600 ; N asciicircum ; B 108 250 492 616 ; +C 95 ; WX 600 ; N underscore ; B 0 -125 600 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 178 277 428 562 ; +C 97 ; WX 600 ; N a ; B 35 -15 570 454 ; +C 98 ; WX 600 ; N b ; B 0 -15 584 626 ; +C 99 ; WX 600 ; N c ; B 40 -15 545 459 ; +C 100 ; WX 600 ; N d ; B 20 -15 591 626 ; +C 101 ; WX 600 ; N e ; B 40 -15 563 454 ; +C 102 ; WX 600 ; N f ; B 83 0 547 626 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 30 -146 580 454 ; +C 104 ; WX 600 ; N h ; B 5 0 592 626 ; +C 105 ; WX 600 ; N i ; B 77 0 523 658 ; +C 106 ; WX 600 ; N j ; B 63 -146 440 658 ; +C 107 ; WX 600 ; N k ; B 20 0 585 626 ; +C 108 ; WX 600 ; N l ; B 77 0 523 626 ; +C 109 ; WX 600 ; N m ; B -22 0 626 454 ; +C 110 ; WX 600 ; N n ; B 18 0 592 454 ; +C 111 ; WX 600 ; N o ; B 30 -15 570 454 ; +C 112 ; WX 600 ; N p ; B -1 -142 570 454 ; +C 113 ; WX 600 ; N q ; B 20 -142 591 454 ; +C 114 ; WX 600 ; N r ; B 47 0 580 454 ; +C 115 ; WX 600 ; N s ; B 68 -17 535 459 ; +C 116 ; WX 600 ; N t ; B 47 -15 532 562 ; +C 117 ; WX 600 ; N u ; B -1 -15 569 439 ; +C 118 ; WX 600 ; N v ; B -1 0 601 439 ; +C 119 ; WX 600 ; N w ; B -18 0 618 439 ; +C 120 ; WX 600 ; N x ; B 6 0 594 439 ; +C 121 ; WX 600 ; N y ; B -4 -142 601 439 ; +C 122 ; WX 600 ; N z ; B 81 0 520 439 ; +C 123 ; WX 600 ; N braceleft ; B 160 -102 464 616 ; +C 124 ; WX 600 ; N bar ; B 255 -250 345 750 ; +C 125 ; WX 600 ; N braceright ; B 136 -102 440 616 ; +C 126 ; WX 600 ; N asciitilde ; B 71 153 530 356 ; +C 161 ; WX 600 ; N exclamdown ; B 202 -146 398 449 ; +C 162 ; WX 600 ; N cent ; B 66 -49 518 614 ; +C 163 ; WX 600 ; N sterling ; B 72 -28 558 611 ; +C 164 ; WX 600 ; N fraction ; B 25 -60 576 661 ; +C 165 ; WX 600 ; N yen ; B 10 0 590 562 ; +C 166 ; WX 600 ; N florin ; B -30 -131 572 616 ; +C 167 ; WX 600 ; N section ; B 83 -70 517 580 ; +C 168 ; WX 600 ; N currency ; B 54 49 546 517 ; +C 169 ; WX 600 ; N quotesingle ; B 227 277 373 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 71 277 535 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 8 70 553 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 141 70 459 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 141 70 459 446 ; +C 174 ; WX 600 ; N fi ; B 12 0 593 626 ; +C 175 ; WX 600 ; N fl ; B 12 0 593 626 ; +C 177 ; WX 600 ; N endash ; B 65 203 535 313 ; +C 178 ; WX 600 ; N dagger ; B 106 -70 494 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 106 -70 494 580 ; +C 180 ; WX 600 ; N periodcentered ; B 196 165 404 351 ; +C 182 ; WX 600 ; N paragraph ; B 6 -70 576 580 ; +C 183 ; WX 600 ; N bullet ; B 140 132 460 430 ; +C 184 ; WX 600 ; N quotesinglbase ; B 175 -142 427 143 ; +C 185 ; WX 600 ; N quotedblbase ; B 65 -142 529 143 ; +C 186 ; WX 600 ; N quotedblright ; B 61 277 525 562 ; +C 187 ; WX 600 ; N guillemotright ; B 47 70 592 446 ; +C 188 ; WX 600 ; N ellipsis ; B 26 -15 574 116 ; +C 189 ; WX 600 ; N perthousand ; B -113 -15 713 616 ; +C 191 ; WX 600 ; N questiondown ; B 99 -146 502 449 ; +C 193 ; WX 600 ; N grave ; B 132 508 395 661 ; +C 194 ; WX 600 ; N acute ; B 205 508 468 661 ; +C 195 ; WX 600 ; N circumflex ; B 103 483 497 657 ; +C 196 ; WX 600 ; N tilde ; B 89 493 512 636 ; +C 197 ; WX 600 ; N macron ; B 88 505 512 585 ; +C 198 ; WX 600 ; N breve ; B 83 468 517 631 ; +C 199 ; WX 600 ; N dotaccent ; B 230 498 370 638 ; +C 200 ; WX 600 ; N dieresis ; B 128 498 472 638 ; +C 202 ; WX 600 ; N ring ; B 198 481 402 678 ; +C 203 ; WX 600 ; N cedilla ; B 205 -206 387 0 ; +C 205 ; WX 600 ; N hungarumlaut ; B 68 488 588 661 ; +C 206 ; WX 600 ; N ogonek ; B 169 -199 400 0 ; +C 207 ; WX 600 ; N caron ; B 103 493 497 667 ; +C 208 ; WX 600 ; N emdash ; B -10 203 610 313 ; +C 225 ; WX 600 ; N AE ; B -29 0 602 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 147 196 453 580 ; +C 232 ; WX 600 ; N Lslash ; B 39 0 578 562 ; +C 233 ; WX 600 ; N Oslash ; B 22 -22 578 584 ; +C 234 ; WX 600 ; N OE ; B -25 0 595 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 147 196 453 580 ; +C 241 ; WX 600 ; N ae ; B -4 -15 601 454 ; +C 245 ; WX 600 ; N dotlessi ; B 77 0 523 439 ; +C 248 ; WX 600 ; N lslash ; B 77 0 523 626 ; +C 249 ; WX 600 ; N oslash ; B 30 -24 570 463 ; +C 250 ; WX 600 ; N oe ; B -18 -15 611 454 ; +C 251 ; WX 600 ; N germandbls ; B 22 -15 596 626 ; +C -1 ; WX 600 ; N Idieresis ; B 77 0 523 761 ; +C -1 ; WX 600 ; N eacute ; B 40 -15 563 661 ; +C -1 ; WX 600 ; N abreve ; B 35 -15 570 661 ; +C -1 ; WX 600 ; N uhungarumlaut ; B -1 -15 628 661 ; +C -1 ; WX 600 ; N ecaron ; B 40 -15 563 667 ; +C -1 ; WX 600 ; N Ydieresis ; B 12 0 589 761 ; +C -1 ; WX 600 ; N divide ; B 71 16 529 500 ; +C -1 ; WX 600 ; N Yacute ; B 12 0 589 784 ; +C -1 ; WX 600 ; N Acircumflex ; B -9 0 609 780 ; +C -1 ; WX 600 ; N aacute ; B 35 -15 570 661 ; +C -1 ; WX 600 ; N Ucircumflex ; B 4 -18 596 780 ; +C -1 ; WX 600 ; N yacute ; B -4 -142 601 661 ; +C -1 ; WX 600 ; N scommaaccent ; B 68 -250 535 459 ; +C -1 ; WX 600 ; N ecircumflex ; B 40 -15 563 657 ; +C -1 ; WX 600 ; N Uring ; B 4 -18 596 801 ; +C -1 ; WX 600 ; N Udieresis ; B 4 -18 596 761 ; +C -1 ; WX 600 ; N aogonek ; B 35 -199 586 454 ; +C -1 ; WX 600 ; N Uacute ; B 4 -18 596 784 ; +C -1 ; WX 600 ; N uogonek ; B -1 -199 585 439 ; +C -1 ; WX 600 ; N Edieresis ; B 25 0 560 761 ; +C -1 ; WX 600 ; N Dcroat ; B 30 0 594 562 ; +C -1 ; WX 600 ; N commaaccent ; B 205 -250 397 -57 ; +C -1 ; WX 600 ; N copyright ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N Emacron ; B 25 0 560 708 ; +C -1 ; WX 600 ; N ccaron ; B 40 -15 545 667 ; +C -1 ; WX 600 ; N aring ; B 35 -15 570 678 ; +C -1 ; WX 600 ; N Ncommaaccent ; B 8 -250 610 562 ; +C -1 ; WX 600 ; N lacute ; B 77 0 523 801 ; +C -1 ; WX 600 ; N agrave ; B 35 -15 570 661 ; +C -1 ; WX 600 ; N Tcommaaccent ; B 21 -250 579 562 ; +C -1 ; WX 600 ; N Cacute ; B 22 -18 560 784 ; +C -1 ; WX 600 ; N atilde ; B 35 -15 570 636 ; +C -1 ; WX 600 ; N Edotaccent ; B 25 0 560 761 ; +C -1 ; WX 600 ; N scaron ; B 68 -17 535 667 ; +C -1 ; WX 600 ; N scedilla ; B 68 -206 535 459 ; +C -1 ; WX 600 ; N iacute ; B 77 0 523 661 ; +C -1 ; WX 600 ; N lozenge ; B 66 0 534 740 ; +C -1 ; WX 600 ; N Rcaron ; B 24 0 599 790 ; +C -1 ; WX 600 ; N Gcommaaccent ; B 22 -250 594 580 ; +C -1 ; WX 600 ; N ucircumflex ; B -1 -15 569 657 ; +C -1 ; WX 600 ; N acircumflex ; B 35 -15 570 657 ; +C -1 ; WX 600 ; N Amacron ; B -9 0 609 708 ; +C -1 ; WX 600 ; N rcaron ; B 47 0 580 667 ; +C -1 ; WX 600 ; N ccedilla ; B 40 -206 545 459 ; +C -1 ; WX 600 ; N Zdotaccent ; B 62 0 539 761 ; +C -1 ; WX 600 ; N Thorn ; B 48 0 557 562 ; +C -1 ; WX 600 ; N Omacron ; B 22 -18 578 708 ; +C -1 ; WX 600 ; N Racute ; B 24 0 599 784 ; +C -1 ; WX 600 ; N Sacute ; B 47 -22 553 784 ; +C -1 ; WX 600 ; N dcaron ; B 20 -15 727 626 ; +C -1 ; WX 600 ; N Umacron ; B 4 -18 596 708 ; +C -1 ; WX 600 ; N uring ; B -1 -15 569 678 ; +C -1 ; WX 600 ; N threesuperior ; B 138 222 433 616 ; +C -1 ; WX 600 ; N Ograve ; B 22 -18 578 784 ; +C -1 ; WX 600 ; N Agrave ; B -9 0 609 784 ; +C -1 ; WX 600 ; N Abreve ; B -9 0 609 784 ; +C -1 ; WX 600 ; N multiply ; B 81 39 520 478 ; +C -1 ; WX 600 ; N uacute ; B -1 -15 569 661 ; +C -1 ; WX 600 ; N Tcaron ; B 21 0 579 790 ; +C -1 ; WX 600 ; N partialdiff ; B 63 -38 537 728 ; +C -1 ; WX 600 ; N ydieresis ; B -4 -142 601 638 ; +C -1 ; WX 600 ; N Nacute ; B 8 -12 610 784 ; +C -1 ; WX 600 ; N icircumflex ; B 73 0 523 657 ; +C -1 ; WX 600 ; N Ecircumflex ; B 25 0 560 780 ; +C -1 ; WX 600 ; N adieresis ; B 35 -15 570 638 ; +C -1 ; WX 600 ; N edieresis ; B 40 -15 563 638 ; +C -1 ; WX 600 ; N cacute ; B 40 -15 545 661 ; +C -1 ; WX 600 ; N nacute ; B 18 0 592 661 ; +C -1 ; WX 600 ; N umacron ; B -1 -15 569 585 ; +C -1 ; WX 600 ; N Ncaron ; B 8 -12 610 790 ; +C -1 ; WX 600 ; N Iacute ; B 77 0 523 784 ; +C -1 ; WX 600 ; N plusminus ; B 71 24 529 515 ; +C -1 ; WX 600 ; N brokenbar ; B 255 -175 345 675 ; +C -1 ; WX 600 ; N registered ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N Gbreve ; B 22 -18 594 784 ; +C -1 ; WX 600 ; N Idotaccent ; B 77 0 523 761 ; +C -1 ; WX 600 ; N summation ; B 15 -10 586 706 ; +C -1 ; WX 600 ; N Egrave ; B 25 0 560 784 ; +C -1 ; WX 600 ; N racute ; B 47 0 580 661 ; +C -1 ; WX 600 ; N omacron ; B 30 -15 570 585 ; +C -1 ; WX 600 ; N Zacute ; B 62 0 539 784 ; +C -1 ; WX 600 ; N Zcaron ; B 62 0 539 790 ; +C -1 ; WX 600 ; N greaterequal ; B 26 0 523 696 ; +C -1 ; WX 600 ; N Eth ; B 30 0 594 562 ; +C -1 ; WX 600 ; N Ccedilla ; B 22 -206 560 580 ; +C -1 ; WX 600 ; N lcommaaccent ; B 77 -250 523 626 ; +C -1 ; WX 600 ; N tcaron ; B 47 -15 532 703 ; +C -1 ; WX 600 ; N eogonek ; B 40 -199 563 454 ; +C -1 ; WX 600 ; N Uogonek ; B 4 -199 596 562 ; +C -1 ; WX 600 ; N Aacute ; B -9 0 609 784 ; +C -1 ; WX 600 ; N Adieresis ; B -9 0 609 761 ; +C -1 ; WX 600 ; N egrave ; B 40 -15 563 661 ; +C -1 ; WX 600 ; N zacute ; B 81 0 520 661 ; +C -1 ; WX 600 ; N iogonek ; B 77 -199 523 658 ; +C -1 ; WX 600 ; N Oacute ; B 22 -18 578 784 ; +C -1 ; WX 600 ; N oacute ; B 30 -15 570 661 ; +C -1 ; WX 600 ; N amacron ; B 35 -15 570 585 ; +C -1 ; WX 600 ; N sacute ; B 68 -17 535 661 ; +C -1 ; WX 600 ; N idieresis ; B 77 0 523 618 ; +C -1 ; WX 600 ; N Ocircumflex ; B 22 -18 578 780 ; +C -1 ; WX 600 ; N Ugrave ; B 4 -18 596 784 ; +C -1 ; WX 600 ; N Delta ; B 6 0 594 688 ; +C -1 ; WX 600 ; N thorn ; B -14 -142 570 626 ; +C -1 ; WX 600 ; N twosuperior ; B 143 230 436 616 ; +C -1 ; WX 600 ; N Odieresis ; B 22 -18 578 761 ; +C -1 ; WX 600 ; N mu ; B -1 -142 569 439 ; +C -1 ; WX 600 ; N igrave ; B 77 0 523 661 ; +C -1 ; WX 600 ; N ohungarumlaut ; B 30 -15 668 661 ; +C -1 ; WX 600 ; N Eogonek ; B 25 -199 576 562 ; +C -1 ; WX 600 ; N dcroat ; B 20 -15 591 626 ; +C -1 ; WX 600 ; N threequarters ; B -47 -60 648 661 ; +C -1 ; WX 600 ; N Scedilla ; B 47 -206 553 582 ; +C -1 ; WX 600 ; N lcaron ; B 77 0 597 626 ; +C -1 ; WX 600 ; N Kcommaaccent ; B 21 -250 599 562 ; +C -1 ; WX 600 ; N Lacute ; B 39 0 578 784 ; +C -1 ; WX 600 ; N trademark ; B -9 230 749 562 ; +C -1 ; WX 600 ; N edotaccent ; B 40 -15 563 638 ; +C -1 ; WX 600 ; N Igrave ; B 77 0 523 784 ; +C -1 ; WX 600 ; N Imacron ; B 77 0 523 708 ; +C -1 ; WX 600 ; N Lcaron ; B 39 0 637 562 ; +C -1 ; WX 600 ; N onehalf ; B -47 -60 648 661 ; +C -1 ; WX 600 ; N lessequal ; B 26 0 523 696 ; +C -1 ; WX 600 ; N ocircumflex ; B 30 -15 570 657 ; +C -1 ; WX 600 ; N ntilde ; B 18 0 592 636 ; +C -1 ; WX 600 ; N Uhungarumlaut ; B 4 -18 638 784 ; +C -1 ; WX 600 ; N Eacute ; B 25 0 560 784 ; +C -1 ; WX 600 ; N emacron ; B 40 -15 563 585 ; +C -1 ; WX 600 ; N gbreve ; B 30 -146 580 661 ; +C -1 ; WX 600 ; N onequarter ; B -56 -60 656 661 ; +C -1 ; WX 600 ; N Scaron ; B 47 -22 553 790 ; +C -1 ; WX 600 ; N Scommaaccent ; B 47 -250 553 582 ; +C -1 ; WX 600 ; N Ohungarumlaut ; B 22 -18 628 784 ; +C -1 ; WX 600 ; N degree ; B 86 243 474 616 ; +C -1 ; WX 600 ; N ograve ; B 30 -15 570 661 ; +C -1 ; WX 600 ; N Ccaron ; B 22 -18 560 790 ; +C -1 ; WX 600 ; N ugrave ; B -1 -15 569 661 ; +C -1 ; WX 600 ; N radical ; B -19 -104 473 778 ; +C -1 ; WX 600 ; N Dcaron ; B 30 0 594 790 ; +C -1 ; WX 600 ; N rcommaaccent ; B 47 -250 580 454 ; +C -1 ; WX 600 ; N Ntilde ; B 8 -12 610 759 ; +C -1 ; WX 600 ; N otilde ; B 30 -15 570 636 ; +C -1 ; WX 600 ; N Rcommaaccent ; B 24 -250 599 562 ; +C -1 ; WX 600 ; N Lcommaaccent ; B 39 -250 578 562 ; +C -1 ; WX 600 ; N Atilde ; B -9 0 609 759 ; +C -1 ; WX 600 ; N Aogonek ; B -9 -199 625 562 ; +C -1 ; WX 600 ; N Aring ; B -9 0 609 801 ; +C -1 ; WX 600 ; N Otilde ; B 22 -18 578 759 ; +C -1 ; WX 600 ; N zdotaccent ; B 81 0 520 638 ; +C -1 ; WX 600 ; N Ecaron ; B 25 0 560 790 ; +C -1 ; WX 600 ; N Iogonek ; B 77 -199 523 562 ; +C -1 ; WX 600 ; N kcommaaccent ; B 20 -250 585 626 ; +C -1 ; WX 600 ; N minus ; B 71 203 529 313 ; +C -1 ; WX 600 ; N Icircumflex ; B 77 0 523 780 ; +C -1 ; WX 600 ; N ncaron ; B 18 0 592 667 ; +C -1 ; WX 600 ; N tcommaaccent ; B 47 -250 532 562 ; +C -1 ; WX 600 ; N logicalnot ; B 71 103 529 413 ; +C -1 ; WX 600 ; N odieresis ; B 30 -15 570 638 ; +C -1 ; WX 600 ; N udieresis ; B -1 -15 569 638 ; +C -1 ; WX 600 ; N notequal ; B 12 -47 537 563 ; +C -1 ; WX 600 ; N gcommaaccent ; B 30 -146 580 714 ; +C -1 ; WX 600 ; N eth ; B 58 -27 543 626 ; +C -1 ; WX 600 ; N zcaron ; B 81 0 520 667 ; +C -1 ; WX 600 ; N ncommaaccent ; B 18 -250 592 454 ; +C -1 ; WX 600 ; N onesuperior ; B 153 230 447 616 ; +C -1 ; WX 600 ; N imacron ; B 77 0 523 585 ; +C -1 ; WX 600 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-BoldOblique.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-BoldOblique.afm new file mode 100644 index 00000000..29d3b8b1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-BoldOblique.afm @@ -0,0 +1,342 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Mon Jun 23 16:28:46 1997 +Comment UniqueID 43049 +Comment VMusage 17529 79244 +FontName Courier-BoldOblique +FullName Courier Bold Oblique +FamilyName Courier +Weight Bold +ItalicAngle -12 +IsFixedPitch true +CharacterSet ExtendedRoman +FontBBox -57 -250 869 801 +UnderlinePosition -100 +UnderlineThickness 50 +Version 003.000 +Notice Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 439 +Ascender 629 +Descender -157 +StdHW 84 +StdVW 106 +StartCharMetrics 315 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 215 -15 495 572 ; +C 34 ; WX 600 ; N quotedbl ; B 211 277 585 562 ; +C 35 ; WX 600 ; N numbersign ; B 88 -45 641 651 ; +C 36 ; WX 600 ; N dollar ; B 87 -126 630 666 ; +C 37 ; WX 600 ; N percent ; B 101 -15 625 616 ; +C 38 ; WX 600 ; N ampersand ; B 61 -15 595 543 ; +C 39 ; WX 600 ; N quoteright ; B 229 277 543 562 ; +C 40 ; WX 600 ; N parenleft ; B 265 -102 592 616 ; +C 41 ; WX 600 ; N parenright ; B 117 -102 444 616 ; +C 42 ; WX 600 ; N asterisk ; B 179 219 598 601 ; +C 43 ; WX 600 ; N plus ; B 114 39 596 478 ; +C 44 ; WX 600 ; N comma ; B 99 -111 430 174 ; +C 45 ; WX 600 ; N hyphen ; B 143 203 567 313 ; +C 46 ; WX 600 ; N period ; B 206 -15 427 171 ; +C 47 ; WX 600 ; N slash ; B 90 -77 626 626 ; +C 48 ; WX 600 ; N zero ; B 135 -15 593 616 ; +C 49 ; WX 600 ; N one ; B 93 0 562 616 ; +C 50 ; WX 600 ; N two ; B 61 0 594 616 ; +C 51 ; WX 600 ; N three ; B 71 -15 571 616 ; +C 52 ; WX 600 ; N four ; B 81 0 559 616 ; +C 53 ; WX 600 ; N five ; B 77 -15 621 601 ; +C 54 ; WX 600 ; N six ; B 135 -15 652 616 ; +C 55 ; WX 600 ; N seven ; B 147 0 622 601 ; +C 56 ; WX 600 ; N eight ; B 115 -15 604 616 ; +C 57 ; WX 600 ; N nine ; B 75 -15 592 616 ; +C 58 ; WX 600 ; N colon ; B 205 -15 480 425 ; +C 59 ; WX 600 ; N semicolon ; B 99 -111 481 425 ; +C 60 ; WX 600 ; N less ; B 120 15 613 501 ; +C 61 ; WX 600 ; N equal ; B 96 118 614 398 ; +C 62 ; WX 600 ; N greater ; B 97 15 589 501 ; +C 63 ; WX 600 ; N question ; B 183 -14 592 580 ; +C 64 ; WX 600 ; N at ; B 65 -15 642 616 ; +C 65 ; WX 600 ; N A ; B -9 0 632 562 ; +C 66 ; WX 600 ; N B ; B 30 0 630 562 ; +C 67 ; WX 600 ; N C ; B 74 -18 675 580 ; +C 68 ; WX 600 ; N D ; B 30 0 664 562 ; +C 69 ; WX 600 ; N E ; B 25 0 670 562 ; +C 70 ; WX 600 ; N F ; B 39 0 684 562 ; +C 71 ; WX 600 ; N G ; B 74 -18 675 580 ; +C 72 ; WX 600 ; N H ; B 20 0 700 562 ; +C 73 ; WX 600 ; N I ; B 77 0 643 562 ; +C 74 ; WX 600 ; N J ; B 58 -18 721 562 ; +C 75 ; WX 600 ; N K ; B 21 0 692 562 ; +C 76 ; WX 600 ; N L ; B 39 0 636 562 ; +C 77 ; WX 600 ; N M ; B -2 0 722 562 ; +C 78 ; WX 600 ; N N ; B 8 -12 730 562 ; +C 79 ; WX 600 ; N O ; B 74 -18 645 580 ; +C 80 ; WX 600 ; N P ; B 48 0 643 562 ; +C 81 ; WX 600 ; N Q ; B 83 -138 636 580 ; +C 82 ; WX 600 ; N R ; B 24 0 617 562 ; +C 83 ; WX 600 ; N S ; B 54 -22 673 582 ; +C 84 ; WX 600 ; N T ; B 86 0 679 562 ; +C 85 ; WX 600 ; N U ; B 101 -18 716 562 ; +C 86 ; WX 600 ; N V ; B 84 0 733 562 ; +C 87 ; WX 600 ; N W ; B 79 0 738 562 ; +C 88 ; WX 600 ; N X ; B 12 0 690 562 ; +C 89 ; WX 600 ; N Y ; B 109 0 709 562 ; +C 90 ; WX 600 ; N Z ; B 62 0 637 562 ; +C 91 ; WX 600 ; N bracketleft ; B 223 -102 606 616 ; +C 92 ; WX 600 ; N backslash ; B 222 -77 496 626 ; +C 93 ; WX 600 ; N bracketright ; B 103 -102 486 616 ; +C 94 ; WX 600 ; N asciicircum ; B 171 250 556 616 ; +C 95 ; WX 600 ; N underscore ; B -27 -125 585 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 297 277 487 562 ; +C 97 ; WX 600 ; N a ; B 61 -15 593 454 ; +C 98 ; WX 600 ; N b ; B 13 -15 636 626 ; +C 99 ; WX 600 ; N c ; B 81 -15 631 459 ; +C 100 ; WX 600 ; N d ; B 60 -15 645 626 ; +C 101 ; WX 600 ; N e ; B 81 -15 605 454 ; +C 102 ; WX 600 ; N f ; B 83 0 677 626 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 40 -146 674 454 ; +C 104 ; WX 600 ; N h ; B 18 0 615 626 ; +C 105 ; WX 600 ; N i ; B 77 0 546 658 ; +C 106 ; WX 600 ; N j ; B 36 -146 580 658 ; +C 107 ; WX 600 ; N k ; B 33 0 643 626 ; +C 108 ; WX 600 ; N l ; B 77 0 546 626 ; +C 109 ; WX 600 ; N m ; B -22 0 649 454 ; +C 110 ; WX 600 ; N n ; B 18 0 615 454 ; +C 111 ; WX 600 ; N o ; B 71 -15 622 454 ; +C 112 ; WX 600 ; N p ; B -32 -142 622 454 ; +C 113 ; WX 600 ; N q ; B 60 -142 685 454 ; +C 114 ; WX 600 ; N r ; B 47 0 655 454 ; +C 115 ; WX 600 ; N s ; B 66 -17 608 459 ; +C 116 ; WX 600 ; N t ; B 118 -15 567 562 ; +C 117 ; WX 600 ; N u ; B 70 -15 592 439 ; +C 118 ; WX 600 ; N v ; B 70 0 695 439 ; +C 119 ; WX 600 ; N w ; B 53 0 712 439 ; +C 120 ; WX 600 ; N x ; B 6 0 671 439 ; +C 121 ; WX 600 ; N y ; B -21 -142 695 439 ; +C 122 ; WX 600 ; N z ; B 81 0 614 439 ; +C 123 ; WX 600 ; N braceleft ; B 203 -102 595 616 ; +C 124 ; WX 600 ; N bar ; B 201 -250 505 750 ; +C 125 ; WX 600 ; N braceright ; B 114 -102 506 616 ; +C 126 ; WX 600 ; N asciitilde ; B 120 153 590 356 ; +C 161 ; WX 600 ; N exclamdown ; B 196 -146 477 449 ; +C 162 ; WX 600 ; N cent ; B 121 -49 605 614 ; +C 163 ; WX 600 ; N sterling ; B 106 -28 650 611 ; +C 164 ; WX 600 ; N fraction ; B 22 -60 708 661 ; +C 165 ; WX 600 ; N yen ; B 98 0 710 562 ; +C 166 ; WX 600 ; N florin ; B -57 -131 702 616 ; +C 167 ; WX 600 ; N section ; B 74 -70 620 580 ; +C 168 ; WX 600 ; N currency ; B 77 49 644 517 ; +C 169 ; WX 600 ; N quotesingle ; B 303 277 493 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 190 277 594 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 62 70 639 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 195 70 545 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 165 70 514 446 ; +C 174 ; WX 600 ; N fi ; B 12 0 644 626 ; +C 175 ; WX 600 ; N fl ; B 12 0 644 626 ; +C 177 ; WX 600 ; N endash ; B 108 203 602 313 ; +C 178 ; WX 600 ; N dagger ; B 175 -70 586 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 121 -70 587 580 ; +C 180 ; WX 600 ; N periodcentered ; B 248 165 461 351 ; +C 182 ; WX 600 ; N paragraph ; B 61 -70 700 580 ; +C 183 ; WX 600 ; N bullet ; B 196 132 523 430 ; +C 184 ; WX 600 ; N quotesinglbase ; B 144 -142 458 143 ; +C 185 ; WX 600 ; N quotedblbase ; B 34 -142 560 143 ; +C 186 ; WX 600 ; N quotedblright ; B 119 277 645 562 ; +C 187 ; WX 600 ; N guillemotright ; B 71 70 647 446 ; +C 188 ; WX 600 ; N ellipsis ; B 35 -15 587 116 ; +C 189 ; WX 600 ; N perthousand ; B -45 -15 743 616 ; +C 191 ; WX 600 ; N questiondown ; B 100 -146 509 449 ; +C 193 ; WX 600 ; N grave ; B 272 508 503 661 ; +C 194 ; WX 600 ; N acute ; B 312 508 609 661 ; +C 195 ; WX 600 ; N circumflex ; B 212 483 607 657 ; +C 196 ; WX 600 ; N tilde ; B 199 493 643 636 ; +C 197 ; WX 600 ; N macron ; B 195 505 637 585 ; +C 198 ; WX 600 ; N breve ; B 217 468 652 631 ; +C 199 ; WX 600 ; N dotaccent ; B 348 498 493 638 ; +C 200 ; WX 600 ; N dieresis ; B 246 498 595 638 ; +C 202 ; WX 600 ; N ring ; B 319 481 528 678 ; +C 203 ; WX 600 ; N cedilla ; B 168 -206 368 0 ; +C 205 ; WX 600 ; N hungarumlaut ; B 171 488 729 661 ; +C 206 ; WX 600 ; N ogonek ; B 143 -199 367 0 ; +C 207 ; WX 600 ; N caron ; B 238 493 633 667 ; +C 208 ; WX 600 ; N emdash ; B 33 203 677 313 ; +C 225 ; WX 600 ; N AE ; B -29 0 708 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 188 196 526 580 ; +C 232 ; WX 600 ; N Lslash ; B 39 0 636 562 ; +C 233 ; WX 600 ; N Oslash ; B 48 -22 673 584 ; +C 234 ; WX 600 ; N OE ; B 26 0 701 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 188 196 543 580 ; +C 241 ; WX 600 ; N ae ; B 21 -15 652 454 ; +C 245 ; WX 600 ; N dotlessi ; B 77 0 546 439 ; +C 248 ; WX 600 ; N lslash ; B 77 0 587 626 ; +C 249 ; WX 600 ; N oslash ; B 54 -24 638 463 ; +C 250 ; WX 600 ; N oe ; B 18 -15 662 454 ; +C 251 ; WX 600 ; N germandbls ; B 22 -15 629 626 ; +C -1 ; WX 600 ; N Idieresis ; B 77 0 643 761 ; +C -1 ; WX 600 ; N eacute ; B 81 -15 609 661 ; +C -1 ; WX 600 ; N abreve ; B 61 -15 658 661 ; +C -1 ; WX 600 ; N uhungarumlaut ; B 70 -15 769 661 ; +C -1 ; WX 600 ; N ecaron ; B 81 -15 633 667 ; +C -1 ; WX 600 ; N Ydieresis ; B 109 0 709 761 ; +C -1 ; WX 600 ; N divide ; B 114 16 596 500 ; +C -1 ; WX 600 ; N Yacute ; B 109 0 709 784 ; +C -1 ; WX 600 ; N Acircumflex ; B -9 0 632 780 ; +C -1 ; WX 600 ; N aacute ; B 61 -15 609 661 ; +C -1 ; WX 600 ; N Ucircumflex ; B 101 -18 716 780 ; +C -1 ; WX 600 ; N yacute ; B -21 -142 695 661 ; +C -1 ; WX 600 ; N scommaaccent ; B 66 -250 608 459 ; +C -1 ; WX 600 ; N ecircumflex ; B 81 -15 607 657 ; +C -1 ; WX 600 ; N Uring ; B 101 -18 716 801 ; +C -1 ; WX 600 ; N Udieresis ; B 101 -18 716 761 ; +C -1 ; WX 600 ; N aogonek ; B 61 -199 593 454 ; +C -1 ; WX 600 ; N Uacute ; B 101 -18 716 784 ; +C -1 ; WX 600 ; N uogonek ; B 70 -199 592 439 ; +C -1 ; WX 600 ; N Edieresis ; B 25 0 670 761 ; +C -1 ; WX 600 ; N Dcroat ; B 30 0 664 562 ; +C -1 ; WX 600 ; N commaaccent ; B 151 -250 385 -57 ; +C -1 ; WX 600 ; N copyright ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N Emacron ; B 25 0 670 708 ; +C -1 ; WX 600 ; N ccaron ; B 81 -15 633 667 ; +C -1 ; WX 600 ; N aring ; B 61 -15 593 678 ; +C -1 ; WX 600 ; N Ncommaaccent ; B 8 -250 730 562 ; +C -1 ; WX 600 ; N lacute ; B 77 0 639 801 ; +C -1 ; WX 600 ; N agrave ; B 61 -15 593 661 ; +C -1 ; WX 600 ; N Tcommaaccent ; B 86 -250 679 562 ; +C -1 ; WX 600 ; N Cacute ; B 74 -18 675 784 ; +C -1 ; WX 600 ; N atilde ; B 61 -15 643 636 ; +C -1 ; WX 600 ; N Edotaccent ; B 25 0 670 761 ; +C -1 ; WX 600 ; N scaron ; B 66 -17 633 667 ; +C -1 ; WX 600 ; N scedilla ; B 66 -206 608 459 ; +C -1 ; WX 600 ; N iacute ; B 77 0 609 661 ; +C -1 ; WX 600 ; N lozenge ; B 145 0 614 740 ; +C -1 ; WX 600 ; N Rcaron ; B 24 0 659 790 ; +C -1 ; WX 600 ; N Gcommaaccent ; B 74 -250 675 580 ; +C -1 ; WX 600 ; N ucircumflex ; B 70 -15 597 657 ; +C -1 ; WX 600 ; N acircumflex ; B 61 -15 607 657 ; +C -1 ; WX 600 ; N Amacron ; B -9 0 633 708 ; +C -1 ; WX 600 ; N rcaron ; B 47 0 655 667 ; +C -1 ; WX 600 ; N ccedilla ; B 81 -206 631 459 ; +C -1 ; WX 600 ; N Zdotaccent ; B 62 0 637 761 ; +C -1 ; WX 600 ; N Thorn ; B 48 0 620 562 ; +C -1 ; WX 600 ; N Omacron ; B 74 -18 663 708 ; +C -1 ; WX 600 ; N Racute ; B 24 0 665 784 ; +C -1 ; WX 600 ; N Sacute ; B 54 -22 673 784 ; +C -1 ; WX 600 ; N dcaron ; B 60 -15 861 626 ; +C -1 ; WX 600 ; N Umacron ; B 101 -18 716 708 ; +C -1 ; WX 600 ; N uring ; B 70 -15 592 678 ; +C -1 ; WX 600 ; N threesuperior ; B 193 222 526 616 ; +C -1 ; WX 600 ; N Ograve ; B 74 -18 645 784 ; +C -1 ; WX 600 ; N Agrave ; B -9 0 632 784 ; +C -1 ; WX 600 ; N Abreve ; B -9 0 684 784 ; +C -1 ; WX 600 ; N multiply ; B 104 39 606 478 ; +C -1 ; WX 600 ; N uacute ; B 70 -15 599 661 ; +C -1 ; WX 600 ; N Tcaron ; B 86 0 679 790 ; +C -1 ; WX 600 ; N partialdiff ; B 91 -38 627 728 ; +C -1 ; WX 600 ; N ydieresis ; B -21 -142 695 638 ; +C -1 ; WX 600 ; N Nacute ; B 8 -12 730 784 ; +C -1 ; WX 600 ; N icircumflex ; B 77 0 577 657 ; +C -1 ; WX 600 ; N Ecircumflex ; B 25 0 670 780 ; +C -1 ; WX 600 ; N adieresis ; B 61 -15 595 638 ; +C -1 ; WX 600 ; N edieresis ; B 81 -15 605 638 ; +C -1 ; WX 600 ; N cacute ; B 81 -15 649 661 ; +C -1 ; WX 600 ; N nacute ; B 18 0 639 661 ; +C -1 ; WX 600 ; N umacron ; B 70 -15 637 585 ; +C -1 ; WX 600 ; N Ncaron ; B 8 -12 730 790 ; +C -1 ; WX 600 ; N Iacute ; B 77 0 643 784 ; +C -1 ; WX 600 ; N plusminus ; B 76 24 614 515 ; +C -1 ; WX 600 ; N brokenbar ; B 217 -175 489 675 ; +C -1 ; WX 600 ; N registered ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N Gbreve ; B 74 -18 684 784 ; +C -1 ; WX 600 ; N Idotaccent ; B 77 0 643 761 ; +C -1 ; WX 600 ; N summation ; B 15 -10 672 706 ; +C -1 ; WX 600 ; N Egrave ; B 25 0 670 784 ; +C -1 ; WX 600 ; N racute ; B 47 0 655 661 ; +C -1 ; WX 600 ; N omacron ; B 71 -15 637 585 ; +C -1 ; WX 600 ; N Zacute ; B 62 0 665 784 ; +C -1 ; WX 600 ; N Zcaron ; B 62 0 659 790 ; +C -1 ; WX 600 ; N greaterequal ; B 26 0 627 696 ; +C -1 ; WX 600 ; N Eth ; B 30 0 664 562 ; +C -1 ; WX 600 ; N Ccedilla ; B 74 -206 675 580 ; +C -1 ; WX 600 ; N lcommaaccent ; B 77 -250 546 626 ; +C -1 ; WX 600 ; N tcaron ; B 118 -15 627 703 ; +C -1 ; WX 600 ; N eogonek ; B 81 -199 605 454 ; +C -1 ; WX 600 ; N Uogonek ; B 101 -199 716 562 ; +C -1 ; WX 600 ; N Aacute ; B -9 0 655 784 ; +C -1 ; WX 600 ; N Adieresis ; B -9 0 632 761 ; +C -1 ; WX 600 ; N egrave ; B 81 -15 605 661 ; +C -1 ; WX 600 ; N zacute ; B 81 0 614 661 ; +C -1 ; WX 600 ; N iogonek ; B 77 -199 546 658 ; +C -1 ; WX 600 ; N Oacute ; B 74 -18 645 784 ; +C -1 ; WX 600 ; N oacute ; B 71 -15 649 661 ; +C -1 ; WX 600 ; N amacron ; B 61 -15 637 585 ; +C -1 ; WX 600 ; N sacute ; B 66 -17 609 661 ; +C -1 ; WX 600 ; N idieresis ; B 77 0 561 618 ; +C -1 ; WX 600 ; N Ocircumflex ; B 74 -18 645 780 ; +C -1 ; WX 600 ; N Ugrave ; B 101 -18 716 784 ; +C -1 ; WX 600 ; N Delta ; B 6 0 594 688 ; +C -1 ; WX 600 ; N thorn ; B -32 -142 622 626 ; +C -1 ; WX 600 ; N twosuperior ; B 191 230 542 616 ; +C -1 ; WX 600 ; N Odieresis ; B 74 -18 645 761 ; +C -1 ; WX 600 ; N mu ; B 49 -142 592 439 ; +C -1 ; WX 600 ; N igrave ; B 77 0 546 661 ; +C -1 ; WX 600 ; N ohungarumlaut ; B 71 -15 809 661 ; +C -1 ; WX 600 ; N Eogonek ; B 25 -199 670 562 ; +C -1 ; WX 600 ; N dcroat ; B 60 -15 712 626 ; +C -1 ; WX 600 ; N threequarters ; B 8 -60 699 661 ; +C -1 ; WX 600 ; N Scedilla ; B 54 -206 673 582 ; +C -1 ; WX 600 ; N lcaron ; B 77 0 731 626 ; +C -1 ; WX 600 ; N Kcommaaccent ; B 21 -250 692 562 ; +C -1 ; WX 600 ; N Lacute ; B 39 0 636 784 ; +C -1 ; WX 600 ; N trademark ; B 86 230 869 562 ; +C -1 ; WX 600 ; N edotaccent ; B 81 -15 605 638 ; +C -1 ; WX 600 ; N Igrave ; B 77 0 643 784 ; +C -1 ; WX 600 ; N Imacron ; B 77 0 663 708 ; +C -1 ; WX 600 ; N Lcaron ; B 39 0 757 562 ; +C -1 ; WX 600 ; N onehalf ; B 22 -60 716 661 ; +C -1 ; WX 600 ; N lessequal ; B 26 0 671 696 ; +C -1 ; WX 600 ; N ocircumflex ; B 71 -15 622 657 ; +C -1 ; WX 600 ; N ntilde ; B 18 0 643 636 ; +C -1 ; WX 600 ; N Uhungarumlaut ; B 101 -18 805 784 ; +C -1 ; WX 600 ; N Eacute ; B 25 0 670 784 ; +C -1 ; WX 600 ; N emacron ; B 81 -15 637 585 ; +C -1 ; WX 600 ; N gbreve ; B 40 -146 674 661 ; +C -1 ; WX 600 ; N onequarter ; B 13 -60 707 661 ; +C -1 ; WX 600 ; N Scaron ; B 54 -22 689 790 ; +C -1 ; WX 600 ; N Scommaaccent ; B 54 -250 673 582 ; +C -1 ; WX 600 ; N Ohungarumlaut ; B 74 -18 795 784 ; +C -1 ; WX 600 ; N degree ; B 173 243 570 616 ; +C -1 ; WX 600 ; N ograve ; B 71 -15 622 661 ; +C -1 ; WX 600 ; N Ccaron ; B 74 -18 689 790 ; +C -1 ; WX 600 ; N ugrave ; B 70 -15 592 661 ; +C -1 ; WX 600 ; N radical ; B 67 -104 635 778 ; +C -1 ; WX 600 ; N Dcaron ; B 30 0 664 790 ; +C -1 ; WX 600 ; N rcommaaccent ; B 47 -250 655 454 ; +C -1 ; WX 600 ; N Ntilde ; B 8 -12 730 759 ; +C -1 ; WX 600 ; N otilde ; B 71 -15 643 636 ; +C -1 ; WX 600 ; N Rcommaaccent ; B 24 -250 617 562 ; +C -1 ; WX 600 ; N Lcommaaccent ; B 39 -250 636 562 ; +C -1 ; WX 600 ; N Atilde ; B -9 0 669 759 ; +C -1 ; WX 600 ; N Aogonek ; B -9 -199 632 562 ; +C -1 ; WX 600 ; N Aring ; B -9 0 632 801 ; +C -1 ; WX 600 ; N Otilde ; B 74 -18 669 759 ; +C -1 ; WX 600 ; N zdotaccent ; B 81 0 614 638 ; +C -1 ; WX 600 ; N Ecaron ; B 25 0 670 790 ; +C -1 ; WX 600 ; N Iogonek ; B 77 -199 643 562 ; +C -1 ; WX 600 ; N kcommaaccent ; B 33 -250 643 626 ; +C -1 ; WX 600 ; N minus ; B 114 203 596 313 ; +C -1 ; WX 600 ; N Icircumflex ; B 77 0 643 780 ; +C -1 ; WX 600 ; N ncaron ; B 18 0 633 667 ; +C -1 ; WX 600 ; N tcommaaccent ; B 118 -250 567 562 ; +C -1 ; WX 600 ; N logicalnot ; B 135 103 617 413 ; +C -1 ; WX 600 ; N odieresis ; B 71 -15 622 638 ; +C -1 ; WX 600 ; N udieresis ; B 70 -15 595 638 ; +C -1 ; WX 600 ; N notequal ; B 30 -47 626 563 ; +C -1 ; WX 600 ; N gcommaaccent ; B 40 -146 674 714 ; +C -1 ; WX 600 ; N eth ; B 93 -27 661 626 ; +C -1 ; WX 600 ; N zcaron ; B 81 0 643 667 ; +C -1 ; WX 600 ; N ncommaaccent ; B 18 -250 615 454 ; +C -1 ; WX 600 ; N onesuperior ; B 212 230 514 616 ; +C -1 ; WX 600 ; N imacron ; B 77 0 575 585 ; +C -1 ; WX 600 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Oblique.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Oblique.afm new file mode 100644 index 00000000..3dc163f7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier-Oblique.afm @@ -0,0 +1,342 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 17:37:52 1997 +Comment UniqueID 43051 +Comment VMusage 16248 75829 +FontName Courier-Oblique +FullName Courier Oblique +FamilyName Courier +Weight Medium +ItalicAngle -12 +IsFixedPitch true +CharacterSet ExtendedRoman +FontBBox -27 -250 849 805 +UnderlinePosition -100 +UnderlineThickness 50 +Version 003.000 +Notice Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 426 +Ascender 629 +Descender -157 +StdHW 51 +StdVW 51 +StartCharMetrics 315 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 243 -15 464 572 ; +C 34 ; WX 600 ; N quotedbl ; B 273 328 532 562 ; +C 35 ; WX 600 ; N numbersign ; B 133 -32 596 639 ; +C 36 ; WX 600 ; N dollar ; B 108 -126 596 662 ; +C 37 ; WX 600 ; N percent ; B 134 -15 599 622 ; +C 38 ; WX 600 ; N ampersand ; B 87 -15 580 543 ; +C 39 ; WX 600 ; N quoteright ; B 283 328 495 562 ; +C 40 ; WX 600 ; N parenleft ; B 313 -108 572 622 ; +C 41 ; WX 600 ; N parenright ; B 137 -108 396 622 ; +C 42 ; WX 600 ; N asterisk ; B 212 257 580 607 ; +C 43 ; WX 600 ; N plus ; B 129 44 580 470 ; +C 44 ; WX 600 ; N comma ; B 157 -112 370 122 ; +C 45 ; WX 600 ; N hyphen ; B 152 231 558 285 ; +C 46 ; WX 600 ; N period ; B 238 -15 382 109 ; +C 47 ; WX 600 ; N slash ; B 112 -80 604 629 ; +C 48 ; WX 600 ; N zero ; B 154 -15 575 622 ; +C 49 ; WX 600 ; N one ; B 98 0 515 622 ; +C 50 ; WX 600 ; N two ; B 70 0 568 622 ; +C 51 ; WX 600 ; N three ; B 82 -15 538 622 ; +C 52 ; WX 600 ; N four ; B 108 0 541 622 ; +C 53 ; WX 600 ; N five ; B 99 -15 589 607 ; +C 54 ; WX 600 ; N six ; B 155 -15 629 622 ; +C 55 ; WX 600 ; N seven ; B 182 0 612 607 ; +C 56 ; WX 600 ; N eight ; B 132 -15 588 622 ; +C 57 ; WX 600 ; N nine ; B 93 -15 574 622 ; +C 58 ; WX 600 ; N colon ; B 238 -15 441 385 ; +C 59 ; WX 600 ; N semicolon ; B 157 -112 441 385 ; +C 60 ; WX 600 ; N less ; B 96 42 610 472 ; +C 61 ; WX 600 ; N equal ; B 109 138 600 376 ; +C 62 ; WX 600 ; N greater ; B 85 42 599 472 ; +C 63 ; WX 600 ; N question ; B 222 -15 583 572 ; +C 64 ; WX 600 ; N at ; B 127 -15 582 622 ; +C 65 ; WX 600 ; N A ; B 3 0 607 562 ; +C 66 ; WX 600 ; N B ; B 43 0 616 562 ; +C 67 ; WX 600 ; N C ; B 93 -18 655 580 ; +C 68 ; WX 600 ; N D ; B 43 0 645 562 ; +C 69 ; WX 600 ; N E ; B 53 0 660 562 ; +C 70 ; WX 600 ; N F ; B 53 0 660 562 ; +C 71 ; WX 600 ; N G ; B 83 -18 645 580 ; +C 72 ; WX 600 ; N H ; B 32 0 687 562 ; +C 73 ; WX 600 ; N I ; B 96 0 623 562 ; +C 74 ; WX 600 ; N J ; B 52 -18 685 562 ; +C 75 ; WX 600 ; N K ; B 38 0 671 562 ; +C 76 ; WX 600 ; N L ; B 47 0 607 562 ; +C 77 ; WX 600 ; N M ; B 4 0 715 562 ; +C 78 ; WX 600 ; N N ; B 7 -13 712 562 ; +C 79 ; WX 600 ; N O ; B 94 -18 625 580 ; +C 80 ; WX 600 ; N P ; B 79 0 644 562 ; +C 81 ; WX 600 ; N Q ; B 95 -138 625 580 ; +C 82 ; WX 600 ; N R ; B 38 0 598 562 ; +C 83 ; WX 600 ; N S ; B 76 -20 650 580 ; +C 84 ; WX 600 ; N T ; B 108 0 665 562 ; +C 85 ; WX 600 ; N U ; B 125 -18 702 562 ; +C 86 ; WX 600 ; N V ; B 105 -13 723 562 ; +C 87 ; WX 600 ; N W ; B 106 -13 722 562 ; +C 88 ; WX 600 ; N X ; B 23 0 675 562 ; +C 89 ; WX 600 ; N Y ; B 133 0 695 562 ; +C 90 ; WX 600 ; N Z ; B 86 0 610 562 ; +C 91 ; WX 600 ; N bracketleft ; B 246 -108 574 622 ; +C 92 ; WX 600 ; N backslash ; B 249 -80 468 629 ; +C 93 ; WX 600 ; N bracketright ; B 135 -108 463 622 ; +C 94 ; WX 600 ; N asciicircum ; B 175 354 587 622 ; +C 95 ; WX 600 ; N underscore ; B -27 -125 584 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 343 328 457 562 ; +C 97 ; WX 600 ; N a ; B 76 -15 569 441 ; +C 98 ; WX 600 ; N b ; B 29 -15 625 629 ; +C 99 ; WX 600 ; N c ; B 106 -15 608 441 ; +C 100 ; WX 600 ; N d ; B 85 -15 640 629 ; +C 101 ; WX 600 ; N e ; B 106 -15 598 441 ; +C 102 ; WX 600 ; N f ; B 114 0 662 629 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 61 -157 657 441 ; +C 104 ; WX 600 ; N h ; B 33 0 592 629 ; +C 105 ; WX 600 ; N i ; B 95 0 515 657 ; +C 106 ; WX 600 ; N j ; B 52 -157 550 657 ; +C 107 ; WX 600 ; N k ; B 58 0 633 629 ; +C 108 ; WX 600 ; N l ; B 95 0 515 629 ; +C 109 ; WX 600 ; N m ; B -5 0 615 441 ; +C 110 ; WX 600 ; N n ; B 26 0 585 441 ; +C 111 ; WX 600 ; N o ; B 102 -15 588 441 ; +C 112 ; WX 600 ; N p ; B -24 -157 605 441 ; +C 113 ; WX 600 ; N q ; B 85 -157 682 441 ; +C 114 ; WX 600 ; N r ; B 60 0 636 441 ; +C 115 ; WX 600 ; N s ; B 78 -15 584 441 ; +C 116 ; WX 600 ; N t ; B 167 -15 561 561 ; +C 117 ; WX 600 ; N u ; B 101 -15 572 426 ; +C 118 ; WX 600 ; N v ; B 90 -10 681 426 ; +C 119 ; WX 600 ; N w ; B 76 -10 695 426 ; +C 120 ; WX 600 ; N x ; B 20 0 655 426 ; +C 121 ; WX 600 ; N y ; B -4 -157 683 426 ; +C 122 ; WX 600 ; N z ; B 99 0 593 426 ; +C 123 ; WX 600 ; N braceleft ; B 233 -108 569 622 ; +C 124 ; WX 600 ; N bar ; B 222 -250 485 750 ; +C 125 ; WX 600 ; N braceright ; B 140 -108 477 622 ; +C 126 ; WX 600 ; N asciitilde ; B 116 197 600 320 ; +C 161 ; WX 600 ; N exclamdown ; B 225 -157 445 430 ; +C 162 ; WX 600 ; N cent ; B 151 -49 588 614 ; +C 163 ; WX 600 ; N sterling ; B 124 -21 621 611 ; +C 164 ; WX 600 ; N fraction ; B 84 -57 646 665 ; +C 165 ; WX 600 ; N yen ; B 120 0 693 562 ; +C 166 ; WX 600 ; N florin ; B -26 -143 671 622 ; +C 167 ; WX 600 ; N section ; B 104 -78 590 580 ; +C 168 ; WX 600 ; N currency ; B 94 58 628 506 ; +C 169 ; WX 600 ; N quotesingle ; B 345 328 460 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 262 328 541 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 92 70 652 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 204 70 540 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 170 70 506 446 ; +C 174 ; WX 600 ; N fi ; B 3 0 619 629 ; +C 175 ; WX 600 ; N fl ; B 3 0 619 629 ; +C 177 ; WX 600 ; N endash ; B 124 231 586 285 ; +C 178 ; WX 600 ; N dagger ; B 217 -78 546 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 163 -78 546 580 ; +C 180 ; WX 600 ; N periodcentered ; B 275 189 434 327 ; +C 182 ; WX 600 ; N paragraph ; B 100 -78 630 562 ; +C 183 ; WX 600 ; N bullet ; B 224 130 485 383 ; +C 184 ; WX 600 ; N quotesinglbase ; B 185 -134 397 100 ; +C 185 ; WX 600 ; N quotedblbase ; B 115 -134 478 100 ; +C 186 ; WX 600 ; N quotedblright ; B 213 328 576 562 ; +C 187 ; WX 600 ; N guillemotright ; B 58 70 618 446 ; +C 188 ; WX 600 ; N ellipsis ; B 46 -15 575 111 ; +C 189 ; WX 600 ; N perthousand ; B 59 -15 627 622 ; +C 191 ; WX 600 ; N questiondown ; B 105 -157 466 430 ; +C 193 ; WX 600 ; N grave ; B 294 497 484 672 ; +C 194 ; WX 600 ; N acute ; B 348 497 612 672 ; +C 195 ; WX 600 ; N circumflex ; B 229 477 581 654 ; +C 196 ; WX 600 ; N tilde ; B 212 489 629 606 ; +C 197 ; WX 600 ; N macron ; B 232 525 600 565 ; +C 198 ; WX 600 ; N breve ; B 279 501 576 609 ; +C 199 ; WX 600 ; N dotaccent ; B 373 537 478 640 ; +C 200 ; WX 600 ; N dieresis ; B 272 537 579 640 ; +C 202 ; WX 600 ; N ring ; B 332 463 500 627 ; +C 203 ; WX 600 ; N cedilla ; B 197 -151 344 10 ; +C 205 ; WX 600 ; N hungarumlaut ; B 239 497 683 672 ; +C 206 ; WX 600 ; N ogonek ; B 189 -172 377 4 ; +C 207 ; WX 600 ; N caron ; B 262 492 614 669 ; +C 208 ; WX 600 ; N emdash ; B 49 231 661 285 ; +C 225 ; WX 600 ; N AE ; B 3 0 655 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 209 249 512 580 ; +C 232 ; WX 600 ; N Lslash ; B 47 0 607 562 ; +C 233 ; WX 600 ; N Oslash ; B 94 -80 625 629 ; +C 234 ; WX 600 ; N OE ; B 59 0 672 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 210 249 535 580 ; +C 241 ; WX 600 ; N ae ; B 41 -15 626 441 ; +C 245 ; WX 600 ; N dotlessi ; B 95 0 515 426 ; +C 248 ; WX 600 ; N lslash ; B 95 0 587 629 ; +C 249 ; WX 600 ; N oslash ; B 102 -80 588 506 ; +C 250 ; WX 600 ; N oe ; B 54 -15 615 441 ; +C 251 ; WX 600 ; N germandbls ; B 48 -15 617 629 ; +C -1 ; WX 600 ; N Idieresis ; B 96 0 623 753 ; +C -1 ; WX 600 ; N eacute ; B 106 -15 612 672 ; +C -1 ; WX 600 ; N abreve ; B 76 -15 576 609 ; +C -1 ; WX 600 ; N uhungarumlaut ; B 101 -15 723 672 ; +C -1 ; WX 600 ; N ecaron ; B 106 -15 614 669 ; +C -1 ; WX 600 ; N Ydieresis ; B 133 0 695 753 ; +C -1 ; WX 600 ; N divide ; B 136 48 573 467 ; +C -1 ; WX 600 ; N Yacute ; B 133 0 695 805 ; +C -1 ; WX 600 ; N Acircumflex ; B 3 0 607 787 ; +C -1 ; WX 600 ; N aacute ; B 76 -15 612 672 ; +C -1 ; WX 600 ; N Ucircumflex ; B 125 -18 702 787 ; +C -1 ; WX 600 ; N yacute ; B -4 -157 683 672 ; +C -1 ; WX 600 ; N scommaaccent ; B 78 -250 584 441 ; +C -1 ; WX 600 ; N ecircumflex ; B 106 -15 598 654 ; +C -1 ; WX 600 ; N Uring ; B 125 -18 702 760 ; +C -1 ; WX 600 ; N Udieresis ; B 125 -18 702 753 ; +C -1 ; WX 600 ; N aogonek ; B 76 -172 569 441 ; +C -1 ; WX 600 ; N Uacute ; B 125 -18 702 805 ; +C -1 ; WX 600 ; N uogonek ; B 101 -172 572 426 ; +C -1 ; WX 600 ; N Edieresis ; B 53 0 660 753 ; +C -1 ; WX 600 ; N Dcroat ; B 43 0 645 562 ; +C -1 ; WX 600 ; N commaaccent ; B 145 -250 323 -58 ; +C -1 ; WX 600 ; N copyright ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N Emacron ; B 53 0 660 698 ; +C -1 ; WX 600 ; N ccaron ; B 106 -15 614 669 ; +C -1 ; WX 600 ; N aring ; B 76 -15 569 627 ; +C -1 ; WX 600 ; N Ncommaaccent ; B 7 -250 712 562 ; +C -1 ; WX 600 ; N lacute ; B 95 0 640 805 ; +C -1 ; WX 600 ; N agrave ; B 76 -15 569 672 ; +C -1 ; WX 600 ; N Tcommaaccent ; B 108 -250 665 562 ; +C -1 ; WX 600 ; N Cacute ; B 93 -18 655 805 ; +C -1 ; WX 600 ; N atilde ; B 76 -15 629 606 ; +C -1 ; WX 600 ; N Edotaccent ; B 53 0 660 753 ; +C -1 ; WX 600 ; N scaron ; B 78 -15 614 669 ; +C -1 ; WX 600 ; N scedilla ; B 78 -151 584 441 ; +C -1 ; WX 600 ; N iacute ; B 95 0 612 672 ; +C -1 ; WX 600 ; N lozenge ; B 94 0 519 706 ; +C -1 ; WX 600 ; N Rcaron ; B 38 0 642 802 ; +C -1 ; WX 600 ; N Gcommaaccent ; B 83 -250 645 580 ; +C -1 ; WX 600 ; N ucircumflex ; B 101 -15 572 654 ; +C -1 ; WX 600 ; N acircumflex ; B 76 -15 581 654 ; +C -1 ; WX 600 ; N Amacron ; B 3 0 607 698 ; +C -1 ; WX 600 ; N rcaron ; B 60 0 636 669 ; +C -1 ; WX 600 ; N ccedilla ; B 106 -151 614 441 ; +C -1 ; WX 600 ; N Zdotaccent ; B 86 0 610 753 ; +C -1 ; WX 600 ; N Thorn ; B 79 0 606 562 ; +C -1 ; WX 600 ; N Omacron ; B 94 -18 628 698 ; +C -1 ; WX 600 ; N Racute ; B 38 0 670 805 ; +C -1 ; WX 600 ; N Sacute ; B 76 -20 650 805 ; +C -1 ; WX 600 ; N dcaron ; B 85 -15 849 629 ; +C -1 ; WX 600 ; N Umacron ; B 125 -18 702 698 ; +C -1 ; WX 600 ; N uring ; B 101 -15 572 627 ; +C -1 ; WX 600 ; N threesuperior ; B 213 240 501 622 ; +C -1 ; WX 600 ; N Ograve ; B 94 -18 625 805 ; +C -1 ; WX 600 ; N Agrave ; B 3 0 607 805 ; +C -1 ; WX 600 ; N Abreve ; B 3 0 607 732 ; +C -1 ; WX 600 ; N multiply ; B 103 43 607 470 ; +C -1 ; WX 600 ; N uacute ; B 101 -15 602 672 ; +C -1 ; WX 600 ; N Tcaron ; B 108 0 665 802 ; +C -1 ; WX 600 ; N partialdiff ; B 45 -38 546 710 ; +C -1 ; WX 600 ; N ydieresis ; B -4 -157 683 620 ; +C -1 ; WX 600 ; N Nacute ; B 7 -13 712 805 ; +C -1 ; WX 600 ; N icircumflex ; B 95 0 551 654 ; +C -1 ; WX 600 ; N Ecircumflex ; B 53 0 660 787 ; +C -1 ; WX 600 ; N adieresis ; B 76 -15 575 620 ; +C -1 ; WX 600 ; N edieresis ; B 106 -15 598 620 ; +C -1 ; WX 600 ; N cacute ; B 106 -15 612 672 ; +C -1 ; WX 600 ; N nacute ; B 26 0 602 672 ; +C -1 ; WX 600 ; N umacron ; B 101 -15 600 565 ; +C -1 ; WX 600 ; N Ncaron ; B 7 -13 712 802 ; +C -1 ; WX 600 ; N Iacute ; B 96 0 640 805 ; +C -1 ; WX 600 ; N plusminus ; B 96 44 594 558 ; +C -1 ; WX 600 ; N brokenbar ; B 238 -175 469 675 ; +C -1 ; WX 600 ; N registered ; B 53 -18 667 580 ; +C -1 ; WX 600 ; N Gbreve ; B 83 -18 645 732 ; +C -1 ; WX 600 ; N Idotaccent ; B 96 0 623 753 ; +C -1 ; WX 600 ; N summation ; B 15 -10 670 706 ; +C -1 ; WX 600 ; N Egrave ; B 53 0 660 805 ; +C -1 ; WX 600 ; N racute ; B 60 0 636 672 ; +C -1 ; WX 600 ; N omacron ; B 102 -15 600 565 ; +C -1 ; WX 600 ; N Zacute ; B 86 0 670 805 ; +C -1 ; WX 600 ; N Zcaron ; B 86 0 642 802 ; +C -1 ; WX 600 ; N greaterequal ; B 98 0 594 710 ; +C -1 ; WX 600 ; N Eth ; B 43 0 645 562 ; +C -1 ; WX 600 ; N Ccedilla ; B 93 -151 658 580 ; +C -1 ; WX 600 ; N lcommaaccent ; B 95 -250 515 629 ; +C -1 ; WX 600 ; N tcaron ; B 167 -15 587 717 ; +C -1 ; WX 600 ; N eogonek ; B 106 -172 598 441 ; +C -1 ; WX 600 ; N Uogonek ; B 124 -172 702 562 ; +C -1 ; WX 600 ; N Aacute ; B 3 0 660 805 ; +C -1 ; WX 600 ; N Adieresis ; B 3 0 607 753 ; +C -1 ; WX 600 ; N egrave ; B 106 -15 598 672 ; +C -1 ; WX 600 ; N zacute ; B 99 0 612 672 ; +C -1 ; WX 600 ; N iogonek ; B 95 -172 515 657 ; +C -1 ; WX 600 ; N Oacute ; B 94 -18 640 805 ; +C -1 ; WX 600 ; N oacute ; B 102 -15 612 672 ; +C -1 ; WX 600 ; N amacron ; B 76 -15 600 565 ; +C -1 ; WX 600 ; N sacute ; B 78 -15 612 672 ; +C -1 ; WX 600 ; N idieresis ; B 95 0 545 620 ; +C -1 ; WX 600 ; N Ocircumflex ; B 94 -18 625 787 ; +C -1 ; WX 600 ; N Ugrave ; B 125 -18 702 805 ; +C -1 ; WX 600 ; N Delta ; B 6 0 598 688 ; +C -1 ; WX 600 ; N thorn ; B -24 -157 605 629 ; +C -1 ; WX 600 ; N twosuperior ; B 230 249 535 622 ; +C -1 ; WX 600 ; N Odieresis ; B 94 -18 625 753 ; +C -1 ; WX 600 ; N mu ; B 72 -157 572 426 ; +C -1 ; WX 600 ; N igrave ; B 95 0 515 672 ; +C -1 ; WX 600 ; N ohungarumlaut ; B 102 -15 723 672 ; +C -1 ; WX 600 ; N Eogonek ; B 53 -172 660 562 ; +C -1 ; WX 600 ; N dcroat ; B 85 -15 704 629 ; +C -1 ; WX 600 ; N threequarters ; B 73 -56 659 666 ; +C -1 ; WX 600 ; N Scedilla ; B 76 -151 650 580 ; +C -1 ; WX 600 ; N lcaron ; B 95 0 667 629 ; +C -1 ; WX 600 ; N Kcommaaccent ; B 38 -250 671 562 ; +C -1 ; WX 600 ; N Lacute ; B 47 0 607 805 ; +C -1 ; WX 600 ; N trademark ; B 75 263 742 562 ; +C -1 ; WX 600 ; N edotaccent ; B 106 -15 598 620 ; +C -1 ; WX 600 ; N Igrave ; B 96 0 623 805 ; +C -1 ; WX 600 ; N Imacron ; B 96 0 628 698 ; +C -1 ; WX 600 ; N Lcaron ; B 47 0 632 562 ; +C -1 ; WX 600 ; N onehalf ; B 65 -57 669 665 ; +C -1 ; WX 600 ; N lessequal ; B 98 0 645 710 ; +C -1 ; WX 600 ; N ocircumflex ; B 102 -15 588 654 ; +C -1 ; WX 600 ; N ntilde ; B 26 0 629 606 ; +C -1 ; WX 600 ; N Uhungarumlaut ; B 125 -18 761 805 ; +C -1 ; WX 600 ; N Eacute ; B 53 0 670 805 ; +C -1 ; WX 600 ; N emacron ; B 106 -15 600 565 ; +C -1 ; WX 600 ; N gbreve ; B 61 -157 657 609 ; +C -1 ; WX 600 ; N onequarter ; B 65 -57 674 665 ; +C -1 ; WX 600 ; N Scaron ; B 76 -20 672 802 ; +C -1 ; WX 600 ; N Scommaaccent ; B 76 -250 650 580 ; +C -1 ; WX 600 ; N Ohungarumlaut ; B 94 -18 751 805 ; +C -1 ; WX 600 ; N degree ; B 214 269 576 622 ; +C -1 ; WX 600 ; N ograve ; B 102 -15 588 672 ; +C -1 ; WX 600 ; N Ccaron ; B 93 -18 672 802 ; +C -1 ; WX 600 ; N ugrave ; B 101 -15 572 672 ; +C -1 ; WX 600 ; N radical ; B 85 -15 765 792 ; +C -1 ; WX 600 ; N Dcaron ; B 43 0 645 802 ; +C -1 ; WX 600 ; N rcommaaccent ; B 60 -250 636 441 ; +C -1 ; WX 600 ; N Ntilde ; B 7 -13 712 729 ; +C -1 ; WX 600 ; N otilde ; B 102 -15 629 606 ; +C -1 ; WX 600 ; N Rcommaaccent ; B 38 -250 598 562 ; +C -1 ; WX 600 ; N Lcommaaccent ; B 47 -250 607 562 ; +C -1 ; WX 600 ; N Atilde ; B 3 0 655 729 ; +C -1 ; WX 600 ; N Aogonek ; B 3 -172 607 562 ; +C -1 ; WX 600 ; N Aring ; B 3 0 607 750 ; +C -1 ; WX 600 ; N Otilde ; B 94 -18 655 729 ; +C -1 ; WX 600 ; N zdotaccent ; B 99 0 593 620 ; +C -1 ; WX 600 ; N Ecaron ; B 53 0 660 802 ; +C -1 ; WX 600 ; N Iogonek ; B 96 -172 623 562 ; +C -1 ; WX 600 ; N kcommaaccent ; B 58 -250 633 629 ; +C -1 ; WX 600 ; N minus ; B 129 232 580 283 ; +C -1 ; WX 600 ; N Icircumflex ; B 96 0 623 787 ; +C -1 ; WX 600 ; N ncaron ; B 26 0 614 669 ; +C -1 ; WX 600 ; N tcommaaccent ; B 165 -250 561 561 ; +C -1 ; WX 600 ; N logicalnot ; B 155 108 591 369 ; +C -1 ; WX 600 ; N odieresis ; B 102 -15 588 620 ; +C -1 ; WX 600 ; N udieresis ; B 101 -15 575 620 ; +C -1 ; WX 600 ; N notequal ; B 43 -16 621 529 ; +C -1 ; WX 600 ; N gcommaaccent ; B 61 -157 657 708 ; +C -1 ; WX 600 ; N eth ; B 102 -15 639 629 ; +C -1 ; WX 600 ; N zcaron ; B 99 0 624 669 ; +C -1 ; WX 600 ; N ncommaaccent ; B 26 -250 585 441 ; +C -1 ; WX 600 ; N onesuperior ; B 231 249 491 622 ; +C -1 ; WX 600 ; N imacron ; B 95 0 543 565 ; +C -1 ; WX 600 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier.afm new file mode 100644 index 00000000..2f7be81d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Courier.afm @@ -0,0 +1,342 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 17:27:09 1997 +Comment UniqueID 43050 +Comment VMusage 39754 50779 +FontName Courier +FullName Courier +FamilyName Courier +Weight Medium +ItalicAngle 0 +IsFixedPitch true +CharacterSet ExtendedRoman +FontBBox -23 -250 715 805 +UnderlinePosition -100 +UnderlineThickness 50 +Version 003.000 +Notice Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +EncodingScheme AdobeStandardEncoding +CapHeight 562 +XHeight 426 +Ascender 629 +Descender -157 +StdHW 51 +StdVW 51 +StartCharMetrics 315 +C 32 ; WX 600 ; N space ; B 0 0 0 0 ; +C 33 ; WX 600 ; N exclam ; B 236 -15 364 572 ; +C 34 ; WX 600 ; N quotedbl ; B 187 328 413 562 ; +C 35 ; WX 600 ; N numbersign ; B 93 -32 507 639 ; +C 36 ; WX 600 ; N dollar ; B 105 -126 496 662 ; +C 37 ; WX 600 ; N percent ; B 81 -15 518 622 ; +C 38 ; WX 600 ; N ampersand ; B 63 -15 538 543 ; +C 39 ; WX 600 ; N quoteright ; B 213 328 376 562 ; +C 40 ; WX 600 ; N parenleft ; B 269 -108 440 622 ; +C 41 ; WX 600 ; N parenright ; B 160 -108 331 622 ; +C 42 ; WX 600 ; N asterisk ; B 116 257 484 607 ; +C 43 ; WX 600 ; N plus ; B 80 44 520 470 ; +C 44 ; WX 600 ; N comma ; B 181 -112 344 122 ; +C 45 ; WX 600 ; N hyphen ; B 103 231 497 285 ; +C 46 ; WX 600 ; N period ; B 229 -15 371 109 ; +C 47 ; WX 600 ; N slash ; B 125 -80 475 629 ; +C 48 ; WX 600 ; N zero ; B 106 -15 494 622 ; +C 49 ; WX 600 ; N one ; B 96 0 505 622 ; +C 50 ; WX 600 ; N two ; B 70 0 471 622 ; +C 51 ; WX 600 ; N three ; B 75 -15 466 622 ; +C 52 ; WX 600 ; N four ; B 78 0 500 622 ; +C 53 ; WX 600 ; N five ; B 92 -15 497 607 ; +C 54 ; WX 600 ; N six ; B 111 -15 497 622 ; +C 55 ; WX 600 ; N seven ; B 82 0 483 607 ; +C 56 ; WX 600 ; N eight ; B 102 -15 498 622 ; +C 57 ; WX 600 ; N nine ; B 96 -15 489 622 ; +C 58 ; WX 600 ; N colon ; B 229 -15 371 385 ; +C 59 ; WX 600 ; N semicolon ; B 181 -112 371 385 ; +C 60 ; WX 600 ; N less ; B 41 42 519 472 ; +C 61 ; WX 600 ; N equal ; B 80 138 520 376 ; +C 62 ; WX 600 ; N greater ; B 66 42 544 472 ; +C 63 ; WX 600 ; N question ; B 129 -15 492 572 ; +C 64 ; WX 600 ; N at ; B 77 -15 533 622 ; +C 65 ; WX 600 ; N A ; B 3 0 597 562 ; +C 66 ; WX 600 ; N B ; B 43 0 559 562 ; +C 67 ; WX 600 ; N C ; B 41 -18 540 580 ; +C 68 ; WX 600 ; N D ; B 43 0 574 562 ; +C 69 ; WX 600 ; N E ; B 53 0 550 562 ; +C 70 ; WX 600 ; N F ; B 53 0 545 562 ; +C 71 ; WX 600 ; N G ; B 31 -18 575 580 ; +C 72 ; WX 600 ; N H ; B 32 0 568 562 ; +C 73 ; WX 600 ; N I ; B 96 0 504 562 ; +C 74 ; WX 600 ; N J ; B 34 -18 566 562 ; +C 75 ; WX 600 ; N K ; B 38 0 582 562 ; +C 76 ; WX 600 ; N L ; B 47 0 554 562 ; +C 77 ; WX 600 ; N M ; B 4 0 596 562 ; +C 78 ; WX 600 ; N N ; B 7 -13 593 562 ; +C 79 ; WX 600 ; N O ; B 43 -18 557 580 ; +C 80 ; WX 600 ; N P ; B 79 0 558 562 ; +C 81 ; WX 600 ; N Q ; B 43 -138 557 580 ; +C 82 ; WX 600 ; N R ; B 38 0 588 562 ; +C 83 ; WX 600 ; N S ; B 72 -20 529 580 ; +C 84 ; WX 600 ; N T ; B 38 0 563 562 ; +C 85 ; WX 600 ; N U ; B 17 -18 583 562 ; +C 86 ; WX 600 ; N V ; B -4 -13 604 562 ; +C 87 ; WX 600 ; N W ; B -3 -13 603 562 ; +C 88 ; WX 600 ; N X ; B 23 0 577 562 ; +C 89 ; WX 600 ; N Y ; B 24 0 576 562 ; +C 90 ; WX 600 ; N Z ; B 86 0 514 562 ; +C 91 ; WX 600 ; N bracketleft ; B 269 -108 442 622 ; +C 92 ; WX 600 ; N backslash ; B 118 -80 482 629 ; +C 93 ; WX 600 ; N bracketright ; B 158 -108 331 622 ; +C 94 ; WX 600 ; N asciicircum ; B 94 354 506 622 ; +C 95 ; WX 600 ; N underscore ; B 0 -125 600 -75 ; +C 96 ; WX 600 ; N quoteleft ; B 224 328 387 562 ; +C 97 ; WX 600 ; N a ; B 53 -15 559 441 ; +C 98 ; WX 600 ; N b ; B 14 -15 575 629 ; +C 99 ; WX 600 ; N c ; B 66 -15 529 441 ; +C 100 ; WX 600 ; N d ; B 45 -15 591 629 ; +C 101 ; WX 600 ; N e ; B 66 -15 548 441 ; +C 102 ; WX 600 ; N f ; B 114 0 531 629 ; L i fi ; L l fl ; +C 103 ; WX 600 ; N g ; B 45 -157 566 441 ; +C 104 ; WX 600 ; N h ; B 18 0 582 629 ; +C 105 ; WX 600 ; N i ; B 95 0 505 657 ; +C 106 ; WX 600 ; N j ; B 82 -157 410 657 ; +C 107 ; WX 600 ; N k ; B 43 0 580 629 ; +C 108 ; WX 600 ; N l ; B 95 0 505 629 ; +C 109 ; WX 600 ; N m ; B -5 0 605 441 ; +C 110 ; WX 600 ; N n ; B 26 0 575 441 ; +C 111 ; WX 600 ; N o ; B 62 -15 538 441 ; +C 112 ; WX 600 ; N p ; B 9 -157 555 441 ; +C 113 ; WX 600 ; N q ; B 45 -157 591 441 ; +C 114 ; WX 600 ; N r ; B 60 0 559 441 ; +C 115 ; WX 600 ; N s ; B 80 -15 513 441 ; +C 116 ; WX 600 ; N t ; B 87 -15 530 561 ; +C 117 ; WX 600 ; N u ; B 21 -15 562 426 ; +C 118 ; WX 600 ; N v ; B 10 -10 590 426 ; +C 119 ; WX 600 ; N w ; B -4 -10 604 426 ; +C 120 ; WX 600 ; N x ; B 20 0 580 426 ; +C 121 ; WX 600 ; N y ; B 7 -157 592 426 ; +C 122 ; WX 600 ; N z ; B 99 0 502 426 ; +C 123 ; WX 600 ; N braceleft ; B 182 -108 437 622 ; +C 124 ; WX 600 ; N bar ; B 275 -250 326 750 ; +C 125 ; WX 600 ; N braceright ; B 163 -108 418 622 ; +C 126 ; WX 600 ; N asciitilde ; B 63 197 540 320 ; +C 161 ; WX 600 ; N exclamdown ; B 236 -157 364 430 ; +C 162 ; WX 600 ; N cent ; B 96 -49 500 614 ; +C 163 ; WX 600 ; N sterling ; B 84 -21 521 611 ; +C 164 ; WX 600 ; N fraction ; B 92 -57 509 665 ; +C 165 ; WX 600 ; N yen ; B 26 0 574 562 ; +C 166 ; WX 600 ; N florin ; B 4 -143 539 622 ; +C 167 ; WX 600 ; N section ; B 113 -78 488 580 ; +C 168 ; WX 600 ; N currency ; B 73 58 527 506 ; +C 169 ; WX 600 ; N quotesingle ; B 259 328 341 562 ; +C 170 ; WX 600 ; N quotedblleft ; B 143 328 471 562 ; +C 171 ; WX 600 ; N guillemotleft ; B 37 70 563 446 ; +C 172 ; WX 600 ; N guilsinglleft ; B 149 70 451 446 ; +C 173 ; WX 600 ; N guilsinglright ; B 149 70 451 446 ; +C 174 ; WX 600 ; N fi ; B 3 0 597 629 ; +C 175 ; WX 600 ; N fl ; B 3 0 597 629 ; +C 177 ; WX 600 ; N endash ; B 75 231 525 285 ; +C 178 ; WX 600 ; N dagger ; B 141 -78 459 580 ; +C 179 ; WX 600 ; N daggerdbl ; B 141 -78 459 580 ; +C 180 ; WX 600 ; N periodcentered ; B 222 189 378 327 ; +C 182 ; WX 600 ; N paragraph ; B 50 -78 511 562 ; +C 183 ; WX 600 ; N bullet ; B 172 130 428 383 ; +C 184 ; WX 600 ; N quotesinglbase ; B 213 -134 376 100 ; +C 185 ; WX 600 ; N quotedblbase ; B 143 -134 457 100 ; +C 186 ; WX 600 ; N quotedblright ; B 143 328 457 562 ; +C 187 ; WX 600 ; N guillemotright ; B 37 70 563 446 ; +C 188 ; WX 600 ; N ellipsis ; B 37 -15 563 111 ; +C 189 ; WX 600 ; N perthousand ; B 3 -15 600 622 ; +C 191 ; WX 600 ; N questiondown ; B 108 -157 471 430 ; +C 193 ; WX 600 ; N grave ; B 151 497 378 672 ; +C 194 ; WX 600 ; N acute ; B 242 497 469 672 ; +C 195 ; WX 600 ; N circumflex ; B 124 477 476 654 ; +C 196 ; WX 600 ; N tilde ; B 105 489 503 606 ; +C 197 ; WX 600 ; N macron ; B 120 525 480 565 ; +C 198 ; WX 600 ; N breve ; B 153 501 447 609 ; +C 199 ; WX 600 ; N dotaccent ; B 249 537 352 640 ; +C 200 ; WX 600 ; N dieresis ; B 148 537 453 640 ; +C 202 ; WX 600 ; N ring ; B 218 463 382 627 ; +C 203 ; WX 600 ; N cedilla ; B 224 -151 362 10 ; +C 205 ; WX 600 ; N hungarumlaut ; B 133 497 540 672 ; +C 206 ; WX 600 ; N ogonek ; B 211 -172 407 4 ; +C 207 ; WX 600 ; N caron ; B 124 492 476 669 ; +C 208 ; WX 600 ; N emdash ; B 0 231 600 285 ; +C 225 ; WX 600 ; N AE ; B 3 0 550 562 ; +C 227 ; WX 600 ; N ordfeminine ; B 156 249 442 580 ; +C 232 ; WX 600 ; N Lslash ; B 47 0 554 562 ; +C 233 ; WX 600 ; N Oslash ; B 43 -80 557 629 ; +C 234 ; WX 600 ; N OE ; B 7 0 567 562 ; +C 235 ; WX 600 ; N ordmasculine ; B 157 249 443 580 ; +C 241 ; WX 600 ; N ae ; B 19 -15 570 441 ; +C 245 ; WX 600 ; N dotlessi ; B 95 0 505 426 ; +C 248 ; WX 600 ; N lslash ; B 95 0 505 629 ; +C 249 ; WX 600 ; N oslash ; B 62 -80 538 506 ; +C 250 ; WX 600 ; N oe ; B 19 -15 559 441 ; +C 251 ; WX 600 ; N germandbls ; B 48 -15 588 629 ; +C -1 ; WX 600 ; N Idieresis ; B 96 0 504 753 ; +C -1 ; WX 600 ; N eacute ; B 66 -15 548 672 ; +C -1 ; WX 600 ; N abreve ; B 53 -15 559 609 ; +C -1 ; WX 600 ; N uhungarumlaut ; B 21 -15 580 672 ; +C -1 ; WX 600 ; N ecaron ; B 66 -15 548 669 ; +C -1 ; WX 600 ; N Ydieresis ; B 24 0 576 753 ; +C -1 ; WX 600 ; N divide ; B 87 48 513 467 ; +C -1 ; WX 600 ; N Yacute ; B 24 0 576 805 ; +C -1 ; WX 600 ; N Acircumflex ; B 3 0 597 787 ; +C -1 ; WX 600 ; N aacute ; B 53 -15 559 672 ; +C -1 ; WX 600 ; N Ucircumflex ; B 17 -18 583 787 ; +C -1 ; WX 600 ; N yacute ; B 7 -157 592 672 ; +C -1 ; WX 600 ; N scommaaccent ; B 80 -250 513 441 ; +C -1 ; WX 600 ; N ecircumflex ; B 66 -15 548 654 ; +C -1 ; WX 600 ; N Uring ; B 17 -18 583 760 ; +C -1 ; WX 600 ; N Udieresis ; B 17 -18 583 753 ; +C -1 ; WX 600 ; N aogonek ; B 53 -172 587 441 ; +C -1 ; WX 600 ; N Uacute ; B 17 -18 583 805 ; +C -1 ; WX 600 ; N uogonek ; B 21 -172 590 426 ; +C -1 ; WX 600 ; N Edieresis ; B 53 0 550 753 ; +C -1 ; WX 600 ; N Dcroat ; B 30 0 574 562 ; +C -1 ; WX 600 ; N commaaccent ; B 198 -250 335 -58 ; +C -1 ; WX 600 ; N copyright ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N Emacron ; B 53 0 550 698 ; +C -1 ; WX 600 ; N ccaron ; B 66 -15 529 669 ; +C -1 ; WX 600 ; N aring ; B 53 -15 559 627 ; +C -1 ; WX 600 ; N Ncommaaccent ; B 7 -250 593 562 ; +C -1 ; WX 600 ; N lacute ; B 95 0 505 805 ; +C -1 ; WX 600 ; N agrave ; B 53 -15 559 672 ; +C -1 ; WX 600 ; N Tcommaaccent ; B 38 -250 563 562 ; +C -1 ; WX 600 ; N Cacute ; B 41 -18 540 805 ; +C -1 ; WX 600 ; N atilde ; B 53 -15 559 606 ; +C -1 ; WX 600 ; N Edotaccent ; B 53 0 550 753 ; +C -1 ; WX 600 ; N scaron ; B 80 -15 513 669 ; +C -1 ; WX 600 ; N scedilla ; B 80 -151 513 441 ; +C -1 ; WX 600 ; N iacute ; B 95 0 505 672 ; +C -1 ; WX 600 ; N lozenge ; B 18 0 443 706 ; +C -1 ; WX 600 ; N Rcaron ; B 38 0 588 802 ; +C -1 ; WX 600 ; N Gcommaaccent ; B 31 -250 575 580 ; +C -1 ; WX 600 ; N ucircumflex ; B 21 -15 562 654 ; +C -1 ; WX 600 ; N acircumflex ; B 53 -15 559 654 ; +C -1 ; WX 600 ; N Amacron ; B 3 0 597 698 ; +C -1 ; WX 600 ; N rcaron ; B 60 0 559 669 ; +C -1 ; WX 600 ; N ccedilla ; B 66 -151 529 441 ; +C -1 ; WX 600 ; N Zdotaccent ; B 86 0 514 753 ; +C -1 ; WX 600 ; N Thorn ; B 79 0 538 562 ; +C -1 ; WX 600 ; N Omacron ; B 43 -18 557 698 ; +C -1 ; WX 600 ; N Racute ; B 38 0 588 805 ; +C -1 ; WX 600 ; N Sacute ; B 72 -20 529 805 ; +C -1 ; WX 600 ; N dcaron ; B 45 -15 715 629 ; +C -1 ; WX 600 ; N Umacron ; B 17 -18 583 698 ; +C -1 ; WX 600 ; N uring ; B 21 -15 562 627 ; +C -1 ; WX 600 ; N threesuperior ; B 155 240 406 622 ; +C -1 ; WX 600 ; N Ograve ; B 43 -18 557 805 ; +C -1 ; WX 600 ; N Agrave ; B 3 0 597 805 ; +C -1 ; WX 600 ; N Abreve ; B 3 0 597 732 ; +C -1 ; WX 600 ; N multiply ; B 87 43 515 470 ; +C -1 ; WX 600 ; N uacute ; B 21 -15 562 672 ; +C -1 ; WX 600 ; N Tcaron ; B 38 0 563 802 ; +C -1 ; WX 600 ; N partialdiff ; B 17 -38 459 710 ; +C -1 ; WX 600 ; N ydieresis ; B 7 -157 592 620 ; +C -1 ; WX 600 ; N Nacute ; B 7 -13 593 805 ; +C -1 ; WX 600 ; N icircumflex ; B 94 0 505 654 ; +C -1 ; WX 600 ; N Ecircumflex ; B 53 0 550 787 ; +C -1 ; WX 600 ; N adieresis ; B 53 -15 559 620 ; +C -1 ; WX 600 ; N edieresis ; B 66 -15 548 620 ; +C -1 ; WX 600 ; N cacute ; B 66 -15 529 672 ; +C -1 ; WX 600 ; N nacute ; B 26 0 575 672 ; +C -1 ; WX 600 ; N umacron ; B 21 -15 562 565 ; +C -1 ; WX 600 ; N Ncaron ; B 7 -13 593 802 ; +C -1 ; WX 600 ; N Iacute ; B 96 0 504 805 ; +C -1 ; WX 600 ; N plusminus ; B 87 44 513 558 ; +C -1 ; WX 600 ; N brokenbar ; B 275 -175 326 675 ; +C -1 ; WX 600 ; N registered ; B 0 -18 600 580 ; +C -1 ; WX 600 ; N Gbreve ; B 31 -18 575 732 ; +C -1 ; WX 600 ; N Idotaccent ; B 96 0 504 753 ; +C -1 ; WX 600 ; N summation ; B 15 -10 585 706 ; +C -1 ; WX 600 ; N Egrave ; B 53 0 550 805 ; +C -1 ; WX 600 ; N racute ; B 60 0 559 672 ; +C -1 ; WX 600 ; N omacron ; B 62 -15 538 565 ; +C -1 ; WX 600 ; N Zacute ; B 86 0 514 805 ; +C -1 ; WX 600 ; N Zcaron ; B 86 0 514 802 ; +C -1 ; WX 600 ; N greaterequal ; B 98 0 502 710 ; +C -1 ; WX 600 ; N Eth ; B 30 0 574 562 ; +C -1 ; WX 600 ; N Ccedilla ; B 41 -151 540 580 ; +C -1 ; WX 600 ; N lcommaaccent ; B 95 -250 505 629 ; +C -1 ; WX 600 ; N tcaron ; B 87 -15 530 717 ; +C -1 ; WX 600 ; N eogonek ; B 66 -172 548 441 ; +C -1 ; WX 600 ; N Uogonek ; B 17 -172 583 562 ; +C -1 ; WX 600 ; N Aacute ; B 3 0 597 805 ; +C -1 ; WX 600 ; N Adieresis ; B 3 0 597 753 ; +C -1 ; WX 600 ; N egrave ; B 66 -15 548 672 ; +C -1 ; WX 600 ; N zacute ; B 99 0 502 672 ; +C -1 ; WX 600 ; N iogonek ; B 95 -172 505 657 ; +C -1 ; WX 600 ; N Oacute ; B 43 -18 557 805 ; +C -1 ; WX 600 ; N oacute ; B 62 -15 538 672 ; +C -1 ; WX 600 ; N amacron ; B 53 -15 559 565 ; +C -1 ; WX 600 ; N sacute ; B 80 -15 513 672 ; +C -1 ; WX 600 ; N idieresis ; B 95 0 505 620 ; +C -1 ; WX 600 ; N Ocircumflex ; B 43 -18 557 787 ; +C -1 ; WX 600 ; N Ugrave ; B 17 -18 583 805 ; +C -1 ; WX 600 ; N Delta ; B 6 0 598 688 ; +C -1 ; WX 600 ; N thorn ; B -6 -157 555 629 ; +C -1 ; WX 600 ; N twosuperior ; B 177 249 424 622 ; +C -1 ; WX 600 ; N Odieresis ; B 43 -18 557 753 ; +C -1 ; WX 600 ; N mu ; B 21 -157 562 426 ; +C -1 ; WX 600 ; N igrave ; B 95 0 505 672 ; +C -1 ; WX 600 ; N ohungarumlaut ; B 62 -15 580 672 ; +C -1 ; WX 600 ; N Eogonek ; B 53 -172 561 562 ; +C -1 ; WX 600 ; N dcroat ; B 45 -15 591 629 ; +C -1 ; WX 600 ; N threequarters ; B 8 -56 593 666 ; +C -1 ; WX 600 ; N Scedilla ; B 72 -151 529 580 ; +C -1 ; WX 600 ; N lcaron ; B 95 0 533 629 ; +C -1 ; WX 600 ; N Kcommaaccent ; B 38 -250 582 562 ; +C -1 ; WX 600 ; N Lacute ; B 47 0 554 805 ; +C -1 ; WX 600 ; N trademark ; B -23 263 623 562 ; +C -1 ; WX 600 ; N edotaccent ; B 66 -15 548 620 ; +C -1 ; WX 600 ; N Igrave ; B 96 0 504 805 ; +C -1 ; WX 600 ; N Imacron ; B 96 0 504 698 ; +C -1 ; WX 600 ; N Lcaron ; B 47 0 554 562 ; +C -1 ; WX 600 ; N onehalf ; B 0 -57 611 665 ; +C -1 ; WX 600 ; N lessequal ; B 98 0 502 710 ; +C -1 ; WX 600 ; N ocircumflex ; B 62 -15 538 654 ; +C -1 ; WX 600 ; N ntilde ; B 26 0 575 606 ; +C -1 ; WX 600 ; N Uhungarumlaut ; B 17 -18 590 805 ; +C -1 ; WX 600 ; N Eacute ; B 53 0 550 805 ; +C -1 ; WX 600 ; N emacron ; B 66 -15 548 565 ; +C -1 ; WX 600 ; N gbreve ; B 45 -157 566 609 ; +C -1 ; WX 600 ; N onequarter ; B 0 -57 600 665 ; +C -1 ; WX 600 ; N Scaron ; B 72 -20 529 802 ; +C -1 ; WX 600 ; N Scommaaccent ; B 72 -250 529 580 ; +C -1 ; WX 600 ; N Ohungarumlaut ; B 43 -18 580 805 ; +C -1 ; WX 600 ; N degree ; B 123 269 477 622 ; +C -1 ; WX 600 ; N ograve ; B 62 -15 538 672 ; +C -1 ; WX 600 ; N Ccaron ; B 41 -18 540 802 ; +C -1 ; WX 600 ; N ugrave ; B 21 -15 562 672 ; +C -1 ; WX 600 ; N radical ; B 3 -15 597 792 ; +C -1 ; WX 600 ; N Dcaron ; B 43 0 574 802 ; +C -1 ; WX 600 ; N rcommaaccent ; B 60 -250 559 441 ; +C -1 ; WX 600 ; N Ntilde ; B 7 -13 593 729 ; +C -1 ; WX 600 ; N otilde ; B 62 -15 538 606 ; +C -1 ; WX 600 ; N Rcommaaccent ; B 38 -250 588 562 ; +C -1 ; WX 600 ; N Lcommaaccent ; B 47 -250 554 562 ; +C -1 ; WX 600 ; N Atilde ; B 3 0 597 729 ; +C -1 ; WX 600 ; N Aogonek ; B 3 -172 608 562 ; +C -1 ; WX 600 ; N Aring ; B 3 0 597 750 ; +C -1 ; WX 600 ; N Otilde ; B 43 -18 557 729 ; +C -1 ; WX 600 ; N zdotaccent ; B 99 0 502 620 ; +C -1 ; WX 600 ; N Ecaron ; B 53 0 550 802 ; +C -1 ; WX 600 ; N Iogonek ; B 96 -172 504 562 ; +C -1 ; WX 600 ; N kcommaaccent ; B 43 -250 580 629 ; +C -1 ; WX 600 ; N minus ; B 80 232 520 283 ; +C -1 ; WX 600 ; N Icircumflex ; B 96 0 504 787 ; +C -1 ; WX 600 ; N ncaron ; B 26 0 575 669 ; +C -1 ; WX 600 ; N tcommaaccent ; B 87 -250 530 561 ; +C -1 ; WX 600 ; N logicalnot ; B 87 108 513 369 ; +C -1 ; WX 600 ; N odieresis ; B 62 -15 538 620 ; +C -1 ; WX 600 ; N udieresis ; B 21 -15 562 620 ; +C -1 ; WX 600 ; N notequal ; B 15 -16 540 529 ; +C -1 ; WX 600 ; N gcommaaccent ; B 45 -157 566 708 ; +C -1 ; WX 600 ; N eth ; B 62 -15 538 629 ; +C -1 ; WX 600 ; N zcaron ; B 99 0 502 669 ; +C -1 ; WX 600 ; N ncommaaccent ; B 26 -250 575 441 ; +C -1 ; WX 600 ; N onesuperior ; B 172 249 428 622 ; +C -1 ; WX 600 ; N imacron ; B 95 0 505 565 ; +C -1 ; WX 600 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Bold.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Bold.afm new file mode 100644 index 00000000..837c594e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Bold.afm @@ -0,0 +1,2827 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:43:52 1997 +Comment UniqueID 43052 +Comment VMusage 37169 48194 +FontName Helvetica-Bold +FullName Helvetica Bold +FamilyName Helvetica +Weight Bold +ItalicAngle 0 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -170 -228 1003 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StdHW 118 +StdVW 140 +StartCharMetrics 315 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 90 0 244 718 ; +C 34 ; WX 474 ; N quotedbl ; B 98 447 376 718 ; +C 35 ; WX 556 ; N numbersign ; B 18 0 538 698 ; +C 36 ; WX 556 ; N dollar ; B 30 -115 523 775 ; +C 37 ; WX 889 ; N percent ; B 28 -19 861 710 ; +C 38 ; WX 722 ; N ampersand ; B 54 -19 701 718 ; +C 39 ; WX 278 ; N quoteright ; B 69 445 209 718 ; +C 40 ; WX 333 ; N parenleft ; B 35 -208 314 734 ; +C 41 ; WX 333 ; N parenright ; B 19 -208 298 734 ; +C 42 ; WX 389 ; N asterisk ; B 27 387 362 718 ; +C 43 ; WX 584 ; N plus ; B 40 0 544 506 ; +C 44 ; WX 278 ; N comma ; B 64 -168 214 146 ; +C 45 ; WX 333 ; N hyphen ; B 27 215 306 345 ; +C 46 ; WX 278 ; N period ; B 64 0 214 146 ; +C 47 ; WX 278 ; N slash ; B -33 -19 311 737 ; +C 48 ; WX 556 ; N zero ; B 32 -19 524 710 ; +C 49 ; WX 556 ; N one ; B 69 0 378 710 ; +C 50 ; WX 556 ; N two ; B 26 0 511 710 ; +C 51 ; WX 556 ; N three ; B 27 -19 516 710 ; +C 52 ; WX 556 ; N four ; B 27 0 526 710 ; +C 53 ; WX 556 ; N five ; B 27 -19 516 698 ; +C 54 ; WX 556 ; N six ; B 31 -19 520 710 ; +C 55 ; WX 556 ; N seven ; B 25 0 528 698 ; +C 56 ; WX 556 ; N eight ; B 32 -19 524 710 ; +C 57 ; WX 556 ; N nine ; B 30 -19 522 710 ; +C 58 ; WX 333 ; N colon ; B 92 0 242 512 ; +C 59 ; WX 333 ; N semicolon ; B 92 -168 242 512 ; +C 60 ; WX 584 ; N less ; B 38 -8 546 514 ; +C 61 ; WX 584 ; N equal ; B 40 87 544 419 ; +C 62 ; WX 584 ; N greater ; B 38 -8 546 514 ; +C 63 ; WX 611 ; N question ; B 60 0 556 727 ; +C 64 ; WX 975 ; N at ; B 118 -19 856 737 ; +C 65 ; WX 722 ; N A ; B 20 0 702 718 ; +C 66 ; WX 722 ; N B ; B 76 0 669 718 ; +C 67 ; WX 722 ; N C ; B 44 -19 684 737 ; +C 68 ; WX 722 ; N D ; B 76 0 685 718 ; +C 69 ; WX 667 ; N E ; B 76 0 621 718 ; +C 70 ; WX 611 ; N F ; B 76 0 587 718 ; +C 71 ; WX 778 ; N G ; B 44 -19 713 737 ; +C 72 ; WX 722 ; N H ; B 71 0 651 718 ; +C 73 ; WX 278 ; N I ; B 64 0 214 718 ; +C 74 ; WX 556 ; N J ; B 22 -18 484 718 ; +C 75 ; WX 722 ; N K ; B 87 0 722 718 ; +C 76 ; WX 611 ; N L ; B 76 0 583 718 ; +C 77 ; WX 833 ; N M ; B 69 0 765 718 ; +C 78 ; WX 722 ; N N ; B 69 0 654 718 ; +C 79 ; WX 778 ; N O ; B 44 -19 734 737 ; +C 80 ; WX 667 ; N P ; B 76 0 627 718 ; +C 81 ; WX 778 ; N Q ; B 44 -52 737 737 ; +C 82 ; WX 722 ; N R ; B 76 0 677 718 ; +C 83 ; WX 667 ; N S ; B 39 -19 629 737 ; +C 84 ; WX 611 ; N T ; B 14 0 598 718 ; +C 85 ; WX 722 ; N U ; B 72 -19 651 718 ; +C 86 ; WX 667 ; N V ; B 19 0 648 718 ; +C 87 ; WX 944 ; N W ; B 16 0 929 718 ; +C 88 ; WX 667 ; N X ; B 14 0 653 718 ; +C 89 ; WX 667 ; N Y ; B 15 0 653 718 ; +C 90 ; WX 611 ; N Z ; B 25 0 586 718 ; +C 91 ; WX 333 ; N bracketleft ; B 63 -196 309 722 ; +C 92 ; WX 278 ; N backslash ; B -33 -19 311 737 ; +C 93 ; WX 333 ; N bracketright ; B 24 -196 270 722 ; +C 94 ; WX 584 ; N asciicircum ; B 62 323 522 698 ; +C 95 ; WX 556 ; N underscore ; B 0 -125 556 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 69 454 209 727 ; +C 97 ; WX 556 ; N a ; B 29 -14 527 546 ; +C 98 ; WX 611 ; N b ; B 61 -14 578 718 ; +C 99 ; WX 556 ; N c ; B 34 -14 524 546 ; +C 100 ; WX 611 ; N d ; B 34 -14 551 718 ; +C 101 ; WX 556 ; N e ; B 23 -14 528 546 ; +C 102 ; WX 333 ; N f ; B 10 0 318 727 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 40 -217 553 546 ; +C 104 ; WX 611 ; N h ; B 65 0 546 718 ; +C 105 ; WX 278 ; N i ; B 69 0 209 725 ; +C 106 ; WX 278 ; N j ; B 3 -214 209 725 ; +C 107 ; WX 556 ; N k ; B 69 0 562 718 ; +C 108 ; WX 278 ; N l ; B 69 0 209 718 ; +C 109 ; WX 889 ; N m ; B 64 0 826 546 ; +C 110 ; WX 611 ; N n ; B 65 0 546 546 ; +C 111 ; WX 611 ; N o ; B 34 -14 578 546 ; +C 112 ; WX 611 ; N p ; B 62 -207 578 546 ; +C 113 ; WX 611 ; N q ; B 34 -207 552 546 ; +C 114 ; WX 389 ; N r ; B 64 0 373 546 ; +C 115 ; WX 556 ; N s ; B 30 -14 519 546 ; +C 116 ; WX 333 ; N t ; B 10 -6 309 676 ; +C 117 ; WX 611 ; N u ; B 66 -14 545 532 ; +C 118 ; WX 556 ; N v ; B 13 0 543 532 ; +C 119 ; WX 778 ; N w ; B 10 0 769 532 ; +C 120 ; WX 556 ; N x ; B 15 0 541 532 ; +C 121 ; WX 556 ; N y ; B 10 -214 539 532 ; +C 122 ; WX 500 ; N z ; B 20 0 480 532 ; +C 123 ; WX 389 ; N braceleft ; B 48 -196 365 722 ; +C 124 ; WX 280 ; N bar ; B 84 -225 196 775 ; +C 125 ; WX 389 ; N braceright ; B 24 -196 341 722 ; +C 126 ; WX 584 ; N asciitilde ; B 61 163 523 343 ; +C 161 ; WX 333 ; N exclamdown ; B 90 -186 244 532 ; +C 162 ; WX 556 ; N cent ; B 34 -118 524 628 ; +C 163 ; WX 556 ; N sterling ; B 28 -16 541 718 ; +C 164 ; WX 167 ; N fraction ; B -170 -19 336 710 ; +C 165 ; WX 556 ; N yen ; B -9 0 565 698 ; +C 166 ; WX 556 ; N florin ; B -10 -210 516 737 ; +C 167 ; WX 556 ; N section ; B 34 -184 522 727 ; +C 168 ; WX 556 ; N currency ; B -3 76 559 636 ; +C 169 ; WX 238 ; N quotesingle ; B 70 447 168 718 ; +C 170 ; WX 500 ; N quotedblleft ; B 64 454 436 727 ; +C 171 ; WX 556 ; N guillemotleft ; B 88 76 468 484 ; +C 172 ; WX 333 ; N guilsinglleft ; B 83 76 250 484 ; +C 173 ; WX 333 ; N guilsinglright ; B 83 76 250 484 ; +C 174 ; WX 611 ; N fi ; B 10 0 542 727 ; +C 175 ; WX 611 ; N fl ; B 10 0 542 727 ; +C 177 ; WX 556 ; N endash ; B 0 227 556 333 ; +C 178 ; WX 556 ; N dagger ; B 36 -171 520 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 36 -171 520 718 ; +C 180 ; WX 278 ; N periodcentered ; B 58 172 220 334 ; +C 182 ; WX 556 ; N paragraph ; B -8 -191 539 700 ; +C 183 ; WX 350 ; N bullet ; B 10 194 340 524 ; +C 184 ; WX 278 ; N quotesinglbase ; B 69 -146 209 127 ; +C 185 ; WX 500 ; N quotedblbase ; B 64 -146 436 127 ; +C 186 ; WX 500 ; N quotedblright ; B 64 445 436 718 ; +C 187 ; WX 556 ; N guillemotright ; B 88 76 468 484 ; +C 188 ; WX 1000 ; N ellipsis ; B 92 0 908 146 ; +C 189 ; WX 1000 ; N perthousand ; B -3 -19 1003 710 ; +C 191 ; WX 611 ; N questiondown ; B 55 -195 551 532 ; +C 193 ; WX 333 ; N grave ; B -23 604 225 750 ; +C 194 ; WX 333 ; N acute ; B 108 604 356 750 ; +C 195 ; WX 333 ; N circumflex ; B -10 604 343 750 ; +C 196 ; WX 333 ; N tilde ; B -17 610 350 737 ; +C 197 ; WX 333 ; N macron ; B -6 604 339 678 ; +C 198 ; WX 333 ; N breve ; B -2 604 335 750 ; +C 199 ; WX 333 ; N dotaccent ; B 104 614 230 729 ; +C 200 ; WX 333 ; N dieresis ; B 6 614 327 729 ; +C 202 ; WX 333 ; N ring ; B 59 568 275 776 ; +C 203 ; WX 333 ; N cedilla ; B 6 -228 245 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 9 604 486 750 ; +C 206 ; WX 333 ; N ogonek ; B 71 -228 304 0 ; +C 207 ; WX 333 ; N caron ; B -10 604 343 750 ; +C 208 ; WX 1000 ; N emdash ; B 0 227 1000 333 ; +C 225 ; WX 1000 ; N AE ; B 5 0 954 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 22 401 347 737 ; +C 232 ; WX 611 ; N Lslash ; B -20 0 583 718 ; +C 233 ; WX 778 ; N Oslash ; B 33 -27 744 745 ; +C 234 ; WX 1000 ; N OE ; B 37 -19 961 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 6 401 360 737 ; +C 241 ; WX 889 ; N ae ; B 29 -14 858 546 ; +C 245 ; WX 278 ; N dotlessi ; B 69 0 209 532 ; +C 248 ; WX 278 ; N lslash ; B -18 0 296 718 ; +C 249 ; WX 611 ; N oslash ; B 22 -29 589 560 ; +C 250 ; WX 944 ; N oe ; B 34 -14 912 546 ; +C 251 ; WX 611 ; N germandbls ; B 69 -14 579 731 ; +C -1 ; WX 278 ; N Idieresis ; B -21 0 300 915 ; +C -1 ; WX 556 ; N eacute ; B 23 -14 528 750 ; +C -1 ; WX 556 ; N abreve ; B 29 -14 527 750 ; +C -1 ; WX 611 ; N uhungarumlaut ; B 66 -14 625 750 ; +C -1 ; WX 556 ; N ecaron ; B 23 -14 528 750 ; +C -1 ; WX 667 ; N Ydieresis ; B 15 0 653 915 ; +C -1 ; WX 584 ; N divide ; B 40 -42 544 548 ; +C -1 ; WX 667 ; N Yacute ; B 15 0 653 936 ; +C -1 ; WX 722 ; N Acircumflex ; B 20 0 702 936 ; +C -1 ; WX 556 ; N aacute ; B 29 -14 527 750 ; +C -1 ; WX 722 ; N Ucircumflex ; B 72 -19 651 936 ; +C -1 ; WX 556 ; N yacute ; B 10 -214 539 750 ; +C -1 ; WX 556 ; N scommaaccent ; B 30 -228 519 546 ; +C -1 ; WX 556 ; N ecircumflex ; B 23 -14 528 750 ; +C -1 ; WX 722 ; N Uring ; B 72 -19 651 962 ; +C -1 ; WX 722 ; N Udieresis ; B 72 -19 651 915 ; +C -1 ; WX 556 ; N aogonek ; B 29 -224 545 546 ; +C -1 ; WX 722 ; N Uacute ; B 72 -19 651 936 ; +C -1 ; WX 611 ; N uogonek ; B 66 -228 545 532 ; +C -1 ; WX 667 ; N Edieresis ; B 76 0 621 915 ; +C -1 ; WX 722 ; N Dcroat ; B -5 0 685 718 ; +C -1 ; WX 250 ; N commaaccent ; B 64 -228 199 -50 ; +C -1 ; WX 737 ; N copyright ; B -11 -19 749 737 ; +C -1 ; WX 667 ; N Emacron ; B 76 0 621 864 ; +C -1 ; WX 556 ; N ccaron ; B 34 -14 524 750 ; +C -1 ; WX 556 ; N aring ; B 29 -14 527 776 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 69 -228 654 718 ; +C -1 ; WX 278 ; N lacute ; B 69 0 329 936 ; +C -1 ; WX 556 ; N agrave ; B 29 -14 527 750 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 14 -228 598 718 ; +C -1 ; WX 722 ; N Cacute ; B 44 -19 684 936 ; +C -1 ; WX 556 ; N atilde ; B 29 -14 527 737 ; +C -1 ; WX 667 ; N Edotaccent ; B 76 0 621 915 ; +C -1 ; WX 556 ; N scaron ; B 30 -14 519 750 ; +C -1 ; WX 556 ; N scedilla ; B 30 -228 519 546 ; +C -1 ; WX 278 ; N iacute ; B 69 0 329 750 ; +C -1 ; WX 494 ; N lozenge ; B 10 0 484 745 ; +C -1 ; WX 722 ; N Rcaron ; B 76 0 677 936 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 44 -228 713 737 ; +C -1 ; WX 611 ; N ucircumflex ; B 66 -14 545 750 ; +C -1 ; WX 556 ; N acircumflex ; B 29 -14 527 750 ; +C -1 ; WX 722 ; N Amacron ; B 20 0 702 864 ; +C -1 ; WX 389 ; N rcaron ; B 18 0 373 750 ; +C -1 ; WX 556 ; N ccedilla ; B 34 -228 524 546 ; +C -1 ; WX 611 ; N Zdotaccent ; B 25 0 586 915 ; +C -1 ; WX 667 ; N Thorn ; B 76 0 627 718 ; +C -1 ; WX 778 ; N Omacron ; B 44 -19 734 864 ; +C -1 ; WX 722 ; N Racute ; B 76 0 677 936 ; +C -1 ; WX 667 ; N Sacute ; B 39 -19 629 936 ; +C -1 ; WX 743 ; N dcaron ; B 34 -14 750 718 ; +C -1 ; WX 722 ; N Umacron ; B 72 -19 651 864 ; +C -1 ; WX 611 ; N uring ; B 66 -14 545 776 ; +C -1 ; WX 333 ; N threesuperior ; B 8 271 326 710 ; +C -1 ; WX 778 ; N Ograve ; B 44 -19 734 936 ; +C -1 ; WX 722 ; N Agrave ; B 20 0 702 936 ; +C -1 ; WX 722 ; N Abreve ; B 20 0 702 936 ; +C -1 ; WX 584 ; N multiply ; B 40 1 545 505 ; +C -1 ; WX 611 ; N uacute ; B 66 -14 545 750 ; +C -1 ; WX 611 ; N Tcaron ; B 14 0 598 936 ; +C -1 ; WX 494 ; N partialdiff ; B 11 -21 494 750 ; +C -1 ; WX 556 ; N ydieresis ; B 10 -214 539 729 ; +C -1 ; WX 722 ; N Nacute ; B 69 0 654 936 ; +C -1 ; WX 278 ; N icircumflex ; B -37 0 316 750 ; +C -1 ; WX 667 ; N Ecircumflex ; B 76 0 621 936 ; +C -1 ; WX 556 ; N adieresis ; B 29 -14 527 729 ; +C -1 ; WX 556 ; N edieresis ; B 23 -14 528 729 ; +C -1 ; WX 556 ; N cacute ; B 34 -14 524 750 ; +C -1 ; WX 611 ; N nacute ; B 65 0 546 750 ; +C -1 ; WX 611 ; N umacron ; B 66 -14 545 678 ; +C -1 ; WX 722 ; N Ncaron ; B 69 0 654 936 ; +C -1 ; WX 278 ; N Iacute ; B 64 0 329 936 ; +C -1 ; WX 584 ; N plusminus ; B 40 0 544 506 ; +C -1 ; WX 280 ; N brokenbar ; B 84 -150 196 700 ; +C -1 ; WX 737 ; N registered ; B -11 -19 748 737 ; +C -1 ; WX 778 ; N Gbreve ; B 44 -19 713 936 ; +C -1 ; WX 278 ; N Idotaccent ; B 64 0 214 915 ; +C -1 ; WX 600 ; N summation ; B 14 -10 585 706 ; +C -1 ; WX 667 ; N Egrave ; B 76 0 621 936 ; +C -1 ; WX 389 ; N racute ; B 64 0 384 750 ; +C -1 ; WX 611 ; N omacron ; B 34 -14 578 678 ; +C -1 ; WX 611 ; N Zacute ; B 25 0 586 936 ; +C -1 ; WX 611 ; N Zcaron ; B 25 0 586 936 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 704 ; +C -1 ; WX 722 ; N Eth ; B -5 0 685 718 ; +C -1 ; WX 722 ; N Ccedilla ; B 44 -228 684 737 ; +C -1 ; WX 278 ; N lcommaaccent ; B 69 -228 213 718 ; +C -1 ; WX 389 ; N tcaron ; B 10 -6 421 878 ; +C -1 ; WX 556 ; N eogonek ; B 23 -228 528 546 ; +C -1 ; WX 722 ; N Uogonek ; B 72 -228 651 718 ; +C -1 ; WX 722 ; N Aacute ; B 20 0 702 936 ; +C -1 ; WX 722 ; N Adieresis ; B 20 0 702 915 ; +C -1 ; WX 556 ; N egrave ; B 23 -14 528 750 ; +C -1 ; WX 500 ; N zacute ; B 20 0 480 750 ; +C -1 ; WX 278 ; N iogonek ; B 16 -224 249 725 ; +C -1 ; WX 778 ; N Oacute ; B 44 -19 734 936 ; +C -1 ; WX 611 ; N oacute ; B 34 -14 578 750 ; +C -1 ; WX 556 ; N amacron ; B 29 -14 527 678 ; +C -1 ; WX 556 ; N sacute ; B 30 -14 519 750 ; +C -1 ; WX 278 ; N idieresis ; B -21 0 300 729 ; +C -1 ; WX 778 ; N Ocircumflex ; B 44 -19 734 936 ; +C -1 ; WX 722 ; N Ugrave ; B 72 -19 651 936 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 611 ; N thorn ; B 62 -208 578 718 ; +C -1 ; WX 333 ; N twosuperior ; B 9 283 324 710 ; +C -1 ; WX 778 ; N Odieresis ; B 44 -19 734 915 ; +C -1 ; WX 611 ; N mu ; B 66 -207 545 532 ; +C -1 ; WX 278 ; N igrave ; B -50 0 209 750 ; +C -1 ; WX 611 ; N ohungarumlaut ; B 34 -14 625 750 ; +C -1 ; WX 667 ; N Eogonek ; B 76 -224 639 718 ; +C -1 ; WX 611 ; N dcroat ; B 34 -14 650 718 ; +C -1 ; WX 834 ; N threequarters ; B 16 -19 799 710 ; +C -1 ; WX 667 ; N Scedilla ; B 39 -228 629 737 ; +C -1 ; WX 400 ; N lcaron ; B 69 0 408 718 ; +C -1 ; WX 722 ; N Kcommaaccent ; B 87 -228 722 718 ; +C -1 ; WX 611 ; N Lacute ; B 76 0 583 936 ; +C -1 ; WX 1000 ; N trademark ; B 44 306 956 718 ; +C -1 ; WX 556 ; N edotaccent ; B 23 -14 528 729 ; +C -1 ; WX 278 ; N Igrave ; B -50 0 214 936 ; +C -1 ; WX 278 ; N Imacron ; B -33 0 312 864 ; +C -1 ; WX 611 ; N Lcaron ; B 76 0 583 718 ; +C -1 ; WX 834 ; N onehalf ; B 26 -19 794 710 ; +C -1 ; WX 549 ; N lessequal ; B 29 0 526 704 ; +C -1 ; WX 611 ; N ocircumflex ; B 34 -14 578 750 ; +C -1 ; WX 611 ; N ntilde ; B 65 0 546 737 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 72 -19 681 936 ; +C -1 ; WX 667 ; N Eacute ; B 76 0 621 936 ; +C -1 ; WX 556 ; N emacron ; B 23 -14 528 678 ; +C -1 ; WX 611 ; N gbreve ; B 40 -217 553 750 ; +C -1 ; WX 834 ; N onequarter ; B 26 -19 766 710 ; +C -1 ; WX 667 ; N Scaron ; B 39 -19 629 936 ; +C -1 ; WX 667 ; N Scommaaccent ; B 39 -228 629 737 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 44 -19 734 936 ; +C -1 ; WX 400 ; N degree ; B 57 426 343 712 ; +C -1 ; WX 611 ; N ograve ; B 34 -14 578 750 ; +C -1 ; WX 722 ; N Ccaron ; B 44 -19 684 936 ; +C -1 ; WX 611 ; N ugrave ; B 66 -14 545 750 ; +C -1 ; WX 549 ; N radical ; B 10 -46 512 850 ; +C -1 ; WX 722 ; N Dcaron ; B 76 0 685 936 ; +C -1 ; WX 389 ; N rcommaaccent ; B 64 -228 373 546 ; +C -1 ; WX 722 ; N Ntilde ; B 69 0 654 923 ; +C -1 ; WX 611 ; N otilde ; B 34 -14 578 737 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 76 -228 677 718 ; +C -1 ; WX 611 ; N Lcommaaccent ; B 76 -228 583 718 ; +C -1 ; WX 722 ; N Atilde ; B 20 0 702 923 ; +C -1 ; WX 722 ; N Aogonek ; B 20 -224 742 718 ; +C -1 ; WX 722 ; N Aring ; B 20 0 702 962 ; +C -1 ; WX 778 ; N Otilde ; B 44 -19 734 923 ; +C -1 ; WX 500 ; N zdotaccent ; B 20 0 480 729 ; +C -1 ; WX 667 ; N Ecaron ; B 76 0 621 936 ; +C -1 ; WX 278 ; N Iogonek ; B -11 -228 222 718 ; +C -1 ; WX 556 ; N kcommaaccent ; B 69 -228 562 718 ; +C -1 ; WX 584 ; N minus ; B 40 197 544 309 ; +C -1 ; WX 278 ; N Icircumflex ; B -37 0 316 936 ; +C -1 ; WX 611 ; N ncaron ; B 65 0 546 750 ; +C -1 ; WX 333 ; N tcommaaccent ; B 10 -228 309 676 ; +C -1 ; WX 584 ; N logicalnot ; B 40 108 544 419 ; +C -1 ; WX 611 ; N odieresis ; B 34 -14 578 729 ; +C -1 ; WX 611 ; N udieresis ; B 66 -14 545 729 ; +C -1 ; WX 549 ; N notequal ; B 15 -49 540 570 ; +C -1 ; WX 611 ; N gcommaaccent ; B 40 -217 553 850 ; +C -1 ; WX 611 ; N eth ; B 34 -14 578 737 ; +C -1 ; WX 500 ; N zcaron ; B 20 0 480 750 ; +C -1 ; WX 611 ; N ncommaaccent ; B 65 -228 546 546 ; +C -1 ; WX 333 ; N onesuperior ; B 26 283 237 710 ; +C -1 ; WX 278 ; N imacron ; B -8 0 285 678 ; +C -1 ; WX 556 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2481 +KPX A C -40 +KPX A Cacute -40 +KPX A Ccaron -40 +KPX A Ccedilla -40 +KPX A G -50 +KPX A Gbreve -50 +KPX A Gcommaaccent -50 +KPX A O -40 +KPX A Oacute -40 +KPX A Ocircumflex -40 +KPX A Odieresis -40 +KPX A Ograve -40 +KPX A Ohungarumlaut -40 +KPX A Omacron -40 +KPX A Oslash -40 +KPX A Otilde -40 +KPX A Q -40 +KPX A T -90 +KPX A Tcaron -90 +KPX A Tcommaaccent -90 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -80 +KPX A W -60 +KPX A Y -110 +KPX A Yacute -110 +KPX A Ydieresis -110 +KPX A u -30 +KPX A uacute -30 +KPX A ucircumflex -30 +KPX A udieresis -30 +KPX A ugrave -30 +KPX A uhungarumlaut -30 +KPX A umacron -30 +KPX A uogonek -30 +KPX A uring -30 +KPX A v -40 +KPX A w -30 +KPX A y -30 +KPX A yacute -30 +KPX A ydieresis -30 +KPX Aacute C -40 +KPX Aacute Cacute -40 +KPX Aacute Ccaron -40 +KPX Aacute Ccedilla -40 +KPX Aacute G -50 +KPX Aacute Gbreve -50 +KPX Aacute Gcommaaccent -50 +KPX Aacute O -40 +KPX Aacute Oacute -40 +KPX Aacute Ocircumflex -40 +KPX Aacute Odieresis -40 +KPX Aacute Ograve -40 +KPX Aacute Ohungarumlaut -40 +KPX Aacute Omacron -40 +KPX Aacute Oslash -40 +KPX Aacute Otilde -40 +KPX Aacute Q -40 +KPX Aacute T -90 +KPX Aacute Tcaron -90 +KPX Aacute Tcommaaccent -90 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -80 +KPX Aacute W -60 +KPX Aacute Y -110 +KPX Aacute Yacute -110 +KPX Aacute Ydieresis -110 +KPX Aacute u -30 +KPX Aacute uacute -30 +KPX Aacute ucircumflex -30 +KPX Aacute udieresis -30 +KPX Aacute ugrave -30 +KPX Aacute uhungarumlaut -30 +KPX Aacute umacron -30 +KPX Aacute uogonek -30 +KPX Aacute uring -30 +KPX Aacute v -40 +KPX Aacute w -30 +KPX Aacute y -30 +KPX Aacute yacute -30 +KPX Aacute ydieresis -30 +KPX Abreve C -40 +KPX Abreve Cacute -40 +KPX Abreve Ccaron -40 +KPX Abreve Ccedilla -40 +KPX Abreve G -50 +KPX Abreve Gbreve -50 +KPX Abreve Gcommaaccent -50 +KPX Abreve O -40 +KPX Abreve Oacute -40 +KPX Abreve Ocircumflex -40 +KPX Abreve Odieresis -40 +KPX Abreve Ograve -40 +KPX Abreve Ohungarumlaut -40 +KPX Abreve Omacron -40 +KPX Abreve Oslash -40 +KPX Abreve Otilde -40 +KPX Abreve Q -40 +KPX Abreve T -90 +KPX Abreve Tcaron -90 +KPX Abreve Tcommaaccent -90 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -80 +KPX Abreve W -60 +KPX Abreve Y -110 +KPX Abreve Yacute -110 +KPX Abreve Ydieresis -110 +KPX Abreve u -30 +KPX Abreve uacute -30 +KPX Abreve ucircumflex -30 +KPX Abreve udieresis -30 +KPX Abreve ugrave -30 +KPX Abreve uhungarumlaut -30 +KPX Abreve umacron -30 +KPX Abreve uogonek -30 +KPX Abreve uring -30 +KPX Abreve v -40 +KPX Abreve w -30 +KPX Abreve y -30 +KPX Abreve yacute -30 +KPX Abreve ydieresis -30 +KPX Acircumflex C -40 +KPX Acircumflex Cacute -40 +KPX Acircumflex Ccaron -40 +KPX Acircumflex Ccedilla -40 +KPX Acircumflex G -50 +KPX Acircumflex Gbreve -50 +KPX Acircumflex Gcommaaccent -50 +KPX Acircumflex O -40 +KPX Acircumflex Oacute -40 +KPX Acircumflex Ocircumflex -40 +KPX Acircumflex Odieresis -40 +KPX Acircumflex Ograve -40 +KPX Acircumflex Ohungarumlaut -40 +KPX Acircumflex Omacron -40 +KPX Acircumflex Oslash -40 +KPX Acircumflex Otilde -40 +KPX Acircumflex Q -40 +KPX Acircumflex T -90 +KPX Acircumflex Tcaron -90 +KPX Acircumflex Tcommaaccent -90 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -80 +KPX Acircumflex W -60 +KPX Acircumflex Y -110 +KPX Acircumflex Yacute -110 +KPX Acircumflex Ydieresis -110 +KPX Acircumflex u -30 +KPX Acircumflex uacute -30 +KPX Acircumflex ucircumflex -30 +KPX Acircumflex udieresis -30 +KPX Acircumflex ugrave -30 +KPX Acircumflex uhungarumlaut -30 +KPX Acircumflex umacron -30 +KPX Acircumflex uogonek -30 +KPX Acircumflex uring -30 +KPX Acircumflex v -40 +KPX Acircumflex w -30 +KPX Acircumflex y -30 +KPX Acircumflex yacute -30 +KPX Acircumflex ydieresis -30 +KPX Adieresis C -40 +KPX Adieresis Cacute -40 +KPX Adieresis Ccaron -40 +KPX Adieresis Ccedilla -40 +KPX Adieresis G -50 +KPX Adieresis Gbreve -50 +KPX Adieresis Gcommaaccent -50 +KPX Adieresis O -40 +KPX Adieresis Oacute -40 +KPX Adieresis Ocircumflex -40 +KPX Adieresis Odieresis -40 +KPX Adieresis Ograve -40 +KPX Adieresis Ohungarumlaut -40 +KPX Adieresis Omacron -40 +KPX Adieresis Oslash -40 +KPX Adieresis Otilde -40 +KPX Adieresis Q -40 +KPX Adieresis T -90 +KPX Adieresis Tcaron -90 +KPX Adieresis Tcommaaccent -90 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -80 +KPX Adieresis W -60 +KPX Adieresis Y -110 +KPX Adieresis Yacute -110 +KPX Adieresis Ydieresis -110 +KPX Adieresis u -30 +KPX Adieresis uacute -30 +KPX Adieresis ucircumflex -30 +KPX Adieresis udieresis -30 +KPX Adieresis ugrave -30 +KPX Adieresis uhungarumlaut -30 +KPX Adieresis umacron -30 +KPX Adieresis uogonek -30 +KPX Adieresis uring -30 +KPX Adieresis v -40 +KPX Adieresis w -30 +KPX Adieresis y -30 +KPX Adieresis yacute -30 +KPX Adieresis ydieresis -30 +KPX Agrave C -40 +KPX Agrave Cacute -40 +KPX Agrave Ccaron -40 +KPX Agrave Ccedilla -40 +KPX Agrave G -50 +KPX Agrave Gbreve -50 +KPX Agrave Gcommaaccent -50 +KPX Agrave O -40 +KPX Agrave Oacute -40 +KPX Agrave Ocircumflex -40 +KPX Agrave Odieresis -40 +KPX Agrave Ograve -40 +KPX Agrave Ohungarumlaut -40 +KPX Agrave Omacron -40 +KPX Agrave Oslash -40 +KPX Agrave Otilde -40 +KPX Agrave Q -40 +KPX Agrave T -90 +KPX Agrave Tcaron -90 +KPX Agrave Tcommaaccent -90 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -80 +KPX Agrave W -60 +KPX Agrave Y -110 +KPX Agrave Yacute -110 +KPX Agrave Ydieresis -110 +KPX Agrave u -30 +KPX Agrave uacute -30 +KPX Agrave ucircumflex -30 +KPX Agrave udieresis -30 +KPX Agrave ugrave -30 +KPX Agrave uhungarumlaut -30 +KPX Agrave umacron -30 +KPX Agrave uogonek -30 +KPX Agrave uring -30 +KPX Agrave v -40 +KPX Agrave w -30 +KPX Agrave y -30 +KPX Agrave yacute -30 +KPX Agrave ydieresis -30 +KPX Amacron C -40 +KPX Amacron Cacute -40 +KPX Amacron Ccaron -40 +KPX Amacron Ccedilla -40 +KPX Amacron G -50 +KPX Amacron Gbreve -50 +KPX Amacron Gcommaaccent -50 +KPX Amacron O -40 +KPX Amacron Oacute -40 +KPX Amacron Ocircumflex -40 +KPX Amacron Odieresis -40 +KPX Amacron Ograve -40 +KPX Amacron Ohungarumlaut -40 +KPX Amacron Omacron -40 +KPX Amacron Oslash -40 +KPX Amacron Otilde -40 +KPX Amacron Q -40 +KPX Amacron T -90 +KPX Amacron Tcaron -90 +KPX Amacron Tcommaaccent -90 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -80 +KPX Amacron W -60 +KPX Amacron Y -110 +KPX Amacron Yacute -110 +KPX Amacron Ydieresis -110 +KPX Amacron u -30 +KPX Amacron uacute -30 +KPX Amacron ucircumflex -30 +KPX Amacron udieresis -30 +KPX Amacron ugrave -30 +KPX Amacron uhungarumlaut -30 +KPX Amacron umacron -30 +KPX Amacron uogonek -30 +KPX Amacron uring -30 +KPX Amacron v -40 +KPX Amacron w -30 +KPX Amacron y -30 +KPX Amacron yacute -30 +KPX Amacron ydieresis -30 +KPX Aogonek C -40 +KPX Aogonek Cacute -40 +KPX Aogonek Ccaron -40 +KPX Aogonek Ccedilla -40 +KPX Aogonek G -50 +KPX Aogonek Gbreve -50 +KPX Aogonek Gcommaaccent -50 +KPX Aogonek O -40 +KPX Aogonek Oacute -40 +KPX Aogonek Ocircumflex -40 +KPX Aogonek Odieresis -40 +KPX Aogonek Ograve -40 +KPX Aogonek Ohungarumlaut -40 +KPX Aogonek Omacron -40 +KPX Aogonek Oslash -40 +KPX Aogonek Otilde -40 +KPX Aogonek Q -40 +KPX Aogonek T -90 +KPX Aogonek Tcaron -90 +KPX Aogonek Tcommaaccent -90 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -80 +KPX Aogonek W -60 +KPX Aogonek Y -110 +KPX Aogonek Yacute -110 +KPX Aogonek Ydieresis -110 +KPX Aogonek u -30 +KPX Aogonek uacute -30 +KPX Aogonek ucircumflex -30 +KPX Aogonek udieresis -30 +KPX Aogonek ugrave -30 +KPX Aogonek uhungarumlaut -30 +KPX Aogonek umacron -30 +KPX Aogonek uogonek -30 +KPX Aogonek uring -30 +KPX Aogonek v -40 +KPX Aogonek w -30 +KPX Aogonek y -30 +KPX Aogonek yacute -30 +KPX Aogonek ydieresis -30 +KPX Aring C -40 +KPX Aring Cacute -40 +KPX Aring Ccaron -40 +KPX Aring Ccedilla -40 +KPX Aring G -50 +KPX Aring Gbreve -50 +KPX Aring Gcommaaccent -50 +KPX Aring O -40 +KPX Aring Oacute -40 +KPX Aring Ocircumflex -40 +KPX Aring Odieresis -40 +KPX Aring Ograve -40 +KPX Aring Ohungarumlaut -40 +KPX Aring Omacron -40 +KPX Aring Oslash -40 +KPX Aring Otilde -40 +KPX Aring Q -40 +KPX Aring T -90 +KPX Aring Tcaron -90 +KPX Aring Tcommaaccent -90 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -80 +KPX Aring W -60 +KPX Aring Y -110 +KPX Aring Yacute -110 +KPX Aring Ydieresis -110 +KPX Aring u -30 +KPX Aring uacute -30 +KPX Aring ucircumflex -30 +KPX Aring udieresis -30 +KPX Aring ugrave -30 +KPX Aring uhungarumlaut -30 +KPX Aring umacron -30 +KPX Aring uogonek -30 +KPX Aring uring -30 +KPX Aring v -40 +KPX Aring w -30 +KPX Aring y -30 +KPX Aring yacute -30 +KPX Aring ydieresis -30 +KPX Atilde C -40 +KPX Atilde Cacute -40 +KPX Atilde Ccaron -40 +KPX Atilde Ccedilla -40 +KPX Atilde G -50 +KPX Atilde Gbreve -50 +KPX Atilde Gcommaaccent -50 +KPX Atilde O -40 +KPX Atilde Oacute -40 +KPX Atilde Ocircumflex -40 +KPX Atilde Odieresis -40 +KPX Atilde Ograve -40 +KPX Atilde Ohungarumlaut -40 +KPX Atilde Omacron -40 +KPX Atilde Oslash -40 +KPX Atilde Otilde -40 +KPX Atilde Q -40 +KPX Atilde T -90 +KPX Atilde Tcaron -90 +KPX Atilde Tcommaaccent -90 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -80 +KPX Atilde W -60 +KPX Atilde Y -110 +KPX Atilde Yacute -110 +KPX Atilde Ydieresis -110 +KPX Atilde u -30 +KPX Atilde uacute -30 +KPX Atilde ucircumflex -30 +KPX Atilde udieresis -30 +KPX Atilde ugrave -30 +KPX Atilde uhungarumlaut -30 +KPX Atilde umacron -30 +KPX Atilde uogonek -30 +KPX Atilde uring -30 +KPX Atilde v -40 +KPX Atilde w -30 +KPX Atilde y -30 +KPX Atilde yacute -30 +KPX Atilde ydieresis -30 +KPX B A -30 +KPX B Aacute -30 +KPX B Abreve -30 +KPX B Acircumflex -30 +KPX B Adieresis -30 +KPX B Agrave -30 +KPX B Amacron -30 +KPX B Aogonek -30 +KPX B Aring -30 +KPX B Atilde -30 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -40 +KPX D Aacute -40 +KPX D Abreve -40 +KPX D Acircumflex -40 +KPX D Adieresis -40 +KPX D Agrave -40 +KPX D Amacron -40 +KPX D Aogonek -40 +KPX D Aring -40 +KPX D Atilde -40 +KPX D V -40 +KPX D W -40 +KPX D Y -70 +KPX D Yacute -70 +KPX D Ydieresis -70 +KPX D comma -30 +KPX D period -30 +KPX Dcaron A -40 +KPX Dcaron Aacute -40 +KPX Dcaron Abreve -40 +KPX Dcaron Acircumflex -40 +KPX Dcaron Adieresis -40 +KPX Dcaron Agrave -40 +KPX Dcaron Amacron -40 +KPX Dcaron Aogonek -40 +KPX Dcaron Aring -40 +KPX Dcaron Atilde -40 +KPX Dcaron V -40 +KPX Dcaron W -40 +KPX Dcaron Y -70 +KPX Dcaron Yacute -70 +KPX Dcaron Ydieresis -70 +KPX Dcaron comma -30 +KPX Dcaron period -30 +KPX Dcroat A -40 +KPX Dcroat Aacute -40 +KPX Dcroat Abreve -40 +KPX Dcroat Acircumflex -40 +KPX Dcroat Adieresis -40 +KPX Dcroat Agrave -40 +KPX Dcroat Amacron -40 +KPX Dcroat Aogonek -40 +KPX Dcroat Aring -40 +KPX Dcroat Atilde -40 +KPX Dcroat V -40 +KPX Dcroat W -40 +KPX Dcroat Y -70 +KPX Dcroat Yacute -70 +KPX Dcroat Ydieresis -70 +KPX Dcroat comma -30 +KPX Dcroat period -30 +KPX F A -80 +KPX F Aacute -80 +KPX F Abreve -80 +KPX F Acircumflex -80 +KPX F Adieresis -80 +KPX F Agrave -80 +KPX F Amacron -80 +KPX F Aogonek -80 +KPX F Aring -80 +KPX F Atilde -80 +KPX F a -20 +KPX F aacute -20 +KPX F abreve -20 +KPX F acircumflex -20 +KPX F adieresis -20 +KPX F agrave -20 +KPX F amacron -20 +KPX F aogonek -20 +KPX F aring -20 +KPX F atilde -20 +KPX F comma -100 +KPX F period -100 +KPX J A -20 +KPX J Aacute -20 +KPX J Abreve -20 +KPX J Acircumflex -20 +KPX J Adieresis -20 +KPX J Agrave -20 +KPX J Amacron -20 +KPX J Aogonek -20 +KPX J Aring -20 +KPX J Atilde -20 +KPX J comma -20 +KPX J period -20 +KPX J u -20 +KPX J uacute -20 +KPX J ucircumflex -20 +KPX J udieresis -20 +KPX J ugrave -20 +KPX J uhungarumlaut -20 +KPX J umacron -20 +KPX J uogonek -20 +KPX J uring -20 +KPX K O -30 +KPX K Oacute -30 +KPX K Ocircumflex -30 +KPX K Odieresis -30 +KPX K Ograve -30 +KPX K Ohungarumlaut -30 +KPX K Omacron -30 +KPX K Oslash -30 +KPX K Otilde -30 +KPX K e -15 +KPX K eacute -15 +KPX K ecaron -15 +KPX K ecircumflex -15 +KPX K edieresis -15 +KPX K edotaccent -15 +KPX K egrave -15 +KPX K emacron -15 +KPX K eogonek -15 +KPX K o -35 +KPX K oacute -35 +KPX K ocircumflex -35 +KPX K odieresis -35 +KPX K ograve -35 +KPX K ohungarumlaut -35 +KPX K omacron -35 +KPX K oslash -35 +KPX K otilde -35 +KPX K u -30 +KPX K uacute -30 +KPX K ucircumflex -30 +KPX K udieresis -30 +KPX K ugrave -30 +KPX K uhungarumlaut -30 +KPX K umacron -30 +KPX K uogonek -30 +KPX K uring -30 +KPX K y -40 +KPX K yacute -40 +KPX K ydieresis -40 +KPX Kcommaaccent O -30 +KPX Kcommaaccent Oacute -30 +KPX Kcommaaccent Ocircumflex -30 +KPX Kcommaaccent Odieresis -30 +KPX Kcommaaccent Ograve -30 +KPX Kcommaaccent Ohungarumlaut -30 +KPX Kcommaaccent Omacron -30 +KPX Kcommaaccent Oslash -30 +KPX Kcommaaccent Otilde -30 +KPX Kcommaaccent e -15 +KPX Kcommaaccent eacute -15 +KPX Kcommaaccent ecaron -15 +KPX Kcommaaccent ecircumflex -15 +KPX Kcommaaccent edieresis -15 +KPX Kcommaaccent edotaccent -15 +KPX Kcommaaccent egrave -15 +KPX Kcommaaccent emacron -15 +KPX Kcommaaccent eogonek -15 +KPX Kcommaaccent o -35 +KPX Kcommaaccent oacute -35 +KPX Kcommaaccent ocircumflex -35 +KPX Kcommaaccent odieresis -35 +KPX Kcommaaccent ograve -35 +KPX Kcommaaccent ohungarumlaut -35 +KPX Kcommaaccent omacron -35 +KPX Kcommaaccent oslash -35 +KPX Kcommaaccent otilde -35 +KPX Kcommaaccent u -30 +KPX Kcommaaccent uacute -30 +KPX Kcommaaccent ucircumflex -30 +KPX Kcommaaccent udieresis -30 +KPX Kcommaaccent ugrave -30 +KPX Kcommaaccent uhungarumlaut -30 +KPX Kcommaaccent umacron -30 +KPX Kcommaaccent uogonek -30 +KPX Kcommaaccent uring -30 +KPX Kcommaaccent y -40 +KPX Kcommaaccent yacute -40 +KPX Kcommaaccent ydieresis -40 +KPX L T -90 +KPX L Tcaron -90 +KPX L Tcommaaccent -90 +KPX L V -110 +KPX L W -80 +KPX L Y -120 +KPX L Yacute -120 +KPX L Ydieresis -120 +KPX L quotedblright -140 +KPX L quoteright -140 +KPX L y -30 +KPX L yacute -30 +KPX L ydieresis -30 +KPX Lacute T -90 +KPX Lacute Tcaron -90 +KPX Lacute Tcommaaccent -90 +KPX Lacute V -110 +KPX Lacute W -80 +KPX Lacute Y -120 +KPX Lacute Yacute -120 +KPX Lacute Ydieresis -120 +KPX Lacute quotedblright -140 +KPX Lacute quoteright -140 +KPX Lacute y -30 +KPX Lacute yacute -30 +KPX Lacute ydieresis -30 +KPX Lcommaaccent T -90 +KPX Lcommaaccent Tcaron -90 +KPX Lcommaaccent Tcommaaccent -90 +KPX Lcommaaccent V -110 +KPX Lcommaaccent W -80 +KPX Lcommaaccent Y -120 +KPX Lcommaaccent Yacute -120 +KPX Lcommaaccent Ydieresis -120 +KPX Lcommaaccent quotedblright -140 +KPX Lcommaaccent quoteright -140 +KPX Lcommaaccent y -30 +KPX Lcommaaccent yacute -30 +KPX Lcommaaccent ydieresis -30 +KPX Lslash T -90 +KPX Lslash Tcaron -90 +KPX Lslash Tcommaaccent -90 +KPX Lslash V -110 +KPX Lslash W -80 +KPX Lslash Y -120 +KPX Lslash Yacute -120 +KPX Lslash Ydieresis -120 +KPX Lslash quotedblright -140 +KPX Lslash quoteright -140 +KPX Lslash y -30 +KPX Lslash yacute -30 +KPX Lslash ydieresis -30 +KPX O A -50 +KPX O Aacute -50 +KPX O Abreve -50 +KPX O Acircumflex -50 +KPX O Adieresis -50 +KPX O Agrave -50 +KPX O Amacron -50 +KPX O Aogonek -50 +KPX O Aring -50 +KPX O Atilde -50 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -50 +KPX O X -50 +KPX O Y -70 +KPX O Yacute -70 +KPX O Ydieresis -70 +KPX O comma -40 +KPX O period -40 +KPX Oacute A -50 +KPX Oacute Aacute -50 +KPX Oacute Abreve -50 +KPX Oacute Acircumflex -50 +KPX Oacute Adieresis -50 +KPX Oacute Agrave -50 +KPX Oacute Amacron -50 +KPX Oacute Aogonek -50 +KPX Oacute Aring -50 +KPX Oacute Atilde -50 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -50 +KPX Oacute X -50 +KPX Oacute Y -70 +KPX Oacute Yacute -70 +KPX Oacute Ydieresis -70 +KPX Oacute comma -40 +KPX Oacute period -40 +KPX Ocircumflex A -50 +KPX Ocircumflex Aacute -50 +KPX Ocircumflex Abreve -50 +KPX Ocircumflex Acircumflex -50 +KPX Ocircumflex Adieresis -50 +KPX Ocircumflex Agrave -50 +KPX Ocircumflex Amacron -50 +KPX Ocircumflex Aogonek -50 +KPX Ocircumflex Aring -50 +KPX Ocircumflex Atilde -50 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -50 +KPX Ocircumflex X -50 +KPX Ocircumflex Y -70 +KPX Ocircumflex Yacute -70 +KPX Ocircumflex Ydieresis -70 +KPX Ocircumflex comma -40 +KPX Ocircumflex period -40 +KPX Odieresis A -50 +KPX Odieresis Aacute -50 +KPX Odieresis Abreve -50 +KPX Odieresis Acircumflex -50 +KPX Odieresis Adieresis -50 +KPX Odieresis Agrave -50 +KPX Odieresis Amacron -50 +KPX Odieresis Aogonek -50 +KPX Odieresis Aring -50 +KPX Odieresis Atilde -50 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -50 +KPX Odieresis X -50 +KPX Odieresis Y -70 +KPX Odieresis Yacute -70 +KPX Odieresis Ydieresis -70 +KPX Odieresis comma -40 +KPX Odieresis period -40 +KPX Ograve A -50 +KPX Ograve Aacute -50 +KPX Ograve Abreve -50 +KPX Ograve Acircumflex -50 +KPX Ograve Adieresis -50 +KPX Ograve Agrave -50 +KPX Ograve Amacron -50 +KPX Ograve Aogonek -50 +KPX Ograve Aring -50 +KPX Ograve Atilde -50 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -50 +KPX Ograve X -50 +KPX Ograve Y -70 +KPX Ograve Yacute -70 +KPX Ograve Ydieresis -70 +KPX Ograve comma -40 +KPX Ograve period -40 +KPX Ohungarumlaut A -50 +KPX Ohungarumlaut Aacute -50 +KPX Ohungarumlaut Abreve -50 +KPX Ohungarumlaut Acircumflex -50 +KPX Ohungarumlaut Adieresis -50 +KPX Ohungarumlaut Agrave -50 +KPX Ohungarumlaut Amacron -50 +KPX Ohungarumlaut Aogonek -50 +KPX Ohungarumlaut Aring -50 +KPX Ohungarumlaut Atilde -50 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -50 +KPX Ohungarumlaut X -50 +KPX Ohungarumlaut Y -70 +KPX Ohungarumlaut Yacute -70 +KPX Ohungarumlaut Ydieresis -70 +KPX Ohungarumlaut comma -40 +KPX Ohungarumlaut period -40 +KPX Omacron A -50 +KPX Omacron Aacute -50 +KPX Omacron Abreve -50 +KPX Omacron Acircumflex -50 +KPX Omacron Adieresis -50 +KPX Omacron Agrave -50 +KPX Omacron Amacron -50 +KPX Omacron Aogonek -50 +KPX Omacron Aring -50 +KPX Omacron Atilde -50 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -50 +KPX Omacron X -50 +KPX Omacron Y -70 +KPX Omacron Yacute -70 +KPX Omacron Ydieresis -70 +KPX Omacron comma -40 +KPX Omacron period -40 +KPX Oslash A -50 +KPX Oslash Aacute -50 +KPX Oslash Abreve -50 +KPX Oslash Acircumflex -50 +KPX Oslash Adieresis -50 +KPX Oslash Agrave -50 +KPX Oslash Amacron -50 +KPX Oslash Aogonek -50 +KPX Oslash Aring -50 +KPX Oslash Atilde -50 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -50 +KPX Oslash X -50 +KPX Oslash Y -70 +KPX Oslash Yacute -70 +KPX Oslash Ydieresis -70 +KPX Oslash comma -40 +KPX Oslash period -40 +KPX Otilde A -50 +KPX Otilde Aacute -50 +KPX Otilde Abreve -50 +KPX Otilde Acircumflex -50 +KPX Otilde Adieresis -50 +KPX Otilde Agrave -50 +KPX Otilde Amacron -50 +KPX Otilde Aogonek -50 +KPX Otilde Aring -50 +KPX Otilde Atilde -50 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -50 +KPX Otilde X -50 +KPX Otilde Y -70 +KPX Otilde Yacute -70 +KPX Otilde Ydieresis -70 +KPX Otilde comma -40 +KPX Otilde period -40 +KPX P A -100 +KPX P Aacute -100 +KPX P Abreve -100 +KPX P Acircumflex -100 +KPX P Adieresis -100 +KPX P Agrave -100 +KPX P Amacron -100 +KPX P Aogonek -100 +KPX P Aring -100 +KPX P Atilde -100 +KPX P a -30 +KPX P aacute -30 +KPX P abreve -30 +KPX P acircumflex -30 +KPX P adieresis -30 +KPX P agrave -30 +KPX P amacron -30 +KPX P aogonek -30 +KPX P aring -30 +KPX P atilde -30 +KPX P comma -120 +KPX P e -30 +KPX P eacute -30 +KPX P ecaron -30 +KPX P ecircumflex -30 +KPX P edieresis -30 +KPX P edotaccent -30 +KPX P egrave -30 +KPX P emacron -30 +KPX P eogonek -30 +KPX P o -40 +KPX P oacute -40 +KPX P ocircumflex -40 +KPX P odieresis -40 +KPX P ograve -40 +KPX P ohungarumlaut -40 +KPX P omacron -40 +KPX P oslash -40 +KPX P otilde -40 +KPX P period -120 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX Q comma 20 +KPX Q period 20 +KPX R O -20 +KPX R Oacute -20 +KPX R Ocircumflex -20 +KPX R Odieresis -20 +KPX R Ograve -20 +KPX R Ohungarumlaut -20 +KPX R Omacron -20 +KPX R Oslash -20 +KPX R Otilde -20 +KPX R T -20 +KPX R Tcaron -20 +KPX R Tcommaaccent -20 +KPX R U -20 +KPX R Uacute -20 +KPX R Ucircumflex -20 +KPX R Udieresis -20 +KPX R Ugrave -20 +KPX R Uhungarumlaut -20 +KPX R Umacron -20 +KPX R Uogonek -20 +KPX R Uring -20 +KPX R V -50 +KPX R W -40 +KPX R Y -50 +KPX R Yacute -50 +KPX R Ydieresis -50 +KPX Racute O -20 +KPX Racute Oacute -20 +KPX Racute Ocircumflex -20 +KPX Racute Odieresis -20 +KPX Racute Ograve -20 +KPX Racute Ohungarumlaut -20 +KPX Racute Omacron -20 +KPX Racute Oslash -20 +KPX Racute Otilde -20 +KPX Racute T -20 +KPX Racute Tcaron -20 +KPX Racute Tcommaaccent -20 +KPX Racute U -20 +KPX Racute Uacute -20 +KPX Racute Ucircumflex -20 +KPX Racute Udieresis -20 +KPX Racute Ugrave -20 +KPX Racute Uhungarumlaut -20 +KPX Racute Umacron -20 +KPX Racute Uogonek -20 +KPX Racute Uring -20 +KPX Racute V -50 +KPX Racute W -40 +KPX Racute Y -50 +KPX Racute Yacute -50 +KPX Racute Ydieresis -50 +KPX Rcaron O -20 +KPX Rcaron Oacute -20 +KPX Rcaron Ocircumflex -20 +KPX Rcaron Odieresis -20 +KPX Rcaron Ograve -20 +KPX Rcaron Ohungarumlaut -20 +KPX Rcaron Omacron -20 +KPX Rcaron Oslash -20 +KPX Rcaron Otilde -20 +KPX Rcaron T -20 +KPX Rcaron Tcaron -20 +KPX Rcaron Tcommaaccent -20 +KPX Rcaron U -20 +KPX Rcaron Uacute -20 +KPX Rcaron Ucircumflex -20 +KPX Rcaron Udieresis -20 +KPX Rcaron Ugrave -20 +KPX Rcaron Uhungarumlaut -20 +KPX Rcaron Umacron -20 +KPX Rcaron Uogonek -20 +KPX Rcaron Uring -20 +KPX Rcaron V -50 +KPX Rcaron W -40 +KPX Rcaron Y -50 +KPX Rcaron Yacute -50 +KPX Rcaron Ydieresis -50 +KPX Rcommaaccent O -20 +KPX Rcommaaccent Oacute -20 +KPX Rcommaaccent Ocircumflex -20 +KPX Rcommaaccent Odieresis -20 +KPX Rcommaaccent Ograve -20 +KPX Rcommaaccent Ohungarumlaut -20 +KPX Rcommaaccent Omacron -20 +KPX Rcommaaccent Oslash -20 +KPX Rcommaaccent Otilde -20 +KPX Rcommaaccent T -20 +KPX Rcommaaccent Tcaron -20 +KPX Rcommaaccent Tcommaaccent -20 +KPX Rcommaaccent U -20 +KPX Rcommaaccent Uacute -20 +KPX Rcommaaccent Ucircumflex -20 +KPX Rcommaaccent Udieresis -20 +KPX Rcommaaccent Ugrave -20 +KPX Rcommaaccent Uhungarumlaut -20 +KPX Rcommaaccent Umacron -20 +KPX Rcommaaccent Uogonek -20 +KPX Rcommaaccent Uring -20 +KPX Rcommaaccent V -50 +KPX Rcommaaccent W -40 +KPX Rcommaaccent Y -50 +KPX Rcommaaccent Yacute -50 +KPX Rcommaaccent Ydieresis -50 +KPX T A -90 +KPX T Aacute -90 +KPX T Abreve -90 +KPX T Acircumflex -90 +KPX T Adieresis -90 +KPX T Agrave -90 +KPX T Amacron -90 +KPX T Aogonek -90 +KPX T Aring -90 +KPX T Atilde -90 +KPX T O -40 +KPX T Oacute -40 +KPX T Ocircumflex -40 +KPX T Odieresis -40 +KPX T Ograve -40 +KPX T Ohungarumlaut -40 +KPX T Omacron -40 +KPX T Oslash -40 +KPX T Otilde -40 +KPX T a -80 +KPX T aacute -80 +KPX T abreve -80 +KPX T acircumflex -80 +KPX T adieresis -80 +KPX T agrave -80 +KPX T amacron -80 +KPX T aogonek -80 +KPX T aring -80 +KPX T atilde -80 +KPX T colon -40 +KPX T comma -80 +KPX T e -60 +KPX T eacute -60 +KPX T ecaron -60 +KPX T ecircumflex -60 +KPX T edieresis -60 +KPX T edotaccent -60 +KPX T egrave -60 +KPX T emacron -60 +KPX T eogonek -60 +KPX T hyphen -120 +KPX T o -80 +KPX T oacute -80 +KPX T ocircumflex -80 +KPX T odieresis -80 +KPX T ograve -80 +KPX T ohungarumlaut -80 +KPX T omacron -80 +KPX T oslash -80 +KPX T otilde -80 +KPX T period -80 +KPX T r -80 +KPX T racute -80 +KPX T rcommaaccent -80 +KPX T semicolon -40 +KPX T u -90 +KPX T uacute -90 +KPX T ucircumflex -90 +KPX T udieresis -90 +KPX T ugrave -90 +KPX T uhungarumlaut -90 +KPX T umacron -90 +KPX T uogonek -90 +KPX T uring -90 +KPX T w -60 +KPX T y -60 +KPX T yacute -60 +KPX T ydieresis -60 +KPX Tcaron A -90 +KPX Tcaron Aacute -90 +KPX Tcaron Abreve -90 +KPX Tcaron Acircumflex -90 +KPX Tcaron Adieresis -90 +KPX Tcaron Agrave -90 +KPX Tcaron Amacron -90 +KPX Tcaron Aogonek -90 +KPX Tcaron Aring -90 +KPX Tcaron Atilde -90 +KPX Tcaron O -40 +KPX Tcaron Oacute -40 +KPX Tcaron Ocircumflex -40 +KPX Tcaron Odieresis -40 +KPX Tcaron Ograve -40 +KPX Tcaron Ohungarumlaut -40 +KPX Tcaron Omacron -40 +KPX Tcaron Oslash -40 +KPX Tcaron Otilde -40 +KPX Tcaron a -80 +KPX Tcaron aacute -80 +KPX Tcaron abreve -80 +KPX Tcaron acircumflex -80 +KPX Tcaron adieresis -80 +KPX Tcaron agrave -80 +KPX Tcaron amacron -80 +KPX Tcaron aogonek -80 +KPX Tcaron aring -80 +KPX Tcaron atilde -80 +KPX Tcaron colon -40 +KPX Tcaron comma -80 +KPX Tcaron e -60 +KPX Tcaron eacute -60 +KPX Tcaron ecaron -60 +KPX Tcaron ecircumflex -60 +KPX Tcaron edieresis -60 +KPX Tcaron edotaccent -60 +KPX Tcaron egrave -60 +KPX Tcaron emacron -60 +KPX Tcaron eogonek -60 +KPX Tcaron hyphen -120 +KPX Tcaron o -80 +KPX Tcaron oacute -80 +KPX Tcaron ocircumflex -80 +KPX Tcaron odieresis -80 +KPX Tcaron ograve -80 +KPX Tcaron ohungarumlaut -80 +KPX Tcaron omacron -80 +KPX Tcaron oslash -80 +KPX Tcaron otilde -80 +KPX Tcaron period -80 +KPX Tcaron r -80 +KPX Tcaron racute -80 +KPX Tcaron rcommaaccent -80 +KPX Tcaron semicolon -40 +KPX Tcaron u -90 +KPX Tcaron uacute -90 +KPX Tcaron ucircumflex -90 +KPX Tcaron udieresis -90 +KPX Tcaron ugrave -90 +KPX Tcaron uhungarumlaut -90 +KPX Tcaron umacron -90 +KPX Tcaron uogonek -90 +KPX Tcaron uring -90 +KPX Tcaron w -60 +KPX Tcaron y -60 +KPX Tcaron yacute -60 +KPX Tcaron ydieresis -60 +KPX Tcommaaccent A -90 +KPX Tcommaaccent Aacute -90 +KPX Tcommaaccent Abreve -90 +KPX Tcommaaccent Acircumflex -90 +KPX Tcommaaccent Adieresis -90 +KPX Tcommaaccent Agrave -90 +KPX Tcommaaccent Amacron -90 +KPX Tcommaaccent Aogonek -90 +KPX Tcommaaccent Aring -90 +KPX Tcommaaccent Atilde -90 +KPX Tcommaaccent O -40 +KPX Tcommaaccent Oacute -40 +KPX Tcommaaccent Ocircumflex -40 +KPX Tcommaaccent Odieresis -40 +KPX Tcommaaccent Ograve -40 +KPX Tcommaaccent Ohungarumlaut -40 +KPX Tcommaaccent Omacron -40 +KPX Tcommaaccent Oslash -40 +KPX Tcommaaccent Otilde -40 +KPX Tcommaaccent a -80 +KPX Tcommaaccent aacute -80 +KPX Tcommaaccent abreve -80 +KPX Tcommaaccent acircumflex -80 +KPX Tcommaaccent adieresis -80 +KPX Tcommaaccent agrave -80 +KPX Tcommaaccent amacron -80 +KPX Tcommaaccent aogonek -80 +KPX Tcommaaccent aring -80 +KPX Tcommaaccent atilde -80 +KPX Tcommaaccent colon -40 +KPX Tcommaaccent comma -80 +KPX Tcommaaccent e -60 +KPX Tcommaaccent eacute -60 +KPX Tcommaaccent ecaron -60 +KPX Tcommaaccent ecircumflex -60 +KPX Tcommaaccent edieresis -60 +KPX Tcommaaccent edotaccent -60 +KPX Tcommaaccent egrave -60 +KPX Tcommaaccent emacron -60 +KPX Tcommaaccent eogonek -60 +KPX Tcommaaccent hyphen -120 +KPX Tcommaaccent o -80 +KPX Tcommaaccent oacute -80 +KPX Tcommaaccent ocircumflex -80 +KPX Tcommaaccent odieresis -80 +KPX Tcommaaccent ograve -80 +KPX Tcommaaccent ohungarumlaut -80 +KPX Tcommaaccent omacron -80 +KPX Tcommaaccent oslash -80 +KPX Tcommaaccent otilde -80 +KPX Tcommaaccent period -80 +KPX Tcommaaccent r -80 +KPX Tcommaaccent racute -80 +KPX Tcommaaccent rcommaaccent -80 +KPX Tcommaaccent semicolon -40 +KPX Tcommaaccent u -90 +KPX Tcommaaccent uacute -90 +KPX Tcommaaccent ucircumflex -90 +KPX Tcommaaccent udieresis -90 +KPX Tcommaaccent ugrave -90 +KPX Tcommaaccent uhungarumlaut -90 +KPX Tcommaaccent umacron -90 +KPX Tcommaaccent uogonek -90 +KPX Tcommaaccent uring -90 +KPX Tcommaaccent w -60 +KPX Tcommaaccent y -60 +KPX Tcommaaccent yacute -60 +KPX Tcommaaccent ydieresis -60 +KPX U A -50 +KPX U Aacute -50 +KPX U Abreve -50 +KPX U Acircumflex -50 +KPX U Adieresis -50 +KPX U Agrave -50 +KPX U Amacron -50 +KPX U Aogonek -50 +KPX U Aring -50 +KPX U Atilde -50 +KPX U comma -30 +KPX U period -30 +KPX Uacute A -50 +KPX Uacute Aacute -50 +KPX Uacute Abreve -50 +KPX Uacute Acircumflex -50 +KPX Uacute Adieresis -50 +KPX Uacute Agrave -50 +KPX Uacute Amacron -50 +KPX Uacute Aogonek -50 +KPX Uacute Aring -50 +KPX Uacute Atilde -50 +KPX Uacute comma -30 +KPX Uacute period -30 +KPX Ucircumflex A -50 +KPX Ucircumflex Aacute -50 +KPX Ucircumflex Abreve -50 +KPX Ucircumflex Acircumflex -50 +KPX Ucircumflex Adieresis -50 +KPX Ucircumflex Agrave -50 +KPX Ucircumflex Amacron -50 +KPX Ucircumflex Aogonek -50 +KPX Ucircumflex Aring -50 +KPX Ucircumflex Atilde -50 +KPX Ucircumflex comma -30 +KPX Ucircumflex period -30 +KPX Udieresis A -50 +KPX Udieresis Aacute -50 +KPX Udieresis Abreve -50 +KPX Udieresis Acircumflex -50 +KPX Udieresis Adieresis -50 +KPX Udieresis Agrave -50 +KPX Udieresis Amacron -50 +KPX Udieresis Aogonek -50 +KPX Udieresis Aring -50 +KPX Udieresis Atilde -50 +KPX Udieresis comma -30 +KPX Udieresis period -30 +KPX Ugrave A -50 +KPX Ugrave Aacute -50 +KPX Ugrave Abreve -50 +KPX Ugrave Acircumflex -50 +KPX Ugrave Adieresis -50 +KPX Ugrave Agrave -50 +KPX Ugrave Amacron -50 +KPX Ugrave Aogonek -50 +KPX Ugrave Aring -50 +KPX Ugrave Atilde -50 +KPX Ugrave comma -30 +KPX Ugrave period -30 +KPX Uhungarumlaut A -50 +KPX Uhungarumlaut Aacute -50 +KPX Uhungarumlaut Abreve -50 +KPX Uhungarumlaut Acircumflex -50 +KPX Uhungarumlaut Adieresis -50 +KPX Uhungarumlaut Agrave -50 +KPX Uhungarumlaut Amacron -50 +KPX Uhungarumlaut Aogonek -50 +KPX Uhungarumlaut Aring -50 +KPX Uhungarumlaut Atilde -50 +KPX Uhungarumlaut comma -30 +KPX Uhungarumlaut period -30 +KPX Umacron A -50 +KPX Umacron Aacute -50 +KPX Umacron Abreve -50 +KPX Umacron Acircumflex -50 +KPX Umacron Adieresis -50 +KPX Umacron Agrave -50 +KPX Umacron Amacron -50 +KPX Umacron Aogonek -50 +KPX Umacron Aring -50 +KPX Umacron Atilde -50 +KPX Umacron comma -30 +KPX Umacron period -30 +KPX Uogonek A -50 +KPX Uogonek Aacute -50 +KPX Uogonek Abreve -50 +KPX Uogonek Acircumflex -50 +KPX Uogonek Adieresis -50 +KPX Uogonek Agrave -50 +KPX Uogonek Amacron -50 +KPX Uogonek Aogonek -50 +KPX Uogonek Aring -50 +KPX Uogonek Atilde -50 +KPX Uogonek comma -30 +KPX Uogonek period -30 +KPX Uring A -50 +KPX Uring Aacute -50 +KPX Uring Abreve -50 +KPX Uring Acircumflex -50 +KPX Uring Adieresis -50 +KPX Uring Agrave -50 +KPX Uring Amacron -50 +KPX Uring Aogonek -50 +KPX Uring Aring -50 +KPX Uring Atilde -50 +KPX Uring comma -30 +KPX Uring period -30 +KPX V A -80 +KPX V Aacute -80 +KPX V Abreve -80 +KPX V Acircumflex -80 +KPX V Adieresis -80 +KPX V Agrave -80 +KPX V Amacron -80 +KPX V Aogonek -80 +KPX V Aring -80 +KPX V Atilde -80 +KPX V G -50 +KPX V Gbreve -50 +KPX V Gcommaaccent -50 +KPX V O -50 +KPX V Oacute -50 +KPX V Ocircumflex -50 +KPX V Odieresis -50 +KPX V Ograve -50 +KPX V Ohungarumlaut -50 +KPX V Omacron -50 +KPX V Oslash -50 +KPX V Otilde -50 +KPX V a -60 +KPX V aacute -60 +KPX V abreve -60 +KPX V acircumflex -60 +KPX V adieresis -60 +KPX V agrave -60 +KPX V amacron -60 +KPX V aogonek -60 +KPX V aring -60 +KPX V atilde -60 +KPX V colon -40 +KPX V comma -120 +KPX V e -50 +KPX V eacute -50 +KPX V ecaron -50 +KPX V ecircumflex -50 +KPX V edieresis -50 +KPX V edotaccent -50 +KPX V egrave -50 +KPX V emacron -50 +KPX V eogonek -50 +KPX V hyphen -80 +KPX V o -90 +KPX V oacute -90 +KPX V ocircumflex -90 +KPX V odieresis -90 +KPX V ograve -90 +KPX V ohungarumlaut -90 +KPX V omacron -90 +KPX V oslash -90 +KPX V otilde -90 +KPX V period -120 +KPX V semicolon -40 +KPX V u -60 +KPX V uacute -60 +KPX V ucircumflex -60 +KPX V udieresis -60 +KPX V ugrave -60 +KPX V uhungarumlaut -60 +KPX V umacron -60 +KPX V uogonek -60 +KPX V uring -60 +KPX W A -60 +KPX W Aacute -60 +KPX W Abreve -60 +KPX W Acircumflex -60 +KPX W Adieresis -60 +KPX W Agrave -60 +KPX W Amacron -60 +KPX W Aogonek -60 +KPX W Aring -60 +KPX W Atilde -60 +KPX W O -20 +KPX W Oacute -20 +KPX W Ocircumflex -20 +KPX W Odieresis -20 +KPX W Ograve -20 +KPX W Ohungarumlaut -20 +KPX W Omacron -20 +KPX W Oslash -20 +KPX W Otilde -20 +KPX W a -40 +KPX W aacute -40 +KPX W abreve -40 +KPX W acircumflex -40 +KPX W adieresis -40 +KPX W agrave -40 +KPX W amacron -40 +KPX W aogonek -40 +KPX W aring -40 +KPX W atilde -40 +KPX W colon -10 +KPX W comma -80 +KPX W e -35 +KPX W eacute -35 +KPX W ecaron -35 +KPX W ecircumflex -35 +KPX W edieresis -35 +KPX W edotaccent -35 +KPX W egrave -35 +KPX W emacron -35 +KPX W eogonek -35 +KPX W hyphen -40 +KPX W o -60 +KPX W oacute -60 +KPX W ocircumflex -60 +KPX W odieresis -60 +KPX W ograve -60 +KPX W ohungarumlaut -60 +KPX W omacron -60 +KPX W oslash -60 +KPX W otilde -60 +KPX W period -80 +KPX W semicolon -10 +KPX W u -45 +KPX W uacute -45 +KPX W ucircumflex -45 +KPX W udieresis -45 +KPX W ugrave -45 +KPX W uhungarumlaut -45 +KPX W umacron -45 +KPX W uogonek -45 +KPX W uring -45 +KPX W y -20 +KPX W yacute -20 +KPX W ydieresis -20 +KPX Y A -110 +KPX Y Aacute -110 +KPX Y Abreve -110 +KPX Y Acircumflex -110 +KPX Y Adieresis -110 +KPX Y Agrave -110 +KPX Y Amacron -110 +KPX Y Aogonek -110 +KPX Y Aring -110 +KPX Y Atilde -110 +KPX Y O -70 +KPX Y Oacute -70 +KPX Y Ocircumflex -70 +KPX Y Odieresis -70 +KPX Y Ograve -70 +KPX Y Ohungarumlaut -70 +KPX Y Omacron -70 +KPX Y Oslash -70 +KPX Y Otilde -70 +KPX Y a -90 +KPX Y aacute -90 +KPX Y abreve -90 +KPX Y acircumflex -90 +KPX Y adieresis -90 +KPX Y agrave -90 +KPX Y amacron -90 +KPX Y aogonek -90 +KPX Y aring -90 +KPX Y atilde -90 +KPX Y colon -50 +KPX Y comma -100 +KPX Y e -80 +KPX Y eacute -80 +KPX Y ecaron -80 +KPX Y ecircumflex -80 +KPX Y edieresis -80 +KPX Y edotaccent -80 +KPX Y egrave -80 +KPX Y emacron -80 +KPX Y eogonek -80 +KPX Y o -100 +KPX Y oacute -100 +KPX Y ocircumflex -100 +KPX Y odieresis -100 +KPX Y ograve -100 +KPX Y ohungarumlaut -100 +KPX Y omacron -100 +KPX Y oslash -100 +KPX Y otilde -100 +KPX Y period -100 +KPX Y semicolon -50 +KPX Y u -100 +KPX Y uacute -100 +KPX Y ucircumflex -100 +KPX Y udieresis -100 +KPX Y ugrave -100 +KPX Y uhungarumlaut -100 +KPX Y umacron -100 +KPX Y uogonek -100 +KPX Y uring -100 +KPX Yacute A -110 +KPX Yacute Aacute -110 +KPX Yacute Abreve -110 +KPX Yacute Acircumflex -110 +KPX Yacute Adieresis -110 +KPX Yacute Agrave -110 +KPX Yacute Amacron -110 +KPX Yacute Aogonek -110 +KPX Yacute Aring -110 +KPX Yacute Atilde -110 +KPX Yacute O -70 +KPX Yacute Oacute -70 +KPX Yacute Ocircumflex -70 +KPX Yacute Odieresis -70 +KPX Yacute Ograve -70 +KPX Yacute Ohungarumlaut -70 +KPX Yacute Omacron -70 +KPX Yacute Oslash -70 +KPX Yacute Otilde -70 +KPX Yacute a -90 +KPX Yacute aacute -90 +KPX Yacute abreve -90 +KPX Yacute acircumflex -90 +KPX Yacute adieresis -90 +KPX Yacute agrave -90 +KPX Yacute amacron -90 +KPX Yacute aogonek -90 +KPX Yacute aring -90 +KPX Yacute atilde -90 +KPX Yacute colon -50 +KPX Yacute comma -100 +KPX Yacute e -80 +KPX Yacute eacute -80 +KPX Yacute ecaron -80 +KPX Yacute ecircumflex -80 +KPX Yacute edieresis -80 +KPX Yacute edotaccent -80 +KPX Yacute egrave -80 +KPX Yacute emacron -80 +KPX Yacute eogonek -80 +KPX Yacute o -100 +KPX Yacute oacute -100 +KPX Yacute ocircumflex -100 +KPX Yacute odieresis -100 +KPX Yacute ograve -100 +KPX Yacute ohungarumlaut -100 +KPX Yacute omacron -100 +KPX Yacute oslash -100 +KPX Yacute otilde -100 +KPX Yacute period -100 +KPX Yacute semicolon -50 +KPX Yacute u -100 +KPX Yacute uacute -100 +KPX Yacute ucircumflex -100 +KPX Yacute udieresis -100 +KPX Yacute ugrave -100 +KPX Yacute uhungarumlaut -100 +KPX Yacute umacron -100 +KPX Yacute uogonek -100 +KPX Yacute uring -100 +KPX Ydieresis A -110 +KPX Ydieresis Aacute -110 +KPX Ydieresis Abreve -110 +KPX Ydieresis Acircumflex -110 +KPX Ydieresis Adieresis -110 +KPX Ydieresis Agrave -110 +KPX Ydieresis Amacron -110 +KPX Ydieresis Aogonek -110 +KPX Ydieresis Aring -110 +KPX Ydieresis Atilde -110 +KPX Ydieresis O -70 +KPX Ydieresis Oacute -70 +KPX Ydieresis Ocircumflex -70 +KPX Ydieresis Odieresis -70 +KPX Ydieresis Ograve -70 +KPX Ydieresis Ohungarumlaut -70 +KPX Ydieresis Omacron -70 +KPX Ydieresis Oslash -70 +KPX Ydieresis Otilde -70 +KPX Ydieresis a -90 +KPX Ydieresis aacute -90 +KPX Ydieresis abreve -90 +KPX Ydieresis acircumflex -90 +KPX Ydieresis adieresis -90 +KPX Ydieresis agrave -90 +KPX Ydieresis amacron -90 +KPX Ydieresis aogonek -90 +KPX Ydieresis aring -90 +KPX Ydieresis atilde -90 +KPX Ydieresis colon -50 +KPX Ydieresis comma -100 +KPX Ydieresis e -80 +KPX Ydieresis eacute -80 +KPX Ydieresis ecaron -80 +KPX Ydieresis ecircumflex -80 +KPX Ydieresis edieresis -80 +KPX Ydieresis edotaccent -80 +KPX Ydieresis egrave -80 +KPX Ydieresis emacron -80 +KPX Ydieresis eogonek -80 +KPX Ydieresis o -100 +KPX Ydieresis oacute -100 +KPX Ydieresis ocircumflex -100 +KPX Ydieresis odieresis -100 +KPX Ydieresis ograve -100 +KPX Ydieresis ohungarumlaut -100 +KPX Ydieresis omacron -100 +KPX Ydieresis oslash -100 +KPX Ydieresis otilde -100 +KPX Ydieresis period -100 +KPX Ydieresis semicolon -50 +KPX Ydieresis u -100 +KPX Ydieresis uacute -100 +KPX Ydieresis ucircumflex -100 +KPX Ydieresis udieresis -100 +KPX Ydieresis ugrave -100 +KPX Ydieresis uhungarumlaut -100 +KPX Ydieresis umacron -100 +KPX Ydieresis uogonek -100 +KPX Ydieresis uring -100 +KPX a g -10 +KPX a gbreve -10 +KPX a gcommaaccent -10 +KPX a v -15 +KPX a w -15 +KPX a y -20 +KPX a yacute -20 +KPX a ydieresis -20 +KPX aacute g -10 +KPX aacute gbreve -10 +KPX aacute gcommaaccent -10 +KPX aacute v -15 +KPX aacute w -15 +KPX aacute y -20 +KPX aacute yacute -20 +KPX aacute ydieresis -20 +KPX abreve g -10 +KPX abreve gbreve -10 +KPX abreve gcommaaccent -10 +KPX abreve v -15 +KPX abreve w -15 +KPX abreve y -20 +KPX abreve yacute -20 +KPX abreve ydieresis -20 +KPX acircumflex g -10 +KPX acircumflex gbreve -10 +KPX acircumflex gcommaaccent -10 +KPX acircumflex v -15 +KPX acircumflex w -15 +KPX acircumflex y -20 +KPX acircumflex yacute -20 +KPX acircumflex ydieresis -20 +KPX adieresis g -10 +KPX adieresis gbreve -10 +KPX adieresis gcommaaccent -10 +KPX adieresis v -15 +KPX adieresis w -15 +KPX adieresis y -20 +KPX adieresis yacute -20 +KPX adieresis ydieresis -20 +KPX agrave g -10 +KPX agrave gbreve -10 +KPX agrave gcommaaccent -10 +KPX agrave v -15 +KPX agrave w -15 +KPX agrave y -20 +KPX agrave yacute -20 +KPX agrave ydieresis -20 +KPX amacron g -10 +KPX amacron gbreve -10 +KPX amacron gcommaaccent -10 +KPX amacron v -15 +KPX amacron w -15 +KPX amacron y -20 +KPX amacron yacute -20 +KPX amacron ydieresis -20 +KPX aogonek g -10 +KPX aogonek gbreve -10 +KPX aogonek gcommaaccent -10 +KPX aogonek v -15 +KPX aogonek w -15 +KPX aogonek y -20 +KPX aogonek yacute -20 +KPX aogonek ydieresis -20 +KPX aring g -10 +KPX aring gbreve -10 +KPX aring gcommaaccent -10 +KPX aring v -15 +KPX aring w -15 +KPX aring y -20 +KPX aring yacute -20 +KPX aring ydieresis -20 +KPX atilde g -10 +KPX atilde gbreve -10 +KPX atilde gcommaaccent -10 +KPX atilde v -15 +KPX atilde w -15 +KPX atilde y -20 +KPX atilde yacute -20 +KPX atilde ydieresis -20 +KPX b l -10 +KPX b lacute -10 +KPX b lcommaaccent -10 +KPX b lslash -10 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -20 +KPX b y -20 +KPX b yacute -20 +KPX b ydieresis -20 +KPX c h -10 +KPX c k -20 +KPX c kcommaaccent -20 +KPX c l -20 +KPX c lacute -20 +KPX c lcommaaccent -20 +KPX c lslash -20 +KPX c y -10 +KPX c yacute -10 +KPX c ydieresis -10 +KPX cacute h -10 +KPX cacute k -20 +KPX cacute kcommaaccent -20 +KPX cacute l -20 +KPX cacute lacute -20 +KPX cacute lcommaaccent -20 +KPX cacute lslash -20 +KPX cacute y -10 +KPX cacute yacute -10 +KPX cacute ydieresis -10 +KPX ccaron h -10 +KPX ccaron k -20 +KPX ccaron kcommaaccent -20 +KPX ccaron l -20 +KPX ccaron lacute -20 +KPX ccaron lcommaaccent -20 +KPX ccaron lslash -20 +KPX ccaron y -10 +KPX ccaron yacute -10 +KPX ccaron ydieresis -10 +KPX ccedilla h -10 +KPX ccedilla k -20 +KPX ccedilla kcommaaccent -20 +KPX ccedilla l -20 +KPX ccedilla lacute -20 +KPX ccedilla lcommaaccent -20 +KPX ccedilla lslash -20 +KPX ccedilla y -10 +KPX ccedilla yacute -10 +KPX ccedilla ydieresis -10 +KPX colon space -40 +KPX comma quotedblright -120 +KPX comma quoteright -120 +KPX comma space -40 +KPX d d -10 +KPX d dcroat -10 +KPX d v -15 +KPX d w -15 +KPX d y -15 +KPX d yacute -15 +KPX d ydieresis -15 +KPX dcroat d -10 +KPX dcroat dcroat -10 +KPX dcroat v -15 +KPX dcroat w -15 +KPX dcroat y -15 +KPX dcroat yacute -15 +KPX dcroat ydieresis -15 +KPX e comma 10 +KPX e period 20 +KPX e v -15 +KPX e w -15 +KPX e x -15 +KPX e y -15 +KPX e yacute -15 +KPX e ydieresis -15 +KPX eacute comma 10 +KPX eacute period 20 +KPX eacute v -15 +KPX eacute w -15 +KPX eacute x -15 +KPX eacute y -15 +KPX eacute yacute -15 +KPX eacute ydieresis -15 +KPX ecaron comma 10 +KPX ecaron period 20 +KPX ecaron v -15 +KPX ecaron w -15 +KPX ecaron x -15 +KPX ecaron y -15 +KPX ecaron yacute -15 +KPX ecaron ydieresis -15 +KPX ecircumflex comma 10 +KPX ecircumflex period 20 +KPX ecircumflex v -15 +KPX ecircumflex w -15 +KPX ecircumflex x -15 +KPX ecircumflex y -15 +KPX ecircumflex yacute -15 +KPX ecircumflex ydieresis -15 +KPX edieresis comma 10 +KPX edieresis period 20 +KPX edieresis v -15 +KPX edieresis w -15 +KPX edieresis x -15 +KPX edieresis y -15 +KPX edieresis yacute -15 +KPX edieresis ydieresis -15 +KPX edotaccent comma 10 +KPX edotaccent period 20 +KPX edotaccent v -15 +KPX edotaccent w -15 +KPX edotaccent x -15 +KPX edotaccent y -15 +KPX edotaccent yacute -15 +KPX edotaccent ydieresis -15 +KPX egrave comma 10 +KPX egrave period 20 +KPX egrave v -15 +KPX egrave w -15 +KPX egrave x -15 +KPX egrave y -15 +KPX egrave yacute -15 +KPX egrave ydieresis -15 +KPX emacron comma 10 +KPX emacron period 20 +KPX emacron v -15 +KPX emacron w -15 +KPX emacron x -15 +KPX emacron y -15 +KPX emacron yacute -15 +KPX emacron ydieresis -15 +KPX eogonek comma 10 +KPX eogonek period 20 +KPX eogonek v -15 +KPX eogonek w -15 +KPX eogonek x -15 +KPX eogonek y -15 +KPX eogonek yacute -15 +KPX eogonek ydieresis -15 +KPX f comma -10 +KPX f e -10 +KPX f eacute -10 +KPX f ecaron -10 +KPX f ecircumflex -10 +KPX f edieresis -10 +KPX f edotaccent -10 +KPX f egrave -10 +KPX f emacron -10 +KPX f eogonek -10 +KPX f o -20 +KPX f oacute -20 +KPX f ocircumflex -20 +KPX f odieresis -20 +KPX f ograve -20 +KPX f ohungarumlaut -20 +KPX f omacron -20 +KPX f oslash -20 +KPX f otilde -20 +KPX f period -10 +KPX f quotedblright 30 +KPX f quoteright 30 +KPX g e 10 +KPX g eacute 10 +KPX g ecaron 10 +KPX g ecircumflex 10 +KPX g edieresis 10 +KPX g edotaccent 10 +KPX g egrave 10 +KPX g emacron 10 +KPX g eogonek 10 +KPX g g -10 +KPX g gbreve -10 +KPX g gcommaaccent -10 +KPX gbreve e 10 +KPX gbreve eacute 10 +KPX gbreve ecaron 10 +KPX gbreve ecircumflex 10 +KPX gbreve edieresis 10 +KPX gbreve edotaccent 10 +KPX gbreve egrave 10 +KPX gbreve emacron 10 +KPX gbreve eogonek 10 +KPX gbreve g -10 +KPX gbreve gbreve -10 +KPX gbreve gcommaaccent -10 +KPX gcommaaccent e 10 +KPX gcommaaccent eacute 10 +KPX gcommaaccent ecaron 10 +KPX gcommaaccent ecircumflex 10 +KPX gcommaaccent edieresis 10 +KPX gcommaaccent edotaccent 10 +KPX gcommaaccent egrave 10 +KPX gcommaaccent emacron 10 +KPX gcommaaccent eogonek 10 +KPX gcommaaccent g -10 +KPX gcommaaccent gbreve -10 +KPX gcommaaccent gcommaaccent -10 +KPX h y -20 +KPX h yacute -20 +KPX h ydieresis -20 +KPX k o -15 +KPX k oacute -15 +KPX k ocircumflex -15 +KPX k odieresis -15 +KPX k ograve -15 +KPX k ohungarumlaut -15 +KPX k omacron -15 +KPX k oslash -15 +KPX k otilde -15 +KPX kcommaaccent o -15 +KPX kcommaaccent oacute -15 +KPX kcommaaccent ocircumflex -15 +KPX kcommaaccent odieresis -15 +KPX kcommaaccent ograve -15 +KPX kcommaaccent ohungarumlaut -15 +KPX kcommaaccent omacron -15 +KPX kcommaaccent oslash -15 +KPX kcommaaccent otilde -15 +KPX l w -15 +KPX l y -15 +KPX l yacute -15 +KPX l ydieresis -15 +KPX lacute w -15 +KPX lacute y -15 +KPX lacute yacute -15 +KPX lacute ydieresis -15 +KPX lcommaaccent w -15 +KPX lcommaaccent y -15 +KPX lcommaaccent yacute -15 +KPX lcommaaccent ydieresis -15 +KPX lslash w -15 +KPX lslash y -15 +KPX lslash yacute -15 +KPX lslash ydieresis -15 +KPX m u -20 +KPX m uacute -20 +KPX m ucircumflex -20 +KPX m udieresis -20 +KPX m ugrave -20 +KPX m uhungarumlaut -20 +KPX m umacron -20 +KPX m uogonek -20 +KPX m uring -20 +KPX m y -30 +KPX m yacute -30 +KPX m ydieresis -30 +KPX n u -10 +KPX n uacute -10 +KPX n ucircumflex -10 +KPX n udieresis -10 +KPX n ugrave -10 +KPX n uhungarumlaut -10 +KPX n umacron -10 +KPX n uogonek -10 +KPX n uring -10 +KPX n v -40 +KPX n y -20 +KPX n yacute -20 +KPX n ydieresis -20 +KPX nacute u -10 +KPX nacute uacute -10 +KPX nacute ucircumflex -10 +KPX nacute udieresis -10 +KPX nacute ugrave -10 +KPX nacute uhungarumlaut -10 +KPX nacute umacron -10 +KPX nacute uogonek -10 +KPX nacute uring -10 +KPX nacute v -40 +KPX nacute y -20 +KPX nacute yacute -20 +KPX nacute ydieresis -20 +KPX ncaron u -10 +KPX ncaron uacute -10 +KPX ncaron ucircumflex -10 +KPX ncaron udieresis -10 +KPX ncaron ugrave -10 +KPX ncaron uhungarumlaut -10 +KPX ncaron umacron -10 +KPX ncaron uogonek -10 +KPX ncaron uring -10 +KPX ncaron v -40 +KPX ncaron y -20 +KPX ncaron yacute -20 +KPX ncaron ydieresis -20 +KPX ncommaaccent u -10 +KPX ncommaaccent uacute -10 +KPX ncommaaccent ucircumflex -10 +KPX ncommaaccent udieresis -10 +KPX ncommaaccent ugrave -10 +KPX ncommaaccent uhungarumlaut -10 +KPX ncommaaccent umacron -10 +KPX ncommaaccent uogonek -10 +KPX ncommaaccent uring -10 +KPX ncommaaccent v -40 +KPX ncommaaccent y -20 +KPX ncommaaccent yacute -20 +KPX ncommaaccent ydieresis -20 +KPX ntilde u -10 +KPX ntilde uacute -10 +KPX ntilde ucircumflex -10 +KPX ntilde udieresis -10 +KPX ntilde ugrave -10 +KPX ntilde uhungarumlaut -10 +KPX ntilde umacron -10 +KPX ntilde uogonek -10 +KPX ntilde uring -10 +KPX ntilde v -40 +KPX ntilde y -20 +KPX ntilde yacute -20 +KPX ntilde ydieresis -20 +KPX o v -20 +KPX o w -15 +KPX o x -30 +KPX o y -20 +KPX o yacute -20 +KPX o ydieresis -20 +KPX oacute v -20 +KPX oacute w -15 +KPX oacute x -30 +KPX oacute y -20 +KPX oacute yacute -20 +KPX oacute ydieresis -20 +KPX ocircumflex v -20 +KPX ocircumflex w -15 +KPX ocircumflex x -30 +KPX ocircumflex y -20 +KPX ocircumflex yacute -20 +KPX ocircumflex ydieresis -20 +KPX odieresis v -20 +KPX odieresis w -15 +KPX odieresis x -30 +KPX odieresis y -20 +KPX odieresis yacute -20 +KPX odieresis ydieresis -20 +KPX ograve v -20 +KPX ograve w -15 +KPX ograve x -30 +KPX ograve y -20 +KPX ograve yacute -20 +KPX ograve ydieresis -20 +KPX ohungarumlaut v -20 +KPX ohungarumlaut w -15 +KPX ohungarumlaut x -30 +KPX ohungarumlaut y -20 +KPX ohungarumlaut yacute -20 +KPX ohungarumlaut ydieresis -20 +KPX omacron v -20 +KPX omacron w -15 +KPX omacron x -30 +KPX omacron y -20 +KPX omacron yacute -20 +KPX omacron ydieresis -20 +KPX oslash v -20 +KPX oslash w -15 +KPX oslash x -30 +KPX oslash y -20 +KPX oslash yacute -20 +KPX oslash ydieresis -20 +KPX otilde v -20 +KPX otilde w -15 +KPX otilde x -30 +KPX otilde y -20 +KPX otilde yacute -20 +KPX otilde ydieresis -20 +KPX p y -15 +KPX p yacute -15 +KPX p ydieresis -15 +KPX period quotedblright -120 +KPX period quoteright -120 +KPX period space -40 +KPX quotedblright space -80 +KPX quoteleft quoteleft -46 +KPX quoteright d -80 +KPX quoteright dcroat -80 +KPX quoteright l -20 +KPX quoteright lacute -20 +KPX quoteright lcommaaccent -20 +KPX quoteright lslash -20 +KPX quoteright quoteright -46 +KPX quoteright r -40 +KPX quoteright racute -40 +KPX quoteright rcaron -40 +KPX quoteright rcommaaccent -40 +KPX quoteright s -60 +KPX quoteright sacute -60 +KPX quoteright scaron -60 +KPX quoteright scedilla -60 +KPX quoteright scommaaccent -60 +KPX quoteright space -80 +KPX quoteright v -20 +KPX r c -20 +KPX r cacute -20 +KPX r ccaron -20 +KPX r ccedilla -20 +KPX r comma -60 +KPX r d -20 +KPX r dcroat -20 +KPX r g -15 +KPX r gbreve -15 +KPX r gcommaaccent -15 +KPX r hyphen -20 +KPX r o -20 +KPX r oacute -20 +KPX r ocircumflex -20 +KPX r odieresis -20 +KPX r ograve -20 +KPX r ohungarumlaut -20 +KPX r omacron -20 +KPX r oslash -20 +KPX r otilde -20 +KPX r period -60 +KPX r q -20 +KPX r s -15 +KPX r sacute -15 +KPX r scaron -15 +KPX r scedilla -15 +KPX r scommaaccent -15 +KPX r t 20 +KPX r tcommaaccent 20 +KPX r v 10 +KPX r y 10 +KPX r yacute 10 +KPX r ydieresis 10 +KPX racute c -20 +KPX racute cacute -20 +KPX racute ccaron -20 +KPX racute ccedilla -20 +KPX racute comma -60 +KPX racute d -20 +KPX racute dcroat -20 +KPX racute g -15 +KPX racute gbreve -15 +KPX racute gcommaaccent -15 +KPX racute hyphen -20 +KPX racute o -20 +KPX racute oacute -20 +KPX racute ocircumflex -20 +KPX racute odieresis -20 +KPX racute ograve -20 +KPX racute ohungarumlaut -20 +KPX racute omacron -20 +KPX racute oslash -20 +KPX racute otilde -20 +KPX racute period -60 +KPX racute q -20 +KPX racute s -15 +KPX racute sacute -15 +KPX racute scaron -15 +KPX racute scedilla -15 +KPX racute scommaaccent -15 +KPX racute t 20 +KPX racute tcommaaccent 20 +KPX racute v 10 +KPX racute y 10 +KPX racute yacute 10 +KPX racute ydieresis 10 +KPX rcaron c -20 +KPX rcaron cacute -20 +KPX rcaron ccaron -20 +KPX rcaron ccedilla -20 +KPX rcaron comma -60 +KPX rcaron d -20 +KPX rcaron dcroat -20 +KPX rcaron g -15 +KPX rcaron gbreve -15 +KPX rcaron gcommaaccent -15 +KPX rcaron hyphen -20 +KPX rcaron o -20 +KPX rcaron oacute -20 +KPX rcaron ocircumflex -20 +KPX rcaron odieresis -20 +KPX rcaron ograve -20 +KPX rcaron ohungarumlaut -20 +KPX rcaron omacron -20 +KPX rcaron oslash -20 +KPX rcaron otilde -20 +KPX rcaron period -60 +KPX rcaron q -20 +KPX rcaron s -15 +KPX rcaron sacute -15 +KPX rcaron scaron -15 +KPX rcaron scedilla -15 +KPX rcaron scommaaccent -15 +KPX rcaron t 20 +KPX rcaron tcommaaccent 20 +KPX rcaron v 10 +KPX rcaron y 10 +KPX rcaron yacute 10 +KPX rcaron ydieresis 10 +KPX rcommaaccent c -20 +KPX rcommaaccent cacute -20 +KPX rcommaaccent ccaron -20 +KPX rcommaaccent ccedilla -20 +KPX rcommaaccent comma -60 +KPX rcommaaccent d -20 +KPX rcommaaccent dcroat -20 +KPX rcommaaccent g -15 +KPX rcommaaccent gbreve -15 +KPX rcommaaccent gcommaaccent -15 +KPX rcommaaccent hyphen -20 +KPX rcommaaccent o -20 +KPX rcommaaccent oacute -20 +KPX rcommaaccent ocircumflex -20 +KPX rcommaaccent odieresis -20 +KPX rcommaaccent ograve -20 +KPX rcommaaccent ohungarumlaut -20 +KPX rcommaaccent omacron -20 +KPX rcommaaccent oslash -20 +KPX rcommaaccent otilde -20 +KPX rcommaaccent period -60 +KPX rcommaaccent q -20 +KPX rcommaaccent s -15 +KPX rcommaaccent sacute -15 +KPX rcommaaccent scaron -15 +KPX rcommaaccent scedilla -15 +KPX rcommaaccent scommaaccent -15 +KPX rcommaaccent t 20 +KPX rcommaaccent tcommaaccent 20 +KPX rcommaaccent v 10 +KPX rcommaaccent y 10 +KPX rcommaaccent yacute 10 +KPX rcommaaccent ydieresis 10 +KPX s w -15 +KPX sacute w -15 +KPX scaron w -15 +KPX scedilla w -15 +KPX scommaaccent w -15 +KPX semicolon space -40 +KPX space T -100 +KPX space Tcaron -100 +KPX space Tcommaaccent -100 +KPX space V -80 +KPX space W -80 +KPX space Y -120 +KPX space Yacute -120 +KPX space Ydieresis -120 +KPX space quotedblleft -80 +KPX space quoteleft -60 +KPX v a -20 +KPX v aacute -20 +KPX v abreve -20 +KPX v acircumflex -20 +KPX v adieresis -20 +KPX v agrave -20 +KPX v amacron -20 +KPX v aogonek -20 +KPX v aring -20 +KPX v atilde -20 +KPX v comma -80 +KPX v o -30 +KPX v oacute -30 +KPX v ocircumflex -30 +KPX v odieresis -30 +KPX v ograve -30 +KPX v ohungarumlaut -30 +KPX v omacron -30 +KPX v oslash -30 +KPX v otilde -30 +KPX v period -80 +KPX w comma -40 +KPX w o -20 +KPX w oacute -20 +KPX w ocircumflex -20 +KPX w odieresis -20 +KPX w ograve -20 +KPX w ohungarumlaut -20 +KPX w omacron -20 +KPX w oslash -20 +KPX w otilde -20 +KPX w period -40 +KPX x e -10 +KPX x eacute -10 +KPX x ecaron -10 +KPX x ecircumflex -10 +KPX x edieresis -10 +KPX x edotaccent -10 +KPX x egrave -10 +KPX x emacron -10 +KPX x eogonek -10 +KPX y a -30 +KPX y aacute -30 +KPX y abreve -30 +KPX y acircumflex -30 +KPX y adieresis -30 +KPX y agrave -30 +KPX y amacron -30 +KPX y aogonek -30 +KPX y aring -30 +KPX y atilde -30 +KPX y comma -80 +KPX y e -10 +KPX y eacute -10 +KPX y ecaron -10 +KPX y ecircumflex -10 +KPX y edieresis -10 +KPX y edotaccent -10 +KPX y egrave -10 +KPX y emacron -10 +KPX y eogonek -10 +KPX y o -25 +KPX y oacute -25 +KPX y ocircumflex -25 +KPX y odieresis -25 +KPX y ograve -25 +KPX y ohungarumlaut -25 +KPX y omacron -25 +KPX y oslash -25 +KPX y otilde -25 +KPX y period -80 +KPX yacute a -30 +KPX yacute aacute -30 +KPX yacute abreve -30 +KPX yacute acircumflex -30 +KPX yacute adieresis -30 +KPX yacute agrave -30 +KPX yacute amacron -30 +KPX yacute aogonek -30 +KPX yacute aring -30 +KPX yacute atilde -30 +KPX yacute comma -80 +KPX yacute e -10 +KPX yacute eacute -10 +KPX yacute ecaron -10 +KPX yacute ecircumflex -10 +KPX yacute edieresis -10 +KPX yacute edotaccent -10 +KPX yacute egrave -10 +KPX yacute emacron -10 +KPX yacute eogonek -10 +KPX yacute o -25 +KPX yacute oacute -25 +KPX yacute ocircumflex -25 +KPX yacute odieresis -25 +KPX yacute ograve -25 +KPX yacute ohungarumlaut -25 +KPX yacute omacron -25 +KPX yacute oslash -25 +KPX yacute otilde -25 +KPX yacute period -80 +KPX ydieresis a -30 +KPX ydieresis aacute -30 +KPX ydieresis abreve -30 +KPX ydieresis acircumflex -30 +KPX ydieresis adieresis -30 +KPX ydieresis agrave -30 +KPX ydieresis amacron -30 +KPX ydieresis aogonek -30 +KPX ydieresis aring -30 +KPX ydieresis atilde -30 +KPX ydieresis comma -80 +KPX ydieresis e -10 +KPX ydieresis eacute -10 +KPX ydieresis ecaron -10 +KPX ydieresis ecircumflex -10 +KPX ydieresis edieresis -10 +KPX ydieresis edotaccent -10 +KPX ydieresis egrave -10 +KPX ydieresis emacron -10 +KPX ydieresis eogonek -10 +KPX ydieresis o -25 +KPX ydieresis oacute -25 +KPX ydieresis ocircumflex -25 +KPX ydieresis odieresis -25 +KPX ydieresis ograve -25 +KPX ydieresis ohungarumlaut -25 +KPX ydieresis omacron -25 +KPX ydieresis oslash -25 +KPX ydieresis otilde -25 +KPX ydieresis period -80 +KPX z e 10 +KPX z eacute 10 +KPX z ecaron 10 +KPX z ecircumflex 10 +KPX z edieresis 10 +KPX z edotaccent 10 +KPX z egrave 10 +KPX z emacron 10 +KPX z eogonek 10 +KPX zacute e 10 +KPX zacute eacute 10 +KPX zacute ecaron 10 +KPX zacute ecircumflex 10 +KPX zacute edieresis 10 +KPX zacute edotaccent 10 +KPX zacute egrave 10 +KPX zacute emacron 10 +KPX zacute eogonek 10 +KPX zcaron e 10 +KPX zcaron eacute 10 +KPX zcaron ecaron 10 +KPX zcaron ecircumflex 10 +KPX zcaron edieresis 10 +KPX zcaron edotaccent 10 +KPX zcaron egrave 10 +KPX zcaron emacron 10 +KPX zcaron eogonek 10 +KPX zdotaccent e 10 +KPX zdotaccent eacute 10 +KPX zdotaccent ecaron 10 +KPX zdotaccent ecircumflex 10 +KPX zdotaccent edieresis 10 +KPX zdotaccent edotaccent 10 +KPX zdotaccent egrave 10 +KPX zdotaccent emacron 10 +KPX zdotaccent eogonek 10 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-BoldOblique.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-BoldOblique.afm new file mode 100644 index 00000000..1715b210 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-BoldOblique.afm @@ -0,0 +1,2827 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:45:12 1997 +Comment UniqueID 43053 +Comment VMusage 14482 68586 +FontName Helvetica-BoldOblique +FullName Helvetica Bold Oblique +FamilyName Helvetica +Weight Bold +ItalicAngle -12 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -174 -228 1114 962 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 532 +Ascender 718 +Descender -207 +StdHW 118 +StdVW 140 +StartCharMetrics 315 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 94 0 397 718 ; +C 34 ; WX 474 ; N quotedbl ; B 193 447 529 718 ; +C 35 ; WX 556 ; N numbersign ; B 60 0 644 698 ; +C 36 ; WX 556 ; N dollar ; B 67 -115 622 775 ; +C 37 ; WX 889 ; N percent ; B 136 -19 901 710 ; +C 38 ; WX 722 ; N ampersand ; B 89 -19 732 718 ; +C 39 ; WX 278 ; N quoteright ; B 167 445 362 718 ; +C 40 ; WX 333 ; N parenleft ; B 76 -208 470 734 ; +C 41 ; WX 333 ; N parenright ; B -25 -208 369 734 ; +C 42 ; WX 389 ; N asterisk ; B 146 387 481 718 ; +C 43 ; WX 584 ; N plus ; B 82 0 610 506 ; +C 44 ; WX 278 ; N comma ; B 28 -168 245 146 ; +C 45 ; WX 333 ; N hyphen ; B 73 215 379 345 ; +C 46 ; WX 278 ; N period ; B 64 0 245 146 ; +C 47 ; WX 278 ; N slash ; B -37 -19 468 737 ; +C 48 ; WX 556 ; N zero ; B 86 -19 617 710 ; +C 49 ; WX 556 ; N one ; B 173 0 529 710 ; +C 50 ; WX 556 ; N two ; B 26 0 619 710 ; +C 51 ; WX 556 ; N three ; B 65 -19 608 710 ; +C 52 ; WX 556 ; N four ; B 60 0 598 710 ; +C 53 ; WX 556 ; N five ; B 64 -19 636 698 ; +C 54 ; WX 556 ; N six ; B 85 -19 619 710 ; +C 55 ; WX 556 ; N seven ; B 125 0 676 698 ; +C 56 ; WX 556 ; N eight ; B 69 -19 616 710 ; +C 57 ; WX 556 ; N nine ; B 78 -19 615 710 ; +C 58 ; WX 333 ; N colon ; B 92 0 351 512 ; +C 59 ; WX 333 ; N semicolon ; B 56 -168 351 512 ; +C 60 ; WX 584 ; N less ; B 82 -8 655 514 ; +C 61 ; WX 584 ; N equal ; B 58 87 633 419 ; +C 62 ; WX 584 ; N greater ; B 36 -8 609 514 ; +C 63 ; WX 611 ; N question ; B 165 0 671 727 ; +C 64 ; WX 975 ; N at ; B 186 -19 954 737 ; +C 65 ; WX 722 ; N A ; B 20 0 702 718 ; +C 66 ; WX 722 ; N B ; B 76 0 764 718 ; +C 67 ; WX 722 ; N C ; B 107 -19 789 737 ; +C 68 ; WX 722 ; N D ; B 76 0 777 718 ; +C 69 ; WX 667 ; N E ; B 76 0 757 718 ; +C 70 ; WX 611 ; N F ; B 76 0 740 718 ; +C 71 ; WX 778 ; N G ; B 108 -19 817 737 ; +C 72 ; WX 722 ; N H ; B 71 0 804 718 ; +C 73 ; WX 278 ; N I ; B 64 0 367 718 ; +C 74 ; WX 556 ; N J ; B 60 -18 637 718 ; +C 75 ; WX 722 ; N K ; B 87 0 858 718 ; +C 76 ; WX 611 ; N L ; B 76 0 611 718 ; +C 77 ; WX 833 ; N M ; B 69 0 918 718 ; +C 78 ; WX 722 ; N N ; B 69 0 807 718 ; +C 79 ; WX 778 ; N O ; B 107 -19 823 737 ; +C 80 ; WX 667 ; N P ; B 76 0 738 718 ; +C 81 ; WX 778 ; N Q ; B 107 -52 823 737 ; +C 82 ; WX 722 ; N R ; B 76 0 778 718 ; +C 83 ; WX 667 ; N S ; B 81 -19 718 737 ; +C 84 ; WX 611 ; N T ; B 140 0 751 718 ; +C 85 ; WX 722 ; N U ; B 116 -19 804 718 ; +C 86 ; WX 667 ; N V ; B 172 0 801 718 ; +C 87 ; WX 944 ; N W ; B 169 0 1082 718 ; +C 88 ; WX 667 ; N X ; B 14 0 791 718 ; +C 89 ; WX 667 ; N Y ; B 168 0 806 718 ; +C 90 ; WX 611 ; N Z ; B 25 0 737 718 ; +C 91 ; WX 333 ; N bracketleft ; B 21 -196 462 722 ; +C 92 ; WX 278 ; N backslash ; B 124 -19 307 737 ; +C 93 ; WX 333 ; N bracketright ; B -18 -196 423 722 ; +C 94 ; WX 584 ; N asciicircum ; B 131 323 591 698 ; +C 95 ; WX 556 ; N underscore ; B -27 -125 540 -75 ; +C 96 ; WX 278 ; N quoteleft ; B 165 454 361 727 ; +C 97 ; WX 556 ; N a ; B 55 -14 583 546 ; +C 98 ; WX 611 ; N b ; B 61 -14 645 718 ; +C 99 ; WX 556 ; N c ; B 79 -14 599 546 ; +C 100 ; WX 611 ; N d ; B 82 -14 704 718 ; +C 101 ; WX 556 ; N e ; B 70 -14 593 546 ; +C 102 ; WX 333 ; N f ; B 87 0 469 727 ; L i fi ; L l fl ; +C 103 ; WX 611 ; N g ; B 38 -217 666 546 ; +C 104 ; WX 611 ; N h ; B 65 0 629 718 ; +C 105 ; WX 278 ; N i ; B 69 0 363 725 ; +C 106 ; WX 278 ; N j ; B -42 -214 363 725 ; +C 107 ; WX 556 ; N k ; B 69 0 670 718 ; +C 108 ; WX 278 ; N l ; B 69 0 362 718 ; +C 109 ; WX 889 ; N m ; B 64 0 909 546 ; +C 110 ; WX 611 ; N n ; B 65 0 629 546 ; +C 111 ; WX 611 ; N o ; B 82 -14 643 546 ; +C 112 ; WX 611 ; N p ; B 18 -207 645 546 ; +C 113 ; WX 611 ; N q ; B 80 -207 665 546 ; +C 114 ; WX 389 ; N r ; B 64 0 489 546 ; +C 115 ; WX 556 ; N s ; B 63 -14 584 546 ; +C 116 ; WX 333 ; N t ; B 100 -6 422 676 ; +C 117 ; WX 611 ; N u ; B 98 -14 658 532 ; +C 118 ; WX 556 ; N v ; B 126 0 656 532 ; +C 119 ; WX 778 ; N w ; B 123 0 882 532 ; +C 120 ; WX 556 ; N x ; B 15 0 648 532 ; +C 121 ; WX 556 ; N y ; B 42 -214 652 532 ; +C 122 ; WX 500 ; N z ; B 20 0 583 532 ; +C 123 ; WX 389 ; N braceleft ; B 94 -196 518 722 ; +C 124 ; WX 280 ; N bar ; B 36 -225 361 775 ; +C 125 ; WX 389 ; N braceright ; B -18 -196 407 722 ; +C 126 ; WX 584 ; N asciitilde ; B 115 163 577 343 ; +C 161 ; WX 333 ; N exclamdown ; B 50 -186 353 532 ; +C 162 ; WX 556 ; N cent ; B 79 -118 599 628 ; +C 163 ; WX 556 ; N sterling ; B 50 -16 635 718 ; +C 164 ; WX 167 ; N fraction ; B -174 -19 487 710 ; +C 165 ; WX 556 ; N yen ; B 60 0 713 698 ; +C 166 ; WX 556 ; N florin ; B -50 -210 669 737 ; +C 167 ; WX 556 ; N section ; B 61 -184 598 727 ; +C 168 ; WX 556 ; N currency ; B 27 76 680 636 ; +C 169 ; WX 238 ; N quotesingle ; B 165 447 321 718 ; +C 170 ; WX 500 ; N quotedblleft ; B 160 454 588 727 ; +C 171 ; WX 556 ; N guillemotleft ; B 135 76 571 484 ; +C 172 ; WX 333 ; N guilsinglleft ; B 130 76 353 484 ; +C 173 ; WX 333 ; N guilsinglright ; B 99 76 322 484 ; +C 174 ; WX 611 ; N fi ; B 87 0 696 727 ; +C 175 ; WX 611 ; N fl ; B 87 0 695 727 ; +C 177 ; WX 556 ; N endash ; B 48 227 627 333 ; +C 178 ; WX 556 ; N dagger ; B 118 -171 626 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 46 -171 628 718 ; +C 180 ; WX 278 ; N periodcentered ; B 110 172 276 334 ; +C 182 ; WX 556 ; N paragraph ; B 98 -191 688 700 ; +C 183 ; WX 350 ; N bullet ; B 83 194 420 524 ; +C 184 ; WX 278 ; N quotesinglbase ; B 41 -146 236 127 ; +C 185 ; WX 500 ; N quotedblbase ; B 36 -146 463 127 ; +C 186 ; WX 500 ; N quotedblright ; B 162 445 589 718 ; +C 187 ; WX 556 ; N guillemotright ; B 104 76 540 484 ; +C 188 ; WX 1000 ; N ellipsis ; B 92 0 939 146 ; +C 189 ; WX 1000 ; N perthousand ; B 76 -19 1038 710 ; +C 191 ; WX 611 ; N questiondown ; B 53 -195 559 532 ; +C 193 ; WX 333 ; N grave ; B 136 604 353 750 ; +C 194 ; WX 333 ; N acute ; B 236 604 515 750 ; +C 195 ; WX 333 ; N circumflex ; B 118 604 471 750 ; +C 196 ; WX 333 ; N tilde ; B 113 610 507 737 ; +C 197 ; WX 333 ; N macron ; B 122 604 483 678 ; +C 198 ; WX 333 ; N breve ; B 156 604 494 750 ; +C 199 ; WX 333 ; N dotaccent ; B 235 614 385 729 ; +C 200 ; WX 333 ; N dieresis ; B 137 614 482 729 ; +C 202 ; WX 333 ; N ring ; B 200 568 420 776 ; +C 203 ; WX 333 ; N cedilla ; B -37 -228 220 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 137 604 645 750 ; +C 206 ; WX 333 ; N ogonek ; B 41 -228 264 0 ; +C 207 ; WX 333 ; N caron ; B 149 604 502 750 ; +C 208 ; WX 1000 ; N emdash ; B 48 227 1071 333 ; +C 225 ; WX 1000 ; N AE ; B 5 0 1100 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 125 401 465 737 ; +C 232 ; WX 611 ; N Lslash ; B 34 0 611 718 ; +C 233 ; WX 778 ; N Oslash ; B 35 -27 894 745 ; +C 234 ; WX 1000 ; N OE ; B 99 -19 1114 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 123 401 485 737 ; +C 241 ; WX 889 ; N ae ; B 56 -14 923 546 ; +C 245 ; WX 278 ; N dotlessi ; B 69 0 322 532 ; +C 248 ; WX 278 ; N lslash ; B 40 0 407 718 ; +C 249 ; WX 611 ; N oslash ; B 22 -29 701 560 ; +C 250 ; WX 944 ; N oe ; B 82 -14 977 546 ; +C 251 ; WX 611 ; N germandbls ; B 69 -14 657 731 ; +C -1 ; WX 278 ; N Idieresis ; B 64 0 494 915 ; +C -1 ; WX 556 ; N eacute ; B 70 -14 627 750 ; +C -1 ; WX 556 ; N abreve ; B 55 -14 606 750 ; +C -1 ; WX 611 ; N uhungarumlaut ; B 98 -14 784 750 ; +C -1 ; WX 556 ; N ecaron ; B 70 -14 614 750 ; +C -1 ; WX 667 ; N Ydieresis ; B 168 0 806 915 ; +C -1 ; WX 584 ; N divide ; B 82 -42 610 548 ; +C -1 ; WX 667 ; N Yacute ; B 168 0 806 936 ; +C -1 ; WX 722 ; N Acircumflex ; B 20 0 706 936 ; +C -1 ; WX 556 ; N aacute ; B 55 -14 627 750 ; +C -1 ; WX 722 ; N Ucircumflex ; B 116 -19 804 936 ; +C -1 ; WX 556 ; N yacute ; B 42 -214 652 750 ; +C -1 ; WX 556 ; N scommaaccent ; B 63 -228 584 546 ; +C -1 ; WX 556 ; N ecircumflex ; B 70 -14 593 750 ; +C -1 ; WX 722 ; N Uring ; B 116 -19 804 962 ; +C -1 ; WX 722 ; N Udieresis ; B 116 -19 804 915 ; +C -1 ; WX 556 ; N aogonek ; B 55 -224 583 546 ; +C -1 ; WX 722 ; N Uacute ; B 116 -19 804 936 ; +C -1 ; WX 611 ; N uogonek ; B 98 -228 658 532 ; +C -1 ; WX 667 ; N Edieresis ; B 76 0 757 915 ; +C -1 ; WX 722 ; N Dcroat ; B 62 0 777 718 ; +C -1 ; WX 250 ; N commaaccent ; B 16 -228 188 -50 ; +C -1 ; WX 737 ; N copyright ; B 56 -19 835 737 ; +C -1 ; WX 667 ; N Emacron ; B 76 0 757 864 ; +C -1 ; WX 556 ; N ccaron ; B 79 -14 614 750 ; +C -1 ; WX 556 ; N aring ; B 55 -14 583 776 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 69 -228 807 718 ; +C -1 ; WX 278 ; N lacute ; B 69 0 528 936 ; +C -1 ; WX 556 ; N agrave ; B 55 -14 583 750 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 140 -228 751 718 ; +C -1 ; WX 722 ; N Cacute ; B 107 -19 789 936 ; +C -1 ; WX 556 ; N atilde ; B 55 -14 619 737 ; +C -1 ; WX 667 ; N Edotaccent ; B 76 0 757 915 ; +C -1 ; WX 556 ; N scaron ; B 63 -14 614 750 ; +C -1 ; WX 556 ; N scedilla ; B 63 -228 584 546 ; +C -1 ; WX 278 ; N iacute ; B 69 0 488 750 ; +C -1 ; WX 494 ; N lozenge ; B 90 0 564 745 ; +C -1 ; WX 722 ; N Rcaron ; B 76 0 778 936 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 108 -228 817 737 ; +C -1 ; WX 611 ; N ucircumflex ; B 98 -14 658 750 ; +C -1 ; WX 556 ; N acircumflex ; B 55 -14 583 750 ; +C -1 ; WX 722 ; N Amacron ; B 20 0 718 864 ; +C -1 ; WX 389 ; N rcaron ; B 64 0 530 750 ; +C -1 ; WX 556 ; N ccedilla ; B 79 -228 599 546 ; +C -1 ; WX 611 ; N Zdotaccent ; B 25 0 737 915 ; +C -1 ; WX 667 ; N Thorn ; B 76 0 716 718 ; +C -1 ; WX 778 ; N Omacron ; B 107 -19 823 864 ; +C -1 ; WX 722 ; N Racute ; B 76 0 778 936 ; +C -1 ; WX 667 ; N Sacute ; B 81 -19 722 936 ; +C -1 ; WX 743 ; N dcaron ; B 82 -14 903 718 ; +C -1 ; WX 722 ; N Umacron ; B 116 -19 804 864 ; +C -1 ; WX 611 ; N uring ; B 98 -14 658 776 ; +C -1 ; WX 333 ; N threesuperior ; B 91 271 441 710 ; +C -1 ; WX 778 ; N Ograve ; B 107 -19 823 936 ; +C -1 ; WX 722 ; N Agrave ; B 20 0 702 936 ; +C -1 ; WX 722 ; N Abreve ; B 20 0 729 936 ; +C -1 ; WX 584 ; N multiply ; B 57 1 635 505 ; +C -1 ; WX 611 ; N uacute ; B 98 -14 658 750 ; +C -1 ; WX 611 ; N Tcaron ; B 140 0 751 936 ; +C -1 ; WX 494 ; N partialdiff ; B 43 -21 585 750 ; +C -1 ; WX 556 ; N ydieresis ; B 42 -214 652 729 ; +C -1 ; WX 722 ; N Nacute ; B 69 0 807 936 ; +C -1 ; WX 278 ; N icircumflex ; B 69 0 444 750 ; +C -1 ; WX 667 ; N Ecircumflex ; B 76 0 757 936 ; +C -1 ; WX 556 ; N adieresis ; B 55 -14 594 729 ; +C -1 ; WX 556 ; N edieresis ; B 70 -14 594 729 ; +C -1 ; WX 556 ; N cacute ; B 79 -14 627 750 ; +C -1 ; WX 611 ; N nacute ; B 65 0 654 750 ; +C -1 ; WX 611 ; N umacron ; B 98 -14 658 678 ; +C -1 ; WX 722 ; N Ncaron ; B 69 0 807 936 ; +C -1 ; WX 278 ; N Iacute ; B 64 0 528 936 ; +C -1 ; WX 584 ; N plusminus ; B 40 0 625 506 ; +C -1 ; WX 280 ; N brokenbar ; B 52 -150 345 700 ; +C -1 ; WX 737 ; N registered ; B 55 -19 834 737 ; +C -1 ; WX 778 ; N Gbreve ; B 108 -19 817 936 ; +C -1 ; WX 278 ; N Idotaccent ; B 64 0 397 915 ; +C -1 ; WX 600 ; N summation ; B 14 -10 670 706 ; +C -1 ; WX 667 ; N Egrave ; B 76 0 757 936 ; +C -1 ; WX 389 ; N racute ; B 64 0 543 750 ; +C -1 ; WX 611 ; N omacron ; B 82 -14 643 678 ; +C -1 ; WX 611 ; N Zacute ; B 25 0 737 936 ; +C -1 ; WX 611 ; N Zcaron ; B 25 0 737 936 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 629 704 ; +C -1 ; WX 722 ; N Eth ; B 62 0 777 718 ; +C -1 ; WX 722 ; N Ccedilla ; B 107 -228 789 737 ; +C -1 ; WX 278 ; N lcommaaccent ; B 30 -228 362 718 ; +C -1 ; WX 389 ; N tcaron ; B 100 -6 608 878 ; +C -1 ; WX 556 ; N eogonek ; B 70 -228 593 546 ; +C -1 ; WX 722 ; N Uogonek ; B 116 -228 804 718 ; +C -1 ; WX 722 ; N Aacute ; B 20 0 750 936 ; +C -1 ; WX 722 ; N Adieresis ; B 20 0 716 915 ; +C -1 ; WX 556 ; N egrave ; B 70 -14 593 750 ; +C -1 ; WX 500 ; N zacute ; B 20 0 599 750 ; +C -1 ; WX 278 ; N iogonek ; B -14 -224 363 725 ; +C -1 ; WX 778 ; N Oacute ; B 107 -19 823 936 ; +C -1 ; WX 611 ; N oacute ; B 82 -14 654 750 ; +C -1 ; WX 556 ; N amacron ; B 55 -14 595 678 ; +C -1 ; WX 556 ; N sacute ; B 63 -14 627 750 ; +C -1 ; WX 278 ; N idieresis ; B 69 0 455 729 ; +C -1 ; WX 778 ; N Ocircumflex ; B 107 -19 823 936 ; +C -1 ; WX 722 ; N Ugrave ; B 116 -19 804 936 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 611 ; N thorn ; B 18 -208 645 718 ; +C -1 ; WX 333 ; N twosuperior ; B 69 283 449 710 ; +C -1 ; WX 778 ; N Odieresis ; B 107 -19 823 915 ; +C -1 ; WX 611 ; N mu ; B 22 -207 658 532 ; +C -1 ; WX 278 ; N igrave ; B 69 0 326 750 ; +C -1 ; WX 611 ; N ohungarumlaut ; B 82 -14 784 750 ; +C -1 ; WX 667 ; N Eogonek ; B 76 -224 757 718 ; +C -1 ; WX 611 ; N dcroat ; B 82 -14 789 718 ; +C -1 ; WX 834 ; N threequarters ; B 99 -19 839 710 ; +C -1 ; WX 667 ; N Scedilla ; B 81 -228 718 737 ; +C -1 ; WX 400 ; N lcaron ; B 69 0 561 718 ; +C -1 ; WX 722 ; N Kcommaaccent ; B 87 -228 858 718 ; +C -1 ; WX 611 ; N Lacute ; B 76 0 611 936 ; +C -1 ; WX 1000 ; N trademark ; B 179 306 1109 718 ; +C -1 ; WX 556 ; N edotaccent ; B 70 -14 593 729 ; +C -1 ; WX 278 ; N Igrave ; B 64 0 367 936 ; +C -1 ; WX 278 ; N Imacron ; B 64 0 496 864 ; +C -1 ; WX 611 ; N Lcaron ; B 76 0 643 718 ; +C -1 ; WX 834 ; N onehalf ; B 132 -19 858 710 ; +C -1 ; WX 549 ; N lessequal ; B 29 0 676 704 ; +C -1 ; WX 611 ; N ocircumflex ; B 82 -14 643 750 ; +C -1 ; WX 611 ; N ntilde ; B 65 0 646 737 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 116 -19 880 936 ; +C -1 ; WX 667 ; N Eacute ; B 76 0 757 936 ; +C -1 ; WX 556 ; N emacron ; B 70 -14 595 678 ; +C -1 ; WX 611 ; N gbreve ; B 38 -217 666 750 ; +C -1 ; WX 834 ; N onequarter ; B 132 -19 806 710 ; +C -1 ; WX 667 ; N Scaron ; B 81 -19 718 936 ; +C -1 ; WX 667 ; N Scommaaccent ; B 81 -228 718 737 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 107 -19 908 936 ; +C -1 ; WX 400 ; N degree ; B 175 426 467 712 ; +C -1 ; WX 611 ; N ograve ; B 82 -14 643 750 ; +C -1 ; WX 722 ; N Ccaron ; B 107 -19 789 936 ; +C -1 ; WX 611 ; N ugrave ; B 98 -14 658 750 ; +C -1 ; WX 549 ; N radical ; B 112 -46 689 850 ; +C -1 ; WX 722 ; N Dcaron ; B 76 0 777 936 ; +C -1 ; WX 389 ; N rcommaaccent ; B 26 -228 489 546 ; +C -1 ; WX 722 ; N Ntilde ; B 69 0 807 923 ; +C -1 ; WX 611 ; N otilde ; B 82 -14 646 737 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 76 -228 778 718 ; +C -1 ; WX 611 ; N Lcommaaccent ; B 76 -228 611 718 ; +C -1 ; WX 722 ; N Atilde ; B 20 0 741 923 ; +C -1 ; WX 722 ; N Aogonek ; B 20 -224 702 718 ; +C -1 ; WX 722 ; N Aring ; B 20 0 702 962 ; +C -1 ; WX 778 ; N Otilde ; B 107 -19 823 923 ; +C -1 ; WX 500 ; N zdotaccent ; B 20 0 583 729 ; +C -1 ; WX 667 ; N Ecaron ; B 76 0 757 936 ; +C -1 ; WX 278 ; N Iogonek ; B -41 -228 367 718 ; +C -1 ; WX 556 ; N kcommaaccent ; B 69 -228 670 718 ; +C -1 ; WX 584 ; N minus ; B 82 197 610 309 ; +C -1 ; WX 278 ; N Icircumflex ; B 64 0 484 936 ; +C -1 ; WX 611 ; N ncaron ; B 65 0 641 750 ; +C -1 ; WX 333 ; N tcommaaccent ; B 58 -228 422 676 ; +C -1 ; WX 584 ; N logicalnot ; B 105 108 633 419 ; +C -1 ; WX 611 ; N odieresis ; B 82 -14 643 729 ; +C -1 ; WX 611 ; N udieresis ; B 98 -14 658 729 ; +C -1 ; WX 549 ; N notequal ; B 32 -49 630 570 ; +C -1 ; WX 611 ; N gcommaaccent ; B 38 -217 666 850 ; +C -1 ; WX 611 ; N eth ; B 82 -14 670 737 ; +C -1 ; WX 500 ; N zcaron ; B 20 0 586 750 ; +C -1 ; WX 611 ; N ncommaaccent ; B 65 -228 629 546 ; +C -1 ; WX 333 ; N onesuperior ; B 148 283 388 710 ; +C -1 ; WX 278 ; N imacron ; B 69 0 429 678 ; +C -1 ; WX 556 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2481 +KPX A C -40 +KPX A Cacute -40 +KPX A Ccaron -40 +KPX A Ccedilla -40 +KPX A G -50 +KPX A Gbreve -50 +KPX A Gcommaaccent -50 +KPX A O -40 +KPX A Oacute -40 +KPX A Ocircumflex -40 +KPX A Odieresis -40 +KPX A Ograve -40 +KPX A Ohungarumlaut -40 +KPX A Omacron -40 +KPX A Oslash -40 +KPX A Otilde -40 +KPX A Q -40 +KPX A T -90 +KPX A Tcaron -90 +KPX A Tcommaaccent -90 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -80 +KPX A W -60 +KPX A Y -110 +KPX A Yacute -110 +KPX A Ydieresis -110 +KPX A u -30 +KPX A uacute -30 +KPX A ucircumflex -30 +KPX A udieresis -30 +KPX A ugrave -30 +KPX A uhungarumlaut -30 +KPX A umacron -30 +KPX A uogonek -30 +KPX A uring -30 +KPX A v -40 +KPX A w -30 +KPX A y -30 +KPX A yacute -30 +KPX A ydieresis -30 +KPX Aacute C -40 +KPX Aacute Cacute -40 +KPX Aacute Ccaron -40 +KPX Aacute Ccedilla -40 +KPX Aacute G -50 +KPX Aacute Gbreve -50 +KPX Aacute Gcommaaccent -50 +KPX Aacute O -40 +KPX Aacute Oacute -40 +KPX Aacute Ocircumflex -40 +KPX Aacute Odieresis -40 +KPX Aacute Ograve -40 +KPX Aacute Ohungarumlaut -40 +KPX Aacute Omacron -40 +KPX Aacute Oslash -40 +KPX Aacute Otilde -40 +KPX Aacute Q -40 +KPX Aacute T -90 +KPX Aacute Tcaron -90 +KPX Aacute Tcommaaccent -90 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -80 +KPX Aacute W -60 +KPX Aacute Y -110 +KPX Aacute Yacute -110 +KPX Aacute Ydieresis -110 +KPX Aacute u -30 +KPX Aacute uacute -30 +KPX Aacute ucircumflex -30 +KPX Aacute udieresis -30 +KPX Aacute ugrave -30 +KPX Aacute uhungarumlaut -30 +KPX Aacute umacron -30 +KPX Aacute uogonek -30 +KPX Aacute uring -30 +KPX Aacute v -40 +KPX Aacute w -30 +KPX Aacute y -30 +KPX Aacute yacute -30 +KPX Aacute ydieresis -30 +KPX Abreve C -40 +KPX Abreve Cacute -40 +KPX Abreve Ccaron -40 +KPX Abreve Ccedilla -40 +KPX Abreve G -50 +KPX Abreve Gbreve -50 +KPX Abreve Gcommaaccent -50 +KPX Abreve O -40 +KPX Abreve Oacute -40 +KPX Abreve Ocircumflex -40 +KPX Abreve Odieresis -40 +KPX Abreve Ograve -40 +KPX Abreve Ohungarumlaut -40 +KPX Abreve Omacron -40 +KPX Abreve Oslash -40 +KPX Abreve Otilde -40 +KPX Abreve Q -40 +KPX Abreve T -90 +KPX Abreve Tcaron -90 +KPX Abreve Tcommaaccent -90 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -80 +KPX Abreve W -60 +KPX Abreve Y -110 +KPX Abreve Yacute -110 +KPX Abreve Ydieresis -110 +KPX Abreve u -30 +KPX Abreve uacute -30 +KPX Abreve ucircumflex -30 +KPX Abreve udieresis -30 +KPX Abreve ugrave -30 +KPX Abreve uhungarumlaut -30 +KPX Abreve umacron -30 +KPX Abreve uogonek -30 +KPX Abreve uring -30 +KPX Abreve v -40 +KPX Abreve w -30 +KPX Abreve y -30 +KPX Abreve yacute -30 +KPX Abreve ydieresis -30 +KPX Acircumflex C -40 +KPX Acircumflex Cacute -40 +KPX Acircumflex Ccaron -40 +KPX Acircumflex Ccedilla -40 +KPX Acircumflex G -50 +KPX Acircumflex Gbreve -50 +KPX Acircumflex Gcommaaccent -50 +KPX Acircumflex O -40 +KPX Acircumflex Oacute -40 +KPX Acircumflex Ocircumflex -40 +KPX Acircumflex Odieresis -40 +KPX Acircumflex Ograve -40 +KPX Acircumflex Ohungarumlaut -40 +KPX Acircumflex Omacron -40 +KPX Acircumflex Oslash -40 +KPX Acircumflex Otilde -40 +KPX Acircumflex Q -40 +KPX Acircumflex T -90 +KPX Acircumflex Tcaron -90 +KPX Acircumflex Tcommaaccent -90 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -80 +KPX Acircumflex W -60 +KPX Acircumflex Y -110 +KPX Acircumflex Yacute -110 +KPX Acircumflex Ydieresis -110 +KPX Acircumflex u -30 +KPX Acircumflex uacute -30 +KPX Acircumflex ucircumflex -30 +KPX Acircumflex udieresis -30 +KPX Acircumflex ugrave -30 +KPX Acircumflex uhungarumlaut -30 +KPX Acircumflex umacron -30 +KPX Acircumflex uogonek -30 +KPX Acircumflex uring -30 +KPX Acircumflex v -40 +KPX Acircumflex w -30 +KPX Acircumflex y -30 +KPX Acircumflex yacute -30 +KPX Acircumflex ydieresis -30 +KPX Adieresis C -40 +KPX Adieresis Cacute -40 +KPX Adieresis Ccaron -40 +KPX Adieresis Ccedilla -40 +KPX Adieresis G -50 +KPX Adieresis Gbreve -50 +KPX Adieresis Gcommaaccent -50 +KPX Adieresis O -40 +KPX Adieresis Oacute -40 +KPX Adieresis Ocircumflex -40 +KPX Adieresis Odieresis -40 +KPX Adieresis Ograve -40 +KPX Adieresis Ohungarumlaut -40 +KPX Adieresis Omacron -40 +KPX Adieresis Oslash -40 +KPX Adieresis Otilde -40 +KPX Adieresis Q -40 +KPX Adieresis T -90 +KPX Adieresis Tcaron -90 +KPX Adieresis Tcommaaccent -90 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -80 +KPX Adieresis W -60 +KPX Adieresis Y -110 +KPX Adieresis Yacute -110 +KPX Adieresis Ydieresis -110 +KPX Adieresis u -30 +KPX Adieresis uacute -30 +KPX Adieresis ucircumflex -30 +KPX Adieresis udieresis -30 +KPX Adieresis ugrave -30 +KPX Adieresis uhungarumlaut -30 +KPX Adieresis umacron -30 +KPX Adieresis uogonek -30 +KPX Adieresis uring -30 +KPX Adieresis v -40 +KPX Adieresis w -30 +KPX Adieresis y -30 +KPX Adieresis yacute -30 +KPX Adieresis ydieresis -30 +KPX Agrave C -40 +KPX Agrave Cacute -40 +KPX Agrave Ccaron -40 +KPX Agrave Ccedilla -40 +KPX Agrave G -50 +KPX Agrave Gbreve -50 +KPX Agrave Gcommaaccent -50 +KPX Agrave O -40 +KPX Agrave Oacute -40 +KPX Agrave Ocircumflex -40 +KPX Agrave Odieresis -40 +KPX Agrave Ograve -40 +KPX Agrave Ohungarumlaut -40 +KPX Agrave Omacron -40 +KPX Agrave Oslash -40 +KPX Agrave Otilde -40 +KPX Agrave Q -40 +KPX Agrave T -90 +KPX Agrave Tcaron -90 +KPX Agrave Tcommaaccent -90 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -80 +KPX Agrave W -60 +KPX Agrave Y -110 +KPX Agrave Yacute -110 +KPX Agrave Ydieresis -110 +KPX Agrave u -30 +KPX Agrave uacute -30 +KPX Agrave ucircumflex -30 +KPX Agrave udieresis -30 +KPX Agrave ugrave -30 +KPX Agrave uhungarumlaut -30 +KPX Agrave umacron -30 +KPX Agrave uogonek -30 +KPX Agrave uring -30 +KPX Agrave v -40 +KPX Agrave w -30 +KPX Agrave y -30 +KPX Agrave yacute -30 +KPX Agrave ydieresis -30 +KPX Amacron C -40 +KPX Amacron Cacute -40 +KPX Amacron Ccaron -40 +KPX Amacron Ccedilla -40 +KPX Amacron G -50 +KPX Amacron Gbreve -50 +KPX Amacron Gcommaaccent -50 +KPX Amacron O -40 +KPX Amacron Oacute -40 +KPX Amacron Ocircumflex -40 +KPX Amacron Odieresis -40 +KPX Amacron Ograve -40 +KPX Amacron Ohungarumlaut -40 +KPX Amacron Omacron -40 +KPX Amacron Oslash -40 +KPX Amacron Otilde -40 +KPX Amacron Q -40 +KPX Amacron T -90 +KPX Amacron Tcaron -90 +KPX Amacron Tcommaaccent -90 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -80 +KPX Amacron W -60 +KPX Amacron Y -110 +KPX Amacron Yacute -110 +KPX Amacron Ydieresis -110 +KPX Amacron u -30 +KPX Amacron uacute -30 +KPX Amacron ucircumflex -30 +KPX Amacron udieresis -30 +KPX Amacron ugrave -30 +KPX Amacron uhungarumlaut -30 +KPX Amacron umacron -30 +KPX Amacron uogonek -30 +KPX Amacron uring -30 +KPX Amacron v -40 +KPX Amacron w -30 +KPX Amacron y -30 +KPX Amacron yacute -30 +KPX Amacron ydieresis -30 +KPX Aogonek C -40 +KPX Aogonek Cacute -40 +KPX Aogonek Ccaron -40 +KPX Aogonek Ccedilla -40 +KPX Aogonek G -50 +KPX Aogonek Gbreve -50 +KPX Aogonek Gcommaaccent -50 +KPX Aogonek O -40 +KPX Aogonek Oacute -40 +KPX Aogonek Ocircumflex -40 +KPX Aogonek Odieresis -40 +KPX Aogonek Ograve -40 +KPX Aogonek Ohungarumlaut -40 +KPX Aogonek Omacron -40 +KPX Aogonek Oslash -40 +KPX Aogonek Otilde -40 +KPX Aogonek Q -40 +KPX Aogonek T -90 +KPX Aogonek Tcaron -90 +KPX Aogonek Tcommaaccent -90 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -80 +KPX Aogonek W -60 +KPX Aogonek Y -110 +KPX Aogonek Yacute -110 +KPX Aogonek Ydieresis -110 +KPX Aogonek u -30 +KPX Aogonek uacute -30 +KPX Aogonek ucircumflex -30 +KPX Aogonek udieresis -30 +KPX Aogonek ugrave -30 +KPX Aogonek uhungarumlaut -30 +KPX Aogonek umacron -30 +KPX Aogonek uogonek -30 +KPX Aogonek uring -30 +KPX Aogonek v -40 +KPX Aogonek w -30 +KPX Aogonek y -30 +KPX Aogonek yacute -30 +KPX Aogonek ydieresis -30 +KPX Aring C -40 +KPX Aring Cacute -40 +KPX Aring Ccaron -40 +KPX Aring Ccedilla -40 +KPX Aring G -50 +KPX Aring Gbreve -50 +KPX Aring Gcommaaccent -50 +KPX Aring O -40 +KPX Aring Oacute -40 +KPX Aring Ocircumflex -40 +KPX Aring Odieresis -40 +KPX Aring Ograve -40 +KPX Aring Ohungarumlaut -40 +KPX Aring Omacron -40 +KPX Aring Oslash -40 +KPX Aring Otilde -40 +KPX Aring Q -40 +KPX Aring T -90 +KPX Aring Tcaron -90 +KPX Aring Tcommaaccent -90 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -80 +KPX Aring W -60 +KPX Aring Y -110 +KPX Aring Yacute -110 +KPX Aring Ydieresis -110 +KPX Aring u -30 +KPX Aring uacute -30 +KPX Aring ucircumflex -30 +KPX Aring udieresis -30 +KPX Aring ugrave -30 +KPX Aring uhungarumlaut -30 +KPX Aring umacron -30 +KPX Aring uogonek -30 +KPX Aring uring -30 +KPX Aring v -40 +KPX Aring w -30 +KPX Aring y -30 +KPX Aring yacute -30 +KPX Aring ydieresis -30 +KPX Atilde C -40 +KPX Atilde Cacute -40 +KPX Atilde Ccaron -40 +KPX Atilde Ccedilla -40 +KPX Atilde G -50 +KPX Atilde Gbreve -50 +KPX Atilde Gcommaaccent -50 +KPX Atilde O -40 +KPX Atilde Oacute -40 +KPX Atilde Ocircumflex -40 +KPX Atilde Odieresis -40 +KPX Atilde Ograve -40 +KPX Atilde Ohungarumlaut -40 +KPX Atilde Omacron -40 +KPX Atilde Oslash -40 +KPX Atilde Otilde -40 +KPX Atilde Q -40 +KPX Atilde T -90 +KPX Atilde Tcaron -90 +KPX Atilde Tcommaaccent -90 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -80 +KPX Atilde W -60 +KPX Atilde Y -110 +KPX Atilde Yacute -110 +KPX Atilde Ydieresis -110 +KPX Atilde u -30 +KPX Atilde uacute -30 +KPX Atilde ucircumflex -30 +KPX Atilde udieresis -30 +KPX Atilde ugrave -30 +KPX Atilde uhungarumlaut -30 +KPX Atilde umacron -30 +KPX Atilde uogonek -30 +KPX Atilde uring -30 +KPX Atilde v -40 +KPX Atilde w -30 +KPX Atilde y -30 +KPX Atilde yacute -30 +KPX Atilde ydieresis -30 +KPX B A -30 +KPX B Aacute -30 +KPX B Abreve -30 +KPX B Acircumflex -30 +KPX B Adieresis -30 +KPX B Agrave -30 +KPX B Amacron -30 +KPX B Aogonek -30 +KPX B Aring -30 +KPX B Atilde -30 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -40 +KPX D Aacute -40 +KPX D Abreve -40 +KPX D Acircumflex -40 +KPX D Adieresis -40 +KPX D Agrave -40 +KPX D Amacron -40 +KPX D Aogonek -40 +KPX D Aring -40 +KPX D Atilde -40 +KPX D V -40 +KPX D W -40 +KPX D Y -70 +KPX D Yacute -70 +KPX D Ydieresis -70 +KPX D comma -30 +KPX D period -30 +KPX Dcaron A -40 +KPX Dcaron Aacute -40 +KPX Dcaron Abreve -40 +KPX Dcaron Acircumflex -40 +KPX Dcaron Adieresis -40 +KPX Dcaron Agrave -40 +KPX Dcaron Amacron -40 +KPX Dcaron Aogonek -40 +KPX Dcaron Aring -40 +KPX Dcaron Atilde -40 +KPX Dcaron V -40 +KPX Dcaron W -40 +KPX Dcaron Y -70 +KPX Dcaron Yacute -70 +KPX Dcaron Ydieresis -70 +KPX Dcaron comma -30 +KPX Dcaron period -30 +KPX Dcroat A -40 +KPX Dcroat Aacute -40 +KPX Dcroat Abreve -40 +KPX Dcroat Acircumflex -40 +KPX Dcroat Adieresis -40 +KPX Dcroat Agrave -40 +KPX Dcroat Amacron -40 +KPX Dcroat Aogonek -40 +KPX Dcroat Aring -40 +KPX Dcroat Atilde -40 +KPX Dcroat V -40 +KPX Dcroat W -40 +KPX Dcroat Y -70 +KPX Dcroat Yacute -70 +KPX Dcroat Ydieresis -70 +KPX Dcroat comma -30 +KPX Dcroat period -30 +KPX F A -80 +KPX F Aacute -80 +KPX F Abreve -80 +KPX F Acircumflex -80 +KPX F Adieresis -80 +KPX F Agrave -80 +KPX F Amacron -80 +KPX F Aogonek -80 +KPX F Aring -80 +KPX F Atilde -80 +KPX F a -20 +KPX F aacute -20 +KPX F abreve -20 +KPX F acircumflex -20 +KPX F adieresis -20 +KPX F agrave -20 +KPX F amacron -20 +KPX F aogonek -20 +KPX F aring -20 +KPX F atilde -20 +KPX F comma -100 +KPX F period -100 +KPX J A -20 +KPX J Aacute -20 +KPX J Abreve -20 +KPX J Acircumflex -20 +KPX J Adieresis -20 +KPX J Agrave -20 +KPX J Amacron -20 +KPX J Aogonek -20 +KPX J Aring -20 +KPX J Atilde -20 +KPX J comma -20 +KPX J period -20 +KPX J u -20 +KPX J uacute -20 +KPX J ucircumflex -20 +KPX J udieresis -20 +KPX J ugrave -20 +KPX J uhungarumlaut -20 +KPX J umacron -20 +KPX J uogonek -20 +KPX J uring -20 +KPX K O -30 +KPX K Oacute -30 +KPX K Ocircumflex -30 +KPX K Odieresis -30 +KPX K Ograve -30 +KPX K Ohungarumlaut -30 +KPX K Omacron -30 +KPX K Oslash -30 +KPX K Otilde -30 +KPX K e -15 +KPX K eacute -15 +KPX K ecaron -15 +KPX K ecircumflex -15 +KPX K edieresis -15 +KPX K edotaccent -15 +KPX K egrave -15 +KPX K emacron -15 +KPX K eogonek -15 +KPX K o -35 +KPX K oacute -35 +KPX K ocircumflex -35 +KPX K odieresis -35 +KPX K ograve -35 +KPX K ohungarumlaut -35 +KPX K omacron -35 +KPX K oslash -35 +KPX K otilde -35 +KPX K u -30 +KPX K uacute -30 +KPX K ucircumflex -30 +KPX K udieresis -30 +KPX K ugrave -30 +KPX K uhungarumlaut -30 +KPX K umacron -30 +KPX K uogonek -30 +KPX K uring -30 +KPX K y -40 +KPX K yacute -40 +KPX K ydieresis -40 +KPX Kcommaaccent O -30 +KPX Kcommaaccent Oacute -30 +KPX Kcommaaccent Ocircumflex -30 +KPX Kcommaaccent Odieresis -30 +KPX Kcommaaccent Ograve -30 +KPX Kcommaaccent Ohungarumlaut -30 +KPX Kcommaaccent Omacron -30 +KPX Kcommaaccent Oslash -30 +KPX Kcommaaccent Otilde -30 +KPX Kcommaaccent e -15 +KPX Kcommaaccent eacute -15 +KPX Kcommaaccent ecaron -15 +KPX Kcommaaccent ecircumflex -15 +KPX Kcommaaccent edieresis -15 +KPX Kcommaaccent edotaccent -15 +KPX Kcommaaccent egrave -15 +KPX Kcommaaccent emacron -15 +KPX Kcommaaccent eogonek -15 +KPX Kcommaaccent o -35 +KPX Kcommaaccent oacute -35 +KPX Kcommaaccent ocircumflex -35 +KPX Kcommaaccent odieresis -35 +KPX Kcommaaccent ograve -35 +KPX Kcommaaccent ohungarumlaut -35 +KPX Kcommaaccent omacron -35 +KPX Kcommaaccent oslash -35 +KPX Kcommaaccent otilde -35 +KPX Kcommaaccent u -30 +KPX Kcommaaccent uacute -30 +KPX Kcommaaccent ucircumflex -30 +KPX Kcommaaccent udieresis -30 +KPX Kcommaaccent ugrave -30 +KPX Kcommaaccent uhungarumlaut -30 +KPX Kcommaaccent umacron -30 +KPX Kcommaaccent uogonek -30 +KPX Kcommaaccent uring -30 +KPX Kcommaaccent y -40 +KPX Kcommaaccent yacute -40 +KPX Kcommaaccent ydieresis -40 +KPX L T -90 +KPX L Tcaron -90 +KPX L Tcommaaccent -90 +KPX L V -110 +KPX L W -80 +KPX L Y -120 +KPX L Yacute -120 +KPX L Ydieresis -120 +KPX L quotedblright -140 +KPX L quoteright -140 +KPX L y -30 +KPX L yacute -30 +KPX L ydieresis -30 +KPX Lacute T -90 +KPX Lacute Tcaron -90 +KPX Lacute Tcommaaccent -90 +KPX Lacute V -110 +KPX Lacute W -80 +KPX Lacute Y -120 +KPX Lacute Yacute -120 +KPX Lacute Ydieresis -120 +KPX Lacute quotedblright -140 +KPX Lacute quoteright -140 +KPX Lacute y -30 +KPX Lacute yacute -30 +KPX Lacute ydieresis -30 +KPX Lcommaaccent T -90 +KPX Lcommaaccent Tcaron -90 +KPX Lcommaaccent Tcommaaccent -90 +KPX Lcommaaccent V -110 +KPX Lcommaaccent W -80 +KPX Lcommaaccent Y -120 +KPX Lcommaaccent Yacute -120 +KPX Lcommaaccent Ydieresis -120 +KPX Lcommaaccent quotedblright -140 +KPX Lcommaaccent quoteright -140 +KPX Lcommaaccent y -30 +KPX Lcommaaccent yacute -30 +KPX Lcommaaccent ydieresis -30 +KPX Lslash T -90 +KPX Lslash Tcaron -90 +KPX Lslash Tcommaaccent -90 +KPX Lslash V -110 +KPX Lslash W -80 +KPX Lslash Y -120 +KPX Lslash Yacute -120 +KPX Lslash Ydieresis -120 +KPX Lslash quotedblright -140 +KPX Lslash quoteright -140 +KPX Lslash y -30 +KPX Lslash yacute -30 +KPX Lslash ydieresis -30 +KPX O A -50 +KPX O Aacute -50 +KPX O Abreve -50 +KPX O Acircumflex -50 +KPX O Adieresis -50 +KPX O Agrave -50 +KPX O Amacron -50 +KPX O Aogonek -50 +KPX O Aring -50 +KPX O Atilde -50 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -50 +KPX O X -50 +KPX O Y -70 +KPX O Yacute -70 +KPX O Ydieresis -70 +KPX O comma -40 +KPX O period -40 +KPX Oacute A -50 +KPX Oacute Aacute -50 +KPX Oacute Abreve -50 +KPX Oacute Acircumflex -50 +KPX Oacute Adieresis -50 +KPX Oacute Agrave -50 +KPX Oacute Amacron -50 +KPX Oacute Aogonek -50 +KPX Oacute Aring -50 +KPX Oacute Atilde -50 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -50 +KPX Oacute X -50 +KPX Oacute Y -70 +KPX Oacute Yacute -70 +KPX Oacute Ydieresis -70 +KPX Oacute comma -40 +KPX Oacute period -40 +KPX Ocircumflex A -50 +KPX Ocircumflex Aacute -50 +KPX Ocircumflex Abreve -50 +KPX Ocircumflex Acircumflex -50 +KPX Ocircumflex Adieresis -50 +KPX Ocircumflex Agrave -50 +KPX Ocircumflex Amacron -50 +KPX Ocircumflex Aogonek -50 +KPX Ocircumflex Aring -50 +KPX Ocircumflex Atilde -50 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -50 +KPX Ocircumflex X -50 +KPX Ocircumflex Y -70 +KPX Ocircumflex Yacute -70 +KPX Ocircumflex Ydieresis -70 +KPX Ocircumflex comma -40 +KPX Ocircumflex period -40 +KPX Odieresis A -50 +KPX Odieresis Aacute -50 +KPX Odieresis Abreve -50 +KPX Odieresis Acircumflex -50 +KPX Odieresis Adieresis -50 +KPX Odieresis Agrave -50 +KPX Odieresis Amacron -50 +KPX Odieresis Aogonek -50 +KPX Odieresis Aring -50 +KPX Odieresis Atilde -50 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -50 +KPX Odieresis X -50 +KPX Odieresis Y -70 +KPX Odieresis Yacute -70 +KPX Odieresis Ydieresis -70 +KPX Odieresis comma -40 +KPX Odieresis period -40 +KPX Ograve A -50 +KPX Ograve Aacute -50 +KPX Ograve Abreve -50 +KPX Ograve Acircumflex -50 +KPX Ograve Adieresis -50 +KPX Ograve Agrave -50 +KPX Ograve Amacron -50 +KPX Ograve Aogonek -50 +KPX Ograve Aring -50 +KPX Ograve Atilde -50 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -50 +KPX Ograve X -50 +KPX Ograve Y -70 +KPX Ograve Yacute -70 +KPX Ograve Ydieresis -70 +KPX Ograve comma -40 +KPX Ograve period -40 +KPX Ohungarumlaut A -50 +KPX Ohungarumlaut Aacute -50 +KPX Ohungarumlaut Abreve -50 +KPX Ohungarumlaut Acircumflex -50 +KPX Ohungarumlaut Adieresis -50 +KPX Ohungarumlaut Agrave -50 +KPX Ohungarumlaut Amacron -50 +KPX Ohungarumlaut Aogonek -50 +KPX Ohungarumlaut Aring -50 +KPX Ohungarumlaut Atilde -50 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -50 +KPX Ohungarumlaut X -50 +KPX Ohungarumlaut Y -70 +KPX Ohungarumlaut Yacute -70 +KPX Ohungarumlaut Ydieresis -70 +KPX Ohungarumlaut comma -40 +KPX Ohungarumlaut period -40 +KPX Omacron A -50 +KPX Omacron Aacute -50 +KPX Omacron Abreve -50 +KPX Omacron Acircumflex -50 +KPX Omacron Adieresis -50 +KPX Omacron Agrave -50 +KPX Omacron Amacron -50 +KPX Omacron Aogonek -50 +KPX Omacron Aring -50 +KPX Omacron Atilde -50 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -50 +KPX Omacron X -50 +KPX Omacron Y -70 +KPX Omacron Yacute -70 +KPX Omacron Ydieresis -70 +KPX Omacron comma -40 +KPX Omacron period -40 +KPX Oslash A -50 +KPX Oslash Aacute -50 +KPX Oslash Abreve -50 +KPX Oslash Acircumflex -50 +KPX Oslash Adieresis -50 +KPX Oslash Agrave -50 +KPX Oslash Amacron -50 +KPX Oslash Aogonek -50 +KPX Oslash Aring -50 +KPX Oslash Atilde -50 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -50 +KPX Oslash X -50 +KPX Oslash Y -70 +KPX Oslash Yacute -70 +KPX Oslash Ydieresis -70 +KPX Oslash comma -40 +KPX Oslash period -40 +KPX Otilde A -50 +KPX Otilde Aacute -50 +KPX Otilde Abreve -50 +KPX Otilde Acircumflex -50 +KPX Otilde Adieresis -50 +KPX Otilde Agrave -50 +KPX Otilde Amacron -50 +KPX Otilde Aogonek -50 +KPX Otilde Aring -50 +KPX Otilde Atilde -50 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -50 +KPX Otilde X -50 +KPX Otilde Y -70 +KPX Otilde Yacute -70 +KPX Otilde Ydieresis -70 +KPX Otilde comma -40 +KPX Otilde period -40 +KPX P A -100 +KPX P Aacute -100 +KPX P Abreve -100 +KPX P Acircumflex -100 +KPX P Adieresis -100 +KPX P Agrave -100 +KPX P Amacron -100 +KPX P Aogonek -100 +KPX P Aring -100 +KPX P Atilde -100 +KPX P a -30 +KPX P aacute -30 +KPX P abreve -30 +KPX P acircumflex -30 +KPX P adieresis -30 +KPX P agrave -30 +KPX P amacron -30 +KPX P aogonek -30 +KPX P aring -30 +KPX P atilde -30 +KPX P comma -120 +KPX P e -30 +KPX P eacute -30 +KPX P ecaron -30 +KPX P ecircumflex -30 +KPX P edieresis -30 +KPX P edotaccent -30 +KPX P egrave -30 +KPX P emacron -30 +KPX P eogonek -30 +KPX P o -40 +KPX P oacute -40 +KPX P ocircumflex -40 +KPX P odieresis -40 +KPX P ograve -40 +KPX P ohungarumlaut -40 +KPX P omacron -40 +KPX P oslash -40 +KPX P otilde -40 +KPX P period -120 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX Q comma 20 +KPX Q period 20 +KPX R O -20 +KPX R Oacute -20 +KPX R Ocircumflex -20 +KPX R Odieresis -20 +KPX R Ograve -20 +KPX R Ohungarumlaut -20 +KPX R Omacron -20 +KPX R Oslash -20 +KPX R Otilde -20 +KPX R T -20 +KPX R Tcaron -20 +KPX R Tcommaaccent -20 +KPX R U -20 +KPX R Uacute -20 +KPX R Ucircumflex -20 +KPX R Udieresis -20 +KPX R Ugrave -20 +KPX R Uhungarumlaut -20 +KPX R Umacron -20 +KPX R Uogonek -20 +KPX R Uring -20 +KPX R V -50 +KPX R W -40 +KPX R Y -50 +KPX R Yacute -50 +KPX R Ydieresis -50 +KPX Racute O -20 +KPX Racute Oacute -20 +KPX Racute Ocircumflex -20 +KPX Racute Odieresis -20 +KPX Racute Ograve -20 +KPX Racute Ohungarumlaut -20 +KPX Racute Omacron -20 +KPX Racute Oslash -20 +KPX Racute Otilde -20 +KPX Racute T -20 +KPX Racute Tcaron -20 +KPX Racute Tcommaaccent -20 +KPX Racute U -20 +KPX Racute Uacute -20 +KPX Racute Ucircumflex -20 +KPX Racute Udieresis -20 +KPX Racute Ugrave -20 +KPX Racute Uhungarumlaut -20 +KPX Racute Umacron -20 +KPX Racute Uogonek -20 +KPX Racute Uring -20 +KPX Racute V -50 +KPX Racute W -40 +KPX Racute Y -50 +KPX Racute Yacute -50 +KPX Racute Ydieresis -50 +KPX Rcaron O -20 +KPX Rcaron Oacute -20 +KPX Rcaron Ocircumflex -20 +KPX Rcaron Odieresis -20 +KPX Rcaron Ograve -20 +KPX Rcaron Ohungarumlaut -20 +KPX Rcaron Omacron -20 +KPX Rcaron Oslash -20 +KPX Rcaron Otilde -20 +KPX Rcaron T -20 +KPX Rcaron Tcaron -20 +KPX Rcaron Tcommaaccent -20 +KPX Rcaron U -20 +KPX Rcaron Uacute -20 +KPX Rcaron Ucircumflex -20 +KPX Rcaron Udieresis -20 +KPX Rcaron Ugrave -20 +KPX Rcaron Uhungarumlaut -20 +KPX Rcaron Umacron -20 +KPX Rcaron Uogonek -20 +KPX Rcaron Uring -20 +KPX Rcaron V -50 +KPX Rcaron W -40 +KPX Rcaron Y -50 +KPX Rcaron Yacute -50 +KPX Rcaron Ydieresis -50 +KPX Rcommaaccent O -20 +KPX Rcommaaccent Oacute -20 +KPX Rcommaaccent Ocircumflex -20 +KPX Rcommaaccent Odieresis -20 +KPX Rcommaaccent Ograve -20 +KPX Rcommaaccent Ohungarumlaut -20 +KPX Rcommaaccent Omacron -20 +KPX Rcommaaccent Oslash -20 +KPX Rcommaaccent Otilde -20 +KPX Rcommaaccent T -20 +KPX Rcommaaccent Tcaron -20 +KPX Rcommaaccent Tcommaaccent -20 +KPX Rcommaaccent U -20 +KPX Rcommaaccent Uacute -20 +KPX Rcommaaccent Ucircumflex -20 +KPX Rcommaaccent Udieresis -20 +KPX Rcommaaccent Ugrave -20 +KPX Rcommaaccent Uhungarumlaut -20 +KPX Rcommaaccent Umacron -20 +KPX Rcommaaccent Uogonek -20 +KPX Rcommaaccent Uring -20 +KPX Rcommaaccent V -50 +KPX Rcommaaccent W -40 +KPX Rcommaaccent Y -50 +KPX Rcommaaccent Yacute -50 +KPX Rcommaaccent Ydieresis -50 +KPX T A -90 +KPX T Aacute -90 +KPX T Abreve -90 +KPX T Acircumflex -90 +KPX T Adieresis -90 +KPX T Agrave -90 +KPX T Amacron -90 +KPX T Aogonek -90 +KPX T Aring -90 +KPX T Atilde -90 +KPX T O -40 +KPX T Oacute -40 +KPX T Ocircumflex -40 +KPX T Odieresis -40 +KPX T Ograve -40 +KPX T Ohungarumlaut -40 +KPX T Omacron -40 +KPX T Oslash -40 +KPX T Otilde -40 +KPX T a -80 +KPX T aacute -80 +KPX T abreve -80 +KPX T acircumflex -80 +KPX T adieresis -80 +KPX T agrave -80 +KPX T amacron -80 +KPX T aogonek -80 +KPX T aring -80 +KPX T atilde -80 +KPX T colon -40 +KPX T comma -80 +KPX T e -60 +KPX T eacute -60 +KPX T ecaron -60 +KPX T ecircumflex -60 +KPX T edieresis -60 +KPX T edotaccent -60 +KPX T egrave -60 +KPX T emacron -60 +KPX T eogonek -60 +KPX T hyphen -120 +KPX T o -80 +KPX T oacute -80 +KPX T ocircumflex -80 +KPX T odieresis -80 +KPX T ograve -80 +KPX T ohungarumlaut -80 +KPX T omacron -80 +KPX T oslash -80 +KPX T otilde -80 +KPX T period -80 +KPX T r -80 +KPX T racute -80 +KPX T rcommaaccent -80 +KPX T semicolon -40 +KPX T u -90 +KPX T uacute -90 +KPX T ucircumflex -90 +KPX T udieresis -90 +KPX T ugrave -90 +KPX T uhungarumlaut -90 +KPX T umacron -90 +KPX T uogonek -90 +KPX T uring -90 +KPX T w -60 +KPX T y -60 +KPX T yacute -60 +KPX T ydieresis -60 +KPX Tcaron A -90 +KPX Tcaron Aacute -90 +KPX Tcaron Abreve -90 +KPX Tcaron Acircumflex -90 +KPX Tcaron Adieresis -90 +KPX Tcaron Agrave -90 +KPX Tcaron Amacron -90 +KPX Tcaron Aogonek -90 +KPX Tcaron Aring -90 +KPX Tcaron Atilde -90 +KPX Tcaron O -40 +KPX Tcaron Oacute -40 +KPX Tcaron Ocircumflex -40 +KPX Tcaron Odieresis -40 +KPX Tcaron Ograve -40 +KPX Tcaron Ohungarumlaut -40 +KPX Tcaron Omacron -40 +KPX Tcaron Oslash -40 +KPX Tcaron Otilde -40 +KPX Tcaron a -80 +KPX Tcaron aacute -80 +KPX Tcaron abreve -80 +KPX Tcaron acircumflex -80 +KPX Tcaron adieresis -80 +KPX Tcaron agrave -80 +KPX Tcaron amacron -80 +KPX Tcaron aogonek -80 +KPX Tcaron aring -80 +KPX Tcaron atilde -80 +KPX Tcaron colon -40 +KPX Tcaron comma -80 +KPX Tcaron e -60 +KPX Tcaron eacute -60 +KPX Tcaron ecaron -60 +KPX Tcaron ecircumflex -60 +KPX Tcaron edieresis -60 +KPX Tcaron edotaccent -60 +KPX Tcaron egrave -60 +KPX Tcaron emacron -60 +KPX Tcaron eogonek -60 +KPX Tcaron hyphen -120 +KPX Tcaron o -80 +KPX Tcaron oacute -80 +KPX Tcaron ocircumflex -80 +KPX Tcaron odieresis -80 +KPX Tcaron ograve -80 +KPX Tcaron ohungarumlaut -80 +KPX Tcaron omacron -80 +KPX Tcaron oslash -80 +KPX Tcaron otilde -80 +KPX Tcaron period -80 +KPX Tcaron r -80 +KPX Tcaron racute -80 +KPX Tcaron rcommaaccent -80 +KPX Tcaron semicolon -40 +KPX Tcaron u -90 +KPX Tcaron uacute -90 +KPX Tcaron ucircumflex -90 +KPX Tcaron udieresis -90 +KPX Tcaron ugrave -90 +KPX Tcaron uhungarumlaut -90 +KPX Tcaron umacron -90 +KPX Tcaron uogonek -90 +KPX Tcaron uring -90 +KPX Tcaron w -60 +KPX Tcaron y -60 +KPX Tcaron yacute -60 +KPX Tcaron ydieresis -60 +KPX Tcommaaccent A -90 +KPX Tcommaaccent Aacute -90 +KPX Tcommaaccent Abreve -90 +KPX Tcommaaccent Acircumflex -90 +KPX Tcommaaccent Adieresis -90 +KPX Tcommaaccent Agrave -90 +KPX Tcommaaccent Amacron -90 +KPX Tcommaaccent Aogonek -90 +KPX Tcommaaccent Aring -90 +KPX Tcommaaccent Atilde -90 +KPX Tcommaaccent O -40 +KPX Tcommaaccent Oacute -40 +KPX Tcommaaccent Ocircumflex -40 +KPX Tcommaaccent Odieresis -40 +KPX Tcommaaccent Ograve -40 +KPX Tcommaaccent Ohungarumlaut -40 +KPX Tcommaaccent Omacron -40 +KPX Tcommaaccent Oslash -40 +KPX Tcommaaccent Otilde -40 +KPX Tcommaaccent a -80 +KPX Tcommaaccent aacute -80 +KPX Tcommaaccent abreve -80 +KPX Tcommaaccent acircumflex -80 +KPX Tcommaaccent adieresis -80 +KPX Tcommaaccent agrave -80 +KPX Tcommaaccent amacron -80 +KPX Tcommaaccent aogonek -80 +KPX Tcommaaccent aring -80 +KPX Tcommaaccent atilde -80 +KPX Tcommaaccent colon -40 +KPX Tcommaaccent comma -80 +KPX Tcommaaccent e -60 +KPX Tcommaaccent eacute -60 +KPX Tcommaaccent ecaron -60 +KPX Tcommaaccent ecircumflex -60 +KPX Tcommaaccent edieresis -60 +KPX Tcommaaccent edotaccent -60 +KPX Tcommaaccent egrave -60 +KPX Tcommaaccent emacron -60 +KPX Tcommaaccent eogonek -60 +KPX Tcommaaccent hyphen -120 +KPX Tcommaaccent o -80 +KPX Tcommaaccent oacute -80 +KPX Tcommaaccent ocircumflex -80 +KPX Tcommaaccent odieresis -80 +KPX Tcommaaccent ograve -80 +KPX Tcommaaccent ohungarumlaut -80 +KPX Tcommaaccent omacron -80 +KPX Tcommaaccent oslash -80 +KPX Tcommaaccent otilde -80 +KPX Tcommaaccent period -80 +KPX Tcommaaccent r -80 +KPX Tcommaaccent racute -80 +KPX Tcommaaccent rcommaaccent -80 +KPX Tcommaaccent semicolon -40 +KPX Tcommaaccent u -90 +KPX Tcommaaccent uacute -90 +KPX Tcommaaccent ucircumflex -90 +KPX Tcommaaccent udieresis -90 +KPX Tcommaaccent ugrave -90 +KPX Tcommaaccent uhungarumlaut -90 +KPX Tcommaaccent umacron -90 +KPX Tcommaaccent uogonek -90 +KPX Tcommaaccent uring -90 +KPX Tcommaaccent w -60 +KPX Tcommaaccent y -60 +KPX Tcommaaccent yacute -60 +KPX Tcommaaccent ydieresis -60 +KPX U A -50 +KPX U Aacute -50 +KPX U Abreve -50 +KPX U Acircumflex -50 +KPX U Adieresis -50 +KPX U Agrave -50 +KPX U Amacron -50 +KPX U Aogonek -50 +KPX U Aring -50 +KPX U Atilde -50 +KPX U comma -30 +KPX U period -30 +KPX Uacute A -50 +KPX Uacute Aacute -50 +KPX Uacute Abreve -50 +KPX Uacute Acircumflex -50 +KPX Uacute Adieresis -50 +KPX Uacute Agrave -50 +KPX Uacute Amacron -50 +KPX Uacute Aogonek -50 +KPX Uacute Aring -50 +KPX Uacute Atilde -50 +KPX Uacute comma -30 +KPX Uacute period -30 +KPX Ucircumflex A -50 +KPX Ucircumflex Aacute -50 +KPX Ucircumflex Abreve -50 +KPX Ucircumflex Acircumflex -50 +KPX Ucircumflex Adieresis -50 +KPX Ucircumflex Agrave -50 +KPX Ucircumflex Amacron -50 +KPX Ucircumflex Aogonek -50 +KPX Ucircumflex Aring -50 +KPX Ucircumflex Atilde -50 +KPX Ucircumflex comma -30 +KPX Ucircumflex period -30 +KPX Udieresis A -50 +KPX Udieresis Aacute -50 +KPX Udieresis Abreve -50 +KPX Udieresis Acircumflex -50 +KPX Udieresis Adieresis -50 +KPX Udieresis Agrave -50 +KPX Udieresis Amacron -50 +KPX Udieresis Aogonek -50 +KPX Udieresis Aring -50 +KPX Udieresis Atilde -50 +KPX Udieresis comma -30 +KPX Udieresis period -30 +KPX Ugrave A -50 +KPX Ugrave Aacute -50 +KPX Ugrave Abreve -50 +KPX Ugrave Acircumflex -50 +KPX Ugrave Adieresis -50 +KPX Ugrave Agrave -50 +KPX Ugrave Amacron -50 +KPX Ugrave Aogonek -50 +KPX Ugrave Aring -50 +KPX Ugrave Atilde -50 +KPX Ugrave comma -30 +KPX Ugrave period -30 +KPX Uhungarumlaut A -50 +KPX Uhungarumlaut Aacute -50 +KPX Uhungarumlaut Abreve -50 +KPX Uhungarumlaut Acircumflex -50 +KPX Uhungarumlaut Adieresis -50 +KPX Uhungarumlaut Agrave -50 +KPX Uhungarumlaut Amacron -50 +KPX Uhungarumlaut Aogonek -50 +KPX Uhungarumlaut Aring -50 +KPX Uhungarumlaut Atilde -50 +KPX Uhungarumlaut comma -30 +KPX Uhungarumlaut period -30 +KPX Umacron A -50 +KPX Umacron Aacute -50 +KPX Umacron Abreve -50 +KPX Umacron Acircumflex -50 +KPX Umacron Adieresis -50 +KPX Umacron Agrave -50 +KPX Umacron Amacron -50 +KPX Umacron Aogonek -50 +KPX Umacron Aring -50 +KPX Umacron Atilde -50 +KPX Umacron comma -30 +KPX Umacron period -30 +KPX Uogonek A -50 +KPX Uogonek Aacute -50 +KPX Uogonek Abreve -50 +KPX Uogonek Acircumflex -50 +KPX Uogonek Adieresis -50 +KPX Uogonek Agrave -50 +KPX Uogonek Amacron -50 +KPX Uogonek Aogonek -50 +KPX Uogonek Aring -50 +KPX Uogonek Atilde -50 +KPX Uogonek comma -30 +KPX Uogonek period -30 +KPX Uring A -50 +KPX Uring Aacute -50 +KPX Uring Abreve -50 +KPX Uring Acircumflex -50 +KPX Uring Adieresis -50 +KPX Uring Agrave -50 +KPX Uring Amacron -50 +KPX Uring Aogonek -50 +KPX Uring Aring -50 +KPX Uring Atilde -50 +KPX Uring comma -30 +KPX Uring period -30 +KPX V A -80 +KPX V Aacute -80 +KPX V Abreve -80 +KPX V Acircumflex -80 +KPX V Adieresis -80 +KPX V Agrave -80 +KPX V Amacron -80 +KPX V Aogonek -80 +KPX V Aring -80 +KPX V Atilde -80 +KPX V G -50 +KPX V Gbreve -50 +KPX V Gcommaaccent -50 +KPX V O -50 +KPX V Oacute -50 +KPX V Ocircumflex -50 +KPX V Odieresis -50 +KPX V Ograve -50 +KPX V Ohungarumlaut -50 +KPX V Omacron -50 +KPX V Oslash -50 +KPX V Otilde -50 +KPX V a -60 +KPX V aacute -60 +KPX V abreve -60 +KPX V acircumflex -60 +KPX V adieresis -60 +KPX V agrave -60 +KPX V amacron -60 +KPX V aogonek -60 +KPX V aring -60 +KPX V atilde -60 +KPX V colon -40 +KPX V comma -120 +KPX V e -50 +KPX V eacute -50 +KPX V ecaron -50 +KPX V ecircumflex -50 +KPX V edieresis -50 +KPX V edotaccent -50 +KPX V egrave -50 +KPX V emacron -50 +KPX V eogonek -50 +KPX V hyphen -80 +KPX V o -90 +KPX V oacute -90 +KPX V ocircumflex -90 +KPX V odieresis -90 +KPX V ograve -90 +KPX V ohungarumlaut -90 +KPX V omacron -90 +KPX V oslash -90 +KPX V otilde -90 +KPX V period -120 +KPX V semicolon -40 +KPX V u -60 +KPX V uacute -60 +KPX V ucircumflex -60 +KPX V udieresis -60 +KPX V ugrave -60 +KPX V uhungarumlaut -60 +KPX V umacron -60 +KPX V uogonek -60 +KPX V uring -60 +KPX W A -60 +KPX W Aacute -60 +KPX W Abreve -60 +KPX W Acircumflex -60 +KPX W Adieresis -60 +KPX W Agrave -60 +KPX W Amacron -60 +KPX W Aogonek -60 +KPX W Aring -60 +KPX W Atilde -60 +KPX W O -20 +KPX W Oacute -20 +KPX W Ocircumflex -20 +KPX W Odieresis -20 +KPX W Ograve -20 +KPX W Ohungarumlaut -20 +KPX W Omacron -20 +KPX W Oslash -20 +KPX W Otilde -20 +KPX W a -40 +KPX W aacute -40 +KPX W abreve -40 +KPX W acircumflex -40 +KPX W adieresis -40 +KPX W agrave -40 +KPX W amacron -40 +KPX W aogonek -40 +KPX W aring -40 +KPX W atilde -40 +KPX W colon -10 +KPX W comma -80 +KPX W e -35 +KPX W eacute -35 +KPX W ecaron -35 +KPX W ecircumflex -35 +KPX W edieresis -35 +KPX W edotaccent -35 +KPX W egrave -35 +KPX W emacron -35 +KPX W eogonek -35 +KPX W hyphen -40 +KPX W o -60 +KPX W oacute -60 +KPX W ocircumflex -60 +KPX W odieresis -60 +KPX W ograve -60 +KPX W ohungarumlaut -60 +KPX W omacron -60 +KPX W oslash -60 +KPX W otilde -60 +KPX W period -80 +KPX W semicolon -10 +KPX W u -45 +KPX W uacute -45 +KPX W ucircumflex -45 +KPX W udieresis -45 +KPX W ugrave -45 +KPX W uhungarumlaut -45 +KPX W umacron -45 +KPX W uogonek -45 +KPX W uring -45 +KPX W y -20 +KPX W yacute -20 +KPX W ydieresis -20 +KPX Y A -110 +KPX Y Aacute -110 +KPX Y Abreve -110 +KPX Y Acircumflex -110 +KPX Y Adieresis -110 +KPX Y Agrave -110 +KPX Y Amacron -110 +KPX Y Aogonek -110 +KPX Y Aring -110 +KPX Y Atilde -110 +KPX Y O -70 +KPX Y Oacute -70 +KPX Y Ocircumflex -70 +KPX Y Odieresis -70 +KPX Y Ograve -70 +KPX Y Ohungarumlaut -70 +KPX Y Omacron -70 +KPX Y Oslash -70 +KPX Y Otilde -70 +KPX Y a -90 +KPX Y aacute -90 +KPX Y abreve -90 +KPX Y acircumflex -90 +KPX Y adieresis -90 +KPX Y agrave -90 +KPX Y amacron -90 +KPX Y aogonek -90 +KPX Y aring -90 +KPX Y atilde -90 +KPX Y colon -50 +KPX Y comma -100 +KPX Y e -80 +KPX Y eacute -80 +KPX Y ecaron -80 +KPX Y ecircumflex -80 +KPX Y edieresis -80 +KPX Y edotaccent -80 +KPX Y egrave -80 +KPX Y emacron -80 +KPX Y eogonek -80 +KPX Y o -100 +KPX Y oacute -100 +KPX Y ocircumflex -100 +KPX Y odieresis -100 +KPX Y ograve -100 +KPX Y ohungarumlaut -100 +KPX Y omacron -100 +KPX Y oslash -100 +KPX Y otilde -100 +KPX Y period -100 +KPX Y semicolon -50 +KPX Y u -100 +KPX Y uacute -100 +KPX Y ucircumflex -100 +KPX Y udieresis -100 +KPX Y ugrave -100 +KPX Y uhungarumlaut -100 +KPX Y umacron -100 +KPX Y uogonek -100 +KPX Y uring -100 +KPX Yacute A -110 +KPX Yacute Aacute -110 +KPX Yacute Abreve -110 +KPX Yacute Acircumflex -110 +KPX Yacute Adieresis -110 +KPX Yacute Agrave -110 +KPX Yacute Amacron -110 +KPX Yacute Aogonek -110 +KPX Yacute Aring -110 +KPX Yacute Atilde -110 +KPX Yacute O -70 +KPX Yacute Oacute -70 +KPX Yacute Ocircumflex -70 +KPX Yacute Odieresis -70 +KPX Yacute Ograve -70 +KPX Yacute Ohungarumlaut -70 +KPX Yacute Omacron -70 +KPX Yacute Oslash -70 +KPX Yacute Otilde -70 +KPX Yacute a -90 +KPX Yacute aacute -90 +KPX Yacute abreve -90 +KPX Yacute acircumflex -90 +KPX Yacute adieresis -90 +KPX Yacute agrave -90 +KPX Yacute amacron -90 +KPX Yacute aogonek -90 +KPX Yacute aring -90 +KPX Yacute atilde -90 +KPX Yacute colon -50 +KPX Yacute comma -100 +KPX Yacute e -80 +KPX Yacute eacute -80 +KPX Yacute ecaron -80 +KPX Yacute ecircumflex -80 +KPX Yacute edieresis -80 +KPX Yacute edotaccent -80 +KPX Yacute egrave -80 +KPX Yacute emacron -80 +KPX Yacute eogonek -80 +KPX Yacute o -100 +KPX Yacute oacute -100 +KPX Yacute ocircumflex -100 +KPX Yacute odieresis -100 +KPX Yacute ograve -100 +KPX Yacute ohungarumlaut -100 +KPX Yacute omacron -100 +KPX Yacute oslash -100 +KPX Yacute otilde -100 +KPX Yacute period -100 +KPX Yacute semicolon -50 +KPX Yacute u -100 +KPX Yacute uacute -100 +KPX Yacute ucircumflex -100 +KPX Yacute udieresis -100 +KPX Yacute ugrave -100 +KPX Yacute uhungarumlaut -100 +KPX Yacute umacron -100 +KPX Yacute uogonek -100 +KPX Yacute uring -100 +KPX Ydieresis A -110 +KPX Ydieresis Aacute -110 +KPX Ydieresis Abreve -110 +KPX Ydieresis Acircumflex -110 +KPX Ydieresis Adieresis -110 +KPX Ydieresis Agrave -110 +KPX Ydieresis Amacron -110 +KPX Ydieresis Aogonek -110 +KPX Ydieresis Aring -110 +KPX Ydieresis Atilde -110 +KPX Ydieresis O -70 +KPX Ydieresis Oacute -70 +KPX Ydieresis Ocircumflex -70 +KPX Ydieresis Odieresis -70 +KPX Ydieresis Ograve -70 +KPX Ydieresis Ohungarumlaut -70 +KPX Ydieresis Omacron -70 +KPX Ydieresis Oslash -70 +KPX Ydieresis Otilde -70 +KPX Ydieresis a -90 +KPX Ydieresis aacute -90 +KPX Ydieresis abreve -90 +KPX Ydieresis acircumflex -90 +KPX Ydieresis adieresis -90 +KPX Ydieresis agrave -90 +KPX Ydieresis amacron -90 +KPX Ydieresis aogonek -90 +KPX Ydieresis aring -90 +KPX Ydieresis atilde -90 +KPX Ydieresis colon -50 +KPX Ydieresis comma -100 +KPX Ydieresis e -80 +KPX Ydieresis eacute -80 +KPX Ydieresis ecaron -80 +KPX Ydieresis ecircumflex -80 +KPX Ydieresis edieresis -80 +KPX Ydieresis edotaccent -80 +KPX Ydieresis egrave -80 +KPX Ydieresis emacron -80 +KPX Ydieresis eogonek -80 +KPX Ydieresis o -100 +KPX Ydieresis oacute -100 +KPX Ydieresis ocircumflex -100 +KPX Ydieresis odieresis -100 +KPX Ydieresis ograve -100 +KPX Ydieresis ohungarumlaut -100 +KPX Ydieresis omacron -100 +KPX Ydieresis oslash -100 +KPX Ydieresis otilde -100 +KPX Ydieresis period -100 +KPX Ydieresis semicolon -50 +KPX Ydieresis u -100 +KPX Ydieresis uacute -100 +KPX Ydieresis ucircumflex -100 +KPX Ydieresis udieresis -100 +KPX Ydieresis ugrave -100 +KPX Ydieresis uhungarumlaut -100 +KPX Ydieresis umacron -100 +KPX Ydieresis uogonek -100 +KPX Ydieresis uring -100 +KPX a g -10 +KPX a gbreve -10 +KPX a gcommaaccent -10 +KPX a v -15 +KPX a w -15 +KPX a y -20 +KPX a yacute -20 +KPX a ydieresis -20 +KPX aacute g -10 +KPX aacute gbreve -10 +KPX aacute gcommaaccent -10 +KPX aacute v -15 +KPX aacute w -15 +KPX aacute y -20 +KPX aacute yacute -20 +KPX aacute ydieresis -20 +KPX abreve g -10 +KPX abreve gbreve -10 +KPX abreve gcommaaccent -10 +KPX abreve v -15 +KPX abreve w -15 +KPX abreve y -20 +KPX abreve yacute -20 +KPX abreve ydieresis -20 +KPX acircumflex g -10 +KPX acircumflex gbreve -10 +KPX acircumflex gcommaaccent -10 +KPX acircumflex v -15 +KPX acircumflex w -15 +KPX acircumflex y -20 +KPX acircumflex yacute -20 +KPX acircumflex ydieresis -20 +KPX adieresis g -10 +KPX adieresis gbreve -10 +KPX adieresis gcommaaccent -10 +KPX adieresis v -15 +KPX adieresis w -15 +KPX adieresis y -20 +KPX adieresis yacute -20 +KPX adieresis ydieresis -20 +KPX agrave g -10 +KPX agrave gbreve -10 +KPX agrave gcommaaccent -10 +KPX agrave v -15 +KPX agrave w -15 +KPX agrave y -20 +KPX agrave yacute -20 +KPX agrave ydieresis -20 +KPX amacron g -10 +KPX amacron gbreve -10 +KPX amacron gcommaaccent -10 +KPX amacron v -15 +KPX amacron w -15 +KPX amacron y -20 +KPX amacron yacute -20 +KPX amacron ydieresis -20 +KPX aogonek g -10 +KPX aogonek gbreve -10 +KPX aogonek gcommaaccent -10 +KPX aogonek v -15 +KPX aogonek w -15 +KPX aogonek y -20 +KPX aogonek yacute -20 +KPX aogonek ydieresis -20 +KPX aring g -10 +KPX aring gbreve -10 +KPX aring gcommaaccent -10 +KPX aring v -15 +KPX aring w -15 +KPX aring y -20 +KPX aring yacute -20 +KPX aring ydieresis -20 +KPX atilde g -10 +KPX atilde gbreve -10 +KPX atilde gcommaaccent -10 +KPX atilde v -15 +KPX atilde w -15 +KPX atilde y -20 +KPX atilde yacute -20 +KPX atilde ydieresis -20 +KPX b l -10 +KPX b lacute -10 +KPX b lcommaaccent -10 +KPX b lslash -10 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -20 +KPX b y -20 +KPX b yacute -20 +KPX b ydieresis -20 +KPX c h -10 +KPX c k -20 +KPX c kcommaaccent -20 +KPX c l -20 +KPX c lacute -20 +KPX c lcommaaccent -20 +KPX c lslash -20 +KPX c y -10 +KPX c yacute -10 +KPX c ydieresis -10 +KPX cacute h -10 +KPX cacute k -20 +KPX cacute kcommaaccent -20 +KPX cacute l -20 +KPX cacute lacute -20 +KPX cacute lcommaaccent -20 +KPX cacute lslash -20 +KPX cacute y -10 +KPX cacute yacute -10 +KPX cacute ydieresis -10 +KPX ccaron h -10 +KPX ccaron k -20 +KPX ccaron kcommaaccent -20 +KPX ccaron l -20 +KPX ccaron lacute -20 +KPX ccaron lcommaaccent -20 +KPX ccaron lslash -20 +KPX ccaron y -10 +KPX ccaron yacute -10 +KPX ccaron ydieresis -10 +KPX ccedilla h -10 +KPX ccedilla k -20 +KPX ccedilla kcommaaccent -20 +KPX ccedilla l -20 +KPX ccedilla lacute -20 +KPX ccedilla lcommaaccent -20 +KPX ccedilla lslash -20 +KPX ccedilla y -10 +KPX ccedilla yacute -10 +KPX ccedilla ydieresis -10 +KPX colon space -40 +KPX comma quotedblright -120 +KPX comma quoteright -120 +KPX comma space -40 +KPX d d -10 +KPX d dcroat -10 +KPX d v -15 +KPX d w -15 +KPX d y -15 +KPX d yacute -15 +KPX d ydieresis -15 +KPX dcroat d -10 +KPX dcroat dcroat -10 +KPX dcroat v -15 +KPX dcroat w -15 +KPX dcroat y -15 +KPX dcroat yacute -15 +KPX dcroat ydieresis -15 +KPX e comma 10 +KPX e period 20 +KPX e v -15 +KPX e w -15 +KPX e x -15 +KPX e y -15 +KPX e yacute -15 +KPX e ydieresis -15 +KPX eacute comma 10 +KPX eacute period 20 +KPX eacute v -15 +KPX eacute w -15 +KPX eacute x -15 +KPX eacute y -15 +KPX eacute yacute -15 +KPX eacute ydieresis -15 +KPX ecaron comma 10 +KPX ecaron period 20 +KPX ecaron v -15 +KPX ecaron w -15 +KPX ecaron x -15 +KPX ecaron y -15 +KPX ecaron yacute -15 +KPX ecaron ydieresis -15 +KPX ecircumflex comma 10 +KPX ecircumflex period 20 +KPX ecircumflex v -15 +KPX ecircumflex w -15 +KPX ecircumflex x -15 +KPX ecircumflex y -15 +KPX ecircumflex yacute -15 +KPX ecircumflex ydieresis -15 +KPX edieresis comma 10 +KPX edieresis period 20 +KPX edieresis v -15 +KPX edieresis w -15 +KPX edieresis x -15 +KPX edieresis y -15 +KPX edieresis yacute -15 +KPX edieresis ydieresis -15 +KPX edotaccent comma 10 +KPX edotaccent period 20 +KPX edotaccent v -15 +KPX edotaccent w -15 +KPX edotaccent x -15 +KPX edotaccent y -15 +KPX edotaccent yacute -15 +KPX edotaccent ydieresis -15 +KPX egrave comma 10 +KPX egrave period 20 +KPX egrave v -15 +KPX egrave w -15 +KPX egrave x -15 +KPX egrave y -15 +KPX egrave yacute -15 +KPX egrave ydieresis -15 +KPX emacron comma 10 +KPX emacron period 20 +KPX emacron v -15 +KPX emacron w -15 +KPX emacron x -15 +KPX emacron y -15 +KPX emacron yacute -15 +KPX emacron ydieresis -15 +KPX eogonek comma 10 +KPX eogonek period 20 +KPX eogonek v -15 +KPX eogonek w -15 +KPX eogonek x -15 +KPX eogonek y -15 +KPX eogonek yacute -15 +KPX eogonek ydieresis -15 +KPX f comma -10 +KPX f e -10 +KPX f eacute -10 +KPX f ecaron -10 +KPX f ecircumflex -10 +KPX f edieresis -10 +KPX f edotaccent -10 +KPX f egrave -10 +KPX f emacron -10 +KPX f eogonek -10 +KPX f o -20 +KPX f oacute -20 +KPX f ocircumflex -20 +KPX f odieresis -20 +KPX f ograve -20 +KPX f ohungarumlaut -20 +KPX f omacron -20 +KPX f oslash -20 +KPX f otilde -20 +KPX f period -10 +KPX f quotedblright 30 +KPX f quoteright 30 +KPX g e 10 +KPX g eacute 10 +KPX g ecaron 10 +KPX g ecircumflex 10 +KPX g edieresis 10 +KPX g edotaccent 10 +KPX g egrave 10 +KPX g emacron 10 +KPX g eogonek 10 +KPX g g -10 +KPX g gbreve -10 +KPX g gcommaaccent -10 +KPX gbreve e 10 +KPX gbreve eacute 10 +KPX gbreve ecaron 10 +KPX gbreve ecircumflex 10 +KPX gbreve edieresis 10 +KPX gbreve edotaccent 10 +KPX gbreve egrave 10 +KPX gbreve emacron 10 +KPX gbreve eogonek 10 +KPX gbreve g -10 +KPX gbreve gbreve -10 +KPX gbreve gcommaaccent -10 +KPX gcommaaccent e 10 +KPX gcommaaccent eacute 10 +KPX gcommaaccent ecaron 10 +KPX gcommaaccent ecircumflex 10 +KPX gcommaaccent edieresis 10 +KPX gcommaaccent edotaccent 10 +KPX gcommaaccent egrave 10 +KPX gcommaaccent emacron 10 +KPX gcommaaccent eogonek 10 +KPX gcommaaccent g -10 +KPX gcommaaccent gbreve -10 +KPX gcommaaccent gcommaaccent -10 +KPX h y -20 +KPX h yacute -20 +KPX h ydieresis -20 +KPX k o -15 +KPX k oacute -15 +KPX k ocircumflex -15 +KPX k odieresis -15 +KPX k ograve -15 +KPX k ohungarumlaut -15 +KPX k omacron -15 +KPX k oslash -15 +KPX k otilde -15 +KPX kcommaaccent o -15 +KPX kcommaaccent oacute -15 +KPX kcommaaccent ocircumflex -15 +KPX kcommaaccent odieresis -15 +KPX kcommaaccent ograve -15 +KPX kcommaaccent ohungarumlaut -15 +KPX kcommaaccent omacron -15 +KPX kcommaaccent oslash -15 +KPX kcommaaccent otilde -15 +KPX l w -15 +KPX l y -15 +KPX l yacute -15 +KPX l ydieresis -15 +KPX lacute w -15 +KPX lacute y -15 +KPX lacute yacute -15 +KPX lacute ydieresis -15 +KPX lcommaaccent w -15 +KPX lcommaaccent y -15 +KPX lcommaaccent yacute -15 +KPX lcommaaccent ydieresis -15 +KPX lslash w -15 +KPX lslash y -15 +KPX lslash yacute -15 +KPX lslash ydieresis -15 +KPX m u -20 +KPX m uacute -20 +KPX m ucircumflex -20 +KPX m udieresis -20 +KPX m ugrave -20 +KPX m uhungarumlaut -20 +KPX m umacron -20 +KPX m uogonek -20 +KPX m uring -20 +KPX m y -30 +KPX m yacute -30 +KPX m ydieresis -30 +KPX n u -10 +KPX n uacute -10 +KPX n ucircumflex -10 +KPX n udieresis -10 +KPX n ugrave -10 +KPX n uhungarumlaut -10 +KPX n umacron -10 +KPX n uogonek -10 +KPX n uring -10 +KPX n v -40 +KPX n y -20 +KPX n yacute -20 +KPX n ydieresis -20 +KPX nacute u -10 +KPX nacute uacute -10 +KPX nacute ucircumflex -10 +KPX nacute udieresis -10 +KPX nacute ugrave -10 +KPX nacute uhungarumlaut -10 +KPX nacute umacron -10 +KPX nacute uogonek -10 +KPX nacute uring -10 +KPX nacute v -40 +KPX nacute y -20 +KPX nacute yacute -20 +KPX nacute ydieresis -20 +KPX ncaron u -10 +KPX ncaron uacute -10 +KPX ncaron ucircumflex -10 +KPX ncaron udieresis -10 +KPX ncaron ugrave -10 +KPX ncaron uhungarumlaut -10 +KPX ncaron umacron -10 +KPX ncaron uogonek -10 +KPX ncaron uring -10 +KPX ncaron v -40 +KPX ncaron y -20 +KPX ncaron yacute -20 +KPX ncaron ydieresis -20 +KPX ncommaaccent u -10 +KPX ncommaaccent uacute -10 +KPX ncommaaccent ucircumflex -10 +KPX ncommaaccent udieresis -10 +KPX ncommaaccent ugrave -10 +KPX ncommaaccent uhungarumlaut -10 +KPX ncommaaccent umacron -10 +KPX ncommaaccent uogonek -10 +KPX ncommaaccent uring -10 +KPX ncommaaccent v -40 +KPX ncommaaccent y -20 +KPX ncommaaccent yacute -20 +KPX ncommaaccent ydieresis -20 +KPX ntilde u -10 +KPX ntilde uacute -10 +KPX ntilde ucircumflex -10 +KPX ntilde udieresis -10 +KPX ntilde ugrave -10 +KPX ntilde uhungarumlaut -10 +KPX ntilde umacron -10 +KPX ntilde uogonek -10 +KPX ntilde uring -10 +KPX ntilde v -40 +KPX ntilde y -20 +KPX ntilde yacute -20 +KPX ntilde ydieresis -20 +KPX o v -20 +KPX o w -15 +KPX o x -30 +KPX o y -20 +KPX o yacute -20 +KPX o ydieresis -20 +KPX oacute v -20 +KPX oacute w -15 +KPX oacute x -30 +KPX oacute y -20 +KPX oacute yacute -20 +KPX oacute ydieresis -20 +KPX ocircumflex v -20 +KPX ocircumflex w -15 +KPX ocircumflex x -30 +KPX ocircumflex y -20 +KPX ocircumflex yacute -20 +KPX ocircumflex ydieresis -20 +KPX odieresis v -20 +KPX odieresis w -15 +KPX odieresis x -30 +KPX odieresis y -20 +KPX odieresis yacute -20 +KPX odieresis ydieresis -20 +KPX ograve v -20 +KPX ograve w -15 +KPX ograve x -30 +KPX ograve y -20 +KPX ograve yacute -20 +KPX ograve ydieresis -20 +KPX ohungarumlaut v -20 +KPX ohungarumlaut w -15 +KPX ohungarumlaut x -30 +KPX ohungarumlaut y -20 +KPX ohungarumlaut yacute -20 +KPX ohungarumlaut ydieresis -20 +KPX omacron v -20 +KPX omacron w -15 +KPX omacron x -30 +KPX omacron y -20 +KPX omacron yacute -20 +KPX omacron ydieresis -20 +KPX oslash v -20 +KPX oslash w -15 +KPX oslash x -30 +KPX oslash y -20 +KPX oslash yacute -20 +KPX oslash ydieresis -20 +KPX otilde v -20 +KPX otilde w -15 +KPX otilde x -30 +KPX otilde y -20 +KPX otilde yacute -20 +KPX otilde ydieresis -20 +KPX p y -15 +KPX p yacute -15 +KPX p ydieresis -15 +KPX period quotedblright -120 +KPX period quoteright -120 +KPX period space -40 +KPX quotedblright space -80 +KPX quoteleft quoteleft -46 +KPX quoteright d -80 +KPX quoteright dcroat -80 +KPX quoteright l -20 +KPX quoteright lacute -20 +KPX quoteright lcommaaccent -20 +KPX quoteright lslash -20 +KPX quoteright quoteright -46 +KPX quoteright r -40 +KPX quoteright racute -40 +KPX quoteright rcaron -40 +KPX quoteright rcommaaccent -40 +KPX quoteright s -60 +KPX quoteright sacute -60 +KPX quoteright scaron -60 +KPX quoteright scedilla -60 +KPX quoteright scommaaccent -60 +KPX quoteright space -80 +KPX quoteright v -20 +KPX r c -20 +KPX r cacute -20 +KPX r ccaron -20 +KPX r ccedilla -20 +KPX r comma -60 +KPX r d -20 +KPX r dcroat -20 +KPX r g -15 +KPX r gbreve -15 +KPX r gcommaaccent -15 +KPX r hyphen -20 +KPX r o -20 +KPX r oacute -20 +KPX r ocircumflex -20 +KPX r odieresis -20 +KPX r ograve -20 +KPX r ohungarumlaut -20 +KPX r omacron -20 +KPX r oslash -20 +KPX r otilde -20 +KPX r period -60 +KPX r q -20 +KPX r s -15 +KPX r sacute -15 +KPX r scaron -15 +KPX r scedilla -15 +KPX r scommaaccent -15 +KPX r t 20 +KPX r tcommaaccent 20 +KPX r v 10 +KPX r y 10 +KPX r yacute 10 +KPX r ydieresis 10 +KPX racute c -20 +KPX racute cacute -20 +KPX racute ccaron -20 +KPX racute ccedilla -20 +KPX racute comma -60 +KPX racute d -20 +KPX racute dcroat -20 +KPX racute g -15 +KPX racute gbreve -15 +KPX racute gcommaaccent -15 +KPX racute hyphen -20 +KPX racute o -20 +KPX racute oacute -20 +KPX racute ocircumflex -20 +KPX racute odieresis -20 +KPX racute ograve -20 +KPX racute ohungarumlaut -20 +KPX racute omacron -20 +KPX racute oslash -20 +KPX racute otilde -20 +KPX racute period -60 +KPX racute q -20 +KPX racute s -15 +KPX racute sacute -15 +KPX racute scaron -15 +KPX racute scedilla -15 +KPX racute scommaaccent -15 +KPX racute t 20 +KPX racute tcommaaccent 20 +KPX racute v 10 +KPX racute y 10 +KPX racute yacute 10 +KPX racute ydieresis 10 +KPX rcaron c -20 +KPX rcaron cacute -20 +KPX rcaron ccaron -20 +KPX rcaron ccedilla -20 +KPX rcaron comma -60 +KPX rcaron d -20 +KPX rcaron dcroat -20 +KPX rcaron g -15 +KPX rcaron gbreve -15 +KPX rcaron gcommaaccent -15 +KPX rcaron hyphen -20 +KPX rcaron o -20 +KPX rcaron oacute -20 +KPX rcaron ocircumflex -20 +KPX rcaron odieresis -20 +KPX rcaron ograve -20 +KPX rcaron ohungarumlaut -20 +KPX rcaron omacron -20 +KPX rcaron oslash -20 +KPX rcaron otilde -20 +KPX rcaron period -60 +KPX rcaron q -20 +KPX rcaron s -15 +KPX rcaron sacute -15 +KPX rcaron scaron -15 +KPX rcaron scedilla -15 +KPX rcaron scommaaccent -15 +KPX rcaron t 20 +KPX rcaron tcommaaccent 20 +KPX rcaron v 10 +KPX rcaron y 10 +KPX rcaron yacute 10 +KPX rcaron ydieresis 10 +KPX rcommaaccent c -20 +KPX rcommaaccent cacute -20 +KPX rcommaaccent ccaron -20 +KPX rcommaaccent ccedilla -20 +KPX rcommaaccent comma -60 +KPX rcommaaccent d -20 +KPX rcommaaccent dcroat -20 +KPX rcommaaccent g -15 +KPX rcommaaccent gbreve -15 +KPX rcommaaccent gcommaaccent -15 +KPX rcommaaccent hyphen -20 +KPX rcommaaccent o -20 +KPX rcommaaccent oacute -20 +KPX rcommaaccent ocircumflex -20 +KPX rcommaaccent odieresis -20 +KPX rcommaaccent ograve -20 +KPX rcommaaccent ohungarumlaut -20 +KPX rcommaaccent omacron -20 +KPX rcommaaccent oslash -20 +KPX rcommaaccent otilde -20 +KPX rcommaaccent period -60 +KPX rcommaaccent q -20 +KPX rcommaaccent s -15 +KPX rcommaaccent sacute -15 +KPX rcommaaccent scaron -15 +KPX rcommaaccent scedilla -15 +KPX rcommaaccent scommaaccent -15 +KPX rcommaaccent t 20 +KPX rcommaaccent tcommaaccent 20 +KPX rcommaaccent v 10 +KPX rcommaaccent y 10 +KPX rcommaaccent yacute 10 +KPX rcommaaccent ydieresis 10 +KPX s w -15 +KPX sacute w -15 +KPX scaron w -15 +KPX scedilla w -15 +KPX scommaaccent w -15 +KPX semicolon space -40 +KPX space T -100 +KPX space Tcaron -100 +KPX space Tcommaaccent -100 +KPX space V -80 +KPX space W -80 +KPX space Y -120 +KPX space Yacute -120 +KPX space Ydieresis -120 +KPX space quotedblleft -80 +KPX space quoteleft -60 +KPX v a -20 +KPX v aacute -20 +KPX v abreve -20 +KPX v acircumflex -20 +KPX v adieresis -20 +KPX v agrave -20 +KPX v amacron -20 +KPX v aogonek -20 +KPX v aring -20 +KPX v atilde -20 +KPX v comma -80 +KPX v o -30 +KPX v oacute -30 +KPX v ocircumflex -30 +KPX v odieresis -30 +KPX v ograve -30 +KPX v ohungarumlaut -30 +KPX v omacron -30 +KPX v oslash -30 +KPX v otilde -30 +KPX v period -80 +KPX w comma -40 +KPX w o -20 +KPX w oacute -20 +KPX w ocircumflex -20 +KPX w odieresis -20 +KPX w ograve -20 +KPX w ohungarumlaut -20 +KPX w omacron -20 +KPX w oslash -20 +KPX w otilde -20 +KPX w period -40 +KPX x e -10 +KPX x eacute -10 +KPX x ecaron -10 +KPX x ecircumflex -10 +KPX x edieresis -10 +KPX x edotaccent -10 +KPX x egrave -10 +KPX x emacron -10 +KPX x eogonek -10 +KPX y a -30 +KPX y aacute -30 +KPX y abreve -30 +KPX y acircumflex -30 +KPX y adieresis -30 +KPX y agrave -30 +KPX y amacron -30 +KPX y aogonek -30 +KPX y aring -30 +KPX y atilde -30 +KPX y comma -80 +KPX y e -10 +KPX y eacute -10 +KPX y ecaron -10 +KPX y ecircumflex -10 +KPX y edieresis -10 +KPX y edotaccent -10 +KPX y egrave -10 +KPX y emacron -10 +KPX y eogonek -10 +KPX y o -25 +KPX y oacute -25 +KPX y ocircumflex -25 +KPX y odieresis -25 +KPX y ograve -25 +KPX y ohungarumlaut -25 +KPX y omacron -25 +KPX y oslash -25 +KPX y otilde -25 +KPX y period -80 +KPX yacute a -30 +KPX yacute aacute -30 +KPX yacute abreve -30 +KPX yacute acircumflex -30 +KPX yacute adieresis -30 +KPX yacute agrave -30 +KPX yacute amacron -30 +KPX yacute aogonek -30 +KPX yacute aring -30 +KPX yacute atilde -30 +KPX yacute comma -80 +KPX yacute e -10 +KPX yacute eacute -10 +KPX yacute ecaron -10 +KPX yacute ecircumflex -10 +KPX yacute edieresis -10 +KPX yacute edotaccent -10 +KPX yacute egrave -10 +KPX yacute emacron -10 +KPX yacute eogonek -10 +KPX yacute o -25 +KPX yacute oacute -25 +KPX yacute ocircumflex -25 +KPX yacute odieresis -25 +KPX yacute ograve -25 +KPX yacute ohungarumlaut -25 +KPX yacute omacron -25 +KPX yacute oslash -25 +KPX yacute otilde -25 +KPX yacute period -80 +KPX ydieresis a -30 +KPX ydieresis aacute -30 +KPX ydieresis abreve -30 +KPX ydieresis acircumflex -30 +KPX ydieresis adieresis -30 +KPX ydieresis agrave -30 +KPX ydieresis amacron -30 +KPX ydieresis aogonek -30 +KPX ydieresis aring -30 +KPX ydieresis atilde -30 +KPX ydieresis comma -80 +KPX ydieresis e -10 +KPX ydieresis eacute -10 +KPX ydieresis ecaron -10 +KPX ydieresis ecircumflex -10 +KPX ydieresis edieresis -10 +KPX ydieresis edotaccent -10 +KPX ydieresis egrave -10 +KPX ydieresis emacron -10 +KPX ydieresis eogonek -10 +KPX ydieresis o -25 +KPX ydieresis oacute -25 +KPX ydieresis ocircumflex -25 +KPX ydieresis odieresis -25 +KPX ydieresis ograve -25 +KPX ydieresis ohungarumlaut -25 +KPX ydieresis omacron -25 +KPX ydieresis oslash -25 +KPX ydieresis otilde -25 +KPX ydieresis period -80 +KPX z e 10 +KPX z eacute 10 +KPX z ecaron 10 +KPX z ecircumflex 10 +KPX z edieresis 10 +KPX z edotaccent 10 +KPX z egrave 10 +KPX z emacron 10 +KPX z eogonek 10 +KPX zacute e 10 +KPX zacute eacute 10 +KPX zacute ecaron 10 +KPX zacute ecircumflex 10 +KPX zacute edieresis 10 +KPX zacute edotaccent 10 +KPX zacute egrave 10 +KPX zacute emacron 10 +KPX zacute eogonek 10 +KPX zcaron e 10 +KPX zcaron eacute 10 +KPX zcaron ecaron 10 +KPX zcaron ecircumflex 10 +KPX zcaron edieresis 10 +KPX zcaron edotaccent 10 +KPX zcaron egrave 10 +KPX zcaron emacron 10 +KPX zcaron eogonek 10 +KPX zdotaccent e 10 +KPX zdotaccent eacute 10 +KPX zdotaccent ecaron 10 +KPX zdotaccent ecircumflex 10 +KPX zdotaccent edieresis 10 +KPX zdotaccent edotaccent 10 +KPX zdotaccent egrave 10 +KPX zdotaccent emacron 10 +KPX zdotaccent eogonek 10 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Oblique.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Oblique.afm new file mode 100644 index 00000000..7a7af001 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica-Oblique.afm @@ -0,0 +1,3051 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:44:31 1997 +Comment UniqueID 43055 +Comment VMusage 14960 69346 +FontName Helvetica-Oblique +FullName Helvetica Oblique +FamilyName Helvetica +Weight Medium +ItalicAngle -12 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -170 -225 1116 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StdHW 76 +StdVW 88 +StartCharMetrics 315 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 90 0 340 718 ; +C 34 ; WX 355 ; N quotedbl ; B 168 463 438 718 ; +C 35 ; WX 556 ; N numbersign ; B 73 0 631 688 ; +C 36 ; WX 556 ; N dollar ; B 69 -115 617 775 ; +C 37 ; WX 889 ; N percent ; B 147 -19 889 703 ; +C 38 ; WX 667 ; N ampersand ; B 77 -15 647 718 ; +C 39 ; WX 222 ; N quoteright ; B 151 463 310 718 ; +C 40 ; WX 333 ; N parenleft ; B 108 -207 454 733 ; +C 41 ; WX 333 ; N parenright ; B -9 -207 337 733 ; +C 42 ; WX 389 ; N asterisk ; B 165 431 475 718 ; +C 43 ; WX 584 ; N plus ; B 85 0 606 505 ; +C 44 ; WX 278 ; N comma ; B 56 -147 214 106 ; +C 45 ; WX 333 ; N hyphen ; B 93 232 357 322 ; +C 46 ; WX 278 ; N period ; B 87 0 214 106 ; +C 47 ; WX 278 ; N slash ; B -21 -19 452 737 ; +C 48 ; WX 556 ; N zero ; B 93 -19 608 703 ; +C 49 ; WX 556 ; N one ; B 207 0 508 703 ; +C 50 ; WX 556 ; N two ; B 26 0 617 703 ; +C 51 ; WX 556 ; N three ; B 75 -19 610 703 ; +C 52 ; WX 556 ; N four ; B 61 0 576 703 ; +C 53 ; WX 556 ; N five ; B 68 -19 621 688 ; +C 54 ; WX 556 ; N six ; B 91 -19 615 703 ; +C 55 ; WX 556 ; N seven ; B 137 0 669 688 ; +C 56 ; WX 556 ; N eight ; B 74 -19 607 703 ; +C 57 ; WX 556 ; N nine ; B 82 -19 609 703 ; +C 58 ; WX 278 ; N colon ; B 87 0 301 516 ; +C 59 ; WX 278 ; N semicolon ; B 56 -147 301 516 ; +C 60 ; WX 584 ; N less ; B 94 11 641 495 ; +C 61 ; WX 584 ; N equal ; B 63 115 628 390 ; +C 62 ; WX 584 ; N greater ; B 50 11 597 495 ; +C 63 ; WX 556 ; N question ; B 161 0 610 727 ; +C 64 ; WX 1015 ; N at ; B 215 -19 965 737 ; +C 65 ; WX 667 ; N A ; B 14 0 654 718 ; +C 66 ; WX 667 ; N B ; B 74 0 712 718 ; +C 67 ; WX 722 ; N C ; B 108 -19 782 737 ; +C 68 ; WX 722 ; N D ; B 81 0 764 718 ; +C 69 ; WX 667 ; N E ; B 86 0 762 718 ; +C 70 ; WX 611 ; N F ; B 86 0 736 718 ; +C 71 ; WX 778 ; N G ; B 111 -19 799 737 ; +C 72 ; WX 722 ; N H ; B 77 0 799 718 ; +C 73 ; WX 278 ; N I ; B 91 0 341 718 ; +C 74 ; WX 500 ; N J ; B 47 -19 581 718 ; +C 75 ; WX 667 ; N K ; B 76 0 808 718 ; +C 76 ; WX 556 ; N L ; B 76 0 555 718 ; +C 77 ; WX 833 ; N M ; B 73 0 914 718 ; +C 78 ; WX 722 ; N N ; B 76 0 799 718 ; +C 79 ; WX 778 ; N O ; B 105 -19 826 737 ; +C 80 ; WX 667 ; N P ; B 86 0 737 718 ; +C 81 ; WX 778 ; N Q ; B 105 -56 826 737 ; +C 82 ; WX 722 ; N R ; B 88 0 773 718 ; +C 83 ; WX 667 ; N S ; B 90 -19 713 737 ; +C 84 ; WX 611 ; N T ; B 148 0 750 718 ; +C 85 ; WX 722 ; N U ; B 123 -19 797 718 ; +C 86 ; WX 667 ; N V ; B 173 0 800 718 ; +C 87 ; WX 944 ; N W ; B 169 0 1081 718 ; +C 88 ; WX 667 ; N X ; B 19 0 790 718 ; +C 89 ; WX 667 ; N Y ; B 167 0 806 718 ; +C 90 ; WX 611 ; N Z ; B 23 0 741 718 ; +C 91 ; WX 278 ; N bracketleft ; B 21 -196 403 722 ; +C 92 ; WX 278 ; N backslash ; B 140 -19 291 737 ; +C 93 ; WX 278 ; N bracketright ; B -14 -196 368 722 ; +C 94 ; WX 469 ; N asciicircum ; B 42 264 539 688 ; +C 95 ; WX 556 ; N underscore ; B -27 -125 540 -75 ; +C 96 ; WX 222 ; N quoteleft ; B 165 470 323 725 ; +C 97 ; WX 556 ; N a ; B 61 -15 559 538 ; +C 98 ; WX 556 ; N b ; B 58 -15 584 718 ; +C 99 ; WX 500 ; N c ; B 74 -15 553 538 ; +C 100 ; WX 556 ; N d ; B 84 -15 652 718 ; +C 101 ; WX 556 ; N e ; B 84 -15 578 538 ; +C 102 ; WX 278 ; N f ; B 86 0 416 728 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 42 -220 610 538 ; +C 104 ; WX 556 ; N h ; B 65 0 573 718 ; +C 105 ; WX 222 ; N i ; B 67 0 308 718 ; +C 106 ; WX 222 ; N j ; B -60 -210 308 718 ; +C 107 ; WX 500 ; N k ; B 67 0 600 718 ; +C 108 ; WX 222 ; N l ; B 67 0 308 718 ; +C 109 ; WX 833 ; N m ; B 65 0 852 538 ; +C 110 ; WX 556 ; N n ; B 65 0 573 538 ; +C 111 ; WX 556 ; N o ; B 83 -14 585 538 ; +C 112 ; WX 556 ; N p ; B 14 -207 584 538 ; +C 113 ; WX 556 ; N q ; B 84 -207 605 538 ; +C 114 ; WX 333 ; N r ; B 77 0 446 538 ; +C 115 ; WX 500 ; N s ; B 63 -15 529 538 ; +C 116 ; WX 278 ; N t ; B 102 -7 368 669 ; +C 117 ; WX 556 ; N u ; B 94 -15 600 523 ; +C 118 ; WX 500 ; N v ; B 119 0 603 523 ; +C 119 ; WX 722 ; N w ; B 125 0 820 523 ; +C 120 ; WX 500 ; N x ; B 11 0 594 523 ; +C 121 ; WX 500 ; N y ; B 15 -214 600 523 ; +C 122 ; WX 500 ; N z ; B 31 0 571 523 ; +C 123 ; WX 334 ; N braceleft ; B 92 -196 445 722 ; +C 124 ; WX 260 ; N bar ; B 46 -225 332 775 ; +C 125 ; WX 334 ; N braceright ; B 0 -196 354 722 ; +C 126 ; WX 584 ; N asciitilde ; B 111 180 580 326 ; +C 161 ; WX 333 ; N exclamdown ; B 77 -195 326 523 ; +C 162 ; WX 556 ; N cent ; B 95 -115 584 623 ; +C 163 ; WX 556 ; N sterling ; B 49 -16 634 718 ; +C 164 ; WX 167 ; N fraction ; B -170 -19 482 703 ; +C 165 ; WX 556 ; N yen ; B 81 0 699 688 ; +C 166 ; WX 556 ; N florin ; B -52 -207 654 737 ; +C 167 ; WX 556 ; N section ; B 76 -191 584 737 ; +C 168 ; WX 556 ; N currency ; B 60 99 646 603 ; +C 169 ; WX 191 ; N quotesingle ; B 157 463 285 718 ; +C 170 ; WX 333 ; N quotedblleft ; B 138 470 461 725 ; +C 171 ; WX 556 ; N guillemotleft ; B 146 108 554 446 ; +C 172 ; WX 333 ; N guilsinglleft ; B 137 108 340 446 ; +C 173 ; WX 333 ; N guilsinglright ; B 111 108 314 446 ; +C 174 ; WX 500 ; N fi ; B 86 0 587 728 ; +C 175 ; WX 500 ; N fl ; B 86 0 585 728 ; +C 177 ; WX 556 ; N endash ; B 51 240 623 313 ; +C 178 ; WX 556 ; N dagger ; B 135 -159 622 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 52 -159 623 718 ; +C 180 ; WX 278 ; N periodcentered ; B 129 190 257 315 ; +C 182 ; WX 537 ; N paragraph ; B 126 -173 650 718 ; +C 183 ; WX 350 ; N bullet ; B 91 202 413 517 ; +C 184 ; WX 222 ; N quotesinglbase ; B 21 -149 180 106 ; +C 185 ; WX 333 ; N quotedblbase ; B -6 -149 318 106 ; +C 186 ; WX 333 ; N quotedblright ; B 124 463 448 718 ; +C 187 ; WX 556 ; N guillemotright ; B 120 108 528 446 ; +C 188 ; WX 1000 ; N ellipsis ; B 115 0 908 106 ; +C 189 ; WX 1000 ; N perthousand ; B 88 -19 1029 703 ; +C 191 ; WX 611 ; N questiondown ; B 85 -201 534 525 ; +C 193 ; WX 333 ; N grave ; B 170 593 337 734 ; +C 194 ; WX 333 ; N acute ; B 248 593 475 734 ; +C 195 ; WX 333 ; N circumflex ; B 147 593 438 734 ; +C 196 ; WX 333 ; N tilde ; B 125 606 490 722 ; +C 197 ; WX 333 ; N macron ; B 143 627 468 684 ; +C 198 ; WX 333 ; N breve ; B 167 595 476 731 ; +C 199 ; WX 333 ; N dotaccent ; B 249 604 362 706 ; +C 200 ; WX 333 ; N dieresis ; B 168 604 443 706 ; +C 202 ; WX 333 ; N ring ; B 214 572 402 756 ; +C 203 ; WX 333 ; N cedilla ; B 2 -225 232 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 157 593 565 734 ; +C 206 ; WX 333 ; N ogonek ; B 43 -225 249 0 ; +C 207 ; WX 333 ; N caron ; B 177 593 468 734 ; +C 208 ; WX 1000 ; N emdash ; B 51 240 1067 313 ; +C 225 ; WX 1000 ; N AE ; B 8 0 1097 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 127 405 449 737 ; +C 232 ; WX 556 ; N Lslash ; B 41 0 555 718 ; +C 233 ; WX 778 ; N Oslash ; B 43 -19 890 737 ; +C 234 ; WX 1000 ; N OE ; B 98 -19 1116 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 141 405 468 737 ; +C 241 ; WX 889 ; N ae ; B 61 -15 909 538 ; +C 245 ; WX 278 ; N dotlessi ; B 95 0 294 523 ; +C 248 ; WX 222 ; N lslash ; B 41 0 347 718 ; +C 249 ; WX 611 ; N oslash ; B 29 -22 647 545 ; +C 250 ; WX 944 ; N oe ; B 83 -15 964 538 ; +C 251 ; WX 611 ; N germandbls ; B 67 -15 658 728 ; +C -1 ; WX 278 ; N Idieresis ; B 91 0 458 901 ; +C -1 ; WX 556 ; N eacute ; B 84 -15 587 734 ; +C -1 ; WX 556 ; N abreve ; B 61 -15 578 731 ; +C -1 ; WX 556 ; N uhungarumlaut ; B 94 -15 677 734 ; +C -1 ; WX 556 ; N ecaron ; B 84 -15 580 734 ; +C -1 ; WX 667 ; N Ydieresis ; B 167 0 806 901 ; +C -1 ; WX 584 ; N divide ; B 85 -19 606 524 ; +C -1 ; WX 667 ; N Yacute ; B 167 0 806 929 ; +C -1 ; WX 667 ; N Acircumflex ; B 14 0 654 929 ; +C -1 ; WX 556 ; N aacute ; B 61 -15 587 734 ; +C -1 ; WX 722 ; N Ucircumflex ; B 123 -19 797 929 ; +C -1 ; WX 500 ; N yacute ; B 15 -214 600 734 ; +C -1 ; WX 500 ; N scommaaccent ; B 63 -225 529 538 ; +C -1 ; WX 556 ; N ecircumflex ; B 84 -15 578 734 ; +C -1 ; WX 722 ; N Uring ; B 123 -19 797 931 ; +C -1 ; WX 722 ; N Udieresis ; B 123 -19 797 901 ; +C -1 ; WX 556 ; N aogonek ; B 61 -220 559 538 ; +C -1 ; WX 722 ; N Uacute ; B 123 -19 797 929 ; +C -1 ; WX 556 ; N uogonek ; B 94 -225 600 523 ; +C -1 ; WX 667 ; N Edieresis ; B 86 0 762 901 ; +C -1 ; WX 722 ; N Dcroat ; B 69 0 764 718 ; +C -1 ; WX 250 ; N commaaccent ; B 39 -225 172 -40 ; +C -1 ; WX 737 ; N copyright ; B 54 -19 837 737 ; +C -1 ; WX 667 ; N Emacron ; B 86 0 762 879 ; +C -1 ; WX 500 ; N ccaron ; B 74 -15 553 734 ; +C -1 ; WX 556 ; N aring ; B 61 -15 559 756 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 76 -225 799 718 ; +C -1 ; WX 222 ; N lacute ; B 67 0 461 929 ; +C -1 ; WX 556 ; N agrave ; B 61 -15 559 734 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 148 -225 750 718 ; +C -1 ; WX 722 ; N Cacute ; B 108 -19 782 929 ; +C -1 ; WX 556 ; N atilde ; B 61 -15 592 722 ; +C -1 ; WX 667 ; N Edotaccent ; B 86 0 762 901 ; +C -1 ; WX 500 ; N scaron ; B 63 -15 552 734 ; +C -1 ; WX 500 ; N scedilla ; B 63 -225 529 538 ; +C -1 ; WX 278 ; N iacute ; B 95 0 448 734 ; +C -1 ; WX 471 ; N lozenge ; B 88 0 540 728 ; +C -1 ; WX 722 ; N Rcaron ; B 88 0 773 929 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 111 -225 799 737 ; +C -1 ; WX 556 ; N ucircumflex ; B 94 -15 600 734 ; +C -1 ; WX 556 ; N acircumflex ; B 61 -15 559 734 ; +C -1 ; WX 667 ; N Amacron ; B 14 0 677 879 ; +C -1 ; WX 333 ; N rcaron ; B 77 0 508 734 ; +C -1 ; WX 500 ; N ccedilla ; B 74 -225 553 538 ; +C -1 ; WX 611 ; N Zdotaccent ; B 23 0 741 901 ; +C -1 ; WX 667 ; N Thorn ; B 86 0 712 718 ; +C -1 ; WX 778 ; N Omacron ; B 105 -19 826 879 ; +C -1 ; WX 722 ; N Racute ; B 88 0 773 929 ; +C -1 ; WX 667 ; N Sacute ; B 90 -19 713 929 ; +C -1 ; WX 643 ; N dcaron ; B 84 -15 808 718 ; +C -1 ; WX 722 ; N Umacron ; B 123 -19 797 879 ; +C -1 ; WX 556 ; N uring ; B 94 -15 600 756 ; +C -1 ; WX 333 ; N threesuperior ; B 90 270 436 703 ; +C -1 ; WX 778 ; N Ograve ; B 105 -19 826 929 ; +C -1 ; WX 667 ; N Agrave ; B 14 0 654 929 ; +C -1 ; WX 667 ; N Abreve ; B 14 0 685 926 ; +C -1 ; WX 584 ; N multiply ; B 50 0 642 506 ; +C -1 ; WX 556 ; N uacute ; B 94 -15 600 734 ; +C -1 ; WX 611 ; N Tcaron ; B 148 0 750 929 ; +C -1 ; WX 476 ; N partialdiff ; B 41 -38 550 714 ; +C -1 ; WX 500 ; N ydieresis ; B 15 -214 600 706 ; +C -1 ; WX 722 ; N Nacute ; B 76 0 799 929 ; +C -1 ; WX 278 ; N icircumflex ; B 95 0 411 734 ; +C -1 ; WX 667 ; N Ecircumflex ; B 86 0 762 929 ; +C -1 ; WX 556 ; N adieresis ; B 61 -15 559 706 ; +C -1 ; WX 556 ; N edieresis ; B 84 -15 578 706 ; +C -1 ; WX 500 ; N cacute ; B 74 -15 559 734 ; +C -1 ; WX 556 ; N nacute ; B 65 0 587 734 ; +C -1 ; WX 556 ; N umacron ; B 94 -15 600 684 ; +C -1 ; WX 722 ; N Ncaron ; B 76 0 799 929 ; +C -1 ; WX 278 ; N Iacute ; B 91 0 489 929 ; +C -1 ; WX 584 ; N plusminus ; B 39 0 618 506 ; +C -1 ; WX 260 ; N brokenbar ; B 62 -150 316 700 ; +C -1 ; WX 737 ; N registered ; B 54 -19 837 737 ; +C -1 ; WX 778 ; N Gbreve ; B 111 -19 799 926 ; +C -1 ; WX 278 ; N Idotaccent ; B 91 0 377 901 ; +C -1 ; WX 600 ; N summation ; B 15 -10 671 706 ; +C -1 ; WX 667 ; N Egrave ; B 86 0 762 929 ; +C -1 ; WX 333 ; N racute ; B 77 0 475 734 ; +C -1 ; WX 556 ; N omacron ; B 83 -14 585 684 ; +C -1 ; WX 611 ; N Zacute ; B 23 0 741 929 ; +C -1 ; WX 611 ; N Zcaron ; B 23 0 741 929 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 620 674 ; +C -1 ; WX 722 ; N Eth ; B 69 0 764 718 ; +C -1 ; WX 722 ; N Ccedilla ; B 108 -225 782 737 ; +C -1 ; WX 222 ; N lcommaaccent ; B 25 -225 308 718 ; +C -1 ; WX 317 ; N tcaron ; B 102 -7 501 808 ; +C -1 ; WX 556 ; N eogonek ; B 84 -225 578 538 ; +C -1 ; WX 722 ; N Uogonek ; B 123 -225 797 718 ; +C -1 ; WX 667 ; N Aacute ; B 14 0 683 929 ; +C -1 ; WX 667 ; N Adieresis ; B 14 0 654 901 ; +C -1 ; WX 556 ; N egrave ; B 84 -15 578 734 ; +C -1 ; WX 500 ; N zacute ; B 31 0 571 734 ; +C -1 ; WX 222 ; N iogonek ; B -61 -225 308 718 ; +C -1 ; WX 778 ; N Oacute ; B 105 -19 826 929 ; +C -1 ; WX 556 ; N oacute ; B 83 -14 587 734 ; +C -1 ; WX 556 ; N amacron ; B 61 -15 580 684 ; +C -1 ; WX 500 ; N sacute ; B 63 -15 559 734 ; +C -1 ; WX 278 ; N idieresis ; B 95 0 416 706 ; +C -1 ; WX 778 ; N Ocircumflex ; B 105 -19 826 929 ; +C -1 ; WX 722 ; N Ugrave ; B 123 -19 797 929 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 556 ; N thorn ; B 14 -207 584 718 ; +C -1 ; WX 333 ; N twosuperior ; B 64 281 449 703 ; +C -1 ; WX 778 ; N Odieresis ; B 105 -19 826 901 ; +C -1 ; WX 556 ; N mu ; B 24 -207 600 523 ; +C -1 ; WX 278 ; N igrave ; B 95 0 310 734 ; +C -1 ; WX 556 ; N ohungarumlaut ; B 83 -14 677 734 ; +C -1 ; WX 667 ; N Eogonek ; B 86 -220 762 718 ; +C -1 ; WX 556 ; N dcroat ; B 84 -15 689 718 ; +C -1 ; WX 834 ; N threequarters ; B 130 -19 861 703 ; +C -1 ; WX 667 ; N Scedilla ; B 90 -225 713 737 ; +C -1 ; WX 299 ; N lcaron ; B 67 0 464 718 ; +C -1 ; WX 667 ; N Kcommaaccent ; B 76 -225 808 718 ; +C -1 ; WX 556 ; N Lacute ; B 76 0 555 929 ; +C -1 ; WX 1000 ; N trademark ; B 186 306 1056 718 ; +C -1 ; WX 556 ; N edotaccent ; B 84 -15 578 706 ; +C -1 ; WX 278 ; N Igrave ; B 91 0 351 929 ; +C -1 ; WX 278 ; N Imacron ; B 91 0 483 879 ; +C -1 ; WX 556 ; N Lcaron ; B 76 0 570 718 ; +C -1 ; WX 834 ; N onehalf ; B 114 -19 839 703 ; +C -1 ; WX 549 ; N lessequal ; B 26 0 666 674 ; +C -1 ; WX 556 ; N ocircumflex ; B 83 -14 585 734 ; +C -1 ; WX 556 ; N ntilde ; B 65 0 592 722 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 123 -19 801 929 ; +C -1 ; WX 667 ; N Eacute ; B 86 0 762 929 ; +C -1 ; WX 556 ; N emacron ; B 84 -15 580 684 ; +C -1 ; WX 556 ; N gbreve ; B 42 -220 610 731 ; +C -1 ; WX 834 ; N onequarter ; B 150 -19 802 703 ; +C -1 ; WX 667 ; N Scaron ; B 90 -19 713 929 ; +C -1 ; WX 667 ; N Scommaaccent ; B 90 -225 713 737 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 105 -19 829 929 ; +C -1 ; WX 400 ; N degree ; B 169 411 468 703 ; +C -1 ; WX 556 ; N ograve ; B 83 -14 585 734 ; +C -1 ; WX 722 ; N Ccaron ; B 108 -19 782 929 ; +C -1 ; WX 556 ; N ugrave ; B 94 -15 600 734 ; +C -1 ; WX 453 ; N radical ; B 79 -80 617 762 ; +C -1 ; WX 722 ; N Dcaron ; B 81 0 764 929 ; +C -1 ; WX 333 ; N rcommaaccent ; B 30 -225 446 538 ; +C -1 ; WX 722 ; N Ntilde ; B 76 0 799 917 ; +C -1 ; WX 556 ; N otilde ; B 83 -14 602 722 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 88 -225 773 718 ; +C -1 ; WX 556 ; N Lcommaaccent ; B 76 -225 555 718 ; +C -1 ; WX 667 ; N Atilde ; B 14 0 699 917 ; +C -1 ; WX 667 ; N Aogonek ; B 14 -225 654 718 ; +C -1 ; WX 667 ; N Aring ; B 14 0 654 931 ; +C -1 ; WX 778 ; N Otilde ; B 105 -19 826 917 ; +C -1 ; WX 500 ; N zdotaccent ; B 31 0 571 706 ; +C -1 ; WX 667 ; N Ecaron ; B 86 0 762 929 ; +C -1 ; WX 278 ; N Iogonek ; B -33 -225 341 718 ; +C -1 ; WX 500 ; N kcommaaccent ; B 67 -225 600 718 ; +C -1 ; WX 584 ; N minus ; B 85 216 606 289 ; +C -1 ; WX 278 ; N Icircumflex ; B 91 0 452 929 ; +C -1 ; WX 556 ; N ncaron ; B 65 0 580 734 ; +C -1 ; WX 278 ; N tcommaaccent ; B 63 -225 368 669 ; +C -1 ; WX 584 ; N logicalnot ; B 106 108 628 390 ; +C -1 ; WX 556 ; N odieresis ; B 83 -14 585 706 ; +C -1 ; WX 556 ; N udieresis ; B 94 -15 600 706 ; +C -1 ; WX 549 ; N notequal ; B 34 -35 623 551 ; +C -1 ; WX 556 ; N gcommaaccent ; B 42 -220 610 822 ; +C -1 ; WX 556 ; N eth ; B 81 -15 617 737 ; +C -1 ; WX 500 ; N zcaron ; B 31 0 571 734 ; +C -1 ; WX 556 ; N ncommaaccent ; B 65 -225 573 538 ; +C -1 ; WX 333 ; N onesuperior ; B 166 281 371 703 ; +C -1 ; WX 278 ; N imacron ; B 95 0 417 684 ; +C -1 ; WX 556 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2705 +KPX A C -30 +KPX A Cacute -30 +KPX A Ccaron -30 +KPX A Ccedilla -30 +KPX A G -30 +KPX A Gbreve -30 +KPX A Gcommaaccent -30 +KPX A O -30 +KPX A Oacute -30 +KPX A Ocircumflex -30 +KPX A Odieresis -30 +KPX A Ograve -30 +KPX A Ohungarumlaut -30 +KPX A Omacron -30 +KPX A Oslash -30 +KPX A Otilde -30 +KPX A Q -30 +KPX A T -120 +KPX A Tcaron -120 +KPX A Tcommaaccent -120 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -70 +KPX A W -50 +KPX A Y -100 +KPX A Yacute -100 +KPX A Ydieresis -100 +KPX A u -30 +KPX A uacute -30 +KPX A ucircumflex -30 +KPX A udieresis -30 +KPX A ugrave -30 +KPX A uhungarumlaut -30 +KPX A umacron -30 +KPX A uogonek -30 +KPX A uring -30 +KPX A v -40 +KPX A w -40 +KPX A y -40 +KPX A yacute -40 +KPX A ydieresis -40 +KPX Aacute C -30 +KPX Aacute Cacute -30 +KPX Aacute Ccaron -30 +KPX Aacute Ccedilla -30 +KPX Aacute G -30 +KPX Aacute Gbreve -30 +KPX Aacute Gcommaaccent -30 +KPX Aacute O -30 +KPX Aacute Oacute -30 +KPX Aacute Ocircumflex -30 +KPX Aacute Odieresis -30 +KPX Aacute Ograve -30 +KPX Aacute Ohungarumlaut -30 +KPX Aacute Omacron -30 +KPX Aacute Oslash -30 +KPX Aacute Otilde -30 +KPX Aacute Q -30 +KPX Aacute T -120 +KPX Aacute Tcaron -120 +KPX Aacute Tcommaaccent -120 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -70 +KPX Aacute W -50 +KPX Aacute Y -100 +KPX Aacute Yacute -100 +KPX Aacute Ydieresis -100 +KPX Aacute u -30 +KPX Aacute uacute -30 +KPX Aacute ucircumflex -30 +KPX Aacute udieresis -30 +KPX Aacute ugrave -30 +KPX Aacute uhungarumlaut -30 +KPX Aacute umacron -30 +KPX Aacute uogonek -30 +KPX Aacute uring -30 +KPX Aacute v -40 +KPX Aacute w -40 +KPX Aacute y -40 +KPX Aacute yacute -40 +KPX Aacute ydieresis -40 +KPX Abreve C -30 +KPX Abreve Cacute -30 +KPX Abreve Ccaron -30 +KPX Abreve Ccedilla -30 +KPX Abreve G -30 +KPX Abreve Gbreve -30 +KPX Abreve Gcommaaccent -30 +KPX Abreve O -30 +KPX Abreve Oacute -30 +KPX Abreve Ocircumflex -30 +KPX Abreve Odieresis -30 +KPX Abreve Ograve -30 +KPX Abreve Ohungarumlaut -30 +KPX Abreve Omacron -30 +KPX Abreve Oslash -30 +KPX Abreve Otilde -30 +KPX Abreve Q -30 +KPX Abreve T -120 +KPX Abreve Tcaron -120 +KPX Abreve Tcommaaccent -120 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -70 +KPX Abreve W -50 +KPX Abreve Y -100 +KPX Abreve Yacute -100 +KPX Abreve Ydieresis -100 +KPX Abreve u -30 +KPX Abreve uacute -30 +KPX Abreve ucircumflex -30 +KPX Abreve udieresis -30 +KPX Abreve ugrave -30 +KPX Abreve uhungarumlaut -30 +KPX Abreve umacron -30 +KPX Abreve uogonek -30 +KPX Abreve uring -30 +KPX Abreve v -40 +KPX Abreve w -40 +KPX Abreve y -40 +KPX Abreve yacute -40 +KPX Abreve ydieresis -40 +KPX Acircumflex C -30 +KPX Acircumflex Cacute -30 +KPX Acircumflex Ccaron -30 +KPX Acircumflex Ccedilla -30 +KPX Acircumflex G -30 +KPX Acircumflex Gbreve -30 +KPX Acircumflex Gcommaaccent -30 +KPX Acircumflex O -30 +KPX Acircumflex Oacute -30 +KPX Acircumflex Ocircumflex -30 +KPX Acircumflex Odieresis -30 +KPX Acircumflex Ograve -30 +KPX Acircumflex Ohungarumlaut -30 +KPX Acircumflex Omacron -30 +KPX Acircumflex Oslash -30 +KPX Acircumflex Otilde -30 +KPX Acircumflex Q -30 +KPX Acircumflex T -120 +KPX Acircumflex Tcaron -120 +KPX Acircumflex Tcommaaccent -120 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -70 +KPX Acircumflex W -50 +KPX Acircumflex Y -100 +KPX Acircumflex Yacute -100 +KPX Acircumflex Ydieresis -100 +KPX Acircumflex u -30 +KPX Acircumflex uacute -30 +KPX Acircumflex ucircumflex -30 +KPX Acircumflex udieresis -30 +KPX Acircumflex ugrave -30 +KPX Acircumflex uhungarumlaut -30 +KPX Acircumflex umacron -30 +KPX Acircumflex uogonek -30 +KPX Acircumflex uring -30 +KPX Acircumflex v -40 +KPX Acircumflex w -40 +KPX Acircumflex y -40 +KPX Acircumflex yacute -40 +KPX Acircumflex ydieresis -40 +KPX Adieresis C -30 +KPX Adieresis Cacute -30 +KPX Adieresis Ccaron -30 +KPX Adieresis Ccedilla -30 +KPX Adieresis G -30 +KPX Adieresis Gbreve -30 +KPX Adieresis Gcommaaccent -30 +KPX Adieresis O -30 +KPX Adieresis Oacute -30 +KPX Adieresis Ocircumflex -30 +KPX Adieresis Odieresis -30 +KPX Adieresis Ograve -30 +KPX Adieresis Ohungarumlaut -30 +KPX Adieresis Omacron -30 +KPX Adieresis Oslash -30 +KPX Adieresis Otilde -30 +KPX Adieresis Q -30 +KPX Adieresis T -120 +KPX Adieresis Tcaron -120 +KPX Adieresis Tcommaaccent -120 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -70 +KPX Adieresis W -50 +KPX Adieresis Y -100 +KPX Adieresis Yacute -100 +KPX Adieresis Ydieresis -100 +KPX Adieresis u -30 +KPX Adieresis uacute -30 +KPX Adieresis ucircumflex -30 +KPX Adieresis udieresis -30 +KPX Adieresis ugrave -30 +KPX Adieresis uhungarumlaut -30 +KPX Adieresis umacron -30 +KPX Adieresis uogonek -30 +KPX Adieresis uring -30 +KPX Adieresis v -40 +KPX Adieresis w -40 +KPX Adieresis y -40 +KPX Adieresis yacute -40 +KPX Adieresis ydieresis -40 +KPX Agrave C -30 +KPX Agrave Cacute -30 +KPX Agrave Ccaron -30 +KPX Agrave Ccedilla -30 +KPX Agrave G -30 +KPX Agrave Gbreve -30 +KPX Agrave Gcommaaccent -30 +KPX Agrave O -30 +KPX Agrave Oacute -30 +KPX Agrave Ocircumflex -30 +KPX Agrave Odieresis -30 +KPX Agrave Ograve -30 +KPX Agrave Ohungarumlaut -30 +KPX Agrave Omacron -30 +KPX Agrave Oslash -30 +KPX Agrave Otilde -30 +KPX Agrave Q -30 +KPX Agrave T -120 +KPX Agrave Tcaron -120 +KPX Agrave Tcommaaccent -120 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -70 +KPX Agrave W -50 +KPX Agrave Y -100 +KPX Agrave Yacute -100 +KPX Agrave Ydieresis -100 +KPX Agrave u -30 +KPX Agrave uacute -30 +KPX Agrave ucircumflex -30 +KPX Agrave udieresis -30 +KPX Agrave ugrave -30 +KPX Agrave uhungarumlaut -30 +KPX Agrave umacron -30 +KPX Agrave uogonek -30 +KPX Agrave uring -30 +KPX Agrave v -40 +KPX Agrave w -40 +KPX Agrave y -40 +KPX Agrave yacute -40 +KPX Agrave ydieresis -40 +KPX Amacron C -30 +KPX Amacron Cacute -30 +KPX Amacron Ccaron -30 +KPX Amacron Ccedilla -30 +KPX Amacron G -30 +KPX Amacron Gbreve -30 +KPX Amacron Gcommaaccent -30 +KPX Amacron O -30 +KPX Amacron Oacute -30 +KPX Amacron Ocircumflex -30 +KPX Amacron Odieresis -30 +KPX Amacron Ograve -30 +KPX Amacron Ohungarumlaut -30 +KPX Amacron Omacron -30 +KPX Amacron Oslash -30 +KPX Amacron Otilde -30 +KPX Amacron Q -30 +KPX Amacron T -120 +KPX Amacron Tcaron -120 +KPX Amacron Tcommaaccent -120 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -70 +KPX Amacron W -50 +KPX Amacron Y -100 +KPX Amacron Yacute -100 +KPX Amacron Ydieresis -100 +KPX Amacron u -30 +KPX Amacron uacute -30 +KPX Amacron ucircumflex -30 +KPX Amacron udieresis -30 +KPX Amacron ugrave -30 +KPX Amacron uhungarumlaut -30 +KPX Amacron umacron -30 +KPX Amacron uogonek -30 +KPX Amacron uring -30 +KPX Amacron v -40 +KPX Amacron w -40 +KPX Amacron y -40 +KPX Amacron yacute -40 +KPX Amacron ydieresis -40 +KPX Aogonek C -30 +KPX Aogonek Cacute -30 +KPX Aogonek Ccaron -30 +KPX Aogonek Ccedilla -30 +KPX Aogonek G -30 +KPX Aogonek Gbreve -30 +KPX Aogonek Gcommaaccent -30 +KPX Aogonek O -30 +KPX Aogonek Oacute -30 +KPX Aogonek Ocircumflex -30 +KPX Aogonek Odieresis -30 +KPX Aogonek Ograve -30 +KPX Aogonek Ohungarumlaut -30 +KPX Aogonek Omacron -30 +KPX Aogonek Oslash -30 +KPX Aogonek Otilde -30 +KPX Aogonek Q -30 +KPX Aogonek T -120 +KPX Aogonek Tcaron -120 +KPX Aogonek Tcommaaccent -120 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -70 +KPX Aogonek W -50 +KPX Aogonek Y -100 +KPX Aogonek Yacute -100 +KPX Aogonek Ydieresis -100 +KPX Aogonek u -30 +KPX Aogonek uacute -30 +KPX Aogonek ucircumflex -30 +KPX Aogonek udieresis -30 +KPX Aogonek ugrave -30 +KPX Aogonek uhungarumlaut -30 +KPX Aogonek umacron -30 +KPX Aogonek uogonek -30 +KPX Aogonek uring -30 +KPX Aogonek v -40 +KPX Aogonek w -40 +KPX Aogonek y -40 +KPX Aogonek yacute -40 +KPX Aogonek ydieresis -40 +KPX Aring C -30 +KPX Aring Cacute -30 +KPX Aring Ccaron -30 +KPX Aring Ccedilla -30 +KPX Aring G -30 +KPX Aring Gbreve -30 +KPX Aring Gcommaaccent -30 +KPX Aring O -30 +KPX Aring Oacute -30 +KPX Aring Ocircumflex -30 +KPX Aring Odieresis -30 +KPX Aring Ograve -30 +KPX Aring Ohungarumlaut -30 +KPX Aring Omacron -30 +KPX Aring Oslash -30 +KPX Aring Otilde -30 +KPX Aring Q -30 +KPX Aring T -120 +KPX Aring Tcaron -120 +KPX Aring Tcommaaccent -120 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -70 +KPX Aring W -50 +KPX Aring Y -100 +KPX Aring Yacute -100 +KPX Aring Ydieresis -100 +KPX Aring u -30 +KPX Aring uacute -30 +KPX Aring ucircumflex -30 +KPX Aring udieresis -30 +KPX Aring ugrave -30 +KPX Aring uhungarumlaut -30 +KPX Aring umacron -30 +KPX Aring uogonek -30 +KPX Aring uring -30 +KPX Aring v -40 +KPX Aring w -40 +KPX Aring y -40 +KPX Aring yacute -40 +KPX Aring ydieresis -40 +KPX Atilde C -30 +KPX Atilde Cacute -30 +KPX Atilde Ccaron -30 +KPX Atilde Ccedilla -30 +KPX Atilde G -30 +KPX Atilde Gbreve -30 +KPX Atilde Gcommaaccent -30 +KPX Atilde O -30 +KPX Atilde Oacute -30 +KPX Atilde Ocircumflex -30 +KPX Atilde Odieresis -30 +KPX Atilde Ograve -30 +KPX Atilde Ohungarumlaut -30 +KPX Atilde Omacron -30 +KPX Atilde Oslash -30 +KPX Atilde Otilde -30 +KPX Atilde Q -30 +KPX Atilde T -120 +KPX Atilde Tcaron -120 +KPX Atilde Tcommaaccent -120 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -70 +KPX Atilde W -50 +KPX Atilde Y -100 +KPX Atilde Yacute -100 +KPX Atilde Ydieresis -100 +KPX Atilde u -30 +KPX Atilde uacute -30 +KPX Atilde ucircumflex -30 +KPX Atilde udieresis -30 +KPX Atilde ugrave -30 +KPX Atilde uhungarumlaut -30 +KPX Atilde umacron -30 +KPX Atilde uogonek -30 +KPX Atilde uring -30 +KPX Atilde v -40 +KPX Atilde w -40 +KPX Atilde y -40 +KPX Atilde yacute -40 +KPX Atilde ydieresis -40 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX B comma -20 +KPX B period -20 +KPX C comma -30 +KPX C period -30 +KPX Cacute comma -30 +KPX Cacute period -30 +KPX Ccaron comma -30 +KPX Ccaron period -30 +KPX Ccedilla comma -30 +KPX Ccedilla period -30 +KPX D A -40 +KPX D Aacute -40 +KPX D Abreve -40 +KPX D Acircumflex -40 +KPX D Adieresis -40 +KPX D Agrave -40 +KPX D Amacron -40 +KPX D Aogonek -40 +KPX D Aring -40 +KPX D Atilde -40 +KPX D V -70 +KPX D W -40 +KPX D Y -90 +KPX D Yacute -90 +KPX D Ydieresis -90 +KPX D comma -70 +KPX D period -70 +KPX Dcaron A -40 +KPX Dcaron Aacute -40 +KPX Dcaron Abreve -40 +KPX Dcaron Acircumflex -40 +KPX Dcaron Adieresis -40 +KPX Dcaron Agrave -40 +KPX Dcaron Amacron -40 +KPX Dcaron Aogonek -40 +KPX Dcaron Aring -40 +KPX Dcaron Atilde -40 +KPX Dcaron V -70 +KPX Dcaron W -40 +KPX Dcaron Y -90 +KPX Dcaron Yacute -90 +KPX Dcaron Ydieresis -90 +KPX Dcaron comma -70 +KPX Dcaron period -70 +KPX Dcroat A -40 +KPX Dcroat Aacute -40 +KPX Dcroat Abreve -40 +KPX Dcroat Acircumflex -40 +KPX Dcroat Adieresis -40 +KPX Dcroat Agrave -40 +KPX Dcroat Amacron -40 +KPX Dcroat Aogonek -40 +KPX Dcroat Aring -40 +KPX Dcroat Atilde -40 +KPX Dcroat V -70 +KPX Dcroat W -40 +KPX Dcroat Y -90 +KPX Dcroat Yacute -90 +KPX Dcroat Ydieresis -90 +KPX Dcroat comma -70 +KPX Dcroat period -70 +KPX F A -80 +KPX F Aacute -80 +KPX F Abreve -80 +KPX F Acircumflex -80 +KPX F Adieresis -80 +KPX F Agrave -80 +KPX F Amacron -80 +KPX F Aogonek -80 +KPX F Aring -80 +KPX F Atilde -80 +KPX F a -50 +KPX F aacute -50 +KPX F abreve -50 +KPX F acircumflex -50 +KPX F adieresis -50 +KPX F agrave -50 +KPX F amacron -50 +KPX F aogonek -50 +KPX F aring -50 +KPX F atilde -50 +KPX F comma -150 +KPX F e -30 +KPX F eacute -30 +KPX F ecaron -30 +KPX F ecircumflex -30 +KPX F edieresis -30 +KPX F edotaccent -30 +KPX F egrave -30 +KPX F emacron -30 +KPX F eogonek -30 +KPX F o -30 +KPX F oacute -30 +KPX F ocircumflex -30 +KPX F odieresis -30 +KPX F ograve -30 +KPX F ohungarumlaut -30 +KPX F omacron -30 +KPX F oslash -30 +KPX F otilde -30 +KPX F period -150 +KPX F r -45 +KPX F racute -45 +KPX F rcaron -45 +KPX F rcommaaccent -45 +KPX J A -20 +KPX J Aacute -20 +KPX J Abreve -20 +KPX J Acircumflex -20 +KPX J Adieresis -20 +KPX J Agrave -20 +KPX J Amacron -20 +KPX J Aogonek -20 +KPX J Aring -20 +KPX J Atilde -20 +KPX J a -20 +KPX J aacute -20 +KPX J abreve -20 +KPX J acircumflex -20 +KPX J adieresis -20 +KPX J agrave -20 +KPX J amacron -20 +KPX J aogonek -20 +KPX J aring -20 +KPX J atilde -20 +KPX J comma -30 +KPX J period -30 +KPX J u -20 +KPX J uacute -20 +KPX J ucircumflex -20 +KPX J udieresis -20 +KPX J ugrave -20 +KPX J uhungarumlaut -20 +KPX J umacron -20 +KPX J uogonek -20 +KPX J uring -20 +KPX K O -50 +KPX K Oacute -50 +KPX K Ocircumflex -50 +KPX K Odieresis -50 +KPX K Ograve -50 +KPX K Ohungarumlaut -50 +KPX K Omacron -50 +KPX K Oslash -50 +KPX K Otilde -50 +KPX K e -40 +KPX K eacute -40 +KPX K ecaron -40 +KPX K ecircumflex -40 +KPX K edieresis -40 +KPX K edotaccent -40 +KPX K egrave -40 +KPX K emacron -40 +KPX K eogonek -40 +KPX K o -40 +KPX K oacute -40 +KPX K ocircumflex -40 +KPX K odieresis -40 +KPX K ograve -40 +KPX K ohungarumlaut -40 +KPX K omacron -40 +KPX K oslash -40 +KPX K otilde -40 +KPX K u -30 +KPX K uacute -30 +KPX K ucircumflex -30 +KPX K udieresis -30 +KPX K ugrave -30 +KPX K uhungarumlaut -30 +KPX K umacron -30 +KPX K uogonek -30 +KPX K uring -30 +KPX K y -50 +KPX K yacute -50 +KPX K ydieresis -50 +KPX Kcommaaccent O -50 +KPX Kcommaaccent Oacute -50 +KPX Kcommaaccent Ocircumflex -50 +KPX Kcommaaccent Odieresis -50 +KPX Kcommaaccent Ograve -50 +KPX Kcommaaccent Ohungarumlaut -50 +KPX Kcommaaccent Omacron -50 +KPX Kcommaaccent Oslash -50 +KPX Kcommaaccent Otilde -50 +KPX Kcommaaccent e -40 +KPX Kcommaaccent eacute -40 +KPX Kcommaaccent ecaron -40 +KPX Kcommaaccent ecircumflex -40 +KPX Kcommaaccent edieresis -40 +KPX Kcommaaccent edotaccent -40 +KPX Kcommaaccent egrave -40 +KPX Kcommaaccent emacron -40 +KPX Kcommaaccent eogonek -40 +KPX Kcommaaccent o -40 +KPX Kcommaaccent oacute -40 +KPX Kcommaaccent ocircumflex -40 +KPX Kcommaaccent odieresis -40 +KPX Kcommaaccent ograve -40 +KPX Kcommaaccent ohungarumlaut -40 +KPX Kcommaaccent omacron -40 +KPX Kcommaaccent oslash -40 +KPX Kcommaaccent otilde -40 +KPX Kcommaaccent u -30 +KPX Kcommaaccent uacute -30 +KPX Kcommaaccent ucircumflex -30 +KPX Kcommaaccent udieresis -30 +KPX Kcommaaccent ugrave -30 +KPX Kcommaaccent uhungarumlaut -30 +KPX Kcommaaccent umacron -30 +KPX Kcommaaccent uogonek -30 +KPX Kcommaaccent uring -30 +KPX Kcommaaccent y -50 +KPX Kcommaaccent yacute -50 +KPX Kcommaaccent ydieresis -50 +KPX L T -110 +KPX L Tcaron -110 +KPX L Tcommaaccent -110 +KPX L V -110 +KPX L W -70 +KPX L Y -140 +KPX L Yacute -140 +KPX L Ydieresis -140 +KPX L quotedblright -140 +KPX L quoteright -160 +KPX L y -30 +KPX L yacute -30 +KPX L ydieresis -30 +KPX Lacute T -110 +KPX Lacute Tcaron -110 +KPX Lacute Tcommaaccent -110 +KPX Lacute V -110 +KPX Lacute W -70 +KPX Lacute Y -140 +KPX Lacute Yacute -140 +KPX Lacute Ydieresis -140 +KPX Lacute quotedblright -140 +KPX Lacute quoteright -160 +KPX Lacute y -30 +KPX Lacute yacute -30 +KPX Lacute ydieresis -30 +KPX Lcaron T -110 +KPX Lcaron Tcaron -110 +KPX Lcaron Tcommaaccent -110 +KPX Lcaron V -110 +KPX Lcaron W -70 +KPX Lcaron Y -140 +KPX Lcaron Yacute -140 +KPX Lcaron Ydieresis -140 +KPX Lcaron quotedblright -140 +KPX Lcaron quoteright -160 +KPX Lcaron y -30 +KPX Lcaron yacute -30 +KPX Lcaron ydieresis -30 +KPX Lcommaaccent T -110 +KPX Lcommaaccent Tcaron -110 +KPX Lcommaaccent Tcommaaccent -110 +KPX Lcommaaccent V -110 +KPX Lcommaaccent W -70 +KPX Lcommaaccent Y -140 +KPX Lcommaaccent Yacute -140 +KPX Lcommaaccent Ydieresis -140 +KPX Lcommaaccent quotedblright -140 +KPX Lcommaaccent quoteright -160 +KPX Lcommaaccent y -30 +KPX Lcommaaccent yacute -30 +KPX Lcommaaccent ydieresis -30 +KPX Lslash T -110 +KPX Lslash Tcaron -110 +KPX Lslash Tcommaaccent -110 +KPX Lslash V -110 +KPX Lslash W -70 +KPX Lslash Y -140 +KPX Lslash Yacute -140 +KPX Lslash Ydieresis -140 +KPX Lslash quotedblright -140 +KPX Lslash quoteright -160 +KPX Lslash y -30 +KPX Lslash yacute -30 +KPX Lslash ydieresis -30 +KPX O A -20 +KPX O Aacute -20 +KPX O Abreve -20 +KPX O Acircumflex -20 +KPX O Adieresis -20 +KPX O Agrave -20 +KPX O Amacron -20 +KPX O Aogonek -20 +KPX O Aring -20 +KPX O Atilde -20 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -30 +KPX O X -60 +KPX O Y -70 +KPX O Yacute -70 +KPX O Ydieresis -70 +KPX O comma -40 +KPX O period -40 +KPX Oacute A -20 +KPX Oacute Aacute -20 +KPX Oacute Abreve -20 +KPX Oacute Acircumflex -20 +KPX Oacute Adieresis -20 +KPX Oacute Agrave -20 +KPX Oacute Amacron -20 +KPX Oacute Aogonek -20 +KPX Oacute Aring -20 +KPX Oacute Atilde -20 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -30 +KPX Oacute X -60 +KPX Oacute Y -70 +KPX Oacute Yacute -70 +KPX Oacute Ydieresis -70 +KPX Oacute comma -40 +KPX Oacute period -40 +KPX Ocircumflex A -20 +KPX Ocircumflex Aacute -20 +KPX Ocircumflex Abreve -20 +KPX Ocircumflex Acircumflex -20 +KPX Ocircumflex Adieresis -20 +KPX Ocircumflex Agrave -20 +KPX Ocircumflex Amacron -20 +KPX Ocircumflex Aogonek -20 +KPX Ocircumflex Aring -20 +KPX Ocircumflex Atilde -20 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -30 +KPX Ocircumflex X -60 +KPX Ocircumflex Y -70 +KPX Ocircumflex Yacute -70 +KPX Ocircumflex Ydieresis -70 +KPX Ocircumflex comma -40 +KPX Ocircumflex period -40 +KPX Odieresis A -20 +KPX Odieresis Aacute -20 +KPX Odieresis Abreve -20 +KPX Odieresis Acircumflex -20 +KPX Odieresis Adieresis -20 +KPX Odieresis Agrave -20 +KPX Odieresis Amacron -20 +KPX Odieresis Aogonek -20 +KPX Odieresis Aring -20 +KPX Odieresis Atilde -20 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -30 +KPX Odieresis X -60 +KPX Odieresis Y -70 +KPX Odieresis Yacute -70 +KPX Odieresis Ydieresis -70 +KPX Odieresis comma -40 +KPX Odieresis period -40 +KPX Ograve A -20 +KPX Ograve Aacute -20 +KPX Ograve Abreve -20 +KPX Ograve Acircumflex -20 +KPX Ograve Adieresis -20 +KPX Ograve Agrave -20 +KPX Ograve Amacron -20 +KPX Ograve Aogonek -20 +KPX Ograve Aring -20 +KPX Ograve Atilde -20 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -30 +KPX Ograve X -60 +KPX Ograve Y -70 +KPX Ograve Yacute -70 +KPX Ograve Ydieresis -70 +KPX Ograve comma -40 +KPX Ograve period -40 +KPX Ohungarumlaut A -20 +KPX Ohungarumlaut Aacute -20 +KPX Ohungarumlaut Abreve -20 +KPX Ohungarumlaut Acircumflex -20 +KPX Ohungarumlaut Adieresis -20 +KPX Ohungarumlaut Agrave -20 +KPX Ohungarumlaut Amacron -20 +KPX Ohungarumlaut Aogonek -20 +KPX Ohungarumlaut Aring -20 +KPX Ohungarumlaut Atilde -20 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -30 +KPX Ohungarumlaut X -60 +KPX Ohungarumlaut Y -70 +KPX Ohungarumlaut Yacute -70 +KPX Ohungarumlaut Ydieresis -70 +KPX Ohungarumlaut comma -40 +KPX Ohungarumlaut period -40 +KPX Omacron A -20 +KPX Omacron Aacute -20 +KPX Omacron Abreve -20 +KPX Omacron Acircumflex -20 +KPX Omacron Adieresis -20 +KPX Omacron Agrave -20 +KPX Omacron Amacron -20 +KPX Omacron Aogonek -20 +KPX Omacron Aring -20 +KPX Omacron Atilde -20 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -30 +KPX Omacron X -60 +KPX Omacron Y -70 +KPX Omacron Yacute -70 +KPX Omacron Ydieresis -70 +KPX Omacron comma -40 +KPX Omacron period -40 +KPX Oslash A -20 +KPX Oslash Aacute -20 +KPX Oslash Abreve -20 +KPX Oslash Acircumflex -20 +KPX Oslash Adieresis -20 +KPX Oslash Agrave -20 +KPX Oslash Amacron -20 +KPX Oslash Aogonek -20 +KPX Oslash Aring -20 +KPX Oslash Atilde -20 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -30 +KPX Oslash X -60 +KPX Oslash Y -70 +KPX Oslash Yacute -70 +KPX Oslash Ydieresis -70 +KPX Oslash comma -40 +KPX Oslash period -40 +KPX Otilde A -20 +KPX Otilde Aacute -20 +KPX Otilde Abreve -20 +KPX Otilde Acircumflex -20 +KPX Otilde Adieresis -20 +KPX Otilde Agrave -20 +KPX Otilde Amacron -20 +KPX Otilde Aogonek -20 +KPX Otilde Aring -20 +KPX Otilde Atilde -20 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -30 +KPX Otilde X -60 +KPX Otilde Y -70 +KPX Otilde Yacute -70 +KPX Otilde Ydieresis -70 +KPX Otilde comma -40 +KPX Otilde period -40 +KPX P A -120 +KPX P Aacute -120 +KPX P Abreve -120 +KPX P Acircumflex -120 +KPX P Adieresis -120 +KPX P Agrave -120 +KPX P Amacron -120 +KPX P Aogonek -120 +KPX P Aring -120 +KPX P Atilde -120 +KPX P a -40 +KPX P aacute -40 +KPX P abreve -40 +KPX P acircumflex -40 +KPX P adieresis -40 +KPX P agrave -40 +KPX P amacron -40 +KPX P aogonek -40 +KPX P aring -40 +KPX P atilde -40 +KPX P comma -180 +KPX P e -50 +KPX P eacute -50 +KPX P ecaron -50 +KPX P ecircumflex -50 +KPX P edieresis -50 +KPX P edotaccent -50 +KPX P egrave -50 +KPX P emacron -50 +KPX P eogonek -50 +KPX P o -50 +KPX P oacute -50 +KPX P ocircumflex -50 +KPX P odieresis -50 +KPX P ograve -50 +KPX P ohungarumlaut -50 +KPX P omacron -50 +KPX P oslash -50 +KPX P otilde -50 +KPX P period -180 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX R O -20 +KPX R Oacute -20 +KPX R Ocircumflex -20 +KPX R Odieresis -20 +KPX R Ograve -20 +KPX R Ohungarumlaut -20 +KPX R Omacron -20 +KPX R Oslash -20 +KPX R Otilde -20 +KPX R T -30 +KPX R Tcaron -30 +KPX R Tcommaaccent -30 +KPX R U -40 +KPX R Uacute -40 +KPX R Ucircumflex -40 +KPX R Udieresis -40 +KPX R Ugrave -40 +KPX R Uhungarumlaut -40 +KPX R Umacron -40 +KPX R Uogonek -40 +KPX R Uring -40 +KPX R V -50 +KPX R W -30 +KPX R Y -50 +KPX R Yacute -50 +KPX R Ydieresis -50 +KPX Racute O -20 +KPX Racute Oacute -20 +KPX Racute Ocircumflex -20 +KPX Racute Odieresis -20 +KPX Racute Ograve -20 +KPX Racute Ohungarumlaut -20 +KPX Racute Omacron -20 +KPX Racute Oslash -20 +KPX Racute Otilde -20 +KPX Racute T -30 +KPX Racute Tcaron -30 +KPX Racute Tcommaaccent -30 +KPX Racute U -40 +KPX Racute Uacute -40 +KPX Racute Ucircumflex -40 +KPX Racute Udieresis -40 +KPX Racute Ugrave -40 +KPX Racute Uhungarumlaut -40 +KPX Racute Umacron -40 +KPX Racute Uogonek -40 +KPX Racute Uring -40 +KPX Racute V -50 +KPX Racute W -30 +KPX Racute Y -50 +KPX Racute Yacute -50 +KPX Racute Ydieresis -50 +KPX Rcaron O -20 +KPX Rcaron Oacute -20 +KPX Rcaron Ocircumflex -20 +KPX Rcaron Odieresis -20 +KPX Rcaron Ograve -20 +KPX Rcaron Ohungarumlaut -20 +KPX Rcaron Omacron -20 +KPX Rcaron Oslash -20 +KPX Rcaron Otilde -20 +KPX Rcaron T -30 +KPX Rcaron Tcaron -30 +KPX Rcaron Tcommaaccent -30 +KPX Rcaron U -40 +KPX Rcaron Uacute -40 +KPX Rcaron Ucircumflex -40 +KPX Rcaron Udieresis -40 +KPX Rcaron Ugrave -40 +KPX Rcaron Uhungarumlaut -40 +KPX Rcaron Umacron -40 +KPX Rcaron Uogonek -40 +KPX Rcaron Uring -40 +KPX Rcaron V -50 +KPX Rcaron W -30 +KPX Rcaron Y -50 +KPX Rcaron Yacute -50 +KPX Rcaron Ydieresis -50 +KPX Rcommaaccent O -20 +KPX Rcommaaccent Oacute -20 +KPX Rcommaaccent Ocircumflex -20 +KPX Rcommaaccent Odieresis -20 +KPX Rcommaaccent Ograve -20 +KPX Rcommaaccent Ohungarumlaut -20 +KPX Rcommaaccent Omacron -20 +KPX Rcommaaccent Oslash -20 +KPX Rcommaaccent Otilde -20 +KPX Rcommaaccent T -30 +KPX Rcommaaccent Tcaron -30 +KPX Rcommaaccent Tcommaaccent -30 +KPX Rcommaaccent U -40 +KPX Rcommaaccent Uacute -40 +KPX Rcommaaccent Ucircumflex -40 +KPX Rcommaaccent Udieresis -40 +KPX Rcommaaccent Ugrave -40 +KPX Rcommaaccent Uhungarumlaut -40 +KPX Rcommaaccent Umacron -40 +KPX Rcommaaccent Uogonek -40 +KPX Rcommaaccent Uring -40 +KPX Rcommaaccent V -50 +KPX Rcommaaccent W -30 +KPX Rcommaaccent Y -50 +KPX Rcommaaccent Yacute -50 +KPX Rcommaaccent Ydieresis -50 +KPX S comma -20 +KPX S period -20 +KPX Sacute comma -20 +KPX Sacute period -20 +KPX Scaron comma -20 +KPX Scaron period -20 +KPX Scedilla comma -20 +KPX Scedilla period -20 +KPX Scommaaccent comma -20 +KPX Scommaaccent period -20 +KPX T A -120 +KPX T Aacute -120 +KPX T Abreve -120 +KPX T Acircumflex -120 +KPX T Adieresis -120 +KPX T Agrave -120 +KPX T Amacron -120 +KPX T Aogonek -120 +KPX T Aring -120 +KPX T Atilde -120 +KPX T O -40 +KPX T Oacute -40 +KPX T Ocircumflex -40 +KPX T Odieresis -40 +KPX T Ograve -40 +KPX T Ohungarumlaut -40 +KPX T Omacron -40 +KPX T Oslash -40 +KPX T Otilde -40 +KPX T a -120 +KPX T aacute -120 +KPX T abreve -60 +KPX T acircumflex -120 +KPX T adieresis -120 +KPX T agrave -120 +KPX T amacron -60 +KPX T aogonek -120 +KPX T aring -120 +KPX T atilde -60 +KPX T colon -20 +KPX T comma -120 +KPX T e -120 +KPX T eacute -120 +KPX T ecaron -120 +KPX T ecircumflex -120 +KPX T edieresis -120 +KPX T edotaccent -120 +KPX T egrave -60 +KPX T emacron -60 +KPX T eogonek -120 +KPX T hyphen -140 +KPX T o -120 +KPX T oacute -120 +KPX T ocircumflex -120 +KPX T odieresis -120 +KPX T ograve -120 +KPX T ohungarumlaut -120 +KPX T omacron -60 +KPX T oslash -120 +KPX T otilde -60 +KPX T period -120 +KPX T r -120 +KPX T racute -120 +KPX T rcaron -120 +KPX T rcommaaccent -120 +KPX T semicolon -20 +KPX T u -120 +KPX T uacute -120 +KPX T ucircumflex -120 +KPX T udieresis -120 +KPX T ugrave -120 +KPX T uhungarumlaut -120 +KPX T umacron -60 +KPX T uogonek -120 +KPX T uring -120 +KPX T w -120 +KPX T y -120 +KPX T yacute -120 +KPX T ydieresis -60 +KPX Tcaron A -120 +KPX Tcaron Aacute -120 +KPX Tcaron Abreve -120 +KPX Tcaron Acircumflex -120 +KPX Tcaron Adieresis -120 +KPX Tcaron Agrave -120 +KPX Tcaron Amacron -120 +KPX Tcaron Aogonek -120 +KPX Tcaron Aring -120 +KPX Tcaron Atilde -120 +KPX Tcaron O -40 +KPX Tcaron Oacute -40 +KPX Tcaron Ocircumflex -40 +KPX Tcaron Odieresis -40 +KPX Tcaron Ograve -40 +KPX Tcaron Ohungarumlaut -40 +KPX Tcaron Omacron -40 +KPX Tcaron Oslash -40 +KPX Tcaron Otilde -40 +KPX Tcaron a -120 +KPX Tcaron aacute -120 +KPX Tcaron abreve -60 +KPX Tcaron acircumflex -120 +KPX Tcaron adieresis -120 +KPX Tcaron agrave -120 +KPX Tcaron amacron -60 +KPX Tcaron aogonek -120 +KPX Tcaron aring -120 +KPX Tcaron atilde -60 +KPX Tcaron colon -20 +KPX Tcaron comma -120 +KPX Tcaron e -120 +KPX Tcaron eacute -120 +KPX Tcaron ecaron -120 +KPX Tcaron ecircumflex -120 +KPX Tcaron edieresis -120 +KPX Tcaron edotaccent -120 +KPX Tcaron egrave -60 +KPX Tcaron emacron -60 +KPX Tcaron eogonek -120 +KPX Tcaron hyphen -140 +KPX Tcaron o -120 +KPX Tcaron oacute -120 +KPX Tcaron ocircumflex -120 +KPX Tcaron odieresis -120 +KPX Tcaron ograve -120 +KPX Tcaron ohungarumlaut -120 +KPX Tcaron omacron -60 +KPX Tcaron oslash -120 +KPX Tcaron otilde -60 +KPX Tcaron period -120 +KPX Tcaron r -120 +KPX Tcaron racute -120 +KPX Tcaron rcaron -120 +KPX Tcaron rcommaaccent -120 +KPX Tcaron semicolon -20 +KPX Tcaron u -120 +KPX Tcaron uacute -120 +KPX Tcaron ucircumflex -120 +KPX Tcaron udieresis -120 +KPX Tcaron ugrave -120 +KPX Tcaron uhungarumlaut -120 +KPX Tcaron umacron -60 +KPX Tcaron uogonek -120 +KPX Tcaron uring -120 +KPX Tcaron w -120 +KPX Tcaron y -120 +KPX Tcaron yacute -120 +KPX Tcaron ydieresis -60 +KPX Tcommaaccent A -120 +KPX Tcommaaccent Aacute -120 +KPX Tcommaaccent Abreve -120 +KPX Tcommaaccent Acircumflex -120 +KPX Tcommaaccent Adieresis -120 +KPX Tcommaaccent Agrave -120 +KPX Tcommaaccent Amacron -120 +KPX Tcommaaccent Aogonek -120 +KPX Tcommaaccent Aring -120 +KPX Tcommaaccent Atilde -120 +KPX Tcommaaccent O -40 +KPX Tcommaaccent Oacute -40 +KPX Tcommaaccent Ocircumflex -40 +KPX Tcommaaccent Odieresis -40 +KPX Tcommaaccent Ograve -40 +KPX Tcommaaccent Ohungarumlaut -40 +KPX Tcommaaccent Omacron -40 +KPX Tcommaaccent Oslash -40 +KPX Tcommaaccent Otilde -40 +KPX Tcommaaccent a -120 +KPX Tcommaaccent aacute -120 +KPX Tcommaaccent abreve -60 +KPX Tcommaaccent acircumflex -120 +KPX Tcommaaccent adieresis -120 +KPX Tcommaaccent agrave -120 +KPX Tcommaaccent amacron -60 +KPX Tcommaaccent aogonek -120 +KPX Tcommaaccent aring -120 +KPX Tcommaaccent atilde -60 +KPX Tcommaaccent colon -20 +KPX Tcommaaccent comma -120 +KPX Tcommaaccent e -120 +KPX Tcommaaccent eacute -120 +KPX Tcommaaccent ecaron -120 +KPX Tcommaaccent ecircumflex -120 +KPX Tcommaaccent edieresis -120 +KPX Tcommaaccent edotaccent -120 +KPX Tcommaaccent egrave -60 +KPX Tcommaaccent emacron -60 +KPX Tcommaaccent eogonek -120 +KPX Tcommaaccent hyphen -140 +KPX Tcommaaccent o -120 +KPX Tcommaaccent oacute -120 +KPX Tcommaaccent ocircumflex -120 +KPX Tcommaaccent odieresis -120 +KPX Tcommaaccent ograve -120 +KPX Tcommaaccent ohungarumlaut -120 +KPX Tcommaaccent omacron -60 +KPX Tcommaaccent oslash -120 +KPX Tcommaaccent otilde -60 +KPX Tcommaaccent period -120 +KPX Tcommaaccent r -120 +KPX Tcommaaccent racute -120 +KPX Tcommaaccent rcaron -120 +KPX Tcommaaccent rcommaaccent -120 +KPX Tcommaaccent semicolon -20 +KPX Tcommaaccent u -120 +KPX Tcommaaccent uacute -120 +KPX Tcommaaccent ucircumflex -120 +KPX Tcommaaccent udieresis -120 +KPX Tcommaaccent ugrave -120 +KPX Tcommaaccent uhungarumlaut -120 +KPX Tcommaaccent umacron -60 +KPX Tcommaaccent uogonek -120 +KPX Tcommaaccent uring -120 +KPX Tcommaaccent w -120 +KPX Tcommaaccent y -120 +KPX Tcommaaccent yacute -120 +KPX Tcommaaccent ydieresis -60 +KPX U A -40 +KPX U Aacute -40 +KPX U Abreve -40 +KPX U Acircumflex -40 +KPX U Adieresis -40 +KPX U Agrave -40 +KPX U Amacron -40 +KPX U Aogonek -40 +KPX U Aring -40 +KPX U Atilde -40 +KPX U comma -40 +KPX U period -40 +KPX Uacute A -40 +KPX Uacute Aacute -40 +KPX Uacute Abreve -40 +KPX Uacute Acircumflex -40 +KPX Uacute Adieresis -40 +KPX Uacute Agrave -40 +KPX Uacute Amacron -40 +KPX Uacute Aogonek -40 +KPX Uacute Aring -40 +KPX Uacute Atilde -40 +KPX Uacute comma -40 +KPX Uacute period -40 +KPX Ucircumflex A -40 +KPX Ucircumflex Aacute -40 +KPX Ucircumflex Abreve -40 +KPX Ucircumflex Acircumflex -40 +KPX Ucircumflex Adieresis -40 +KPX Ucircumflex Agrave -40 +KPX Ucircumflex Amacron -40 +KPX Ucircumflex Aogonek -40 +KPX Ucircumflex Aring -40 +KPX Ucircumflex Atilde -40 +KPX Ucircumflex comma -40 +KPX Ucircumflex period -40 +KPX Udieresis A -40 +KPX Udieresis Aacute -40 +KPX Udieresis Abreve -40 +KPX Udieresis Acircumflex -40 +KPX Udieresis Adieresis -40 +KPX Udieresis Agrave -40 +KPX Udieresis Amacron -40 +KPX Udieresis Aogonek -40 +KPX Udieresis Aring -40 +KPX Udieresis Atilde -40 +KPX Udieresis comma -40 +KPX Udieresis period -40 +KPX Ugrave A -40 +KPX Ugrave Aacute -40 +KPX Ugrave Abreve -40 +KPX Ugrave Acircumflex -40 +KPX Ugrave Adieresis -40 +KPX Ugrave Agrave -40 +KPX Ugrave Amacron -40 +KPX Ugrave Aogonek -40 +KPX Ugrave Aring -40 +KPX Ugrave Atilde -40 +KPX Ugrave comma -40 +KPX Ugrave period -40 +KPX Uhungarumlaut A -40 +KPX Uhungarumlaut Aacute -40 +KPX Uhungarumlaut Abreve -40 +KPX Uhungarumlaut Acircumflex -40 +KPX Uhungarumlaut Adieresis -40 +KPX Uhungarumlaut Agrave -40 +KPX Uhungarumlaut Amacron -40 +KPX Uhungarumlaut Aogonek -40 +KPX Uhungarumlaut Aring -40 +KPX Uhungarumlaut Atilde -40 +KPX Uhungarumlaut comma -40 +KPX Uhungarumlaut period -40 +KPX Umacron A -40 +KPX Umacron Aacute -40 +KPX Umacron Abreve -40 +KPX Umacron Acircumflex -40 +KPX Umacron Adieresis -40 +KPX Umacron Agrave -40 +KPX Umacron Amacron -40 +KPX Umacron Aogonek -40 +KPX Umacron Aring -40 +KPX Umacron Atilde -40 +KPX Umacron comma -40 +KPX Umacron period -40 +KPX Uogonek A -40 +KPX Uogonek Aacute -40 +KPX Uogonek Abreve -40 +KPX Uogonek Acircumflex -40 +KPX Uogonek Adieresis -40 +KPX Uogonek Agrave -40 +KPX Uogonek Amacron -40 +KPX Uogonek Aogonek -40 +KPX Uogonek Aring -40 +KPX Uogonek Atilde -40 +KPX Uogonek comma -40 +KPX Uogonek period -40 +KPX Uring A -40 +KPX Uring Aacute -40 +KPX Uring Abreve -40 +KPX Uring Acircumflex -40 +KPX Uring Adieresis -40 +KPX Uring Agrave -40 +KPX Uring Amacron -40 +KPX Uring Aogonek -40 +KPX Uring Aring -40 +KPX Uring Atilde -40 +KPX Uring comma -40 +KPX Uring period -40 +KPX V A -80 +KPX V Aacute -80 +KPX V Abreve -80 +KPX V Acircumflex -80 +KPX V Adieresis -80 +KPX V Agrave -80 +KPX V Amacron -80 +KPX V Aogonek -80 +KPX V Aring -80 +KPX V Atilde -80 +KPX V G -40 +KPX V Gbreve -40 +KPX V Gcommaaccent -40 +KPX V O -40 +KPX V Oacute -40 +KPX V Ocircumflex -40 +KPX V Odieresis -40 +KPX V Ograve -40 +KPX V Ohungarumlaut -40 +KPX V Omacron -40 +KPX V Oslash -40 +KPX V Otilde -40 +KPX V a -70 +KPX V aacute -70 +KPX V abreve -70 +KPX V acircumflex -70 +KPX V adieresis -70 +KPX V agrave -70 +KPX V amacron -70 +KPX V aogonek -70 +KPX V aring -70 +KPX V atilde -70 +KPX V colon -40 +KPX V comma -125 +KPX V e -80 +KPX V eacute -80 +KPX V ecaron -80 +KPX V ecircumflex -80 +KPX V edieresis -80 +KPX V edotaccent -80 +KPX V egrave -80 +KPX V emacron -80 +KPX V eogonek -80 +KPX V hyphen -80 +KPX V o -80 +KPX V oacute -80 +KPX V ocircumflex -80 +KPX V odieresis -80 +KPX V ograve -80 +KPX V ohungarumlaut -80 +KPX V omacron -80 +KPX V oslash -80 +KPX V otilde -80 +KPX V period -125 +KPX V semicolon -40 +KPX V u -70 +KPX V uacute -70 +KPX V ucircumflex -70 +KPX V udieresis -70 +KPX V ugrave -70 +KPX V uhungarumlaut -70 +KPX V umacron -70 +KPX V uogonek -70 +KPX V uring -70 +KPX W A -50 +KPX W Aacute -50 +KPX W Abreve -50 +KPX W Acircumflex -50 +KPX W Adieresis -50 +KPX W Agrave -50 +KPX W Amacron -50 +KPX W Aogonek -50 +KPX W Aring -50 +KPX W Atilde -50 +KPX W O -20 +KPX W Oacute -20 +KPX W Ocircumflex -20 +KPX W Odieresis -20 +KPX W Ograve -20 +KPX W Ohungarumlaut -20 +KPX W Omacron -20 +KPX W Oslash -20 +KPX W Otilde -20 +KPX W a -40 +KPX W aacute -40 +KPX W abreve -40 +KPX W acircumflex -40 +KPX W adieresis -40 +KPX W agrave -40 +KPX W amacron -40 +KPX W aogonek -40 +KPX W aring -40 +KPX W atilde -40 +KPX W comma -80 +KPX W e -30 +KPX W eacute -30 +KPX W ecaron -30 +KPX W ecircumflex -30 +KPX W edieresis -30 +KPX W edotaccent -30 +KPX W egrave -30 +KPX W emacron -30 +KPX W eogonek -30 +KPX W hyphen -40 +KPX W o -30 +KPX W oacute -30 +KPX W ocircumflex -30 +KPX W odieresis -30 +KPX W ograve -30 +KPX W ohungarumlaut -30 +KPX W omacron -30 +KPX W oslash -30 +KPX W otilde -30 +KPX W period -80 +KPX W u -30 +KPX W uacute -30 +KPX W ucircumflex -30 +KPX W udieresis -30 +KPX W ugrave -30 +KPX W uhungarumlaut -30 +KPX W umacron -30 +KPX W uogonek -30 +KPX W uring -30 +KPX W y -20 +KPX W yacute -20 +KPX W ydieresis -20 +KPX Y A -110 +KPX Y Aacute -110 +KPX Y Abreve -110 +KPX Y Acircumflex -110 +KPX Y Adieresis -110 +KPX Y Agrave -110 +KPX Y Amacron -110 +KPX Y Aogonek -110 +KPX Y Aring -110 +KPX Y Atilde -110 +KPX Y O -85 +KPX Y Oacute -85 +KPX Y Ocircumflex -85 +KPX Y Odieresis -85 +KPX Y Ograve -85 +KPX Y Ohungarumlaut -85 +KPX Y Omacron -85 +KPX Y Oslash -85 +KPX Y Otilde -85 +KPX Y a -140 +KPX Y aacute -140 +KPX Y abreve -70 +KPX Y acircumflex -140 +KPX Y adieresis -140 +KPX Y agrave -140 +KPX Y amacron -70 +KPX Y aogonek -140 +KPX Y aring -140 +KPX Y atilde -140 +KPX Y colon -60 +KPX Y comma -140 +KPX Y e -140 +KPX Y eacute -140 +KPX Y ecaron -140 +KPX Y ecircumflex -140 +KPX Y edieresis -140 +KPX Y edotaccent -140 +KPX Y egrave -140 +KPX Y emacron -70 +KPX Y eogonek -140 +KPX Y hyphen -140 +KPX Y i -20 +KPX Y iacute -20 +KPX Y iogonek -20 +KPX Y o -140 +KPX Y oacute -140 +KPX Y ocircumflex -140 +KPX Y odieresis -140 +KPX Y ograve -140 +KPX Y ohungarumlaut -140 +KPX Y omacron -140 +KPX Y oslash -140 +KPX Y otilde -140 +KPX Y period -140 +KPX Y semicolon -60 +KPX Y u -110 +KPX Y uacute -110 +KPX Y ucircumflex -110 +KPX Y udieresis -110 +KPX Y ugrave -110 +KPX Y uhungarumlaut -110 +KPX Y umacron -110 +KPX Y uogonek -110 +KPX Y uring -110 +KPX Yacute A -110 +KPX Yacute Aacute -110 +KPX Yacute Abreve -110 +KPX Yacute Acircumflex -110 +KPX Yacute Adieresis -110 +KPX Yacute Agrave -110 +KPX Yacute Amacron -110 +KPX Yacute Aogonek -110 +KPX Yacute Aring -110 +KPX Yacute Atilde -110 +KPX Yacute O -85 +KPX Yacute Oacute -85 +KPX Yacute Ocircumflex -85 +KPX Yacute Odieresis -85 +KPX Yacute Ograve -85 +KPX Yacute Ohungarumlaut -85 +KPX Yacute Omacron -85 +KPX Yacute Oslash -85 +KPX Yacute Otilde -85 +KPX Yacute a -140 +KPX Yacute aacute -140 +KPX Yacute abreve -70 +KPX Yacute acircumflex -140 +KPX Yacute adieresis -140 +KPX Yacute agrave -140 +KPX Yacute amacron -70 +KPX Yacute aogonek -140 +KPX Yacute aring -140 +KPX Yacute atilde -70 +KPX Yacute colon -60 +KPX Yacute comma -140 +KPX Yacute e -140 +KPX Yacute eacute -140 +KPX Yacute ecaron -140 +KPX Yacute ecircumflex -140 +KPX Yacute edieresis -140 +KPX Yacute edotaccent -140 +KPX Yacute egrave -140 +KPX Yacute emacron -70 +KPX Yacute eogonek -140 +KPX Yacute hyphen -140 +KPX Yacute i -20 +KPX Yacute iacute -20 +KPX Yacute iogonek -20 +KPX Yacute o -140 +KPX Yacute oacute -140 +KPX Yacute ocircumflex -140 +KPX Yacute odieresis -140 +KPX Yacute ograve -140 +KPX Yacute ohungarumlaut -140 +KPX Yacute omacron -70 +KPX Yacute oslash -140 +KPX Yacute otilde -140 +KPX Yacute period -140 +KPX Yacute semicolon -60 +KPX Yacute u -110 +KPX Yacute uacute -110 +KPX Yacute ucircumflex -110 +KPX Yacute udieresis -110 +KPX Yacute ugrave -110 +KPX Yacute uhungarumlaut -110 +KPX Yacute umacron -110 +KPX Yacute uogonek -110 +KPX Yacute uring -110 +KPX Ydieresis A -110 +KPX Ydieresis Aacute -110 +KPX Ydieresis Abreve -110 +KPX Ydieresis Acircumflex -110 +KPX Ydieresis Adieresis -110 +KPX Ydieresis Agrave -110 +KPX Ydieresis Amacron -110 +KPX Ydieresis Aogonek -110 +KPX Ydieresis Aring -110 +KPX Ydieresis Atilde -110 +KPX Ydieresis O -85 +KPX Ydieresis Oacute -85 +KPX Ydieresis Ocircumflex -85 +KPX Ydieresis Odieresis -85 +KPX Ydieresis Ograve -85 +KPX Ydieresis Ohungarumlaut -85 +KPX Ydieresis Omacron -85 +KPX Ydieresis Oslash -85 +KPX Ydieresis Otilde -85 +KPX Ydieresis a -140 +KPX Ydieresis aacute -140 +KPX Ydieresis abreve -70 +KPX Ydieresis acircumflex -140 +KPX Ydieresis adieresis -140 +KPX Ydieresis agrave -140 +KPX Ydieresis amacron -70 +KPX Ydieresis aogonek -140 +KPX Ydieresis aring -140 +KPX Ydieresis atilde -70 +KPX Ydieresis colon -60 +KPX Ydieresis comma -140 +KPX Ydieresis e -140 +KPX Ydieresis eacute -140 +KPX Ydieresis ecaron -140 +KPX Ydieresis ecircumflex -140 +KPX Ydieresis edieresis -140 +KPX Ydieresis edotaccent -140 +KPX Ydieresis egrave -140 +KPX Ydieresis emacron -70 +KPX Ydieresis eogonek -140 +KPX Ydieresis hyphen -140 +KPX Ydieresis i -20 +KPX Ydieresis iacute -20 +KPX Ydieresis iogonek -20 +KPX Ydieresis o -140 +KPX Ydieresis oacute -140 +KPX Ydieresis ocircumflex -140 +KPX Ydieresis odieresis -140 +KPX Ydieresis ograve -140 +KPX Ydieresis ohungarumlaut -140 +KPX Ydieresis omacron -140 +KPX Ydieresis oslash -140 +KPX Ydieresis otilde -140 +KPX Ydieresis period -140 +KPX Ydieresis semicolon -60 +KPX Ydieresis u -110 +KPX Ydieresis uacute -110 +KPX Ydieresis ucircumflex -110 +KPX Ydieresis udieresis -110 +KPX Ydieresis ugrave -110 +KPX Ydieresis uhungarumlaut -110 +KPX Ydieresis umacron -110 +KPX Ydieresis uogonek -110 +KPX Ydieresis uring -110 +KPX a v -20 +KPX a w -20 +KPX a y -30 +KPX a yacute -30 +KPX a ydieresis -30 +KPX aacute v -20 +KPX aacute w -20 +KPX aacute y -30 +KPX aacute yacute -30 +KPX aacute ydieresis -30 +KPX abreve v -20 +KPX abreve w -20 +KPX abreve y -30 +KPX abreve yacute -30 +KPX abreve ydieresis -30 +KPX acircumflex v -20 +KPX acircumflex w -20 +KPX acircumflex y -30 +KPX acircumflex yacute -30 +KPX acircumflex ydieresis -30 +KPX adieresis v -20 +KPX adieresis w -20 +KPX adieresis y -30 +KPX adieresis yacute -30 +KPX adieresis ydieresis -30 +KPX agrave v -20 +KPX agrave w -20 +KPX agrave y -30 +KPX agrave yacute -30 +KPX agrave ydieresis -30 +KPX amacron v -20 +KPX amacron w -20 +KPX amacron y -30 +KPX amacron yacute -30 +KPX amacron ydieresis -30 +KPX aogonek v -20 +KPX aogonek w -20 +KPX aogonek y -30 +KPX aogonek yacute -30 +KPX aogonek ydieresis -30 +KPX aring v -20 +KPX aring w -20 +KPX aring y -30 +KPX aring yacute -30 +KPX aring ydieresis -30 +KPX atilde v -20 +KPX atilde w -20 +KPX atilde y -30 +KPX atilde yacute -30 +KPX atilde ydieresis -30 +KPX b b -10 +KPX b comma -40 +KPX b l -20 +KPX b lacute -20 +KPX b lcommaaccent -20 +KPX b lslash -20 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -20 +KPX b y -20 +KPX b yacute -20 +KPX b ydieresis -20 +KPX c comma -15 +KPX c k -20 +KPX c kcommaaccent -20 +KPX cacute comma -15 +KPX cacute k -20 +KPX cacute kcommaaccent -20 +KPX ccaron comma -15 +KPX ccaron k -20 +KPX ccaron kcommaaccent -20 +KPX ccedilla comma -15 +KPX ccedilla k -20 +KPX ccedilla kcommaaccent -20 +KPX colon space -50 +KPX comma quotedblright -100 +KPX comma quoteright -100 +KPX e comma -15 +KPX e period -15 +KPX e v -30 +KPX e w -20 +KPX e x -30 +KPX e y -20 +KPX e yacute -20 +KPX e ydieresis -20 +KPX eacute comma -15 +KPX eacute period -15 +KPX eacute v -30 +KPX eacute w -20 +KPX eacute x -30 +KPX eacute y -20 +KPX eacute yacute -20 +KPX eacute ydieresis -20 +KPX ecaron comma -15 +KPX ecaron period -15 +KPX ecaron v -30 +KPX ecaron w -20 +KPX ecaron x -30 +KPX ecaron y -20 +KPX ecaron yacute -20 +KPX ecaron ydieresis -20 +KPX ecircumflex comma -15 +KPX ecircumflex period -15 +KPX ecircumflex v -30 +KPX ecircumflex w -20 +KPX ecircumflex x -30 +KPX ecircumflex y -20 +KPX ecircumflex yacute -20 +KPX ecircumflex ydieresis -20 +KPX edieresis comma -15 +KPX edieresis period -15 +KPX edieresis v -30 +KPX edieresis w -20 +KPX edieresis x -30 +KPX edieresis y -20 +KPX edieresis yacute -20 +KPX edieresis ydieresis -20 +KPX edotaccent comma -15 +KPX edotaccent period -15 +KPX edotaccent v -30 +KPX edotaccent w -20 +KPX edotaccent x -30 +KPX edotaccent y -20 +KPX edotaccent yacute -20 +KPX edotaccent ydieresis -20 +KPX egrave comma -15 +KPX egrave period -15 +KPX egrave v -30 +KPX egrave w -20 +KPX egrave x -30 +KPX egrave y -20 +KPX egrave yacute -20 +KPX egrave ydieresis -20 +KPX emacron comma -15 +KPX emacron period -15 +KPX emacron v -30 +KPX emacron w -20 +KPX emacron x -30 +KPX emacron y -20 +KPX emacron yacute -20 +KPX emacron ydieresis -20 +KPX eogonek comma -15 +KPX eogonek period -15 +KPX eogonek v -30 +KPX eogonek w -20 +KPX eogonek x -30 +KPX eogonek y -20 +KPX eogonek yacute -20 +KPX eogonek ydieresis -20 +KPX f a -30 +KPX f aacute -30 +KPX f abreve -30 +KPX f acircumflex -30 +KPX f adieresis -30 +KPX f agrave -30 +KPX f amacron -30 +KPX f aogonek -30 +KPX f aring -30 +KPX f atilde -30 +KPX f comma -30 +KPX f dotlessi -28 +KPX f e -30 +KPX f eacute -30 +KPX f ecaron -30 +KPX f ecircumflex -30 +KPX f edieresis -30 +KPX f edotaccent -30 +KPX f egrave -30 +KPX f emacron -30 +KPX f eogonek -30 +KPX f o -30 +KPX f oacute -30 +KPX f ocircumflex -30 +KPX f odieresis -30 +KPX f ograve -30 +KPX f ohungarumlaut -30 +KPX f omacron -30 +KPX f oslash -30 +KPX f otilde -30 +KPX f period -30 +KPX f quotedblright 60 +KPX f quoteright 50 +KPX g r -10 +KPX g racute -10 +KPX g rcaron -10 +KPX g rcommaaccent -10 +KPX gbreve r -10 +KPX gbreve racute -10 +KPX gbreve rcaron -10 +KPX gbreve rcommaaccent -10 +KPX gcommaaccent r -10 +KPX gcommaaccent racute -10 +KPX gcommaaccent rcaron -10 +KPX gcommaaccent rcommaaccent -10 +KPX h y -30 +KPX h yacute -30 +KPX h ydieresis -30 +KPX k e -20 +KPX k eacute -20 +KPX k ecaron -20 +KPX k ecircumflex -20 +KPX k edieresis -20 +KPX k edotaccent -20 +KPX k egrave -20 +KPX k emacron -20 +KPX k eogonek -20 +KPX k o -20 +KPX k oacute -20 +KPX k ocircumflex -20 +KPX k odieresis -20 +KPX k ograve -20 +KPX k ohungarumlaut -20 +KPX k omacron -20 +KPX k oslash -20 +KPX k otilde -20 +KPX kcommaaccent e -20 +KPX kcommaaccent eacute -20 +KPX kcommaaccent ecaron -20 +KPX kcommaaccent ecircumflex -20 +KPX kcommaaccent edieresis -20 +KPX kcommaaccent edotaccent -20 +KPX kcommaaccent egrave -20 +KPX kcommaaccent emacron -20 +KPX kcommaaccent eogonek -20 +KPX kcommaaccent o -20 +KPX kcommaaccent oacute -20 +KPX kcommaaccent ocircumflex -20 +KPX kcommaaccent odieresis -20 +KPX kcommaaccent ograve -20 +KPX kcommaaccent ohungarumlaut -20 +KPX kcommaaccent omacron -20 +KPX kcommaaccent oslash -20 +KPX kcommaaccent otilde -20 +KPX m u -10 +KPX m uacute -10 +KPX m ucircumflex -10 +KPX m udieresis -10 +KPX m ugrave -10 +KPX m uhungarumlaut -10 +KPX m umacron -10 +KPX m uogonek -10 +KPX m uring -10 +KPX m y -15 +KPX m yacute -15 +KPX m ydieresis -15 +KPX n u -10 +KPX n uacute -10 +KPX n ucircumflex -10 +KPX n udieresis -10 +KPX n ugrave -10 +KPX n uhungarumlaut -10 +KPX n umacron -10 +KPX n uogonek -10 +KPX n uring -10 +KPX n v -20 +KPX n y -15 +KPX n yacute -15 +KPX n ydieresis -15 +KPX nacute u -10 +KPX nacute uacute -10 +KPX nacute ucircumflex -10 +KPX nacute udieresis -10 +KPX nacute ugrave -10 +KPX nacute uhungarumlaut -10 +KPX nacute umacron -10 +KPX nacute uogonek -10 +KPX nacute uring -10 +KPX nacute v -20 +KPX nacute y -15 +KPX nacute yacute -15 +KPX nacute ydieresis -15 +KPX ncaron u -10 +KPX ncaron uacute -10 +KPX ncaron ucircumflex -10 +KPX ncaron udieresis -10 +KPX ncaron ugrave -10 +KPX ncaron uhungarumlaut -10 +KPX ncaron umacron -10 +KPX ncaron uogonek -10 +KPX ncaron uring -10 +KPX ncaron v -20 +KPX ncaron y -15 +KPX ncaron yacute -15 +KPX ncaron ydieresis -15 +KPX ncommaaccent u -10 +KPX ncommaaccent uacute -10 +KPX ncommaaccent ucircumflex -10 +KPX ncommaaccent udieresis -10 +KPX ncommaaccent ugrave -10 +KPX ncommaaccent uhungarumlaut -10 +KPX ncommaaccent umacron -10 +KPX ncommaaccent uogonek -10 +KPX ncommaaccent uring -10 +KPX ncommaaccent v -20 +KPX ncommaaccent y -15 +KPX ncommaaccent yacute -15 +KPX ncommaaccent ydieresis -15 +KPX ntilde u -10 +KPX ntilde uacute -10 +KPX ntilde ucircumflex -10 +KPX ntilde udieresis -10 +KPX ntilde ugrave -10 +KPX ntilde uhungarumlaut -10 +KPX ntilde umacron -10 +KPX ntilde uogonek -10 +KPX ntilde uring -10 +KPX ntilde v -20 +KPX ntilde y -15 +KPX ntilde yacute -15 +KPX ntilde ydieresis -15 +KPX o comma -40 +KPX o period -40 +KPX o v -15 +KPX o w -15 +KPX o x -30 +KPX o y -30 +KPX o yacute -30 +KPX o ydieresis -30 +KPX oacute comma -40 +KPX oacute period -40 +KPX oacute v -15 +KPX oacute w -15 +KPX oacute x -30 +KPX oacute y -30 +KPX oacute yacute -30 +KPX oacute ydieresis -30 +KPX ocircumflex comma -40 +KPX ocircumflex period -40 +KPX ocircumflex v -15 +KPX ocircumflex w -15 +KPX ocircumflex x -30 +KPX ocircumflex y -30 +KPX ocircumflex yacute -30 +KPX ocircumflex ydieresis -30 +KPX odieresis comma -40 +KPX odieresis period -40 +KPX odieresis v -15 +KPX odieresis w -15 +KPX odieresis x -30 +KPX odieresis y -30 +KPX odieresis yacute -30 +KPX odieresis ydieresis -30 +KPX ograve comma -40 +KPX ograve period -40 +KPX ograve v -15 +KPX ograve w -15 +KPX ograve x -30 +KPX ograve y -30 +KPX ograve yacute -30 +KPX ograve ydieresis -30 +KPX ohungarumlaut comma -40 +KPX ohungarumlaut period -40 +KPX ohungarumlaut v -15 +KPX ohungarumlaut w -15 +KPX ohungarumlaut x -30 +KPX ohungarumlaut y -30 +KPX ohungarumlaut yacute -30 +KPX ohungarumlaut ydieresis -30 +KPX omacron comma -40 +KPX omacron period -40 +KPX omacron v -15 +KPX omacron w -15 +KPX omacron x -30 +KPX omacron y -30 +KPX omacron yacute -30 +KPX omacron ydieresis -30 +KPX oslash a -55 +KPX oslash aacute -55 +KPX oslash abreve -55 +KPX oslash acircumflex -55 +KPX oslash adieresis -55 +KPX oslash agrave -55 +KPX oslash amacron -55 +KPX oslash aogonek -55 +KPX oslash aring -55 +KPX oslash atilde -55 +KPX oslash b -55 +KPX oslash c -55 +KPX oslash cacute -55 +KPX oslash ccaron -55 +KPX oslash ccedilla -55 +KPX oslash comma -95 +KPX oslash d -55 +KPX oslash dcroat -55 +KPX oslash e -55 +KPX oslash eacute -55 +KPX oslash ecaron -55 +KPX oslash ecircumflex -55 +KPX oslash edieresis -55 +KPX oslash edotaccent -55 +KPX oslash egrave -55 +KPX oslash emacron -55 +KPX oslash eogonek -55 +KPX oslash f -55 +KPX oslash g -55 +KPX oslash gbreve -55 +KPX oslash gcommaaccent -55 +KPX oslash h -55 +KPX oslash i -55 +KPX oslash iacute -55 +KPX oslash icircumflex -55 +KPX oslash idieresis -55 +KPX oslash igrave -55 +KPX oslash imacron -55 +KPX oslash iogonek -55 +KPX oslash j -55 +KPX oslash k -55 +KPX oslash kcommaaccent -55 +KPX oslash l -55 +KPX oslash lacute -55 +KPX oslash lcommaaccent -55 +KPX oslash lslash -55 +KPX oslash m -55 +KPX oslash n -55 +KPX oslash nacute -55 +KPX oslash ncaron -55 +KPX oslash ncommaaccent -55 +KPX oslash ntilde -55 +KPX oslash o -55 +KPX oslash oacute -55 +KPX oslash ocircumflex -55 +KPX oslash odieresis -55 +KPX oslash ograve -55 +KPX oslash ohungarumlaut -55 +KPX oslash omacron -55 +KPX oslash oslash -55 +KPX oslash otilde -55 +KPX oslash p -55 +KPX oslash period -95 +KPX oslash q -55 +KPX oslash r -55 +KPX oslash racute -55 +KPX oslash rcaron -55 +KPX oslash rcommaaccent -55 +KPX oslash s -55 +KPX oslash sacute -55 +KPX oslash scaron -55 +KPX oslash scedilla -55 +KPX oslash scommaaccent -55 +KPX oslash t -55 +KPX oslash tcommaaccent -55 +KPX oslash u -55 +KPX oslash uacute -55 +KPX oslash ucircumflex -55 +KPX oslash udieresis -55 +KPX oslash ugrave -55 +KPX oslash uhungarumlaut -55 +KPX oslash umacron -55 +KPX oslash uogonek -55 +KPX oslash uring -55 +KPX oslash v -70 +KPX oslash w -70 +KPX oslash x -85 +KPX oslash y -70 +KPX oslash yacute -70 +KPX oslash ydieresis -70 +KPX oslash z -55 +KPX oslash zacute -55 +KPX oslash zcaron -55 +KPX oslash zdotaccent -55 +KPX otilde comma -40 +KPX otilde period -40 +KPX otilde v -15 +KPX otilde w -15 +KPX otilde x -30 +KPX otilde y -30 +KPX otilde yacute -30 +KPX otilde ydieresis -30 +KPX p comma -35 +KPX p period -35 +KPX p y -30 +KPX p yacute -30 +KPX p ydieresis -30 +KPX period quotedblright -100 +KPX period quoteright -100 +KPX period space -60 +KPX quotedblright space -40 +KPX quoteleft quoteleft -57 +KPX quoteright d -50 +KPX quoteright dcroat -50 +KPX quoteright quoteright -57 +KPX quoteright r -50 +KPX quoteright racute -50 +KPX quoteright rcaron -50 +KPX quoteright rcommaaccent -50 +KPX quoteright s -50 +KPX quoteright sacute -50 +KPX quoteright scaron -50 +KPX quoteright scedilla -50 +KPX quoteright scommaaccent -50 +KPX quoteright space -70 +KPX r a -10 +KPX r aacute -10 +KPX r abreve -10 +KPX r acircumflex -10 +KPX r adieresis -10 +KPX r agrave -10 +KPX r amacron -10 +KPX r aogonek -10 +KPX r aring -10 +KPX r atilde -10 +KPX r colon 30 +KPX r comma -50 +KPX r i 15 +KPX r iacute 15 +KPX r icircumflex 15 +KPX r idieresis 15 +KPX r igrave 15 +KPX r imacron 15 +KPX r iogonek 15 +KPX r k 15 +KPX r kcommaaccent 15 +KPX r l 15 +KPX r lacute 15 +KPX r lcommaaccent 15 +KPX r lslash 15 +KPX r m 25 +KPX r n 25 +KPX r nacute 25 +KPX r ncaron 25 +KPX r ncommaaccent 25 +KPX r ntilde 25 +KPX r p 30 +KPX r period -50 +KPX r semicolon 30 +KPX r t 40 +KPX r tcommaaccent 40 +KPX r u 15 +KPX r uacute 15 +KPX r ucircumflex 15 +KPX r udieresis 15 +KPX r ugrave 15 +KPX r uhungarumlaut 15 +KPX r umacron 15 +KPX r uogonek 15 +KPX r uring 15 +KPX r v 30 +KPX r y 30 +KPX r yacute 30 +KPX r ydieresis 30 +KPX racute a -10 +KPX racute aacute -10 +KPX racute abreve -10 +KPX racute acircumflex -10 +KPX racute adieresis -10 +KPX racute agrave -10 +KPX racute amacron -10 +KPX racute aogonek -10 +KPX racute aring -10 +KPX racute atilde -10 +KPX racute colon 30 +KPX racute comma -50 +KPX racute i 15 +KPX racute iacute 15 +KPX racute icircumflex 15 +KPX racute idieresis 15 +KPX racute igrave 15 +KPX racute imacron 15 +KPX racute iogonek 15 +KPX racute k 15 +KPX racute kcommaaccent 15 +KPX racute l 15 +KPX racute lacute 15 +KPX racute lcommaaccent 15 +KPX racute lslash 15 +KPX racute m 25 +KPX racute n 25 +KPX racute nacute 25 +KPX racute ncaron 25 +KPX racute ncommaaccent 25 +KPX racute ntilde 25 +KPX racute p 30 +KPX racute period -50 +KPX racute semicolon 30 +KPX racute t 40 +KPX racute tcommaaccent 40 +KPX racute u 15 +KPX racute uacute 15 +KPX racute ucircumflex 15 +KPX racute udieresis 15 +KPX racute ugrave 15 +KPX racute uhungarumlaut 15 +KPX racute umacron 15 +KPX racute uogonek 15 +KPX racute uring 15 +KPX racute v 30 +KPX racute y 30 +KPX racute yacute 30 +KPX racute ydieresis 30 +KPX rcaron a -10 +KPX rcaron aacute -10 +KPX rcaron abreve -10 +KPX rcaron acircumflex -10 +KPX rcaron adieresis -10 +KPX rcaron agrave -10 +KPX rcaron amacron -10 +KPX rcaron aogonek -10 +KPX rcaron aring -10 +KPX rcaron atilde -10 +KPX rcaron colon 30 +KPX rcaron comma -50 +KPX rcaron i 15 +KPX rcaron iacute 15 +KPX rcaron icircumflex 15 +KPX rcaron idieresis 15 +KPX rcaron igrave 15 +KPX rcaron imacron 15 +KPX rcaron iogonek 15 +KPX rcaron k 15 +KPX rcaron kcommaaccent 15 +KPX rcaron l 15 +KPX rcaron lacute 15 +KPX rcaron lcommaaccent 15 +KPX rcaron lslash 15 +KPX rcaron m 25 +KPX rcaron n 25 +KPX rcaron nacute 25 +KPX rcaron ncaron 25 +KPX rcaron ncommaaccent 25 +KPX rcaron ntilde 25 +KPX rcaron p 30 +KPX rcaron period -50 +KPX rcaron semicolon 30 +KPX rcaron t 40 +KPX rcaron tcommaaccent 40 +KPX rcaron u 15 +KPX rcaron uacute 15 +KPX rcaron ucircumflex 15 +KPX rcaron udieresis 15 +KPX rcaron ugrave 15 +KPX rcaron uhungarumlaut 15 +KPX rcaron umacron 15 +KPX rcaron uogonek 15 +KPX rcaron uring 15 +KPX rcaron v 30 +KPX rcaron y 30 +KPX rcaron yacute 30 +KPX rcaron ydieresis 30 +KPX rcommaaccent a -10 +KPX rcommaaccent aacute -10 +KPX rcommaaccent abreve -10 +KPX rcommaaccent acircumflex -10 +KPX rcommaaccent adieresis -10 +KPX rcommaaccent agrave -10 +KPX rcommaaccent amacron -10 +KPX rcommaaccent aogonek -10 +KPX rcommaaccent aring -10 +KPX rcommaaccent atilde -10 +KPX rcommaaccent colon 30 +KPX rcommaaccent comma -50 +KPX rcommaaccent i 15 +KPX rcommaaccent iacute 15 +KPX rcommaaccent icircumflex 15 +KPX rcommaaccent idieresis 15 +KPX rcommaaccent igrave 15 +KPX rcommaaccent imacron 15 +KPX rcommaaccent iogonek 15 +KPX rcommaaccent k 15 +KPX rcommaaccent kcommaaccent 15 +KPX rcommaaccent l 15 +KPX rcommaaccent lacute 15 +KPX rcommaaccent lcommaaccent 15 +KPX rcommaaccent lslash 15 +KPX rcommaaccent m 25 +KPX rcommaaccent n 25 +KPX rcommaaccent nacute 25 +KPX rcommaaccent ncaron 25 +KPX rcommaaccent ncommaaccent 25 +KPX rcommaaccent ntilde 25 +KPX rcommaaccent p 30 +KPX rcommaaccent period -50 +KPX rcommaaccent semicolon 30 +KPX rcommaaccent t 40 +KPX rcommaaccent tcommaaccent 40 +KPX rcommaaccent u 15 +KPX rcommaaccent uacute 15 +KPX rcommaaccent ucircumflex 15 +KPX rcommaaccent udieresis 15 +KPX rcommaaccent ugrave 15 +KPX rcommaaccent uhungarumlaut 15 +KPX rcommaaccent umacron 15 +KPX rcommaaccent uogonek 15 +KPX rcommaaccent uring 15 +KPX rcommaaccent v 30 +KPX rcommaaccent y 30 +KPX rcommaaccent yacute 30 +KPX rcommaaccent ydieresis 30 +KPX s comma -15 +KPX s period -15 +KPX s w -30 +KPX sacute comma -15 +KPX sacute period -15 +KPX sacute w -30 +KPX scaron comma -15 +KPX scaron period -15 +KPX scaron w -30 +KPX scedilla comma -15 +KPX scedilla period -15 +KPX scedilla w -30 +KPX scommaaccent comma -15 +KPX scommaaccent period -15 +KPX scommaaccent w -30 +KPX semicolon space -50 +KPX space T -50 +KPX space Tcaron -50 +KPX space Tcommaaccent -50 +KPX space V -50 +KPX space W -40 +KPX space Y -90 +KPX space Yacute -90 +KPX space Ydieresis -90 +KPX space quotedblleft -30 +KPX space quoteleft -60 +KPX v a -25 +KPX v aacute -25 +KPX v abreve -25 +KPX v acircumflex -25 +KPX v adieresis -25 +KPX v agrave -25 +KPX v amacron -25 +KPX v aogonek -25 +KPX v aring -25 +KPX v atilde -25 +KPX v comma -80 +KPX v e -25 +KPX v eacute -25 +KPX v ecaron -25 +KPX v ecircumflex -25 +KPX v edieresis -25 +KPX v edotaccent -25 +KPX v egrave -25 +KPX v emacron -25 +KPX v eogonek -25 +KPX v o -25 +KPX v oacute -25 +KPX v ocircumflex -25 +KPX v odieresis -25 +KPX v ograve -25 +KPX v ohungarumlaut -25 +KPX v omacron -25 +KPX v oslash -25 +KPX v otilde -25 +KPX v period -80 +KPX w a -15 +KPX w aacute -15 +KPX w abreve -15 +KPX w acircumflex -15 +KPX w adieresis -15 +KPX w agrave -15 +KPX w amacron -15 +KPX w aogonek -15 +KPX w aring -15 +KPX w atilde -15 +KPX w comma -60 +KPX w e -10 +KPX w eacute -10 +KPX w ecaron -10 +KPX w ecircumflex -10 +KPX w edieresis -10 +KPX w edotaccent -10 +KPX w egrave -10 +KPX w emacron -10 +KPX w eogonek -10 +KPX w o -10 +KPX w oacute -10 +KPX w ocircumflex -10 +KPX w odieresis -10 +KPX w ograve -10 +KPX w ohungarumlaut -10 +KPX w omacron -10 +KPX w oslash -10 +KPX w otilde -10 +KPX w period -60 +KPX x e -30 +KPX x eacute -30 +KPX x ecaron -30 +KPX x ecircumflex -30 +KPX x edieresis -30 +KPX x edotaccent -30 +KPX x egrave -30 +KPX x emacron -30 +KPX x eogonek -30 +KPX y a -20 +KPX y aacute -20 +KPX y abreve -20 +KPX y acircumflex -20 +KPX y adieresis -20 +KPX y agrave -20 +KPX y amacron -20 +KPX y aogonek -20 +KPX y aring -20 +KPX y atilde -20 +KPX y comma -100 +KPX y e -20 +KPX y eacute -20 +KPX y ecaron -20 +KPX y ecircumflex -20 +KPX y edieresis -20 +KPX y edotaccent -20 +KPX y egrave -20 +KPX y emacron -20 +KPX y eogonek -20 +KPX y o -20 +KPX y oacute -20 +KPX y ocircumflex -20 +KPX y odieresis -20 +KPX y ograve -20 +KPX y ohungarumlaut -20 +KPX y omacron -20 +KPX y oslash -20 +KPX y otilde -20 +KPX y period -100 +KPX yacute a -20 +KPX yacute aacute -20 +KPX yacute abreve -20 +KPX yacute acircumflex -20 +KPX yacute adieresis -20 +KPX yacute agrave -20 +KPX yacute amacron -20 +KPX yacute aogonek -20 +KPX yacute aring -20 +KPX yacute atilde -20 +KPX yacute comma -100 +KPX yacute e -20 +KPX yacute eacute -20 +KPX yacute ecaron -20 +KPX yacute ecircumflex -20 +KPX yacute edieresis -20 +KPX yacute edotaccent -20 +KPX yacute egrave -20 +KPX yacute emacron -20 +KPX yacute eogonek -20 +KPX yacute o -20 +KPX yacute oacute -20 +KPX yacute ocircumflex -20 +KPX yacute odieresis -20 +KPX yacute ograve -20 +KPX yacute ohungarumlaut -20 +KPX yacute omacron -20 +KPX yacute oslash -20 +KPX yacute otilde -20 +KPX yacute period -100 +KPX ydieresis a -20 +KPX ydieresis aacute -20 +KPX ydieresis abreve -20 +KPX ydieresis acircumflex -20 +KPX ydieresis adieresis -20 +KPX ydieresis agrave -20 +KPX ydieresis amacron -20 +KPX ydieresis aogonek -20 +KPX ydieresis aring -20 +KPX ydieresis atilde -20 +KPX ydieresis comma -100 +KPX ydieresis e -20 +KPX ydieresis eacute -20 +KPX ydieresis ecaron -20 +KPX ydieresis ecircumflex -20 +KPX ydieresis edieresis -20 +KPX ydieresis edotaccent -20 +KPX ydieresis egrave -20 +KPX ydieresis emacron -20 +KPX ydieresis eogonek -20 +KPX ydieresis o -20 +KPX ydieresis oacute -20 +KPX ydieresis ocircumflex -20 +KPX ydieresis odieresis -20 +KPX ydieresis ograve -20 +KPX ydieresis ohungarumlaut -20 +KPX ydieresis omacron -20 +KPX ydieresis oslash -20 +KPX ydieresis otilde -20 +KPX ydieresis period -100 +KPX z e -15 +KPX z eacute -15 +KPX z ecaron -15 +KPX z ecircumflex -15 +KPX z edieresis -15 +KPX z edotaccent -15 +KPX z egrave -15 +KPX z emacron -15 +KPX z eogonek -15 +KPX z o -15 +KPX z oacute -15 +KPX z ocircumflex -15 +KPX z odieresis -15 +KPX z ograve -15 +KPX z ohungarumlaut -15 +KPX z omacron -15 +KPX z oslash -15 +KPX z otilde -15 +KPX zacute e -15 +KPX zacute eacute -15 +KPX zacute ecaron -15 +KPX zacute ecircumflex -15 +KPX zacute edieresis -15 +KPX zacute edotaccent -15 +KPX zacute egrave -15 +KPX zacute emacron -15 +KPX zacute eogonek -15 +KPX zacute o -15 +KPX zacute oacute -15 +KPX zacute ocircumflex -15 +KPX zacute odieresis -15 +KPX zacute ograve -15 +KPX zacute ohungarumlaut -15 +KPX zacute omacron -15 +KPX zacute oslash -15 +KPX zacute otilde -15 +KPX zcaron e -15 +KPX zcaron eacute -15 +KPX zcaron ecaron -15 +KPX zcaron ecircumflex -15 +KPX zcaron edieresis -15 +KPX zcaron edotaccent -15 +KPX zcaron egrave -15 +KPX zcaron emacron -15 +KPX zcaron eogonek -15 +KPX zcaron o -15 +KPX zcaron oacute -15 +KPX zcaron ocircumflex -15 +KPX zcaron odieresis -15 +KPX zcaron ograve -15 +KPX zcaron ohungarumlaut -15 +KPX zcaron omacron -15 +KPX zcaron oslash -15 +KPX zcaron otilde -15 +KPX zdotaccent e -15 +KPX zdotaccent eacute -15 +KPX zdotaccent ecaron -15 +KPX zdotaccent ecircumflex -15 +KPX zdotaccent edieresis -15 +KPX zdotaccent edotaccent -15 +KPX zdotaccent egrave -15 +KPX zdotaccent emacron -15 +KPX zdotaccent eogonek -15 +KPX zdotaccent o -15 +KPX zdotaccent oacute -15 +KPX zdotaccent ocircumflex -15 +KPX zdotaccent odieresis -15 +KPX zdotaccent ograve -15 +KPX zdotaccent ohungarumlaut -15 +KPX zdotaccent omacron -15 +KPX zdotaccent oslash -15 +KPX zdotaccent otilde -15 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica.afm new file mode 100644 index 00000000..bd32af54 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Helvetica.afm @@ -0,0 +1,3051 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:38:23 1997 +Comment UniqueID 43054 +Comment VMusage 37069 48094 +FontName Helvetica +FullName Helvetica +FamilyName Helvetica +Weight Medium +ItalicAngle 0 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -166 -225 1000 931 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 718 +XHeight 523 +Ascender 718 +Descender -207 +StdHW 76 +StdVW 88 +StartCharMetrics 315 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 90 0 187 718 ; +C 34 ; WX 355 ; N quotedbl ; B 70 463 285 718 ; +C 35 ; WX 556 ; N numbersign ; B 28 0 529 688 ; +C 36 ; WX 556 ; N dollar ; B 32 -115 520 775 ; +C 37 ; WX 889 ; N percent ; B 39 -19 850 703 ; +C 38 ; WX 667 ; N ampersand ; B 44 -15 645 718 ; +C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ; +C 40 ; WX 333 ; N parenleft ; B 68 -207 299 733 ; +C 41 ; WX 333 ; N parenright ; B 34 -207 265 733 ; +C 42 ; WX 389 ; N asterisk ; B 39 431 349 718 ; +C 43 ; WX 584 ; N plus ; B 39 0 545 505 ; +C 44 ; WX 278 ; N comma ; B 87 -147 191 106 ; +C 45 ; WX 333 ; N hyphen ; B 44 232 289 322 ; +C 46 ; WX 278 ; N period ; B 87 0 191 106 ; +C 47 ; WX 278 ; N slash ; B -17 -19 295 737 ; +C 48 ; WX 556 ; N zero ; B 37 -19 519 703 ; +C 49 ; WX 556 ; N one ; B 101 0 359 703 ; +C 50 ; WX 556 ; N two ; B 26 0 507 703 ; +C 51 ; WX 556 ; N three ; B 34 -19 522 703 ; +C 52 ; WX 556 ; N four ; B 25 0 523 703 ; +C 53 ; WX 556 ; N five ; B 32 -19 514 688 ; +C 54 ; WX 556 ; N six ; B 38 -19 518 703 ; +C 55 ; WX 556 ; N seven ; B 37 0 523 688 ; +C 56 ; WX 556 ; N eight ; B 38 -19 517 703 ; +C 57 ; WX 556 ; N nine ; B 42 -19 514 703 ; +C 58 ; WX 278 ; N colon ; B 87 0 191 516 ; +C 59 ; WX 278 ; N semicolon ; B 87 -147 191 516 ; +C 60 ; WX 584 ; N less ; B 48 11 536 495 ; +C 61 ; WX 584 ; N equal ; B 39 115 545 390 ; +C 62 ; WX 584 ; N greater ; B 48 11 536 495 ; +C 63 ; WX 556 ; N question ; B 56 0 492 727 ; +C 64 ; WX 1015 ; N at ; B 147 -19 868 737 ; +C 65 ; WX 667 ; N A ; B 14 0 654 718 ; +C 66 ; WX 667 ; N B ; B 74 0 627 718 ; +C 67 ; WX 722 ; N C ; B 44 -19 681 737 ; +C 68 ; WX 722 ; N D ; B 81 0 674 718 ; +C 69 ; WX 667 ; N E ; B 86 0 616 718 ; +C 70 ; WX 611 ; N F ; B 86 0 583 718 ; +C 71 ; WX 778 ; N G ; B 48 -19 704 737 ; +C 72 ; WX 722 ; N H ; B 77 0 646 718 ; +C 73 ; WX 278 ; N I ; B 91 0 188 718 ; +C 74 ; WX 500 ; N J ; B 17 -19 428 718 ; +C 75 ; WX 667 ; N K ; B 76 0 663 718 ; +C 76 ; WX 556 ; N L ; B 76 0 537 718 ; +C 77 ; WX 833 ; N M ; B 73 0 761 718 ; +C 78 ; WX 722 ; N N ; B 76 0 646 718 ; +C 79 ; WX 778 ; N O ; B 39 -19 739 737 ; +C 80 ; WX 667 ; N P ; B 86 0 622 718 ; +C 81 ; WX 778 ; N Q ; B 39 -56 739 737 ; +C 82 ; WX 722 ; N R ; B 88 0 684 718 ; +C 83 ; WX 667 ; N S ; B 49 -19 620 737 ; +C 84 ; WX 611 ; N T ; B 14 0 597 718 ; +C 85 ; WX 722 ; N U ; B 79 -19 644 718 ; +C 86 ; WX 667 ; N V ; B 20 0 647 718 ; +C 87 ; WX 944 ; N W ; B 16 0 928 718 ; +C 88 ; WX 667 ; N X ; B 19 0 648 718 ; +C 89 ; WX 667 ; N Y ; B 14 0 653 718 ; +C 90 ; WX 611 ; N Z ; B 23 0 588 718 ; +C 91 ; WX 278 ; N bracketleft ; B 63 -196 250 722 ; +C 92 ; WX 278 ; N backslash ; B -17 -19 295 737 ; +C 93 ; WX 278 ; N bracketright ; B 28 -196 215 722 ; +C 94 ; WX 469 ; N asciicircum ; B -14 264 483 688 ; +C 95 ; WX 556 ; N underscore ; B 0 -125 556 -75 ; +C 96 ; WX 222 ; N quoteleft ; B 65 470 169 725 ; +C 97 ; WX 556 ; N a ; B 36 -15 530 538 ; +C 98 ; WX 556 ; N b ; B 58 -15 517 718 ; +C 99 ; WX 500 ; N c ; B 30 -15 477 538 ; +C 100 ; WX 556 ; N d ; B 35 -15 499 718 ; +C 101 ; WX 556 ; N e ; B 40 -15 516 538 ; +C 102 ; WX 278 ; N f ; B 14 0 262 728 ; L i fi ; L l fl ; +C 103 ; WX 556 ; N g ; B 40 -220 499 538 ; +C 104 ; WX 556 ; N h ; B 65 0 491 718 ; +C 105 ; WX 222 ; N i ; B 67 0 155 718 ; +C 106 ; WX 222 ; N j ; B -16 -210 155 718 ; +C 107 ; WX 500 ; N k ; B 67 0 501 718 ; +C 108 ; WX 222 ; N l ; B 67 0 155 718 ; +C 109 ; WX 833 ; N m ; B 65 0 769 538 ; +C 110 ; WX 556 ; N n ; B 65 0 491 538 ; +C 111 ; WX 556 ; N o ; B 35 -14 521 538 ; +C 112 ; WX 556 ; N p ; B 58 -207 517 538 ; +C 113 ; WX 556 ; N q ; B 35 -207 494 538 ; +C 114 ; WX 333 ; N r ; B 77 0 332 538 ; +C 115 ; WX 500 ; N s ; B 32 -15 464 538 ; +C 116 ; WX 278 ; N t ; B 14 -7 257 669 ; +C 117 ; WX 556 ; N u ; B 68 -15 489 523 ; +C 118 ; WX 500 ; N v ; B 8 0 492 523 ; +C 119 ; WX 722 ; N w ; B 14 0 709 523 ; +C 120 ; WX 500 ; N x ; B 11 0 490 523 ; +C 121 ; WX 500 ; N y ; B 11 -214 489 523 ; +C 122 ; WX 500 ; N z ; B 31 0 469 523 ; +C 123 ; WX 334 ; N braceleft ; B 42 -196 292 722 ; +C 124 ; WX 260 ; N bar ; B 94 -225 167 775 ; +C 125 ; WX 334 ; N braceright ; B 42 -196 292 722 ; +C 126 ; WX 584 ; N asciitilde ; B 61 180 523 326 ; +C 161 ; WX 333 ; N exclamdown ; B 118 -195 215 523 ; +C 162 ; WX 556 ; N cent ; B 51 -115 513 623 ; +C 163 ; WX 556 ; N sterling ; B 33 -16 539 718 ; +C 164 ; WX 167 ; N fraction ; B -166 -19 333 703 ; +C 165 ; WX 556 ; N yen ; B 3 0 553 688 ; +C 166 ; WX 556 ; N florin ; B -11 -207 501 737 ; +C 167 ; WX 556 ; N section ; B 43 -191 512 737 ; +C 168 ; WX 556 ; N currency ; B 28 99 528 603 ; +C 169 ; WX 191 ; N quotesingle ; B 59 463 132 718 ; +C 170 ; WX 333 ; N quotedblleft ; B 38 470 307 725 ; +C 171 ; WX 556 ; N guillemotleft ; B 97 108 459 446 ; +C 172 ; WX 333 ; N guilsinglleft ; B 88 108 245 446 ; +C 173 ; WX 333 ; N guilsinglright ; B 88 108 245 446 ; +C 174 ; WX 500 ; N fi ; B 14 0 434 728 ; +C 175 ; WX 500 ; N fl ; B 14 0 432 728 ; +C 177 ; WX 556 ; N endash ; B 0 240 556 313 ; +C 178 ; WX 556 ; N dagger ; B 43 -159 514 718 ; +C 179 ; WX 556 ; N daggerdbl ; B 43 -159 514 718 ; +C 180 ; WX 278 ; N periodcentered ; B 77 190 202 315 ; +C 182 ; WX 537 ; N paragraph ; B 18 -173 497 718 ; +C 183 ; WX 350 ; N bullet ; B 18 202 333 517 ; +C 184 ; WX 222 ; N quotesinglbase ; B 53 -149 157 106 ; +C 185 ; WX 333 ; N quotedblbase ; B 26 -149 295 106 ; +C 186 ; WX 333 ; N quotedblright ; B 26 463 295 718 ; +C 187 ; WX 556 ; N guillemotright ; B 97 108 459 446 ; +C 188 ; WX 1000 ; N ellipsis ; B 115 0 885 106 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -19 994 703 ; +C 191 ; WX 611 ; N questiondown ; B 91 -201 527 525 ; +C 193 ; WX 333 ; N grave ; B 14 593 211 734 ; +C 194 ; WX 333 ; N acute ; B 122 593 319 734 ; +C 195 ; WX 333 ; N circumflex ; B 21 593 312 734 ; +C 196 ; WX 333 ; N tilde ; B -4 606 337 722 ; +C 197 ; WX 333 ; N macron ; B 10 627 323 684 ; +C 198 ; WX 333 ; N breve ; B 13 595 321 731 ; +C 199 ; WX 333 ; N dotaccent ; B 121 604 212 706 ; +C 200 ; WX 333 ; N dieresis ; B 40 604 293 706 ; +C 202 ; WX 333 ; N ring ; B 75 572 259 756 ; +C 203 ; WX 333 ; N cedilla ; B 45 -225 259 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 31 593 409 734 ; +C 206 ; WX 333 ; N ogonek ; B 73 -225 287 0 ; +C 207 ; WX 333 ; N caron ; B 21 593 312 734 ; +C 208 ; WX 1000 ; N emdash ; B 0 240 1000 313 ; +C 225 ; WX 1000 ; N AE ; B 8 0 951 718 ; +C 227 ; WX 370 ; N ordfeminine ; B 24 405 346 737 ; +C 232 ; WX 556 ; N Lslash ; B -20 0 537 718 ; +C 233 ; WX 778 ; N Oslash ; B 39 -19 740 737 ; +C 234 ; WX 1000 ; N OE ; B 36 -19 965 737 ; +C 235 ; WX 365 ; N ordmasculine ; B 25 405 341 737 ; +C 241 ; WX 889 ; N ae ; B 36 -15 847 538 ; +C 245 ; WX 278 ; N dotlessi ; B 95 0 183 523 ; +C 248 ; WX 222 ; N lslash ; B -20 0 242 718 ; +C 249 ; WX 611 ; N oslash ; B 28 -22 537 545 ; +C 250 ; WX 944 ; N oe ; B 35 -15 902 538 ; +C 251 ; WX 611 ; N germandbls ; B 67 -15 571 728 ; +C -1 ; WX 278 ; N Idieresis ; B 13 0 266 901 ; +C -1 ; WX 556 ; N eacute ; B 40 -15 516 734 ; +C -1 ; WX 556 ; N abreve ; B 36 -15 530 731 ; +C -1 ; WX 556 ; N uhungarumlaut ; B 68 -15 521 734 ; +C -1 ; WX 556 ; N ecaron ; B 40 -15 516 734 ; +C -1 ; WX 667 ; N Ydieresis ; B 14 0 653 901 ; +C -1 ; WX 584 ; N divide ; B 39 -19 545 524 ; +C -1 ; WX 667 ; N Yacute ; B 14 0 653 929 ; +C -1 ; WX 667 ; N Acircumflex ; B 14 0 654 929 ; +C -1 ; WX 556 ; N aacute ; B 36 -15 530 734 ; +C -1 ; WX 722 ; N Ucircumflex ; B 79 -19 644 929 ; +C -1 ; WX 500 ; N yacute ; B 11 -214 489 734 ; +C -1 ; WX 500 ; N scommaaccent ; B 32 -225 464 538 ; +C -1 ; WX 556 ; N ecircumflex ; B 40 -15 516 734 ; +C -1 ; WX 722 ; N Uring ; B 79 -19 644 931 ; +C -1 ; WX 722 ; N Udieresis ; B 79 -19 644 901 ; +C -1 ; WX 556 ; N aogonek ; B 36 -220 547 538 ; +C -1 ; WX 722 ; N Uacute ; B 79 -19 644 929 ; +C -1 ; WX 556 ; N uogonek ; B 68 -225 519 523 ; +C -1 ; WX 667 ; N Edieresis ; B 86 0 616 901 ; +C -1 ; WX 722 ; N Dcroat ; B 0 0 674 718 ; +C -1 ; WX 250 ; N commaaccent ; B 87 -225 181 -40 ; +C -1 ; WX 737 ; N copyright ; B -14 -19 752 737 ; +C -1 ; WX 667 ; N Emacron ; B 86 0 616 879 ; +C -1 ; WX 500 ; N ccaron ; B 30 -15 477 734 ; +C -1 ; WX 556 ; N aring ; B 36 -15 530 756 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 76 -225 646 718 ; +C -1 ; WX 222 ; N lacute ; B 67 0 264 929 ; +C -1 ; WX 556 ; N agrave ; B 36 -15 530 734 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 14 -225 597 718 ; +C -1 ; WX 722 ; N Cacute ; B 44 -19 681 929 ; +C -1 ; WX 556 ; N atilde ; B 36 -15 530 722 ; +C -1 ; WX 667 ; N Edotaccent ; B 86 0 616 901 ; +C -1 ; WX 500 ; N scaron ; B 32 -15 464 734 ; +C -1 ; WX 500 ; N scedilla ; B 32 -225 464 538 ; +C -1 ; WX 278 ; N iacute ; B 95 0 292 734 ; +C -1 ; WX 471 ; N lozenge ; B 10 0 462 728 ; +C -1 ; WX 722 ; N Rcaron ; B 88 0 684 929 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 48 -225 704 737 ; +C -1 ; WX 556 ; N ucircumflex ; B 68 -15 489 734 ; +C -1 ; WX 556 ; N acircumflex ; B 36 -15 530 734 ; +C -1 ; WX 667 ; N Amacron ; B 14 0 654 879 ; +C -1 ; WX 333 ; N rcaron ; B 61 0 352 734 ; +C -1 ; WX 500 ; N ccedilla ; B 30 -225 477 538 ; +C -1 ; WX 611 ; N Zdotaccent ; B 23 0 588 901 ; +C -1 ; WX 667 ; N Thorn ; B 86 0 622 718 ; +C -1 ; WX 778 ; N Omacron ; B 39 -19 739 879 ; +C -1 ; WX 722 ; N Racute ; B 88 0 684 929 ; +C -1 ; WX 667 ; N Sacute ; B 49 -19 620 929 ; +C -1 ; WX 643 ; N dcaron ; B 35 -15 655 718 ; +C -1 ; WX 722 ; N Umacron ; B 79 -19 644 879 ; +C -1 ; WX 556 ; N uring ; B 68 -15 489 756 ; +C -1 ; WX 333 ; N threesuperior ; B 5 270 325 703 ; +C -1 ; WX 778 ; N Ograve ; B 39 -19 739 929 ; +C -1 ; WX 667 ; N Agrave ; B 14 0 654 929 ; +C -1 ; WX 667 ; N Abreve ; B 14 0 654 926 ; +C -1 ; WX 584 ; N multiply ; B 39 0 545 506 ; +C -1 ; WX 556 ; N uacute ; B 68 -15 489 734 ; +C -1 ; WX 611 ; N Tcaron ; B 14 0 597 929 ; +C -1 ; WX 476 ; N partialdiff ; B 13 -38 463 714 ; +C -1 ; WX 500 ; N ydieresis ; B 11 -214 489 706 ; +C -1 ; WX 722 ; N Nacute ; B 76 0 646 929 ; +C -1 ; WX 278 ; N icircumflex ; B -6 0 285 734 ; +C -1 ; WX 667 ; N Ecircumflex ; B 86 0 616 929 ; +C -1 ; WX 556 ; N adieresis ; B 36 -15 530 706 ; +C -1 ; WX 556 ; N edieresis ; B 40 -15 516 706 ; +C -1 ; WX 500 ; N cacute ; B 30 -15 477 734 ; +C -1 ; WX 556 ; N nacute ; B 65 0 491 734 ; +C -1 ; WX 556 ; N umacron ; B 68 -15 489 684 ; +C -1 ; WX 722 ; N Ncaron ; B 76 0 646 929 ; +C -1 ; WX 278 ; N Iacute ; B 91 0 292 929 ; +C -1 ; WX 584 ; N plusminus ; B 39 0 545 506 ; +C -1 ; WX 260 ; N brokenbar ; B 94 -150 167 700 ; +C -1 ; WX 737 ; N registered ; B -14 -19 752 737 ; +C -1 ; WX 778 ; N Gbreve ; B 48 -19 704 926 ; +C -1 ; WX 278 ; N Idotaccent ; B 91 0 188 901 ; +C -1 ; WX 600 ; N summation ; B 15 -10 586 706 ; +C -1 ; WX 667 ; N Egrave ; B 86 0 616 929 ; +C -1 ; WX 333 ; N racute ; B 77 0 332 734 ; +C -1 ; WX 556 ; N omacron ; B 35 -14 521 684 ; +C -1 ; WX 611 ; N Zacute ; B 23 0 588 929 ; +C -1 ; WX 611 ; N Zcaron ; B 23 0 588 929 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 674 ; +C -1 ; WX 722 ; N Eth ; B 0 0 674 718 ; +C -1 ; WX 722 ; N Ccedilla ; B 44 -225 681 737 ; +C -1 ; WX 222 ; N lcommaaccent ; B 67 -225 167 718 ; +C -1 ; WX 317 ; N tcaron ; B 14 -7 329 808 ; +C -1 ; WX 556 ; N eogonek ; B 40 -225 516 538 ; +C -1 ; WX 722 ; N Uogonek ; B 79 -225 644 718 ; +C -1 ; WX 667 ; N Aacute ; B 14 0 654 929 ; +C -1 ; WX 667 ; N Adieresis ; B 14 0 654 901 ; +C -1 ; WX 556 ; N egrave ; B 40 -15 516 734 ; +C -1 ; WX 500 ; N zacute ; B 31 0 469 734 ; +C -1 ; WX 222 ; N iogonek ; B -31 -225 183 718 ; +C -1 ; WX 778 ; N Oacute ; B 39 -19 739 929 ; +C -1 ; WX 556 ; N oacute ; B 35 -14 521 734 ; +C -1 ; WX 556 ; N amacron ; B 36 -15 530 684 ; +C -1 ; WX 500 ; N sacute ; B 32 -15 464 734 ; +C -1 ; WX 278 ; N idieresis ; B 13 0 266 706 ; +C -1 ; WX 778 ; N Ocircumflex ; B 39 -19 739 929 ; +C -1 ; WX 722 ; N Ugrave ; B 79 -19 644 929 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 556 ; N thorn ; B 58 -207 517 718 ; +C -1 ; WX 333 ; N twosuperior ; B 4 281 323 703 ; +C -1 ; WX 778 ; N Odieresis ; B 39 -19 739 901 ; +C -1 ; WX 556 ; N mu ; B 68 -207 489 523 ; +C -1 ; WX 278 ; N igrave ; B -13 0 184 734 ; +C -1 ; WX 556 ; N ohungarumlaut ; B 35 -14 521 734 ; +C -1 ; WX 667 ; N Eogonek ; B 86 -220 633 718 ; +C -1 ; WX 556 ; N dcroat ; B 35 -15 550 718 ; +C -1 ; WX 834 ; N threequarters ; B 45 -19 810 703 ; +C -1 ; WX 667 ; N Scedilla ; B 49 -225 620 737 ; +C -1 ; WX 299 ; N lcaron ; B 67 0 311 718 ; +C -1 ; WX 667 ; N Kcommaaccent ; B 76 -225 663 718 ; +C -1 ; WX 556 ; N Lacute ; B 76 0 537 929 ; +C -1 ; WX 1000 ; N trademark ; B 46 306 903 718 ; +C -1 ; WX 556 ; N edotaccent ; B 40 -15 516 706 ; +C -1 ; WX 278 ; N Igrave ; B -13 0 188 929 ; +C -1 ; WX 278 ; N Imacron ; B -17 0 296 879 ; +C -1 ; WX 556 ; N Lcaron ; B 76 0 537 718 ; +C -1 ; WX 834 ; N onehalf ; B 43 -19 773 703 ; +C -1 ; WX 549 ; N lessequal ; B 26 0 523 674 ; +C -1 ; WX 556 ; N ocircumflex ; B 35 -14 521 734 ; +C -1 ; WX 556 ; N ntilde ; B 65 0 491 722 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 79 -19 644 929 ; +C -1 ; WX 667 ; N Eacute ; B 86 0 616 929 ; +C -1 ; WX 556 ; N emacron ; B 40 -15 516 684 ; +C -1 ; WX 556 ; N gbreve ; B 40 -220 499 731 ; +C -1 ; WX 834 ; N onequarter ; B 73 -19 756 703 ; +C -1 ; WX 667 ; N Scaron ; B 49 -19 620 929 ; +C -1 ; WX 667 ; N Scommaaccent ; B 49 -225 620 737 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 39 -19 739 929 ; +C -1 ; WX 400 ; N degree ; B 54 411 346 703 ; +C -1 ; WX 556 ; N ograve ; B 35 -14 521 734 ; +C -1 ; WX 722 ; N Ccaron ; B 44 -19 681 929 ; +C -1 ; WX 556 ; N ugrave ; B 68 -15 489 734 ; +C -1 ; WX 453 ; N radical ; B -4 -80 458 762 ; +C -1 ; WX 722 ; N Dcaron ; B 81 0 674 929 ; +C -1 ; WX 333 ; N rcommaaccent ; B 77 -225 332 538 ; +C -1 ; WX 722 ; N Ntilde ; B 76 0 646 917 ; +C -1 ; WX 556 ; N otilde ; B 35 -14 521 722 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 88 -225 684 718 ; +C -1 ; WX 556 ; N Lcommaaccent ; B 76 -225 537 718 ; +C -1 ; WX 667 ; N Atilde ; B 14 0 654 917 ; +C -1 ; WX 667 ; N Aogonek ; B 14 -225 654 718 ; +C -1 ; WX 667 ; N Aring ; B 14 0 654 931 ; +C -1 ; WX 778 ; N Otilde ; B 39 -19 739 917 ; +C -1 ; WX 500 ; N zdotaccent ; B 31 0 469 706 ; +C -1 ; WX 667 ; N Ecaron ; B 86 0 616 929 ; +C -1 ; WX 278 ; N Iogonek ; B -3 -225 211 718 ; +C -1 ; WX 500 ; N kcommaaccent ; B 67 -225 501 718 ; +C -1 ; WX 584 ; N minus ; B 39 216 545 289 ; +C -1 ; WX 278 ; N Icircumflex ; B -6 0 285 929 ; +C -1 ; WX 556 ; N ncaron ; B 65 0 491 734 ; +C -1 ; WX 278 ; N tcommaaccent ; B 14 -225 257 669 ; +C -1 ; WX 584 ; N logicalnot ; B 39 108 545 390 ; +C -1 ; WX 556 ; N odieresis ; B 35 -14 521 706 ; +C -1 ; WX 556 ; N udieresis ; B 68 -15 489 706 ; +C -1 ; WX 549 ; N notequal ; B 12 -35 537 551 ; +C -1 ; WX 556 ; N gcommaaccent ; B 40 -220 499 822 ; +C -1 ; WX 556 ; N eth ; B 35 -15 522 737 ; +C -1 ; WX 500 ; N zcaron ; B 31 0 469 734 ; +C -1 ; WX 556 ; N ncommaaccent ; B 65 -225 491 538 ; +C -1 ; WX 333 ; N onesuperior ; B 43 281 222 703 ; +C -1 ; WX 278 ; N imacron ; B 5 0 272 684 ; +C -1 ; WX 556 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2705 +KPX A C -30 +KPX A Cacute -30 +KPX A Ccaron -30 +KPX A Ccedilla -30 +KPX A G -30 +KPX A Gbreve -30 +KPX A Gcommaaccent -30 +KPX A O -30 +KPX A Oacute -30 +KPX A Ocircumflex -30 +KPX A Odieresis -30 +KPX A Ograve -30 +KPX A Ohungarumlaut -30 +KPX A Omacron -30 +KPX A Oslash -30 +KPX A Otilde -30 +KPX A Q -30 +KPX A T -120 +KPX A Tcaron -120 +KPX A Tcommaaccent -120 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -70 +KPX A W -50 +KPX A Y -100 +KPX A Yacute -100 +KPX A Ydieresis -100 +KPX A u -30 +KPX A uacute -30 +KPX A ucircumflex -30 +KPX A udieresis -30 +KPX A ugrave -30 +KPX A uhungarumlaut -30 +KPX A umacron -30 +KPX A uogonek -30 +KPX A uring -30 +KPX A v -40 +KPX A w -40 +KPX A y -40 +KPX A yacute -40 +KPX A ydieresis -40 +KPX Aacute C -30 +KPX Aacute Cacute -30 +KPX Aacute Ccaron -30 +KPX Aacute Ccedilla -30 +KPX Aacute G -30 +KPX Aacute Gbreve -30 +KPX Aacute Gcommaaccent -30 +KPX Aacute O -30 +KPX Aacute Oacute -30 +KPX Aacute Ocircumflex -30 +KPX Aacute Odieresis -30 +KPX Aacute Ograve -30 +KPX Aacute Ohungarumlaut -30 +KPX Aacute Omacron -30 +KPX Aacute Oslash -30 +KPX Aacute Otilde -30 +KPX Aacute Q -30 +KPX Aacute T -120 +KPX Aacute Tcaron -120 +KPX Aacute Tcommaaccent -120 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -70 +KPX Aacute W -50 +KPX Aacute Y -100 +KPX Aacute Yacute -100 +KPX Aacute Ydieresis -100 +KPX Aacute u -30 +KPX Aacute uacute -30 +KPX Aacute ucircumflex -30 +KPX Aacute udieresis -30 +KPX Aacute ugrave -30 +KPX Aacute uhungarumlaut -30 +KPX Aacute umacron -30 +KPX Aacute uogonek -30 +KPX Aacute uring -30 +KPX Aacute v -40 +KPX Aacute w -40 +KPX Aacute y -40 +KPX Aacute yacute -40 +KPX Aacute ydieresis -40 +KPX Abreve C -30 +KPX Abreve Cacute -30 +KPX Abreve Ccaron -30 +KPX Abreve Ccedilla -30 +KPX Abreve G -30 +KPX Abreve Gbreve -30 +KPX Abreve Gcommaaccent -30 +KPX Abreve O -30 +KPX Abreve Oacute -30 +KPX Abreve Ocircumflex -30 +KPX Abreve Odieresis -30 +KPX Abreve Ograve -30 +KPX Abreve Ohungarumlaut -30 +KPX Abreve Omacron -30 +KPX Abreve Oslash -30 +KPX Abreve Otilde -30 +KPX Abreve Q -30 +KPX Abreve T -120 +KPX Abreve Tcaron -120 +KPX Abreve Tcommaaccent -120 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -70 +KPX Abreve W -50 +KPX Abreve Y -100 +KPX Abreve Yacute -100 +KPX Abreve Ydieresis -100 +KPX Abreve u -30 +KPX Abreve uacute -30 +KPX Abreve ucircumflex -30 +KPX Abreve udieresis -30 +KPX Abreve ugrave -30 +KPX Abreve uhungarumlaut -30 +KPX Abreve umacron -30 +KPX Abreve uogonek -30 +KPX Abreve uring -30 +KPX Abreve v -40 +KPX Abreve w -40 +KPX Abreve y -40 +KPX Abreve yacute -40 +KPX Abreve ydieresis -40 +KPX Acircumflex C -30 +KPX Acircumflex Cacute -30 +KPX Acircumflex Ccaron -30 +KPX Acircumflex Ccedilla -30 +KPX Acircumflex G -30 +KPX Acircumflex Gbreve -30 +KPX Acircumflex Gcommaaccent -30 +KPX Acircumflex O -30 +KPX Acircumflex Oacute -30 +KPX Acircumflex Ocircumflex -30 +KPX Acircumflex Odieresis -30 +KPX Acircumflex Ograve -30 +KPX Acircumflex Ohungarumlaut -30 +KPX Acircumflex Omacron -30 +KPX Acircumflex Oslash -30 +KPX Acircumflex Otilde -30 +KPX Acircumflex Q -30 +KPX Acircumflex T -120 +KPX Acircumflex Tcaron -120 +KPX Acircumflex Tcommaaccent -120 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -70 +KPX Acircumflex W -50 +KPX Acircumflex Y -100 +KPX Acircumflex Yacute -100 +KPX Acircumflex Ydieresis -100 +KPX Acircumflex u -30 +KPX Acircumflex uacute -30 +KPX Acircumflex ucircumflex -30 +KPX Acircumflex udieresis -30 +KPX Acircumflex ugrave -30 +KPX Acircumflex uhungarumlaut -30 +KPX Acircumflex umacron -30 +KPX Acircumflex uogonek -30 +KPX Acircumflex uring -30 +KPX Acircumflex v -40 +KPX Acircumflex w -40 +KPX Acircumflex y -40 +KPX Acircumflex yacute -40 +KPX Acircumflex ydieresis -40 +KPX Adieresis C -30 +KPX Adieresis Cacute -30 +KPX Adieresis Ccaron -30 +KPX Adieresis Ccedilla -30 +KPX Adieresis G -30 +KPX Adieresis Gbreve -30 +KPX Adieresis Gcommaaccent -30 +KPX Adieresis O -30 +KPX Adieresis Oacute -30 +KPX Adieresis Ocircumflex -30 +KPX Adieresis Odieresis -30 +KPX Adieresis Ograve -30 +KPX Adieresis Ohungarumlaut -30 +KPX Adieresis Omacron -30 +KPX Adieresis Oslash -30 +KPX Adieresis Otilde -30 +KPX Adieresis Q -30 +KPX Adieresis T -120 +KPX Adieresis Tcaron -120 +KPX Adieresis Tcommaaccent -120 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -70 +KPX Adieresis W -50 +KPX Adieresis Y -100 +KPX Adieresis Yacute -100 +KPX Adieresis Ydieresis -100 +KPX Adieresis u -30 +KPX Adieresis uacute -30 +KPX Adieresis ucircumflex -30 +KPX Adieresis udieresis -30 +KPX Adieresis ugrave -30 +KPX Adieresis uhungarumlaut -30 +KPX Adieresis umacron -30 +KPX Adieresis uogonek -30 +KPX Adieresis uring -30 +KPX Adieresis v -40 +KPX Adieresis w -40 +KPX Adieresis y -40 +KPX Adieresis yacute -40 +KPX Adieresis ydieresis -40 +KPX Agrave C -30 +KPX Agrave Cacute -30 +KPX Agrave Ccaron -30 +KPX Agrave Ccedilla -30 +KPX Agrave G -30 +KPX Agrave Gbreve -30 +KPX Agrave Gcommaaccent -30 +KPX Agrave O -30 +KPX Agrave Oacute -30 +KPX Agrave Ocircumflex -30 +KPX Agrave Odieresis -30 +KPX Agrave Ograve -30 +KPX Agrave Ohungarumlaut -30 +KPX Agrave Omacron -30 +KPX Agrave Oslash -30 +KPX Agrave Otilde -30 +KPX Agrave Q -30 +KPX Agrave T -120 +KPX Agrave Tcaron -120 +KPX Agrave Tcommaaccent -120 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -70 +KPX Agrave W -50 +KPX Agrave Y -100 +KPX Agrave Yacute -100 +KPX Agrave Ydieresis -100 +KPX Agrave u -30 +KPX Agrave uacute -30 +KPX Agrave ucircumflex -30 +KPX Agrave udieresis -30 +KPX Agrave ugrave -30 +KPX Agrave uhungarumlaut -30 +KPX Agrave umacron -30 +KPX Agrave uogonek -30 +KPX Agrave uring -30 +KPX Agrave v -40 +KPX Agrave w -40 +KPX Agrave y -40 +KPX Agrave yacute -40 +KPX Agrave ydieresis -40 +KPX Amacron C -30 +KPX Amacron Cacute -30 +KPX Amacron Ccaron -30 +KPX Amacron Ccedilla -30 +KPX Amacron G -30 +KPX Amacron Gbreve -30 +KPX Amacron Gcommaaccent -30 +KPX Amacron O -30 +KPX Amacron Oacute -30 +KPX Amacron Ocircumflex -30 +KPX Amacron Odieresis -30 +KPX Amacron Ograve -30 +KPX Amacron Ohungarumlaut -30 +KPX Amacron Omacron -30 +KPX Amacron Oslash -30 +KPX Amacron Otilde -30 +KPX Amacron Q -30 +KPX Amacron T -120 +KPX Amacron Tcaron -120 +KPX Amacron Tcommaaccent -120 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -70 +KPX Amacron W -50 +KPX Amacron Y -100 +KPX Amacron Yacute -100 +KPX Amacron Ydieresis -100 +KPX Amacron u -30 +KPX Amacron uacute -30 +KPX Amacron ucircumflex -30 +KPX Amacron udieresis -30 +KPX Amacron ugrave -30 +KPX Amacron uhungarumlaut -30 +KPX Amacron umacron -30 +KPX Amacron uogonek -30 +KPX Amacron uring -30 +KPX Amacron v -40 +KPX Amacron w -40 +KPX Amacron y -40 +KPX Amacron yacute -40 +KPX Amacron ydieresis -40 +KPX Aogonek C -30 +KPX Aogonek Cacute -30 +KPX Aogonek Ccaron -30 +KPX Aogonek Ccedilla -30 +KPX Aogonek G -30 +KPX Aogonek Gbreve -30 +KPX Aogonek Gcommaaccent -30 +KPX Aogonek O -30 +KPX Aogonek Oacute -30 +KPX Aogonek Ocircumflex -30 +KPX Aogonek Odieresis -30 +KPX Aogonek Ograve -30 +KPX Aogonek Ohungarumlaut -30 +KPX Aogonek Omacron -30 +KPX Aogonek Oslash -30 +KPX Aogonek Otilde -30 +KPX Aogonek Q -30 +KPX Aogonek T -120 +KPX Aogonek Tcaron -120 +KPX Aogonek Tcommaaccent -120 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -70 +KPX Aogonek W -50 +KPX Aogonek Y -100 +KPX Aogonek Yacute -100 +KPX Aogonek Ydieresis -100 +KPX Aogonek u -30 +KPX Aogonek uacute -30 +KPX Aogonek ucircumflex -30 +KPX Aogonek udieresis -30 +KPX Aogonek ugrave -30 +KPX Aogonek uhungarumlaut -30 +KPX Aogonek umacron -30 +KPX Aogonek uogonek -30 +KPX Aogonek uring -30 +KPX Aogonek v -40 +KPX Aogonek w -40 +KPX Aogonek y -40 +KPX Aogonek yacute -40 +KPX Aogonek ydieresis -40 +KPX Aring C -30 +KPX Aring Cacute -30 +KPX Aring Ccaron -30 +KPX Aring Ccedilla -30 +KPX Aring G -30 +KPX Aring Gbreve -30 +KPX Aring Gcommaaccent -30 +KPX Aring O -30 +KPX Aring Oacute -30 +KPX Aring Ocircumflex -30 +KPX Aring Odieresis -30 +KPX Aring Ograve -30 +KPX Aring Ohungarumlaut -30 +KPX Aring Omacron -30 +KPX Aring Oslash -30 +KPX Aring Otilde -30 +KPX Aring Q -30 +KPX Aring T -120 +KPX Aring Tcaron -120 +KPX Aring Tcommaaccent -120 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -70 +KPX Aring W -50 +KPX Aring Y -100 +KPX Aring Yacute -100 +KPX Aring Ydieresis -100 +KPX Aring u -30 +KPX Aring uacute -30 +KPX Aring ucircumflex -30 +KPX Aring udieresis -30 +KPX Aring ugrave -30 +KPX Aring uhungarumlaut -30 +KPX Aring umacron -30 +KPX Aring uogonek -30 +KPX Aring uring -30 +KPX Aring v -40 +KPX Aring w -40 +KPX Aring y -40 +KPX Aring yacute -40 +KPX Aring ydieresis -40 +KPX Atilde C -30 +KPX Atilde Cacute -30 +KPX Atilde Ccaron -30 +KPX Atilde Ccedilla -30 +KPX Atilde G -30 +KPX Atilde Gbreve -30 +KPX Atilde Gcommaaccent -30 +KPX Atilde O -30 +KPX Atilde Oacute -30 +KPX Atilde Ocircumflex -30 +KPX Atilde Odieresis -30 +KPX Atilde Ograve -30 +KPX Atilde Ohungarumlaut -30 +KPX Atilde Omacron -30 +KPX Atilde Oslash -30 +KPX Atilde Otilde -30 +KPX Atilde Q -30 +KPX Atilde T -120 +KPX Atilde Tcaron -120 +KPX Atilde Tcommaaccent -120 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -70 +KPX Atilde W -50 +KPX Atilde Y -100 +KPX Atilde Yacute -100 +KPX Atilde Ydieresis -100 +KPX Atilde u -30 +KPX Atilde uacute -30 +KPX Atilde ucircumflex -30 +KPX Atilde udieresis -30 +KPX Atilde ugrave -30 +KPX Atilde uhungarumlaut -30 +KPX Atilde umacron -30 +KPX Atilde uogonek -30 +KPX Atilde uring -30 +KPX Atilde v -40 +KPX Atilde w -40 +KPX Atilde y -40 +KPX Atilde yacute -40 +KPX Atilde ydieresis -40 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX B comma -20 +KPX B period -20 +KPX C comma -30 +KPX C period -30 +KPX Cacute comma -30 +KPX Cacute period -30 +KPX Ccaron comma -30 +KPX Ccaron period -30 +KPX Ccedilla comma -30 +KPX Ccedilla period -30 +KPX D A -40 +KPX D Aacute -40 +KPX D Abreve -40 +KPX D Acircumflex -40 +KPX D Adieresis -40 +KPX D Agrave -40 +KPX D Amacron -40 +KPX D Aogonek -40 +KPX D Aring -40 +KPX D Atilde -40 +KPX D V -70 +KPX D W -40 +KPX D Y -90 +KPX D Yacute -90 +KPX D Ydieresis -90 +KPX D comma -70 +KPX D period -70 +KPX Dcaron A -40 +KPX Dcaron Aacute -40 +KPX Dcaron Abreve -40 +KPX Dcaron Acircumflex -40 +KPX Dcaron Adieresis -40 +KPX Dcaron Agrave -40 +KPX Dcaron Amacron -40 +KPX Dcaron Aogonek -40 +KPX Dcaron Aring -40 +KPX Dcaron Atilde -40 +KPX Dcaron V -70 +KPX Dcaron W -40 +KPX Dcaron Y -90 +KPX Dcaron Yacute -90 +KPX Dcaron Ydieresis -90 +KPX Dcaron comma -70 +KPX Dcaron period -70 +KPX Dcroat A -40 +KPX Dcroat Aacute -40 +KPX Dcroat Abreve -40 +KPX Dcroat Acircumflex -40 +KPX Dcroat Adieresis -40 +KPX Dcroat Agrave -40 +KPX Dcroat Amacron -40 +KPX Dcroat Aogonek -40 +KPX Dcroat Aring -40 +KPX Dcroat Atilde -40 +KPX Dcroat V -70 +KPX Dcroat W -40 +KPX Dcroat Y -90 +KPX Dcroat Yacute -90 +KPX Dcroat Ydieresis -90 +KPX Dcroat comma -70 +KPX Dcroat period -70 +KPX F A -80 +KPX F Aacute -80 +KPX F Abreve -80 +KPX F Acircumflex -80 +KPX F Adieresis -80 +KPX F Agrave -80 +KPX F Amacron -80 +KPX F Aogonek -80 +KPX F Aring -80 +KPX F Atilde -80 +KPX F a -50 +KPX F aacute -50 +KPX F abreve -50 +KPX F acircumflex -50 +KPX F adieresis -50 +KPX F agrave -50 +KPX F amacron -50 +KPX F aogonek -50 +KPX F aring -50 +KPX F atilde -50 +KPX F comma -150 +KPX F e -30 +KPX F eacute -30 +KPX F ecaron -30 +KPX F ecircumflex -30 +KPX F edieresis -30 +KPX F edotaccent -30 +KPX F egrave -30 +KPX F emacron -30 +KPX F eogonek -30 +KPX F o -30 +KPX F oacute -30 +KPX F ocircumflex -30 +KPX F odieresis -30 +KPX F ograve -30 +KPX F ohungarumlaut -30 +KPX F omacron -30 +KPX F oslash -30 +KPX F otilde -30 +KPX F period -150 +KPX F r -45 +KPX F racute -45 +KPX F rcaron -45 +KPX F rcommaaccent -45 +KPX J A -20 +KPX J Aacute -20 +KPX J Abreve -20 +KPX J Acircumflex -20 +KPX J Adieresis -20 +KPX J Agrave -20 +KPX J Amacron -20 +KPX J Aogonek -20 +KPX J Aring -20 +KPX J Atilde -20 +KPX J a -20 +KPX J aacute -20 +KPX J abreve -20 +KPX J acircumflex -20 +KPX J adieresis -20 +KPX J agrave -20 +KPX J amacron -20 +KPX J aogonek -20 +KPX J aring -20 +KPX J atilde -20 +KPX J comma -30 +KPX J period -30 +KPX J u -20 +KPX J uacute -20 +KPX J ucircumflex -20 +KPX J udieresis -20 +KPX J ugrave -20 +KPX J uhungarumlaut -20 +KPX J umacron -20 +KPX J uogonek -20 +KPX J uring -20 +KPX K O -50 +KPX K Oacute -50 +KPX K Ocircumflex -50 +KPX K Odieresis -50 +KPX K Ograve -50 +KPX K Ohungarumlaut -50 +KPX K Omacron -50 +KPX K Oslash -50 +KPX K Otilde -50 +KPX K e -40 +KPX K eacute -40 +KPX K ecaron -40 +KPX K ecircumflex -40 +KPX K edieresis -40 +KPX K edotaccent -40 +KPX K egrave -40 +KPX K emacron -40 +KPX K eogonek -40 +KPX K o -40 +KPX K oacute -40 +KPX K ocircumflex -40 +KPX K odieresis -40 +KPX K ograve -40 +KPX K ohungarumlaut -40 +KPX K omacron -40 +KPX K oslash -40 +KPX K otilde -40 +KPX K u -30 +KPX K uacute -30 +KPX K ucircumflex -30 +KPX K udieresis -30 +KPX K ugrave -30 +KPX K uhungarumlaut -30 +KPX K umacron -30 +KPX K uogonek -30 +KPX K uring -30 +KPX K y -50 +KPX K yacute -50 +KPX K ydieresis -50 +KPX Kcommaaccent O -50 +KPX Kcommaaccent Oacute -50 +KPX Kcommaaccent Ocircumflex -50 +KPX Kcommaaccent Odieresis -50 +KPX Kcommaaccent Ograve -50 +KPX Kcommaaccent Ohungarumlaut -50 +KPX Kcommaaccent Omacron -50 +KPX Kcommaaccent Oslash -50 +KPX Kcommaaccent Otilde -50 +KPX Kcommaaccent e -40 +KPX Kcommaaccent eacute -40 +KPX Kcommaaccent ecaron -40 +KPX Kcommaaccent ecircumflex -40 +KPX Kcommaaccent edieresis -40 +KPX Kcommaaccent edotaccent -40 +KPX Kcommaaccent egrave -40 +KPX Kcommaaccent emacron -40 +KPX Kcommaaccent eogonek -40 +KPX Kcommaaccent o -40 +KPX Kcommaaccent oacute -40 +KPX Kcommaaccent ocircumflex -40 +KPX Kcommaaccent odieresis -40 +KPX Kcommaaccent ograve -40 +KPX Kcommaaccent ohungarumlaut -40 +KPX Kcommaaccent omacron -40 +KPX Kcommaaccent oslash -40 +KPX Kcommaaccent otilde -40 +KPX Kcommaaccent u -30 +KPX Kcommaaccent uacute -30 +KPX Kcommaaccent ucircumflex -30 +KPX Kcommaaccent udieresis -30 +KPX Kcommaaccent ugrave -30 +KPX Kcommaaccent uhungarumlaut -30 +KPX Kcommaaccent umacron -30 +KPX Kcommaaccent uogonek -30 +KPX Kcommaaccent uring -30 +KPX Kcommaaccent y -50 +KPX Kcommaaccent yacute -50 +KPX Kcommaaccent ydieresis -50 +KPX L T -110 +KPX L Tcaron -110 +KPX L Tcommaaccent -110 +KPX L V -110 +KPX L W -70 +KPX L Y -140 +KPX L Yacute -140 +KPX L Ydieresis -140 +KPX L quotedblright -140 +KPX L quoteright -160 +KPX L y -30 +KPX L yacute -30 +KPX L ydieresis -30 +KPX Lacute T -110 +KPX Lacute Tcaron -110 +KPX Lacute Tcommaaccent -110 +KPX Lacute V -110 +KPX Lacute W -70 +KPX Lacute Y -140 +KPX Lacute Yacute -140 +KPX Lacute Ydieresis -140 +KPX Lacute quotedblright -140 +KPX Lacute quoteright -160 +KPX Lacute y -30 +KPX Lacute yacute -30 +KPX Lacute ydieresis -30 +KPX Lcaron T -110 +KPX Lcaron Tcaron -110 +KPX Lcaron Tcommaaccent -110 +KPX Lcaron V -110 +KPX Lcaron W -70 +KPX Lcaron Y -140 +KPX Lcaron Yacute -140 +KPX Lcaron Ydieresis -140 +KPX Lcaron quotedblright -140 +KPX Lcaron quoteright -160 +KPX Lcaron y -30 +KPX Lcaron yacute -30 +KPX Lcaron ydieresis -30 +KPX Lcommaaccent T -110 +KPX Lcommaaccent Tcaron -110 +KPX Lcommaaccent Tcommaaccent -110 +KPX Lcommaaccent V -110 +KPX Lcommaaccent W -70 +KPX Lcommaaccent Y -140 +KPX Lcommaaccent Yacute -140 +KPX Lcommaaccent Ydieresis -140 +KPX Lcommaaccent quotedblright -140 +KPX Lcommaaccent quoteright -160 +KPX Lcommaaccent y -30 +KPX Lcommaaccent yacute -30 +KPX Lcommaaccent ydieresis -30 +KPX Lslash T -110 +KPX Lslash Tcaron -110 +KPX Lslash Tcommaaccent -110 +KPX Lslash V -110 +KPX Lslash W -70 +KPX Lslash Y -140 +KPX Lslash Yacute -140 +KPX Lslash Ydieresis -140 +KPX Lslash quotedblright -140 +KPX Lslash quoteright -160 +KPX Lslash y -30 +KPX Lslash yacute -30 +KPX Lslash ydieresis -30 +KPX O A -20 +KPX O Aacute -20 +KPX O Abreve -20 +KPX O Acircumflex -20 +KPX O Adieresis -20 +KPX O Agrave -20 +KPX O Amacron -20 +KPX O Aogonek -20 +KPX O Aring -20 +KPX O Atilde -20 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -30 +KPX O X -60 +KPX O Y -70 +KPX O Yacute -70 +KPX O Ydieresis -70 +KPX O comma -40 +KPX O period -40 +KPX Oacute A -20 +KPX Oacute Aacute -20 +KPX Oacute Abreve -20 +KPX Oacute Acircumflex -20 +KPX Oacute Adieresis -20 +KPX Oacute Agrave -20 +KPX Oacute Amacron -20 +KPX Oacute Aogonek -20 +KPX Oacute Aring -20 +KPX Oacute Atilde -20 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -30 +KPX Oacute X -60 +KPX Oacute Y -70 +KPX Oacute Yacute -70 +KPX Oacute Ydieresis -70 +KPX Oacute comma -40 +KPX Oacute period -40 +KPX Ocircumflex A -20 +KPX Ocircumflex Aacute -20 +KPX Ocircumflex Abreve -20 +KPX Ocircumflex Acircumflex -20 +KPX Ocircumflex Adieresis -20 +KPX Ocircumflex Agrave -20 +KPX Ocircumflex Amacron -20 +KPX Ocircumflex Aogonek -20 +KPX Ocircumflex Aring -20 +KPX Ocircumflex Atilde -20 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -30 +KPX Ocircumflex X -60 +KPX Ocircumflex Y -70 +KPX Ocircumflex Yacute -70 +KPX Ocircumflex Ydieresis -70 +KPX Ocircumflex comma -40 +KPX Ocircumflex period -40 +KPX Odieresis A -20 +KPX Odieresis Aacute -20 +KPX Odieresis Abreve -20 +KPX Odieresis Acircumflex -20 +KPX Odieresis Adieresis -20 +KPX Odieresis Agrave -20 +KPX Odieresis Amacron -20 +KPX Odieresis Aogonek -20 +KPX Odieresis Aring -20 +KPX Odieresis Atilde -20 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -30 +KPX Odieresis X -60 +KPX Odieresis Y -70 +KPX Odieresis Yacute -70 +KPX Odieresis Ydieresis -70 +KPX Odieresis comma -40 +KPX Odieresis period -40 +KPX Ograve A -20 +KPX Ograve Aacute -20 +KPX Ograve Abreve -20 +KPX Ograve Acircumflex -20 +KPX Ograve Adieresis -20 +KPX Ograve Agrave -20 +KPX Ograve Amacron -20 +KPX Ograve Aogonek -20 +KPX Ograve Aring -20 +KPX Ograve Atilde -20 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -30 +KPX Ograve X -60 +KPX Ograve Y -70 +KPX Ograve Yacute -70 +KPX Ograve Ydieresis -70 +KPX Ograve comma -40 +KPX Ograve period -40 +KPX Ohungarumlaut A -20 +KPX Ohungarumlaut Aacute -20 +KPX Ohungarumlaut Abreve -20 +KPX Ohungarumlaut Acircumflex -20 +KPX Ohungarumlaut Adieresis -20 +KPX Ohungarumlaut Agrave -20 +KPX Ohungarumlaut Amacron -20 +KPX Ohungarumlaut Aogonek -20 +KPX Ohungarumlaut Aring -20 +KPX Ohungarumlaut Atilde -20 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -30 +KPX Ohungarumlaut X -60 +KPX Ohungarumlaut Y -70 +KPX Ohungarumlaut Yacute -70 +KPX Ohungarumlaut Ydieresis -70 +KPX Ohungarumlaut comma -40 +KPX Ohungarumlaut period -40 +KPX Omacron A -20 +KPX Omacron Aacute -20 +KPX Omacron Abreve -20 +KPX Omacron Acircumflex -20 +KPX Omacron Adieresis -20 +KPX Omacron Agrave -20 +KPX Omacron Amacron -20 +KPX Omacron Aogonek -20 +KPX Omacron Aring -20 +KPX Omacron Atilde -20 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -30 +KPX Omacron X -60 +KPX Omacron Y -70 +KPX Omacron Yacute -70 +KPX Omacron Ydieresis -70 +KPX Omacron comma -40 +KPX Omacron period -40 +KPX Oslash A -20 +KPX Oslash Aacute -20 +KPX Oslash Abreve -20 +KPX Oslash Acircumflex -20 +KPX Oslash Adieresis -20 +KPX Oslash Agrave -20 +KPX Oslash Amacron -20 +KPX Oslash Aogonek -20 +KPX Oslash Aring -20 +KPX Oslash Atilde -20 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -30 +KPX Oslash X -60 +KPX Oslash Y -70 +KPX Oslash Yacute -70 +KPX Oslash Ydieresis -70 +KPX Oslash comma -40 +KPX Oslash period -40 +KPX Otilde A -20 +KPX Otilde Aacute -20 +KPX Otilde Abreve -20 +KPX Otilde Acircumflex -20 +KPX Otilde Adieresis -20 +KPX Otilde Agrave -20 +KPX Otilde Amacron -20 +KPX Otilde Aogonek -20 +KPX Otilde Aring -20 +KPX Otilde Atilde -20 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -30 +KPX Otilde X -60 +KPX Otilde Y -70 +KPX Otilde Yacute -70 +KPX Otilde Ydieresis -70 +KPX Otilde comma -40 +KPX Otilde period -40 +KPX P A -120 +KPX P Aacute -120 +KPX P Abreve -120 +KPX P Acircumflex -120 +KPX P Adieresis -120 +KPX P Agrave -120 +KPX P Amacron -120 +KPX P Aogonek -120 +KPX P Aring -120 +KPX P Atilde -120 +KPX P a -40 +KPX P aacute -40 +KPX P abreve -40 +KPX P acircumflex -40 +KPX P adieresis -40 +KPX P agrave -40 +KPX P amacron -40 +KPX P aogonek -40 +KPX P aring -40 +KPX P atilde -40 +KPX P comma -180 +KPX P e -50 +KPX P eacute -50 +KPX P ecaron -50 +KPX P ecircumflex -50 +KPX P edieresis -50 +KPX P edotaccent -50 +KPX P egrave -50 +KPX P emacron -50 +KPX P eogonek -50 +KPX P o -50 +KPX P oacute -50 +KPX P ocircumflex -50 +KPX P odieresis -50 +KPX P ograve -50 +KPX P ohungarumlaut -50 +KPX P omacron -50 +KPX P oslash -50 +KPX P otilde -50 +KPX P period -180 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX R O -20 +KPX R Oacute -20 +KPX R Ocircumflex -20 +KPX R Odieresis -20 +KPX R Ograve -20 +KPX R Ohungarumlaut -20 +KPX R Omacron -20 +KPX R Oslash -20 +KPX R Otilde -20 +KPX R T -30 +KPX R Tcaron -30 +KPX R Tcommaaccent -30 +KPX R U -40 +KPX R Uacute -40 +KPX R Ucircumflex -40 +KPX R Udieresis -40 +KPX R Ugrave -40 +KPX R Uhungarumlaut -40 +KPX R Umacron -40 +KPX R Uogonek -40 +KPX R Uring -40 +KPX R V -50 +KPX R W -30 +KPX R Y -50 +KPX R Yacute -50 +KPX R Ydieresis -50 +KPX Racute O -20 +KPX Racute Oacute -20 +KPX Racute Ocircumflex -20 +KPX Racute Odieresis -20 +KPX Racute Ograve -20 +KPX Racute Ohungarumlaut -20 +KPX Racute Omacron -20 +KPX Racute Oslash -20 +KPX Racute Otilde -20 +KPX Racute T -30 +KPX Racute Tcaron -30 +KPX Racute Tcommaaccent -30 +KPX Racute U -40 +KPX Racute Uacute -40 +KPX Racute Ucircumflex -40 +KPX Racute Udieresis -40 +KPX Racute Ugrave -40 +KPX Racute Uhungarumlaut -40 +KPX Racute Umacron -40 +KPX Racute Uogonek -40 +KPX Racute Uring -40 +KPX Racute V -50 +KPX Racute W -30 +KPX Racute Y -50 +KPX Racute Yacute -50 +KPX Racute Ydieresis -50 +KPX Rcaron O -20 +KPX Rcaron Oacute -20 +KPX Rcaron Ocircumflex -20 +KPX Rcaron Odieresis -20 +KPX Rcaron Ograve -20 +KPX Rcaron Ohungarumlaut -20 +KPX Rcaron Omacron -20 +KPX Rcaron Oslash -20 +KPX Rcaron Otilde -20 +KPX Rcaron T -30 +KPX Rcaron Tcaron -30 +KPX Rcaron Tcommaaccent -30 +KPX Rcaron U -40 +KPX Rcaron Uacute -40 +KPX Rcaron Ucircumflex -40 +KPX Rcaron Udieresis -40 +KPX Rcaron Ugrave -40 +KPX Rcaron Uhungarumlaut -40 +KPX Rcaron Umacron -40 +KPX Rcaron Uogonek -40 +KPX Rcaron Uring -40 +KPX Rcaron V -50 +KPX Rcaron W -30 +KPX Rcaron Y -50 +KPX Rcaron Yacute -50 +KPX Rcaron Ydieresis -50 +KPX Rcommaaccent O -20 +KPX Rcommaaccent Oacute -20 +KPX Rcommaaccent Ocircumflex -20 +KPX Rcommaaccent Odieresis -20 +KPX Rcommaaccent Ograve -20 +KPX Rcommaaccent Ohungarumlaut -20 +KPX Rcommaaccent Omacron -20 +KPX Rcommaaccent Oslash -20 +KPX Rcommaaccent Otilde -20 +KPX Rcommaaccent T -30 +KPX Rcommaaccent Tcaron -30 +KPX Rcommaaccent Tcommaaccent -30 +KPX Rcommaaccent U -40 +KPX Rcommaaccent Uacute -40 +KPX Rcommaaccent Ucircumflex -40 +KPX Rcommaaccent Udieresis -40 +KPX Rcommaaccent Ugrave -40 +KPX Rcommaaccent Uhungarumlaut -40 +KPX Rcommaaccent Umacron -40 +KPX Rcommaaccent Uogonek -40 +KPX Rcommaaccent Uring -40 +KPX Rcommaaccent V -50 +KPX Rcommaaccent W -30 +KPX Rcommaaccent Y -50 +KPX Rcommaaccent Yacute -50 +KPX Rcommaaccent Ydieresis -50 +KPX S comma -20 +KPX S period -20 +KPX Sacute comma -20 +KPX Sacute period -20 +KPX Scaron comma -20 +KPX Scaron period -20 +KPX Scedilla comma -20 +KPX Scedilla period -20 +KPX Scommaaccent comma -20 +KPX Scommaaccent period -20 +KPX T A -120 +KPX T Aacute -120 +KPX T Abreve -120 +KPX T Acircumflex -120 +KPX T Adieresis -120 +KPX T Agrave -120 +KPX T Amacron -120 +KPX T Aogonek -120 +KPX T Aring -120 +KPX T Atilde -120 +KPX T O -40 +KPX T Oacute -40 +KPX T Ocircumflex -40 +KPX T Odieresis -40 +KPX T Ograve -40 +KPX T Ohungarumlaut -40 +KPX T Omacron -40 +KPX T Oslash -40 +KPX T Otilde -40 +KPX T a -120 +KPX T aacute -120 +KPX T abreve -60 +KPX T acircumflex -120 +KPX T adieresis -120 +KPX T agrave -120 +KPX T amacron -60 +KPX T aogonek -120 +KPX T aring -120 +KPX T atilde -60 +KPX T colon -20 +KPX T comma -120 +KPX T e -120 +KPX T eacute -120 +KPX T ecaron -120 +KPX T ecircumflex -120 +KPX T edieresis -120 +KPX T edotaccent -120 +KPX T egrave -60 +KPX T emacron -60 +KPX T eogonek -120 +KPX T hyphen -140 +KPX T o -120 +KPX T oacute -120 +KPX T ocircumflex -120 +KPX T odieresis -120 +KPX T ograve -120 +KPX T ohungarumlaut -120 +KPX T omacron -60 +KPX T oslash -120 +KPX T otilde -60 +KPX T period -120 +KPX T r -120 +KPX T racute -120 +KPX T rcaron -120 +KPX T rcommaaccent -120 +KPX T semicolon -20 +KPX T u -120 +KPX T uacute -120 +KPX T ucircumflex -120 +KPX T udieresis -120 +KPX T ugrave -120 +KPX T uhungarumlaut -120 +KPX T umacron -60 +KPX T uogonek -120 +KPX T uring -120 +KPX T w -120 +KPX T y -120 +KPX T yacute -120 +KPX T ydieresis -60 +KPX Tcaron A -120 +KPX Tcaron Aacute -120 +KPX Tcaron Abreve -120 +KPX Tcaron Acircumflex -120 +KPX Tcaron Adieresis -120 +KPX Tcaron Agrave -120 +KPX Tcaron Amacron -120 +KPX Tcaron Aogonek -120 +KPX Tcaron Aring -120 +KPX Tcaron Atilde -120 +KPX Tcaron O -40 +KPX Tcaron Oacute -40 +KPX Tcaron Ocircumflex -40 +KPX Tcaron Odieresis -40 +KPX Tcaron Ograve -40 +KPX Tcaron Ohungarumlaut -40 +KPX Tcaron Omacron -40 +KPX Tcaron Oslash -40 +KPX Tcaron Otilde -40 +KPX Tcaron a -120 +KPX Tcaron aacute -120 +KPX Tcaron abreve -60 +KPX Tcaron acircumflex -120 +KPX Tcaron adieresis -120 +KPX Tcaron agrave -120 +KPX Tcaron amacron -60 +KPX Tcaron aogonek -120 +KPX Tcaron aring -120 +KPX Tcaron atilde -60 +KPX Tcaron colon -20 +KPX Tcaron comma -120 +KPX Tcaron e -120 +KPX Tcaron eacute -120 +KPX Tcaron ecaron -120 +KPX Tcaron ecircumflex -120 +KPX Tcaron edieresis -120 +KPX Tcaron edotaccent -120 +KPX Tcaron egrave -60 +KPX Tcaron emacron -60 +KPX Tcaron eogonek -120 +KPX Tcaron hyphen -140 +KPX Tcaron o -120 +KPX Tcaron oacute -120 +KPX Tcaron ocircumflex -120 +KPX Tcaron odieresis -120 +KPX Tcaron ograve -120 +KPX Tcaron ohungarumlaut -120 +KPX Tcaron omacron -60 +KPX Tcaron oslash -120 +KPX Tcaron otilde -60 +KPX Tcaron period -120 +KPX Tcaron r -120 +KPX Tcaron racute -120 +KPX Tcaron rcaron -120 +KPX Tcaron rcommaaccent -120 +KPX Tcaron semicolon -20 +KPX Tcaron u -120 +KPX Tcaron uacute -120 +KPX Tcaron ucircumflex -120 +KPX Tcaron udieresis -120 +KPX Tcaron ugrave -120 +KPX Tcaron uhungarumlaut -120 +KPX Tcaron umacron -60 +KPX Tcaron uogonek -120 +KPX Tcaron uring -120 +KPX Tcaron w -120 +KPX Tcaron y -120 +KPX Tcaron yacute -120 +KPX Tcaron ydieresis -60 +KPX Tcommaaccent A -120 +KPX Tcommaaccent Aacute -120 +KPX Tcommaaccent Abreve -120 +KPX Tcommaaccent Acircumflex -120 +KPX Tcommaaccent Adieresis -120 +KPX Tcommaaccent Agrave -120 +KPX Tcommaaccent Amacron -120 +KPX Tcommaaccent Aogonek -120 +KPX Tcommaaccent Aring -120 +KPX Tcommaaccent Atilde -120 +KPX Tcommaaccent O -40 +KPX Tcommaaccent Oacute -40 +KPX Tcommaaccent Ocircumflex -40 +KPX Tcommaaccent Odieresis -40 +KPX Tcommaaccent Ograve -40 +KPX Tcommaaccent Ohungarumlaut -40 +KPX Tcommaaccent Omacron -40 +KPX Tcommaaccent Oslash -40 +KPX Tcommaaccent Otilde -40 +KPX Tcommaaccent a -120 +KPX Tcommaaccent aacute -120 +KPX Tcommaaccent abreve -60 +KPX Tcommaaccent acircumflex -120 +KPX Tcommaaccent adieresis -120 +KPX Tcommaaccent agrave -120 +KPX Tcommaaccent amacron -60 +KPX Tcommaaccent aogonek -120 +KPX Tcommaaccent aring -120 +KPX Tcommaaccent atilde -60 +KPX Tcommaaccent colon -20 +KPX Tcommaaccent comma -120 +KPX Tcommaaccent e -120 +KPX Tcommaaccent eacute -120 +KPX Tcommaaccent ecaron -120 +KPX Tcommaaccent ecircumflex -120 +KPX Tcommaaccent edieresis -120 +KPX Tcommaaccent edotaccent -120 +KPX Tcommaaccent egrave -60 +KPX Tcommaaccent emacron -60 +KPX Tcommaaccent eogonek -120 +KPX Tcommaaccent hyphen -140 +KPX Tcommaaccent o -120 +KPX Tcommaaccent oacute -120 +KPX Tcommaaccent ocircumflex -120 +KPX Tcommaaccent odieresis -120 +KPX Tcommaaccent ograve -120 +KPX Tcommaaccent ohungarumlaut -120 +KPX Tcommaaccent omacron -60 +KPX Tcommaaccent oslash -120 +KPX Tcommaaccent otilde -60 +KPX Tcommaaccent period -120 +KPX Tcommaaccent r -120 +KPX Tcommaaccent racute -120 +KPX Tcommaaccent rcaron -120 +KPX Tcommaaccent rcommaaccent -120 +KPX Tcommaaccent semicolon -20 +KPX Tcommaaccent u -120 +KPX Tcommaaccent uacute -120 +KPX Tcommaaccent ucircumflex -120 +KPX Tcommaaccent udieresis -120 +KPX Tcommaaccent ugrave -120 +KPX Tcommaaccent uhungarumlaut -120 +KPX Tcommaaccent umacron -60 +KPX Tcommaaccent uogonek -120 +KPX Tcommaaccent uring -120 +KPX Tcommaaccent w -120 +KPX Tcommaaccent y -120 +KPX Tcommaaccent yacute -120 +KPX Tcommaaccent ydieresis -60 +KPX U A -40 +KPX U Aacute -40 +KPX U Abreve -40 +KPX U Acircumflex -40 +KPX U Adieresis -40 +KPX U Agrave -40 +KPX U Amacron -40 +KPX U Aogonek -40 +KPX U Aring -40 +KPX U Atilde -40 +KPX U comma -40 +KPX U period -40 +KPX Uacute A -40 +KPX Uacute Aacute -40 +KPX Uacute Abreve -40 +KPX Uacute Acircumflex -40 +KPX Uacute Adieresis -40 +KPX Uacute Agrave -40 +KPX Uacute Amacron -40 +KPX Uacute Aogonek -40 +KPX Uacute Aring -40 +KPX Uacute Atilde -40 +KPX Uacute comma -40 +KPX Uacute period -40 +KPX Ucircumflex A -40 +KPX Ucircumflex Aacute -40 +KPX Ucircumflex Abreve -40 +KPX Ucircumflex Acircumflex -40 +KPX Ucircumflex Adieresis -40 +KPX Ucircumflex Agrave -40 +KPX Ucircumflex Amacron -40 +KPX Ucircumflex Aogonek -40 +KPX Ucircumflex Aring -40 +KPX Ucircumflex Atilde -40 +KPX Ucircumflex comma -40 +KPX Ucircumflex period -40 +KPX Udieresis A -40 +KPX Udieresis Aacute -40 +KPX Udieresis Abreve -40 +KPX Udieresis Acircumflex -40 +KPX Udieresis Adieresis -40 +KPX Udieresis Agrave -40 +KPX Udieresis Amacron -40 +KPX Udieresis Aogonek -40 +KPX Udieresis Aring -40 +KPX Udieresis Atilde -40 +KPX Udieresis comma -40 +KPX Udieresis period -40 +KPX Ugrave A -40 +KPX Ugrave Aacute -40 +KPX Ugrave Abreve -40 +KPX Ugrave Acircumflex -40 +KPX Ugrave Adieresis -40 +KPX Ugrave Agrave -40 +KPX Ugrave Amacron -40 +KPX Ugrave Aogonek -40 +KPX Ugrave Aring -40 +KPX Ugrave Atilde -40 +KPX Ugrave comma -40 +KPX Ugrave period -40 +KPX Uhungarumlaut A -40 +KPX Uhungarumlaut Aacute -40 +KPX Uhungarumlaut Abreve -40 +KPX Uhungarumlaut Acircumflex -40 +KPX Uhungarumlaut Adieresis -40 +KPX Uhungarumlaut Agrave -40 +KPX Uhungarumlaut Amacron -40 +KPX Uhungarumlaut Aogonek -40 +KPX Uhungarumlaut Aring -40 +KPX Uhungarumlaut Atilde -40 +KPX Uhungarumlaut comma -40 +KPX Uhungarumlaut period -40 +KPX Umacron A -40 +KPX Umacron Aacute -40 +KPX Umacron Abreve -40 +KPX Umacron Acircumflex -40 +KPX Umacron Adieresis -40 +KPX Umacron Agrave -40 +KPX Umacron Amacron -40 +KPX Umacron Aogonek -40 +KPX Umacron Aring -40 +KPX Umacron Atilde -40 +KPX Umacron comma -40 +KPX Umacron period -40 +KPX Uogonek A -40 +KPX Uogonek Aacute -40 +KPX Uogonek Abreve -40 +KPX Uogonek Acircumflex -40 +KPX Uogonek Adieresis -40 +KPX Uogonek Agrave -40 +KPX Uogonek Amacron -40 +KPX Uogonek Aogonek -40 +KPX Uogonek Aring -40 +KPX Uogonek Atilde -40 +KPX Uogonek comma -40 +KPX Uogonek period -40 +KPX Uring A -40 +KPX Uring Aacute -40 +KPX Uring Abreve -40 +KPX Uring Acircumflex -40 +KPX Uring Adieresis -40 +KPX Uring Agrave -40 +KPX Uring Amacron -40 +KPX Uring Aogonek -40 +KPX Uring Aring -40 +KPX Uring Atilde -40 +KPX Uring comma -40 +KPX Uring period -40 +KPX V A -80 +KPX V Aacute -80 +KPX V Abreve -80 +KPX V Acircumflex -80 +KPX V Adieresis -80 +KPX V Agrave -80 +KPX V Amacron -80 +KPX V Aogonek -80 +KPX V Aring -80 +KPX V Atilde -80 +KPX V G -40 +KPX V Gbreve -40 +KPX V Gcommaaccent -40 +KPX V O -40 +KPX V Oacute -40 +KPX V Ocircumflex -40 +KPX V Odieresis -40 +KPX V Ograve -40 +KPX V Ohungarumlaut -40 +KPX V Omacron -40 +KPX V Oslash -40 +KPX V Otilde -40 +KPX V a -70 +KPX V aacute -70 +KPX V abreve -70 +KPX V acircumflex -70 +KPX V adieresis -70 +KPX V agrave -70 +KPX V amacron -70 +KPX V aogonek -70 +KPX V aring -70 +KPX V atilde -70 +KPX V colon -40 +KPX V comma -125 +KPX V e -80 +KPX V eacute -80 +KPX V ecaron -80 +KPX V ecircumflex -80 +KPX V edieresis -80 +KPX V edotaccent -80 +KPX V egrave -80 +KPX V emacron -80 +KPX V eogonek -80 +KPX V hyphen -80 +KPX V o -80 +KPX V oacute -80 +KPX V ocircumflex -80 +KPX V odieresis -80 +KPX V ograve -80 +KPX V ohungarumlaut -80 +KPX V omacron -80 +KPX V oslash -80 +KPX V otilde -80 +KPX V period -125 +KPX V semicolon -40 +KPX V u -70 +KPX V uacute -70 +KPX V ucircumflex -70 +KPX V udieresis -70 +KPX V ugrave -70 +KPX V uhungarumlaut -70 +KPX V umacron -70 +KPX V uogonek -70 +KPX V uring -70 +KPX W A -50 +KPX W Aacute -50 +KPX W Abreve -50 +KPX W Acircumflex -50 +KPX W Adieresis -50 +KPX W Agrave -50 +KPX W Amacron -50 +KPX W Aogonek -50 +KPX W Aring -50 +KPX W Atilde -50 +KPX W O -20 +KPX W Oacute -20 +KPX W Ocircumflex -20 +KPX W Odieresis -20 +KPX W Ograve -20 +KPX W Ohungarumlaut -20 +KPX W Omacron -20 +KPX W Oslash -20 +KPX W Otilde -20 +KPX W a -40 +KPX W aacute -40 +KPX W abreve -40 +KPX W acircumflex -40 +KPX W adieresis -40 +KPX W agrave -40 +KPX W amacron -40 +KPX W aogonek -40 +KPX W aring -40 +KPX W atilde -40 +KPX W comma -80 +KPX W e -30 +KPX W eacute -30 +KPX W ecaron -30 +KPX W ecircumflex -30 +KPX W edieresis -30 +KPX W edotaccent -30 +KPX W egrave -30 +KPX W emacron -30 +KPX W eogonek -30 +KPX W hyphen -40 +KPX W o -30 +KPX W oacute -30 +KPX W ocircumflex -30 +KPX W odieresis -30 +KPX W ograve -30 +KPX W ohungarumlaut -30 +KPX W omacron -30 +KPX W oslash -30 +KPX W otilde -30 +KPX W period -80 +KPX W u -30 +KPX W uacute -30 +KPX W ucircumflex -30 +KPX W udieresis -30 +KPX W ugrave -30 +KPX W uhungarumlaut -30 +KPX W umacron -30 +KPX W uogonek -30 +KPX W uring -30 +KPX W y -20 +KPX W yacute -20 +KPX W ydieresis -20 +KPX Y A -110 +KPX Y Aacute -110 +KPX Y Abreve -110 +KPX Y Acircumflex -110 +KPX Y Adieresis -110 +KPX Y Agrave -110 +KPX Y Amacron -110 +KPX Y Aogonek -110 +KPX Y Aring -110 +KPX Y Atilde -110 +KPX Y O -85 +KPX Y Oacute -85 +KPX Y Ocircumflex -85 +KPX Y Odieresis -85 +KPX Y Ograve -85 +KPX Y Ohungarumlaut -85 +KPX Y Omacron -85 +KPX Y Oslash -85 +KPX Y Otilde -85 +KPX Y a -140 +KPX Y aacute -140 +KPX Y abreve -70 +KPX Y acircumflex -140 +KPX Y adieresis -140 +KPX Y agrave -140 +KPX Y amacron -70 +KPX Y aogonek -140 +KPX Y aring -140 +KPX Y atilde -140 +KPX Y colon -60 +KPX Y comma -140 +KPX Y e -140 +KPX Y eacute -140 +KPX Y ecaron -140 +KPX Y ecircumflex -140 +KPX Y edieresis -140 +KPX Y edotaccent -140 +KPX Y egrave -140 +KPX Y emacron -70 +KPX Y eogonek -140 +KPX Y hyphen -140 +KPX Y i -20 +KPX Y iacute -20 +KPX Y iogonek -20 +KPX Y o -140 +KPX Y oacute -140 +KPX Y ocircumflex -140 +KPX Y odieresis -140 +KPX Y ograve -140 +KPX Y ohungarumlaut -140 +KPX Y omacron -140 +KPX Y oslash -140 +KPX Y otilde -140 +KPX Y period -140 +KPX Y semicolon -60 +KPX Y u -110 +KPX Y uacute -110 +KPX Y ucircumflex -110 +KPX Y udieresis -110 +KPX Y ugrave -110 +KPX Y uhungarumlaut -110 +KPX Y umacron -110 +KPX Y uogonek -110 +KPX Y uring -110 +KPX Yacute A -110 +KPX Yacute Aacute -110 +KPX Yacute Abreve -110 +KPX Yacute Acircumflex -110 +KPX Yacute Adieresis -110 +KPX Yacute Agrave -110 +KPX Yacute Amacron -110 +KPX Yacute Aogonek -110 +KPX Yacute Aring -110 +KPX Yacute Atilde -110 +KPX Yacute O -85 +KPX Yacute Oacute -85 +KPX Yacute Ocircumflex -85 +KPX Yacute Odieresis -85 +KPX Yacute Ograve -85 +KPX Yacute Ohungarumlaut -85 +KPX Yacute Omacron -85 +KPX Yacute Oslash -85 +KPX Yacute Otilde -85 +KPX Yacute a -140 +KPX Yacute aacute -140 +KPX Yacute abreve -70 +KPX Yacute acircumflex -140 +KPX Yacute adieresis -140 +KPX Yacute agrave -140 +KPX Yacute amacron -70 +KPX Yacute aogonek -140 +KPX Yacute aring -140 +KPX Yacute atilde -70 +KPX Yacute colon -60 +KPX Yacute comma -140 +KPX Yacute e -140 +KPX Yacute eacute -140 +KPX Yacute ecaron -140 +KPX Yacute ecircumflex -140 +KPX Yacute edieresis -140 +KPX Yacute edotaccent -140 +KPX Yacute egrave -140 +KPX Yacute emacron -70 +KPX Yacute eogonek -140 +KPX Yacute hyphen -140 +KPX Yacute i -20 +KPX Yacute iacute -20 +KPX Yacute iogonek -20 +KPX Yacute o -140 +KPX Yacute oacute -140 +KPX Yacute ocircumflex -140 +KPX Yacute odieresis -140 +KPX Yacute ograve -140 +KPX Yacute ohungarumlaut -140 +KPX Yacute omacron -70 +KPX Yacute oslash -140 +KPX Yacute otilde -140 +KPX Yacute period -140 +KPX Yacute semicolon -60 +KPX Yacute u -110 +KPX Yacute uacute -110 +KPX Yacute ucircumflex -110 +KPX Yacute udieresis -110 +KPX Yacute ugrave -110 +KPX Yacute uhungarumlaut -110 +KPX Yacute umacron -110 +KPX Yacute uogonek -110 +KPX Yacute uring -110 +KPX Ydieresis A -110 +KPX Ydieresis Aacute -110 +KPX Ydieresis Abreve -110 +KPX Ydieresis Acircumflex -110 +KPX Ydieresis Adieresis -110 +KPX Ydieresis Agrave -110 +KPX Ydieresis Amacron -110 +KPX Ydieresis Aogonek -110 +KPX Ydieresis Aring -110 +KPX Ydieresis Atilde -110 +KPX Ydieresis O -85 +KPX Ydieresis Oacute -85 +KPX Ydieresis Ocircumflex -85 +KPX Ydieresis Odieresis -85 +KPX Ydieresis Ograve -85 +KPX Ydieresis Ohungarumlaut -85 +KPX Ydieresis Omacron -85 +KPX Ydieresis Oslash -85 +KPX Ydieresis Otilde -85 +KPX Ydieresis a -140 +KPX Ydieresis aacute -140 +KPX Ydieresis abreve -70 +KPX Ydieresis acircumflex -140 +KPX Ydieresis adieresis -140 +KPX Ydieresis agrave -140 +KPX Ydieresis amacron -70 +KPX Ydieresis aogonek -140 +KPX Ydieresis aring -140 +KPX Ydieresis atilde -70 +KPX Ydieresis colon -60 +KPX Ydieresis comma -140 +KPX Ydieresis e -140 +KPX Ydieresis eacute -140 +KPX Ydieresis ecaron -140 +KPX Ydieresis ecircumflex -140 +KPX Ydieresis edieresis -140 +KPX Ydieresis edotaccent -140 +KPX Ydieresis egrave -140 +KPX Ydieresis emacron -70 +KPX Ydieresis eogonek -140 +KPX Ydieresis hyphen -140 +KPX Ydieresis i -20 +KPX Ydieresis iacute -20 +KPX Ydieresis iogonek -20 +KPX Ydieresis o -140 +KPX Ydieresis oacute -140 +KPX Ydieresis ocircumflex -140 +KPX Ydieresis odieresis -140 +KPX Ydieresis ograve -140 +KPX Ydieresis ohungarumlaut -140 +KPX Ydieresis omacron -140 +KPX Ydieresis oslash -140 +KPX Ydieresis otilde -140 +KPX Ydieresis period -140 +KPX Ydieresis semicolon -60 +KPX Ydieresis u -110 +KPX Ydieresis uacute -110 +KPX Ydieresis ucircumflex -110 +KPX Ydieresis udieresis -110 +KPX Ydieresis ugrave -110 +KPX Ydieresis uhungarumlaut -110 +KPX Ydieresis umacron -110 +KPX Ydieresis uogonek -110 +KPX Ydieresis uring -110 +KPX a v -20 +KPX a w -20 +KPX a y -30 +KPX a yacute -30 +KPX a ydieresis -30 +KPX aacute v -20 +KPX aacute w -20 +KPX aacute y -30 +KPX aacute yacute -30 +KPX aacute ydieresis -30 +KPX abreve v -20 +KPX abreve w -20 +KPX abreve y -30 +KPX abreve yacute -30 +KPX abreve ydieresis -30 +KPX acircumflex v -20 +KPX acircumflex w -20 +KPX acircumflex y -30 +KPX acircumflex yacute -30 +KPX acircumflex ydieresis -30 +KPX adieresis v -20 +KPX adieresis w -20 +KPX adieresis y -30 +KPX adieresis yacute -30 +KPX adieresis ydieresis -30 +KPX agrave v -20 +KPX agrave w -20 +KPX agrave y -30 +KPX agrave yacute -30 +KPX agrave ydieresis -30 +KPX amacron v -20 +KPX amacron w -20 +KPX amacron y -30 +KPX amacron yacute -30 +KPX amacron ydieresis -30 +KPX aogonek v -20 +KPX aogonek w -20 +KPX aogonek y -30 +KPX aogonek yacute -30 +KPX aogonek ydieresis -30 +KPX aring v -20 +KPX aring w -20 +KPX aring y -30 +KPX aring yacute -30 +KPX aring ydieresis -30 +KPX atilde v -20 +KPX atilde w -20 +KPX atilde y -30 +KPX atilde yacute -30 +KPX atilde ydieresis -30 +KPX b b -10 +KPX b comma -40 +KPX b l -20 +KPX b lacute -20 +KPX b lcommaaccent -20 +KPX b lslash -20 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -20 +KPX b y -20 +KPX b yacute -20 +KPX b ydieresis -20 +KPX c comma -15 +KPX c k -20 +KPX c kcommaaccent -20 +KPX cacute comma -15 +KPX cacute k -20 +KPX cacute kcommaaccent -20 +KPX ccaron comma -15 +KPX ccaron k -20 +KPX ccaron kcommaaccent -20 +KPX ccedilla comma -15 +KPX ccedilla k -20 +KPX ccedilla kcommaaccent -20 +KPX colon space -50 +KPX comma quotedblright -100 +KPX comma quoteright -100 +KPX e comma -15 +KPX e period -15 +KPX e v -30 +KPX e w -20 +KPX e x -30 +KPX e y -20 +KPX e yacute -20 +KPX e ydieresis -20 +KPX eacute comma -15 +KPX eacute period -15 +KPX eacute v -30 +KPX eacute w -20 +KPX eacute x -30 +KPX eacute y -20 +KPX eacute yacute -20 +KPX eacute ydieresis -20 +KPX ecaron comma -15 +KPX ecaron period -15 +KPX ecaron v -30 +KPX ecaron w -20 +KPX ecaron x -30 +KPX ecaron y -20 +KPX ecaron yacute -20 +KPX ecaron ydieresis -20 +KPX ecircumflex comma -15 +KPX ecircumflex period -15 +KPX ecircumflex v -30 +KPX ecircumflex w -20 +KPX ecircumflex x -30 +KPX ecircumflex y -20 +KPX ecircumflex yacute -20 +KPX ecircumflex ydieresis -20 +KPX edieresis comma -15 +KPX edieresis period -15 +KPX edieresis v -30 +KPX edieresis w -20 +KPX edieresis x -30 +KPX edieresis y -20 +KPX edieresis yacute -20 +KPX edieresis ydieresis -20 +KPX edotaccent comma -15 +KPX edotaccent period -15 +KPX edotaccent v -30 +KPX edotaccent w -20 +KPX edotaccent x -30 +KPX edotaccent y -20 +KPX edotaccent yacute -20 +KPX edotaccent ydieresis -20 +KPX egrave comma -15 +KPX egrave period -15 +KPX egrave v -30 +KPX egrave w -20 +KPX egrave x -30 +KPX egrave y -20 +KPX egrave yacute -20 +KPX egrave ydieresis -20 +KPX emacron comma -15 +KPX emacron period -15 +KPX emacron v -30 +KPX emacron w -20 +KPX emacron x -30 +KPX emacron y -20 +KPX emacron yacute -20 +KPX emacron ydieresis -20 +KPX eogonek comma -15 +KPX eogonek period -15 +KPX eogonek v -30 +KPX eogonek w -20 +KPX eogonek x -30 +KPX eogonek y -20 +KPX eogonek yacute -20 +KPX eogonek ydieresis -20 +KPX f a -30 +KPX f aacute -30 +KPX f abreve -30 +KPX f acircumflex -30 +KPX f adieresis -30 +KPX f agrave -30 +KPX f amacron -30 +KPX f aogonek -30 +KPX f aring -30 +KPX f atilde -30 +KPX f comma -30 +KPX f dotlessi -28 +KPX f e -30 +KPX f eacute -30 +KPX f ecaron -30 +KPX f ecircumflex -30 +KPX f edieresis -30 +KPX f edotaccent -30 +KPX f egrave -30 +KPX f emacron -30 +KPX f eogonek -30 +KPX f o -30 +KPX f oacute -30 +KPX f ocircumflex -30 +KPX f odieresis -30 +KPX f ograve -30 +KPX f ohungarumlaut -30 +KPX f omacron -30 +KPX f oslash -30 +KPX f otilde -30 +KPX f period -30 +KPX f quotedblright 60 +KPX f quoteright 50 +KPX g r -10 +KPX g racute -10 +KPX g rcaron -10 +KPX g rcommaaccent -10 +KPX gbreve r -10 +KPX gbreve racute -10 +KPX gbreve rcaron -10 +KPX gbreve rcommaaccent -10 +KPX gcommaaccent r -10 +KPX gcommaaccent racute -10 +KPX gcommaaccent rcaron -10 +KPX gcommaaccent rcommaaccent -10 +KPX h y -30 +KPX h yacute -30 +KPX h ydieresis -30 +KPX k e -20 +KPX k eacute -20 +KPX k ecaron -20 +KPX k ecircumflex -20 +KPX k edieresis -20 +KPX k edotaccent -20 +KPX k egrave -20 +KPX k emacron -20 +KPX k eogonek -20 +KPX k o -20 +KPX k oacute -20 +KPX k ocircumflex -20 +KPX k odieresis -20 +KPX k ograve -20 +KPX k ohungarumlaut -20 +KPX k omacron -20 +KPX k oslash -20 +KPX k otilde -20 +KPX kcommaaccent e -20 +KPX kcommaaccent eacute -20 +KPX kcommaaccent ecaron -20 +KPX kcommaaccent ecircumflex -20 +KPX kcommaaccent edieresis -20 +KPX kcommaaccent edotaccent -20 +KPX kcommaaccent egrave -20 +KPX kcommaaccent emacron -20 +KPX kcommaaccent eogonek -20 +KPX kcommaaccent o -20 +KPX kcommaaccent oacute -20 +KPX kcommaaccent ocircumflex -20 +KPX kcommaaccent odieresis -20 +KPX kcommaaccent ograve -20 +KPX kcommaaccent ohungarumlaut -20 +KPX kcommaaccent omacron -20 +KPX kcommaaccent oslash -20 +KPX kcommaaccent otilde -20 +KPX m u -10 +KPX m uacute -10 +KPX m ucircumflex -10 +KPX m udieresis -10 +KPX m ugrave -10 +KPX m uhungarumlaut -10 +KPX m umacron -10 +KPX m uogonek -10 +KPX m uring -10 +KPX m y -15 +KPX m yacute -15 +KPX m ydieresis -15 +KPX n u -10 +KPX n uacute -10 +KPX n ucircumflex -10 +KPX n udieresis -10 +KPX n ugrave -10 +KPX n uhungarumlaut -10 +KPX n umacron -10 +KPX n uogonek -10 +KPX n uring -10 +KPX n v -20 +KPX n y -15 +KPX n yacute -15 +KPX n ydieresis -15 +KPX nacute u -10 +KPX nacute uacute -10 +KPX nacute ucircumflex -10 +KPX nacute udieresis -10 +KPX nacute ugrave -10 +KPX nacute uhungarumlaut -10 +KPX nacute umacron -10 +KPX nacute uogonek -10 +KPX nacute uring -10 +KPX nacute v -20 +KPX nacute y -15 +KPX nacute yacute -15 +KPX nacute ydieresis -15 +KPX ncaron u -10 +KPX ncaron uacute -10 +KPX ncaron ucircumflex -10 +KPX ncaron udieresis -10 +KPX ncaron ugrave -10 +KPX ncaron uhungarumlaut -10 +KPX ncaron umacron -10 +KPX ncaron uogonek -10 +KPX ncaron uring -10 +KPX ncaron v -20 +KPX ncaron y -15 +KPX ncaron yacute -15 +KPX ncaron ydieresis -15 +KPX ncommaaccent u -10 +KPX ncommaaccent uacute -10 +KPX ncommaaccent ucircumflex -10 +KPX ncommaaccent udieresis -10 +KPX ncommaaccent ugrave -10 +KPX ncommaaccent uhungarumlaut -10 +KPX ncommaaccent umacron -10 +KPX ncommaaccent uogonek -10 +KPX ncommaaccent uring -10 +KPX ncommaaccent v -20 +KPX ncommaaccent y -15 +KPX ncommaaccent yacute -15 +KPX ncommaaccent ydieresis -15 +KPX ntilde u -10 +KPX ntilde uacute -10 +KPX ntilde ucircumflex -10 +KPX ntilde udieresis -10 +KPX ntilde ugrave -10 +KPX ntilde uhungarumlaut -10 +KPX ntilde umacron -10 +KPX ntilde uogonek -10 +KPX ntilde uring -10 +KPX ntilde v -20 +KPX ntilde y -15 +KPX ntilde yacute -15 +KPX ntilde ydieresis -15 +KPX o comma -40 +KPX o period -40 +KPX o v -15 +KPX o w -15 +KPX o x -30 +KPX o y -30 +KPX o yacute -30 +KPX o ydieresis -30 +KPX oacute comma -40 +KPX oacute period -40 +KPX oacute v -15 +KPX oacute w -15 +KPX oacute x -30 +KPX oacute y -30 +KPX oacute yacute -30 +KPX oacute ydieresis -30 +KPX ocircumflex comma -40 +KPX ocircumflex period -40 +KPX ocircumflex v -15 +KPX ocircumflex w -15 +KPX ocircumflex x -30 +KPX ocircumflex y -30 +KPX ocircumflex yacute -30 +KPX ocircumflex ydieresis -30 +KPX odieresis comma -40 +KPX odieresis period -40 +KPX odieresis v -15 +KPX odieresis w -15 +KPX odieresis x -30 +KPX odieresis y -30 +KPX odieresis yacute -30 +KPX odieresis ydieresis -30 +KPX ograve comma -40 +KPX ograve period -40 +KPX ograve v -15 +KPX ograve w -15 +KPX ograve x -30 +KPX ograve y -30 +KPX ograve yacute -30 +KPX ograve ydieresis -30 +KPX ohungarumlaut comma -40 +KPX ohungarumlaut period -40 +KPX ohungarumlaut v -15 +KPX ohungarumlaut w -15 +KPX ohungarumlaut x -30 +KPX ohungarumlaut y -30 +KPX ohungarumlaut yacute -30 +KPX ohungarumlaut ydieresis -30 +KPX omacron comma -40 +KPX omacron period -40 +KPX omacron v -15 +KPX omacron w -15 +KPX omacron x -30 +KPX omacron y -30 +KPX omacron yacute -30 +KPX omacron ydieresis -30 +KPX oslash a -55 +KPX oslash aacute -55 +KPX oslash abreve -55 +KPX oslash acircumflex -55 +KPX oslash adieresis -55 +KPX oslash agrave -55 +KPX oslash amacron -55 +KPX oslash aogonek -55 +KPX oslash aring -55 +KPX oslash atilde -55 +KPX oslash b -55 +KPX oslash c -55 +KPX oslash cacute -55 +KPX oslash ccaron -55 +KPX oslash ccedilla -55 +KPX oslash comma -95 +KPX oslash d -55 +KPX oslash dcroat -55 +KPX oslash e -55 +KPX oslash eacute -55 +KPX oslash ecaron -55 +KPX oslash ecircumflex -55 +KPX oslash edieresis -55 +KPX oslash edotaccent -55 +KPX oslash egrave -55 +KPX oslash emacron -55 +KPX oslash eogonek -55 +KPX oslash f -55 +KPX oslash g -55 +KPX oslash gbreve -55 +KPX oslash gcommaaccent -55 +KPX oslash h -55 +KPX oslash i -55 +KPX oslash iacute -55 +KPX oslash icircumflex -55 +KPX oslash idieresis -55 +KPX oslash igrave -55 +KPX oslash imacron -55 +KPX oslash iogonek -55 +KPX oslash j -55 +KPX oslash k -55 +KPX oslash kcommaaccent -55 +KPX oslash l -55 +KPX oslash lacute -55 +KPX oslash lcommaaccent -55 +KPX oslash lslash -55 +KPX oslash m -55 +KPX oslash n -55 +KPX oslash nacute -55 +KPX oslash ncaron -55 +KPX oslash ncommaaccent -55 +KPX oslash ntilde -55 +KPX oslash o -55 +KPX oslash oacute -55 +KPX oslash ocircumflex -55 +KPX oslash odieresis -55 +KPX oslash ograve -55 +KPX oslash ohungarumlaut -55 +KPX oslash omacron -55 +KPX oslash oslash -55 +KPX oslash otilde -55 +KPX oslash p -55 +KPX oslash period -95 +KPX oslash q -55 +KPX oslash r -55 +KPX oslash racute -55 +KPX oslash rcaron -55 +KPX oslash rcommaaccent -55 +KPX oslash s -55 +KPX oslash sacute -55 +KPX oslash scaron -55 +KPX oslash scedilla -55 +KPX oslash scommaaccent -55 +KPX oslash t -55 +KPX oslash tcommaaccent -55 +KPX oslash u -55 +KPX oslash uacute -55 +KPX oslash ucircumflex -55 +KPX oslash udieresis -55 +KPX oslash ugrave -55 +KPX oslash uhungarumlaut -55 +KPX oslash umacron -55 +KPX oslash uogonek -55 +KPX oslash uring -55 +KPX oslash v -70 +KPX oslash w -70 +KPX oslash x -85 +KPX oslash y -70 +KPX oslash yacute -70 +KPX oslash ydieresis -70 +KPX oslash z -55 +KPX oslash zacute -55 +KPX oslash zcaron -55 +KPX oslash zdotaccent -55 +KPX otilde comma -40 +KPX otilde period -40 +KPX otilde v -15 +KPX otilde w -15 +KPX otilde x -30 +KPX otilde y -30 +KPX otilde yacute -30 +KPX otilde ydieresis -30 +KPX p comma -35 +KPX p period -35 +KPX p y -30 +KPX p yacute -30 +KPX p ydieresis -30 +KPX period quotedblright -100 +KPX period quoteright -100 +KPX period space -60 +KPX quotedblright space -40 +KPX quoteleft quoteleft -57 +KPX quoteright d -50 +KPX quoteright dcroat -50 +KPX quoteright quoteright -57 +KPX quoteright r -50 +KPX quoteright racute -50 +KPX quoteright rcaron -50 +KPX quoteright rcommaaccent -50 +KPX quoteright s -50 +KPX quoteright sacute -50 +KPX quoteright scaron -50 +KPX quoteright scedilla -50 +KPX quoteright scommaaccent -50 +KPX quoteright space -70 +KPX r a -10 +KPX r aacute -10 +KPX r abreve -10 +KPX r acircumflex -10 +KPX r adieresis -10 +KPX r agrave -10 +KPX r amacron -10 +KPX r aogonek -10 +KPX r aring -10 +KPX r atilde -10 +KPX r colon 30 +KPX r comma -50 +KPX r i 15 +KPX r iacute 15 +KPX r icircumflex 15 +KPX r idieresis 15 +KPX r igrave 15 +KPX r imacron 15 +KPX r iogonek 15 +KPX r k 15 +KPX r kcommaaccent 15 +KPX r l 15 +KPX r lacute 15 +KPX r lcommaaccent 15 +KPX r lslash 15 +KPX r m 25 +KPX r n 25 +KPX r nacute 25 +KPX r ncaron 25 +KPX r ncommaaccent 25 +KPX r ntilde 25 +KPX r p 30 +KPX r period -50 +KPX r semicolon 30 +KPX r t 40 +KPX r tcommaaccent 40 +KPX r u 15 +KPX r uacute 15 +KPX r ucircumflex 15 +KPX r udieresis 15 +KPX r ugrave 15 +KPX r uhungarumlaut 15 +KPX r umacron 15 +KPX r uogonek 15 +KPX r uring 15 +KPX r v 30 +KPX r y 30 +KPX r yacute 30 +KPX r ydieresis 30 +KPX racute a -10 +KPX racute aacute -10 +KPX racute abreve -10 +KPX racute acircumflex -10 +KPX racute adieresis -10 +KPX racute agrave -10 +KPX racute amacron -10 +KPX racute aogonek -10 +KPX racute aring -10 +KPX racute atilde -10 +KPX racute colon 30 +KPX racute comma -50 +KPX racute i 15 +KPX racute iacute 15 +KPX racute icircumflex 15 +KPX racute idieresis 15 +KPX racute igrave 15 +KPX racute imacron 15 +KPX racute iogonek 15 +KPX racute k 15 +KPX racute kcommaaccent 15 +KPX racute l 15 +KPX racute lacute 15 +KPX racute lcommaaccent 15 +KPX racute lslash 15 +KPX racute m 25 +KPX racute n 25 +KPX racute nacute 25 +KPX racute ncaron 25 +KPX racute ncommaaccent 25 +KPX racute ntilde 25 +KPX racute p 30 +KPX racute period -50 +KPX racute semicolon 30 +KPX racute t 40 +KPX racute tcommaaccent 40 +KPX racute u 15 +KPX racute uacute 15 +KPX racute ucircumflex 15 +KPX racute udieresis 15 +KPX racute ugrave 15 +KPX racute uhungarumlaut 15 +KPX racute umacron 15 +KPX racute uogonek 15 +KPX racute uring 15 +KPX racute v 30 +KPX racute y 30 +KPX racute yacute 30 +KPX racute ydieresis 30 +KPX rcaron a -10 +KPX rcaron aacute -10 +KPX rcaron abreve -10 +KPX rcaron acircumflex -10 +KPX rcaron adieresis -10 +KPX rcaron agrave -10 +KPX rcaron amacron -10 +KPX rcaron aogonek -10 +KPX rcaron aring -10 +KPX rcaron atilde -10 +KPX rcaron colon 30 +KPX rcaron comma -50 +KPX rcaron i 15 +KPX rcaron iacute 15 +KPX rcaron icircumflex 15 +KPX rcaron idieresis 15 +KPX rcaron igrave 15 +KPX rcaron imacron 15 +KPX rcaron iogonek 15 +KPX rcaron k 15 +KPX rcaron kcommaaccent 15 +KPX rcaron l 15 +KPX rcaron lacute 15 +KPX rcaron lcommaaccent 15 +KPX rcaron lslash 15 +KPX rcaron m 25 +KPX rcaron n 25 +KPX rcaron nacute 25 +KPX rcaron ncaron 25 +KPX rcaron ncommaaccent 25 +KPX rcaron ntilde 25 +KPX rcaron p 30 +KPX rcaron period -50 +KPX rcaron semicolon 30 +KPX rcaron t 40 +KPX rcaron tcommaaccent 40 +KPX rcaron u 15 +KPX rcaron uacute 15 +KPX rcaron ucircumflex 15 +KPX rcaron udieresis 15 +KPX rcaron ugrave 15 +KPX rcaron uhungarumlaut 15 +KPX rcaron umacron 15 +KPX rcaron uogonek 15 +KPX rcaron uring 15 +KPX rcaron v 30 +KPX rcaron y 30 +KPX rcaron yacute 30 +KPX rcaron ydieresis 30 +KPX rcommaaccent a -10 +KPX rcommaaccent aacute -10 +KPX rcommaaccent abreve -10 +KPX rcommaaccent acircumflex -10 +KPX rcommaaccent adieresis -10 +KPX rcommaaccent agrave -10 +KPX rcommaaccent amacron -10 +KPX rcommaaccent aogonek -10 +KPX rcommaaccent aring -10 +KPX rcommaaccent atilde -10 +KPX rcommaaccent colon 30 +KPX rcommaaccent comma -50 +KPX rcommaaccent i 15 +KPX rcommaaccent iacute 15 +KPX rcommaaccent icircumflex 15 +KPX rcommaaccent idieresis 15 +KPX rcommaaccent igrave 15 +KPX rcommaaccent imacron 15 +KPX rcommaaccent iogonek 15 +KPX rcommaaccent k 15 +KPX rcommaaccent kcommaaccent 15 +KPX rcommaaccent l 15 +KPX rcommaaccent lacute 15 +KPX rcommaaccent lcommaaccent 15 +KPX rcommaaccent lslash 15 +KPX rcommaaccent m 25 +KPX rcommaaccent n 25 +KPX rcommaaccent nacute 25 +KPX rcommaaccent ncaron 25 +KPX rcommaaccent ncommaaccent 25 +KPX rcommaaccent ntilde 25 +KPX rcommaaccent p 30 +KPX rcommaaccent period -50 +KPX rcommaaccent semicolon 30 +KPX rcommaaccent t 40 +KPX rcommaaccent tcommaaccent 40 +KPX rcommaaccent u 15 +KPX rcommaaccent uacute 15 +KPX rcommaaccent ucircumflex 15 +KPX rcommaaccent udieresis 15 +KPX rcommaaccent ugrave 15 +KPX rcommaaccent uhungarumlaut 15 +KPX rcommaaccent umacron 15 +KPX rcommaaccent uogonek 15 +KPX rcommaaccent uring 15 +KPX rcommaaccent v 30 +KPX rcommaaccent y 30 +KPX rcommaaccent yacute 30 +KPX rcommaaccent ydieresis 30 +KPX s comma -15 +KPX s period -15 +KPX s w -30 +KPX sacute comma -15 +KPX sacute period -15 +KPX sacute w -30 +KPX scaron comma -15 +KPX scaron period -15 +KPX scaron w -30 +KPX scedilla comma -15 +KPX scedilla period -15 +KPX scedilla w -30 +KPX scommaaccent comma -15 +KPX scommaaccent period -15 +KPX scommaaccent w -30 +KPX semicolon space -50 +KPX space T -50 +KPX space Tcaron -50 +KPX space Tcommaaccent -50 +KPX space V -50 +KPX space W -40 +KPX space Y -90 +KPX space Yacute -90 +KPX space Ydieresis -90 +KPX space quotedblleft -30 +KPX space quoteleft -60 +KPX v a -25 +KPX v aacute -25 +KPX v abreve -25 +KPX v acircumflex -25 +KPX v adieresis -25 +KPX v agrave -25 +KPX v amacron -25 +KPX v aogonek -25 +KPX v aring -25 +KPX v atilde -25 +KPX v comma -80 +KPX v e -25 +KPX v eacute -25 +KPX v ecaron -25 +KPX v ecircumflex -25 +KPX v edieresis -25 +KPX v edotaccent -25 +KPX v egrave -25 +KPX v emacron -25 +KPX v eogonek -25 +KPX v o -25 +KPX v oacute -25 +KPX v ocircumflex -25 +KPX v odieresis -25 +KPX v ograve -25 +KPX v ohungarumlaut -25 +KPX v omacron -25 +KPX v oslash -25 +KPX v otilde -25 +KPX v period -80 +KPX w a -15 +KPX w aacute -15 +KPX w abreve -15 +KPX w acircumflex -15 +KPX w adieresis -15 +KPX w agrave -15 +KPX w amacron -15 +KPX w aogonek -15 +KPX w aring -15 +KPX w atilde -15 +KPX w comma -60 +KPX w e -10 +KPX w eacute -10 +KPX w ecaron -10 +KPX w ecircumflex -10 +KPX w edieresis -10 +KPX w edotaccent -10 +KPX w egrave -10 +KPX w emacron -10 +KPX w eogonek -10 +KPX w o -10 +KPX w oacute -10 +KPX w ocircumflex -10 +KPX w odieresis -10 +KPX w ograve -10 +KPX w ohungarumlaut -10 +KPX w omacron -10 +KPX w oslash -10 +KPX w otilde -10 +KPX w period -60 +KPX x e -30 +KPX x eacute -30 +KPX x ecaron -30 +KPX x ecircumflex -30 +KPX x edieresis -30 +KPX x edotaccent -30 +KPX x egrave -30 +KPX x emacron -30 +KPX x eogonek -30 +KPX y a -20 +KPX y aacute -20 +KPX y abreve -20 +KPX y acircumflex -20 +KPX y adieresis -20 +KPX y agrave -20 +KPX y amacron -20 +KPX y aogonek -20 +KPX y aring -20 +KPX y atilde -20 +KPX y comma -100 +KPX y e -20 +KPX y eacute -20 +KPX y ecaron -20 +KPX y ecircumflex -20 +KPX y edieresis -20 +KPX y edotaccent -20 +KPX y egrave -20 +KPX y emacron -20 +KPX y eogonek -20 +KPX y o -20 +KPX y oacute -20 +KPX y ocircumflex -20 +KPX y odieresis -20 +KPX y ograve -20 +KPX y ohungarumlaut -20 +KPX y omacron -20 +KPX y oslash -20 +KPX y otilde -20 +KPX y period -100 +KPX yacute a -20 +KPX yacute aacute -20 +KPX yacute abreve -20 +KPX yacute acircumflex -20 +KPX yacute adieresis -20 +KPX yacute agrave -20 +KPX yacute amacron -20 +KPX yacute aogonek -20 +KPX yacute aring -20 +KPX yacute atilde -20 +KPX yacute comma -100 +KPX yacute e -20 +KPX yacute eacute -20 +KPX yacute ecaron -20 +KPX yacute ecircumflex -20 +KPX yacute edieresis -20 +KPX yacute edotaccent -20 +KPX yacute egrave -20 +KPX yacute emacron -20 +KPX yacute eogonek -20 +KPX yacute o -20 +KPX yacute oacute -20 +KPX yacute ocircumflex -20 +KPX yacute odieresis -20 +KPX yacute ograve -20 +KPX yacute ohungarumlaut -20 +KPX yacute omacron -20 +KPX yacute oslash -20 +KPX yacute otilde -20 +KPX yacute period -100 +KPX ydieresis a -20 +KPX ydieresis aacute -20 +KPX ydieresis abreve -20 +KPX ydieresis acircumflex -20 +KPX ydieresis adieresis -20 +KPX ydieresis agrave -20 +KPX ydieresis amacron -20 +KPX ydieresis aogonek -20 +KPX ydieresis aring -20 +KPX ydieresis atilde -20 +KPX ydieresis comma -100 +KPX ydieresis e -20 +KPX ydieresis eacute -20 +KPX ydieresis ecaron -20 +KPX ydieresis ecircumflex -20 +KPX ydieresis edieresis -20 +KPX ydieresis edotaccent -20 +KPX ydieresis egrave -20 +KPX ydieresis emacron -20 +KPX ydieresis eogonek -20 +KPX ydieresis o -20 +KPX ydieresis oacute -20 +KPX ydieresis ocircumflex -20 +KPX ydieresis odieresis -20 +KPX ydieresis ograve -20 +KPX ydieresis ohungarumlaut -20 +KPX ydieresis omacron -20 +KPX ydieresis oslash -20 +KPX ydieresis otilde -20 +KPX ydieresis period -100 +KPX z e -15 +KPX z eacute -15 +KPX z ecaron -15 +KPX z ecircumflex -15 +KPX z edieresis -15 +KPX z edotaccent -15 +KPX z egrave -15 +KPX z emacron -15 +KPX z eogonek -15 +KPX z o -15 +KPX z oacute -15 +KPX z ocircumflex -15 +KPX z odieresis -15 +KPX z ograve -15 +KPX z ohungarumlaut -15 +KPX z omacron -15 +KPX z oslash -15 +KPX z otilde -15 +KPX zacute e -15 +KPX zacute eacute -15 +KPX zacute ecaron -15 +KPX zacute ecircumflex -15 +KPX zacute edieresis -15 +KPX zacute edotaccent -15 +KPX zacute egrave -15 +KPX zacute emacron -15 +KPX zacute eogonek -15 +KPX zacute o -15 +KPX zacute oacute -15 +KPX zacute ocircumflex -15 +KPX zacute odieresis -15 +KPX zacute ograve -15 +KPX zacute ohungarumlaut -15 +KPX zacute omacron -15 +KPX zacute oslash -15 +KPX zacute otilde -15 +KPX zcaron e -15 +KPX zcaron eacute -15 +KPX zcaron ecaron -15 +KPX zcaron ecircumflex -15 +KPX zcaron edieresis -15 +KPX zcaron edotaccent -15 +KPX zcaron egrave -15 +KPX zcaron emacron -15 +KPX zcaron eogonek -15 +KPX zcaron o -15 +KPX zcaron oacute -15 +KPX zcaron ocircumflex -15 +KPX zcaron odieresis -15 +KPX zcaron ograve -15 +KPX zcaron ohungarumlaut -15 +KPX zcaron omacron -15 +KPX zcaron oslash -15 +KPX zcaron otilde -15 +KPX zdotaccent e -15 +KPX zdotaccent eacute -15 +KPX zdotaccent ecaron -15 +KPX zdotaccent ecircumflex -15 +KPX zdotaccent edieresis -15 +KPX zdotaccent edotaccent -15 +KPX zdotaccent egrave -15 +KPX zdotaccent emacron -15 +KPX zdotaccent eogonek -15 +KPX zdotaccent o -15 +KPX zdotaccent oacute -15 +KPX zdotaccent ocircumflex -15 +KPX zdotaccent odieresis -15 +KPX zdotaccent ograve -15 +KPX zdotaccent ohungarumlaut -15 +KPX zdotaccent omacron -15 +KPX zdotaccent oslash -15 +KPX zdotaccent otilde -15 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Symbol.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Symbol.afm new file mode 100644 index 00000000..6a5386a9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Symbol.afm @@ -0,0 +1,213 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All rights reserved. +Comment Creation Date: Thu May 1 15:12:25 1997 +Comment UniqueID 43064 +Comment VMusage 30820 39997 +FontName Symbol +FullName Symbol +FamilyName Symbol +Weight Medium +ItalicAngle 0 +IsFixedPitch false +CharacterSet Special +FontBBox -180 -293 1090 1010 +UnderlinePosition -100 +UnderlineThickness 50 +Version 001.008 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All rights reserved. +EncodingScheme FontSpecific +StdHW 92 +StdVW 85 +StartCharMetrics 190 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 128 -17 240 672 ; +C 34 ; WX 713 ; N universal ; B 31 0 681 705 ; +C 35 ; WX 500 ; N numbersign ; B 20 -16 481 673 ; +C 36 ; WX 549 ; N existential ; B 25 0 478 707 ; +C 37 ; WX 833 ; N percent ; B 63 -36 771 655 ; +C 38 ; WX 778 ; N ampersand ; B 41 -18 750 661 ; +C 39 ; WX 439 ; N suchthat ; B 48 -17 414 500 ; +C 40 ; WX 333 ; N parenleft ; B 53 -191 300 673 ; +C 41 ; WX 333 ; N parenright ; B 30 -191 277 673 ; +C 42 ; WX 500 ; N asteriskmath ; B 65 134 427 551 ; +C 43 ; WX 549 ; N plus ; B 10 0 539 533 ; +C 44 ; WX 250 ; N comma ; B 56 -152 194 104 ; +C 45 ; WX 549 ; N minus ; B 11 233 535 288 ; +C 46 ; WX 250 ; N period ; B 69 -17 181 95 ; +C 47 ; WX 278 ; N slash ; B 0 -18 254 646 ; +C 48 ; WX 500 ; N zero ; B 24 -14 476 685 ; +C 49 ; WX 500 ; N one ; B 117 0 390 673 ; +C 50 ; WX 500 ; N two ; B 25 0 475 685 ; +C 51 ; WX 500 ; N three ; B 43 -14 435 685 ; +C 52 ; WX 500 ; N four ; B 15 0 469 685 ; +C 53 ; WX 500 ; N five ; B 32 -14 445 690 ; +C 54 ; WX 500 ; N six ; B 34 -14 468 685 ; +C 55 ; WX 500 ; N seven ; B 24 -16 448 673 ; +C 56 ; WX 500 ; N eight ; B 56 -14 445 685 ; +C 57 ; WX 500 ; N nine ; B 30 -18 459 685 ; +C 58 ; WX 278 ; N colon ; B 81 -17 193 460 ; +C 59 ; WX 278 ; N semicolon ; B 83 -152 221 460 ; +C 60 ; WX 549 ; N less ; B 26 0 523 522 ; +C 61 ; WX 549 ; N equal ; B 11 141 537 390 ; +C 62 ; WX 549 ; N greater ; B 26 0 523 522 ; +C 63 ; WX 444 ; N question ; B 70 -17 412 686 ; +C 64 ; WX 549 ; N congruent ; B 11 0 537 475 ; +C 65 ; WX 722 ; N Alpha ; B 4 0 684 673 ; +C 66 ; WX 667 ; N Beta ; B 29 0 592 673 ; +C 67 ; WX 722 ; N Chi ; B -9 0 704 673 ; +C 68 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C 69 ; WX 611 ; N Epsilon ; B 32 0 617 673 ; +C 70 ; WX 763 ; N Phi ; B 26 0 741 673 ; +C 71 ; WX 603 ; N Gamma ; B 24 0 609 673 ; +C 72 ; WX 722 ; N Eta ; B 39 0 729 673 ; +C 73 ; WX 333 ; N Iota ; B 32 0 316 673 ; +C 74 ; WX 631 ; N theta1 ; B 18 -18 623 689 ; +C 75 ; WX 722 ; N Kappa ; B 35 0 722 673 ; +C 76 ; WX 686 ; N Lambda ; B 6 0 680 688 ; +C 77 ; WX 889 ; N Mu ; B 28 0 887 673 ; +C 78 ; WX 722 ; N Nu ; B 29 -8 720 673 ; +C 79 ; WX 722 ; N Omicron ; B 41 -17 715 685 ; +C 80 ; WX 768 ; N Pi ; B 25 0 745 673 ; +C 81 ; WX 741 ; N Theta ; B 41 -17 715 685 ; +C 82 ; WX 556 ; N Rho ; B 28 0 563 673 ; +C 83 ; WX 592 ; N Sigma ; B 5 0 589 673 ; +C 84 ; WX 611 ; N Tau ; B 33 0 607 673 ; +C 85 ; WX 690 ; N Upsilon ; B -8 0 694 673 ; +C 86 ; WX 439 ; N sigma1 ; B 40 -233 436 500 ; +C 87 ; WX 768 ; N Omega ; B 34 0 736 688 ; +C 88 ; WX 645 ; N Xi ; B 40 0 599 673 ; +C 89 ; WX 795 ; N Psi ; B 15 0 781 684 ; +C 90 ; WX 611 ; N Zeta ; B 44 0 636 673 ; +C 91 ; WX 333 ; N bracketleft ; B 86 -155 299 674 ; +C 92 ; WX 863 ; N therefore ; B 163 0 701 487 ; +C 93 ; WX 333 ; N bracketright ; B 33 -155 246 674 ; +C 94 ; WX 658 ; N perpendicular ; B 15 0 652 674 ; +C 95 ; WX 500 ; N underscore ; B -2 -125 502 -75 ; +C 96 ; WX 500 ; N radicalex ; B 480 881 1090 917 ; +C 97 ; WX 631 ; N alpha ; B 41 -18 622 500 ; +C 98 ; WX 549 ; N beta ; B 61 -223 515 741 ; +C 99 ; WX 549 ; N chi ; B 12 -231 522 499 ; +C 100 ; WX 494 ; N delta ; B 40 -19 481 740 ; +C 101 ; WX 439 ; N epsilon ; B 22 -19 427 502 ; +C 102 ; WX 521 ; N phi ; B 28 -224 492 673 ; +C 103 ; WX 411 ; N gamma ; B 5 -225 484 499 ; +C 104 ; WX 603 ; N eta ; B 0 -202 527 514 ; +C 105 ; WX 329 ; N iota ; B 0 -17 301 503 ; +C 106 ; WX 603 ; N phi1 ; B 36 -224 587 499 ; +C 107 ; WX 549 ; N kappa ; B 33 0 558 501 ; +C 108 ; WX 549 ; N lambda ; B 24 -17 548 739 ; +C 109 ; WX 576 ; N mu ; B 33 -223 567 500 ; +C 110 ; WX 521 ; N nu ; B -9 -16 475 507 ; +C 111 ; WX 549 ; N omicron ; B 35 -19 501 499 ; +C 112 ; WX 549 ; N pi ; B 10 -19 530 487 ; +C 113 ; WX 521 ; N theta ; B 43 -17 485 690 ; +C 114 ; WX 549 ; N rho ; B 50 -230 490 499 ; +C 115 ; WX 603 ; N sigma ; B 30 -21 588 500 ; +C 116 ; WX 439 ; N tau ; B 10 -19 418 500 ; +C 117 ; WX 576 ; N upsilon ; B 7 -18 535 507 ; +C 118 ; WX 713 ; N omega1 ; B 12 -18 671 583 ; +C 119 ; WX 686 ; N omega ; B 42 -17 684 500 ; +C 120 ; WX 493 ; N xi ; B 27 -224 469 766 ; +C 121 ; WX 686 ; N psi ; B 12 -228 701 500 ; +C 122 ; WX 494 ; N zeta ; B 60 -225 467 756 ; +C 123 ; WX 480 ; N braceleft ; B 58 -183 397 673 ; +C 124 ; WX 200 ; N bar ; B 65 -293 135 707 ; +C 125 ; WX 480 ; N braceright ; B 79 -183 418 673 ; +C 126 ; WX 549 ; N similar ; B 17 203 529 307 ; +C 160 ; WX 750 ; N Euro ; B 20 -12 714 685 ; +C 161 ; WX 620 ; N Upsilon1 ; B -2 0 610 685 ; +C 162 ; WX 247 ; N minute ; B 27 459 228 735 ; +C 163 ; WX 549 ; N lessequal ; B 29 0 526 639 ; +C 164 ; WX 167 ; N fraction ; B -180 -12 340 677 ; +C 165 ; WX 713 ; N infinity ; B 26 124 688 404 ; +C 166 ; WX 500 ; N florin ; B 2 -193 494 686 ; +C 167 ; WX 753 ; N club ; B 86 -26 660 533 ; +C 168 ; WX 753 ; N diamond ; B 142 -36 600 550 ; +C 169 ; WX 753 ; N heart ; B 117 -33 631 532 ; +C 170 ; WX 753 ; N spade ; B 113 -36 629 548 ; +C 171 ; WX 1042 ; N arrowboth ; B 24 -15 1024 511 ; +C 172 ; WX 987 ; N arrowleft ; B 32 -15 942 511 ; +C 173 ; WX 603 ; N arrowup ; B 45 0 571 910 ; +C 174 ; WX 987 ; N arrowright ; B 49 -15 959 511 ; +C 175 ; WX 603 ; N arrowdown ; B 45 -22 571 888 ; +C 176 ; WX 400 ; N degree ; B 50 385 350 685 ; +C 177 ; WX 549 ; N plusminus ; B 10 0 539 645 ; +C 178 ; WX 411 ; N second ; B 20 459 413 737 ; +C 179 ; WX 549 ; N greaterequal ; B 29 0 526 639 ; +C 180 ; WX 549 ; N multiply ; B 17 8 533 524 ; +C 181 ; WX 713 ; N proportional ; B 27 123 639 404 ; +C 182 ; WX 494 ; N partialdiff ; B 26 -20 462 746 ; +C 183 ; WX 460 ; N bullet ; B 50 113 410 473 ; +C 184 ; WX 549 ; N divide ; B 10 71 536 456 ; +C 185 ; WX 549 ; N notequal ; B 15 -25 540 549 ; +C 186 ; WX 549 ; N equivalence ; B 14 82 538 443 ; +C 187 ; WX 549 ; N approxequal ; B 14 135 527 394 ; +C 188 ; WX 1000 ; N ellipsis ; B 111 -17 889 95 ; +C 189 ; WX 603 ; N arrowvertex ; B 280 -120 336 1010 ; +C 190 ; WX 1000 ; N arrowhorizex ; B -60 220 1050 276 ; +C 191 ; WX 658 ; N carriagereturn ; B 15 -16 602 629 ; +C 192 ; WX 823 ; N aleph ; B 175 -18 661 658 ; +C 193 ; WX 686 ; N Ifraktur ; B 10 -53 578 740 ; +C 194 ; WX 795 ; N Rfraktur ; B 26 -15 759 734 ; +C 195 ; WX 987 ; N weierstrass ; B 159 -211 870 573 ; +C 196 ; WX 768 ; N circlemultiply ; B 43 -17 733 673 ; +C 197 ; WX 768 ; N circleplus ; B 43 -15 733 675 ; +C 198 ; WX 823 ; N emptyset ; B 39 -24 781 719 ; +C 199 ; WX 768 ; N intersection ; B 40 0 732 509 ; +C 200 ; WX 768 ; N union ; B 40 -17 732 492 ; +C 201 ; WX 713 ; N propersuperset ; B 20 0 673 470 ; +C 202 ; WX 713 ; N reflexsuperset ; B 20 -125 673 470 ; +C 203 ; WX 713 ; N notsubset ; B 36 -70 690 540 ; +C 204 ; WX 713 ; N propersubset ; B 37 0 690 470 ; +C 205 ; WX 713 ; N reflexsubset ; B 37 -125 690 470 ; +C 206 ; WX 713 ; N element ; B 45 0 505 468 ; +C 207 ; WX 713 ; N notelement ; B 45 -58 505 555 ; +C 208 ; WX 768 ; N angle ; B 26 0 738 673 ; +C 209 ; WX 713 ; N gradient ; B 36 -19 681 718 ; +C 210 ; WX 790 ; N registerserif ; B 50 -17 740 673 ; +C 211 ; WX 790 ; N copyrightserif ; B 51 -15 741 675 ; +C 212 ; WX 890 ; N trademarkserif ; B 18 293 855 673 ; +C 213 ; WX 823 ; N product ; B 25 -101 803 751 ; +C 214 ; WX 549 ; N radical ; B 10 -38 515 917 ; +C 215 ; WX 250 ; N dotmath ; B 69 210 169 310 ; +C 216 ; WX 713 ; N logicalnot ; B 15 0 680 288 ; +C 217 ; WX 603 ; N logicaland ; B 23 0 583 454 ; +C 218 ; WX 603 ; N logicalor ; B 30 0 578 477 ; +C 219 ; WX 1042 ; N arrowdblboth ; B 27 -20 1023 510 ; +C 220 ; WX 987 ; N arrowdblleft ; B 30 -15 939 513 ; +C 221 ; WX 603 ; N arrowdblup ; B 39 2 567 911 ; +C 222 ; WX 987 ; N arrowdblright ; B 45 -20 954 508 ; +C 223 ; WX 603 ; N arrowdbldown ; B 44 -19 572 890 ; +C 224 ; WX 494 ; N lozenge ; B 18 0 466 745 ; +C 225 ; WX 329 ; N angleleft ; B 25 -198 306 746 ; +C 226 ; WX 790 ; N registersans ; B 50 -20 740 670 ; +C 227 ; WX 790 ; N copyrightsans ; B 49 -15 739 675 ; +C 228 ; WX 786 ; N trademarksans ; B 5 293 725 673 ; +C 229 ; WX 713 ; N summation ; B 14 -108 695 752 ; +C 230 ; WX 384 ; N parenlefttp ; B 24 -293 436 926 ; +C 231 ; WX 384 ; N parenleftex ; B 24 -85 108 925 ; +C 232 ; WX 384 ; N parenleftbt ; B 24 -293 436 926 ; +C 233 ; WX 384 ; N bracketlefttp ; B 0 -80 349 926 ; +C 234 ; WX 384 ; N bracketleftex ; B 0 -79 77 925 ; +C 235 ; WX 384 ; N bracketleftbt ; B 0 -80 349 926 ; +C 236 ; WX 494 ; N bracelefttp ; B 209 -85 445 925 ; +C 237 ; WX 494 ; N braceleftmid ; B 20 -85 284 935 ; +C 238 ; WX 494 ; N braceleftbt ; B 209 -75 445 935 ; +C 239 ; WX 494 ; N braceex ; B 209 -85 284 935 ; +C 241 ; WX 329 ; N angleright ; B 21 -198 302 746 ; +C 242 ; WX 274 ; N integral ; B 2 -107 291 916 ; +C 243 ; WX 686 ; N integraltp ; B 308 -88 675 920 ; +C 244 ; WX 686 ; N integralex ; B 308 -88 378 975 ; +C 245 ; WX 686 ; N integralbt ; B 11 -87 378 921 ; +C 246 ; WX 384 ; N parenrighttp ; B 54 -293 466 926 ; +C 247 ; WX 384 ; N parenrightex ; B 382 -85 466 925 ; +C 248 ; WX 384 ; N parenrightbt ; B 54 -293 466 926 ; +C 249 ; WX 384 ; N bracketrighttp ; B 22 -80 371 926 ; +C 250 ; WX 384 ; N bracketrightex ; B 294 -79 371 925 ; +C 251 ; WX 384 ; N bracketrightbt ; B 22 -80 371 926 ; +C 252 ; WX 494 ; N bracerighttp ; B 48 -85 284 925 ; +C 253 ; WX 494 ; N bracerightmid ; B 209 -85 473 935 ; +C 254 ; WX 494 ; N bracerightbt ; B 48 -75 284 935 ; +C -1 ; WX 790 ; N apple ; B 56 -3 733 808 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Bold.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Bold.afm new file mode 100644 index 00000000..559ebaeb --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Bold.afm @@ -0,0 +1,2588 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:52:56 1997 +Comment UniqueID 43065 +Comment VMusage 41636 52661 +FontName Times-Bold +FullName Times Bold +FamilyName Times +Weight Bold +ItalicAngle 0 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -168 -218 1000 935 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 676 +XHeight 461 +Ascender 683 +Descender -217 +StdHW 44 +StdVW 139 +StartCharMetrics 315 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 81 -13 251 691 ; +C 34 ; WX 555 ; N quotedbl ; B 83 404 472 691 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 496 700 ; +C 36 ; WX 500 ; N dollar ; B 29 -99 472 750 ; +C 37 ; WX 1000 ; N percent ; B 124 -14 877 692 ; +C 38 ; WX 833 ; N ampersand ; B 62 -16 787 691 ; +C 39 ; WX 333 ; N quoteright ; B 79 356 263 691 ; +C 40 ; WX 333 ; N parenleft ; B 46 -168 306 694 ; +C 41 ; WX 333 ; N parenright ; B 27 -168 287 694 ; +C 42 ; WX 500 ; N asterisk ; B 56 255 447 691 ; +C 43 ; WX 570 ; N plus ; B 33 0 537 506 ; +C 44 ; WX 250 ; N comma ; B 39 -180 223 155 ; +C 45 ; WX 333 ; N hyphen ; B 44 171 287 287 ; +C 46 ; WX 250 ; N period ; B 41 -13 210 156 ; +C 47 ; WX 278 ; N slash ; B -24 -19 302 691 ; +C 48 ; WX 500 ; N zero ; B 24 -13 476 688 ; +C 49 ; WX 500 ; N one ; B 65 0 442 688 ; +C 50 ; WX 500 ; N two ; B 17 0 478 688 ; +C 51 ; WX 500 ; N three ; B 16 -14 468 688 ; +C 52 ; WX 500 ; N four ; B 19 0 475 688 ; +C 53 ; WX 500 ; N five ; B 22 -8 470 676 ; +C 54 ; WX 500 ; N six ; B 28 -13 475 688 ; +C 55 ; WX 500 ; N seven ; B 17 0 477 676 ; +C 56 ; WX 500 ; N eight ; B 28 -13 472 688 ; +C 57 ; WX 500 ; N nine ; B 26 -13 473 688 ; +C 58 ; WX 333 ; N colon ; B 82 -13 251 472 ; +C 59 ; WX 333 ; N semicolon ; B 82 -180 266 472 ; +C 60 ; WX 570 ; N less ; B 31 -8 539 514 ; +C 61 ; WX 570 ; N equal ; B 33 107 537 399 ; +C 62 ; WX 570 ; N greater ; B 31 -8 539 514 ; +C 63 ; WX 500 ; N question ; B 57 -13 445 689 ; +C 64 ; WX 930 ; N at ; B 108 -19 822 691 ; +C 65 ; WX 722 ; N A ; B 9 0 689 690 ; +C 66 ; WX 667 ; N B ; B 16 0 619 676 ; +C 67 ; WX 722 ; N C ; B 49 -19 687 691 ; +C 68 ; WX 722 ; N D ; B 14 0 690 676 ; +C 69 ; WX 667 ; N E ; B 16 0 641 676 ; +C 70 ; WX 611 ; N F ; B 16 0 583 676 ; +C 71 ; WX 778 ; N G ; B 37 -19 755 691 ; +C 72 ; WX 778 ; N H ; B 21 0 759 676 ; +C 73 ; WX 389 ; N I ; B 20 0 370 676 ; +C 74 ; WX 500 ; N J ; B 3 -96 479 676 ; +C 75 ; WX 778 ; N K ; B 30 0 769 676 ; +C 76 ; WX 667 ; N L ; B 19 0 638 676 ; +C 77 ; WX 944 ; N M ; B 14 0 921 676 ; +C 78 ; WX 722 ; N N ; B 16 -18 701 676 ; +C 79 ; WX 778 ; N O ; B 35 -19 743 691 ; +C 80 ; WX 611 ; N P ; B 16 0 600 676 ; +C 81 ; WX 778 ; N Q ; B 35 -176 743 691 ; +C 82 ; WX 722 ; N R ; B 26 0 715 676 ; +C 83 ; WX 556 ; N S ; B 35 -19 513 692 ; +C 84 ; WX 667 ; N T ; B 31 0 636 676 ; +C 85 ; WX 722 ; N U ; B 16 -19 701 676 ; +C 86 ; WX 722 ; N V ; B 16 -18 701 676 ; +C 87 ; WX 1000 ; N W ; B 19 -15 981 676 ; +C 88 ; WX 722 ; N X ; B 16 0 699 676 ; +C 89 ; WX 722 ; N Y ; B 15 0 699 676 ; +C 90 ; WX 667 ; N Z ; B 28 0 634 676 ; +C 91 ; WX 333 ; N bracketleft ; B 67 -149 301 678 ; +C 92 ; WX 278 ; N backslash ; B -25 -19 303 691 ; +C 93 ; WX 333 ; N bracketright ; B 32 -149 266 678 ; +C 94 ; WX 581 ; N asciicircum ; B 73 311 509 676 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 70 356 254 691 ; +C 97 ; WX 500 ; N a ; B 25 -14 488 473 ; +C 98 ; WX 556 ; N b ; B 17 -14 521 676 ; +C 99 ; WX 444 ; N c ; B 25 -14 430 473 ; +C 100 ; WX 556 ; N d ; B 25 -14 534 676 ; +C 101 ; WX 444 ; N e ; B 25 -14 426 473 ; +C 102 ; WX 333 ; N f ; B 14 0 389 691 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 28 -206 483 473 ; +C 104 ; WX 556 ; N h ; B 16 0 534 676 ; +C 105 ; WX 278 ; N i ; B 16 0 255 691 ; +C 106 ; WX 333 ; N j ; B -57 -203 263 691 ; +C 107 ; WX 556 ; N k ; B 22 0 543 676 ; +C 108 ; WX 278 ; N l ; B 16 0 255 676 ; +C 109 ; WX 833 ; N m ; B 16 0 814 473 ; +C 110 ; WX 556 ; N n ; B 21 0 539 473 ; +C 111 ; WX 500 ; N o ; B 25 -14 476 473 ; +C 112 ; WX 556 ; N p ; B 19 -205 524 473 ; +C 113 ; WX 556 ; N q ; B 34 -205 536 473 ; +C 114 ; WX 444 ; N r ; B 29 0 434 473 ; +C 115 ; WX 389 ; N s ; B 25 -14 361 473 ; +C 116 ; WX 333 ; N t ; B 20 -12 332 630 ; +C 117 ; WX 556 ; N u ; B 16 -14 537 461 ; +C 118 ; WX 500 ; N v ; B 21 -14 485 461 ; +C 119 ; WX 722 ; N w ; B 23 -14 707 461 ; +C 120 ; WX 500 ; N x ; B 12 0 484 461 ; +C 121 ; WX 500 ; N y ; B 16 -205 480 461 ; +C 122 ; WX 444 ; N z ; B 21 0 420 461 ; +C 123 ; WX 394 ; N braceleft ; B 22 -175 340 698 ; +C 124 ; WX 220 ; N bar ; B 66 -218 154 782 ; +C 125 ; WX 394 ; N braceright ; B 54 -175 372 698 ; +C 126 ; WX 520 ; N asciitilde ; B 29 173 491 333 ; +C 161 ; WX 333 ; N exclamdown ; B 82 -203 252 501 ; +C 162 ; WX 500 ; N cent ; B 53 -140 458 588 ; +C 163 ; WX 500 ; N sterling ; B 21 -14 477 684 ; +C 164 ; WX 167 ; N fraction ; B -168 -12 329 688 ; +C 165 ; WX 500 ; N yen ; B -64 0 547 676 ; +C 166 ; WX 500 ; N florin ; B 0 -155 498 706 ; +C 167 ; WX 500 ; N section ; B 57 -132 443 691 ; +C 168 ; WX 500 ; N currency ; B -26 61 526 613 ; +C 169 ; WX 278 ; N quotesingle ; B 75 404 204 691 ; +C 170 ; WX 500 ; N quotedblleft ; B 32 356 486 691 ; +C 171 ; WX 500 ; N guillemotleft ; B 23 36 473 415 ; +C 172 ; WX 333 ; N guilsinglleft ; B 51 36 305 415 ; +C 173 ; WX 333 ; N guilsinglright ; B 28 36 282 415 ; +C 174 ; WX 556 ; N fi ; B 14 0 536 691 ; +C 175 ; WX 556 ; N fl ; B 14 0 536 691 ; +C 177 ; WX 500 ; N endash ; B 0 181 500 271 ; +C 178 ; WX 500 ; N dagger ; B 47 -134 453 691 ; +C 179 ; WX 500 ; N daggerdbl ; B 45 -132 456 691 ; +C 180 ; WX 250 ; N periodcentered ; B 41 248 210 417 ; +C 182 ; WX 540 ; N paragraph ; B 0 -186 519 676 ; +C 183 ; WX 350 ; N bullet ; B 35 198 315 478 ; +C 184 ; WX 333 ; N quotesinglbase ; B 79 -180 263 155 ; +C 185 ; WX 500 ; N quotedblbase ; B 14 -180 468 155 ; +C 186 ; WX 500 ; N quotedblright ; B 14 356 468 691 ; +C 187 ; WX 500 ; N guillemotright ; B 27 36 477 415 ; +C 188 ; WX 1000 ; N ellipsis ; B 82 -13 917 156 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -29 995 706 ; +C 191 ; WX 500 ; N questiondown ; B 55 -201 443 501 ; +C 193 ; WX 333 ; N grave ; B 8 528 246 713 ; +C 194 ; WX 333 ; N acute ; B 86 528 324 713 ; +C 195 ; WX 333 ; N circumflex ; B -2 528 335 704 ; +C 196 ; WX 333 ; N tilde ; B -16 547 349 674 ; +C 197 ; WX 333 ; N macron ; B 1 565 331 637 ; +C 198 ; WX 333 ; N breve ; B 15 528 318 691 ; +C 199 ; WX 333 ; N dotaccent ; B 103 536 258 691 ; +C 200 ; WX 333 ; N dieresis ; B -2 537 335 667 ; +C 202 ; WX 333 ; N ring ; B 60 527 273 740 ; +C 203 ; WX 333 ; N cedilla ; B 68 -218 294 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -13 528 425 713 ; +C 206 ; WX 333 ; N ogonek ; B 90 -193 319 24 ; +C 207 ; WX 333 ; N caron ; B -2 528 335 704 ; +C 208 ; WX 1000 ; N emdash ; B 0 181 1000 271 ; +C 225 ; WX 1000 ; N AE ; B 4 0 951 676 ; +C 227 ; WX 300 ; N ordfeminine ; B -1 397 301 688 ; +C 232 ; WX 667 ; N Lslash ; B 19 0 638 676 ; +C 233 ; WX 778 ; N Oslash ; B 35 -74 743 737 ; +C 234 ; WX 1000 ; N OE ; B 22 -5 981 684 ; +C 235 ; WX 330 ; N ordmasculine ; B 18 397 312 688 ; +C 241 ; WX 722 ; N ae ; B 33 -14 693 473 ; +C 245 ; WX 278 ; N dotlessi ; B 16 0 255 461 ; +C 248 ; WX 278 ; N lslash ; B -22 0 303 676 ; +C 249 ; WX 500 ; N oslash ; B 25 -92 476 549 ; +C 250 ; WX 722 ; N oe ; B 22 -14 696 473 ; +C 251 ; WX 556 ; N germandbls ; B 19 -12 517 691 ; +C -1 ; WX 389 ; N Idieresis ; B 20 0 370 877 ; +C -1 ; WX 444 ; N eacute ; B 25 -14 426 713 ; +C -1 ; WX 500 ; N abreve ; B 25 -14 488 691 ; +C -1 ; WX 556 ; N uhungarumlaut ; B 16 -14 557 713 ; +C -1 ; WX 444 ; N ecaron ; B 25 -14 426 704 ; +C -1 ; WX 722 ; N Ydieresis ; B 15 0 699 877 ; +C -1 ; WX 570 ; N divide ; B 33 -31 537 537 ; +C -1 ; WX 722 ; N Yacute ; B 15 0 699 923 ; +C -1 ; WX 722 ; N Acircumflex ; B 9 0 689 914 ; +C -1 ; WX 500 ; N aacute ; B 25 -14 488 713 ; +C -1 ; WX 722 ; N Ucircumflex ; B 16 -19 701 914 ; +C -1 ; WX 500 ; N yacute ; B 16 -205 480 713 ; +C -1 ; WX 389 ; N scommaaccent ; B 25 -218 361 473 ; +C -1 ; WX 444 ; N ecircumflex ; B 25 -14 426 704 ; +C -1 ; WX 722 ; N Uring ; B 16 -19 701 935 ; +C -1 ; WX 722 ; N Udieresis ; B 16 -19 701 877 ; +C -1 ; WX 500 ; N aogonek ; B 25 -193 504 473 ; +C -1 ; WX 722 ; N Uacute ; B 16 -19 701 923 ; +C -1 ; WX 556 ; N uogonek ; B 16 -193 539 461 ; +C -1 ; WX 667 ; N Edieresis ; B 16 0 641 877 ; +C -1 ; WX 722 ; N Dcroat ; B 6 0 690 676 ; +C -1 ; WX 250 ; N commaaccent ; B 47 -218 203 -50 ; +C -1 ; WX 747 ; N copyright ; B 26 -19 721 691 ; +C -1 ; WX 667 ; N Emacron ; B 16 0 641 847 ; +C -1 ; WX 444 ; N ccaron ; B 25 -14 430 704 ; +C -1 ; WX 500 ; N aring ; B 25 -14 488 740 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 16 -188 701 676 ; +C -1 ; WX 278 ; N lacute ; B 16 0 297 923 ; +C -1 ; WX 500 ; N agrave ; B 25 -14 488 713 ; +C -1 ; WX 667 ; N Tcommaaccent ; B 31 -218 636 676 ; +C -1 ; WX 722 ; N Cacute ; B 49 -19 687 923 ; +C -1 ; WX 500 ; N atilde ; B 25 -14 488 674 ; +C -1 ; WX 667 ; N Edotaccent ; B 16 0 641 901 ; +C -1 ; WX 389 ; N scaron ; B 25 -14 363 704 ; +C -1 ; WX 389 ; N scedilla ; B 25 -218 361 473 ; +C -1 ; WX 278 ; N iacute ; B 16 0 289 713 ; +C -1 ; WX 494 ; N lozenge ; B 10 0 484 745 ; +C -1 ; WX 722 ; N Rcaron ; B 26 0 715 914 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 37 -218 755 691 ; +C -1 ; WX 556 ; N ucircumflex ; B 16 -14 537 704 ; +C -1 ; WX 500 ; N acircumflex ; B 25 -14 488 704 ; +C -1 ; WX 722 ; N Amacron ; B 9 0 689 847 ; +C -1 ; WX 444 ; N rcaron ; B 29 0 434 704 ; +C -1 ; WX 444 ; N ccedilla ; B 25 -218 430 473 ; +C -1 ; WX 667 ; N Zdotaccent ; B 28 0 634 901 ; +C -1 ; WX 611 ; N Thorn ; B 16 0 600 676 ; +C -1 ; WX 778 ; N Omacron ; B 35 -19 743 847 ; +C -1 ; WX 722 ; N Racute ; B 26 0 715 923 ; +C -1 ; WX 556 ; N Sacute ; B 35 -19 513 923 ; +C -1 ; WX 672 ; N dcaron ; B 25 -14 681 682 ; +C -1 ; WX 722 ; N Umacron ; B 16 -19 701 847 ; +C -1 ; WX 556 ; N uring ; B 16 -14 537 740 ; +C -1 ; WX 300 ; N threesuperior ; B 3 268 297 688 ; +C -1 ; WX 778 ; N Ograve ; B 35 -19 743 923 ; +C -1 ; WX 722 ; N Agrave ; B 9 0 689 923 ; +C -1 ; WX 722 ; N Abreve ; B 9 0 689 901 ; +C -1 ; WX 570 ; N multiply ; B 48 16 522 490 ; +C -1 ; WX 556 ; N uacute ; B 16 -14 537 713 ; +C -1 ; WX 667 ; N Tcaron ; B 31 0 636 914 ; +C -1 ; WX 494 ; N partialdiff ; B 11 -21 494 750 ; +C -1 ; WX 500 ; N ydieresis ; B 16 -205 480 667 ; +C -1 ; WX 722 ; N Nacute ; B 16 -18 701 923 ; +C -1 ; WX 278 ; N icircumflex ; B -37 0 300 704 ; +C -1 ; WX 667 ; N Ecircumflex ; B 16 0 641 914 ; +C -1 ; WX 500 ; N adieresis ; B 25 -14 488 667 ; +C -1 ; WX 444 ; N edieresis ; B 25 -14 426 667 ; +C -1 ; WX 444 ; N cacute ; B 25 -14 430 713 ; +C -1 ; WX 556 ; N nacute ; B 21 0 539 713 ; +C -1 ; WX 556 ; N umacron ; B 16 -14 537 637 ; +C -1 ; WX 722 ; N Ncaron ; B 16 -18 701 914 ; +C -1 ; WX 389 ; N Iacute ; B 20 0 370 923 ; +C -1 ; WX 570 ; N plusminus ; B 33 0 537 506 ; +C -1 ; WX 220 ; N brokenbar ; B 66 -143 154 707 ; +C -1 ; WX 747 ; N registered ; B 26 -19 721 691 ; +C -1 ; WX 778 ; N Gbreve ; B 37 -19 755 901 ; +C -1 ; WX 389 ; N Idotaccent ; B 20 0 370 901 ; +C -1 ; WX 600 ; N summation ; B 14 -10 585 706 ; +C -1 ; WX 667 ; N Egrave ; B 16 0 641 923 ; +C -1 ; WX 444 ; N racute ; B 29 0 434 713 ; +C -1 ; WX 500 ; N omacron ; B 25 -14 476 637 ; +C -1 ; WX 667 ; N Zacute ; B 28 0 634 923 ; +C -1 ; WX 667 ; N Zcaron ; B 28 0 634 914 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 704 ; +C -1 ; WX 722 ; N Eth ; B 6 0 690 676 ; +C -1 ; WX 722 ; N Ccedilla ; B 49 -218 687 691 ; +C -1 ; WX 278 ; N lcommaaccent ; B 16 -218 255 676 ; +C -1 ; WX 416 ; N tcaron ; B 20 -12 425 815 ; +C -1 ; WX 444 ; N eogonek ; B 25 -193 426 473 ; +C -1 ; WX 722 ; N Uogonek ; B 16 -193 701 676 ; +C -1 ; WX 722 ; N Aacute ; B 9 0 689 923 ; +C -1 ; WX 722 ; N Adieresis ; B 9 0 689 877 ; +C -1 ; WX 444 ; N egrave ; B 25 -14 426 713 ; +C -1 ; WX 444 ; N zacute ; B 21 0 420 713 ; +C -1 ; WX 278 ; N iogonek ; B 16 -193 274 691 ; +C -1 ; WX 778 ; N Oacute ; B 35 -19 743 923 ; +C -1 ; WX 500 ; N oacute ; B 25 -14 476 713 ; +C -1 ; WX 500 ; N amacron ; B 25 -14 488 637 ; +C -1 ; WX 389 ; N sacute ; B 25 -14 361 713 ; +C -1 ; WX 278 ; N idieresis ; B -37 0 300 667 ; +C -1 ; WX 778 ; N Ocircumflex ; B 35 -19 743 914 ; +C -1 ; WX 722 ; N Ugrave ; B 16 -19 701 923 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 556 ; N thorn ; B 19 -205 524 676 ; +C -1 ; WX 300 ; N twosuperior ; B 0 275 300 688 ; +C -1 ; WX 778 ; N Odieresis ; B 35 -19 743 877 ; +C -1 ; WX 556 ; N mu ; B 33 -206 536 461 ; +C -1 ; WX 278 ; N igrave ; B -27 0 255 713 ; +C -1 ; WX 500 ; N ohungarumlaut ; B 25 -14 529 713 ; +C -1 ; WX 667 ; N Eogonek ; B 16 -193 644 676 ; +C -1 ; WX 556 ; N dcroat ; B 25 -14 534 676 ; +C -1 ; WX 750 ; N threequarters ; B 23 -12 733 688 ; +C -1 ; WX 556 ; N Scedilla ; B 35 -218 513 692 ; +C -1 ; WX 394 ; N lcaron ; B 16 0 412 682 ; +C -1 ; WX 778 ; N Kcommaaccent ; B 30 -218 769 676 ; +C -1 ; WX 667 ; N Lacute ; B 19 0 638 923 ; +C -1 ; WX 1000 ; N trademark ; B 24 271 977 676 ; +C -1 ; WX 444 ; N edotaccent ; B 25 -14 426 691 ; +C -1 ; WX 389 ; N Igrave ; B 20 0 370 923 ; +C -1 ; WX 389 ; N Imacron ; B 20 0 370 847 ; +C -1 ; WX 667 ; N Lcaron ; B 19 0 652 682 ; +C -1 ; WX 750 ; N onehalf ; B -7 -12 775 688 ; +C -1 ; WX 549 ; N lessequal ; B 29 0 526 704 ; +C -1 ; WX 500 ; N ocircumflex ; B 25 -14 476 704 ; +C -1 ; WX 556 ; N ntilde ; B 21 0 539 674 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 16 -19 701 923 ; +C -1 ; WX 667 ; N Eacute ; B 16 0 641 923 ; +C -1 ; WX 444 ; N emacron ; B 25 -14 426 637 ; +C -1 ; WX 500 ; N gbreve ; B 28 -206 483 691 ; +C -1 ; WX 750 ; N onequarter ; B 28 -12 743 688 ; +C -1 ; WX 556 ; N Scaron ; B 35 -19 513 914 ; +C -1 ; WX 556 ; N Scommaaccent ; B 35 -218 513 692 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 35 -19 743 923 ; +C -1 ; WX 400 ; N degree ; B 57 402 343 688 ; +C -1 ; WX 500 ; N ograve ; B 25 -14 476 713 ; +C -1 ; WX 722 ; N Ccaron ; B 49 -19 687 914 ; +C -1 ; WX 556 ; N ugrave ; B 16 -14 537 713 ; +C -1 ; WX 549 ; N radical ; B 10 -46 512 850 ; +C -1 ; WX 722 ; N Dcaron ; B 14 0 690 914 ; +C -1 ; WX 444 ; N rcommaaccent ; B 29 -218 434 473 ; +C -1 ; WX 722 ; N Ntilde ; B 16 -18 701 884 ; +C -1 ; WX 500 ; N otilde ; B 25 -14 476 674 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 26 -218 715 676 ; +C -1 ; WX 667 ; N Lcommaaccent ; B 19 -218 638 676 ; +C -1 ; WX 722 ; N Atilde ; B 9 0 689 884 ; +C -1 ; WX 722 ; N Aogonek ; B 9 -193 699 690 ; +C -1 ; WX 722 ; N Aring ; B 9 0 689 935 ; +C -1 ; WX 778 ; N Otilde ; B 35 -19 743 884 ; +C -1 ; WX 444 ; N zdotaccent ; B 21 0 420 691 ; +C -1 ; WX 667 ; N Ecaron ; B 16 0 641 914 ; +C -1 ; WX 389 ; N Iogonek ; B 20 -193 370 676 ; +C -1 ; WX 556 ; N kcommaaccent ; B 22 -218 543 676 ; +C -1 ; WX 570 ; N minus ; B 33 209 537 297 ; +C -1 ; WX 389 ; N Icircumflex ; B 20 0 370 914 ; +C -1 ; WX 556 ; N ncaron ; B 21 0 539 704 ; +C -1 ; WX 333 ; N tcommaaccent ; B 20 -218 332 630 ; +C -1 ; WX 570 ; N logicalnot ; B 33 108 537 399 ; +C -1 ; WX 500 ; N odieresis ; B 25 -14 476 667 ; +C -1 ; WX 556 ; N udieresis ; B 16 -14 537 667 ; +C -1 ; WX 549 ; N notequal ; B 15 -49 540 570 ; +C -1 ; WX 500 ; N gcommaaccent ; B 28 -206 483 829 ; +C -1 ; WX 500 ; N eth ; B 25 -14 476 691 ; +C -1 ; WX 444 ; N zcaron ; B 21 0 420 704 ; +C -1 ; WX 556 ; N ncommaaccent ; B 21 -218 539 473 ; +C -1 ; WX 300 ; N onesuperior ; B 28 275 273 688 ; +C -1 ; WX 278 ; N imacron ; B -8 0 272 637 ; +C -1 ; WX 500 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2242 +KPX A C -55 +KPX A Cacute -55 +KPX A Ccaron -55 +KPX A Ccedilla -55 +KPX A G -55 +KPX A Gbreve -55 +KPX A Gcommaaccent -55 +KPX A O -45 +KPX A Oacute -45 +KPX A Ocircumflex -45 +KPX A Odieresis -45 +KPX A Ograve -45 +KPX A Ohungarumlaut -45 +KPX A Omacron -45 +KPX A Oslash -45 +KPX A Otilde -45 +KPX A Q -45 +KPX A T -95 +KPX A Tcaron -95 +KPX A Tcommaaccent -95 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -145 +KPX A W -130 +KPX A Y -100 +KPX A Yacute -100 +KPX A Ydieresis -100 +KPX A p -25 +KPX A quoteright -74 +KPX A u -50 +KPX A uacute -50 +KPX A ucircumflex -50 +KPX A udieresis -50 +KPX A ugrave -50 +KPX A uhungarumlaut -50 +KPX A umacron -50 +KPX A uogonek -50 +KPX A uring -50 +KPX A v -100 +KPX A w -90 +KPX A y -74 +KPX A yacute -74 +KPX A ydieresis -74 +KPX Aacute C -55 +KPX Aacute Cacute -55 +KPX Aacute Ccaron -55 +KPX Aacute Ccedilla -55 +KPX Aacute G -55 +KPX Aacute Gbreve -55 +KPX Aacute Gcommaaccent -55 +KPX Aacute O -45 +KPX Aacute Oacute -45 +KPX Aacute Ocircumflex -45 +KPX Aacute Odieresis -45 +KPX Aacute Ograve -45 +KPX Aacute Ohungarumlaut -45 +KPX Aacute Omacron -45 +KPX Aacute Oslash -45 +KPX Aacute Otilde -45 +KPX Aacute Q -45 +KPX Aacute T -95 +KPX Aacute Tcaron -95 +KPX Aacute Tcommaaccent -95 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -145 +KPX Aacute W -130 +KPX Aacute Y -100 +KPX Aacute Yacute -100 +KPX Aacute Ydieresis -100 +KPX Aacute p -25 +KPX Aacute quoteright -74 +KPX Aacute u -50 +KPX Aacute uacute -50 +KPX Aacute ucircumflex -50 +KPX Aacute udieresis -50 +KPX Aacute ugrave -50 +KPX Aacute uhungarumlaut -50 +KPX Aacute umacron -50 +KPX Aacute uogonek -50 +KPX Aacute uring -50 +KPX Aacute v -100 +KPX Aacute w -90 +KPX Aacute y -74 +KPX Aacute yacute -74 +KPX Aacute ydieresis -74 +KPX Abreve C -55 +KPX Abreve Cacute -55 +KPX Abreve Ccaron -55 +KPX Abreve Ccedilla -55 +KPX Abreve G -55 +KPX Abreve Gbreve -55 +KPX Abreve Gcommaaccent -55 +KPX Abreve O -45 +KPX Abreve Oacute -45 +KPX Abreve Ocircumflex -45 +KPX Abreve Odieresis -45 +KPX Abreve Ograve -45 +KPX Abreve Ohungarumlaut -45 +KPX Abreve Omacron -45 +KPX Abreve Oslash -45 +KPX Abreve Otilde -45 +KPX Abreve Q -45 +KPX Abreve T -95 +KPX Abreve Tcaron -95 +KPX Abreve Tcommaaccent -95 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -145 +KPX Abreve W -130 +KPX Abreve Y -100 +KPX Abreve Yacute -100 +KPX Abreve Ydieresis -100 +KPX Abreve p -25 +KPX Abreve quoteright -74 +KPX Abreve u -50 +KPX Abreve uacute -50 +KPX Abreve ucircumflex -50 +KPX Abreve udieresis -50 +KPX Abreve ugrave -50 +KPX Abreve uhungarumlaut -50 +KPX Abreve umacron -50 +KPX Abreve uogonek -50 +KPX Abreve uring -50 +KPX Abreve v -100 +KPX Abreve w -90 +KPX Abreve y -74 +KPX Abreve yacute -74 +KPX Abreve ydieresis -74 +KPX Acircumflex C -55 +KPX Acircumflex Cacute -55 +KPX Acircumflex Ccaron -55 +KPX Acircumflex Ccedilla -55 +KPX Acircumflex G -55 +KPX Acircumflex Gbreve -55 +KPX Acircumflex Gcommaaccent -55 +KPX Acircumflex O -45 +KPX Acircumflex Oacute -45 +KPX Acircumflex Ocircumflex -45 +KPX Acircumflex Odieresis -45 +KPX Acircumflex Ograve -45 +KPX Acircumflex Ohungarumlaut -45 +KPX Acircumflex Omacron -45 +KPX Acircumflex Oslash -45 +KPX Acircumflex Otilde -45 +KPX Acircumflex Q -45 +KPX Acircumflex T -95 +KPX Acircumflex Tcaron -95 +KPX Acircumflex Tcommaaccent -95 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -145 +KPX Acircumflex W -130 +KPX Acircumflex Y -100 +KPX Acircumflex Yacute -100 +KPX Acircumflex Ydieresis -100 +KPX Acircumflex p -25 +KPX Acircumflex quoteright -74 +KPX Acircumflex u -50 +KPX Acircumflex uacute -50 +KPX Acircumflex ucircumflex -50 +KPX Acircumflex udieresis -50 +KPX Acircumflex ugrave -50 +KPX Acircumflex uhungarumlaut -50 +KPX Acircumflex umacron -50 +KPX Acircumflex uogonek -50 +KPX Acircumflex uring -50 +KPX Acircumflex v -100 +KPX Acircumflex w -90 +KPX Acircumflex y -74 +KPX Acircumflex yacute -74 +KPX Acircumflex ydieresis -74 +KPX Adieresis C -55 +KPX Adieresis Cacute -55 +KPX Adieresis Ccaron -55 +KPX Adieresis Ccedilla -55 +KPX Adieresis G -55 +KPX Adieresis Gbreve -55 +KPX Adieresis Gcommaaccent -55 +KPX Adieresis O -45 +KPX Adieresis Oacute -45 +KPX Adieresis Ocircumflex -45 +KPX Adieresis Odieresis -45 +KPX Adieresis Ograve -45 +KPX Adieresis Ohungarumlaut -45 +KPX Adieresis Omacron -45 +KPX Adieresis Oslash -45 +KPX Adieresis Otilde -45 +KPX Adieresis Q -45 +KPX Adieresis T -95 +KPX Adieresis Tcaron -95 +KPX Adieresis Tcommaaccent -95 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -145 +KPX Adieresis W -130 +KPX Adieresis Y -100 +KPX Adieresis Yacute -100 +KPX Adieresis Ydieresis -100 +KPX Adieresis p -25 +KPX Adieresis quoteright -74 +KPX Adieresis u -50 +KPX Adieresis uacute -50 +KPX Adieresis ucircumflex -50 +KPX Adieresis udieresis -50 +KPX Adieresis ugrave -50 +KPX Adieresis uhungarumlaut -50 +KPX Adieresis umacron -50 +KPX Adieresis uogonek -50 +KPX Adieresis uring -50 +KPX Adieresis v -100 +KPX Adieresis w -90 +KPX Adieresis y -74 +KPX Adieresis yacute -74 +KPX Adieresis ydieresis -74 +KPX Agrave C -55 +KPX Agrave Cacute -55 +KPX Agrave Ccaron -55 +KPX Agrave Ccedilla -55 +KPX Agrave G -55 +KPX Agrave Gbreve -55 +KPX Agrave Gcommaaccent -55 +KPX Agrave O -45 +KPX Agrave Oacute -45 +KPX Agrave Ocircumflex -45 +KPX Agrave Odieresis -45 +KPX Agrave Ograve -45 +KPX Agrave Ohungarumlaut -45 +KPX Agrave Omacron -45 +KPX Agrave Oslash -45 +KPX Agrave Otilde -45 +KPX Agrave Q -45 +KPX Agrave T -95 +KPX Agrave Tcaron -95 +KPX Agrave Tcommaaccent -95 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -145 +KPX Agrave W -130 +KPX Agrave Y -100 +KPX Agrave Yacute -100 +KPX Agrave Ydieresis -100 +KPX Agrave p -25 +KPX Agrave quoteright -74 +KPX Agrave u -50 +KPX Agrave uacute -50 +KPX Agrave ucircumflex -50 +KPX Agrave udieresis -50 +KPX Agrave ugrave -50 +KPX Agrave uhungarumlaut -50 +KPX Agrave umacron -50 +KPX Agrave uogonek -50 +KPX Agrave uring -50 +KPX Agrave v -100 +KPX Agrave w -90 +KPX Agrave y -74 +KPX Agrave yacute -74 +KPX Agrave ydieresis -74 +KPX Amacron C -55 +KPX Amacron Cacute -55 +KPX Amacron Ccaron -55 +KPX Amacron Ccedilla -55 +KPX Amacron G -55 +KPX Amacron Gbreve -55 +KPX Amacron Gcommaaccent -55 +KPX Amacron O -45 +KPX Amacron Oacute -45 +KPX Amacron Ocircumflex -45 +KPX Amacron Odieresis -45 +KPX Amacron Ograve -45 +KPX Amacron Ohungarumlaut -45 +KPX Amacron Omacron -45 +KPX Amacron Oslash -45 +KPX Amacron Otilde -45 +KPX Amacron Q -45 +KPX Amacron T -95 +KPX Amacron Tcaron -95 +KPX Amacron Tcommaaccent -95 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -145 +KPX Amacron W -130 +KPX Amacron Y -100 +KPX Amacron Yacute -100 +KPX Amacron Ydieresis -100 +KPX Amacron p -25 +KPX Amacron quoteright -74 +KPX Amacron u -50 +KPX Amacron uacute -50 +KPX Amacron ucircumflex -50 +KPX Amacron udieresis -50 +KPX Amacron ugrave -50 +KPX Amacron uhungarumlaut -50 +KPX Amacron umacron -50 +KPX Amacron uogonek -50 +KPX Amacron uring -50 +KPX Amacron v -100 +KPX Amacron w -90 +KPX Amacron y -74 +KPX Amacron yacute -74 +KPX Amacron ydieresis -74 +KPX Aogonek C -55 +KPX Aogonek Cacute -55 +KPX Aogonek Ccaron -55 +KPX Aogonek Ccedilla -55 +KPX Aogonek G -55 +KPX Aogonek Gbreve -55 +KPX Aogonek Gcommaaccent -55 +KPX Aogonek O -45 +KPX Aogonek Oacute -45 +KPX Aogonek Ocircumflex -45 +KPX Aogonek Odieresis -45 +KPX Aogonek Ograve -45 +KPX Aogonek Ohungarumlaut -45 +KPX Aogonek Omacron -45 +KPX Aogonek Oslash -45 +KPX Aogonek Otilde -45 +KPX Aogonek Q -45 +KPX Aogonek T -95 +KPX Aogonek Tcaron -95 +KPX Aogonek Tcommaaccent -95 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -145 +KPX Aogonek W -130 +KPX Aogonek Y -100 +KPX Aogonek Yacute -100 +KPX Aogonek Ydieresis -100 +KPX Aogonek p -25 +KPX Aogonek quoteright -74 +KPX Aogonek u -50 +KPX Aogonek uacute -50 +KPX Aogonek ucircumflex -50 +KPX Aogonek udieresis -50 +KPX Aogonek ugrave -50 +KPX Aogonek uhungarumlaut -50 +KPX Aogonek umacron -50 +KPX Aogonek uogonek -50 +KPX Aogonek uring -50 +KPX Aogonek v -100 +KPX Aogonek w -90 +KPX Aogonek y -34 +KPX Aogonek yacute -34 +KPX Aogonek ydieresis -34 +KPX Aring C -55 +KPX Aring Cacute -55 +KPX Aring Ccaron -55 +KPX Aring Ccedilla -55 +KPX Aring G -55 +KPX Aring Gbreve -55 +KPX Aring Gcommaaccent -55 +KPX Aring O -45 +KPX Aring Oacute -45 +KPX Aring Ocircumflex -45 +KPX Aring Odieresis -45 +KPX Aring Ograve -45 +KPX Aring Ohungarumlaut -45 +KPX Aring Omacron -45 +KPX Aring Oslash -45 +KPX Aring Otilde -45 +KPX Aring Q -45 +KPX Aring T -95 +KPX Aring Tcaron -95 +KPX Aring Tcommaaccent -95 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -145 +KPX Aring W -130 +KPX Aring Y -100 +KPX Aring Yacute -100 +KPX Aring Ydieresis -100 +KPX Aring p -25 +KPX Aring quoteright -74 +KPX Aring u -50 +KPX Aring uacute -50 +KPX Aring ucircumflex -50 +KPX Aring udieresis -50 +KPX Aring ugrave -50 +KPX Aring uhungarumlaut -50 +KPX Aring umacron -50 +KPX Aring uogonek -50 +KPX Aring uring -50 +KPX Aring v -100 +KPX Aring w -90 +KPX Aring y -74 +KPX Aring yacute -74 +KPX Aring ydieresis -74 +KPX Atilde C -55 +KPX Atilde Cacute -55 +KPX Atilde Ccaron -55 +KPX Atilde Ccedilla -55 +KPX Atilde G -55 +KPX Atilde Gbreve -55 +KPX Atilde Gcommaaccent -55 +KPX Atilde O -45 +KPX Atilde Oacute -45 +KPX Atilde Ocircumflex -45 +KPX Atilde Odieresis -45 +KPX Atilde Ograve -45 +KPX Atilde Ohungarumlaut -45 +KPX Atilde Omacron -45 +KPX Atilde Oslash -45 +KPX Atilde Otilde -45 +KPX Atilde Q -45 +KPX Atilde T -95 +KPX Atilde Tcaron -95 +KPX Atilde Tcommaaccent -95 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -145 +KPX Atilde W -130 +KPX Atilde Y -100 +KPX Atilde Yacute -100 +KPX Atilde Ydieresis -100 +KPX Atilde p -25 +KPX Atilde quoteright -74 +KPX Atilde u -50 +KPX Atilde uacute -50 +KPX Atilde ucircumflex -50 +KPX Atilde udieresis -50 +KPX Atilde ugrave -50 +KPX Atilde uhungarumlaut -50 +KPX Atilde umacron -50 +KPX Atilde uogonek -50 +KPX Atilde uring -50 +KPX Atilde v -100 +KPX Atilde w -90 +KPX Atilde y -74 +KPX Atilde yacute -74 +KPX Atilde ydieresis -74 +KPX B A -30 +KPX B Aacute -30 +KPX B Abreve -30 +KPX B Acircumflex -30 +KPX B Adieresis -30 +KPX B Agrave -30 +KPX B Amacron -30 +KPX B Aogonek -30 +KPX B Aring -30 +KPX B Atilde -30 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -35 +KPX D Aacute -35 +KPX D Abreve -35 +KPX D Acircumflex -35 +KPX D Adieresis -35 +KPX D Agrave -35 +KPX D Amacron -35 +KPX D Aogonek -35 +KPX D Aring -35 +KPX D Atilde -35 +KPX D V -40 +KPX D W -40 +KPX D Y -40 +KPX D Yacute -40 +KPX D Ydieresis -40 +KPX D period -20 +KPX Dcaron A -35 +KPX Dcaron Aacute -35 +KPX Dcaron Abreve -35 +KPX Dcaron Acircumflex -35 +KPX Dcaron Adieresis -35 +KPX Dcaron Agrave -35 +KPX Dcaron Amacron -35 +KPX Dcaron Aogonek -35 +KPX Dcaron Aring -35 +KPX Dcaron Atilde -35 +KPX Dcaron V -40 +KPX Dcaron W -40 +KPX Dcaron Y -40 +KPX Dcaron Yacute -40 +KPX Dcaron Ydieresis -40 +KPX Dcaron period -20 +KPX Dcroat A -35 +KPX Dcroat Aacute -35 +KPX Dcroat Abreve -35 +KPX Dcroat Acircumflex -35 +KPX Dcroat Adieresis -35 +KPX Dcroat Agrave -35 +KPX Dcroat Amacron -35 +KPX Dcroat Aogonek -35 +KPX Dcroat Aring -35 +KPX Dcroat Atilde -35 +KPX Dcroat V -40 +KPX Dcroat W -40 +KPX Dcroat Y -40 +KPX Dcroat Yacute -40 +KPX Dcroat Ydieresis -40 +KPX Dcroat period -20 +KPX F A -90 +KPX F Aacute -90 +KPX F Abreve -90 +KPX F Acircumflex -90 +KPX F Adieresis -90 +KPX F Agrave -90 +KPX F Amacron -90 +KPX F Aogonek -90 +KPX F Aring -90 +KPX F Atilde -90 +KPX F a -25 +KPX F aacute -25 +KPX F abreve -25 +KPX F acircumflex -25 +KPX F adieresis -25 +KPX F agrave -25 +KPX F amacron -25 +KPX F aogonek -25 +KPX F aring -25 +KPX F atilde -25 +KPX F comma -92 +KPX F e -25 +KPX F eacute -25 +KPX F ecaron -25 +KPX F ecircumflex -25 +KPX F edieresis -25 +KPX F edotaccent -25 +KPX F egrave -25 +KPX F emacron -25 +KPX F eogonek -25 +KPX F o -25 +KPX F oacute -25 +KPX F ocircumflex -25 +KPX F odieresis -25 +KPX F ograve -25 +KPX F ohungarumlaut -25 +KPX F omacron -25 +KPX F oslash -25 +KPX F otilde -25 +KPX F period -110 +KPX J A -30 +KPX J Aacute -30 +KPX J Abreve -30 +KPX J Acircumflex -30 +KPX J Adieresis -30 +KPX J Agrave -30 +KPX J Amacron -30 +KPX J Aogonek -30 +KPX J Aring -30 +KPX J Atilde -30 +KPX J a -15 +KPX J aacute -15 +KPX J abreve -15 +KPX J acircumflex -15 +KPX J adieresis -15 +KPX J agrave -15 +KPX J amacron -15 +KPX J aogonek -15 +KPX J aring -15 +KPX J atilde -15 +KPX J e -15 +KPX J eacute -15 +KPX J ecaron -15 +KPX J ecircumflex -15 +KPX J edieresis -15 +KPX J edotaccent -15 +KPX J egrave -15 +KPX J emacron -15 +KPX J eogonek -15 +KPX J o -15 +KPX J oacute -15 +KPX J ocircumflex -15 +KPX J odieresis -15 +KPX J ograve -15 +KPX J ohungarumlaut -15 +KPX J omacron -15 +KPX J oslash -15 +KPX J otilde -15 +KPX J period -20 +KPX J u -15 +KPX J uacute -15 +KPX J ucircumflex -15 +KPX J udieresis -15 +KPX J ugrave -15 +KPX J uhungarumlaut -15 +KPX J umacron -15 +KPX J uogonek -15 +KPX J uring -15 +KPX K O -30 +KPX K Oacute -30 +KPX K Ocircumflex -30 +KPX K Odieresis -30 +KPX K Ograve -30 +KPX K Ohungarumlaut -30 +KPX K Omacron -30 +KPX K Oslash -30 +KPX K Otilde -30 +KPX K e -25 +KPX K eacute -25 +KPX K ecaron -25 +KPX K ecircumflex -25 +KPX K edieresis -25 +KPX K edotaccent -25 +KPX K egrave -25 +KPX K emacron -25 +KPX K eogonek -25 +KPX K o -25 +KPX K oacute -25 +KPX K ocircumflex -25 +KPX K odieresis -25 +KPX K ograve -25 +KPX K ohungarumlaut -25 +KPX K omacron -25 +KPX K oslash -25 +KPX K otilde -25 +KPX K u -15 +KPX K uacute -15 +KPX K ucircumflex -15 +KPX K udieresis -15 +KPX K ugrave -15 +KPX K uhungarumlaut -15 +KPX K umacron -15 +KPX K uogonek -15 +KPX K uring -15 +KPX K y -45 +KPX K yacute -45 +KPX K ydieresis -45 +KPX Kcommaaccent O -30 +KPX Kcommaaccent Oacute -30 +KPX Kcommaaccent Ocircumflex -30 +KPX Kcommaaccent Odieresis -30 +KPX Kcommaaccent Ograve -30 +KPX Kcommaaccent Ohungarumlaut -30 +KPX Kcommaaccent Omacron -30 +KPX Kcommaaccent Oslash -30 +KPX Kcommaaccent Otilde -30 +KPX Kcommaaccent e -25 +KPX Kcommaaccent eacute -25 +KPX Kcommaaccent ecaron -25 +KPX Kcommaaccent ecircumflex -25 +KPX Kcommaaccent edieresis -25 +KPX Kcommaaccent edotaccent -25 +KPX Kcommaaccent egrave -25 +KPX Kcommaaccent emacron -25 +KPX Kcommaaccent eogonek -25 +KPX Kcommaaccent o -25 +KPX Kcommaaccent oacute -25 +KPX Kcommaaccent ocircumflex -25 +KPX Kcommaaccent odieresis -25 +KPX Kcommaaccent ograve -25 +KPX Kcommaaccent ohungarumlaut -25 +KPX Kcommaaccent omacron -25 +KPX Kcommaaccent oslash -25 +KPX Kcommaaccent otilde -25 +KPX Kcommaaccent u -15 +KPX Kcommaaccent uacute -15 +KPX Kcommaaccent ucircumflex -15 +KPX Kcommaaccent udieresis -15 +KPX Kcommaaccent ugrave -15 +KPX Kcommaaccent uhungarumlaut -15 +KPX Kcommaaccent umacron -15 +KPX Kcommaaccent uogonek -15 +KPX Kcommaaccent uring -15 +KPX Kcommaaccent y -45 +KPX Kcommaaccent yacute -45 +KPX Kcommaaccent ydieresis -45 +KPX L T -92 +KPX L Tcaron -92 +KPX L Tcommaaccent -92 +KPX L V -92 +KPX L W -92 +KPX L Y -92 +KPX L Yacute -92 +KPX L Ydieresis -92 +KPX L quotedblright -20 +KPX L quoteright -110 +KPX L y -55 +KPX L yacute -55 +KPX L ydieresis -55 +KPX Lacute T -92 +KPX Lacute Tcaron -92 +KPX Lacute Tcommaaccent -92 +KPX Lacute V -92 +KPX Lacute W -92 +KPX Lacute Y -92 +KPX Lacute Yacute -92 +KPX Lacute Ydieresis -92 +KPX Lacute quotedblright -20 +KPX Lacute quoteright -110 +KPX Lacute y -55 +KPX Lacute yacute -55 +KPX Lacute ydieresis -55 +KPX Lcommaaccent T -92 +KPX Lcommaaccent Tcaron -92 +KPX Lcommaaccent Tcommaaccent -92 +KPX Lcommaaccent V -92 +KPX Lcommaaccent W -92 +KPX Lcommaaccent Y -92 +KPX Lcommaaccent Yacute -92 +KPX Lcommaaccent Ydieresis -92 +KPX Lcommaaccent quotedblright -20 +KPX Lcommaaccent quoteright -110 +KPX Lcommaaccent y -55 +KPX Lcommaaccent yacute -55 +KPX Lcommaaccent ydieresis -55 +KPX Lslash T -92 +KPX Lslash Tcaron -92 +KPX Lslash Tcommaaccent -92 +KPX Lslash V -92 +KPX Lslash W -92 +KPX Lslash Y -92 +KPX Lslash Yacute -92 +KPX Lslash Ydieresis -92 +KPX Lslash quotedblright -20 +KPX Lslash quoteright -110 +KPX Lslash y -55 +KPX Lslash yacute -55 +KPX Lslash ydieresis -55 +KPX N A -20 +KPX N Aacute -20 +KPX N Abreve -20 +KPX N Acircumflex -20 +KPX N Adieresis -20 +KPX N Agrave -20 +KPX N Amacron -20 +KPX N Aogonek -20 +KPX N Aring -20 +KPX N Atilde -20 +KPX Nacute A -20 +KPX Nacute Aacute -20 +KPX Nacute Abreve -20 +KPX Nacute Acircumflex -20 +KPX Nacute Adieresis -20 +KPX Nacute Agrave -20 +KPX Nacute Amacron -20 +KPX Nacute Aogonek -20 +KPX Nacute Aring -20 +KPX Nacute Atilde -20 +KPX Ncaron A -20 +KPX Ncaron Aacute -20 +KPX Ncaron Abreve -20 +KPX Ncaron Acircumflex -20 +KPX Ncaron Adieresis -20 +KPX Ncaron Agrave -20 +KPX Ncaron Amacron -20 +KPX Ncaron Aogonek -20 +KPX Ncaron Aring -20 +KPX Ncaron Atilde -20 +KPX Ncommaaccent A -20 +KPX Ncommaaccent Aacute -20 +KPX Ncommaaccent Abreve -20 +KPX Ncommaaccent Acircumflex -20 +KPX Ncommaaccent Adieresis -20 +KPX Ncommaaccent Agrave -20 +KPX Ncommaaccent Amacron -20 +KPX Ncommaaccent Aogonek -20 +KPX Ncommaaccent Aring -20 +KPX Ncommaaccent Atilde -20 +KPX Ntilde A -20 +KPX Ntilde Aacute -20 +KPX Ntilde Abreve -20 +KPX Ntilde Acircumflex -20 +KPX Ntilde Adieresis -20 +KPX Ntilde Agrave -20 +KPX Ntilde Amacron -20 +KPX Ntilde Aogonek -20 +KPX Ntilde Aring -20 +KPX Ntilde Atilde -20 +KPX O A -40 +KPX O Aacute -40 +KPX O Abreve -40 +KPX O Acircumflex -40 +KPX O Adieresis -40 +KPX O Agrave -40 +KPX O Amacron -40 +KPX O Aogonek -40 +KPX O Aring -40 +KPX O Atilde -40 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -50 +KPX O X -40 +KPX O Y -50 +KPX O Yacute -50 +KPX O Ydieresis -50 +KPX Oacute A -40 +KPX Oacute Aacute -40 +KPX Oacute Abreve -40 +KPX Oacute Acircumflex -40 +KPX Oacute Adieresis -40 +KPX Oacute Agrave -40 +KPX Oacute Amacron -40 +KPX Oacute Aogonek -40 +KPX Oacute Aring -40 +KPX Oacute Atilde -40 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -50 +KPX Oacute X -40 +KPX Oacute Y -50 +KPX Oacute Yacute -50 +KPX Oacute Ydieresis -50 +KPX Ocircumflex A -40 +KPX Ocircumflex Aacute -40 +KPX Ocircumflex Abreve -40 +KPX Ocircumflex Acircumflex -40 +KPX Ocircumflex Adieresis -40 +KPX Ocircumflex Agrave -40 +KPX Ocircumflex Amacron -40 +KPX Ocircumflex Aogonek -40 +KPX Ocircumflex Aring -40 +KPX Ocircumflex Atilde -40 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -50 +KPX Ocircumflex X -40 +KPX Ocircumflex Y -50 +KPX Ocircumflex Yacute -50 +KPX Ocircumflex Ydieresis -50 +KPX Odieresis A -40 +KPX Odieresis Aacute -40 +KPX Odieresis Abreve -40 +KPX Odieresis Acircumflex -40 +KPX Odieresis Adieresis -40 +KPX Odieresis Agrave -40 +KPX Odieresis Amacron -40 +KPX Odieresis Aogonek -40 +KPX Odieresis Aring -40 +KPX Odieresis Atilde -40 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -50 +KPX Odieresis X -40 +KPX Odieresis Y -50 +KPX Odieresis Yacute -50 +KPX Odieresis Ydieresis -50 +KPX Ograve A -40 +KPX Ograve Aacute -40 +KPX Ograve Abreve -40 +KPX Ograve Acircumflex -40 +KPX Ograve Adieresis -40 +KPX Ograve Agrave -40 +KPX Ograve Amacron -40 +KPX Ograve Aogonek -40 +KPX Ograve Aring -40 +KPX Ograve Atilde -40 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -50 +KPX Ograve X -40 +KPX Ograve Y -50 +KPX Ograve Yacute -50 +KPX Ograve Ydieresis -50 +KPX Ohungarumlaut A -40 +KPX Ohungarumlaut Aacute -40 +KPX Ohungarumlaut Abreve -40 +KPX Ohungarumlaut Acircumflex -40 +KPX Ohungarumlaut Adieresis -40 +KPX Ohungarumlaut Agrave -40 +KPX Ohungarumlaut Amacron -40 +KPX Ohungarumlaut Aogonek -40 +KPX Ohungarumlaut Aring -40 +KPX Ohungarumlaut Atilde -40 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -50 +KPX Ohungarumlaut X -40 +KPX Ohungarumlaut Y -50 +KPX Ohungarumlaut Yacute -50 +KPX Ohungarumlaut Ydieresis -50 +KPX Omacron A -40 +KPX Omacron Aacute -40 +KPX Omacron Abreve -40 +KPX Omacron Acircumflex -40 +KPX Omacron Adieresis -40 +KPX Omacron Agrave -40 +KPX Omacron Amacron -40 +KPX Omacron Aogonek -40 +KPX Omacron Aring -40 +KPX Omacron Atilde -40 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -50 +KPX Omacron X -40 +KPX Omacron Y -50 +KPX Omacron Yacute -50 +KPX Omacron Ydieresis -50 +KPX Oslash A -40 +KPX Oslash Aacute -40 +KPX Oslash Abreve -40 +KPX Oslash Acircumflex -40 +KPX Oslash Adieresis -40 +KPX Oslash Agrave -40 +KPX Oslash Amacron -40 +KPX Oslash Aogonek -40 +KPX Oslash Aring -40 +KPX Oslash Atilde -40 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -50 +KPX Oslash X -40 +KPX Oslash Y -50 +KPX Oslash Yacute -50 +KPX Oslash Ydieresis -50 +KPX Otilde A -40 +KPX Otilde Aacute -40 +KPX Otilde Abreve -40 +KPX Otilde Acircumflex -40 +KPX Otilde Adieresis -40 +KPX Otilde Agrave -40 +KPX Otilde Amacron -40 +KPX Otilde Aogonek -40 +KPX Otilde Aring -40 +KPX Otilde Atilde -40 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -50 +KPX Otilde X -40 +KPX Otilde Y -50 +KPX Otilde Yacute -50 +KPX Otilde Ydieresis -50 +KPX P A -74 +KPX P Aacute -74 +KPX P Abreve -74 +KPX P Acircumflex -74 +KPX P Adieresis -74 +KPX P Agrave -74 +KPX P Amacron -74 +KPX P Aogonek -74 +KPX P Aring -74 +KPX P Atilde -74 +KPX P a -10 +KPX P aacute -10 +KPX P abreve -10 +KPX P acircumflex -10 +KPX P adieresis -10 +KPX P agrave -10 +KPX P amacron -10 +KPX P aogonek -10 +KPX P aring -10 +KPX P atilde -10 +KPX P comma -92 +KPX P e -20 +KPX P eacute -20 +KPX P ecaron -20 +KPX P ecircumflex -20 +KPX P edieresis -20 +KPX P edotaccent -20 +KPX P egrave -20 +KPX P emacron -20 +KPX P eogonek -20 +KPX P o -20 +KPX P oacute -20 +KPX P ocircumflex -20 +KPX P odieresis -20 +KPX P ograve -20 +KPX P ohungarumlaut -20 +KPX P omacron -20 +KPX P oslash -20 +KPX P otilde -20 +KPX P period -110 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX Q period -20 +KPX R O -30 +KPX R Oacute -30 +KPX R Ocircumflex -30 +KPX R Odieresis -30 +KPX R Ograve -30 +KPX R Ohungarumlaut -30 +KPX R Omacron -30 +KPX R Oslash -30 +KPX R Otilde -30 +KPX R T -40 +KPX R Tcaron -40 +KPX R Tcommaaccent -40 +KPX R U -30 +KPX R Uacute -30 +KPX R Ucircumflex -30 +KPX R Udieresis -30 +KPX R Ugrave -30 +KPX R Uhungarumlaut -30 +KPX R Umacron -30 +KPX R Uogonek -30 +KPX R Uring -30 +KPX R V -55 +KPX R W -35 +KPX R Y -35 +KPX R Yacute -35 +KPX R Ydieresis -35 +KPX Racute O -30 +KPX Racute Oacute -30 +KPX Racute Ocircumflex -30 +KPX Racute Odieresis -30 +KPX Racute Ograve -30 +KPX Racute Ohungarumlaut -30 +KPX Racute Omacron -30 +KPX Racute Oslash -30 +KPX Racute Otilde -30 +KPX Racute T -40 +KPX Racute Tcaron -40 +KPX Racute Tcommaaccent -40 +KPX Racute U -30 +KPX Racute Uacute -30 +KPX Racute Ucircumflex -30 +KPX Racute Udieresis -30 +KPX Racute Ugrave -30 +KPX Racute Uhungarumlaut -30 +KPX Racute Umacron -30 +KPX Racute Uogonek -30 +KPX Racute Uring -30 +KPX Racute V -55 +KPX Racute W -35 +KPX Racute Y -35 +KPX Racute Yacute -35 +KPX Racute Ydieresis -35 +KPX Rcaron O -30 +KPX Rcaron Oacute -30 +KPX Rcaron Ocircumflex -30 +KPX Rcaron Odieresis -30 +KPX Rcaron Ograve -30 +KPX Rcaron Ohungarumlaut -30 +KPX Rcaron Omacron -30 +KPX Rcaron Oslash -30 +KPX Rcaron Otilde -30 +KPX Rcaron T -40 +KPX Rcaron Tcaron -40 +KPX Rcaron Tcommaaccent -40 +KPX Rcaron U -30 +KPX Rcaron Uacute -30 +KPX Rcaron Ucircumflex -30 +KPX Rcaron Udieresis -30 +KPX Rcaron Ugrave -30 +KPX Rcaron Uhungarumlaut -30 +KPX Rcaron Umacron -30 +KPX Rcaron Uogonek -30 +KPX Rcaron Uring -30 +KPX Rcaron V -55 +KPX Rcaron W -35 +KPX Rcaron Y -35 +KPX Rcaron Yacute -35 +KPX Rcaron Ydieresis -35 +KPX Rcommaaccent O -30 +KPX Rcommaaccent Oacute -30 +KPX Rcommaaccent Ocircumflex -30 +KPX Rcommaaccent Odieresis -30 +KPX Rcommaaccent Ograve -30 +KPX Rcommaaccent Ohungarumlaut -30 +KPX Rcommaaccent Omacron -30 +KPX Rcommaaccent Oslash -30 +KPX Rcommaaccent Otilde -30 +KPX Rcommaaccent T -40 +KPX Rcommaaccent Tcaron -40 +KPX Rcommaaccent Tcommaaccent -40 +KPX Rcommaaccent U -30 +KPX Rcommaaccent Uacute -30 +KPX Rcommaaccent Ucircumflex -30 +KPX Rcommaaccent Udieresis -30 +KPX Rcommaaccent Ugrave -30 +KPX Rcommaaccent Uhungarumlaut -30 +KPX Rcommaaccent Umacron -30 +KPX Rcommaaccent Uogonek -30 +KPX Rcommaaccent Uring -30 +KPX Rcommaaccent V -55 +KPX Rcommaaccent W -35 +KPX Rcommaaccent Y -35 +KPX Rcommaaccent Yacute -35 +KPX Rcommaaccent Ydieresis -35 +KPX T A -90 +KPX T Aacute -90 +KPX T Abreve -90 +KPX T Acircumflex -90 +KPX T Adieresis -90 +KPX T Agrave -90 +KPX T Amacron -90 +KPX T Aogonek -90 +KPX T Aring -90 +KPX T Atilde -90 +KPX T O -18 +KPX T Oacute -18 +KPX T Ocircumflex -18 +KPX T Odieresis -18 +KPX T Ograve -18 +KPX T Ohungarumlaut -18 +KPX T Omacron -18 +KPX T Oslash -18 +KPX T Otilde -18 +KPX T a -92 +KPX T aacute -92 +KPX T abreve -52 +KPX T acircumflex -52 +KPX T adieresis -52 +KPX T agrave -52 +KPX T amacron -52 +KPX T aogonek -92 +KPX T aring -92 +KPX T atilde -52 +KPX T colon -74 +KPX T comma -74 +KPX T e -92 +KPX T eacute -92 +KPX T ecaron -92 +KPX T ecircumflex -92 +KPX T edieresis -52 +KPX T edotaccent -92 +KPX T egrave -52 +KPX T emacron -52 +KPX T eogonek -92 +KPX T hyphen -92 +KPX T i -18 +KPX T iacute -18 +KPX T iogonek -18 +KPX T o -92 +KPX T oacute -92 +KPX T ocircumflex -92 +KPX T odieresis -92 +KPX T ograve -92 +KPX T ohungarumlaut -92 +KPX T omacron -92 +KPX T oslash -92 +KPX T otilde -92 +KPX T period -90 +KPX T r -74 +KPX T racute -74 +KPX T rcaron -74 +KPX T rcommaaccent -74 +KPX T semicolon -74 +KPX T u -92 +KPX T uacute -92 +KPX T ucircumflex -92 +KPX T udieresis -92 +KPX T ugrave -92 +KPX T uhungarumlaut -92 +KPX T umacron -92 +KPX T uogonek -92 +KPX T uring -92 +KPX T w -74 +KPX T y -34 +KPX T yacute -34 +KPX T ydieresis -34 +KPX Tcaron A -90 +KPX Tcaron Aacute -90 +KPX Tcaron Abreve -90 +KPX Tcaron Acircumflex -90 +KPX Tcaron Adieresis -90 +KPX Tcaron Agrave -90 +KPX Tcaron Amacron -90 +KPX Tcaron Aogonek -90 +KPX Tcaron Aring -90 +KPX Tcaron Atilde -90 +KPX Tcaron O -18 +KPX Tcaron Oacute -18 +KPX Tcaron Ocircumflex -18 +KPX Tcaron Odieresis -18 +KPX Tcaron Ograve -18 +KPX Tcaron Ohungarumlaut -18 +KPX Tcaron Omacron -18 +KPX Tcaron Oslash -18 +KPX Tcaron Otilde -18 +KPX Tcaron a -92 +KPX Tcaron aacute -92 +KPX Tcaron abreve -52 +KPX Tcaron acircumflex -52 +KPX Tcaron adieresis -52 +KPX Tcaron agrave -52 +KPX Tcaron amacron -52 +KPX Tcaron aogonek -92 +KPX Tcaron aring -92 +KPX Tcaron atilde -52 +KPX Tcaron colon -74 +KPX Tcaron comma -74 +KPX Tcaron e -92 +KPX Tcaron eacute -92 +KPX Tcaron ecaron -92 +KPX Tcaron ecircumflex -92 +KPX Tcaron edieresis -52 +KPX Tcaron edotaccent -92 +KPX Tcaron egrave -52 +KPX Tcaron emacron -52 +KPX Tcaron eogonek -92 +KPX Tcaron hyphen -92 +KPX Tcaron i -18 +KPX Tcaron iacute -18 +KPX Tcaron iogonek -18 +KPX Tcaron o -92 +KPX Tcaron oacute -92 +KPX Tcaron ocircumflex -92 +KPX Tcaron odieresis -92 +KPX Tcaron ograve -92 +KPX Tcaron ohungarumlaut -92 +KPX Tcaron omacron -92 +KPX Tcaron oslash -92 +KPX Tcaron otilde -92 +KPX Tcaron period -90 +KPX Tcaron r -74 +KPX Tcaron racute -74 +KPX Tcaron rcaron -74 +KPX Tcaron rcommaaccent -74 +KPX Tcaron semicolon -74 +KPX Tcaron u -92 +KPX Tcaron uacute -92 +KPX Tcaron ucircumflex -92 +KPX Tcaron udieresis -92 +KPX Tcaron ugrave -92 +KPX Tcaron uhungarumlaut -92 +KPX Tcaron umacron -92 +KPX Tcaron uogonek -92 +KPX Tcaron uring -92 +KPX Tcaron w -74 +KPX Tcaron y -34 +KPX Tcaron yacute -34 +KPX Tcaron ydieresis -34 +KPX Tcommaaccent A -90 +KPX Tcommaaccent Aacute -90 +KPX Tcommaaccent Abreve -90 +KPX Tcommaaccent Acircumflex -90 +KPX Tcommaaccent Adieresis -90 +KPX Tcommaaccent Agrave -90 +KPX Tcommaaccent Amacron -90 +KPX Tcommaaccent Aogonek -90 +KPX Tcommaaccent Aring -90 +KPX Tcommaaccent Atilde -90 +KPX Tcommaaccent O -18 +KPX Tcommaaccent Oacute -18 +KPX Tcommaaccent Ocircumflex -18 +KPX Tcommaaccent Odieresis -18 +KPX Tcommaaccent Ograve -18 +KPX Tcommaaccent Ohungarumlaut -18 +KPX Tcommaaccent Omacron -18 +KPX Tcommaaccent Oslash -18 +KPX Tcommaaccent Otilde -18 +KPX Tcommaaccent a -92 +KPX Tcommaaccent aacute -92 +KPX Tcommaaccent abreve -52 +KPX Tcommaaccent acircumflex -52 +KPX Tcommaaccent adieresis -52 +KPX Tcommaaccent agrave -52 +KPX Tcommaaccent amacron -52 +KPX Tcommaaccent aogonek -92 +KPX Tcommaaccent aring -92 +KPX Tcommaaccent atilde -52 +KPX Tcommaaccent colon -74 +KPX Tcommaaccent comma -74 +KPX Tcommaaccent e -92 +KPX Tcommaaccent eacute -92 +KPX Tcommaaccent ecaron -92 +KPX Tcommaaccent ecircumflex -92 +KPX Tcommaaccent edieresis -52 +KPX Tcommaaccent edotaccent -92 +KPX Tcommaaccent egrave -52 +KPX Tcommaaccent emacron -52 +KPX Tcommaaccent eogonek -92 +KPX Tcommaaccent hyphen -92 +KPX Tcommaaccent i -18 +KPX Tcommaaccent iacute -18 +KPX Tcommaaccent iogonek -18 +KPX Tcommaaccent o -92 +KPX Tcommaaccent oacute -92 +KPX Tcommaaccent ocircumflex -92 +KPX Tcommaaccent odieresis -92 +KPX Tcommaaccent ograve -92 +KPX Tcommaaccent ohungarumlaut -92 +KPX Tcommaaccent omacron -92 +KPX Tcommaaccent oslash -92 +KPX Tcommaaccent otilde -92 +KPX Tcommaaccent period -90 +KPX Tcommaaccent r -74 +KPX Tcommaaccent racute -74 +KPX Tcommaaccent rcaron -74 +KPX Tcommaaccent rcommaaccent -74 +KPX Tcommaaccent semicolon -74 +KPX Tcommaaccent u -92 +KPX Tcommaaccent uacute -92 +KPX Tcommaaccent ucircumflex -92 +KPX Tcommaaccent udieresis -92 +KPX Tcommaaccent ugrave -92 +KPX Tcommaaccent uhungarumlaut -92 +KPX Tcommaaccent umacron -92 +KPX Tcommaaccent uogonek -92 +KPX Tcommaaccent uring -92 +KPX Tcommaaccent w -74 +KPX Tcommaaccent y -34 +KPX Tcommaaccent yacute -34 +KPX Tcommaaccent ydieresis -34 +KPX U A -60 +KPX U Aacute -60 +KPX U Abreve -60 +KPX U Acircumflex -60 +KPX U Adieresis -60 +KPX U Agrave -60 +KPX U Amacron -60 +KPX U Aogonek -60 +KPX U Aring -60 +KPX U Atilde -60 +KPX U comma -50 +KPX U period -50 +KPX Uacute A -60 +KPX Uacute Aacute -60 +KPX Uacute Abreve -60 +KPX Uacute Acircumflex -60 +KPX Uacute Adieresis -60 +KPX Uacute Agrave -60 +KPX Uacute Amacron -60 +KPX Uacute Aogonek -60 +KPX Uacute Aring -60 +KPX Uacute Atilde -60 +KPX Uacute comma -50 +KPX Uacute period -50 +KPX Ucircumflex A -60 +KPX Ucircumflex Aacute -60 +KPX Ucircumflex Abreve -60 +KPX Ucircumflex Acircumflex -60 +KPX Ucircumflex Adieresis -60 +KPX Ucircumflex Agrave -60 +KPX Ucircumflex Amacron -60 +KPX Ucircumflex Aogonek -60 +KPX Ucircumflex Aring -60 +KPX Ucircumflex Atilde -60 +KPX Ucircumflex comma -50 +KPX Ucircumflex period -50 +KPX Udieresis A -60 +KPX Udieresis Aacute -60 +KPX Udieresis Abreve -60 +KPX Udieresis Acircumflex -60 +KPX Udieresis Adieresis -60 +KPX Udieresis Agrave -60 +KPX Udieresis Amacron -60 +KPX Udieresis Aogonek -60 +KPX Udieresis Aring -60 +KPX Udieresis Atilde -60 +KPX Udieresis comma -50 +KPX Udieresis period -50 +KPX Ugrave A -60 +KPX Ugrave Aacute -60 +KPX Ugrave Abreve -60 +KPX Ugrave Acircumflex -60 +KPX Ugrave Adieresis -60 +KPX Ugrave Agrave -60 +KPX Ugrave Amacron -60 +KPX Ugrave Aogonek -60 +KPX Ugrave Aring -60 +KPX Ugrave Atilde -60 +KPX Ugrave comma -50 +KPX Ugrave period -50 +KPX Uhungarumlaut A -60 +KPX Uhungarumlaut Aacute -60 +KPX Uhungarumlaut Abreve -60 +KPX Uhungarumlaut Acircumflex -60 +KPX Uhungarumlaut Adieresis -60 +KPX Uhungarumlaut Agrave -60 +KPX Uhungarumlaut Amacron -60 +KPX Uhungarumlaut Aogonek -60 +KPX Uhungarumlaut Aring -60 +KPX Uhungarumlaut Atilde -60 +KPX Uhungarumlaut comma -50 +KPX Uhungarumlaut period -50 +KPX Umacron A -60 +KPX Umacron Aacute -60 +KPX Umacron Abreve -60 +KPX Umacron Acircumflex -60 +KPX Umacron Adieresis -60 +KPX Umacron Agrave -60 +KPX Umacron Amacron -60 +KPX Umacron Aogonek -60 +KPX Umacron Aring -60 +KPX Umacron Atilde -60 +KPX Umacron comma -50 +KPX Umacron period -50 +KPX Uogonek A -60 +KPX Uogonek Aacute -60 +KPX Uogonek Abreve -60 +KPX Uogonek Acircumflex -60 +KPX Uogonek Adieresis -60 +KPX Uogonek Agrave -60 +KPX Uogonek Amacron -60 +KPX Uogonek Aogonek -60 +KPX Uogonek Aring -60 +KPX Uogonek Atilde -60 +KPX Uogonek comma -50 +KPX Uogonek period -50 +KPX Uring A -60 +KPX Uring Aacute -60 +KPX Uring Abreve -60 +KPX Uring Acircumflex -60 +KPX Uring Adieresis -60 +KPX Uring Agrave -60 +KPX Uring Amacron -60 +KPX Uring Aogonek -60 +KPX Uring Aring -60 +KPX Uring Atilde -60 +KPX Uring comma -50 +KPX Uring period -50 +KPX V A -135 +KPX V Aacute -135 +KPX V Abreve -135 +KPX V Acircumflex -135 +KPX V Adieresis -135 +KPX V Agrave -135 +KPX V Amacron -135 +KPX V Aogonek -135 +KPX V Aring -135 +KPX V Atilde -135 +KPX V G -30 +KPX V Gbreve -30 +KPX V Gcommaaccent -30 +KPX V O -45 +KPX V Oacute -45 +KPX V Ocircumflex -45 +KPX V Odieresis -45 +KPX V Ograve -45 +KPX V Ohungarumlaut -45 +KPX V Omacron -45 +KPX V Oslash -45 +KPX V Otilde -45 +KPX V a -92 +KPX V aacute -92 +KPX V abreve -92 +KPX V acircumflex -92 +KPX V adieresis -92 +KPX V agrave -92 +KPX V amacron -92 +KPX V aogonek -92 +KPX V aring -92 +KPX V atilde -92 +KPX V colon -92 +KPX V comma -129 +KPX V e -100 +KPX V eacute -100 +KPX V ecaron -100 +KPX V ecircumflex -100 +KPX V edieresis -100 +KPX V edotaccent -100 +KPX V egrave -100 +KPX V emacron -100 +KPX V eogonek -100 +KPX V hyphen -74 +KPX V i -37 +KPX V iacute -37 +KPX V icircumflex -37 +KPX V idieresis -37 +KPX V igrave -37 +KPX V imacron -37 +KPX V iogonek -37 +KPX V o -100 +KPX V oacute -100 +KPX V ocircumflex -100 +KPX V odieresis -100 +KPX V ograve -100 +KPX V ohungarumlaut -100 +KPX V omacron -100 +KPX V oslash -100 +KPX V otilde -100 +KPX V period -145 +KPX V semicolon -92 +KPX V u -92 +KPX V uacute -92 +KPX V ucircumflex -92 +KPX V udieresis -92 +KPX V ugrave -92 +KPX V uhungarumlaut -92 +KPX V umacron -92 +KPX V uogonek -92 +KPX V uring -92 +KPX W A -120 +KPX W Aacute -120 +KPX W Abreve -120 +KPX W Acircumflex -120 +KPX W Adieresis -120 +KPX W Agrave -120 +KPX W Amacron -120 +KPX W Aogonek -120 +KPX W Aring -120 +KPX W Atilde -120 +KPX W O -10 +KPX W Oacute -10 +KPX W Ocircumflex -10 +KPX W Odieresis -10 +KPX W Ograve -10 +KPX W Ohungarumlaut -10 +KPX W Omacron -10 +KPX W Oslash -10 +KPX W Otilde -10 +KPX W a -65 +KPX W aacute -65 +KPX W abreve -65 +KPX W acircumflex -65 +KPX W adieresis -65 +KPX W agrave -65 +KPX W amacron -65 +KPX W aogonek -65 +KPX W aring -65 +KPX W atilde -65 +KPX W colon -55 +KPX W comma -92 +KPX W e -65 +KPX W eacute -65 +KPX W ecaron -65 +KPX W ecircumflex -65 +KPX W edieresis -65 +KPX W edotaccent -65 +KPX W egrave -65 +KPX W emacron -65 +KPX W eogonek -65 +KPX W hyphen -37 +KPX W i -18 +KPX W iacute -18 +KPX W iogonek -18 +KPX W o -75 +KPX W oacute -75 +KPX W ocircumflex -75 +KPX W odieresis -75 +KPX W ograve -75 +KPX W ohungarumlaut -75 +KPX W omacron -75 +KPX W oslash -75 +KPX W otilde -75 +KPX W period -92 +KPX W semicolon -55 +KPX W u -50 +KPX W uacute -50 +KPX W ucircumflex -50 +KPX W udieresis -50 +KPX W ugrave -50 +KPX W uhungarumlaut -50 +KPX W umacron -50 +KPX W uogonek -50 +KPX W uring -50 +KPX W y -60 +KPX W yacute -60 +KPX W ydieresis -60 +KPX Y A -110 +KPX Y Aacute -110 +KPX Y Abreve -110 +KPX Y Acircumflex -110 +KPX Y Adieresis -110 +KPX Y Agrave -110 +KPX Y Amacron -110 +KPX Y Aogonek -110 +KPX Y Aring -110 +KPX Y Atilde -110 +KPX Y O -35 +KPX Y Oacute -35 +KPX Y Ocircumflex -35 +KPX Y Odieresis -35 +KPX Y Ograve -35 +KPX Y Ohungarumlaut -35 +KPX Y Omacron -35 +KPX Y Oslash -35 +KPX Y Otilde -35 +KPX Y a -85 +KPX Y aacute -85 +KPX Y abreve -85 +KPX Y acircumflex -85 +KPX Y adieresis -85 +KPX Y agrave -85 +KPX Y amacron -85 +KPX Y aogonek -85 +KPX Y aring -85 +KPX Y atilde -85 +KPX Y colon -92 +KPX Y comma -92 +KPX Y e -111 +KPX Y eacute -111 +KPX Y ecaron -111 +KPX Y ecircumflex -111 +KPX Y edieresis -71 +KPX Y edotaccent -111 +KPX Y egrave -71 +KPX Y emacron -71 +KPX Y eogonek -111 +KPX Y hyphen -92 +KPX Y i -37 +KPX Y iacute -37 +KPX Y iogonek -37 +KPX Y o -111 +KPX Y oacute -111 +KPX Y ocircumflex -111 +KPX Y odieresis -111 +KPX Y ograve -111 +KPX Y ohungarumlaut -111 +KPX Y omacron -111 +KPX Y oslash -111 +KPX Y otilde -111 +KPX Y period -92 +KPX Y semicolon -92 +KPX Y u -92 +KPX Y uacute -92 +KPX Y ucircumflex -92 +KPX Y udieresis -92 +KPX Y ugrave -92 +KPX Y uhungarumlaut -92 +KPX Y umacron -92 +KPX Y uogonek -92 +KPX Y uring -92 +KPX Yacute A -110 +KPX Yacute Aacute -110 +KPX Yacute Abreve -110 +KPX Yacute Acircumflex -110 +KPX Yacute Adieresis -110 +KPX Yacute Agrave -110 +KPX Yacute Amacron -110 +KPX Yacute Aogonek -110 +KPX Yacute Aring -110 +KPX Yacute Atilde -110 +KPX Yacute O -35 +KPX Yacute Oacute -35 +KPX Yacute Ocircumflex -35 +KPX Yacute Odieresis -35 +KPX Yacute Ograve -35 +KPX Yacute Ohungarumlaut -35 +KPX Yacute Omacron -35 +KPX Yacute Oslash -35 +KPX Yacute Otilde -35 +KPX Yacute a -85 +KPX Yacute aacute -85 +KPX Yacute abreve -85 +KPX Yacute acircumflex -85 +KPX Yacute adieresis -85 +KPX Yacute agrave -85 +KPX Yacute amacron -85 +KPX Yacute aogonek -85 +KPX Yacute aring -85 +KPX Yacute atilde -85 +KPX Yacute colon -92 +KPX Yacute comma -92 +KPX Yacute e -111 +KPX Yacute eacute -111 +KPX Yacute ecaron -111 +KPX Yacute ecircumflex -111 +KPX Yacute edieresis -71 +KPX Yacute edotaccent -111 +KPX Yacute egrave -71 +KPX Yacute emacron -71 +KPX Yacute eogonek -111 +KPX Yacute hyphen -92 +KPX Yacute i -37 +KPX Yacute iacute -37 +KPX Yacute iogonek -37 +KPX Yacute o -111 +KPX Yacute oacute -111 +KPX Yacute ocircumflex -111 +KPX Yacute odieresis -111 +KPX Yacute ograve -111 +KPX Yacute ohungarumlaut -111 +KPX Yacute omacron -111 +KPX Yacute oslash -111 +KPX Yacute otilde -111 +KPX Yacute period -92 +KPX Yacute semicolon -92 +KPX Yacute u -92 +KPX Yacute uacute -92 +KPX Yacute ucircumflex -92 +KPX Yacute udieresis -92 +KPX Yacute ugrave -92 +KPX Yacute uhungarumlaut -92 +KPX Yacute umacron -92 +KPX Yacute uogonek -92 +KPX Yacute uring -92 +KPX Ydieresis A -110 +KPX Ydieresis Aacute -110 +KPX Ydieresis Abreve -110 +KPX Ydieresis Acircumflex -110 +KPX Ydieresis Adieresis -110 +KPX Ydieresis Agrave -110 +KPX Ydieresis Amacron -110 +KPX Ydieresis Aogonek -110 +KPX Ydieresis Aring -110 +KPX Ydieresis Atilde -110 +KPX Ydieresis O -35 +KPX Ydieresis Oacute -35 +KPX Ydieresis Ocircumflex -35 +KPX Ydieresis Odieresis -35 +KPX Ydieresis Ograve -35 +KPX Ydieresis Ohungarumlaut -35 +KPX Ydieresis Omacron -35 +KPX Ydieresis Oslash -35 +KPX Ydieresis Otilde -35 +KPX Ydieresis a -85 +KPX Ydieresis aacute -85 +KPX Ydieresis abreve -85 +KPX Ydieresis acircumflex -85 +KPX Ydieresis adieresis -85 +KPX Ydieresis agrave -85 +KPX Ydieresis amacron -85 +KPX Ydieresis aogonek -85 +KPX Ydieresis aring -85 +KPX Ydieresis atilde -85 +KPX Ydieresis colon -92 +KPX Ydieresis comma -92 +KPX Ydieresis e -111 +KPX Ydieresis eacute -111 +KPX Ydieresis ecaron -111 +KPX Ydieresis ecircumflex -111 +KPX Ydieresis edieresis -71 +KPX Ydieresis edotaccent -111 +KPX Ydieresis egrave -71 +KPX Ydieresis emacron -71 +KPX Ydieresis eogonek -111 +KPX Ydieresis hyphen -92 +KPX Ydieresis i -37 +KPX Ydieresis iacute -37 +KPX Ydieresis iogonek -37 +KPX Ydieresis o -111 +KPX Ydieresis oacute -111 +KPX Ydieresis ocircumflex -111 +KPX Ydieresis odieresis -111 +KPX Ydieresis ograve -111 +KPX Ydieresis ohungarumlaut -111 +KPX Ydieresis omacron -111 +KPX Ydieresis oslash -111 +KPX Ydieresis otilde -111 +KPX Ydieresis period -92 +KPX Ydieresis semicolon -92 +KPX Ydieresis u -92 +KPX Ydieresis uacute -92 +KPX Ydieresis ucircumflex -92 +KPX Ydieresis udieresis -92 +KPX Ydieresis ugrave -92 +KPX Ydieresis uhungarumlaut -92 +KPX Ydieresis umacron -92 +KPX Ydieresis uogonek -92 +KPX Ydieresis uring -92 +KPX a v -25 +KPX aacute v -25 +KPX abreve v -25 +KPX acircumflex v -25 +KPX adieresis v -25 +KPX agrave v -25 +KPX amacron v -25 +KPX aogonek v -25 +KPX aring v -25 +KPX atilde v -25 +KPX b b -10 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -15 +KPX comma quotedblright -45 +KPX comma quoteright -55 +KPX d w -15 +KPX dcroat w -15 +KPX e v -15 +KPX eacute v -15 +KPX ecaron v -15 +KPX ecircumflex v -15 +KPX edieresis v -15 +KPX edotaccent v -15 +KPX egrave v -15 +KPX emacron v -15 +KPX eogonek v -15 +KPX f comma -15 +KPX f dotlessi -35 +KPX f i -25 +KPX f o -25 +KPX f oacute -25 +KPX f ocircumflex -25 +KPX f odieresis -25 +KPX f ograve -25 +KPX f ohungarumlaut -25 +KPX f omacron -25 +KPX f oslash -25 +KPX f otilde -25 +KPX f period -15 +KPX f quotedblright 50 +KPX f quoteright 55 +KPX g period -15 +KPX gbreve period -15 +KPX gcommaaccent period -15 +KPX h y -15 +KPX h yacute -15 +KPX h ydieresis -15 +KPX i v -10 +KPX iacute v -10 +KPX icircumflex v -10 +KPX idieresis v -10 +KPX igrave v -10 +KPX imacron v -10 +KPX iogonek v -10 +KPX k e -10 +KPX k eacute -10 +KPX k ecaron -10 +KPX k ecircumflex -10 +KPX k edieresis -10 +KPX k edotaccent -10 +KPX k egrave -10 +KPX k emacron -10 +KPX k eogonek -10 +KPX k o -15 +KPX k oacute -15 +KPX k ocircumflex -15 +KPX k odieresis -15 +KPX k ograve -15 +KPX k ohungarumlaut -15 +KPX k omacron -15 +KPX k oslash -15 +KPX k otilde -15 +KPX k y -15 +KPX k yacute -15 +KPX k ydieresis -15 +KPX kcommaaccent e -10 +KPX kcommaaccent eacute -10 +KPX kcommaaccent ecaron -10 +KPX kcommaaccent ecircumflex -10 +KPX kcommaaccent edieresis -10 +KPX kcommaaccent edotaccent -10 +KPX kcommaaccent egrave -10 +KPX kcommaaccent emacron -10 +KPX kcommaaccent eogonek -10 +KPX kcommaaccent o -15 +KPX kcommaaccent oacute -15 +KPX kcommaaccent ocircumflex -15 +KPX kcommaaccent odieresis -15 +KPX kcommaaccent ograve -15 +KPX kcommaaccent ohungarumlaut -15 +KPX kcommaaccent omacron -15 +KPX kcommaaccent oslash -15 +KPX kcommaaccent otilde -15 +KPX kcommaaccent y -15 +KPX kcommaaccent yacute -15 +KPX kcommaaccent ydieresis -15 +KPX n v -40 +KPX nacute v -40 +KPX ncaron v -40 +KPX ncommaaccent v -40 +KPX ntilde v -40 +KPX o v -10 +KPX o w -10 +KPX oacute v -10 +KPX oacute w -10 +KPX ocircumflex v -10 +KPX ocircumflex w -10 +KPX odieresis v -10 +KPX odieresis w -10 +KPX ograve v -10 +KPX ograve w -10 +KPX ohungarumlaut v -10 +KPX ohungarumlaut w -10 +KPX omacron v -10 +KPX omacron w -10 +KPX oslash v -10 +KPX oslash w -10 +KPX otilde v -10 +KPX otilde w -10 +KPX period quotedblright -55 +KPX period quoteright -55 +KPX quotedblleft A -10 +KPX quotedblleft Aacute -10 +KPX quotedblleft Abreve -10 +KPX quotedblleft Acircumflex -10 +KPX quotedblleft Adieresis -10 +KPX quotedblleft Agrave -10 +KPX quotedblleft Amacron -10 +KPX quotedblleft Aogonek -10 +KPX quotedblleft Aring -10 +KPX quotedblleft Atilde -10 +KPX quoteleft A -10 +KPX quoteleft Aacute -10 +KPX quoteleft Abreve -10 +KPX quoteleft Acircumflex -10 +KPX quoteleft Adieresis -10 +KPX quoteleft Agrave -10 +KPX quoteleft Amacron -10 +KPX quoteleft Aogonek -10 +KPX quoteleft Aring -10 +KPX quoteleft Atilde -10 +KPX quoteleft quoteleft -63 +KPX quoteright d -20 +KPX quoteright dcroat -20 +KPX quoteright quoteright -63 +KPX quoteright r -20 +KPX quoteright racute -20 +KPX quoteright rcaron -20 +KPX quoteright rcommaaccent -20 +KPX quoteright s -37 +KPX quoteright sacute -37 +KPX quoteright scaron -37 +KPX quoteright scedilla -37 +KPX quoteright scommaaccent -37 +KPX quoteright space -74 +KPX quoteright v -20 +KPX r c -18 +KPX r cacute -18 +KPX r ccaron -18 +KPX r ccedilla -18 +KPX r comma -92 +KPX r e -18 +KPX r eacute -18 +KPX r ecaron -18 +KPX r ecircumflex -18 +KPX r edieresis -18 +KPX r edotaccent -18 +KPX r egrave -18 +KPX r emacron -18 +KPX r eogonek -18 +KPX r g -10 +KPX r gbreve -10 +KPX r gcommaaccent -10 +KPX r hyphen -37 +KPX r n -15 +KPX r nacute -15 +KPX r ncaron -15 +KPX r ncommaaccent -15 +KPX r ntilde -15 +KPX r o -18 +KPX r oacute -18 +KPX r ocircumflex -18 +KPX r odieresis -18 +KPX r ograve -18 +KPX r ohungarumlaut -18 +KPX r omacron -18 +KPX r oslash -18 +KPX r otilde -18 +KPX r p -10 +KPX r period -100 +KPX r q -18 +KPX r v -10 +KPX racute c -18 +KPX racute cacute -18 +KPX racute ccaron -18 +KPX racute ccedilla -18 +KPX racute comma -92 +KPX racute e -18 +KPX racute eacute -18 +KPX racute ecaron -18 +KPX racute ecircumflex -18 +KPX racute edieresis -18 +KPX racute edotaccent -18 +KPX racute egrave -18 +KPX racute emacron -18 +KPX racute eogonek -18 +KPX racute g -10 +KPX racute gbreve -10 +KPX racute gcommaaccent -10 +KPX racute hyphen -37 +KPX racute n -15 +KPX racute nacute -15 +KPX racute ncaron -15 +KPX racute ncommaaccent -15 +KPX racute ntilde -15 +KPX racute o -18 +KPX racute oacute -18 +KPX racute ocircumflex -18 +KPX racute odieresis -18 +KPX racute ograve -18 +KPX racute ohungarumlaut -18 +KPX racute omacron -18 +KPX racute oslash -18 +KPX racute otilde -18 +KPX racute p -10 +KPX racute period -100 +KPX racute q -18 +KPX racute v -10 +KPX rcaron c -18 +KPX rcaron cacute -18 +KPX rcaron ccaron -18 +KPX rcaron ccedilla -18 +KPX rcaron comma -92 +KPX rcaron e -18 +KPX rcaron eacute -18 +KPX rcaron ecaron -18 +KPX rcaron ecircumflex -18 +KPX rcaron edieresis -18 +KPX rcaron edotaccent -18 +KPX rcaron egrave -18 +KPX rcaron emacron -18 +KPX rcaron eogonek -18 +KPX rcaron g -10 +KPX rcaron gbreve -10 +KPX rcaron gcommaaccent -10 +KPX rcaron hyphen -37 +KPX rcaron n -15 +KPX rcaron nacute -15 +KPX rcaron ncaron -15 +KPX rcaron ncommaaccent -15 +KPX rcaron ntilde -15 +KPX rcaron o -18 +KPX rcaron oacute -18 +KPX rcaron ocircumflex -18 +KPX rcaron odieresis -18 +KPX rcaron ograve -18 +KPX rcaron ohungarumlaut -18 +KPX rcaron omacron -18 +KPX rcaron oslash -18 +KPX rcaron otilde -18 +KPX rcaron p -10 +KPX rcaron period -100 +KPX rcaron q -18 +KPX rcaron v -10 +KPX rcommaaccent c -18 +KPX rcommaaccent cacute -18 +KPX rcommaaccent ccaron -18 +KPX rcommaaccent ccedilla -18 +KPX rcommaaccent comma -92 +KPX rcommaaccent e -18 +KPX rcommaaccent eacute -18 +KPX rcommaaccent ecaron -18 +KPX rcommaaccent ecircumflex -18 +KPX rcommaaccent edieresis -18 +KPX rcommaaccent edotaccent -18 +KPX rcommaaccent egrave -18 +KPX rcommaaccent emacron -18 +KPX rcommaaccent eogonek -18 +KPX rcommaaccent g -10 +KPX rcommaaccent gbreve -10 +KPX rcommaaccent gcommaaccent -10 +KPX rcommaaccent hyphen -37 +KPX rcommaaccent n -15 +KPX rcommaaccent nacute -15 +KPX rcommaaccent ncaron -15 +KPX rcommaaccent ncommaaccent -15 +KPX rcommaaccent ntilde -15 +KPX rcommaaccent o -18 +KPX rcommaaccent oacute -18 +KPX rcommaaccent ocircumflex -18 +KPX rcommaaccent odieresis -18 +KPX rcommaaccent ograve -18 +KPX rcommaaccent ohungarumlaut -18 +KPX rcommaaccent omacron -18 +KPX rcommaaccent oslash -18 +KPX rcommaaccent otilde -18 +KPX rcommaaccent p -10 +KPX rcommaaccent period -100 +KPX rcommaaccent q -18 +KPX rcommaaccent v -10 +KPX space A -55 +KPX space Aacute -55 +KPX space Abreve -55 +KPX space Acircumflex -55 +KPX space Adieresis -55 +KPX space Agrave -55 +KPX space Amacron -55 +KPX space Aogonek -55 +KPX space Aring -55 +KPX space Atilde -55 +KPX space T -30 +KPX space Tcaron -30 +KPX space Tcommaaccent -30 +KPX space V -45 +KPX space W -30 +KPX space Y -55 +KPX space Yacute -55 +KPX space Ydieresis -55 +KPX v a -10 +KPX v aacute -10 +KPX v abreve -10 +KPX v acircumflex -10 +KPX v adieresis -10 +KPX v agrave -10 +KPX v amacron -10 +KPX v aogonek -10 +KPX v aring -10 +KPX v atilde -10 +KPX v comma -55 +KPX v e -10 +KPX v eacute -10 +KPX v ecaron -10 +KPX v ecircumflex -10 +KPX v edieresis -10 +KPX v edotaccent -10 +KPX v egrave -10 +KPX v emacron -10 +KPX v eogonek -10 +KPX v o -10 +KPX v oacute -10 +KPX v ocircumflex -10 +KPX v odieresis -10 +KPX v ograve -10 +KPX v ohungarumlaut -10 +KPX v omacron -10 +KPX v oslash -10 +KPX v otilde -10 +KPX v period -70 +KPX w comma -55 +KPX w o -10 +KPX w oacute -10 +KPX w ocircumflex -10 +KPX w odieresis -10 +KPX w ograve -10 +KPX w ohungarumlaut -10 +KPX w omacron -10 +KPX w oslash -10 +KPX w otilde -10 +KPX w period -70 +KPX y comma -55 +KPX y e -10 +KPX y eacute -10 +KPX y ecaron -10 +KPX y ecircumflex -10 +KPX y edieresis -10 +KPX y edotaccent -10 +KPX y egrave -10 +KPX y emacron -10 +KPX y eogonek -10 +KPX y o -25 +KPX y oacute -25 +KPX y ocircumflex -25 +KPX y odieresis -25 +KPX y ograve -25 +KPX y ohungarumlaut -25 +KPX y omacron -25 +KPX y oslash -25 +KPX y otilde -25 +KPX y period -70 +KPX yacute comma -55 +KPX yacute e -10 +KPX yacute eacute -10 +KPX yacute ecaron -10 +KPX yacute ecircumflex -10 +KPX yacute edieresis -10 +KPX yacute edotaccent -10 +KPX yacute egrave -10 +KPX yacute emacron -10 +KPX yacute eogonek -10 +KPX yacute o -25 +KPX yacute oacute -25 +KPX yacute ocircumflex -25 +KPX yacute odieresis -25 +KPX yacute ograve -25 +KPX yacute ohungarumlaut -25 +KPX yacute omacron -25 +KPX yacute oslash -25 +KPX yacute otilde -25 +KPX yacute period -70 +KPX ydieresis comma -55 +KPX ydieresis e -10 +KPX ydieresis eacute -10 +KPX ydieresis ecaron -10 +KPX ydieresis ecircumflex -10 +KPX ydieresis edieresis -10 +KPX ydieresis edotaccent -10 +KPX ydieresis egrave -10 +KPX ydieresis emacron -10 +KPX ydieresis eogonek -10 +KPX ydieresis o -25 +KPX ydieresis oacute -25 +KPX ydieresis ocircumflex -25 +KPX ydieresis odieresis -25 +KPX ydieresis ograve -25 +KPX ydieresis ohungarumlaut -25 +KPX ydieresis omacron -25 +KPX ydieresis oslash -25 +KPX ydieresis otilde -25 +KPX ydieresis period -70 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-BoldItalic.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-BoldItalic.afm new file mode 100644 index 00000000..2301dfd2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-BoldItalic.afm @@ -0,0 +1,2384 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 13:04:06 1997 +Comment UniqueID 43066 +Comment VMusage 45874 56899 +FontName Times-BoldItalic +FullName Times Bold Italic +FamilyName Times +Weight Bold +ItalicAngle -15 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -200 -218 996 921 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 669 +XHeight 462 +Ascender 683 +Descender -217 +StdHW 42 +StdVW 121 +StartCharMetrics 315 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 389 ; N exclam ; B 67 -13 370 684 ; +C 34 ; WX 555 ; N quotedbl ; B 136 398 536 685 ; +C 35 ; WX 500 ; N numbersign ; B -33 0 533 700 ; +C 36 ; WX 500 ; N dollar ; B -20 -100 497 733 ; +C 37 ; WX 833 ; N percent ; B 39 -10 793 692 ; +C 38 ; WX 778 ; N ampersand ; B 5 -19 699 682 ; +C 39 ; WX 333 ; N quoteright ; B 98 369 302 685 ; +C 40 ; WX 333 ; N parenleft ; B 28 -179 344 685 ; +C 41 ; WX 333 ; N parenright ; B -44 -179 271 685 ; +C 42 ; WX 500 ; N asterisk ; B 65 249 456 685 ; +C 43 ; WX 570 ; N plus ; B 33 0 537 506 ; +C 44 ; WX 250 ; N comma ; B -60 -182 144 134 ; +C 45 ; WX 333 ; N hyphen ; B 2 166 271 282 ; +C 46 ; WX 250 ; N period ; B -9 -13 139 135 ; +C 47 ; WX 278 ; N slash ; B -64 -18 342 685 ; +C 48 ; WX 500 ; N zero ; B 17 -14 477 683 ; +C 49 ; WX 500 ; N one ; B 5 0 419 683 ; +C 50 ; WX 500 ; N two ; B -27 0 446 683 ; +C 51 ; WX 500 ; N three ; B -15 -13 450 683 ; +C 52 ; WX 500 ; N four ; B -15 0 503 683 ; +C 53 ; WX 500 ; N five ; B -11 -13 487 669 ; +C 54 ; WX 500 ; N six ; B 23 -15 509 679 ; +C 55 ; WX 500 ; N seven ; B 52 0 525 669 ; +C 56 ; WX 500 ; N eight ; B 3 -13 476 683 ; +C 57 ; WX 500 ; N nine ; B -12 -10 475 683 ; +C 58 ; WX 333 ; N colon ; B 23 -13 264 459 ; +C 59 ; WX 333 ; N semicolon ; B -25 -183 264 459 ; +C 60 ; WX 570 ; N less ; B 31 -8 539 514 ; +C 61 ; WX 570 ; N equal ; B 33 107 537 399 ; +C 62 ; WX 570 ; N greater ; B 31 -8 539 514 ; +C 63 ; WX 500 ; N question ; B 79 -13 470 684 ; +C 64 ; WX 832 ; N at ; B 63 -18 770 685 ; +C 65 ; WX 667 ; N A ; B -67 0 593 683 ; +C 66 ; WX 667 ; N B ; B -24 0 624 669 ; +C 67 ; WX 667 ; N C ; B 32 -18 677 685 ; +C 68 ; WX 722 ; N D ; B -46 0 685 669 ; +C 69 ; WX 667 ; N E ; B -27 0 653 669 ; +C 70 ; WX 667 ; N F ; B -13 0 660 669 ; +C 71 ; WX 722 ; N G ; B 21 -18 706 685 ; +C 72 ; WX 778 ; N H ; B -24 0 799 669 ; +C 73 ; WX 389 ; N I ; B -32 0 406 669 ; +C 74 ; WX 500 ; N J ; B -46 -99 524 669 ; +C 75 ; WX 667 ; N K ; B -21 0 702 669 ; +C 76 ; WX 611 ; N L ; B -22 0 590 669 ; +C 77 ; WX 889 ; N M ; B -29 -12 917 669 ; +C 78 ; WX 722 ; N N ; B -27 -15 748 669 ; +C 79 ; WX 722 ; N O ; B 27 -18 691 685 ; +C 80 ; WX 611 ; N P ; B -27 0 613 669 ; +C 81 ; WX 722 ; N Q ; B 27 -208 691 685 ; +C 82 ; WX 667 ; N R ; B -29 0 623 669 ; +C 83 ; WX 556 ; N S ; B 2 -18 526 685 ; +C 84 ; WX 611 ; N T ; B 50 0 650 669 ; +C 85 ; WX 722 ; N U ; B 67 -18 744 669 ; +C 86 ; WX 667 ; N V ; B 65 -18 715 669 ; +C 87 ; WX 889 ; N W ; B 65 -18 940 669 ; +C 88 ; WX 667 ; N X ; B -24 0 694 669 ; +C 89 ; WX 611 ; N Y ; B 73 0 659 669 ; +C 90 ; WX 611 ; N Z ; B -11 0 590 669 ; +C 91 ; WX 333 ; N bracketleft ; B -37 -159 362 674 ; +C 92 ; WX 278 ; N backslash ; B -1 -18 279 685 ; +C 93 ; WX 333 ; N bracketright ; B -56 -157 343 674 ; +C 94 ; WX 570 ; N asciicircum ; B 67 304 503 669 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 128 369 332 685 ; +C 97 ; WX 500 ; N a ; B -21 -14 455 462 ; +C 98 ; WX 500 ; N b ; B -14 -13 444 699 ; +C 99 ; WX 444 ; N c ; B -5 -13 392 462 ; +C 100 ; WX 500 ; N d ; B -21 -13 517 699 ; +C 101 ; WX 444 ; N e ; B 5 -13 398 462 ; +C 102 ; WX 333 ; N f ; B -169 -205 446 698 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B -52 -203 478 462 ; +C 104 ; WX 556 ; N h ; B -13 -9 498 699 ; +C 105 ; WX 278 ; N i ; B 2 -9 263 684 ; +C 106 ; WX 278 ; N j ; B -189 -207 279 684 ; +C 107 ; WX 500 ; N k ; B -23 -8 483 699 ; +C 108 ; WX 278 ; N l ; B 2 -9 290 699 ; +C 109 ; WX 778 ; N m ; B -14 -9 722 462 ; +C 110 ; WX 556 ; N n ; B -6 -9 493 462 ; +C 111 ; WX 500 ; N o ; B -3 -13 441 462 ; +C 112 ; WX 500 ; N p ; B -120 -205 446 462 ; +C 113 ; WX 500 ; N q ; B 1 -205 471 462 ; +C 114 ; WX 389 ; N r ; B -21 0 389 462 ; +C 115 ; WX 389 ; N s ; B -19 -13 333 462 ; +C 116 ; WX 278 ; N t ; B -11 -9 281 594 ; +C 117 ; WX 556 ; N u ; B 15 -9 492 462 ; +C 118 ; WX 444 ; N v ; B 16 -13 401 462 ; +C 119 ; WX 667 ; N w ; B 16 -13 614 462 ; +C 120 ; WX 500 ; N x ; B -46 -13 469 462 ; +C 121 ; WX 444 ; N y ; B -94 -205 392 462 ; +C 122 ; WX 389 ; N z ; B -43 -78 368 449 ; +C 123 ; WX 348 ; N braceleft ; B 5 -187 436 686 ; +C 124 ; WX 220 ; N bar ; B 66 -218 154 782 ; +C 125 ; WX 348 ; N braceright ; B -129 -187 302 686 ; +C 126 ; WX 570 ; N asciitilde ; B 54 173 516 333 ; +C 161 ; WX 389 ; N exclamdown ; B 19 -205 322 492 ; +C 162 ; WX 500 ; N cent ; B 42 -143 439 576 ; +C 163 ; WX 500 ; N sterling ; B -32 -12 510 683 ; +C 164 ; WX 167 ; N fraction ; B -169 -14 324 683 ; +C 165 ; WX 500 ; N yen ; B 33 0 628 669 ; +C 166 ; WX 500 ; N florin ; B -87 -156 537 707 ; +C 167 ; WX 500 ; N section ; B 36 -143 459 685 ; +C 168 ; WX 500 ; N currency ; B -26 34 526 586 ; +C 169 ; WX 278 ; N quotesingle ; B 128 398 268 685 ; +C 170 ; WX 500 ; N quotedblleft ; B 53 369 513 685 ; +C 171 ; WX 500 ; N guillemotleft ; B 12 32 468 415 ; +C 172 ; WX 333 ; N guilsinglleft ; B 32 32 303 415 ; +C 173 ; WX 333 ; N guilsinglright ; B 10 32 281 415 ; +C 174 ; WX 556 ; N fi ; B -188 -205 514 703 ; +C 175 ; WX 556 ; N fl ; B -186 -205 553 704 ; +C 177 ; WX 500 ; N endash ; B -40 178 477 269 ; +C 178 ; WX 500 ; N dagger ; B 91 -145 494 685 ; +C 179 ; WX 500 ; N daggerdbl ; B 10 -139 493 685 ; +C 180 ; WX 250 ; N periodcentered ; B 51 257 199 405 ; +C 182 ; WX 500 ; N paragraph ; B -57 -193 562 669 ; +C 183 ; WX 350 ; N bullet ; B 0 175 350 525 ; +C 184 ; WX 333 ; N quotesinglbase ; B -5 -182 199 134 ; +C 185 ; WX 500 ; N quotedblbase ; B -57 -182 403 134 ; +C 186 ; WX 500 ; N quotedblright ; B 53 369 513 685 ; +C 187 ; WX 500 ; N guillemotright ; B 12 32 468 415 ; +C 188 ; WX 1000 ; N ellipsis ; B 40 -13 852 135 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -29 996 706 ; +C 191 ; WX 500 ; N questiondown ; B 30 -205 421 492 ; +C 193 ; WX 333 ; N grave ; B 85 516 297 697 ; +C 194 ; WX 333 ; N acute ; B 139 516 379 697 ; +C 195 ; WX 333 ; N circumflex ; B 40 516 367 690 ; +C 196 ; WX 333 ; N tilde ; B 48 536 407 655 ; +C 197 ; WX 333 ; N macron ; B 51 553 393 623 ; +C 198 ; WX 333 ; N breve ; B 71 516 387 678 ; +C 199 ; WX 333 ; N dotaccent ; B 163 550 298 684 ; +C 200 ; WX 333 ; N dieresis ; B 55 550 402 684 ; +C 202 ; WX 333 ; N ring ; B 127 516 340 729 ; +C 203 ; WX 333 ; N cedilla ; B -80 -218 156 5 ; +C 205 ; WX 333 ; N hungarumlaut ; B 69 516 498 697 ; +C 206 ; WX 333 ; N ogonek ; B 15 -183 244 34 ; +C 207 ; WX 333 ; N caron ; B 79 516 411 690 ; +C 208 ; WX 1000 ; N emdash ; B -40 178 977 269 ; +C 225 ; WX 944 ; N AE ; B -64 0 918 669 ; +C 227 ; WX 266 ; N ordfeminine ; B 16 399 330 685 ; +C 232 ; WX 611 ; N Lslash ; B -22 0 590 669 ; +C 233 ; WX 722 ; N Oslash ; B 27 -125 691 764 ; +C 234 ; WX 944 ; N OE ; B 23 -8 946 677 ; +C 235 ; WX 300 ; N ordmasculine ; B 56 400 347 685 ; +C 241 ; WX 722 ; N ae ; B -5 -13 673 462 ; +C 245 ; WX 278 ; N dotlessi ; B 2 -9 238 462 ; +C 248 ; WX 278 ; N lslash ; B -7 -9 307 699 ; +C 249 ; WX 500 ; N oslash ; B -3 -119 441 560 ; +C 250 ; WX 722 ; N oe ; B 6 -13 674 462 ; +C 251 ; WX 500 ; N germandbls ; B -200 -200 473 705 ; +C -1 ; WX 389 ; N Idieresis ; B -32 0 450 862 ; +C -1 ; WX 444 ; N eacute ; B 5 -13 435 697 ; +C -1 ; WX 500 ; N abreve ; B -21 -14 471 678 ; +C -1 ; WX 556 ; N uhungarumlaut ; B 15 -9 610 697 ; +C -1 ; WX 444 ; N ecaron ; B 5 -13 467 690 ; +C -1 ; WX 611 ; N Ydieresis ; B 73 0 659 862 ; +C -1 ; WX 570 ; N divide ; B 33 -29 537 535 ; +C -1 ; WX 611 ; N Yacute ; B 73 0 659 904 ; +C -1 ; WX 667 ; N Acircumflex ; B -67 0 593 897 ; +C -1 ; WX 500 ; N aacute ; B -21 -14 463 697 ; +C -1 ; WX 722 ; N Ucircumflex ; B 67 -18 744 897 ; +C -1 ; WX 444 ; N yacute ; B -94 -205 435 697 ; +C -1 ; WX 389 ; N scommaaccent ; B -19 -218 333 462 ; +C -1 ; WX 444 ; N ecircumflex ; B 5 -13 423 690 ; +C -1 ; WX 722 ; N Uring ; B 67 -18 744 921 ; +C -1 ; WX 722 ; N Udieresis ; B 67 -18 744 862 ; +C -1 ; WX 500 ; N aogonek ; B -21 -183 455 462 ; +C -1 ; WX 722 ; N Uacute ; B 67 -18 744 904 ; +C -1 ; WX 556 ; N uogonek ; B 15 -183 492 462 ; +C -1 ; WX 667 ; N Edieresis ; B -27 0 653 862 ; +C -1 ; WX 722 ; N Dcroat ; B -31 0 700 669 ; +C -1 ; WX 250 ; N commaaccent ; B -36 -218 131 -50 ; +C -1 ; WX 747 ; N copyright ; B 30 -18 718 685 ; +C -1 ; WX 667 ; N Emacron ; B -27 0 653 830 ; +C -1 ; WX 444 ; N ccaron ; B -5 -13 467 690 ; +C -1 ; WX 500 ; N aring ; B -21 -14 455 729 ; +C -1 ; WX 722 ; N Ncommaaccent ; B -27 -218 748 669 ; +C -1 ; WX 278 ; N lacute ; B 2 -9 392 904 ; +C -1 ; WX 500 ; N agrave ; B -21 -14 455 697 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 50 -218 650 669 ; +C -1 ; WX 667 ; N Cacute ; B 32 -18 677 904 ; +C -1 ; WX 500 ; N atilde ; B -21 -14 491 655 ; +C -1 ; WX 667 ; N Edotaccent ; B -27 0 653 862 ; +C -1 ; WX 389 ; N scaron ; B -19 -13 424 690 ; +C -1 ; WX 389 ; N scedilla ; B -19 -218 333 462 ; +C -1 ; WX 278 ; N iacute ; B 2 -9 352 697 ; +C -1 ; WX 494 ; N lozenge ; B 10 0 484 745 ; +C -1 ; WX 667 ; N Rcaron ; B -29 0 623 897 ; +C -1 ; WX 722 ; N Gcommaaccent ; B 21 -218 706 685 ; +C -1 ; WX 556 ; N ucircumflex ; B 15 -9 492 690 ; +C -1 ; WX 500 ; N acircumflex ; B -21 -14 455 690 ; +C -1 ; WX 667 ; N Amacron ; B -67 0 593 830 ; +C -1 ; WX 389 ; N rcaron ; B -21 0 424 690 ; +C -1 ; WX 444 ; N ccedilla ; B -5 -218 392 462 ; +C -1 ; WX 611 ; N Zdotaccent ; B -11 0 590 862 ; +C -1 ; WX 611 ; N Thorn ; B -27 0 573 669 ; +C -1 ; WX 722 ; N Omacron ; B 27 -18 691 830 ; +C -1 ; WX 667 ; N Racute ; B -29 0 623 904 ; +C -1 ; WX 556 ; N Sacute ; B 2 -18 531 904 ; +C -1 ; WX 608 ; N dcaron ; B -21 -13 675 708 ; +C -1 ; WX 722 ; N Umacron ; B 67 -18 744 830 ; +C -1 ; WX 556 ; N uring ; B 15 -9 492 729 ; +C -1 ; WX 300 ; N threesuperior ; B 17 265 321 683 ; +C -1 ; WX 722 ; N Ograve ; B 27 -18 691 904 ; +C -1 ; WX 667 ; N Agrave ; B -67 0 593 904 ; +C -1 ; WX 667 ; N Abreve ; B -67 0 593 885 ; +C -1 ; WX 570 ; N multiply ; B 48 16 522 490 ; +C -1 ; WX 556 ; N uacute ; B 15 -9 492 697 ; +C -1 ; WX 611 ; N Tcaron ; B 50 0 650 897 ; +C -1 ; WX 494 ; N partialdiff ; B 11 -21 494 750 ; +C -1 ; WX 444 ; N ydieresis ; B -94 -205 443 655 ; +C -1 ; WX 722 ; N Nacute ; B -27 -15 748 904 ; +C -1 ; WX 278 ; N icircumflex ; B -3 -9 324 690 ; +C -1 ; WX 667 ; N Ecircumflex ; B -27 0 653 897 ; +C -1 ; WX 500 ; N adieresis ; B -21 -14 476 655 ; +C -1 ; WX 444 ; N edieresis ; B 5 -13 448 655 ; +C -1 ; WX 444 ; N cacute ; B -5 -13 435 697 ; +C -1 ; WX 556 ; N nacute ; B -6 -9 493 697 ; +C -1 ; WX 556 ; N umacron ; B 15 -9 492 623 ; +C -1 ; WX 722 ; N Ncaron ; B -27 -15 748 897 ; +C -1 ; WX 389 ; N Iacute ; B -32 0 432 904 ; +C -1 ; WX 570 ; N plusminus ; B 33 0 537 506 ; +C -1 ; WX 220 ; N brokenbar ; B 66 -143 154 707 ; +C -1 ; WX 747 ; N registered ; B 30 -18 718 685 ; +C -1 ; WX 722 ; N Gbreve ; B 21 -18 706 885 ; +C -1 ; WX 389 ; N Idotaccent ; B -32 0 406 862 ; +C -1 ; WX 600 ; N summation ; B 14 -10 585 706 ; +C -1 ; WX 667 ; N Egrave ; B -27 0 653 904 ; +C -1 ; WX 389 ; N racute ; B -21 0 407 697 ; +C -1 ; WX 500 ; N omacron ; B -3 -13 462 623 ; +C -1 ; WX 611 ; N Zacute ; B -11 0 590 904 ; +C -1 ; WX 611 ; N Zcaron ; B -11 0 590 897 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 704 ; +C -1 ; WX 722 ; N Eth ; B -31 0 700 669 ; +C -1 ; WX 667 ; N Ccedilla ; B 32 -218 677 685 ; +C -1 ; WX 278 ; N lcommaaccent ; B -42 -218 290 699 ; +C -1 ; WX 366 ; N tcaron ; B -11 -9 434 754 ; +C -1 ; WX 444 ; N eogonek ; B 5 -183 398 462 ; +C -1 ; WX 722 ; N Uogonek ; B 67 -183 744 669 ; +C -1 ; WX 667 ; N Aacute ; B -67 0 593 904 ; +C -1 ; WX 667 ; N Adieresis ; B -67 0 593 862 ; +C -1 ; WX 444 ; N egrave ; B 5 -13 398 697 ; +C -1 ; WX 389 ; N zacute ; B -43 -78 407 697 ; +C -1 ; WX 278 ; N iogonek ; B -20 -183 263 684 ; +C -1 ; WX 722 ; N Oacute ; B 27 -18 691 904 ; +C -1 ; WX 500 ; N oacute ; B -3 -13 463 697 ; +C -1 ; WX 500 ; N amacron ; B -21 -14 467 623 ; +C -1 ; WX 389 ; N sacute ; B -19 -13 407 697 ; +C -1 ; WX 278 ; N idieresis ; B 2 -9 364 655 ; +C -1 ; WX 722 ; N Ocircumflex ; B 27 -18 691 897 ; +C -1 ; WX 722 ; N Ugrave ; B 67 -18 744 904 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 500 ; N thorn ; B -120 -205 446 699 ; +C -1 ; WX 300 ; N twosuperior ; B 2 274 313 683 ; +C -1 ; WX 722 ; N Odieresis ; B 27 -18 691 862 ; +C -1 ; WX 576 ; N mu ; B -60 -207 516 449 ; +C -1 ; WX 278 ; N igrave ; B 2 -9 259 697 ; +C -1 ; WX 500 ; N ohungarumlaut ; B -3 -13 582 697 ; +C -1 ; WX 667 ; N Eogonek ; B -27 -183 653 669 ; +C -1 ; WX 500 ; N dcroat ; B -21 -13 552 699 ; +C -1 ; WX 750 ; N threequarters ; B 7 -14 726 683 ; +C -1 ; WX 556 ; N Scedilla ; B 2 -218 526 685 ; +C -1 ; WX 382 ; N lcaron ; B 2 -9 448 708 ; +C -1 ; WX 667 ; N Kcommaaccent ; B -21 -218 702 669 ; +C -1 ; WX 611 ; N Lacute ; B -22 0 590 904 ; +C -1 ; WX 1000 ; N trademark ; B 32 263 968 669 ; +C -1 ; WX 444 ; N edotaccent ; B 5 -13 398 655 ; +C -1 ; WX 389 ; N Igrave ; B -32 0 406 904 ; +C -1 ; WX 389 ; N Imacron ; B -32 0 461 830 ; +C -1 ; WX 611 ; N Lcaron ; B -22 0 671 718 ; +C -1 ; WX 750 ; N onehalf ; B -9 -14 723 683 ; +C -1 ; WX 549 ; N lessequal ; B 29 0 526 704 ; +C -1 ; WX 500 ; N ocircumflex ; B -3 -13 451 690 ; +C -1 ; WX 556 ; N ntilde ; B -6 -9 504 655 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 67 -18 744 904 ; +C -1 ; WX 667 ; N Eacute ; B -27 0 653 904 ; +C -1 ; WX 444 ; N emacron ; B 5 -13 439 623 ; +C -1 ; WX 500 ; N gbreve ; B -52 -203 478 678 ; +C -1 ; WX 750 ; N onequarter ; B 7 -14 721 683 ; +C -1 ; WX 556 ; N Scaron ; B 2 -18 553 897 ; +C -1 ; WX 556 ; N Scommaaccent ; B 2 -218 526 685 ; +C -1 ; WX 722 ; N Ohungarumlaut ; B 27 -18 723 904 ; +C -1 ; WX 400 ; N degree ; B 83 397 369 683 ; +C -1 ; WX 500 ; N ograve ; B -3 -13 441 697 ; +C -1 ; WX 667 ; N Ccaron ; B 32 -18 677 897 ; +C -1 ; WX 556 ; N ugrave ; B 15 -9 492 697 ; +C -1 ; WX 549 ; N radical ; B 10 -46 512 850 ; +C -1 ; WX 722 ; N Dcaron ; B -46 0 685 897 ; +C -1 ; WX 389 ; N rcommaaccent ; B -67 -218 389 462 ; +C -1 ; WX 722 ; N Ntilde ; B -27 -15 748 862 ; +C -1 ; WX 500 ; N otilde ; B -3 -13 491 655 ; +C -1 ; WX 667 ; N Rcommaaccent ; B -29 -218 623 669 ; +C -1 ; WX 611 ; N Lcommaaccent ; B -22 -218 590 669 ; +C -1 ; WX 667 ; N Atilde ; B -67 0 593 862 ; +C -1 ; WX 667 ; N Aogonek ; B -67 -183 604 683 ; +C -1 ; WX 667 ; N Aring ; B -67 0 593 921 ; +C -1 ; WX 722 ; N Otilde ; B 27 -18 691 862 ; +C -1 ; WX 389 ; N zdotaccent ; B -43 -78 368 655 ; +C -1 ; WX 667 ; N Ecaron ; B -27 0 653 897 ; +C -1 ; WX 389 ; N Iogonek ; B -32 -183 406 669 ; +C -1 ; WX 500 ; N kcommaaccent ; B -23 -218 483 699 ; +C -1 ; WX 606 ; N minus ; B 51 209 555 297 ; +C -1 ; WX 389 ; N Icircumflex ; B -32 0 450 897 ; +C -1 ; WX 556 ; N ncaron ; B -6 -9 523 690 ; +C -1 ; WX 278 ; N tcommaaccent ; B -62 -218 281 594 ; +C -1 ; WX 606 ; N logicalnot ; B 51 108 555 399 ; +C -1 ; WX 500 ; N odieresis ; B -3 -13 471 655 ; +C -1 ; WX 556 ; N udieresis ; B 15 -9 499 655 ; +C -1 ; WX 549 ; N notequal ; B 15 -49 540 570 ; +C -1 ; WX 500 ; N gcommaaccent ; B -52 -203 478 767 ; +C -1 ; WX 500 ; N eth ; B -3 -13 454 699 ; +C -1 ; WX 389 ; N zcaron ; B -43 -78 424 690 ; +C -1 ; WX 556 ; N ncommaaccent ; B -6 -218 493 462 ; +C -1 ; WX 300 ; N onesuperior ; B 30 274 301 683 ; +C -1 ; WX 278 ; N imacron ; B 2 -9 294 623 ; +C -1 ; WX 500 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2038 +KPX A C -65 +KPX A Cacute -65 +KPX A Ccaron -65 +KPX A Ccedilla -65 +KPX A G -60 +KPX A Gbreve -60 +KPX A Gcommaaccent -60 +KPX A O -50 +KPX A Oacute -50 +KPX A Ocircumflex -50 +KPX A Odieresis -50 +KPX A Ograve -50 +KPX A Ohungarumlaut -50 +KPX A Omacron -50 +KPX A Oslash -50 +KPX A Otilde -50 +KPX A Q -55 +KPX A T -55 +KPX A Tcaron -55 +KPX A Tcommaaccent -55 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -95 +KPX A W -100 +KPX A Y -70 +KPX A Yacute -70 +KPX A Ydieresis -70 +KPX A quoteright -74 +KPX A u -30 +KPX A uacute -30 +KPX A ucircumflex -30 +KPX A udieresis -30 +KPX A ugrave -30 +KPX A uhungarumlaut -30 +KPX A umacron -30 +KPX A uogonek -30 +KPX A uring -30 +KPX A v -74 +KPX A w -74 +KPX A y -74 +KPX A yacute -74 +KPX A ydieresis -74 +KPX Aacute C -65 +KPX Aacute Cacute -65 +KPX Aacute Ccaron -65 +KPX Aacute Ccedilla -65 +KPX Aacute G -60 +KPX Aacute Gbreve -60 +KPX Aacute Gcommaaccent -60 +KPX Aacute O -50 +KPX Aacute Oacute -50 +KPX Aacute Ocircumflex -50 +KPX Aacute Odieresis -50 +KPX Aacute Ograve -50 +KPX Aacute Ohungarumlaut -50 +KPX Aacute Omacron -50 +KPX Aacute Oslash -50 +KPX Aacute Otilde -50 +KPX Aacute Q -55 +KPX Aacute T -55 +KPX Aacute Tcaron -55 +KPX Aacute Tcommaaccent -55 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -95 +KPX Aacute W -100 +KPX Aacute Y -70 +KPX Aacute Yacute -70 +KPX Aacute Ydieresis -70 +KPX Aacute quoteright -74 +KPX Aacute u -30 +KPX Aacute uacute -30 +KPX Aacute ucircumflex -30 +KPX Aacute udieresis -30 +KPX Aacute ugrave -30 +KPX Aacute uhungarumlaut -30 +KPX Aacute umacron -30 +KPX Aacute uogonek -30 +KPX Aacute uring -30 +KPX Aacute v -74 +KPX Aacute w -74 +KPX Aacute y -74 +KPX Aacute yacute -74 +KPX Aacute ydieresis -74 +KPX Abreve C -65 +KPX Abreve Cacute -65 +KPX Abreve Ccaron -65 +KPX Abreve Ccedilla -65 +KPX Abreve G -60 +KPX Abreve Gbreve -60 +KPX Abreve Gcommaaccent -60 +KPX Abreve O -50 +KPX Abreve Oacute -50 +KPX Abreve Ocircumflex -50 +KPX Abreve Odieresis -50 +KPX Abreve Ograve -50 +KPX Abreve Ohungarumlaut -50 +KPX Abreve Omacron -50 +KPX Abreve Oslash -50 +KPX Abreve Otilde -50 +KPX Abreve Q -55 +KPX Abreve T -55 +KPX Abreve Tcaron -55 +KPX Abreve Tcommaaccent -55 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -95 +KPX Abreve W -100 +KPX Abreve Y -70 +KPX Abreve Yacute -70 +KPX Abreve Ydieresis -70 +KPX Abreve quoteright -74 +KPX Abreve u -30 +KPX Abreve uacute -30 +KPX Abreve ucircumflex -30 +KPX Abreve udieresis -30 +KPX Abreve ugrave -30 +KPX Abreve uhungarumlaut -30 +KPX Abreve umacron -30 +KPX Abreve uogonek -30 +KPX Abreve uring -30 +KPX Abreve v -74 +KPX Abreve w -74 +KPX Abreve y -74 +KPX Abreve yacute -74 +KPX Abreve ydieresis -74 +KPX Acircumflex C -65 +KPX Acircumflex Cacute -65 +KPX Acircumflex Ccaron -65 +KPX Acircumflex Ccedilla -65 +KPX Acircumflex G -60 +KPX Acircumflex Gbreve -60 +KPX Acircumflex Gcommaaccent -60 +KPX Acircumflex O -50 +KPX Acircumflex Oacute -50 +KPX Acircumflex Ocircumflex -50 +KPX Acircumflex Odieresis -50 +KPX Acircumflex Ograve -50 +KPX Acircumflex Ohungarumlaut -50 +KPX Acircumflex Omacron -50 +KPX Acircumflex Oslash -50 +KPX Acircumflex Otilde -50 +KPX Acircumflex Q -55 +KPX Acircumflex T -55 +KPX Acircumflex Tcaron -55 +KPX Acircumflex Tcommaaccent -55 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -95 +KPX Acircumflex W -100 +KPX Acircumflex Y -70 +KPX Acircumflex Yacute -70 +KPX Acircumflex Ydieresis -70 +KPX Acircumflex quoteright -74 +KPX Acircumflex u -30 +KPX Acircumflex uacute -30 +KPX Acircumflex ucircumflex -30 +KPX Acircumflex udieresis -30 +KPX Acircumflex ugrave -30 +KPX Acircumflex uhungarumlaut -30 +KPX Acircumflex umacron -30 +KPX Acircumflex uogonek -30 +KPX Acircumflex uring -30 +KPX Acircumflex v -74 +KPX Acircumflex w -74 +KPX Acircumflex y -74 +KPX Acircumflex yacute -74 +KPX Acircumflex ydieresis -74 +KPX Adieresis C -65 +KPX Adieresis Cacute -65 +KPX Adieresis Ccaron -65 +KPX Adieresis Ccedilla -65 +KPX Adieresis G -60 +KPX Adieresis Gbreve -60 +KPX Adieresis Gcommaaccent -60 +KPX Adieresis O -50 +KPX Adieresis Oacute -50 +KPX Adieresis Ocircumflex -50 +KPX Adieresis Odieresis -50 +KPX Adieresis Ograve -50 +KPX Adieresis Ohungarumlaut -50 +KPX Adieresis Omacron -50 +KPX Adieresis Oslash -50 +KPX Adieresis Otilde -50 +KPX Adieresis Q -55 +KPX Adieresis T -55 +KPX Adieresis Tcaron -55 +KPX Adieresis Tcommaaccent -55 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -95 +KPX Adieresis W -100 +KPX Adieresis Y -70 +KPX Adieresis Yacute -70 +KPX Adieresis Ydieresis -70 +KPX Adieresis quoteright -74 +KPX Adieresis u -30 +KPX Adieresis uacute -30 +KPX Adieresis ucircumflex -30 +KPX Adieresis udieresis -30 +KPX Adieresis ugrave -30 +KPX Adieresis uhungarumlaut -30 +KPX Adieresis umacron -30 +KPX Adieresis uogonek -30 +KPX Adieresis uring -30 +KPX Adieresis v -74 +KPX Adieresis w -74 +KPX Adieresis y -74 +KPX Adieresis yacute -74 +KPX Adieresis ydieresis -74 +KPX Agrave C -65 +KPX Agrave Cacute -65 +KPX Agrave Ccaron -65 +KPX Agrave Ccedilla -65 +KPX Agrave G -60 +KPX Agrave Gbreve -60 +KPX Agrave Gcommaaccent -60 +KPX Agrave O -50 +KPX Agrave Oacute -50 +KPX Agrave Ocircumflex -50 +KPX Agrave Odieresis -50 +KPX Agrave Ograve -50 +KPX Agrave Ohungarumlaut -50 +KPX Agrave Omacron -50 +KPX Agrave Oslash -50 +KPX Agrave Otilde -50 +KPX Agrave Q -55 +KPX Agrave T -55 +KPX Agrave Tcaron -55 +KPX Agrave Tcommaaccent -55 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -95 +KPX Agrave W -100 +KPX Agrave Y -70 +KPX Agrave Yacute -70 +KPX Agrave Ydieresis -70 +KPX Agrave quoteright -74 +KPX Agrave u -30 +KPX Agrave uacute -30 +KPX Agrave ucircumflex -30 +KPX Agrave udieresis -30 +KPX Agrave ugrave -30 +KPX Agrave uhungarumlaut -30 +KPX Agrave umacron -30 +KPX Agrave uogonek -30 +KPX Agrave uring -30 +KPX Agrave v -74 +KPX Agrave w -74 +KPX Agrave y -74 +KPX Agrave yacute -74 +KPX Agrave ydieresis -74 +KPX Amacron C -65 +KPX Amacron Cacute -65 +KPX Amacron Ccaron -65 +KPX Amacron Ccedilla -65 +KPX Amacron G -60 +KPX Amacron Gbreve -60 +KPX Amacron Gcommaaccent -60 +KPX Amacron O -50 +KPX Amacron Oacute -50 +KPX Amacron Ocircumflex -50 +KPX Amacron Odieresis -50 +KPX Amacron Ograve -50 +KPX Amacron Ohungarumlaut -50 +KPX Amacron Omacron -50 +KPX Amacron Oslash -50 +KPX Amacron Otilde -50 +KPX Amacron Q -55 +KPX Amacron T -55 +KPX Amacron Tcaron -55 +KPX Amacron Tcommaaccent -55 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -95 +KPX Amacron W -100 +KPX Amacron Y -70 +KPX Amacron Yacute -70 +KPX Amacron Ydieresis -70 +KPX Amacron quoteright -74 +KPX Amacron u -30 +KPX Amacron uacute -30 +KPX Amacron ucircumflex -30 +KPX Amacron udieresis -30 +KPX Amacron ugrave -30 +KPX Amacron uhungarumlaut -30 +KPX Amacron umacron -30 +KPX Amacron uogonek -30 +KPX Amacron uring -30 +KPX Amacron v -74 +KPX Amacron w -74 +KPX Amacron y -74 +KPX Amacron yacute -74 +KPX Amacron ydieresis -74 +KPX Aogonek C -65 +KPX Aogonek Cacute -65 +KPX Aogonek Ccaron -65 +KPX Aogonek Ccedilla -65 +KPX Aogonek G -60 +KPX Aogonek Gbreve -60 +KPX Aogonek Gcommaaccent -60 +KPX Aogonek O -50 +KPX Aogonek Oacute -50 +KPX Aogonek Ocircumflex -50 +KPX Aogonek Odieresis -50 +KPX Aogonek Ograve -50 +KPX Aogonek Ohungarumlaut -50 +KPX Aogonek Omacron -50 +KPX Aogonek Oslash -50 +KPX Aogonek Otilde -50 +KPX Aogonek Q -55 +KPX Aogonek T -55 +KPX Aogonek Tcaron -55 +KPX Aogonek Tcommaaccent -55 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -95 +KPX Aogonek W -100 +KPX Aogonek Y -70 +KPX Aogonek Yacute -70 +KPX Aogonek Ydieresis -70 +KPX Aogonek quoteright -74 +KPX Aogonek u -30 +KPX Aogonek uacute -30 +KPX Aogonek ucircumflex -30 +KPX Aogonek udieresis -30 +KPX Aogonek ugrave -30 +KPX Aogonek uhungarumlaut -30 +KPX Aogonek umacron -30 +KPX Aogonek uogonek -30 +KPX Aogonek uring -30 +KPX Aogonek v -74 +KPX Aogonek w -74 +KPX Aogonek y -34 +KPX Aogonek yacute -34 +KPX Aogonek ydieresis -34 +KPX Aring C -65 +KPX Aring Cacute -65 +KPX Aring Ccaron -65 +KPX Aring Ccedilla -65 +KPX Aring G -60 +KPX Aring Gbreve -60 +KPX Aring Gcommaaccent -60 +KPX Aring O -50 +KPX Aring Oacute -50 +KPX Aring Ocircumflex -50 +KPX Aring Odieresis -50 +KPX Aring Ograve -50 +KPX Aring Ohungarumlaut -50 +KPX Aring Omacron -50 +KPX Aring Oslash -50 +KPX Aring Otilde -50 +KPX Aring Q -55 +KPX Aring T -55 +KPX Aring Tcaron -55 +KPX Aring Tcommaaccent -55 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -95 +KPX Aring W -100 +KPX Aring Y -70 +KPX Aring Yacute -70 +KPX Aring Ydieresis -70 +KPX Aring quoteright -74 +KPX Aring u -30 +KPX Aring uacute -30 +KPX Aring ucircumflex -30 +KPX Aring udieresis -30 +KPX Aring ugrave -30 +KPX Aring uhungarumlaut -30 +KPX Aring umacron -30 +KPX Aring uogonek -30 +KPX Aring uring -30 +KPX Aring v -74 +KPX Aring w -74 +KPX Aring y -74 +KPX Aring yacute -74 +KPX Aring ydieresis -74 +KPX Atilde C -65 +KPX Atilde Cacute -65 +KPX Atilde Ccaron -65 +KPX Atilde Ccedilla -65 +KPX Atilde G -60 +KPX Atilde Gbreve -60 +KPX Atilde Gcommaaccent -60 +KPX Atilde O -50 +KPX Atilde Oacute -50 +KPX Atilde Ocircumflex -50 +KPX Atilde Odieresis -50 +KPX Atilde Ograve -50 +KPX Atilde Ohungarumlaut -50 +KPX Atilde Omacron -50 +KPX Atilde Oslash -50 +KPX Atilde Otilde -50 +KPX Atilde Q -55 +KPX Atilde T -55 +KPX Atilde Tcaron -55 +KPX Atilde Tcommaaccent -55 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -95 +KPX Atilde W -100 +KPX Atilde Y -70 +KPX Atilde Yacute -70 +KPX Atilde Ydieresis -70 +KPX Atilde quoteright -74 +KPX Atilde u -30 +KPX Atilde uacute -30 +KPX Atilde ucircumflex -30 +KPX Atilde udieresis -30 +KPX Atilde ugrave -30 +KPX Atilde uhungarumlaut -30 +KPX Atilde umacron -30 +KPX Atilde uogonek -30 +KPX Atilde uring -30 +KPX Atilde v -74 +KPX Atilde w -74 +KPX Atilde y -74 +KPX Atilde yacute -74 +KPX Atilde ydieresis -74 +KPX B A -25 +KPX B Aacute -25 +KPX B Abreve -25 +KPX B Acircumflex -25 +KPX B Adieresis -25 +KPX B Agrave -25 +KPX B Amacron -25 +KPX B Aogonek -25 +KPX B Aring -25 +KPX B Atilde -25 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -25 +KPX D Aacute -25 +KPX D Abreve -25 +KPX D Acircumflex -25 +KPX D Adieresis -25 +KPX D Agrave -25 +KPX D Amacron -25 +KPX D Aogonek -25 +KPX D Aring -25 +KPX D Atilde -25 +KPX D V -50 +KPX D W -40 +KPX D Y -50 +KPX D Yacute -50 +KPX D Ydieresis -50 +KPX Dcaron A -25 +KPX Dcaron Aacute -25 +KPX Dcaron Abreve -25 +KPX Dcaron Acircumflex -25 +KPX Dcaron Adieresis -25 +KPX Dcaron Agrave -25 +KPX Dcaron Amacron -25 +KPX Dcaron Aogonek -25 +KPX Dcaron Aring -25 +KPX Dcaron Atilde -25 +KPX Dcaron V -50 +KPX Dcaron W -40 +KPX Dcaron Y -50 +KPX Dcaron Yacute -50 +KPX Dcaron Ydieresis -50 +KPX Dcroat A -25 +KPX Dcroat Aacute -25 +KPX Dcroat Abreve -25 +KPX Dcroat Acircumflex -25 +KPX Dcroat Adieresis -25 +KPX Dcroat Agrave -25 +KPX Dcroat Amacron -25 +KPX Dcroat Aogonek -25 +KPX Dcroat Aring -25 +KPX Dcroat Atilde -25 +KPX Dcroat V -50 +KPX Dcroat W -40 +KPX Dcroat Y -50 +KPX Dcroat Yacute -50 +KPX Dcroat Ydieresis -50 +KPX F A -100 +KPX F Aacute -100 +KPX F Abreve -100 +KPX F Acircumflex -100 +KPX F Adieresis -100 +KPX F Agrave -100 +KPX F Amacron -100 +KPX F Aogonek -100 +KPX F Aring -100 +KPX F Atilde -100 +KPX F a -95 +KPX F aacute -95 +KPX F abreve -95 +KPX F acircumflex -95 +KPX F adieresis -95 +KPX F agrave -95 +KPX F amacron -95 +KPX F aogonek -95 +KPX F aring -95 +KPX F atilde -95 +KPX F comma -129 +KPX F e -100 +KPX F eacute -100 +KPX F ecaron -100 +KPX F ecircumflex -100 +KPX F edieresis -100 +KPX F edotaccent -100 +KPX F egrave -100 +KPX F emacron -100 +KPX F eogonek -100 +KPX F i -40 +KPX F iacute -40 +KPX F icircumflex -40 +KPX F idieresis -40 +KPX F igrave -40 +KPX F imacron -40 +KPX F iogonek -40 +KPX F o -70 +KPX F oacute -70 +KPX F ocircumflex -70 +KPX F odieresis -70 +KPX F ograve -70 +KPX F ohungarumlaut -70 +KPX F omacron -70 +KPX F oslash -70 +KPX F otilde -70 +KPX F period -129 +KPX F r -50 +KPX F racute -50 +KPX F rcaron -50 +KPX F rcommaaccent -50 +KPX J A -25 +KPX J Aacute -25 +KPX J Abreve -25 +KPX J Acircumflex -25 +KPX J Adieresis -25 +KPX J Agrave -25 +KPX J Amacron -25 +KPX J Aogonek -25 +KPX J Aring -25 +KPX J Atilde -25 +KPX J a -40 +KPX J aacute -40 +KPX J abreve -40 +KPX J acircumflex -40 +KPX J adieresis -40 +KPX J agrave -40 +KPX J amacron -40 +KPX J aogonek -40 +KPX J aring -40 +KPX J atilde -40 +KPX J comma -10 +KPX J e -40 +KPX J eacute -40 +KPX J ecaron -40 +KPX J ecircumflex -40 +KPX J edieresis -40 +KPX J edotaccent -40 +KPX J egrave -40 +KPX J emacron -40 +KPX J eogonek -40 +KPX J o -40 +KPX J oacute -40 +KPX J ocircumflex -40 +KPX J odieresis -40 +KPX J ograve -40 +KPX J ohungarumlaut -40 +KPX J omacron -40 +KPX J oslash -40 +KPX J otilde -40 +KPX J period -10 +KPX J u -40 +KPX J uacute -40 +KPX J ucircumflex -40 +KPX J udieresis -40 +KPX J ugrave -40 +KPX J uhungarumlaut -40 +KPX J umacron -40 +KPX J uogonek -40 +KPX J uring -40 +KPX K O -30 +KPX K Oacute -30 +KPX K Ocircumflex -30 +KPX K Odieresis -30 +KPX K Ograve -30 +KPX K Ohungarumlaut -30 +KPX K Omacron -30 +KPX K Oslash -30 +KPX K Otilde -30 +KPX K e -25 +KPX K eacute -25 +KPX K ecaron -25 +KPX K ecircumflex -25 +KPX K edieresis -25 +KPX K edotaccent -25 +KPX K egrave -25 +KPX K emacron -25 +KPX K eogonek -25 +KPX K o -25 +KPX K oacute -25 +KPX K ocircumflex -25 +KPX K odieresis -25 +KPX K ograve -25 +KPX K ohungarumlaut -25 +KPX K omacron -25 +KPX K oslash -25 +KPX K otilde -25 +KPX K u -20 +KPX K uacute -20 +KPX K ucircumflex -20 +KPX K udieresis -20 +KPX K ugrave -20 +KPX K uhungarumlaut -20 +KPX K umacron -20 +KPX K uogonek -20 +KPX K uring -20 +KPX K y -20 +KPX K yacute -20 +KPX K ydieresis -20 +KPX Kcommaaccent O -30 +KPX Kcommaaccent Oacute -30 +KPX Kcommaaccent Ocircumflex -30 +KPX Kcommaaccent Odieresis -30 +KPX Kcommaaccent Ograve -30 +KPX Kcommaaccent Ohungarumlaut -30 +KPX Kcommaaccent Omacron -30 +KPX Kcommaaccent Oslash -30 +KPX Kcommaaccent Otilde -30 +KPX Kcommaaccent e -25 +KPX Kcommaaccent eacute -25 +KPX Kcommaaccent ecaron -25 +KPX Kcommaaccent ecircumflex -25 +KPX Kcommaaccent edieresis -25 +KPX Kcommaaccent edotaccent -25 +KPX Kcommaaccent egrave -25 +KPX Kcommaaccent emacron -25 +KPX Kcommaaccent eogonek -25 +KPX Kcommaaccent o -25 +KPX Kcommaaccent oacute -25 +KPX Kcommaaccent ocircumflex -25 +KPX Kcommaaccent odieresis -25 +KPX Kcommaaccent ograve -25 +KPX Kcommaaccent ohungarumlaut -25 +KPX Kcommaaccent omacron -25 +KPX Kcommaaccent oslash -25 +KPX Kcommaaccent otilde -25 +KPX Kcommaaccent u -20 +KPX Kcommaaccent uacute -20 +KPX Kcommaaccent ucircumflex -20 +KPX Kcommaaccent udieresis -20 +KPX Kcommaaccent ugrave -20 +KPX Kcommaaccent uhungarumlaut -20 +KPX Kcommaaccent umacron -20 +KPX Kcommaaccent uogonek -20 +KPX Kcommaaccent uring -20 +KPX Kcommaaccent y -20 +KPX Kcommaaccent yacute -20 +KPX Kcommaaccent ydieresis -20 +KPX L T -18 +KPX L Tcaron -18 +KPX L Tcommaaccent -18 +KPX L V -37 +KPX L W -37 +KPX L Y -37 +KPX L Yacute -37 +KPX L Ydieresis -37 +KPX L quoteright -55 +KPX L y -37 +KPX L yacute -37 +KPX L ydieresis -37 +KPX Lacute T -18 +KPX Lacute Tcaron -18 +KPX Lacute Tcommaaccent -18 +KPX Lacute V -37 +KPX Lacute W -37 +KPX Lacute Y -37 +KPX Lacute Yacute -37 +KPX Lacute Ydieresis -37 +KPX Lacute quoteright -55 +KPX Lacute y -37 +KPX Lacute yacute -37 +KPX Lacute ydieresis -37 +KPX Lcommaaccent T -18 +KPX Lcommaaccent Tcaron -18 +KPX Lcommaaccent Tcommaaccent -18 +KPX Lcommaaccent V -37 +KPX Lcommaaccent W -37 +KPX Lcommaaccent Y -37 +KPX Lcommaaccent Yacute -37 +KPX Lcommaaccent Ydieresis -37 +KPX Lcommaaccent quoteright -55 +KPX Lcommaaccent y -37 +KPX Lcommaaccent yacute -37 +KPX Lcommaaccent ydieresis -37 +KPX Lslash T -18 +KPX Lslash Tcaron -18 +KPX Lslash Tcommaaccent -18 +KPX Lslash V -37 +KPX Lslash W -37 +KPX Lslash Y -37 +KPX Lslash Yacute -37 +KPX Lslash Ydieresis -37 +KPX Lslash quoteright -55 +KPX Lslash y -37 +KPX Lslash yacute -37 +KPX Lslash ydieresis -37 +KPX N A -30 +KPX N Aacute -30 +KPX N Abreve -30 +KPX N Acircumflex -30 +KPX N Adieresis -30 +KPX N Agrave -30 +KPX N Amacron -30 +KPX N Aogonek -30 +KPX N Aring -30 +KPX N Atilde -30 +KPX Nacute A -30 +KPX Nacute Aacute -30 +KPX Nacute Abreve -30 +KPX Nacute Acircumflex -30 +KPX Nacute Adieresis -30 +KPX Nacute Agrave -30 +KPX Nacute Amacron -30 +KPX Nacute Aogonek -30 +KPX Nacute Aring -30 +KPX Nacute Atilde -30 +KPX Ncaron A -30 +KPX Ncaron Aacute -30 +KPX Ncaron Abreve -30 +KPX Ncaron Acircumflex -30 +KPX Ncaron Adieresis -30 +KPX Ncaron Agrave -30 +KPX Ncaron Amacron -30 +KPX Ncaron Aogonek -30 +KPX Ncaron Aring -30 +KPX Ncaron Atilde -30 +KPX Ncommaaccent A -30 +KPX Ncommaaccent Aacute -30 +KPX Ncommaaccent Abreve -30 +KPX Ncommaaccent Acircumflex -30 +KPX Ncommaaccent Adieresis -30 +KPX Ncommaaccent Agrave -30 +KPX Ncommaaccent Amacron -30 +KPX Ncommaaccent Aogonek -30 +KPX Ncommaaccent Aring -30 +KPX Ncommaaccent Atilde -30 +KPX Ntilde A -30 +KPX Ntilde Aacute -30 +KPX Ntilde Abreve -30 +KPX Ntilde Acircumflex -30 +KPX Ntilde Adieresis -30 +KPX Ntilde Agrave -30 +KPX Ntilde Amacron -30 +KPX Ntilde Aogonek -30 +KPX Ntilde Aring -30 +KPX Ntilde Atilde -30 +KPX O A -40 +KPX O Aacute -40 +KPX O Abreve -40 +KPX O Acircumflex -40 +KPX O Adieresis -40 +KPX O Agrave -40 +KPX O Amacron -40 +KPX O Aogonek -40 +KPX O Aring -40 +KPX O Atilde -40 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -50 +KPX O X -40 +KPX O Y -50 +KPX O Yacute -50 +KPX O Ydieresis -50 +KPX Oacute A -40 +KPX Oacute Aacute -40 +KPX Oacute Abreve -40 +KPX Oacute Acircumflex -40 +KPX Oacute Adieresis -40 +KPX Oacute Agrave -40 +KPX Oacute Amacron -40 +KPX Oacute Aogonek -40 +KPX Oacute Aring -40 +KPX Oacute Atilde -40 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -50 +KPX Oacute X -40 +KPX Oacute Y -50 +KPX Oacute Yacute -50 +KPX Oacute Ydieresis -50 +KPX Ocircumflex A -40 +KPX Ocircumflex Aacute -40 +KPX Ocircumflex Abreve -40 +KPX Ocircumflex Acircumflex -40 +KPX Ocircumflex Adieresis -40 +KPX Ocircumflex Agrave -40 +KPX Ocircumflex Amacron -40 +KPX Ocircumflex Aogonek -40 +KPX Ocircumflex Aring -40 +KPX Ocircumflex Atilde -40 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -50 +KPX Ocircumflex X -40 +KPX Ocircumflex Y -50 +KPX Ocircumflex Yacute -50 +KPX Ocircumflex Ydieresis -50 +KPX Odieresis A -40 +KPX Odieresis Aacute -40 +KPX Odieresis Abreve -40 +KPX Odieresis Acircumflex -40 +KPX Odieresis Adieresis -40 +KPX Odieresis Agrave -40 +KPX Odieresis Amacron -40 +KPX Odieresis Aogonek -40 +KPX Odieresis Aring -40 +KPX Odieresis Atilde -40 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -50 +KPX Odieresis X -40 +KPX Odieresis Y -50 +KPX Odieresis Yacute -50 +KPX Odieresis Ydieresis -50 +KPX Ograve A -40 +KPX Ograve Aacute -40 +KPX Ograve Abreve -40 +KPX Ograve Acircumflex -40 +KPX Ograve Adieresis -40 +KPX Ograve Agrave -40 +KPX Ograve Amacron -40 +KPX Ograve Aogonek -40 +KPX Ograve Aring -40 +KPX Ograve Atilde -40 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -50 +KPX Ograve X -40 +KPX Ograve Y -50 +KPX Ograve Yacute -50 +KPX Ograve Ydieresis -50 +KPX Ohungarumlaut A -40 +KPX Ohungarumlaut Aacute -40 +KPX Ohungarumlaut Abreve -40 +KPX Ohungarumlaut Acircumflex -40 +KPX Ohungarumlaut Adieresis -40 +KPX Ohungarumlaut Agrave -40 +KPX Ohungarumlaut Amacron -40 +KPX Ohungarumlaut Aogonek -40 +KPX Ohungarumlaut Aring -40 +KPX Ohungarumlaut Atilde -40 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -50 +KPX Ohungarumlaut X -40 +KPX Ohungarumlaut Y -50 +KPX Ohungarumlaut Yacute -50 +KPX Ohungarumlaut Ydieresis -50 +KPX Omacron A -40 +KPX Omacron Aacute -40 +KPX Omacron Abreve -40 +KPX Omacron Acircumflex -40 +KPX Omacron Adieresis -40 +KPX Omacron Agrave -40 +KPX Omacron Amacron -40 +KPX Omacron Aogonek -40 +KPX Omacron Aring -40 +KPX Omacron Atilde -40 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -50 +KPX Omacron X -40 +KPX Omacron Y -50 +KPX Omacron Yacute -50 +KPX Omacron Ydieresis -50 +KPX Oslash A -40 +KPX Oslash Aacute -40 +KPX Oslash Abreve -40 +KPX Oslash Acircumflex -40 +KPX Oslash Adieresis -40 +KPX Oslash Agrave -40 +KPX Oslash Amacron -40 +KPX Oslash Aogonek -40 +KPX Oslash Aring -40 +KPX Oslash Atilde -40 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -50 +KPX Oslash X -40 +KPX Oslash Y -50 +KPX Oslash Yacute -50 +KPX Oslash Ydieresis -50 +KPX Otilde A -40 +KPX Otilde Aacute -40 +KPX Otilde Abreve -40 +KPX Otilde Acircumflex -40 +KPX Otilde Adieresis -40 +KPX Otilde Agrave -40 +KPX Otilde Amacron -40 +KPX Otilde Aogonek -40 +KPX Otilde Aring -40 +KPX Otilde Atilde -40 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -50 +KPX Otilde X -40 +KPX Otilde Y -50 +KPX Otilde Yacute -50 +KPX Otilde Ydieresis -50 +KPX P A -85 +KPX P Aacute -85 +KPX P Abreve -85 +KPX P Acircumflex -85 +KPX P Adieresis -85 +KPX P Agrave -85 +KPX P Amacron -85 +KPX P Aogonek -85 +KPX P Aring -85 +KPX P Atilde -85 +KPX P a -40 +KPX P aacute -40 +KPX P abreve -40 +KPX P acircumflex -40 +KPX P adieresis -40 +KPX P agrave -40 +KPX P amacron -40 +KPX P aogonek -40 +KPX P aring -40 +KPX P atilde -40 +KPX P comma -129 +KPX P e -50 +KPX P eacute -50 +KPX P ecaron -50 +KPX P ecircumflex -50 +KPX P edieresis -50 +KPX P edotaccent -50 +KPX P egrave -50 +KPX P emacron -50 +KPX P eogonek -50 +KPX P o -55 +KPX P oacute -55 +KPX P ocircumflex -55 +KPX P odieresis -55 +KPX P ograve -55 +KPX P ohungarumlaut -55 +KPX P omacron -55 +KPX P oslash -55 +KPX P otilde -55 +KPX P period -129 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX R O -40 +KPX R Oacute -40 +KPX R Ocircumflex -40 +KPX R Odieresis -40 +KPX R Ograve -40 +KPX R Ohungarumlaut -40 +KPX R Omacron -40 +KPX R Oslash -40 +KPX R Otilde -40 +KPX R T -30 +KPX R Tcaron -30 +KPX R Tcommaaccent -30 +KPX R U -40 +KPX R Uacute -40 +KPX R Ucircumflex -40 +KPX R Udieresis -40 +KPX R Ugrave -40 +KPX R Uhungarumlaut -40 +KPX R Umacron -40 +KPX R Uogonek -40 +KPX R Uring -40 +KPX R V -18 +KPX R W -18 +KPX R Y -18 +KPX R Yacute -18 +KPX R Ydieresis -18 +KPX Racute O -40 +KPX Racute Oacute -40 +KPX Racute Ocircumflex -40 +KPX Racute Odieresis -40 +KPX Racute Ograve -40 +KPX Racute Ohungarumlaut -40 +KPX Racute Omacron -40 +KPX Racute Oslash -40 +KPX Racute Otilde -40 +KPX Racute T -30 +KPX Racute Tcaron -30 +KPX Racute Tcommaaccent -30 +KPX Racute U -40 +KPX Racute Uacute -40 +KPX Racute Ucircumflex -40 +KPX Racute Udieresis -40 +KPX Racute Ugrave -40 +KPX Racute Uhungarumlaut -40 +KPX Racute Umacron -40 +KPX Racute Uogonek -40 +KPX Racute Uring -40 +KPX Racute V -18 +KPX Racute W -18 +KPX Racute Y -18 +KPX Racute Yacute -18 +KPX Racute Ydieresis -18 +KPX Rcaron O -40 +KPX Rcaron Oacute -40 +KPX Rcaron Ocircumflex -40 +KPX Rcaron Odieresis -40 +KPX Rcaron Ograve -40 +KPX Rcaron Ohungarumlaut -40 +KPX Rcaron Omacron -40 +KPX Rcaron Oslash -40 +KPX Rcaron Otilde -40 +KPX Rcaron T -30 +KPX Rcaron Tcaron -30 +KPX Rcaron Tcommaaccent -30 +KPX Rcaron U -40 +KPX Rcaron Uacute -40 +KPX Rcaron Ucircumflex -40 +KPX Rcaron Udieresis -40 +KPX Rcaron Ugrave -40 +KPX Rcaron Uhungarumlaut -40 +KPX Rcaron Umacron -40 +KPX Rcaron Uogonek -40 +KPX Rcaron Uring -40 +KPX Rcaron V -18 +KPX Rcaron W -18 +KPX Rcaron Y -18 +KPX Rcaron Yacute -18 +KPX Rcaron Ydieresis -18 +KPX Rcommaaccent O -40 +KPX Rcommaaccent Oacute -40 +KPX Rcommaaccent Ocircumflex -40 +KPX Rcommaaccent Odieresis -40 +KPX Rcommaaccent Ograve -40 +KPX Rcommaaccent Ohungarumlaut -40 +KPX Rcommaaccent Omacron -40 +KPX Rcommaaccent Oslash -40 +KPX Rcommaaccent Otilde -40 +KPX Rcommaaccent T -30 +KPX Rcommaaccent Tcaron -30 +KPX Rcommaaccent Tcommaaccent -30 +KPX Rcommaaccent U -40 +KPX Rcommaaccent Uacute -40 +KPX Rcommaaccent Ucircumflex -40 +KPX Rcommaaccent Udieresis -40 +KPX Rcommaaccent Ugrave -40 +KPX Rcommaaccent Uhungarumlaut -40 +KPX Rcommaaccent Umacron -40 +KPX Rcommaaccent Uogonek -40 +KPX Rcommaaccent Uring -40 +KPX Rcommaaccent V -18 +KPX Rcommaaccent W -18 +KPX Rcommaaccent Y -18 +KPX Rcommaaccent Yacute -18 +KPX Rcommaaccent Ydieresis -18 +KPX T A -55 +KPX T Aacute -55 +KPX T Abreve -55 +KPX T Acircumflex -55 +KPX T Adieresis -55 +KPX T Agrave -55 +KPX T Amacron -55 +KPX T Aogonek -55 +KPX T Aring -55 +KPX T Atilde -55 +KPX T O -18 +KPX T Oacute -18 +KPX T Ocircumflex -18 +KPX T Odieresis -18 +KPX T Ograve -18 +KPX T Ohungarumlaut -18 +KPX T Omacron -18 +KPX T Oslash -18 +KPX T Otilde -18 +KPX T a -92 +KPX T aacute -92 +KPX T abreve -92 +KPX T acircumflex -92 +KPX T adieresis -92 +KPX T agrave -92 +KPX T amacron -92 +KPX T aogonek -92 +KPX T aring -92 +KPX T atilde -92 +KPX T colon -74 +KPX T comma -92 +KPX T e -92 +KPX T eacute -92 +KPX T ecaron -92 +KPX T ecircumflex -92 +KPX T edieresis -52 +KPX T edotaccent -92 +KPX T egrave -52 +KPX T emacron -52 +KPX T eogonek -92 +KPX T hyphen -92 +KPX T i -37 +KPX T iacute -37 +KPX T iogonek -37 +KPX T o -95 +KPX T oacute -95 +KPX T ocircumflex -95 +KPX T odieresis -95 +KPX T ograve -95 +KPX T ohungarumlaut -95 +KPX T omacron -95 +KPX T oslash -95 +KPX T otilde -95 +KPX T period -92 +KPX T r -37 +KPX T racute -37 +KPX T rcaron -37 +KPX T rcommaaccent -37 +KPX T semicolon -74 +KPX T u -37 +KPX T uacute -37 +KPX T ucircumflex -37 +KPX T udieresis -37 +KPX T ugrave -37 +KPX T uhungarumlaut -37 +KPX T umacron -37 +KPX T uogonek -37 +KPX T uring -37 +KPX T w -37 +KPX T y -37 +KPX T yacute -37 +KPX T ydieresis -37 +KPX Tcaron A -55 +KPX Tcaron Aacute -55 +KPX Tcaron Abreve -55 +KPX Tcaron Acircumflex -55 +KPX Tcaron Adieresis -55 +KPX Tcaron Agrave -55 +KPX Tcaron Amacron -55 +KPX Tcaron Aogonek -55 +KPX Tcaron Aring -55 +KPX Tcaron Atilde -55 +KPX Tcaron O -18 +KPX Tcaron Oacute -18 +KPX Tcaron Ocircumflex -18 +KPX Tcaron Odieresis -18 +KPX Tcaron Ograve -18 +KPX Tcaron Ohungarumlaut -18 +KPX Tcaron Omacron -18 +KPX Tcaron Oslash -18 +KPX Tcaron Otilde -18 +KPX Tcaron a -92 +KPX Tcaron aacute -92 +KPX Tcaron abreve -92 +KPX Tcaron acircumflex -92 +KPX Tcaron adieresis -92 +KPX Tcaron agrave -92 +KPX Tcaron amacron -92 +KPX Tcaron aogonek -92 +KPX Tcaron aring -92 +KPX Tcaron atilde -92 +KPX Tcaron colon -74 +KPX Tcaron comma -92 +KPX Tcaron e -92 +KPX Tcaron eacute -92 +KPX Tcaron ecaron -92 +KPX Tcaron ecircumflex -92 +KPX Tcaron edieresis -52 +KPX Tcaron edotaccent -92 +KPX Tcaron egrave -52 +KPX Tcaron emacron -52 +KPX Tcaron eogonek -92 +KPX Tcaron hyphen -92 +KPX Tcaron i -37 +KPX Tcaron iacute -37 +KPX Tcaron iogonek -37 +KPX Tcaron o -95 +KPX Tcaron oacute -95 +KPX Tcaron ocircumflex -95 +KPX Tcaron odieresis -95 +KPX Tcaron ograve -95 +KPX Tcaron ohungarumlaut -95 +KPX Tcaron omacron -95 +KPX Tcaron oslash -95 +KPX Tcaron otilde -95 +KPX Tcaron period -92 +KPX Tcaron r -37 +KPX Tcaron racute -37 +KPX Tcaron rcaron -37 +KPX Tcaron rcommaaccent -37 +KPX Tcaron semicolon -74 +KPX Tcaron u -37 +KPX Tcaron uacute -37 +KPX Tcaron ucircumflex -37 +KPX Tcaron udieresis -37 +KPX Tcaron ugrave -37 +KPX Tcaron uhungarumlaut -37 +KPX Tcaron umacron -37 +KPX Tcaron uogonek -37 +KPX Tcaron uring -37 +KPX Tcaron w -37 +KPX Tcaron y -37 +KPX Tcaron yacute -37 +KPX Tcaron ydieresis -37 +KPX Tcommaaccent A -55 +KPX Tcommaaccent Aacute -55 +KPX Tcommaaccent Abreve -55 +KPX Tcommaaccent Acircumflex -55 +KPX Tcommaaccent Adieresis -55 +KPX Tcommaaccent Agrave -55 +KPX Tcommaaccent Amacron -55 +KPX Tcommaaccent Aogonek -55 +KPX Tcommaaccent Aring -55 +KPX Tcommaaccent Atilde -55 +KPX Tcommaaccent O -18 +KPX Tcommaaccent Oacute -18 +KPX Tcommaaccent Ocircumflex -18 +KPX Tcommaaccent Odieresis -18 +KPX Tcommaaccent Ograve -18 +KPX Tcommaaccent Ohungarumlaut -18 +KPX Tcommaaccent Omacron -18 +KPX Tcommaaccent Oslash -18 +KPX Tcommaaccent Otilde -18 +KPX Tcommaaccent a -92 +KPX Tcommaaccent aacute -92 +KPX Tcommaaccent abreve -92 +KPX Tcommaaccent acircumflex -92 +KPX Tcommaaccent adieresis -92 +KPX Tcommaaccent agrave -92 +KPX Tcommaaccent amacron -92 +KPX Tcommaaccent aogonek -92 +KPX Tcommaaccent aring -92 +KPX Tcommaaccent atilde -92 +KPX Tcommaaccent colon -74 +KPX Tcommaaccent comma -92 +KPX Tcommaaccent e -92 +KPX Tcommaaccent eacute -92 +KPX Tcommaaccent ecaron -92 +KPX Tcommaaccent ecircumflex -92 +KPX Tcommaaccent edieresis -52 +KPX Tcommaaccent edotaccent -92 +KPX Tcommaaccent egrave -52 +KPX Tcommaaccent emacron -52 +KPX Tcommaaccent eogonek -92 +KPX Tcommaaccent hyphen -92 +KPX Tcommaaccent i -37 +KPX Tcommaaccent iacute -37 +KPX Tcommaaccent iogonek -37 +KPX Tcommaaccent o -95 +KPX Tcommaaccent oacute -95 +KPX Tcommaaccent ocircumflex -95 +KPX Tcommaaccent odieresis -95 +KPX Tcommaaccent ograve -95 +KPX Tcommaaccent ohungarumlaut -95 +KPX Tcommaaccent omacron -95 +KPX Tcommaaccent oslash -95 +KPX Tcommaaccent otilde -95 +KPX Tcommaaccent period -92 +KPX Tcommaaccent r -37 +KPX Tcommaaccent racute -37 +KPX Tcommaaccent rcaron -37 +KPX Tcommaaccent rcommaaccent -37 +KPX Tcommaaccent semicolon -74 +KPX Tcommaaccent u -37 +KPX Tcommaaccent uacute -37 +KPX Tcommaaccent ucircumflex -37 +KPX Tcommaaccent udieresis -37 +KPX Tcommaaccent ugrave -37 +KPX Tcommaaccent uhungarumlaut -37 +KPX Tcommaaccent umacron -37 +KPX Tcommaaccent uogonek -37 +KPX Tcommaaccent uring -37 +KPX Tcommaaccent w -37 +KPX Tcommaaccent y -37 +KPX Tcommaaccent yacute -37 +KPX Tcommaaccent ydieresis -37 +KPX U A -45 +KPX U Aacute -45 +KPX U Abreve -45 +KPX U Acircumflex -45 +KPX U Adieresis -45 +KPX U Agrave -45 +KPX U Amacron -45 +KPX U Aogonek -45 +KPX U Aring -45 +KPX U Atilde -45 +KPX Uacute A -45 +KPX Uacute Aacute -45 +KPX Uacute Abreve -45 +KPX Uacute Acircumflex -45 +KPX Uacute Adieresis -45 +KPX Uacute Agrave -45 +KPX Uacute Amacron -45 +KPX Uacute Aogonek -45 +KPX Uacute Aring -45 +KPX Uacute Atilde -45 +KPX Ucircumflex A -45 +KPX Ucircumflex Aacute -45 +KPX Ucircumflex Abreve -45 +KPX Ucircumflex Acircumflex -45 +KPX Ucircumflex Adieresis -45 +KPX Ucircumflex Agrave -45 +KPX Ucircumflex Amacron -45 +KPX Ucircumflex Aogonek -45 +KPX Ucircumflex Aring -45 +KPX Ucircumflex Atilde -45 +KPX Udieresis A -45 +KPX Udieresis Aacute -45 +KPX Udieresis Abreve -45 +KPX Udieresis Acircumflex -45 +KPX Udieresis Adieresis -45 +KPX Udieresis Agrave -45 +KPX Udieresis Amacron -45 +KPX Udieresis Aogonek -45 +KPX Udieresis Aring -45 +KPX Udieresis Atilde -45 +KPX Ugrave A -45 +KPX Ugrave Aacute -45 +KPX Ugrave Abreve -45 +KPX Ugrave Acircumflex -45 +KPX Ugrave Adieresis -45 +KPX Ugrave Agrave -45 +KPX Ugrave Amacron -45 +KPX Ugrave Aogonek -45 +KPX Ugrave Aring -45 +KPX Ugrave Atilde -45 +KPX Uhungarumlaut A -45 +KPX Uhungarumlaut Aacute -45 +KPX Uhungarumlaut Abreve -45 +KPX Uhungarumlaut Acircumflex -45 +KPX Uhungarumlaut Adieresis -45 +KPX Uhungarumlaut Agrave -45 +KPX Uhungarumlaut Amacron -45 +KPX Uhungarumlaut Aogonek -45 +KPX Uhungarumlaut Aring -45 +KPX Uhungarumlaut Atilde -45 +KPX Umacron A -45 +KPX Umacron Aacute -45 +KPX Umacron Abreve -45 +KPX Umacron Acircumflex -45 +KPX Umacron Adieresis -45 +KPX Umacron Agrave -45 +KPX Umacron Amacron -45 +KPX Umacron Aogonek -45 +KPX Umacron Aring -45 +KPX Umacron Atilde -45 +KPX Uogonek A -45 +KPX Uogonek Aacute -45 +KPX Uogonek Abreve -45 +KPX Uogonek Acircumflex -45 +KPX Uogonek Adieresis -45 +KPX Uogonek Agrave -45 +KPX Uogonek Amacron -45 +KPX Uogonek Aogonek -45 +KPX Uogonek Aring -45 +KPX Uogonek Atilde -45 +KPX Uring A -45 +KPX Uring Aacute -45 +KPX Uring Abreve -45 +KPX Uring Acircumflex -45 +KPX Uring Adieresis -45 +KPX Uring Agrave -45 +KPX Uring Amacron -45 +KPX Uring Aogonek -45 +KPX Uring Aring -45 +KPX Uring Atilde -45 +KPX V A -85 +KPX V Aacute -85 +KPX V Abreve -85 +KPX V Acircumflex -85 +KPX V Adieresis -85 +KPX V Agrave -85 +KPX V Amacron -85 +KPX V Aogonek -85 +KPX V Aring -85 +KPX V Atilde -85 +KPX V G -10 +KPX V Gbreve -10 +KPX V Gcommaaccent -10 +KPX V O -30 +KPX V Oacute -30 +KPX V Ocircumflex -30 +KPX V Odieresis -30 +KPX V Ograve -30 +KPX V Ohungarumlaut -30 +KPX V Omacron -30 +KPX V Oslash -30 +KPX V Otilde -30 +KPX V a -111 +KPX V aacute -111 +KPX V abreve -111 +KPX V acircumflex -111 +KPX V adieresis -111 +KPX V agrave -111 +KPX V amacron -111 +KPX V aogonek -111 +KPX V aring -111 +KPX V atilde -111 +KPX V colon -74 +KPX V comma -129 +KPX V e -111 +KPX V eacute -111 +KPX V ecaron -111 +KPX V ecircumflex -111 +KPX V edieresis -71 +KPX V edotaccent -111 +KPX V egrave -71 +KPX V emacron -71 +KPX V eogonek -111 +KPX V hyphen -70 +KPX V i -55 +KPX V iacute -55 +KPX V iogonek -55 +KPX V o -111 +KPX V oacute -111 +KPX V ocircumflex -111 +KPX V odieresis -111 +KPX V ograve -111 +KPX V ohungarumlaut -111 +KPX V omacron -111 +KPX V oslash -111 +KPX V otilde -111 +KPX V period -129 +KPX V semicolon -74 +KPX V u -55 +KPX V uacute -55 +KPX V ucircumflex -55 +KPX V udieresis -55 +KPX V ugrave -55 +KPX V uhungarumlaut -55 +KPX V umacron -55 +KPX V uogonek -55 +KPX V uring -55 +KPX W A -74 +KPX W Aacute -74 +KPX W Abreve -74 +KPX W Acircumflex -74 +KPX W Adieresis -74 +KPX W Agrave -74 +KPX W Amacron -74 +KPX W Aogonek -74 +KPX W Aring -74 +KPX W Atilde -74 +KPX W O -15 +KPX W Oacute -15 +KPX W Ocircumflex -15 +KPX W Odieresis -15 +KPX W Ograve -15 +KPX W Ohungarumlaut -15 +KPX W Omacron -15 +KPX W Oslash -15 +KPX W Otilde -15 +KPX W a -85 +KPX W aacute -85 +KPX W abreve -85 +KPX W acircumflex -85 +KPX W adieresis -85 +KPX W agrave -85 +KPX W amacron -85 +KPX W aogonek -85 +KPX W aring -85 +KPX W atilde -85 +KPX W colon -55 +KPX W comma -74 +KPX W e -90 +KPX W eacute -90 +KPX W ecaron -90 +KPX W ecircumflex -90 +KPX W edieresis -50 +KPX W edotaccent -90 +KPX W egrave -50 +KPX W emacron -50 +KPX W eogonek -90 +KPX W hyphen -50 +KPX W i -37 +KPX W iacute -37 +KPX W iogonek -37 +KPX W o -80 +KPX W oacute -80 +KPX W ocircumflex -80 +KPX W odieresis -80 +KPX W ograve -80 +KPX W ohungarumlaut -80 +KPX W omacron -80 +KPX W oslash -80 +KPX W otilde -80 +KPX W period -74 +KPX W semicolon -55 +KPX W u -55 +KPX W uacute -55 +KPX W ucircumflex -55 +KPX W udieresis -55 +KPX W ugrave -55 +KPX W uhungarumlaut -55 +KPX W umacron -55 +KPX W uogonek -55 +KPX W uring -55 +KPX W y -55 +KPX W yacute -55 +KPX W ydieresis -55 +KPX Y A -74 +KPX Y Aacute -74 +KPX Y Abreve -74 +KPX Y Acircumflex -74 +KPX Y Adieresis -74 +KPX Y Agrave -74 +KPX Y Amacron -74 +KPX Y Aogonek -74 +KPX Y Aring -74 +KPX Y Atilde -74 +KPX Y O -25 +KPX Y Oacute -25 +KPX Y Ocircumflex -25 +KPX Y Odieresis -25 +KPX Y Ograve -25 +KPX Y Ohungarumlaut -25 +KPX Y Omacron -25 +KPX Y Oslash -25 +KPX Y Otilde -25 +KPX Y a -92 +KPX Y aacute -92 +KPX Y abreve -92 +KPX Y acircumflex -92 +KPX Y adieresis -92 +KPX Y agrave -92 +KPX Y amacron -92 +KPX Y aogonek -92 +KPX Y aring -92 +KPX Y atilde -92 +KPX Y colon -92 +KPX Y comma -92 +KPX Y e -111 +KPX Y eacute -111 +KPX Y ecaron -111 +KPX Y ecircumflex -71 +KPX Y edieresis -71 +KPX Y edotaccent -111 +KPX Y egrave -71 +KPX Y emacron -71 +KPX Y eogonek -111 +KPX Y hyphen -92 +KPX Y i -55 +KPX Y iacute -55 +KPX Y iogonek -55 +KPX Y o -111 +KPX Y oacute -111 +KPX Y ocircumflex -111 +KPX Y odieresis -111 +KPX Y ograve -111 +KPX Y ohungarumlaut -111 +KPX Y omacron -111 +KPX Y oslash -111 +KPX Y otilde -111 +KPX Y period -74 +KPX Y semicolon -92 +KPX Y u -92 +KPX Y uacute -92 +KPX Y ucircumflex -92 +KPX Y udieresis -92 +KPX Y ugrave -92 +KPX Y uhungarumlaut -92 +KPX Y umacron -92 +KPX Y uogonek -92 +KPX Y uring -92 +KPX Yacute A -74 +KPX Yacute Aacute -74 +KPX Yacute Abreve -74 +KPX Yacute Acircumflex -74 +KPX Yacute Adieresis -74 +KPX Yacute Agrave -74 +KPX Yacute Amacron -74 +KPX Yacute Aogonek -74 +KPX Yacute Aring -74 +KPX Yacute Atilde -74 +KPX Yacute O -25 +KPX Yacute Oacute -25 +KPX Yacute Ocircumflex -25 +KPX Yacute Odieresis -25 +KPX Yacute Ograve -25 +KPX Yacute Ohungarumlaut -25 +KPX Yacute Omacron -25 +KPX Yacute Oslash -25 +KPX Yacute Otilde -25 +KPX Yacute a -92 +KPX Yacute aacute -92 +KPX Yacute abreve -92 +KPX Yacute acircumflex -92 +KPX Yacute adieresis -92 +KPX Yacute agrave -92 +KPX Yacute amacron -92 +KPX Yacute aogonek -92 +KPX Yacute aring -92 +KPX Yacute atilde -92 +KPX Yacute colon -92 +KPX Yacute comma -92 +KPX Yacute e -111 +KPX Yacute eacute -111 +KPX Yacute ecaron -111 +KPX Yacute ecircumflex -71 +KPX Yacute edieresis -71 +KPX Yacute edotaccent -111 +KPX Yacute egrave -71 +KPX Yacute emacron -71 +KPX Yacute eogonek -111 +KPX Yacute hyphen -92 +KPX Yacute i -55 +KPX Yacute iacute -55 +KPX Yacute iogonek -55 +KPX Yacute o -111 +KPX Yacute oacute -111 +KPX Yacute ocircumflex -111 +KPX Yacute odieresis -111 +KPX Yacute ograve -111 +KPX Yacute ohungarumlaut -111 +KPX Yacute omacron -111 +KPX Yacute oslash -111 +KPX Yacute otilde -111 +KPX Yacute period -74 +KPX Yacute semicolon -92 +KPX Yacute u -92 +KPX Yacute uacute -92 +KPX Yacute ucircumflex -92 +KPX Yacute udieresis -92 +KPX Yacute ugrave -92 +KPX Yacute uhungarumlaut -92 +KPX Yacute umacron -92 +KPX Yacute uogonek -92 +KPX Yacute uring -92 +KPX Ydieresis A -74 +KPX Ydieresis Aacute -74 +KPX Ydieresis Abreve -74 +KPX Ydieresis Acircumflex -74 +KPX Ydieresis Adieresis -74 +KPX Ydieresis Agrave -74 +KPX Ydieresis Amacron -74 +KPX Ydieresis Aogonek -74 +KPX Ydieresis Aring -74 +KPX Ydieresis Atilde -74 +KPX Ydieresis O -25 +KPX Ydieresis Oacute -25 +KPX Ydieresis Ocircumflex -25 +KPX Ydieresis Odieresis -25 +KPX Ydieresis Ograve -25 +KPX Ydieresis Ohungarumlaut -25 +KPX Ydieresis Omacron -25 +KPX Ydieresis Oslash -25 +KPX Ydieresis Otilde -25 +KPX Ydieresis a -92 +KPX Ydieresis aacute -92 +KPX Ydieresis abreve -92 +KPX Ydieresis acircumflex -92 +KPX Ydieresis adieresis -92 +KPX Ydieresis agrave -92 +KPX Ydieresis amacron -92 +KPX Ydieresis aogonek -92 +KPX Ydieresis aring -92 +KPX Ydieresis atilde -92 +KPX Ydieresis colon -92 +KPX Ydieresis comma -92 +KPX Ydieresis e -111 +KPX Ydieresis eacute -111 +KPX Ydieresis ecaron -111 +KPX Ydieresis ecircumflex -71 +KPX Ydieresis edieresis -71 +KPX Ydieresis edotaccent -111 +KPX Ydieresis egrave -71 +KPX Ydieresis emacron -71 +KPX Ydieresis eogonek -111 +KPX Ydieresis hyphen -92 +KPX Ydieresis i -55 +KPX Ydieresis iacute -55 +KPX Ydieresis iogonek -55 +KPX Ydieresis o -111 +KPX Ydieresis oacute -111 +KPX Ydieresis ocircumflex -111 +KPX Ydieresis odieresis -111 +KPX Ydieresis ograve -111 +KPX Ydieresis ohungarumlaut -111 +KPX Ydieresis omacron -111 +KPX Ydieresis oslash -111 +KPX Ydieresis otilde -111 +KPX Ydieresis period -74 +KPX Ydieresis semicolon -92 +KPX Ydieresis u -92 +KPX Ydieresis uacute -92 +KPX Ydieresis ucircumflex -92 +KPX Ydieresis udieresis -92 +KPX Ydieresis ugrave -92 +KPX Ydieresis uhungarumlaut -92 +KPX Ydieresis umacron -92 +KPX Ydieresis uogonek -92 +KPX Ydieresis uring -92 +KPX b b -10 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX c h -10 +KPX c k -10 +KPX c kcommaaccent -10 +KPX cacute h -10 +KPX cacute k -10 +KPX cacute kcommaaccent -10 +KPX ccaron h -10 +KPX ccaron k -10 +KPX ccaron kcommaaccent -10 +KPX ccedilla h -10 +KPX ccedilla k -10 +KPX ccedilla kcommaaccent -10 +KPX comma quotedblright -95 +KPX comma quoteright -95 +KPX e b -10 +KPX eacute b -10 +KPX ecaron b -10 +KPX ecircumflex b -10 +KPX edieresis b -10 +KPX edotaccent b -10 +KPX egrave b -10 +KPX emacron b -10 +KPX eogonek b -10 +KPX f comma -10 +KPX f dotlessi -30 +KPX f e -10 +KPX f eacute -10 +KPX f edotaccent -10 +KPX f eogonek -10 +KPX f f -18 +KPX f o -10 +KPX f oacute -10 +KPX f ocircumflex -10 +KPX f ograve -10 +KPX f ohungarumlaut -10 +KPX f oslash -10 +KPX f otilde -10 +KPX f period -10 +KPX f quoteright 55 +KPX k e -30 +KPX k eacute -30 +KPX k ecaron -30 +KPX k ecircumflex -30 +KPX k edieresis -30 +KPX k edotaccent -30 +KPX k egrave -30 +KPX k emacron -30 +KPX k eogonek -30 +KPX k o -10 +KPX k oacute -10 +KPX k ocircumflex -10 +KPX k odieresis -10 +KPX k ograve -10 +KPX k ohungarumlaut -10 +KPX k omacron -10 +KPX k oslash -10 +KPX k otilde -10 +KPX kcommaaccent e -30 +KPX kcommaaccent eacute -30 +KPX kcommaaccent ecaron -30 +KPX kcommaaccent ecircumflex -30 +KPX kcommaaccent edieresis -30 +KPX kcommaaccent edotaccent -30 +KPX kcommaaccent egrave -30 +KPX kcommaaccent emacron -30 +KPX kcommaaccent eogonek -30 +KPX kcommaaccent o -10 +KPX kcommaaccent oacute -10 +KPX kcommaaccent ocircumflex -10 +KPX kcommaaccent odieresis -10 +KPX kcommaaccent ograve -10 +KPX kcommaaccent ohungarumlaut -10 +KPX kcommaaccent omacron -10 +KPX kcommaaccent oslash -10 +KPX kcommaaccent otilde -10 +KPX n v -40 +KPX nacute v -40 +KPX ncaron v -40 +KPX ncommaaccent v -40 +KPX ntilde v -40 +KPX o v -15 +KPX o w -25 +KPX o x -10 +KPX o y -10 +KPX o yacute -10 +KPX o ydieresis -10 +KPX oacute v -15 +KPX oacute w -25 +KPX oacute x -10 +KPX oacute y -10 +KPX oacute yacute -10 +KPX oacute ydieresis -10 +KPX ocircumflex v -15 +KPX ocircumflex w -25 +KPX ocircumflex x -10 +KPX ocircumflex y -10 +KPX ocircumflex yacute -10 +KPX ocircumflex ydieresis -10 +KPX odieresis v -15 +KPX odieresis w -25 +KPX odieresis x -10 +KPX odieresis y -10 +KPX odieresis yacute -10 +KPX odieresis ydieresis -10 +KPX ograve v -15 +KPX ograve w -25 +KPX ograve x -10 +KPX ograve y -10 +KPX ograve yacute -10 +KPX ograve ydieresis -10 +KPX ohungarumlaut v -15 +KPX ohungarumlaut w -25 +KPX ohungarumlaut x -10 +KPX ohungarumlaut y -10 +KPX ohungarumlaut yacute -10 +KPX ohungarumlaut ydieresis -10 +KPX omacron v -15 +KPX omacron w -25 +KPX omacron x -10 +KPX omacron y -10 +KPX omacron yacute -10 +KPX omacron ydieresis -10 +KPX oslash v -15 +KPX oslash w -25 +KPX oslash x -10 +KPX oslash y -10 +KPX oslash yacute -10 +KPX oslash ydieresis -10 +KPX otilde v -15 +KPX otilde w -25 +KPX otilde x -10 +KPX otilde y -10 +KPX otilde yacute -10 +KPX otilde ydieresis -10 +KPX period quotedblright -95 +KPX period quoteright -95 +KPX quoteleft quoteleft -74 +KPX quoteright d -15 +KPX quoteright dcroat -15 +KPX quoteright quoteright -74 +KPX quoteright r -15 +KPX quoteright racute -15 +KPX quoteright rcaron -15 +KPX quoteright rcommaaccent -15 +KPX quoteright s -74 +KPX quoteright sacute -74 +KPX quoteright scaron -74 +KPX quoteright scedilla -74 +KPX quoteright scommaaccent -74 +KPX quoteright space -74 +KPX quoteright t -37 +KPX quoteright tcommaaccent -37 +KPX quoteright v -15 +KPX r comma -65 +KPX r period -65 +KPX racute comma -65 +KPX racute period -65 +KPX rcaron comma -65 +KPX rcaron period -65 +KPX rcommaaccent comma -65 +KPX rcommaaccent period -65 +KPX space A -37 +KPX space Aacute -37 +KPX space Abreve -37 +KPX space Acircumflex -37 +KPX space Adieresis -37 +KPX space Agrave -37 +KPX space Amacron -37 +KPX space Aogonek -37 +KPX space Aring -37 +KPX space Atilde -37 +KPX space V -70 +KPX space W -70 +KPX space Y -70 +KPX space Yacute -70 +KPX space Ydieresis -70 +KPX v comma -37 +KPX v e -15 +KPX v eacute -15 +KPX v ecaron -15 +KPX v ecircumflex -15 +KPX v edieresis -15 +KPX v edotaccent -15 +KPX v egrave -15 +KPX v emacron -15 +KPX v eogonek -15 +KPX v o -15 +KPX v oacute -15 +KPX v ocircumflex -15 +KPX v odieresis -15 +KPX v ograve -15 +KPX v ohungarumlaut -15 +KPX v omacron -15 +KPX v oslash -15 +KPX v otilde -15 +KPX v period -37 +KPX w a -10 +KPX w aacute -10 +KPX w abreve -10 +KPX w acircumflex -10 +KPX w adieresis -10 +KPX w agrave -10 +KPX w amacron -10 +KPX w aogonek -10 +KPX w aring -10 +KPX w atilde -10 +KPX w comma -37 +KPX w e -10 +KPX w eacute -10 +KPX w ecaron -10 +KPX w ecircumflex -10 +KPX w edieresis -10 +KPX w edotaccent -10 +KPX w egrave -10 +KPX w emacron -10 +KPX w eogonek -10 +KPX w o -15 +KPX w oacute -15 +KPX w ocircumflex -15 +KPX w odieresis -15 +KPX w ograve -15 +KPX w ohungarumlaut -15 +KPX w omacron -15 +KPX w oslash -15 +KPX w otilde -15 +KPX w period -37 +KPX x e -10 +KPX x eacute -10 +KPX x ecaron -10 +KPX x ecircumflex -10 +KPX x edieresis -10 +KPX x edotaccent -10 +KPX x egrave -10 +KPX x emacron -10 +KPX x eogonek -10 +KPX y comma -37 +KPX y period -37 +KPX yacute comma -37 +KPX yacute period -37 +KPX ydieresis comma -37 +KPX ydieresis period -37 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Italic.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Italic.afm new file mode 100644 index 00000000..b0eaee40 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Italic.afm @@ -0,0 +1,2667 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:56:55 1997 +Comment UniqueID 43067 +Comment VMusage 47727 58752 +FontName Times-Italic +FullName Times Italic +FamilyName Times +Weight Medium +ItalicAngle -15.5 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -169 -217 1010 883 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 653 +XHeight 441 +Ascender 683 +Descender -217 +StdHW 32 +StdVW 76 +StartCharMetrics 315 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 39 -11 302 667 ; +C 34 ; WX 420 ; N quotedbl ; B 144 421 432 666 ; +C 35 ; WX 500 ; N numbersign ; B 2 0 540 676 ; +C 36 ; WX 500 ; N dollar ; B 31 -89 497 731 ; +C 37 ; WX 833 ; N percent ; B 79 -13 790 676 ; +C 38 ; WX 778 ; N ampersand ; B 76 -18 723 666 ; +C 39 ; WX 333 ; N quoteright ; B 151 436 290 666 ; +C 40 ; WX 333 ; N parenleft ; B 42 -181 315 669 ; +C 41 ; WX 333 ; N parenright ; B 16 -180 289 669 ; +C 42 ; WX 500 ; N asterisk ; B 128 255 492 666 ; +C 43 ; WX 675 ; N plus ; B 86 0 590 506 ; +C 44 ; WX 250 ; N comma ; B -4 -129 135 101 ; +C 45 ; WX 333 ; N hyphen ; B 49 192 282 255 ; +C 46 ; WX 250 ; N period ; B 27 -11 138 100 ; +C 47 ; WX 278 ; N slash ; B -65 -18 386 666 ; +C 48 ; WX 500 ; N zero ; B 32 -7 497 676 ; +C 49 ; WX 500 ; N one ; B 49 0 409 676 ; +C 50 ; WX 500 ; N two ; B 12 0 452 676 ; +C 51 ; WX 500 ; N three ; B 15 -7 465 676 ; +C 52 ; WX 500 ; N four ; B 1 0 479 676 ; +C 53 ; WX 500 ; N five ; B 15 -7 491 666 ; +C 54 ; WX 500 ; N six ; B 30 -7 521 686 ; +C 55 ; WX 500 ; N seven ; B 75 -8 537 666 ; +C 56 ; WX 500 ; N eight ; B 30 -7 493 676 ; +C 57 ; WX 500 ; N nine ; B 23 -17 492 676 ; +C 58 ; WX 333 ; N colon ; B 50 -11 261 441 ; +C 59 ; WX 333 ; N semicolon ; B 27 -129 261 441 ; +C 60 ; WX 675 ; N less ; B 84 -8 592 514 ; +C 61 ; WX 675 ; N equal ; B 86 120 590 386 ; +C 62 ; WX 675 ; N greater ; B 84 -8 592 514 ; +C 63 ; WX 500 ; N question ; B 132 -12 472 664 ; +C 64 ; WX 920 ; N at ; B 118 -18 806 666 ; +C 65 ; WX 611 ; N A ; B -51 0 564 668 ; +C 66 ; WX 611 ; N B ; B -8 0 588 653 ; +C 67 ; WX 667 ; N C ; B 66 -18 689 666 ; +C 68 ; WX 722 ; N D ; B -8 0 700 653 ; +C 69 ; WX 611 ; N E ; B -1 0 634 653 ; +C 70 ; WX 611 ; N F ; B 8 0 645 653 ; +C 71 ; WX 722 ; N G ; B 52 -18 722 666 ; +C 72 ; WX 722 ; N H ; B -8 0 767 653 ; +C 73 ; WX 333 ; N I ; B -8 0 384 653 ; +C 74 ; WX 444 ; N J ; B -6 -18 491 653 ; +C 75 ; WX 667 ; N K ; B 7 0 722 653 ; +C 76 ; WX 556 ; N L ; B -8 0 559 653 ; +C 77 ; WX 833 ; N M ; B -18 0 873 653 ; +C 78 ; WX 667 ; N N ; B -20 -15 727 653 ; +C 79 ; WX 722 ; N O ; B 60 -18 699 666 ; +C 80 ; WX 611 ; N P ; B 0 0 605 653 ; +C 81 ; WX 722 ; N Q ; B 59 -182 699 666 ; +C 82 ; WX 611 ; N R ; B -13 0 588 653 ; +C 83 ; WX 500 ; N S ; B 17 -18 508 667 ; +C 84 ; WX 556 ; N T ; B 59 0 633 653 ; +C 85 ; WX 722 ; N U ; B 102 -18 765 653 ; +C 86 ; WX 611 ; N V ; B 76 -18 688 653 ; +C 87 ; WX 833 ; N W ; B 71 -18 906 653 ; +C 88 ; WX 611 ; N X ; B -29 0 655 653 ; +C 89 ; WX 556 ; N Y ; B 78 0 633 653 ; +C 90 ; WX 556 ; N Z ; B -6 0 606 653 ; +C 91 ; WX 389 ; N bracketleft ; B 21 -153 391 663 ; +C 92 ; WX 278 ; N backslash ; B -41 -18 319 666 ; +C 93 ; WX 389 ; N bracketright ; B 12 -153 382 663 ; +C 94 ; WX 422 ; N asciicircum ; B 0 301 422 666 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 171 436 310 666 ; +C 97 ; WX 500 ; N a ; B 17 -11 476 441 ; +C 98 ; WX 500 ; N b ; B 23 -11 473 683 ; +C 99 ; WX 444 ; N c ; B 30 -11 425 441 ; +C 100 ; WX 500 ; N d ; B 15 -13 527 683 ; +C 101 ; WX 444 ; N e ; B 31 -11 412 441 ; +C 102 ; WX 278 ; N f ; B -147 -207 424 678 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 8 -206 472 441 ; +C 104 ; WX 500 ; N h ; B 19 -9 478 683 ; +C 105 ; WX 278 ; N i ; B 49 -11 264 654 ; +C 106 ; WX 278 ; N j ; B -124 -207 276 654 ; +C 107 ; WX 444 ; N k ; B 14 -11 461 683 ; +C 108 ; WX 278 ; N l ; B 41 -11 279 683 ; +C 109 ; WX 722 ; N m ; B 12 -9 704 441 ; +C 110 ; WX 500 ; N n ; B 14 -9 474 441 ; +C 111 ; WX 500 ; N o ; B 27 -11 468 441 ; +C 112 ; WX 500 ; N p ; B -75 -205 469 441 ; +C 113 ; WX 500 ; N q ; B 25 -209 483 441 ; +C 114 ; WX 389 ; N r ; B 45 0 412 441 ; +C 115 ; WX 389 ; N s ; B 16 -13 366 442 ; +C 116 ; WX 278 ; N t ; B 37 -11 296 546 ; +C 117 ; WX 500 ; N u ; B 42 -11 475 441 ; +C 118 ; WX 444 ; N v ; B 21 -18 426 441 ; +C 119 ; WX 667 ; N w ; B 16 -18 648 441 ; +C 120 ; WX 444 ; N x ; B -27 -11 447 441 ; +C 121 ; WX 444 ; N y ; B -24 -206 426 441 ; +C 122 ; WX 389 ; N z ; B -2 -81 380 428 ; +C 123 ; WX 400 ; N braceleft ; B 51 -177 407 687 ; +C 124 ; WX 275 ; N bar ; B 105 -217 171 783 ; +C 125 ; WX 400 ; N braceright ; B -7 -177 349 687 ; +C 126 ; WX 541 ; N asciitilde ; B 40 183 502 323 ; +C 161 ; WX 389 ; N exclamdown ; B 59 -205 322 473 ; +C 162 ; WX 500 ; N cent ; B 77 -143 472 560 ; +C 163 ; WX 500 ; N sterling ; B 10 -6 517 670 ; +C 164 ; WX 167 ; N fraction ; B -169 -10 337 676 ; +C 165 ; WX 500 ; N yen ; B 27 0 603 653 ; +C 166 ; WX 500 ; N florin ; B 25 -182 507 682 ; +C 167 ; WX 500 ; N section ; B 53 -162 461 666 ; +C 168 ; WX 500 ; N currency ; B -22 53 522 597 ; +C 169 ; WX 214 ; N quotesingle ; B 132 421 241 666 ; +C 170 ; WX 556 ; N quotedblleft ; B 166 436 514 666 ; +C 171 ; WX 500 ; N guillemotleft ; B 53 37 445 403 ; +C 172 ; WX 333 ; N guilsinglleft ; B 51 37 281 403 ; +C 173 ; WX 333 ; N guilsinglright ; B 52 37 282 403 ; +C 174 ; WX 500 ; N fi ; B -141 -207 481 681 ; +C 175 ; WX 500 ; N fl ; B -141 -204 518 682 ; +C 177 ; WX 500 ; N endash ; B -6 197 505 243 ; +C 178 ; WX 500 ; N dagger ; B 101 -159 488 666 ; +C 179 ; WX 500 ; N daggerdbl ; B 22 -143 491 666 ; +C 180 ; WX 250 ; N periodcentered ; B 70 199 181 310 ; +C 182 ; WX 523 ; N paragraph ; B 55 -123 616 653 ; +C 183 ; WX 350 ; N bullet ; B 40 191 310 461 ; +C 184 ; WX 333 ; N quotesinglbase ; B 44 -129 183 101 ; +C 185 ; WX 556 ; N quotedblbase ; B 57 -129 405 101 ; +C 186 ; WX 556 ; N quotedblright ; B 151 436 499 666 ; +C 187 ; WX 500 ; N guillemotright ; B 55 37 447 403 ; +C 188 ; WX 889 ; N ellipsis ; B 57 -11 762 100 ; +C 189 ; WX 1000 ; N perthousand ; B 25 -19 1010 706 ; +C 191 ; WX 500 ; N questiondown ; B 28 -205 368 471 ; +C 193 ; WX 333 ; N grave ; B 121 492 311 664 ; +C 194 ; WX 333 ; N acute ; B 180 494 403 664 ; +C 195 ; WX 333 ; N circumflex ; B 91 492 385 661 ; +C 196 ; WX 333 ; N tilde ; B 100 517 427 624 ; +C 197 ; WX 333 ; N macron ; B 99 532 411 583 ; +C 198 ; WX 333 ; N breve ; B 117 492 418 650 ; +C 199 ; WX 333 ; N dotaccent ; B 207 548 305 646 ; +C 200 ; WX 333 ; N dieresis ; B 107 548 405 646 ; +C 202 ; WX 333 ; N ring ; B 155 492 355 691 ; +C 203 ; WX 333 ; N cedilla ; B -30 -217 182 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 93 494 486 664 ; +C 206 ; WX 333 ; N ogonek ; B 20 -169 203 40 ; +C 207 ; WX 333 ; N caron ; B 121 492 426 661 ; +C 208 ; WX 889 ; N emdash ; B -6 197 894 243 ; +C 225 ; WX 889 ; N AE ; B -27 0 911 653 ; +C 227 ; WX 276 ; N ordfeminine ; B 42 406 352 676 ; +C 232 ; WX 556 ; N Lslash ; B -8 0 559 653 ; +C 233 ; WX 722 ; N Oslash ; B 60 -105 699 722 ; +C 234 ; WX 944 ; N OE ; B 49 -8 964 666 ; +C 235 ; WX 310 ; N ordmasculine ; B 67 406 362 676 ; +C 241 ; WX 667 ; N ae ; B 23 -11 640 441 ; +C 245 ; WX 278 ; N dotlessi ; B 49 -11 235 441 ; +C 248 ; WX 278 ; N lslash ; B 41 -11 312 683 ; +C 249 ; WX 500 ; N oslash ; B 28 -135 469 554 ; +C 250 ; WX 667 ; N oe ; B 20 -12 646 441 ; +C 251 ; WX 500 ; N germandbls ; B -168 -207 493 679 ; +C -1 ; WX 333 ; N Idieresis ; B -8 0 435 818 ; +C -1 ; WX 444 ; N eacute ; B 31 -11 459 664 ; +C -1 ; WX 500 ; N abreve ; B 17 -11 502 650 ; +C -1 ; WX 500 ; N uhungarumlaut ; B 42 -11 580 664 ; +C -1 ; WX 444 ; N ecaron ; B 31 -11 482 661 ; +C -1 ; WX 556 ; N Ydieresis ; B 78 0 633 818 ; +C -1 ; WX 675 ; N divide ; B 86 -11 590 517 ; +C -1 ; WX 556 ; N Yacute ; B 78 0 633 876 ; +C -1 ; WX 611 ; N Acircumflex ; B -51 0 564 873 ; +C -1 ; WX 500 ; N aacute ; B 17 -11 487 664 ; +C -1 ; WX 722 ; N Ucircumflex ; B 102 -18 765 873 ; +C -1 ; WX 444 ; N yacute ; B -24 -206 459 664 ; +C -1 ; WX 389 ; N scommaaccent ; B 16 -217 366 442 ; +C -1 ; WX 444 ; N ecircumflex ; B 31 -11 441 661 ; +C -1 ; WX 722 ; N Uring ; B 102 -18 765 883 ; +C -1 ; WX 722 ; N Udieresis ; B 102 -18 765 818 ; +C -1 ; WX 500 ; N aogonek ; B 17 -169 476 441 ; +C -1 ; WX 722 ; N Uacute ; B 102 -18 765 876 ; +C -1 ; WX 500 ; N uogonek ; B 42 -169 477 441 ; +C -1 ; WX 611 ; N Edieresis ; B -1 0 634 818 ; +C -1 ; WX 722 ; N Dcroat ; B -8 0 700 653 ; +C -1 ; WX 250 ; N commaaccent ; B 8 -217 133 -50 ; +C -1 ; WX 760 ; N copyright ; B 41 -18 719 666 ; +C -1 ; WX 611 ; N Emacron ; B -1 0 634 795 ; +C -1 ; WX 444 ; N ccaron ; B 30 -11 482 661 ; +C -1 ; WX 500 ; N aring ; B 17 -11 476 691 ; +C -1 ; WX 667 ; N Ncommaaccent ; B -20 -187 727 653 ; +C -1 ; WX 278 ; N lacute ; B 41 -11 395 876 ; +C -1 ; WX 500 ; N agrave ; B 17 -11 476 664 ; +C -1 ; WX 556 ; N Tcommaaccent ; B 59 -217 633 653 ; +C -1 ; WX 667 ; N Cacute ; B 66 -18 690 876 ; +C -1 ; WX 500 ; N atilde ; B 17 -11 511 624 ; +C -1 ; WX 611 ; N Edotaccent ; B -1 0 634 818 ; +C -1 ; WX 389 ; N scaron ; B 16 -13 454 661 ; +C -1 ; WX 389 ; N scedilla ; B 16 -217 366 442 ; +C -1 ; WX 278 ; N iacute ; B 49 -11 355 664 ; +C -1 ; WX 471 ; N lozenge ; B 13 0 459 724 ; +C -1 ; WX 611 ; N Rcaron ; B -13 0 588 873 ; +C -1 ; WX 722 ; N Gcommaaccent ; B 52 -217 722 666 ; +C -1 ; WX 500 ; N ucircumflex ; B 42 -11 475 661 ; +C -1 ; WX 500 ; N acircumflex ; B 17 -11 476 661 ; +C -1 ; WX 611 ; N Amacron ; B -51 0 564 795 ; +C -1 ; WX 389 ; N rcaron ; B 45 0 434 661 ; +C -1 ; WX 444 ; N ccedilla ; B 30 -217 425 441 ; +C -1 ; WX 556 ; N Zdotaccent ; B -6 0 606 818 ; +C -1 ; WX 611 ; N Thorn ; B 0 0 569 653 ; +C -1 ; WX 722 ; N Omacron ; B 60 -18 699 795 ; +C -1 ; WX 611 ; N Racute ; B -13 0 588 876 ; +C -1 ; WX 500 ; N Sacute ; B 17 -18 508 876 ; +C -1 ; WX 544 ; N dcaron ; B 15 -13 658 683 ; +C -1 ; WX 722 ; N Umacron ; B 102 -18 765 795 ; +C -1 ; WX 500 ; N uring ; B 42 -11 475 691 ; +C -1 ; WX 300 ; N threesuperior ; B 43 268 339 676 ; +C -1 ; WX 722 ; N Ograve ; B 60 -18 699 876 ; +C -1 ; WX 611 ; N Agrave ; B -51 0 564 876 ; +C -1 ; WX 611 ; N Abreve ; B -51 0 564 862 ; +C -1 ; WX 675 ; N multiply ; B 93 8 582 497 ; +C -1 ; WX 500 ; N uacute ; B 42 -11 477 664 ; +C -1 ; WX 556 ; N Tcaron ; B 59 0 633 873 ; +C -1 ; WX 476 ; N partialdiff ; B 17 -38 459 710 ; +C -1 ; WX 444 ; N ydieresis ; B -24 -206 441 606 ; +C -1 ; WX 667 ; N Nacute ; B -20 -15 727 876 ; +C -1 ; WX 278 ; N icircumflex ; B 33 -11 327 661 ; +C -1 ; WX 611 ; N Ecircumflex ; B -1 0 634 873 ; +C -1 ; WX 500 ; N adieresis ; B 17 -11 489 606 ; +C -1 ; WX 444 ; N edieresis ; B 31 -11 451 606 ; +C -1 ; WX 444 ; N cacute ; B 30 -11 459 664 ; +C -1 ; WX 500 ; N nacute ; B 14 -9 477 664 ; +C -1 ; WX 500 ; N umacron ; B 42 -11 485 583 ; +C -1 ; WX 667 ; N Ncaron ; B -20 -15 727 873 ; +C -1 ; WX 333 ; N Iacute ; B -8 0 433 876 ; +C -1 ; WX 675 ; N plusminus ; B 86 0 590 506 ; +C -1 ; WX 275 ; N brokenbar ; B 105 -142 171 708 ; +C -1 ; WX 760 ; N registered ; B 41 -18 719 666 ; +C -1 ; WX 722 ; N Gbreve ; B 52 -18 722 862 ; +C -1 ; WX 333 ; N Idotaccent ; B -8 0 384 818 ; +C -1 ; WX 600 ; N summation ; B 15 -10 585 706 ; +C -1 ; WX 611 ; N Egrave ; B -1 0 634 876 ; +C -1 ; WX 389 ; N racute ; B 45 0 431 664 ; +C -1 ; WX 500 ; N omacron ; B 27 -11 495 583 ; +C -1 ; WX 556 ; N Zacute ; B -6 0 606 876 ; +C -1 ; WX 556 ; N Zcaron ; B -6 0 606 873 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 658 ; +C -1 ; WX 722 ; N Eth ; B -8 0 700 653 ; +C -1 ; WX 667 ; N Ccedilla ; B 66 -217 689 666 ; +C -1 ; WX 278 ; N lcommaaccent ; B 22 -217 279 683 ; +C -1 ; WX 300 ; N tcaron ; B 37 -11 407 681 ; +C -1 ; WX 444 ; N eogonek ; B 31 -169 412 441 ; +C -1 ; WX 722 ; N Uogonek ; B 102 -184 765 653 ; +C -1 ; WX 611 ; N Aacute ; B -51 0 564 876 ; +C -1 ; WX 611 ; N Adieresis ; B -51 0 564 818 ; +C -1 ; WX 444 ; N egrave ; B 31 -11 412 664 ; +C -1 ; WX 389 ; N zacute ; B -2 -81 431 664 ; +C -1 ; WX 278 ; N iogonek ; B 49 -169 264 654 ; +C -1 ; WX 722 ; N Oacute ; B 60 -18 699 876 ; +C -1 ; WX 500 ; N oacute ; B 27 -11 487 664 ; +C -1 ; WX 500 ; N amacron ; B 17 -11 495 583 ; +C -1 ; WX 389 ; N sacute ; B 16 -13 431 664 ; +C -1 ; WX 278 ; N idieresis ; B 49 -11 352 606 ; +C -1 ; WX 722 ; N Ocircumflex ; B 60 -18 699 873 ; +C -1 ; WX 722 ; N Ugrave ; B 102 -18 765 876 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 500 ; N thorn ; B -75 -205 469 683 ; +C -1 ; WX 300 ; N twosuperior ; B 33 271 324 676 ; +C -1 ; WX 722 ; N Odieresis ; B 60 -18 699 818 ; +C -1 ; WX 500 ; N mu ; B -30 -209 497 428 ; +C -1 ; WX 278 ; N igrave ; B 49 -11 284 664 ; +C -1 ; WX 500 ; N ohungarumlaut ; B 27 -11 590 664 ; +C -1 ; WX 611 ; N Eogonek ; B -1 -169 634 653 ; +C -1 ; WX 500 ; N dcroat ; B 15 -13 572 683 ; +C -1 ; WX 750 ; N threequarters ; B 23 -10 736 676 ; +C -1 ; WX 500 ; N Scedilla ; B 17 -217 508 667 ; +C -1 ; WX 300 ; N lcaron ; B 41 -11 407 683 ; +C -1 ; WX 667 ; N Kcommaaccent ; B 7 -217 722 653 ; +C -1 ; WX 556 ; N Lacute ; B -8 0 559 876 ; +C -1 ; WX 980 ; N trademark ; B 30 247 957 653 ; +C -1 ; WX 444 ; N edotaccent ; B 31 -11 412 606 ; +C -1 ; WX 333 ; N Igrave ; B -8 0 384 876 ; +C -1 ; WX 333 ; N Imacron ; B -8 0 441 795 ; +C -1 ; WX 611 ; N Lcaron ; B -8 0 586 653 ; +C -1 ; WX 750 ; N onehalf ; B 34 -10 749 676 ; +C -1 ; WX 549 ; N lessequal ; B 26 0 523 658 ; +C -1 ; WX 500 ; N ocircumflex ; B 27 -11 468 661 ; +C -1 ; WX 500 ; N ntilde ; B 14 -9 476 624 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 102 -18 765 876 ; +C -1 ; WX 611 ; N Eacute ; B -1 0 634 876 ; +C -1 ; WX 444 ; N emacron ; B 31 -11 457 583 ; +C -1 ; WX 500 ; N gbreve ; B 8 -206 487 650 ; +C -1 ; WX 750 ; N onequarter ; B 33 -10 736 676 ; +C -1 ; WX 500 ; N Scaron ; B 17 -18 520 873 ; +C -1 ; WX 500 ; N Scommaaccent ; B 17 -217 508 667 ; +C -1 ; WX 722 ; N Ohungarumlaut ; B 60 -18 699 876 ; +C -1 ; WX 400 ; N degree ; B 101 390 387 676 ; +C -1 ; WX 500 ; N ograve ; B 27 -11 468 664 ; +C -1 ; WX 667 ; N Ccaron ; B 66 -18 689 873 ; +C -1 ; WX 500 ; N ugrave ; B 42 -11 475 664 ; +C -1 ; WX 453 ; N radical ; B 2 -60 452 768 ; +C -1 ; WX 722 ; N Dcaron ; B -8 0 700 873 ; +C -1 ; WX 389 ; N rcommaaccent ; B -3 -217 412 441 ; +C -1 ; WX 667 ; N Ntilde ; B -20 -15 727 836 ; +C -1 ; WX 500 ; N otilde ; B 27 -11 496 624 ; +C -1 ; WX 611 ; N Rcommaaccent ; B -13 -187 588 653 ; +C -1 ; WX 556 ; N Lcommaaccent ; B -8 -217 559 653 ; +C -1 ; WX 611 ; N Atilde ; B -51 0 566 836 ; +C -1 ; WX 611 ; N Aogonek ; B -51 -169 566 668 ; +C -1 ; WX 611 ; N Aring ; B -51 0 564 883 ; +C -1 ; WX 722 ; N Otilde ; B 60 -18 699 836 ; +C -1 ; WX 389 ; N zdotaccent ; B -2 -81 380 606 ; +C -1 ; WX 611 ; N Ecaron ; B -1 0 634 873 ; +C -1 ; WX 333 ; N Iogonek ; B -8 -169 384 653 ; +C -1 ; WX 444 ; N kcommaaccent ; B 14 -187 461 683 ; +C -1 ; WX 675 ; N minus ; B 86 220 590 286 ; +C -1 ; WX 333 ; N Icircumflex ; B -8 0 425 873 ; +C -1 ; WX 500 ; N ncaron ; B 14 -9 510 661 ; +C -1 ; WX 278 ; N tcommaaccent ; B 2 -217 296 546 ; +C -1 ; WX 675 ; N logicalnot ; B 86 108 590 386 ; +C -1 ; WX 500 ; N odieresis ; B 27 -11 489 606 ; +C -1 ; WX 500 ; N udieresis ; B 42 -11 479 606 ; +C -1 ; WX 549 ; N notequal ; B 12 -29 537 541 ; +C -1 ; WX 500 ; N gcommaaccent ; B 8 -206 472 706 ; +C -1 ; WX 500 ; N eth ; B 27 -11 482 683 ; +C -1 ; WX 389 ; N zcaron ; B -2 -81 434 661 ; +C -1 ; WX 500 ; N ncommaaccent ; B 14 -187 474 441 ; +C -1 ; WX 300 ; N onesuperior ; B 43 271 284 676 ; +C -1 ; WX 278 ; N imacron ; B 46 -11 311 583 ; +C -1 ; WX 500 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2321 +KPX A C -30 +KPX A Cacute -30 +KPX A Ccaron -30 +KPX A Ccedilla -30 +KPX A G -35 +KPX A Gbreve -35 +KPX A Gcommaaccent -35 +KPX A O -40 +KPX A Oacute -40 +KPX A Ocircumflex -40 +KPX A Odieresis -40 +KPX A Ograve -40 +KPX A Ohungarumlaut -40 +KPX A Omacron -40 +KPX A Oslash -40 +KPX A Otilde -40 +KPX A Q -40 +KPX A T -37 +KPX A Tcaron -37 +KPX A Tcommaaccent -37 +KPX A U -50 +KPX A Uacute -50 +KPX A Ucircumflex -50 +KPX A Udieresis -50 +KPX A Ugrave -50 +KPX A Uhungarumlaut -50 +KPX A Umacron -50 +KPX A Uogonek -50 +KPX A Uring -50 +KPX A V -105 +KPX A W -95 +KPX A Y -55 +KPX A Yacute -55 +KPX A Ydieresis -55 +KPX A quoteright -37 +KPX A u -20 +KPX A uacute -20 +KPX A ucircumflex -20 +KPX A udieresis -20 +KPX A ugrave -20 +KPX A uhungarumlaut -20 +KPX A umacron -20 +KPX A uogonek -20 +KPX A uring -20 +KPX A v -55 +KPX A w -55 +KPX A y -55 +KPX A yacute -55 +KPX A ydieresis -55 +KPX Aacute C -30 +KPX Aacute Cacute -30 +KPX Aacute Ccaron -30 +KPX Aacute Ccedilla -30 +KPX Aacute G -35 +KPX Aacute Gbreve -35 +KPX Aacute Gcommaaccent -35 +KPX Aacute O -40 +KPX Aacute Oacute -40 +KPX Aacute Ocircumflex -40 +KPX Aacute Odieresis -40 +KPX Aacute Ograve -40 +KPX Aacute Ohungarumlaut -40 +KPX Aacute Omacron -40 +KPX Aacute Oslash -40 +KPX Aacute Otilde -40 +KPX Aacute Q -40 +KPX Aacute T -37 +KPX Aacute Tcaron -37 +KPX Aacute Tcommaaccent -37 +KPX Aacute U -50 +KPX Aacute Uacute -50 +KPX Aacute Ucircumflex -50 +KPX Aacute Udieresis -50 +KPX Aacute Ugrave -50 +KPX Aacute Uhungarumlaut -50 +KPX Aacute Umacron -50 +KPX Aacute Uogonek -50 +KPX Aacute Uring -50 +KPX Aacute V -105 +KPX Aacute W -95 +KPX Aacute Y -55 +KPX Aacute Yacute -55 +KPX Aacute Ydieresis -55 +KPX Aacute quoteright -37 +KPX Aacute u -20 +KPX Aacute uacute -20 +KPX Aacute ucircumflex -20 +KPX Aacute udieresis -20 +KPX Aacute ugrave -20 +KPX Aacute uhungarumlaut -20 +KPX Aacute umacron -20 +KPX Aacute uogonek -20 +KPX Aacute uring -20 +KPX Aacute v -55 +KPX Aacute w -55 +KPX Aacute y -55 +KPX Aacute yacute -55 +KPX Aacute ydieresis -55 +KPX Abreve C -30 +KPX Abreve Cacute -30 +KPX Abreve Ccaron -30 +KPX Abreve Ccedilla -30 +KPX Abreve G -35 +KPX Abreve Gbreve -35 +KPX Abreve Gcommaaccent -35 +KPX Abreve O -40 +KPX Abreve Oacute -40 +KPX Abreve Ocircumflex -40 +KPX Abreve Odieresis -40 +KPX Abreve Ograve -40 +KPX Abreve Ohungarumlaut -40 +KPX Abreve Omacron -40 +KPX Abreve Oslash -40 +KPX Abreve Otilde -40 +KPX Abreve Q -40 +KPX Abreve T -37 +KPX Abreve Tcaron -37 +KPX Abreve Tcommaaccent -37 +KPX Abreve U -50 +KPX Abreve Uacute -50 +KPX Abreve Ucircumflex -50 +KPX Abreve Udieresis -50 +KPX Abreve Ugrave -50 +KPX Abreve Uhungarumlaut -50 +KPX Abreve Umacron -50 +KPX Abreve Uogonek -50 +KPX Abreve Uring -50 +KPX Abreve V -105 +KPX Abreve W -95 +KPX Abreve Y -55 +KPX Abreve Yacute -55 +KPX Abreve Ydieresis -55 +KPX Abreve quoteright -37 +KPX Abreve u -20 +KPX Abreve uacute -20 +KPX Abreve ucircumflex -20 +KPX Abreve udieresis -20 +KPX Abreve ugrave -20 +KPX Abreve uhungarumlaut -20 +KPX Abreve umacron -20 +KPX Abreve uogonek -20 +KPX Abreve uring -20 +KPX Abreve v -55 +KPX Abreve w -55 +KPX Abreve y -55 +KPX Abreve yacute -55 +KPX Abreve ydieresis -55 +KPX Acircumflex C -30 +KPX Acircumflex Cacute -30 +KPX Acircumflex Ccaron -30 +KPX Acircumflex Ccedilla -30 +KPX Acircumflex G -35 +KPX Acircumflex Gbreve -35 +KPX Acircumflex Gcommaaccent -35 +KPX Acircumflex O -40 +KPX Acircumflex Oacute -40 +KPX Acircumflex Ocircumflex -40 +KPX Acircumflex Odieresis -40 +KPX Acircumflex Ograve -40 +KPX Acircumflex Ohungarumlaut -40 +KPX Acircumflex Omacron -40 +KPX Acircumflex Oslash -40 +KPX Acircumflex Otilde -40 +KPX Acircumflex Q -40 +KPX Acircumflex T -37 +KPX Acircumflex Tcaron -37 +KPX Acircumflex Tcommaaccent -37 +KPX Acircumflex U -50 +KPX Acircumflex Uacute -50 +KPX Acircumflex Ucircumflex -50 +KPX Acircumflex Udieresis -50 +KPX Acircumflex Ugrave -50 +KPX Acircumflex Uhungarumlaut -50 +KPX Acircumflex Umacron -50 +KPX Acircumflex Uogonek -50 +KPX Acircumflex Uring -50 +KPX Acircumflex V -105 +KPX Acircumflex W -95 +KPX Acircumflex Y -55 +KPX Acircumflex Yacute -55 +KPX Acircumflex Ydieresis -55 +KPX Acircumflex quoteright -37 +KPX Acircumflex u -20 +KPX Acircumflex uacute -20 +KPX Acircumflex ucircumflex -20 +KPX Acircumflex udieresis -20 +KPX Acircumflex ugrave -20 +KPX Acircumflex uhungarumlaut -20 +KPX Acircumflex umacron -20 +KPX Acircumflex uogonek -20 +KPX Acircumflex uring -20 +KPX Acircumflex v -55 +KPX Acircumflex w -55 +KPX Acircumflex y -55 +KPX Acircumflex yacute -55 +KPX Acircumflex ydieresis -55 +KPX Adieresis C -30 +KPX Adieresis Cacute -30 +KPX Adieresis Ccaron -30 +KPX Adieresis Ccedilla -30 +KPX Adieresis G -35 +KPX Adieresis Gbreve -35 +KPX Adieresis Gcommaaccent -35 +KPX Adieresis O -40 +KPX Adieresis Oacute -40 +KPX Adieresis Ocircumflex -40 +KPX Adieresis Odieresis -40 +KPX Adieresis Ograve -40 +KPX Adieresis Ohungarumlaut -40 +KPX Adieresis Omacron -40 +KPX Adieresis Oslash -40 +KPX Adieresis Otilde -40 +KPX Adieresis Q -40 +KPX Adieresis T -37 +KPX Adieresis Tcaron -37 +KPX Adieresis Tcommaaccent -37 +KPX Adieresis U -50 +KPX Adieresis Uacute -50 +KPX Adieresis Ucircumflex -50 +KPX Adieresis Udieresis -50 +KPX Adieresis Ugrave -50 +KPX Adieresis Uhungarumlaut -50 +KPX Adieresis Umacron -50 +KPX Adieresis Uogonek -50 +KPX Adieresis Uring -50 +KPX Adieresis V -105 +KPX Adieresis W -95 +KPX Adieresis Y -55 +KPX Adieresis Yacute -55 +KPX Adieresis Ydieresis -55 +KPX Adieresis quoteright -37 +KPX Adieresis u -20 +KPX Adieresis uacute -20 +KPX Adieresis ucircumflex -20 +KPX Adieresis udieresis -20 +KPX Adieresis ugrave -20 +KPX Adieresis uhungarumlaut -20 +KPX Adieresis umacron -20 +KPX Adieresis uogonek -20 +KPX Adieresis uring -20 +KPX Adieresis v -55 +KPX Adieresis w -55 +KPX Adieresis y -55 +KPX Adieresis yacute -55 +KPX Adieresis ydieresis -55 +KPX Agrave C -30 +KPX Agrave Cacute -30 +KPX Agrave Ccaron -30 +KPX Agrave Ccedilla -30 +KPX Agrave G -35 +KPX Agrave Gbreve -35 +KPX Agrave Gcommaaccent -35 +KPX Agrave O -40 +KPX Agrave Oacute -40 +KPX Agrave Ocircumflex -40 +KPX Agrave Odieresis -40 +KPX Agrave Ograve -40 +KPX Agrave Ohungarumlaut -40 +KPX Agrave Omacron -40 +KPX Agrave Oslash -40 +KPX Agrave Otilde -40 +KPX Agrave Q -40 +KPX Agrave T -37 +KPX Agrave Tcaron -37 +KPX Agrave Tcommaaccent -37 +KPX Agrave U -50 +KPX Agrave Uacute -50 +KPX Agrave Ucircumflex -50 +KPX Agrave Udieresis -50 +KPX Agrave Ugrave -50 +KPX Agrave Uhungarumlaut -50 +KPX Agrave Umacron -50 +KPX Agrave Uogonek -50 +KPX Agrave Uring -50 +KPX Agrave V -105 +KPX Agrave W -95 +KPX Agrave Y -55 +KPX Agrave Yacute -55 +KPX Agrave Ydieresis -55 +KPX Agrave quoteright -37 +KPX Agrave u -20 +KPX Agrave uacute -20 +KPX Agrave ucircumflex -20 +KPX Agrave udieresis -20 +KPX Agrave ugrave -20 +KPX Agrave uhungarumlaut -20 +KPX Agrave umacron -20 +KPX Agrave uogonek -20 +KPX Agrave uring -20 +KPX Agrave v -55 +KPX Agrave w -55 +KPX Agrave y -55 +KPX Agrave yacute -55 +KPX Agrave ydieresis -55 +KPX Amacron C -30 +KPX Amacron Cacute -30 +KPX Amacron Ccaron -30 +KPX Amacron Ccedilla -30 +KPX Amacron G -35 +KPX Amacron Gbreve -35 +KPX Amacron Gcommaaccent -35 +KPX Amacron O -40 +KPX Amacron Oacute -40 +KPX Amacron Ocircumflex -40 +KPX Amacron Odieresis -40 +KPX Amacron Ograve -40 +KPX Amacron Ohungarumlaut -40 +KPX Amacron Omacron -40 +KPX Amacron Oslash -40 +KPX Amacron Otilde -40 +KPX Amacron Q -40 +KPX Amacron T -37 +KPX Amacron Tcaron -37 +KPX Amacron Tcommaaccent -37 +KPX Amacron U -50 +KPX Amacron Uacute -50 +KPX Amacron Ucircumflex -50 +KPX Amacron Udieresis -50 +KPX Amacron Ugrave -50 +KPX Amacron Uhungarumlaut -50 +KPX Amacron Umacron -50 +KPX Amacron Uogonek -50 +KPX Amacron Uring -50 +KPX Amacron V -105 +KPX Amacron W -95 +KPX Amacron Y -55 +KPX Amacron Yacute -55 +KPX Amacron Ydieresis -55 +KPX Amacron quoteright -37 +KPX Amacron u -20 +KPX Amacron uacute -20 +KPX Amacron ucircumflex -20 +KPX Amacron udieresis -20 +KPX Amacron ugrave -20 +KPX Amacron uhungarumlaut -20 +KPX Amacron umacron -20 +KPX Amacron uogonek -20 +KPX Amacron uring -20 +KPX Amacron v -55 +KPX Amacron w -55 +KPX Amacron y -55 +KPX Amacron yacute -55 +KPX Amacron ydieresis -55 +KPX Aogonek C -30 +KPX Aogonek Cacute -30 +KPX Aogonek Ccaron -30 +KPX Aogonek Ccedilla -30 +KPX Aogonek G -35 +KPX Aogonek Gbreve -35 +KPX Aogonek Gcommaaccent -35 +KPX Aogonek O -40 +KPX Aogonek Oacute -40 +KPX Aogonek Ocircumflex -40 +KPX Aogonek Odieresis -40 +KPX Aogonek Ograve -40 +KPX Aogonek Ohungarumlaut -40 +KPX Aogonek Omacron -40 +KPX Aogonek Oslash -40 +KPX Aogonek Otilde -40 +KPX Aogonek Q -40 +KPX Aogonek T -37 +KPX Aogonek Tcaron -37 +KPX Aogonek Tcommaaccent -37 +KPX Aogonek U -50 +KPX Aogonek Uacute -50 +KPX Aogonek Ucircumflex -50 +KPX Aogonek Udieresis -50 +KPX Aogonek Ugrave -50 +KPX Aogonek Uhungarumlaut -50 +KPX Aogonek Umacron -50 +KPX Aogonek Uogonek -50 +KPX Aogonek Uring -50 +KPX Aogonek V -105 +KPX Aogonek W -95 +KPX Aogonek Y -55 +KPX Aogonek Yacute -55 +KPX Aogonek Ydieresis -55 +KPX Aogonek quoteright -37 +KPX Aogonek u -20 +KPX Aogonek uacute -20 +KPX Aogonek ucircumflex -20 +KPX Aogonek udieresis -20 +KPX Aogonek ugrave -20 +KPX Aogonek uhungarumlaut -20 +KPX Aogonek umacron -20 +KPX Aogonek uogonek -20 +KPX Aogonek uring -20 +KPX Aogonek v -55 +KPX Aogonek w -55 +KPX Aogonek y -55 +KPX Aogonek yacute -55 +KPX Aogonek ydieresis -55 +KPX Aring C -30 +KPX Aring Cacute -30 +KPX Aring Ccaron -30 +KPX Aring Ccedilla -30 +KPX Aring G -35 +KPX Aring Gbreve -35 +KPX Aring Gcommaaccent -35 +KPX Aring O -40 +KPX Aring Oacute -40 +KPX Aring Ocircumflex -40 +KPX Aring Odieresis -40 +KPX Aring Ograve -40 +KPX Aring Ohungarumlaut -40 +KPX Aring Omacron -40 +KPX Aring Oslash -40 +KPX Aring Otilde -40 +KPX Aring Q -40 +KPX Aring T -37 +KPX Aring Tcaron -37 +KPX Aring Tcommaaccent -37 +KPX Aring U -50 +KPX Aring Uacute -50 +KPX Aring Ucircumflex -50 +KPX Aring Udieresis -50 +KPX Aring Ugrave -50 +KPX Aring Uhungarumlaut -50 +KPX Aring Umacron -50 +KPX Aring Uogonek -50 +KPX Aring Uring -50 +KPX Aring V -105 +KPX Aring W -95 +KPX Aring Y -55 +KPX Aring Yacute -55 +KPX Aring Ydieresis -55 +KPX Aring quoteright -37 +KPX Aring u -20 +KPX Aring uacute -20 +KPX Aring ucircumflex -20 +KPX Aring udieresis -20 +KPX Aring ugrave -20 +KPX Aring uhungarumlaut -20 +KPX Aring umacron -20 +KPX Aring uogonek -20 +KPX Aring uring -20 +KPX Aring v -55 +KPX Aring w -55 +KPX Aring y -55 +KPX Aring yacute -55 +KPX Aring ydieresis -55 +KPX Atilde C -30 +KPX Atilde Cacute -30 +KPX Atilde Ccaron -30 +KPX Atilde Ccedilla -30 +KPX Atilde G -35 +KPX Atilde Gbreve -35 +KPX Atilde Gcommaaccent -35 +KPX Atilde O -40 +KPX Atilde Oacute -40 +KPX Atilde Ocircumflex -40 +KPX Atilde Odieresis -40 +KPX Atilde Ograve -40 +KPX Atilde Ohungarumlaut -40 +KPX Atilde Omacron -40 +KPX Atilde Oslash -40 +KPX Atilde Otilde -40 +KPX Atilde Q -40 +KPX Atilde T -37 +KPX Atilde Tcaron -37 +KPX Atilde Tcommaaccent -37 +KPX Atilde U -50 +KPX Atilde Uacute -50 +KPX Atilde Ucircumflex -50 +KPX Atilde Udieresis -50 +KPX Atilde Ugrave -50 +KPX Atilde Uhungarumlaut -50 +KPX Atilde Umacron -50 +KPX Atilde Uogonek -50 +KPX Atilde Uring -50 +KPX Atilde V -105 +KPX Atilde W -95 +KPX Atilde Y -55 +KPX Atilde Yacute -55 +KPX Atilde Ydieresis -55 +KPX Atilde quoteright -37 +KPX Atilde u -20 +KPX Atilde uacute -20 +KPX Atilde ucircumflex -20 +KPX Atilde udieresis -20 +KPX Atilde ugrave -20 +KPX Atilde uhungarumlaut -20 +KPX Atilde umacron -20 +KPX Atilde uogonek -20 +KPX Atilde uring -20 +KPX Atilde v -55 +KPX Atilde w -55 +KPX Atilde y -55 +KPX Atilde yacute -55 +KPX Atilde ydieresis -55 +KPX B A -25 +KPX B Aacute -25 +KPX B Abreve -25 +KPX B Acircumflex -25 +KPX B Adieresis -25 +KPX B Agrave -25 +KPX B Amacron -25 +KPX B Aogonek -25 +KPX B Aring -25 +KPX B Atilde -25 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -35 +KPX D Aacute -35 +KPX D Abreve -35 +KPX D Acircumflex -35 +KPX D Adieresis -35 +KPX D Agrave -35 +KPX D Amacron -35 +KPX D Aogonek -35 +KPX D Aring -35 +KPX D Atilde -35 +KPX D V -40 +KPX D W -40 +KPX D Y -40 +KPX D Yacute -40 +KPX D Ydieresis -40 +KPX Dcaron A -35 +KPX Dcaron Aacute -35 +KPX Dcaron Abreve -35 +KPX Dcaron Acircumflex -35 +KPX Dcaron Adieresis -35 +KPX Dcaron Agrave -35 +KPX Dcaron Amacron -35 +KPX Dcaron Aogonek -35 +KPX Dcaron Aring -35 +KPX Dcaron Atilde -35 +KPX Dcaron V -40 +KPX Dcaron W -40 +KPX Dcaron Y -40 +KPX Dcaron Yacute -40 +KPX Dcaron Ydieresis -40 +KPX Dcroat A -35 +KPX Dcroat Aacute -35 +KPX Dcroat Abreve -35 +KPX Dcroat Acircumflex -35 +KPX Dcroat Adieresis -35 +KPX Dcroat Agrave -35 +KPX Dcroat Amacron -35 +KPX Dcroat Aogonek -35 +KPX Dcroat Aring -35 +KPX Dcroat Atilde -35 +KPX Dcroat V -40 +KPX Dcroat W -40 +KPX Dcroat Y -40 +KPX Dcroat Yacute -40 +KPX Dcroat Ydieresis -40 +KPX F A -115 +KPX F Aacute -115 +KPX F Abreve -115 +KPX F Acircumflex -115 +KPX F Adieresis -115 +KPX F Agrave -115 +KPX F Amacron -115 +KPX F Aogonek -115 +KPX F Aring -115 +KPX F Atilde -115 +KPX F a -75 +KPX F aacute -75 +KPX F abreve -75 +KPX F acircumflex -75 +KPX F adieresis -75 +KPX F agrave -75 +KPX F amacron -75 +KPX F aogonek -75 +KPX F aring -75 +KPX F atilde -75 +KPX F comma -135 +KPX F e -75 +KPX F eacute -75 +KPX F ecaron -75 +KPX F ecircumflex -75 +KPX F edieresis -75 +KPX F edotaccent -75 +KPX F egrave -75 +KPX F emacron -75 +KPX F eogonek -75 +KPX F i -45 +KPX F iacute -45 +KPX F icircumflex -45 +KPX F idieresis -45 +KPX F igrave -45 +KPX F imacron -45 +KPX F iogonek -45 +KPX F o -105 +KPX F oacute -105 +KPX F ocircumflex -105 +KPX F odieresis -105 +KPX F ograve -105 +KPX F ohungarumlaut -105 +KPX F omacron -105 +KPX F oslash -105 +KPX F otilde -105 +KPX F period -135 +KPX F r -55 +KPX F racute -55 +KPX F rcaron -55 +KPX F rcommaaccent -55 +KPX J A -40 +KPX J Aacute -40 +KPX J Abreve -40 +KPX J Acircumflex -40 +KPX J Adieresis -40 +KPX J Agrave -40 +KPX J Amacron -40 +KPX J Aogonek -40 +KPX J Aring -40 +KPX J Atilde -40 +KPX J a -35 +KPX J aacute -35 +KPX J abreve -35 +KPX J acircumflex -35 +KPX J adieresis -35 +KPX J agrave -35 +KPX J amacron -35 +KPX J aogonek -35 +KPX J aring -35 +KPX J atilde -35 +KPX J comma -25 +KPX J e -25 +KPX J eacute -25 +KPX J ecaron -25 +KPX J ecircumflex -25 +KPX J edieresis -25 +KPX J edotaccent -25 +KPX J egrave -25 +KPX J emacron -25 +KPX J eogonek -25 +KPX J o -25 +KPX J oacute -25 +KPX J ocircumflex -25 +KPX J odieresis -25 +KPX J ograve -25 +KPX J ohungarumlaut -25 +KPX J omacron -25 +KPX J oslash -25 +KPX J otilde -25 +KPX J period -25 +KPX J u -35 +KPX J uacute -35 +KPX J ucircumflex -35 +KPX J udieresis -35 +KPX J ugrave -35 +KPX J uhungarumlaut -35 +KPX J umacron -35 +KPX J uogonek -35 +KPX J uring -35 +KPX K O -50 +KPX K Oacute -50 +KPX K Ocircumflex -50 +KPX K Odieresis -50 +KPX K Ograve -50 +KPX K Ohungarumlaut -50 +KPX K Omacron -50 +KPX K Oslash -50 +KPX K Otilde -50 +KPX K e -35 +KPX K eacute -35 +KPX K ecaron -35 +KPX K ecircumflex -35 +KPX K edieresis -35 +KPX K edotaccent -35 +KPX K egrave -35 +KPX K emacron -35 +KPX K eogonek -35 +KPX K o -40 +KPX K oacute -40 +KPX K ocircumflex -40 +KPX K odieresis -40 +KPX K ograve -40 +KPX K ohungarumlaut -40 +KPX K omacron -40 +KPX K oslash -40 +KPX K otilde -40 +KPX K u -40 +KPX K uacute -40 +KPX K ucircumflex -40 +KPX K udieresis -40 +KPX K ugrave -40 +KPX K uhungarumlaut -40 +KPX K umacron -40 +KPX K uogonek -40 +KPX K uring -40 +KPX K y -40 +KPX K yacute -40 +KPX K ydieresis -40 +KPX Kcommaaccent O -50 +KPX Kcommaaccent Oacute -50 +KPX Kcommaaccent Ocircumflex -50 +KPX Kcommaaccent Odieresis -50 +KPX Kcommaaccent Ograve -50 +KPX Kcommaaccent Ohungarumlaut -50 +KPX Kcommaaccent Omacron -50 +KPX Kcommaaccent Oslash -50 +KPX Kcommaaccent Otilde -50 +KPX Kcommaaccent e -35 +KPX Kcommaaccent eacute -35 +KPX Kcommaaccent ecaron -35 +KPX Kcommaaccent ecircumflex -35 +KPX Kcommaaccent edieresis -35 +KPX Kcommaaccent edotaccent -35 +KPX Kcommaaccent egrave -35 +KPX Kcommaaccent emacron -35 +KPX Kcommaaccent eogonek -35 +KPX Kcommaaccent o -40 +KPX Kcommaaccent oacute -40 +KPX Kcommaaccent ocircumflex -40 +KPX Kcommaaccent odieresis -40 +KPX Kcommaaccent ograve -40 +KPX Kcommaaccent ohungarumlaut -40 +KPX Kcommaaccent omacron -40 +KPX Kcommaaccent oslash -40 +KPX Kcommaaccent otilde -40 +KPX Kcommaaccent u -40 +KPX Kcommaaccent uacute -40 +KPX Kcommaaccent ucircumflex -40 +KPX Kcommaaccent udieresis -40 +KPX Kcommaaccent ugrave -40 +KPX Kcommaaccent uhungarumlaut -40 +KPX Kcommaaccent umacron -40 +KPX Kcommaaccent uogonek -40 +KPX Kcommaaccent uring -40 +KPX Kcommaaccent y -40 +KPX Kcommaaccent yacute -40 +KPX Kcommaaccent ydieresis -40 +KPX L T -20 +KPX L Tcaron -20 +KPX L Tcommaaccent -20 +KPX L V -55 +KPX L W -55 +KPX L Y -20 +KPX L Yacute -20 +KPX L Ydieresis -20 +KPX L quoteright -37 +KPX L y -30 +KPX L yacute -30 +KPX L ydieresis -30 +KPX Lacute T -20 +KPX Lacute Tcaron -20 +KPX Lacute Tcommaaccent -20 +KPX Lacute V -55 +KPX Lacute W -55 +KPX Lacute Y -20 +KPX Lacute Yacute -20 +KPX Lacute Ydieresis -20 +KPX Lacute quoteright -37 +KPX Lacute y -30 +KPX Lacute yacute -30 +KPX Lacute ydieresis -30 +KPX Lcommaaccent T -20 +KPX Lcommaaccent Tcaron -20 +KPX Lcommaaccent Tcommaaccent -20 +KPX Lcommaaccent V -55 +KPX Lcommaaccent W -55 +KPX Lcommaaccent Y -20 +KPX Lcommaaccent Yacute -20 +KPX Lcommaaccent Ydieresis -20 +KPX Lcommaaccent quoteright -37 +KPX Lcommaaccent y -30 +KPX Lcommaaccent yacute -30 +KPX Lcommaaccent ydieresis -30 +KPX Lslash T -20 +KPX Lslash Tcaron -20 +KPX Lslash Tcommaaccent -20 +KPX Lslash V -55 +KPX Lslash W -55 +KPX Lslash Y -20 +KPX Lslash Yacute -20 +KPX Lslash Ydieresis -20 +KPX Lslash quoteright -37 +KPX Lslash y -30 +KPX Lslash yacute -30 +KPX Lslash ydieresis -30 +KPX N A -27 +KPX N Aacute -27 +KPX N Abreve -27 +KPX N Acircumflex -27 +KPX N Adieresis -27 +KPX N Agrave -27 +KPX N Amacron -27 +KPX N Aogonek -27 +KPX N Aring -27 +KPX N Atilde -27 +KPX Nacute A -27 +KPX Nacute Aacute -27 +KPX Nacute Abreve -27 +KPX Nacute Acircumflex -27 +KPX Nacute Adieresis -27 +KPX Nacute Agrave -27 +KPX Nacute Amacron -27 +KPX Nacute Aogonek -27 +KPX Nacute Aring -27 +KPX Nacute Atilde -27 +KPX Ncaron A -27 +KPX Ncaron Aacute -27 +KPX Ncaron Abreve -27 +KPX Ncaron Acircumflex -27 +KPX Ncaron Adieresis -27 +KPX Ncaron Agrave -27 +KPX Ncaron Amacron -27 +KPX Ncaron Aogonek -27 +KPX Ncaron Aring -27 +KPX Ncaron Atilde -27 +KPX Ncommaaccent A -27 +KPX Ncommaaccent Aacute -27 +KPX Ncommaaccent Abreve -27 +KPX Ncommaaccent Acircumflex -27 +KPX Ncommaaccent Adieresis -27 +KPX Ncommaaccent Agrave -27 +KPX Ncommaaccent Amacron -27 +KPX Ncommaaccent Aogonek -27 +KPX Ncommaaccent Aring -27 +KPX Ncommaaccent Atilde -27 +KPX Ntilde A -27 +KPX Ntilde Aacute -27 +KPX Ntilde Abreve -27 +KPX Ntilde Acircumflex -27 +KPX Ntilde Adieresis -27 +KPX Ntilde Agrave -27 +KPX Ntilde Amacron -27 +KPX Ntilde Aogonek -27 +KPX Ntilde Aring -27 +KPX Ntilde Atilde -27 +KPX O A -55 +KPX O Aacute -55 +KPX O Abreve -55 +KPX O Acircumflex -55 +KPX O Adieresis -55 +KPX O Agrave -55 +KPX O Amacron -55 +KPX O Aogonek -55 +KPX O Aring -55 +KPX O Atilde -55 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -50 +KPX O X -40 +KPX O Y -50 +KPX O Yacute -50 +KPX O Ydieresis -50 +KPX Oacute A -55 +KPX Oacute Aacute -55 +KPX Oacute Abreve -55 +KPX Oacute Acircumflex -55 +KPX Oacute Adieresis -55 +KPX Oacute Agrave -55 +KPX Oacute Amacron -55 +KPX Oacute Aogonek -55 +KPX Oacute Aring -55 +KPX Oacute Atilde -55 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -50 +KPX Oacute X -40 +KPX Oacute Y -50 +KPX Oacute Yacute -50 +KPX Oacute Ydieresis -50 +KPX Ocircumflex A -55 +KPX Ocircumflex Aacute -55 +KPX Ocircumflex Abreve -55 +KPX Ocircumflex Acircumflex -55 +KPX Ocircumflex Adieresis -55 +KPX Ocircumflex Agrave -55 +KPX Ocircumflex Amacron -55 +KPX Ocircumflex Aogonek -55 +KPX Ocircumflex Aring -55 +KPX Ocircumflex Atilde -55 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -50 +KPX Ocircumflex X -40 +KPX Ocircumflex Y -50 +KPX Ocircumflex Yacute -50 +KPX Ocircumflex Ydieresis -50 +KPX Odieresis A -55 +KPX Odieresis Aacute -55 +KPX Odieresis Abreve -55 +KPX Odieresis Acircumflex -55 +KPX Odieresis Adieresis -55 +KPX Odieresis Agrave -55 +KPX Odieresis Amacron -55 +KPX Odieresis Aogonek -55 +KPX Odieresis Aring -55 +KPX Odieresis Atilde -55 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -50 +KPX Odieresis X -40 +KPX Odieresis Y -50 +KPX Odieresis Yacute -50 +KPX Odieresis Ydieresis -50 +KPX Ograve A -55 +KPX Ograve Aacute -55 +KPX Ograve Abreve -55 +KPX Ograve Acircumflex -55 +KPX Ograve Adieresis -55 +KPX Ograve Agrave -55 +KPX Ograve Amacron -55 +KPX Ograve Aogonek -55 +KPX Ograve Aring -55 +KPX Ograve Atilde -55 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -50 +KPX Ograve X -40 +KPX Ograve Y -50 +KPX Ograve Yacute -50 +KPX Ograve Ydieresis -50 +KPX Ohungarumlaut A -55 +KPX Ohungarumlaut Aacute -55 +KPX Ohungarumlaut Abreve -55 +KPX Ohungarumlaut Acircumflex -55 +KPX Ohungarumlaut Adieresis -55 +KPX Ohungarumlaut Agrave -55 +KPX Ohungarumlaut Amacron -55 +KPX Ohungarumlaut Aogonek -55 +KPX Ohungarumlaut Aring -55 +KPX Ohungarumlaut Atilde -55 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -50 +KPX Ohungarumlaut X -40 +KPX Ohungarumlaut Y -50 +KPX Ohungarumlaut Yacute -50 +KPX Ohungarumlaut Ydieresis -50 +KPX Omacron A -55 +KPX Omacron Aacute -55 +KPX Omacron Abreve -55 +KPX Omacron Acircumflex -55 +KPX Omacron Adieresis -55 +KPX Omacron Agrave -55 +KPX Omacron Amacron -55 +KPX Omacron Aogonek -55 +KPX Omacron Aring -55 +KPX Omacron Atilde -55 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -50 +KPX Omacron X -40 +KPX Omacron Y -50 +KPX Omacron Yacute -50 +KPX Omacron Ydieresis -50 +KPX Oslash A -55 +KPX Oslash Aacute -55 +KPX Oslash Abreve -55 +KPX Oslash Acircumflex -55 +KPX Oslash Adieresis -55 +KPX Oslash Agrave -55 +KPX Oslash Amacron -55 +KPX Oslash Aogonek -55 +KPX Oslash Aring -55 +KPX Oslash Atilde -55 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -50 +KPX Oslash X -40 +KPX Oslash Y -50 +KPX Oslash Yacute -50 +KPX Oslash Ydieresis -50 +KPX Otilde A -55 +KPX Otilde Aacute -55 +KPX Otilde Abreve -55 +KPX Otilde Acircumflex -55 +KPX Otilde Adieresis -55 +KPX Otilde Agrave -55 +KPX Otilde Amacron -55 +KPX Otilde Aogonek -55 +KPX Otilde Aring -55 +KPX Otilde Atilde -55 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -50 +KPX Otilde X -40 +KPX Otilde Y -50 +KPX Otilde Yacute -50 +KPX Otilde Ydieresis -50 +KPX P A -90 +KPX P Aacute -90 +KPX P Abreve -90 +KPX P Acircumflex -90 +KPX P Adieresis -90 +KPX P Agrave -90 +KPX P Amacron -90 +KPX P Aogonek -90 +KPX P Aring -90 +KPX P Atilde -90 +KPX P a -80 +KPX P aacute -80 +KPX P abreve -80 +KPX P acircumflex -80 +KPX P adieresis -80 +KPX P agrave -80 +KPX P amacron -80 +KPX P aogonek -80 +KPX P aring -80 +KPX P atilde -80 +KPX P comma -135 +KPX P e -80 +KPX P eacute -80 +KPX P ecaron -80 +KPX P ecircumflex -80 +KPX P edieresis -80 +KPX P edotaccent -80 +KPX P egrave -80 +KPX P emacron -80 +KPX P eogonek -80 +KPX P o -80 +KPX P oacute -80 +KPX P ocircumflex -80 +KPX P odieresis -80 +KPX P ograve -80 +KPX P ohungarumlaut -80 +KPX P omacron -80 +KPX P oslash -80 +KPX P otilde -80 +KPX P period -135 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX R O -40 +KPX R Oacute -40 +KPX R Ocircumflex -40 +KPX R Odieresis -40 +KPX R Ograve -40 +KPX R Ohungarumlaut -40 +KPX R Omacron -40 +KPX R Oslash -40 +KPX R Otilde -40 +KPX R U -40 +KPX R Uacute -40 +KPX R Ucircumflex -40 +KPX R Udieresis -40 +KPX R Ugrave -40 +KPX R Uhungarumlaut -40 +KPX R Umacron -40 +KPX R Uogonek -40 +KPX R Uring -40 +KPX R V -18 +KPX R W -18 +KPX R Y -18 +KPX R Yacute -18 +KPX R Ydieresis -18 +KPX Racute O -40 +KPX Racute Oacute -40 +KPX Racute Ocircumflex -40 +KPX Racute Odieresis -40 +KPX Racute Ograve -40 +KPX Racute Ohungarumlaut -40 +KPX Racute Omacron -40 +KPX Racute Oslash -40 +KPX Racute Otilde -40 +KPX Racute U -40 +KPX Racute Uacute -40 +KPX Racute Ucircumflex -40 +KPX Racute Udieresis -40 +KPX Racute Ugrave -40 +KPX Racute Uhungarumlaut -40 +KPX Racute Umacron -40 +KPX Racute Uogonek -40 +KPX Racute Uring -40 +KPX Racute V -18 +KPX Racute W -18 +KPX Racute Y -18 +KPX Racute Yacute -18 +KPX Racute Ydieresis -18 +KPX Rcaron O -40 +KPX Rcaron Oacute -40 +KPX Rcaron Ocircumflex -40 +KPX Rcaron Odieresis -40 +KPX Rcaron Ograve -40 +KPX Rcaron Ohungarumlaut -40 +KPX Rcaron Omacron -40 +KPX Rcaron Oslash -40 +KPX Rcaron Otilde -40 +KPX Rcaron U -40 +KPX Rcaron Uacute -40 +KPX Rcaron Ucircumflex -40 +KPX Rcaron Udieresis -40 +KPX Rcaron Ugrave -40 +KPX Rcaron Uhungarumlaut -40 +KPX Rcaron Umacron -40 +KPX Rcaron Uogonek -40 +KPX Rcaron Uring -40 +KPX Rcaron V -18 +KPX Rcaron W -18 +KPX Rcaron Y -18 +KPX Rcaron Yacute -18 +KPX Rcaron Ydieresis -18 +KPX Rcommaaccent O -40 +KPX Rcommaaccent Oacute -40 +KPX Rcommaaccent Ocircumflex -40 +KPX Rcommaaccent Odieresis -40 +KPX Rcommaaccent Ograve -40 +KPX Rcommaaccent Ohungarumlaut -40 +KPX Rcommaaccent Omacron -40 +KPX Rcommaaccent Oslash -40 +KPX Rcommaaccent Otilde -40 +KPX Rcommaaccent U -40 +KPX Rcommaaccent Uacute -40 +KPX Rcommaaccent Ucircumflex -40 +KPX Rcommaaccent Udieresis -40 +KPX Rcommaaccent Ugrave -40 +KPX Rcommaaccent Uhungarumlaut -40 +KPX Rcommaaccent Umacron -40 +KPX Rcommaaccent Uogonek -40 +KPX Rcommaaccent Uring -40 +KPX Rcommaaccent V -18 +KPX Rcommaaccent W -18 +KPX Rcommaaccent Y -18 +KPX Rcommaaccent Yacute -18 +KPX Rcommaaccent Ydieresis -18 +KPX T A -50 +KPX T Aacute -50 +KPX T Abreve -50 +KPX T Acircumflex -50 +KPX T Adieresis -50 +KPX T Agrave -50 +KPX T Amacron -50 +KPX T Aogonek -50 +KPX T Aring -50 +KPX T Atilde -50 +KPX T O -18 +KPX T Oacute -18 +KPX T Ocircumflex -18 +KPX T Odieresis -18 +KPX T Ograve -18 +KPX T Ohungarumlaut -18 +KPX T Omacron -18 +KPX T Oslash -18 +KPX T Otilde -18 +KPX T a -92 +KPX T aacute -92 +KPX T abreve -92 +KPX T acircumflex -92 +KPX T adieresis -92 +KPX T agrave -92 +KPX T amacron -92 +KPX T aogonek -92 +KPX T aring -92 +KPX T atilde -92 +KPX T colon -55 +KPX T comma -74 +KPX T e -92 +KPX T eacute -92 +KPX T ecaron -92 +KPX T ecircumflex -52 +KPX T edieresis -52 +KPX T edotaccent -92 +KPX T egrave -52 +KPX T emacron -52 +KPX T eogonek -92 +KPX T hyphen -74 +KPX T i -55 +KPX T iacute -55 +KPX T iogonek -55 +KPX T o -92 +KPX T oacute -92 +KPX T ocircumflex -92 +KPX T odieresis -92 +KPX T ograve -92 +KPX T ohungarumlaut -92 +KPX T omacron -92 +KPX T oslash -92 +KPX T otilde -92 +KPX T period -74 +KPX T r -55 +KPX T racute -55 +KPX T rcaron -55 +KPX T rcommaaccent -55 +KPX T semicolon -65 +KPX T u -55 +KPX T uacute -55 +KPX T ucircumflex -55 +KPX T udieresis -55 +KPX T ugrave -55 +KPX T uhungarumlaut -55 +KPX T umacron -55 +KPX T uogonek -55 +KPX T uring -55 +KPX T w -74 +KPX T y -74 +KPX T yacute -74 +KPX T ydieresis -34 +KPX Tcaron A -50 +KPX Tcaron Aacute -50 +KPX Tcaron Abreve -50 +KPX Tcaron Acircumflex -50 +KPX Tcaron Adieresis -50 +KPX Tcaron Agrave -50 +KPX Tcaron Amacron -50 +KPX Tcaron Aogonek -50 +KPX Tcaron Aring -50 +KPX Tcaron Atilde -50 +KPX Tcaron O -18 +KPX Tcaron Oacute -18 +KPX Tcaron Ocircumflex -18 +KPX Tcaron Odieresis -18 +KPX Tcaron Ograve -18 +KPX Tcaron Ohungarumlaut -18 +KPX Tcaron Omacron -18 +KPX Tcaron Oslash -18 +KPX Tcaron Otilde -18 +KPX Tcaron a -92 +KPX Tcaron aacute -92 +KPX Tcaron abreve -92 +KPX Tcaron acircumflex -92 +KPX Tcaron adieresis -92 +KPX Tcaron agrave -92 +KPX Tcaron amacron -92 +KPX Tcaron aogonek -92 +KPX Tcaron aring -92 +KPX Tcaron atilde -92 +KPX Tcaron colon -55 +KPX Tcaron comma -74 +KPX Tcaron e -92 +KPX Tcaron eacute -92 +KPX Tcaron ecaron -92 +KPX Tcaron ecircumflex -52 +KPX Tcaron edieresis -52 +KPX Tcaron edotaccent -92 +KPX Tcaron egrave -52 +KPX Tcaron emacron -52 +KPX Tcaron eogonek -92 +KPX Tcaron hyphen -74 +KPX Tcaron i -55 +KPX Tcaron iacute -55 +KPX Tcaron iogonek -55 +KPX Tcaron o -92 +KPX Tcaron oacute -92 +KPX Tcaron ocircumflex -92 +KPX Tcaron odieresis -92 +KPX Tcaron ograve -92 +KPX Tcaron ohungarumlaut -92 +KPX Tcaron omacron -92 +KPX Tcaron oslash -92 +KPX Tcaron otilde -92 +KPX Tcaron period -74 +KPX Tcaron r -55 +KPX Tcaron racute -55 +KPX Tcaron rcaron -55 +KPX Tcaron rcommaaccent -55 +KPX Tcaron semicolon -65 +KPX Tcaron u -55 +KPX Tcaron uacute -55 +KPX Tcaron ucircumflex -55 +KPX Tcaron udieresis -55 +KPX Tcaron ugrave -55 +KPX Tcaron uhungarumlaut -55 +KPX Tcaron umacron -55 +KPX Tcaron uogonek -55 +KPX Tcaron uring -55 +KPX Tcaron w -74 +KPX Tcaron y -74 +KPX Tcaron yacute -74 +KPX Tcaron ydieresis -34 +KPX Tcommaaccent A -50 +KPX Tcommaaccent Aacute -50 +KPX Tcommaaccent Abreve -50 +KPX Tcommaaccent Acircumflex -50 +KPX Tcommaaccent Adieresis -50 +KPX Tcommaaccent Agrave -50 +KPX Tcommaaccent Amacron -50 +KPX Tcommaaccent Aogonek -50 +KPX Tcommaaccent Aring -50 +KPX Tcommaaccent Atilde -50 +KPX Tcommaaccent O -18 +KPX Tcommaaccent Oacute -18 +KPX Tcommaaccent Ocircumflex -18 +KPX Tcommaaccent Odieresis -18 +KPX Tcommaaccent Ograve -18 +KPX Tcommaaccent Ohungarumlaut -18 +KPX Tcommaaccent Omacron -18 +KPX Tcommaaccent Oslash -18 +KPX Tcommaaccent Otilde -18 +KPX Tcommaaccent a -92 +KPX Tcommaaccent aacute -92 +KPX Tcommaaccent abreve -92 +KPX Tcommaaccent acircumflex -92 +KPX Tcommaaccent adieresis -92 +KPX Tcommaaccent agrave -92 +KPX Tcommaaccent amacron -92 +KPX Tcommaaccent aogonek -92 +KPX Tcommaaccent aring -92 +KPX Tcommaaccent atilde -92 +KPX Tcommaaccent colon -55 +KPX Tcommaaccent comma -74 +KPX Tcommaaccent e -92 +KPX Tcommaaccent eacute -92 +KPX Tcommaaccent ecaron -92 +KPX Tcommaaccent ecircumflex -52 +KPX Tcommaaccent edieresis -52 +KPX Tcommaaccent edotaccent -92 +KPX Tcommaaccent egrave -52 +KPX Tcommaaccent emacron -52 +KPX Tcommaaccent eogonek -92 +KPX Tcommaaccent hyphen -74 +KPX Tcommaaccent i -55 +KPX Tcommaaccent iacute -55 +KPX Tcommaaccent iogonek -55 +KPX Tcommaaccent o -92 +KPX Tcommaaccent oacute -92 +KPX Tcommaaccent ocircumflex -92 +KPX Tcommaaccent odieresis -92 +KPX Tcommaaccent ograve -92 +KPX Tcommaaccent ohungarumlaut -92 +KPX Tcommaaccent omacron -92 +KPX Tcommaaccent oslash -92 +KPX Tcommaaccent otilde -92 +KPX Tcommaaccent period -74 +KPX Tcommaaccent r -55 +KPX Tcommaaccent racute -55 +KPX Tcommaaccent rcaron -55 +KPX Tcommaaccent rcommaaccent -55 +KPX Tcommaaccent semicolon -65 +KPX Tcommaaccent u -55 +KPX Tcommaaccent uacute -55 +KPX Tcommaaccent ucircumflex -55 +KPX Tcommaaccent udieresis -55 +KPX Tcommaaccent ugrave -55 +KPX Tcommaaccent uhungarumlaut -55 +KPX Tcommaaccent umacron -55 +KPX Tcommaaccent uogonek -55 +KPX Tcommaaccent uring -55 +KPX Tcommaaccent w -74 +KPX Tcommaaccent y -74 +KPX Tcommaaccent yacute -74 +KPX Tcommaaccent ydieresis -34 +KPX U A -40 +KPX U Aacute -40 +KPX U Abreve -40 +KPX U Acircumflex -40 +KPX U Adieresis -40 +KPX U Agrave -40 +KPX U Amacron -40 +KPX U Aogonek -40 +KPX U Aring -40 +KPX U Atilde -40 +KPX U comma -25 +KPX U period -25 +KPX Uacute A -40 +KPX Uacute Aacute -40 +KPX Uacute Abreve -40 +KPX Uacute Acircumflex -40 +KPX Uacute Adieresis -40 +KPX Uacute Agrave -40 +KPX Uacute Amacron -40 +KPX Uacute Aogonek -40 +KPX Uacute Aring -40 +KPX Uacute Atilde -40 +KPX Uacute comma -25 +KPX Uacute period -25 +KPX Ucircumflex A -40 +KPX Ucircumflex Aacute -40 +KPX Ucircumflex Abreve -40 +KPX Ucircumflex Acircumflex -40 +KPX Ucircumflex Adieresis -40 +KPX Ucircumflex Agrave -40 +KPX Ucircumflex Amacron -40 +KPX Ucircumflex Aogonek -40 +KPX Ucircumflex Aring -40 +KPX Ucircumflex Atilde -40 +KPX Ucircumflex comma -25 +KPX Ucircumflex period -25 +KPX Udieresis A -40 +KPX Udieresis Aacute -40 +KPX Udieresis Abreve -40 +KPX Udieresis Acircumflex -40 +KPX Udieresis Adieresis -40 +KPX Udieresis Agrave -40 +KPX Udieresis Amacron -40 +KPX Udieresis Aogonek -40 +KPX Udieresis Aring -40 +KPX Udieresis Atilde -40 +KPX Udieresis comma -25 +KPX Udieresis period -25 +KPX Ugrave A -40 +KPX Ugrave Aacute -40 +KPX Ugrave Abreve -40 +KPX Ugrave Acircumflex -40 +KPX Ugrave Adieresis -40 +KPX Ugrave Agrave -40 +KPX Ugrave Amacron -40 +KPX Ugrave Aogonek -40 +KPX Ugrave Aring -40 +KPX Ugrave Atilde -40 +KPX Ugrave comma -25 +KPX Ugrave period -25 +KPX Uhungarumlaut A -40 +KPX Uhungarumlaut Aacute -40 +KPX Uhungarumlaut Abreve -40 +KPX Uhungarumlaut Acircumflex -40 +KPX Uhungarumlaut Adieresis -40 +KPX Uhungarumlaut Agrave -40 +KPX Uhungarumlaut Amacron -40 +KPX Uhungarumlaut Aogonek -40 +KPX Uhungarumlaut Aring -40 +KPX Uhungarumlaut Atilde -40 +KPX Uhungarumlaut comma -25 +KPX Uhungarumlaut period -25 +KPX Umacron A -40 +KPX Umacron Aacute -40 +KPX Umacron Abreve -40 +KPX Umacron Acircumflex -40 +KPX Umacron Adieresis -40 +KPX Umacron Agrave -40 +KPX Umacron Amacron -40 +KPX Umacron Aogonek -40 +KPX Umacron Aring -40 +KPX Umacron Atilde -40 +KPX Umacron comma -25 +KPX Umacron period -25 +KPX Uogonek A -40 +KPX Uogonek Aacute -40 +KPX Uogonek Abreve -40 +KPX Uogonek Acircumflex -40 +KPX Uogonek Adieresis -40 +KPX Uogonek Agrave -40 +KPX Uogonek Amacron -40 +KPX Uogonek Aogonek -40 +KPX Uogonek Aring -40 +KPX Uogonek Atilde -40 +KPX Uogonek comma -25 +KPX Uogonek period -25 +KPX Uring A -40 +KPX Uring Aacute -40 +KPX Uring Abreve -40 +KPX Uring Acircumflex -40 +KPX Uring Adieresis -40 +KPX Uring Agrave -40 +KPX Uring Amacron -40 +KPX Uring Aogonek -40 +KPX Uring Aring -40 +KPX Uring Atilde -40 +KPX Uring comma -25 +KPX Uring period -25 +KPX V A -60 +KPX V Aacute -60 +KPX V Abreve -60 +KPX V Acircumflex -60 +KPX V Adieresis -60 +KPX V Agrave -60 +KPX V Amacron -60 +KPX V Aogonek -60 +KPX V Aring -60 +KPX V Atilde -60 +KPX V O -30 +KPX V Oacute -30 +KPX V Ocircumflex -30 +KPX V Odieresis -30 +KPX V Ograve -30 +KPX V Ohungarumlaut -30 +KPX V Omacron -30 +KPX V Oslash -30 +KPX V Otilde -30 +KPX V a -111 +KPX V aacute -111 +KPX V abreve -111 +KPX V acircumflex -111 +KPX V adieresis -111 +KPX V agrave -111 +KPX V amacron -111 +KPX V aogonek -111 +KPX V aring -111 +KPX V atilde -111 +KPX V colon -65 +KPX V comma -129 +KPX V e -111 +KPX V eacute -111 +KPX V ecaron -111 +KPX V ecircumflex -111 +KPX V edieresis -71 +KPX V edotaccent -111 +KPX V egrave -71 +KPX V emacron -71 +KPX V eogonek -111 +KPX V hyphen -55 +KPX V i -74 +KPX V iacute -74 +KPX V icircumflex -34 +KPX V idieresis -34 +KPX V igrave -34 +KPX V imacron -34 +KPX V iogonek -74 +KPX V o -111 +KPX V oacute -111 +KPX V ocircumflex -111 +KPX V odieresis -111 +KPX V ograve -111 +KPX V ohungarumlaut -111 +KPX V omacron -111 +KPX V oslash -111 +KPX V otilde -111 +KPX V period -129 +KPX V semicolon -74 +KPX V u -74 +KPX V uacute -74 +KPX V ucircumflex -74 +KPX V udieresis -74 +KPX V ugrave -74 +KPX V uhungarumlaut -74 +KPX V umacron -74 +KPX V uogonek -74 +KPX V uring -74 +KPX W A -60 +KPX W Aacute -60 +KPX W Abreve -60 +KPX W Acircumflex -60 +KPX W Adieresis -60 +KPX W Agrave -60 +KPX W Amacron -60 +KPX W Aogonek -60 +KPX W Aring -60 +KPX W Atilde -60 +KPX W O -25 +KPX W Oacute -25 +KPX W Ocircumflex -25 +KPX W Odieresis -25 +KPX W Ograve -25 +KPX W Ohungarumlaut -25 +KPX W Omacron -25 +KPX W Oslash -25 +KPX W Otilde -25 +KPX W a -92 +KPX W aacute -92 +KPX W abreve -92 +KPX W acircumflex -92 +KPX W adieresis -92 +KPX W agrave -92 +KPX W amacron -92 +KPX W aogonek -92 +KPX W aring -92 +KPX W atilde -92 +KPX W colon -65 +KPX W comma -92 +KPX W e -92 +KPX W eacute -92 +KPX W ecaron -92 +KPX W ecircumflex -92 +KPX W edieresis -52 +KPX W edotaccent -92 +KPX W egrave -52 +KPX W emacron -52 +KPX W eogonek -92 +KPX W hyphen -37 +KPX W i -55 +KPX W iacute -55 +KPX W iogonek -55 +KPX W o -92 +KPX W oacute -92 +KPX W ocircumflex -92 +KPX W odieresis -92 +KPX W ograve -92 +KPX W ohungarumlaut -92 +KPX W omacron -92 +KPX W oslash -92 +KPX W otilde -92 +KPX W period -92 +KPX W semicolon -65 +KPX W u -55 +KPX W uacute -55 +KPX W ucircumflex -55 +KPX W udieresis -55 +KPX W ugrave -55 +KPX W uhungarumlaut -55 +KPX W umacron -55 +KPX W uogonek -55 +KPX W uring -55 +KPX W y -70 +KPX W yacute -70 +KPX W ydieresis -70 +KPX Y A -50 +KPX Y Aacute -50 +KPX Y Abreve -50 +KPX Y Acircumflex -50 +KPX Y Adieresis -50 +KPX Y Agrave -50 +KPX Y Amacron -50 +KPX Y Aogonek -50 +KPX Y Aring -50 +KPX Y Atilde -50 +KPX Y O -15 +KPX Y Oacute -15 +KPX Y Ocircumflex -15 +KPX Y Odieresis -15 +KPX Y Ograve -15 +KPX Y Ohungarumlaut -15 +KPX Y Omacron -15 +KPX Y Oslash -15 +KPX Y Otilde -15 +KPX Y a -92 +KPX Y aacute -92 +KPX Y abreve -92 +KPX Y acircumflex -92 +KPX Y adieresis -92 +KPX Y agrave -92 +KPX Y amacron -92 +KPX Y aogonek -92 +KPX Y aring -92 +KPX Y atilde -92 +KPX Y colon -65 +KPX Y comma -92 +KPX Y e -92 +KPX Y eacute -92 +KPX Y ecaron -92 +KPX Y ecircumflex -92 +KPX Y edieresis -52 +KPX Y edotaccent -92 +KPX Y egrave -52 +KPX Y emacron -52 +KPX Y eogonek -92 +KPX Y hyphen -74 +KPX Y i -74 +KPX Y iacute -74 +KPX Y icircumflex -34 +KPX Y idieresis -34 +KPX Y igrave -34 +KPX Y imacron -34 +KPX Y iogonek -74 +KPX Y o -92 +KPX Y oacute -92 +KPX Y ocircumflex -92 +KPX Y odieresis -92 +KPX Y ograve -92 +KPX Y ohungarumlaut -92 +KPX Y omacron -92 +KPX Y oslash -92 +KPX Y otilde -92 +KPX Y period -92 +KPX Y semicolon -65 +KPX Y u -92 +KPX Y uacute -92 +KPX Y ucircumflex -92 +KPX Y udieresis -92 +KPX Y ugrave -92 +KPX Y uhungarumlaut -92 +KPX Y umacron -92 +KPX Y uogonek -92 +KPX Y uring -92 +KPX Yacute A -50 +KPX Yacute Aacute -50 +KPX Yacute Abreve -50 +KPX Yacute Acircumflex -50 +KPX Yacute Adieresis -50 +KPX Yacute Agrave -50 +KPX Yacute Amacron -50 +KPX Yacute Aogonek -50 +KPX Yacute Aring -50 +KPX Yacute Atilde -50 +KPX Yacute O -15 +KPX Yacute Oacute -15 +KPX Yacute Ocircumflex -15 +KPX Yacute Odieresis -15 +KPX Yacute Ograve -15 +KPX Yacute Ohungarumlaut -15 +KPX Yacute Omacron -15 +KPX Yacute Oslash -15 +KPX Yacute Otilde -15 +KPX Yacute a -92 +KPX Yacute aacute -92 +KPX Yacute abreve -92 +KPX Yacute acircumflex -92 +KPX Yacute adieresis -92 +KPX Yacute agrave -92 +KPX Yacute amacron -92 +KPX Yacute aogonek -92 +KPX Yacute aring -92 +KPX Yacute atilde -92 +KPX Yacute colon -65 +KPX Yacute comma -92 +KPX Yacute e -92 +KPX Yacute eacute -92 +KPX Yacute ecaron -92 +KPX Yacute ecircumflex -92 +KPX Yacute edieresis -52 +KPX Yacute edotaccent -92 +KPX Yacute egrave -52 +KPX Yacute emacron -52 +KPX Yacute eogonek -92 +KPX Yacute hyphen -74 +KPX Yacute i -74 +KPX Yacute iacute -74 +KPX Yacute icircumflex -34 +KPX Yacute idieresis -34 +KPX Yacute igrave -34 +KPX Yacute imacron -34 +KPX Yacute iogonek -74 +KPX Yacute o -92 +KPX Yacute oacute -92 +KPX Yacute ocircumflex -92 +KPX Yacute odieresis -92 +KPX Yacute ograve -92 +KPX Yacute ohungarumlaut -92 +KPX Yacute omacron -92 +KPX Yacute oslash -92 +KPX Yacute otilde -92 +KPX Yacute period -92 +KPX Yacute semicolon -65 +KPX Yacute u -92 +KPX Yacute uacute -92 +KPX Yacute ucircumflex -92 +KPX Yacute udieresis -92 +KPX Yacute ugrave -92 +KPX Yacute uhungarumlaut -92 +KPX Yacute umacron -92 +KPX Yacute uogonek -92 +KPX Yacute uring -92 +KPX Ydieresis A -50 +KPX Ydieresis Aacute -50 +KPX Ydieresis Abreve -50 +KPX Ydieresis Acircumflex -50 +KPX Ydieresis Adieresis -50 +KPX Ydieresis Agrave -50 +KPX Ydieresis Amacron -50 +KPX Ydieresis Aogonek -50 +KPX Ydieresis Aring -50 +KPX Ydieresis Atilde -50 +KPX Ydieresis O -15 +KPX Ydieresis Oacute -15 +KPX Ydieresis Ocircumflex -15 +KPX Ydieresis Odieresis -15 +KPX Ydieresis Ograve -15 +KPX Ydieresis Ohungarumlaut -15 +KPX Ydieresis Omacron -15 +KPX Ydieresis Oslash -15 +KPX Ydieresis Otilde -15 +KPX Ydieresis a -92 +KPX Ydieresis aacute -92 +KPX Ydieresis abreve -92 +KPX Ydieresis acircumflex -92 +KPX Ydieresis adieresis -92 +KPX Ydieresis agrave -92 +KPX Ydieresis amacron -92 +KPX Ydieresis aogonek -92 +KPX Ydieresis aring -92 +KPX Ydieresis atilde -92 +KPX Ydieresis colon -65 +KPX Ydieresis comma -92 +KPX Ydieresis e -92 +KPX Ydieresis eacute -92 +KPX Ydieresis ecaron -92 +KPX Ydieresis ecircumflex -92 +KPX Ydieresis edieresis -52 +KPX Ydieresis edotaccent -92 +KPX Ydieresis egrave -52 +KPX Ydieresis emacron -52 +KPX Ydieresis eogonek -92 +KPX Ydieresis hyphen -74 +KPX Ydieresis i -74 +KPX Ydieresis iacute -74 +KPX Ydieresis icircumflex -34 +KPX Ydieresis idieresis -34 +KPX Ydieresis igrave -34 +KPX Ydieresis imacron -34 +KPX Ydieresis iogonek -74 +KPX Ydieresis o -92 +KPX Ydieresis oacute -92 +KPX Ydieresis ocircumflex -92 +KPX Ydieresis odieresis -92 +KPX Ydieresis ograve -92 +KPX Ydieresis ohungarumlaut -92 +KPX Ydieresis omacron -92 +KPX Ydieresis oslash -92 +KPX Ydieresis otilde -92 +KPX Ydieresis period -92 +KPX Ydieresis semicolon -65 +KPX Ydieresis u -92 +KPX Ydieresis uacute -92 +KPX Ydieresis ucircumflex -92 +KPX Ydieresis udieresis -92 +KPX Ydieresis ugrave -92 +KPX Ydieresis uhungarumlaut -92 +KPX Ydieresis umacron -92 +KPX Ydieresis uogonek -92 +KPX Ydieresis uring -92 +KPX a g -10 +KPX a gbreve -10 +KPX a gcommaaccent -10 +KPX aacute g -10 +KPX aacute gbreve -10 +KPX aacute gcommaaccent -10 +KPX abreve g -10 +KPX abreve gbreve -10 +KPX abreve gcommaaccent -10 +KPX acircumflex g -10 +KPX acircumflex gbreve -10 +KPX acircumflex gcommaaccent -10 +KPX adieresis g -10 +KPX adieresis gbreve -10 +KPX adieresis gcommaaccent -10 +KPX agrave g -10 +KPX agrave gbreve -10 +KPX agrave gcommaaccent -10 +KPX amacron g -10 +KPX amacron gbreve -10 +KPX amacron gcommaaccent -10 +KPX aogonek g -10 +KPX aogonek gbreve -10 +KPX aogonek gcommaaccent -10 +KPX aring g -10 +KPX aring gbreve -10 +KPX aring gcommaaccent -10 +KPX atilde g -10 +KPX atilde gbreve -10 +KPX atilde gcommaaccent -10 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX c h -15 +KPX c k -20 +KPX c kcommaaccent -20 +KPX cacute h -15 +KPX cacute k -20 +KPX cacute kcommaaccent -20 +KPX ccaron h -15 +KPX ccaron k -20 +KPX ccaron kcommaaccent -20 +KPX ccedilla h -15 +KPX ccedilla k -20 +KPX ccedilla kcommaaccent -20 +KPX comma quotedblright -140 +KPX comma quoteright -140 +KPX e comma -10 +KPX e g -40 +KPX e gbreve -40 +KPX e gcommaaccent -40 +KPX e period -15 +KPX e v -15 +KPX e w -15 +KPX e x -20 +KPX e y -30 +KPX e yacute -30 +KPX e ydieresis -30 +KPX eacute comma -10 +KPX eacute g -40 +KPX eacute gbreve -40 +KPX eacute gcommaaccent -40 +KPX eacute period -15 +KPX eacute v -15 +KPX eacute w -15 +KPX eacute x -20 +KPX eacute y -30 +KPX eacute yacute -30 +KPX eacute ydieresis -30 +KPX ecaron comma -10 +KPX ecaron g -40 +KPX ecaron gbreve -40 +KPX ecaron gcommaaccent -40 +KPX ecaron period -15 +KPX ecaron v -15 +KPX ecaron w -15 +KPX ecaron x -20 +KPX ecaron y -30 +KPX ecaron yacute -30 +KPX ecaron ydieresis -30 +KPX ecircumflex comma -10 +KPX ecircumflex g -40 +KPX ecircumflex gbreve -40 +KPX ecircumflex gcommaaccent -40 +KPX ecircumflex period -15 +KPX ecircumflex v -15 +KPX ecircumflex w -15 +KPX ecircumflex x -20 +KPX ecircumflex y -30 +KPX ecircumflex yacute -30 +KPX ecircumflex ydieresis -30 +KPX edieresis comma -10 +KPX edieresis g -40 +KPX edieresis gbreve -40 +KPX edieresis gcommaaccent -40 +KPX edieresis period -15 +KPX edieresis v -15 +KPX edieresis w -15 +KPX edieresis x -20 +KPX edieresis y -30 +KPX edieresis yacute -30 +KPX edieresis ydieresis -30 +KPX edotaccent comma -10 +KPX edotaccent g -40 +KPX edotaccent gbreve -40 +KPX edotaccent gcommaaccent -40 +KPX edotaccent period -15 +KPX edotaccent v -15 +KPX edotaccent w -15 +KPX edotaccent x -20 +KPX edotaccent y -30 +KPX edotaccent yacute -30 +KPX edotaccent ydieresis -30 +KPX egrave comma -10 +KPX egrave g -40 +KPX egrave gbreve -40 +KPX egrave gcommaaccent -40 +KPX egrave period -15 +KPX egrave v -15 +KPX egrave w -15 +KPX egrave x -20 +KPX egrave y -30 +KPX egrave yacute -30 +KPX egrave ydieresis -30 +KPX emacron comma -10 +KPX emacron g -40 +KPX emacron gbreve -40 +KPX emacron gcommaaccent -40 +KPX emacron period -15 +KPX emacron v -15 +KPX emacron w -15 +KPX emacron x -20 +KPX emacron y -30 +KPX emacron yacute -30 +KPX emacron ydieresis -30 +KPX eogonek comma -10 +KPX eogonek g -40 +KPX eogonek gbreve -40 +KPX eogonek gcommaaccent -40 +KPX eogonek period -15 +KPX eogonek v -15 +KPX eogonek w -15 +KPX eogonek x -20 +KPX eogonek y -30 +KPX eogonek yacute -30 +KPX eogonek ydieresis -30 +KPX f comma -10 +KPX f dotlessi -60 +KPX f f -18 +KPX f i -20 +KPX f iogonek -20 +KPX f period -15 +KPX f quoteright 92 +KPX g comma -10 +KPX g e -10 +KPX g eacute -10 +KPX g ecaron -10 +KPX g ecircumflex -10 +KPX g edieresis -10 +KPX g edotaccent -10 +KPX g egrave -10 +KPX g emacron -10 +KPX g eogonek -10 +KPX g g -10 +KPX g gbreve -10 +KPX g gcommaaccent -10 +KPX g period -15 +KPX gbreve comma -10 +KPX gbreve e -10 +KPX gbreve eacute -10 +KPX gbreve ecaron -10 +KPX gbreve ecircumflex -10 +KPX gbreve edieresis -10 +KPX gbreve edotaccent -10 +KPX gbreve egrave -10 +KPX gbreve emacron -10 +KPX gbreve eogonek -10 +KPX gbreve g -10 +KPX gbreve gbreve -10 +KPX gbreve gcommaaccent -10 +KPX gbreve period -15 +KPX gcommaaccent comma -10 +KPX gcommaaccent e -10 +KPX gcommaaccent eacute -10 +KPX gcommaaccent ecaron -10 +KPX gcommaaccent ecircumflex -10 +KPX gcommaaccent edieresis -10 +KPX gcommaaccent edotaccent -10 +KPX gcommaaccent egrave -10 +KPX gcommaaccent emacron -10 +KPX gcommaaccent eogonek -10 +KPX gcommaaccent g -10 +KPX gcommaaccent gbreve -10 +KPX gcommaaccent gcommaaccent -10 +KPX gcommaaccent period -15 +KPX k e -10 +KPX k eacute -10 +KPX k ecaron -10 +KPX k ecircumflex -10 +KPX k edieresis -10 +KPX k edotaccent -10 +KPX k egrave -10 +KPX k emacron -10 +KPX k eogonek -10 +KPX k o -10 +KPX k oacute -10 +KPX k ocircumflex -10 +KPX k odieresis -10 +KPX k ograve -10 +KPX k ohungarumlaut -10 +KPX k omacron -10 +KPX k oslash -10 +KPX k otilde -10 +KPX k y -10 +KPX k yacute -10 +KPX k ydieresis -10 +KPX kcommaaccent e -10 +KPX kcommaaccent eacute -10 +KPX kcommaaccent ecaron -10 +KPX kcommaaccent ecircumflex -10 +KPX kcommaaccent edieresis -10 +KPX kcommaaccent edotaccent -10 +KPX kcommaaccent egrave -10 +KPX kcommaaccent emacron -10 +KPX kcommaaccent eogonek -10 +KPX kcommaaccent o -10 +KPX kcommaaccent oacute -10 +KPX kcommaaccent ocircumflex -10 +KPX kcommaaccent odieresis -10 +KPX kcommaaccent ograve -10 +KPX kcommaaccent ohungarumlaut -10 +KPX kcommaaccent omacron -10 +KPX kcommaaccent oslash -10 +KPX kcommaaccent otilde -10 +KPX kcommaaccent y -10 +KPX kcommaaccent yacute -10 +KPX kcommaaccent ydieresis -10 +KPX n v -40 +KPX nacute v -40 +KPX ncaron v -40 +KPX ncommaaccent v -40 +KPX ntilde v -40 +KPX o g -10 +KPX o gbreve -10 +KPX o gcommaaccent -10 +KPX o v -10 +KPX oacute g -10 +KPX oacute gbreve -10 +KPX oacute gcommaaccent -10 +KPX oacute v -10 +KPX ocircumflex g -10 +KPX ocircumflex gbreve -10 +KPX ocircumflex gcommaaccent -10 +KPX ocircumflex v -10 +KPX odieresis g -10 +KPX odieresis gbreve -10 +KPX odieresis gcommaaccent -10 +KPX odieresis v -10 +KPX ograve g -10 +KPX ograve gbreve -10 +KPX ograve gcommaaccent -10 +KPX ograve v -10 +KPX ohungarumlaut g -10 +KPX ohungarumlaut gbreve -10 +KPX ohungarumlaut gcommaaccent -10 +KPX ohungarumlaut v -10 +KPX omacron g -10 +KPX omacron gbreve -10 +KPX omacron gcommaaccent -10 +KPX omacron v -10 +KPX oslash g -10 +KPX oslash gbreve -10 +KPX oslash gcommaaccent -10 +KPX oslash v -10 +KPX otilde g -10 +KPX otilde gbreve -10 +KPX otilde gcommaaccent -10 +KPX otilde v -10 +KPX period quotedblright -140 +KPX period quoteright -140 +KPX quoteleft quoteleft -111 +KPX quoteright d -25 +KPX quoteright dcroat -25 +KPX quoteright quoteright -111 +KPX quoteright r -25 +KPX quoteright racute -25 +KPX quoteright rcaron -25 +KPX quoteright rcommaaccent -25 +KPX quoteright s -40 +KPX quoteright sacute -40 +KPX quoteright scaron -40 +KPX quoteright scedilla -40 +KPX quoteright scommaaccent -40 +KPX quoteright space -111 +KPX quoteright t -30 +KPX quoteright tcommaaccent -30 +KPX quoteright v -10 +KPX r a -15 +KPX r aacute -15 +KPX r abreve -15 +KPX r acircumflex -15 +KPX r adieresis -15 +KPX r agrave -15 +KPX r amacron -15 +KPX r aogonek -15 +KPX r aring -15 +KPX r atilde -15 +KPX r c -37 +KPX r cacute -37 +KPX r ccaron -37 +KPX r ccedilla -37 +KPX r comma -111 +KPX r d -37 +KPX r dcroat -37 +KPX r e -37 +KPX r eacute -37 +KPX r ecaron -37 +KPX r ecircumflex -37 +KPX r edieresis -37 +KPX r edotaccent -37 +KPX r egrave -37 +KPX r emacron -37 +KPX r eogonek -37 +KPX r g -37 +KPX r gbreve -37 +KPX r gcommaaccent -37 +KPX r hyphen -20 +KPX r o -45 +KPX r oacute -45 +KPX r ocircumflex -45 +KPX r odieresis -45 +KPX r ograve -45 +KPX r ohungarumlaut -45 +KPX r omacron -45 +KPX r oslash -45 +KPX r otilde -45 +KPX r period -111 +KPX r q -37 +KPX r s -10 +KPX r sacute -10 +KPX r scaron -10 +KPX r scedilla -10 +KPX r scommaaccent -10 +KPX racute a -15 +KPX racute aacute -15 +KPX racute abreve -15 +KPX racute acircumflex -15 +KPX racute adieresis -15 +KPX racute agrave -15 +KPX racute amacron -15 +KPX racute aogonek -15 +KPX racute aring -15 +KPX racute atilde -15 +KPX racute c -37 +KPX racute cacute -37 +KPX racute ccaron -37 +KPX racute ccedilla -37 +KPX racute comma -111 +KPX racute d -37 +KPX racute dcroat -37 +KPX racute e -37 +KPX racute eacute -37 +KPX racute ecaron -37 +KPX racute ecircumflex -37 +KPX racute edieresis -37 +KPX racute edotaccent -37 +KPX racute egrave -37 +KPX racute emacron -37 +KPX racute eogonek -37 +KPX racute g -37 +KPX racute gbreve -37 +KPX racute gcommaaccent -37 +KPX racute hyphen -20 +KPX racute o -45 +KPX racute oacute -45 +KPX racute ocircumflex -45 +KPX racute odieresis -45 +KPX racute ograve -45 +KPX racute ohungarumlaut -45 +KPX racute omacron -45 +KPX racute oslash -45 +KPX racute otilde -45 +KPX racute period -111 +KPX racute q -37 +KPX racute s -10 +KPX racute sacute -10 +KPX racute scaron -10 +KPX racute scedilla -10 +KPX racute scommaaccent -10 +KPX rcaron a -15 +KPX rcaron aacute -15 +KPX rcaron abreve -15 +KPX rcaron acircumflex -15 +KPX rcaron adieresis -15 +KPX rcaron agrave -15 +KPX rcaron amacron -15 +KPX rcaron aogonek -15 +KPX rcaron aring -15 +KPX rcaron atilde -15 +KPX rcaron c -37 +KPX rcaron cacute -37 +KPX rcaron ccaron -37 +KPX rcaron ccedilla -37 +KPX rcaron comma -111 +KPX rcaron d -37 +KPX rcaron dcroat -37 +KPX rcaron e -37 +KPX rcaron eacute -37 +KPX rcaron ecaron -37 +KPX rcaron ecircumflex -37 +KPX rcaron edieresis -37 +KPX rcaron edotaccent -37 +KPX rcaron egrave -37 +KPX rcaron emacron -37 +KPX rcaron eogonek -37 +KPX rcaron g -37 +KPX rcaron gbreve -37 +KPX rcaron gcommaaccent -37 +KPX rcaron hyphen -20 +KPX rcaron o -45 +KPX rcaron oacute -45 +KPX rcaron ocircumflex -45 +KPX rcaron odieresis -45 +KPX rcaron ograve -45 +KPX rcaron ohungarumlaut -45 +KPX rcaron omacron -45 +KPX rcaron oslash -45 +KPX rcaron otilde -45 +KPX rcaron period -111 +KPX rcaron q -37 +KPX rcaron s -10 +KPX rcaron sacute -10 +KPX rcaron scaron -10 +KPX rcaron scedilla -10 +KPX rcaron scommaaccent -10 +KPX rcommaaccent a -15 +KPX rcommaaccent aacute -15 +KPX rcommaaccent abreve -15 +KPX rcommaaccent acircumflex -15 +KPX rcommaaccent adieresis -15 +KPX rcommaaccent agrave -15 +KPX rcommaaccent amacron -15 +KPX rcommaaccent aogonek -15 +KPX rcommaaccent aring -15 +KPX rcommaaccent atilde -15 +KPX rcommaaccent c -37 +KPX rcommaaccent cacute -37 +KPX rcommaaccent ccaron -37 +KPX rcommaaccent ccedilla -37 +KPX rcommaaccent comma -111 +KPX rcommaaccent d -37 +KPX rcommaaccent dcroat -37 +KPX rcommaaccent e -37 +KPX rcommaaccent eacute -37 +KPX rcommaaccent ecaron -37 +KPX rcommaaccent ecircumflex -37 +KPX rcommaaccent edieresis -37 +KPX rcommaaccent edotaccent -37 +KPX rcommaaccent egrave -37 +KPX rcommaaccent emacron -37 +KPX rcommaaccent eogonek -37 +KPX rcommaaccent g -37 +KPX rcommaaccent gbreve -37 +KPX rcommaaccent gcommaaccent -37 +KPX rcommaaccent hyphen -20 +KPX rcommaaccent o -45 +KPX rcommaaccent oacute -45 +KPX rcommaaccent ocircumflex -45 +KPX rcommaaccent odieresis -45 +KPX rcommaaccent ograve -45 +KPX rcommaaccent ohungarumlaut -45 +KPX rcommaaccent omacron -45 +KPX rcommaaccent oslash -45 +KPX rcommaaccent otilde -45 +KPX rcommaaccent period -111 +KPX rcommaaccent q -37 +KPX rcommaaccent s -10 +KPX rcommaaccent sacute -10 +KPX rcommaaccent scaron -10 +KPX rcommaaccent scedilla -10 +KPX rcommaaccent scommaaccent -10 +KPX space A -18 +KPX space Aacute -18 +KPX space Abreve -18 +KPX space Acircumflex -18 +KPX space Adieresis -18 +KPX space Agrave -18 +KPX space Amacron -18 +KPX space Aogonek -18 +KPX space Aring -18 +KPX space Atilde -18 +KPX space T -18 +KPX space Tcaron -18 +KPX space Tcommaaccent -18 +KPX space V -35 +KPX space W -40 +KPX space Y -75 +KPX space Yacute -75 +KPX space Ydieresis -75 +KPX v comma -74 +KPX v period -74 +KPX w comma -74 +KPX w period -74 +KPX y comma -55 +KPX y period -55 +KPX yacute comma -55 +KPX yacute period -55 +KPX ydieresis comma -55 +KPX ydieresis period -55 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Roman.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Roman.afm new file mode 100644 index 00000000..a0953f28 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/Times-Roman.afm @@ -0,0 +1,2419 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 12:49:17 1997 +Comment UniqueID 43068 +Comment VMusage 43909 54934 +FontName Times-Roman +FullName Times Roman +FamilyName Times +Weight Roman +ItalicAngle 0 +IsFixedPitch false +CharacterSet ExtendedRoman +FontBBox -168 -218 1000 898 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries. +EncodingScheme AdobeStandardEncoding +CapHeight 662 +XHeight 450 +Ascender 683 +Descender -217 +StdHW 28 +StdVW 84 +StartCharMetrics 315 +C 32 ; WX 250 ; N space ; B 0 0 0 0 ; +C 33 ; WX 333 ; N exclam ; B 130 -9 238 676 ; +C 34 ; WX 408 ; N quotedbl ; B 77 431 331 676 ; +C 35 ; WX 500 ; N numbersign ; B 5 0 496 662 ; +C 36 ; WX 500 ; N dollar ; B 44 -87 457 727 ; +C 37 ; WX 833 ; N percent ; B 61 -13 772 676 ; +C 38 ; WX 778 ; N ampersand ; B 42 -13 750 676 ; +C 39 ; WX 333 ; N quoteright ; B 79 433 218 676 ; +C 40 ; WX 333 ; N parenleft ; B 48 -177 304 676 ; +C 41 ; WX 333 ; N parenright ; B 29 -177 285 676 ; +C 42 ; WX 500 ; N asterisk ; B 69 265 432 676 ; +C 43 ; WX 564 ; N plus ; B 30 0 534 506 ; +C 44 ; WX 250 ; N comma ; B 56 -141 195 102 ; +C 45 ; WX 333 ; N hyphen ; B 39 194 285 257 ; +C 46 ; WX 250 ; N period ; B 70 -11 181 100 ; +C 47 ; WX 278 ; N slash ; B -9 -14 287 676 ; +C 48 ; WX 500 ; N zero ; B 24 -14 476 676 ; +C 49 ; WX 500 ; N one ; B 111 0 394 676 ; +C 50 ; WX 500 ; N two ; B 30 0 475 676 ; +C 51 ; WX 500 ; N three ; B 43 -14 431 676 ; +C 52 ; WX 500 ; N four ; B 12 0 472 676 ; +C 53 ; WX 500 ; N five ; B 32 -14 438 688 ; +C 54 ; WX 500 ; N six ; B 34 -14 468 684 ; +C 55 ; WX 500 ; N seven ; B 20 -8 449 662 ; +C 56 ; WX 500 ; N eight ; B 56 -14 445 676 ; +C 57 ; WX 500 ; N nine ; B 30 -22 459 676 ; +C 58 ; WX 278 ; N colon ; B 81 -11 192 459 ; +C 59 ; WX 278 ; N semicolon ; B 80 -141 219 459 ; +C 60 ; WX 564 ; N less ; B 28 -8 536 514 ; +C 61 ; WX 564 ; N equal ; B 30 120 534 386 ; +C 62 ; WX 564 ; N greater ; B 28 -8 536 514 ; +C 63 ; WX 444 ; N question ; B 68 -8 414 676 ; +C 64 ; WX 921 ; N at ; B 116 -14 809 676 ; +C 65 ; WX 722 ; N A ; B 15 0 706 674 ; +C 66 ; WX 667 ; N B ; B 17 0 593 662 ; +C 67 ; WX 667 ; N C ; B 28 -14 633 676 ; +C 68 ; WX 722 ; N D ; B 16 0 685 662 ; +C 69 ; WX 611 ; N E ; B 12 0 597 662 ; +C 70 ; WX 556 ; N F ; B 12 0 546 662 ; +C 71 ; WX 722 ; N G ; B 32 -14 709 676 ; +C 72 ; WX 722 ; N H ; B 19 0 702 662 ; +C 73 ; WX 333 ; N I ; B 18 0 315 662 ; +C 74 ; WX 389 ; N J ; B 10 -14 370 662 ; +C 75 ; WX 722 ; N K ; B 34 0 723 662 ; +C 76 ; WX 611 ; N L ; B 12 0 598 662 ; +C 77 ; WX 889 ; N M ; B 12 0 863 662 ; +C 78 ; WX 722 ; N N ; B 12 -11 707 662 ; +C 79 ; WX 722 ; N O ; B 34 -14 688 676 ; +C 80 ; WX 556 ; N P ; B 16 0 542 662 ; +C 81 ; WX 722 ; N Q ; B 34 -178 701 676 ; +C 82 ; WX 667 ; N R ; B 17 0 659 662 ; +C 83 ; WX 556 ; N S ; B 42 -14 491 676 ; +C 84 ; WX 611 ; N T ; B 17 0 593 662 ; +C 85 ; WX 722 ; N U ; B 14 -14 705 662 ; +C 86 ; WX 722 ; N V ; B 16 -11 697 662 ; +C 87 ; WX 944 ; N W ; B 5 -11 932 662 ; +C 88 ; WX 722 ; N X ; B 10 0 704 662 ; +C 89 ; WX 722 ; N Y ; B 22 0 703 662 ; +C 90 ; WX 611 ; N Z ; B 9 0 597 662 ; +C 91 ; WX 333 ; N bracketleft ; B 88 -156 299 662 ; +C 92 ; WX 278 ; N backslash ; B -9 -14 287 676 ; +C 93 ; WX 333 ; N bracketright ; B 34 -156 245 662 ; +C 94 ; WX 469 ; N asciicircum ; B 24 297 446 662 ; +C 95 ; WX 500 ; N underscore ; B 0 -125 500 -75 ; +C 96 ; WX 333 ; N quoteleft ; B 115 433 254 676 ; +C 97 ; WX 444 ; N a ; B 37 -10 442 460 ; +C 98 ; WX 500 ; N b ; B 3 -10 468 683 ; +C 99 ; WX 444 ; N c ; B 25 -10 412 460 ; +C 100 ; WX 500 ; N d ; B 27 -10 491 683 ; +C 101 ; WX 444 ; N e ; B 25 -10 424 460 ; +C 102 ; WX 333 ; N f ; B 20 0 383 683 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 28 -218 470 460 ; +C 104 ; WX 500 ; N h ; B 9 0 487 683 ; +C 105 ; WX 278 ; N i ; B 16 0 253 683 ; +C 106 ; WX 278 ; N j ; B -70 -218 194 683 ; +C 107 ; WX 500 ; N k ; B 7 0 505 683 ; +C 108 ; WX 278 ; N l ; B 19 0 257 683 ; +C 109 ; WX 778 ; N m ; B 16 0 775 460 ; +C 110 ; WX 500 ; N n ; B 16 0 485 460 ; +C 111 ; WX 500 ; N o ; B 29 -10 470 460 ; +C 112 ; WX 500 ; N p ; B 5 -217 470 460 ; +C 113 ; WX 500 ; N q ; B 24 -217 488 460 ; +C 114 ; WX 333 ; N r ; B 5 0 335 460 ; +C 115 ; WX 389 ; N s ; B 51 -10 348 460 ; +C 116 ; WX 278 ; N t ; B 13 -10 279 579 ; +C 117 ; WX 500 ; N u ; B 9 -10 479 450 ; +C 118 ; WX 500 ; N v ; B 19 -14 477 450 ; +C 119 ; WX 722 ; N w ; B 21 -14 694 450 ; +C 120 ; WX 500 ; N x ; B 17 0 479 450 ; +C 121 ; WX 500 ; N y ; B 14 -218 475 450 ; +C 122 ; WX 444 ; N z ; B 27 0 418 450 ; +C 123 ; WX 480 ; N braceleft ; B 100 -181 350 680 ; +C 124 ; WX 200 ; N bar ; B 67 -218 133 782 ; +C 125 ; WX 480 ; N braceright ; B 130 -181 380 680 ; +C 126 ; WX 541 ; N asciitilde ; B 40 183 502 323 ; +C 161 ; WX 333 ; N exclamdown ; B 97 -218 205 467 ; +C 162 ; WX 500 ; N cent ; B 53 -138 448 579 ; +C 163 ; WX 500 ; N sterling ; B 12 -8 490 676 ; +C 164 ; WX 167 ; N fraction ; B -168 -14 331 676 ; +C 165 ; WX 500 ; N yen ; B -53 0 512 662 ; +C 166 ; WX 500 ; N florin ; B 7 -189 490 676 ; +C 167 ; WX 500 ; N section ; B 70 -148 426 676 ; +C 168 ; WX 500 ; N currency ; B -22 58 522 602 ; +C 169 ; WX 180 ; N quotesingle ; B 48 431 133 676 ; +C 170 ; WX 444 ; N quotedblleft ; B 43 433 414 676 ; +C 171 ; WX 500 ; N guillemotleft ; B 42 33 456 416 ; +C 172 ; WX 333 ; N guilsinglleft ; B 63 33 285 416 ; +C 173 ; WX 333 ; N guilsinglright ; B 48 33 270 416 ; +C 174 ; WX 556 ; N fi ; B 31 0 521 683 ; +C 175 ; WX 556 ; N fl ; B 32 0 521 683 ; +C 177 ; WX 500 ; N endash ; B 0 201 500 250 ; +C 178 ; WX 500 ; N dagger ; B 59 -149 442 676 ; +C 179 ; WX 500 ; N daggerdbl ; B 58 -153 442 676 ; +C 180 ; WX 250 ; N periodcentered ; B 70 199 181 310 ; +C 182 ; WX 453 ; N paragraph ; B -22 -154 450 662 ; +C 183 ; WX 350 ; N bullet ; B 40 196 310 466 ; +C 184 ; WX 333 ; N quotesinglbase ; B 79 -141 218 102 ; +C 185 ; WX 444 ; N quotedblbase ; B 45 -141 416 102 ; +C 186 ; WX 444 ; N quotedblright ; B 30 433 401 676 ; +C 187 ; WX 500 ; N guillemotright ; B 44 33 458 416 ; +C 188 ; WX 1000 ; N ellipsis ; B 111 -11 888 100 ; +C 189 ; WX 1000 ; N perthousand ; B 7 -19 994 706 ; +C 191 ; WX 444 ; N questiondown ; B 30 -218 376 466 ; +C 193 ; WX 333 ; N grave ; B 19 507 242 678 ; +C 194 ; WX 333 ; N acute ; B 93 507 317 678 ; +C 195 ; WX 333 ; N circumflex ; B 11 507 322 674 ; +C 196 ; WX 333 ; N tilde ; B 1 532 331 638 ; +C 197 ; WX 333 ; N macron ; B 11 547 322 601 ; +C 198 ; WX 333 ; N breve ; B 26 507 307 664 ; +C 199 ; WX 333 ; N dotaccent ; B 118 581 216 681 ; +C 200 ; WX 333 ; N dieresis ; B 18 581 315 681 ; +C 202 ; WX 333 ; N ring ; B 67 512 266 711 ; +C 203 ; WX 333 ; N cedilla ; B 52 -215 261 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B -3 507 377 678 ; +C 206 ; WX 333 ; N ogonek ; B 62 -165 243 0 ; +C 207 ; WX 333 ; N caron ; B 11 507 322 674 ; +C 208 ; WX 1000 ; N emdash ; B 0 201 1000 250 ; +C 225 ; WX 889 ; N AE ; B 0 0 863 662 ; +C 227 ; WX 276 ; N ordfeminine ; B 4 394 270 676 ; +C 232 ; WX 611 ; N Lslash ; B 12 0 598 662 ; +C 233 ; WX 722 ; N Oslash ; B 34 -80 688 734 ; +C 234 ; WX 889 ; N OE ; B 30 -6 885 668 ; +C 235 ; WX 310 ; N ordmasculine ; B 6 394 304 676 ; +C 241 ; WX 667 ; N ae ; B 38 -10 632 460 ; +C 245 ; WX 278 ; N dotlessi ; B 16 0 253 460 ; +C 248 ; WX 278 ; N lslash ; B 19 0 259 683 ; +C 249 ; WX 500 ; N oslash ; B 29 -112 470 551 ; +C 250 ; WX 722 ; N oe ; B 30 -10 690 460 ; +C 251 ; WX 500 ; N germandbls ; B 12 -9 468 683 ; +C -1 ; WX 333 ; N Idieresis ; B 18 0 315 835 ; +C -1 ; WX 444 ; N eacute ; B 25 -10 424 678 ; +C -1 ; WX 444 ; N abreve ; B 37 -10 442 664 ; +C -1 ; WX 500 ; N uhungarumlaut ; B 9 -10 501 678 ; +C -1 ; WX 444 ; N ecaron ; B 25 -10 424 674 ; +C -1 ; WX 722 ; N Ydieresis ; B 22 0 703 835 ; +C -1 ; WX 564 ; N divide ; B 30 -10 534 516 ; +C -1 ; WX 722 ; N Yacute ; B 22 0 703 890 ; +C -1 ; WX 722 ; N Acircumflex ; B 15 0 706 886 ; +C -1 ; WX 444 ; N aacute ; B 37 -10 442 678 ; +C -1 ; WX 722 ; N Ucircumflex ; B 14 -14 705 886 ; +C -1 ; WX 500 ; N yacute ; B 14 -218 475 678 ; +C -1 ; WX 389 ; N scommaaccent ; B 51 -218 348 460 ; +C -1 ; WX 444 ; N ecircumflex ; B 25 -10 424 674 ; +C -1 ; WX 722 ; N Uring ; B 14 -14 705 898 ; +C -1 ; WX 722 ; N Udieresis ; B 14 -14 705 835 ; +C -1 ; WX 444 ; N aogonek ; B 37 -165 469 460 ; +C -1 ; WX 722 ; N Uacute ; B 14 -14 705 890 ; +C -1 ; WX 500 ; N uogonek ; B 9 -155 487 450 ; +C -1 ; WX 611 ; N Edieresis ; B 12 0 597 835 ; +C -1 ; WX 722 ; N Dcroat ; B 16 0 685 662 ; +C -1 ; WX 250 ; N commaaccent ; B 59 -218 184 -50 ; +C -1 ; WX 760 ; N copyright ; B 38 -14 722 676 ; +C -1 ; WX 611 ; N Emacron ; B 12 0 597 813 ; +C -1 ; WX 444 ; N ccaron ; B 25 -10 412 674 ; +C -1 ; WX 444 ; N aring ; B 37 -10 442 711 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 12 -198 707 662 ; +C -1 ; WX 278 ; N lacute ; B 19 0 290 890 ; +C -1 ; WX 444 ; N agrave ; B 37 -10 442 678 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 17 -218 593 662 ; +C -1 ; WX 667 ; N Cacute ; B 28 -14 633 890 ; +C -1 ; WX 444 ; N atilde ; B 37 -10 442 638 ; +C -1 ; WX 611 ; N Edotaccent ; B 12 0 597 835 ; +C -1 ; WX 389 ; N scaron ; B 39 -10 350 674 ; +C -1 ; WX 389 ; N scedilla ; B 51 -215 348 460 ; +C -1 ; WX 278 ; N iacute ; B 16 0 290 678 ; +C -1 ; WX 471 ; N lozenge ; B 13 0 459 724 ; +C -1 ; WX 667 ; N Rcaron ; B 17 0 659 886 ; +C -1 ; WX 722 ; N Gcommaaccent ; B 32 -218 709 676 ; +C -1 ; WX 500 ; N ucircumflex ; B 9 -10 479 674 ; +C -1 ; WX 444 ; N acircumflex ; B 37 -10 442 674 ; +C -1 ; WX 722 ; N Amacron ; B 15 0 706 813 ; +C -1 ; WX 333 ; N rcaron ; B 5 0 335 674 ; +C -1 ; WX 444 ; N ccedilla ; B 25 -215 412 460 ; +C -1 ; WX 611 ; N Zdotaccent ; B 9 0 597 835 ; +C -1 ; WX 556 ; N Thorn ; B 16 0 542 662 ; +C -1 ; WX 722 ; N Omacron ; B 34 -14 688 813 ; +C -1 ; WX 667 ; N Racute ; B 17 0 659 890 ; +C -1 ; WX 556 ; N Sacute ; B 42 -14 491 890 ; +C -1 ; WX 588 ; N dcaron ; B 27 -10 589 695 ; +C -1 ; WX 722 ; N Umacron ; B 14 -14 705 813 ; +C -1 ; WX 500 ; N uring ; B 9 -10 479 711 ; +C -1 ; WX 300 ; N threesuperior ; B 15 262 291 676 ; +C -1 ; WX 722 ; N Ograve ; B 34 -14 688 890 ; +C -1 ; WX 722 ; N Agrave ; B 15 0 706 890 ; +C -1 ; WX 722 ; N Abreve ; B 15 0 706 876 ; +C -1 ; WX 564 ; N multiply ; B 38 8 527 497 ; +C -1 ; WX 500 ; N uacute ; B 9 -10 479 678 ; +C -1 ; WX 611 ; N Tcaron ; B 17 0 593 886 ; +C -1 ; WX 476 ; N partialdiff ; B 17 -38 459 710 ; +C -1 ; WX 500 ; N ydieresis ; B 14 -218 475 623 ; +C -1 ; WX 722 ; N Nacute ; B 12 -11 707 890 ; +C -1 ; WX 278 ; N icircumflex ; B -16 0 295 674 ; +C -1 ; WX 611 ; N Ecircumflex ; B 12 0 597 886 ; +C -1 ; WX 444 ; N adieresis ; B 37 -10 442 623 ; +C -1 ; WX 444 ; N edieresis ; B 25 -10 424 623 ; +C -1 ; WX 444 ; N cacute ; B 25 -10 413 678 ; +C -1 ; WX 500 ; N nacute ; B 16 0 485 678 ; +C -1 ; WX 500 ; N umacron ; B 9 -10 479 601 ; +C -1 ; WX 722 ; N Ncaron ; B 12 -11 707 886 ; +C -1 ; WX 333 ; N Iacute ; B 18 0 317 890 ; +C -1 ; WX 564 ; N plusminus ; B 30 0 534 506 ; +C -1 ; WX 200 ; N brokenbar ; B 67 -143 133 707 ; +C -1 ; WX 760 ; N registered ; B 38 -14 722 676 ; +C -1 ; WX 722 ; N Gbreve ; B 32 -14 709 876 ; +C -1 ; WX 333 ; N Idotaccent ; B 18 0 315 835 ; +C -1 ; WX 600 ; N summation ; B 15 -10 585 706 ; +C -1 ; WX 611 ; N Egrave ; B 12 0 597 890 ; +C -1 ; WX 333 ; N racute ; B 5 0 335 678 ; +C -1 ; WX 500 ; N omacron ; B 29 -10 470 601 ; +C -1 ; WX 611 ; N Zacute ; B 9 0 597 890 ; +C -1 ; WX 611 ; N Zcaron ; B 9 0 597 886 ; +C -1 ; WX 549 ; N greaterequal ; B 26 0 523 666 ; +C -1 ; WX 722 ; N Eth ; B 16 0 685 662 ; +C -1 ; WX 667 ; N Ccedilla ; B 28 -215 633 676 ; +C -1 ; WX 278 ; N lcommaaccent ; B 19 -218 257 683 ; +C -1 ; WX 326 ; N tcaron ; B 13 -10 318 722 ; +C -1 ; WX 444 ; N eogonek ; B 25 -165 424 460 ; +C -1 ; WX 722 ; N Uogonek ; B 14 -165 705 662 ; +C -1 ; WX 722 ; N Aacute ; B 15 0 706 890 ; +C -1 ; WX 722 ; N Adieresis ; B 15 0 706 835 ; +C -1 ; WX 444 ; N egrave ; B 25 -10 424 678 ; +C -1 ; WX 444 ; N zacute ; B 27 0 418 678 ; +C -1 ; WX 278 ; N iogonek ; B 16 -165 265 683 ; +C -1 ; WX 722 ; N Oacute ; B 34 -14 688 890 ; +C -1 ; WX 500 ; N oacute ; B 29 -10 470 678 ; +C -1 ; WX 444 ; N amacron ; B 37 -10 442 601 ; +C -1 ; WX 389 ; N sacute ; B 51 -10 348 678 ; +C -1 ; WX 278 ; N idieresis ; B -9 0 288 623 ; +C -1 ; WX 722 ; N Ocircumflex ; B 34 -14 688 886 ; +C -1 ; WX 722 ; N Ugrave ; B 14 -14 705 890 ; +C -1 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C -1 ; WX 500 ; N thorn ; B 5 -217 470 683 ; +C -1 ; WX 300 ; N twosuperior ; B 1 270 296 676 ; +C -1 ; WX 722 ; N Odieresis ; B 34 -14 688 835 ; +C -1 ; WX 500 ; N mu ; B 36 -218 512 450 ; +C -1 ; WX 278 ; N igrave ; B -8 0 253 678 ; +C -1 ; WX 500 ; N ohungarumlaut ; B 29 -10 491 678 ; +C -1 ; WX 611 ; N Eogonek ; B 12 -165 597 662 ; +C -1 ; WX 500 ; N dcroat ; B 27 -10 500 683 ; +C -1 ; WX 750 ; N threequarters ; B 15 -14 718 676 ; +C -1 ; WX 556 ; N Scedilla ; B 42 -215 491 676 ; +C -1 ; WX 344 ; N lcaron ; B 19 0 347 695 ; +C -1 ; WX 722 ; N Kcommaaccent ; B 34 -198 723 662 ; +C -1 ; WX 611 ; N Lacute ; B 12 0 598 890 ; +C -1 ; WX 980 ; N trademark ; B 30 256 957 662 ; +C -1 ; WX 444 ; N edotaccent ; B 25 -10 424 623 ; +C -1 ; WX 333 ; N Igrave ; B 18 0 315 890 ; +C -1 ; WX 333 ; N Imacron ; B 11 0 322 813 ; +C -1 ; WX 611 ; N Lcaron ; B 12 0 598 676 ; +C -1 ; WX 750 ; N onehalf ; B 31 -14 746 676 ; +C -1 ; WX 549 ; N lessequal ; B 26 0 523 666 ; +C -1 ; WX 500 ; N ocircumflex ; B 29 -10 470 674 ; +C -1 ; WX 500 ; N ntilde ; B 16 0 485 638 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 14 -14 705 890 ; +C -1 ; WX 611 ; N Eacute ; B 12 0 597 890 ; +C -1 ; WX 444 ; N emacron ; B 25 -10 424 601 ; +C -1 ; WX 500 ; N gbreve ; B 28 -218 470 664 ; +C -1 ; WX 750 ; N onequarter ; B 37 -14 718 676 ; +C -1 ; WX 556 ; N Scaron ; B 42 -14 491 886 ; +C -1 ; WX 556 ; N Scommaaccent ; B 42 -218 491 676 ; +C -1 ; WX 722 ; N Ohungarumlaut ; B 34 -14 688 890 ; +C -1 ; WX 400 ; N degree ; B 57 390 343 676 ; +C -1 ; WX 500 ; N ograve ; B 29 -10 470 678 ; +C -1 ; WX 667 ; N Ccaron ; B 28 -14 633 886 ; +C -1 ; WX 500 ; N ugrave ; B 9 -10 479 678 ; +C -1 ; WX 453 ; N radical ; B 2 -60 452 768 ; +C -1 ; WX 722 ; N Dcaron ; B 16 0 685 886 ; +C -1 ; WX 333 ; N rcommaaccent ; B 5 -218 335 460 ; +C -1 ; WX 722 ; N Ntilde ; B 12 -11 707 850 ; +C -1 ; WX 500 ; N otilde ; B 29 -10 470 638 ; +C -1 ; WX 667 ; N Rcommaaccent ; B 17 -198 659 662 ; +C -1 ; WX 611 ; N Lcommaaccent ; B 12 -218 598 662 ; +C -1 ; WX 722 ; N Atilde ; B 15 0 706 850 ; +C -1 ; WX 722 ; N Aogonek ; B 15 -165 738 674 ; +C -1 ; WX 722 ; N Aring ; B 15 0 706 898 ; +C -1 ; WX 722 ; N Otilde ; B 34 -14 688 850 ; +C -1 ; WX 444 ; N zdotaccent ; B 27 0 418 623 ; +C -1 ; WX 611 ; N Ecaron ; B 12 0 597 886 ; +C -1 ; WX 333 ; N Iogonek ; B 18 -165 315 662 ; +C -1 ; WX 500 ; N kcommaaccent ; B 7 -218 505 683 ; +C -1 ; WX 564 ; N minus ; B 30 220 534 286 ; +C -1 ; WX 333 ; N Icircumflex ; B 11 0 322 886 ; +C -1 ; WX 500 ; N ncaron ; B 16 0 485 674 ; +C -1 ; WX 278 ; N tcommaaccent ; B 13 -218 279 579 ; +C -1 ; WX 564 ; N logicalnot ; B 30 108 534 386 ; +C -1 ; WX 500 ; N odieresis ; B 29 -10 470 623 ; +C -1 ; WX 500 ; N udieresis ; B 9 -10 479 623 ; +C -1 ; WX 549 ; N notequal ; B 12 -31 537 547 ; +C -1 ; WX 500 ; N gcommaaccent ; B 28 -218 470 749 ; +C -1 ; WX 500 ; N eth ; B 29 -10 471 686 ; +C -1 ; WX 444 ; N zcaron ; B 27 0 418 674 ; +C -1 ; WX 500 ; N ncommaaccent ; B 16 -218 485 460 ; +C -1 ; WX 300 ; N onesuperior ; B 57 270 248 676 ; +C -1 ; WX 278 ; N imacron ; B 6 0 271 601 ; +C -1 ; WX 500 ; N Euro ; B 0 0 0 0 ; +EndCharMetrics +StartKernData +StartKernPairs 2073 +KPX A C -40 +KPX A Cacute -40 +KPX A Ccaron -40 +KPX A Ccedilla -40 +KPX A G -40 +KPX A Gbreve -40 +KPX A Gcommaaccent -40 +KPX A O -55 +KPX A Oacute -55 +KPX A Ocircumflex -55 +KPX A Odieresis -55 +KPX A Ograve -55 +KPX A Ohungarumlaut -55 +KPX A Omacron -55 +KPX A Oslash -55 +KPX A Otilde -55 +KPX A Q -55 +KPX A T -111 +KPX A Tcaron -111 +KPX A Tcommaaccent -111 +KPX A U -55 +KPX A Uacute -55 +KPX A Ucircumflex -55 +KPX A Udieresis -55 +KPX A Ugrave -55 +KPX A Uhungarumlaut -55 +KPX A Umacron -55 +KPX A Uogonek -55 +KPX A Uring -55 +KPX A V -135 +KPX A W -90 +KPX A Y -105 +KPX A Yacute -105 +KPX A Ydieresis -105 +KPX A quoteright -111 +KPX A v -74 +KPX A w -92 +KPX A y -92 +KPX A yacute -92 +KPX A ydieresis -92 +KPX Aacute C -40 +KPX Aacute Cacute -40 +KPX Aacute Ccaron -40 +KPX Aacute Ccedilla -40 +KPX Aacute G -40 +KPX Aacute Gbreve -40 +KPX Aacute Gcommaaccent -40 +KPX Aacute O -55 +KPX Aacute Oacute -55 +KPX Aacute Ocircumflex -55 +KPX Aacute Odieresis -55 +KPX Aacute Ograve -55 +KPX Aacute Ohungarumlaut -55 +KPX Aacute Omacron -55 +KPX Aacute Oslash -55 +KPX Aacute Otilde -55 +KPX Aacute Q -55 +KPX Aacute T -111 +KPX Aacute Tcaron -111 +KPX Aacute Tcommaaccent -111 +KPX Aacute U -55 +KPX Aacute Uacute -55 +KPX Aacute Ucircumflex -55 +KPX Aacute Udieresis -55 +KPX Aacute Ugrave -55 +KPX Aacute Uhungarumlaut -55 +KPX Aacute Umacron -55 +KPX Aacute Uogonek -55 +KPX Aacute Uring -55 +KPX Aacute V -135 +KPX Aacute W -90 +KPX Aacute Y -105 +KPX Aacute Yacute -105 +KPX Aacute Ydieresis -105 +KPX Aacute quoteright -111 +KPX Aacute v -74 +KPX Aacute w -92 +KPX Aacute y -92 +KPX Aacute yacute -92 +KPX Aacute ydieresis -92 +KPX Abreve C -40 +KPX Abreve Cacute -40 +KPX Abreve Ccaron -40 +KPX Abreve Ccedilla -40 +KPX Abreve G -40 +KPX Abreve Gbreve -40 +KPX Abreve Gcommaaccent -40 +KPX Abreve O -55 +KPX Abreve Oacute -55 +KPX Abreve Ocircumflex -55 +KPX Abreve Odieresis -55 +KPX Abreve Ograve -55 +KPX Abreve Ohungarumlaut -55 +KPX Abreve Omacron -55 +KPX Abreve Oslash -55 +KPX Abreve Otilde -55 +KPX Abreve Q -55 +KPX Abreve T -111 +KPX Abreve Tcaron -111 +KPX Abreve Tcommaaccent -111 +KPX Abreve U -55 +KPX Abreve Uacute -55 +KPX Abreve Ucircumflex -55 +KPX Abreve Udieresis -55 +KPX Abreve Ugrave -55 +KPX Abreve Uhungarumlaut -55 +KPX Abreve Umacron -55 +KPX Abreve Uogonek -55 +KPX Abreve Uring -55 +KPX Abreve V -135 +KPX Abreve W -90 +KPX Abreve Y -105 +KPX Abreve Yacute -105 +KPX Abreve Ydieresis -105 +KPX Abreve quoteright -111 +KPX Abreve v -74 +KPX Abreve w -92 +KPX Abreve y -92 +KPX Abreve yacute -92 +KPX Abreve ydieresis -92 +KPX Acircumflex C -40 +KPX Acircumflex Cacute -40 +KPX Acircumflex Ccaron -40 +KPX Acircumflex Ccedilla -40 +KPX Acircumflex G -40 +KPX Acircumflex Gbreve -40 +KPX Acircumflex Gcommaaccent -40 +KPX Acircumflex O -55 +KPX Acircumflex Oacute -55 +KPX Acircumflex Ocircumflex -55 +KPX Acircumflex Odieresis -55 +KPX Acircumflex Ograve -55 +KPX Acircumflex Ohungarumlaut -55 +KPX Acircumflex Omacron -55 +KPX Acircumflex Oslash -55 +KPX Acircumflex Otilde -55 +KPX Acircumflex Q -55 +KPX Acircumflex T -111 +KPX Acircumflex Tcaron -111 +KPX Acircumflex Tcommaaccent -111 +KPX Acircumflex U -55 +KPX Acircumflex Uacute -55 +KPX Acircumflex Ucircumflex -55 +KPX Acircumflex Udieresis -55 +KPX Acircumflex Ugrave -55 +KPX Acircumflex Uhungarumlaut -55 +KPX Acircumflex Umacron -55 +KPX Acircumflex Uogonek -55 +KPX Acircumflex Uring -55 +KPX Acircumflex V -135 +KPX Acircumflex W -90 +KPX Acircumflex Y -105 +KPX Acircumflex Yacute -105 +KPX Acircumflex Ydieresis -105 +KPX Acircumflex quoteright -111 +KPX Acircumflex v -74 +KPX Acircumflex w -92 +KPX Acircumflex y -92 +KPX Acircumflex yacute -92 +KPX Acircumflex ydieresis -92 +KPX Adieresis C -40 +KPX Adieresis Cacute -40 +KPX Adieresis Ccaron -40 +KPX Adieresis Ccedilla -40 +KPX Adieresis G -40 +KPX Adieresis Gbreve -40 +KPX Adieresis Gcommaaccent -40 +KPX Adieresis O -55 +KPX Adieresis Oacute -55 +KPX Adieresis Ocircumflex -55 +KPX Adieresis Odieresis -55 +KPX Adieresis Ograve -55 +KPX Adieresis Ohungarumlaut -55 +KPX Adieresis Omacron -55 +KPX Adieresis Oslash -55 +KPX Adieresis Otilde -55 +KPX Adieresis Q -55 +KPX Adieresis T -111 +KPX Adieresis Tcaron -111 +KPX Adieresis Tcommaaccent -111 +KPX Adieresis U -55 +KPX Adieresis Uacute -55 +KPX Adieresis Ucircumflex -55 +KPX Adieresis Udieresis -55 +KPX Adieresis Ugrave -55 +KPX Adieresis Uhungarumlaut -55 +KPX Adieresis Umacron -55 +KPX Adieresis Uogonek -55 +KPX Adieresis Uring -55 +KPX Adieresis V -135 +KPX Adieresis W -90 +KPX Adieresis Y -105 +KPX Adieresis Yacute -105 +KPX Adieresis Ydieresis -105 +KPX Adieresis quoteright -111 +KPX Adieresis v -74 +KPX Adieresis w -92 +KPX Adieresis y -92 +KPX Adieresis yacute -92 +KPX Adieresis ydieresis -92 +KPX Agrave C -40 +KPX Agrave Cacute -40 +KPX Agrave Ccaron -40 +KPX Agrave Ccedilla -40 +KPX Agrave G -40 +KPX Agrave Gbreve -40 +KPX Agrave Gcommaaccent -40 +KPX Agrave O -55 +KPX Agrave Oacute -55 +KPX Agrave Ocircumflex -55 +KPX Agrave Odieresis -55 +KPX Agrave Ograve -55 +KPX Agrave Ohungarumlaut -55 +KPX Agrave Omacron -55 +KPX Agrave Oslash -55 +KPX Agrave Otilde -55 +KPX Agrave Q -55 +KPX Agrave T -111 +KPX Agrave Tcaron -111 +KPX Agrave Tcommaaccent -111 +KPX Agrave U -55 +KPX Agrave Uacute -55 +KPX Agrave Ucircumflex -55 +KPX Agrave Udieresis -55 +KPX Agrave Ugrave -55 +KPX Agrave Uhungarumlaut -55 +KPX Agrave Umacron -55 +KPX Agrave Uogonek -55 +KPX Agrave Uring -55 +KPX Agrave V -135 +KPX Agrave W -90 +KPX Agrave Y -105 +KPX Agrave Yacute -105 +KPX Agrave Ydieresis -105 +KPX Agrave quoteright -111 +KPX Agrave v -74 +KPX Agrave w -92 +KPX Agrave y -92 +KPX Agrave yacute -92 +KPX Agrave ydieresis -92 +KPX Amacron C -40 +KPX Amacron Cacute -40 +KPX Amacron Ccaron -40 +KPX Amacron Ccedilla -40 +KPX Amacron G -40 +KPX Amacron Gbreve -40 +KPX Amacron Gcommaaccent -40 +KPX Amacron O -55 +KPX Amacron Oacute -55 +KPX Amacron Ocircumflex -55 +KPX Amacron Odieresis -55 +KPX Amacron Ograve -55 +KPX Amacron Ohungarumlaut -55 +KPX Amacron Omacron -55 +KPX Amacron Oslash -55 +KPX Amacron Otilde -55 +KPX Amacron Q -55 +KPX Amacron T -111 +KPX Amacron Tcaron -111 +KPX Amacron Tcommaaccent -111 +KPX Amacron U -55 +KPX Amacron Uacute -55 +KPX Amacron Ucircumflex -55 +KPX Amacron Udieresis -55 +KPX Amacron Ugrave -55 +KPX Amacron Uhungarumlaut -55 +KPX Amacron Umacron -55 +KPX Amacron Uogonek -55 +KPX Amacron Uring -55 +KPX Amacron V -135 +KPX Amacron W -90 +KPX Amacron Y -105 +KPX Amacron Yacute -105 +KPX Amacron Ydieresis -105 +KPX Amacron quoteright -111 +KPX Amacron v -74 +KPX Amacron w -92 +KPX Amacron y -92 +KPX Amacron yacute -92 +KPX Amacron ydieresis -92 +KPX Aogonek C -40 +KPX Aogonek Cacute -40 +KPX Aogonek Ccaron -40 +KPX Aogonek Ccedilla -40 +KPX Aogonek G -40 +KPX Aogonek Gbreve -40 +KPX Aogonek Gcommaaccent -40 +KPX Aogonek O -55 +KPX Aogonek Oacute -55 +KPX Aogonek Ocircumflex -55 +KPX Aogonek Odieresis -55 +KPX Aogonek Ograve -55 +KPX Aogonek Ohungarumlaut -55 +KPX Aogonek Omacron -55 +KPX Aogonek Oslash -55 +KPX Aogonek Otilde -55 +KPX Aogonek Q -55 +KPX Aogonek T -111 +KPX Aogonek Tcaron -111 +KPX Aogonek Tcommaaccent -111 +KPX Aogonek U -55 +KPX Aogonek Uacute -55 +KPX Aogonek Ucircumflex -55 +KPX Aogonek Udieresis -55 +KPX Aogonek Ugrave -55 +KPX Aogonek Uhungarumlaut -55 +KPX Aogonek Umacron -55 +KPX Aogonek Uogonek -55 +KPX Aogonek Uring -55 +KPX Aogonek V -135 +KPX Aogonek W -90 +KPX Aogonek Y -105 +KPX Aogonek Yacute -105 +KPX Aogonek Ydieresis -105 +KPX Aogonek quoteright -111 +KPX Aogonek v -74 +KPX Aogonek w -52 +KPX Aogonek y -52 +KPX Aogonek yacute -52 +KPX Aogonek ydieresis -52 +KPX Aring C -40 +KPX Aring Cacute -40 +KPX Aring Ccaron -40 +KPX Aring Ccedilla -40 +KPX Aring G -40 +KPX Aring Gbreve -40 +KPX Aring Gcommaaccent -40 +KPX Aring O -55 +KPX Aring Oacute -55 +KPX Aring Ocircumflex -55 +KPX Aring Odieresis -55 +KPX Aring Ograve -55 +KPX Aring Ohungarumlaut -55 +KPX Aring Omacron -55 +KPX Aring Oslash -55 +KPX Aring Otilde -55 +KPX Aring Q -55 +KPX Aring T -111 +KPX Aring Tcaron -111 +KPX Aring Tcommaaccent -111 +KPX Aring U -55 +KPX Aring Uacute -55 +KPX Aring Ucircumflex -55 +KPX Aring Udieresis -55 +KPX Aring Ugrave -55 +KPX Aring Uhungarumlaut -55 +KPX Aring Umacron -55 +KPX Aring Uogonek -55 +KPX Aring Uring -55 +KPX Aring V -135 +KPX Aring W -90 +KPX Aring Y -105 +KPX Aring Yacute -105 +KPX Aring Ydieresis -105 +KPX Aring quoteright -111 +KPX Aring v -74 +KPX Aring w -92 +KPX Aring y -92 +KPX Aring yacute -92 +KPX Aring ydieresis -92 +KPX Atilde C -40 +KPX Atilde Cacute -40 +KPX Atilde Ccaron -40 +KPX Atilde Ccedilla -40 +KPX Atilde G -40 +KPX Atilde Gbreve -40 +KPX Atilde Gcommaaccent -40 +KPX Atilde O -55 +KPX Atilde Oacute -55 +KPX Atilde Ocircumflex -55 +KPX Atilde Odieresis -55 +KPX Atilde Ograve -55 +KPX Atilde Ohungarumlaut -55 +KPX Atilde Omacron -55 +KPX Atilde Oslash -55 +KPX Atilde Otilde -55 +KPX Atilde Q -55 +KPX Atilde T -111 +KPX Atilde Tcaron -111 +KPX Atilde Tcommaaccent -111 +KPX Atilde U -55 +KPX Atilde Uacute -55 +KPX Atilde Ucircumflex -55 +KPX Atilde Udieresis -55 +KPX Atilde Ugrave -55 +KPX Atilde Uhungarumlaut -55 +KPX Atilde Umacron -55 +KPX Atilde Uogonek -55 +KPX Atilde Uring -55 +KPX Atilde V -135 +KPX Atilde W -90 +KPX Atilde Y -105 +KPX Atilde Yacute -105 +KPX Atilde Ydieresis -105 +KPX Atilde quoteright -111 +KPX Atilde v -74 +KPX Atilde w -92 +KPX Atilde y -92 +KPX Atilde yacute -92 +KPX Atilde ydieresis -92 +KPX B A -35 +KPX B Aacute -35 +KPX B Abreve -35 +KPX B Acircumflex -35 +KPX B Adieresis -35 +KPX B Agrave -35 +KPX B Amacron -35 +KPX B Aogonek -35 +KPX B Aring -35 +KPX B Atilde -35 +KPX B U -10 +KPX B Uacute -10 +KPX B Ucircumflex -10 +KPX B Udieresis -10 +KPX B Ugrave -10 +KPX B Uhungarumlaut -10 +KPX B Umacron -10 +KPX B Uogonek -10 +KPX B Uring -10 +KPX D A -40 +KPX D Aacute -40 +KPX D Abreve -40 +KPX D Acircumflex -40 +KPX D Adieresis -40 +KPX D Agrave -40 +KPX D Amacron -40 +KPX D Aogonek -40 +KPX D Aring -40 +KPX D Atilde -40 +KPX D V -40 +KPX D W -30 +KPX D Y -55 +KPX D Yacute -55 +KPX D Ydieresis -55 +KPX Dcaron A -40 +KPX Dcaron Aacute -40 +KPX Dcaron Abreve -40 +KPX Dcaron Acircumflex -40 +KPX Dcaron Adieresis -40 +KPX Dcaron Agrave -40 +KPX Dcaron Amacron -40 +KPX Dcaron Aogonek -40 +KPX Dcaron Aring -40 +KPX Dcaron Atilde -40 +KPX Dcaron V -40 +KPX Dcaron W -30 +KPX Dcaron Y -55 +KPX Dcaron Yacute -55 +KPX Dcaron Ydieresis -55 +KPX Dcroat A -40 +KPX Dcroat Aacute -40 +KPX Dcroat Abreve -40 +KPX Dcroat Acircumflex -40 +KPX Dcroat Adieresis -40 +KPX Dcroat Agrave -40 +KPX Dcroat Amacron -40 +KPX Dcroat Aogonek -40 +KPX Dcroat Aring -40 +KPX Dcroat Atilde -40 +KPX Dcroat V -40 +KPX Dcroat W -30 +KPX Dcroat Y -55 +KPX Dcroat Yacute -55 +KPX Dcroat Ydieresis -55 +KPX F A -74 +KPX F Aacute -74 +KPX F Abreve -74 +KPX F Acircumflex -74 +KPX F Adieresis -74 +KPX F Agrave -74 +KPX F Amacron -74 +KPX F Aogonek -74 +KPX F Aring -74 +KPX F Atilde -74 +KPX F a -15 +KPX F aacute -15 +KPX F abreve -15 +KPX F acircumflex -15 +KPX F adieresis -15 +KPX F agrave -15 +KPX F amacron -15 +KPX F aogonek -15 +KPX F aring -15 +KPX F atilde -15 +KPX F comma -80 +KPX F o -15 +KPX F oacute -15 +KPX F ocircumflex -15 +KPX F odieresis -15 +KPX F ograve -15 +KPX F ohungarumlaut -15 +KPX F omacron -15 +KPX F oslash -15 +KPX F otilde -15 +KPX F period -80 +KPX J A -60 +KPX J Aacute -60 +KPX J Abreve -60 +KPX J Acircumflex -60 +KPX J Adieresis -60 +KPX J Agrave -60 +KPX J Amacron -60 +KPX J Aogonek -60 +KPX J Aring -60 +KPX J Atilde -60 +KPX K O -30 +KPX K Oacute -30 +KPX K Ocircumflex -30 +KPX K Odieresis -30 +KPX K Ograve -30 +KPX K Ohungarumlaut -30 +KPX K Omacron -30 +KPX K Oslash -30 +KPX K Otilde -30 +KPX K e -25 +KPX K eacute -25 +KPX K ecaron -25 +KPX K ecircumflex -25 +KPX K edieresis -25 +KPX K edotaccent -25 +KPX K egrave -25 +KPX K emacron -25 +KPX K eogonek -25 +KPX K o -35 +KPX K oacute -35 +KPX K ocircumflex -35 +KPX K odieresis -35 +KPX K ograve -35 +KPX K ohungarumlaut -35 +KPX K omacron -35 +KPX K oslash -35 +KPX K otilde -35 +KPX K u -15 +KPX K uacute -15 +KPX K ucircumflex -15 +KPX K udieresis -15 +KPX K ugrave -15 +KPX K uhungarumlaut -15 +KPX K umacron -15 +KPX K uogonek -15 +KPX K uring -15 +KPX K y -25 +KPX K yacute -25 +KPX K ydieresis -25 +KPX Kcommaaccent O -30 +KPX Kcommaaccent Oacute -30 +KPX Kcommaaccent Ocircumflex -30 +KPX Kcommaaccent Odieresis -30 +KPX Kcommaaccent Ograve -30 +KPX Kcommaaccent Ohungarumlaut -30 +KPX Kcommaaccent Omacron -30 +KPX Kcommaaccent Oslash -30 +KPX Kcommaaccent Otilde -30 +KPX Kcommaaccent e -25 +KPX Kcommaaccent eacute -25 +KPX Kcommaaccent ecaron -25 +KPX Kcommaaccent ecircumflex -25 +KPX Kcommaaccent edieresis -25 +KPX Kcommaaccent edotaccent -25 +KPX Kcommaaccent egrave -25 +KPX Kcommaaccent emacron -25 +KPX Kcommaaccent eogonek -25 +KPX Kcommaaccent o -35 +KPX Kcommaaccent oacute -35 +KPX Kcommaaccent ocircumflex -35 +KPX Kcommaaccent odieresis -35 +KPX Kcommaaccent ograve -35 +KPX Kcommaaccent ohungarumlaut -35 +KPX Kcommaaccent omacron -35 +KPX Kcommaaccent oslash -35 +KPX Kcommaaccent otilde -35 +KPX Kcommaaccent u -15 +KPX Kcommaaccent uacute -15 +KPX Kcommaaccent ucircumflex -15 +KPX Kcommaaccent udieresis -15 +KPX Kcommaaccent ugrave -15 +KPX Kcommaaccent uhungarumlaut -15 +KPX Kcommaaccent umacron -15 +KPX Kcommaaccent uogonek -15 +KPX Kcommaaccent uring -15 +KPX Kcommaaccent y -25 +KPX Kcommaaccent yacute -25 +KPX Kcommaaccent ydieresis -25 +KPX L T -92 +KPX L Tcaron -92 +KPX L Tcommaaccent -92 +KPX L V -100 +KPX L W -74 +KPX L Y -100 +KPX L Yacute -100 +KPX L Ydieresis -100 +KPX L quoteright -92 +KPX L y -55 +KPX L yacute -55 +KPX L ydieresis -55 +KPX Lacute T -92 +KPX Lacute Tcaron -92 +KPX Lacute Tcommaaccent -92 +KPX Lacute V -100 +KPX Lacute W -74 +KPX Lacute Y -100 +KPX Lacute Yacute -100 +KPX Lacute Ydieresis -100 +KPX Lacute quoteright -92 +KPX Lacute y -55 +KPX Lacute yacute -55 +KPX Lacute ydieresis -55 +KPX Lcaron quoteright -92 +KPX Lcaron y -55 +KPX Lcaron yacute -55 +KPX Lcaron ydieresis -55 +KPX Lcommaaccent T -92 +KPX Lcommaaccent Tcaron -92 +KPX Lcommaaccent Tcommaaccent -92 +KPX Lcommaaccent V -100 +KPX Lcommaaccent W -74 +KPX Lcommaaccent Y -100 +KPX Lcommaaccent Yacute -100 +KPX Lcommaaccent Ydieresis -100 +KPX Lcommaaccent quoteright -92 +KPX Lcommaaccent y -55 +KPX Lcommaaccent yacute -55 +KPX Lcommaaccent ydieresis -55 +KPX Lslash T -92 +KPX Lslash Tcaron -92 +KPX Lslash Tcommaaccent -92 +KPX Lslash V -100 +KPX Lslash W -74 +KPX Lslash Y -100 +KPX Lslash Yacute -100 +KPX Lslash Ydieresis -100 +KPX Lslash quoteright -92 +KPX Lslash y -55 +KPX Lslash yacute -55 +KPX Lslash ydieresis -55 +KPX N A -35 +KPX N Aacute -35 +KPX N Abreve -35 +KPX N Acircumflex -35 +KPX N Adieresis -35 +KPX N Agrave -35 +KPX N Amacron -35 +KPX N Aogonek -35 +KPX N Aring -35 +KPX N Atilde -35 +KPX Nacute A -35 +KPX Nacute Aacute -35 +KPX Nacute Abreve -35 +KPX Nacute Acircumflex -35 +KPX Nacute Adieresis -35 +KPX Nacute Agrave -35 +KPX Nacute Amacron -35 +KPX Nacute Aogonek -35 +KPX Nacute Aring -35 +KPX Nacute Atilde -35 +KPX Ncaron A -35 +KPX Ncaron Aacute -35 +KPX Ncaron Abreve -35 +KPX Ncaron Acircumflex -35 +KPX Ncaron Adieresis -35 +KPX Ncaron Agrave -35 +KPX Ncaron Amacron -35 +KPX Ncaron Aogonek -35 +KPX Ncaron Aring -35 +KPX Ncaron Atilde -35 +KPX Ncommaaccent A -35 +KPX Ncommaaccent Aacute -35 +KPX Ncommaaccent Abreve -35 +KPX Ncommaaccent Acircumflex -35 +KPX Ncommaaccent Adieresis -35 +KPX Ncommaaccent Agrave -35 +KPX Ncommaaccent Amacron -35 +KPX Ncommaaccent Aogonek -35 +KPX Ncommaaccent Aring -35 +KPX Ncommaaccent Atilde -35 +KPX Ntilde A -35 +KPX Ntilde Aacute -35 +KPX Ntilde Abreve -35 +KPX Ntilde Acircumflex -35 +KPX Ntilde Adieresis -35 +KPX Ntilde Agrave -35 +KPX Ntilde Amacron -35 +KPX Ntilde Aogonek -35 +KPX Ntilde Aring -35 +KPX Ntilde Atilde -35 +KPX O A -35 +KPX O Aacute -35 +KPX O Abreve -35 +KPX O Acircumflex -35 +KPX O Adieresis -35 +KPX O Agrave -35 +KPX O Amacron -35 +KPX O Aogonek -35 +KPX O Aring -35 +KPX O Atilde -35 +KPX O T -40 +KPX O Tcaron -40 +KPX O Tcommaaccent -40 +KPX O V -50 +KPX O W -35 +KPX O X -40 +KPX O Y -50 +KPX O Yacute -50 +KPX O Ydieresis -50 +KPX Oacute A -35 +KPX Oacute Aacute -35 +KPX Oacute Abreve -35 +KPX Oacute Acircumflex -35 +KPX Oacute Adieresis -35 +KPX Oacute Agrave -35 +KPX Oacute Amacron -35 +KPX Oacute Aogonek -35 +KPX Oacute Aring -35 +KPX Oacute Atilde -35 +KPX Oacute T -40 +KPX Oacute Tcaron -40 +KPX Oacute Tcommaaccent -40 +KPX Oacute V -50 +KPX Oacute W -35 +KPX Oacute X -40 +KPX Oacute Y -50 +KPX Oacute Yacute -50 +KPX Oacute Ydieresis -50 +KPX Ocircumflex A -35 +KPX Ocircumflex Aacute -35 +KPX Ocircumflex Abreve -35 +KPX Ocircumflex Acircumflex -35 +KPX Ocircumflex Adieresis -35 +KPX Ocircumflex Agrave -35 +KPX Ocircumflex Amacron -35 +KPX Ocircumflex Aogonek -35 +KPX Ocircumflex Aring -35 +KPX Ocircumflex Atilde -35 +KPX Ocircumflex T -40 +KPX Ocircumflex Tcaron -40 +KPX Ocircumflex Tcommaaccent -40 +KPX Ocircumflex V -50 +KPX Ocircumflex W -35 +KPX Ocircumflex X -40 +KPX Ocircumflex Y -50 +KPX Ocircumflex Yacute -50 +KPX Ocircumflex Ydieresis -50 +KPX Odieresis A -35 +KPX Odieresis Aacute -35 +KPX Odieresis Abreve -35 +KPX Odieresis Acircumflex -35 +KPX Odieresis Adieresis -35 +KPX Odieresis Agrave -35 +KPX Odieresis Amacron -35 +KPX Odieresis Aogonek -35 +KPX Odieresis Aring -35 +KPX Odieresis Atilde -35 +KPX Odieresis T -40 +KPX Odieresis Tcaron -40 +KPX Odieresis Tcommaaccent -40 +KPX Odieresis V -50 +KPX Odieresis W -35 +KPX Odieresis X -40 +KPX Odieresis Y -50 +KPX Odieresis Yacute -50 +KPX Odieresis Ydieresis -50 +KPX Ograve A -35 +KPX Ograve Aacute -35 +KPX Ograve Abreve -35 +KPX Ograve Acircumflex -35 +KPX Ograve Adieresis -35 +KPX Ograve Agrave -35 +KPX Ograve Amacron -35 +KPX Ograve Aogonek -35 +KPX Ograve Aring -35 +KPX Ograve Atilde -35 +KPX Ograve T -40 +KPX Ograve Tcaron -40 +KPX Ograve Tcommaaccent -40 +KPX Ograve V -50 +KPX Ograve W -35 +KPX Ograve X -40 +KPX Ograve Y -50 +KPX Ograve Yacute -50 +KPX Ograve Ydieresis -50 +KPX Ohungarumlaut A -35 +KPX Ohungarumlaut Aacute -35 +KPX Ohungarumlaut Abreve -35 +KPX Ohungarumlaut Acircumflex -35 +KPX Ohungarumlaut Adieresis -35 +KPX Ohungarumlaut Agrave -35 +KPX Ohungarumlaut Amacron -35 +KPX Ohungarumlaut Aogonek -35 +KPX Ohungarumlaut Aring -35 +KPX Ohungarumlaut Atilde -35 +KPX Ohungarumlaut T -40 +KPX Ohungarumlaut Tcaron -40 +KPX Ohungarumlaut Tcommaaccent -40 +KPX Ohungarumlaut V -50 +KPX Ohungarumlaut W -35 +KPX Ohungarumlaut X -40 +KPX Ohungarumlaut Y -50 +KPX Ohungarumlaut Yacute -50 +KPX Ohungarumlaut Ydieresis -50 +KPX Omacron A -35 +KPX Omacron Aacute -35 +KPX Omacron Abreve -35 +KPX Omacron Acircumflex -35 +KPX Omacron Adieresis -35 +KPX Omacron Agrave -35 +KPX Omacron Amacron -35 +KPX Omacron Aogonek -35 +KPX Omacron Aring -35 +KPX Omacron Atilde -35 +KPX Omacron T -40 +KPX Omacron Tcaron -40 +KPX Omacron Tcommaaccent -40 +KPX Omacron V -50 +KPX Omacron W -35 +KPX Omacron X -40 +KPX Omacron Y -50 +KPX Omacron Yacute -50 +KPX Omacron Ydieresis -50 +KPX Oslash A -35 +KPX Oslash Aacute -35 +KPX Oslash Abreve -35 +KPX Oslash Acircumflex -35 +KPX Oslash Adieresis -35 +KPX Oslash Agrave -35 +KPX Oslash Amacron -35 +KPX Oslash Aogonek -35 +KPX Oslash Aring -35 +KPX Oslash Atilde -35 +KPX Oslash T -40 +KPX Oslash Tcaron -40 +KPX Oslash Tcommaaccent -40 +KPX Oslash V -50 +KPX Oslash W -35 +KPX Oslash X -40 +KPX Oslash Y -50 +KPX Oslash Yacute -50 +KPX Oslash Ydieresis -50 +KPX Otilde A -35 +KPX Otilde Aacute -35 +KPX Otilde Abreve -35 +KPX Otilde Acircumflex -35 +KPX Otilde Adieresis -35 +KPX Otilde Agrave -35 +KPX Otilde Amacron -35 +KPX Otilde Aogonek -35 +KPX Otilde Aring -35 +KPX Otilde Atilde -35 +KPX Otilde T -40 +KPX Otilde Tcaron -40 +KPX Otilde Tcommaaccent -40 +KPX Otilde V -50 +KPX Otilde W -35 +KPX Otilde X -40 +KPX Otilde Y -50 +KPX Otilde Yacute -50 +KPX Otilde Ydieresis -50 +KPX P A -92 +KPX P Aacute -92 +KPX P Abreve -92 +KPX P Acircumflex -92 +KPX P Adieresis -92 +KPX P Agrave -92 +KPX P Amacron -92 +KPX P Aogonek -92 +KPX P Aring -92 +KPX P Atilde -92 +KPX P a -15 +KPX P aacute -15 +KPX P abreve -15 +KPX P acircumflex -15 +KPX P adieresis -15 +KPX P agrave -15 +KPX P amacron -15 +KPX P aogonek -15 +KPX P aring -15 +KPX P atilde -15 +KPX P comma -111 +KPX P period -111 +KPX Q U -10 +KPX Q Uacute -10 +KPX Q Ucircumflex -10 +KPX Q Udieresis -10 +KPX Q Ugrave -10 +KPX Q Uhungarumlaut -10 +KPX Q Umacron -10 +KPX Q Uogonek -10 +KPX Q Uring -10 +KPX R O -40 +KPX R Oacute -40 +KPX R Ocircumflex -40 +KPX R Odieresis -40 +KPX R Ograve -40 +KPX R Ohungarumlaut -40 +KPX R Omacron -40 +KPX R Oslash -40 +KPX R Otilde -40 +KPX R T -60 +KPX R Tcaron -60 +KPX R Tcommaaccent -60 +KPX R U -40 +KPX R Uacute -40 +KPX R Ucircumflex -40 +KPX R Udieresis -40 +KPX R Ugrave -40 +KPX R Uhungarumlaut -40 +KPX R Umacron -40 +KPX R Uogonek -40 +KPX R Uring -40 +KPX R V -80 +KPX R W -55 +KPX R Y -65 +KPX R Yacute -65 +KPX R Ydieresis -65 +KPX Racute O -40 +KPX Racute Oacute -40 +KPX Racute Ocircumflex -40 +KPX Racute Odieresis -40 +KPX Racute Ograve -40 +KPX Racute Ohungarumlaut -40 +KPX Racute Omacron -40 +KPX Racute Oslash -40 +KPX Racute Otilde -40 +KPX Racute T -60 +KPX Racute Tcaron -60 +KPX Racute Tcommaaccent -60 +KPX Racute U -40 +KPX Racute Uacute -40 +KPX Racute Ucircumflex -40 +KPX Racute Udieresis -40 +KPX Racute Ugrave -40 +KPX Racute Uhungarumlaut -40 +KPX Racute Umacron -40 +KPX Racute Uogonek -40 +KPX Racute Uring -40 +KPX Racute V -80 +KPX Racute W -55 +KPX Racute Y -65 +KPX Racute Yacute -65 +KPX Racute Ydieresis -65 +KPX Rcaron O -40 +KPX Rcaron Oacute -40 +KPX Rcaron Ocircumflex -40 +KPX Rcaron Odieresis -40 +KPX Rcaron Ograve -40 +KPX Rcaron Ohungarumlaut -40 +KPX Rcaron Omacron -40 +KPX Rcaron Oslash -40 +KPX Rcaron Otilde -40 +KPX Rcaron T -60 +KPX Rcaron Tcaron -60 +KPX Rcaron Tcommaaccent -60 +KPX Rcaron U -40 +KPX Rcaron Uacute -40 +KPX Rcaron Ucircumflex -40 +KPX Rcaron Udieresis -40 +KPX Rcaron Ugrave -40 +KPX Rcaron Uhungarumlaut -40 +KPX Rcaron Umacron -40 +KPX Rcaron Uogonek -40 +KPX Rcaron Uring -40 +KPX Rcaron V -80 +KPX Rcaron W -55 +KPX Rcaron Y -65 +KPX Rcaron Yacute -65 +KPX Rcaron Ydieresis -65 +KPX Rcommaaccent O -40 +KPX Rcommaaccent Oacute -40 +KPX Rcommaaccent Ocircumflex -40 +KPX Rcommaaccent Odieresis -40 +KPX Rcommaaccent Ograve -40 +KPX Rcommaaccent Ohungarumlaut -40 +KPX Rcommaaccent Omacron -40 +KPX Rcommaaccent Oslash -40 +KPX Rcommaaccent Otilde -40 +KPX Rcommaaccent T -60 +KPX Rcommaaccent Tcaron -60 +KPX Rcommaaccent Tcommaaccent -60 +KPX Rcommaaccent U -40 +KPX Rcommaaccent Uacute -40 +KPX Rcommaaccent Ucircumflex -40 +KPX Rcommaaccent Udieresis -40 +KPX Rcommaaccent Ugrave -40 +KPX Rcommaaccent Uhungarumlaut -40 +KPX Rcommaaccent Umacron -40 +KPX Rcommaaccent Uogonek -40 +KPX Rcommaaccent Uring -40 +KPX Rcommaaccent V -80 +KPX Rcommaaccent W -55 +KPX Rcommaaccent Y -65 +KPX Rcommaaccent Yacute -65 +KPX Rcommaaccent Ydieresis -65 +KPX T A -93 +KPX T Aacute -93 +KPX T Abreve -93 +KPX T Acircumflex -93 +KPX T Adieresis -93 +KPX T Agrave -93 +KPX T Amacron -93 +KPX T Aogonek -93 +KPX T Aring -93 +KPX T Atilde -93 +KPX T O -18 +KPX T Oacute -18 +KPX T Ocircumflex -18 +KPX T Odieresis -18 +KPX T Ograve -18 +KPX T Ohungarumlaut -18 +KPX T Omacron -18 +KPX T Oslash -18 +KPX T Otilde -18 +KPX T a -80 +KPX T aacute -80 +KPX T abreve -80 +KPX T acircumflex -80 +KPX T adieresis -40 +KPX T agrave -40 +KPX T amacron -40 +KPX T aogonek -80 +KPX T aring -80 +KPX T atilde -40 +KPX T colon -50 +KPX T comma -74 +KPX T e -70 +KPX T eacute -70 +KPX T ecaron -70 +KPX T ecircumflex -70 +KPX T edieresis -30 +KPX T edotaccent -70 +KPX T egrave -70 +KPX T emacron -30 +KPX T eogonek -70 +KPX T hyphen -92 +KPX T i -35 +KPX T iacute -35 +KPX T iogonek -35 +KPX T o -80 +KPX T oacute -80 +KPX T ocircumflex -80 +KPX T odieresis -80 +KPX T ograve -80 +KPX T ohungarumlaut -80 +KPX T omacron -80 +KPX T oslash -80 +KPX T otilde -80 +KPX T period -74 +KPX T r -35 +KPX T racute -35 +KPX T rcaron -35 +KPX T rcommaaccent -35 +KPX T semicolon -55 +KPX T u -45 +KPX T uacute -45 +KPX T ucircumflex -45 +KPX T udieresis -45 +KPX T ugrave -45 +KPX T uhungarumlaut -45 +KPX T umacron -45 +KPX T uogonek -45 +KPX T uring -45 +KPX T w -80 +KPX T y -80 +KPX T yacute -80 +KPX T ydieresis -80 +KPX Tcaron A -93 +KPX Tcaron Aacute -93 +KPX Tcaron Abreve -93 +KPX Tcaron Acircumflex -93 +KPX Tcaron Adieresis -93 +KPX Tcaron Agrave -93 +KPX Tcaron Amacron -93 +KPX Tcaron Aogonek -93 +KPX Tcaron Aring -93 +KPX Tcaron Atilde -93 +KPX Tcaron O -18 +KPX Tcaron Oacute -18 +KPX Tcaron Ocircumflex -18 +KPX Tcaron Odieresis -18 +KPX Tcaron Ograve -18 +KPX Tcaron Ohungarumlaut -18 +KPX Tcaron Omacron -18 +KPX Tcaron Oslash -18 +KPX Tcaron Otilde -18 +KPX Tcaron a -80 +KPX Tcaron aacute -80 +KPX Tcaron abreve -80 +KPX Tcaron acircumflex -80 +KPX Tcaron adieresis -40 +KPX Tcaron agrave -40 +KPX Tcaron amacron -40 +KPX Tcaron aogonek -80 +KPX Tcaron aring -80 +KPX Tcaron atilde -40 +KPX Tcaron colon -50 +KPX Tcaron comma -74 +KPX Tcaron e -70 +KPX Tcaron eacute -70 +KPX Tcaron ecaron -70 +KPX Tcaron ecircumflex -30 +KPX Tcaron edieresis -30 +KPX Tcaron edotaccent -70 +KPX Tcaron egrave -70 +KPX Tcaron emacron -30 +KPX Tcaron eogonek -70 +KPX Tcaron hyphen -92 +KPX Tcaron i -35 +KPX Tcaron iacute -35 +KPX Tcaron iogonek -35 +KPX Tcaron o -80 +KPX Tcaron oacute -80 +KPX Tcaron ocircumflex -80 +KPX Tcaron odieresis -80 +KPX Tcaron ograve -80 +KPX Tcaron ohungarumlaut -80 +KPX Tcaron omacron -80 +KPX Tcaron oslash -80 +KPX Tcaron otilde -80 +KPX Tcaron period -74 +KPX Tcaron r -35 +KPX Tcaron racute -35 +KPX Tcaron rcaron -35 +KPX Tcaron rcommaaccent -35 +KPX Tcaron semicolon -55 +KPX Tcaron u -45 +KPX Tcaron uacute -45 +KPX Tcaron ucircumflex -45 +KPX Tcaron udieresis -45 +KPX Tcaron ugrave -45 +KPX Tcaron uhungarumlaut -45 +KPX Tcaron umacron -45 +KPX Tcaron uogonek -45 +KPX Tcaron uring -45 +KPX Tcaron w -80 +KPX Tcaron y -80 +KPX Tcaron yacute -80 +KPX Tcaron ydieresis -80 +KPX Tcommaaccent A -93 +KPX Tcommaaccent Aacute -93 +KPX Tcommaaccent Abreve -93 +KPX Tcommaaccent Acircumflex -93 +KPX Tcommaaccent Adieresis -93 +KPX Tcommaaccent Agrave -93 +KPX Tcommaaccent Amacron -93 +KPX Tcommaaccent Aogonek -93 +KPX Tcommaaccent Aring -93 +KPX Tcommaaccent Atilde -93 +KPX Tcommaaccent O -18 +KPX Tcommaaccent Oacute -18 +KPX Tcommaaccent Ocircumflex -18 +KPX Tcommaaccent Odieresis -18 +KPX Tcommaaccent Ograve -18 +KPX Tcommaaccent Ohungarumlaut -18 +KPX Tcommaaccent Omacron -18 +KPX Tcommaaccent Oslash -18 +KPX Tcommaaccent Otilde -18 +KPX Tcommaaccent a -80 +KPX Tcommaaccent aacute -80 +KPX Tcommaaccent abreve -80 +KPX Tcommaaccent acircumflex -80 +KPX Tcommaaccent adieresis -40 +KPX Tcommaaccent agrave -40 +KPX Tcommaaccent amacron -40 +KPX Tcommaaccent aogonek -80 +KPX Tcommaaccent aring -80 +KPX Tcommaaccent atilde -40 +KPX Tcommaaccent colon -50 +KPX Tcommaaccent comma -74 +KPX Tcommaaccent e -70 +KPX Tcommaaccent eacute -70 +KPX Tcommaaccent ecaron -70 +KPX Tcommaaccent ecircumflex -30 +KPX Tcommaaccent edieresis -30 +KPX Tcommaaccent edotaccent -70 +KPX Tcommaaccent egrave -30 +KPX Tcommaaccent emacron -70 +KPX Tcommaaccent eogonek -70 +KPX Tcommaaccent hyphen -92 +KPX Tcommaaccent i -35 +KPX Tcommaaccent iacute -35 +KPX Tcommaaccent iogonek -35 +KPX Tcommaaccent o -80 +KPX Tcommaaccent oacute -80 +KPX Tcommaaccent ocircumflex -80 +KPX Tcommaaccent odieresis -80 +KPX Tcommaaccent ograve -80 +KPX Tcommaaccent ohungarumlaut -80 +KPX Tcommaaccent omacron -80 +KPX Tcommaaccent oslash -80 +KPX Tcommaaccent otilde -80 +KPX Tcommaaccent period -74 +KPX Tcommaaccent r -35 +KPX Tcommaaccent racute -35 +KPX Tcommaaccent rcaron -35 +KPX Tcommaaccent rcommaaccent -35 +KPX Tcommaaccent semicolon -55 +KPX Tcommaaccent u -45 +KPX Tcommaaccent uacute -45 +KPX Tcommaaccent ucircumflex -45 +KPX Tcommaaccent udieresis -45 +KPX Tcommaaccent ugrave -45 +KPX Tcommaaccent uhungarumlaut -45 +KPX Tcommaaccent umacron -45 +KPX Tcommaaccent uogonek -45 +KPX Tcommaaccent uring -45 +KPX Tcommaaccent w -80 +KPX Tcommaaccent y -80 +KPX Tcommaaccent yacute -80 +KPX Tcommaaccent ydieresis -80 +KPX U A -40 +KPX U Aacute -40 +KPX U Abreve -40 +KPX U Acircumflex -40 +KPX U Adieresis -40 +KPX U Agrave -40 +KPX U Amacron -40 +KPX U Aogonek -40 +KPX U Aring -40 +KPX U Atilde -40 +KPX Uacute A -40 +KPX Uacute Aacute -40 +KPX Uacute Abreve -40 +KPX Uacute Acircumflex -40 +KPX Uacute Adieresis -40 +KPX Uacute Agrave -40 +KPX Uacute Amacron -40 +KPX Uacute Aogonek -40 +KPX Uacute Aring -40 +KPX Uacute Atilde -40 +KPX Ucircumflex A -40 +KPX Ucircumflex Aacute -40 +KPX Ucircumflex Abreve -40 +KPX Ucircumflex Acircumflex -40 +KPX Ucircumflex Adieresis -40 +KPX Ucircumflex Agrave -40 +KPX Ucircumflex Amacron -40 +KPX Ucircumflex Aogonek -40 +KPX Ucircumflex Aring -40 +KPX Ucircumflex Atilde -40 +KPX Udieresis A -40 +KPX Udieresis Aacute -40 +KPX Udieresis Abreve -40 +KPX Udieresis Acircumflex -40 +KPX Udieresis Adieresis -40 +KPX Udieresis Agrave -40 +KPX Udieresis Amacron -40 +KPX Udieresis Aogonek -40 +KPX Udieresis Aring -40 +KPX Udieresis Atilde -40 +KPX Ugrave A -40 +KPX Ugrave Aacute -40 +KPX Ugrave Abreve -40 +KPX Ugrave Acircumflex -40 +KPX Ugrave Adieresis -40 +KPX Ugrave Agrave -40 +KPX Ugrave Amacron -40 +KPX Ugrave Aogonek -40 +KPX Ugrave Aring -40 +KPX Ugrave Atilde -40 +KPX Uhungarumlaut A -40 +KPX Uhungarumlaut Aacute -40 +KPX Uhungarumlaut Abreve -40 +KPX Uhungarumlaut Acircumflex -40 +KPX Uhungarumlaut Adieresis -40 +KPX Uhungarumlaut Agrave -40 +KPX Uhungarumlaut Amacron -40 +KPX Uhungarumlaut Aogonek -40 +KPX Uhungarumlaut Aring -40 +KPX Uhungarumlaut Atilde -40 +KPX Umacron A -40 +KPX Umacron Aacute -40 +KPX Umacron Abreve -40 +KPX Umacron Acircumflex -40 +KPX Umacron Adieresis -40 +KPX Umacron Agrave -40 +KPX Umacron Amacron -40 +KPX Umacron Aogonek -40 +KPX Umacron Aring -40 +KPX Umacron Atilde -40 +KPX Uogonek A -40 +KPX Uogonek Aacute -40 +KPX Uogonek Abreve -40 +KPX Uogonek Acircumflex -40 +KPX Uogonek Adieresis -40 +KPX Uogonek Agrave -40 +KPX Uogonek Amacron -40 +KPX Uogonek Aogonek -40 +KPX Uogonek Aring -40 +KPX Uogonek Atilde -40 +KPX Uring A -40 +KPX Uring Aacute -40 +KPX Uring Abreve -40 +KPX Uring Acircumflex -40 +KPX Uring Adieresis -40 +KPX Uring Agrave -40 +KPX Uring Amacron -40 +KPX Uring Aogonek -40 +KPX Uring Aring -40 +KPX Uring Atilde -40 +KPX V A -135 +KPX V Aacute -135 +KPX V Abreve -135 +KPX V Acircumflex -135 +KPX V Adieresis -135 +KPX V Agrave -135 +KPX V Amacron -135 +KPX V Aogonek -135 +KPX V Aring -135 +KPX V Atilde -135 +KPX V G -15 +KPX V Gbreve -15 +KPX V Gcommaaccent -15 +KPX V O -40 +KPX V Oacute -40 +KPX V Ocircumflex -40 +KPX V Odieresis -40 +KPX V Ograve -40 +KPX V Ohungarumlaut -40 +KPX V Omacron -40 +KPX V Oslash -40 +KPX V Otilde -40 +KPX V a -111 +KPX V aacute -111 +KPX V abreve -111 +KPX V acircumflex -71 +KPX V adieresis -71 +KPX V agrave -71 +KPX V amacron -71 +KPX V aogonek -111 +KPX V aring -111 +KPX V atilde -71 +KPX V colon -74 +KPX V comma -129 +KPX V e -111 +KPX V eacute -111 +KPX V ecaron -71 +KPX V ecircumflex -71 +KPX V edieresis -71 +KPX V edotaccent -111 +KPX V egrave -71 +KPX V emacron -71 +KPX V eogonek -111 +KPX V hyphen -100 +KPX V i -60 +KPX V iacute -60 +KPX V icircumflex -20 +KPX V idieresis -20 +KPX V igrave -20 +KPX V imacron -20 +KPX V iogonek -60 +KPX V o -129 +KPX V oacute -129 +KPX V ocircumflex -129 +KPX V odieresis -89 +KPX V ograve -89 +KPX V ohungarumlaut -129 +KPX V omacron -89 +KPX V oslash -129 +KPX V otilde -89 +KPX V period -129 +KPX V semicolon -74 +KPX V u -75 +KPX V uacute -75 +KPX V ucircumflex -75 +KPX V udieresis -75 +KPX V ugrave -75 +KPX V uhungarumlaut -75 +KPX V umacron -75 +KPX V uogonek -75 +KPX V uring -75 +KPX W A -120 +KPX W Aacute -120 +KPX W Abreve -120 +KPX W Acircumflex -120 +KPX W Adieresis -120 +KPX W Agrave -120 +KPX W Amacron -120 +KPX W Aogonek -120 +KPX W Aring -120 +KPX W Atilde -120 +KPX W O -10 +KPX W Oacute -10 +KPX W Ocircumflex -10 +KPX W Odieresis -10 +KPX W Ograve -10 +KPX W Ohungarumlaut -10 +KPX W Omacron -10 +KPX W Oslash -10 +KPX W Otilde -10 +KPX W a -80 +KPX W aacute -80 +KPX W abreve -80 +KPX W acircumflex -80 +KPX W adieresis -80 +KPX W agrave -80 +KPX W amacron -80 +KPX W aogonek -80 +KPX W aring -80 +KPX W atilde -80 +KPX W colon -37 +KPX W comma -92 +KPX W e -80 +KPX W eacute -80 +KPX W ecaron -80 +KPX W ecircumflex -80 +KPX W edieresis -40 +KPX W edotaccent -80 +KPX W egrave -40 +KPX W emacron -40 +KPX W eogonek -80 +KPX W hyphen -65 +KPX W i -40 +KPX W iacute -40 +KPX W iogonek -40 +KPX W o -80 +KPX W oacute -80 +KPX W ocircumflex -80 +KPX W odieresis -80 +KPX W ograve -80 +KPX W ohungarumlaut -80 +KPX W omacron -80 +KPX W oslash -80 +KPX W otilde -80 +KPX W period -92 +KPX W semicolon -37 +KPX W u -50 +KPX W uacute -50 +KPX W ucircumflex -50 +KPX W udieresis -50 +KPX W ugrave -50 +KPX W uhungarumlaut -50 +KPX W umacron -50 +KPX W uogonek -50 +KPX W uring -50 +KPX W y -73 +KPX W yacute -73 +KPX W ydieresis -73 +KPX Y A -120 +KPX Y Aacute -120 +KPX Y Abreve -120 +KPX Y Acircumflex -120 +KPX Y Adieresis -120 +KPX Y Agrave -120 +KPX Y Amacron -120 +KPX Y Aogonek -120 +KPX Y Aring -120 +KPX Y Atilde -120 +KPX Y O -30 +KPX Y Oacute -30 +KPX Y Ocircumflex -30 +KPX Y Odieresis -30 +KPX Y Ograve -30 +KPX Y Ohungarumlaut -30 +KPX Y Omacron -30 +KPX Y Oslash -30 +KPX Y Otilde -30 +KPX Y a -100 +KPX Y aacute -100 +KPX Y abreve -100 +KPX Y acircumflex -100 +KPX Y adieresis -60 +KPX Y agrave -60 +KPX Y amacron -60 +KPX Y aogonek -100 +KPX Y aring -100 +KPX Y atilde -60 +KPX Y colon -92 +KPX Y comma -129 +KPX Y e -100 +KPX Y eacute -100 +KPX Y ecaron -100 +KPX Y ecircumflex -100 +KPX Y edieresis -60 +KPX Y edotaccent -100 +KPX Y egrave -60 +KPX Y emacron -60 +KPX Y eogonek -100 +KPX Y hyphen -111 +KPX Y i -55 +KPX Y iacute -55 +KPX Y iogonek -55 +KPX Y o -110 +KPX Y oacute -110 +KPX Y ocircumflex -110 +KPX Y odieresis -70 +KPX Y ograve -70 +KPX Y ohungarumlaut -110 +KPX Y omacron -70 +KPX Y oslash -110 +KPX Y otilde -70 +KPX Y period -129 +KPX Y semicolon -92 +KPX Y u -111 +KPX Y uacute -111 +KPX Y ucircumflex -111 +KPX Y udieresis -71 +KPX Y ugrave -71 +KPX Y uhungarumlaut -111 +KPX Y umacron -71 +KPX Y uogonek -111 +KPX Y uring -111 +KPX Yacute A -120 +KPX Yacute Aacute -120 +KPX Yacute Abreve -120 +KPX Yacute Acircumflex -120 +KPX Yacute Adieresis -120 +KPX Yacute Agrave -120 +KPX Yacute Amacron -120 +KPX Yacute Aogonek -120 +KPX Yacute Aring -120 +KPX Yacute Atilde -120 +KPX Yacute O -30 +KPX Yacute Oacute -30 +KPX Yacute Ocircumflex -30 +KPX Yacute Odieresis -30 +KPX Yacute Ograve -30 +KPX Yacute Ohungarumlaut -30 +KPX Yacute Omacron -30 +KPX Yacute Oslash -30 +KPX Yacute Otilde -30 +KPX Yacute a -100 +KPX Yacute aacute -100 +KPX Yacute abreve -100 +KPX Yacute acircumflex -100 +KPX Yacute adieresis -60 +KPX Yacute agrave -60 +KPX Yacute amacron -60 +KPX Yacute aogonek -100 +KPX Yacute aring -100 +KPX Yacute atilde -60 +KPX Yacute colon -92 +KPX Yacute comma -129 +KPX Yacute e -100 +KPX Yacute eacute -100 +KPX Yacute ecaron -100 +KPX Yacute ecircumflex -100 +KPX Yacute edieresis -60 +KPX Yacute edotaccent -100 +KPX Yacute egrave -60 +KPX Yacute emacron -60 +KPX Yacute eogonek -100 +KPX Yacute hyphen -111 +KPX Yacute i -55 +KPX Yacute iacute -55 +KPX Yacute iogonek -55 +KPX Yacute o -110 +KPX Yacute oacute -110 +KPX Yacute ocircumflex -110 +KPX Yacute odieresis -70 +KPX Yacute ograve -70 +KPX Yacute ohungarumlaut -110 +KPX Yacute omacron -70 +KPX Yacute oslash -110 +KPX Yacute otilde -70 +KPX Yacute period -129 +KPX Yacute semicolon -92 +KPX Yacute u -111 +KPX Yacute uacute -111 +KPX Yacute ucircumflex -111 +KPX Yacute udieresis -71 +KPX Yacute ugrave -71 +KPX Yacute uhungarumlaut -111 +KPX Yacute umacron -71 +KPX Yacute uogonek -111 +KPX Yacute uring -111 +KPX Ydieresis A -120 +KPX Ydieresis Aacute -120 +KPX Ydieresis Abreve -120 +KPX Ydieresis Acircumflex -120 +KPX Ydieresis Adieresis -120 +KPX Ydieresis Agrave -120 +KPX Ydieresis Amacron -120 +KPX Ydieresis Aogonek -120 +KPX Ydieresis Aring -120 +KPX Ydieresis Atilde -120 +KPX Ydieresis O -30 +KPX Ydieresis Oacute -30 +KPX Ydieresis Ocircumflex -30 +KPX Ydieresis Odieresis -30 +KPX Ydieresis Ograve -30 +KPX Ydieresis Ohungarumlaut -30 +KPX Ydieresis Omacron -30 +KPX Ydieresis Oslash -30 +KPX Ydieresis Otilde -30 +KPX Ydieresis a -100 +KPX Ydieresis aacute -100 +KPX Ydieresis abreve -100 +KPX Ydieresis acircumflex -100 +KPX Ydieresis adieresis -60 +KPX Ydieresis agrave -60 +KPX Ydieresis amacron -60 +KPX Ydieresis aogonek -100 +KPX Ydieresis aring -100 +KPX Ydieresis atilde -100 +KPX Ydieresis colon -92 +KPX Ydieresis comma -129 +KPX Ydieresis e -100 +KPX Ydieresis eacute -100 +KPX Ydieresis ecaron -100 +KPX Ydieresis ecircumflex -100 +KPX Ydieresis edieresis -60 +KPX Ydieresis edotaccent -100 +KPX Ydieresis egrave -60 +KPX Ydieresis emacron -60 +KPX Ydieresis eogonek -100 +KPX Ydieresis hyphen -111 +KPX Ydieresis i -55 +KPX Ydieresis iacute -55 +KPX Ydieresis iogonek -55 +KPX Ydieresis o -110 +KPX Ydieresis oacute -110 +KPX Ydieresis ocircumflex -110 +KPX Ydieresis odieresis -70 +KPX Ydieresis ograve -70 +KPX Ydieresis ohungarumlaut -110 +KPX Ydieresis omacron -70 +KPX Ydieresis oslash -110 +KPX Ydieresis otilde -70 +KPX Ydieresis period -129 +KPX Ydieresis semicolon -92 +KPX Ydieresis u -111 +KPX Ydieresis uacute -111 +KPX Ydieresis ucircumflex -111 +KPX Ydieresis udieresis -71 +KPX Ydieresis ugrave -71 +KPX Ydieresis uhungarumlaut -111 +KPX Ydieresis umacron -71 +KPX Ydieresis uogonek -111 +KPX Ydieresis uring -111 +KPX a v -20 +KPX a w -15 +KPX aacute v -20 +KPX aacute w -15 +KPX abreve v -20 +KPX abreve w -15 +KPX acircumflex v -20 +KPX acircumflex w -15 +KPX adieresis v -20 +KPX adieresis w -15 +KPX agrave v -20 +KPX agrave w -15 +KPX amacron v -20 +KPX amacron w -15 +KPX aogonek v -20 +KPX aogonek w -15 +KPX aring v -20 +KPX aring w -15 +KPX atilde v -20 +KPX atilde w -15 +KPX b period -40 +KPX b u -20 +KPX b uacute -20 +KPX b ucircumflex -20 +KPX b udieresis -20 +KPX b ugrave -20 +KPX b uhungarumlaut -20 +KPX b umacron -20 +KPX b uogonek -20 +KPX b uring -20 +KPX b v -15 +KPX c y -15 +KPX c yacute -15 +KPX c ydieresis -15 +KPX cacute y -15 +KPX cacute yacute -15 +KPX cacute ydieresis -15 +KPX ccaron y -15 +KPX ccaron yacute -15 +KPX ccaron ydieresis -15 +KPX ccedilla y -15 +KPX ccedilla yacute -15 +KPX ccedilla ydieresis -15 +KPX comma quotedblright -70 +KPX comma quoteright -70 +KPX e g -15 +KPX e gbreve -15 +KPX e gcommaaccent -15 +KPX e v -25 +KPX e w -25 +KPX e x -15 +KPX e y -15 +KPX e yacute -15 +KPX e ydieresis -15 +KPX eacute g -15 +KPX eacute gbreve -15 +KPX eacute gcommaaccent -15 +KPX eacute v -25 +KPX eacute w -25 +KPX eacute x -15 +KPX eacute y -15 +KPX eacute yacute -15 +KPX eacute ydieresis -15 +KPX ecaron g -15 +KPX ecaron gbreve -15 +KPX ecaron gcommaaccent -15 +KPX ecaron v -25 +KPX ecaron w -25 +KPX ecaron x -15 +KPX ecaron y -15 +KPX ecaron yacute -15 +KPX ecaron ydieresis -15 +KPX ecircumflex g -15 +KPX ecircumflex gbreve -15 +KPX ecircumflex gcommaaccent -15 +KPX ecircumflex v -25 +KPX ecircumflex w -25 +KPX ecircumflex x -15 +KPX ecircumflex y -15 +KPX ecircumflex yacute -15 +KPX ecircumflex ydieresis -15 +KPX edieresis g -15 +KPX edieresis gbreve -15 +KPX edieresis gcommaaccent -15 +KPX edieresis v -25 +KPX edieresis w -25 +KPX edieresis x -15 +KPX edieresis y -15 +KPX edieresis yacute -15 +KPX edieresis ydieresis -15 +KPX edotaccent g -15 +KPX edotaccent gbreve -15 +KPX edotaccent gcommaaccent -15 +KPX edotaccent v -25 +KPX edotaccent w -25 +KPX edotaccent x -15 +KPX edotaccent y -15 +KPX edotaccent yacute -15 +KPX edotaccent ydieresis -15 +KPX egrave g -15 +KPX egrave gbreve -15 +KPX egrave gcommaaccent -15 +KPX egrave v -25 +KPX egrave w -25 +KPX egrave x -15 +KPX egrave y -15 +KPX egrave yacute -15 +KPX egrave ydieresis -15 +KPX emacron g -15 +KPX emacron gbreve -15 +KPX emacron gcommaaccent -15 +KPX emacron v -25 +KPX emacron w -25 +KPX emacron x -15 +KPX emacron y -15 +KPX emacron yacute -15 +KPX emacron ydieresis -15 +KPX eogonek g -15 +KPX eogonek gbreve -15 +KPX eogonek gcommaaccent -15 +KPX eogonek v -25 +KPX eogonek w -25 +KPX eogonek x -15 +KPX eogonek y -15 +KPX eogonek yacute -15 +KPX eogonek ydieresis -15 +KPX f a -10 +KPX f aacute -10 +KPX f abreve -10 +KPX f acircumflex -10 +KPX f adieresis -10 +KPX f agrave -10 +KPX f amacron -10 +KPX f aogonek -10 +KPX f aring -10 +KPX f atilde -10 +KPX f dotlessi -50 +KPX f f -25 +KPX f i -20 +KPX f iacute -20 +KPX f quoteright 55 +KPX g a -5 +KPX g aacute -5 +KPX g abreve -5 +KPX g acircumflex -5 +KPX g adieresis -5 +KPX g agrave -5 +KPX g amacron -5 +KPX g aogonek -5 +KPX g aring -5 +KPX g atilde -5 +KPX gbreve a -5 +KPX gbreve aacute -5 +KPX gbreve abreve -5 +KPX gbreve acircumflex -5 +KPX gbreve adieresis -5 +KPX gbreve agrave -5 +KPX gbreve amacron -5 +KPX gbreve aogonek -5 +KPX gbreve aring -5 +KPX gbreve atilde -5 +KPX gcommaaccent a -5 +KPX gcommaaccent aacute -5 +KPX gcommaaccent abreve -5 +KPX gcommaaccent acircumflex -5 +KPX gcommaaccent adieresis -5 +KPX gcommaaccent agrave -5 +KPX gcommaaccent amacron -5 +KPX gcommaaccent aogonek -5 +KPX gcommaaccent aring -5 +KPX gcommaaccent atilde -5 +KPX h y -5 +KPX h yacute -5 +KPX h ydieresis -5 +KPX i v -25 +KPX iacute v -25 +KPX icircumflex v -25 +KPX idieresis v -25 +KPX igrave v -25 +KPX imacron v -25 +KPX iogonek v -25 +KPX k e -10 +KPX k eacute -10 +KPX k ecaron -10 +KPX k ecircumflex -10 +KPX k edieresis -10 +KPX k edotaccent -10 +KPX k egrave -10 +KPX k emacron -10 +KPX k eogonek -10 +KPX k o -10 +KPX k oacute -10 +KPX k ocircumflex -10 +KPX k odieresis -10 +KPX k ograve -10 +KPX k ohungarumlaut -10 +KPX k omacron -10 +KPX k oslash -10 +KPX k otilde -10 +KPX k y -15 +KPX k yacute -15 +KPX k ydieresis -15 +KPX kcommaaccent e -10 +KPX kcommaaccent eacute -10 +KPX kcommaaccent ecaron -10 +KPX kcommaaccent ecircumflex -10 +KPX kcommaaccent edieresis -10 +KPX kcommaaccent edotaccent -10 +KPX kcommaaccent egrave -10 +KPX kcommaaccent emacron -10 +KPX kcommaaccent eogonek -10 +KPX kcommaaccent o -10 +KPX kcommaaccent oacute -10 +KPX kcommaaccent ocircumflex -10 +KPX kcommaaccent odieresis -10 +KPX kcommaaccent ograve -10 +KPX kcommaaccent ohungarumlaut -10 +KPX kcommaaccent omacron -10 +KPX kcommaaccent oslash -10 +KPX kcommaaccent otilde -10 +KPX kcommaaccent y -15 +KPX kcommaaccent yacute -15 +KPX kcommaaccent ydieresis -15 +KPX l w -10 +KPX lacute w -10 +KPX lcommaaccent w -10 +KPX lslash w -10 +KPX n v -40 +KPX n y -15 +KPX n yacute -15 +KPX n ydieresis -15 +KPX nacute v -40 +KPX nacute y -15 +KPX nacute yacute -15 +KPX nacute ydieresis -15 +KPX ncaron v -40 +KPX ncaron y -15 +KPX ncaron yacute -15 +KPX ncaron ydieresis -15 +KPX ncommaaccent v -40 +KPX ncommaaccent y -15 +KPX ncommaaccent yacute -15 +KPX ncommaaccent ydieresis -15 +KPX ntilde v -40 +KPX ntilde y -15 +KPX ntilde yacute -15 +KPX ntilde ydieresis -15 +KPX o v -15 +KPX o w -25 +KPX o y -10 +KPX o yacute -10 +KPX o ydieresis -10 +KPX oacute v -15 +KPX oacute w -25 +KPX oacute y -10 +KPX oacute yacute -10 +KPX oacute ydieresis -10 +KPX ocircumflex v -15 +KPX ocircumflex w -25 +KPX ocircumflex y -10 +KPX ocircumflex yacute -10 +KPX ocircumflex ydieresis -10 +KPX odieresis v -15 +KPX odieresis w -25 +KPX odieresis y -10 +KPX odieresis yacute -10 +KPX odieresis ydieresis -10 +KPX ograve v -15 +KPX ograve w -25 +KPX ograve y -10 +KPX ograve yacute -10 +KPX ograve ydieresis -10 +KPX ohungarumlaut v -15 +KPX ohungarumlaut w -25 +KPX ohungarumlaut y -10 +KPX ohungarumlaut yacute -10 +KPX ohungarumlaut ydieresis -10 +KPX omacron v -15 +KPX omacron w -25 +KPX omacron y -10 +KPX omacron yacute -10 +KPX omacron ydieresis -10 +KPX oslash v -15 +KPX oslash w -25 +KPX oslash y -10 +KPX oslash yacute -10 +KPX oslash ydieresis -10 +KPX otilde v -15 +KPX otilde w -25 +KPX otilde y -10 +KPX otilde yacute -10 +KPX otilde ydieresis -10 +KPX p y -10 +KPX p yacute -10 +KPX p ydieresis -10 +KPX period quotedblright -70 +KPX period quoteright -70 +KPX quotedblleft A -80 +KPX quotedblleft Aacute -80 +KPX quotedblleft Abreve -80 +KPX quotedblleft Acircumflex -80 +KPX quotedblleft Adieresis -80 +KPX quotedblleft Agrave -80 +KPX quotedblleft Amacron -80 +KPX quotedblleft Aogonek -80 +KPX quotedblleft Aring -80 +KPX quotedblleft Atilde -80 +KPX quoteleft A -80 +KPX quoteleft Aacute -80 +KPX quoteleft Abreve -80 +KPX quoteleft Acircumflex -80 +KPX quoteleft Adieresis -80 +KPX quoteleft Agrave -80 +KPX quoteleft Amacron -80 +KPX quoteleft Aogonek -80 +KPX quoteleft Aring -80 +KPX quoteleft Atilde -80 +KPX quoteleft quoteleft -74 +KPX quoteright d -50 +KPX quoteright dcroat -50 +KPX quoteright l -10 +KPX quoteright lacute -10 +KPX quoteright lcommaaccent -10 +KPX quoteright lslash -10 +KPX quoteright quoteright -74 +KPX quoteright r -50 +KPX quoteright racute -50 +KPX quoteright rcaron -50 +KPX quoteright rcommaaccent -50 +KPX quoteright s -55 +KPX quoteright sacute -55 +KPX quoteright scaron -55 +KPX quoteright scedilla -55 +KPX quoteright scommaaccent -55 +KPX quoteright space -74 +KPX quoteright t -18 +KPX quoteright tcommaaccent -18 +KPX quoteright v -50 +KPX r comma -40 +KPX r g -18 +KPX r gbreve -18 +KPX r gcommaaccent -18 +KPX r hyphen -20 +KPX r period -55 +KPX racute comma -40 +KPX racute g -18 +KPX racute gbreve -18 +KPX racute gcommaaccent -18 +KPX racute hyphen -20 +KPX racute period -55 +KPX rcaron comma -40 +KPX rcaron g -18 +KPX rcaron gbreve -18 +KPX rcaron gcommaaccent -18 +KPX rcaron hyphen -20 +KPX rcaron period -55 +KPX rcommaaccent comma -40 +KPX rcommaaccent g -18 +KPX rcommaaccent gbreve -18 +KPX rcommaaccent gcommaaccent -18 +KPX rcommaaccent hyphen -20 +KPX rcommaaccent period -55 +KPX space A -55 +KPX space Aacute -55 +KPX space Abreve -55 +KPX space Acircumflex -55 +KPX space Adieresis -55 +KPX space Agrave -55 +KPX space Amacron -55 +KPX space Aogonek -55 +KPX space Aring -55 +KPX space Atilde -55 +KPX space T -18 +KPX space Tcaron -18 +KPX space Tcommaaccent -18 +KPX space V -50 +KPX space W -30 +KPX space Y -90 +KPX space Yacute -90 +KPX space Ydieresis -90 +KPX v a -25 +KPX v aacute -25 +KPX v abreve -25 +KPX v acircumflex -25 +KPX v adieresis -25 +KPX v agrave -25 +KPX v amacron -25 +KPX v aogonek -25 +KPX v aring -25 +KPX v atilde -25 +KPX v comma -65 +KPX v e -15 +KPX v eacute -15 +KPX v ecaron -15 +KPX v ecircumflex -15 +KPX v edieresis -15 +KPX v edotaccent -15 +KPX v egrave -15 +KPX v emacron -15 +KPX v eogonek -15 +KPX v o -20 +KPX v oacute -20 +KPX v ocircumflex -20 +KPX v odieresis -20 +KPX v ograve -20 +KPX v ohungarumlaut -20 +KPX v omacron -20 +KPX v oslash -20 +KPX v otilde -20 +KPX v period -65 +KPX w a -10 +KPX w aacute -10 +KPX w abreve -10 +KPX w acircumflex -10 +KPX w adieresis -10 +KPX w agrave -10 +KPX w amacron -10 +KPX w aogonek -10 +KPX w aring -10 +KPX w atilde -10 +KPX w comma -65 +KPX w o -10 +KPX w oacute -10 +KPX w ocircumflex -10 +KPX w odieresis -10 +KPX w ograve -10 +KPX w ohungarumlaut -10 +KPX w omacron -10 +KPX w oslash -10 +KPX w otilde -10 +KPX w period -65 +KPX x e -15 +KPX x eacute -15 +KPX x ecaron -15 +KPX x ecircumflex -15 +KPX x edieresis -15 +KPX x edotaccent -15 +KPX x egrave -15 +KPX x emacron -15 +KPX x eogonek -15 +KPX y comma -65 +KPX y period -65 +KPX yacute comma -65 +KPX yacute period -65 +KPX ydieresis comma -65 +KPX ydieresis period -65 +EndKernPairs +EndKernData +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/ZapfDingbats.afm b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/ZapfDingbats.afm new file mode 100644 index 00000000..b2745053 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/ZapfDingbats.afm @@ -0,0 +1,225 @@ +StartFontMetrics 4.1 +Comment Copyright (c) 1985, 1987, 1988, 1989, 1997 Adobe Systems Incorporated. All Rights Reserved. +Comment Creation Date: Thu May 1 15:14:13 1997 +Comment UniqueID 43082 +Comment VMusage 45775 55535 +FontName ZapfDingbats +FullName ITC Zapf Dingbats +FamilyName ZapfDingbats +Weight Medium +ItalicAngle 0 +IsFixedPitch false +CharacterSet Special +FontBBox -1 -143 981 820 +UnderlinePosition -100 +UnderlineThickness 50 +Version 002.000 +Notice Copyright (c) 1985, 1987, 1988, 1989, 1997 Adobe Systems Incorporated. All Rights Reserved.ITC Zapf Dingbats is a registered trademark of International Typeface Corporation. +EncodingScheme FontSpecific +StdHW 28 +StdVW 90 +StartCharMetrics 202 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 974 ; N a1 ; B 35 72 939 621 ; +C 34 ; WX 961 ; N a2 ; B 35 81 927 611 ; +C 35 ; WX 974 ; N a202 ; B 35 72 939 621 ; +C 36 ; WX 980 ; N a3 ; B 35 0 945 692 ; +C 37 ; WX 719 ; N a4 ; B 34 139 685 566 ; +C 38 ; WX 789 ; N a5 ; B 35 -14 755 705 ; +C 39 ; WX 790 ; N a119 ; B 35 -14 755 705 ; +C 40 ; WX 791 ; N a118 ; B 35 -13 761 705 ; +C 41 ; WX 690 ; N a117 ; B 34 138 655 553 ; +C 42 ; WX 960 ; N a11 ; B 35 123 925 568 ; +C 43 ; WX 939 ; N a12 ; B 35 134 904 559 ; +C 44 ; WX 549 ; N a13 ; B 29 -11 516 705 ; +C 45 ; WX 855 ; N a14 ; B 34 59 820 632 ; +C 46 ; WX 911 ; N a15 ; B 35 50 876 642 ; +C 47 ; WX 933 ; N a16 ; B 35 139 899 550 ; +C 48 ; WX 911 ; N a105 ; B 35 50 876 642 ; +C 49 ; WX 945 ; N a17 ; B 35 139 909 553 ; +C 50 ; WX 974 ; N a18 ; B 35 104 938 587 ; +C 51 ; WX 755 ; N a19 ; B 34 -13 721 705 ; +C 52 ; WX 846 ; N a20 ; B 36 -14 811 705 ; +C 53 ; WX 762 ; N a21 ; B 35 0 727 692 ; +C 54 ; WX 761 ; N a22 ; B 35 0 727 692 ; +C 55 ; WX 571 ; N a23 ; B -1 -68 571 661 ; +C 56 ; WX 677 ; N a24 ; B 36 -13 642 705 ; +C 57 ; WX 763 ; N a25 ; B 35 0 728 692 ; +C 58 ; WX 760 ; N a26 ; B 35 0 726 692 ; +C 59 ; WX 759 ; N a27 ; B 35 0 725 692 ; +C 60 ; WX 754 ; N a28 ; B 35 0 720 692 ; +C 61 ; WX 494 ; N a6 ; B 35 0 460 692 ; +C 62 ; WX 552 ; N a7 ; B 35 0 517 692 ; +C 63 ; WX 537 ; N a8 ; B 35 0 503 692 ; +C 64 ; WX 577 ; N a9 ; B 35 96 542 596 ; +C 65 ; WX 692 ; N a10 ; B 35 -14 657 705 ; +C 66 ; WX 786 ; N a29 ; B 35 -14 751 705 ; +C 67 ; WX 788 ; N a30 ; B 35 -14 752 705 ; +C 68 ; WX 788 ; N a31 ; B 35 -14 753 705 ; +C 69 ; WX 790 ; N a32 ; B 35 -14 756 705 ; +C 70 ; WX 793 ; N a33 ; B 35 -13 759 705 ; +C 71 ; WX 794 ; N a34 ; B 35 -13 759 705 ; +C 72 ; WX 816 ; N a35 ; B 35 -14 782 705 ; +C 73 ; WX 823 ; N a36 ; B 35 -14 787 705 ; +C 74 ; WX 789 ; N a37 ; B 35 -14 754 705 ; +C 75 ; WX 841 ; N a38 ; B 35 -14 807 705 ; +C 76 ; WX 823 ; N a39 ; B 35 -14 789 705 ; +C 77 ; WX 833 ; N a40 ; B 35 -14 798 705 ; +C 78 ; WX 816 ; N a41 ; B 35 -13 782 705 ; +C 79 ; WX 831 ; N a42 ; B 35 -14 796 705 ; +C 80 ; WX 923 ; N a43 ; B 35 -14 888 705 ; +C 81 ; WX 744 ; N a44 ; B 35 0 710 692 ; +C 82 ; WX 723 ; N a45 ; B 35 0 688 692 ; +C 83 ; WX 749 ; N a46 ; B 35 0 714 692 ; +C 84 ; WX 790 ; N a47 ; B 34 -14 756 705 ; +C 85 ; WX 792 ; N a48 ; B 35 -14 758 705 ; +C 86 ; WX 695 ; N a49 ; B 35 -14 661 706 ; +C 87 ; WX 776 ; N a50 ; B 35 -6 741 699 ; +C 88 ; WX 768 ; N a51 ; B 35 -7 734 699 ; +C 89 ; WX 792 ; N a52 ; B 35 -14 757 705 ; +C 90 ; WX 759 ; N a53 ; B 35 0 725 692 ; +C 91 ; WX 707 ; N a54 ; B 35 -13 672 704 ; +C 92 ; WX 708 ; N a55 ; B 35 -14 672 705 ; +C 93 ; WX 682 ; N a56 ; B 35 -14 647 705 ; +C 94 ; WX 701 ; N a57 ; B 35 -14 666 705 ; +C 95 ; WX 826 ; N a58 ; B 35 -14 791 705 ; +C 96 ; WX 815 ; N a59 ; B 35 -14 780 705 ; +C 97 ; WX 789 ; N a60 ; B 35 -14 754 705 ; +C 98 ; WX 789 ; N a61 ; B 35 -14 754 705 ; +C 99 ; WX 707 ; N a62 ; B 34 -14 673 705 ; +C 100 ; WX 687 ; N a63 ; B 36 0 651 692 ; +C 101 ; WX 696 ; N a64 ; B 35 0 661 691 ; +C 102 ; WX 689 ; N a65 ; B 35 0 655 692 ; +C 103 ; WX 786 ; N a66 ; B 34 -14 751 705 ; +C 104 ; WX 787 ; N a67 ; B 35 -14 752 705 ; +C 105 ; WX 713 ; N a68 ; B 35 -14 678 705 ; +C 106 ; WX 791 ; N a69 ; B 35 -14 756 705 ; +C 107 ; WX 785 ; N a70 ; B 36 -14 751 705 ; +C 108 ; WX 791 ; N a71 ; B 35 -14 757 705 ; +C 109 ; WX 873 ; N a72 ; B 35 -14 838 705 ; +C 110 ; WX 761 ; N a73 ; B 35 0 726 692 ; +C 111 ; WX 762 ; N a74 ; B 35 0 727 692 ; +C 112 ; WX 762 ; N a203 ; B 35 0 727 692 ; +C 113 ; WX 759 ; N a75 ; B 35 0 725 692 ; +C 114 ; WX 759 ; N a204 ; B 35 0 725 692 ; +C 115 ; WX 892 ; N a76 ; B 35 0 858 705 ; +C 116 ; WX 892 ; N a77 ; B 35 -14 858 692 ; +C 117 ; WX 788 ; N a78 ; B 35 -14 754 705 ; +C 118 ; WX 784 ; N a79 ; B 35 -14 749 705 ; +C 119 ; WX 438 ; N a81 ; B 35 -14 403 705 ; +C 120 ; WX 138 ; N a82 ; B 35 0 104 692 ; +C 121 ; WX 277 ; N a83 ; B 35 0 242 692 ; +C 122 ; WX 415 ; N a84 ; B 35 0 380 692 ; +C 123 ; WX 392 ; N a97 ; B 35 263 357 705 ; +C 124 ; WX 392 ; N a98 ; B 34 263 357 705 ; +C 125 ; WX 668 ; N a99 ; B 35 263 633 705 ; +C 126 ; WX 668 ; N a100 ; B 36 263 634 705 ; +C 128 ; WX 390 ; N a89 ; B 35 -14 356 705 ; +C 129 ; WX 390 ; N a90 ; B 35 -14 355 705 ; +C 130 ; WX 317 ; N a93 ; B 35 0 283 692 ; +C 131 ; WX 317 ; N a94 ; B 35 0 283 692 ; +C 132 ; WX 276 ; N a91 ; B 35 0 242 692 ; +C 133 ; WX 276 ; N a92 ; B 35 0 242 692 ; +C 134 ; WX 509 ; N a205 ; B 35 0 475 692 ; +C 135 ; WX 509 ; N a85 ; B 35 0 475 692 ; +C 136 ; WX 410 ; N a206 ; B 35 0 375 692 ; +C 137 ; WX 410 ; N a86 ; B 35 0 375 692 ; +C 138 ; WX 234 ; N a87 ; B 35 -14 199 705 ; +C 139 ; WX 234 ; N a88 ; B 35 -14 199 705 ; +C 140 ; WX 334 ; N a95 ; B 35 0 299 692 ; +C 141 ; WX 334 ; N a96 ; B 35 0 299 692 ; +C 161 ; WX 732 ; N a101 ; B 35 -143 697 806 ; +C 162 ; WX 544 ; N a102 ; B 56 -14 488 706 ; +C 163 ; WX 544 ; N a103 ; B 34 -14 508 705 ; +C 164 ; WX 910 ; N a104 ; B 35 40 875 651 ; +C 165 ; WX 667 ; N a106 ; B 35 -14 633 705 ; +C 166 ; WX 760 ; N a107 ; B 35 -14 726 705 ; +C 167 ; WX 760 ; N a108 ; B 0 121 758 569 ; +C 168 ; WX 776 ; N a112 ; B 35 0 741 705 ; +C 169 ; WX 595 ; N a111 ; B 34 -14 560 705 ; +C 170 ; WX 694 ; N a110 ; B 35 -14 659 705 ; +C 171 ; WX 626 ; N a109 ; B 34 0 591 705 ; +C 172 ; WX 788 ; N a120 ; B 35 -14 754 705 ; +C 173 ; WX 788 ; N a121 ; B 35 -14 754 705 ; +C 174 ; WX 788 ; N a122 ; B 35 -14 754 705 ; +C 175 ; WX 788 ; N a123 ; B 35 -14 754 705 ; +C 176 ; WX 788 ; N a124 ; B 35 -14 754 705 ; +C 177 ; WX 788 ; N a125 ; B 35 -14 754 705 ; +C 178 ; WX 788 ; N a126 ; B 35 -14 754 705 ; +C 179 ; WX 788 ; N a127 ; B 35 -14 754 705 ; +C 180 ; WX 788 ; N a128 ; B 35 -14 754 705 ; +C 181 ; WX 788 ; N a129 ; B 35 -14 754 705 ; +C 182 ; WX 788 ; N a130 ; B 35 -14 754 705 ; +C 183 ; WX 788 ; N a131 ; B 35 -14 754 705 ; +C 184 ; WX 788 ; N a132 ; B 35 -14 754 705 ; +C 185 ; WX 788 ; N a133 ; B 35 -14 754 705 ; +C 186 ; WX 788 ; N a134 ; B 35 -14 754 705 ; +C 187 ; WX 788 ; N a135 ; B 35 -14 754 705 ; +C 188 ; WX 788 ; N a136 ; B 35 -14 754 705 ; +C 189 ; WX 788 ; N a137 ; B 35 -14 754 705 ; +C 190 ; WX 788 ; N a138 ; B 35 -14 754 705 ; +C 191 ; WX 788 ; N a139 ; B 35 -14 754 705 ; +C 192 ; WX 788 ; N a140 ; B 35 -14 754 705 ; +C 193 ; WX 788 ; N a141 ; B 35 -14 754 705 ; +C 194 ; WX 788 ; N a142 ; B 35 -14 754 705 ; +C 195 ; WX 788 ; N a143 ; B 35 -14 754 705 ; +C 196 ; WX 788 ; N a144 ; B 35 -14 754 705 ; +C 197 ; WX 788 ; N a145 ; B 35 -14 754 705 ; +C 198 ; WX 788 ; N a146 ; B 35 -14 754 705 ; +C 199 ; WX 788 ; N a147 ; B 35 -14 754 705 ; +C 200 ; WX 788 ; N a148 ; B 35 -14 754 705 ; +C 201 ; WX 788 ; N a149 ; B 35 -14 754 705 ; +C 202 ; WX 788 ; N a150 ; B 35 -14 754 705 ; +C 203 ; WX 788 ; N a151 ; B 35 -14 754 705 ; +C 204 ; WX 788 ; N a152 ; B 35 -14 754 705 ; +C 205 ; WX 788 ; N a153 ; B 35 -14 754 705 ; +C 206 ; WX 788 ; N a154 ; B 35 -14 754 705 ; +C 207 ; WX 788 ; N a155 ; B 35 -14 754 705 ; +C 208 ; WX 788 ; N a156 ; B 35 -14 754 705 ; +C 209 ; WX 788 ; N a157 ; B 35 -14 754 705 ; +C 210 ; WX 788 ; N a158 ; B 35 -14 754 705 ; +C 211 ; WX 788 ; N a159 ; B 35 -14 754 705 ; +C 212 ; WX 894 ; N a160 ; B 35 58 860 634 ; +C 213 ; WX 838 ; N a161 ; B 35 152 803 540 ; +C 214 ; WX 1016 ; N a163 ; B 34 152 981 540 ; +C 215 ; WX 458 ; N a164 ; B 35 -127 422 820 ; +C 216 ; WX 748 ; N a196 ; B 35 94 698 597 ; +C 217 ; WX 924 ; N a165 ; B 35 140 890 552 ; +C 218 ; WX 748 ; N a192 ; B 35 94 698 597 ; +C 219 ; WX 918 ; N a166 ; B 35 166 884 526 ; +C 220 ; WX 927 ; N a167 ; B 35 32 892 660 ; +C 221 ; WX 928 ; N a168 ; B 35 129 891 562 ; +C 222 ; WX 928 ; N a169 ; B 35 128 893 563 ; +C 223 ; WX 834 ; N a170 ; B 35 155 799 537 ; +C 224 ; WX 873 ; N a171 ; B 35 93 838 599 ; +C 225 ; WX 828 ; N a172 ; B 35 104 791 588 ; +C 226 ; WX 924 ; N a173 ; B 35 98 889 594 ; +C 227 ; WX 924 ; N a162 ; B 35 98 889 594 ; +C 228 ; WX 917 ; N a174 ; B 35 0 882 692 ; +C 229 ; WX 930 ; N a175 ; B 35 84 896 608 ; +C 230 ; WX 931 ; N a176 ; B 35 84 896 608 ; +C 231 ; WX 463 ; N a177 ; B 35 -99 429 791 ; +C 232 ; WX 883 ; N a178 ; B 35 71 848 623 ; +C 233 ; WX 836 ; N a179 ; B 35 44 802 648 ; +C 234 ; WX 836 ; N a193 ; B 35 44 802 648 ; +C 235 ; WX 867 ; N a180 ; B 35 101 832 591 ; +C 236 ; WX 867 ; N a199 ; B 35 101 832 591 ; +C 237 ; WX 696 ; N a181 ; B 35 44 661 648 ; +C 238 ; WX 696 ; N a200 ; B 35 44 661 648 ; +C 239 ; WX 874 ; N a182 ; B 35 77 840 619 ; +C 241 ; WX 874 ; N a201 ; B 35 73 840 615 ; +C 242 ; WX 760 ; N a183 ; B 35 0 725 692 ; +C 243 ; WX 946 ; N a184 ; B 35 160 911 533 ; +C 244 ; WX 771 ; N a197 ; B 34 37 736 655 ; +C 245 ; WX 865 ; N a185 ; B 35 207 830 481 ; +C 246 ; WX 771 ; N a194 ; B 34 37 736 655 ; +C 247 ; WX 888 ; N a198 ; B 34 -19 853 712 ; +C 248 ; WX 967 ; N a186 ; B 35 124 932 568 ; +C 249 ; WX 888 ; N a195 ; B 34 -19 853 712 ; +C 250 ; WX 831 ; N a187 ; B 35 113 796 579 ; +C 251 ; WX 873 ; N a188 ; B 36 118 838 578 ; +C 252 ; WX 927 ; N a189 ; B 35 150 891 542 ; +C 253 ; WX 970 ; N a190 ; B 35 76 931 616 ; +C 254 ; WX 918 ; N a191 ; B 34 99 884 593 ; +EndCharMetrics +EndFontMetrics diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/readme.txt b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/readme.txt new file mode 100644 index 00000000..047ae70a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts/readme.txt @@ -0,0 +1,15 @@ +Font Metrics for the 14 PDF Core Fonts +====================================== + +This directory contains font metrics for the 14 PDF Core Fonts, +downloaded from Adobe. The title and this paragraph were added by +Matplotlib developers. The download URL was +. + +This file and the 14 PostScript(R) AFM files it accompanies may be used, copied, +and distributed for any purpose and without charge, with or without modification, +provided that all copyright notices are retained; that the AFM files are not +distributed without this file; that all modifications to this file or any of +the AFM files are prominently noted in the modified file(s); and that this +paragraph is not modified. Adobe Systems has no responsibility or obligation +to support the use of the AFM files. diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf new file mode 100644 index 00000000..1f22f07c Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf new file mode 100644 index 00000000..b8886cb5 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf new file mode 100644 index 00000000..300ea68b Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf new file mode 100644 index 00000000..52672188 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf new file mode 100644 index 00000000..36758a2e Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf new file mode 100644 index 00000000..cbcdd31d Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf new file mode 100644 index 00000000..da513440 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf new file mode 100644 index 00000000..0185ce95 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono.ttf new file mode 100644 index 00000000..278cd781 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf new file mode 100644 index 00000000..d683eb28 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf new file mode 100644 index 00000000..b4831f76 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf new file mode 100644 index 00000000..45b508b8 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf new file mode 100644 index 00000000..39dd3946 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf new file mode 100644 index 00000000..1623714d Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_DEJAVU b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_DEJAVU new file mode 100644 index 00000000..254e2cc4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_DEJAVU @@ -0,0 +1,99 @@ +Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. +Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) + +Bitstream Vera Fonts Copyright +------------------------------ + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is +a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of the fonts accompanying this license ("Fonts") and associated +documentation files (the "Font Software"), to reproduce and distribute the +Font Software, including without limitation the rights to use, copy, merge, +publish, distribute, and/or sell copies of the Font Software, and to permit +persons to whom the Font Software is furnished to do so, subject to the +following conditions: + +The above copyright and trademark notices and this permission notice shall +be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular +the designs of glyphs or characters in the Fonts may be modified and +additional glyphs or characters may be added to the Fonts, only if the fonts +are renamed to names not containing either the words "Bitstream" or the word +"Vera". + +This License becomes null and void to the extent applicable to Fonts or Font +Software that has been modified and is distributed under the "Bitstream +Vera" names. + +The Font Software may be sold as part of a larger software package but no +copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, +TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME +FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING +ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE +FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome +Foundation, and Bitstream Inc., shall not be used in advertising or +otherwise to promote the sale, use or other dealings in this Font Software +without prior written authorization from the Gnome Foundation or Bitstream +Inc., respectively. For further information, contact: fonts at gnome dot +org. + +Arev Fonts Copyright +------------------------------ + +Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the fonts accompanying this license ("Fonts") and +associated documentation files (the "Font Software"), to reproduce +and distribute the modifications to the Bitstream Vera Font Software, +including without limitation the rights to use, copy, merge, publish, +distribute, and/or sell copies of the Font Software, and to permit +persons to whom the Font Software is furnished to do so, subject to +the following conditions: + +The above copyright and trademark notices and this permission notice +shall be included in all copies of one or more of the Font Software +typefaces. + +The Font Software may be modified, altered, or added to, and in +particular the designs of glyphs or characters in the Fonts may be +modified and additional glyphs or characters may be added to the +Fonts, only if the fonts are renamed to names not containing either +the words "Tavmjong Bah" or the word "Arev". + +This License becomes null and void to the extent applicable to Fonts +or Font Software that has been modified and is distributed under the +"Tavmjong Bah Arev" names. + +The Font Software may be sold as part of a larger software package but +no copy of one or more of the Font Software typefaces may be sold by +itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL +TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the name of Tavmjong Bah shall not +be used in advertising or otherwise to promote the sale, use or other +dealings in this Font Software without prior written authorization +from Tavmjong Bah. For further information, contact: tavmjong @ free +. fr. + +$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX new file mode 100644 index 00000000..6034d947 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX @@ -0,0 +1,124 @@ +The STIX fonts distributed with matplotlib have been modified from +their canonical form. They have been converted from OTF to TTF format +using Fontforge and this script: + + #!/usr/bin/env fontforge + i=1 + while ( i<$argc ) + Open($argv[i]) + Generate($argv[i]:r + ".ttf") + i = i+1 + endloop + +The original STIX Font License begins below. + +----------------------------------------------------------- + +STIX Font License + +24 May 2010 + +Copyright (c) 2001-2010 by the STI Pub Companies, consisting of the American +Institute of Physics, the American Chemical Society, the American Mathematical +Society, the American Physical Society, Elsevier, Inc., and The Institute of +Electrical and Electronic Engineers, Inc. (www.stixfonts.org), with Reserved +Font Name STIX Fonts, STIX Fonts (TM) is a trademark of The Institute of +Electrical and Electronics Engineers, Inc. + +Portions copyright (c) 1998-2003 by MicroPress, Inc. (www.micropress-inc.com), +with Reserved Font Name TM Math. To obtain additional mathematical fonts, please +contact MicroPress, Inc., 68-30 Harrow Street, Forest Hills, NY 11375, USA, +Phone: (718) 575-1816. + +Portions copyright (c) 1990 by Elsevier, Inc. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf new file mode 100644 index 00000000..86994000 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf new file mode 100644 index 00000000..ba80b537 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf new file mode 100644 index 00000000..5957dabb Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf new file mode 100644 index 00000000..2830b6b9 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf new file mode 100644 index 00000000..a70c797d Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf new file mode 100644 index 00000000..ccbd9a60 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf new file mode 100644 index 00000000..e75e09e6 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf new file mode 100644 index 00000000..c27d42fb Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf new file mode 100644 index 00000000..f81717ec Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf new file mode 100644 index 00000000..855dec98 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf new file mode 100644 index 00000000..f955ca2a Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf new file mode 100644 index 00000000..6ffd3577 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf new file mode 100644 index 00000000..01ed101c Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf new file mode 100644 index 00000000..1ccf365e Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf new file mode 100644 index 00000000..bf2b66af Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf new file mode 100644 index 00000000..bd5f93f0 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf new file mode 100644 index 00000000..73b9930f Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmb10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmb10.ttf new file mode 100644 index 00000000..189bdf0f Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmb10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf new file mode 100644 index 00000000..e4b468dc Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf new file mode 100644 index 00000000..8d326610 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmr10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmr10.ttf new file mode 100644 index 00000000..8bc44966 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmr10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmss10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmss10.ttf new file mode 100644 index 00000000..ef70532c Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmss10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf new file mode 100644 index 00000000..45d8421a Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmtt10.ttf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmtt10.ttf new file mode 100644 index 00000000..15bdb68b Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/cmtt10.ttf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back-symbolic.svg new file mode 100644 index 00000000..0c2d653c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back-symbolic.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.pdf new file mode 100644 index 00000000..79709d8f Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.svg new file mode 100644 index 00000000..0c2d653c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/back.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave-symbolic.svg new file mode 100644 index 00000000..856721b6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave-symbolic.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.pdf new file mode 100644 index 00000000..794a1152 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.svg new file mode 100644 index 00000000..856721b6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/filesave.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward-symbolic.svg new file mode 100644 index 00000000..08b6fe17 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward-symbolic.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.pdf new file mode 100644 index 00000000..ce4a1bcb Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.svg new file mode 100644 index 00000000..08b6fe17 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/forward.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.pdf new file mode 100644 index 00000000..13088169 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.svg new file mode 100644 index 00000000..28b96a2a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/hand.svg @@ -0,0 +1,130 @@ + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help-symbolic.svg new file mode 100644 index 00000000..260528d6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help-symbolic.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.pdf new file mode 100644 index 00000000..38178d05 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.svg new file mode 100644 index 00000000..260528d6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/help.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home-symbolic.svg new file mode 100644 index 00000000..db140d43 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home-symbolic.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.pdf new file mode 100644 index 00000000..f9c6439b Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.svg new file mode 100644 index 00000000..db140d43 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/home.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.pdf new file mode 100644 index 00000000..6c44566a Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.svg new file mode 100644 index 00000000..95d1b612 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/matplotlib.svg @@ -0,0 +1,3171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move-symbolic.svg new file mode 100644 index 00000000..f7e23ab0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move-symbolic.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.pdf new file mode 100644 index 00000000..d883d922 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.svg new file mode 100644 index 00000000..f7e23ab0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/move.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.pdf new file mode 100644 index 00000000..a92f2cc3 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.svg new file mode 100644 index 00000000..02adfbc4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/qt4_editor_options.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots-symbolic.svg new file mode 100644 index 00000000..9a0fa909 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots-symbolic.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.pdf new file mode 100644 index 00000000..f4046655 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.svg new file mode 100644 index 00000000..9a0fa909 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/subplots.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg new file mode 100644 index 00000000..44e59a8a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect-symbolic.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.pdf b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.pdf new file mode 100644 index 00000000..22add33b Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.pdf differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.svg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.svg new file mode 100644 index 00000000..44e59a8a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/images/zoom_to_rect.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/kpsewhich.lua b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/kpsewhich.lua new file mode 100644 index 00000000..8e9172a4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/kpsewhich.lua @@ -0,0 +1,3 @@ +-- see dviread._LuatexKpsewhich +kpse.set_program_name("latex") +while true do print(kpse.lookup(io.read():gsub("\r", ""))); io.flush(); end diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/matplotlibrc b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/matplotlibrc new file mode 100644 index 00000000..29ffb20f --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/matplotlibrc @@ -0,0 +1,800 @@ +#### MATPLOTLIBRC FORMAT + +## NOTE FOR END USERS: DO NOT EDIT THIS FILE! +## +## This is a sample Matplotlib configuration file - you can find a copy +## of it on your system in site-packages/matplotlib/mpl-data/matplotlibrc +## (relative to your Python installation location). +## DO NOT EDIT IT! +## +## If you wish to change your default style, copy this file to one of the +## following locations: +## Unix/Linux: +## $HOME/.config/matplotlib/matplotlibrc OR +## $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set) +## Other platforms: +## $HOME/.matplotlib/matplotlibrc +## and edit that copy. +## +## See https://matplotlib.org/stable/users/explain/customizing.html#customizing-with-matplotlibrc-files +## for more details on the paths which are checked for the configuration file. +## +## Blank lines, or lines starting with a comment symbol, are ignored, as are +## trailing comments. Other lines must have the format: +## key: val # optional comment +## +## Formatting: Use PEP8-like style (as enforced in the rest of the codebase). +## All lines start with an additional '#', so that removing all leading '#'s +## yields a valid style file. +## +## Colors: for the color values below, you can either use +## - a Matplotlib color string, such as r, k, or b +## - an RGB tuple, such as (1.0, 0.5, 0.0) +## - a double-quoted hex string, such as "#ff00ff". +## The unquoted string ff00ff is also supported for backward +## compatibility, but is discouraged. +## - a scalar grayscale intensity such as 0.75 +## - a legal html color name, e.g., red, blue, darkslategray +## +## String values may optionally be enclosed in double quotes, which allows +## using the comment character # in the string. +## +## This file (and other style files) must be encoded as utf-8. +## +## Matplotlib configuration are currently divided into following parts: +## - BACKENDS +## - LINES +## - PATCHES +## - HATCHES +## - BOXPLOT +## - FONT +## - TEXT +## - LaTeX +## - AXES +## - DATES +## - TICKS +## - GRIDS +## - LEGEND +## - FIGURE +## - IMAGES +## - CONTOUR PLOTS +## - ERRORBAR PLOTS +## - HISTOGRAM PLOTS +## - SCATTER PLOTS +## - AGG RENDERING +## - PATHS +## - SAVING FIGURES +## - INTERACTIVE KEYMAPS +## - ANIMATION + +##### CONFIGURATION BEGINS HERE + + +## *************************************************************************** +## * BACKENDS * +## *************************************************************************** +## The default backend. If you omit this parameter, the first working +## backend from the following list is used: +## MacOSX QtAgg Gtk4Agg Gtk3Agg TkAgg WxAgg Agg +## Other choices include: +## QtCairo GTK4Cairo GTK3Cairo TkCairo WxCairo Cairo +## Qt5Agg Qt5Cairo Wx # deprecated. +## PS PDF SVG Template +## You can also deploy your own backend outside of Matplotlib by referring to +## the module name (which must be in the PYTHONPATH) as 'module://my_backend'. +##backend: Agg + +## The port to use for the web server in the WebAgg backend. +#webagg.port: 8988 + +## The address on which the WebAgg web server should be reachable +#webagg.address: 127.0.0.1 + +## If webagg.port is unavailable, a number of other random ports will +## be tried until one that is available is found. +#webagg.port_retries: 50 + +## When True, open the web browser to the plot that is shown +#webagg.open_in_browser: True + +## If you are running pyplot inside a GUI and your backend choice +## conflicts, we will automatically try to find a compatible one for +## you if backend_fallback is True +#backend_fallback: True + +#interactive: False +#figure.hooks: # list of dotted.module.name:dotted.callable.name +#toolbar: toolbar2 # {None, toolbar2, toolmanager} +#timezone: UTC # a pytz timezone string, e.g., US/Central or Europe/Paris + + +## *************************************************************************** +## * LINES * +## *************************************************************************** +## See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.lines +## for more information on line properties. +#lines.linewidth: 1.5 # line width in points +#lines.linestyle: - # solid line +#lines.color: C0 # has no affect on plot(); see axes.prop_cycle +#lines.marker: None # the default marker +#lines.markerfacecolor: auto # the default marker face color +#lines.markeredgecolor: auto # the default marker edge color +#lines.markeredgewidth: 1.0 # the line width around the marker symbol +#lines.markersize: 6 # marker size, in points +#lines.dash_joinstyle: round # {miter, round, bevel} +#lines.dash_capstyle: butt # {butt, round, projecting} +#lines.solid_joinstyle: round # {miter, round, bevel} +#lines.solid_capstyle: projecting # {butt, round, projecting} +#lines.antialiased: True # render lines in antialiased (no jaggies) + +## The three standard dash patterns. These are scaled by the linewidth. +#lines.dashed_pattern: 3.7, 1.6 +#lines.dashdot_pattern: 6.4, 1.6, 1, 1.6 +#lines.dotted_pattern: 1, 1.65 +#lines.scale_dashes: True + +#markers.fillstyle: full # {full, left, right, bottom, top, none} + +#pcolor.shading: auto +#pcolormesh.snap: True # Whether to snap the mesh to pixel boundaries. This is + # provided solely to allow old test images to remain + # unchanged. Set to False to obtain the previous behavior. + +## *************************************************************************** +## * PATCHES * +## *************************************************************************** +## Patches are graphical objects that fill 2D space, like polygons or circles. +## See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.patches +## for more information on patch properties. +#patch.linewidth: 1.0 # edge width in points. +#patch.facecolor: C0 +#patch.edgecolor: black # if forced, or patch is not filled +#patch.force_edgecolor: False # True to always use edgecolor +#patch.antialiased: True # render patches in antialiased (no jaggies) + + +## *************************************************************************** +## * HATCHES * +## *************************************************************************** +#hatch.color: black +#hatch.linewidth: 1.0 + + +## *************************************************************************** +## * BOXPLOT * +## *************************************************************************** +#boxplot.notch: False +#boxplot.vertical: True +#boxplot.whiskers: 1.5 +#boxplot.bootstrap: None +#boxplot.patchartist: False +#boxplot.showmeans: False +#boxplot.showcaps: True +#boxplot.showbox: True +#boxplot.showfliers: True +#boxplot.meanline: False + +#boxplot.flierprops.color: black +#boxplot.flierprops.marker: o +#boxplot.flierprops.markerfacecolor: none +#boxplot.flierprops.markeredgecolor: black +#boxplot.flierprops.markeredgewidth: 1.0 +#boxplot.flierprops.markersize: 6 +#boxplot.flierprops.linestyle: none +#boxplot.flierprops.linewidth: 1.0 + +#boxplot.boxprops.color: black +#boxplot.boxprops.linewidth: 1.0 +#boxplot.boxprops.linestyle: - + +#boxplot.whiskerprops.color: black +#boxplot.whiskerprops.linewidth: 1.0 +#boxplot.whiskerprops.linestyle: - + +#boxplot.capprops.color: black +#boxplot.capprops.linewidth: 1.0 +#boxplot.capprops.linestyle: - + +#boxplot.medianprops.color: C1 +#boxplot.medianprops.linewidth: 1.0 +#boxplot.medianprops.linestyle: - + +#boxplot.meanprops.color: C2 +#boxplot.meanprops.marker: ^ +#boxplot.meanprops.markerfacecolor: C2 +#boxplot.meanprops.markeredgecolor: C2 +#boxplot.meanprops.markersize: 6 +#boxplot.meanprops.linestyle: -- +#boxplot.meanprops.linewidth: 1.0 + + +## *************************************************************************** +## * FONT * +## *************************************************************************** +## The font properties used by `text.Text`. +## See https://matplotlib.org/stable/api/font_manager_api.html for more information +## on font properties. The 6 font properties used for font matching are +## given below with their default values. +## +## The font.family property can take either a single or multiple entries of any +## combination of concrete font names (not supported when rendering text with +## usetex) or the following five generic values: +## - 'serif' (e.g., Times), +## - 'sans-serif' (e.g., Helvetica), +## - 'cursive' (e.g., Zapf-Chancery), +## - 'fantasy' (e.g., Western), and +## - 'monospace' (e.g., Courier). +## Each of these values has a corresponding default list of font names +## (font.serif, etc.); the first available font in the list is used. Note that +## for font.serif, font.sans-serif, and font.monospace, the first element of +## the list (a DejaVu font) will always be used because DejaVu is shipped with +## Matplotlib and is thus guaranteed to be available; the other entries are +## left as examples of other possible values. +## +## The font.style property has three values: normal (or roman), italic +## or oblique. The oblique style will be used for italic, if it is not +## present. +## +## The font.variant property has two values: normal or small-caps. For +## TrueType fonts, which are scalable fonts, small-caps is equivalent +## to using a font size of 'smaller', or about 83 % of the current font +## size. +## +## The font.weight property has effectively 13 values: normal, bold, +## bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as +## 400, and bold is 700. bolder and lighter are relative values with +## respect to the current weight. +## +## The font.stretch property has 11 values: ultra-condensed, +## extra-condensed, condensed, semi-condensed, normal, semi-expanded, +## expanded, extra-expanded, ultra-expanded, wider, and narrower. This +## property is not currently implemented. +## +## The font.size property is the default font size for text, given in points. +## 10 pt is the standard value. +## +## Note that font.size controls default text sizes. To configure +## special text sizes tick labels, axes, labels, title, etc., see the rc +## settings for axes and ticks. Special text sizes can be defined +## relative to font.size, using the following values: xx-small, x-small, +## small, medium, large, x-large, xx-large, larger, or smaller + +#font.family: sans-serif +#font.style: normal +#font.variant: normal +#font.weight: normal +#font.stretch: normal +#font.size: 10.0 + +#font.serif: DejaVu Serif, Bitstream Vera Serif, Computer Modern Roman, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif +#font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif +#font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, Comic Neue, Comic Sans MS, cursive +#font.fantasy: Chicago, Charcoal, Impact, Western, xkcd script, fantasy +#font.monospace: DejaVu Sans Mono, Bitstream Vera Sans Mono, Computer Modern Typewriter, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace + + +## *************************************************************************** +## * TEXT * +## *************************************************************************** +## The text properties used by `text.Text`. +## See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.text +## for more information on text properties +#text.color: black + +## FreeType hinting flag ("foo" corresponds to FT_LOAD_FOO); may be one of the +## following (Proprietary Matplotlib-specific synonyms are given in parentheses, +## but their use is discouraged): +## - default: Use the font's native hinter if possible, else FreeType's auto-hinter. +## ("either" is a synonym). +## - no_autohint: Use the font's native hinter if possible, else don't hint. +## ("native" is a synonym.) +## - force_autohint: Use FreeType's auto-hinter. ("auto" is a synonym.) +## - no_hinting: Disable hinting. ("none" is a synonym.) +#text.hinting: force_autohint + +#text.hinting_factor: 8 # Specifies the amount of softness for hinting in the + # horizontal direction. A value of 1 will hint to full + # pixels. A value of 2 will hint to half pixels etc. +#text.kerning_factor: 0 # Specifies the scaling factor for kerning values. This + # is provided solely to allow old test images to remain + # unchanged. Set to 6 to obtain previous behavior. + # Values other than 0 or 6 have no defined meaning. +#text.antialiased: True # If True (default), the text will be antialiased. + # This only affects raster outputs. +#text.parse_math: True # Use mathtext if there is an even number of unescaped + # dollar signs. + + +## *************************************************************************** +## * LaTeX * +## *************************************************************************** +## For more information on LaTeX properties, see +## https://matplotlib.org/stable/users/explain/text/usetex.html +#text.usetex: False # use latex for all text handling. The following fonts + # are supported through the usual rc parameter settings: + # new century schoolbook, bookman, times, palatino, + # zapf chancery, charter, serif, sans-serif, helvetica, + # avant garde, courier, monospace, computer modern roman, + # computer modern sans serif, computer modern typewriter +#text.latex.preamble: # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES + # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP + # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. + # text.latex.preamble is a single line of LaTeX code that + # will be passed on to the LaTeX system. It may contain + # any code that is valid for the LaTeX "preamble", i.e. + # between the "\documentclass" and "\begin{document}" + # statements. + # Note that it has to be put on a single line, which may + # become quite long. + # The following packages are always loaded with usetex, + # so beware of package collisions: + # geometry, inputenc, type1cm. + # PostScript (PSNFSS) font packages may also be + # loaded, depending on your font settings. + +## The following settings allow you to select the fonts in math mode. +#mathtext.fontset: dejavusans # Should be 'dejavusans' (default), + # 'dejavuserif', 'cm' (Computer Modern), 'stix', + # 'stixsans' or 'custom' +## "mathtext.fontset: custom" is defined by the mathtext.bf, .cal, .it, ... +## settings which map a TeX font name to a fontconfig font pattern. (These +## settings are not used for other font sets.) +#mathtext.bf: sans:bold +#mathtext.bfit: sans:italic:bold +#mathtext.cal: cursive +#mathtext.it: sans:italic +#mathtext.rm: sans +#mathtext.sf: sans +#mathtext.tt: monospace +#mathtext.fallback: cm # Select fallback font from ['cm' (Computer Modern), 'stix' + # 'stixsans'] when a symbol cannot be found in one of the + # custom math fonts. Select 'None' to not perform fallback + # and replace the missing character by a dummy symbol. +#mathtext.default: it # The default font to use for math. + # Can be any of the LaTeX font names, including + # the special name "regular" for the same font + # used in regular text. + + +## *************************************************************************** +## * AXES * +## *************************************************************************** +## Following are default face and edge colors, default tick sizes, +## default font sizes for tick labels, and so on. See +## https://matplotlib.org/stable/api/axes_api.html#module-matplotlib.axes +#axes.facecolor: white # axes background color +#axes.edgecolor: black # axes edge color +#axes.linewidth: 0.8 # edge line width +#axes.grid: False # display grid or not +#axes.grid.axis: both # which axis the grid should apply to +#axes.grid.which: major # grid lines at {major, minor, both} ticks +#axes.titlelocation: center # alignment of the title: {left, right, center} +#axes.titlesize: large # font size of the axes title +#axes.titleweight: normal # font weight of title +#axes.titlecolor: auto # color of the axes title, auto falls back to + # text.color as default value +#axes.titley: None # position title (axes relative units). None implies auto +#axes.titlepad: 6.0 # pad between axes and title in points +#axes.labelsize: medium # font size of the x and y labels +#axes.labelpad: 4.0 # space between label and axis +#axes.labelweight: normal # weight of the x and y labels +#axes.labelcolor: black +#axes.axisbelow: line # draw axis gridlines and ticks: + # - below patches (True) + # - above patches but below lines ('line') + # - above all (False) + +#axes.formatter.limits: -5, 6 # use scientific notation if log10 + # of the axis range is smaller than the + # first or larger than the second +#axes.formatter.use_locale: False # When True, format tick labels + # according to the user's locale. + # For example, use ',' as a decimal + # separator in the fr_FR locale. +#axes.formatter.use_mathtext: False # When True, use mathtext for scientific + # notation. +#axes.formatter.min_exponent: 0 # minimum exponent to format in scientific notation +#axes.formatter.useoffset: True # If True, the tick label formatter + # will default to labeling ticks relative + # to an offset when the data range is + # small compared to the minimum absolute + # value of the data. +#axes.formatter.offset_threshold: 4 # When useoffset is True, the offset + # will be used when it can remove + # at least this number of significant + # digits from tick labels. + +#axes.spines.left: True # display axis spines +#axes.spines.bottom: True +#axes.spines.top: True +#axes.spines.right: True + +#axes.unicode_minus: True # use Unicode for the minus symbol rather than hyphen. See + # https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes +#axes.prop_cycle: cycler('color', ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', '9467bd', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf']) + # color cycle for plot lines as list of string color specs: + # single letter, long name, or web-style hex + # As opposed to all other parameters in this file, the color + # values must be enclosed in quotes for this parameter, + # e.g. '1f77b4', instead of 1f77b4. + # See also https://matplotlib.org/stable/users/explain/artists/color_cycle.html + # for more details on prop_cycle usage. +#axes.xmargin: .05 # x margin. See `axes.Axes.margins` +#axes.ymargin: .05 # y margin. See `axes.Axes.margins` +#axes.zmargin: .05 # z margin. See `axes.Axes.margins` +#axes.autolimit_mode: data # If "data", use axes.xmargin and axes.ymargin as is. + # If "round_numbers", after application of margins, axis + # limits are further expanded to the nearest "round" number. +#polaraxes.grid: True # display grid on polar axes +#axes3d.grid: True # display grid on 3D axes +#axes3d.automargin: False # automatically add margin when manually setting 3D axis limits + +#axes3d.xaxis.panecolor: (0.95, 0.95, 0.95, 0.5) # background pane on 3D axes +#axes3d.yaxis.panecolor: (0.90, 0.90, 0.90, 0.5) # background pane on 3D axes +#axes3d.zaxis.panecolor: (0.925, 0.925, 0.925, 0.5) # background pane on 3D axes + +## *************************************************************************** +## * AXIS * +## *************************************************************************** +#xaxis.labellocation: center # alignment of the xaxis label: {left, right, center} +#yaxis.labellocation: center # alignment of the yaxis label: {bottom, top, center} + + +## *************************************************************************** +## * DATES * +## *************************************************************************** +## These control the default format strings used in AutoDateFormatter. +## Any valid format datetime format string can be used (see the python +## `datetime` for details). For example, by using: +## - '%x' will use the locale date representation +## - '%X' will use the locale time representation +## - '%c' will use the full locale datetime representation +## These values map to the scales: +## {'year': 365, 'month': 30, 'day': 1, 'hour': 1/24, 'minute': 1 / (24 * 60)} + +#date.autoformatter.year: %Y +#date.autoformatter.month: %Y-%m +#date.autoformatter.day: %Y-%m-%d +#date.autoformatter.hour: %m-%d %H +#date.autoformatter.minute: %d %H:%M +#date.autoformatter.second: %H:%M:%S +#date.autoformatter.microsecond: %M:%S.%f +## The reference date for Matplotlib's internal date representation +## See https://matplotlib.org/stable/gallery/ticks/date_precision_and_epochs.html +#date.epoch: 1970-01-01T00:00:00 +## 'auto', 'concise': +#date.converter: auto +## For auto converter whether to use interval_multiples: +#date.interval_multiples: True + +## *************************************************************************** +## * TICKS * +## *************************************************************************** +## See https://matplotlib.org/stable/api/axis_api.html#matplotlib.axis.Tick +#xtick.top: False # draw ticks on the top side +#xtick.bottom: True # draw ticks on the bottom side +#xtick.labeltop: False # draw label on the top +#xtick.labelbottom: True # draw label on the bottom +#xtick.major.size: 3.5 # major tick size in points +#xtick.minor.size: 2 # minor tick size in points +#xtick.major.width: 0.8 # major tick width in points +#xtick.minor.width: 0.6 # minor tick width in points +#xtick.major.pad: 3.5 # distance to major tick label in points +#xtick.minor.pad: 3.4 # distance to the minor tick label in points +#xtick.color: black # color of the ticks +#xtick.labelcolor: inherit # color of the tick labels or inherit from xtick.color +#xtick.labelsize: medium # font size of the tick labels +#xtick.direction: out # direction: {in, out, inout} +#xtick.minor.visible: False # visibility of minor ticks on x-axis +#xtick.major.top: True # draw x axis top major ticks +#xtick.major.bottom: True # draw x axis bottom major ticks +#xtick.minor.top: True # draw x axis top minor ticks +#xtick.minor.bottom: True # draw x axis bottom minor ticks +#xtick.minor.ndivs: auto # number of minor ticks between the major ticks on x-axis +#xtick.alignment: center # alignment of xticks + +#ytick.left: True # draw ticks on the left side +#ytick.right: False # draw ticks on the right side +#ytick.labelleft: True # draw tick labels on the left side +#ytick.labelright: False # draw tick labels on the right side +#ytick.major.size: 3.5 # major tick size in points +#ytick.minor.size: 2 # minor tick size in points +#ytick.major.width: 0.8 # major tick width in points +#ytick.minor.width: 0.6 # minor tick width in points +#ytick.major.pad: 3.5 # distance to major tick label in points +#ytick.minor.pad: 3.4 # distance to the minor tick label in points +#ytick.color: black # color of the ticks +#ytick.labelcolor: inherit # color of the tick labels or inherit from ytick.color +#ytick.labelsize: medium # font size of the tick labels +#ytick.direction: out # direction: {in, out, inout} +#ytick.minor.visible: False # visibility of minor ticks on y-axis +#ytick.major.left: True # draw y axis left major ticks +#ytick.major.right: True # draw y axis right major ticks +#ytick.minor.left: True # draw y axis left minor ticks +#ytick.minor.right: True # draw y axis right minor ticks +#ytick.minor.ndivs: auto # number of minor ticks between the major ticks on y-axis +#ytick.alignment: center_baseline # alignment of yticks + + +## *************************************************************************** +## * GRIDS * +## *************************************************************************** +#grid.color: "#b0b0b0" # grid color +#grid.linestyle: - # solid +#grid.linewidth: 0.8 # in points +#grid.alpha: 1.0 # transparency, between 0.0 and 1.0 + + +## *************************************************************************** +## * LEGEND * +## *************************************************************************** +#legend.loc: best +#legend.frameon: True # if True, draw the legend on a background patch +#legend.framealpha: 0.8 # legend patch transparency +#legend.facecolor: inherit # inherit from axes.facecolor; or color spec +#legend.edgecolor: 0.8 # background patch boundary color +#legend.fancybox: True # if True, use a rounded box for the + # legend background, else a rectangle +#legend.shadow: False # if True, give background a shadow effect +#legend.numpoints: 1 # the number of marker points in the legend line +#legend.scatterpoints: 1 # number of scatter points +#legend.markerscale: 1.0 # the relative size of legend markers vs. original +#legend.fontsize: medium +#legend.labelcolor: None +#legend.title_fontsize: None # None sets to the same as the default axes. + +## Dimensions as fraction of font size: +#legend.borderpad: 0.4 # border whitespace +#legend.labelspacing: 0.5 # the vertical space between the legend entries +#legend.handlelength: 2.0 # the length of the legend lines +#legend.handleheight: 0.7 # the height of the legend handle +#legend.handletextpad: 0.8 # the space between the legend line and legend text +#legend.borderaxespad: 0.5 # the border between the axes and legend edge +#legend.columnspacing: 2.0 # column separation + + +## *************************************************************************** +## * FIGURE * +## *************************************************************************** +## See https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure +#figure.titlesize: large # size of the figure title (``Figure.suptitle()``) +#figure.titleweight: normal # weight of the figure title +#figure.labelsize: large # size of the figure label (``Figure.sup[x|y]label()``) +#figure.labelweight: normal # weight of the figure label +#figure.figsize: 6.4, 4.8 # figure size in inches +#figure.dpi: 100 # figure dots per inch +#figure.facecolor: white # figure face color +#figure.edgecolor: white # figure edge color +#figure.frameon: True # enable figure frame +#figure.max_open_warning: 20 # The maximum number of figures to open through + # the pyplot interface before emitting a warning. + # If less than one this feature is disabled. +#figure.raise_window : True # Raise the GUI window to front when show() is called. + +## The figure subplot parameters. All dimensions are a fraction of the figure width and height. +#figure.subplot.left: 0.125 # the left side of the subplots of the figure +#figure.subplot.right: 0.9 # the right side of the subplots of the figure +#figure.subplot.bottom: 0.11 # the bottom of the subplots of the figure +#figure.subplot.top: 0.88 # the top of the subplots of the figure +#figure.subplot.wspace: 0.2 # the amount of width reserved for space between subplots, + # expressed as a fraction of the average axis width +#figure.subplot.hspace: 0.2 # the amount of height reserved for space between subplots, + # expressed as a fraction of the average axis height + +## Figure layout +#figure.autolayout: False # When True, automatically adjust subplot + # parameters to make the plot fit the figure + # using `tight_layout` +#figure.constrained_layout.use: False # When True, automatically make plot + # elements fit on the figure. (Not + # compatible with `autolayout`, above). +## Padding (in inches) around axes; defaults to 3/72 inches, i.e. 3 points. +#figure.constrained_layout.h_pad: 0.04167 +#figure.constrained_layout.w_pad: 0.04167 +## Spacing between subplots, relative to the subplot sizes. Much smaller than for +## tight_layout (figure.subplot.hspace, figure.subplot.wspace) as constrained_layout +## already takes surrounding texts (titles, labels, # ticklabels) into account. +#figure.constrained_layout.hspace: 0.02 +#figure.constrained_layout.wspace: 0.02 + + +## *************************************************************************** +## * IMAGES * +## *************************************************************************** +#image.aspect: equal # {equal, auto} or a number +#image.interpolation: antialiased # see help(imshow) for options +#image.interpolation_stage: data # see help(imshow) for options +#image.cmap: viridis # A colormap name (plasma, magma, etc.) +#image.lut: 256 # the size of the colormap lookup table +#image.origin: upper # {lower, upper} +#image.resample: True +#image.composite_image: True # When True, all the images on a set of axes are + # combined into a single composite image before + # saving a figure as a vector graphics file, + # such as a PDF. + + +## *************************************************************************** +## * CONTOUR PLOTS * +## *************************************************************************** +#contour.negative_linestyle: dashed # string or on-off ink sequence +#contour.corner_mask: True # {True, False} +#contour.linewidth: None # {float, None} Size of the contour line + # widths. If set to None, it falls back to + # `line.linewidth`. +#contour.algorithm: mpl2014 # {mpl2005, mpl2014, serial, threaded} + + +## *************************************************************************** +## * ERRORBAR PLOTS * +## *************************************************************************** +#errorbar.capsize: 0 # length of end cap on error bars in pixels + + +## *************************************************************************** +## * HISTOGRAM PLOTS * +## *************************************************************************** +#hist.bins: 10 # The default number of histogram bins or 'auto'. + + +## *************************************************************************** +## * SCATTER PLOTS * +## *************************************************************************** +#scatter.marker: o # The default marker type for scatter plots. +#scatter.edgecolors: face # The default edge colors for scatter plots. + + +## *************************************************************************** +## * AGG RENDERING * +## *************************************************************************** +## Warning: experimental, 2008/10/10 +#agg.path.chunksize: 0 # 0 to disable; values in the range + # 10000 to 100000 can improve speed slightly + # and prevent an Agg rendering failure + # when plotting very large data sets, + # especially if they are very gappy. + # It may cause minor artifacts, though. + # A value of 20000 is probably a good + # starting point. + + +## *************************************************************************** +## * PATHS * +## *************************************************************************** +#path.simplify: True # When True, simplify paths by removing "invisible" + # points to reduce file size and increase rendering + # speed +#path.simplify_threshold: 0.111111111111 # The threshold of similarity below + # which vertices will be removed in + # the simplification process. +#path.snap: True # When True, rectilinear axis-aligned paths will be snapped + # to the nearest pixel when certain criteria are met. + # When False, paths will never be snapped. +#path.sketch: None # May be None, or a tuple of the form: + # path.sketch: (scale, length, randomness) + # - *scale* is the amplitude of the wiggle + # perpendicular to the line (in pixels). + # - *length* is the length of the wiggle along the + # line (in pixels). + # - *randomness* is the factor by which the length is + # randomly scaled. +#path.effects: + + +## *************************************************************************** +## * SAVING FIGURES * +## *************************************************************************** +## The default savefig parameters can be different from the display parameters +## e.g., you may want a higher resolution, or to make the figure +## background white +#savefig.dpi: figure # figure dots per inch or 'figure' +#savefig.facecolor: auto # figure face color when saving +#savefig.edgecolor: auto # figure edge color when saving +#savefig.format: png # {png, ps, pdf, svg} +#savefig.bbox: standard # {tight, standard} + # 'tight' is incompatible with generating frames + # for animation +#savefig.pad_inches: 0.1 # padding to be used, when bbox is set to 'tight' +#savefig.directory: ~ # default directory in savefig dialog, gets updated after + # interactive saves, unless set to the empty string (i.e. + # the current directory); use '.' to start at the current + # directory but update after interactive saves +#savefig.transparent: False # whether figures are saved with a transparent + # background by default +#savefig.orientation: portrait # orientation of saved figure, for PostScript output only + +### macosx backend params +#macosx.window_mode : system # How to open new figures (system, tab, window) + # system uses the MacOS system preferences + +### tk backend params +#tk.window_focus: False # Maintain shell focus for TkAgg + +### ps backend params +#ps.papersize: letter # {figure, letter, legal, ledger, A0-A10, B0-B10} +#ps.useafm: False # use AFM fonts, results in small files +#ps.usedistiller: False # {ghostscript, xpdf, None} + # Experimental: may produce smaller files. + # xpdf intended for production of publication quality files, + # but requires ghostscript, xpdf and ps2eps +#ps.distiller.res: 6000 # dpi +#ps.fonttype: 3 # Output Type 3 (Type3) or Type 42 (TrueType) + +### PDF backend params +#pdf.compression: 6 # integer from 0 to 9 + # 0 disables compression (good for debugging) +#pdf.fonttype: 3 # Output Type 3 (Type3) or Type 42 (TrueType) +#pdf.use14corefonts: False +#pdf.inheritcolor: False + +### SVG backend params +#svg.image_inline: True # Write raster image data directly into the SVG file +#svg.fonttype: path # How to handle SVG fonts: + # path: Embed characters as paths -- supported + # by most SVG renderers + # None: Assume fonts are installed on the + # machine where the SVG will be viewed. +#svg.hashsalt: None # If not None, use this string as hash salt instead of uuid4 + +### pgf parameter +## See https://matplotlib.org/stable/tutorials/text/pgf.html for more information. +#pgf.rcfonts: True +#pgf.preamble: # See text.latex.preamble for documentation +#pgf.texsystem: xelatex + +### docstring params +#docstring.hardcopy: False # set this when you want to generate hardcopy docstring + + +## *************************************************************************** +## * INTERACTIVE KEYMAPS * +## *************************************************************************** +## Event keys to interact with figures/plots via keyboard. +## See https://matplotlib.org/stable/users/explain/interactive.html for more +## details on interactive navigation. Customize these settings according to +## your needs. Leave the field(s) empty if you don't need a key-map. (i.e., +## fullscreen : '') +#keymap.fullscreen: f, ctrl+f # toggling +#keymap.home: h, r, home # home or reset mnemonic +#keymap.back: left, c, backspace, MouseButton.BACK # forward / backward keys +#keymap.forward: right, v, MouseButton.FORWARD # for quick navigation +#keymap.pan: p # pan mnemonic +#keymap.zoom: o # zoom mnemonic +#keymap.save: s, ctrl+s # saving current figure +#keymap.help: f1 # display help about active tools +#keymap.quit: ctrl+w, cmd+w, q # close the current figure +#keymap.quit_all: # close all figures +#keymap.grid: g # switching on/off major grids in current axes +#keymap.grid_minor: G # switching on/off minor grids in current axes +#keymap.yscale: l # toggle scaling of y-axes ('log'/'linear') +#keymap.xscale: k, L # toggle scaling of x-axes ('log'/'linear') +#keymap.copy: ctrl+c, cmd+c # copy figure to clipboard + + +## *************************************************************************** +## * ANIMATION * +## *************************************************************************** +#animation.html: none # How to display the animation as HTML in + # the IPython notebook: + # - 'html5' uses HTML5 video tag + # - 'jshtml' creates a JavaScript animation +#animation.writer: ffmpeg # MovieWriter 'backend' to use +#animation.codec: h264 # Codec to use for writing movie +#animation.bitrate: -1 # Controls size/quality trade-off for movie. + # -1 implies let utility auto-determine +#animation.frame_format: png # Controls frame format used by temp files + +## Path to ffmpeg binary. Unqualified paths are resolved by subprocess.Popen. +#animation.ffmpeg_path: ffmpeg +## Additional arguments to pass to ffmpeg. +#animation.ffmpeg_args: + +## Path to ImageMagick's convert binary. Unqualified paths are resolved by +## subprocess.Popen, except that on Windows, we look up an install of +## ImageMagick in the registry (as convert is also the name of a system tool). +#animation.convert_path: convert +## Additional arguments to pass to convert. +#animation.convert_args: -layers, OptimizePlus +# +#animation.embed_limit: 20.0 # Limit, in MB, of size of base64 encoded + # animation in HTML (i.e. IPython notebook) diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/plot_directive/plot_directive.css b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/plot_directive/plot_directive.css new file mode 100644 index 00000000..d45593c9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/plot_directive/plot_directive.css @@ -0,0 +1,16 @@ +/* + * plot_directive.css + * ~~~~~~~~~~~~ + * + * Stylesheet controlling images created using the `plot` directive within + * Sphinx. + * + * :copyright: Copyright 2020-* by the Matplotlib development team. + * :license: Matplotlib, see LICENSE for details. + * + */ + +img.plot-directive { + border: 0; + max-width: 100%; +} diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/README.txt b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/README.txt new file mode 100644 index 00000000..75a53495 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/README.txt @@ -0,0 +1,2 @@ +This is the sample data needed for some of matplotlib's examples and +docs. See matplotlib.cbook.get_sample_data for more info. diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/Stocks.csv b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/Stocks.csv new file mode 100644 index 00000000..575d353d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/Stocks.csv @@ -0,0 +1,526 @@ +# Data source: https://finance.yahoo.com +Date,IBM,AAPL,MSFT,XRX,AMZN,DELL,GOOGL,ADBE,^GSPC,^IXIC +1990-01-01,10.970438003540039,0.24251236021518707,0.40375930070877075,11.202081680297852,,,,1.379060983657837,329.0799865722656,415.79998779296875 +1990-02-01,11.554415702819824,0.24251236021518707,0.43104037642478943,10.39472484588623,,,,1.7790844440460205,331.8900146484375,425.79998779296875 +1990-02-05,,,,,,,,,, +1990-03-01,11.951693534851074,0.28801724314689636,0.4834197461605072,11.394058227539062,,,,2.2348830699920654,339.94000244140625,435.5 +1990-04-01,12.275476455688477,0.2817564308643341,0.5063362717628479,10.139430046081543,,,,2.2531447410583496,330.79998779296875,420.1000061035156 +1990-05-01,13.514284133911133,0.295173317193985,0.6372847557067871,9.704153060913086,,,,2.0985164642333984,361.2300109863281,459.0 +1990-05-04,,,,,,,,,, +1990-06-01,13.380948066711426,0.3211067020893097,0.6634747385978699,9.749448776245117,,,,2.164785146713257,358.0199890136719,462.29998779296875 +1990-07-01,12.697657585144043,0.3013734817504883,0.5805402994155884,9.489465713500977,,,,2.069063901901245,356.1499938964844,438.20001220703125 +1990-08-01,11.601561546325684,0.26549553871154785,0.5368908047676086,8.553519248962402,,,,1.4750508069992065,322.55999755859375,381.20001220703125 +1990-08-06,,,,,,,,,, +1990-09-01,12.251119613647461,0.20872052013874054,0.5499854683876038,7.255113124847412,,,,1.1210384368896484,306.04998779296875,344.5 +1990-10-01,12.15034294128418,0.22131578624248505,0.5565334558486938,6.248927116394043,,,,1.416249394416809,304.0,329.79998779296875 +1990-11-01,13.08609390258789,0.26449888944625854,0.6307373642921448,7.361023426055908,,,,1.4900128841400146,322.2200012207031,359.1000061035156 +1990-11-05,,,,,,,,,, +1990-12-01,13.161062240600586,0.31051647663116455,0.6569272875785828,7.519896507263184,,,,1.7186784744262695,330.2200012207031,373.79998779296875 +1991-01-01,14.762505531311035,0.40078282356262207,0.8566243648529053,10.554410934448242,,,,2.242394208908081,343.92999267578125,414.20001220703125 +1991-02-01,14.995450973510742,0.4134202301502228,0.9057300686836243,12.286416053771973,,,,2.8402483463287354,367.07000732421875,453.1000061035156 +1991-02-04,,,,,,,,,, +1991-03-01,13.39067268371582,0.49208223819732666,0.92646324634552,12.511940002441406,,,,3.1869795322418213,375.2200012207031,482.29998779296875 +1991-04-01,12.111870765686035,0.39800751209259033,0.8642628788948059,12.511940002441406,,,,3.0589873790740967,375.3399963378906,484.7200012207031 +1991-05-01,12.479341506958008,0.34011581540107727,0.9581103920936584,12.73144817352295,,,,2.9850986003875732,389.8299865722656,506.1099853515625 +1991-05-06,,,,,,,,,, +1991-06-01,11.555957794189453,0.30108359456062317,0.89208984375,11.853414535522461,,,,2.5565452575683594,371.1600036621094,475.9200134277344 +1991-07-01,12.04675579071045,0.33554431796073914,0.9624748229980469,12.397871017456055,,,,3.1678967475891113,387.80999755859375,502.0400085449219 +1991-08-01,11.526222229003906,0.3845158815383911,1.1163398027420044,13.037229537963867,,,,3.012463331222534,395.42999267578125,525.6799926757812 +1991-08-06,,,,,,,,,, +1991-09-01,12.478833198547363,0.3599340617656708,1.1654454469680786,13.740047454833984,,,,3.0346662998199463,387.8599853515625,526.8800048828125 +1991-10-01,11.83155345916748,0.37447676062583923,1.2292828559875488,14.41578483581543,,,,3.1431360244750977,392.45001220703125,542.97998046875 +1991-11-01,11.139124870300293,0.36902356147766113,1.2734787464141846,13.965290069580078,,,,2.846613883972168,375.2200012207031,523.9000244140625 +1991-11-04,,,,,,,,,, +1991-12-01,10.851117134094238,0.4109107553958893,1.4568067789077759,15.42939281463623,,,,3.8844411373138428,417.0899963378906,586.3400268554688 +1992-01-01,10.973037719726562,0.4719553291797638,1.5746610164642334,17.584869384765625,,,,3.639812469482422,408.7799987792969,620.2100219726562 +1992-02-01,10.592026710510254,0.49199995398521423,1.61721932888031,18.04088020324707,,,,3.3547844886779785,412.70001220703125,633.469970703125 +1992-02-06,,,,,,,,,, +1992-03-01,10.317353248596191,0.4253714978694916,1.5517452955245972,16.302349090576172,,,,3.043056011199951,403.69000244140625,603.77001953125 +1992-04-01,11.213163375854492,0.43906375765800476,1.4437123537063599,17.062589645385742,,,,2.631263494491577,414.95001220703125,578.6799926757812 +1992-05-01,11.213163375854492,0.4363253116607666,1.5844820737838745,17.263996124267578,,,,2.705594062805176,415.3500061035156,585.3099975585938 +1992-05-07,,,,,,,,,, +1992-06-01,12.25231647491455,0.3505205810070038,1.3749638795852661,16.055517196655273,,,,2.705594062805176,408.1400146484375,563.5999755859375 +1992-07-01,11.861115455627441,0.34207984805107117,1.4289811849594116,17.38025665283203,,,,2.263554334640503,424.2099914550781,580.8300170898438 +1992-08-01,10.84400749206543,0.33659130334854126,1.4633547067642212,17.525571823120117,,,,1.9359338283538818,414.0299987792969,563.1199951171875 +1992-08-06,,,,,,,,,, +1992-09-01,10.243829727172852,0.3310767114162445,1.58120858669281,18.464359283447266,,,,1.6753284931182861,417.79998779296875,583.27001953125 +1992-10-01,8.483662605285645,0.38518592715263367,1.7432584762573242,17.436922073364258,,,,2.12785267829895,418.67999267578125,605.1699829101562 +1992-11-01,8.658098220825195,0.42187052965164185,1.8291932344436646,18.493711471557617,,,,2.030792474746704,431.3500061035156,652.72998046875 +1992-11-05,,,,,,,,,, +1992-12-01,6.505843639373779,0.43931084871292114,1.6769649982452393,18.788379669189453,,,,1.8814688920974731,435.7099914550781,676.9500122070312 +1993-01-01,6.651134490966797,0.43747296929359436,1.6990629434585571,20.329378128051758,,,,2.4787611961364746,438.7799987792969,696.3400268554688 +1993-02-01,7.022435188293457,0.38968151807785034,1.6376806497573853,19.618152618408203,,,,2.670894145965576,443.3800048828125,670.77001953125 +1993-02-04,,,,,,,,,, +1993-03-01,6.6405534744262695,0.37947842478752136,1.8169171810150146,19.766319274902344,,,,2.573633909225464,451.6700134277344,690.1300048828125 +1993-04-01,6.346868991851807,0.3776364326477051,1.6794201135635376,18.451818466186523,,,,3.434307336807251,440.19000244140625,661.4199829101562 +1993-05-01,6.885295867919922,0.4172421991825104,1.8193715810775757,18.12286949157715,,,,3.959200859069824,450.19000244140625,700.530029296875 +1993-05-06,,,,,,,,,, +1993-06-01,6.51603364944458,0.29166528582572937,1.7285257577896118,19.299583435058594,,,,3.7042527198791504,450.5299987792969,703.9500122070312 +1993-07-01,5.872671604156494,0.2049039751291275,1.453533411026001,17.638439178466797,,,,2.9742372035980225,448.1300048828125,704.7000122070312 +1993-08-01,6.037637233734131,0.19567380845546722,1.4756313562393188,17.759246826171875,,,,2.5536391735076904,463.55999755859375,742.8400268554688 +1993-08-05,,,,,,,,,, +1993-09-01,5.574150562286377,0.1733584851026535,1.620492935180664,17.849544525146484,,,,2.1931254863739014,458.92999267578125,762.780029296875 +1993-10-01,6.105024337768555,0.22805523872375488,1.5738422870635986,19.34462547302246,,,,2.6137242317199707,467.8299865722656,779.260009765625 +1993-11-01,7.150176048278809,0.2336171418428421,1.5713871717453003,20.107433319091797,,,,2.786593437194824,461.7900085449219,754.3900146484375 +1993-11-04,,,,,,,,,, +1993-12-01,7.535686016082764,0.21771006286144257,1.5836634635925293,22.01595687866211,,,,2.68115496635437,466.45001220703125,776.7999877929688 +1994-01-01,7.535686016082764,0.24376071989536285,1.672054648399353,24.171361923217773,,,,3.64516544342041,481.6099853515625,800.469970703125 +1994-02-01,7.052198886871338,0.27167221903800964,1.620492935180664,23.894229888916016,,,,3.5310842990875244,467.1400146484375,792.5 +1994-02-04,,,,,,,,,, +1994-03-01,7.31842041015625,0.24837146699428558,1.6646885871887207,23.706161499023438,,,,2.9274797439575195,445.7699890136719,743.4600219726562 +1994-04-01,7.703606128692627,0.22409436106681824,1.8169171810150146,24.543949127197266,,,,3.2354440689086914,450.9100036621094,733.8400268554688 +1994-05-01,8.440468788146973,0.21849241852760315,2.1115520000457764,24.947307586669922,,,,3.4773480892181396,456.5,735.1900024414062 +1994-05-05,,,,,,,,,, +1994-06-01,7.905290126800537,0.19873161613941193,2.028071165084839,24.444643020629883,,,,3.2959203720092773,444.2699890136719,705.9600219726562 +1994-07-01,8.325791358947754,0.2526327669620514,2.023160934448242,25.569963455200195,,,,3.756444215774536,458.260009765625,722.1599731445312 +1994-08-01,9.217235565185547,0.27138155698776245,2.2834222316741943,26.789077758789062,,,,3.847325563430786,475.489990234375,765.6199951171875 +1994-08-04,,,,,,,,,, +1994-09-01,9.405942916870117,0.25350791215896606,2.2048532962799072,26.88198471069336,,,,3.9382081031799316,462.7099914550781,764.2899780273438 +1994-10-01,10.064526557922363,0.324998676776886,2.474935293197632,25.811735153198242,,,,4.368794918060303,472.3500061035156,777.489990234375 +1994-11-01,9.557921409606934,0.28031668066978455,2.470024824142456,24.741479873657227,,,,4.004726409912109,453.69000244140625,750.3200073242188 +1994-11-04,,,,,,,,,, +1994-12-01,9.9633207321167,0.2943686842918396,2.401276111602783,25.12115478515625,,,,3.6103241443634033,459.2699890136719,751.9600219726562 +1995-01-01,9.77692985534668,0.3047473132610321,2.332528591156006,27.753808975219727,,,,3.5117223262786865,470.4200134277344,755.2000122070312 +1995-02-01,10.200541496276855,0.29814332723617554,2.474935293197632,28.13443946838379,,,,4.345465660095215,487.3900146484375,793.72998046875 +1995-02-06,,,,,,,,,, +1995-03-01,11.169903755187988,0.2667955756187439,2.7941226959228516,29.989917755126953,,,,6.016797065734863,500.7099914550781,817.2100219726562 +1995-04-01,12.870043754577637,0.2895018756389618,3.2115228176116943,31.52293586730957,,,,7.08742618560791,514.7100219726562,843.97998046875 +1995-05-01,12.649023056030273,0.31457316875457764,3.326920747756958,28.96788215637207,,,,6.326970100402832,533.4000244140625,864.5800170898438 +1995-05-04,,,,,,,,,, +1995-06-01,13.091790199279785,0.3524453043937683,3.5503528118133545,30.15083122253418,,,,7.057007789611816,544.75,933.4500122070312 +1995-07-01,14.847586631774902,0.3415350615978241,3.5552642345428467,30.697277069091797,,,,7.513277530670166,562.0599975585938,1001.2100219726562 +1995-08-01,14.09753131866455,0.32635587453842163,3.6338343620300293,31.08300018310547,,,,6.210629463195801,561.8800048828125,1020.1099853515625 +1995-08-08,,,,,,,,,, +1995-09-01,12.916881561279297,0.28348639607429504,3.5552642345428467,34.767181396484375,,,,6.301961898803711,584.4099731445312,1043.5400390625 +1995-10-01,13.292764663696289,0.27635207772254944,3.92846941947937,33.5381965637207,,,,6.941293239593506,581.5,1036.06005859375 +1995-11-01,13.207347869873047,0.2901458144187927,3.4226772785186768,35.478694915771484,,,,8.243063926696777,605.3699951171875,1059.199951171875 +1995-11-08,,,,,,,,,, +1995-12-01,12.52143669128418,0.24333631992340088,3.447230815887451,35.68303298950195,,,,7.557409763336182,615.9299926757812,1052.1300048828125 +1996-01-01,14.868143081665039,0.21089188754558563,3.6338343620300293,32.199371337890625,,,,4.14438533782959,636.02001953125,1059.7900390625 +1996-02-01,16.80373764038086,0.2099376916885376,3.876908779144287,33.924922943115234,,,,4.089058876037598,640.4299926757812,1100.050048828125 +1996-02-07,,,,,,,,,, +1996-03-01,15.278267860412598,0.1875123232603073,4.051232814788818,32.900360107421875,,,,3.936483860015869,645.5,1101.4000244140625 +1996-04-01,14.797598838806152,0.1860809624195099,4.448990821838379,38.40559768676758,,,,5.248644828796387,654.1699829101562,1190.52001953125 +1996-05-01,14.660264015197754,0.1994406133890152,4.6650567054748535,41.25652313232422,,,,4.538435459136963,669.1199951171875,1243.4300537109375 +1996-05-08,,,,,,,,,, +1996-06-01,13.641029357910156,0.1603158563375473,4.719073295593262,42.07575225830078,,,,4.385625839233398,670.6300048828125,1185.02001953125 +1996-07-01,14.812233924865723,0.1679503321647644,4.630680561065674,39.836021423339844,,,,3.7132644653320312,639.9500122070312,1080.5899658203125 +1996-08-01,15.759532928466797,0.18512675166130066,4.812370777130127,43.394588470458984,,,,4.269299030303955,651.989990234375,1141.5 +1996-08-07,,,,,,,,,, +1996-09-01,17.209583282470703,0.16938161849975586,5.180670261383057,42.40607833862305,,,,4.5600385665893555,687.3300170898438,1226.9200439453125 +1996-10-01,17.831613540649414,0.17558389902114868,5.391822814941406,36.86507034301758,,,,4.244296073913574,705.27001953125,1221.510009765625 +1996-11-01,22.03032875061035,0.184172585606575,6.162785530090332,38.95176315307617,,,,4.841867923736572,757.02001953125,1292.6099853515625 +1996-11-06,,,,,,,,,, +1996-12-01,20.998197555541992,0.15936164557933807,6.491794109344482,41.83340072631836,,,,4.581387996673584,740.739990234375,1291.030029296875 +1997-01-01,21.743183135986328,0.12691716849803925,8.01407527923584,46.8797492980957,,,,4.642676830291748,786.1599731445312,1379.8499755859375 +1997-02-01,19.924028396606445,0.1240537017583847,7.660515785217285,49.97840881347656,,,,4.47982120513916,790.8200073242188,1309.0 +1997-02-06,,,,,,,,,, +1997-03-01,19.067983627319336,0.13932174444198608,7.203826904296875,45.4803581237793,,,,4.924733638763428,757.1199951171875,1221.699951171875 +1997-04-01,22.298084259033203,0.12977975606918335,9.546177864074707,49.431339263916016,,,,4.807621955871582,801.3400268554688,1260.760009765625 +1997-05-01,24.034704208374023,0.12691716849803925,9.742606163024902,54.45485305786133,,,,5.483453750610352,848.280029296875,1400.3199462890625 +1997-05-07,,,,,,,,,, +1997-05-28,,,,,,,,,, +1997-06-01,25.13742446899414,0.10878564417362213,9.929201126098633,63.396705627441406,0.07708299905061722,,,4.3084282875061035,885.1400146484375,1442.0699462890625 +1997-07-01,29.45465660095215,0.1335965245962143,11.107746124267578,66.42845916748047,0.11979199945926666,,,4.592585563659668,954.3099975585938,1593.81005859375 +1997-08-01,28.23609161376953,0.1660410314798355,10.385887145996094,60.97687911987305,0.11692699790000916,,,4.851738929748535,899.469970703125,1587.3199462890625 +1997-08-07,,,,,,,,,, +1997-09-01,29.579116821289062,0.16556398570537567,10.395710945129395,67.9932632446289,0.21692700684070587,,,6.2071452140808105,947.280029296875,1685.68994140625 +1997-10-01,27.48627281188965,0.13001829385757446,10.214018821716309,64.32245635986328,0.25416699051856995,,,5.889601707458496,914.6199951171875,1593.6099853515625 +1997-11-01,30.555805206298828,0.13550494611263275,11.117568969726562,63.00460433959961,0.20624999701976776,,,5.180382251739502,955.4000244140625,1600.550048828125 +1997-11-06,,,,,,,,,, +1997-12-01,29.25237274169922,0.10019782930612564,10.155089378356934,59.91267013549805,0.2510420083999634,,,5.087874889373779,970.4299926757812,1570.3499755859375 +1998-01-01,27.609769821166992,0.1397988647222519,11.721570014953613,65.44635009765625,0.24583299458026886,,,4.750911235809326,980.280029296875,1619.3599853515625 +1998-02-01,29.19993782043457,0.1803557574748993,13.317505836486816,72.36756134033203,0.3208329975605011,,,5.452751159667969,1049.3399658203125,1770.510009765625 +1998-02-06,,,,,,,,,, +1998-03-01,29.10112953186035,0.2099376916885376,14.06391716003418,86.66805267333984,0.35637998580932617,,,5.576151371002197,1101.75,1835.6800537109375 +1998-04-01,32.4630012512207,0.20898354053497314,14.162128448486328,92.79229736328125,0.3822920024394989,,,6.177727699279785,1111.75,1868.4100341796875 +1998-05-01,32.918251037597656,0.2032574564218521,13.327329635620117,84.10579681396484,0.3671880066394806,,,4.930263519287109,1090.8199462890625,1778.8699951171875 +1998-05-06,,,,,,,,,, +1998-06-01,32.225502014160156,0.2190026193857193,17.029911041259766,83.08383178710938,0.831250011920929,,,5.238887786865234,1133.8399658203125,1894.739990234375 +1998-07-01,37.19002914428711,0.26433059573173523,17.27544403076172,86.6082992553711,0.9239580035209656,,,3.988961935043335,1120.6700439453125,1872.3900146484375 +1998-08-01,31.611520767211914,0.23808826506137848,15.075493812561035,72.04536437988281,0.6979169845581055,,,3.2419238090515137,957.280029296875,1499.25 +1998-08-06,,,,,,,,,, +1998-09-01,36.12905502319336,0.2910497486591339,17.295076370239258,69.53275299072266,0.9302080273628235,,,4.283971786499023,1017.010009765625,1693.8399658203125 +1998-10-01,41.75224685668945,0.2834153473377228,16.637067794799805,80.36154174804688,1.0536459684371948,,,4.59221076965332,1098.6700439453125,1771.3900146484375 +1998-11-01,46.4265251159668,0.2438134402036667,19.170928955078125,88.54693603515625,1.600000023841858,,,5.535391330718994,1163.6300048828125,1949.5400390625 +1998-11-06,,,,,,,,,, +1998-12-01,51.91548538208008,0.3125200569629669,21.793180465698242,97.19573974609375,2.6770830154418945,,,5.782783031463623,1229.22998046875,2192.68994140625 +1999-01-01,51.59874725341797,0.3144294023513794,27.499271392822266,102.47120666503906,2.92343807220459,,,5.912916660308838,1279.6400146484375,2505.889892578125 +1999-02-01,47.797481536865234,0.2657618522644043,23.5904541015625,91.21175384521484,3.203125,,,4.984185218811035,1238.3299560546875,2288.030029296875 +1999-02-08,,,,,,,,,, +1999-03-01,49.97552490234375,0.27435049414634705,28.16712188720703,88.21611785888672,4.304687976837158,,,7.027392387390137,1286.3699951171875,2461.39990234375 +1999-04-01,58.98025894165039,0.35116779804229736,25.554689407348633,97.44929504394531,4.301562786102295,,,7.854666709899902,1335.1800537109375,2542.860107421875 +1999-05-01,65.41220092773438,0.3363769054412842,25.35825538635254,93.19886779785156,2.96875,,,9.187017440795898,1301.8399658203125,2470.52001953125 +1999-05-06,,,,,,,,,, +1999-05-27,,,,,,,,,, +1999-06-01,72.96644592285156,0.35355332493782043,28.343910217285156,97.96764373779297,3.128124952316284,,,10.182408332824707,1372.7099609375,2686.1201171875 +1999-07-01,70.95524597167969,0.4251234233379364,26.96893310546875,81.35432434082031,2.50156307220459,,,10.634023666381836,1328.719970703125,2638.489990234375 +1999-08-01,70.32015991210938,0.49812400341033936,29.090301513671875,79.7938461303711,3.109375,,,12.354691505432129,1320.4100341796875,2739.35009765625 +1999-08-06,,,,,,,,,, +1999-09-01,68.37564849853516,0.48333317041397095,28.46175193786621,69.8066177368164,3.996875047683716,,,14.07535457611084,1282.7099609375,2746.159912109375 +1999-10-01,55.519859313964844,0.6116815209388733,29.090301513671875,47.42917251586914,3.53125,,,17.35419464111328,1362.9300537109375,2966.429931640625 +1999-11-01,58.239349365234375,0.747186541557312,28.613975524902344,45.75767135620117,4.253125190734863,,,17.044021606445312,1388.9100341796875,3336.159912109375 +1999-11-08,,,,,,,,,, +1999-12-01,61.04003143310547,0.7848799824714661,36.6919059753418,37.92245101928711,3.8062500953674316,,,16.687326431274414,1469.25,4069.31005859375 +2000-01-01,63.515560150146484,0.7920366525650024,30.75990104675293,35.14961242675781,3.2281250953674316,,,13.668244361877441,1394.4599609375,3940.35009765625 +2000-02-01,58.14006042480469,0.8750578165054321,28.088550567626953,36.62297058105469,3.4437499046325684,,,25.31960105895996,1366.4200439453125,4696.68994140625 +2000-02-08,,,,,,,,,, +2000-03-01,67.05181884765625,1.0368047952651978,33.39197540283203,43.779178619384766,3.3499999046325684,,,27.631258010864258,1498.5799560546875,4572.830078125 +2000-04-01,63.157623291015625,0.947104275226593,21.920852661132812,45.03520965576172,2.7593750953674316,,,30.027847290039062,1452.4300537109375,3860.659912109375 +2000-05-01,60.785640716552734,0.6412634253501892,19.661985397338867,46.097347259521484,2.4156250953674316,,,27.948402404785156,1420.5999755859375,3400.909912109375 +2000-05-08,,,,,,,,,, +2000-06-01,62.13500213623047,0.7996708750724792,25.142194747924805,35.529056549072266,1.8156249523162842,,,32.277984619140625,1454.5999755859375,3966.110107421875 +2000-07-01,63.65913009643555,0.7758141756057739,21.940492630004883,25.79067039489746,1.506250023841858,,,28.43518829345703,1430.8299560546875,3766.989990234375 +2000-08-01,74.86860656738281,0.9304049015045166,21.940492630004883,27.82395362854004,2.075000047683716,,,32.28449630737305,1517.6800537109375,4206.35009765625 +2000-08-08,,,,,,,,,, +2000-09-01,63.94328689575195,0.3931553065776825,18.95485496520996,25.980575561523438,1.921875,,,38.555137634277344,1436.510009765625,3672.820068359375 +2000-10-01,55.92375183105469,0.29868337512016296,21.645862579345703,14.6140718460083,1.8312499523162842,,,37.785430908203125,1429.4000244140625,3369.6298828125 +2000-11-01,53.08496856689453,0.2519250810146332,18.03167152404785,12.016016960144043,1.234375,,,31.482683181762695,1314.949951171875,2597.929931640625 +2000-11-08,,,,,,,,,, +2000-12-01,48.32046127319336,0.22711420059204102,13.631781578063965,8.067792892456055,0.778124988079071,,,28.90570068359375,1320.280029296875,2470.52001953125 +2001-01-01,63.6693229675293,0.33017459511756897,19.190568923950195,14.251648902893066,0.8656250238418579,,,21.702556610107422,1366.010009765625,2772.72998046875 +2001-02-01,56.790767669677734,0.2786443829536438,18.54237174987793,10.536102294921875,0.5093749761581421,,,14.440549850463867,1239.93994140625,2151.830078125 +2001-02-07,,,,,,,,,, +2001-03-01,54.73835754394531,0.3369686007499695,17.18704605102539,10.535667419433594,0.5115000009536743,,,17.375865936279297,1160.3299560546875,1840.260009765625 +2001-04-01,65.52893829345703,0.38918623328208923,21.292295455932617,15.900238990783691,0.7889999747276306,,,22.32872772216797,1249.4599609375,2116.239990234375 +2001-05-01,63.62804412841797,0.3046000301837921,21.741714477539062,17.430465698242188,0.8345000147819519,,,19.768779754638672,1255.8199462890625,2110.489990234375 +2001-05-08,,,,,,,,,, +2001-06-01,64.6737060546875,0.35498547554016113,22.942251205444336,16.83243751525879,0.7074999809265137,,,23.362648010253906,1224.3800048828125,2160.5400390625 +2001-07-01,59.949947357177734,0.28688937425613403,20.80202293395996,14.035829544067383,0.6244999766349792,,,18.640790939331055,1211.22998046875,2027.1300048828125 +2001-08-01,56.952762603759766,0.2832247018814087,17.929533004760742,16.18165397644043,0.44699999690055847,,,16.711578369140625,1133.5799560546875,1805.4300537109375 +2001-08-08,,,,,,,,,, +2001-09-01,52.33213424682617,0.23680917918682098,16.081575393676758,13.6312894821167,0.2985000014305115,,,11.92334270477295,1040.93994140625,1498.800048828125 +2001-10-01,61.660858154296875,0.26810887455940247,18.275238037109375,12.312134742736816,0.3490000069141388,,,13.133195877075195,1059.780029296875,1690.199951171875 +2001-11-01,65.95150756835938,0.3252120614051819,20.17975616455078,14.774558067321777,0.5659999847412109,,,15.958827018737793,1139.449951171875,1930.5799560546875 +2001-11-07,,,,,,,,,, +2001-12-01,69.1006088256836,0.3343726694583893,20.820878982543945,18.32748794555664,0.5410000085830688,,,15.446427345275879,1148.0799560546875,1950.4000244140625 +2002-01-01,61.63407897949219,0.37742963433265686,20.022619247436523,19.928070068359375,0.7095000147819519,,,16.771486282348633,1130.199951171875,1934.030029296875 +2002-02-01,56.052799224853516,0.3313194811344147,18.334945678710938,17.07868194580078,0.7049999833106995,,,18.105239868164062,1106.72998046875,1731.489990234375 +2002-02-06,,,,,,,,,, +2002-03-01,59.49020767211914,0.3613981306552887,18.95407485961914,18.907917022705078,0.7149999737739563,,,20.051130294799805,1147.3900146484375,1845.3499755859375 +2002-04-01,47.912540435791016,0.3705587685108185,16.424144744873047,15.56605339050293,0.8345000147819519,,,19.893611907958984,1076.9200439453125,1688.22998046875 +2002-05-01,46.01911926269531,0.35574817657470703,15.999865531921387,15.777122497558594,0.9114999771118164,,,17.971961975097656,1067.1400146484375,1615.72998046875 +2002-05-08,,,,,,,,,, +2002-06-01,41.26642990112305,0.2705524265766144,17.190977096557617,10.55325984954834,0.8125,,,14.188389778137207,989.8200073242188,1463.2099609375 +2002-07-01,40.349422454833984,0.23299239575862885,15.079033851623535,12.224191665649414,0.7225000262260437,,,11.933782577514648,911.6199951171875,1328.260009765625 +2002-08-01,43.203697204589844,0.22520573437213898,15.424735069274902,12.329721450805664,0.746999979019165,,,10.01123046875,916.0700073242188,1314.8499755859375 +2002-08-07,,,,,,,,,, +2002-09-01,33.49409484863281,0.22138899564743042,13.746496200561523,8.706437110900879,0.796500027179718,,,9.513158798217773,815.280029296875,1172.06005859375 +2002-10-01,45.344242095947266,0.24535933136940002,16.804426193237305,11.678934097290039,0.9679999947547913,,,11.782204627990723,885.760009765625,1329.75 +2002-11-01,49.92806625366211,0.23665708303451538,18.127525329589844,15.337401390075684,1.1675000190734863,,,14.71778678894043,936.3099975585938,1478.780029296875 +2002-11-06,,,,,,,,,, +2002-12-01,44.5990104675293,0.2187930941581726,16.248149871826172,14.15894889831543,0.9445000290870667,,,12.360349655151367,879.8200073242188,1335.510009765625 +2003-01-01,45.00184631347656,0.21925139427185059,14.91561222076416,15.56605339050293,1.0924999713897705,,,13.167760848999023,855.7000122070312,1320.9100341796875 +2003-02-01,44.85797119140625,0.22917553782463074,14.896756172180176,15.829883575439453,1.1004999876022339,,,13.712512969970703,841.1500244140625,1337.52001953125 +2003-02-06,,,,,,,,,, +2003-03-01,45.22197723388672,0.2158920168876648,15.266251564025879,15.302220344543457,1.3014999628067017,,,15.372973442077637,848.1799926757812,1341.1700439453125 +2003-04-01,48.95253372192383,0.21711383759975433,16.123830795288086,17.342517852783203,1.434499979019165,,,17.22471046447754,916.9199829101562,1464.31005859375 +2003-05-01,50.76301956176758,0.2740640342235565,15.518482208251953,19.224523544311523,1.7944999933242798,,,17.618791580200195,963.5900268554688,1595.9100341796875 +2003-05-07,,,,,,,,,, +2003-06-01,47.655845642089844,0.29101142287254333,16.16796875,18.626508712768555,1.815999984741211,,,15.997578620910645,974.5,1622.800048828125 +2003-07-01,46.933773040771484,0.32185351848602295,16.653514862060547,18.995861053466797,2.0820000171661377,,,16.333431243896484,990.3099975585938,1735.02001953125 +2003-08-01,47.37279510498047,0.34521347284317017,16.722881317138672,18.960683822631836,2.315999984741211,,,19.37755012512207,1008.010009765625,1810.449951171875 +2003-08-06,,,,,,,,,, +2003-09-01,51.1259651184082,0.3163566291332245,17.530014038085938,18.046072006225586,2.4214999675750732,,,19.657007217407227,995.969970703125,1786.93994140625 +2003-10-01,51.79159927368164,0.3494885563850403,16.48325538635254,18.468202590942383,2.7214999198913574,,,21.84463119506836,1050.7099609375,1932.2099609375 +2003-11-01,52.405128479003906,0.3192576766014099,16.303056716918945,21.423110961914062,2.698499917984009,,,20.621614456176758,1058.199951171875,1960.260009765625 +2003-11-06,,,,,,,,,, +2003-12-01,53.74093246459961,0.32628077268600464,17.35569190979004,24.272485733032227,2.63100004196167,,,19.5084171295166,1111.9200439453125,2003.3699951171875 +2004-01-01,57.53900146484375,0.3444499373435974,17.533241271972656,25.74994659423828,2.5199999809265137,,,19.119047164916992,1131.1300048828125,2066.14990234375 +2004-02-01,55.95598602294922,0.36521488428115845,16.82303810119629,24.87051010131836,2.1505000591278076,,,18.600963592529297,1144.93994140625,2029.8199462890625 +2004-02-06,,,,,,,,,, +2004-03-01,53.3401985168457,0.4128514230251312,15.808448791503906,25.6268310546875,2.1640000343322754,,,19.62464141845703,1126.2099609375,1994.219970703125 +2004-04-01,51.208683013916016,0.39361342787742615,16.56939125061035,23.6217041015625,2.180000066757202,,,20.729951858520508,1107.300048828125,1920.1500244140625 +2004-05-01,51.45262145996094,0.4284247159957886,16.632802963256836,23.815183639526367,2.424999952316284,,,22.293439865112305,1120.6800537109375,1986.739990234375 +2004-05-06,,,,,,,,,, +2004-06-01,51.300846099853516,0.4968261420726776,18.110280990600586,25.503700256347656,2.7200000286102295,,,23.227535247802734,1140.8399658203125,2047.7900390625 +2004-07-01,50.672325134277344,0.4937727451324463,18.065902709960938,24.378023147583008,1.9459999799728394,,,21.075881958007812,1101.719970703125,1887.3599853515625 +2004-08-01,49.28722381591797,0.5265995860099792,17.31130027770996,23.6217041015625,1.906999945640564,,,22.91964340209961,1104.239990234375,1838.0999755859375 +2004-08-06,,,,,,,,,, +2004-09-01,50.00397872924805,0.5916416049003601,17.5849609375,24.764976501464844,2.0429999828338623,,64.8648681640625,24.718441009521484,1114.5799560546875,1896.8399658203125 +2004-10-01,52.34260559082031,0.800052285194397,17.788476943969727,25.978591918945312,1.7065000534057617,,95.41541290283203,28.003637313842773,1130.199951171875,1974.989990234375 +2004-11-01,54.96117401123047,1.0237311124801636,17.050731658935547,26.945974349975586,1.9839999675750732,,91.0810775756836,30.26772117614746,1173.8199462890625,2096.81005859375 +2004-11-08,,,,,,,,,, +2004-12-01,57.60344696044922,0.9832708239555359,18.939943313598633,29.918479919433594,2.2144999504089355,,96.49149322509766,31.357276916503906,1211.9200439453125,2175.43994140625 +2005-01-01,54.58831024169922,1.1741228103637695,18.628063201904297,27.930959701538086,2.1610000133514404,,97.90790557861328,28.444419860839844,1181.27001953125,2062.409912109375 +2005-02-01,54.09749221801758,1.3698610067367554,17.83417510986328,27.438472747802734,1.7589999437332153,,94.0890884399414,30.86894416809082,1203.5999755859375,2051.719970703125 +2005-02-08,,,,,,,,,, +2005-03-01,53.49815368652344,1.2724499702453613,17.18527603149414,26.6469669342041,1.7135000228881836,,90.34534454345703,33.57841110229492,1180.5899658203125,1999.22998046875 +2005-04-01,44.7164421081543,1.1011403799057007,17.988739013671875,23.305103302001953,1.6180000305175781,,110.110107421875,29.735000610351562,1156.8499755859375,1921.6500244140625 +2005-05-01,44.23051071166992,1.2141252756118774,18.3442440032959,23.867952346801758,1.7755000591278076,,138.77377319335938,33.119998931884766,1191.5,2068.219970703125 +2005-05-06,,,,,,,,,, +2005-06-01,43.555538177490234,1.124043345451355,17.71768569946289,24.254899978637695,1.6545000076293945,,147.22222900390625,28.610000610351562,1191.3299560546875,2056.9599609375 +2005-07-01,48.991188049316406,1.3023751974105835,18.26690673828125,23.234752655029297,2.257499933242798,,144.02401733398438,29.639999389648438,1234.1800537109375,2184.830078125 +2005-08-01,47.3240966796875,1.431849479675293,19.529403686523438,23.58652687072754,2.134999990463257,,143.1431427001953,27.040000915527344,1220.3299560546875,2152.090087890625 +2005-08-08,,,,,,,,,, +2005-09-01,47.202552795410156,1.6370543241500854,18.40694236755371,24.00865936279297,2.265000104904175,,158.3883819580078,29.850000381469727,1228.81005859375,2151.68994140625 +2005-10-01,48.1793098449707,1.7585887908935547,18.385473251342773,23.867952346801758,1.9930000305175781,,186.25625610351562,32.25,1207.010009765625,2120.300048828125 +2005-11-01,52.309974670410156,2.0709757804870605,19.80194664001465,24.976051330566406,2.4230000972747803,,202.65765380859375,32.61000061035156,1249.47998046875,2232.820068359375 +2005-11-08,,,,,,,,,, +2005-12-01,48.483585357666016,2.1952593326568604,18.762245178222656,25.76755142211914,2.3575000762939453,,207.63763427734375,36.959999084472656,1248.2900390625,2205.320068359375 +2006-01-01,47.95273208618164,2.305800437927246,20.19721794128418,25.169517517089844,2.240999937057495,,216.5465545654297,39.72999954223633,1280.0799560546875,2305.820068359375 +2006-02-01,47.32752227783203,2.0914342403411865,19.27882957458496,26.207246780395508,1.871999979019165,,181.49148559570312,38.54999923706055,1280.6600341796875,2281.389892578125 +2006-02-08,,,,,,,,,, +2006-03-01,48.76497268676758,1.9152405261993408,19.588937759399414,26.734920501708984,1.8265000581741333,,195.1951904296875,34.95000076293945,1294.8699951171875,2339.7900390625 +2006-04-01,48.6880989074707,2.149454355239868,17.385986328125,24.694625854492188,1.7604999542236328,,209.17918395996094,39.20000076293945,1310.6099853515625,2322.570068359375 +2006-05-01,47.24531936645508,1.8251585960388184,16.306108474731445,24.149375915527344,1.7304999828338623,,186.09609985351562,28.6299991607666,1270.0899658203125,2178.8798828125 +2006-05-08,,,,,,,,,, +2006-06-01,45.58832931518555,1.7488168478012085,16.83946990966797,24.465961456298828,1.934000015258789,,209.8748779296875,30.360000610351562,1270.199951171875,2172.090087890625 +2006-07-01,45.938453674316406,2.075251340866089,17.388734817504883,24.78256607055664,1.344499945640564,,193.49349975585938,28.510000228881836,1276.6600341796875,2091.469970703125 +2006-08-01,48.051090240478516,2.0718915462493896,18.574007034301758,26.048952102661133,1.5414999723434448,,189.45445251464844,32.439998626708984,1303.8199462890625,2183.75 +2006-08-08,,,,,,,,,, +2006-09-01,48.820682525634766,2.350689172744751,19.839282989501953,27.368104934692383,1.6059999465942383,,201.15115356445312,37.459999084472656,1335.8499755859375,2258.429931640625 +2006-10-01,55.01115798950195,2.475886821746826,20.82581329345703,29.90088653564453,1.9045000076293945,,238.4334259033203,38.25,1377.93994140625,2366.7099609375 +2006-11-01,54.766883850097656,2.798962354660034,21.29731559753418,29.021446228027344,2.0169999599456787,,242.64764404296875,40.15999984741211,1400.6300048828125,2431.77001953125 +2006-11-08,,,,,,,,,, +2006-12-01,58.07079315185547,2.5907039642333984,21.73406219482422,29.812957763671875,1.9730000495910645,,230.47047424316406,41.119998931884766,1418.300048828125,2415.2900390625 +2007-01-01,59.266300201416016,2.617882013320923,22.461923599243164,30.252676010131836,1.8834999799728394,,251.00100708007812,38.869998931884766,1438.239990234375,2463.929931640625 +2007-02-01,55.55428695678711,2.583681344985962,20.50397491455078,30.37578582763672,1.9570000171661377,,224.949951171875,39.25,1406.8199462890625,2416.14990234375 +2007-02-07,,,,,,,,,, +2007-03-01,56.51309585571289,2.8371317386627197,20.3559513092041,29.707414627075195,1.9895000457763672,,229.30931091308594,41.70000076293945,1420.8599853515625,2421.639892578125 +2007-04-01,61.27952575683594,3.0475287437438965,21.867843627929688,32.539215087890625,3.066499948501587,,235.92591857910156,41.560001373291016,1482.3699951171875,2525.090087890625 +2007-05-01,63.91150665283203,3.700700044631958,22.415639877319336,33.18999099731445,3.4570000171661377,,249.20420837402344,44.060001373291016,1530.6199951171875,2604.52001953125 +2007-05-08,,,,,,,,,, +2007-06-01,63.347747802734375,3.7266552448272705,21.59428596496582,32.5040397644043,3.4205000400543213,,261.6116027832031,40.150001525878906,1503.3499755859375,2603.22998046875 +2007-07-01,66.59786987304688,4.023471355438232,21.242568969726562,30.70998764038086,3.927000045776367,,255.2552490234375,40.290000915527344,1455.27001953125,2546.27001953125 +2007-08-01,70.23324584960938,4.228675365447998,21.052053451538086,30.12954330444336,3.995500087738037,,257.88287353515625,42.75,1473.989990234375,2596.360107421875 +2007-08-08,,,,,,,,,, +2007-09-01,71.1520004272461,4.68641471862793,21.662628173828125,30.49891471862793,4.65749979019165,,283.9189147949219,43.65999984741211,1526.75,2701.5 +2007-10-01,70.13726806640625,5.800380706787109,27.067256927490234,30.674802780151367,4.457499980926514,,353.8538513183594,47.900001525878906,1549.3800048828125,2859.1201171875 +2007-11-01,63.529457092285156,5.564334392547607,24.70686912536621,29.6898193359375,4.5279998779296875,,346.8468322753906,42.13999938964844,1481.1400146484375,2660.9599609375 +2007-11-07,,,,,,,,,, +2007-12-01,65.52474212646484,6.048642158508301,26.26405906677246,28.4762020111084,4.631999969482422,,346.0860900878906,42.72999954223633,1468.3599853515625,2652.280029296875 +2008-01-01,64.92465209960938,4.133399963378906,24.050800323486328,27.21040916442871,3.884999990463257,,282.43243408203125,34.93000030517578,1378.550048828125,2389.860107421875 +2008-02-01,69.0161361694336,3.8176541328430176,20.066930770874023,25.923078536987305,3.2235000133514404,,235.82582092285156,33.650001525878906,1330.6300048828125,2271.47998046875 +2008-02-06,,,,,,,,,, +2008-03-01,70.05885314941406,4.381966590881348,21.01883316040039,26.399211883544922,3.565000057220459,,220.45545959472656,35.59000015258789,1322.699951171875,2279.10009765625 +2008-04-01,73.44194030761719,5.311798572540283,21.122520446777344,24.706567764282227,3.93149995803833,,287.43243408203125,37.290000915527344,1385.5899658203125,2412.800048828125 +2008-05-01,78.75386810302734,5.763737201690674,20.974388122558594,24.016834259033203,4.080999851226807,,293.1932067871094,44.060001373291016,1400.3800048828125,2522.659912109375 +2008-05-07,,,,,,,,,, +2008-06-01,72.41636657714844,5.11300802230835,20.449499130249023,23.981456756591797,3.6665000915527344,,263.4734802246094,39.38999938964844,1280.0,2292.97998046875 +2008-07-01,78.18988800048828,4.853753566741943,19.118900299072266,24.197914123535156,3.816999912261963,,237.1121063232422,41.349998474121094,1267.3800048828125,2325.550048828125 +2008-08-01,74.37141418457031,5.176827907562256,20.285959243774414,24.712379455566406,4.040500164031982,,231.8768768310547,42.83000183105469,1282.8299560546875,2367.52001953125 +2008-08-06,,,,,,,,,, +2008-09-01,71.73551177978516,3.470762014389038,19.91908073425293,20.454687118530273,3.638000011444092,,200.46046447753906,39.470001220703125,1166.3599853515625,2091.8798828125 +2008-10-01,57.02163314819336,3.2854056358337402,16.66515350341797,14.2785062789917,2.861999988555908,,179.85986328125,26.639999389648438,968.75,1720.949951171875 +2008-11-01,50.04803466796875,2.8298041820526123,15.090431213378906,12.444729804992676,2.134999990463257,,146.6266326904297,23.15999984741211,896.239990234375,1535.5699462890625 +2008-11-06,,,,,,,,,, +2008-12-01,51.90673828125,2.6062774658203125,14.606595039367676,14.189484596252441,2.563999891281128,,153.97897338867188,21.290000915527344,903.25,1577.030029296875 +2009-01-01,56.52627944946289,2.7522425651550293,12.848398208618164,11.888165473937988,2.940999984741211,,169.43443298339844,19.309999465942383,825.8800048828125,1476.4200439453125 +2009-02-01,56.76066589355469,2.7272019386291504,12.13459587097168,9.274202346801758,3.239500045776367,,169.16416931152344,16.700000762939453,735.0900268554688,1377.8399658203125 +2009-02-06,,,,,,,,,, +2009-03-01,60.08320999145508,3.209982395172119,13.897279739379883,8.146258354187012,3.671999931335449,,174.20420837402344,21.389999389648438,797.8699951171875,1528.5899658203125 +2009-04-01,64.00231170654297,3.8423893451690674,15.3270902633667,11.028571128845215,4.026000022888184,,198.1831817626953,27.350000381469727,872.8099975585938,1717.300048828125 +2009-05-01,65.90607452392578,4.147140979766846,15.803704261779785,12.274019241333008,3.8994998931884766,,208.82382202148438,28.18000030517578,919.1400146484375,1774.3299560546875 +2009-05-06,,,,,,,,,, +2009-06-01,65.09091186523438,4.349293231964111,18.0966796875,11.69642448425293,4.183000087738037,,211.00601196289062,28.299999237060547,919.3200073242188,1835.0400390625 +2009-07-01,73.51245880126953,4.989336013793945,17.906352996826172,14.879191398620605,4.288000106811523,,221.7467498779297,32.41999816894531,987.47998046875,1978.5 +2009-08-01,73.58724975585938,5.1365203857421875,18.766645431518555,15.714898109436035,4.059500217437744,,231.06607055664062,31.420000076293945,1020.6199951171875,2009.06005859375 +2009-08-06,,,,,,,,,, +2009-09-01,74.90744018554688,5.659914016723633,19.69136619567871,14.061647415161133,4.668000221252441,,248.1731719970703,33.040000915527344,1057.0799560546875,2122.419921875 +2009-10-01,75.53370666503906,5.756102561950684,21.230228424072266,13.72740650177002,5.940499782562256,,268.3283386230469,32.939998626708984,1036.18994140625,2045.1099853515625 +2009-11-01,79.12847900390625,6.1045241355896,22.51645278930664,14.055986404418945,6.795499801635742,,291.7917785644531,35.08000183105469,1095.6300048828125,2144.60009765625 +2009-11-06,,,,,,,,,, +2009-12-01,82.34589385986328,6.434925556182861,23.438796997070312,15.443329811096191,6.72599983215332,,310.30029296875,36.779998779296875,1115.0999755859375,2269.14990234375 +2010-01-01,76.99246215820312,5.86481237411499,21.670120239257812,15.999075889587402,6.270500183105469,,265.2352294921875,32.29999923706055,1073.8699951171875,2147.35009765625 +2010-02-01,79.99315643310547,6.248349666595459,22.04693031311035,17.19167137145996,5.920000076293945,,263.6636657714844,34.650001525878906,1104.489990234375,2238.260009765625 +2010-02-08,,,,,,,,,, +2010-03-01,81.0396728515625,7.176041126251221,22.629026412963867,17.88887596130371,6.78849983215332,,283.8438415527344,35.369998931884766,1169.4300537109375,2397.9599609375 +2010-04-01,81.51359558105469,7.972740650177002,23.594758987426758,20.0878963470459,6.855000019073486,,263.11309814453125,33.599998474121094,1186.68994140625,2461.18994140625 +2010-05-01,79.1503677368164,7.84417724609375,19.932706832885742,17.157638549804688,6.2729997634887695,,243.0580596923828,32.08000183105469,1089.4100341796875,2257.0400390625 +2010-05-06,,,,,,,,,, +2010-06-01,78.42550659179688,7.680809020996094,17.857412338256836,14.817129135131836,5.4629998207092285,,222.69769287109375,26.43000030517578,1030.7099609375,2109.239990234375 +2010-07-01,81.55033874511719,7.855478763580322,20.03040885925293,18.038850784301758,5.894499778747559,,242.66766357421875,28.719999313354492,1101.5999755859375,2254.699951171875 +2010-08-01,78.20323944091797,7.4233856201171875,18.214401245117188,15.64971923828125,6.241499900817871,,225.2352294921875,27.700000762939453,1049.3299560546875,2114.030029296875 +2010-08-06,,,,,,,,,, +2010-09-01,85.6181411743164,8.664690971374512,19.10737419128418,19.168588638305664,7.853000164031982,,263.1581726074219,26.149999618530273,1141.199951171875,2368.6201171875 +2010-10-01,91.65619659423828,9.190831184387207,20.808244705200195,21.757949829101562,8.261500358581543,,307.15716552734375,28.149999618530273,1183.260009765625,2507.409912109375 +2010-11-01,90.290283203125,9.501388549804688,19.70814323425293,21.311634063720703,8.770000457763672,,278.1331481933594,27.799999237060547,1180.550048828125,2498.22998046875 +2010-11-08,,,,,,,,,, +2010-12-01,94.08943176269531,9.84980583190918,21.909496307373047,21.423206329345703,9.0,,297.28228759765625,30.780000686645508,1257.6400146484375,2652.8701171875 +2011-01-01,103.8599853515625,10.361597061157227,21.76820182800293,19.823131561279297,8.482000350952148,,300.48046875,33.04999923706055,1286.1199951171875,2700.080078125 +2011-02-01,103.78302001953125,10.785745620727539,20.865453720092773,20.065792083740234,8.66450023651123,,307.00701904296875,34.5,1327.219970703125,2782.27001953125 +2011-02-08,,,,,,,,,, +2011-03-01,104.95984649658203,10.64222526550293,20.04909324645996,19.879127502441406,9.006500244140625,,293.6736755371094,33.15999984741211,1325.8299560546875,2781.070068359375 +2011-04-01,109.79368591308594,10.691693305969238,20.467607498168945,18.910266876220703,9.790499687194824,,272.32232666015625,33.54999923706055,1363.6099853515625,2873.5400390625 +2011-05-01,108.73165130615234,10.621461868286133,19.7490291595459,19.135168075561523,9.834500312805176,,264.7747802734375,34.630001068115234,1345.199951171875,2835.300048828125 +2011-05-06,,,,,,,,,, +2011-06-01,110.91179656982422,10.25013542175293,20.665348052978516,19.510000228881836,10.224499702453613,,253.4434356689453,31.450000762939453,1320.6400146484375,2773.52001953125 +2011-07-01,117.571044921875,11.923834800720215,21.778095245361328,17.562105178833008,11.12600040435791,,302.14715576171875,27.709999084472656,1292.280029296875,2756.3798828125 +2011-08-01,111.14454650878906,11.75130844116211,21.142244338989258,15.623312950134277,10.761500358581543,,270.7507629394531,25.239999771118164,1218.8900146484375,2579.4599609375 +2011-08-08,,,,,,,,,, +2011-09-01,113.55061340332031,11.644124984741211,19.90796661376953,13.119815826416016,10.81149959564209,,257.77777099609375,24.170000076293945,1131.4200439453125,2415.39990234375 +2011-10-01,119.88819122314453,12.360504150390625,21.299680709838867,15.485393524169922,10.67549991607666,,296.6166076660156,29.40999984741211,1253.300048828125,2684.409912109375 +2011-11-01,122.07645416259766,11.670994758605957,20.459848403930664,15.42860221862793,9.614500045776367,,299.9949951171875,27.420000076293945,1246.9599609375,2620.340087890625 +2011-11-08,,,,,,,,,, +2011-12-01,119.88117218017578,12.367225646972656,20.92014503479004,15.068914413452148,8.654999732971191,,323.2732849121094,28.270000457763672,1257.5999755859375,2605.14990234375 +2012-01-01,125.56623077392578,13.939234733581543,23.79706382751465,14.749091148376465,9.722000122070312,,290.3453369140625,30.950000762939453,1312.4100341796875,2813.840087890625 +2012-02-01,128.25875854492188,16.564136505126953,25.57801628112793,15.662582397460938,8.98449993133545,,309.4344482421875,32.88999938964844,1365.6800537109375,2966.889892578125 +2012-02-08,,,,,,,,,, +2012-03-01,136.5597381591797,18.308074951171875,26.1682071685791,15.377117156982422,10.125499725341797,,320.9409484863281,34.310001373291016,1408.469970703125,3091.570068359375 +2012-04-01,135.53221130371094,17.83262062072754,25.97353172302246,14.882647514343262,11.595000267028809,,302.72772216796875,33.54999923706055,1397.9100341796875,3046.360107421875 +2012-05-01,126.25150299072266,17.64176368713379,23.677928924560547,13.811394691467285,10.645500183105469,,290.7207336425781,31.049999237060547,1310.3299560546875,2827.340087890625 +2012-05-08,,,,,,,,,, +2012-06-01,128.5418243408203,17.83323097229004,24.976381301879883,15.054808616638184,11.417499542236328,,290.3253173828125,32.369998931884766,1362.1600341796875,2935.050048828125 +2012-07-01,128.80467224121094,18.650381088256836,24.06191635131836,13.332178115844727,11.664999961853027,,316.8017883300781,30.8799991607666,1379.3199462890625,2939.52001953125 +2012-08-01,128.06199645996094,20.314008712768555,25.1641845703125,14.178669929504395,12.41349983215332,,342.88787841796875,31.270000457763672,1406.5799560546875,3066.9599609375 +2012-08-08,,,,,,,,,, +2012-09-01,136.92532348632812,20.458269119262695,24.459667205810547,14.120949745178223,12.715999603271484,,377.62762451171875,32.439998626708984,1440.6700439453125,3116.22998046875 +2012-10-01,128.39756774902344,18.256948471069336,23.456958770751953,12.4627103805542,11.644499778747559,,340.490478515625,34.029998779296875,1412.1600341796875,2977.22998046875 +2012-11-01,125.45381927490234,17.94904899597168,21.878910064697266,13.178736686706543,12.602499961853027,,349.5345458984375,34.61000061035156,1416.1800537109375,3010.239990234375 +2012-11-07,,,,,,,,,, +2012-12-01,126.98394775390625,16.39484405517578,22.13326644897461,13.19808578491211,12.543499946594238,,354.0440368652344,37.68000030517578,1426.18994140625,3019.510009765625 +2013-01-01,134.6208953857422,14.03252124786377,22.746475219726562,15.598185539245605,13.274999618530273,,378.2232360839844,37.83000183105469,1498.1099853515625,3142.1298828125 +2013-02-01,133.1359405517578,13.598445892333984,23.036500930786133,15.79291820526123,13.213500022888184,,401.0010070800781,39.310001373291016,1514.6800537109375,3160.18994140625 +2013-02-06,,,,,,,,,, +2013-03-01,141.99786376953125,13.716739654541016,23.903995513916016,16.74711036682129,13.32450008392334,,397.49249267578125,43.52000045776367,1569.18994140625,3267.52001953125 +2013-04-01,134.8347625732422,13.720457077026367,27.655447006225586,16.822824478149414,12.690500259399414,,412.69769287109375,45.08000183105469,1597.5699462890625,3328.7900390625 +2013-05-01,138.48284912109375,13.935823440551758,29.15936851501465,17.234567642211914,13.460000038146973,,436.0460510253906,42.90999984741211,1630.739990234375,3455.909912109375 +2013-05-08,,,,,,,,,, +2013-06-01,127.82191467285156,12.368638038635254,29.060949325561523,17.783567428588867,13.884499549865723,,440.6256408691406,45.560001373291016,1606.280029296875,3403.25 +2013-07-01,130.45040893554688,14.115401268005371,26.789243698120117,19.142587661743164,15.060999870300293,,444.3193054199219,47.279998779296875,1685.72998046875,3626.3701171875 +2013-08-01,121.90938568115234,15.19745922088623,28.101774215698242,19.695158004760742,14.048999786376953,,423.8738708496094,45.75,1632.969970703125,3589.8701171875 +2013-08-07,,,,,,,,,, +2013-09-01,124.47478485107422,14.96906566619873,28.19812774658203,20.306934356689453,15.631999969482422,,438.3934020996094,51.939998626708984,1681.550048828125,3771.47998046875 +2013-10-01,120.46192169189453,16.41180992126465,30.002870559692383,19.72601890563965,18.201499938964844,,515.8057861328125,54.220001220703125,1756.5400390625,3919.7099609375 +2013-11-01,120.77778625488281,17.45956802368164,32.30753707885742,22.58371353149414,19.680999755859375,,530.3253173828125,56.779998779296875,1805.81005859375,4059.889892578125 +2013-11-06,,,,,,,,,, +2013-12-01,126.7584228515625,17.71782684326172,31.937856674194336,24.151473999023438,19.93950080871582,,560.9158935546875,59.880001068115234,1848.3599853515625,4176.58984375 +2014-01-01,119.39906311035156,15.80967903137207,32.304969787597656,21.634523391723633,17.934499740600586,,591.0760498046875,59.189998626708984,1782.5899658203125,4103.8798828125 +2014-02-01,125.13655090332031,16.61942481994629,32.70622634887695,21.913677215576172,18.104999542236328,,608.4334106445312,68.62999725341797,1859.449951171875,4308.1201171875 +2014-02-06,,,,,,,,,, +2014-03-01,130.79644775390625,17.052499771118164,35.256614685058594,22.53180694580078,16.818500518798828,,557.8128051757812,65.73999786376953,1872.3399658203125,4198.990234375 +2014-04-01,133.50091552734375,18.747455596923828,34.7491340637207,24.246538162231445,15.206500053405762,,534.8800048828125,61.689998626708984,1883.949951171875,4114.56005859375 +2014-05-01,125.27215576171875,20.11072540283203,35.21359634399414,24.767969131469727,15.6274995803833,,571.6500244140625,64.54000091552734,1923.5699462890625,4242.6201171875 +2014-05-07,,,,,,,,,, +2014-06-01,123.88963317871094,20.782461166381836,36.12032699584961,24.94846534729004,16.23900032043457,,584.6699829101562,72.36000061035156,1960.22998046875,4408.18017578125 +2014-07-01,130.99761962890625,21.37957000732422,37.38497543334961,26.72607421875,15.649499893188477,,579.5499877929688,69.25,1930.6700439453125,4369.77001953125 +2014-08-01,131.4281463623047,22.922651290893555,39.35124206542969,27.834640502929688,16.95199966430664,,582.3599853515625,71.9000015258789,2003.3699951171875,4580.27001953125 +2014-08-06,,,,,,,,,, +2014-09-01,130.50729370117188,22.643360137939453,40.40761947631836,26.66560935974121,16.121999740600586,,588.4099731445312,69.19000244140625,1972.2900390625,4493.39013671875 +2014-10-01,113.0242691040039,24.27278709411621,40.92185974121094,26.89417266845703,15.27299976348877,,567.8699951171875,70.12000274658203,2018.050048828125,4630.740234375 +2014-11-01,111.49117279052734,26.729284286499023,41.67144012451172,28.27128028869629,16.93199920654297,,549.0800170898438,73.68000030517578,2067.56005859375,4791.6298828125 +2014-11-06,,,,,,,,,, +2014-12-01,111.05672454833984,24.915250778198242,40.74142074584961,28.068769454956055,15.517499923706055,,530.6599731445312,72.69999694824219,2058.89990234375,4736.0498046875 +2015-01-01,106.12132263183594,26.445661544799805,35.434940338134766,26.79075813293457,17.726499557495117,,537.5499877929688,70.12999725341797,1994.989990234375,4635.240234375 +2015-02-01,112.09505462646484,28.996322631835938,38.460933685302734,27.767194747924805,19.007999420166016,,562.6300048828125,79.0999984741211,2104.5,4963.52978515625 +2015-02-06,,,,,,,,,, +2015-03-01,111.87759399414062,28.197509765625,35.91679000854492,26.139816284179688,18.604999542236328,,554.7000122070312,73.94000244140625,2067.889892578125,4900.8798828125 +2015-04-01,119.3988265991211,28.360668182373047,42.96587371826172,23.521541595458984,21.089000701904297,,548.77001953125,76.05999755859375,2085.510009765625,4941.419921875 +2015-05-01,118.25563049316406,29.523195266723633,41.39352035522461,23.3579158782959,21.46150016784668,,545.3200073242188,79.08999633789062,2107.389892578125,5070.02978515625 +2015-05-06,,,,,,,,,, +2015-06-01,114.24130249023438,28.542850494384766,39.253108978271484,21.762542724609375,21.704500198364258,,540.0399780273438,81.01000213623047,2063.110107421875,4986.8701171875 +2015-07-01,113.77072143554688,27.60302734375,41.520286560058594,22.683992385864258,26.8075008392334,,657.5,81.98999786376953,2103.840087890625,5128.27978515625 +2015-08-01,103.86784362792969,25.65966796875,38.692989349365234,20.93431854248047,25.644500732421875,,647.8200073242188,78.56999969482422,1972.1800537109375,4776.509765625 +2015-08-06,,,,,,,,,, +2015-09-01,102.66226959228516,25.21347999572754,39.61040496826172,20.028608322143555,25.594499588012695,,638.3699951171875,82.22000122070312,1920.030029296875,4620.16015625 +2015-10-01,99.1993637084961,27.31651496887207,47.11008071899414,19.46390151977539,31.295000076293945,,737.3900146484375,88.66000366210938,2079.360107421875,5053.75 +2015-11-01,98.7319564819336,27.042200088500977,48.64043045043945,21.868392944335938,33.2400016784668,,762.8499755859375,91.45999908447266,2080.409912109375,5108.669921875 +2015-11-06,,,,,,,,,, +2015-12-01,98.37144470214844,24.16438102722168,49.98638916015625,22.03421974182129,33.794498443603516,,778.010009765625,93.94000244140625,2043.93994140625,5007.41015625 +2016-01-01,89.20050811767578,22.3461971282959,49.63501739501953,20.343839645385742,29.350000381469727,,761.3499755859375,89.12999725341797,1940.239990234375,4613.9501953125 +2016-02-01,93.6608657836914,22.196985244750977,45.841888427734375,20.051719665527344,27.625999450683594,,717.219970703125,85.1500015258789,1932.22998046875,4557.9501953125 +2016-02-08,,,,,,,,,, +2016-03-01,109.36297607421875,25.15644073486328,50.11842727661133,23.285871505737305,29.68199920654297,,762.9000244140625,93.80000305175781,2059.739990234375,4869.85009765625 +2016-04-01,105.3841552734375,21.636524200439453,45.25450134277344,20.178363800048828,32.97949981689453,,707.8800048828125,94.22000122070312,2065.300048828125,4775.35986328125 +2016-05-01,111.01663208007812,23.049110412597656,48.094825744628906,20.956079483032227,36.13949966430664,,748.8499755859375,99.47000122070312,2096.949951171875,4948.0498046875 +2016-05-06,,,,,,,,,, +2016-06-01,110.65898895263672,22.20018196105957,46.75897216796875,19.947153091430664,35.78099822998047,,703.530029296875,95.79000091552734,2098.860107421875,4842.669921875 +2016-07-01,117.10401916503906,24.199600219726562,51.79398727416992,21.839828491210938,37.94049835205078,,791.3400268554688,97.86000061035156,2173.60009765625,5162.1298828125 +2016-08-01,115.83541107177734,24.638490676879883,52.506752014160156,20.885658264160156,38.45800018310547,,789.8499755859375,102.30999755859375,2170.949951171875,5213.22021484375 +2016-08-08,,,,,,,,,, +2016-09-01,116.81381225585938,26.394628524780273,52.96271896362305,21.479366302490234,41.865501403808594,13.321450233459473,804.0599975585938,108.54000091552734,2168.27001953125,5312.0 +2016-10-01,113.019287109375,26.509033203125,55.095947265625,20.878395080566406,39.49100112915039,13.680961608886719,809.9000244140625,107.51000213623047,2126.14990234375,5189.14013671875 +2016-11-01,119.29200744628906,25.803936004638672,55.40858840942383,19.980859756469727,37.528499603271484,14.926712036132812,775.8800048828125,102.80999755859375,2198.81005859375,5323.68017578125 +2016-11-08,,,,,,,,,, +2016-12-01,123.1717300415039,27.180198669433594,57.52321243286133,18.655929565429688,37.493499755859375,15.31966781616211,792.4500122070312,102.94999694824219,2238.830078125,5383.1201171875 +2017-01-01,129.5013427734375,28.47795867919922,59.84672927856445,22.670724868774414,41.17399978637695,17.554771423339844,820.1900024414062,113.37999725341797,2278.8701171875,5614.7900390625 +2017-02-01,133.43417358398438,32.148292541503906,59.22650909423828,24.339130401611328,42.25199890136719,17.69411849975586,844.9299926757812,118.33999633789062,2363.639892578125,5825.43994140625 +2017-02-08,,,,,,,,,, +2017-03-01,130.24111938476562,33.85976028442383,61.33644485473633,24.011991500854492,44.32699966430664,17.858545303344727,847.7999877929688,130.1300048828125,2362.719970703125,5911.740234375 +2017-04-01,119.88253784179688,33.85739517211914,63.75787353515625,23.72492027282715,46.2495002746582,18.70298194885254,924.52001953125,133.74000549316406,2384.199951171875,6047.60986328125 +2017-05-01,114.1535415649414,36.00456237792969,65.0430908203125,23.328956604003906,49.73099899291992,19.338397979736328,987.0900268554688,141.86000061035156,2411.800048828125,6198.52001953125 +2017-05-08,,,,,,,,,, +2017-06-01,116.17494201660156,34.084716796875,64.56354522705078,23.700172424316406,48.400001525878906,17.030832290649414,929.6799926757812,141.44000244140625,2423.409912109375,6140.419921875 +2017-07-01,109.25714874267578,35.19940948486328,68.0947265625,25.520694732666016,49.388999938964844,17.911497116088867,945.5,146.49000549316406,2470.300048828125,6348.1201171875 +2017-08-01,108.01860809326172,38.81330490112305,70.03360748291016,26.852062225341797,49.029998779296875,20.882347106933594,955.239990234375,155.16000366210938,2471.64990234375,6428.66015625 +2017-08-08,,,,,,,,,, +2017-09-01,110.72441864013672,36.6182861328125,70.14307403564453,27.700807571411133,48.067501068115234,21.517763137817383,973.719970703125,149.17999267578125,2519.360107421875,6495.9599609375 +2017-10-01,117.57792663574219,40.163211822509766,78.32596588134766,25.408233642578125,55.263999938964844,23.067289352416992,1033.0400390625,175.16000366210938,2575.260009765625,6727.669921875 +2017-11-01,117.50923919677734,40.83085632324219,79.2582015991211,24.86334991455078,58.837501525878906,21.80481719970703,1036.1700439453125,181.47000122070312,2647.580078125,6873.97021484375 +2017-11-09,,,,,,,,,, +2017-12-01,118.25981140136719,40.3528938293457,80.95279693603516,24.43583106994629,58.4734992980957,22.65203857421875,1053.4000244140625,175.24000549316406,2673.610107421875,6903.39013671875 +2018-01-01,126.18390655517578,39.9236946105957,89.91493225097656,28.855159759521484,72.54450225830078,19.982173919677734,1182.219970703125,199.75999450683594,2823.81005859375,7411.47998046875 +2018-02-01,120.11751556396484,42.472713470458984,88.74141693115234,25.634004592895508,75.62249755859375,20.7039852142334,1103.9200439453125,209.1300048828125,2713.830078125,7273.009765625 +2018-02-08,,,,,,,,,, +2018-03-01,119.43197631835938,40.170265197753906,86.7812271118164,24.33201026916504,72.36699676513672,20.402997970581055,1037.1400146484375,216.0800018310547,2640.8701171875,7063.4501953125 +2018-04-01,112.83880615234375,39.566917419433594,88.92057037353516,26.82056999206543,78.30650329589844,20.00168228149414,1018.5800170898438,221.60000610351562,2648.050048828125,7066.27001953125 +2018-05-01,109.99760437011719,44.7408332824707,93.97891998291016,23.179109573364258,81.48100280761719,22.479249954223633,1100.0,249.27999877929688,2705.27001953125,7442.1201171875 +2018-05-09,,,,,,,,,, +2018-06-01,109.95153045654297,44.4903450012207,94.16664123535156,20.467208862304688,84.98999786376953,23.571720123291016,1129.18994140625,243.80999755859375,2718.3701171875,7510.2998046875 +2018-07-01,114.06781768798828,45.73533630371094,101.30004119873047,22.375450134277344,88.87200164794922,25.784528732299805,1227.219970703125,244.67999267578125,2816.2900390625,7671.7900390625 +2018-08-01,115.2877197265625,54.709842681884766,107.2684097290039,24.00385284423828,100.635498046875,26.8017520904541,1231.800048828125,263.510009765625,2901.52001953125,8109.5400390625 +2018-08-09,,,,,,,,,, +2018-09-01,120.2962646484375,54.445865631103516,109.63678741455078,23.24565315246582,100.1500015258789,27.066509246826172,1207.0799560546875,269.95001220703125,2913.97998046875,8046.35009765625 +2018-10-01,91.83122253417969,52.78649139404297,102.38966369628906,24.236047744750977,79.90049743652344,25.190916061401367,1090.5799560546875,245.75999450683594,2711.739990234375,7305.89990234375 +2018-11-01,98.86396026611328,43.07142639160156,106.3008041381836,23.4099178314209,84.50849914550781,29.396371841430664,1109.6500244140625,250.88999938964844,2760.169921875,7330.5400390625 +2018-11-08,,,,,,,,,, +2018-12-01,91.58279418945312,38.17780685424805,97.78714752197266,17.18350601196289,75.09850311279297,24.59708595275879,1044.9599609375,226.24000549316406,2506.85009765625,6635.27978515625 +2019-01-01,108.30086517333984,40.28346252441406,100.5406265258789,24.84735679626465,85.9365005493164,24.456159591674805,1125.8900146484375,247.82000732421875,2704.10009765625,7281.740234375 +2019-02-01,111.28997039794922,41.90748596191406,107.85758972167969,27.216707229614258,81.99150085449219,28.095136642456055,1126.550048828125,262.5,2784.489990234375,7532.52978515625 +2019-02-07,,,,,,,,,, +2019-03-01,115.00740814208984,46.17075729370117,114.03240966796875,28.167972564697266,89.0374984741211,29.539655685424805,1176.8900146484375,266.489990234375,2834.39990234375,7729.31982421875 +2019-04-01,114.33090209960938,48.77644348144531,126.27296447753906,29.61660385131836,96.32599639892578,33.9285774230957,1198.9599609375,289.25,2945.830078125,8095.39013671875 +2019-05-01,103.50668334960938,42.55390930175781,119.58222198486328,27.175188064575195,88.75350189208984,29.972509384155273,1106.5,270.8999938964844,2752.06005859375,7453.14990234375 +2019-05-09,,,,,,,,,, +2019-06-01,113.73433685302734,48.293270111083984,130.00108337402344,31.43656349182129,94.68150329589844,25.56848907470703,1082.800048828125,294.6499938964844,2941.760009765625,8006.240234375 +2019-07-01,122.26231384277344,51.98261260986328,132.24281311035156,28.701255798339844,93.33899688720703,29.061506271362305,1218.199951171875,298.8599853515625,2980.3798828125,8175.419921875 +2019-08-01,111.7796401977539,50.93339920043945,133.78579711914062,25.92054557800293,88.81449890136719,25.9359073638916,1190.530029296875,284.510009765625,2926.4599609375,7962.8798828125 +2019-08-08,,,,,,,,,, +2019-09-01,121.34967803955078,54.85721969604492,135.37051391601562,26.743131637573242,86.79550170898438,26.10200309753418,1221.1400146484375,276.25,2976.739990234375,7999.33984375 +2019-10-01,111.59463500976562,60.929054260253906,139.59625244140625,30.58913803100586,88.83300018310547,26.620418548583984,1258.800048828125,277.92999267578125,3037.56005859375,8292.3603515625 +2019-11-01,112.19547271728516,65.45783996582031,147.39544677734375,35.09682083129883,90.04000091552734,24.40582847595215,1304.0899658203125,309.5299987792969,3140.97998046875,8665.4697265625 +2019-11-07,,,,,,,,,, +2019-12-01,113.17443084716797,72.13994598388672,154.07154846191406,33.23965072631836,92.39199829101562,25.86544418334961,1339.3900146484375,329.80999755859375,3230.780029296875,8972.599609375 +2020-01-01,121.35601806640625,76.03622436523438,166.31326293945312,32.28398132324219,100.43599700927734,24.546754837036133,1432.780029296875,351.1400146484375,3225.52001953125,9150.9404296875 +2020-02-01,109.88997650146484,67.1553726196289,158.28240966796875,29.225305557250977,94.1875,20.364192962646484,1339.25,345.1199951171875,2954.219970703125,8567.3701171875 +2020-02-07,,,,,,,,,, +2020-03-01,94.6399154663086,62.61878204345703,154.502197265625,17.190288543701172,97.48600006103516,19.90617561340332,1161.949951171875,318.239990234375,2584.590087890625,7700.10009765625 +2020-04-01,107.12150573730469,72.34808349609375,175.5648956298828,16.6003360748291,123.69999694824219,21.486589431762695,1346.699951171875,353.6400146484375,2912.429931640625,8889.5498046875 +2020-05-01,106.55841827392578,78.29256439208984,179.52272033691406,14.412978172302246,122.11849975585938,24.98464012145996,1433.52001953125,386.6000061035156,3044.31005859375,9489.8701171875 +2020-05-07,,,,,,,,,, +2020-06-01,104.41674041748047,90.0749740600586,199.92588806152344,13.877481460571289,137.9409942626953,27.652219772338867,1418.050048828125,435.30999755859375,3100.2900390625,10058.76953125 +2020-07-01,106.29290008544922,104.9491958618164,201.3994598388672,15.366937637329102,158.23399353027344,30.11343765258789,1487.949951171875,444.32000732421875,3271.1201171875,10745.26953125 +2020-08-01,106.61280059814453,127.44819641113281,221.55807495117188,17.406635284423828,172.54800415039062,33.25917053222656,1629.530029296875,513.3900146484375,3500.31005859375,11775.4599609375 +2020-08-07,,,,,,,,,, +2020-09-01,106.57222747802734,114.5876235961914,207.12527465820312,17.323570251464844,157.43649291992188,34.06950759887695,1465.5999755859375,490.42999267578125,3363.0,11167.509765625 +2020-10-01,97.80435180664062,107.71099090576172,199.38504028320312,16.259458541870117,151.8074951171875,30.329862594604492,1616.1099853515625,447.1000061035156,3269.9599609375,10911.58984375 +2020-11-01,108.19266510009766,117.79344177246094,210.8082733154297,20.478687286376953,158.40199279785156,34.74394989013672,1754.4000244140625,478.4700012207031,3621.6298828125,12198.740234375 +2020-11-09,,,,,,,,,, +2020-12-01,111.85865020751953,131.51597595214844,219.60447692871094,21.694869995117188,162.84649658203125,36.88808059692383,1752.6400146484375,500.1199951171875,3756.070068359375,12888.2802734375 +2021-01-01,105.84272766113281,130.7924346923828,229.0237274169922,19.891191482543945,160.30999755859375,36.6867561340332,1827.3599853515625,458.7699890136719,3714.239990234375,13070.6904296875 +2021-02-01,105.68277740478516,120.18710327148438,229.4384002685547,24.100215911865234,154.64649963378906,40.80388259887695,2021.9100341796875,459.6700134277344,3811.14990234375,13192.349609375 +2021-02-09,,,,,,,,,, +2021-03-01,119.9990005493164,121.25013732910156,233.32164001464844,22.955739974975586,154.70399475097656,44.367366790771484,2062.52001953125,475.3699951171875,3972.889892578125,13246.8701171875 +2021-04-01,127.76121520996094,130.49156188964844,249.56121826171875,23.070621490478516,173.37100219726562,49.49113082885742,2353.5,508.3399963378906,4181.169921875,13962.6796875 +2021-05-01,129.4361114501953,123.6920166015625,247.08718872070312,22.41118812561035,161.15350341796875,49.64715576171875,2356.85009765625,504.5799865722656,4204.10986328125,13748.740234375 +2021-05-07,,,,,,,,,, +2021-06-01,133.47738647460938,136.1819610595703,268.70587158203125,22.44941520690918,172.00799560546875,50.16557312011719,2441.7900390625,585.6400146484375,4297.5,14503.9501953125 +2021-07-01,128.35101318359375,145.03138732910156,282.6023864746094,23.305561065673828,166.37950134277344,48.63045883178711,2694.530029296875,621.6300048828125,4395.259765625,14672.6796875 +2021-08-01,127.78646087646484,150.96749877929688,299.4349365234375,21.74091148376465,173.5395050048828,49.053245544433594,2893.949951171875,663.7000122070312,4522.68017578125,15259.240234375 +2021-08-09,,,,,,,,,, +2021-09-01,127.95899963378906,140.906982421875,280.1719665527344,19.48086166381836,164.2519989013672,52.36507034301758,2673.52001953125,575.719970703125,4307.5400390625,14448.580078125 +2021-10-01,115.22111511230469,149.1721954345703,329.56378173828125,17.397972106933594,168.6215057373047,55.35980224609375,2960.919921875,650.3599853515625,4605.3798828125,15498.3896484375 +2021-11-01,112.8140869140625,164.60723876953125,328.5401611328125,18.003969192504883,175.35350036621094,56.077186584472656,2837.949951171875,669.8499755859375,4567.0,15537.6904296875 +2021-11-04,,,,,,,,,, +2021-11-09,,,,,,,,,, +2021-12-01,130.48629760742188,177.08387756347656,334.8461608886719,22.1286563873291,166.7169952392578,55.77927017211914,2897.0400390625,567.0599975585938,4766.18017578125,15644.9697265625 +2022-01-01,130.3984375,174.30149841308594,309.6171875,20.856517791748047,149.57350158691406,56.41482162475586,2706.070068359375,534.2999877929688,4515.5498046875,14239.8798828125 +2022-02-01,119.60104370117188,164.66795349121094,297.4805908203125,19.47332763671875,153.56300354003906,50.60551452636719,2701.139892578125,467.67999267578125,4373.93994140625,13751.400390625 +2022-02-10,,,,,,,,,, +2022-03-01,128.46168518066406,174.3538360595703,307.59356689453125,19.927804946899414,162.99749755859375,49.84086990356445,2781.35009765625,455.6199951171875,4530.41015625,14220.51953125 +2022-04-01,130.6254425048828,157.418701171875,276.8751220703125,17.399999618530273,124.28150177001953,46.68299102783203,2282.18994140625,395.95001220703125,4131.93017578125,12334.6396484375 +2022-05-01,137.1759796142578,148.6216278076172,271.2382507324219,18.81999969482422,120.20950317382812,49.939998626708984,2275.239990234375,416.4800109863281,4132.14990234375,12081.3896484375 +2022-05-09,,,,,,,,,, +2022-06-01,141.86000061035156,137.44000244140625,256.4800109863281,15.819999694824219,107.4000015258789,48.939998626708984,2240.14990234375,365.6300048828125,3821.550048828125,11181.5400390625 +2022-06-28,141.86000061035156,137.44000244140625,256.4800109863281,15.819999694824219,107.4000015258789,48.939998626708984,2240.14990234375,365.6300048828125,3821.550048828125,11181.5400390625 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/axes_grid/bivariate_normal.npy b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/axes_grid/bivariate_normal.npy new file mode 100644 index 00000000..b6b8dacd Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/axes_grid/bivariate_normal.npy differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/data_x_x2_x3.csv b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/data_x_x2_x3.csv new file mode 100644 index 00000000..521da145 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/data_x_x2_x3.csv @@ -0,0 +1,11 @@ + 0 0 0 + 1 1 1 + 2 4 8 + 3 9 27 + 4 16 64 + 5 25 125 + 6 36 216 + 7 49 343 + 8 64 512 + 9 81 729 +10 100 1000 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/eeg.dat b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/eeg.dat new file mode 100644 index 00000000..c666c650 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/eeg.dat differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/embedding_in_wx3.xrc b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/embedding_in_wx3.xrc new file mode 100644 index 00000000..220656d7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/embedding_in_wx3.xrc @@ -0,0 +1,65 @@ + + + + embedding_in_wx3 + + + wxVERTICAL + + + + + + + wxALL|wxEXPAND + 5 + + + + wxHORIZONTAL + + + + + + wxALL|wxEXPAND + 2 + + + + + + + wxALL|wxEXPAND + 2 + + + + + + + + wxALL|wxEXPAND + 2 + + + + 0 + + + wxEXPAND + + + + wxLEFT|wxRIGHT|wxEXPAND + 5 + + + + + wxEXPAND + + + + + \ No newline at end of file diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/goog.npz b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/goog.npz new file mode 100644 index 00000000..6cbfd68b Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/goog.npz differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/grace_hopper.jpg b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/grace_hopper.jpg new file mode 100644 index 00000000..478720d6 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/grace_hopper.jpg differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/jacksboro_fault_dem.npz b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/jacksboro_fault_dem.npz new file mode 100644 index 00000000..d2502864 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/jacksboro_fault_dem.npz differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/membrane.dat b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/membrane.dat new file mode 100644 index 00000000..68f5e6b2 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/membrane.dat differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/msft.csv b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/msft.csv new file mode 100644 index 00000000..727b1bef --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/msft.csv @@ -0,0 +1,66 @@ +Date,Open,High,Low,Close,Volume,Adj. Close* +19-Sep-03,29.76,29.97,29.52,29.96,92433800,29.79 +18-Sep-03,28.49,29.51,28.42,29.50,67268096,29.34 +17-Sep-03,28.76,28.95,28.47,28.50,47221600,28.34 +16-Sep-03,28.41,28.95,28.32,28.90,52060600,28.74 +15-Sep-03,28.37,28.61,28.33,28.36,41432300,28.20 +12-Sep-03,27.48,28.40,27.45,28.34,55777200,28.18 +11-Sep-03,27.66,28.11,27.59,27.84,37813300,27.68 +10-Sep-03,28.03,28.18,27.48,27.55,54763500,27.40 +9-Sep-03,28.65,28.71,28.31,28.37,44315200,28.21 +8-Sep-03,28.39,28.92,28.34,28.84,46105300,28.68 +5-Sep-03,28.23,28.75,28.17,28.38,64024500,28.22 +4-Sep-03,28.10,28.47,27.99,28.43,59840800,28.27 +3-Sep-03,27.42,28.40,27.38,28.30,109437800,28.14 +2-Sep-03,26.70,27.30,26.47,27.26,74168896,27.11 +29-Aug-03,26.46,26.55,26.35,26.52,34503000,26.37 +28-Aug-03,26.50,26.58,26.24,26.51,46211200,26.36 +27-Aug-03,26.51,26.58,26.30,26.42,30633900,26.27 +26-Aug-03,26.31,26.67,25.96,26.57,47546000,26.42 +25-Aug-03,26.31,26.54,26.23,26.50,36132900,26.35 +22-Aug-03,26.78,26.95,26.21,26.22,65846300,26.07 +21-Aug-03,26.65,26.73,26.13,26.24,63802700,26.09 +20-Aug-03,26.30,26.53,26.00,26.45,56739300,26.30 +19-Aug-03,25.85,26.65,25.77,26.62,72952896,26.47 +18-Aug-03,25.56,25.83,25.46,25.70,45817400,25.56 +15-Aug-03,25.61,25.66,25.43,25.54,27607900,25.40 +14-Aug-03,25.66,25.71,25.52,25.63,37338300,25.49 +13-Aug-03,25.79,25.89,25.50,25.60,39636900,25.46 +12-Aug-03,25.71,25.77,25.45,25.73,38208400,25.59 +11-Aug-03,25.61,25.99,25.54,25.61,36433900,25.47 +8-Aug-03,25.88,25.98,25.50,25.58,33241400,25.44 +7-Aug-03,25.72,25.81,25.45,25.71,44258500,25.57 +6-Aug-03,25.54,26.19,25.43,25.65,56294900,25.51 +5-Aug-03,26.31,26.54,25.60,25.66,58825800,25.52 +4-Aug-03,26.15,26.41,25.75,26.18,51825600,26.03 +1-Aug-03,26.33,26.51,26.12,26.17,42649700,26.02 +31-Jul-03,26.60,26.99,26.31,26.41,64504800,26.26 +30-Jul-03,26.46,26.57,26.17,26.23,41240300,26.08 +29-Jul-03,26.88,26.90,26.24,26.47,62391100,26.32 +28-Jul-03,26.94,27.00,26.49,26.61,52658300,26.46 +25-Jul-03,26.28,26.95,26.07,26.89,54173000,26.74 +24-Jul-03,26.78,26.92,25.98,26.00,53556600,25.85 +23-Jul-03,26.42,26.65,26.14,26.45,49828200,26.30 +22-Jul-03,26.28,26.56,26.13,26.38,51791000,26.23 +21-Jul-03,26.87,26.91,26.00,26.04,48480800,25.89 +18-Jul-03,27.11,27.23,26.75,26.89,63388400,26.74 +17-Jul-03,27.14,27.27,26.54,26.69,72805000,26.54 +16-Jul-03,27.56,27.62,27.20,27.52,49838900,27.37 +15-Jul-03,27.47,27.53,27.10,27.27,53567600,27.12 +14-Jul-03,27.63,27.81,27.05,27.40,60464400,27.25 +11-Jul-03,26.95,27.45,26.89,27.31,50377300,27.16 +10-Jul-03,27.25,27.42,26.59,26.91,55350800,26.76 +9-Jul-03,27.56,27.70,27.25,27.47,62300700,27.32 +8-Jul-03,27.26,27.80,27.25,27.70,61896800,27.55 +7-Jul-03,27.02,27.55,26.95,27.42,88960800,27.27 +3-Jul-03,26.69,26.95,26.41,26.50,39440900,26.35 +2-Jul-03,26.50,26.93,26.45,26.88,94069296,26.73 +1-Jul-03,25.59,26.20,25.39,26.15,60926000,26.00 +30-Jun-03,25.94,26.12,25.50,25.64,48073100,25.50 +27-Jun-03,25.95,26.34,25.53,25.63,76040304,25.49 +26-Jun-03,25.39,26.51,25.21,25.75,51758100,25.61 +25-Jun-03,25.64,25.99,25.14,25.26,60483500,25.12 +24-Jun-03,25.65,26.04,25.52,25.70,51820300,25.56 +23-Jun-03,26.14,26.24,25.49,25.78,52584500,25.64 +20-Jun-03,26.34,26.38,26.01,26.33,86048896,26.18 +19-Jun-03,26.09,26.39,26.01,26.07,63626900,25.92 \ No newline at end of file diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/s1045.ima.gz b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/s1045.ima.gz new file mode 100644 index 00000000..347db4c0 Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/s1045.ima.gz differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/topobathy.npz b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/topobathy.npz new file mode 100644 index 00000000..9f9b085f Binary files /dev/null and b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/topobathy.npz differ diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/Solarize_Light2.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/Solarize_Light2.mplstyle new file mode 100644 index 00000000..41872131 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/Solarize_Light2.mplstyle @@ -0,0 +1,53 @@ +# Solarized color palette taken from https://ethanschoonover.com/solarized/ +# Inspired by, and copied from ggthemes https://github.com/jrnold/ggthemes + +#TODO: +# 1. Padding to title from face +# 2. Remove top & right ticks +# 3. Give Title a Magenta Color(?) + +#base00 ='#657b83' +#base01 ='#93a1a1' +#base2 ='#eee8d5' +#base3 ='#fdf6e3' +#base01 ='#586e75' +#Magenta ='#d33682' +#Blue ='#268bd2' +#cyan ='#2aa198' +#violet ='#6c71c4' +#green ='#859900' +#orange ='#cb4b16' + +figure.facecolor : FDF6E3 + +patch.antialiased : True + +lines.linewidth : 2.0 +lines.solid_capstyle: butt + +axes.titlesize : 16 +axes.labelsize : 12 +axes.labelcolor : 657b83 +axes.facecolor : eee8d5 +axes.edgecolor : eee8d5 +axes.axisbelow : True +axes.prop_cycle : cycler('color', ['268BD2', '2AA198', '859900', 'B58900', 'CB4B16', 'DC322F', 'D33682', '6C71C4']) +# Blue +# Cyan +# Green +# Yellow +# Orange +# Red +# Magenta +# Violet +axes.grid : True +grid.color : fdf6e3 # grid color +grid.linestyle : - # line +grid.linewidth : 1 # in points + +### TICKS +xtick.color : 657b83 +xtick.direction : out + +ytick.color : 657b83 +ytick.direction : out diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle new file mode 100644 index 00000000..96f62f4b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle @@ -0,0 +1,6 @@ +# This patch should go on top of the "classic" style and exists solely to avoid +# changing baseline images. + +text.kerning_factor : 6 + +ytick.alignment: center_baseline diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle new file mode 100644 index 00000000..911658fe --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle @@ -0,0 +1,19 @@ +# This style is used for the plot_types gallery. It is considered private. + +axes.grid: False +axes.axisbelow: True + +figure.figsize: 2, 2 +# make it so the axes labels don't show up. Obviously +# not good style for any quantitative analysis: +figure.subplot.left: 0.01 +figure.subplot.right: 0.99 +figure.subplot.bottom: 0.01 +figure.subplot.top: 0.99 + +xtick.major.size: 0.0 +ytick.major.size: 0.0 + +# colors: +image.cmap : Blues +axes.prop_cycle: cycler('color', ['1f77b4', '82bbdb', 'ccdff1']) diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle new file mode 100644 index 00000000..75c95bf1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle @@ -0,0 +1,19 @@ +# This style is used for the plot_types gallery. It is considered part of the private API. + +axes.grid: True +axes.axisbelow: True + +figure.figsize: 2, 2 +# make it so the axes labels don't show up. Obviously +# not good style for any quantitative analysis: +figure.subplot.left: 0.01 +figure.subplot.right: 0.99 +figure.subplot.bottom: 0.01 +figure.subplot.top: 0.99 + +xtick.major.size: 0.0 +ytick.major.size: 0.0 + +# colors: +image.cmap : Blues +axes.prop_cycle: cycler('color', ['1f77b4', '58a1cf', 'abd0e6']) diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/bmh.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/bmh.mplstyle new file mode 100644 index 00000000..1b449cc0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/bmh.mplstyle @@ -0,0 +1,29 @@ +#Author: Cameron Davidson-Pilon, original styles from Bayesian Methods for Hackers +# https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ + +lines.linewidth : 2.0 + +patch.linewidth: 0.5 +patch.facecolor: blue +patch.edgecolor: eeeeee +patch.antialiased: True + +text.hinting_factor : 8 + +mathtext.fontset : cm + +axes.facecolor: eeeeee +axes.edgecolor: bcbcbc +axes.grid : True +axes.titlesize: x-large +axes.labelsize: large +axes.prop_cycle: cycler('color', ['348ABD', 'A60628', '7A68A6', '467821', 'D55E00', 'CC79A7', '56B4E9', '009E73', 'F0E442', '0072B2']) + +grid.color: b2b2b2 +grid.linestyle: -- +grid.linewidth: 0.5 + +legend.fancybox: True + +xtick.direction: in +ytick.direction: in diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/classic.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/classic.mplstyle new file mode 100644 index 00000000..976ab291 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/classic.mplstyle @@ -0,0 +1,493 @@ +### Classic matplotlib plotting style as of v1.5 + + +### LINES +# See https://matplotlib.org/api/artist_api.html#module-matplotlib.lines for more +# information on line properties. +lines.linewidth : 1.0 # line width in points +lines.linestyle : - # solid line +lines.color : b # has no affect on plot(); see axes.prop_cycle +lines.marker : None # the default marker +lines.markerfacecolor : auto # the default markerfacecolor +lines.markeredgecolor : auto # the default markeredgecolor +lines.markeredgewidth : 0.5 # the line width around the marker symbol +lines.markersize : 6 # markersize, in points +lines.dash_joinstyle : round # miter|round|bevel +lines.dash_capstyle : butt # butt|round|projecting +lines.solid_joinstyle : round # miter|round|bevel +lines.solid_capstyle : projecting # butt|round|projecting +lines.antialiased : True # render lines in antialiased (no jaggies) +lines.dashed_pattern : 6, 6 +lines.dashdot_pattern : 3, 5, 1, 5 +lines.dotted_pattern : 1, 3 +lines.scale_dashes: False + +### Marker props +markers.fillstyle: full + +### PATCHES +# Patches are graphical objects that fill 2D space, like polygons or +# circles. See +# https://matplotlib.org/api/artist_api.html#module-matplotlib.patches +# information on patch properties +patch.linewidth : 1.0 # edge width in points +patch.facecolor : b +patch.force_edgecolor : True +patch.edgecolor : k +patch.antialiased : True # render patches in antialiased (no jaggies) + +hatch.color : k +hatch.linewidth : 1.0 + +hist.bins : 10 + +### FONT +# +# font properties used by text.Text. See +# https://matplotlib.org/api/font_manager_api.html for more +# information on font properties. The 6 font properties used for font +# matching are given below with their default values. +# +# The font.family property has five values: 'serif' (e.g., Times), +# 'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery), +# 'fantasy' (e.g., Western), and 'monospace' (e.g., Courier). Each of +# these font families has a default list of font names in decreasing +# order of priority associated with them. When text.usetex is False, +# font.family may also be one or more concrete font names. +# +# The font.style property has three values: normal (or roman), italic +# or oblique. The oblique style will be used for italic, if it is not +# present. +# +# The font.variant property has two values: normal or small-caps. For +# TrueType fonts, which are scalable fonts, small-caps is equivalent +# to using a font size of 'smaller', or about 83% of the current font +# size. +# +# The font.weight property has effectively 13 values: normal, bold, +# bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as +# 400, and bold is 700. bolder and lighter are relative values with +# respect to the current weight. +# +# The font.stretch property has 11 values: ultra-condensed, +# extra-condensed, condensed, semi-condensed, normal, semi-expanded, +# expanded, extra-expanded, ultra-expanded, wider, and narrower. This +# property is not currently implemented. +# +# The font.size property is the default font size for text, given in pts. +# 12pt is the standard value. +# +font.family : sans-serif +font.style : normal +font.variant : normal +font.weight : normal +font.stretch : normal +# note that font.size controls default text sizes. To configure +# special text sizes tick labels, axes, labels, title, etc, see the rc +# settings for axes and ticks. Special text sizes can be defined +# relative to font.size, using the following values: xx-small, x-small, +# small, medium, large, x-large, xx-large, larger, or smaller +font.size : 12.0 +font.serif : DejaVu Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif +font.sans-serif: DejaVu Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif +font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive +font.fantasy : Comic Sans MS, Chicago, Charcoal, ImpactWestern, xkcd script, fantasy +font.monospace : DejaVu Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace + +### TEXT +# text properties used by text.Text. See +# https://matplotlib.org/api/artist_api.html#module-matplotlib.text for more +# information on text properties + +text.color : k + +### LaTeX customizations. See http://www.scipy.org/Wiki/Cookbook/Matplotlib/UsingTex +text.usetex : False # use latex for all text handling. The following fonts + # are supported through the usual rc parameter settings: + # new century schoolbook, bookman, times, palatino, + # zapf chancery, charter, serif, sans-serif, helvetica, + # avant garde, courier, monospace, computer modern roman, + # computer modern sans serif, computer modern typewriter + # If another font is desired which can loaded using the + # LaTeX \usepackage command, please inquire at the + # matplotlib mailing list +text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES + # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP + # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. + # text.latex.preamble is a single line of LaTeX code that + # will be passed on to the LaTeX system. It may contain + # any code that is valid for the LaTeX "preamble", i.e. + # between the "\documentclass" and "\begin{document}" + # statements. + # Note that it has to be put on a single line, which may + # become quite long. + # The following packages are always loaded with usetex, so + # beware of package collisions: color, geometry, graphicx, + # type1cm, textcomp. + # Adobe Postscript (PSSNFS) font packages may also be + # loaded, depending on your font settings. + +text.hinting : auto # May be one of the following: + # 'none': Perform no hinting + # 'auto': Use freetype's autohinter + # 'native': Use the hinting information in the + # font file, if available, and if your + # freetype library supports it + # 'either': Use the native hinting information, + # or the autohinter if none is available. + # For backward compatibility, this value may also be + # True === 'auto' or False === 'none'. +text.hinting_factor : 8 # Specifies the amount of softness for hinting in the + # horizontal direction. A value of 1 will hint to full + # pixels. A value of 2 will hint to half pixels etc. + +text.antialiased : True # If True (default), the text will be antialiased. + # This only affects the Agg backend. + +# The following settings allow you to select the fonts in math mode. +# They map from a TeX font name to a fontconfig font pattern. +# These settings are only used if mathtext.fontset is 'custom'. +# Note that this "custom" mode is unsupported and may go away in the +# future. +mathtext.cal : cursive +mathtext.rm : serif +mathtext.tt : monospace +mathtext.it : serif:italic +mathtext.bf : serif:bold +mathtext.sf : sans\-serif +mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix', + # 'stixsans' or 'custom' +mathtext.fallback: cm # Select fallback font from ['cm' (Computer Modern), 'stix' + # 'stixsans'] when a symbol cannot be found in one of the + # custom math fonts. Select 'None' to not perform fallback + # and replace the missing character by a dummy. + +mathtext.default : it # The default font to use for math. + # Can be any of the LaTeX font names, including + # the special name "regular" for the same font + # used in regular text. + +### AXES +# default face and edge color, default tick sizes, +# default fontsizes for ticklabels, and so on. See +# https://matplotlib.org/api/axes_api.html#module-matplotlib.axes +axes.facecolor : w # axes background color +axes.edgecolor : k # axes edge color +axes.linewidth : 1.0 # edge linewidth +axes.grid : False # display grid or not +axes.grid.which : major +axes.grid.axis : both +axes.titlesize : large # fontsize of the axes title +axes.titley : 1.0 # at the top, no autopositioning. +axes.titlepad : 5.0 # pad between axes and title in points +axes.titleweight : normal # font weight for axes title +axes.labelsize : medium # fontsize of the x any y labels +axes.labelpad : 5.0 # space between label and axis +axes.labelweight : normal # weight of the x and y labels +axes.labelcolor : k +axes.axisbelow : False # whether axis gridlines and ticks are below + # the axes elements (lines, text, etc) + +axes.formatter.limits : -7, 7 # use scientific notation if log10 + # of the axis range is smaller than the + # first or larger than the second +axes.formatter.use_locale : False # When True, format tick labels + # according to the user's locale. + # For example, use ',' as a decimal + # separator in the fr_FR locale. +axes.formatter.use_mathtext : False # When True, use mathtext for scientific + # notation. +axes.formatter.useoffset : True # If True, the tick label formatter + # will default to labeling ticks relative + # to an offset when the data range is very + # small compared to the minimum absolute + # value of the data. +axes.formatter.offset_threshold : 2 # When useoffset is True, the offset + # will be used when it can remove + # at least this number of significant + # digits from tick labels. + +axes.unicode_minus : True # use Unicode for the minus symbol + # rather than hyphen. See + # https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes +axes.prop_cycle : cycler('color', 'bgrcmyk') + # color cycle for plot lines + # as list of string colorspecs: + # single letter, long name, or + # web-style hex +axes.autolimit_mode : round_numbers +axes.xmargin : 0 # x margin. See `axes.Axes.margins` +axes.ymargin : 0 # y margin See `axes.Axes.margins` +axes.spines.bottom : True +axes.spines.left : True +axes.spines.right : True +axes.spines.top : True +polaraxes.grid : True # display grid on polar axes +axes3d.grid : True # display grid on 3D axes +axes3d.automargin : False # automatically add margin when manually setting 3D axis limits + +date.autoformatter.year : %Y +date.autoformatter.month : %b %Y +date.autoformatter.day : %b %d %Y +date.autoformatter.hour : %H:%M:%S +date.autoformatter.minute : %H:%M:%S.%f +date.autoformatter.second : %H:%M:%S.%f +date.autoformatter.microsecond : %H:%M:%S.%f +date.converter: auto # 'auto', 'concise' + +### TICKS +# see https://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick + +xtick.top : True # draw ticks on the top side +xtick.bottom : True # draw ticks on the bottom side +xtick.major.size : 4 # major tick size in points +xtick.minor.size : 2 # minor tick size in points +xtick.minor.visible : False +xtick.major.width : 0.5 # major tick width in points +xtick.minor.width : 0.5 # minor tick width in points +xtick.major.pad : 4 # distance to major tick label in points +xtick.minor.pad : 4 # distance to the minor tick label in points +xtick.color : k # color of the tick labels +xtick.labelsize : medium # fontsize of the tick labels +xtick.direction : in # direction: in, out, or inout +xtick.major.top : True # draw x axis top major ticks +xtick.major.bottom : True # draw x axis bottom major ticks +xtick.minor.top : True # draw x axis top minor ticks +xtick.minor.bottom : True # draw x axis bottom minor ticks +xtick.alignment : center + +ytick.left : True # draw ticks on the left side +ytick.right : True # draw ticks on the right side +ytick.major.size : 4 # major tick size in points +ytick.minor.size : 2 # minor tick size in points +ytick.minor.visible : False +ytick.major.width : 0.5 # major tick width in points +ytick.minor.width : 0.5 # minor tick width in points +ytick.major.pad : 4 # distance to major tick label in points +ytick.minor.pad : 4 # distance to the minor tick label in points +ytick.color : k # color of the tick labels +ytick.labelsize : medium # fontsize of the tick labels +ytick.direction : in # direction: in, out, or inout +ytick.major.left : True # draw y axis left major ticks +ytick.major.right : True # draw y axis right major ticks +ytick.minor.left : True # draw y axis left minor ticks +ytick.minor.right : True # draw y axis right minor ticks +ytick.alignment : center + +### GRIDS +grid.color : k # grid color +grid.linestyle : : # dotted +grid.linewidth : 0.5 # in points +grid.alpha : 1.0 # transparency, between 0.0 and 1.0 + +### Legend +legend.fancybox : False # if True, use a rounded box for the + # legend, else a rectangle +legend.loc : upper right +legend.numpoints : 2 # the number of points in the legend line +legend.fontsize : large +legend.borderpad : 0.4 # border whitespace in fontsize units +legend.markerscale : 1.0 # the relative size of legend markers vs. original +# the following dimensions are in axes coords +legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize +legend.handlelength : 2. # the length of the legend lines in fraction of fontsize +legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize +legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize +legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize +legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize +legend.shadow : False +legend.frameon : True # whether or not to draw a frame around legend +legend.framealpha : None # opacity of legend frame +legend.scatterpoints : 3 # number of scatter points +legend.facecolor : inherit # legend background color (when 'inherit' uses axes.facecolor) +legend.edgecolor : inherit # legend edge color (when 'inherit' uses axes.edgecolor) + + + +### FIGURE +# See https://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure +figure.titlesize : medium # size of the figure title +figure.titleweight : normal # weight of the figure title +figure.labelsize: medium # size of the figure label +figure.labelweight: normal # weight of the figure label +figure.figsize : 8, 6 # figure size in inches +figure.dpi : 80 # figure dots per inch +figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray +figure.edgecolor : w # figure edgecolor +figure.autolayout : False # When True, automatically adjust subplot + # parameters to make the plot fit the figure +figure.frameon : True + +# The figure subplot parameters. All dimensions are a fraction of the +# figure width or height +figure.subplot.left : 0.125 # the left side of the subplots of the figure +figure.subplot.right : 0.9 # the right side of the subplots of the figure +figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure +figure.subplot.top : 0.9 # the top of the subplots of the figure +figure.subplot.wspace : 0.2 # the amount of width reserved for space between subplots, + # expressed as a fraction of the average axis width +figure.subplot.hspace : 0.2 # the amount of height reserved for space between subplots, + # expressed as a fraction of the average axis height + +### IMAGES +image.aspect : equal # equal | auto | a number +image.interpolation : bilinear # see help(imshow) for options +image.cmap : jet # gray | jet | ... +image.lut : 256 # the size of the colormap lookup table +image.origin : upper # lower | upper +image.resample : False +image.composite_image : True + +### CONTOUR PLOTS +contour.negative_linestyle : dashed # dashed | solid +contour.corner_mask : True + +# errorbar props +errorbar.capsize: 3 + +# scatter props +scatter.marker: o + +### Boxplots +boxplot.bootstrap: None +boxplot.boxprops.color: b +boxplot.boxprops.linestyle: - +boxplot.boxprops.linewidth: 1.0 +boxplot.capprops.color: k +boxplot.capprops.linestyle: - +boxplot.capprops.linewidth: 1.0 +boxplot.flierprops.color: b +boxplot.flierprops.linestyle: none +boxplot.flierprops.linewidth: 1.0 +boxplot.flierprops.marker: + +boxplot.flierprops.markeredgecolor: k +boxplot.flierprops.markerfacecolor: auto +boxplot.flierprops.markersize: 6.0 +boxplot.meanline: False +boxplot.meanprops.color: r +boxplot.meanprops.linestyle: - +boxplot.meanprops.linewidth: 1.0 +boxplot.medianprops.color: r +boxplot.meanprops.marker: s +boxplot.meanprops.markerfacecolor: r +boxplot.meanprops.markeredgecolor: k +boxplot.meanprops.markersize: 6.0 +boxplot.medianprops.linestyle: - +boxplot.medianprops.linewidth: 1.0 +boxplot.notch: False +boxplot.patchartist: False +boxplot.showbox: True +boxplot.showcaps: True +boxplot.showfliers: True +boxplot.showmeans: False +boxplot.vertical: True +boxplot.whiskerprops.color: b +boxplot.whiskerprops.linestyle: -- +boxplot.whiskerprops.linewidth: 1.0 +boxplot.whiskers: 1.5 + +### Agg rendering +### Warning: experimental, 2008/10/10 +agg.path.chunksize : 0 # 0 to disable; values in the range + # 10000 to 100000 can improve speed slightly + # and prevent an Agg rendering failure + # when plotting very large data sets, + # especially if they are very gappy. + # It may cause minor artifacts, though. + # A value of 20000 is probably a good + # starting point. +### SAVING FIGURES +path.simplify : True # When True, simplify paths by removing "invisible" + # points to reduce file size and increase rendering + # speed +path.simplify_threshold : 0.1111111111111111 + # The threshold of similarity below which + # vertices will be removed in the simplification + # process +path.snap : True # When True, rectilinear axis-aligned paths will be snapped to + # the nearest pixel when certain criteria are met. When False, + # paths will never be snapped. +path.sketch : None # May be none, or a 3-tuple of the form (scale, length, + # randomness). + # *scale* is the amplitude of the wiggle + # perpendicular to the line (in pixels). *length* + # is the length of the wiggle along the line (in + # pixels). *randomness* is the factor by which + # the length is randomly scaled. + +# the default savefig params can be different from the display params +# e.g., you may want a higher resolution, or to make the figure +# background white +savefig.dpi : 100 # figure dots per inch +savefig.facecolor : w # figure facecolor when saving +savefig.edgecolor : w # figure edgecolor when saving +savefig.format : png # png, ps, pdf, svg +savefig.bbox : standard # 'tight' or 'standard'. + # 'tight' is incompatible with pipe-based animation + # backends (e.g. 'ffmpeg') but will work with those + # based on temporary files (e.g. 'ffmpeg_file') +savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight' +savefig.transparent : False # setting that controls whether figures are saved with a + # transparent background by default +savefig.orientation : portrait + +# ps backend params +ps.papersize : letter # auto, letter, legal, ledger, A0-A10, B0-B10 +ps.useafm : False # use of afm fonts, results in small files +ps.usedistiller : False # can be: None, ghostscript or xpdf + # Experimental: may produce smaller files. + # xpdf intended for production of publication quality files, + # but requires ghostscript, xpdf and ps2eps +ps.distiller.res : 6000 # dpi +ps.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) + +# pdf backend params +pdf.compression : 6 # integer from 0 to 9 + # 0 disables compression (good for debugging) +pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) +pdf.inheritcolor : False +pdf.use14corefonts : False + +# pgf backend params +pgf.texsystem : xelatex +pgf.rcfonts : True +pgf.preamble : + +# svg backend params +svg.image_inline : True # write raster image data directly into the svg file +svg.fonttype : path # How to handle SVG fonts: +# 'none': Assume fonts are installed on the machine where the SVG will be viewed. +# 'path': Embed characters as paths -- supported by most SVG renderers + +# Event keys to interact with figures/plots via keyboard. +# Customize these settings according to your needs. +# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '') + +keymap.fullscreen : f, ctrl+f # toggling +keymap.home : h, r, home # home or reset mnemonic +keymap.back : left, c, backspace # forward / backward keys to enable +keymap.forward : right, v # left handed quick navigation +keymap.pan : p # pan mnemonic +keymap.zoom : o # zoom mnemonic +keymap.save : s, ctrl+s # saving current figure +keymap.quit : ctrl+w, cmd+w # close the current figure +keymap.grid : g # switching on/off a grid in current axes +keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') +keymap.xscale : k, L # toggle scaling of x-axes ('log'/'linear') + +###ANIMATION settings +animation.writer : ffmpeg # MovieWriter 'backend' to use +animation.codec : mpeg4 # Codec to use for writing movie +animation.bitrate: -1 # Controls size/quality tradeoff for movie. + # -1 implies let utility auto-determine +animation.frame_format: png # Controls frame format used by temp files +animation.ffmpeg_path: ffmpeg # Path to ffmpeg binary. Without full path + # $PATH is searched +animation.ffmpeg_args: # Additional arguments to pass to ffmpeg +animation.convert_path: convert # Path to ImageMagick's convert binary. + # On Windows use the full path since convert + # is also the name of a system tool. +animation.convert_args: +animation.html: none + +_internal.classic_mode: True diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/dark_background.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/dark_background.mplstyle new file mode 100644 index 00000000..c4b7741a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/dark_background.mplstyle @@ -0,0 +1,29 @@ +# Set black background default line colors to white. + +lines.color: white +patch.edgecolor: white + +text.color: white + +axes.facecolor: black +axes.edgecolor: white +axes.labelcolor: white +axes.prop_cycle: cycler('color', ['8dd3c7', 'feffb3', 'bfbbd9', 'fa8174', '81b1d2', 'fdb462', 'b3de69', 'bc82bd', 'ccebc4', 'ffed6f']) + +xtick.color: white +ytick.color: white + +grid.color: white + +figure.facecolor: black +figure.edgecolor: black + +savefig.facecolor: black +savefig.edgecolor: black + +### Boxplots +boxplot.boxprops.color: white +boxplot.capprops.color: white +boxplot.flierprops.color: white +boxplot.flierprops.markeredgecolor: white +boxplot.whiskerprops.color: white diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fast.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fast.mplstyle new file mode 100644 index 00000000..1f7be7d4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fast.mplstyle @@ -0,0 +1,11 @@ +# a small set of changes that will make your plotting FAST (1). +# +# (1) in some cases + +# Maximally simplify lines. +path.simplify: True +path.simplify_threshold: 1.0 + +# chunk up large lines into smaller lines! +# simple trick to avoid those pesky O(>n) algorithms! +agg.path.chunksize: 10000 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fivethirtyeight.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fivethirtyeight.mplstyle new file mode 100644 index 00000000..738db39f --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/fivethirtyeight.mplstyle @@ -0,0 +1,40 @@ +#Author: Cameron Davidson-Pilon, replicated styles from FiveThirtyEight.com +# See https://www.dataorigami.net/blogs/fivethirtyeight-mpl + +lines.linewidth: 4 +lines.solid_capstyle: butt + +legend.fancybox: true + +axes.prop_cycle: cycler('color', ['008fd5', 'fc4f30', 'e5ae38', '6d904f', '8b8b8b', '810f7c']) +axes.facecolor: f0f0f0 +axes.labelsize: large +axes.axisbelow: true +axes.grid: true +axes.edgecolor: f0f0f0 +axes.linewidth: 3.0 +axes.titlesize: x-large + +patch.edgecolor: f0f0f0 +patch.linewidth: 0.5 + +svg.fonttype: path + +grid.linestyle: - +grid.linewidth: 1.0 +grid.color: cbcbcb + +xtick.major.size: 0 +xtick.minor.size: 0 +ytick.major.size: 0 +ytick.minor.size: 0 + +font.size:14.0 + +savefig.edgecolor: f0f0f0 +savefig.facecolor: f0f0f0 + +figure.subplot.left: 0.08 +figure.subplot.right: 0.95 +figure.subplot.bottom: 0.07 +figure.facecolor: f0f0f0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/ggplot.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/ggplot.mplstyle new file mode 100644 index 00000000..d1b3ba2e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/ggplot.mplstyle @@ -0,0 +1,39 @@ +# from https://everyhue.me/posts/sane-color-scheme-for-matplotlib/ + +patch.linewidth: 0.5 +patch.facecolor: 348ABD # blue +patch.edgecolor: EEEEEE +patch.antialiased: True + +font.size: 10.0 + +axes.facecolor: E5E5E5 +axes.edgecolor: white +axes.linewidth: 1 +axes.grid: True +axes.titlesize: x-large +axes.labelsize: large +axes.labelcolor: 555555 +axes.axisbelow: True # grid/ticks are below elements (e.g., lines, text) + +axes.prop_cycle: cycler('color', ['E24A33', '348ABD', '988ED5', '777777', 'FBC15E', '8EBA42', 'FFB5B8']) + # E24A33 : red + # 348ABD : blue + # 988ED5 : purple + # 777777 : gray + # FBC15E : yellow + # 8EBA42 : green + # FFB5B8 : pink + +xtick.color: 555555 +xtick.direction: out + +ytick.color: 555555 +ytick.direction: out + +grid.color: white +grid.linestyle: - # solid line + +figure.facecolor: white +figure.edgecolor: 0.50 + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/grayscale.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/grayscale.mplstyle new file mode 100644 index 00000000..6a1114e4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/grayscale.mplstyle @@ -0,0 +1,29 @@ +# Set all colors to grayscale +# Note: strings of float values are interpreted by matplotlib as gray values. + + +lines.color: black +patch.facecolor: gray +patch.edgecolor: black + +text.color: black + +axes.facecolor: white +axes.edgecolor: black +axes.labelcolor: black +# black to light gray +axes.prop_cycle: cycler('color', ['0.00', '0.40', '0.60', '0.70']) + +xtick.color: black +ytick.color: black + +grid.color: black + +figure.facecolor: 0.75 +figure.edgecolor: white + +image.cmap: gray + +savefig.facecolor: white +savefig.edgecolor: white + diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle new file mode 100644 index 00000000..5e9e9493 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle @@ -0,0 +1,3 @@ +# Seaborn bright palette +axes.prop_cycle: cycler('color', ['003FFF', '03ED3A', 'E8000B', '8A2BE2', 'FFC400', '00D7FF']) +patch.facecolor: 003FFF diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle new file mode 100644 index 00000000..e13b7aad --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle @@ -0,0 +1,3 @@ +# Seaborn colorblind palette +axes.prop_cycle: cycler('color', ['0072B2', '009E73', 'D55E00', 'CC79A7', 'F0E442', '56B4E9']) +patch.facecolor: 0072B2 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle new file mode 100644 index 00000000..30160ae2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle @@ -0,0 +1,3 @@ +# Seaborn dark palette +axes.prop_cycle: cycler('color', ['001C7F', '017517', '8C0900', '7600A1', 'B8860B', '006374']) +patch.facecolor: 001C7F diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle new file mode 100644 index 00000000..55b50b5b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle @@ -0,0 +1,30 @@ +# Seaborn common parameters +# .15 = dark_gray +# .8 = light_gray +figure.facecolor: white +text.color: .15 +axes.labelcolor: .15 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 +axes.axisbelow: True +image.cmap: Greys +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +grid.linestyle: - +lines.solid_capstyle: round + +# Seaborn dark parameters +axes.grid: False +axes.facecolor: EAEAF2 +axes.edgecolor: white +axes.linewidth: 0 +grid.color: white +xtick.major.size: 0 +ytick.major.size: 0 +xtick.minor.size: 0 +ytick.minor.size: 0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle new file mode 100644 index 00000000..0f5d955d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle @@ -0,0 +1,30 @@ +# Seaborn common parameters +# .15 = dark_gray +# .8 = light_gray +figure.facecolor: white +text.color: .15 +axes.labelcolor: .15 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 +axes.axisbelow: True +image.cmap: Greys +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +grid.linestyle: - +lines.solid_capstyle: round + +# Seaborn darkgrid parameters +axes.grid: True +axes.facecolor: EAEAF2 +axes.edgecolor: white +axes.linewidth: 0 +grid.color: white +xtick.major.size: 0 +ytick.major.size: 0 +xtick.minor.size: 0 +ytick.minor.size: 0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle new file mode 100644 index 00000000..5d6b7c56 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle @@ -0,0 +1,3 @@ +# Seaborn deep palette +axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B2', 'CCB974', '64B5CD']) +patch.facecolor: 4C72B0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle new file mode 100644 index 00000000..4a71646c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle @@ -0,0 +1,3 @@ +# Seaborn muted palette +axes.prop_cycle: cycler('color', ['4878CF', '6ACC65', 'D65F5F', 'B47CC7', 'C4AD66', '77BEDB']) +patch.facecolor: 4878CF diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle new file mode 100644 index 00000000..18bcf3e1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle @@ -0,0 +1,21 @@ +# Seaborn notebook context +figure.figsize: 8.0, 5.5 +axes.labelsize: 11 +axes.titlesize: 12 +xtick.labelsize: 10 +ytick.labelsize: 10 +legend.fontsize: 10 + +grid.linewidth: 1 +lines.linewidth: 1.75 +patch.linewidth: .3 +lines.markersize: 7 +lines.markeredgewidth: 0 + +xtick.major.width: 1 +ytick.major.width: 1 +xtick.minor.width: .5 +ytick.minor.width: .5 + +xtick.major.pad: 7 +ytick.major.pad: 7 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle new file mode 100644 index 00000000..3326be43 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle @@ -0,0 +1,21 @@ +# Seaborn paper context +figure.figsize: 6.4, 4.4 +axes.labelsize: 8.8 +axes.titlesize: 9.6 +xtick.labelsize: 8 +ytick.labelsize: 8 +legend.fontsize: 8 + +grid.linewidth: 0.8 +lines.linewidth: 1.4 +patch.linewidth: 0.24 +lines.markersize: 5.6 +lines.markeredgewidth: 0 + +xtick.major.width: 0.8 +ytick.major.width: 0.8 +xtick.minor.width: 0.4 +ytick.minor.width: 0.4 + +xtick.major.pad: 5.6 +ytick.major.pad: 5.6 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle new file mode 100644 index 00000000..dff67482 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle @@ -0,0 +1,3 @@ +# Seaborn pastel palette +axes.prop_cycle: cycler('color', ['92C6FF', '97F0AA', 'FF9F9A', 'D0BBFF', 'FFFEA3', 'B0E0E6']) +patch.facecolor: 92C6FF diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle new file mode 100644 index 00000000..47f23700 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle @@ -0,0 +1,21 @@ +# Seaborn poster context +figure.figsize: 12.8, 8.8 +axes.labelsize: 17.6 +axes.titlesize: 19.2 +xtick.labelsize: 16 +ytick.labelsize: 16 +legend.fontsize: 16 + +grid.linewidth: 1.6 +lines.linewidth: 2.8 +patch.linewidth: 0.48 +lines.markersize: 11.2 +lines.markeredgewidth: 0 + +xtick.major.width: 1.6 +ytick.major.width: 1.6 +xtick.minor.width: 0.8 +ytick.minor.width: 0.8 + +xtick.major.pad: 11.2 +ytick.major.pad: 11.2 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle new file mode 100644 index 00000000..29a77c53 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle @@ -0,0 +1,21 @@ +# Seaborn talk context +figure.figsize: 10.4, 7.15 +axes.labelsize: 14.3 +axes.titlesize: 15.6 +xtick.labelsize: 13 +ytick.labelsize: 13 +legend.fontsize: 13 + +grid.linewidth: 1.3 +lines.linewidth: 2.275 +patch.linewidth: 0.39 +lines.markersize: 9.1 +lines.markeredgewidth: 0 + +xtick.major.width: 1.3 +ytick.major.width: 1.3 +xtick.minor.width: 0.65 +ytick.minor.width: 0.65 + +xtick.major.pad: 9.1 +ytick.major.pad: 9.1 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle new file mode 100644 index 00000000..c2a1cab9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle @@ -0,0 +1,30 @@ +# Seaborn common parameters +# .15 = dark_gray +# .8 = light_gray +figure.facecolor: white +text.color: .15 +axes.labelcolor: .15 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 +axes.axisbelow: True +image.cmap: Greys +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +grid.linestyle: - +lines.solid_capstyle: round + +# Seaborn white parameters +axes.grid: False +axes.facecolor: white +axes.edgecolor: .15 +axes.linewidth: 1.25 +grid.color: .8 +xtick.major.size: 6 +ytick.major.size: 6 +xtick.minor.size: 3 +ytick.minor.size: 3 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-white.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-white.mplstyle new file mode 100644 index 00000000..dcbe3acf --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-white.mplstyle @@ -0,0 +1,30 @@ +# Seaborn common parameters +# .15 = dark_gray +# .8 = light_gray +figure.facecolor: white +text.color: .15 +axes.labelcolor: .15 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 +axes.axisbelow: True +image.cmap: Greys +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +grid.linestyle: - +lines.solid_capstyle: round + +# Seaborn white parameters +axes.grid: False +axes.facecolor: white +axes.edgecolor: .15 +axes.linewidth: 1.25 +grid.color: .8 +xtick.major.size: 0 +ytick.major.size: 0 +xtick.minor.size: 0 +ytick.minor.size: 0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle new file mode 100644 index 00000000..612e2181 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle @@ -0,0 +1,30 @@ +# Seaborn common parameters +# .15 = dark_gray +# .8 = light_gray +figure.facecolor: white +text.color: .15 +axes.labelcolor: .15 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 +axes.axisbelow: True +image.cmap: Greys +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +grid.linestyle: - +lines.solid_capstyle: round + +# Seaborn whitegrid parameters +axes.grid: True +axes.facecolor: white +axes.edgecolor: .8 +axes.linewidth: 1 +grid.color: .8 +xtick.major.size: 0 +ytick.major.size: 0 +xtick.minor.size: 0 +ytick.minor.size: 0 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8.mplstyle new file mode 100644 index 00000000..94b1bc83 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/seaborn-v0_8.mplstyle @@ -0,0 +1,57 @@ +# default seaborn aesthetic +# darkgrid + deep palette + notebook context + +axes.axisbelow: True +axes.edgecolor: white +axes.facecolor: EAEAF2 +axes.grid: True +axes.labelcolor: .15 +axes.labelsize: 11 +axes.linewidth: 0 +axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B2', 'CCB974', '64B5CD']) +axes.titlesize: 12 + +figure.facecolor: white +figure.figsize: 8.0, 5.5 + +font.family: sans-serif +font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif + +grid.color: white +grid.linestyle: - +grid.linewidth: 1 + +image.cmap: Greys + +legend.fontsize: 10 +legend.frameon: False +legend.numpoints: 1 +legend.scatterpoints: 1 + +lines.linewidth: 1.75 +lines.markeredgewidth: 0 +lines.markersize: 7 +lines.solid_capstyle: round + +patch.facecolor: 4C72B0 +patch.linewidth: .3 + +text.color: .15 + +xtick.color: .15 +xtick.direction: out +xtick.labelsize: 10 +xtick.major.pad: 7 +xtick.major.size: 0 +xtick.major.width: 1 +xtick.minor.size: 0 +xtick.minor.width: .5 + +ytick.color: .15 +ytick.direction: out +ytick.labelsize: 10 +ytick.major.pad: 7 +ytick.major.size: 0 +ytick.major.width: 1 +ytick.minor.size: 0 +ytick.minor.width: .5 diff --git a/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/tableau-colorblind10.mplstyle b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/tableau-colorblind10.mplstyle new file mode 100644 index 00000000..2d8cb020 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/mpl-data/stylelib/tableau-colorblind10.mplstyle @@ -0,0 +1,3 @@ +# Tableau colorblind 10 palette +axes.prop_cycle: cycler('color', ['006BA4', 'FF800E', 'ABABAB', '595959', '5F9ED1', 'C85200', '898989', 'A2C8EC', 'FFBC79', 'CFCFCF']) +patch.facecolor: 006BA4 \ No newline at end of file diff --git a/venv/lib/python3.10/site-packages/matplotlib/offsetbox.py b/venv/lib/python3.10/site-packages/matplotlib/offsetbox.py new file mode 100644 index 00000000..32c5bafc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/offsetbox.py @@ -0,0 +1,1569 @@ +r""" +Container classes for `.Artist`\s. + +`OffsetBox` + The base of all container artists defined in this module. + +`AnchoredOffsetbox`, `AnchoredText` + Anchor and align an arbitrary `.Artist` or a text relative to the parent + axes or a specific anchor point. + +`DrawingArea` + A container with fixed width and height. Children have a fixed position + inside the container and may be clipped. + +`HPacker`, `VPacker` + Containers for layouting their children vertically or horizontally. + +`PaddedBox` + A container to add a padding around an `.Artist`. + +`TextArea` + Contains a single `.Text` instance. +""" + +import functools + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, _docstring +import matplotlib.artist as martist +import matplotlib.path as mpath +import matplotlib.text as mtext +import matplotlib.transforms as mtransforms +from matplotlib.font_manager import FontProperties +from matplotlib.image import BboxImage +from matplotlib.patches import ( + FancyBboxPatch, FancyArrowPatch, bbox_artist as mbbox_artist) +from matplotlib.transforms import Bbox, BboxBase, TransformedBbox + + +DEBUG = False + + +def _compat_get_offset(meth): + """ + Decorator for the get_offset method of OffsetBox and subclasses, that + allows supporting both the new signature (self, bbox, renderer) and the old + signature (self, width, height, xdescent, ydescent, renderer). + """ + sigs = [lambda self, width, height, xdescent, ydescent, renderer: locals(), + lambda self, bbox, renderer: locals()] + + @functools.wraps(meth) + def get_offset(self, *args, **kwargs): + params = _api.select_matching_signature(sigs, self, *args, **kwargs) + bbox = (params["bbox"] if "bbox" in params else + Bbox.from_bounds(-params["xdescent"], -params["ydescent"], + params["width"], params["height"])) + return meth(params["self"], bbox, params["renderer"]) + return get_offset + + +# for debugging use +def _bbox_artist(*args, **kwargs): + if DEBUG: + mbbox_artist(*args, **kwargs) + + +def _get_packed_offsets(widths, total, sep, mode="fixed"): + r""" + Pack boxes specified by their *widths*. + + For simplicity of the description, the terminology used here assumes a + horizontal layout, but the function works equally for a vertical layout. + + There are three packing *mode*\s: + + - 'fixed': The elements are packed tight to the left with a spacing of + *sep* in between. If *total* is *None* the returned total will be the + right edge of the last box. A non-*None* total will be passed unchecked + to the output. In particular this means that right edge of the last + box may be further to the right than the returned total. + + - 'expand': Distribute the boxes with equal spacing so that the left edge + of the first box is at 0, and the right edge of the last box is at + *total*. The parameter *sep* is ignored in this mode. A total of *None* + is accepted and considered equal to 1. The total is returned unchanged + (except for the conversion *None* to 1). If the total is smaller than + the sum of the widths, the laid out boxes will overlap. + + - 'equal': If *total* is given, the total space is divided in N equal + ranges and each box is left-aligned within its subspace. + Otherwise (*total* is *None*), *sep* must be provided and each box is + left-aligned in its subspace of width ``(max(widths) + sep)``. The + total width is then calculated to be ``N * (max(widths) + sep)``. + + Parameters + ---------- + widths : list of float + Widths of boxes to be packed. + total : float or None + Intended total length. *None* if not used. + sep : float or None + Spacing between boxes. + mode : {'fixed', 'expand', 'equal'} + The packing mode. + + Returns + ------- + total : float + The total width needed to accommodate the laid out boxes. + offsets : array of float + The left offsets of the boxes. + """ + _api.check_in_list(["fixed", "expand", "equal"], mode=mode) + + if mode == "fixed": + offsets_ = np.cumsum([0] + [w + sep for w in widths]) + offsets = offsets_[:-1] + if total is None: + total = offsets_[-1] - sep + return total, offsets + + elif mode == "expand": + # This is a bit of a hack to avoid a TypeError when *total* + # is None and used in conjugation with tight layout. + if total is None: + total = 1 + if len(widths) > 1: + sep = (total - sum(widths)) / (len(widths) - 1) + else: + sep = 0 + offsets_ = np.cumsum([0] + [w + sep for w in widths]) + offsets = offsets_[:-1] + return total, offsets + + elif mode == "equal": + maxh = max(widths) + if total is None: + if sep is None: + raise ValueError("total and sep cannot both be None when " + "using layout mode 'equal'") + total = (maxh + sep) * len(widths) + else: + sep = total / len(widths) - maxh + offsets = (maxh + sep) * np.arange(len(widths)) + return total, offsets + + +def _get_aligned_offsets(yspans, height, align="baseline"): + """ + Align boxes each specified by their ``(y0, y1)`` spans. + + For simplicity of the description, the terminology used here assumes a + horizontal layout (i.e., vertical alignment), but the function works + equally for a vertical layout. + + Parameters + ---------- + yspans + List of (y0, y1) spans of boxes to be aligned. + height : float or None + Intended total height. If None, the maximum of the heights + (``y1 - y0``) in *yspans* is used. + align : {'baseline', 'left', 'top', 'right', 'bottom', 'center'} + The alignment anchor of the boxes. + + Returns + ------- + (y0, y1) + y range spanned by the packing. If a *height* was originally passed + in, then for all alignments other than "baseline", a span of ``(0, + height)`` is used without checking that it is actually large enough). + descent + The descent of the packing. + offsets + The bottom offsets of the boxes. + """ + + _api.check_in_list( + ["baseline", "left", "top", "right", "bottom", "center"], align=align) + if height is None: + height = max(y1 - y0 for y0, y1 in yspans) + + if align == "baseline": + yspan = (min(y0 for y0, y1 in yspans), max(y1 for y0, y1 in yspans)) + offsets = [0] * len(yspans) + elif align in ["left", "bottom"]: + yspan = (0, height) + offsets = [-y0 for y0, y1 in yspans] + elif align in ["right", "top"]: + yspan = (0, height) + offsets = [height - y1 for y0, y1 in yspans] + elif align == "center": + yspan = (0, height) + offsets = [(height - (y1 - y0)) * .5 - y0 for y0, y1 in yspans] + + return yspan, offsets + + +class OffsetBox(martist.Artist): + """ + The OffsetBox is a simple container artist. + + The child artists are meant to be drawn at a relative position to its + parent. + + Being an artist itself, all parameters are passed on to `.Artist`. + """ + def __init__(self, *args, **kwargs): + super().__init__(*args) + self._internal_update(kwargs) + # Clipping has not been implemented in the OffsetBox family, so + # disable the clip flag for consistency. It can always be turned back + # on to zero effect. + self.set_clip_on(False) + self._children = [] + self._offset = (0, 0) + + def set_figure(self, fig): + """ + Set the `.Figure` for the `.OffsetBox` and all its children. + + Parameters + ---------- + fig : `~matplotlib.figure.Figure` + """ + super().set_figure(fig) + for c in self.get_children(): + c.set_figure(fig) + + @martist.Artist.axes.setter + def axes(self, ax): + # TODO deal with this better + martist.Artist.axes.fset(self, ax) + for c in self.get_children(): + if c is not None: + c.axes = ax + + def contains(self, mouseevent): + """ + Delegate the mouse event contains-check to the children. + + As a container, the `.OffsetBox` does not respond itself to + mouseevents. + + Parameters + ---------- + mouseevent : `~matplotlib.backend_bases.MouseEvent` + + Returns + ------- + contains : bool + Whether any values are within the radius. + details : dict + An artist-specific dictionary of details of the event context, + such as which points are contained in the pick radius. See the + individual Artist subclasses for details. + + See Also + -------- + .Artist.contains + """ + if self._different_canvas(mouseevent): + return False, {} + for c in self.get_children(): + a, b = c.contains(mouseevent) + if a: + return a, b + return False, {} + + def set_offset(self, xy): + """ + Set the offset. + + Parameters + ---------- + xy : (float, float) or callable + The (x, y) coordinates of the offset in display units. These can + either be given explicitly as a tuple (x, y), or by providing a + function that converts the extent into the offset. This function + must have the signature:: + + def offset(width, height, xdescent, ydescent, renderer) \ +-> (float, float) + """ + self._offset = xy + self.stale = True + + @_compat_get_offset + def get_offset(self, bbox, renderer): + """ + Return the offset as a tuple (x, y). + + The extent parameters have to be provided to handle the case where the + offset is dynamically determined by a callable (see + `~.OffsetBox.set_offset`). + + Parameters + ---------- + bbox : `.Bbox` + renderer : `.RendererBase` subclass + """ + return ( + self._offset(bbox.width, bbox.height, -bbox.x0, -bbox.y0, renderer) + if callable(self._offset) + else self._offset) + + def set_width(self, width): + """ + Set the width of the box. + + Parameters + ---------- + width : float + """ + self.width = width + self.stale = True + + def set_height(self, height): + """ + Set the height of the box. + + Parameters + ---------- + height : float + """ + self.height = height + self.stale = True + + def get_visible_children(self): + r"""Return a list of the visible child `.Artist`\s.""" + return [c for c in self._children if c.get_visible()] + + def get_children(self): + r"""Return a list of the child `.Artist`\s.""" + return self._children + + def _get_bbox_and_child_offsets(self, renderer): + """ + Return the bbox of the offsetbox and the child offsets. + + The bbox should satisfy ``x0 <= x1 and y0 <= y1``. + + Parameters + ---------- + renderer : `.RendererBase` subclass + + Returns + ------- + bbox + list of (xoffset, yoffset) pairs + """ + raise NotImplementedError( + "get_bbox_and_offsets must be overridden in derived classes") + + def get_bbox(self, renderer): + """Return the bbox of the offsetbox, ignoring parent offsets.""" + bbox, offsets = self._get_bbox_and_child_offsets(renderer) + return bbox + + def get_window_extent(self, renderer=None): + # docstring inherited + if renderer is None: + renderer = self.figure._get_renderer() + bbox = self.get_bbox(renderer) + try: # Some subclasses redefine get_offset to take no args. + px, py = self.get_offset(bbox, renderer) + except TypeError: + px, py = self.get_offset() + return bbox.translated(px, py) + + def draw(self, renderer): + """ + Update the location of children if necessary and draw them + to the given *renderer*. + """ + bbox, offsets = self._get_bbox_and_child_offsets(renderer) + px, py = self.get_offset(bbox, renderer) + for c, (ox, oy) in zip(self.get_visible_children(), offsets): + c.set_offset((px + ox, py + oy)) + c.draw(renderer) + _bbox_artist(self, renderer, fill=False, props=dict(pad=0.)) + self.stale = False + + +class PackerBase(OffsetBox): + def __init__(self, pad=0., sep=0., width=None, height=None, + align="baseline", mode="fixed", children=None): + """ + Parameters + ---------- + pad : float, default: 0.0 + The boundary padding in points. + + sep : float, default: 0.0 + The spacing between items in points. + + width, height : float, optional + Width and height of the container box in pixels, calculated if + *None*. + + align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}, \ +default: 'baseline' + Alignment of boxes. + + mode : {'fixed', 'expand', 'equal'}, default: 'fixed' + The packing mode. + + - 'fixed' packs the given `.Artist`\\s tight with *sep* spacing. + - 'expand' uses the maximal available space to distribute the + artists with equal spacing in between. + - 'equal': Each artist an equal fraction of the available space + and is left-aligned (or top-aligned) therein. + + children : list of `.Artist` + The artists to pack. + + Notes + ----- + *pad* and *sep* are in points and will be scaled with the renderer + dpi, while *width* and *height* are in pixels. + """ + super().__init__() + self.height = height + self.width = width + self.sep = sep + self.pad = pad + self.mode = mode + self.align = align + self._children = children + + +class VPacker(PackerBase): + """ + VPacker packs its children vertically, automatically adjusting their + relative positions at draw time. + """ + + def _get_bbox_and_child_offsets(self, renderer): + # docstring inherited + dpicor = renderer.points_to_pixels(1.) + pad = self.pad * dpicor + sep = self.sep * dpicor + + if self.width is not None: + for c in self.get_visible_children(): + if isinstance(c, PackerBase) and c.mode == "expand": + c.set_width(self.width) + + bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()] + (x0, x1), xoffsets = _get_aligned_offsets( + [bbox.intervalx for bbox in bboxes], self.width, self.align) + height, yoffsets = _get_packed_offsets( + [bbox.height for bbox in bboxes], self.height, sep, self.mode) + + yoffsets = height - (yoffsets + [bbox.y1 for bbox in bboxes]) + ydescent = yoffsets[0] + yoffsets = yoffsets - ydescent + + return ( + Bbox.from_bounds(x0, -ydescent, x1 - x0, height).padded(pad), + [*zip(xoffsets, yoffsets)]) + + +class HPacker(PackerBase): + """ + HPacker packs its children horizontally, automatically adjusting their + relative positions at draw time. + """ + + def _get_bbox_and_child_offsets(self, renderer): + # docstring inherited + dpicor = renderer.points_to_pixels(1.) + pad = self.pad * dpicor + sep = self.sep * dpicor + + bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()] + if not bboxes: + return Bbox.from_bounds(0, 0, 0, 0).padded(pad), [] + + (y0, y1), yoffsets = _get_aligned_offsets( + [bbox.intervaly for bbox in bboxes], self.height, self.align) + width, xoffsets = _get_packed_offsets( + [bbox.width for bbox in bboxes], self.width, sep, self.mode) + + x0 = bboxes[0].x0 + xoffsets -= ([bbox.x0 for bbox in bboxes] - x0) + + return (Bbox.from_bounds(x0, y0, width, y1 - y0).padded(pad), + [*zip(xoffsets, yoffsets)]) + + +class PaddedBox(OffsetBox): + """ + A container to add a padding around an `.Artist`. + + The `.PaddedBox` contains a `.FancyBboxPatch` that is used to visualize + it when rendering. + """ + + def __init__(self, child, pad=0., *, draw_frame=False, patch_attrs=None): + """ + Parameters + ---------- + child : `~matplotlib.artist.Artist` + The contained `.Artist`. + pad : float, default: 0.0 + The padding in points. This will be scaled with the renderer dpi. + In contrast, *width* and *height* are in *pixels* and thus not + scaled. + draw_frame : bool + Whether to draw the contained `.FancyBboxPatch`. + patch_attrs : dict or None + Additional parameters passed to the contained `.FancyBboxPatch`. + """ + super().__init__() + self.pad = pad + self._children = [child] + self.patch = FancyBboxPatch( + xy=(0.0, 0.0), width=1., height=1., + facecolor='w', edgecolor='k', + mutation_scale=1, # self.prop.get_size_in_points(), + snap=True, + visible=draw_frame, + boxstyle="square,pad=0", + ) + if patch_attrs is not None: + self.patch.update(patch_attrs) + + def _get_bbox_and_child_offsets(self, renderer): + # docstring inherited. + pad = self.pad * renderer.points_to_pixels(1.) + return (self._children[0].get_bbox(renderer).padded(pad), [(0, 0)]) + + def draw(self, renderer): + # docstring inherited + bbox, offsets = self._get_bbox_and_child_offsets(renderer) + px, py = self.get_offset(bbox, renderer) + for c, (ox, oy) in zip(self.get_visible_children(), offsets): + c.set_offset((px + ox, py + oy)) + + self.draw_frame(renderer) + + for c in self.get_visible_children(): + c.draw(renderer) + + self.stale = False + + def update_frame(self, bbox, fontsize=None): + self.patch.set_bounds(bbox.bounds) + if fontsize: + self.patch.set_mutation_scale(fontsize) + self.stale = True + + def draw_frame(self, renderer): + # update the location and size of the legend + self.update_frame(self.get_window_extent(renderer)) + self.patch.draw(renderer) + + +class DrawingArea(OffsetBox): + """ + The DrawingArea can contain any Artist as a child. The DrawingArea + has a fixed width and height. The position of children relative to + the parent is fixed. The children can be clipped at the + boundaries of the parent. + """ + + def __init__(self, width, height, xdescent=0., ydescent=0., clip=False): + """ + Parameters + ---------- + width, height : float + Width and height of the container box. + xdescent, ydescent : float + Descent of the box in x- and y-direction. + clip : bool + Whether to clip the children to the box. + """ + super().__init__() + self.width = width + self.height = height + self.xdescent = xdescent + self.ydescent = ydescent + self._clip_children = clip + self.offset_transform = mtransforms.Affine2D() + self.dpi_transform = mtransforms.Affine2D() + + @property + def clip_children(self): + """ + If the children of this DrawingArea should be clipped + by DrawingArea bounding box. + """ + return self._clip_children + + @clip_children.setter + def clip_children(self, val): + self._clip_children = bool(val) + self.stale = True + + def get_transform(self): + """ + Return the `~matplotlib.transforms.Transform` applied to the children. + """ + return self.dpi_transform + self.offset_transform + + def set_transform(self, t): + """ + set_transform is ignored. + """ + + def set_offset(self, xy): + """ + Set the offset of the container. + + Parameters + ---------- + xy : (float, float) + The (x, y) coordinates of the offset in display units. + """ + self._offset = xy + self.offset_transform.clear() + self.offset_transform.translate(xy[0], xy[1]) + self.stale = True + + def get_offset(self): + """Return offset of the container.""" + return self._offset + + def get_bbox(self, renderer): + # docstring inherited + dpi_cor = renderer.points_to_pixels(1.) + return Bbox.from_bounds( + -self.xdescent * dpi_cor, -self.ydescent * dpi_cor, + self.width * dpi_cor, self.height * dpi_cor) + + def add_artist(self, a): + """Add an `.Artist` to the container box.""" + self._children.append(a) + if not a.is_transform_set(): + a.set_transform(self.get_transform()) + if self.axes is not None: + a.axes = self.axes + fig = self.figure + if fig is not None: + a.set_figure(fig) + + def draw(self, renderer): + # docstring inherited + + dpi_cor = renderer.points_to_pixels(1.) + self.dpi_transform.clear() + self.dpi_transform.scale(dpi_cor) + + # At this point the DrawingArea has a transform + # to the display space so the path created is + # good for clipping children + tpath = mtransforms.TransformedPath( + mpath.Path([[0, 0], [0, self.height], + [self.width, self.height], + [self.width, 0]]), + self.get_transform()) + for c in self._children: + if self._clip_children and not (c.clipbox or c._clippath): + c.set_clip_path(tpath) + c.draw(renderer) + + _bbox_artist(self, renderer, fill=False, props=dict(pad=0.)) + self.stale = False + + +class TextArea(OffsetBox): + """ + The TextArea is a container artist for a single Text instance. + + The text is placed at (0, 0) with baseline+left alignment, by default. The + width and height of the TextArea instance is the width and height of its + child text. + """ + + def __init__(self, s, + *, + textprops=None, + multilinebaseline=False, + ): + """ + Parameters + ---------- + s : str + The text to be displayed. + textprops : dict, default: {} + Dictionary of keyword parameters to be passed to the `.Text` + instance in the TextArea. + multilinebaseline : bool, default: False + Whether the baseline for multiline text is adjusted so that it + is (approximately) center-aligned with single-line text. + """ + if textprops is None: + textprops = {} + self._text = mtext.Text(0, 0, s, **textprops) + super().__init__() + self._children = [self._text] + self.offset_transform = mtransforms.Affine2D() + self._baseline_transform = mtransforms.Affine2D() + self._text.set_transform(self.offset_transform + + self._baseline_transform) + self._multilinebaseline = multilinebaseline + + def set_text(self, s): + """Set the text of this area as a string.""" + self._text.set_text(s) + self.stale = True + + def get_text(self): + """Return the string representation of this area's text.""" + return self._text.get_text() + + def set_multilinebaseline(self, t): + """ + Set multilinebaseline. + + If True, the baseline for multiline text is adjusted so that it is + (approximately) center-aligned with single-line text. This is used + e.g. by the legend implementation so that single-line labels are + baseline-aligned, but multiline labels are "center"-aligned with them. + """ + self._multilinebaseline = t + self.stale = True + + def get_multilinebaseline(self): + """ + Get multilinebaseline. + """ + return self._multilinebaseline + + def set_transform(self, t): + """ + set_transform is ignored. + """ + + def set_offset(self, xy): + """ + Set the offset of the container. + + Parameters + ---------- + xy : (float, float) + The (x, y) coordinates of the offset in display units. + """ + self._offset = xy + self.offset_transform.clear() + self.offset_transform.translate(xy[0], xy[1]) + self.stale = True + + def get_offset(self): + """Return offset of the container.""" + return self._offset + + def get_bbox(self, renderer): + _, h_, d_ = renderer.get_text_width_height_descent( + "lp", self._text._fontproperties, + ismath="TeX" if self._text.get_usetex() else False) + + bbox, info, yd = self._text._get_layout(renderer) + w, h = bbox.size + + self._baseline_transform.clear() + + if len(info) > 1 and self._multilinebaseline: + yd_new = 0.5 * h - 0.5 * (h_ - d_) + self._baseline_transform.translate(0, yd - yd_new) + yd = yd_new + else: # single line + h_d = max(h_ - d_, h - yd) + h = h_d + yd + + ha = self._text.get_horizontalalignment() + x0 = {"left": 0, "center": -w / 2, "right": -w}[ha] + + return Bbox.from_bounds(x0, -yd, w, h) + + def draw(self, renderer): + # docstring inherited + self._text.draw(renderer) + _bbox_artist(self, renderer, fill=False, props=dict(pad=0.)) + self.stale = False + + +class AuxTransformBox(OffsetBox): + """ + Offset Box with the aux_transform. Its children will be + transformed with the aux_transform first then will be + offsetted. The absolute coordinate of the aux_transform is meaning + as it will be automatically adjust so that the left-lower corner + of the bounding box of children will be set to (0, 0) before the + offset transform. + + It is similar to drawing area, except that the extent of the box + is not predetermined but calculated from the window extent of its + children. Furthermore, the extent of the children will be + calculated in the transformed coordinate. + """ + def __init__(self, aux_transform): + self.aux_transform = aux_transform + super().__init__() + self.offset_transform = mtransforms.Affine2D() + # ref_offset_transform makes offset_transform always relative to the + # lower-left corner of the bbox of its children. + self.ref_offset_transform = mtransforms.Affine2D() + + def add_artist(self, a): + """Add an `.Artist` to the container box.""" + self._children.append(a) + a.set_transform(self.get_transform()) + self.stale = True + + def get_transform(self): + """ + Return the :class:`~matplotlib.transforms.Transform` applied + to the children + """ + return (self.aux_transform + + self.ref_offset_transform + + self.offset_transform) + + def set_transform(self, t): + """ + set_transform is ignored. + """ + + def set_offset(self, xy): + """ + Set the offset of the container. + + Parameters + ---------- + xy : (float, float) + The (x, y) coordinates of the offset in display units. + """ + self._offset = xy + self.offset_transform.clear() + self.offset_transform.translate(xy[0], xy[1]) + self.stale = True + + def get_offset(self): + """Return offset of the container.""" + return self._offset + + def get_bbox(self, renderer): + # clear the offset transforms + _off = self.offset_transform.get_matrix() # to be restored later + self.ref_offset_transform.clear() + self.offset_transform.clear() + # calculate the extent + bboxes = [c.get_window_extent(renderer) for c in self._children] + ub = Bbox.union(bboxes) + # adjust ref_offset_transform + self.ref_offset_transform.translate(-ub.x0, -ub.y0) + # restore offset transform + self.offset_transform.set_matrix(_off) + return Bbox.from_bounds(0, 0, ub.width, ub.height) + + def draw(self, renderer): + # docstring inherited + for c in self._children: + c.draw(renderer) + _bbox_artist(self, renderer, fill=False, props=dict(pad=0.)) + self.stale = False + + +class AnchoredOffsetbox(OffsetBox): + """ + An offset box placed according to location *loc*. + + AnchoredOffsetbox has a single child. When multiple children are needed, + use an extra OffsetBox to enclose them. By default, the offset box is + anchored against its parent Axes. You may explicitly specify the + *bbox_to_anchor*. + """ + zorder = 5 # zorder of the legend + + # Location codes + codes = {'upper right': 1, + 'upper left': 2, + 'lower left': 3, + 'lower right': 4, + 'right': 5, + 'center left': 6, + 'center right': 7, + 'lower center': 8, + 'upper center': 9, + 'center': 10, + } + + def __init__(self, loc, *, + pad=0.4, borderpad=0.5, + child=None, prop=None, frameon=True, + bbox_to_anchor=None, + bbox_transform=None, + **kwargs): + """ + Parameters + ---------- + loc : str + The box location. Valid locations are + 'upper left', 'upper center', 'upper right', + 'center left', 'center', 'center right', + 'lower left', 'lower center', 'lower right'. + For backward compatibility, numeric values are accepted as well. + See the parameter *loc* of `.Legend` for details. + pad : float, default: 0.4 + Padding around the child as fraction of the fontsize. + borderpad : float, default: 0.5 + Padding between the offsetbox frame and the *bbox_to_anchor*. + child : `.OffsetBox` + The box that will be anchored. + prop : `.FontProperties` + This is only used as a reference for paddings. If not given, + :rc:`legend.fontsize` is used. + frameon : bool + Whether to draw a frame around the box. + bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats + Box that is used to position the legend in conjunction with *loc*. + bbox_transform : None or :class:`matplotlib.transforms.Transform` + The transform for the bounding box (*bbox_to_anchor*). + **kwargs + All other parameters are passed on to `.OffsetBox`. + + Notes + ----- + See `.Legend` for a detailed description of the anchoring mechanism. + """ + super().__init__(**kwargs) + + self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform) + self.set_child(child) + + if isinstance(loc, str): + loc = _api.check_getitem(self.codes, loc=loc) + + self.loc = loc + self.borderpad = borderpad + self.pad = pad + + if prop is None: + self.prop = FontProperties(size=mpl.rcParams["legend.fontsize"]) + else: + self.prop = FontProperties._from_any(prop) + if isinstance(prop, dict) and "size" not in prop: + self.prop.set_size(mpl.rcParams["legend.fontsize"]) + + self.patch = FancyBboxPatch( + xy=(0.0, 0.0), width=1., height=1., + facecolor='w', edgecolor='k', + mutation_scale=self.prop.get_size_in_points(), + snap=True, + visible=frameon, + boxstyle="square,pad=0", + ) + + def set_child(self, child): + """Set the child to be anchored.""" + self._child = child + if child is not None: + child.axes = self.axes + self.stale = True + + def get_child(self): + """Return the child.""" + return self._child + + def get_children(self): + """Return the list of children.""" + return [self._child] + + def get_bbox(self, renderer): + # docstring inherited + fontsize = renderer.points_to_pixels(self.prop.get_size_in_points()) + pad = self.pad * fontsize + return self.get_child().get_bbox(renderer).padded(pad) + + def get_bbox_to_anchor(self): + """Return the bbox that the box is anchored to.""" + if self._bbox_to_anchor is None: + return self.axes.bbox + else: + transform = self._bbox_to_anchor_transform + if transform is None: + return self._bbox_to_anchor + else: + return TransformedBbox(self._bbox_to_anchor, transform) + + def set_bbox_to_anchor(self, bbox, transform=None): + """ + Set the bbox that the box is anchored to. + + *bbox* can be a Bbox instance, a list of [left, bottom, width, + height], or a list of [left, bottom] where the width and + height will be assumed to be zero. The bbox will be + transformed to display coordinate by the given transform. + """ + if bbox is None or isinstance(bbox, BboxBase): + self._bbox_to_anchor = bbox + else: + try: + l = len(bbox) + except TypeError as err: + raise ValueError(f"Invalid bbox: {bbox}") from err + + if l == 2: + bbox = [bbox[0], bbox[1], 0, 0] + + self._bbox_to_anchor = Bbox.from_bounds(*bbox) + + self._bbox_to_anchor_transform = transform + self.stale = True + + @_compat_get_offset + def get_offset(self, bbox, renderer): + # docstring inherited + pad = (self.borderpad + * renderer.points_to_pixels(self.prop.get_size_in_points())) + bbox_to_anchor = self.get_bbox_to_anchor() + x0, y0 = _get_anchored_bbox( + self.loc, Bbox.from_bounds(0, 0, bbox.width, bbox.height), + bbox_to_anchor, pad) + return x0 - bbox.x0, y0 - bbox.y0 + + def update_frame(self, bbox, fontsize=None): + self.patch.set_bounds(bbox.bounds) + if fontsize: + self.patch.set_mutation_scale(fontsize) + + def draw(self, renderer): + # docstring inherited + if not self.get_visible(): + return + + # update the location and size of the legend + bbox = self.get_window_extent(renderer) + fontsize = renderer.points_to_pixels(self.prop.get_size_in_points()) + self.update_frame(bbox, fontsize) + self.patch.draw(renderer) + + px, py = self.get_offset(self.get_bbox(renderer), renderer) + self.get_child().set_offset((px, py)) + self.get_child().draw(renderer) + self.stale = False + + +def _get_anchored_bbox(loc, bbox, parentbbox, borderpad): + """ + Return the (x, y) position of the *bbox* anchored at the *parentbbox* with + the *loc* code with the *borderpad*. + """ + # This is only called internally and *loc* should already have been + # validated. If 0 (None), we just let ``bbox.anchored`` raise. + c = [None, "NE", "NW", "SW", "SE", "E", "W", "E", "S", "N", "C"][loc] + container = parentbbox.padded(-borderpad) + return bbox.anchored(c, container=container).p0 + + +class AnchoredText(AnchoredOffsetbox): + """ + AnchoredOffsetbox with Text. + """ + + def __init__(self, s, loc, *, pad=0.4, borderpad=0.5, prop=None, **kwargs): + """ + Parameters + ---------- + s : str + Text. + + loc : str + Location code. See `AnchoredOffsetbox`. + + pad : float, default: 0.4 + Padding around the text as fraction of the fontsize. + + borderpad : float, default: 0.5 + Spacing between the offsetbox frame and the *bbox_to_anchor*. + + prop : dict, optional + Dictionary of keyword parameters to be passed to the + `~matplotlib.text.Text` instance contained inside AnchoredText. + + **kwargs + All other parameters are passed to `AnchoredOffsetbox`. + """ + + if prop is None: + prop = {} + badkwargs = {'va', 'verticalalignment'} + if badkwargs & set(prop): + raise ValueError( + 'Mixing verticalalignment with AnchoredText is not supported.') + + self.txt = TextArea(s, textprops=prop) + fp = self.txt._text.get_fontproperties() + super().__init__( + loc, pad=pad, borderpad=borderpad, child=self.txt, prop=fp, + **kwargs) + + +class OffsetImage(OffsetBox): + + def __init__(self, arr, *, + zoom=1, + cmap=None, + norm=None, + interpolation=None, + origin=None, + filternorm=True, + filterrad=4.0, + resample=False, + dpi_cor=True, + **kwargs + ): + + super().__init__() + self._dpi_cor = dpi_cor + + self.image = BboxImage(bbox=self.get_window_extent, + cmap=cmap, + norm=norm, + interpolation=interpolation, + origin=origin, + filternorm=filternorm, + filterrad=filterrad, + resample=resample, + **kwargs + ) + + self._children = [self.image] + + self.set_zoom(zoom) + self.set_data(arr) + + def set_data(self, arr): + self._data = np.asarray(arr) + self.image.set_data(self._data) + self.stale = True + + def get_data(self): + return self._data + + def set_zoom(self, zoom): + self._zoom = zoom + self.stale = True + + def get_zoom(self): + return self._zoom + + def get_offset(self): + """Return offset of the container.""" + return self._offset + + def get_children(self): + return [self.image] + + def get_bbox(self, renderer): + dpi_cor = renderer.points_to_pixels(1.) if self._dpi_cor else 1. + zoom = self.get_zoom() + data = self.get_data() + ny, nx = data.shape[:2] + w, h = dpi_cor * nx * zoom, dpi_cor * ny * zoom + return Bbox.from_bounds(0, 0, w, h) + + def draw(self, renderer): + # docstring inherited + self.image.draw(renderer) + # bbox_artist(self, renderer, fill=False, props=dict(pad=0.)) + self.stale = False + + +class AnnotationBbox(martist.Artist, mtext._AnnotationBase): + """ + Container for an `OffsetBox` referring to a specific position *xy*. + + Optionally an arrow pointing from the offsetbox to *xy* can be drawn. + + This is like `.Annotation`, but with `OffsetBox` instead of `.Text`. + """ + + zorder = 3 + + def __str__(self): + return f"AnnotationBbox({self.xy[0]:g},{self.xy[1]:g})" + + @_docstring.dedent_interpd + def __init__(self, offsetbox, xy, xybox=None, xycoords='data', boxcoords=None, *, + frameon=True, pad=0.4, # FancyBboxPatch boxstyle. + annotation_clip=None, + box_alignment=(0.5, 0.5), + bboxprops=None, + arrowprops=None, + fontsize=None, + **kwargs): + """ + Parameters + ---------- + offsetbox : `OffsetBox` + + xy : (float, float) + The point *(x, y)* to annotate. The coordinate system is determined + by *xycoords*. + + xybox : (float, float), default: *xy* + The position *(x, y)* to place the text at. The coordinate system + is determined by *boxcoords*. + + xycoords : single or two-tuple of str or `.Artist` or `.Transform` or \ +callable, default: 'data' + The coordinate system that *xy* is given in. See the parameter + *xycoords* in `.Annotation` for a detailed description. + + boxcoords : single or two-tuple of str or `.Artist` or `.Transform` \ +or callable, default: value of *xycoords* + The coordinate system that *xybox* is given in. See the parameter + *textcoords* in `.Annotation` for a detailed description. + + frameon : bool, default: True + By default, the text is surrounded by a white `.FancyBboxPatch` + (accessible as the ``patch`` attribute of the `.AnnotationBbox`). + If *frameon* is set to False, this patch is made invisible. + + annotation_clip: bool or None, default: None + Whether to clip (i.e. not draw) the annotation when the annotation + point *xy* is outside the Axes area. + + - If *True*, the annotation will be clipped when *xy* is outside + the Axes. + - If *False*, the annotation will always be drawn. + - If *None*, the annotation will be clipped when *xy* is outside + the Axes and *xycoords* is 'data'. + + pad : float, default: 0.4 + Padding around the offsetbox. + + box_alignment : (float, float) + A tuple of two floats for a vertical and horizontal alignment of + the offset box w.r.t. the *boxcoords*. + The lower-left corner is (0, 0) and upper-right corner is (1, 1). + + bboxprops : dict, optional + A dictionary of properties to set for the annotation bounding box, + for example *boxstyle* and *alpha*. See `.FancyBboxPatch` for + details. + + arrowprops: dict, optional + Arrow properties, see `.Annotation` for description. + + fontsize: float or str, optional + Translated to points and passed as *mutation_scale* into + `.FancyBboxPatch` to scale attributes of the box style (e.g. pad + or rounding_size). The name is chosen in analogy to `.Text` where + *fontsize* defines the mutation scale as well. If not given, + :rc:`legend.fontsize` is used. See `.Text.set_fontsize` for valid + values. + + **kwargs + Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for + a list. + """ + + martist.Artist.__init__(self) + mtext._AnnotationBase.__init__( + self, xy, xycoords=xycoords, annotation_clip=annotation_clip) + + self.offsetbox = offsetbox + self.arrowprops = arrowprops.copy() if arrowprops is not None else None + self.set_fontsize(fontsize) + self.xybox = xybox if xybox is not None else xy + self.boxcoords = boxcoords if boxcoords is not None else xycoords + self._box_alignment = box_alignment + + if arrowprops is not None: + self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5)) + self.arrow_patch = FancyArrowPatch((0, 0), (1, 1), + **self.arrowprops) + else: + self._arrow_relpos = None + self.arrow_patch = None + + self.patch = FancyBboxPatch( # frame + xy=(0.0, 0.0), width=1., height=1., + facecolor='w', edgecolor='k', + mutation_scale=self.prop.get_size_in_points(), + snap=True, + visible=frameon, + ) + self.patch.set_boxstyle("square", pad=pad) + if bboxprops: + self.patch.set(**bboxprops) + + self._internal_update(kwargs) + + @property + def xyann(self): + return self.xybox + + @xyann.setter + def xyann(self, xyann): + self.xybox = xyann + self.stale = True + + @property + def anncoords(self): + return self.boxcoords + + @anncoords.setter + def anncoords(self, coords): + self.boxcoords = coords + self.stale = True + + def contains(self, mouseevent): + if self._different_canvas(mouseevent): + return False, {} + if not self._check_xy(None): + return False, {} + return self.offsetbox.contains(mouseevent) + # self.arrow_patch is currently not checked as this can be a line - JJ + + def get_children(self): + children = [self.offsetbox, self.patch] + if self.arrow_patch: + children.append(self.arrow_patch) + return children + + def set_figure(self, fig): + if self.arrow_patch is not None: + self.arrow_patch.set_figure(fig) + self.offsetbox.set_figure(fig) + martist.Artist.set_figure(self, fig) + + def set_fontsize(self, s=None): + """ + Set the fontsize in points. + + If *s* is not given, reset to :rc:`legend.fontsize`. + """ + if s is None: + s = mpl.rcParams["legend.fontsize"] + + self.prop = FontProperties(size=s) + self.stale = True + + def get_fontsize(self): + """Return the fontsize in points.""" + return self.prop.get_size_in_points() + + def get_window_extent(self, renderer=None): + # docstring inherited + if renderer is None: + renderer = self.figure._get_renderer() + self.update_positions(renderer) + return Bbox.union([child.get_window_extent(renderer) + for child in self.get_children()]) + + def get_tightbbox(self, renderer=None): + # docstring inherited + if renderer is None: + renderer = self.figure._get_renderer() + self.update_positions(renderer) + return Bbox.union([child.get_tightbbox(renderer) + for child in self.get_children()]) + + def update_positions(self, renderer): + """Update pixel positions for the annotated point, the text, and the arrow.""" + + ox0, oy0 = self._get_xy(renderer, self.xybox, self.boxcoords) + bbox = self.offsetbox.get_bbox(renderer) + fw, fh = self._box_alignment + self.offsetbox.set_offset( + (ox0 - fw*bbox.width - bbox.x0, oy0 - fh*bbox.height - bbox.y0)) + + bbox = self.offsetbox.get_window_extent(renderer) + self.patch.set_bounds(bbox.bounds) + + mutation_scale = renderer.points_to_pixels(self.get_fontsize()) + self.patch.set_mutation_scale(mutation_scale) + + if self.arrowprops: + # Use FancyArrowPatch if self.arrowprops has "arrowstyle" key. + + # Adjust the starting point of the arrow relative to the textbox. + # TODO: Rotation needs to be accounted. + arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos + arrow_end = self._get_position_xy(renderer) + # The arrow (from arrow_begin to arrow_end) will be first clipped + # by patchA and patchB, then shrunk by shrinkA and shrinkB (in + # points). If patch A is not set, self.bbox_patch is used. + self.arrow_patch.set_positions(arrow_begin, arrow_end) + + if "mutation_scale" in self.arrowprops: + mutation_scale = renderer.points_to_pixels( + self.arrowprops["mutation_scale"]) + # Else, use fontsize-based mutation_scale defined above. + self.arrow_patch.set_mutation_scale(mutation_scale) + + patchA = self.arrowprops.get("patchA", self.patch) + self.arrow_patch.set_patchA(patchA) + + def draw(self, renderer): + # docstring inherited + if not self.get_visible() or not self._check_xy(renderer): + return + renderer.open_group(self.__class__.__name__, gid=self.get_gid()) + self.update_positions(renderer) + if self.arrow_patch is not None: + if self.arrow_patch.figure is None and self.figure is not None: + self.arrow_patch.figure = self.figure + self.arrow_patch.draw(renderer) + self.patch.draw(renderer) + self.offsetbox.draw(renderer) + renderer.close_group(self.__class__.__name__) + self.stale = False + + +class DraggableBase: + """ + Helper base class for a draggable artist (legend, offsetbox). + + Derived classes must override the following methods:: + + def save_offset(self): + ''' + Called when the object is picked for dragging; should save the + reference position of the artist. + ''' + + def update_offset(self, dx, dy): + ''' + Called during the dragging; (*dx*, *dy*) is the pixel offset from + the point where the mouse drag started. + ''' + + Optionally, you may override the following method:: + + def finalize_offset(self): + '''Called when the mouse is released.''' + + In the current implementation of `.DraggableLegend` and + `DraggableAnnotation`, `update_offset` places the artists in display + coordinates, and `finalize_offset` recalculates their position in axes + coordinate and set a relevant attribute. + """ + + def __init__(self, ref_artist, use_blit=False): + self.ref_artist = ref_artist + if not ref_artist.pickable(): + ref_artist.set_picker(True) + self.got_artist = False + self._use_blit = use_blit and self.canvas.supports_blit + callbacks = self.canvas.callbacks + self._disconnectors = [ + functools.partial( + callbacks.disconnect, callbacks._connect_picklable(name, func)) + for name, func in [ + ("pick_event", self.on_pick), + ("button_release_event", self.on_release), + ("motion_notify_event", self.on_motion), + ] + ] + + # A property, not an attribute, to maintain picklability. + canvas = property(lambda self: self.ref_artist.figure.canvas) + cids = property(lambda self: [ + disconnect.args[0] for disconnect in self._disconnectors[:2]]) + + def on_motion(self, evt): + if self._check_still_parented() and self.got_artist: + dx = evt.x - self.mouse_x + dy = evt.y - self.mouse_y + self.update_offset(dx, dy) + if self._use_blit: + self.canvas.restore_region(self.background) + self.ref_artist.draw( + self.ref_artist.figure._get_renderer()) + self.canvas.blit() + else: + self.canvas.draw() + + def on_pick(self, evt): + if self._check_still_parented() and evt.artist == self.ref_artist: + self.mouse_x = evt.mouseevent.x + self.mouse_y = evt.mouseevent.y + self.got_artist = True + if self._use_blit: + self.ref_artist.set_animated(True) + self.canvas.draw() + self.background = \ + self.canvas.copy_from_bbox(self.ref_artist.figure.bbox) + self.ref_artist.draw( + self.ref_artist.figure._get_renderer()) + self.canvas.blit() + self.save_offset() + + def on_release(self, event): + if self._check_still_parented() and self.got_artist: + self.finalize_offset() + self.got_artist = False + if self._use_blit: + self.ref_artist.set_animated(False) + + def _check_still_parented(self): + if self.ref_artist.figure is None: + self.disconnect() + return False + else: + return True + + def disconnect(self): + """Disconnect the callbacks.""" + for disconnector in self._disconnectors: + disconnector() + + def save_offset(self): + pass + + def update_offset(self, dx, dy): + pass + + def finalize_offset(self): + pass + + +class DraggableOffsetBox(DraggableBase): + def __init__(self, ref_artist, offsetbox, use_blit=False): + super().__init__(ref_artist, use_blit=use_blit) + self.offsetbox = offsetbox + + def save_offset(self): + offsetbox = self.offsetbox + renderer = offsetbox.figure._get_renderer() + offset = offsetbox.get_offset(offsetbox.get_bbox(renderer), renderer) + self.offsetbox_x, self.offsetbox_y = offset + self.offsetbox.set_offset(offset) + + def update_offset(self, dx, dy): + loc_in_canvas = self.offsetbox_x + dx, self.offsetbox_y + dy + self.offsetbox.set_offset(loc_in_canvas) + + def get_loc_in_canvas(self): + offsetbox = self.offsetbox + renderer = offsetbox.figure._get_renderer() + bbox = offsetbox.get_bbox(renderer) + ox, oy = offsetbox._offset + loc_in_canvas = (ox + bbox.x0, oy + bbox.y0) + return loc_in_canvas + + +class DraggableAnnotation(DraggableBase): + def __init__(self, annotation, use_blit=False): + super().__init__(annotation, use_blit=use_blit) + self.annotation = annotation + + def save_offset(self): + ann = self.annotation + self.ox, self.oy = ann.get_transform().transform(ann.xyann) + + def update_offset(self, dx, dy): + ann = self.annotation + ann.xyann = ann.get_transform().inverted().transform( + (self.ox + dx, self.oy + dy)) diff --git a/venv/lib/python3.10/site-packages/matplotlib/offsetbox.pyi b/venv/lib/python3.10/site-packages/matplotlib/offsetbox.pyi new file mode 100644 index 00000000..c222a9b2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/offsetbox.pyi @@ -0,0 +1,314 @@ +import matplotlib.artist as martist +from matplotlib.backend_bases import RendererBase, Event, FigureCanvasBase +from matplotlib.colors import Colormap, Normalize +import matplotlib.text as mtext +from matplotlib.figure import Figure +from matplotlib.font_manager import FontProperties +from matplotlib.image import BboxImage +from matplotlib.patches import FancyArrowPatch, FancyBboxPatch +from matplotlib.transforms import Bbox, BboxBase, Transform + +import numpy as np +from numpy.typing import ArrayLike +from collections.abc import Callable, Sequence +from typing import Any, Literal, overload + +DEBUG: bool + +def _get_packed_offsets( + widths: Sequence[float], + total: float | None, + sep: float | None, + mode: Literal["fixed", "expand", "equal"] = ..., +) -> tuple[float, np.ndarray]: ... + +class OffsetBox(martist.Artist): + width: float | None + height: float | None + def __init__(self, *args, **kwargs) -> None: ... + def set_figure(self, fig: Figure) -> None: ... + def set_offset( + self, + xy: tuple[float, float] + | Callable[[float, float, float, float, RendererBase], tuple[float, float]], + ) -> None: ... + + @overload + def get_offset(self, bbox: Bbox, renderer: RendererBase) -> tuple[float, float]: ... + @overload + def get_offset( + self, + width: float, + height: float, + xdescent: float, + ydescent: float, + renderer: RendererBase + ) -> tuple[float, float]: ... + + def set_width(self, width: float) -> None: ... + def set_height(self, height: float) -> None: ... + def get_visible_children(self) -> list[martist.Artist]: ... + def get_children(self) -> list[martist.Artist]: ... + def get_bbox(self, renderer: RendererBase) -> Bbox: ... + def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... + +class PackerBase(OffsetBox): + height: float | None + width: float | None + sep: float | None + pad: float | None + mode: Literal["fixed", "expand", "equal"] + align: Literal["top", "bottom", "left", "right", "center", "baseline"] + def __init__( + self, + pad: float | None = ..., + sep: float | None = ..., + width: float | None = ..., + height: float | None = ..., + align: Literal["top", "bottom", "left", "right", "center", "baseline"] = ..., + mode: Literal["fixed", "expand", "equal"] = ..., + children: list[martist.Artist] | None = ..., + ) -> None: ... + +class VPacker(PackerBase): ... +class HPacker(PackerBase): ... + +class PaddedBox(OffsetBox): + pad: float | None + patch: FancyBboxPatch + def __init__( + self, + child: martist.Artist, + pad: float | None = ..., + *, + draw_frame: bool = ..., + patch_attrs: dict[str, Any] | None = ..., + ) -> None: ... + def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ... + def draw_frame(self, renderer: RendererBase) -> None: ... + +class DrawingArea(OffsetBox): + width: float + height: float + xdescent: float + ydescent: float + offset_transform: Transform + dpi_transform: Transform + def __init__( + self, + width: float, + height: float, + xdescent: float = ..., + ydescent: float = ..., + clip: bool = ..., + ) -> None: ... + @property + def clip_children(self) -> bool: ... + @clip_children.setter + def clip_children(self, val: bool) -> None: ... + def get_transform(self) -> Transform: ... + + # does not accept all options of superclass + def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override] + def get_offset(self) -> tuple[float, float]: ... # type: ignore[override] + def add_artist(self, a: martist.Artist) -> None: ... + +class TextArea(OffsetBox): + offset_transform: Transform + def __init__( + self, + s: str, + *, + textprops: dict[str, Any] | None = ..., + multilinebaseline: bool = ..., + ) -> None: ... + def set_text(self, s: str) -> None: ... + def get_text(self) -> str: ... + def set_multilinebaseline(self, t: bool) -> None: ... + def get_multilinebaseline(self) -> bool: ... + + # does not accept all options of superclass + def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override] + def get_offset(self) -> tuple[float, float]: ... # type: ignore[override] + +class AuxTransformBox(OffsetBox): + aux_transform: Transform + offset_transform: Transform + ref_offset_transform: Transform + def __init__(self, aux_transform: Transform) -> None: ... + def add_artist(self, a: martist.Artist) -> None: ... + def get_transform(self) -> Transform: ... + + # does not accept all options of superclass + def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override] + def get_offset(self) -> tuple[float, float]: ... # type: ignore[override] + +class AnchoredOffsetbox(OffsetBox): + zorder: float + codes: dict[str, int] + loc: int + borderpad: float + pad: float + prop: FontProperties + patch: FancyBboxPatch + def __init__( + self, + loc: str, + *, + pad: float = ..., + borderpad: float = ..., + child: OffsetBox | None = ..., + prop: FontProperties | None = ..., + frameon: bool = ..., + bbox_to_anchor: BboxBase + | tuple[float, float] + | tuple[float, float, float, float] + | None = ..., + bbox_transform: Transform | None = ..., + **kwargs + ) -> None: ... + def set_child(self, child: OffsetBox | None) -> None: ... + def get_child(self) -> OffsetBox | None: ... + def get_children(self) -> list[martist.Artist]: ... + def get_bbox_to_anchor(self) -> Bbox: ... + def set_bbox_to_anchor( + self, bbox: BboxBase, transform: Transform | None = ... + ) -> None: ... + def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ... + +class AnchoredText(AnchoredOffsetbox): + txt: TextArea + def __init__( + self, + s: str, + loc: str, + *, + pad: float = ..., + borderpad: float = ..., + prop: dict[str, Any] | None = ..., + **kwargs + ) -> None: ... + +class OffsetImage(OffsetBox): + image: BboxImage + def __init__( + self, + arr: ArrayLike, + *, + zoom: float = ..., + cmap: Colormap | str | None = ..., + norm: Normalize | str | None = ..., + interpolation: str | None = ..., + origin: Literal["upper", "lower"] | None = ..., + filternorm: bool = ..., + filterrad: float = ..., + resample: bool = ..., + dpi_cor: bool = ..., + **kwargs + ) -> None: ... + stale: bool + def set_data(self, arr: ArrayLike | None) -> None: ... + def get_data(self) -> ArrayLike | None: ... + def set_zoom(self, zoom: float) -> None: ... + def get_zoom(self) -> float: ... + def get_children(self) -> list[martist.Artist]: ... + def get_offset(self) -> tuple[float, float]: ... # type: ignore[override] + +class AnnotationBbox(martist.Artist, mtext._AnnotationBase): + zorder: float + offsetbox: OffsetBox + arrowprops: dict[str, Any] | None + xybox: tuple[float, float] + boxcoords: str | tuple[str, str] | martist.Artist | Transform | Callable[ + [RendererBase], Bbox | Transform + ] + arrow_patch: FancyArrowPatch | None + patch: FancyBboxPatch + prop: FontProperties + def __init__( + self, + offsetbox: OffsetBox, + xy: tuple[float, float], + xybox: tuple[float, float] | None = ..., + xycoords: str + | tuple[str, str] + | martist.Artist + | Transform + | Callable[[RendererBase], Bbox | Transform] = ..., + boxcoords: str + | tuple[str, str] + | martist.Artist + | Transform + | Callable[[RendererBase], Bbox | Transform] + | None = ..., + *, + frameon: bool = ..., + pad: float = ..., + annotation_clip: bool | None = ..., + box_alignment: tuple[float, float] = ..., + bboxprops: dict[str, Any] | None = ..., + arrowprops: dict[str, Any] | None = ..., + fontsize: float | str | None = ..., + **kwargs + ) -> None: ... + @property + def xyann(self) -> tuple[float, float]: ... + @xyann.setter + def xyann(self, xyann: tuple[float, float]) -> None: ... + @property + def anncoords( + self, + ) -> str | tuple[str, str] | martist.Artist | Transform | Callable[ + [RendererBase], Bbox | Transform + ]: ... + @anncoords.setter + def anncoords( + self, + coords: str + | tuple[str, str] + | martist.Artist + | Transform + | Callable[[RendererBase], Bbox | Transform], + ) -> None: ... + def get_children(self) -> list[martist.Artist]: ... + def set_figure(self, fig: Figure) -> None: ... + def set_fontsize(self, s: str | float | None = ...) -> None: ... + def get_fontsize(self) -> float: ... + def get_tightbbox(self, renderer: RendererBase | None = ...) -> Bbox: ... + def update_positions(self, renderer: RendererBase) -> None: ... + +class DraggableBase: + ref_artist: martist.Artist + got_artist: bool + mouse_x: int + mouse_y: int + background: Any + + @property + def canvas(self) -> FigureCanvasBase: ... + @property + def cids(self) -> list[int]: ... + + def __init__(self, ref_artist: martist.Artist, use_blit: bool = ...) -> None: ... + def on_motion(self, evt: Event) -> None: ... + def on_pick(self, evt: Event) -> None: ... + def on_release(self, event: Event) -> None: ... + def disconnect(self) -> None: ... + def save_offset(self) -> None: ... + def update_offset(self, dx: float, dy: float) -> None: ... + def finalize_offset(self) -> None: ... + +class DraggableOffsetBox(DraggableBase): + offsetbox: OffsetBox + def __init__( + self, ref_artist: martist.Artist, offsetbox: OffsetBox, use_blit: bool = ... + ) -> None: ... + def save_offset(self) -> None: ... + def update_offset(self, dx: float, dy: float) -> None: ... + def get_loc_in_canvas(self) -> tuple[float, float]: ... + +class DraggableAnnotation(DraggableBase): + annotation: mtext.Annotation + def __init__(self, annotation: mtext.Annotation, use_blit: bool = ...) -> None: ... + def save_offset(self) -> None: ... + def update_offset(self, dx: float, dy: float) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/patches.py b/venv/lib/python3.10/site-packages/matplotlib/patches.py new file mode 100644 index 00000000..28999526 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/patches.py @@ -0,0 +1,4698 @@ +r""" +Patches are `.Artist`\s with a face color and an edge color. +""" + +import functools +import inspect +import math +from numbers import Number, Real +import textwrap +from types import SimpleNamespace +from collections import namedtuple +from matplotlib.transforms import Affine2D + +import numpy as np + +import matplotlib as mpl +from . import (_api, artist, cbook, colors, _docstring, hatch as mhatch, + lines as mlines, transforms) +from .bezier import ( + NonIntersectingPathException, get_cos_sin, get_intersection, + get_parallels, inside_circle, make_wedged_bezier2, + split_bezier_intersecting_with_closedpath, split_path_inout) +from .path import Path +from ._enums import JoinStyle, CapStyle + + +@_docstring.interpd +@_api.define_aliases({ + "antialiased": ["aa"], + "edgecolor": ["ec"], + "facecolor": ["fc"], + "linestyle": ["ls"], + "linewidth": ["lw"], +}) +class Patch(artist.Artist): + """ + A patch is a 2D artist with a face color and an edge color. + + If any of *edgecolor*, *facecolor*, *linewidth*, or *antialiased* + are *None*, they default to their rc params setting. + """ + zorder = 1 + + # Whether to draw an edge by default. Set on a + # subclass-by-subclass basis. + _edge_default = False + + def __init__(self, *, + edgecolor=None, + facecolor=None, + color=None, + linewidth=None, + linestyle=None, + antialiased=None, + hatch=None, + fill=True, + capstyle=None, + joinstyle=None, + **kwargs): + """ + The following kwarg properties are supported + + %(Patch:kwdoc)s + """ + super().__init__() + + if linestyle is None: + linestyle = "solid" + if capstyle is None: + capstyle = CapStyle.butt + if joinstyle is None: + joinstyle = JoinStyle.miter + + self._hatch_color = colors.to_rgba(mpl.rcParams['hatch.color']) + self._fill = bool(fill) # needed for set_facecolor call + if color is not None: + if edgecolor is not None or facecolor is not None: + _api.warn_external( + "Setting the 'color' property will override " + "the edgecolor or facecolor properties.") + self.set_color(color) + else: + self.set_edgecolor(edgecolor) + self.set_facecolor(facecolor) + + self._linewidth = 0 + self._unscaled_dash_pattern = (0, None) # offset, dash + self._dash_pattern = (0, None) # offset, dash (scaled by linewidth) + + self.set_linestyle(linestyle) + self.set_linewidth(linewidth) + self.set_antialiased(antialiased) + self.set_hatch(hatch) + self.set_capstyle(capstyle) + self.set_joinstyle(joinstyle) + + if len(kwargs): + self._internal_update(kwargs) + + def get_verts(self): + """ + Return a copy of the vertices used in this patch. + + If the patch contains Bézier curves, the curves will be interpolated by + line segments. To access the curves as curves, use `get_path`. + """ + trans = self.get_transform() + path = self.get_path() + polygons = path.to_polygons(trans) + if len(polygons): + return polygons[0] + return [] + + def _process_radius(self, radius): + if radius is not None: + return radius + if isinstance(self._picker, Number): + _radius = self._picker + else: + if self.get_edgecolor()[3] == 0: + _radius = 0 + else: + _radius = self.get_linewidth() + return _radius + + def contains(self, mouseevent, radius=None): + """ + Test whether the mouse event occurred in the patch. + + Parameters + ---------- + mouseevent : `~matplotlib.backend_bases.MouseEvent` + Where the user clicked. + + radius : float, optional + Additional margin on the patch in target coordinates of + `.Patch.get_transform`. See `.Path.contains_point` for further + details. + + If `None`, the default value depends on the state of the object: + + - If `.Artist.get_picker` is a number, the default + is that value. This is so that picking works as expected. + - Otherwise if the edge color has a non-zero alpha, the default + is half of the linewidth. This is so that all the colored + pixels are "in" the patch. + - Finally, if the edge has 0 alpha, the default is 0. This is + so that patches without a stroked edge do not have points + outside of the filled region report as "in" due to an + invisible edge. + + + Returns + ------- + (bool, empty dict) + """ + if self._different_canvas(mouseevent): + return False, {} + radius = self._process_radius(radius) + codes = self.get_path().codes + if codes is not None: + vertices = self.get_path().vertices + # if the current path is concatenated by multiple sub paths. + # get the indexes of the starting code(MOVETO) of all sub paths + idxs, = np.where(codes == Path.MOVETO) + # Don't split before the first MOVETO. + idxs = idxs[1:] + subpaths = map( + Path, np.split(vertices, idxs), np.split(codes, idxs)) + else: + subpaths = [self.get_path()] + inside = any( + subpath.contains_point( + (mouseevent.x, mouseevent.y), self.get_transform(), radius) + for subpath in subpaths) + return inside, {} + + def contains_point(self, point, radius=None): + """ + Return whether the given point is inside the patch. + + Parameters + ---------- + point : (float, float) + The point (x, y) to check, in target coordinates of + ``.Patch.get_transform()``. These are display coordinates for patches + that are added to a figure or Axes. + radius : float, optional + Additional margin on the patch in target coordinates of + `.Patch.get_transform`. See `.Path.contains_point` for further + details. + + If `None`, the default value depends on the state of the object: + + - If `.Artist.get_picker` is a number, the default + is that value. This is so that picking works as expected. + - Otherwise if the edge color has a non-zero alpha, the default + is half of the linewidth. This is so that all the colored + pixels are "in" the patch. + - Finally, if the edge has 0 alpha, the default is 0. This is + so that patches without a stroked edge do not have points + outside of the filled region report as "in" due to an + invisible edge. + + Returns + ------- + bool + + Notes + ----- + The proper use of this method depends on the transform of the patch. + Isolated patches do not have a transform. In this case, the patch + creation coordinates and the point coordinates match. The following + example checks that the center of a circle is within the circle + + >>> center = 0, 0 + >>> c = Circle(center, radius=1) + >>> c.contains_point(center) + True + + The convention of checking against the transformed patch stems from + the fact that this method is predominantly used to check if display + coordinates (e.g. from mouse events) are within the patch. If you want + to do the above check with data coordinates, you have to properly + transform them first: + + >>> center = 0, 0 + >>> c = Circle(center, radius=3) + >>> plt.gca().add_patch(c) + >>> transformed_interior_point = c.get_data_transform().transform((0, 2)) + >>> c.contains_point(transformed_interior_point) + True + + """ + radius = self._process_radius(radius) + return self.get_path().contains_point(point, + self.get_transform(), + radius) + + def contains_points(self, points, radius=None): + """ + Return whether the given points are inside the patch. + + Parameters + ---------- + points : (N, 2) array + The points to check, in target coordinates of + ``self.get_transform()``. These are display coordinates for patches + that are added to a figure or Axes. Columns contain x and y values. + radius : float, optional + Additional margin on the patch in target coordinates of + `.Patch.get_transform`. See `.Path.contains_point` for further + details. + + If `None`, the default value depends on the state of the object: + + - If `.Artist.get_picker` is a number, the default + is that value. This is so that picking works as expected. + - Otherwise if the edge color has a non-zero alpha, the default + is half of the linewidth. This is so that all the colored + pixels are "in" the patch. + - Finally, if the edge has 0 alpha, the default is 0. This is + so that patches without a stroked edge do not have points + outside of the filled region report as "in" due to an + invisible edge. + + Returns + ------- + length-N bool array + + Notes + ----- + The proper use of this method depends on the transform of the patch. + See the notes on `.Patch.contains_point`. + """ + radius = self._process_radius(radius) + return self.get_path().contains_points(points, + self.get_transform(), + radius) + + def update_from(self, other): + # docstring inherited. + super().update_from(other) + # For some properties we don't need or don't want to go through the + # getters/setters, so we just copy them directly. + self._edgecolor = other._edgecolor + self._facecolor = other._facecolor + self._original_edgecolor = other._original_edgecolor + self._original_facecolor = other._original_facecolor + self._fill = other._fill + self._hatch = other._hatch + self._hatch_color = other._hatch_color + self._unscaled_dash_pattern = other._unscaled_dash_pattern + self.set_linewidth(other._linewidth) # also sets scaled dashes + self.set_transform(other.get_data_transform()) + # If the transform of other needs further initialization, then it will + # be the case for this artist too. + self._transformSet = other.is_transform_set() + + def get_extents(self): + """ + Return the `Patch`'s axis-aligned extents as a `~.transforms.Bbox`. + """ + return self.get_path().get_extents(self.get_transform()) + + def get_transform(self): + """Return the `~.transforms.Transform` applied to the `Patch`.""" + return self.get_patch_transform() + artist.Artist.get_transform(self) + + def get_data_transform(self): + """ + Return the `~.transforms.Transform` mapping data coordinates to + physical coordinates. + """ + return artist.Artist.get_transform(self) + + def get_patch_transform(self): + """ + Return the `~.transforms.Transform` instance mapping patch coordinates + to data coordinates. + + For example, one may define a patch of a circle which represents a + radius of 5 by providing coordinates for a unit circle, and a + transform which scales the coordinates (the patch coordinate) by 5. + """ + return transforms.IdentityTransform() + + def get_antialiased(self): + """Return whether antialiasing is used for drawing.""" + return self._antialiased + + def get_edgecolor(self): + """Return the edge color.""" + return self._edgecolor + + def get_facecolor(self): + """Return the face color.""" + return self._facecolor + + def get_linewidth(self): + """Return the line width in points.""" + return self._linewidth + + def get_linestyle(self): + """Return the linestyle.""" + return self._linestyle + + def set_antialiased(self, aa): + """ + Set whether to use antialiased rendering. + + Parameters + ---------- + aa : bool or None + """ + if aa is None: + aa = mpl.rcParams['patch.antialiased'] + self._antialiased = aa + self.stale = True + + def _set_edgecolor(self, color): + set_hatch_color = True + if color is None: + if (mpl.rcParams['patch.force_edgecolor'] or + not self._fill or self._edge_default): + color = mpl.rcParams['patch.edgecolor'] + else: + color = 'none' + set_hatch_color = False + + self._edgecolor = colors.to_rgba(color, self._alpha) + if set_hatch_color: + self._hatch_color = self._edgecolor + self.stale = True + + def set_edgecolor(self, color): + """ + Set the patch edge color. + + Parameters + ---------- + color : :mpltype:`color` or None + """ + self._original_edgecolor = color + self._set_edgecolor(color) + + def _set_facecolor(self, color): + if color is None: + color = mpl.rcParams['patch.facecolor'] + alpha = self._alpha if self._fill else 0 + self._facecolor = colors.to_rgba(color, alpha) + self.stale = True + + def set_facecolor(self, color): + """ + Set the patch face color. + + Parameters + ---------- + color : :mpltype:`color` or None + """ + self._original_facecolor = color + self._set_facecolor(color) + + def set_color(self, c): + """ + Set both the edgecolor and the facecolor. + + Parameters + ---------- + c : :mpltype:`color` + + See Also + -------- + Patch.set_facecolor, Patch.set_edgecolor + For setting the edge or face color individually. + """ + self.set_facecolor(c) + self.set_edgecolor(c) + + def set_alpha(self, alpha): + # docstring inherited + super().set_alpha(alpha) + self._set_facecolor(self._original_facecolor) + self._set_edgecolor(self._original_edgecolor) + # stale is already True + + def set_linewidth(self, w): + """ + Set the patch linewidth in points. + + Parameters + ---------- + w : float or None + """ + if w is None: + w = mpl.rcParams['patch.linewidth'] + self._linewidth = float(w) + self._dash_pattern = mlines._scale_dashes( + *self._unscaled_dash_pattern, w) + self.stale = True + + def set_linestyle(self, ls): + """ + Set the patch linestyle. + + ========================================== ================= + linestyle description + ========================================== ================= + ``'-'`` or ``'solid'`` solid line + ``'--'`` or ``'dashed'`` dashed line + ``'-.'`` or ``'dashdot'`` dash-dotted line + ``':'`` or ``'dotted'`` dotted line + ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing + ========================================== ================= + + Alternatively a dash tuple of the following form can be provided:: + + (offset, onoffseq) + + where ``onoffseq`` is an even length tuple of on and off ink in points. + + Parameters + ---------- + ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} + The line style. + """ + if ls is None: + ls = "solid" + if ls in [' ', '', 'none']: + ls = 'None' + self._linestyle = ls + self._unscaled_dash_pattern = mlines._get_dash_pattern(ls) + self._dash_pattern = mlines._scale_dashes( + *self._unscaled_dash_pattern, self._linewidth) + self.stale = True + + def set_fill(self, b): + """ + Set whether to fill the patch. + + Parameters + ---------- + b : bool + """ + self._fill = bool(b) + self._set_facecolor(self._original_facecolor) + self._set_edgecolor(self._original_edgecolor) + self.stale = True + + def get_fill(self): + """Return whether the patch is filled.""" + return self._fill + + # Make fill a property so as to preserve the long-standing + # but somewhat inconsistent behavior in which fill was an + # attribute. + fill = property(get_fill, set_fill) + + @_docstring.interpd + def set_capstyle(self, s): + """ + Set the `.CapStyle`. + + The default capstyle is 'round' for `.FancyArrowPatch` and 'butt' for + all other patches. + + Parameters + ---------- + s : `.CapStyle` or %(CapStyle)s + """ + cs = CapStyle(s) + self._capstyle = cs + self.stale = True + + def get_capstyle(self): + """Return the capstyle.""" + return self._capstyle.name + + @_docstring.interpd + def set_joinstyle(self, s): + """ + Set the `.JoinStyle`. + + The default joinstyle is 'round' for `.FancyArrowPatch` and 'miter' for + all other patches. + + Parameters + ---------- + s : `.JoinStyle` or %(JoinStyle)s + """ + js = JoinStyle(s) + self._joinstyle = js + self.stale = True + + def get_joinstyle(self): + """Return the joinstyle.""" + return self._joinstyle.name + + def set_hatch(self, hatch): + r""" + Set the hatching pattern. + + *hatch* can be one of:: + + / - diagonal hatching + \ - back diagonal + | - vertical + - - horizontal + + - crossed + x - crossed diagonal + o - small circle + O - large circle + . - dots + * - stars + + Letters can be combined, in which case all the specified + hatchings are done. If same letter repeats, it increases the + density of hatching of that pattern. + + Parameters + ---------- + hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} + """ + # Use validate_hatch(list) after deprecation. + mhatch._validate_hatch_pattern(hatch) + self._hatch = hatch + self.stale = True + + def get_hatch(self): + """Return the hatching pattern.""" + return self._hatch + + def _draw_paths_with_artist_properties( + self, renderer, draw_path_args_list): + """ + ``draw()`` helper factored out for sharing with `FancyArrowPatch`. + + Configure *renderer* and the associated graphics context *gc* + from the artist properties, then repeatedly call + ``renderer.draw_path(gc, *draw_path_args)`` for each tuple + *draw_path_args* in *draw_path_args_list*. + """ + + renderer.open_group('patch', self.get_gid()) + gc = renderer.new_gc() + + gc.set_foreground(self._edgecolor, isRGBA=True) + + lw = self._linewidth + if self._edgecolor[3] == 0 or self._linestyle == 'None': + lw = 0 + gc.set_linewidth(lw) + gc.set_dashes(*self._dash_pattern) + gc.set_capstyle(self._capstyle) + gc.set_joinstyle(self._joinstyle) + + gc.set_antialiased(self._antialiased) + self._set_gc_clip(gc) + gc.set_url(self._url) + gc.set_snap(self.get_snap()) + + gc.set_alpha(self._alpha) + + if self._hatch: + gc.set_hatch(self._hatch) + gc.set_hatch_color(self._hatch_color) + + if self.get_sketch_params() is not None: + gc.set_sketch_params(*self.get_sketch_params()) + + if self.get_path_effects(): + from matplotlib.patheffects import PathEffectRenderer + renderer = PathEffectRenderer(self.get_path_effects(), renderer) + + for draw_path_args in draw_path_args_list: + renderer.draw_path(gc, *draw_path_args) + + gc.restore() + renderer.close_group('patch') + self.stale = False + + @artist.allow_rasterization + def draw(self, renderer): + # docstring inherited + if not self.get_visible(): + return + path = self.get_path() + transform = self.get_transform() + tpath = transform.transform_path_non_affine(path) + affine = transform.get_affine() + self._draw_paths_with_artist_properties( + renderer, + [(tpath, affine, + # Work around a bug in the PDF and SVG renderers, which + # do not draw the hatches if the facecolor is fully + # transparent, but do if it is None. + self._facecolor if self._facecolor[3] else None)]) + + def get_path(self): + """Return the path of this patch.""" + raise NotImplementedError('Derived must override') + + def get_window_extent(self, renderer=None): + return self.get_path().get_extents(self.get_transform()) + + def _convert_xy_units(self, xy): + """Convert x and y units for a tuple (x, y).""" + x = self.convert_xunits(xy[0]) + y = self.convert_yunits(xy[1]) + return x, y + + +class Shadow(Patch): + def __str__(self): + return f"Shadow({self.patch})" + + @_docstring.dedent_interpd + def __init__(self, patch, ox, oy, *, shade=0.7, **kwargs): + """ + Create a shadow of the given *patch*. + + By default, the shadow will have the same face color as the *patch*, + but darkened. The darkness can be controlled by *shade*. + + Parameters + ---------- + patch : `~matplotlib.patches.Patch` + The patch to create the shadow for. + ox, oy : float + The shift of the shadow in data coordinates, scaled by a factor + of dpi/72. + shade : float, default: 0.7 + How the darkness of the shadow relates to the original color. If 1, the + shadow is black, if 0, the shadow has the same color as the *patch*. + + .. versionadded:: 3.8 + + **kwargs + Properties of the shadow patch. Supported keys are: + + %(Patch:kwdoc)s + """ + super().__init__() + self.patch = patch + self._ox, self._oy = ox, oy + self._shadow_transform = transforms.Affine2D() + + self.update_from(self.patch) + if not 0 <= shade <= 1: + raise ValueError("shade must be between 0 and 1.") + color = (1 - shade) * np.asarray(colors.to_rgb(self.patch.get_facecolor())) + self.update({'facecolor': color, 'edgecolor': color, 'alpha': 0.5, + # Place shadow patch directly behind the inherited patch. + 'zorder': np.nextafter(self.patch.zorder, -np.inf), + **kwargs}) + + def _update_transform(self, renderer): + ox = renderer.points_to_pixels(self._ox) + oy = renderer.points_to_pixels(self._oy) + self._shadow_transform.clear().translate(ox, oy) + + def get_path(self): + return self.patch.get_path() + + def get_patch_transform(self): + return self.patch.get_patch_transform() + self._shadow_transform + + def draw(self, renderer): + self._update_transform(renderer) + super().draw(renderer) + + +class Rectangle(Patch): + """ + A rectangle defined via an anchor point *xy* and its *width* and *height*. + + The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction + and from ``xy[1]`` to ``xy[1] + height`` in y-direction. :: + + : +------------------+ + : | | + : height | + : | | + : (xy)---- width -----+ + + One may picture *xy* as the bottom left corner, but which corner *xy* is + actually depends on the direction of the axis and the sign of *width* + and *height*; e.g. *xy* would be the bottom right corner if the x-axis + was inverted or if *width* was negative. + """ + + def __str__(self): + pars = self._x0, self._y0, self._width, self._height, self.angle + fmt = "Rectangle(xy=(%g, %g), width=%g, height=%g, angle=%g)" + return fmt % pars + + @_docstring.dedent_interpd + def __init__(self, xy, width, height, *, + angle=0.0, rotation_point='xy', **kwargs): + """ + Parameters + ---------- + xy : (float, float) + The anchor point. + width : float + Rectangle width. + height : float + Rectangle height. + angle : float, default: 0 + Rotation in degrees anti-clockwise about the rotation point. + rotation_point : {'xy', 'center', (number, number)}, default: 'xy' + If ``'xy'``, rotate around the anchor point. If ``'center'`` rotate + around the center. If 2-tuple of number, rotate around this + coordinate. + + Other Parameters + ---------------- + **kwargs : `~matplotlib.patches.Patch` properties + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + self._x0 = xy[0] + self._y0 = xy[1] + self._width = width + self._height = height + self.angle = float(angle) + self.rotation_point = rotation_point + # Required for RectangleSelector with axes aspect ratio != 1 + # The patch is defined in data coordinates and when changing the + # selector with square modifier and not in data coordinates, we need + # to correct for the aspect ratio difference between the data and + # display coordinate systems. Its value is typically provide by + # Axes._get_aspect_ratio() + self._aspect_ratio_correction = 1.0 + self._convert_units() # Validate the inputs. + + def get_path(self): + """Return the vertices of the rectangle.""" + return Path.unit_rectangle() + + def _convert_units(self): + """Convert bounds of the rectangle.""" + x0 = self.convert_xunits(self._x0) + y0 = self.convert_yunits(self._y0) + x1 = self.convert_xunits(self._x0 + self._width) + y1 = self.convert_yunits(self._y0 + self._height) + return x0, y0, x1, y1 + + def get_patch_transform(self): + # Note: This cannot be called until after this has been added to + # an Axes, otherwise unit conversion will fail. This makes it very + # important to call the accessor method and not directly access the + # transformation member variable. + bbox = self.get_bbox() + if self.rotation_point == 'center': + width, height = bbox.x1 - bbox.x0, bbox.y1 - bbox.y0 + rotation_point = bbox.x0 + width / 2., bbox.y0 + height / 2. + elif self.rotation_point == 'xy': + rotation_point = bbox.x0, bbox.y0 + else: + rotation_point = self.rotation_point + return transforms.BboxTransformTo(bbox) \ + + transforms.Affine2D() \ + .translate(-rotation_point[0], -rotation_point[1]) \ + .scale(1, self._aspect_ratio_correction) \ + .rotate_deg(self.angle) \ + .scale(1, 1 / self._aspect_ratio_correction) \ + .translate(*rotation_point) + + @property + def rotation_point(self): + """The rotation point of the patch.""" + return self._rotation_point + + @rotation_point.setter + def rotation_point(self, value): + if value in ['center', 'xy'] or ( + isinstance(value, tuple) and len(value) == 2 and + isinstance(value[0], Real) and isinstance(value[1], Real) + ): + self._rotation_point = value + else: + raise ValueError("`rotation_point` must be one of " + "{'xy', 'center', (number, number)}.") + + def get_x(self): + """Return the left coordinate of the rectangle.""" + return self._x0 + + def get_y(self): + """Return the bottom coordinate of the rectangle.""" + return self._y0 + + def get_xy(self): + """Return the left and bottom coords of the rectangle as a tuple.""" + return self._x0, self._y0 + + def get_corners(self): + """ + Return the corners of the rectangle, moving anti-clockwise from + (x0, y0). + """ + return self.get_patch_transform().transform( + [(0, 0), (1, 0), (1, 1), (0, 1)]) + + def get_center(self): + """Return the centre of the rectangle.""" + return self.get_patch_transform().transform((0.5, 0.5)) + + def get_width(self): + """Return the width of the rectangle.""" + return self._width + + def get_height(self): + """Return the height of the rectangle.""" + return self._height + + def get_angle(self): + """Get the rotation angle in degrees.""" + return self.angle + + def set_x(self, x): + """Set the left coordinate of the rectangle.""" + self._x0 = x + self.stale = True + + def set_y(self, y): + """Set the bottom coordinate of the rectangle.""" + self._y0 = y + self.stale = True + + def set_angle(self, angle): + """ + Set the rotation angle in degrees. + + The rotation is performed anti-clockwise around *xy*. + """ + self.angle = angle + self.stale = True + + def set_xy(self, xy): + """ + Set the left and bottom coordinates of the rectangle. + + Parameters + ---------- + xy : (float, float) + """ + self._x0, self._y0 = xy + self.stale = True + + def set_width(self, w): + """Set the width of the rectangle.""" + self._width = w + self.stale = True + + def set_height(self, h): + """Set the height of the rectangle.""" + self._height = h + self.stale = True + + def set_bounds(self, *args): + """ + Set the bounds of the rectangle as *left*, *bottom*, *width*, *height*. + + The values may be passed as separate parameters or as a tuple:: + + set_bounds(left, bottom, width, height) + set_bounds((left, bottom, width, height)) + + .. ACCEPTS: (left, bottom, width, height) + """ + if len(args) == 1: + l, b, w, h = args[0] + else: + l, b, w, h = args + self._x0 = l + self._y0 = b + self._width = w + self._height = h + self.stale = True + + def get_bbox(self): + """Return the `.Bbox`.""" + return transforms.Bbox.from_extents(*self._convert_units()) + + xy = property(get_xy, set_xy) + + +class RegularPolygon(Patch): + """A regular polygon patch.""" + + def __str__(self): + s = "RegularPolygon((%g, %g), %d, radius=%g, orientation=%g)" + return s % (self.xy[0], self.xy[1], self.numvertices, self.radius, + self.orientation) + + @_docstring.dedent_interpd + def __init__(self, xy, numVertices, *, + radius=5, orientation=0, **kwargs): + """ + Parameters + ---------- + xy : (float, float) + The center position. + + numVertices : int + The number of vertices. + + radius : float + The distance from the center to each of the vertices. + + orientation : float + The polygon rotation angle (in radians). + + **kwargs + `Patch` properties: + + %(Patch:kwdoc)s + """ + self.xy = xy + self.numvertices = numVertices + self.orientation = orientation + self.radius = radius + self._path = Path.unit_regular_polygon(numVertices) + self._patch_transform = transforms.Affine2D() + super().__init__(**kwargs) + + def get_path(self): + return self._path + + def get_patch_transform(self): + return self._patch_transform.clear() \ + .scale(self.radius) \ + .rotate(self.orientation) \ + .translate(*self.xy) + + +class PathPatch(Patch): + """A general polycurve path patch.""" + + _edge_default = True + + def __str__(self): + s = "PathPatch%d((%g, %g) ...)" + return s % (len(self._path.vertices), *tuple(self._path.vertices[0])) + + @_docstring.dedent_interpd + def __init__(self, path, **kwargs): + """ + *path* is a `.Path` object. + + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + self._path = path + + def get_path(self): + return self._path + + def set_path(self, path): + self._path = path + + +class StepPatch(PathPatch): + """ + A path patch describing a stepwise constant function. + + By default, the path is not closed and starts and stops at + baseline value. + """ + + _edge_default = False + + @_docstring.dedent_interpd + def __init__(self, values, edges, *, + orientation='vertical', baseline=0, **kwargs): + """ + Parameters + ---------- + values : array-like + The step heights. + + edges : array-like + The edge positions, with ``len(edges) == len(vals) + 1``, + between which the curve takes on vals values. + + orientation : {'vertical', 'horizontal'}, default: 'vertical' + The direction of the steps. Vertical means that *values* are + along the y-axis, and edges are along the x-axis. + + baseline : float, array-like or None, default: 0 + The bottom value of the bounding edges or when + ``fill=True``, position of lower edge. If *fill* is + True or an array is passed to *baseline*, a closed + path is drawn. + + **kwargs + `Patch` properties: + + %(Patch:kwdoc)s + """ + self.orientation = orientation + self._edges = np.asarray(edges) + self._values = np.asarray(values) + self._baseline = np.asarray(baseline) if baseline is not None else None + self._update_path() + super().__init__(self._path, **kwargs) + + def _update_path(self): + if np.isnan(np.sum(self._edges)): + raise ValueError('Nan values in "edges" are disallowed') + if self._edges.size - 1 != self._values.size: + raise ValueError('Size mismatch between "values" and "edges". ' + "Expected `len(values) + 1 == len(edges)`, but " + f"`len(values) = {self._values.size}` and " + f"`len(edges) = {self._edges.size}`.") + # Initializing with empty arrays allows supporting empty stairs. + verts, codes = [np.empty((0, 2))], [np.empty(0, dtype=Path.code_type)] + + _nan_mask = np.isnan(self._values) + if self._baseline is not None: + _nan_mask |= np.isnan(self._baseline) + for idx0, idx1 in cbook.contiguous_regions(~_nan_mask): + x = np.repeat(self._edges[idx0:idx1+1], 2) + y = np.repeat(self._values[idx0:idx1], 2) + if self._baseline is None: + y = np.concatenate([y[:1], y, y[-1:]]) + elif self._baseline.ndim == 0: # single baseline value + y = np.concatenate([[self._baseline], y, [self._baseline]]) + elif self._baseline.ndim == 1: # baseline array + base = np.repeat(self._baseline[idx0:idx1], 2)[::-1] + x = np.concatenate([x, x[::-1]]) + y = np.concatenate([base[-1:], y, base[:1], + base[:1], base, base[-1:]]) + else: # no baseline + raise ValueError('Invalid `baseline` specified') + if self.orientation == 'vertical': + xy = np.column_stack([x, y]) + else: + xy = np.column_stack([y, x]) + verts.append(xy) + codes.append([Path.MOVETO] + [Path.LINETO]*(len(xy)-1)) + self._path = Path(np.concatenate(verts), np.concatenate(codes)) + + def get_data(self): + """Get `.StepPatch` values, edges and baseline as namedtuple.""" + StairData = namedtuple('StairData', 'values edges baseline') + return StairData(self._values, self._edges, self._baseline) + + def set_data(self, values=None, edges=None, baseline=None): + """ + Set `.StepPatch` values, edges and baseline. + + Parameters + ---------- + values : 1D array-like or None + Will not update values, if passing None + edges : 1D array-like, optional + baseline : float, 1D array-like or None + """ + if values is None and edges is None and baseline is None: + raise ValueError("Must set *values*, *edges* or *baseline*.") + if values is not None: + self._values = np.asarray(values) + if edges is not None: + self._edges = np.asarray(edges) + if baseline is not None: + self._baseline = np.asarray(baseline) + self._update_path() + self.stale = True + + +class Polygon(Patch): + """A general polygon patch.""" + + def __str__(self): + if len(self._path.vertices): + s = "Polygon%d((%g, %g) ...)" + return s % (len(self._path.vertices), *self._path.vertices[0]) + else: + return "Polygon0()" + + @_docstring.dedent_interpd + def __init__(self, xy, *, closed=True, **kwargs): + """ + Parameters + ---------- + xy : (N, 2) array + + closed : bool, default: True + Whether the polygon is closed (i.e., has identical start and end + points). + + **kwargs + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + self._closed = closed + self.set_xy(xy) + + def get_path(self): + """Get the `.Path` of the polygon.""" + return self._path + + def get_closed(self): + """Return whether the polygon is closed.""" + return self._closed + + def set_closed(self, closed): + """ + Set whether the polygon is closed. + + Parameters + ---------- + closed : bool + True if the polygon is closed + """ + if self._closed == bool(closed): + return + self._closed = bool(closed) + self.set_xy(self.get_xy()) + self.stale = True + + def get_xy(self): + """ + Get the vertices of the path. + + Returns + ------- + (N, 2) array + The coordinates of the vertices. + """ + return self._path.vertices + + def set_xy(self, xy): + """ + Set the vertices of the polygon. + + Parameters + ---------- + xy : (N, 2) array-like + The coordinates of the vertices. + + Notes + ----- + Unlike `.Path`, we do not ignore the last input vertex. If the + polygon is meant to be closed, and the last point of the polygon is not + equal to the first, we assume that the user has not explicitly passed a + ``CLOSEPOLY`` vertex, and add it ourselves. + """ + xy = np.asarray(xy) + nverts, _ = xy.shape + if self._closed: + # if the first and last vertex are the "same", then we assume that + # the user explicitly passed the CLOSEPOLY vertex. Otherwise, we + # have to append one since the last vertex will be "ignored" by + # Path + if nverts == 1 or nverts > 1 and (xy[0] != xy[-1]).any(): + xy = np.concatenate([xy, [xy[0]]]) + else: + # if we aren't closed, and the last vertex matches the first, then + # we assume we have an unnecessary CLOSEPOLY vertex and remove it + if nverts > 2 and (xy[0] == xy[-1]).all(): + xy = xy[:-1] + self._path = Path(xy, closed=self._closed) + self.stale = True + + xy = property(get_xy, set_xy, + doc='The vertices of the path as a (N, 2) array.') + + +class Wedge(Patch): + """Wedge shaped patch.""" + + def __str__(self): + pars = (self.center[0], self.center[1], self.r, + self.theta1, self.theta2, self.width) + fmt = "Wedge(center=(%g, %g), r=%g, theta1=%g, theta2=%g, width=%s)" + return fmt % pars + + @_docstring.dedent_interpd + def __init__(self, center, r, theta1, theta2, *, width=None, **kwargs): + """ + A wedge centered at *x*, *y* center with radius *r* that + sweeps *theta1* to *theta2* (in degrees). If *width* is given, + then a partial wedge is drawn from inner radius *r* - *width* + to outer radius *r*. + + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + self.center = center + self.r, self.width = r, width + self.theta1, self.theta2 = theta1, theta2 + self._patch_transform = transforms.IdentityTransform() + self._recompute_path() + + def _recompute_path(self): + # Inner and outer rings are connected unless the annulus is complete + if abs((self.theta2 - self.theta1) - 360) <= 1e-12: + theta1, theta2 = 0, 360 + connector = Path.MOVETO + else: + theta1, theta2 = self.theta1, self.theta2 + connector = Path.LINETO + + # Form the outer ring + arc = Path.arc(theta1, theta2) + + if self.width is not None: + # Partial annulus needs to draw the outer ring + # followed by a reversed and scaled inner ring + v1 = arc.vertices + v2 = arc.vertices[::-1] * (self.r - self.width) / self.r + v = np.concatenate([v1, v2, [(0, 0)]]) + c = [*arc.codes, connector, *arc.codes[1:], Path.CLOSEPOLY] + else: + # Wedge doesn't need an inner ring + v = np.concatenate([arc.vertices, [(0, 0), (0, 0)]]) + c = [*arc.codes, connector, Path.CLOSEPOLY] + + # Shift and scale the wedge to the final location. + self._path = Path(v * self.r + self.center, c) + + def set_center(self, center): + self._path = None + self.center = center + self.stale = True + + def set_radius(self, radius): + self._path = None + self.r = radius + self.stale = True + + def set_theta1(self, theta1): + self._path = None + self.theta1 = theta1 + self.stale = True + + def set_theta2(self, theta2): + self._path = None + self.theta2 = theta2 + self.stale = True + + def set_width(self, width): + self._path = None + self.width = width + self.stale = True + + def get_path(self): + if self._path is None: + self._recompute_path() + return self._path + + +# COVERAGE NOTE: Not used internally or from examples +class Arrow(Patch): + """An arrow patch.""" + + def __str__(self): + return "Arrow()" + + _path = Path._create_closed([ + [0.0, 0.1], [0.0, -0.1], [0.8, -0.1], [0.8, -0.3], [1.0, 0.0], + [0.8, 0.3], [0.8, 0.1]]) + + @_docstring.dedent_interpd + def __init__(self, x, y, dx, dy, *, width=1.0, **kwargs): + """ + Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*). + The width of the arrow is scaled by *width*. + + Parameters + ---------- + x : float + x coordinate of the arrow tail. + y : float + y coordinate of the arrow tail. + dx : float + Arrow length in the x direction. + dy : float + Arrow length in the y direction. + width : float, default: 1 + Scale factor for the width of the arrow. With a default value of 1, + the tail width is 0.2 and head width is 0.6. + **kwargs + Keyword arguments control the `Patch` properties: + + %(Patch:kwdoc)s + + See Also + -------- + FancyArrow + Patch that allows independent control of the head and tail + properties. + """ + super().__init__(**kwargs) + self.set_data(x, y, dx, dy, width) + + def get_path(self): + return self._path + + def get_patch_transform(self): + return self._patch_transform + + def set_data(self, x=None, y=None, dx=None, dy=None, width=None): + """ + Set `.Arrow` x, y, dx, dy and width. + Values left as None will not be updated. + + Parameters + ---------- + x, y : float or None, default: None + The x and y coordinates of the arrow base. + + dx, dy : float or None, default: None + The length of the arrow along x and y direction. + + width : float or None, default: None + Width of full arrow tail. + """ + if x is not None: + self._x = x + if y is not None: + self._y = y + if dx is not None: + self._dx = dx + if dy is not None: + self._dy = dy + if width is not None: + self._width = width + self._patch_transform = ( + transforms.Affine2D() + .scale(np.hypot(self._dx, self._dy), self._width) + .rotate(np.arctan2(self._dy, self._dx)) + .translate(self._x, self._y) + .frozen()) + + +class FancyArrow(Polygon): + """ + Like Arrow, but lets you set head width and head height independently. + """ + + _edge_default = True + + def __str__(self): + return "FancyArrow()" + + @_docstring.dedent_interpd + def __init__(self, x, y, dx, dy, *, + width=0.001, length_includes_head=False, head_width=None, + head_length=None, shape='full', overhang=0, + head_starts_at_zero=False, **kwargs): + """ + Parameters + ---------- + x, y : float + The x and y coordinates of the arrow base. + + dx, dy : float + The length of the arrow along x and y direction. + + width : float, default: 0.001 + Width of full arrow tail. + + length_includes_head : bool, default: False + True if head is to be counted in calculating the length. + + head_width : float or None, default: 3*width + Total width of the full arrow head. + + head_length : float or None, default: 1.5*head_width + Length of arrow head. + + shape : {'full', 'left', 'right'}, default: 'full' + Draw the left-half, right-half, or full arrow. + + overhang : float, default: 0 + Fraction that the arrow is swept back (0 overhang means + triangular shape). Can be negative or greater than one. + + head_starts_at_zero : bool, default: False + If True, the head starts being drawn at coordinate 0 + instead of ending at coordinate 0. + + **kwargs + `.Patch` properties: + + %(Patch:kwdoc)s + """ + self._x = x + self._y = y + self._dx = dx + self._dy = dy + self._width = width + self._length_includes_head = length_includes_head + self._head_width = head_width + self._head_length = head_length + self._shape = shape + self._overhang = overhang + self._head_starts_at_zero = head_starts_at_zero + self._make_verts() + super().__init__(self.verts, closed=True, **kwargs) + + def set_data(self, *, x=None, y=None, dx=None, dy=None, width=None, + head_width=None, head_length=None): + """ + Set `.FancyArrow` x, y, dx, dy, width, head_with, and head_length. + Values left as None will not be updated. + + Parameters + ---------- + x, y : float or None, default: None + The x and y coordinates of the arrow base. + + dx, dy : float or None, default: None + The length of the arrow along x and y direction. + + width : float or None, default: None + Width of full arrow tail. + + head_width : float or None, default: None + Total width of the full arrow head. + + head_length : float or None, default: None + Length of arrow head. + """ + if x is not None: + self._x = x + if y is not None: + self._y = y + if dx is not None: + self._dx = dx + if dy is not None: + self._dy = dy + if width is not None: + self._width = width + if head_width is not None: + self._head_width = head_width + if head_length is not None: + self._head_length = head_length + self._make_verts() + self.set_xy(self.verts) + + def _make_verts(self): + if self._head_width is None: + head_width = 3 * self._width + else: + head_width = self._head_width + if self._head_length is None: + head_length = 1.5 * head_width + else: + head_length = self._head_length + + distance = np.hypot(self._dx, self._dy) + + if self._length_includes_head: + length = distance + else: + length = distance + head_length + if not length: + self.verts = np.empty([0, 2]) # display nothing if empty + else: + # start by drawing horizontal arrow, point at (0, 0) + hw, hl = head_width, head_length + hs, lw = self._overhang, self._width + left_half_arrow = np.array([ + [0.0, 0.0], # tip + [-hl, -hw / 2], # leftmost + [-hl * (1 - hs), -lw / 2], # meets stem + [-length, -lw / 2], # bottom left + [-length, 0], + ]) + # if we're not including the head, shift up by head length + if not self._length_includes_head: + left_half_arrow += [head_length, 0] + # if the head starts at 0, shift up by another head length + if self._head_starts_at_zero: + left_half_arrow += [head_length / 2, 0] + # figure out the shape, and complete accordingly + if self._shape == 'left': + coords = left_half_arrow + else: + right_half_arrow = left_half_arrow * [1, -1] + if self._shape == 'right': + coords = right_half_arrow + elif self._shape == 'full': + # The half-arrows contain the midpoint of the stem, + # which we can omit from the full arrow. Including it + # twice caused a problem with xpdf. + coords = np.concatenate([left_half_arrow[:-1], + right_half_arrow[-2::-1]]) + else: + raise ValueError(f"Got unknown shape: {self._shape!r}") + if distance != 0: + cx = self._dx / distance + sx = self._dy / distance + else: + # Account for division by zero + cx, sx = 0, 1 + M = [[cx, sx], [-sx, cx]] + self.verts = np.dot(coords, M) + [ + self._x + self._dx, + self._y + self._dy, + ] + + +_docstring.interpd.update( + FancyArrow="\n".join( + (inspect.getdoc(FancyArrow.__init__) or "").splitlines()[2:])) + + +class CirclePolygon(RegularPolygon): + """A polygon-approximation of a circle patch.""" + + def __str__(self): + s = "CirclePolygon((%g, %g), radius=%g, resolution=%d)" + return s % (self.xy[0], self.xy[1], self.radius, self.numvertices) + + @_docstring.dedent_interpd + def __init__(self, xy, radius=5, *, + resolution=20, # the number of vertices + ** kwargs): + """ + Create a circle at *xy* = (*x*, *y*) with given *radius*. + + This circle is approximated by a regular polygon with *resolution* + sides. For a smoother circle drawn with splines, see `Circle`. + + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__( + xy, resolution, radius=radius, orientation=0, **kwargs) + + +class Ellipse(Patch): + """A scale-free ellipse.""" + + def __str__(self): + pars = (self._center[0], self._center[1], + self.width, self.height, self.angle) + fmt = "Ellipse(xy=(%s, %s), width=%s, height=%s, angle=%s)" + return fmt % pars + + @_docstring.dedent_interpd + def __init__(self, xy, width, height, *, angle=0, **kwargs): + """ + Parameters + ---------- + xy : (float, float) + xy coordinates of ellipse centre. + width : float + Total length (diameter) of horizontal axis. + height : float + Total length (diameter) of vertical axis. + angle : float, default: 0 + Rotation in degrees anti-clockwise. + + Notes + ----- + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + + self._center = xy + self._width, self._height = width, height + self._angle = angle + self._path = Path.unit_circle() + # Required for EllipseSelector with axes aspect ratio != 1 + # The patch is defined in data coordinates and when changing the + # selector with square modifier and not in data coordinates, we need + # to correct for the aspect ratio difference between the data and + # display coordinate systems. + self._aspect_ratio_correction = 1.0 + # Note: This cannot be calculated until this is added to an Axes + self._patch_transform = transforms.IdentityTransform() + + def _recompute_transform(self): + """ + Notes + ----- + This cannot be called until after this has been added to an Axes, + otherwise unit conversion will fail. This makes it very important to + call the accessor method and not directly access the transformation + member variable. + """ + center = (self.convert_xunits(self._center[0]), + self.convert_yunits(self._center[1])) + width = self.convert_xunits(self._width) + height = self.convert_yunits(self._height) + self._patch_transform = transforms.Affine2D() \ + .scale(width * 0.5, height * 0.5 * self._aspect_ratio_correction) \ + .rotate_deg(self.angle) \ + .scale(1, 1 / self._aspect_ratio_correction) \ + .translate(*center) + + def get_path(self): + """Return the path of the ellipse.""" + return self._path + + def get_patch_transform(self): + self._recompute_transform() + return self._patch_transform + + def set_center(self, xy): + """ + Set the center of the ellipse. + + Parameters + ---------- + xy : (float, float) + """ + self._center = xy + self.stale = True + + def get_center(self): + """Return the center of the ellipse.""" + return self._center + + center = property(get_center, set_center) + + def set_width(self, width): + """ + Set the width of the ellipse. + + Parameters + ---------- + width : float + """ + self._width = width + self.stale = True + + def get_width(self): + """ + Return the width of the ellipse. + """ + return self._width + + width = property(get_width, set_width) + + def set_height(self, height): + """ + Set the height of the ellipse. + + Parameters + ---------- + height : float + """ + self._height = height + self.stale = True + + def get_height(self): + """Return the height of the ellipse.""" + return self._height + + height = property(get_height, set_height) + + def set_angle(self, angle): + """ + Set the angle of the ellipse. + + Parameters + ---------- + angle : float + """ + self._angle = angle + self.stale = True + + def get_angle(self): + """Return the angle of the ellipse.""" + return self._angle + + angle = property(get_angle, set_angle) + + def get_corners(self): + """ + Return the corners of the ellipse bounding box. + + The bounding box orientation is moving anti-clockwise from the + lower left corner defined before rotation. + """ + return self.get_patch_transform().transform( + [(-1, -1), (1, -1), (1, 1), (-1, 1)]) + + def get_vertices(self): + """ + Return the vertices coordinates of the ellipse. + + The definition can be found `here `_ + + .. versionadded:: 3.8 + """ + if self.width < self.height: + ret = self.get_patch_transform().transform([(0, 1), (0, -1)]) + else: + ret = self.get_patch_transform().transform([(1, 0), (-1, 0)]) + return [tuple(x) for x in ret] + + def get_co_vertices(self): + """ + Return the co-vertices coordinates of the ellipse. + + The definition can be found `here `_ + + .. versionadded:: 3.8 + """ + if self.width < self.height: + ret = self.get_patch_transform().transform([(1, 0), (-1, 0)]) + else: + ret = self.get_patch_transform().transform([(0, 1), (0, -1)]) + return [tuple(x) for x in ret] + + +class Annulus(Patch): + """ + An elliptical annulus. + """ + + @_docstring.dedent_interpd + def __init__(self, xy, r, width, angle=0.0, **kwargs): + """ + Parameters + ---------- + xy : (float, float) + xy coordinates of annulus centre. + r : float or (float, float) + The radius, or semi-axes: + + - If float: radius of the outer circle. + - If two floats: semi-major and -minor axes of outer ellipse. + width : float + Width (thickness) of the annular ring. The width is measured inward + from the outer ellipse so that for the inner ellipse the semi-axes + are given by ``r - width``. *width* must be less than or equal to + the semi-minor axis. + angle : float, default: 0 + Rotation angle in degrees (anti-clockwise from the positive + x-axis). Ignored for circular annuli (i.e., if *r* is a scalar). + **kwargs + Keyword arguments control the `Patch` properties: + + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + + self.set_radii(r) + self.center = xy + self.width = width + self.angle = angle + self._path = None + + def __str__(self): + if self.a == self.b: + r = self.a + else: + r = (self.a, self.b) + + return "Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s)" % \ + (*self.center, r, self.width, self.angle) + + def set_center(self, xy): + """ + Set the center of the annulus. + + Parameters + ---------- + xy : (float, float) + """ + self._center = xy + self._path = None + self.stale = True + + def get_center(self): + """Return the center of the annulus.""" + return self._center + + center = property(get_center, set_center) + + def set_width(self, width): + """ + Set the width (thickness) of the annulus ring. + + The width is measured inwards from the outer ellipse. + + Parameters + ---------- + width : float + """ + if width > min(self.a, self.b): + raise ValueError( + 'Width of annulus must be less than or equal to semi-minor axis') + + self._width = width + self._path = None + self.stale = True + + def get_width(self): + """Return the width (thickness) of the annulus ring.""" + return self._width + + width = property(get_width, set_width) + + def set_angle(self, angle): + """ + Set the tilt angle of the annulus. + + Parameters + ---------- + angle : float + """ + self._angle = angle + self._path = None + self.stale = True + + def get_angle(self): + """Return the angle of the annulus.""" + return self._angle + + angle = property(get_angle, set_angle) + + def set_semimajor(self, a): + """ + Set the semi-major axis *a* of the annulus. + + Parameters + ---------- + a : float + """ + self.a = float(a) + self._path = None + self.stale = True + + def set_semiminor(self, b): + """ + Set the semi-minor axis *b* of the annulus. + + Parameters + ---------- + b : float + """ + self.b = float(b) + self._path = None + self.stale = True + + def set_radii(self, r): + """ + Set the semi-major (*a*) and semi-minor radii (*b*) of the annulus. + + Parameters + ---------- + r : float or (float, float) + The radius, or semi-axes: + + - If float: radius of the outer circle. + - If two floats: semi-major and -minor axes of outer ellipse. + """ + if np.shape(r) == (2,): + self.a, self.b = r + elif np.shape(r) == (): + self.a = self.b = float(r) + else: + raise ValueError("Parameter 'r' must be one or two floats.") + + self._path = None + self.stale = True + + def get_radii(self): + """Return the semi-major and semi-minor radii of the annulus.""" + return self.a, self.b + + radii = property(get_radii, set_radii) + + def _transform_verts(self, verts, a, b): + return transforms.Affine2D() \ + .scale(*self._convert_xy_units((a, b))) \ + .rotate_deg(self.angle) \ + .translate(*self._convert_xy_units(self.center)) \ + .transform(verts) + + def _recompute_path(self): + # circular arc + arc = Path.arc(0, 360) + + # annulus needs to draw an outer ring + # followed by a reversed and scaled inner ring + a, b, w = self.a, self.b, self.width + v1 = self._transform_verts(arc.vertices, a, b) + v2 = self._transform_verts(arc.vertices[::-1], a - w, b - w) + v = np.vstack([v1, v2, v1[0, :], (0, 0)]) + c = np.hstack([arc.codes, Path.MOVETO, + arc.codes[1:], Path.MOVETO, + Path.CLOSEPOLY]) + self._path = Path(v, c) + + def get_path(self): + if self._path is None: + self._recompute_path() + return self._path + + +class Circle(Ellipse): + """ + A circle patch. + """ + def __str__(self): + pars = self.center[0], self.center[1], self.radius + fmt = "Circle(xy=(%g, %g), radius=%g)" + return fmt % pars + + @_docstring.dedent_interpd + def __init__(self, xy, radius=5, **kwargs): + """ + Create a true circle at center *xy* = (*x*, *y*) with given *radius*. + + Unlike `CirclePolygon` which is a polygonal approximation, this uses + Bezier splines and is much closer to a scale-free circle. + + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__(xy, radius * 2, radius * 2, **kwargs) + self.radius = radius + + def set_radius(self, radius): + """ + Set the radius of the circle. + + Parameters + ---------- + radius : float + """ + self.width = self.height = 2 * radius + self.stale = True + + def get_radius(self): + """Return the radius of the circle.""" + return self.width / 2. + + radius = property(get_radius, set_radius) + + +class Arc(Ellipse): + """ + An elliptical arc, i.e. a segment of an ellipse. + + Due to internal optimizations, the arc cannot be filled. + """ + + def __str__(self): + pars = (self.center[0], self.center[1], self.width, + self.height, self.angle, self.theta1, self.theta2) + fmt = ("Arc(xy=(%g, %g), width=%g, " + "height=%g, angle=%g, theta1=%g, theta2=%g)") + return fmt % pars + + @_docstring.dedent_interpd + def __init__(self, xy, width, height, *, + angle=0.0, theta1=0.0, theta2=360.0, **kwargs): + """ + Parameters + ---------- + xy : (float, float) + The center of the ellipse. + + width : float + The length of the horizontal axis. + + height : float + The length of the vertical axis. + + angle : float + Rotation of the ellipse in degrees (counterclockwise). + + theta1, theta2 : float, default: 0, 360 + Starting and ending angles of the arc in degrees. These values + are relative to *angle*, e.g. if *angle* = 45 and *theta1* = 90 + the absolute starting angle is 135. + Default *theta1* = 0, *theta2* = 360, i.e. a complete ellipse. + The arc is drawn in the counterclockwise direction. + Angles greater than or equal to 360, or smaller than 0, are + represented by an equivalent angle in the range [0, 360), by + taking the input value mod 360. + + Other Parameters + ---------------- + **kwargs : `~matplotlib.patches.Patch` properties + Most `.Patch` properties are supported as keyword arguments, + except *fill* and *facecolor* because filling is not supported. + + %(Patch:kwdoc)s + """ + fill = kwargs.setdefault('fill', False) + if fill: + raise ValueError("Arc objects cannot be filled") + + super().__init__(xy, width, height, angle=angle, **kwargs) + + self.theta1 = theta1 + self.theta2 = theta2 + (self._theta1, self._theta2, self._stretched_width, + self._stretched_height) = self._theta_stretch() + self._path = Path.arc(self._theta1, self._theta2) + + @artist.allow_rasterization + def draw(self, renderer): + """ + Draw the arc to the given *renderer*. + + Notes + ----- + Ellipses are normally drawn using an approximation that uses + eight cubic Bezier splines. The error of this approximation + is 1.89818e-6, according to this unverified source: + + Lancaster, Don. *Approximating a Circle or an Ellipse Using + Four Bezier Cubic Splines.* + + https://www.tinaja.com/glib/ellipse4.pdf + + There is a use case where very large ellipses must be drawn + with very high accuracy, and it is too expensive to render the + entire ellipse with enough segments (either splines or line + segments). Therefore, in the case where either radius of the + ellipse is large enough that the error of the spline + approximation will be visible (greater than one pixel offset + from the ideal), a different technique is used. + + In that case, only the visible parts of the ellipse are drawn, + with each visible arc using a fixed number of spline segments + (8). The algorithm proceeds as follows: + + 1. The points where the ellipse intersects the axes (or figure) + bounding box are located. (This is done by performing an inverse + transformation on the bbox such that it is relative to the unit + circle -- this makes the intersection calculation much easier than + doing rotated ellipse intersection directly.) + + This uses the "line intersecting a circle" algorithm from: + + Vince, John. *Geometry for Computer Graphics: Formulae, + Examples & Proofs.* London: Springer-Verlag, 2005. + + 2. The angles of each of the intersection points are calculated. + + 3. Proceeding counterclockwise starting in the positive + x-direction, each of the visible arc-segments between the + pairs of vertices are drawn using the Bezier arc + approximation technique implemented in `.Path.arc`. + """ + if not self.get_visible(): + return + + self._recompute_transform() + + self._update_path() + # Get width and height in pixels we need to use + # `self.get_data_transform` rather than `self.get_transform` + # because we want the transform from dataspace to the + # screen space to estimate how big the arc will be in physical + # units when rendered (the transform that we get via + # `self.get_transform()` goes from an idealized unit-radius + # space to screen space). + data_to_screen_trans = self.get_data_transform() + pwidth, pheight = ( + data_to_screen_trans.transform((self._stretched_width, + self._stretched_height)) - + data_to_screen_trans.transform((0, 0))) + inv_error = (1.0 / 1.89818e-6) * 0.5 + + if pwidth < inv_error and pheight < inv_error: + return Patch.draw(self, renderer) + + def line_circle_intersect(x0, y0, x1, y1): + dx = x1 - x0 + dy = y1 - y0 + dr2 = dx * dx + dy * dy + D = x0 * y1 - x1 * y0 + D2 = D * D + discrim = dr2 - D2 + if discrim >= 0.0: + sign_dy = np.copysign(1, dy) # +/-1, never 0. + sqrt_discrim = np.sqrt(discrim) + return np.array( + [[(D * dy + sign_dy * dx * sqrt_discrim) / dr2, + (-D * dx + abs(dy) * sqrt_discrim) / dr2], + [(D * dy - sign_dy * dx * sqrt_discrim) / dr2, + (-D * dx - abs(dy) * sqrt_discrim) / dr2]]) + else: + return np.empty((0, 2)) + + def segment_circle_intersect(x0, y0, x1, y1): + epsilon = 1e-9 + if x1 < x0: + x0e, x1e = x1, x0 + else: + x0e, x1e = x0, x1 + if y1 < y0: + y0e, y1e = y1, y0 + else: + y0e, y1e = y0, y1 + xys = line_circle_intersect(x0, y0, x1, y1) + xs, ys = xys.T + return xys[ + (x0e - epsilon < xs) & (xs < x1e + epsilon) + & (y0e - epsilon < ys) & (ys < y1e + epsilon) + ] + + # Transform the Axes (or figure) box_path so that it is relative to + # the unit circle in the same way that it is relative to the desired + # ellipse. + box_path_transform = ( + transforms.BboxTransformTo((self.axes or self.figure).bbox) + - self.get_transform()) + box_path = Path.unit_rectangle().transformed(box_path_transform) + + thetas = set() + # For each of the point pairs, there is a line segment + for p0, p1 in zip(box_path.vertices[:-1], box_path.vertices[1:]): + xy = segment_circle_intersect(*p0, *p1) + x, y = xy.T + # arctan2 return [-pi, pi), the rest of our angles are in + # [0, 360], adjust as needed. + theta = (np.rad2deg(np.arctan2(y, x)) + 360) % 360 + thetas.update( + theta[(self._theta1 < theta) & (theta < self._theta2)]) + thetas = sorted(thetas) + [self._theta2] + last_theta = self._theta1 + theta1_rad = np.deg2rad(self._theta1) + inside = box_path.contains_point( + (np.cos(theta1_rad), np.sin(theta1_rad)) + ) + + # save original path + path_original = self._path + for theta in thetas: + if inside: + self._path = Path.arc(last_theta, theta, 8) + Patch.draw(self, renderer) + inside = False + else: + inside = True + last_theta = theta + + # restore original path + self._path = path_original + + def _update_path(self): + # Compute new values and update and set new _path if any value changed + stretched = self._theta_stretch() + if any(a != b for a, b in zip( + stretched, (self._theta1, self._theta2, self._stretched_width, + self._stretched_height))): + (self._theta1, self._theta2, self._stretched_width, + self._stretched_height) = stretched + self._path = Path.arc(self._theta1, self._theta2) + + def _theta_stretch(self): + # If the width and height of ellipse are not equal, take into account + # stretching when calculating angles to draw between + def theta_stretch(theta, scale): + theta = np.deg2rad(theta) + x = np.cos(theta) + y = np.sin(theta) + stheta = np.rad2deg(np.arctan2(scale * y, x)) + # arctan2 has the range [-pi, pi], we expect [0, 2*pi] + return (stheta + 360) % 360 + + width = self.convert_xunits(self.width) + height = self.convert_yunits(self.height) + if ( + # if we need to stretch the angles because we are distorted + width != height + # and we are not doing a full circle. + # + # 0 and 360 do not exactly round-trip through the angle + # stretching (due to both float precision limitations and + # the difference between the range of arctan2 [-pi, pi] and + # this method [0, 360]) so avoid doing it if we don't have to. + and not (self.theta1 != self.theta2 and + self.theta1 % 360 == self.theta2 % 360) + ): + theta1 = theta_stretch(self.theta1, width / height) + theta2 = theta_stretch(self.theta2, width / height) + return theta1, theta2, width, height + return self.theta1, self.theta2, width, height + + +def bbox_artist(artist, renderer, props=None, fill=True): + """ + A debug function to draw a rectangle around the bounding + box returned by an artist's `.Artist.get_window_extent` + to test whether the artist is returning the correct bbox. + + *props* is a dict of rectangle props with the additional property + 'pad' that sets the padding around the bbox in points. + """ + if props is None: + props = {} + props = props.copy() # don't want to alter the pad externally + pad = props.pop('pad', 4) + pad = renderer.points_to_pixels(pad) + bbox = artist.get_window_extent(renderer) + r = Rectangle( + xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2), + width=bbox.width + pad, height=bbox.height + pad, + fill=fill, transform=transforms.IdentityTransform(), clip_on=False) + r.update(props) + r.draw(renderer) + + +def draw_bbox(bbox, renderer, color='k', trans=None): + """ + A debug function to draw a rectangle around the bounding + box returned by an artist's `.Artist.get_window_extent` + to test whether the artist is returning the correct bbox. + """ + r = Rectangle(xy=bbox.p0, width=bbox.width, height=bbox.height, + edgecolor=color, fill=False, clip_on=False) + if trans is not None: + r.set_transform(trans) + r.draw(renderer) + + +class _Style: + """ + A base class for the Styles. It is meant to be a container class, + where actual styles are declared as subclass of it, and it + provides some helper functions. + """ + + def __init_subclass__(cls): + # Automatically perform docstring interpolation on the subclasses: + # This allows listing the supported styles via + # - %(BoxStyle:table)s + # - %(ConnectionStyle:table)s + # - %(ArrowStyle:table)s + # and additionally adding .. ACCEPTS: blocks via + # - %(BoxStyle:table_and_accepts)s + # - %(ConnectionStyle:table_and_accepts)s + # - %(ArrowStyle:table_and_accepts)s + _docstring.interpd.update({ + f"{cls.__name__}:table": cls.pprint_styles(), + f"{cls.__name__}:table_and_accepts": ( + cls.pprint_styles() + + "\n\n .. ACCEPTS: [" + + "|".join(map(" '{}' ".format, cls._style_list)) + + "]") + }) + + def __new__(cls, stylename, **kwargs): + """Return the instance of the subclass with the given style name.""" + # The "class" should have the _style_list attribute, which is a mapping + # of style names to style classes. + _list = stylename.replace(" ", "").split(",") + _name = _list[0].lower() + try: + _cls = cls._style_list[_name] + except KeyError as err: + raise ValueError(f"Unknown style: {stylename!r}") from err + try: + _args_pair = [cs.split("=") for cs in _list[1:]] + _args = {k: float(v) for k, v in _args_pair} + except ValueError as err: + raise ValueError( + f"Incorrect style argument: {stylename!r}") from err + return _cls(**{**_args, **kwargs}) + + @classmethod + def get_styles(cls): + """Return a dictionary of available styles.""" + return cls._style_list + + @classmethod + def pprint_styles(cls): + """Return the available styles as pretty-printed string.""" + table = [('Class', 'Name', 'Attrs'), + *[(cls.__name__, + # Add backquotes, as - and | have special meaning in reST. + f'``{name}``', + # [1:-1] drops the surrounding parentheses. + str(inspect.signature(cls))[1:-1] or 'None') + for name, cls in cls._style_list.items()]] + # Convert to rst table. + col_len = [max(len(cell) for cell in column) for column in zip(*table)] + table_formatstr = ' '.join('=' * cl for cl in col_len) + rst_table = '\n'.join([ + '', + table_formatstr, + ' '.join(cell.ljust(cl) for cell, cl in zip(table[0], col_len)), + table_formatstr, + *[' '.join(cell.ljust(cl) for cell, cl in zip(row, col_len)) + for row in table[1:]], + table_formatstr, + ]) + return textwrap.indent(rst_table, prefix=' ' * 4) + + @classmethod + def register(cls, name, style): + """Register a new style.""" + if not issubclass(style, cls._Base): + raise ValueError(f"{style} must be a subclass of {cls._Base}") + cls._style_list[name] = style + + +def _register_style(style_list, cls=None, *, name=None): + """Class decorator that stashes a class in a (style) dictionary.""" + if cls is None: + return functools.partial(_register_style, style_list, name=name) + style_list[name or cls.__name__.lower()] = cls + return cls + + +@_docstring.dedent_interpd +class BoxStyle(_Style): + """ + `BoxStyle` is a container class which defines several + boxstyle classes, which are used for `FancyBboxPatch`. + + A style object can be created as:: + + BoxStyle.Round(pad=0.2) + + or:: + + BoxStyle("Round", pad=0.2) + + or:: + + BoxStyle("Round, pad=0.2") + + The following boxstyle classes are defined. + + %(BoxStyle:table)s + + An instance of a boxstyle class is a callable object, with the signature :: + + __call__(self, x0, y0, width, height, mutation_size) -> Path + + *x0*, *y0*, *width* and *height* specify the location and size of the box + to be drawn; *mutation_size* scales the outline properties such as padding. + """ + + _style_list = {} + + @_register_style(_style_list) + class Square: + """A square box.""" + + def __init__(self, pad=0.3): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + """ + self.pad = pad + + def __call__(self, x0, y0, width, height, mutation_size): + pad = mutation_size * self.pad + # width and height with padding added. + width, height = width + 2 * pad, height + 2 * pad + # boundary of the padded box + x0, y0 = x0 - pad, y0 - pad + x1, y1 = x0 + width, y0 + height + return Path._create_closed( + [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]) + + @_register_style(_style_list) + class Circle: + """A circular box.""" + + def __init__(self, pad=0.3): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + """ + self.pad = pad + + def __call__(self, x0, y0, width, height, mutation_size): + pad = mutation_size * self.pad + width, height = width + 2 * pad, height + 2 * pad + # boundary of the padded box + x0, y0 = x0 - pad, y0 - pad + return Path.circle((x0 + width / 2, y0 + height / 2), + max(width, height) / 2) + + @_register_style(_style_list) + class Ellipse: + """ + An elliptical box. + + .. versionadded:: 3.7 + """ + + def __init__(self, pad=0.3): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + """ + self.pad = pad + + def __call__(self, x0, y0, width, height, mutation_size): + pad = mutation_size * self.pad + width, height = width + 2 * pad, height + 2 * pad + # boundary of the padded box + x0, y0 = x0 - pad, y0 - pad + a = width / math.sqrt(2) + b = height / math.sqrt(2) + trans = Affine2D().scale(a, b).translate(x0 + width / 2, + y0 + height / 2) + return trans.transform_path(Path.unit_circle()) + + @_register_style(_style_list) + class LArrow: + """A box in the shape of a left-pointing arrow.""" + + def __init__(self, pad=0.3): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + """ + self.pad = pad + + def __call__(self, x0, y0, width, height, mutation_size): + # padding + pad = mutation_size * self.pad + # width and height with padding added. + width, height = width + 2 * pad, height + 2 * pad + # boundary of the padded box + x0, y0 = x0 - pad, y0 - pad, + x1, y1 = x0 + width, y0 + height + + dx = (y1 - y0) / 2 + dxx = dx / 2 + x0 = x0 + pad / 1.4 # adjust by ~sqrt(2) + + return Path._create_closed( + [(x0 + dxx, y0), (x1, y0), (x1, y1), (x0 + dxx, y1), + (x0 + dxx, y1 + dxx), (x0 - dx, y0 + dx), + (x0 + dxx, y0 - dxx), # arrow + (x0 + dxx, y0)]) + + @_register_style(_style_list) + class RArrow(LArrow): + """A box in the shape of a right-pointing arrow.""" + + def __call__(self, x0, y0, width, height, mutation_size): + p = BoxStyle.LArrow.__call__( + self, x0, y0, width, height, mutation_size) + p.vertices[:, 0] = 2 * x0 + width - p.vertices[:, 0] + return p + + @_register_style(_style_list) + class DArrow: + """A box in the shape of a two-way arrow.""" + # Modified from LArrow to add a right arrow to the bbox. + + def __init__(self, pad=0.3): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + """ + self.pad = pad + + def __call__(self, x0, y0, width, height, mutation_size): + # padding + pad = mutation_size * self.pad + # width and height with padding added. + # The width is padded by the arrows, so we don't need to pad it. + height = height + 2 * pad + # boundary of the padded box + x0, y0 = x0 - pad, y0 - pad + x1, y1 = x0 + width, y0 + height + + dx = (y1 - y0) / 2 + dxx = dx / 2 + x0 = x0 + pad / 1.4 # adjust by ~sqrt(2) + + return Path._create_closed([ + (x0 + dxx, y0), (x1, y0), # bot-segment + (x1, y0 - dxx), (x1 + dx + dxx, y0 + dx), + (x1, y1 + dxx), # right-arrow + (x1, y1), (x0 + dxx, y1), # top-segment + (x0 + dxx, y1 + dxx), (x0 - dx, y0 + dx), + (x0 + dxx, y0 - dxx), # left-arrow + (x0 + dxx, y0)]) + + @_register_style(_style_list) + class Round: + """A box with round corners.""" + + def __init__(self, pad=0.3, rounding_size=None): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + rounding_size : float, default: *pad* + Radius of the corners. + """ + self.pad = pad + self.rounding_size = rounding_size + + def __call__(self, x0, y0, width, height, mutation_size): + + # padding + pad = mutation_size * self.pad + + # size of the rounding corner + if self.rounding_size: + dr = mutation_size * self.rounding_size + else: + dr = pad + + width, height = width + 2 * pad, height + 2 * pad + + x0, y0 = x0 - pad, y0 - pad, + x1, y1 = x0 + width, y0 + height + + # Round corners are implemented as quadratic Bezier, e.g., + # [(x0, y0-dr), (x0, y0), (x0+dr, y0)] for lower left corner. + cp = [(x0 + dr, y0), + (x1 - dr, y0), + (x1, y0), (x1, y0 + dr), + (x1, y1 - dr), + (x1, y1), (x1 - dr, y1), + (x0 + dr, y1), + (x0, y1), (x0, y1 - dr), + (x0, y0 + dr), + (x0, y0), (x0 + dr, y0), + (x0 + dr, y0)] + + com = [Path.MOVETO, + Path.LINETO, + Path.CURVE3, Path.CURVE3, + Path.LINETO, + Path.CURVE3, Path.CURVE3, + Path.LINETO, + Path.CURVE3, Path.CURVE3, + Path.LINETO, + Path.CURVE3, Path.CURVE3, + Path.CLOSEPOLY] + + return Path(cp, com) + + @_register_style(_style_list) + class Round4: + """A box with rounded edges.""" + + def __init__(self, pad=0.3, rounding_size=None): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + rounding_size : float, default: *pad*/2 + Rounding of edges. + """ + self.pad = pad + self.rounding_size = rounding_size + + def __call__(self, x0, y0, width, height, mutation_size): + + # padding + pad = mutation_size * self.pad + + # Rounding size; defaults to half of the padding. + if self.rounding_size: + dr = mutation_size * self.rounding_size + else: + dr = pad / 2. + + width = width + 2 * pad - 2 * dr + height = height + 2 * pad - 2 * dr + + x0, y0 = x0 - pad + dr, y0 - pad + dr, + x1, y1 = x0 + width, y0 + height + + cp = [(x0, y0), + (x0 + dr, y0 - dr), (x1 - dr, y0 - dr), (x1, y0), + (x1 + dr, y0 + dr), (x1 + dr, y1 - dr), (x1, y1), + (x1 - dr, y1 + dr), (x0 + dr, y1 + dr), (x0, y1), + (x0 - dr, y1 - dr), (x0 - dr, y0 + dr), (x0, y0), + (x0, y0)] + + com = [Path.MOVETO, + Path.CURVE4, Path.CURVE4, Path.CURVE4, + Path.CURVE4, Path.CURVE4, Path.CURVE4, + Path.CURVE4, Path.CURVE4, Path.CURVE4, + Path.CURVE4, Path.CURVE4, Path.CURVE4, + Path.CLOSEPOLY] + + return Path(cp, com) + + @_register_style(_style_list) + class Sawtooth: + """A box with a sawtooth outline.""" + + def __init__(self, pad=0.3, tooth_size=None): + """ + Parameters + ---------- + pad : float, default: 0.3 + The amount of padding around the original box. + tooth_size : float, default: *pad*/2 + Size of the sawtooth. + """ + self.pad = pad + self.tooth_size = tooth_size + + def _get_sawtooth_vertices(self, x0, y0, width, height, mutation_size): + + # padding + pad = mutation_size * self.pad + + # size of sawtooth + if self.tooth_size is None: + tooth_size = self.pad * .5 * mutation_size + else: + tooth_size = self.tooth_size * mutation_size + + hsz = tooth_size / 2 + width = width + 2 * pad - tooth_size + height = height + 2 * pad - tooth_size + + # the sizes of the vertical and horizontal sawtooth are + # separately adjusted to fit the given box size. + dsx_n = round((width - tooth_size) / (tooth_size * 2)) * 2 + dsy_n = round((height - tooth_size) / (tooth_size * 2)) * 2 + + x0, y0 = x0 - pad + hsz, y0 - pad + hsz + x1, y1 = x0 + width, y0 + height + + xs = [ + x0, *np.linspace(x0 + hsz, x1 - hsz, 2 * dsx_n + 1), # bottom + *([x1, x1 + hsz, x1, x1 - hsz] * dsy_n)[:2*dsy_n+2], # right + x1, *np.linspace(x1 - hsz, x0 + hsz, 2 * dsx_n + 1), # top + *([x0, x0 - hsz, x0, x0 + hsz] * dsy_n)[:2*dsy_n+2], # left + ] + ys = [ + *([y0, y0 - hsz, y0, y0 + hsz] * dsx_n)[:2*dsx_n+2], # bottom + y0, *np.linspace(y0 + hsz, y1 - hsz, 2 * dsy_n + 1), # right + *([y1, y1 + hsz, y1, y1 - hsz] * dsx_n)[:2*dsx_n+2], # top + y1, *np.linspace(y1 - hsz, y0 + hsz, 2 * dsy_n + 1), # left + ] + + return [*zip(xs, ys), (xs[0], ys[0])] + + def __call__(self, x0, y0, width, height, mutation_size): + saw_vertices = self._get_sawtooth_vertices(x0, y0, width, + height, mutation_size) + return Path(saw_vertices, closed=True) + + @_register_style(_style_list) + class Roundtooth(Sawtooth): + """A box with a rounded sawtooth outline.""" + + def __call__(self, x0, y0, width, height, mutation_size): + saw_vertices = self._get_sawtooth_vertices(x0, y0, + width, height, + mutation_size) + # Add a trailing vertex to allow us to close the polygon correctly + saw_vertices = np.concatenate([saw_vertices, [saw_vertices[0]]]) + codes = ([Path.MOVETO] + + [Path.CURVE3, Path.CURVE3] * ((len(saw_vertices)-1)//2) + + [Path.CLOSEPOLY]) + return Path(saw_vertices, codes) + + +@_docstring.dedent_interpd +class ConnectionStyle(_Style): + """ + `ConnectionStyle` is a container class which defines + several connectionstyle classes, which is used to create a path + between two points. These are mainly used with `FancyArrowPatch`. + + A connectionstyle object can be either created as:: + + ConnectionStyle.Arc3(rad=0.2) + + or:: + + ConnectionStyle("Arc3", rad=0.2) + + or:: + + ConnectionStyle("Arc3, rad=0.2") + + The following classes are defined + + %(ConnectionStyle:table)s + + An instance of any connection style class is a callable object, + whose call signature is:: + + __call__(self, posA, posB, + patchA=None, patchB=None, + shrinkA=2., shrinkB=2.) + + and it returns a `.Path` instance. *posA* and *posB* are + tuples of (x, y) coordinates of the two points to be + connected. *patchA* (or *patchB*) is given, the returned path is + clipped so that it start (or end) from the boundary of the + patch. The path is further shrunk by *shrinkA* (or *shrinkB*) + which is given in points. + """ + + _style_list = {} + + class _Base: + """ + A base class for connectionstyle classes. The subclass needs + to implement a *connect* method whose call signature is:: + + connect(posA, posB) + + where posA and posB are tuples of x, y coordinates to be + connected. The method needs to return a path connecting two + points. This base class defines a __call__ method, and a few + helper methods. + """ + def _in_patch(self, patch): + """ + Return a predicate function testing whether a point *xy* is + contained in *patch*. + """ + return lambda xy: patch.contains( + SimpleNamespace(x=xy[0], y=xy[1]))[0] + + def _clip(self, path, in_start, in_stop): + """ + Clip *path* at its start by the region where *in_start* returns + True, and at its stop by the region where *in_stop* returns True. + + The original path is assumed to start in the *in_start* region and + to stop in the *in_stop* region. + """ + if in_start: + try: + _, path = split_path_inout(path, in_start) + except ValueError: + pass + if in_stop: + try: + path, _ = split_path_inout(path, in_stop) + except ValueError: + pass + return path + + def __call__(self, posA, posB, + shrinkA=2., shrinkB=2., patchA=None, patchB=None): + """ + Call the *connect* method to create a path between *posA* and + *posB*; then clip and shrink the path. + """ + path = self.connect(posA, posB) + path = self._clip( + path, + self._in_patch(patchA) if patchA else None, + self._in_patch(patchB) if patchB else None, + ) + path = self._clip( + path, + inside_circle(*path.vertices[0], shrinkA) if shrinkA else None, + inside_circle(*path.vertices[-1], shrinkB) if shrinkB else None + ) + return path + + @_register_style(_style_list) + class Arc3(_Base): + """ + Creates a simple quadratic Bézier curve between two + points. The curve is created so that the middle control point + (C1) is located at the same distance from the start (C0) and + end points(C2) and the distance of the C1 to the line + connecting C0-C2 is *rad* times the distance of C0-C2. + """ + + def __init__(self, rad=0.): + """ + Parameters + ---------- + rad : float + Curvature of the curve. + """ + self.rad = rad + + def connect(self, posA, posB): + x1, y1 = posA + x2, y2 = posB + x12, y12 = (x1 + x2) / 2., (y1 + y2) / 2. + dx, dy = x2 - x1, y2 - y1 + + f = self.rad + + cx, cy = x12 + f * dy, y12 - f * dx + + vertices = [(x1, y1), + (cx, cy), + (x2, y2)] + codes = [Path.MOVETO, + Path.CURVE3, + Path.CURVE3] + + return Path(vertices, codes) + + @_register_style(_style_list) + class Angle3(_Base): + """ + Creates a simple quadratic Bézier curve between two points. The middle + control point is placed at the intersecting point of two lines which + cross the start and end point, and have a slope of *angleA* and + *angleB*, respectively. + """ + + def __init__(self, angleA=90, angleB=0): + """ + Parameters + ---------- + angleA : float + Starting angle of the path. + + angleB : float + Ending angle of the path. + """ + + self.angleA = angleA + self.angleB = angleB + + def connect(self, posA, posB): + x1, y1 = posA + x2, y2 = posB + + cosA = math.cos(math.radians(self.angleA)) + sinA = math.sin(math.radians(self.angleA)) + cosB = math.cos(math.radians(self.angleB)) + sinB = math.sin(math.radians(self.angleB)) + + cx, cy = get_intersection(x1, y1, cosA, sinA, + x2, y2, cosB, sinB) + + vertices = [(x1, y1), (cx, cy), (x2, y2)] + codes = [Path.MOVETO, Path.CURVE3, Path.CURVE3] + + return Path(vertices, codes) + + @_register_style(_style_list) + class Angle(_Base): + """ + Creates a piecewise continuous quadratic Bézier path between two + points. The path has a one passing-through point placed at the + intersecting point of two lines which cross the start and end point, + and have a slope of *angleA* and *angleB*, respectively. + The connecting edges are rounded with *rad*. + """ + + def __init__(self, angleA=90, angleB=0, rad=0.): + """ + Parameters + ---------- + angleA : float + Starting angle of the path. + + angleB : float + Ending angle of the path. + + rad : float + Rounding radius of the edge. + """ + + self.angleA = angleA + self.angleB = angleB + + self.rad = rad + + def connect(self, posA, posB): + x1, y1 = posA + x2, y2 = posB + + cosA = math.cos(math.radians(self.angleA)) + sinA = math.sin(math.radians(self.angleA)) + cosB = math.cos(math.radians(self.angleB)) + sinB = math.sin(math.radians(self.angleB)) + + cx, cy = get_intersection(x1, y1, cosA, sinA, + x2, y2, cosB, sinB) + + vertices = [(x1, y1)] + codes = [Path.MOVETO] + + if self.rad == 0.: + vertices.append((cx, cy)) + codes.append(Path.LINETO) + else: + dx1, dy1 = x1 - cx, y1 - cy + d1 = np.hypot(dx1, dy1) + f1 = self.rad / d1 + dx2, dy2 = x2 - cx, y2 - cy + d2 = np.hypot(dx2, dy2) + f2 = self.rad / d2 + vertices.extend([(cx + dx1 * f1, cy + dy1 * f1), + (cx, cy), + (cx + dx2 * f2, cy + dy2 * f2)]) + codes.extend([Path.LINETO, Path.CURVE3, Path.CURVE3]) + + vertices.append((x2, y2)) + codes.append(Path.LINETO) + + return Path(vertices, codes) + + @_register_style(_style_list) + class Arc(_Base): + """ + Creates a piecewise continuous quadratic Bézier path between two + points. The path can have two passing-through points, a + point placed at the distance of *armA* and angle of *angleA* from + point A, another point with respect to point B. The edges are + rounded with *rad*. + """ + + def __init__(self, angleA=0, angleB=0, armA=None, armB=None, rad=0.): + """ + Parameters + ---------- + angleA : float + Starting angle of the path. + + angleB : float + Ending angle of the path. + + armA : float or None + Length of the starting arm. + + armB : float or None + Length of the ending arm. + + rad : float + Rounding radius of the edges. + """ + + self.angleA = angleA + self.angleB = angleB + self.armA = armA + self.armB = armB + + self.rad = rad + + def connect(self, posA, posB): + x1, y1 = posA + x2, y2 = posB + + vertices = [(x1, y1)] + rounded = [] + codes = [Path.MOVETO] + + if self.armA: + cosA = math.cos(math.radians(self.angleA)) + sinA = math.sin(math.radians(self.angleA)) + # x_armA, y_armB + d = self.armA - self.rad + rounded.append((x1 + d * cosA, y1 + d * sinA)) + d = self.armA + rounded.append((x1 + d * cosA, y1 + d * sinA)) + + if self.armB: + cosB = math.cos(math.radians(self.angleB)) + sinB = math.sin(math.radians(self.angleB)) + x_armB, y_armB = x2 + self.armB * cosB, y2 + self.armB * sinB + + if rounded: + xp, yp = rounded[-1] + dx, dy = x_armB - xp, y_armB - yp + dd = (dx * dx + dy * dy) ** .5 + + rounded.append((xp + self.rad * dx / dd, + yp + self.rad * dy / dd)) + vertices.extend(rounded) + codes.extend([Path.LINETO, + Path.CURVE3, + Path.CURVE3]) + else: + xp, yp = vertices[-1] + dx, dy = x_armB - xp, y_armB - yp + dd = (dx * dx + dy * dy) ** .5 + + d = dd - self.rad + rounded = [(xp + d * dx / dd, yp + d * dy / dd), + (x_armB, y_armB)] + + if rounded: + xp, yp = rounded[-1] + dx, dy = x2 - xp, y2 - yp + dd = (dx * dx + dy * dy) ** .5 + + rounded.append((xp + self.rad * dx / dd, + yp + self.rad * dy / dd)) + vertices.extend(rounded) + codes.extend([Path.LINETO, + Path.CURVE3, + Path.CURVE3]) + + vertices.append((x2, y2)) + codes.append(Path.LINETO) + + return Path(vertices, codes) + + @_register_style(_style_list) + class Bar(_Base): + """ + A line with *angle* between A and B with *armA* and *armB*. One of the + arms is extended so that they are connected in a right angle. The + length of *armA* is determined by (*armA* + *fraction* x AB distance). + Same for *armB*. + """ + + def __init__(self, armA=0., armB=0., fraction=0.3, angle=None): + """ + Parameters + ---------- + armA : float + Minimum length of armA. + + armB : float + Minimum length of armB. + + fraction : float + A fraction of the distance between two points that will be + added to armA and armB. + + angle : float or None + Angle of the connecting line (if None, parallel to A and B). + """ + self.armA = armA + self.armB = armB + self.fraction = fraction + self.angle = angle + + def connect(self, posA, posB): + x1, y1 = posA + x20, y20 = x2, y2 = posB + + theta1 = math.atan2(y2 - y1, x2 - x1) + dx, dy = x2 - x1, y2 - y1 + dd = (dx * dx + dy * dy) ** .5 + ddx, ddy = dx / dd, dy / dd + + armA, armB = self.armA, self.armB + + if self.angle is not None: + theta0 = np.deg2rad(self.angle) + dtheta = theta1 - theta0 + dl = dd * math.sin(dtheta) + dL = dd * math.cos(dtheta) + x2, y2 = x1 + dL * math.cos(theta0), y1 + dL * math.sin(theta0) + armB = armB - dl + + # update + dx, dy = x2 - x1, y2 - y1 + dd2 = (dx * dx + dy * dy) ** .5 + ddx, ddy = dx / dd2, dy / dd2 + + arm = max(armA, armB) + f = self.fraction * dd + arm + + cx1, cy1 = x1 + f * ddy, y1 - f * ddx + cx2, cy2 = x2 + f * ddy, y2 - f * ddx + + vertices = [(x1, y1), + (cx1, cy1), + (cx2, cy2), + (x20, y20)] + codes = [Path.MOVETO, + Path.LINETO, + Path.LINETO, + Path.LINETO] + + return Path(vertices, codes) + + +def _point_along_a_line(x0, y0, x1, y1, d): + """ + Return the point on the line connecting (*x0*, *y0*) -- (*x1*, *y1*) whose + distance from (*x0*, *y0*) is *d*. + """ + dx, dy = x0 - x1, y0 - y1 + ff = d / (dx * dx + dy * dy) ** .5 + x2, y2 = x0 - ff * dx, y0 - ff * dy + + return x2, y2 + + +@_docstring.dedent_interpd +class ArrowStyle(_Style): + """ + `ArrowStyle` is a container class which defines several + arrowstyle classes, which is used to create an arrow path along a + given path. These are mainly used with `FancyArrowPatch`. + + An arrowstyle object can be either created as:: + + ArrowStyle.Fancy(head_length=.4, head_width=.4, tail_width=.4) + + or:: + + ArrowStyle("Fancy", head_length=.4, head_width=.4, tail_width=.4) + + or:: + + ArrowStyle("Fancy, head_length=.4, head_width=.4, tail_width=.4") + + The following classes are defined + + %(ArrowStyle:table)s + + For an overview of the visual appearance, see + :doc:`/gallery/text_labels_and_annotations/fancyarrow_demo`. + + An instance of any arrow style class is a callable object, + whose call signature is:: + + __call__(self, path, mutation_size, linewidth, aspect_ratio=1.) + + and it returns a tuple of a `.Path` instance and a boolean + value. *path* is a `.Path` instance along which the arrow + will be drawn. *mutation_size* and *aspect_ratio* have the same + meaning as in `BoxStyle`. *linewidth* is a line width to be + stroked. This is meant to be used to correct the location of the + head so that it does not overshoot the destination point, but not all + classes support it. + + Notes + ----- + *angleA* and *angleB* specify the orientation of the bracket, as either a + clockwise or counterclockwise angle depending on the arrow type. 0 degrees + means perpendicular to the line connecting the arrow's head and tail. + + .. plot:: gallery/text_labels_and_annotations/angles_on_bracket_arrows.py + """ + + _style_list = {} + + class _Base: + """ + Arrow Transmuter Base class + + ArrowTransmuterBase and its derivatives are used to make a fancy + arrow around a given path. The __call__ method returns a path + (which will be used to create a PathPatch instance) and a boolean + value indicating the path is open therefore is not fillable. This + class is not an artist and actual drawing of the fancy arrow is + done by the FancyArrowPatch class. + """ + + # The derived classes are required to be able to be initialized + # w/o arguments, i.e., all its argument (except self) must have + # the default values. + + @staticmethod + def ensure_quadratic_bezier(path): + """ + Some ArrowStyle classes only works with a simple quadratic + Bézier curve (created with `.ConnectionStyle.Arc3` or + `.ConnectionStyle.Angle3`). This static method checks if the + provided path is a simple quadratic Bézier curve and returns its + control points if true. + """ + segments = list(path.iter_segments()) + if (len(segments) != 2 or segments[0][1] != Path.MOVETO or + segments[1][1] != Path.CURVE3): + raise ValueError( + "'path' is not a valid quadratic Bezier curve") + return [*segments[0][0], *segments[1][0]] + + def transmute(self, path, mutation_size, linewidth): + """ + The transmute method is the very core of the ArrowStyle class and + must be overridden in the subclasses. It receives the *path* + object along which the arrow will be drawn, and the + *mutation_size*, with which the arrow head etc. will be scaled. + The *linewidth* may be used to adjust the path so that it does not + pass beyond the given points. It returns a tuple of a `.Path` + instance and a boolean. The boolean value indicate whether the + path can be filled or not. The return value can also be a list of + paths and list of booleans of the same length. + """ + raise NotImplementedError('Derived must override') + + def __call__(self, path, mutation_size, linewidth, + aspect_ratio=1.): + """ + The __call__ method is a thin wrapper around the transmute method + and takes care of the aspect ratio. + """ + + if aspect_ratio is not None: + # Squeeze the given height by the aspect_ratio + vertices = path.vertices / [1, aspect_ratio] + path_shrunk = Path(vertices, path.codes) + # call transmute method with squeezed height. + path_mutated, fillable = self.transmute(path_shrunk, + mutation_size, + linewidth) + if np.iterable(fillable): + # Restore the height + path_list = [Path(p.vertices * [1, aspect_ratio], p.codes) + for p in path_mutated] + return path_list, fillable + else: + return path_mutated, fillable + else: + return self.transmute(path, mutation_size, linewidth) + + class _Curve(_Base): + """ + A simple arrow which will work with any path instance. The + returned path is the concatenation of the original path, and at + most two paths representing the arrow head or bracket at the start + point and at the end point. The arrow heads can be either open + or closed. + """ + + arrow = "-" + fillbegin = fillend = False # Whether arrows are filled. + + def __init__(self, head_length=.4, head_width=.2, widthA=1., widthB=1., + lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, + scaleB=None): + """ + Parameters + ---------- + head_length : float, default: 0.4 + Length of the arrow head, relative to *mutation_size*. + head_width : float, default: 0.2 + Width of the arrow head, relative to *mutation_size*. + widthA, widthB : float, default: 1.0 + Width of the bracket. + lengthA, lengthB : float, default: 0.2 + Length of the bracket. + angleA, angleB : float, default: 0 + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + scaleA, scaleB : float, default: *mutation_size* + The scale of the brackets. + """ + + self.head_length, self.head_width = head_length, head_width + self.widthA, self.widthB = widthA, widthB + self.lengthA, self.lengthB = lengthA, lengthB + self.angleA, self.angleB = angleA, angleB + self.scaleA, self.scaleB = scaleA, scaleB + + self._beginarrow_head = False + self._beginarrow_bracket = False + self._endarrow_head = False + self._endarrow_bracket = False + + if "-" not in self.arrow: + raise ValueError("arrow must have the '-' between " + "the two heads") + + beginarrow, endarrow = self.arrow.split("-", 1) + + if beginarrow == "<": + self._beginarrow_head = True + self._beginarrow_bracket = False + elif beginarrow == "<|": + self._beginarrow_head = True + self._beginarrow_bracket = False + self.fillbegin = True + elif beginarrow in ("]", "|"): + self._beginarrow_head = False + self._beginarrow_bracket = True + + if endarrow == ">": + self._endarrow_head = True + self._endarrow_bracket = False + elif endarrow == "|>": + self._endarrow_head = True + self._endarrow_bracket = False + self.fillend = True + elif endarrow in ("[", "|"): + self._endarrow_head = False + self._endarrow_bracket = True + + super().__init__() + + def _get_arrow_wedge(self, x0, y0, x1, y1, + head_dist, cos_t, sin_t, linewidth): + """ + Return the paths for arrow heads. Since arrow lines are + drawn with capstyle=projected, The arrow goes beyond the + desired point. This method also returns the amount of the path + to be shrunken so that it does not overshoot. + """ + + # arrow from x0, y0 to x1, y1 + dx, dy = x0 - x1, y0 - y1 + + cp_distance = np.hypot(dx, dy) + + # pad_projected : amount of pad to account the + # overshooting of the projection of the wedge + pad_projected = (.5 * linewidth / sin_t) + + # Account for division by zero + if cp_distance == 0: + cp_distance = 1 + + # apply pad for projected edge + ddx = pad_projected * dx / cp_distance + ddy = pad_projected * dy / cp_distance + + # offset for arrow wedge + dx = dx / cp_distance * head_dist + dy = dy / cp_distance * head_dist + + dx1, dy1 = cos_t * dx + sin_t * dy, -sin_t * dx + cos_t * dy + dx2, dy2 = cos_t * dx - sin_t * dy, sin_t * dx + cos_t * dy + + vertices_arrow = [(x1 + ddx + dx1, y1 + ddy + dy1), + (x1 + ddx, y1 + ddy), + (x1 + ddx + dx2, y1 + ddy + dy2)] + codes_arrow = [Path.MOVETO, + Path.LINETO, + Path.LINETO] + + return vertices_arrow, codes_arrow, ddx, ddy + + def _get_bracket(self, x0, y0, + x1, y1, width, length, angle): + + cos_t, sin_t = get_cos_sin(x1, y1, x0, y0) + + # arrow from x0, y0 to x1, y1 + from matplotlib.bezier import get_normal_points + x1, y1, x2, y2 = get_normal_points(x0, y0, cos_t, sin_t, width) + + dx, dy = length * cos_t, length * sin_t + + vertices_arrow = [(x1 + dx, y1 + dy), + (x1, y1), + (x2, y2), + (x2 + dx, y2 + dy)] + codes_arrow = [Path.MOVETO, + Path.LINETO, + Path.LINETO, + Path.LINETO] + + if angle: + trans = transforms.Affine2D().rotate_deg_around(x0, y0, angle) + vertices_arrow = trans.transform(vertices_arrow) + + return vertices_arrow, codes_arrow + + def transmute(self, path, mutation_size, linewidth): + # docstring inherited + if self._beginarrow_head or self._endarrow_head: + head_length = self.head_length * mutation_size + head_width = self.head_width * mutation_size + head_dist = np.hypot(head_length, head_width) + cos_t, sin_t = head_length / head_dist, head_width / head_dist + + scaleA = mutation_size if self.scaleA is None else self.scaleA + scaleB = mutation_size if self.scaleB is None else self.scaleB + + # begin arrow + x0, y0 = path.vertices[0] + x1, y1 = path.vertices[1] + + # If there is no room for an arrow and a line, then skip the arrow + has_begin_arrow = self._beginarrow_head and (x0, y0) != (x1, y1) + verticesA, codesA, ddxA, ddyA = ( + self._get_arrow_wedge(x1, y1, x0, y0, + head_dist, cos_t, sin_t, linewidth) + if has_begin_arrow + else ([], [], 0, 0) + ) + + # end arrow + x2, y2 = path.vertices[-2] + x3, y3 = path.vertices[-1] + + # If there is no room for an arrow and a line, then skip the arrow + has_end_arrow = self._endarrow_head and (x2, y2) != (x3, y3) + verticesB, codesB, ddxB, ddyB = ( + self._get_arrow_wedge(x2, y2, x3, y3, + head_dist, cos_t, sin_t, linewidth) + if has_end_arrow + else ([], [], 0, 0) + ) + + # This simple code will not work if ddx, ddy is greater than the + # separation between vertices. + paths = [Path(np.concatenate([[(x0 + ddxA, y0 + ddyA)], + path.vertices[1:-1], + [(x3 + ddxB, y3 + ddyB)]]), + path.codes)] + fills = [False] + + if has_begin_arrow: + if self.fillbegin: + paths.append( + Path([*verticesA, (0, 0)], [*codesA, Path.CLOSEPOLY])) + fills.append(True) + else: + paths.append(Path(verticesA, codesA)) + fills.append(False) + elif self._beginarrow_bracket: + x0, y0 = path.vertices[0] + x1, y1 = path.vertices[1] + verticesA, codesA = self._get_bracket(x0, y0, x1, y1, + self.widthA * scaleA, + self.lengthA * scaleA, + self.angleA) + + paths.append(Path(verticesA, codesA)) + fills.append(False) + + if has_end_arrow: + if self.fillend: + fills.append(True) + paths.append( + Path([*verticesB, (0, 0)], [*codesB, Path.CLOSEPOLY])) + else: + fills.append(False) + paths.append(Path(verticesB, codesB)) + elif self._endarrow_bracket: + x0, y0 = path.vertices[-1] + x1, y1 = path.vertices[-2] + verticesB, codesB = self._get_bracket(x0, y0, x1, y1, + self.widthB * scaleB, + self.lengthB * scaleB, + self.angleB) + + paths.append(Path(verticesB, codesB)) + fills.append(False) + + return paths, fills + + @_register_style(_style_list, name="-") + class Curve(_Curve): + """A simple curve without any arrow head.""" + + def __init__(self): # hide head_length, head_width + # These attributes (whose values come from backcompat) only matter + # if someone modifies beginarrow/etc. on an ArrowStyle instance. + super().__init__(head_length=.2, head_width=.1) + + @_register_style(_style_list, name="<-") + class CurveA(_Curve): + """An arrow with a head at its start point.""" + arrow = "<-" + + @_register_style(_style_list, name="->") + class CurveB(_Curve): + """An arrow with a head at its end point.""" + arrow = "->" + + @_register_style(_style_list, name="<->") + class CurveAB(_Curve): + """An arrow with heads both at the start and the end point.""" + arrow = "<->" + + @_register_style(_style_list, name="<|-") + class CurveFilledA(_Curve): + """An arrow with filled triangle head at the start.""" + arrow = "<|-" + + @_register_style(_style_list, name="-|>") + class CurveFilledB(_Curve): + """An arrow with filled triangle head at the end.""" + arrow = "-|>" + + @_register_style(_style_list, name="<|-|>") + class CurveFilledAB(_Curve): + """An arrow with filled triangle heads at both ends.""" + arrow = "<|-|>" + + @_register_style(_style_list, name="]-") + class BracketA(_Curve): + """An arrow with an outward square bracket at its start.""" + arrow = "]-" + + def __init__(self, widthA=1., lengthA=0.2, angleA=0): + """ + Parameters + ---------- + widthA : float, default: 1.0 + Width of the bracket. + lengthA : float, default: 0.2 + Length of the bracket. + angleA : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthA=widthA, lengthA=lengthA, angleA=angleA) + + @_register_style(_style_list, name="-[") + class BracketB(_Curve): + """An arrow with an outward square bracket at its end.""" + arrow = "-[" + + def __init__(self, widthB=1., lengthB=0.2, angleB=0): + """ + Parameters + ---------- + widthB : float, default: 1.0 + Width of the bracket. + lengthB : float, default: 0.2 + Length of the bracket. + angleB : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthB=widthB, lengthB=lengthB, angleB=angleB) + + @_register_style(_style_list, name="]-[") + class BracketAB(_Curve): + """An arrow with outward square brackets at both ends.""" + arrow = "]-[" + + def __init__(self, + widthA=1., lengthA=0.2, angleA=0, + widthB=1., lengthB=0.2, angleB=0): + """ + Parameters + ---------- + widthA, widthB : float, default: 1.0 + Width of the bracket. + lengthA, lengthB : float, default: 0.2 + Length of the bracket. + angleA, angleB : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthA=widthA, lengthA=lengthA, angleA=angleA, + widthB=widthB, lengthB=lengthB, angleB=angleB) + + @_register_style(_style_list, name="|-|") + class BarAB(_Curve): + """An arrow with vertical bars ``|`` at both ends.""" + arrow = "|-|" + + def __init__(self, widthA=1., angleA=0, widthB=1., angleB=0): + """ + Parameters + ---------- + widthA, widthB : float, default: 1.0 + Width of the bracket. + angleA, angleB : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthA=widthA, lengthA=0, angleA=angleA, + widthB=widthB, lengthB=0, angleB=angleB) + + @_register_style(_style_list, name=']->') + class BracketCurve(_Curve): + """ + An arrow with an outward square bracket at its start and a head at + the end. + """ + arrow = "]->" + + def __init__(self, widthA=1., lengthA=0.2, angleA=None): + """ + Parameters + ---------- + widthA : float, default: 1.0 + Width of the bracket. + lengthA : float, default: 0.2 + Length of the bracket. + angleA : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthA=widthA, lengthA=lengthA, angleA=angleA) + + @_register_style(_style_list, name='<-[') + class CurveBracket(_Curve): + """ + An arrow with an outward square bracket at its end and a head at + the start. + """ + arrow = "<-[" + + def __init__(self, widthB=1., lengthB=0.2, angleB=None): + """ + Parameters + ---------- + widthB : float, default: 1.0 + Width of the bracket. + lengthB : float, default: 0.2 + Length of the bracket. + angleB : float, default: 0 degrees + Orientation of the bracket, as a counterclockwise angle. + 0 degrees means perpendicular to the line. + """ + super().__init__(widthB=widthB, lengthB=lengthB, angleB=angleB) + + @_register_style(_style_list) + class Simple(_Base): + """A simple arrow. Only works with a quadratic Bézier curve.""" + + def __init__(self, head_length=.5, head_width=.5, tail_width=.2): + """ + Parameters + ---------- + head_length : float, default: 0.5 + Length of the arrow head. + + head_width : float, default: 0.5 + Width of the arrow head. + + tail_width : float, default: 0.2 + Width of the arrow tail. + """ + self.head_length, self.head_width, self.tail_width = \ + head_length, head_width, tail_width + super().__init__() + + def transmute(self, path, mutation_size, linewidth): + # docstring inherited + x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path) + + # divide the path into a head and a tail + head_length = self.head_length * mutation_size + in_f = inside_circle(x2, y2, head_length) + arrow_path = [(x0, y0), (x1, y1), (x2, y2)] + + try: + arrow_out, arrow_in = \ + split_bezier_intersecting_with_closedpath(arrow_path, in_f) + except NonIntersectingPathException: + # if this happens, make a straight line of the head_length + # long. + x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length) + x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2) + arrow_in = [(x0, y0), (x1n, y1n), (x2, y2)] + arrow_out = None + + # head + head_width = self.head_width * mutation_size + head_left, head_right = make_wedged_bezier2(arrow_in, + head_width / 2., wm=.5) + + # tail + if arrow_out is not None: + tail_width = self.tail_width * mutation_size + tail_left, tail_right = get_parallels(arrow_out, + tail_width / 2.) + + patch_path = [(Path.MOVETO, tail_right[0]), + (Path.CURVE3, tail_right[1]), + (Path.CURVE3, tail_right[2]), + (Path.LINETO, head_right[0]), + (Path.CURVE3, head_right[1]), + (Path.CURVE3, head_right[2]), + (Path.CURVE3, head_left[1]), + (Path.CURVE3, head_left[0]), + (Path.LINETO, tail_left[2]), + (Path.CURVE3, tail_left[1]), + (Path.CURVE3, tail_left[0]), + (Path.LINETO, tail_right[0]), + (Path.CLOSEPOLY, tail_right[0]), + ] + else: + patch_path = [(Path.MOVETO, head_right[0]), + (Path.CURVE3, head_right[1]), + (Path.CURVE3, head_right[2]), + (Path.CURVE3, head_left[1]), + (Path.CURVE3, head_left[0]), + (Path.CLOSEPOLY, head_left[0]), + ] + + path = Path([p for c, p in patch_path], [c for c, p in patch_path]) + + return path, True + + @_register_style(_style_list) + class Fancy(_Base): + """A fancy arrow. Only works with a quadratic Bézier curve.""" + + def __init__(self, head_length=.4, head_width=.4, tail_width=.4): + """ + Parameters + ---------- + head_length : float, default: 0.4 + Length of the arrow head. + + head_width : float, default: 0.4 + Width of the arrow head. + + tail_width : float, default: 0.4 + Width of the arrow tail. + """ + self.head_length, self.head_width, self.tail_width = \ + head_length, head_width, tail_width + super().__init__() + + def transmute(self, path, mutation_size, linewidth): + # docstring inherited + x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path) + + # divide the path into a head and a tail + head_length = self.head_length * mutation_size + arrow_path = [(x0, y0), (x1, y1), (x2, y2)] + + # path for head + in_f = inside_circle(x2, y2, head_length) + try: + path_out, path_in = split_bezier_intersecting_with_closedpath( + arrow_path, in_f) + except NonIntersectingPathException: + # if this happens, make a straight line of the head_length + # long. + x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length) + x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2) + arrow_path = [(x0, y0), (x1n, y1n), (x2, y2)] + path_head = arrow_path + else: + path_head = path_in + + # path for head + in_f = inside_circle(x2, y2, head_length * .8) + path_out, path_in = split_bezier_intersecting_with_closedpath( + arrow_path, in_f) + path_tail = path_out + + # head + head_width = self.head_width * mutation_size + head_l, head_r = make_wedged_bezier2(path_head, + head_width / 2., + wm=.6) + + # tail + tail_width = self.tail_width * mutation_size + tail_left, tail_right = make_wedged_bezier2(path_tail, + tail_width * .5, + w1=1., wm=0.6, w2=0.3) + + # path for head + in_f = inside_circle(x0, y0, tail_width * .3) + path_in, path_out = split_bezier_intersecting_with_closedpath( + arrow_path, in_f) + tail_start = path_in[-1] + + head_right, head_left = head_r, head_l + patch_path = [(Path.MOVETO, tail_start), + (Path.LINETO, tail_right[0]), + (Path.CURVE3, tail_right[1]), + (Path.CURVE3, tail_right[2]), + (Path.LINETO, head_right[0]), + (Path.CURVE3, head_right[1]), + (Path.CURVE3, head_right[2]), + (Path.CURVE3, head_left[1]), + (Path.CURVE3, head_left[0]), + (Path.LINETO, tail_left[2]), + (Path.CURVE3, tail_left[1]), + (Path.CURVE3, tail_left[0]), + (Path.LINETO, tail_start), + (Path.CLOSEPOLY, tail_start), + ] + path = Path([p for c, p in patch_path], [c for c, p in patch_path]) + + return path, True + + @_register_style(_style_list) + class Wedge(_Base): + """ + Wedge(?) shape. Only works with a quadratic Bézier curve. The + start point has a width of the *tail_width* and the end point has a + width of 0. At the middle, the width is *shrink_factor*x*tail_width*. + """ + + def __init__(self, tail_width=.3, shrink_factor=0.5): + """ + Parameters + ---------- + tail_width : float, default: 0.3 + Width of the tail. + + shrink_factor : float, default: 0.5 + Fraction of the arrow width at the middle point. + """ + self.tail_width = tail_width + self.shrink_factor = shrink_factor + super().__init__() + + def transmute(self, path, mutation_size, linewidth): + # docstring inherited + x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path) + + arrow_path = [(x0, y0), (x1, y1), (x2, y2)] + b_plus, b_minus = make_wedged_bezier2( + arrow_path, + self.tail_width * mutation_size / 2., + wm=self.shrink_factor) + + patch_path = [(Path.MOVETO, b_plus[0]), + (Path.CURVE3, b_plus[1]), + (Path.CURVE3, b_plus[2]), + (Path.LINETO, b_minus[2]), + (Path.CURVE3, b_minus[1]), + (Path.CURVE3, b_minus[0]), + (Path.CLOSEPOLY, b_minus[0]), + ] + path = Path([p for c, p in patch_path], [c for c, p in patch_path]) + + return path, True + + +class FancyBboxPatch(Patch): + """ + A fancy box around a rectangle with lower left at *xy* = (*x*, *y*) + with specified width and height. + + `.FancyBboxPatch` is similar to `.Rectangle`, but it draws a fancy box + around the rectangle. The transformation of the rectangle box to the + fancy box is delegated to the style classes defined in `.BoxStyle`. + """ + + _edge_default = True + + def __str__(self): + s = self.__class__.__name__ + "((%g, %g), width=%g, height=%g)" + return s % (self._x, self._y, self._width, self._height) + + @_docstring.dedent_interpd + def __init__(self, xy, width, height, boxstyle="round", *, + mutation_scale=1, mutation_aspect=1, **kwargs): + """ + Parameters + ---------- + xy : (float, float) + The lower left corner of the box. + + width : float + The width of the box. + + height : float + The height of the box. + + boxstyle : str or `~matplotlib.patches.BoxStyle` + The style of the fancy box. This can either be a `.BoxStyle` + instance or a string of the style name and optionally comma + separated attributes (e.g. "Round, pad=0.2"). This string is + passed to `.BoxStyle` to construct a `.BoxStyle` object. See + there for a full documentation. + + The following box styles are available: + + %(BoxStyle:table)s + + mutation_scale : float, default: 1 + Scaling factor applied to the attributes of the box style + (e.g. pad or rounding_size). + + mutation_aspect : float, default: 1 + The height of the rectangle will be squeezed by this value before + the mutation and the mutated box will be stretched by the inverse + of it. For example, this allows different horizontal and vertical + padding. + + Other Parameters + ---------------- + **kwargs : `~matplotlib.patches.Patch` properties + + %(Patch:kwdoc)s + """ + + super().__init__(**kwargs) + self._x, self._y = xy + self._width = width + self._height = height + self.set_boxstyle(boxstyle) + self._mutation_scale = mutation_scale + self._mutation_aspect = mutation_aspect + self.stale = True + + @_docstring.dedent_interpd + def set_boxstyle(self, boxstyle=None, **kwargs): + """ + Set the box style, possibly with further attributes. + + Attributes from the previous box style are not reused. + + Without argument (or with ``boxstyle=None``), the available box styles + are returned as a human-readable string. + + Parameters + ---------- + boxstyle : str or `~matplotlib.patches.BoxStyle` + The style of the box: either a `.BoxStyle` instance, or a string, + which is the style name and optionally comma separated attributes + (e.g. "Round,pad=0.2"). Such a string is used to construct a + `.BoxStyle` object, as documented in that class. + + The following box styles are available: + + %(BoxStyle:table_and_accepts)s + + **kwargs + Additional attributes for the box style. See the table above for + supported parameters. + + Examples + -------- + :: + + set_boxstyle("Round,pad=0.2") + set_boxstyle("round", pad=0.2) + """ + if boxstyle is None: + return BoxStyle.pprint_styles() + self._bbox_transmuter = ( + BoxStyle(boxstyle, **kwargs) + if isinstance(boxstyle, str) else boxstyle) + self.stale = True + + def get_boxstyle(self): + """Return the boxstyle object.""" + return self._bbox_transmuter + + def set_mutation_scale(self, scale): + """ + Set the mutation scale. + + Parameters + ---------- + scale : float + """ + self._mutation_scale = scale + self.stale = True + + def get_mutation_scale(self): + """Return the mutation scale.""" + return self._mutation_scale + + def set_mutation_aspect(self, aspect): + """ + Set the aspect ratio of the bbox mutation. + + Parameters + ---------- + aspect : float + """ + self._mutation_aspect = aspect + self.stale = True + + def get_mutation_aspect(self): + """Return the aspect ratio of the bbox mutation.""" + return (self._mutation_aspect if self._mutation_aspect is not None + else 1) # backcompat. + + def get_path(self): + """Return the mutated path of the rectangle.""" + boxstyle = self.get_boxstyle() + m_aspect = self.get_mutation_aspect() + # Call boxstyle with y, height squeezed by aspect_ratio. + path = boxstyle(self._x, self._y / m_aspect, + self._width, self._height / m_aspect, + self.get_mutation_scale()) + return Path(path.vertices * [1, m_aspect], path.codes) # Unsqueeze y. + + # Following methods are borrowed from the Rectangle class. + + def get_x(self): + """Return the left coord of the rectangle.""" + return self._x + + def get_y(self): + """Return the bottom coord of the rectangle.""" + return self._y + + def get_width(self): + """Return the width of the rectangle.""" + return self._width + + def get_height(self): + """Return the height of the rectangle.""" + return self._height + + def set_x(self, x): + """ + Set the left coord of the rectangle. + + Parameters + ---------- + x : float + """ + self._x = x + self.stale = True + + def set_y(self, y): + """ + Set the bottom coord of the rectangle. + + Parameters + ---------- + y : float + """ + self._y = y + self.stale = True + + def set_width(self, w): + """ + Set the rectangle width. + + Parameters + ---------- + w : float + """ + self._width = w + self.stale = True + + def set_height(self, h): + """ + Set the rectangle height. + + Parameters + ---------- + h : float + """ + self._height = h + self.stale = True + + def set_bounds(self, *args): + """ + Set the bounds of the rectangle. + + Call signatures:: + + set_bounds(left, bottom, width, height) + set_bounds((left, bottom, width, height)) + + Parameters + ---------- + left, bottom : float + The coordinates of the bottom left corner of the rectangle. + width, height : float + The width/height of the rectangle. + """ + if len(args) == 1: + l, b, w, h = args[0] + else: + l, b, w, h = args + self._x = l + self._y = b + self._width = w + self._height = h + self.stale = True + + def get_bbox(self): + """Return the `.Bbox`.""" + return transforms.Bbox.from_bounds(self._x, self._y, + self._width, self._height) + + +class FancyArrowPatch(Patch): + """ + A fancy arrow patch. + + It draws an arrow using the `ArrowStyle`. It is primarily used by the + `~.axes.Axes.annotate` method. For most purposes, use the annotate method for + drawing arrows. + + The head and tail positions are fixed at the specified start and end points + of the arrow, but the size and shape (in display coordinates) of the arrow + does not change when the axis is moved or zoomed. + """ + _edge_default = True + + def __str__(self): + if self._posA_posB is not None: + (x1, y1), (x2, y2) = self._posA_posB + return f"{type(self).__name__}(({x1:g}, {y1:g})->({x2:g}, {y2:g}))" + else: + return f"{type(self).__name__}({self._path_original})" + + @_docstring.dedent_interpd + def __init__(self, posA=None, posB=None, *, + path=None, arrowstyle="simple", connectionstyle="arc3", + patchA=None, patchB=None, shrinkA=2, shrinkB=2, + mutation_scale=1, mutation_aspect=1, **kwargs): + """ + There are two ways for defining an arrow: + + - If *posA* and *posB* are given, a path connecting two points is + created according to *connectionstyle*. The path will be + clipped with *patchA* and *patchB* and further shrunken by + *shrinkA* and *shrinkB*. An arrow is drawn along this + resulting path using the *arrowstyle* parameter. + + - Alternatively if *path* is provided, an arrow is drawn along this + path and *patchA*, *patchB*, *shrinkA*, and *shrinkB* are ignored. + + Parameters + ---------- + posA, posB : (float, float), default: None + (x, y) coordinates of arrow tail and arrow head respectively. + + path : `~matplotlib.path.Path`, default: None + If provided, an arrow is drawn along this path and *patchA*, + *patchB*, *shrinkA*, and *shrinkB* are ignored. + + arrowstyle : str or `.ArrowStyle`, default: 'simple' + The `.ArrowStyle` with which the fancy arrow is drawn. If a + string, it should be one of the available arrowstyle names, with + optional comma-separated attributes. The optional attributes are + meant to be scaled with the *mutation_scale*. The following arrow + styles are available: + + %(ArrowStyle:table)s + + connectionstyle : str or `.ConnectionStyle` or None, optional, \ +default: 'arc3' + The `.ConnectionStyle` with which *posA* and *posB* are connected. + If a string, it should be one of the available connectionstyle + names, with optional comma-separated attributes. The following + connection styles are available: + + %(ConnectionStyle:table)s + + patchA, patchB : `~matplotlib.patches.Patch`, default: None + Head and tail patches, respectively. + + shrinkA, shrinkB : float, default: 2 + Shrink amount, in points, of the tail and head of the arrow respectively. + + mutation_scale : float, default: 1 + Value with which attributes of *arrowstyle* (e.g., *head_length*) + will be scaled. + + mutation_aspect : None or float, default: None + The height of the rectangle will be squeezed by this value before + the mutation and the mutated box will be stretched by the inverse + of it. + + Other Parameters + ---------------- + **kwargs : `~matplotlib.patches.Patch` properties, optional + Here is a list of available `.Patch` properties: + + %(Patch:kwdoc)s + + In contrast to other patches, the default ``capstyle`` and + ``joinstyle`` for `FancyArrowPatch` are set to ``"round"``. + """ + # Traditionally, the cap- and joinstyle for FancyArrowPatch are round + kwargs.setdefault("joinstyle", JoinStyle.round) + kwargs.setdefault("capstyle", CapStyle.round) + + super().__init__(**kwargs) + + if posA is not None and posB is not None and path is None: + self._posA_posB = [posA, posB] + + if connectionstyle is None: + connectionstyle = "arc3" + self.set_connectionstyle(connectionstyle) + + elif posA is None and posB is None and path is not None: + self._posA_posB = None + else: + raise ValueError("Either posA and posB, or path need to provided") + + self.patchA = patchA + self.patchB = patchB + self.shrinkA = shrinkA + self.shrinkB = shrinkB + + self._path_original = path + + self.set_arrowstyle(arrowstyle) + + self._mutation_scale = mutation_scale + self._mutation_aspect = mutation_aspect + + self._dpi_cor = 1.0 + + def set_positions(self, posA, posB): + """ + Set the start and end positions of the connecting path. + + Parameters + ---------- + posA, posB : None, tuple + (x, y) coordinates of arrow tail and arrow head respectively. If + `None` use current value. + """ + if posA is not None: + self._posA_posB[0] = posA + if posB is not None: + self._posA_posB[1] = posB + self.stale = True + + def set_patchA(self, patchA): + """ + Set the tail patch. + + Parameters + ---------- + patchA : `.patches.Patch` + """ + self.patchA = patchA + self.stale = True + + def set_patchB(self, patchB): + """ + Set the head patch. + + Parameters + ---------- + patchB : `.patches.Patch` + """ + self.patchB = patchB + self.stale = True + + @_docstring.dedent_interpd + def set_connectionstyle(self, connectionstyle=None, **kwargs): + """ + Set the connection style, possibly with further attributes. + + Attributes from the previous connection style are not reused. + + Without argument (or with ``connectionstyle=None``), the available box + styles are returned as a human-readable string. + + Parameters + ---------- + connectionstyle : str or `~matplotlib.patches.ConnectionStyle` + The style of the connection: either a `.ConnectionStyle` instance, + or a string, which is the style name and optionally comma separated + attributes (e.g. "Arc,armA=30,rad=10"). Such a string is used to + construct a `.ConnectionStyle` object, as documented in that class. + + The following connection styles are available: + + %(ConnectionStyle:table_and_accepts)s + + **kwargs + Additional attributes for the connection style. See the table above + for supported parameters. + + Examples + -------- + :: + + set_connectionstyle("Arc,armA=30,rad=10") + set_connectionstyle("arc", armA=30, rad=10) + """ + if connectionstyle is None: + return ConnectionStyle.pprint_styles() + self._connector = ( + ConnectionStyle(connectionstyle, **kwargs) + if isinstance(connectionstyle, str) else connectionstyle) + self.stale = True + + def get_connectionstyle(self): + """Return the `ConnectionStyle` used.""" + return self._connector + + def set_arrowstyle(self, arrowstyle=None, **kwargs): + """ + Set the arrow style, possibly with further attributes. + + Attributes from the previous arrow style are not reused. + + Without argument (or with ``arrowstyle=None``), the available box + styles are returned as a human-readable string. + + Parameters + ---------- + arrowstyle : str or `~matplotlib.patches.ArrowStyle` + The style of the arrow: either a `.ArrowStyle` instance, or a + string, which is the style name and optionally comma separated + attributes (e.g. "Fancy,head_length=0.2"). Such a string is used to + construct a `.ArrowStyle` object, as documented in that class. + + The following arrow styles are available: + + %(ArrowStyle:table_and_accepts)s + + **kwargs + Additional attributes for the arrow style. See the table above for + supported parameters. + + Examples + -------- + :: + + set_arrowstyle("Fancy,head_length=0.2") + set_arrowstyle("fancy", head_length=0.2) + """ + if arrowstyle is None: + return ArrowStyle.pprint_styles() + self._arrow_transmuter = ( + ArrowStyle(arrowstyle, **kwargs) + if isinstance(arrowstyle, str) else arrowstyle) + self.stale = True + + def get_arrowstyle(self): + """Return the arrowstyle object.""" + return self._arrow_transmuter + + def set_mutation_scale(self, scale): + """ + Set the mutation scale. + + Parameters + ---------- + scale : float + """ + self._mutation_scale = scale + self.stale = True + + def get_mutation_scale(self): + """ + Return the mutation scale. + + Returns + ------- + scalar + """ + return self._mutation_scale + + def set_mutation_aspect(self, aspect): + """ + Set the aspect ratio of the bbox mutation. + + Parameters + ---------- + aspect : float + """ + self._mutation_aspect = aspect + self.stale = True + + def get_mutation_aspect(self): + """Return the aspect ratio of the bbox mutation.""" + return (self._mutation_aspect if self._mutation_aspect is not None + else 1) # backcompat. + + def get_path(self): + """Return the path of the arrow in the data coordinates.""" + # The path is generated in display coordinates, then converted back to + # data coordinates. + _path, fillable = self._get_path_in_displaycoord() + if np.iterable(fillable): + _path = Path.make_compound_path(*_path) + return self.get_transform().inverted().transform_path(_path) + + def _get_path_in_displaycoord(self): + """Return the mutated path of the arrow in display coordinates.""" + dpi_cor = self._dpi_cor + + if self._posA_posB is not None: + posA = self._convert_xy_units(self._posA_posB[0]) + posB = self._convert_xy_units(self._posA_posB[1]) + (posA, posB) = self.get_transform().transform((posA, posB)) + _path = self.get_connectionstyle()(posA, posB, + patchA=self.patchA, + patchB=self.patchB, + shrinkA=self.shrinkA * dpi_cor, + shrinkB=self.shrinkB * dpi_cor + ) + else: + _path = self.get_transform().transform_path(self._path_original) + + _path, fillable = self.get_arrowstyle()( + _path, + self.get_mutation_scale() * dpi_cor, + self.get_linewidth() * dpi_cor, + self.get_mutation_aspect()) + + return _path, fillable + + def draw(self, renderer): + if not self.get_visible(): + return + + # FIXME: dpi_cor is for the dpi-dependency of the linewidth. There + # could be room for improvement. Maybe _get_path_in_displaycoord could + # take a renderer argument, but get_path should be adapted too. + self._dpi_cor = renderer.points_to_pixels(1.) + path, fillable = self._get_path_in_displaycoord() + + if not np.iterable(fillable): + path = [path] + fillable = [fillable] + + affine = transforms.IdentityTransform() + + self._draw_paths_with_artist_properties( + renderer, + [(p, affine, self._facecolor if f and self._facecolor[3] else None) + for p, f in zip(path, fillable)]) + + +class ConnectionPatch(FancyArrowPatch): + """A patch that connects two points (possibly in different Axes).""" + + def __str__(self): + return "ConnectionPatch((%g, %g), (%g, %g))" % \ + (self.xy1[0], self.xy1[1], self.xy2[0], self.xy2[1]) + + @_docstring.dedent_interpd + def __init__(self, xyA, xyB, coordsA, coordsB=None, *, + axesA=None, axesB=None, + arrowstyle="-", + connectionstyle="arc3", + patchA=None, + patchB=None, + shrinkA=0., + shrinkB=0., + mutation_scale=10., + mutation_aspect=None, + clip_on=False, + **kwargs): + """ + Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*. + + Valid keys are + + =============== ====================================================== + Key Description + =============== ====================================================== + arrowstyle the arrow style + connectionstyle the connection style + relpos default is (0.5, 0.5) + patchA default is bounding box of the text + patchB default is None + shrinkA default is 2 points + shrinkB default is 2 points + mutation_scale default is text size (in points) + mutation_aspect default is 1. + ? any key for `matplotlib.patches.PathPatch` + =============== ====================================================== + + *coordsA* and *coordsB* are strings that indicate the + coordinates of *xyA* and *xyB*. + + ==================== ================================================== + Property Description + ==================== ================================================== + 'figure points' points from the lower left corner of the figure + 'figure pixels' pixels from the lower left corner of the figure + 'figure fraction' 0, 0 is lower left of figure and 1, 1 is upper + right + 'subfigure points' points from the lower left corner of the subfigure + 'subfigure pixels' pixels from the lower left corner of the subfigure + 'subfigure fraction' fraction of the subfigure, 0, 0 is lower left. + 'axes points' points from lower left corner of the Axes + 'axes pixels' pixels from lower left corner of the Axes + 'axes fraction' 0, 0 is lower left of Axes and 1, 1 is upper right + 'data' use the coordinate system of the object being + annotated (default) + 'offset points' offset (in points) from the *xy* value + 'polar' you can specify *theta*, *r* for the annotation, + even in cartesian plots. Note that if you are + using a polar Axes, you do not need to specify + polar for the coordinate system since that is the + native "data" coordinate system. + ==================== ================================================== + + Alternatively they can be set to any valid + `~matplotlib.transforms.Transform`. + + Note that 'subfigure pixels' and 'figure pixels' are the same + for the parent figure, so users who want code that is usable in + a subfigure can use 'subfigure pixels'. + + .. note:: + + Using `ConnectionPatch` across two `~.axes.Axes` instances + is not directly compatible with :ref:`constrained layout + `. Add the artist + directly to the `.Figure` instead of adding it to a specific Axes, + or exclude it from the layout using ``con.set_in_layout(False)``. + + .. code-block:: default + + fig, ax = plt.subplots(1, 2, constrained_layout=True) + con = ConnectionPatch(..., axesA=ax[0], axesB=ax[1]) + fig.add_artist(con) + + """ + if coordsB is None: + coordsB = coordsA + # we'll draw ourself after the artist we annotate by default + self.xy1 = xyA + self.xy2 = xyB + self.coords1 = coordsA + self.coords2 = coordsB + + self.axesA = axesA + self.axesB = axesB + + super().__init__(posA=(0, 0), posB=(1, 1), + arrowstyle=arrowstyle, + connectionstyle=connectionstyle, + patchA=patchA, patchB=patchB, + shrinkA=shrinkA, shrinkB=shrinkB, + mutation_scale=mutation_scale, + mutation_aspect=mutation_aspect, + clip_on=clip_on, + **kwargs) + # if True, draw annotation only if self.xy is inside the Axes + self._annotation_clip = None + + def _get_xy(self, xy, s, axes=None): + """Calculate the pixel position of given point.""" + s0 = s # For the error message, if needed. + if axes is None: + axes = self.axes + xy = np.array(xy) + if s in ["figure points", "axes points"]: + xy *= self.figure.dpi / 72 + s = s.replace("points", "pixels") + elif s == "figure fraction": + s = self.figure.transFigure + elif s == "subfigure fraction": + s = self.figure.transSubfigure + elif s == "axes fraction": + s = axes.transAxes + x, y = xy + + if s == 'data': + trans = axes.transData + x = float(self.convert_xunits(x)) + y = float(self.convert_yunits(y)) + return trans.transform((x, y)) + elif s == 'offset points': + if self.xycoords == 'offset points': # prevent recursion + return self._get_xy(self.xy, 'data') + return ( + self._get_xy(self.xy, self.xycoords) # converted data point + + xy * self.figure.dpi / 72) # converted offset + elif s == 'polar': + theta, r = x, y + x = r * np.cos(theta) + y = r * np.sin(theta) + trans = axes.transData + return trans.transform((x, y)) + elif s == 'figure pixels': + # pixels from the lower left corner of the figure + bb = self.figure.figbbox + x = bb.x0 + x if x >= 0 else bb.x1 + x + y = bb.y0 + y if y >= 0 else bb.y1 + y + return x, y + elif s == 'subfigure pixels': + # pixels from the lower left corner of the figure + bb = self.figure.bbox + x = bb.x0 + x if x >= 0 else bb.x1 + x + y = bb.y0 + y if y >= 0 else bb.y1 + y + return x, y + elif s == 'axes pixels': + # pixels from the lower left corner of the Axes + bb = axes.bbox + x = bb.x0 + x if x >= 0 else bb.x1 + x + y = bb.y0 + y if y >= 0 else bb.y1 + y + return x, y + elif isinstance(s, transforms.Transform): + return s.transform(xy) + else: + raise ValueError(f"{s0} is not a valid coordinate transformation") + + def set_annotation_clip(self, b): + """ + Set the annotation's clipping behavior. + + Parameters + ---------- + b : bool or None + - True: The annotation will be clipped when ``self.xy`` is + outside the Axes. + - False: The annotation will always be drawn. + - None: The annotation will be clipped when ``self.xy`` is + outside the Axes and ``self.xycoords == "data"``. + """ + self._annotation_clip = b + self.stale = True + + def get_annotation_clip(self): + """ + Return the clipping behavior. + + See `.set_annotation_clip` for the meaning of the return value. + """ + return self._annotation_clip + + def _get_path_in_displaycoord(self): + """Return the mutated path of the arrow in display coordinates.""" + dpi_cor = self._dpi_cor + posA = self._get_xy(self.xy1, self.coords1, self.axesA) + posB = self._get_xy(self.xy2, self.coords2, self.axesB) + path = self.get_connectionstyle()( + posA, posB, + patchA=self.patchA, patchB=self.patchB, + shrinkA=self.shrinkA * dpi_cor, shrinkB=self.shrinkB * dpi_cor, + ) + path, fillable = self.get_arrowstyle()( + path, + self.get_mutation_scale() * dpi_cor, + self.get_linewidth() * dpi_cor, + self.get_mutation_aspect() + ) + return path, fillable + + def _check_xy(self, renderer): + """Check whether the annotation needs to be drawn.""" + + b = self.get_annotation_clip() + + if b or (b is None and self.coords1 == "data"): + xy_pixel = self._get_xy(self.xy1, self.coords1, self.axesA) + if self.axesA is None: + axes = self.axes + else: + axes = self.axesA + if not axes.contains_point(xy_pixel): + return False + + if b or (b is None and self.coords2 == "data"): + xy_pixel = self._get_xy(self.xy2, self.coords2, self.axesB) + if self.axesB is None: + axes = self.axes + else: + axes = self.axesB + if not axes.contains_point(xy_pixel): + return False + + return True + + def draw(self, renderer): + if not self.get_visible() or not self._check_xy(renderer): + return + super().draw(renderer) diff --git a/venv/lib/python3.10/site-packages/matplotlib/patches.pyi b/venv/lib/python3.10/site-packages/matplotlib/patches.pyi new file mode 100644 index 00000000..f6c9ddf7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/patches.pyi @@ -0,0 +1,755 @@ +from . import artist +from .axes import Axes +from .backend_bases import RendererBase, MouseEvent +from .path import Path +from .transforms import Transform, Bbox + +from typing import Any, Literal, overload + +import numpy as np +from numpy.typing import ArrayLike +from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType + +class Patch(artist.Artist): + zorder: float + def __init__( + self, + *, + edgecolor: ColorType | None = ..., + facecolor: ColorType | None = ..., + color: ColorType | None = ..., + linewidth: float | None = ..., + linestyle: LineStyleType | None = ..., + antialiased: bool | None = ..., + hatch: str | None = ..., + fill: bool = ..., + capstyle: CapStyleType | None = ..., + joinstyle: JoinStyleType | None = ..., + **kwargs, + ) -> None: ... + def get_verts(self) -> ArrayLike: ... + def contains(self, mouseevent: MouseEvent, radius: float | None = None) -> tuple[bool, dict[Any, Any]]: ... + def contains_point( + self, point: tuple[float, float], radius: float | None = ... + ) -> bool: ... + def contains_points( + self, points: ArrayLike, radius: float | None = ... + ) -> np.ndarray: ... + def get_extents(self) -> Bbox: ... + def get_transform(self) -> Transform: ... + def get_data_transform(self) -> Transform: ... + def get_patch_transform(self) -> Transform: ... + def get_antialiased(self) -> bool: ... + def get_edgecolor(self) -> ColorType: ... + def get_facecolor(self) -> ColorType: ... + def get_linewidth(self) -> float: ... + def get_linestyle(self) -> LineStyleType: ... + def set_antialiased(self, aa: bool | None) -> None: ... + def set_edgecolor(self, color: ColorType | None) -> None: ... + def set_facecolor(self, color: ColorType | None) -> None: ... + def set_color(self, c: ColorType | None) -> None: ... + def set_alpha(self, alpha: float | None) -> None: ... + def set_linewidth(self, w: float | None) -> None: ... + def set_linestyle(self, ls: LineStyleType | None) -> None: ... + def set_fill(self, b: bool) -> None: ... + def get_fill(self) -> bool: ... + fill = property(get_fill, set_fill) + def set_capstyle(self, s: CapStyleType) -> None: ... + def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ... + def set_joinstyle(self, s: JoinStyleType) -> None: ... + def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ... + def set_hatch(self, hatch: str) -> None: ... + def get_hatch(self) -> str: ... + def get_path(self) -> Path: ... + +class Shadow(Patch): + patch: Patch + def __init__(self, patch: Patch, ox: float, oy: float, *, shade: float = ..., **kwargs) -> None: ... + +class Rectangle(Patch): + angle: float + def __init__( + self, + xy: tuple[float, float], + width: float, + height: float, + *, + angle: float = ..., + rotation_point: Literal["xy", "center"] | tuple[float, float] = ..., + **kwargs, + ) -> None: ... + @property + def rotation_point(self) -> Literal["xy", "center"] | tuple[float, float]: ... + @rotation_point.setter + def rotation_point( + self, value: Literal["xy", "center"] | tuple[float, float] + ) -> None: ... + def get_x(self) -> float: ... + def get_y(self) -> float: ... + def get_xy(self) -> tuple[float, float]: ... + def get_corners(self) -> np.ndarray: ... + def get_center(self) -> np.ndarray: ... + def get_width(self) -> float: ... + def get_height(self) -> float: ... + def get_angle(self) -> float: ... + def set_x(self, x: float) -> None: ... + def set_y(self, y: float) -> None: ... + def set_angle(self, angle: float) -> None: ... + def set_xy(self, xy: tuple[float, float]) -> None: ... + def set_width(self, w: float) -> None: ... + def set_height(self, h: float) -> None: ... + @overload + def set_bounds(self, args: tuple[float, float, float, float], /) -> None: ... + @overload + def set_bounds( + self, left: float, bottom: float, width: float, height: float, / + ) -> None: ... + def get_bbox(self) -> Bbox: ... + xy = property(get_xy, set_xy) + +class RegularPolygon(Patch): + xy: tuple[float, float] + numvertices: int + orientation: float + radius: float + def __init__( + self, + xy: tuple[float, float], + numVertices: int, + *, + radius: float = ..., + orientation: float = ..., + **kwargs, + ) -> None: ... + +class PathPatch(Patch): + def __init__(self, path: Path, **kwargs) -> None: ... + def set_path(self, path: Path) -> None: ... + +class StepPatch(PathPatch): + orientation: Literal["vertical", "horizontal"] + def __init__( + self, + values: ArrayLike, + edges: ArrayLike, + *, + orientation: Literal["vertical", "horizontal"] = ..., + baseline: float = ..., + **kwargs, + ) -> None: ... + + # NamedTuple StairData, defined in body of method + def get_data(self) -> tuple[np.ndarray, np.ndarray, float]: ... + def set_data( + self, + values: ArrayLike | None = ..., + edges: ArrayLike | None = ..., + baseline: float | None = ..., + ) -> None: ... + +class Polygon(Patch): + def __init__(self, xy: ArrayLike, *, closed: bool = ..., **kwargs) -> None: ... + def get_closed(self) -> bool: ... + def set_closed(self, closed: bool) -> None: ... + def get_xy(self) -> np.ndarray: ... + def set_xy(self, xy: ArrayLike) -> None: ... + xy = property(get_xy, set_xy) + +class Wedge(Patch): + center: tuple[float, float] + r: float + theta1: float + theta2: float + width: float | None + def __init__( + self, + center: tuple[float, float], + r: float, + theta1: float, + theta2: float, + *, + width: float | None = ..., + **kwargs, + ) -> None: ... + def set_center(self, center: tuple[float, float]) -> None: ... + def set_radius(self, radius: float) -> None: ... + def set_theta1(self, theta1: float) -> None: ... + def set_theta2(self, theta2: float) -> None: ... + def set_width(self, width: float | None) -> None: ... + +class Arrow(Patch): + def __init__( + self, x: float, y: float, dx: float, dy: float, *, width: float = ..., **kwargs + ) -> None: ... + def set_data( + self, + x: float | None = ..., + y: float | None = ..., + dx: float | None = ..., + dy: float | None = ..., + width: float | None = ..., + ) -> None: ... +class FancyArrow(Polygon): + def __init__( + self, + x: float, + y: float, + dx: float, + dy: float, + *, + width: float = ..., + length_includes_head: bool = ..., + head_width: float | None = ..., + head_length: float | None = ..., + shape: Literal["full", "left", "right"] = ..., + overhang: float = ..., + head_starts_at_zero: bool = ..., + **kwargs, + ) -> None: ... + def set_data( + self, + *, + x: float | None = ..., + y: float | None = ..., + dx: float | None = ..., + dy: float | None = ..., + width: float | None = ..., + head_width: float | None = ..., + head_length: float | None = ..., + ) -> None: ... + +class CirclePolygon(RegularPolygon): + def __init__( + self, + xy: tuple[float, float], + radius: float = ..., + *, + resolution: int = ..., + **kwargs, + ) -> None: ... + +class Ellipse(Patch): + def __init__( + self, + xy: tuple[float, float], + width: float, + height: float, + *, + angle: float = ..., + **kwargs, + ) -> None: ... + def set_center(self, xy: tuple[float, float]) -> None: ... + def get_center(self) -> float: ... + center = property(get_center, set_center) + + def set_width(self, width: float) -> None: ... + def get_width(self) -> float: ... + width = property(get_width, set_width) + + def set_height(self, height: float) -> None: ... + def get_height(self) -> float: ... + height = property(get_height, set_height) + + def set_angle(self, angle: float) -> None: ... + def get_angle(self) -> float: ... + angle = property(get_angle, set_angle) + + def get_corners(self) -> np.ndarray: ... + + def get_vertices(self) -> list[tuple[float, float]]: ... + def get_co_vertices(self) -> list[tuple[float, float]]: ... + + +class Annulus(Patch): + a: float + b: float + def __init__( + self, + xy: tuple[float, float], + r: float | tuple[float, float], + width: float, + angle: float = ..., + **kwargs, + ) -> None: ... + def set_center(self, xy: tuple[float, float]) -> None: ... + def get_center(self) -> tuple[float, float]: ... + center = property(get_center, set_center) + + def set_width(self, width: float) -> None: ... + def get_width(self) -> float: ... + width = property(get_width, set_width) + + def set_angle(self, angle: float) -> None: ... + def get_angle(self) -> float: ... + angle = property(get_angle, set_angle) + + def set_semimajor(self, a: float) -> None: ... + def set_semiminor(self, b: float) -> None: ... + def set_radii(self, r: float | tuple[float, float]) -> None: ... + def get_radii(self) -> tuple[float, float]: ... + radii = property(get_radii, set_radii) + +class Circle(Ellipse): + def __init__( + self, xy: tuple[float, float], radius: float = ..., **kwargs + ) -> None: ... + def set_radius(self, radius: float) -> None: ... + def get_radius(self) -> float: ... + radius = property(get_radius, set_radius) + +class Arc(Ellipse): + theta1: float + theta2: float + def __init__( + self, + xy: tuple[float, float], + width: float, + height: float, + *, + angle: float = ..., + theta1: float = ..., + theta2: float = ..., + **kwargs, + ) -> None: ... + +def bbox_artist( + artist: artist.Artist, + renderer: RendererBase, + props: dict[str, Any] | None = ..., + fill: bool = ..., +) -> None: ... +def draw_bbox( + bbox: Bbox, + renderer: RendererBase, + color: ColorType = ..., + trans: Transform | None = ..., +) -> None: ... + +class _Style: + def __new__(cls, stylename, **kwargs): ... + @classmethod + def get_styles(cls) -> dict[str, type]: ... + @classmethod + def pprint_styles(cls) -> str: ... + @classmethod + def register(cls, name: str, style: type) -> None: ... + +class BoxStyle(_Style): + class Square(BoxStyle): + pad: float + def __init__(self, pad: float = ...) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Circle(BoxStyle): + pad: float + def __init__(self, pad: float = ...) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Ellipse(BoxStyle): + pad: float + def __init__(self, pad: float = ...) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class LArrow(BoxStyle): + pad: float + def __init__(self, pad: float = ...) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class RArrow(LArrow): + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class DArrow(BoxStyle): + pad: float + def __init__(self, pad: float = ...) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Round(BoxStyle): + pad: float + rounding_size: float | None + def __init__( + self, pad: float = ..., rounding_size: float | None = ... + ) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Round4(BoxStyle): + pad: float + rounding_size: float | None + def __init__( + self, pad: float = ..., rounding_size: float | None = ... + ) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Sawtooth(BoxStyle): + pad: float + tooth_size: float | None + def __init__( + self, pad: float = ..., tooth_size: float | None = ... + ) -> None: ... + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + + class Roundtooth(Sawtooth): + def __call__( + self, + x0: float, + y0: float, + width: float, + height: float, + mutation_size: float, + ) -> Path: ... + +class ConnectionStyle(_Style): + class _Base(ConnectionStyle): + def __call__( + self, + posA: tuple[float, float], + posB: tuple[float, float], + shrinkA: float = ..., + shrinkB: float = ..., + patchA: Patch | None = ..., + patchB: Patch | None = ..., + ) -> Path: ... + + class Arc3(_Base): + rad: float + def __init__(self, rad: float = ...) -> None: ... + def connect( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> Path: ... + + class Angle3(_Base): + angleA: float + angleB: float + def __init__(self, angleA: float = ..., angleB: float = ...) -> None: ... + def connect( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> Path: ... + + class Angle(_Base): + angleA: float + angleB: float + rad: float + def __init__( + self, angleA: float = ..., angleB: float = ..., rad: float = ... + ) -> None: ... + def connect( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> Path: ... + + class Arc(_Base): + angleA: float + angleB: float + armA: float | None + armB: float | None + rad: float + def __init__( + self, + angleA: float = ..., + angleB: float = ..., + armA: float | None = ..., + armB: float | None = ..., + rad: float = ..., + ) -> None: ... + def connect( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> Path: ... + + class Bar(_Base): + armA: float + armB: float + fraction: float + angle: float | None + def __init__( + self, + armA: float = ..., + armB: float = ..., + fraction: float = ..., + angle: float | None = ..., + ) -> None: ... + def connect( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> Path: ... + +class ArrowStyle(_Style): + class _Base(ArrowStyle): + @staticmethod + def ensure_quadratic_bezier(path: Path) -> list[float]: ... + def transmute( + self, path: Path, mutation_size: float, linewidth: float + ) -> tuple[Path, bool]: ... + def __call__( + self, + path: Path, + mutation_size: float, + linewidth: float, + aspect_ratio: float = ..., + ) -> tuple[Path, bool]: ... + + class _Curve(_Base): + arrow: str + fillbegin: bool + fillend: bool + def __init__( + self, + head_length: float = ..., + head_width: float = ..., + widthA: float = ..., + widthB: float = ..., + lengthA: float = ..., + lengthB: float = ..., + angleA: float | None = ..., + angleB: float | None = ..., + scaleA: float | None = ..., + scaleB: float | None = ..., + ) -> None: ... + + class Curve(_Curve): + def __init__(self) -> None: ... + + class CurveA(_Curve): + arrow: str + + class CurveB(_Curve): + arrow: str + + class CurveAB(_Curve): + arrow: str + + class CurveFilledA(_Curve): + arrow: str + + class CurveFilledB(_Curve): + arrow: str + + class CurveFilledAB(_Curve): + arrow: str + + class BracketA(_Curve): + arrow: str + def __init__( + self, widthA: float = ..., lengthA: float = ..., angleA: float = ... + ) -> None: ... + + class BracketB(_Curve): + arrow: str + def __init__( + self, widthB: float = ..., lengthB: float = ..., angleB: float = ... + ) -> None: ... + + class BracketAB(_Curve): + arrow: str + def __init__( + self, + widthA: float = ..., + lengthA: float = ..., + angleA: float = ..., + widthB: float = ..., + lengthB: float = ..., + angleB: float = ..., + ) -> None: ... + + class BarAB(_Curve): + arrow: str + def __init__( + self, + widthA: float = ..., + angleA: float = ..., + widthB: float = ..., + angleB: float = ..., + ) -> None: ... + + class BracketCurve(_Curve): + arrow: str + def __init__( + self, widthA: float = ..., lengthA: float = ..., angleA: float | None = ... + ) -> None: ... + + class CurveBracket(_Curve): + arrow: str + def __init__( + self, widthB: float = ..., lengthB: float = ..., angleB: float | None = ... + ) -> None: ... + + class Simple(_Base): + def __init__( + self, + head_length: float = ..., + head_width: float = ..., + tail_width: float = ..., + ) -> None: ... + + class Fancy(_Base): + def __init__( + self, + head_length: float = ..., + head_width: float = ..., + tail_width: float = ..., + ) -> None: ... + + class Wedge(_Base): + tail_width: float + shrink_factor: float + def __init__( + self, tail_width: float = ..., shrink_factor: float = ... + ) -> None: ... + +class FancyBboxPatch(Patch): + def __init__( + self, + xy: tuple[float, float], + width: float, + height: float, + boxstyle: str | BoxStyle = ..., + *, + mutation_scale: float = ..., + mutation_aspect: float = ..., + **kwargs, + ) -> None: ... + def set_boxstyle(self, boxstyle: str | BoxStyle | None = ..., **kwargs) -> None: ... + def get_boxstyle(self) -> BoxStyle: ... + def set_mutation_scale(self, scale: float) -> None: ... + def get_mutation_scale(self) -> float: ... + def set_mutation_aspect(self, aspect: float) -> None: ... + def get_mutation_aspect(self) -> float: ... + def get_x(self) -> float: ... + def get_y(self) -> float: ... + def get_width(self) -> float: ... + def get_height(self) -> float: ... + def set_x(self, x: float) -> None: ... + def set_y(self, y: float) -> None: ... + def set_width(self, w: float) -> None: ... + def set_height(self, h: float) -> None: ... + @overload + def set_bounds(self, args: tuple[float, float, float, float], /) -> None: ... + @overload + def set_bounds( + self, left: float, bottom: float, width: float, height: float, / + ) -> None: ... + def get_bbox(self) -> Bbox: ... + +class FancyArrowPatch(Patch): + patchA: Patch + patchB: Patch + shrinkA: float + shrinkB: float + def __init__( + self, + posA: tuple[float, float] | None = ..., + posB: tuple[float, float] | None = ..., + *, + path: Path | None = ..., + arrowstyle: str | ArrowStyle = ..., + connectionstyle: str | ConnectionStyle = ..., + patchA: Patch | None = ..., + patchB: Patch | None = ..., + shrinkA: float = ..., + shrinkB: float = ..., + mutation_scale: float = ..., + mutation_aspect: float | None = ..., + **kwargs, + ) -> None: ... + def set_positions( + self, posA: tuple[float, float], posB: tuple[float, float] + ) -> None: ... + def set_patchA(self, patchA: Patch) -> None: ... + def set_patchB(self, patchB: Patch) -> None: ... + def set_connectionstyle(self, connectionstyle: str | ConnectionStyle | None = ..., **kwargs) -> None: ... + def get_connectionstyle(self) -> ConnectionStyle: ... + def set_arrowstyle(self, arrowstyle: str | ArrowStyle | None = ..., **kwargs) -> None: ... + def get_arrowstyle(self) -> ArrowStyle: ... + def set_mutation_scale(self, scale: float) -> None: ... + def get_mutation_scale(self) -> float: ... + def set_mutation_aspect(self, aspect: float | None) -> None: ... + def get_mutation_aspect(self) -> float: ... + +class ConnectionPatch(FancyArrowPatch): + xy1: tuple[float, float] + xy2: tuple[float, float] + coords1: str | Transform + coords2: str | Transform | None + axesA: Axes | None + axesB: Axes | None + def __init__( + self, + xyA: tuple[float, float], + xyB: tuple[float, float], + coordsA: str | Transform, + coordsB: str | Transform | None = ..., + *, + axesA: Axes | None = ..., + axesB: Axes | None = ..., + arrowstyle: str | ArrowStyle = ..., + connectionstyle: str | ConnectionStyle = ..., + patchA: Patch | None = ..., + patchB: Patch | None = ..., + shrinkA: float = ..., + shrinkB: float = ..., + mutation_scale: float = ..., + mutation_aspect: float | None = ..., + clip_on: bool = ..., + **kwargs, + ) -> None: ... + def set_annotation_clip(self, b: bool | None) -> None: ... + def get_annotation_clip(self) -> bool | None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/path.py b/venv/lib/python3.10/site-packages/matplotlib/path.py new file mode 100644 index 00000000..e72eb1a9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/path.py @@ -0,0 +1,1093 @@ +r""" +A module for dealing with the polylines used throughout Matplotlib. + +The primary class for polyline handling in Matplotlib is `Path`. Almost all +vector drawing makes use of `Path`\s somewhere in the drawing pipeline. + +Whilst a `Path` instance itself cannot be drawn, some `.Artist` subclasses, +such as `.PathPatch` and `.PathCollection`, can be used for convenient `Path` +visualisation. +""" + +import copy +from functools import lru_cache +from weakref import WeakValueDictionary + +import numpy as np + +import matplotlib as mpl +from . import _api, _path +from .cbook import _to_unmasked_float_array, simple_linear_interpolation +from .bezier import BezierSegment + + +class Path: + """ + A series of possibly disconnected, possibly closed, line and curve + segments. + + The underlying storage is made up of two parallel numpy arrays: + + - *vertices*: an (N, 2) float array of vertices + - *codes*: an N-length `numpy.uint8` array of path codes, or None + + These two arrays always have the same length in the first + dimension. For example, to represent a cubic curve, you must + provide three vertices and three `CURVE4` codes. + + The code types are: + + - `STOP` : 1 vertex (ignored) + A marker for the end of the entire path (currently not required and + ignored) + + - `MOVETO` : 1 vertex + Pick up the pen and move to the given vertex. + + - `LINETO` : 1 vertex + Draw a line from the current position to the given vertex. + + - `CURVE3` : 1 control point, 1 endpoint + Draw a quadratic Bézier curve from the current position, with the given + control point, to the given end point. + + - `CURVE4` : 2 control points, 1 endpoint + Draw a cubic Bézier curve from the current position, with the given + control points, to the given end point. + + - `CLOSEPOLY` : 1 vertex (ignored) + Draw a line segment to the start point of the current polyline. + + If *codes* is None, it is interpreted as a `MOVETO` followed by a series + of `LINETO`. + + Users of Path objects should not access the vertices and codes arrays + directly. Instead, they should use `iter_segments` or `cleaned` to get the + vertex/code pairs. This helps, in particular, to consistently handle the + case of *codes* being None. + + Some behavior of Path objects can be controlled by rcParams. See the + rcParams whose keys start with 'path.'. + + .. note:: + + The vertices and codes arrays should be treated as + immutable -- there are a number of optimizations and assumptions + made up front in the constructor that will not change when the + data changes. + """ + + code_type = np.uint8 + + # Path codes + STOP = code_type(0) # 1 vertex + MOVETO = code_type(1) # 1 vertex + LINETO = code_type(2) # 1 vertex + CURVE3 = code_type(3) # 2 vertices + CURVE4 = code_type(4) # 3 vertices + CLOSEPOLY = code_type(79) # 1 vertex + + #: A dictionary mapping Path codes to the number of vertices that the + #: code expects. + NUM_VERTICES_FOR_CODE = {STOP: 1, + MOVETO: 1, + LINETO: 1, + CURVE3: 2, + CURVE4: 3, + CLOSEPOLY: 1} + + def __init__(self, vertices, codes=None, _interpolation_steps=1, + closed=False, readonly=False): + """ + Create a new path with the given vertices and codes. + + Parameters + ---------- + vertices : (N, 2) array-like + The path vertices, as an array, masked array or sequence of pairs. + Masked values, if any, will be converted to NaNs, which are then + handled correctly by the Agg PathIterator and other consumers of + path data, such as :meth:`iter_segments`. + codes : array-like or None, optional + N-length array of integers representing the codes of the path. + If not None, codes must be the same length as vertices. + If None, *vertices* will be treated as a series of line segments. + _interpolation_steps : int, optional + Used as a hint to certain projections, such as Polar, that this + path should be linearly interpolated immediately before drawing. + This attribute is primarily an implementation detail and is not + intended for public use. + closed : bool, optional + If *codes* is None and closed is True, vertices will be treated as + line segments of a closed polygon. Note that the last vertex will + then be ignored (as the corresponding code will be set to + `CLOSEPOLY`). + readonly : bool, optional + Makes the path behave in an immutable way and sets the vertices + and codes as read-only arrays. + """ + vertices = _to_unmasked_float_array(vertices) + _api.check_shape((None, 2), vertices=vertices) + + if codes is not None: + codes = np.asarray(codes, self.code_type) + if codes.ndim != 1 or len(codes) != len(vertices): + raise ValueError("'codes' must be a 1D list or array with the " + "same length of 'vertices'. " + f"Your vertices have shape {vertices.shape} " + f"but your codes have shape {codes.shape}") + if len(codes) and codes[0] != self.MOVETO: + raise ValueError("The first element of 'code' must be equal " + f"to 'MOVETO' ({self.MOVETO}). " + f"Your first code is {codes[0]}") + elif closed and len(vertices): + codes = np.empty(len(vertices), dtype=self.code_type) + codes[0] = self.MOVETO + codes[1:-1] = self.LINETO + codes[-1] = self.CLOSEPOLY + + self._vertices = vertices + self._codes = codes + self._interpolation_steps = _interpolation_steps + self._update_values() + + if readonly: + self._vertices.flags.writeable = False + if self._codes is not None: + self._codes.flags.writeable = False + self._readonly = True + else: + self._readonly = False + + @classmethod + def _fast_from_codes_and_verts(cls, verts, codes, internals_from=None): + """ + Create a Path instance without the expense of calling the constructor. + + Parameters + ---------- + verts : array-like + codes : array + internals_from : Path or None + If not None, another `Path` from which the attributes + ``should_simplify``, ``simplify_threshold``, and + ``interpolation_steps`` will be copied. Note that ``readonly`` is + never copied, and always set to ``False`` by this constructor. + """ + pth = cls.__new__(cls) + pth._vertices = _to_unmasked_float_array(verts) + pth._codes = codes + pth._readonly = False + if internals_from is not None: + pth._should_simplify = internals_from._should_simplify + pth._simplify_threshold = internals_from._simplify_threshold + pth._interpolation_steps = internals_from._interpolation_steps + else: + pth._should_simplify = True + pth._simplify_threshold = mpl.rcParams['path.simplify_threshold'] + pth._interpolation_steps = 1 + return pth + + @classmethod + def _create_closed(cls, vertices): + """ + Create a closed polygonal path going through *vertices*. + + Unlike ``Path(..., closed=True)``, *vertices* should **not** end with + an entry for the CLOSEPATH; this entry is added by `._create_closed`. + """ + v = _to_unmasked_float_array(vertices) + return cls(np.concatenate([v, v[:1]]), closed=True) + + def _update_values(self): + self._simplify_threshold = mpl.rcParams['path.simplify_threshold'] + self._should_simplify = ( + self._simplify_threshold > 0 and + mpl.rcParams['path.simplify'] and + len(self._vertices) >= 128 and + (self._codes is None or np.all(self._codes <= Path.LINETO)) + ) + + @property + def vertices(self): + """The vertices of the `Path` as an (N, 2) array.""" + return self._vertices + + @vertices.setter + def vertices(self, vertices): + if self._readonly: + raise AttributeError("Can't set vertices on a readonly Path") + self._vertices = vertices + self._update_values() + + @property + def codes(self): + """ + The list of codes in the `Path` as a 1D array. + + Each code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4` or + `CLOSEPOLY`. For codes that correspond to more than one vertex + (`CURVE3` and `CURVE4`), that code will be repeated so that the length + of `vertices` and `codes` is always the same. + """ + return self._codes + + @codes.setter + def codes(self, codes): + if self._readonly: + raise AttributeError("Can't set codes on a readonly Path") + self._codes = codes + self._update_values() + + @property + def simplify_threshold(self): + """ + The fraction of a pixel difference below which vertices will + be simplified out. + """ + return self._simplify_threshold + + @simplify_threshold.setter + def simplify_threshold(self, threshold): + self._simplify_threshold = threshold + + @property + def should_simplify(self): + """ + `True` if the vertices array should be simplified. + """ + return self._should_simplify + + @should_simplify.setter + def should_simplify(self, should_simplify): + self._should_simplify = should_simplify + + @property + def readonly(self): + """ + `True` if the `Path` is read-only. + """ + return self._readonly + + def copy(self): + """ + Return a shallow copy of the `Path`, which will share the + vertices and codes with the source `Path`. + """ + return copy.copy(self) + + def __deepcopy__(self, memo=None): + """ + Return a deepcopy of the `Path`. The `Path` will not be + readonly, even if the source `Path` is. + """ + # Deepcopying arrays (vertices, codes) strips the writeable=False flag. + p = copy.deepcopy(super(), memo) + p._readonly = False + return p + + deepcopy = __deepcopy__ + + @classmethod + def make_compound_path_from_polys(cls, XY): + """ + Make a compound `Path` object to draw a number of polygons with equal + numbers of sides. + + .. plot:: gallery/misc/histogram_path.py + + Parameters + ---------- + XY : (numpolys, numsides, 2) array + """ + # for each poly: 1 for the MOVETO, (numsides-1) for the LINETO, 1 for + # the CLOSEPOLY; the vert for the closepoly is ignored but we still + # need it to keep the codes aligned with the vertices + numpolys, numsides, two = XY.shape + if two != 2: + raise ValueError("The third dimension of 'XY' must be 2") + stride = numsides + 1 + nverts = numpolys * stride + verts = np.zeros((nverts, 2)) + codes = np.full(nverts, cls.LINETO, dtype=cls.code_type) + codes[0::stride] = cls.MOVETO + codes[numsides::stride] = cls.CLOSEPOLY + for i in range(numsides): + verts[i::stride] = XY[:, i] + return cls(verts, codes) + + @classmethod + def make_compound_path(cls, *args): + r""" + Concatenate a list of `Path`\s into a single `Path`, removing all `STOP`\s. + """ + if not args: + return Path(np.empty([0, 2], dtype=np.float32)) + vertices = np.concatenate([path.vertices for path in args]) + codes = np.empty(len(vertices), dtype=cls.code_type) + i = 0 + for path in args: + size = len(path.vertices) + if path.codes is None: + if size: + codes[i] = cls.MOVETO + codes[i+1:i+size] = cls.LINETO + else: + codes[i:i+size] = path.codes + i += size + not_stop_mask = codes != cls.STOP # Remove STOPs, as internal STOPs are a bug. + return cls(vertices[not_stop_mask], codes[not_stop_mask]) + + def __repr__(self): + return f"Path({self.vertices!r}, {self.codes!r})" + + def __len__(self): + return len(self.vertices) + + def iter_segments(self, transform=None, remove_nans=True, clip=None, + snap=False, stroke_width=1.0, simplify=None, + curves=True, sketch=None): + """ + Iterate over all curve segments in the path. + + Each iteration returns a pair ``(vertices, code)``, where ``vertices`` + is a sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code. + + Additionally, this method can provide a number of standard cleanups and + conversions to the path. + + Parameters + ---------- + transform : None or :class:`~matplotlib.transforms.Transform` + If not None, the given affine transformation will be applied to the + path. + remove_nans : bool, optional + Whether to remove all NaNs from the path and skip over them using + MOVETO commands. + clip : None or (float, float, float, float), optional + If not None, must be a four-tuple (x1, y1, x2, y2) + defining a rectangle in which to clip the path. + snap : None or bool, optional + If True, snap all nodes to pixels; if False, don't snap them. + If None, snap if the path contains only segments + parallel to the x or y axes, and no more than 1024 of them. + stroke_width : float, optional + The width of the stroke being drawn (used for path snapping). + simplify : None or bool, optional + Whether to simplify the path by removing vertices + that do not affect its appearance. If None, use the + :attr:`should_simplify` attribute. See also :rc:`path.simplify` + and :rc:`path.simplify_threshold`. + curves : bool, optional + If True, curve segments will be returned as curve segments. + If False, all curves will be converted to line segments. + sketch : None or sequence, optional + If not None, must be a 3-tuple of the form + (scale, length, randomness), representing the sketch parameters. + """ + if not len(self): + return + + cleaned = self.cleaned(transform=transform, + remove_nans=remove_nans, clip=clip, + snap=snap, stroke_width=stroke_width, + simplify=simplify, curves=curves, + sketch=sketch) + + # Cache these object lookups for performance in the loop. + NUM_VERTICES_FOR_CODE = self.NUM_VERTICES_FOR_CODE + STOP = self.STOP + + vertices = iter(cleaned.vertices) + codes = iter(cleaned.codes) + for curr_vertices, code in zip(vertices, codes): + if code == STOP: + break + extra_vertices = NUM_VERTICES_FOR_CODE[code] - 1 + if extra_vertices: + for i in range(extra_vertices): + next(codes) + curr_vertices = np.append(curr_vertices, next(vertices)) + yield curr_vertices, code + + def iter_bezier(self, **kwargs): + """ + Iterate over each Bézier curve (lines included) in a `Path`. + + Parameters + ---------- + **kwargs + Forwarded to `.iter_segments`. + + Yields + ------ + B : `~matplotlib.bezier.BezierSegment` + The Bézier curves that make up the current path. Note in particular + that freestanding points are Bézier curves of order 0, and lines + are Bézier curves of order 1 (with two control points). + code : `~matplotlib.path.Path.code_type` + The code describing what kind of curve is being returned. + `MOVETO`, `LINETO`, `CURVE3`, and `CURVE4` correspond to + Bézier curves with 1, 2, 3, and 4 control points (respectively). + `CLOSEPOLY` is a `LINETO` with the control points correctly + chosen based on the start/end points of the current stroke. + """ + first_vert = None + prev_vert = None + for verts, code in self.iter_segments(**kwargs): + if first_vert is None: + if code != Path.MOVETO: + raise ValueError("Malformed path, must start with MOVETO.") + if code == Path.MOVETO: # a point is like "CURVE1" + first_vert = verts + yield BezierSegment(np.array([first_vert])), code + elif code == Path.LINETO: # "CURVE2" + yield BezierSegment(np.array([prev_vert, verts])), code + elif code == Path.CURVE3: + yield BezierSegment(np.array([prev_vert, verts[:2], + verts[2:]])), code + elif code == Path.CURVE4: + yield BezierSegment(np.array([prev_vert, verts[:2], + verts[2:4], verts[4:]])), code + elif code == Path.CLOSEPOLY: + yield BezierSegment(np.array([prev_vert, first_vert])), code + elif code == Path.STOP: + return + else: + raise ValueError(f"Invalid Path.code_type: {code}") + prev_vert = verts[-2:] + + def _iter_connected_components(self): + """Return subpaths split at MOVETOs.""" + if self.codes is None: + yield self + else: + idxs = np.append((self.codes == Path.MOVETO).nonzero()[0], len(self.codes)) + for sl in map(slice, idxs, idxs[1:]): + yield Path._fast_from_codes_and_verts( + self.vertices[sl], self.codes[sl], self) + + def cleaned(self, transform=None, remove_nans=False, clip=None, + *, simplify=False, curves=False, + stroke_width=1.0, snap=False, sketch=None): + """ + Return a new `Path` with vertices and codes cleaned according to the + parameters. + + See Also + -------- + Path.iter_segments : for details of the keyword arguments. + """ + vertices, codes = _path.cleanup_path( + self, transform, remove_nans, clip, snap, stroke_width, simplify, + curves, sketch) + pth = Path._fast_from_codes_and_verts(vertices, codes, self) + if not simplify: + pth._should_simplify = False + return pth + + def transformed(self, transform): + """ + Return a transformed copy of the path. + + See Also + -------- + matplotlib.transforms.TransformedPath + A specialized path class that will cache the transformed result and + automatically update when the transform changes. + """ + return Path(transform.transform(self.vertices), self.codes, + self._interpolation_steps) + + def contains_point(self, point, transform=None, radius=0.0): + """ + Return whether the area enclosed by the path contains the given point. + + The path is always treated as closed; i.e. if the last code is not + `CLOSEPOLY` an implicit segment connecting the last vertex to the first + vertex is assumed. + + Parameters + ---------- + point : (float, float) + The point (x, y) to check. + transform : `~matplotlib.transforms.Transform`, optional + If not ``None``, *point* will be compared to ``self`` transformed + by *transform*; i.e. for a correct check, *transform* should + transform the path into the coordinate system of *point*. + radius : float, default: 0 + Additional margin on the path in coordinates of *point*. + The path is extended tangentially by *radius/2*; i.e. if you would + draw the path with a linewidth of *radius*, all points on the line + would still be considered to be contained in the area. Conversely, + negative values shrink the area: Points on the imaginary line + will be considered outside the area. + + Returns + ------- + bool + + Notes + ----- + The current algorithm has some limitations: + + - The result is undefined for points exactly at the boundary + (i.e. at the path shifted by *radius/2*). + - The result is undefined if there is no enclosed area, i.e. all + vertices are on a straight line. + - If bounding lines start to cross each other due to *radius* shift, + the result is not guaranteed to be correct. + """ + if transform is not None: + transform = transform.frozen() + # `point_in_path` does not handle nonlinear transforms, so we + # transform the path ourselves. If *transform* is affine, letting + # `point_in_path` handle the transform avoids allocating an extra + # buffer. + if transform and not transform.is_affine: + self = transform.transform_path(self) + transform = None + return _path.point_in_path(point[0], point[1], radius, self, transform) + + def contains_points(self, points, transform=None, radius=0.0): + """ + Return whether the area enclosed by the path contains the given points. + + The path is always treated as closed; i.e. if the last code is not + `CLOSEPOLY` an implicit segment connecting the last vertex to the first + vertex is assumed. + + Parameters + ---------- + points : (N, 2) array + The points to check. Columns contain x and y values. + transform : `~matplotlib.transforms.Transform`, optional + If not ``None``, *points* will be compared to ``self`` transformed + by *transform*; i.e. for a correct check, *transform* should + transform the path into the coordinate system of *points*. + radius : float, default: 0 + Additional margin on the path in coordinates of *points*. + The path is extended tangentially by *radius/2*; i.e. if you would + draw the path with a linewidth of *radius*, all points on the line + would still be considered to be contained in the area. Conversely, + negative values shrink the area: Points on the imaginary line + will be considered outside the area. + + Returns + ------- + length-N bool array + + Notes + ----- + The current algorithm has some limitations: + + - The result is undefined for points exactly at the boundary + (i.e. at the path shifted by *radius/2*). + - The result is undefined if there is no enclosed area, i.e. all + vertices are on a straight line. + - If bounding lines start to cross each other due to *radius* shift, + the result is not guaranteed to be correct. + """ + if transform is not None: + transform = transform.frozen() + result = _path.points_in_path(points, radius, self, transform) + return result.astype('bool') + + def contains_path(self, path, transform=None): + """ + Return whether this (closed) path completely contains the given path. + + If *transform* is not ``None``, the path will be transformed before + checking for containment. + """ + if transform is not None: + transform = transform.frozen() + return _path.path_in_path(self, None, path, transform) + + def get_extents(self, transform=None, **kwargs): + """ + Get Bbox of the path. + + Parameters + ---------- + transform : `~matplotlib.transforms.Transform`, optional + Transform to apply to path before computing extents, if any. + **kwargs + Forwarded to `.iter_bezier`. + + Returns + ------- + matplotlib.transforms.Bbox + The extents of the path Bbox([[xmin, ymin], [xmax, ymax]]) + """ + from .transforms import Bbox + if transform is not None: + self = transform.transform_path(self) + if self.codes is None: + xys = self.vertices + elif len(np.intersect1d(self.codes, [Path.CURVE3, Path.CURVE4])) == 0: + # Optimization for the straight line case. + # Instead of iterating through each curve, consider + # each line segment's end-points + # (recall that STOP and CLOSEPOLY vertices are ignored) + xys = self.vertices[np.isin(self.codes, + [Path.MOVETO, Path.LINETO])] + else: + xys = [] + for curve, code in self.iter_bezier(**kwargs): + # places where the derivative is zero can be extrema + _, dzeros = curve.axis_aligned_extrema() + # as can the ends of the curve + xys.append(curve([0, *dzeros, 1])) + xys = np.concatenate(xys) + if len(xys): + return Bbox([xys.min(axis=0), xys.max(axis=0)]) + else: + return Bbox.null() + + def intersects_path(self, other, filled=True): + """ + Return whether if this path intersects another given path. + + If *filled* is True, then this also returns True if one path completely + encloses the other (i.e., the paths are treated as filled). + """ + return _path.path_intersects_path(self, other, filled) + + def intersects_bbox(self, bbox, filled=True): + """ + Return whether this path intersects a given `~.transforms.Bbox`. + + If *filled* is True, then this also returns True if the path completely + encloses the `.Bbox` (i.e., the path is treated as filled). + + The bounding box is always considered filled. + """ + return _path.path_intersects_rectangle( + self, bbox.x0, bbox.y0, bbox.x1, bbox.y1, filled) + + def interpolated(self, steps): + """ + Return a new path resampled to length N x *steps*. + + Codes other than `LINETO` are not handled correctly. + """ + if steps == 1: + return self + + vertices = simple_linear_interpolation(self.vertices, steps) + codes = self.codes + if codes is not None: + new_codes = np.full((len(codes) - 1) * steps + 1, Path.LINETO, + dtype=self.code_type) + new_codes[0::steps] = codes + else: + new_codes = None + return Path(vertices, new_codes) + + def to_polygons(self, transform=None, width=0, height=0, closed_only=True): + """ + Convert this path to a list of polygons or polylines. Each + polygon/polyline is an (N, 2) array of vertices. In other words, + each polygon has no `MOVETO` instructions or curves. This + is useful for displaying in backends that do not support + compound paths or Bézier curves. + + If *width* and *height* are both non-zero then the lines will + be simplified so that vertices outside of (0, 0), (width, + height) will be clipped. + + If *closed_only* is `True` (default), only closed polygons, + with the last point being the same as the first point, will be + returned. Any unclosed polylines in the path will be + explicitly closed. If *closed_only* is `False`, any unclosed + polygons in the path will be returned as unclosed polygons, + and the closed polygons will be returned explicitly closed by + setting the last point to the same as the first point. + """ + if len(self.vertices) == 0: + return [] + + if transform is not None: + transform = transform.frozen() + + if self.codes is None and (width == 0 or height == 0): + vertices = self.vertices + if closed_only: + if len(vertices) < 3: + return [] + elif np.any(vertices[0] != vertices[-1]): + vertices = [*vertices, vertices[0]] + + if transform is None: + return [vertices] + else: + return [transform.transform(vertices)] + + # Deal with the case where there are curves and/or multiple + # subpaths (using extension code) + return _path.convert_path_to_polygons( + self, transform, width, height, closed_only) + + _unit_rectangle = None + + @classmethod + def unit_rectangle(cls): + """ + Return a `Path` instance of the unit rectangle from (0, 0) to (1, 1). + """ + if cls._unit_rectangle is None: + cls._unit_rectangle = cls([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], + closed=True, readonly=True) + return cls._unit_rectangle + + _unit_regular_polygons = WeakValueDictionary() + + @classmethod + def unit_regular_polygon(cls, numVertices): + """ + Return a :class:`Path` instance for a unit regular polygon with the + given *numVertices* such that the circumscribing circle has radius 1.0, + centered at (0, 0). + """ + if numVertices <= 16: + path = cls._unit_regular_polygons.get(numVertices) + else: + path = None + if path is None: + theta = ((2 * np.pi / numVertices) * np.arange(numVertices + 1) + # This initial rotation is to make sure the polygon always + # "points-up". + + np.pi / 2) + verts = np.column_stack((np.cos(theta), np.sin(theta))) + path = cls(verts, closed=True, readonly=True) + if numVertices <= 16: + cls._unit_regular_polygons[numVertices] = path + return path + + _unit_regular_stars = WeakValueDictionary() + + @classmethod + def unit_regular_star(cls, numVertices, innerCircle=0.5): + """ + Return a :class:`Path` for a unit regular star with the given + numVertices and radius of 1.0, centered at (0, 0). + """ + if numVertices <= 16: + path = cls._unit_regular_stars.get((numVertices, innerCircle)) + else: + path = None + if path is None: + ns2 = numVertices * 2 + theta = (2*np.pi/ns2 * np.arange(ns2 + 1)) + # This initial rotation is to make sure the polygon always + # "points-up" + theta += np.pi / 2.0 + r = np.ones(ns2 + 1) + r[1::2] = innerCircle + verts = (r * np.vstack((np.cos(theta), np.sin(theta)))).T + path = cls(verts, closed=True, readonly=True) + if numVertices <= 16: + cls._unit_regular_stars[(numVertices, innerCircle)] = path + return path + + @classmethod + def unit_regular_asterisk(cls, numVertices): + """ + Return a :class:`Path` for a unit regular asterisk with the given + numVertices and radius of 1.0, centered at (0, 0). + """ + return cls.unit_regular_star(numVertices, 0.0) + + _unit_circle = None + + @classmethod + def unit_circle(cls): + """ + Return the readonly :class:`Path` of the unit circle. + + For most cases, :func:`Path.circle` will be what you want. + """ + if cls._unit_circle is None: + cls._unit_circle = cls.circle(center=(0, 0), radius=1, + readonly=True) + return cls._unit_circle + + @classmethod + def circle(cls, center=(0., 0.), radius=1., readonly=False): + """ + Return a `Path` representing a circle of a given radius and center. + + Parameters + ---------- + center : (float, float), default: (0, 0) + The center of the circle. + radius : float, default: 1 + The radius of the circle. + readonly : bool + Whether the created path should have the "readonly" argument + set when creating the Path instance. + + Notes + ----- + The circle is approximated using 8 cubic Bézier curves, as described in + + Lancaster, Don. `Approximating a Circle or an Ellipse Using Four + Bezier Cubic Splines `_. + """ + MAGIC = 0.2652031 + SQRTHALF = np.sqrt(0.5) + MAGIC45 = SQRTHALF * MAGIC + + vertices = np.array([[0.0, -1.0], + + [MAGIC, -1.0], + [SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45], + [SQRTHALF, -SQRTHALF], + + [SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], + + [1.0, MAGIC], + [SQRTHALF+MAGIC45, SQRTHALF-MAGIC45], + [SQRTHALF, SQRTHALF], + + [SQRTHALF-MAGIC45, SQRTHALF+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], + + [-MAGIC, 1.0], + [-SQRTHALF+MAGIC45, SQRTHALF+MAGIC45], + [-SQRTHALF, SQRTHALF], + + [-SQRTHALF-MAGIC45, SQRTHALF-MAGIC45], + [-1.0, MAGIC], + [-1.0, 0.0], + + [-1.0, -MAGIC], + [-SQRTHALF-MAGIC45, -SQRTHALF+MAGIC45], + [-SQRTHALF, -SQRTHALF], + + [-SQRTHALF+MAGIC45, -SQRTHALF-MAGIC45], + [-MAGIC, -1.0], + [0.0, -1.0], + + [0.0, -1.0]], + dtype=float) + + codes = [cls.CURVE4] * 26 + codes[0] = cls.MOVETO + codes[-1] = cls.CLOSEPOLY + return Path(vertices * radius + center, codes, readonly=readonly) + + _unit_circle_righthalf = None + + @classmethod + def unit_circle_righthalf(cls): + """ + Return a `Path` of the right half of a unit circle. + + See `Path.circle` for the reference on the approximation used. + """ + if cls._unit_circle_righthalf is None: + MAGIC = 0.2652031 + SQRTHALF = np.sqrt(0.5) + MAGIC45 = SQRTHALF * MAGIC + + vertices = np.array( + [[0.0, -1.0], + + [MAGIC, -1.0], + [SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45], + [SQRTHALF, -SQRTHALF], + + [SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], + + [1.0, MAGIC], + [SQRTHALF+MAGIC45, SQRTHALF-MAGIC45], + [SQRTHALF, SQRTHALF], + + [SQRTHALF-MAGIC45, SQRTHALF+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], + + [0.0, -1.0]], + + float) + + codes = np.full(14, cls.CURVE4, dtype=cls.code_type) + codes[0] = cls.MOVETO + codes[-1] = cls.CLOSEPOLY + + cls._unit_circle_righthalf = cls(vertices, codes, readonly=True) + return cls._unit_circle_righthalf + + @classmethod + def arc(cls, theta1, theta2, n=None, is_wedge=False): + """ + Return a `Path` for the unit circle arc from angles *theta1* to + *theta2* (in degrees). + + *theta2* is unwrapped to produce the shortest arc within 360 degrees. + That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to + *theta2* - 360 and not a full circle plus some extra overlap. + + If *n* is provided, it is the number of spline segments to make. + If *n* is not provided, the number of spline segments is + determined based on the delta between *theta1* and *theta2*. + + Masionobe, L. 2003. `Drawing an elliptical arc using + polylines, quadratic or cubic Bezier curves + `_. + """ + halfpi = np.pi * 0.5 + + eta1 = theta1 + eta2 = theta2 - 360 * np.floor((theta2 - theta1) / 360) + # Ensure 2pi range is not flattened to 0 due to floating-point errors, + # but don't try to expand existing 0 range. + if theta2 != theta1 and eta2 <= eta1: + eta2 += 360 + eta1, eta2 = np.deg2rad([eta1, eta2]) + + # number of curve segments to make + if n is None: + n = int(2 ** np.ceil((eta2 - eta1) / halfpi)) + if n < 1: + raise ValueError("n must be >= 1 or None") + + deta = (eta2 - eta1) / n + t = np.tan(0.5 * deta) + alpha = np.sin(deta) * (np.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 + + steps = np.linspace(eta1, eta2, n + 1, True) + cos_eta = np.cos(steps) + sin_eta = np.sin(steps) + + xA = cos_eta[:-1] + yA = sin_eta[:-1] + xA_dot = -yA + yA_dot = xA + + xB = cos_eta[1:] + yB = sin_eta[1:] + xB_dot = -yB + yB_dot = xB + + if is_wedge: + length = n * 3 + 4 + vertices = np.zeros((length, 2), float) + codes = np.full(length, cls.CURVE4, dtype=cls.code_type) + vertices[1] = [xA[0], yA[0]] + codes[0:2] = [cls.MOVETO, cls.LINETO] + codes[-2:] = [cls.LINETO, cls.CLOSEPOLY] + vertex_offset = 2 + end = length - 2 + else: + length = n * 3 + 1 + vertices = np.empty((length, 2), float) + codes = np.full(length, cls.CURVE4, dtype=cls.code_type) + vertices[0] = [xA[0], yA[0]] + codes[0] = cls.MOVETO + vertex_offset = 1 + end = length + + vertices[vertex_offset:end:3, 0] = xA + alpha * xA_dot + vertices[vertex_offset:end:3, 1] = yA + alpha * yA_dot + vertices[vertex_offset+1:end:3, 0] = xB - alpha * xB_dot + vertices[vertex_offset+1:end:3, 1] = yB - alpha * yB_dot + vertices[vertex_offset+2:end:3, 0] = xB + vertices[vertex_offset+2:end:3, 1] = yB + + return cls(vertices, codes, readonly=True) + + @classmethod + def wedge(cls, theta1, theta2, n=None): + """ + Return a `Path` for the unit circle wedge from angles *theta1* to + *theta2* (in degrees). + + *theta2* is unwrapped to produce the shortest wedge within 360 degrees. + That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1* + to *theta2* - 360 and not a full circle plus some extra overlap. + + If *n* is provided, it is the number of spline segments to make. + If *n* is not provided, the number of spline segments is + determined based on the delta between *theta1* and *theta2*. + + See `Path.arc` for the reference on the approximation used. + """ + return cls.arc(theta1, theta2, n, True) + + @staticmethod + @lru_cache(8) + def hatch(hatchpattern, density=6): + """ + Given a hatch specifier, *hatchpattern*, generates a `Path` that + can be used in a repeated hatching pattern. *density* is the + number of lines per unit square. + """ + from matplotlib.hatch import get_path + return (get_path(hatchpattern, density) + if hatchpattern is not None else None) + + def clip_to_bbox(self, bbox, inside=True): + """ + Clip the path to the given bounding box. + + The path must be made up of one or more closed polygons. This + algorithm will not behave correctly for unclosed paths. + + If *inside* is `True`, clip to the inside of the box, otherwise + to the outside of the box. + """ + verts = _path.clip_path_to_rect(self, bbox, inside) + paths = [Path(poly) for poly in verts] + return self.make_compound_path(*paths) + + +def get_path_collection_extents( + master_transform, paths, transforms, offsets, offset_transform): + r""" + Get bounding box of a `.PathCollection`\s internal objects. + + That is, given a sequence of `Path`\s, `.Transform`\s objects, and offsets, as found + in a `.PathCollection`, return the bounding box that encapsulates all of them. + + Parameters + ---------- + master_transform : `~matplotlib.transforms.Transform` + Global transformation applied to all paths. + paths : list of `Path` + transforms : list of `~matplotlib.transforms.Affine2DBase` + If non-empty, this overrides *master_transform*. + offsets : (N, 2) array-like + offset_transform : `~matplotlib.transforms.Affine2DBase` + Transform applied to the offsets before offsetting the path. + + Notes + ----- + The way that *paths*, *transforms* and *offsets* are combined follows the same + method as for collections: each is iterated over independently, so if you have 3 + paths (A, B, C), 2 transforms (α, β) and 1 offset (O), their combinations are as + follows: + + - (A, α, O) + - (B, β, O) + - (C, α, O) + """ + from .transforms import Bbox + if len(paths) == 0: + raise ValueError("No paths provided") + if len(offsets) == 0: + _api.warn_deprecated( + "3.8", message="Calling get_path_collection_extents() with an" + " empty offsets list is deprecated since %(since)s. Support will" + " be removed %(removal)s.") + extents, minpos = _path.get_path_collection_extents( + master_transform, paths, np.atleast_3d(transforms), + offsets, offset_transform) + return Bbox.from_extents(*extents, minpos=minpos) diff --git a/venv/lib/python3.10/site-packages/matplotlib/path.pyi b/venv/lib/python3.10/site-packages/matplotlib/path.pyi new file mode 100644 index 00000000..464fc6d9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/path.pyi @@ -0,0 +1,140 @@ +from .bezier import BezierSegment +from .transforms import Affine2D, Transform, Bbox +from collections.abc import Generator, Iterable, Sequence + +import numpy as np +from numpy.typing import ArrayLike + +from typing import Any, overload + +class Path: + code_type: type[np.uint8] + STOP: np.uint8 + MOVETO: np.uint8 + LINETO: np.uint8 + CURVE3: np.uint8 + CURVE4: np.uint8 + CLOSEPOLY: np.uint8 + NUM_VERTICES_FOR_CODE: dict[np.uint8, int] + + def __init__( + self, + vertices: ArrayLike, + codes: ArrayLike | None = ..., + _interpolation_steps: int = ..., + closed: bool = ..., + readonly: bool = ..., + ) -> None: ... + @property + def vertices(self) -> ArrayLike: ... + @vertices.setter + def vertices(self, vertices: ArrayLike) -> None: ... + @property + def codes(self) -> ArrayLike | None: ... + @codes.setter + def codes(self, codes: ArrayLike) -> None: ... + @property + def simplify_threshold(self) -> float: ... + @simplify_threshold.setter + def simplify_threshold(self, threshold: float) -> None: ... + @property + def should_simplify(self) -> bool: ... + @should_simplify.setter + def should_simplify(self, should_simplify: bool) -> None: ... + @property + def readonly(self) -> bool: ... + def copy(self) -> Path: ... + def __deepcopy__(self, memo: dict[int, Any] | None = ...) -> Path: ... + deepcopy = __deepcopy__ + + @classmethod + def make_compound_path_from_polys(cls, XY: ArrayLike) -> Path: ... + @classmethod + def make_compound_path(cls, *args: Path) -> Path: ... + def __len__(self) -> int: ... + def iter_segments( + self, + transform: Transform | None = ..., + remove_nans: bool = ..., + clip: tuple[float, float, float, float] | None = ..., + snap: bool | None = ..., + stroke_width: float = ..., + simplify: bool | None = ..., + curves: bool = ..., + sketch: tuple[float, float, float] | None = ..., + ) -> Generator[tuple[np.ndarray, np.uint8], None, None]: ... + def iter_bezier(self, **kwargs) -> Generator[BezierSegment, None, None]: ... + def cleaned( + self, + transform: Transform | None = ..., + remove_nans: bool = ..., + clip: tuple[float, float, float, float] | None = ..., + *, + simplify: bool | None = ..., + curves: bool = ..., + stroke_width: float = ..., + snap: bool | None = ..., + sketch: tuple[float, float, float] | None = ... + ) -> Path: ... + def transformed(self, transform: Transform) -> Path: ... + def contains_point( + self, + point: tuple[float, float], + transform: Transform | None = ..., + radius: float = ..., + ) -> bool: ... + def contains_points( + self, points: ArrayLike, transform: Transform | None = ..., radius: float = ... + ) -> np.ndarray: ... + def contains_path(self, path: Path, transform: Transform | None = ...) -> bool: ... + def get_extents(self, transform: Transform | None = ..., **kwargs) -> Bbox: ... + def intersects_path(self, other: Path, filled: bool = ...) -> bool: ... + def intersects_bbox(self, bbox: Bbox, filled: bool = ...) -> bool: ... + def interpolated(self, steps: int) -> Path: ... + def to_polygons( + self, + transform: Transform | None = ..., + width: float = ..., + height: float = ..., + closed_only: bool = ..., + ) -> list[ArrayLike]: ... + @classmethod + def unit_rectangle(cls) -> Path: ... + @classmethod + def unit_regular_polygon(cls, numVertices: int) -> Path: ... + @classmethod + def unit_regular_star(cls, numVertices: int, innerCircle: float = ...) -> Path: ... + @classmethod + def unit_regular_asterisk(cls, numVertices: int) -> Path: ... + @classmethod + def unit_circle(cls) -> Path: ... + @classmethod + def circle( + cls, + center: tuple[float, float] = ..., + radius: float = ..., + readonly: bool = ..., + ) -> Path: ... + @classmethod + def unit_circle_righthalf(cls) -> Path: ... + @classmethod + def arc( + cls, theta1: float, theta2: float, n: int | None = ..., is_wedge: bool = ... + ) -> Path: ... + @classmethod + def wedge(cls, theta1: float, theta2: float, n: int | None = ...) -> Path: ... + @overload + @staticmethod + def hatch(hatchpattern: str, density: float = ...) -> Path: ... + @overload + @staticmethod + def hatch(hatchpattern: None, density: float = ...) -> None: ... + def clip_to_bbox(self, bbox: Bbox, inside: bool = ...) -> Path: ... + +def get_path_collection_extents( + master_transform: Transform, + paths: Sequence[Path], + transforms: Iterable[Affine2D], + offsets: ArrayLike, + offset_transform: Affine2D, +) -> Bbox: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/patheffects.py b/venv/lib/python3.10/site-packages/matplotlib/patheffects.py new file mode 100644 index 00000000..cf159ddc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/patheffects.py @@ -0,0 +1,519 @@ +""" +Defines classes for path effects. The path effects are supported in `.Text`, +`.Line2D` and `.Patch`. + +.. seealso:: + :ref:`patheffects_guide` +""" + +from matplotlib.backend_bases import RendererBase +from matplotlib import colors as mcolors +from matplotlib import patches as mpatches +from matplotlib import transforms as mtransforms +from matplotlib.path import Path +import numpy as np + + +class AbstractPathEffect: + """ + A base class for path effects. + + Subclasses should override the ``draw_path`` method to add effect + functionality. + """ + + def __init__(self, offset=(0., 0.)): + """ + Parameters + ---------- + offset : (float, float), default: (0, 0) + The (x, y) offset to apply to the path, measured in points. + """ + self._offset = offset + + def _offset_transform(self, renderer): + """Apply the offset to the given transform.""" + return mtransforms.Affine2D().translate( + *map(renderer.points_to_pixels, self._offset)) + + def _update_gc(self, gc, new_gc_dict): + """ + Update the given GraphicsContext with the given dict of properties. + + The keys in the dictionary are used to identify the appropriate + ``set_`` method on the *gc*. + """ + new_gc_dict = new_gc_dict.copy() + + dashes = new_gc_dict.pop("dashes", None) + if dashes: + gc.set_dashes(**dashes) + + for k, v in new_gc_dict.items(): + set_method = getattr(gc, 'set_' + k, None) + if not callable(set_method): + raise AttributeError(f'Unknown property {k}') + set_method(v) + return gc + + def draw_path(self, renderer, gc, tpath, affine, rgbFace=None): + """ + Derived should override this method. The arguments are the same + as :meth:`matplotlib.backend_bases.RendererBase.draw_path` + except the first argument is a renderer. + """ + # Get the real renderer, not a PathEffectRenderer. + if isinstance(renderer, PathEffectRenderer): + renderer = renderer._renderer + return renderer.draw_path(gc, tpath, affine, rgbFace) + + +class PathEffectRenderer(RendererBase): + """ + Implements a Renderer which contains another renderer. + + This proxy then intercepts draw calls, calling the appropriate + :class:`AbstractPathEffect` draw method. + + .. note:: + Not all methods have been overridden on this RendererBase subclass. + It may be necessary to add further methods to extend the PathEffects + capabilities further. + """ + + def __init__(self, path_effects, renderer): + """ + Parameters + ---------- + path_effects : iterable of :class:`AbstractPathEffect` + The path effects which this renderer represents. + renderer : `~matplotlib.backend_bases.RendererBase` subclass + + """ + self._path_effects = path_effects + self._renderer = renderer + + def copy_with_path_effect(self, path_effects): + return self.__class__(path_effects, self._renderer) + + def draw_path(self, gc, tpath, affine, rgbFace=None): + for path_effect in self._path_effects: + path_effect.draw_path(self._renderer, gc, tpath, affine, + rgbFace) + + def draw_markers( + self, gc, marker_path, marker_trans, path, *args, **kwargs): + # We do a little shimmy so that all markers are drawn for each path + # effect in turn. Essentially, we induce recursion (depth 1) which is + # terminated once we have just a single path effect to work with. + if len(self._path_effects) == 1: + # Call the base path effect function - this uses the unoptimised + # approach of calling "draw_path" multiple times. + return super().draw_markers(gc, marker_path, marker_trans, path, + *args, **kwargs) + + for path_effect in self._path_effects: + renderer = self.copy_with_path_effect([path_effect]) + # Recursively call this method, only next time we will only have + # one path effect. + renderer.draw_markers(gc, marker_path, marker_trans, path, + *args, **kwargs) + + def draw_path_collection(self, gc, master_transform, paths, *args, + **kwargs): + # We do a little shimmy so that all paths are drawn for each path + # effect in turn. Essentially, we induce recursion (depth 1) which is + # terminated once we have just a single path effect to work with. + if len(self._path_effects) == 1: + # Call the base path effect function - this uses the unoptimised + # approach of calling "draw_path" multiple times. + return super().draw_path_collection(gc, master_transform, paths, + *args, **kwargs) + + for path_effect in self._path_effects: + renderer = self.copy_with_path_effect([path_effect]) + # Recursively call this method, only next time we will only have + # one path effect. + renderer.draw_path_collection(gc, master_transform, paths, + *args, **kwargs) + + def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath): + # Implements the naive text drawing as is found in RendererBase. + path, transform = self._get_text_path_transform(x, y, s, prop, + angle, ismath) + color = gc.get_rgb() + gc.set_linewidth(0.0) + self.draw_path(gc, path, transform, rgbFace=color) + + def __getattribute__(self, name): + if name in ['flipy', 'get_canvas_width_height', 'new_gc', + 'points_to_pixels', '_text2path', 'height', 'width']: + return getattr(self._renderer, name) + else: + return object.__getattribute__(self, name) + + def open_group(self, s, gid=None): + return self._renderer.open_group(s, gid) + + def close_group(self, s): + return self._renderer.close_group(s) + + +class Normal(AbstractPathEffect): + """ + The "identity" PathEffect. + + The Normal PathEffect's sole purpose is to draw the original artist with + no special path effect. + """ + + +def _subclass_with_normal(effect_class): + """ + Create a PathEffect class combining *effect_class* and a normal draw. + """ + + class withEffect(effect_class): + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + super().draw_path(renderer, gc, tpath, affine, rgbFace) + renderer.draw_path(gc, tpath, affine, rgbFace) + + withEffect.__name__ = f"with{effect_class.__name__}" + withEffect.__qualname__ = f"with{effect_class.__name__}" + withEffect.__doc__ = f""" + A shortcut PathEffect for applying `.{effect_class.__name__}` and then + drawing the original Artist. + + With this class you can use :: + + artist.set_path_effects([patheffects.with{effect_class.__name__}()]) + + as a shortcut for :: + + artist.set_path_effects([patheffects.{effect_class.__name__}(), + patheffects.Normal()]) + """ + # Docstring inheritance doesn't work for locally-defined subclasses. + withEffect.draw_path.__doc__ = effect_class.draw_path.__doc__ + return withEffect + + +class Stroke(AbstractPathEffect): + """A line based PathEffect which re-draws a stroke.""" + + def __init__(self, offset=(0, 0), **kwargs): + """ + The path will be stroked with its gc updated with the given + keyword arguments, i.e., the keyword arguments should be valid + gc parameter values. + """ + super().__init__(offset) + self._gc = kwargs + + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + """Draw the path with updated gc.""" + gc0 = renderer.new_gc() # Don't modify gc, but a copy! + gc0.copy_properties(gc) + gc0 = self._update_gc(gc0, self._gc) + renderer.draw_path( + gc0, tpath, affine + self._offset_transform(renderer), rgbFace) + gc0.restore() + + +withStroke = _subclass_with_normal(effect_class=Stroke) + + +class SimplePatchShadow(AbstractPathEffect): + """A simple shadow via a filled patch.""" + + def __init__(self, offset=(2, -2), + shadow_rgbFace=None, alpha=None, + rho=0.3, **kwargs): + """ + Parameters + ---------- + offset : (float, float), default: (2, -2) + The (x, y) offset of the shadow in points. + shadow_rgbFace : :mpltype:`color` + The shadow color. + alpha : float, default: 0.3 + The alpha transparency of the created shadow patch. + rho : float, default: 0.3 + A scale factor to apply to the rgbFace color if *shadow_rgbFace* + is not specified. + **kwargs + Extra keywords are stored and passed through to + :meth:`AbstractPathEffect._update_gc`. + + """ + super().__init__(offset) + + if shadow_rgbFace is None: + self._shadow_rgbFace = shadow_rgbFace + else: + self._shadow_rgbFace = mcolors.to_rgba(shadow_rgbFace) + + if alpha is None: + alpha = 0.3 + + self._alpha = alpha + self._rho = rho + + #: The dictionary of keywords to update the graphics collection with. + self._gc = kwargs + + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + """ + Overrides the standard draw_path to add the shadow offset and + necessary color changes for the shadow. + """ + gc0 = renderer.new_gc() # Don't modify gc, but a copy! + gc0.copy_properties(gc) + + if self._shadow_rgbFace is None: + r, g, b = (rgbFace or (1., 1., 1.))[:3] + # Scale the colors by a factor to improve the shadow effect. + shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho) + else: + shadow_rgbFace = self._shadow_rgbFace + + gc0.set_foreground("none") + gc0.set_alpha(self._alpha) + gc0.set_linewidth(0) + + gc0 = self._update_gc(gc0, self._gc) + renderer.draw_path( + gc0, tpath, affine + self._offset_transform(renderer), + shadow_rgbFace) + gc0.restore() + + +withSimplePatchShadow = _subclass_with_normal(effect_class=SimplePatchShadow) + + +class SimpleLineShadow(AbstractPathEffect): + """A simple shadow via a line.""" + + def __init__(self, offset=(2, -2), + shadow_color='k', alpha=0.3, rho=0.3, **kwargs): + """ + Parameters + ---------- + offset : (float, float), default: (2, -2) + The (x, y) offset to apply to the path, in points. + shadow_color : :mpltype:`color`, default: 'black' + The shadow color. + A value of ``None`` takes the original artist's color + with a scale factor of *rho*. + alpha : float, default: 0.3 + The alpha transparency of the created shadow patch. + rho : float, default: 0.3 + A scale factor to apply to the rgbFace color if *shadow_color* + is ``None``. + **kwargs + Extra keywords are stored and passed through to + :meth:`AbstractPathEffect._update_gc`. + """ + super().__init__(offset) + if shadow_color is None: + self._shadow_color = shadow_color + else: + self._shadow_color = mcolors.to_rgba(shadow_color) + self._alpha = alpha + self._rho = rho + #: The dictionary of keywords to update the graphics collection with. + self._gc = kwargs + + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + """ + Overrides the standard draw_path to add the shadow offset and + necessary color changes for the shadow. + """ + gc0 = renderer.new_gc() # Don't modify gc, but a copy! + gc0.copy_properties(gc) + + if self._shadow_color is None: + r, g, b = (gc0.get_foreground() or (1., 1., 1.))[:3] + # Scale the colors by a factor to improve the shadow effect. + shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho) + else: + shadow_rgbFace = self._shadow_color + + gc0.set_foreground(shadow_rgbFace) + gc0.set_alpha(self._alpha) + + gc0 = self._update_gc(gc0, self._gc) + renderer.draw_path( + gc0, tpath, affine + self._offset_transform(renderer)) + gc0.restore() + + +class PathPatchEffect(AbstractPathEffect): + """ + Draws a `.PathPatch` instance whose Path comes from the original + PathEffect artist. + """ + + def __init__(self, offset=(0, 0), **kwargs): + """ + Parameters + ---------- + offset : (float, float), default: (0, 0) + The (x, y) offset to apply to the path, in points. + **kwargs + All keyword arguments are passed through to the + :class:`~matplotlib.patches.PathPatch` constructor. The + properties which cannot be overridden are "path", "clip_box" + "transform" and "clip_path". + """ + super().__init__(offset=offset) + self.patch = mpatches.PathPatch([], **kwargs) + + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + self.patch._path = tpath + self.patch.set_transform(affine + self._offset_transform(renderer)) + self.patch.set_clip_box(gc.get_clip_rectangle()) + clip_path = gc.get_clip_path() + if clip_path and self.patch.get_clip_path() is None: + self.patch.set_clip_path(*clip_path) + self.patch.draw(renderer) + + +class TickedStroke(AbstractPathEffect): + """ + A line-based PathEffect which draws a path with a ticked style. + + This line style is frequently used to represent constraints in + optimization. The ticks may be used to indicate that one side + of the line is invalid or to represent a closed boundary of a + domain (i.e. a wall or the edge of a pipe). + + The spacing, length, and angle of ticks can be controlled. + + This line style is sometimes referred to as a hatched line. + + See also the :doc:`/gallery/misc/tickedstroke_demo` example. + """ + + def __init__(self, offset=(0, 0), + spacing=10.0, angle=45.0, length=np.sqrt(2), + **kwargs): + """ + Parameters + ---------- + offset : (float, float), default: (0, 0) + The (x, y) offset to apply to the path, in points. + spacing : float, default: 10.0 + The spacing between ticks in points. + angle : float, default: 45.0 + The angle between the path and the tick in degrees. The angle + is measured as if you were an ant walking along the curve, with + zero degrees pointing directly ahead, 90 to your left, -90 + to your right, and 180 behind you. To change side of the ticks, + change sign of the angle. + length : float, default: 1.414 + The length of the tick relative to spacing. + Recommended length = 1.414 (sqrt(2)) when angle=45, length=1.0 + when angle=90 and length=2.0 when angle=60. + **kwargs + Extra keywords are stored and passed through to + :meth:`AbstractPathEffect._update_gc`. + + Examples + -------- + See :doc:`/gallery/misc/tickedstroke_demo`. + """ + super().__init__(offset) + + self._spacing = spacing + self._angle = angle + self._length = length + self._gc = kwargs + + def draw_path(self, renderer, gc, tpath, affine, rgbFace): + """Draw the path with updated gc.""" + # Do not modify the input! Use copy instead. + gc0 = renderer.new_gc() + gc0.copy_properties(gc) + + gc0 = self._update_gc(gc0, self._gc) + trans = affine + self._offset_transform(renderer) + + theta = -np.radians(self._angle) + trans_matrix = np.array([[np.cos(theta), -np.sin(theta)], + [np.sin(theta), np.cos(theta)]]) + + # Convert spacing parameter to pixels. + spacing_px = renderer.points_to_pixels(self._spacing) + + # Transform before evaluation because to_polygons works at resolution + # of one -- assuming it is working in pixel space. + transpath = affine.transform_path(tpath) + + # Evaluate path to straight line segments that can be used to + # construct line ticks. + polys = transpath.to_polygons(closed_only=False) + + for p in polys: + x = p[:, 0] + y = p[:, 1] + + # Can not interpolate points or draw line if only one point in + # polyline. + if x.size < 2: + continue + + # Find distance between points on the line + ds = np.hypot(x[1:] - x[:-1], y[1:] - y[:-1]) + + # Build parametric coordinate along curve + s = np.concatenate(([0.0], np.cumsum(ds))) + s_total = s[-1] + + num = int(np.ceil(s_total / spacing_px)) - 1 + # Pick parameter values for ticks. + s_tick = np.linspace(spacing_px/2, s_total - spacing_px/2, num) + + # Find points along the parameterized curve + x_tick = np.interp(s_tick, s, x) + y_tick = np.interp(s_tick, s, y) + + # Find unit vectors in local direction of curve + delta_s = self._spacing * .001 + u = (np.interp(s_tick + delta_s, s, x) - x_tick) / delta_s + v = (np.interp(s_tick + delta_s, s, y) - y_tick) / delta_s + + # Normalize slope into unit slope vector. + n = np.hypot(u, v) + mask = n == 0 + n[mask] = 1.0 + + uv = np.array([u / n, v / n]).T + uv[mask] = np.array([0, 0]).T + + # Rotate and scale unit vector into tick vector + dxy = np.dot(uv, trans_matrix) * self._length * spacing_px + + # Build tick endpoints + x_end = x_tick + dxy[:, 0] + y_end = y_tick + dxy[:, 1] + + # Interleave ticks to form Path vertices + xyt = np.empty((2 * num, 2), dtype=x_tick.dtype) + xyt[0::2, 0] = x_tick + xyt[1::2, 0] = x_end + xyt[0::2, 1] = y_tick + xyt[1::2, 1] = y_end + + # Build up vector of Path codes + codes = np.tile([Path.MOVETO, Path.LINETO], num) + + # Construct and draw resulting path + h = Path(xyt, codes) + # Transform back to data space during render + renderer.draw_path(gc0, h, affine.inverted() + trans, rgbFace) + + gc0.restore() + + +withTickedStroke = _subclass_with_normal(effect_class=TickedStroke) diff --git a/venv/lib/python3.10/site-packages/matplotlib/patheffects.pyi b/venv/lib/python3.10/site-packages/matplotlib/patheffects.pyi new file mode 100644 index 00000000..2c1634ca --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/patheffects.pyi @@ -0,0 +1,106 @@ +from collections.abc import Iterable, Sequence +from typing import Any + +from matplotlib.backend_bases import RendererBase, GraphicsContextBase +from matplotlib.path import Path +from matplotlib.patches import Patch +from matplotlib.transforms import Transform + +from matplotlib.typing import ColorType + +class AbstractPathEffect: + def __init__(self, offset: tuple[float, float] = ...) -> None: ... + def draw_path( + self, + renderer: RendererBase, + gc: GraphicsContextBase, + tpath: Path, + affine: Transform, + rgbFace: ColorType | None = ..., + ) -> None: ... + +class PathEffectRenderer(RendererBase): + def __init__( + self, path_effects: Iterable[AbstractPathEffect], renderer: RendererBase + ) -> None: ... + def copy_with_path_effect(self, path_effects: Iterable[AbstractPathEffect]) -> PathEffectRenderer: ... + def draw_path( + self, + gc: GraphicsContextBase, + tpath: Path, + affine: Transform, + rgbFace: ColorType | None = ..., + ) -> None: ... + def draw_markers( + self, + gc: GraphicsContextBase, + marker_path: Path, + marker_trans: Transform, + path: Path, + *args, + **kwargs + ) -> None: ... + def draw_path_collection( + self, + gc: GraphicsContextBase, + master_transform: Transform, + paths: Sequence[Path], + *args, + **kwargs + ) -> None: ... + def __getattribute__(self, name: str) -> Any: ... + +class Normal(AbstractPathEffect): ... + +class Stroke(AbstractPathEffect): + def __init__(self, offset: tuple[float, float] = ..., **kwargs) -> None: ... + # rgbFace becomes non-optional + def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override] + +class withStroke(Stroke): ... + +class SimplePatchShadow(AbstractPathEffect): + def __init__( + self, + offset: tuple[float, float] = ..., + shadow_rgbFace: ColorType | None = ..., + alpha: float | None = ..., + rho: float = ..., + **kwargs + ) -> None: ... + # rgbFace becomes non-optional + def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override] + +class withSimplePatchShadow(SimplePatchShadow): ... + +class SimpleLineShadow(AbstractPathEffect): + def __init__( + self, + offset: tuple[float, float] = ..., + shadow_color: ColorType = ..., + alpha: float = ..., + rho: float = ..., + **kwargs + ) -> None: ... + # rgbFace becomes non-optional + def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override] + +class PathPatchEffect(AbstractPathEffect): + patch: Patch + def __init__(self, offset: tuple[float, float] = ..., **kwargs) -> None: ... + # rgbFace becomes non-optional + def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override] + +class TickedStroke(AbstractPathEffect): + def __init__( + self, + offset: tuple[float, float] = ..., + spacing: float = ..., + angle: float = ..., + length: float = ..., + **kwargs + ) -> None: ... + # rgbFace becomes non-optional + def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override] + +class withTickedStroke(TickedStroke): ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.py new file mode 100644 index 00000000..b58d1ceb --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.py @@ -0,0 +1,126 @@ +""" +Non-separable transforms that map from data space to screen space. + +Projections are defined as `~.axes.Axes` subclasses. They include the +following elements: + +- A transformation from data coordinates into display coordinates. + +- An inverse of that transformation. This is used, for example, to convert + mouse positions from screen space back into data space. + +- Transformations for the gridlines, ticks and ticklabels. Custom projections + will often need to place these elements in special locations, and Matplotlib + has a facility to help with doing so. + +- Setting up default values (overriding `~.axes.Axes.cla`), since the defaults + for a rectilinear Axes may not be appropriate. + +- Defining the shape of the Axes, for example, an elliptical Axes, that will be + used to draw the background of the plot and for clipping any data elements. + +- Defining custom locators and formatters for the projection. For example, in + a geographic projection, it may be more convenient to display the grid in + degrees, even if the data is in radians. + +- Set up interactive panning and zooming. This is left as an "advanced" + feature left to the reader, but there is an example of this for polar plots + in `matplotlib.projections.polar`. + +- Any additional methods for additional convenience or features. + +Once the projection Axes is defined, it can be used in one of two ways: + +- By defining the class attribute ``name``, the projection Axes can be + registered with `matplotlib.projections.register_projection` and subsequently + simply invoked by name:: + + fig.add_subplot(projection="my_proj_name") + +- For more complex, parameterisable projections, a generic "projection" object + may be defined which includes the method ``_as_mpl_axes``. ``_as_mpl_axes`` + should take no arguments and return the projection's Axes subclass and a + dictionary of additional arguments to pass to the subclass' ``__init__`` + method. Subsequently a parameterised projection can be initialised with:: + + fig.add_subplot(projection=MyProjection(param1=param1_value)) + + where MyProjection is an object which implements a ``_as_mpl_axes`` method. + +A full-fledged and heavily annotated example is in +:doc:`/gallery/misc/custom_projection`. The polar plot functionality in +`matplotlib.projections.polar` may also be of interest. +""" + +from .. import axes, _docstring +from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes +from .polar import PolarAxes + +try: + from mpl_toolkits.mplot3d import Axes3D +except Exception: + import warnings + warnings.warn("Unable to import Axes3D. This may be due to multiple versions of " + "Matplotlib being installed (e.g. as a system package and as a pip " + "package). As a result, the 3D projection is not available.") + Axes3D = None + + +class ProjectionRegistry: + """A mapping of registered projection names to projection classes.""" + + def __init__(self): + self._all_projection_types = {} + + def register(self, *projections): + """Register a new set of projections.""" + for projection in projections: + name = projection.name + self._all_projection_types[name] = projection + + def get_projection_class(self, name): + """Get a projection class from its *name*.""" + return self._all_projection_types[name] + + def get_projection_names(self): + """Return the names of all projections currently registered.""" + return sorted(self._all_projection_types) + + +projection_registry = ProjectionRegistry() +projection_registry.register( + axes.Axes, + PolarAxes, + AitoffAxes, + HammerAxes, + LambertAxes, + MollweideAxes, +) +if Axes3D is not None: + projection_registry.register(Axes3D) +else: + # remove from namespace if not importable + del Axes3D + + +def register_projection(cls): + projection_registry.register(cls) + + +def get_projection_class(projection=None): + """ + Get a projection class from its name. + + If *projection* is None, a standard rectilinear projection is returned. + """ + if projection is None: + projection = 'rectilinear' + + try: + return projection_registry.get_projection_class(projection) + except KeyError as err: + raise ValueError("Unknown projection %r" % projection) from err + + +get_projection_names = projection_registry.get_projection_names +_docstring.interpd.update(projection_names=get_projection_names()) diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.pyi b/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.pyi new file mode 100644 index 00000000..4e0d210f --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/__init__.pyi @@ -0,0 +1,20 @@ +from .geo import ( + AitoffAxes as AitoffAxes, + HammerAxes as HammerAxes, + LambertAxes as LambertAxes, + MollweideAxes as MollweideAxes, +) +from .polar import PolarAxes as PolarAxes +from ..axes import Axes + +class ProjectionRegistry: + def __init__(self) -> None: ... + def register(self, *projections: type[Axes]) -> None: ... + def get_projection_class(self, name: str) -> type[Axes]: ... + def get_projection_names(self) -> list[str]: ... + +projection_registry: ProjectionRegistry + +def register_projection(cls: type[Axes]) -> None: ... +def get_projection_class(projection: str | None = ...) -> type[Axes]: ... +def get_projection_names() -> list[str]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/geo.py b/venv/lib/python3.10/site-packages/matplotlib/projections/geo.py new file mode 100644 index 00000000..498b2f72 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/geo.py @@ -0,0 +1,510 @@ +import numpy as np + +import matplotlib as mpl +from matplotlib import _api +from matplotlib.axes import Axes +import matplotlib.axis as maxis +from matplotlib.patches import Circle +from matplotlib.path import Path +import matplotlib.spines as mspines +from matplotlib.ticker import ( + Formatter, NullLocator, FixedLocator, NullFormatter) +from matplotlib.transforms import Affine2D, BboxTransformTo, Transform + + +class GeoAxes(Axes): + """An abstract base class for geographic projections.""" + + class ThetaFormatter(Formatter): + """ + Used to format the theta tick labels. Converts the native + unit of radians into degrees and adds a degree symbol. + """ + def __init__(self, round_to=1.0): + self._round_to = round_to + + def __call__(self, x, pos=None): + degrees = round(np.rad2deg(x) / self._round_to) * self._round_to + return f"{degrees:0.0f}\N{DEGREE SIGN}" + + RESOLUTION = 75 + + def _init_axis(self): + self.xaxis = maxis.XAxis(self, clear=False) + self.yaxis = maxis.YAxis(self, clear=False) + self.spines['geo'].register_axis(self.yaxis) + + def clear(self): + # docstring inherited + super().clear() + + self.set_longitude_grid(30) + self.set_latitude_grid(15) + self.set_longitude_grid_ends(75) + self.xaxis.set_minor_locator(NullLocator()) + self.yaxis.set_minor_locator(NullLocator()) + self.xaxis.set_ticks_position('none') + self.yaxis.set_ticks_position('none') + self.yaxis.set_tick_params(label1On=True) + # Why do we need to turn on yaxis tick labels, but + # xaxis tick labels are already on? + + self.grid(mpl.rcParams['axes.grid']) + + Axes.set_xlim(self, -np.pi, np.pi) + Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0) + + def _set_lim_and_transforms(self): + # A (possibly non-linear) projection on the (already scaled) data + self.transProjection = self._get_core_transform(self.RESOLUTION) + + self.transAffine = self._get_affine_transform() + + self.transAxes = BboxTransformTo(self.bbox) + + # The complete data transformation stack -- from data all the + # way to display coordinates + self.transData = \ + self.transProjection + \ + self.transAffine + \ + self.transAxes + + # This is the transform for longitude ticks. + self._xaxis_pretransform = \ + Affine2D() \ + .scale(1, self._longitude_cap * 2) \ + .translate(0, -self._longitude_cap) + self._xaxis_transform = \ + self._xaxis_pretransform + \ + self.transData + self._xaxis_text1_transform = \ + Affine2D().scale(1, 0) + \ + self.transData + \ + Affine2D().translate(0, 4) + self._xaxis_text2_transform = \ + Affine2D().scale(1, 0) + \ + self.transData + \ + Affine2D().translate(0, -4) + + # This is the transform for latitude ticks. + yaxis_stretch = Affine2D().scale(np.pi * 2, 1).translate(-np.pi, 0) + yaxis_space = Affine2D().scale(1, 1.1) + self._yaxis_transform = \ + yaxis_stretch + \ + self.transData + yaxis_text_base = \ + yaxis_stretch + \ + self.transProjection + \ + (yaxis_space + + self.transAffine + + self.transAxes) + self._yaxis_text1_transform = \ + yaxis_text_base + \ + Affine2D().translate(-8, 0) + self._yaxis_text2_transform = \ + yaxis_text_base + \ + Affine2D().translate(8, 0) + + def _get_affine_transform(self): + transform = self._get_core_transform(1) + xscale, _ = transform.transform((np.pi, 0)) + _, yscale = transform.transform((0, np.pi/2)) + return Affine2D() \ + .scale(0.5 / xscale, 0.5 / yscale) \ + .translate(0.5, 0.5) + + def get_xaxis_transform(self, which='grid'): + _api.check_in_list(['tick1', 'tick2', 'grid'], which=which) + return self._xaxis_transform + + def get_xaxis_text1_transform(self, pad): + return self._xaxis_text1_transform, 'bottom', 'center' + + def get_xaxis_text2_transform(self, pad): + return self._xaxis_text2_transform, 'top', 'center' + + def get_yaxis_transform(self, which='grid'): + _api.check_in_list(['tick1', 'tick2', 'grid'], which=which) + return self._yaxis_transform + + def get_yaxis_text1_transform(self, pad): + return self._yaxis_text1_transform, 'center', 'right' + + def get_yaxis_text2_transform(self, pad): + return self._yaxis_text2_transform, 'center', 'left' + + def _gen_axes_patch(self): + return Circle((0.5, 0.5), 0.5) + + def _gen_axes_spines(self): + return {'geo': mspines.Spine.circular_spine(self, (0.5, 0.5), 0.5)} + + def set_yscale(self, *args, **kwargs): + if args[0] != 'linear': + raise NotImplementedError + + set_xscale = set_yscale + + def set_xlim(self, *args, **kwargs): + """Not supported. Please consider using Cartopy.""" + raise TypeError("Changing axes limits of a geographic projection is " + "not supported. Please consider using Cartopy.") + + set_ylim = set_xlim + + def format_coord(self, lon, lat): + """Return a format string formatting the coordinate.""" + lon, lat = np.rad2deg([lon, lat]) + ns = 'N' if lat >= 0.0 else 'S' + ew = 'E' if lon >= 0.0 else 'W' + return ('%f\N{DEGREE SIGN}%s, %f\N{DEGREE SIGN}%s' + % (abs(lat), ns, abs(lon), ew)) + + def set_longitude_grid(self, degrees): + """ + Set the number of degrees between each longitude grid. + """ + # Skip -180 and 180, which are the fixed limits. + grid = np.arange(-180 + degrees, 180, degrees) + self.xaxis.set_major_locator(FixedLocator(np.deg2rad(grid))) + self.xaxis.set_major_formatter(self.ThetaFormatter(degrees)) + + def set_latitude_grid(self, degrees): + """ + Set the number of degrees between each latitude grid. + """ + # Skip -90 and 90, which are the fixed limits. + grid = np.arange(-90 + degrees, 90, degrees) + self.yaxis.set_major_locator(FixedLocator(np.deg2rad(grid))) + self.yaxis.set_major_formatter(self.ThetaFormatter(degrees)) + + def set_longitude_grid_ends(self, degrees): + """ + Set the latitude(s) at which to stop drawing the longitude grids. + """ + self._longitude_cap = np.deg2rad(degrees) + self._xaxis_pretransform \ + .clear() \ + .scale(1.0, self._longitude_cap * 2.0) \ + .translate(0.0, -self._longitude_cap) + + def get_data_ratio(self): + """Return the aspect ratio of the data itself.""" + return 1.0 + + ### Interactive panning + + def can_zoom(self): + """ + Return whether this Axes supports the zoom box button functionality. + + This Axes object does not support interactive zoom box. + """ + return False + + def can_pan(self): + """ + Return whether this Axes supports the pan/zoom button functionality. + + This Axes object does not support interactive pan/zoom. + """ + return False + + def start_pan(self, x, y, button): + pass + + def end_pan(self): + pass + + def drag_pan(self, button, key, x, y): + pass + + +class _GeoTransform(Transform): + # Factoring out some common functionality. + input_dims = output_dims = 2 + + def __init__(self, resolution): + """ + Create a new geographical transform. + + Resolution is the number of steps to interpolate between each input + line segment to approximate its path in curved space. + """ + super().__init__() + self._resolution = resolution + + def __str__(self): + return f"{type(self).__name__}({self._resolution})" + + def transform_path_non_affine(self, path): + # docstring inherited + ipath = path.interpolated(self._resolution) + return Path(self.transform(ipath.vertices), ipath.codes) + + +class AitoffAxes(GeoAxes): + name = 'aitoff' + + class AitoffTransform(_GeoTransform): + """The base Aitoff transform.""" + + @_api.rename_parameter("3.8", "ll", "values") + def transform_non_affine(self, values): + # docstring inherited + longitude, latitude = values.T + + # Pre-compute some values + half_long = longitude / 2.0 + cos_latitude = np.cos(latitude) + + alpha = np.arccos(cos_latitude * np.cos(half_long)) + sinc_alpha = np.sinc(alpha / np.pi) # np.sinc is sin(pi*x)/(pi*x). + + x = (cos_latitude * np.sin(half_long)) / sinc_alpha + y = np.sin(latitude) / sinc_alpha + return np.column_stack([x, y]) + + def inverted(self): + # docstring inherited + return AitoffAxes.InvertedAitoffTransform(self._resolution) + + class InvertedAitoffTransform(_GeoTransform): + + @_api.rename_parameter("3.8", "xy", "values") + def transform_non_affine(self, values): + # docstring inherited + # MGDTODO: Math is hard ;( + return np.full_like(values, np.nan) + + def inverted(self): + # docstring inherited + return AitoffAxes.AitoffTransform(self._resolution) + + def __init__(self, *args, **kwargs): + self._longitude_cap = np.pi / 2.0 + super().__init__(*args, **kwargs) + self.set_aspect(0.5, adjustable='box', anchor='C') + self.clear() + + def _get_core_transform(self, resolution): + return self.AitoffTransform(resolution) + + +class HammerAxes(GeoAxes): + name = 'hammer' + + class HammerTransform(_GeoTransform): + """The base Hammer transform.""" + + @_api.rename_parameter("3.8", "ll", "values") + def transform_non_affine(self, values): + # docstring inherited + longitude, latitude = values.T + half_long = longitude / 2.0 + cos_latitude = np.cos(latitude) + sqrt2 = np.sqrt(2.0) + alpha = np.sqrt(1.0 + cos_latitude * np.cos(half_long)) + x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha + y = (sqrt2 * np.sin(latitude)) / alpha + return np.column_stack([x, y]) + + def inverted(self): + # docstring inherited + return HammerAxes.InvertedHammerTransform(self._resolution) + + class InvertedHammerTransform(_GeoTransform): + + @_api.rename_parameter("3.8", "xy", "values") + def transform_non_affine(self, values): + # docstring inherited + x, y = values.T + z = np.sqrt(1 - (x / 4) ** 2 - (y / 2) ** 2) + longitude = 2 * np.arctan((z * x) / (2 * (2 * z ** 2 - 1))) + latitude = np.arcsin(y*z) + return np.column_stack([longitude, latitude]) + + def inverted(self): + # docstring inherited + return HammerAxes.HammerTransform(self._resolution) + + def __init__(self, *args, **kwargs): + self._longitude_cap = np.pi / 2.0 + super().__init__(*args, **kwargs) + self.set_aspect(0.5, adjustable='box', anchor='C') + self.clear() + + def _get_core_transform(self, resolution): + return self.HammerTransform(resolution) + + +class MollweideAxes(GeoAxes): + name = 'mollweide' + + class MollweideTransform(_GeoTransform): + """The base Mollweide transform.""" + + @_api.rename_parameter("3.8", "ll", "values") + def transform_non_affine(self, values): + # docstring inherited + def d(theta): + delta = (-(theta + np.sin(theta) - pi_sin_l) + / (1 + np.cos(theta))) + return delta, np.abs(delta) > 0.001 + + longitude, latitude = values.T + + clat = np.pi/2 - np.abs(latitude) + ihigh = clat < 0.087 # within 5 degrees of the poles + ilow = ~ihigh + aux = np.empty(latitude.shape, dtype=float) + + if ilow.any(): # Newton-Raphson iteration + pi_sin_l = np.pi * np.sin(latitude[ilow]) + theta = 2.0 * latitude[ilow] + delta, large_delta = d(theta) + while np.any(large_delta): + theta[large_delta] += delta[large_delta] + delta, large_delta = d(theta) + aux[ilow] = theta / 2 + + if ihigh.any(): # Taylor series-based approx. solution + e = clat[ihigh] + d = 0.5 * (3 * np.pi * e**2) ** (1.0/3) + aux[ihigh] = (np.pi/2 - d) * np.sign(latitude[ihigh]) + + xy = np.empty(values.shape, dtype=float) + xy[:, 0] = (2.0 * np.sqrt(2.0) / np.pi) * longitude * np.cos(aux) + xy[:, 1] = np.sqrt(2.0) * np.sin(aux) + + return xy + + def inverted(self): + # docstring inherited + return MollweideAxes.InvertedMollweideTransform(self._resolution) + + class InvertedMollweideTransform(_GeoTransform): + + @_api.rename_parameter("3.8", "xy", "values") + def transform_non_affine(self, values): + # docstring inherited + x, y = values.T + # from Equations (7, 8) of + # https://mathworld.wolfram.com/MollweideProjection.html + theta = np.arcsin(y / np.sqrt(2)) + longitude = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta) + latitude = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi) + return np.column_stack([longitude, latitude]) + + def inverted(self): + # docstring inherited + return MollweideAxes.MollweideTransform(self._resolution) + + def __init__(self, *args, **kwargs): + self._longitude_cap = np.pi / 2.0 + super().__init__(*args, **kwargs) + self.set_aspect(0.5, adjustable='box', anchor='C') + self.clear() + + def _get_core_transform(self, resolution): + return self.MollweideTransform(resolution) + + +class LambertAxes(GeoAxes): + name = 'lambert' + + class LambertTransform(_GeoTransform): + """The base Lambert transform.""" + + def __init__(self, center_longitude, center_latitude, resolution): + """ + Create a new Lambert transform. Resolution is the number of steps + to interpolate between each input line segment to approximate its + path in curved Lambert space. + """ + _GeoTransform.__init__(self, resolution) + self._center_longitude = center_longitude + self._center_latitude = center_latitude + + @_api.rename_parameter("3.8", "ll", "values") + def transform_non_affine(self, values): + # docstring inherited + longitude, latitude = values.T + clong = self._center_longitude + clat = self._center_latitude + cos_lat = np.cos(latitude) + sin_lat = np.sin(latitude) + diff_long = longitude - clong + cos_diff_long = np.cos(diff_long) + + inner_k = np.maximum( # Prevent divide-by-zero problems + 1 + np.sin(clat)*sin_lat + np.cos(clat)*cos_lat*cos_diff_long, + 1e-15) + k = np.sqrt(2 / inner_k) + x = k * cos_lat*np.sin(diff_long) + y = k * (np.cos(clat)*sin_lat - np.sin(clat)*cos_lat*cos_diff_long) + + return np.column_stack([x, y]) + + def inverted(self): + # docstring inherited + return LambertAxes.InvertedLambertTransform( + self._center_longitude, + self._center_latitude, + self._resolution) + + class InvertedLambertTransform(_GeoTransform): + + def __init__(self, center_longitude, center_latitude, resolution): + _GeoTransform.__init__(self, resolution) + self._center_longitude = center_longitude + self._center_latitude = center_latitude + + @_api.rename_parameter("3.8", "xy", "values") + def transform_non_affine(self, values): + # docstring inherited + x, y = values.T + clong = self._center_longitude + clat = self._center_latitude + p = np.maximum(np.hypot(x, y), 1e-9) + c = 2 * np.arcsin(0.5 * p) + sin_c = np.sin(c) + cos_c = np.cos(c) + + latitude = np.arcsin(cos_c*np.sin(clat) + + ((y*sin_c*np.cos(clat)) / p)) + longitude = clong + np.arctan( + (x*sin_c) / (p*np.cos(clat)*cos_c - y*np.sin(clat)*sin_c)) + + return np.column_stack([longitude, latitude]) + + def inverted(self): + # docstring inherited + return LambertAxes.LambertTransform( + self._center_longitude, + self._center_latitude, + self._resolution) + + def __init__(self, *args, center_longitude=0, center_latitude=0, **kwargs): + self._longitude_cap = np.pi / 2 + self._center_longitude = center_longitude + self._center_latitude = center_latitude + super().__init__(*args, **kwargs) + self.set_aspect('equal', adjustable='box', anchor='C') + self.clear() + + def clear(self): + # docstring inherited + super().clear() + self.yaxis.set_major_formatter(NullFormatter()) + + def _get_core_transform(self, resolution): + return self.LambertTransform( + self._center_longitude, + self._center_latitude, + resolution) + + def _get_affine_transform(self): + return Affine2D() \ + .scale(0.25) \ + .translate(0.5, 0.5) diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/geo.pyi b/venv/lib/python3.10/site-packages/matplotlib/projections/geo.pyi new file mode 100644 index 00000000..93220f8c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/geo.pyi @@ -0,0 +1,112 @@ +from matplotlib.axes import Axes +from matplotlib.ticker import Formatter +from matplotlib.transforms import Transform + +from typing import Any, Literal + +class GeoAxes(Axes): + class ThetaFormatter(Formatter): + def __init__(self, round_to: float = ...) -> None: ... + def __call__(self, x: float, pos: Any | None = ...): ... + RESOLUTION: float + def get_xaxis_transform( + self, which: Literal["tick1", "tick2", "grid"] = ... + ) -> Transform: ... + def get_xaxis_text1_transform( + self, pad: float + ) -> tuple[ + Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_xaxis_text2_transform( + self, pad: float + ) -> tuple[ + Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_yaxis_transform( + self, which: Literal["tick1", "tick2", "grid"] = ... + ) -> Transform: ... + def get_yaxis_text1_transform( + self, pad: float + ) -> tuple[ + Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_yaxis_text2_transform( + self, pad: float + ) -> tuple[ + Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def set_xlim(self, *args, **kwargs) -> tuple[float, float]: ... + def set_ylim(self, *args, **kwargs) -> tuple[float, float]: ... + def format_coord(self, lon: float, lat: float) -> str: ... + def set_longitude_grid(self, degrees: float) -> None: ... + def set_latitude_grid(self, degrees: float) -> None: ... + def set_longitude_grid_ends(self, degrees: float) -> None: ... + def get_data_ratio(self) -> float: ... + def can_zoom(self) -> bool: ... + def can_pan(self) -> bool: ... + def start_pan(self, x, y, button) -> None: ... + def end_pan(self) -> None: ... + def drag_pan(self, button, key, x, y) -> None: ... + +class _GeoTransform(Transform): + input_dims: int + output_dims: int + def __init__(self, resolution: int) -> None: ... + +class AitoffAxes(GeoAxes): + name: str + + class AitoffTransform(_GeoTransform): + def inverted(self) -> AitoffAxes.InvertedAitoffTransform: ... + + class InvertedAitoffTransform(_GeoTransform): + def inverted(self) -> AitoffAxes.AitoffTransform: ... + +class HammerAxes(GeoAxes): + name: str + + class HammerTransform(_GeoTransform): + def inverted(self) -> HammerAxes.InvertedHammerTransform: ... + + class InvertedHammerTransform(_GeoTransform): + def inverted(self) -> HammerAxes.HammerTransform: ... + +class MollweideAxes(GeoAxes): + name: str + + class MollweideTransform(_GeoTransform): + def inverted(self) -> MollweideAxes.InvertedMollweideTransform: ... + + class InvertedMollweideTransform(_GeoTransform): + def inverted(self) -> MollweideAxes.MollweideTransform: ... + +class LambertAxes(GeoAxes): + name: str + + class LambertTransform(_GeoTransform): + def __init__( + self, center_longitude: float, center_latitude: float, resolution: int + ) -> None: ... + def inverted(self) -> LambertAxes.InvertedLambertTransform: ... + + class InvertedLambertTransform(_GeoTransform): + def __init__( + self, center_longitude: float, center_latitude: float, resolution: int + ) -> None: ... + def inverted(self) -> LambertAxes.LambertTransform: ... + + def __init__( + self, + *args, + center_longitude: float = ..., + center_latitude: float = ..., + **kwargs + ) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/polar.py b/venv/lib/python3.10/site-packages/matplotlib/projections/polar.py new file mode 100644 index 00000000..8d3e03f6 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/polar.py @@ -0,0 +1,1546 @@ +import math +import types + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, cbook +from matplotlib.axes import Axes +import matplotlib.axis as maxis +import matplotlib.markers as mmarkers +import matplotlib.patches as mpatches +from matplotlib.path import Path +import matplotlib.ticker as mticker +import matplotlib.transforms as mtransforms +from matplotlib.spines import Spine + + +def _apply_theta_transforms_warn(): + _api.warn_deprecated( + "3.9", + message=( + "Passing `apply_theta_transforms=True` (the default) " + "is deprecated since Matplotlib %(since)s. " + "Support for this will be removed in Matplotlib %(removal)s. " + "To prevent this warning, set `apply_theta_transforms=False`, " + "and make sure to shift theta values before being passed to " + "this transform." + ) + ) + + +class PolarTransform(mtransforms.Transform): + r""" + The base polar transform. + + This transform maps polar coordinates :math:`\theta, r` into Cartesian + coordinates :math:`x, y = r \cos(\theta), r \sin(\theta)` + (but does not fully transform into Axes coordinates or + handle positioning in screen space). + + This transformation is designed to be applied to data after any scaling + along the radial axis (e.g. log-scaling) has been applied to the input + data. + + Path segments at a fixed radius are automatically transformed to circular + arcs as long as ``path._interpolation_steps > 1``. + """ + + input_dims = output_dims = 2 + + def __init__(self, axis=None, use_rmin=True, *, + apply_theta_transforms=True, scale_transform=None): + """ + Parameters + ---------- + axis : `~matplotlib.axis.Axis`, optional + Axis associated with this transform. This is used to get the + minimum radial limit. + use_rmin : `bool`, optional + If ``True``, subtract the minimum radial axis limit before + transforming to Cartesian coordinates. *axis* must also be + specified for this to take effect. + """ + super().__init__() + self._axis = axis + self._use_rmin = use_rmin + self._apply_theta_transforms = apply_theta_transforms + self._scale_transform = scale_transform + if apply_theta_transforms: + _apply_theta_transforms_warn() + + __str__ = mtransforms._make_str_method( + "_axis", + use_rmin="_use_rmin", + apply_theta_transforms="_apply_theta_transforms") + + def _get_rorigin(self): + # Get lower r limit after being scaled by the radial scale transform + return self._scale_transform.transform( + (0, self._axis.get_rorigin()))[1] + + @_api.rename_parameter("3.8", "tr", "values") + def transform_non_affine(self, values): + # docstring inherited + theta, r = np.transpose(values) + # PolarAxes does not use the theta transforms here, but apply them for + # backwards-compatibility if not being used by it. + if self._apply_theta_transforms and self._axis is not None: + theta *= self._axis.get_theta_direction() + theta += self._axis.get_theta_offset() + if self._use_rmin and self._axis is not None: + r = (r - self._get_rorigin()) * self._axis.get_rsign() + r = np.where(r >= 0, r, np.nan) + return np.column_stack([r * np.cos(theta), r * np.sin(theta)]) + + def transform_path_non_affine(self, path): + # docstring inherited + if not len(path) or path._interpolation_steps == 1: + return Path(self.transform_non_affine(path.vertices), path.codes) + xys = [] + codes = [] + last_t = last_r = None + for trs, c in path.iter_segments(): + trs = trs.reshape((-1, 2)) + if c == Path.LINETO: + (t, r), = trs + if t == last_t: # Same angle: draw a straight line. + xys.extend(self.transform_non_affine(trs)) + codes.append(Path.LINETO) + elif r == last_r: # Same radius: draw an arc. + # The following is complicated by Path.arc() being + # "helpful" and unwrapping the angles, but we don't want + # that behavior here. + last_td, td = np.rad2deg([last_t, t]) + if self._use_rmin and self._axis is not None: + r = ((r - self._get_rorigin()) + * self._axis.get_rsign()) + if last_td <= td: + while td - last_td > 360: + arc = Path.arc(last_td, last_td + 360) + xys.extend(arc.vertices[1:] * r) + codes.extend(arc.codes[1:]) + last_td += 360 + arc = Path.arc(last_td, td) + xys.extend(arc.vertices[1:] * r) + codes.extend(arc.codes[1:]) + else: + # The reverse version also relies on the fact that all + # codes but the first one are the same. + while last_td - td > 360: + arc = Path.arc(last_td - 360, last_td) + xys.extend(arc.vertices[::-1][1:] * r) + codes.extend(arc.codes[1:]) + last_td -= 360 + arc = Path.arc(td, last_td) + xys.extend(arc.vertices[::-1][1:] * r) + codes.extend(arc.codes[1:]) + else: # Interpolate. + trs = cbook.simple_linear_interpolation( + np.vstack([(last_t, last_r), trs]), + path._interpolation_steps)[1:] + xys.extend(self.transform_non_affine(trs)) + codes.extend([Path.LINETO] * len(trs)) + else: # Not a straight line. + xys.extend(self.transform_non_affine(trs)) + codes.extend([c] * len(trs)) + last_t, last_r = trs[-1] + return Path(xys, codes) + + def inverted(self): + # docstring inherited + return PolarAxes.InvertedPolarTransform( + self._axis, self._use_rmin, + apply_theta_transforms=self._apply_theta_transforms + ) + + +class PolarAffine(mtransforms.Affine2DBase): + r""" + The affine part of the polar projection. + + Scales the output so that maximum radius rests on the edge of the Axes + circle and the origin is mapped to (0.5, 0.5). The transform applied is + the same to x and y components and given by: + + .. math:: + + x_{1} = 0.5 \left [ \frac{x_{0}}{(r_{\max} - r_{\min})} + 1 \right ] + + :math:`r_{\min}, r_{\max}` are the minimum and maximum radial limits after + any scaling (e.g. log scaling) has been removed. + """ + def __init__(self, scale_transform, limits): + """ + Parameters + ---------- + scale_transform : `~matplotlib.transforms.Transform` + Scaling transform for the data. This is used to remove any scaling + from the radial view limits. + limits : `~matplotlib.transforms.BboxBase` + View limits of the data. The only part of its bounds that is used + is the y limits (for the radius limits). + """ + super().__init__() + self._scale_transform = scale_transform + self._limits = limits + self.set_children(scale_transform, limits) + self._mtx = None + + __str__ = mtransforms._make_str_method("_scale_transform", "_limits") + + def get_matrix(self): + # docstring inherited + if self._invalid: + limits_scaled = self._limits.transformed(self._scale_transform) + yscale = limits_scaled.ymax - limits_scaled.ymin + affine = mtransforms.Affine2D() \ + .scale(0.5 / yscale) \ + .translate(0.5, 0.5) + self._mtx = affine.get_matrix() + self._inverted = None + self._invalid = 0 + return self._mtx + + +class InvertedPolarTransform(mtransforms.Transform): + """ + The inverse of the polar transform, mapping Cartesian + coordinate space *x* and *y* back to *theta* and *r*. + """ + input_dims = output_dims = 2 + + def __init__(self, axis=None, use_rmin=True, + *, apply_theta_transforms=True): + """ + Parameters + ---------- + axis : `~matplotlib.axis.Axis`, optional + Axis associated with this transform. This is used to get the + minimum radial limit. + use_rmin : `bool`, optional + If ``True``, add the minimum radial axis limit after + transforming from Cartesian coordinates. *axis* must also be + specified for this to take effect. + """ + super().__init__() + self._axis = axis + self._use_rmin = use_rmin + self._apply_theta_transforms = apply_theta_transforms + if apply_theta_transforms: + _apply_theta_transforms_warn() + + __str__ = mtransforms._make_str_method( + "_axis", + use_rmin="_use_rmin", + apply_theta_transforms="_apply_theta_transforms") + + @_api.rename_parameter("3.8", "xy", "values") + def transform_non_affine(self, values): + # docstring inherited + x, y = values.T + r = np.hypot(x, y) + theta = (np.arctan2(y, x) + 2 * np.pi) % (2 * np.pi) + # PolarAxes does not use the theta transforms here, but apply them for + # backwards-compatibility if not being used by it. + if self._apply_theta_transforms and self._axis is not None: + theta -= self._axis.get_theta_offset() + theta *= self._axis.get_theta_direction() + theta %= 2 * np.pi + if self._use_rmin and self._axis is not None: + r += self._axis.get_rorigin() + r *= self._axis.get_rsign() + return np.column_stack([theta, r]) + + def inverted(self): + # docstring inherited + return PolarAxes.PolarTransform( + self._axis, self._use_rmin, + apply_theta_transforms=self._apply_theta_transforms + ) + + +class ThetaFormatter(mticker.Formatter): + """ + Used to format the *theta* tick labels. Converts the native + unit of radians into degrees and adds a degree symbol. + """ + + def __call__(self, x, pos=None): + vmin, vmax = self.axis.get_view_interval() + d = np.rad2deg(abs(vmax - vmin)) + digits = max(-int(np.log10(d) - 1.5), 0) + return f"{np.rad2deg(x):0.{digits}f}\N{DEGREE SIGN}" + + +class _AxisWrapper: + def __init__(self, axis): + self._axis = axis + + def get_view_interval(self): + return np.rad2deg(self._axis.get_view_interval()) + + def set_view_interval(self, vmin, vmax): + self._axis.set_view_interval(*np.deg2rad((vmin, vmax))) + + def get_minpos(self): + return np.rad2deg(self._axis.get_minpos()) + + def get_data_interval(self): + return np.rad2deg(self._axis.get_data_interval()) + + def set_data_interval(self, vmin, vmax): + self._axis.set_data_interval(*np.deg2rad((vmin, vmax))) + + def get_tick_space(self): + return self._axis.get_tick_space() + + +class ThetaLocator(mticker.Locator): + """ + Used to locate theta ticks. + + This will work the same as the base locator except in the case that the + view spans the entire circle. In such cases, the previously used default + locations of every 45 degrees are returned. + """ + + def __init__(self, base): + self.base = base + self.axis = self.base.axis = _AxisWrapper(self.base.axis) + + def set_axis(self, axis): + self.axis = _AxisWrapper(axis) + self.base.set_axis(self.axis) + + def __call__(self): + lim = self.axis.get_view_interval() + if _is_full_circle_deg(lim[0], lim[1]): + return np.deg2rad(min(lim)) + np.arange(8) * 2 * np.pi / 8 + else: + return np.deg2rad(self.base()) + + def view_limits(self, vmin, vmax): + vmin, vmax = np.rad2deg((vmin, vmax)) + return np.deg2rad(self.base.view_limits(vmin, vmax)) + + +class ThetaTick(maxis.XTick): + """ + A theta-axis tick. + + This subclass of `.XTick` provides angular ticks with some small + modification to their re-positioning such that ticks are rotated based on + tick location. This results in ticks that are correctly perpendicular to + the arc spine. + + When 'auto' rotation is enabled, labels are also rotated to be parallel to + the spine. The label padding is also applied here since it's not possible + to use a generic axes transform to produce tick-specific padding. + """ + + def __init__(self, axes, *args, **kwargs): + self._text1_translate = mtransforms.ScaledTranslation( + 0, 0, axes.figure.dpi_scale_trans) + self._text2_translate = mtransforms.ScaledTranslation( + 0, 0, axes.figure.dpi_scale_trans) + super().__init__(axes, *args, **kwargs) + self.label1.set( + rotation_mode='anchor', + transform=self.label1.get_transform() + self._text1_translate) + self.label2.set( + rotation_mode='anchor', + transform=self.label2.get_transform() + self._text2_translate) + + def _apply_params(self, **kwargs): + super()._apply_params(**kwargs) + # Ensure transform is correct; sometimes this gets reset. + trans = self.label1.get_transform() + if not trans.contains_branch(self._text1_translate): + self.label1.set_transform(trans + self._text1_translate) + trans = self.label2.get_transform() + if not trans.contains_branch(self._text2_translate): + self.label2.set_transform(trans + self._text2_translate) + + def _update_padding(self, pad, angle): + padx = pad * np.cos(angle) / 72 + pady = pad * np.sin(angle) / 72 + self._text1_translate._t = (padx, pady) + self._text1_translate.invalidate() + self._text2_translate._t = (-padx, -pady) + self._text2_translate.invalidate() + + def update_position(self, loc): + super().update_position(loc) + axes = self.axes + angle = loc * axes.get_theta_direction() + axes.get_theta_offset() + text_angle = np.rad2deg(angle) % 360 - 90 + angle -= np.pi / 2 + + marker = self.tick1line.get_marker() + if marker in (mmarkers.TICKUP, '|'): + trans = mtransforms.Affine2D().scale(1, 1).rotate(angle) + elif marker == mmarkers.TICKDOWN: + trans = mtransforms.Affine2D().scale(1, -1).rotate(angle) + else: + # Don't modify custom tick line markers. + trans = self.tick1line._marker._transform + self.tick1line._marker._transform = trans + + marker = self.tick2line.get_marker() + if marker in (mmarkers.TICKUP, '|'): + trans = mtransforms.Affine2D().scale(1, 1).rotate(angle) + elif marker == mmarkers.TICKDOWN: + trans = mtransforms.Affine2D().scale(1, -1).rotate(angle) + else: + # Don't modify custom tick line markers. + trans = self.tick2line._marker._transform + self.tick2line._marker._transform = trans + + mode, user_angle = self._labelrotation + if mode == 'default': + text_angle = user_angle + else: + if text_angle > 90: + text_angle -= 180 + elif text_angle < -90: + text_angle += 180 + text_angle += user_angle + self.label1.set_rotation(text_angle) + self.label2.set_rotation(text_angle) + + # This extra padding helps preserve the look from previous releases but + # is also needed because labels are anchored to their center. + pad = self._pad + 7 + self._update_padding(pad, + self._loc * axes.get_theta_direction() + + axes.get_theta_offset()) + + +class ThetaAxis(maxis.XAxis): + """ + A theta Axis. + + This overrides certain properties of an `.XAxis` to provide special-casing + for an angular axis. + """ + __name__ = 'thetaaxis' + axis_name = 'theta' #: Read-only name identifying the axis. + _tick_class = ThetaTick + + def _wrap_locator_formatter(self): + self.set_major_locator(ThetaLocator(self.get_major_locator())) + self.set_major_formatter(ThetaFormatter()) + self.isDefault_majloc = True + self.isDefault_majfmt = True + + def clear(self): + # docstring inherited + super().clear() + self.set_ticks_position('none') + self._wrap_locator_formatter() + + def _set_scale(self, value, **kwargs): + if value != 'linear': + raise NotImplementedError( + "The xscale cannot be set on a polar plot") + super()._set_scale(value, **kwargs) + # LinearScale.set_default_locators_and_formatters just set the major + # locator to be an AutoLocator, so we customize it here to have ticks + # at sensible degree multiples. + self.get_major_locator().set_params(steps=[1, 1.5, 3, 4.5, 9, 10]) + self._wrap_locator_formatter() + + def _copy_tick_props(self, src, dest): + """Copy the props from src tick to dest tick.""" + if src is None or dest is None: + return + super()._copy_tick_props(src, dest) + + # Ensure that tick transforms are independent so that padding works. + trans = dest._get_text1_transform()[0] + dest.label1.set_transform(trans + dest._text1_translate) + trans = dest._get_text2_transform()[0] + dest.label2.set_transform(trans + dest._text2_translate) + + +class RadialLocator(mticker.Locator): + """ + Used to locate radius ticks. + + Ensures that all ticks are strictly positive. For all other tasks, it + delegates to the base `.Locator` (which may be different depending on the + scale of the *r*-axis). + """ + + def __init__(self, base, axes=None): + self.base = base + self._axes = axes + + def set_axis(self, axis): + self.base.set_axis(axis) + + def __call__(self): + # Ensure previous behaviour with full circle non-annular views. + if self._axes: + if _is_full_circle_rad(*self._axes.viewLim.intervalx): + rorigin = self._axes.get_rorigin() * self._axes.get_rsign() + if self._axes.get_rmin() <= rorigin: + return [tick for tick in self.base() if tick > rorigin] + return self.base() + + def _zero_in_bounds(self): + """ + Return True if zero is within the valid values for the + scale of the radial axis. + """ + vmin, vmax = self._axes.yaxis._scale.limit_range_for_scale(0, 1, 1e-5) + return vmin == 0 + + def nonsingular(self, vmin, vmax): + # docstring inherited + if self._zero_in_bounds() and (vmin, vmax) == (-np.inf, np.inf): + # Initial view limits + return (0, 1) + else: + return self.base.nonsingular(vmin, vmax) + + def view_limits(self, vmin, vmax): + vmin, vmax = self.base.view_limits(vmin, vmax) + if self._zero_in_bounds() and vmax > vmin: + # this allows inverted r/y-lims + vmin = min(0, vmin) + return mtransforms.nonsingular(vmin, vmax) + + +class _ThetaShift(mtransforms.ScaledTranslation): + """ + Apply a padding shift based on axes theta limits. + + This is used to create padding for radial ticks. + + Parameters + ---------- + axes : `~matplotlib.axes.Axes` + The owning Axes; used to determine limits. + pad : float + The padding to apply, in points. + mode : {'min', 'max', 'rlabel'} + Whether to shift away from the start (``'min'``) or the end (``'max'``) + of the axes, or using the rlabel position (``'rlabel'``). + """ + def __init__(self, axes, pad, mode): + super().__init__(pad, pad, axes.figure.dpi_scale_trans) + self.set_children(axes._realViewLim) + self.axes = axes + self.mode = mode + self.pad = pad + + __str__ = mtransforms._make_str_method("axes", "pad", "mode") + + def get_matrix(self): + if self._invalid: + if self.mode == 'rlabel': + angle = ( + np.deg2rad(self.axes.get_rlabel_position() + * self.axes.get_theta_direction()) + + self.axes.get_theta_offset() + - np.pi / 2 + ) + elif self.mode == 'min': + angle = self.axes._realViewLim.xmin - np.pi / 2 + elif self.mode == 'max': + angle = self.axes._realViewLim.xmax + np.pi / 2 + self._t = (self.pad * np.cos(angle) / 72, self.pad * np.sin(angle) / 72) + return super().get_matrix() + + +class RadialTick(maxis.YTick): + """ + A radial-axis tick. + + This subclass of `.YTick` provides radial ticks with some small + modification to their re-positioning such that ticks are rotated based on + axes limits. This results in ticks that are correctly perpendicular to + the spine. Labels are also rotated to be perpendicular to the spine, when + 'auto' rotation is enabled. + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.label1.set_rotation_mode('anchor') + self.label2.set_rotation_mode('anchor') + + def _determine_anchor(self, mode, angle, start): + # Note: angle is the (spine angle - 90) because it's used for the tick + # & text setup, so all numbers below are -90 from (normed) spine angle. + if mode == 'auto': + if start: + if -90 <= angle <= 90: + return 'left', 'center' + else: + return 'right', 'center' + else: + if -90 <= angle <= 90: + return 'right', 'center' + else: + return 'left', 'center' + else: + if start: + if angle < -68.5: + return 'center', 'top' + elif angle < -23.5: + return 'left', 'top' + elif angle < 22.5: + return 'left', 'center' + elif angle < 67.5: + return 'left', 'bottom' + elif angle < 112.5: + return 'center', 'bottom' + elif angle < 157.5: + return 'right', 'bottom' + elif angle < 202.5: + return 'right', 'center' + elif angle < 247.5: + return 'right', 'top' + else: + return 'center', 'top' + else: + if angle < -68.5: + return 'center', 'bottom' + elif angle < -23.5: + return 'right', 'bottom' + elif angle < 22.5: + return 'right', 'center' + elif angle < 67.5: + return 'right', 'top' + elif angle < 112.5: + return 'center', 'top' + elif angle < 157.5: + return 'left', 'top' + elif angle < 202.5: + return 'left', 'center' + elif angle < 247.5: + return 'left', 'bottom' + else: + return 'center', 'bottom' + + def update_position(self, loc): + super().update_position(loc) + axes = self.axes + thetamin = axes.get_thetamin() + thetamax = axes.get_thetamax() + direction = axes.get_theta_direction() + offset_rad = axes.get_theta_offset() + offset = np.rad2deg(offset_rad) + full = _is_full_circle_deg(thetamin, thetamax) + + if full: + angle = (axes.get_rlabel_position() * direction + + offset) % 360 - 90 + tick_angle = 0 + else: + angle = (thetamin * direction + offset) % 360 - 90 + if direction > 0: + tick_angle = np.deg2rad(angle) + else: + tick_angle = np.deg2rad(angle + 180) + text_angle = (angle + 90) % 180 - 90 # between -90 and +90. + mode, user_angle = self._labelrotation + if mode == 'auto': + text_angle += user_angle + else: + text_angle = user_angle + + if full: + ha = self.label1.get_horizontalalignment() + va = self.label1.get_verticalalignment() + else: + ha, va = self._determine_anchor(mode, angle, direction > 0) + self.label1.set_horizontalalignment(ha) + self.label1.set_verticalalignment(va) + self.label1.set_rotation(text_angle) + + marker = self.tick1line.get_marker() + if marker == mmarkers.TICKLEFT: + trans = mtransforms.Affine2D().rotate(tick_angle) + elif marker == '_': + trans = mtransforms.Affine2D().rotate(tick_angle + np.pi / 2) + elif marker == mmarkers.TICKRIGHT: + trans = mtransforms.Affine2D().scale(-1, 1).rotate(tick_angle) + else: + # Don't modify custom tick line markers. + trans = self.tick1line._marker._transform + self.tick1line._marker._transform = trans + + if full: + self.label2.set_visible(False) + self.tick2line.set_visible(False) + angle = (thetamax * direction + offset) % 360 - 90 + if direction > 0: + tick_angle = np.deg2rad(angle) + else: + tick_angle = np.deg2rad(angle + 180) + text_angle = (angle + 90) % 180 - 90 # between -90 and +90. + mode, user_angle = self._labelrotation + if mode == 'auto': + text_angle += user_angle + else: + text_angle = user_angle + + ha, va = self._determine_anchor(mode, angle, direction < 0) + self.label2.set_ha(ha) + self.label2.set_va(va) + self.label2.set_rotation(text_angle) + + marker = self.tick2line.get_marker() + if marker == mmarkers.TICKLEFT: + trans = mtransforms.Affine2D().rotate(tick_angle) + elif marker == '_': + trans = mtransforms.Affine2D().rotate(tick_angle + np.pi / 2) + elif marker == mmarkers.TICKRIGHT: + trans = mtransforms.Affine2D().scale(-1, 1).rotate(tick_angle) + else: + # Don't modify custom tick line markers. + trans = self.tick2line._marker._transform + self.tick2line._marker._transform = trans + + +class RadialAxis(maxis.YAxis): + """ + A radial Axis. + + This overrides certain properties of a `.YAxis` to provide special-casing + for a radial axis. + """ + __name__ = 'radialaxis' + axis_name = 'radius' #: Read-only name identifying the axis. + _tick_class = RadialTick + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.sticky_edges.y.append(0) + + def _wrap_locator_formatter(self): + self.set_major_locator(RadialLocator(self.get_major_locator(), + self.axes)) + self.isDefault_majloc = True + + def clear(self): + # docstring inherited + super().clear() + self.set_ticks_position('none') + self._wrap_locator_formatter() + + def _set_scale(self, value, **kwargs): + super()._set_scale(value, **kwargs) + self._wrap_locator_formatter() + + +def _is_full_circle_deg(thetamin, thetamax): + """ + Determine if a wedge (in degrees) spans the full circle. + + The condition is derived from :class:`~matplotlib.patches.Wedge`. + """ + return abs(abs(thetamax - thetamin) - 360.0) < 1e-12 + + +def _is_full_circle_rad(thetamin, thetamax): + """ + Determine if a wedge (in radians) spans the full circle. + + The condition is derived from :class:`~matplotlib.patches.Wedge`. + """ + return abs(abs(thetamax - thetamin) - 2 * np.pi) < 1.74e-14 + + +class _WedgeBbox(mtransforms.Bbox): + """ + Transform (theta, r) wedge Bbox into Axes bounding box. + + Parameters + ---------- + center : (float, float) + Center of the wedge + viewLim : `~matplotlib.transforms.Bbox` + Bbox determining the boundaries of the wedge + originLim : `~matplotlib.transforms.Bbox` + Bbox determining the origin for the wedge, if different from *viewLim* + """ + def __init__(self, center, viewLim, originLim, **kwargs): + super().__init__([[0, 0], [1, 1]], **kwargs) + self._center = center + self._viewLim = viewLim + self._originLim = originLim + self.set_children(viewLim, originLim) + + __str__ = mtransforms._make_str_method("_center", "_viewLim", "_originLim") + + def get_points(self): + # docstring inherited + if self._invalid: + points = self._viewLim.get_points().copy() + # Scale angular limits to work with Wedge. + points[:, 0] *= 180 / np.pi + if points[0, 0] > points[1, 0]: + points[:, 0] = points[::-1, 0] + + # Scale radial limits based on origin radius. + points[:, 1] -= self._originLim.y0 + + # Scale radial limits to match axes limits. + rscale = 0.5 / points[1, 1] + points[:, 1] *= rscale + width = min(points[1, 1] - points[0, 1], 0.5) + + # Generate bounding box for wedge. + wedge = mpatches.Wedge(self._center, points[1, 1], + points[0, 0], points[1, 0], + width=width) + self.update_from_path(wedge.get_path()) + + # Ensure equal aspect ratio. + w, h = self._points[1] - self._points[0] + deltah = max(w - h, 0) / 2 + deltaw = max(h - w, 0) / 2 + self._points += np.array([[-deltaw, -deltah], [deltaw, deltah]]) + + self._invalid = 0 + + return self._points + + +class PolarAxes(Axes): + """ + A polar graph projection, where the input dimensions are *theta*, *r*. + + Theta starts pointing east and goes anti-clockwise. + """ + name = 'polar' + + def __init__(self, *args, + theta_offset=0, theta_direction=1, rlabel_position=22.5, + **kwargs): + # docstring inherited + self._default_theta_offset = theta_offset + self._default_theta_direction = theta_direction + self._default_rlabel_position = np.deg2rad(rlabel_position) + super().__init__(*args, **kwargs) + self.use_sticky_edges = True + self.set_aspect('equal', adjustable='box', anchor='C') + self.clear() + + def clear(self): + # docstring inherited + super().clear() + + self.title.set_y(1.05) + + start = self.spines.get('start', None) + if start: + start.set_visible(False) + end = self.spines.get('end', None) + if end: + end.set_visible(False) + self.set_xlim(0.0, 2 * np.pi) + + self.grid(mpl.rcParams['polaraxes.grid']) + inner = self.spines.get('inner', None) + if inner: + inner.set_visible(False) + + self.set_rorigin(None) + self.set_theta_offset(self._default_theta_offset) + self.set_theta_direction(self._default_theta_direction) + + def _init_axis(self): + # This is moved out of __init__ because non-separable axes don't use it + self.xaxis = ThetaAxis(self, clear=False) + self.yaxis = RadialAxis(self, clear=False) + self.spines['polar'].register_axis(self.yaxis) + + def _set_lim_and_transforms(self): + # A view limit where the minimum radius can be locked if the user + # specifies an alternate origin. + self._originViewLim = mtransforms.LockableBbox(self.viewLim) + + # Handle angular offset and direction. + self._direction = mtransforms.Affine2D() \ + .scale(self._default_theta_direction, 1.0) + self._theta_offset = mtransforms.Affine2D() \ + .translate(self._default_theta_offset, 0.0) + self.transShift = self._direction + self._theta_offset + # A view limit shifted to the correct location after accounting for + # orientation and offset. + self._realViewLim = mtransforms.TransformedBbox(self.viewLim, + self.transShift) + + # Transforms the x and y axis separately by a scale factor + # It is assumed that this part will have non-linear components + self.transScale = mtransforms.TransformWrapper( + mtransforms.IdentityTransform()) + + # Scale view limit into a bbox around the selected wedge. This may be + # smaller than the usual unit axes rectangle if not plotting the full + # circle. + self.axesLim = _WedgeBbox((0.5, 0.5), + self._realViewLim, self._originViewLim) + + # Scale the wedge to fill the axes. + self.transWedge = mtransforms.BboxTransformFrom(self.axesLim) + + # Scale the axes to fill the figure. + self.transAxes = mtransforms.BboxTransformTo(self.bbox) + + # A (possibly non-linear) projection on the (already scaled) + # data. This one is aware of rmin + self.transProjection = self.PolarTransform( + self, + apply_theta_transforms=False, + scale_transform=self.transScale + ) + # Add dependency on rorigin. + self.transProjection.set_children(self._originViewLim) + + # An affine transformation on the data, generally to limit the + # range of the axes + self.transProjectionAffine = self.PolarAffine(self.transScale, + self._originViewLim) + + # The complete data transformation stack -- from data all the + # way to display coordinates + # + # 1. Remove any radial axis scaling (e.g. log scaling) + # 2. Shift data in the theta direction + # 3. Project the data from polar to cartesian values + # (with the origin in the same place) + # 4. Scale and translate the cartesian values to Axes coordinates + # (here the origin is moved to the lower left of the Axes) + # 5. Move and scale to fill the Axes + # 6. Convert from Axes coordinates to Figure coordinates + self.transData = ( + self.transScale + + self.transShift + + self.transProjection + + ( + self.transProjectionAffine + + self.transWedge + + self.transAxes + ) + ) + + # This is the transform for theta-axis ticks. It is + # equivalent to transData, except it always puts r == 0.0 and r == 1.0 + # at the edge of the axis circles. + self._xaxis_transform = ( + mtransforms.blended_transform_factory( + mtransforms.IdentityTransform(), + mtransforms.BboxTransformTo(self.viewLim)) + + self.transData) + # The theta labels are flipped along the radius, so that text 1 is on + # the outside by default. This should work the same as before. + flipr_transform = mtransforms.Affine2D() \ + .translate(0.0, -0.5) \ + .scale(1.0, -1.0) \ + .translate(0.0, 0.5) + self._xaxis_text_transform = flipr_transform + self._xaxis_transform + + # This is the transform for r-axis ticks. It scales the theta + # axis so the gridlines from 0.0 to 1.0, now go from thetamin to + # thetamax. + self._yaxis_transform = ( + mtransforms.blended_transform_factory( + mtransforms.BboxTransformTo(self.viewLim), + mtransforms.IdentityTransform()) + + self.transData) + # The r-axis labels are put at an angle and padded in the r-direction + self._r_label_position = mtransforms.Affine2D() \ + .translate(self._default_rlabel_position, 0.0) + self._yaxis_text_transform = mtransforms.TransformWrapper( + self._r_label_position + self.transData) + + def get_xaxis_transform(self, which='grid'): + _api.check_in_list(['tick1', 'tick2', 'grid'], which=which) + return self._xaxis_transform + + def get_xaxis_text1_transform(self, pad): + return self._xaxis_text_transform, 'center', 'center' + + def get_xaxis_text2_transform(self, pad): + return self._xaxis_text_transform, 'center', 'center' + + def get_yaxis_transform(self, which='grid'): + if which in ('tick1', 'tick2'): + return self._yaxis_text_transform + elif which == 'grid': + return self._yaxis_transform + else: + _api.check_in_list(['tick1', 'tick2', 'grid'], which=which) + + def get_yaxis_text1_transform(self, pad): + thetamin, thetamax = self._realViewLim.intervalx + if _is_full_circle_rad(thetamin, thetamax): + return self._yaxis_text_transform, 'bottom', 'left' + elif self.get_theta_direction() > 0: + halign = 'left' + pad_shift = _ThetaShift(self, pad, 'min') + else: + halign = 'right' + pad_shift = _ThetaShift(self, pad, 'max') + return self._yaxis_text_transform + pad_shift, 'center', halign + + def get_yaxis_text2_transform(self, pad): + if self.get_theta_direction() > 0: + halign = 'right' + pad_shift = _ThetaShift(self, pad, 'max') + else: + halign = 'left' + pad_shift = _ThetaShift(self, pad, 'min') + return self._yaxis_text_transform + pad_shift, 'center', halign + + def draw(self, renderer): + self._unstale_viewLim() + thetamin, thetamax = np.rad2deg(self._realViewLim.intervalx) + if thetamin > thetamax: + thetamin, thetamax = thetamax, thetamin + rmin, rmax = ((self._realViewLim.intervaly - self.get_rorigin()) * + self.get_rsign()) + if isinstance(self.patch, mpatches.Wedge): + # Backwards-compatibility: Any subclassed Axes might override the + # patch to not be the Wedge that PolarAxes uses. + center = self.transWedge.transform((0.5, 0.5)) + self.patch.set_center(center) + self.patch.set_theta1(thetamin) + self.patch.set_theta2(thetamax) + + edge, _ = self.transWedge.transform((1, 0)) + radius = edge - center[0] + width = min(radius * (rmax - rmin) / rmax, radius) + self.patch.set_radius(radius) + self.patch.set_width(width) + + inner_width = radius - width + inner = self.spines.get('inner', None) + if inner: + inner.set_visible(inner_width != 0.0) + + visible = not _is_full_circle_deg(thetamin, thetamax) + # For backwards compatibility, any subclassed Axes might override the + # spines to not include start/end that PolarAxes uses. + start = self.spines.get('start', None) + end = self.spines.get('end', None) + if start: + start.set_visible(visible) + if end: + end.set_visible(visible) + if visible: + yaxis_text_transform = self._yaxis_transform + else: + yaxis_text_transform = self._r_label_position + self.transData + if self._yaxis_text_transform != yaxis_text_transform: + self._yaxis_text_transform.set(yaxis_text_transform) + self.yaxis.reset_ticks() + self.yaxis.set_clip_path(self.patch) + + super().draw(renderer) + + def _gen_axes_patch(self): + return mpatches.Wedge((0.5, 0.5), 0.5, 0.0, 360.0) + + def _gen_axes_spines(self): + spines = { + 'polar': Spine.arc_spine(self, 'top', (0.5, 0.5), 0.5, 0, 360), + 'start': Spine.linear_spine(self, 'left'), + 'end': Spine.linear_spine(self, 'right'), + 'inner': Spine.arc_spine(self, 'bottom', (0.5, 0.5), 0.0, 0, 360), + } + spines['polar'].set_transform(self.transWedge + self.transAxes) + spines['inner'].set_transform(self.transWedge + self.transAxes) + spines['start'].set_transform(self._yaxis_transform) + spines['end'].set_transform(self._yaxis_transform) + return spines + + def set_thetamax(self, thetamax): + """Set the maximum theta limit in degrees.""" + self.viewLim.x1 = np.deg2rad(thetamax) + + def get_thetamax(self): + """Return the maximum theta limit in degrees.""" + return np.rad2deg(self.viewLim.xmax) + + def set_thetamin(self, thetamin): + """Set the minimum theta limit in degrees.""" + self.viewLim.x0 = np.deg2rad(thetamin) + + def get_thetamin(self): + """Get the minimum theta limit in degrees.""" + return np.rad2deg(self.viewLim.xmin) + + def set_thetalim(self, *args, **kwargs): + r""" + Set the minimum and maximum theta values. + + Can take the following signatures: + + - ``set_thetalim(minval, maxval)``: Set the limits in radians. + - ``set_thetalim(thetamin=minval, thetamax=maxval)``: Set the limits + in degrees. + + where minval and maxval are the minimum and maximum limits. Values are + wrapped in to the range :math:`[0, 2\pi]` (in radians), so for example + it is possible to do ``set_thetalim(-np.pi / 2, np.pi / 2)`` to have + an axis symmetric around 0. A ValueError is raised if the absolute + angle difference is larger than a full circle. + """ + orig_lim = self.get_xlim() # in radians + if 'thetamin' in kwargs: + kwargs['xmin'] = np.deg2rad(kwargs.pop('thetamin')) + if 'thetamax' in kwargs: + kwargs['xmax'] = np.deg2rad(kwargs.pop('thetamax')) + new_min, new_max = self.set_xlim(*args, **kwargs) + # Parsing all permutations of *args, **kwargs is tricky; it is simpler + # to let set_xlim() do it and then validate the limits. + if abs(new_max - new_min) > 2 * np.pi: + self.set_xlim(orig_lim) # un-accept the change + raise ValueError("The angle range must be less than a full circle") + return tuple(np.rad2deg((new_min, new_max))) + + def set_theta_offset(self, offset): + """ + Set the offset for the location of 0 in radians. + """ + mtx = self._theta_offset.get_matrix() + mtx[0, 2] = offset + self._theta_offset.invalidate() + + def get_theta_offset(self): + """ + Get the offset for the location of 0 in radians. + """ + return self._theta_offset.get_matrix()[0, 2] + + def set_theta_zero_location(self, loc, offset=0.0): + """ + Set the location of theta's zero. + + This simply calls `set_theta_offset` with the correct value in radians. + + Parameters + ---------- + loc : str + May be one of "N", "NW", "W", "SW", "S", "SE", "E", or "NE". + offset : float, default: 0 + An offset in degrees to apply from the specified *loc*. **Note:** + this offset is *always* applied counter-clockwise regardless of + the direction setting. + """ + mapping = { + 'N': np.pi * 0.5, + 'NW': np.pi * 0.75, + 'W': np.pi, + 'SW': np.pi * 1.25, + 'S': np.pi * 1.5, + 'SE': np.pi * 1.75, + 'E': 0, + 'NE': np.pi * 0.25} + return self.set_theta_offset(mapping[loc] + np.deg2rad(offset)) + + def set_theta_direction(self, direction): + """ + Set the direction in which theta increases. + + clockwise, -1: + Theta increases in the clockwise direction + + counterclockwise, anticlockwise, 1: + Theta increases in the counterclockwise direction + """ + mtx = self._direction.get_matrix() + if direction in ('clockwise', -1): + mtx[0, 0] = -1 + elif direction in ('counterclockwise', 'anticlockwise', 1): + mtx[0, 0] = 1 + else: + _api.check_in_list( + [-1, 1, 'clockwise', 'counterclockwise', 'anticlockwise'], + direction=direction) + self._direction.invalidate() + + def get_theta_direction(self): + """ + Get the direction in which theta increases. + + -1: + Theta increases in the clockwise direction + + 1: + Theta increases in the counterclockwise direction + """ + return self._direction.get_matrix()[0, 0] + + def set_rmax(self, rmax): + """ + Set the outer radial limit. + + Parameters + ---------- + rmax : float + """ + self.viewLim.y1 = rmax + + def get_rmax(self): + """ + Returns + ------- + float + Outer radial limit. + """ + return self.viewLim.ymax + + def set_rmin(self, rmin): + """ + Set the inner radial limit. + + Parameters + ---------- + rmin : float + """ + self.viewLim.y0 = rmin + + def get_rmin(self): + """ + Returns + ------- + float + The inner radial limit. + """ + return self.viewLim.ymin + + def set_rorigin(self, rorigin): + """ + Update the radial origin. + + Parameters + ---------- + rorigin : float + """ + self._originViewLim.locked_y0 = rorigin + + def get_rorigin(self): + """ + Returns + ------- + float + """ + return self._originViewLim.y0 + + def get_rsign(self): + return np.sign(self._originViewLim.y1 - self._originViewLim.y0) + + def set_rlim(self, bottom=None, top=None, *, + emit=True, auto=False, **kwargs): + """ + Set the radial axis view limits. + + This function behaves like `.Axes.set_ylim`, but additionally supports + *rmin* and *rmax* as aliases for *bottom* and *top*. + + See Also + -------- + .Axes.set_ylim + """ + if 'rmin' in kwargs: + if bottom is None: + bottom = kwargs.pop('rmin') + else: + raise ValueError('Cannot supply both positional "bottom"' + 'argument and kwarg "rmin"') + if 'rmax' in kwargs: + if top is None: + top = kwargs.pop('rmax') + else: + raise ValueError('Cannot supply both positional "top"' + 'argument and kwarg "rmax"') + return self.set_ylim(bottom=bottom, top=top, emit=emit, auto=auto, + **kwargs) + + def get_rlabel_position(self): + """ + Returns + ------- + float + The theta position of the radius labels in degrees. + """ + return np.rad2deg(self._r_label_position.get_matrix()[0, 2]) + + def set_rlabel_position(self, value): + """ + Update the theta position of the radius labels. + + Parameters + ---------- + value : number + The angular position of the radius labels in degrees. + """ + self._r_label_position.clear().translate(np.deg2rad(value), 0.0) + + def set_yscale(self, *args, **kwargs): + super().set_yscale(*args, **kwargs) + self.yaxis.set_major_locator( + self.RadialLocator(self.yaxis.get_major_locator(), self)) + + def set_rscale(self, *args, **kwargs): + return Axes.set_yscale(self, *args, **kwargs) + + def set_rticks(self, *args, **kwargs): + return Axes.set_yticks(self, *args, **kwargs) + + def set_thetagrids(self, angles, labels=None, fmt=None, **kwargs): + """ + Set the theta gridlines in a polar plot. + + Parameters + ---------- + angles : tuple with floats, degrees + The angles of the theta gridlines. + + labels : tuple with strings or None + The labels to use at each theta gridline. The + `.projections.polar.ThetaFormatter` will be used if None. + + fmt : str or None + Format string used in `matplotlib.ticker.FormatStrFormatter`. + For example '%f'. Note that the angle that is used is in + radians. + + Returns + ------- + lines : list of `.lines.Line2D` + The theta gridlines. + + labels : list of `.text.Text` + The tick labels. + + Other Parameters + ---------------- + **kwargs + *kwargs* are optional `.Text` properties for the labels. + + .. warning:: + + This only sets the properties of the current ticks. + Ticks are not guaranteed to be persistent. Various operations + can create, delete and modify the Tick instances. There is an + imminent risk that these settings can get lost if you work on + the figure further (including also panning/zooming on a + displayed figure). + + Use `.set_tick_params` instead if possible. + + See Also + -------- + .PolarAxes.set_rgrids + .Axis.get_gridlines + .Axis.get_ticklabels + """ + + # Make sure we take into account unitized data + angles = self.convert_yunits(angles) + angles = np.deg2rad(angles) + self.set_xticks(angles) + if labels is not None: + self.set_xticklabels(labels) + elif fmt is not None: + self.xaxis.set_major_formatter(mticker.FormatStrFormatter(fmt)) + for t in self.xaxis.get_ticklabels(): + t._internal_update(kwargs) + return self.xaxis.get_ticklines(), self.xaxis.get_ticklabels() + + def set_rgrids(self, radii, labels=None, angle=None, fmt=None, **kwargs): + """ + Set the radial gridlines on a polar plot. + + Parameters + ---------- + radii : tuple with floats + The radii for the radial gridlines + + labels : tuple with strings or None + The labels to use at each radial gridline. The + `matplotlib.ticker.ScalarFormatter` will be used if None. + + angle : float + The angular position of the radius labels in degrees. + + fmt : str or None + Format string used in `matplotlib.ticker.FormatStrFormatter`. + For example '%f'. + + Returns + ------- + lines : list of `.lines.Line2D` + The radial gridlines. + + labels : list of `.text.Text` + The tick labels. + + Other Parameters + ---------------- + **kwargs + *kwargs* are optional `.Text` properties for the labels. + + .. warning:: + + This only sets the properties of the current ticks. + Ticks are not guaranteed to be persistent. Various operations + can create, delete and modify the Tick instances. There is an + imminent risk that these settings can get lost if you work on + the figure further (including also panning/zooming on a + displayed figure). + + Use `.set_tick_params` instead if possible. + + See Also + -------- + .PolarAxes.set_thetagrids + .Axis.get_gridlines + .Axis.get_ticklabels + """ + # Make sure we take into account unitized data + radii = self.convert_xunits(radii) + radii = np.asarray(radii) + + self.set_yticks(radii) + if labels is not None: + self.set_yticklabels(labels) + elif fmt is not None: + self.yaxis.set_major_formatter(mticker.FormatStrFormatter(fmt)) + if angle is None: + angle = self.get_rlabel_position() + self.set_rlabel_position(angle) + for t in self.yaxis.get_ticklabels(): + t._internal_update(kwargs) + return self.yaxis.get_gridlines(), self.yaxis.get_ticklabels() + + def format_coord(self, theta, r): + # docstring inherited + screen_xy = self.transData.transform((theta, r)) + screen_xys = screen_xy + np.stack( + np.meshgrid([-1, 0, 1], [-1, 0, 1])).reshape((2, -1)).T + ts, rs = self.transData.inverted().transform(screen_xys).T + delta_t = abs((ts - theta + np.pi) % (2 * np.pi) - np.pi).max() + delta_t_halfturns = delta_t / np.pi + delta_t_degrees = delta_t_halfturns * 180 + delta_r = abs(rs - r).max() + if theta < 0: + theta += 2 * np.pi + theta_halfturns = theta / np.pi + theta_degrees = theta_halfturns * 180 + + # See ScalarFormatter.format_data_short. For r, use #g-formatting + # (as for linear axes), but for theta, use f-formatting as scientific + # notation doesn't make sense and the trailing dot is ugly. + def format_sig(value, delta, opt, fmt): + # For "f", only count digits after decimal point. + prec = (max(0, -math.floor(math.log10(delta))) if fmt == "f" else + cbook._g_sig_digits(value, delta)) + return f"{value:-{opt}.{prec}{fmt}}" + + return ('\N{GREEK SMALL LETTER THETA}={}\N{GREEK SMALL LETTER PI} ' + '({}\N{DEGREE SIGN}), r={}').format( + format_sig(theta_halfturns, delta_t_halfturns, "", "f"), + format_sig(theta_degrees, delta_t_degrees, "", "f"), + format_sig(r, delta_r, "#", "g"), + ) + + def get_data_ratio(self): + """ + Return the aspect ratio of the data itself. For a polar plot, + this should always be 1.0 + """ + return 1.0 + + # # # Interactive panning + + def can_zoom(self): + """ + Return whether this Axes supports the zoom box button functionality. + + A polar Axes does not support zoom boxes. + """ + return False + + def can_pan(self): + """ + Return whether this Axes supports the pan/zoom button functionality. + + For a polar Axes, this is slightly misleading. Both panning and + zooming are performed by the same button. Panning is performed + in azimuth while zooming is done along the radial. + """ + return True + + def start_pan(self, x, y, button): + angle = np.deg2rad(self.get_rlabel_position()) + mode = '' + if button == 1: + epsilon = np.pi / 45.0 + t, r = self.transData.inverted().transform((x, y)) + if angle - epsilon <= t <= angle + epsilon: + mode = 'drag_r_labels' + elif button == 3: + mode = 'zoom' + + self._pan_start = types.SimpleNamespace( + rmax=self.get_rmax(), + trans=self.transData.frozen(), + trans_inverse=self.transData.inverted().frozen(), + r_label_angle=self.get_rlabel_position(), + x=x, + y=y, + mode=mode) + + def end_pan(self): + del self._pan_start + + def drag_pan(self, button, key, x, y): + p = self._pan_start + + if p.mode == 'drag_r_labels': + (startt, startr), (t, r) = p.trans_inverse.transform( + [(p.x, p.y), (x, y)]) + + # Deal with theta + dt = np.rad2deg(startt - t) + self.set_rlabel_position(p.r_label_angle - dt) + + trans, vert1, horiz1 = self.get_yaxis_text1_transform(0.0) + trans, vert2, horiz2 = self.get_yaxis_text2_transform(0.0) + for t in self.yaxis.majorTicks + self.yaxis.minorTicks: + t.label1.set_va(vert1) + t.label1.set_ha(horiz1) + t.label2.set_va(vert2) + t.label2.set_ha(horiz2) + + elif p.mode == 'zoom': + (startt, startr), (t, r) = p.trans_inverse.transform( + [(p.x, p.y), (x, y)]) + + # Deal with r + scale = r / startr + self.set_rmax(p.rmax / scale) + + +# To keep things all self-contained, we can put aliases to the Polar classes +# defined above. This isn't strictly necessary, but it makes some of the +# code more readable, and provides a backwards compatible Polar API. In +# particular, this is used by the :doc:`/gallery/specialty_plots/radar_chart` +# example to override PolarTransform on a PolarAxes subclass, so make sure that +# that example is unaffected before changing this. +PolarAxes.PolarTransform = PolarTransform +PolarAxes.PolarAffine = PolarAffine +PolarAxes.InvertedPolarTransform = InvertedPolarTransform +PolarAxes.ThetaFormatter = ThetaFormatter +PolarAxes.RadialLocator = RadialLocator +PolarAxes.ThetaLocator = ThetaLocator diff --git a/venv/lib/python3.10/site-packages/matplotlib/projections/polar.pyi b/venv/lib/python3.10/site-packages/matplotlib/projections/polar.pyi new file mode 100644 index 00000000..de1cbc29 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/projections/polar.pyi @@ -0,0 +1,197 @@ +import matplotlib.axis as maxis +import matplotlib.ticker as mticker +import matplotlib.transforms as mtransforms +from matplotlib.axes import Axes +from matplotlib.lines import Line2D +from matplotlib.text import Text + +import numpy as np +from numpy.typing import ArrayLike +from collections.abc import Sequence +from typing import Any, ClassVar, Literal, overload + +class PolarTransform(mtransforms.Transform): + input_dims: int + output_dims: int + def __init__( + self, + axis: PolarAxes | None = ..., + use_rmin: bool = ..., + *, + apply_theta_transforms: bool = ..., + scale_transform: mtransforms.Transform | None = ..., + ) -> None: ... + def inverted(self) -> InvertedPolarTransform: ... + +class PolarAffine(mtransforms.Affine2DBase): + def __init__( + self, scale_transform: mtransforms.Transform, limits: mtransforms.BboxBase + ) -> None: ... + +class InvertedPolarTransform(mtransforms.Transform): + input_dims: int + output_dims: int + def __init__( + self, + axis: PolarAxes | None = ..., + use_rmin: bool = ..., + *, + apply_theta_transforms: bool = ..., + ) -> None: ... + def inverted(self) -> PolarTransform: ... + +class ThetaFormatter(mticker.Formatter): ... + +class _AxisWrapper: + def __init__(self, axis: maxis.Axis) -> None: ... + def get_view_interval(self) -> np.ndarray: ... + def set_view_interval(self, vmin: float, vmax: float) -> None: ... + def get_minpos(self) -> float: ... + def get_data_interval(self) -> np.ndarray: ... + def set_data_interval(self, vmin: float, vmax: float) -> None: ... + def get_tick_space(self) -> int: ... + +class ThetaLocator(mticker.Locator): + base: mticker.Locator + axis: _AxisWrapper | None + def __init__(self, base: mticker.Locator) -> None: ... + +class ThetaTick(maxis.XTick): + def __init__(self, axes: PolarAxes, *args, **kwargs) -> None: ... + +class ThetaAxis(maxis.XAxis): + axis_name: str + +class RadialLocator(mticker.Locator): + base: mticker.Locator + def __init__(self, base, axes: PolarAxes | None = ...) -> None: ... + +class RadialTick(maxis.YTick): ... + +class RadialAxis(maxis.YAxis): + axis_name: str + +class _WedgeBbox(mtransforms.Bbox): + def __init__( + self, + center: tuple[float, float], + viewLim: mtransforms.Bbox, + originLim: mtransforms.Bbox, + **kwargs, + ) -> None: ... + +class PolarAxes(Axes): + + PolarTransform: ClassVar[type] = PolarTransform + PolarAffine: ClassVar[type] = PolarAffine + InvertedPolarTransform: ClassVar[type] = InvertedPolarTransform + ThetaFormatter: ClassVar[type] = ThetaFormatter + RadialLocator: ClassVar[type] = RadialLocator + ThetaLocator: ClassVar[type] = ThetaLocator + + name: str + use_sticky_edges: bool + def __init__( + self, + *args, + theta_offset: float = ..., + theta_direction: float = ..., + rlabel_position: float = ..., + **kwargs, + ) -> None: ... + def get_xaxis_transform( + self, which: Literal["tick1", "tick2", "grid"] = ... + ) -> mtransforms.Transform: ... + def get_xaxis_text1_transform( + self, pad: float + ) -> tuple[ + mtransforms.Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_xaxis_text2_transform( + self, pad: float + ) -> tuple[ + mtransforms.Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_yaxis_transform( + self, which: Literal["tick1", "tick2", "grid"] = ... + ) -> mtransforms.Transform: ... + def get_yaxis_text1_transform( + self, pad: float + ) -> tuple[ + mtransforms.Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def get_yaxis_text2_transform( + self, pad: float + ) -> tuple[ + mtransforms.Transform, + Literal["center", "top", "bottom", "baseline", "center_baseline"], + Literal["center", "left", "right"], + ]: ... + def set_thetamax(self, thetamax: float) -> None: ... + def get_thetamax(self) -> float: ... + def set_thetamin(self, thetamin: float) -> None: ... + def get_thetamin(self) -> float: ... + @overload + def set_thetalim(self, minval: float, maxval: float, /) -> tuple[float, float]: ... + @overload + def set_thetalim(self, *, thetamin: float, thetamax: float) -> tuple[float, float]: ... + def set_theta_offset(self, offset: float) -> None: ... + def get_theta_offset(self) -> float: ... + def set_theta_zero_location( + self, + loc: Literal["N", "NW", "W", "SW", "S", "SE", "E", "NE"], + offset: float = ..., + ) -> None: ... + def set_theta_direction( + self, + direction: Literal[-1, 1, "clockwise", "counterclockwise", "anticlockwise"], + ) -> None: ... + def get_theta_direction(self) -> Literal[-1, 1]: ... + def set_rmax(self, rmax: float) -> None: ... + def get_rmax(self) -> float: ... + def set_rmin(self, rmin: float) -> None: ... + def get_rmin(self) -> float: ... + def set_rorigin(self, rorigin: float | None) -> None: ... + def get_rorigin(self) -> float: ... + def get_rsign(self) -> float: ... + def set_rlim( + self, + bottom: float | tuple[float, float] | None = ..., + top: float | None = ..., + *, + emit: bool = ..., + auto: bool = ..., + **kwargs, + ) -> tuple[float, float]: ... + def get_rlabel_position(self) -> float: ... + def set_rlabel_position(self, value: float) -> None: ... + def set_rscale(self, *args, **kwargs) -> None: ... + def set_rticks(self, *args, **kwargs) -> None: ... + def set_thetagrids( + self, + angles: ArrayLike, + labels: Sequence[str | Text] | None = ..., + fmt: str | None = ..., + **kwargs, + ) -> tuple[list[Line2D], list[Text]]: ... + def set_rgrids( + self, + radii: ArrayLike, + labels: Sequence[str | Text] | None = ..., + angle: float | None = ..., + fmt: str | None = ..., + **kwargs, + ) -> tuple[list[Line2D], list[Text]]: ... + def format_coord(self, theta: float, r: float) -> str: ... + def get_data_ratio(self) -> float: ... + def can_zoom(self) -> bool: ... + def can_pan(self) -> bool: ... + def start_pan(self, x: float, y: float, button: int) -> None: ... + def end_pan(self) -> None: ... + def drag_pan(self, button: Any, key: Any, x: float, y: float) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/py.typed b/venv/lib/python3.10/site-packages/matplotlib/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/matplotlib/pylab.py b/venv/lib/python3.10/site-packages/matplotlib/pylab.py new file mode 100644 index 00000000..a50779cf --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/pylab.py @@ -0,0 +1,67 @@ +""" +`pylab` is a historic interface and its use is strongly discouraged. The equivalent +replacement is `matplotlib.pyplot`. See :ref:`api_interfaces` for a full overview +of Matplotlib interfaces. + +`pylab` was designed to support a MATLAB-like way of working with all plotting related +functions directly available in the global namespace. This was achieved through a +wildcard import (``from pylab import *``). + +.. warning:: + The use of `pylab` is discouraged for the following reasons: + + ``from pylab import *`` imports all the functions from `matplotlib.pyplot`, `numpy`, + `numpy.fft`, `numpy.linalg`, and `numpy.random`, and some additional functions into + the global namespace. + + Such a pattern is considered bad practice in modern python, as it clutters the global + namespace. Even more severely, in the case of `pylab`, this will overwrite some + builtin functions (e.g. the builtin `sum` will be replaced by `numpy.sum`), which + can lead to unexpected behavior. + +""" + +from matplotlib.cbook import flatten, silent_list + +import matplotlib as mpl + +from matplotlib.dates import ( + date2num, num2date, datestr2num, drange, DateFormatter, DateLocator, + RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator, + HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR, + SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY, + relativedelta) + +# bring all the symbols in so folks can import them from +# pylab in one fell swoop + +## We are still importing too many things from mlab; more cleanup is needed. + +from matplotlib.mlab import ( + detrend, detrend_linear, detrend_mean, detrend_none, window_hanning, + window_none) + +from matplotlib import cbook, mlab, pyplot as plt +from matplotlib.pyplot import * + +from numpy import * +from numpy.fft import * +from numpy.random import * +from numpy.linalg import * + +import numpy as np +import numpy.ma as ma + +# don't let numpy's datetime hide stdlib +import datetime + +# This is needed, or bytes will be numpy.random.bytes from +# "from numpy.random import *" above +bytes = __import__("builtins").bytes +# We also don't want the numpy version of these functions +abs = __import__("builtins").abs +bool = __import__("builtins").bool +max = __import__("builtins").max +min = __import__("builtins").min +pow = __import__("builtins").pow +round = __import__("builtins").round diff --git a/venv/lib/python3.10/site-packages/matplotlib/pyplot.py b/venv/lib/python3.10/site-packages/matplotlib/pyplot.py new file mode 100644 index 00000000..b1354341 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/pyplot.py @@ -0,0 +1,4511 @@ +# Note: The first part of this file can be modified in place, but the latter +# part is autogenerated by the boilerplate.py script. + +""" +`matplotlib.pyplot` is a state-based interface to matplotlib. It provides +an implicit, MATLAB-like, way of plotting. It also opens figures on your +screen, and acts as the figure GUI manager. + +pyplot is mainly intended for interactive plots and simple cases of +programmatic plot generation:: + + import numpy as np + import matplotlib.pyplot as plt + + x = np.arange(0, 5, 0.1) + y = np.sin(x) + plt.plot(x, y) + +The explicit object-oriented API is recommended for complex plots, though +pyplot is still usually used to create the figure and often the Axes in the +figure. See `.pyplot.figure`, `.pyplot.subplots`, and +`.pyplot.subplot_mosaic` to create figures, and +:doc:`Axes API ` for the plotting methods on an Axes:: + + import numpy as np + import matplotlib.pyplot as plt + + x = np.arange(0, 5, 0.1) + y = np.sin(x) + fig, ax = plt.subplots() + ax.plot(x, y) + + +See :ref:`api_interfaces` for an explanation of the tradeoffs between the +implicit and explicit interfaces. +""" + +# fmt: off + +from __future__ import annotations + +from contextlib import AbstractContextManager, ExitStack +from enum import Enum +import functools +import importlib +import inspect +import logging +import sys +import threading +import time +from typing import TYPE_CHECKING, cast, overload + +from cycler import cycler # noqa: F401 +import matplotlib +import matplotlib.colorbar +import matplotlib.image +from matplotlib import _api +from matplotlib import ( # noqa: F401 Re-exported for typing. + cm as cm, get_backend as get_backend, rcParams as rcParams, style as style) +from matplotlib import _pylab_helpers +from matplotlib import interactive # noqa: F401 +from matplotlib import cbook +from matplotlib import _docstring +from matplotlib.backend_bases import ( + FigureCanvasBase, FigureManagerBase, MouseButton) +from matplotlib.figure import Figure, FigureBase, figaspect +from matplotlib.gridspec import GridSpec, SubplotSpec +from matplotlib import rcsetup, rcParamsDefault, rcParamsOrig +from matplotlib.artist import Artist +from matplotlib.axes import Axes +from matplotlib.axes import Subplot # noqa: F401 +from matplotlib.backends import BackendFilter, backend_registry +from matplotlib.projections import PolarAxes +from matplotlib import mlab # for detrend_none, window_hanning +from matplotlib.scale import get_scale_names # noqa: F401 + +from matplotlib.cm import _colormaps +from matplotlib.colors import _color_sequences, Colormap + +import numpy as np + +if TYPE_CHECKING: + from collections.abc import Callable, Hashable, Iterable, Sequence + import datetime + import pathlib + import os + from typing import Any, BinaryIO, Literal, TypeVar + from typing_extensions import ParamSpec + + import PIL.Image + from numpy.typing import ArrayLike + + from matplotlib.axis import Tick + from matplotlib.axes._base import _AxesBase + from matplotlib.backend_bases import RendererBase, Event + from matplotlib.cm import ScalarMappable + from matplotlib.contour import ContourSet, QuadContourSet + from matplotlib.collections import ( + Collection, + LineCollection, + PolyCollection, + PathCollection, + EventCollection, + QuadMesh, + ) + from matplotlib.colorbar import Colorbar + from matplotlib.container import ( + BarContainer, + ErrorbarContainer, + StemContainer, + ) + from matplotlib.figure import SubFigure + from matplotlib.legend import Legend + from matplotlib.mlab import GaussianKDE + from matplotlib.image import AxesImage, FigureImage + from matplotlib.patches import FancyArrow, StepPatch, Wedge + from matplotlib.quiver import Barbs, Quiver, QuiverKey + from matplotlib.scale import ScaleBase + from matplotlib.transforms import Transform, Bbox + from matplotlib.typing import ColorType, LineStyleType, MarkerType, HashableList + from matplotlib.widgets import SubplotTool + + _P = ParamSpec('_P') + _R = TypeVar('_R') + _T = TypeVar('_T') + + +# We may not need the following imports here: +from matplotlib.colors import Normalize +from matplotlib.lines import Line2D, AxLine +from matplotlib.text import Text, Annotation +from matplotlib.patches import Arrow, Circle, Rectangle # noqa: F401 +from matplotlib.patches import Polygon +from matplotlib.widgets import Button, Slider, Widget # noqa: F401 + +from .ticker import ( # noqa: F401 + TickHelper, Formatter, FixedFormatter, NullFormatter, FuncFormatter, + FormatStrFormatter, ScalarFormatter, LogFormatter, LogFormatterExponent, + LogFormatterMathtext, Locator, IndexLocator, FixedLocator, NullLocator, + LinearLocator, LogLocator, AutoLocator, MultipleLocator, MaxNLocator) + +_log = logging.getLogger(__name__) + + +# Explicit rename instead of import-as for typing's sake. +colormaps = _colormaps +color_sequences = _color_sequences + + +@overload +def _copy_docstring_and_deprecators( + method: Any, + func: Literal[None] = None +) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... + + +@overload +def _copy_docstring_and_deprecators( + method: Any, func: Callable[_P, _R]) -> Callable[_P, _R]: ... + + +def _copy_docstring_and_deprecators( + method: Any, + func: Callable[_P, _R] | None = None +) -> Callable[[Callable[_P, _R]], Callable[_P, _R]] | Callable[_P, _R]: + if func is None: + return cast('Callable[[Callable[_P, _R]], Callable[_P, _R]]', + functools.partial(_copy_docstring_and_deprecators, method)) + decorators: list[Callable[[Callable[_P, _R]], Callable[_P, _R]]] = [ + _docstring.copy(method) + ] + # Check whether the definition of *method* includes @_api.rename_parameter + # or @_api.make_keyword_only decorators; if so, propagate them to the + # pyplot wrapper as well. + while hasattr(method, "__wrapped__"): + potential_decorator = _api.deprecation.DECORATORS.get(method) + if potential_decorator: + decorators.append(potential_decorator) + method = method.__wrapped__ + for decorator in decorators[::-1]: + func = decorator(func) + _add_pyplot_note(func, method) + return func + + +_NO_PYPLOT_NOTE = [ + 'FigureBase._gci', # wrapped_func is private + '_AxesBase._sci', # wrapped_func is private + 'Artist.findobj', # not a standard pyplot wrapper because it does not operate + # on the current Figure / Axes. Explanation of relation would + # be more complex and is not too important. +] + + +def _add_pyplot_note(func, wrapped_func): + """ + Add a note to the docstring of *func* that it is a pyplot wrapper. + + The note is added to the "Notes" section of the docstring. If that does + not exist, a "Notes" section is created. In numpydoc, the "Notes" + section is the third last possible section, only potentially followed by + "References" and "Examples". + """ + if not func.__doc__: + return # nothing to do + + qualname = wrapped_func.__qualname__ + if qualname in _NO_PYPLOT_NOTE: + return + + wrapped_func_is_method = True + if "." not in qualname: + # method qualnames are prefixed by the class and ".", e.g. "Axes.plot" + wrapped_func_is_method = False + link = f"{wrapped_func.__module__}.{qualname}" + elif qualname.startswith("Axes."): # e.g. "Axes.plot" + link = ".axes." + qualname + elif qualname.startswith("_AxesBase."): # e.g. "_AxesBase.set_xlabel" + link = ".axes.Axes" + qualname[9:] + elif qualname.startswith("Figure."): # e.g. "Figure.figimage" + link = "." + qualname + elif qualname.startswith("FigureBase."): # e.g. "FigureBase.gca" + link = ".Figure" + qualname[10:] + elif qualname.startswith("FigureCanvasBase."): # "FigureBaseCanvas.mpl_connect" + link = "." + qualname + else: + raise RuntimeError(f"Wrapped method from unexpected class: {qualname}") + + if wrapped_func_is_method: + message = f"This is the :ref:`pyplot wrapper ` for `{link}`." + else: + message = f"This is equivalent to `{link}`." + + # Find the correct insert position: + # - either we already have a "Notes" section into which we can insert + # - or we create one before the next present section. Note that in numpydoc, the + # "Notes" section is the third last possible section, only potentially followed + # by "References" and "Examples". + # - or we append a new "Notes" section at the end. + doc = inspect.cleandoc(func.__doc__) + if "\nNotes\n-----" in doc: + before, after = doc.split("\nNotes\n-----", 1) + elif (index := doc.find("\nReferences\n----------")) != -1: + before, after = doc[:index], doc[index:] + elif (index := doc.find("\nExamples\n--------")) != -1: + before, after = doc[:index], doc[index:] + else: + # No "Notes", "References", or "Examples" --> append to the end. + before = doc + "\n" + after = "" + + func.__doc__ = f"{before}\nNotes\n-----\n\n.. note::\n\n {message}\n{after}" + + +## Global ## + + +# The state controlled by {,un}install_repl_displayhook(). +_ReplDisplayHook = Enum("_ReplDisplayHook", ["NONE", "PLAIN", "IPYTHON"]) +_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE + + +def _draw_all_if_interactive() -> None: + if matplotlib.is_interactive(): + draw_all() + + +def install_repl_displayhook() -> None: + """ + Connect to the display hook of the current shell. + + The display hook gets called when the read-evaluate-print-loop (REPL) of + the shell has finished the execution of a command. We use this callback + to be able to automatically update a figure in interactive mode. + + This works both with IPython and with vanilla python shells. + """ + global _REPL_DISPLAYHOOK + + if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON: + return + + # See if we have IPython hooks around, if so use them. + # Use ``sys.modules.get(name)`` rather than ``name in sys.modules`` as + # entries can also have been explicitly set to None. + mod_ipython = sys.modules.get("IPython") + if not mod_ipython: + _REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN + return + ip = mod_ipython.get_ipython() + if not ip: + _REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN + return + + ip.events.register("post_execute", _draw_all_if_interactive) + _REPL_DISPLAYHOOK = _ReplDisplayHook.IPYTHON + + if mod_ipython.version_info[:2] < (8, 24): + # Use of backend2gui is not needed for IPython >= 8.24 as that functionality + # has been moved to Matplotlib. + # This code can be removed when Python 3.12, the latest version supported by + # IPython < 8.24, reaches end-of-life in late 2028. + from IPython.core.pylabtools import backend2gui + # trigger IPython's eventloop integration, if available + ipython_gui_name = backend2gui.get(get_backend()) + if ipython_gui_name: + ip.enable_gui(ipython_gui_name) + + +def uninstall_repl_displayhook() -> None: + """Disconnect from the display hook of the current shell.""" + global _REPL_DISPLAYHOOK + if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON: + from IPython import get_ipython + ip = get_ipython() + ip.events.unregister("post_execute", _draw_all_if_interactive) + _REPL_DISPLAYHOOK = _ReplDisplayHook.NONE + + +draw_all = _pylab_helpers.Gcf.draw_all + + +# Ensure this appears in the pyplot docs. +@_copy_docstring_and_deprecators(matplotlib.set_loglevel) +def set_loglevel(*args, **kwargs) -> None: + return matplotlib.set_loglevel(*args, **kwargs) + + +@_copy_docstring_and_deprecators(Artist.findobj) +def findobj( + o: Artist | None = None, + match: Callable[[Artist], bool] | type[Artist] | None = None, + include_self: bool = True +) -> list[Artist]: + if o is None: + o = gcf() + return o.findobj(match, include_self=include_self) + + +_backend_mod: type[matplotlib.backend_bases._Backend] | None = None + + +def _get_backend_mod() -> type[matplotlib.backend_bases._Backend]: + """ + Ensure that a backend is selected and return it. + + This is currently private, but may be made public in the future. + """ + if _backend_mod is None: + # Use rcParams._get("backend") to avoid going through the fallback + # logic (which will (re)import pyplot and then call switch_backend if + # we need to resolve the auto sentinel) + switch_backend(rcParams._get("backend")) + return cast(type[matplotlib.backend_bases._Backend], _backend_mod) + + +def switch_backend(newbackend: str) -> None: + """ + Set the pyplot backend. + + Switching to an interactive backend is possible only if no event loop for + another interactive backend has started. Switching to and from + non-interactive backends is always possible. + + If the new backend is different than the current backend then all open + Figures will be closed via ``plt.close('all')``. + + Parameters + ---------- + newbackend : str + The case-insensitive name of the backend to use. + + """ + global _backend_mod + # make sure the init is pulled up so we can assign to it later + import matplotlib.backends + + if newbackend is rcsetup._auto_backend_sentinel: + current_framework = cbook._get_running_interactive_framework() + + if (current_framework and + (backend := backend_registry.backend_for_gui_framework( + current_framework))): + candidates = [backend] + else: + candidates = [] + candidates += [ + "macosx", "qtagg", "gtk4agg", "gtk3agg", "tkagg", "wxagg"] + + # Don't try to fallback on the cairo-based backends as they each have + # an additional dependency (pycairo) over the agg-based backend, and + # are of worse quality. + for candidate in candidates: + try: + switch_backend(candidate) + except ImportError: + continue + else: + rcParamsOrig['backend'] = candidate + return + else: + # Switching to Agg should always succeed; if it doesn't, let the + # exception propagate out. + switch_backend("agg") + rcParamsOrig["backend"] = "agg" + return + # have to escape the switch on access logic + old_backend = dict.__getitem__(rcParams, 'backend') + + module = backend_registry.load_backend_module(newbackend) + canvas_class = module.FigureCanvas + + required_framework = canvas_class.required_interactive_framework + if required_framework is not None: + current_framework = cbook._get_running_interactive_framework() + if (current_framework and required_framework + and current_framework != required_framework): + raise ImportError( + "Cannot load backend {!r} which requires the {!r} interactive " + "framework, as {!r} is currently running".format( + newbackend, required_framework, current_framework)) + + # Load the new_figure_manager() and show() functions from the backend. + + # Classically, backends can directly export these functions. This should + # keep working for backcompat. + new_figure_manager = getattr(module, "new_figure_manager", None) + show = getattr(module, "show", None) + + # In that classical approach, backends are implemented as modules, but + # "inherit" default method implementations from backend_bases._Backend. + # This is achieved by creating a "class" that inherits from + # backend_bases._Backend and whose body is filled with the module globals. + class backend_mod(matplotlib.backend_bases._Backend): + locals().update(vars(module)) + + # However, the newer approach for defining new_figure_manager and + # show is to derive them from canvas methods. In that case, also + # update backend_mod accordingly; also, per-backend customization of + # draw_if_interactive is disabled. + if new_figure_manager is None: + + def new_figure_manager_given_figure(num, figure): + return canvas_class.new_manager(figure, num) + + def new_figure_manager(num, *args, FigureClass=Figure, **kwargs): + fig = FigureClass(*args, **kwargs) + return new_figure_manager_given_figure(num, fig) + + def draw_if_interactive() -> None: + if matplotlib.is_interactive(): + manager = _pylab_helpers.Gcf.get_active() + if manager: + manager.canvas.draw_idle() + + backend_mod.new_figure_manager_given_figure = ( # type: ignore[method-assign] + new_figure_manager_given_figure) + backend_mod.new_figure_manager = ( # type: ignore[method-assign] + new_figure_manager) + backend_mod.draw_if_interactive = ( # type: ignore[method-assign] + draw_if_interactive) + + # If the manager explicitly overrides pyplot_show, use it even if a global + # show is already present, as the latter may be here for backcompat. + manager_class = getattr(canvas_class, "manager_class", None) + # We can't compare directly manager_class.pyplot_show and FMB.pyplot_show because + # pyplot_show is a classmethod so the above constructs are bound classmethods, and + # thus always different (being bound to different classes). We also have to use + # getattr_static instead of vars as manager_class could have no __dict__. + manager_pyplot_show = inspect.getattr_static(manager_class, "pyplot_show", None) + base_pyplot_show = inspect.getattr_static(FigureManagerBase, "pyplot_show", None) + if (show is None + or (manager_pyplot_show is not None + and manager_pyplot_show != base_pyplot_show)): + if not manager_pyplot_show: + raise ValueError( + f"Backend {newbackend} defines neither FigureCanvas.manager_class nor " + f"a toplevel show function") + _pyplot_show = cast('Any', manager_class).pyplot_show + backend_mod.show = _pyplot_show # type: ignore[method-assign] + + _log.debug("Loaded backend %s version %s.", + newbackend, backend_mod.backend_version) + + if newbackend in ("ipympl", "widget"): + # ipympl < 0.9.4 expects rcParams["backend"] to be the fully-qualified backend + # name "module://ipympl.backend_nbagg" not short names "ipympl" or "widget". + import importlib.metadata as im + from matplotlib import _parse_to_version_info # type: ignore[attr-defined] + try: + module_version = im.version("ipympl") + if _parse_to_version_info(module_version) < (0, 9, 4): + newbackend = "module://ipympl.backend_nbagg" + except im.PackageNotFoundError: + pass + + rcParams['backend'] = rcParamsDefault['backend'] = newbackend + _backend_mod = backend_mod + for func_name in ["new_figure_manager", "draw_if_interactive", "show"]: + globals()[func_name].__signature__ = inspect.signature( + getattr(backend_mod, func_name)) + + # Need to keep a global reference to the backend for compatibility reasons. + # See https://github.com/matplotlib/matplotlib/issues/6092 + matplotlib.backends.backend = newbackend # type: ignore[attr-defined] + + if not cbook._str_equal(old_backend, newbackend): + if get_fignums(): + _api.warn_deprecated("3.8", message=( + "Auto-close()ing of figures upon backend switching is deprecated since " + "%(since)s and will be removed %(removal)s. To suppress this warning, " + "explicitly call plt.close('all') first.")) + close("all") + + # Make sure the repl display hook is installed in case we become interactive. + install_repl_displayhook() + + +def _warn_if_gui_out_of_main_thread() -> None: + warn = False + canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas) + if canvas_class.required_interactive_framework: + if hasattr(threading, 'get_native_id'): + # This compares native thread ids because even if Python-level + # Thread objects match, the underlying OS thread (which is what + # really matters) may be different on Python implementations with + # green threads. + if threading.get_native_id() != threading.main_thread().native_id: + warn = True + else: + # Fall back to Python-level Thread if native IDs are unavailable, + # mainly for PyPy. + if threading.current_thread() is not threading.main_thread(): + warn = True + if warn: + _api.warn_external( + "Starting a Matplotlib GUI outside of the main thread will likely " + "fail.") + + +# This function's signature is rewritten upon backend-load by switch_backend. +def new_figure_manager(*args, **kwargs): + """Create a new figure manager instance.""" + _warn_if_gui_out_of_main_thread() + return _get_backend_mod().new_figure_manager(*args, **kwargs) + + +# This function's signature is rewritten upon backend-load by switch_backend. +def draw_if_interactive(*args, **kwargs): + """ + Redraw the current figure if in interactive mode. + + .. warning:: + + End users will typically not have to call this function because the + the interactive mode takes care of this. + """ + return _get_backend_mod().draw_if_interactive(*args, **kwargs) + + +# This function's signature is rewritten upon backend-load by switch_backend. +def show(*args, **kwargs) -> None: + """ + Display all open figures. + + Parameters + ---------- + block : bool, optional + Whether to wait for all figures to be closed before returning. + + If `True` block and run the GUI main loop until all figure windows + are closed. + + If `False` ensure that all figure windows are displayed and return + immediately. In this case, you are responsible for ensuring + that the event loop is running to have responsive figures. + + Defaults to True in non-interactive mode and to False in interactive + mode (see `.pyplot.isinteractive`). + + See Also + -------- + ion : Enable interactive mode, which shows / updates the figure after + every plotting command, so that calling ``show()`` is not necessary. + ioff : Disable interactive mode. + savefig : Save the figure to an image file instead of showing it on screen. + + Notes + ----- + **Saving figures to file and showing a window at the same time** + + If you want an image file as well as a user interface window, use + `.pyplot.savefig` before `.pyplot.show`. At the end of (a blocking) + ``show()`` the figure is closed and thus unregistered from pyplot. Calling + `.pyplot.savefig` afterwards would save a new and thus empty figure. This + limitation of command order does not apply if the show is non-blocking or + if you keep a reference to the figure and use `.Figure.savefig`. + + **Auto-show in jupyter notebooks** + + The jupyter backends (activated via ``%matplotlib inline``, + ``%matplotlib notebook``, or ``%matplotlib widget``), call ``show()`` at + the end of every cell by default. Thus, you usually don't have to call it + explicitly there. + """ + _warn_if_gui_out_of_main_thread() + return _get_backend_mod().show(*args, **kwargs) + + +def isinteractive() -> bool: + """ + Return whether plots are updated after every plotting command. + + The interactive mode is mainly useful if you build plots from the command + line and want to see the effect of each command while you are building the + figure. + + In interactive mode: + + - newly created figures will be shown immediately; + - figures will automatically redraw on change; + - `.pyplot.show` will not block by default. + + In non-interactive mode: + + - newly created figures and changes to figures will not be reflected until + explicitly asked to be; + - `.pyplot.show` will block by default. + + See Also + -------- + ion : Enable interactive mode. + ioff : Disable interactive mode. + show : Show all figures (and maybe block). + pause : Show all figures, and block for a time. + """ + return matplotlib.is_interactive() + + +# Note: The return type of ioff being AbstractContextManager +# instead of ExitStack is deliberate. +# See https://github.com/matplotlib/matplotlib/issues/27659 +# and https://github.com/matplotlib/matplotlib/pull/27667 for more info. +def ioff() -> AbstractContextManager: + """ + Disable interactive mode. + + See `.pyplot.isinteractive` for more details. + + See Also + -------- + ion : Enable interactive mode. + isinteractive : Whether interactive mode is enabled. + show : Show all figures (and maybe block). + pause : Show all figures, and block for a time. + + Notes + ----- + For a temporary change, this can be used as a context manager:: + + # if interactive mode is on + # then figures will be shown on creation + plt.ion() + # This figure will be shown immediately + fig = plt.figure() + + with plt.ioff(): + # interactive mode will be off + # figures will not automatically be shown + fig2 = plt.figure() + # ... + + To enable optional usage as a context manager, this function returns a + context manager object, which is not intended to be stored or + accessed by the user. + """ + stack = ExitStack() + stack.callback(ion if isinteractive() else ioff) + matplotlib.interactive(False) + uninstall_repl_displayhook() + return stack + + +# Note: The return type of ion being AbstractContextManager +# instead of ExitStack is deliberate. +# See https://github.com/matplotlib/matplotlib/issues/27659 +# and https://github.com/matplotlib/matplotlib/pull/27667 for more info. +def ion() -> AbstractContextManager: + """ + Enable interactive mode. + + See `.pyplot.isinteractive` for more details. + + See Also + -------- + ioff : Disable interactive mode. + isinteractive : Whether interactive mode is enabled. + show : Show all figures (and maybe block). + pause : Show all figures, and block for a time. + + Notes + ----- + For a temporary change, this can be used as a context manager:: + + # if interactive mode is off + # then figures will not be shown on creation + plt.ioff() + # This figure will not be shown immediately + fig = plt.figure() + + with plt.ion(): + # interactive mode will be on + # figures will automatically be shown + fig2 = plt.figure() + # ... + + To enable optional usage as a context manager, this function returns a + context manager object, which is not intended to be stored or + accessed by the user. + """ + stack = ExitStack() + stack.callback(ion if isinteractive() else ioff) + matplotlib.interactive(True) + install_repl_displayhook() + return stack + + +def pause(interval: float) -> None: + """ + Run the GUI event loop for *interval* seconds. + + If there is an active figure, it will be updated and displayed before the + pause, and the GUI event loop (if any) will run during the pause. + + This can be used for crude animation. For more complex animation use + :mod:`matplotlib.animation`. + + If there is no active figure, sleep for *interval* seconds instead. + + See Also + -------- + matplotlib.animation : Proper animations + show : Show all figures and optional block until all figures are closed. + """ + manager = _pylab_helpers.Gcf.get_active() + if manager is not None: + canvas = manager.canvas + if canvas.figure.stale: + canvas.draw_idle() + show(block=False) + canvas.start_event_loop(interval) + else: + time.sleep(interval) + + +@_copy_docstring_and_deprecators(matplotlib.rc) +def rc(group: str, **kwargs) -> None: + matplotlib.rc(group, **kwargs) + + +@_copy_docstring_and_deprecators(matplotlib.rc_context) +def rc_context( + rc: dict[str, Any] | None = None, + fname: str | pathlib.Path | os.PathLike | None = None, +) -> AbstractContextManager[None]: + return matplotlib.rc_context(rc, fname) + + +@_copy_docstring_and_deprecators(matplotlib.rcdefaults) +def rcdefaults() -> None: + matplotlib.rcdefaults() + if matplotlib.is_interactive(): + draw_all() + + +# getp/get/setp are explicitly reexported so that they show up in pyplot docs. + + +@_copy_docstring_and_deprecators(matplotlib.artist.getp) +def getp(obj, *args, **kwargs): + return matplotlib.artist.getp(obj, *args, **kwargs) + + +@_copy_docstring_and_deprecators(matplotlib.artist.get) +def get(obj, *args, **kwargs): + return matplotlib.artist.get(obj, *args, **kwargs) + + +@_copy_docstring_and_deprecators(matplotlib.artist.setp) +def setp(obj, *args, **kwargs): + return matplotlib.artist.setp(obj, *args, **kwargs) + + +def xkcd( + scale: float = 1, length: float = 100, randomness: float = 2 +) -> ExitStack: + """ + Turn on `xkcd `_ sketch-style drawing mode. + + This will only have an effect on things drawn after this function is called. + + For best results, install the `xkcd script `_ + font; xkcd fonts are not packaged with Matplotlib. + + Parameters + ---------- + scale : float, optional + The amplitude of the wiggle perpendicular to the source line. + length : float, optional + The length of the wiggle along the line. + randomness : float, optional + The scale factor by which the length is shrunken or expanded. + + Notes + ----- + This function works by a number of rcParams, so it will probably + override others you have set before. + + If you want the effects of this function to be temporary, it can + be used as a context manager, for example:: + + with plt.xkcd(): + # This figure will be in XKCD-style + fig1 = plt.figure() + # ... + + # This figure will be in regular style + fig2 = plt.figure() + """ + # This cannot be implemented in terms of contextmanager() or rc_context() + # because this needs to work as a non-contextmanager too. + + if rcParams['text.usetex']: + raise RuntimeError( + "xkcd mode is not compatible with text.usetex = True") + + stack = ExitStack() + stack.callback(dict.update, rcParams, rcParams.copy()) # type: ignore[arg-type] + + from matplotlib import patheffects + rcParams.update({ + 'font.family': ['xkcd', 'xkcd Script', 'Comic Neue', 'Comic Sans MS'], + 'font.size': 14.0, + 'path.sketch': (scale, length, randomness), + 'path.effects': [ + patheffects.withStroke(linewidth=4, foreground="w")], + 'axes.linewidth': 1.5, + 'lines.linewidth': 2.0, + 'figure.facecolor': 'white', + 'grid.linewidth': 0.0, + 'axes.grid': False, + 'axes.unicode_minus': False, + 'axes.edgecolor': 'black', + 'xtick.major.size': 8, + 'xtick.major.width': 3, + 'ytick.major.size': 8, + 'ytick.major.width': 3, + }) + + return stack + + +## Figures ## + +def figure( + # autoincrement if None, else integer from 1-N + num: int | str | Figure | SubFigure | None = None, + # defaults to rc figure.figsize + figsize: tuple[float, float] | None = None, + # defaults to rc figure.dpi + dpi: float | None = None, + *, + # defaults to rc figure.facecolor + facecolor: ColorType | None = None, + # defaults to rc figure.edgecolor + edgecolor: ColorType | None = None, + frameon: bool = True, + FigureClass: type[Figure] = Figure, + clear: bool = False, + **kwargs +) -> Figure: + """ + Create a new figure, or activate an existing figure. + + Parameters + ---------- + num : int or str or `.Figure` or `.SubFigure`, optional + A unique identifier for the figure. + + If a figure with that identifier already exists, this figure is made + active and returned. An integer refers to the ``Figure.number`` + attribute, a string refers to the figure label. + + If there is no figure with the identifier or *num* is not given, a new + figure is created, made active and returned. If *num* is an int, it + will be used for the ``Figure.number`` attribute, otherwise, an + auto-generated integer value is used (starting at 1 and incremented + for each new figure). If *num* is a string, the figure label and the + window title is set to this value. If num is a ``SubFigure``, its + parent ``Figure`` is activated. + + figsize : (float, float), default: :rc:`figure.figsize` + Width, height in inches. + + dpi : float, default: :rc:`figure.dpi` + The resolution of the figure in dots-per-inch. + + facecolor : :mpltype:`color`, default: :rc:`figure.facecolor` + The background color. + + edgecolor : :mpltype:`color`, default: :rc:`figure.edgecolor` + The border color. + + frameon : bool, default: True + If False, suppress drawing the figure frame. + + FigureClass : subclass of `~matplotlib.figure.Figure` + If set, an instance of this subclass will be created, rather than a + plain `.Figure`. + + clear : bool, default: False + If True and the figure already exists, then it is cleared. + + layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \ +default: None + The layout mechanism for positioning of plot elements to avoid + overlapping Axes decorations (labels, ticks, etc). Note that layout + managers can measurably slow down figure display. + + - 'constrained': The constrained layout solver adjusts Axes sizes + to avoid overlapping Axes decorations. Can handle complex plot + layouts and colorbars, and is thus recommended. + + See :ref:`constrainedlayout_guide` + for examples. + + - 'compressed': uses the same algorithm as 'constrained', but + removes extra space between fixed-aspect-ratio Axes. Best for + simple grids of Axes. + + - 'tight': Use the tight layout mechanism. This is a relatively + simple algorithm that adjusts the subplot parameters so that + decorations do not overlap. See `.Figure.set_tight_layout` for + further details. + + - 'none': Do not use a layout engine. + + - A `.LayoutEngine` instance. Builtin layout classes are + `.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily + accessible by 'constrained' and 'tight'. Passing an instance + allows third parties to provide their own layout engine. + + If not given, fall back to using the parameters *tight_layout* and + *constrained_layout*, including their config defaults + :rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`. + + **kwargs + Additional keyword arguments are passed to the `.Figure` constructor. + + Returns + ------- + `~matplotlib.figure.Figure` + + Notes + ----- + A newly created figure is passed to the `~.FigureCanvasBase.new_manager` + method or the `new_figure_manager` function provided by the current + backend, which install a canvas and a manager on the figure. + + Once this is done, :rc:`figure.hooks` are called, one at a time, on the + figure; these hooks allow arbitrary customization of the figure (e.g., + attaching callbacks) or of associated elements (e.g., modifying the + toolbar). See :doc:`/gallery/user_interfaces/mplcvd` for an example of + toolbar customization. + + If you are creating many figures, make sure you explicitly call + `.pyplot.close` on the figures you are not using, because this will + enable pyplot to properly clean up the memory. + + `~matplotlib.rcParams` defines the default values, which can be modified + in the matplotlibrc file. + """ + if isinstance(num, FigureBase): + # type narrowed to `Figure | SubFigure` by combination of input and isinstance + if num.canvas.manager is None: + raise ValueError("The passed figure is not managed by pyplot") + _pylab_helpers.Gcf.set_active(num.canvas.manager) + return num.figure + + allnums = get_fignums() + next_num = max(allnums) + 1 if allnums else 1 + fig_label = '' + if num is None: + num = next_num + elif isinstance(num, str): + fig_label = num + all_labels = get_figlabels() + if fig_label not in all_labels: + if fig_label == 'all': + _api.warn_external("close('all') closes all existing figures.") + num = next_num + else: + inum = all_labels.index(fig_label) + num = allnums[inum] + else: + num = int(num) # crude validation of num argument + + # Type of "num" has narrowed to int, but mypy can't quite see it + manager = _pylab_helpers.Gcf.get_fig_manager(num) # type: ignore[arg-type] + if manager is None: + max_open_warning = rcParams['figure.max_open_warning'] + if len(allnums) == max_open_warning >= 1: + _api.warn_external( + f"More than {max_open_warning} figures have been opened. " + f"Figures created through the pyplot interface " + f"(`matplotlib.pyplot.figure`) are retained until explicitly " + f"closed and may consume too much memory. (To control this " + f"warning, see the rcParam `figure.max_open_warning`). " + f"Consider using `matplotlib.pyplot.close()`.", + RuntimeWarning) + + manager = new_figure_manager( + num, figsize=figsize, dpi=dpi, + facecolor=facecolor, edgecolor=edgecolor, frameon=frameon, + FigureClass=FigureClass, **kwargs) + fig = manager.canvas.figure + if fig_label: + fig.set_label(fig_label) + + for hookspecs in rcParams["figure.hooks"]: + module_name, dotted_name = hookspecs.split(":") + obj: Any = importlib.import_module(module_name) + for part in dotted_name.split("."): + obj = getattr(obj, part) + obj(fig) + + _pylab_helpers.Gcf._set_new_active_manager(manager) + + # make sure backends (inline) that we don't ship that expect this + # to be called in plotting commands to make the figure call show + # still work. There is probably a better way to do this in the + # FigureManager base class. + draw_if_interactive() + + if _REPL_DISPLAYHOOK is _ReplDisplayHook.PLAIN: + fig.stale_callback = _auto_draw_if_interactive + + if clear: + manager.canvas.figure.clear() + + return manager.canvas.figure + + +def _auto_draw_if_interactive(fig, val): + """ + An internal helper function for making sure that auto-redrawing + works as intended in the plain python repl. + + Parameters + ---------- + fig : Figure + A figure object which is assumed to be associated with a canvas + """ + if (val and matplotlib.is_interactive() + and not fig.canvas.is_saving() + and not fig.canvas._is_idle_drawing): + # Some artists can mark themselves as stale in the middle of drawing + # (e.g. axes position & tick labels being computed at draw time), but + # this shouldn't trigger a redraw because the current redraw will + # already take them into account. + with fig.canvas._idle_draw_cntx(): + fig.canvas.draw_idle() + + +def gcf() -> Figure: + """ + Get the current figure. + + If there is currently no figure on the pyplot figure stack, a new one is + created using `~.pyplot.figure()`. (To test whether there is currently a + figure on the pyplot figure stack, check whether `~.pyplot.get_fignums()` + is empty.) + """ + manager = _pylab_helpers.Gcf.get_active() + if manager is not None: + return manager.canvas.figure + else: + return figure() + + +def fignum_exists(num: int | str) -> bool: + """ + Return whether the figure with the given id exists. + + Parameters + ---------- + num : int or str + A figure identifier. + + Returns + ------- + bool + Whether or not a figure with id *num* exists. + """ + return ( + _pylab_helpers.Gcf.has_fignum(num) + if isinstance(num, int) + else num in get_figlabels() + ) + + +def get_fignums() -> list[int]: + """Return a list of existing figure numbers.""" + return sorted(_pylab_helpers.Gcf.figs) + + +def get_figlabels() -> list[Any]: + """Return a list of existing figure labels.""" + managers = _pylab_helpers.Gcf.get_all_fig_managers() + managers.sort(key=lambda m: m.num) + return [m.canvas.figure.get_label() for m in managers] + + +def get_current_fig_manager() -> FigureManagerBase | None: + """ + Return the figure manager of the current figure. + + The figure manager is a container for the actual backend-depended window + that displays the figure on screen. + + If no current figure exists, a new one is created, and its figure + manager is returned. + + Returns + ------- + `.FigureManagerBase` or backend-dependent subclass thereof + """ + return gcf().canvas.manager + + +@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_connect) +def connect(s: str, func: Callable[[Event], Any]) -> int: + return gcf().canvas.mpl_connect(s, func) + + +@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_disconnect) +def disconnect(cid: int) -> None: + gcf().canvas.mpl_disconnect(cid) + + +def close(fig: None | int | str | Figure | Literal["all"] = None) -> None: + """ + Close a figure window. + + Parameters + ---------- + fig : None or int or str or `.Figure` + The figure to close. There are a number of ways to specify this: + + - *None*: the current figure + - `.Figure`: the given `.Figure` instance + - ``int``: a figure number + - ``str``: a figure name + - 'all': all figures + + """ + if fig is None: + manager = _pylab_helpers.Gcf.get_active() + if manager is None: + return + else: + _pylab_helpers.Gcf.destroy(manager) + elif fig == 'all': + _pylab_helpers.Gcf.destroy_all() + elif isinstance(fig, int): + _pylab_helpers.Gcf.destroy(fig) + elif hasattr(fig, 'int'): + # if we are dealing with a type UUID, we + # can use its integer representation + _pylab_helpers.Gcf.destroy(fig.int) + elif isinstance(fig, str): + all_labels = get_figlabels() + if fig in all_labels: + num = get_fignums()[all_labels.index(fig)] + _pylab_helpers.Gcf.destroy(num) + elif isinstance(fig, Figure): + _pylab_helpers.Gcf.destroy_fig(fig) + else: + raise TypeError("close() argument must be a Figure, an int, a string, " + "or None, not %s" % type(fig)) + + +def clf() -> None: + """Clear the current figure.""" + gcf().clear() + + +def draw() -> None: + """ + Redraw the current figure. + + This is used to update a figure that has been altered, but not + automatically re-drawn. If interactive mode is on (via `.ion()`), this + should be only rarely needed, but there may be ways to modify the state of + a figure without marking it as "stale". Please report these cases as bugs. + + This is equivalent to calling ``fig.canvas.draw_idle()``, where ``fig`` is + the current figure. + + See Also + -------- + .FigureCanvasBase.draw_idle + .FigureCanvasBase.draw + """ + gcf().canvas.draw_idle() + + +@_copy_docstring_and_deprecators(Figure.savefig) +def savefig(*args, **kwargs) -> None: + fig = gcf() + # savefig default implementation has no return, so mypy is unhappy + # presumably this is here because subclasses can return? + res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value] + fig.canvas.draw_idle() # Need this if 'transparent=True', to reset colors. + return res + + +## Putting things in figures ## + + +def figlegend(*args, **kwargs) -> Legend: + return gcf().legend(*args, **kwargs) +if Figure.legend.__doc__: + figlegend.__doc__ = Figure.legend.__doc__ \ + .replace(" legend(", " figlegend(") \ + .replace("fig.legend(", "plt.figlegend(") \ + .replace("ax.plot(", "plt.plot(") + + +## Axes ## + +@_docstring.dedent_interpd +def axes( + arg: None | tuple[float, float, float, float] = None, + **kwargs +) -> matplotlib.axes.Axes: + """ + Add an Axes to the current figure and make it the current Axes. + + Call signatures:: + + plt.axes() + plt.axes(rect, projection=None, polar=False, **kwargs) + plt.axes(ax) + + Parameters + ---------- + arg : None or 4-tuple + The exact behavior of this function depends on the type: + + - *None*: A new full window Axes is added using + ``subplot(**kwargs)``. + - 4-tuple of floats *rect* = ``(left, bottom, width, height)``. + A new Axes is added with dimensions *rect* in normalized + (0, 1) units using `~.Figure.add_axes` on the current figure. + + projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \ +'polar', 'rectilinear', str}, optional + The projection type of the `~.axes.Axes`. *str* is the name of + a custom projection, see `~matplotlib.projections`. The default + None results in a 'rectilinear' projection. + + polar : bool, default: False + If True, equivalent to projection='polar'. + + sharex, sharey : `~matplotlib.axes.Axes`, optional + Share the x or y `~matplotlib.axis` with sharex and/or sharey. + The axis will have the same limits, ticks, and scale as the axis + of the shared Axes. + + label : str + A label for the returned Axes. + + Returns + ------- + `~.axes.Axes`, or a subclass of `~.axes.Axes` + The returned Axes class depends on the projection used. It is + `~.axes.Axes` if rectilinear projection is used and + `.projections.polar.PolarAxes` if polar projection is used. + + Other Parameters + ---------------- + **kwargs + This method also takes the keyword arguments for + the returned Axes class. The keyword arguments for the + rectilinear Axes class `~.axes.Axes` can be found in + the following table but there might also be other keyword + arguments if another projection is used, see the actual Axes + class. + + %(Axes:kwdoc)s + + See Also + -------- + .Figure.add_axes + .pyplot.subplot + .Figure.add_subplot + .Figure.subplots + .pyplot.subplots + + Examples + -------- + :: + + # Creating a new full window Axes + plt.axes() + + # Creating a new Axes with specified dimensions and a grey background + plt.axes((left, bottom, width, height), facecolor='grey') + """ + fig = gcf() + pos = kwargs.pop('position', None) + if arg is None: + if pos is None: + return fig.add_subplot(**kwargs) + else: + return fig.add_axes(pos, **kwargs) + else: + return fig.add_axes(arg, **kwargs) + + +def delaxes(ax: matplotlib.axes.Axes | None = None) -> None: + """ + Remove an `~.axes.Axes` (defaulting to the current Axes) from its figure. + """ + if ax is None: + ax = gca() + ax.remove() + + +def sca(ax: Axes) -> None: + """ + Set the current Axes to *ax* and the current Figure to the parent of *ax*. + """ + # Mypy sees ax.figure as potentially None, + # but if you are calling this, it won't be None + # Additionally the slight difference between `Figure` and `FigureBase` mypy catches + figure(ax.figure) # type: ignore[arg-type] + ax.figure.sca(ax) # type: ignore[union-attr] + + +def cla() -> None: + """Clear the current Axes.""" + # Not generated via boilerplate.py to allow a different docstring. + return gca().cla() + + +## More ways of creating Axes ## + +@_docstring.dedent_interpd +def subplot(*args, **kwargs) -> Axes: + """ + Add an Axes to the current figure or retrieve an existing Axes. + + This is a wrapper of `.Figure.add_subplot` which provides additional + behavior when working with the implicit API (see the notes section). + + Call signatures:: + + subplot(nrows, ncols, index, **kwargs) + subplot(pos, **kwargs) + subplot(**kwargs) + subplot(ax) + + Parameters + ---------- + *args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1) + The position of the subplot described by one of + + - Three integers (*nrows*, *ncols*, *index*). The subplot will take the + *index* position on a grid with *nrows* rows and *ncols* columns. + *index* starts at 1 in the upper left corner and increases to the + right. *index* can also be a two-tuple specifying the (*first*, + *last*) indices (1-based, and including *last*) of the subplot, e.g., + ``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the + upper 2/3 of the figure. + - A 3-digit integer. The digits are interpreted as if given separately + as three single-digit integers, i.e. ``fig.add_subplot(235)`` is the + same as ``fig.add_subplot(2, 3, 5)``. Note that this can only be used + if there are no more than 9 subplots. + - A `.SubplotSpec`. + + projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \ +'polar', 'rectilinear', str}, optional + The projection type of the subplot (`~.axes.Axes`). *str* is the name + of a custom projection, see `~matplotlib.projections`. The default + None results in a 'rectilinear' projection. + + polar : bool, default: False + If True, equivalent to projection='polar'. + + sharex, sharey : `~matplotlib.axes.Axes`, optional + Share the x or y `~matplotlib.axis` with sharex and/or sharey. The + axis will have the same limits, ticks, and scale as the axis of the + shared Axes. + + label : str + A label for the returned Axes. + + Returns + ------- + `~.axes.Axes` + + The Axes of the subplot. The returned Axes can actually be an instance + of a subclass, such as `.projections.polar.PolarAxes` for polar + projections. + + Other Parameters + ---------------- + **kwargs + This method also takes the keyword arguments for the returned Axes + base class; except for the *figure* argument. The keyword arguments + for the rectilinear base class `~.axes.Axes` can be found in + the following table but there might also be other keyword + arguments if another projection is used. + + %(Axes:kwdoc)s + + Notes + ----- + Creating a new Axes will delete any preexisting Axes that + overlaps with it beyond sharing a boundary:: + + import matplotlib.pyplot as plt + # plot a line, implicitly creating a subplot(111) + plt.plot([1, 2, 3]) + # now create a subplot which represents the top plot of a grid + # with 2 rows and 1 column. Since this subplot will overlap the + # first, the plot (and its Axes) previously created, will be removed + plt.subplot(211) + + If you do not want this behavior, use the `.Figure.add_subplot` method + or the `.pyplot.axes` function instead. + + If no *kwargs* are passed and there exists an Axes in the location + specified by *args* then that Axes will be returned rather than a new + Axes being created. + + If *kwargs* are passed and there exists an Axes in the location + specified by *args*, the projection type is the same, and the + *kwargs* match with the existing Axes, then the existing Axes is + returned. Otherwise a new Axes is created with the specified + parameters. We save a reference to the *kwargs* which we use + for this comparison. If any of the values in *kwargs* are + mutable we will not detect the case where they are mutated. + In these cases we suggest using `.Figure.add_subplot` and the + explicit Axes API rather than the implicit pyplot API. + + See Also + -------- + .Figure.add_subplot + .pyplot.subplots + .pyplot.axes + .Figure.subplots + + Examples + -------- + :: + + plt.subplot(221) + + # equivalent but more general + ax1 = plt.subplot(2, 2, 1) + + # add a subplot with no frame + ax2 = plt.subplot(222, frameon=False) + + # add a polar subplot + plt.subplot(223, projection='polar') + + # add a red subplot that shares the x-axis with ax1 + plt.subplot(224, sharex=ax1, facecolor='red') + + # delete ax2 from the figure + plt.delaxes(ax2) + + # add ax2 to the figure again + plt.subplot(ax2) + + # make the first Axes "current" again + plt.subplot(221) + + """ + # Here we will only normalize `polar=True` vs `projection='polar'` and let + # downstream code deal with the rest. + unset = object() + projection = kwargs.get('projection', unset) + polar = kwargs.pop('polar', unset) + if polar is not unset and polar: + # if we got mixed messages from the user, raise + if projection is not unset and projection != 'polar': + raise ValueError( + f"polar={polar}, yet projection={projection!r}. " + "Only one of these arguments should be supplied." + ) + kwargs['projection'] = projection = 'polar' + + # if subplot called without arguments, create subplot(1, 1, 1) + if len(args) == 0: + args = (1, 1, 1) + + # This check was added because it is very easy to type subplot(1, 2, False) + # when subplots(1, 2, False) was intended (sharex=False, that is). In most + # cases, no error will ever occur, but mysterious behavior can result + # because what was intended to be the sharex argument is instead treated as + # a subplot index for subplot() + if len(args) >= 3 and isinstance(args[2], bool): + _api.warn_external("The subplot index argument to subplot() appears " + "to be a boolean. Did you intend to use " + "subplots()?") + # Check for nrows and ncols, which are not valid subplot args: + if 'nrows' in kwargs or 'ncols' in kwargs: + raise TypeError("subplot() got an unexpected keyword argument 'ncols' " + "and/or 'nrows'. Did you intend to call subplots()?") + + fig = gcf() + + # First, search for an existing subplot with a matching spec. + key = SubplotSpec._from_subplot_args(fig, args) + + for ax in fig.axes: + # If we found an Axes at the position, we can reuse it if the user passed no + # kwargs or if the Axes class and kwargs are identical. + if (ax.get_subplotspec() == key + and (kwargs == {} + or (ax._projection_init + == fig._process_projection_requirements(**kwargs)))): + break + else: + # we have exhausted the known Axes and none match, make a new one! + ax = fig.add_subplot(*args, **kwargs) + + fig.sca(ax) + + return ax + + +def subplots( + nrows: int = 1, ncols: int = 1, *, + sharex: bool | Literal["none", "all", "row", "col"] = False, + sharey: bool | Literal["none", "all", "row", "col"] = False, + squeeze: bool = True, + width_ratios: Sequence[float] | None = None, + height_ratios: Sequence[float] | None = None, + subplot_kw: dict[str, Any] | None = None, + gridspec_kw: dict[str, Any] | None = None, + **fig_kw +) -> tuple[Figure, Any]: + """ + Create a figure and a set of subplots. + + This utility wrapper makes it convenient to create common layouts of + subplots, including the enclosing figure object, in a single call. + + Parameters + ---------- + nrows, ncols : int, default: 1 + Number of rows/columns of the subplot grid. + + sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False + Controls sharing of properties among x (*sharex*) or y (*sharey*) + axes: + + - True or 'all': x- or y-axis will be shared among all subplots. + - False or 'none': each subplot x- or y-axis will be independent. + - 'row': each subplot row will share an x- or y-axis. + - 'col': each subplot column will share an x- or y-axis. + + When subplots have a shared x-axis along a column, only the x tick + labels of the bottom subplot are created. Similarly, when subplots + have a shared y-axis along a row, only the y tick labels of the first + column subplot are created. To later turn other subplots' ticklabels + on, use `~matplotlib.axes.Axes.tick_params`. + + When subplots have a shared axis that has units, calling + `~matplotlib.axis.Axis.set_units` will update each axis with the + new units. + + squeeze : bool, default: True + - If True, extra dimensions are squeezed out from the returned + array of `~matplotlib.axes.Axes`: + + - if only one subplot is constructed (nrows=ncols=1), the + resulting single Axes object is returned as a scalar. + - for Nx1 or 1xM subplots, the returned object is a 1D numpy + object array of Axes objects. + - for NxM, subplots with N>1 and M>1 are returned as a 2D array. + + - If False, no squeezing at all is done: the returned Axes object is + always a 2D array containing Axes instances, even if it ends up + being 1x1. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. Equivalent + to ``gridspec_kw={'width_ratios': [...]}``. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. Convenience + for ``gridspec_kw={'height_ratios': [...]}``. + + subplot_kw : dict, optional + Dict with keywords passed to the + `~matplotlib.figure.Figure.add_subplot` call used to create each + subplot. + + gridspec_kw : dict, optional + Dict with keywords passed to the `~matplotlib.gridspec.GridSpec` + constructor used to create the grid the subplots are placed on. + + **fig_kw + All additional keyword arguments are passed to the + `.pyplot.figure` call. + + Returns + ------- + fig : `.Figure` + + ax : `~matplotlib.axes.Axes` or array of Axes + *ax* can be either a single `~.axes.Axes` object, or an array of Axes + objects if more than one subplot was created. The dimensions of the + resulting array can be controlled with the squeeze keyword, see above. + + Typical idioms for handling the return value are:: + + # using the variable ax for single a Axes + fig, ax = plt.subplots() + + # using the variable axs for multiple Axes + fig, axs = plt.subplots(2, 2) + + # using tuple unpacking for multiple Axes + fig, (ax1, ax2) = plt.subplots(1, 2) + fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) + + The names ``ax`` and pluralized ``axs`` are preferred over ``axes`` + because for the latter it's not clear if it refers to a single + `~.axes.Axes` instance or a collection of these. + + See Also + -------- + .pyplot.figure + .pyplot.subplot + .pyplot.axes + .Figure.subplots + .Figure.add_subplot + + Examples + -------- + :: + + # First create some toy data: + x = np.linspace(0, 2*np.pi, 400) + y = np.sin(x**2) + + # Create just a figure and only one subplot + fig, ax = plt.subplots() + ax.plot(x, y) + ax.set_title('Simple plot') + + # Create two subplots and unpack the output array immediately + f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) + ax1.plot(x, y) + ax1.set_title('Sharing Y axis') + ax2.scatter(x, y) + + # Create four polar Axes and access them through the returned array + fig, axs = plt.subplots(2, 2, subplot_kw=dict(projection="polar")) + axs[0, 0].plot(x, y) + axs[1, 1].scatter(x, y) + + # Share a X axis with each column of subplots + plt.subplots(2, 2, sharex='col') + + # Share a Y axis with each row of subplots + plt.subplots(2, 2, sharey='row') + + # Share both X and Y axes with all subplots + plt.subplots(2, 2, sharex='all', sharey='all') + + # Note that this is the same as + plt.subplots(2, 2, sharex=True, sharey=True) + + # Create figure number 10 with a single subplot + # and clears it if it already exists. + fig, ax = plt.subplots(num=10, clear=True) + + """ + fig = figure(**fig_kw) + axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey, + squeeze=squeeze, subplot_kw=subplot_kw, + gridspec_kw=gridspec_kw, height_ratios=height_ratios, + width_ratios=width_ratios) + return fig, axs + + +@overload +def subplot_mosaic( + mosaic: str, + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: str = ..., + subplot_kw: dict[str, Any] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ..., + **fig_kw: Any +) -> tuple[Figure, dict[str, matplotlib.axes.Axes]]: ... + + +@overload +def subplot_mosaic( + mosaic: list[HashableList[_T]], + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: _T = ..., + subplot_kw: dict[str, Any] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ..., + **fig_kw: Any +) -> tuple[Figure, dict[_T, matplotlib.axes.Axes]]: ... + + +@overload +def subplot_mosaic( + mosaic: list[HashableList[Hashable]], + *, + sharex: bool = ..., + sharey: bool = ..., + width_ratios: ArrayLike | None = ..., + height_ratios: ArrayLike | None = ..., + empty_sentinel: Any = ..., + subplot_kw: dict[str, Any] | None = ..., + gridspec_kw: dict[str, Any] | None = ..., + per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ..., + **fig_kw: Any +) -> tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]: ... + + +def subplot_mosaic( + mosaic: str | list[HashableList[_T]] | list[HashableList[Hashable]], + *, + sharex: bool = False, + sharey: bool = False, + width_ratios: ArrayLike | None = None, + height_ratios: ArrayLike | None = None, + empty_sentinel: Any = '.', + subplot_kw: dict[str, Any] | None = None, + gridspec_kw: dict[str, Any] | None = None, + per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | + dict[_T | tuple[_T, ...], dict[str, Any]] | + dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = None, + **fig_kw: Any +) -> tuple[Figure, dict[str, matplotlib.axes.Axes]] | \ + tuple[Figure, dict[_T, matplotlib.axes.Axes]] | \ + tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]: + """ + Build a layout of Axes based on ASCII art or nested lists. + + This is a helper function to build complex GridSpec layouts visually. + + See :ref:`mosaic` + for an example and full API documentation + + Parameters + ---------- + mosaic : list of list of {hashable or nested} or str + + A visual layout of how you want your Axes to be arranged + labeled as strings. For example :: + + x = [['A panel', 'A panel', 'edge'], + ['C panel', '.', 'edge']] + + produces 4 Axes: + + - 'A panel' which is 1 row high and spans the first two columns + - 'edge' which is 2 rows high and is on the right edge + - 'C panel' which in 1 row and 1 column wide in the bottom left + - a blank space 1 row and 1 column wide in the bottom center + + Any of the entries in the layout can be a list of lists + of the same form to create nested layouts. + + If input is a str, then it must be of the form :: + + ''' + AAE + C.E + ''' + + where each character is a column and each line is a row. + This only allows only single character Axes labels and does + not allow nesting but is very terse. + + sharex, sharey : bool, default: False + If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared + among all subplots. In that case, tick label visibility and axis units + behave as for `subplots`. If False, each subplot's x- or y-axis will + be independent. + + width_ratios : array-like of length *ncols*, optional + Defines the relative widths of the columns. Each column gets a + relative width of ``width_ratios[i] / sum(width_ratios)``. + If not given, all columns will have the same width. Convenience + for ``gridspec_kw={'width_ratios': [...]}``. + + height_ratios : array-like of length *nrows*, optional + Defines the relative heights of the rows. Each row gets a + relative height of ``height_ratios[i] / sum(height_ratios)``. + If not given, all rows will have the same height. Convenience + for ``gridspec_kw={'height_ratios': [...]}``. + + empty_sentinel : object, optional + Entry in the layout to mean "leave this space empty". Defaults + to ``'.'``. Note, if *layout* is a string, it is processed via + `inspect.cleandoc` to remove leading white space, which may + interfere with using white-space as the empty sentinel. + + subplot_kw : dict, optional + Dictionary with keywords passed to the `.Figure.add_subplot` call + used to create each subplot. These values may be overridden by + values in *per_subplot_kw*. + + per_subplot_kw : dict, optional + A dictionary mapping the Axes identifiers or tuples of identifiers + to a dictionary of keyword arguments to be passed to the + `.Figure.add_subplot` call used to create each subplot. The values + in these dictionaries have precedence over the values in + *subplot_kw*. + + If *mosaic* is a string, and thus all keys are single characters, + it is possible to use a single string instead of a tuple as keys; + i.e. ``"AB"`` is equivalent to ``("A", "B")``. + + .. versionadded:: 3.7 + + gridspec_kw : dict, optional + Dictionary with keywords passed to the `.GridSpec` constructor used + to create the grid the subplots are placed on. + + **fig_kw + All additional keyword arguments are passed to the + `.pyplot.figure` call. + + Returns + ------- + fig : `.Figure` + The new figure + + dict[label, Axes] + A dictionary mapping the labels to the Axes objects. The order of + the Axes is left-to-right and top-to-bottom of their position in the + total layout. + + """ + fig = figure(**fig_kw) + ax_dict = fig.subplot_mosaic( # type: ignore[misc] + mosaic, # type: ignore[arg-type] + sharex=sharex, sharey=sharey, + height_ratios=height_ratios, width_ratios=width_ratios, + subplot_kw=subplot_kw, gridspec_kw=gridspec_kw, + empty_sentinel=empty_sentinel, + per_subplot_kw=per_subplot_kw, # type: ignore[arg-type] + ) + return fig, ax_dict + + +def subplot2grid( + shape: tuple[int, int], loc: tuple[int, int], + rowspan: int = 1, colspan: int = 1, + fig: Figure | None = None, + **kwargs +) -> matplotlib.axes.Axes: + """ + Create a subplot at a specific location inside a regular grid. + + Parameters + ---------- + shape : (int, int) + Number of rows and of columns of the grid in which to place axis. + loc : (int, int) + Row number and column number of the axis location within the grid. + rowspan : int, default: 1 + Number of rows for the axis to span downwards. + colspan : int, default: 1 + Number of columns for the axis to span to the right. + fig : `.Figure`, optional + Figure to place the subplot in. Defaults to the current figure. + **kwargs + Additional keyword arguments are handed to `~.Figure.add_subplot`. + + Returns + ------- + `~.axes.Axes` + + The Axes of the subplot. The returned Axes can actually be an instance + of a subclass, such as `.projections.polar.PolarAxes` for polar + projections. + + Notes + ----- + The following call :: + + ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan) + + is identical to :: + + fig = gcf() + gs = fig.add_gridspec(nrows, ncols) + ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan]) + """ + if fig is None: + fig = gcf() + rows, cols = shape + gs = GridSpec._check_gridspec_exists(fig, rows, cols) + subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan) + return fig.add_subplot(subplotspec, **kwargs) + + +def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase: + """ + Make and return a second Axes that shares the *x*-axis. The new Axes will + overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be + on the right. + + Examples + -------- + :doc:`/gallery/subplots_axes_and_figures/two_scales` + """ + if ax is None: + ax = gca() + ax1 = ax.twinx() + return ax1 + + +def twiny(ax: matplotlib.axes.Axes | None = None) -> _AxesBase: + """ + Make and return a second Axes that shares the *y*-axis. The new Axes will + overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be + on the top. + + Examples + -------- + :doc:`/gallery/subplots_axes_and_figures/two_scales` + """ + if ax is None: + ax = gca() + ax1 = ax.twiny() + return ax1 + + +def subplot_tool(targetfig: Figure | None = None) -> SubplotTool | None: + """ + Launch a subplot tool window for a figure. + + Returns + ------- + `matplotlib.widgets.SubplotTool` + """ + if targetfig is None: + targetfig = gcf() + tb = targetfig.canvas.manager.toolbar # type: ignore[union-attr] + if hasattr(tb, "configure_subplots"): # toolbar2 + from matplotlib.backend_bases import NavigationToolbar2 + return cast(NavigationToolbar2, tb).configure_subplots() + elif hasattr(tb, "trigger_tool"): # toolmanager + from matplotlib.backend_bases import ToolContainerBase + cast(ToolContainerBase, tb).trigger_tool("subplots") + return None + else: + raise ValueError("subplot_tool can only be launched for figures with " + "an associated toolbar") + + +def box(on: bool | None = None) -> None: + """ + Turn the Axes box on or off on the current Axes. + + Parameters + ---------- + on : bool or None + The new `~matplotlib.axes.Axes` box state. If ``None``, toggle + the state. + + See Also + -------- + :meth:`matplotlib.axes.Axes.set_frame_on` + :meth:`matplotlib.axes.Axes.get_frame_on` + """ + ax = gca() + if on is None: + on = not ax.get_frame_on() + ax.set_frame_on(on) + +## Axis ## + + +def xlim(*args, **kwargs) -> tuple[float, float]: + """ + Get or set the x limits of the current Axes. + + Call signatures:: + + left, right = xlim() # return the current xlim + xlim((left, right)) # set the xlim to left, right + xlim(left, right) # set the xlim to left, right + + If you do not specify args, you can pass *left* or *right* as kwargs, + i.e.:: + + xlim(right=3) # adjust the right leaving left unchanged + xlim(left=1) # adjust the left leaving right unchanged + + Setting limits turns autoscaling off for the x-axis. + + Returns + ------- + left, right + A tuple of the new x-axis limits. + + Notes + ----- + Calling this function with no arguments (e.g. ``xlim()``) is the pyplot + equivalent of calling `~.Axes.get_xlim` on the current Axes. + Calling this function with arguments is the pyplot equivalent of calling + `~.Axes.set_xlim` on the current Axes. All arguments are passed though. + """ + ax = gca() + if not args and not kwargs: + return ax.get_xlim() + ret = ax.set_xlim(*args, **kwargs) + return ret + + +def ylim(*args, **kwargs) -> tuple[float, float]: + """ + Get or set the y-limits of the current Axes. + + Call signatures:: + + bottom, top = ylim() # return the current ylim + ylim((bottom, top)) # set the ylim to bottom, top + ylim(bottom, top) # set the ylim to bottom, top + + If you do not specify args, you can alternatively pass *bottom* or + *top* as kwargs, i.e.:: + + ylim(top=3) # adjust the top leaving bottom unchanged + ylim(bottom=1) # adjust the bottom leaving top unchanged + + Setting limits turns autoscaling off for the y-axis. + + Returns + ------- + bottom, top + A tuple of the new y-axis limits. + + Notes + ----- + Calling this function with no arguments (e.g. ``ylim()``) is the pyplot + equivalent of calling `~.Axes.get_ylim` on the current Axes. + Calling this function with arguments is the pyplot equivalent of calling + `~.Axes.set_ylim` on the current Axes. All arguments are passed though. + """ + ax = gca() + if not args and not kwargs: + return ax.get_ylim() + ret = ax.set_ylim(*args, **kwargs) + return ret + + +def xticks( + ticks: ArrayLike | None = None, + labels: Sequence[str] | None = None, + *, + minor: bool = False, + **kwargs +) -> tuple[list[Tick] | np.ndarray, list[Text]]: + """ + Get or set the current tick locations and labels of the x-axis. + + Pass no arguments to return the current values without modifying them. + + Parameters + ---------- + ticks : array-like, optional + The list of xtick locations. Passing an empty list removes all xticks. + labels : array-like, optional + The labels to place at the given *ticks* locations. This argument can + only be passed if *ticks* is passed as well. + minor : bool, default: False + If ``False``, get/set the major ticks/labels; if ``True``, the minor + ticks/labels. + **kwargs + `.Text` properties can be used to control the appearance of the labels. + + Returns + ------- + locs + The list of xtick locations. + labels + The list of xlabel `.Text` objects. + + Notes + ----- + Calling this function with no arguments (e.g. ``xticks()``) is the pyplot + equivalent of calling `~.Axes.get_xticks` and `~.Axes.get_xticklabels` on + the current Axes. + Calling this function with arguments is the pyplot equivalent of calling + `~.Axes.set_xticks` and `~.Axes.set_xticklabels` on the current Axes. + + Examples + -------- + >>> locs, labels = xticks() # Get the current locations and labels. + >>> xticks(np.arange(0, 1, step=0.2)) # Set label locations. + >>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels. + >>> xticks([0, 1, 2], ['January', 'February', 'March'], + ... rotation=20) # Set text labels and properties. + >>> xticks([]) # Disable xticks. + """ + ax = gca() + + locs: list[Tick] | np.ndarray + if ticks is None: + locs = ax.get_xticks(minor=minor) + if labels is not None: + raise TypeError("xticks(): Parameter 'labels' can't be set " + "without setting 'ticks'") + else: + locs = ax.set_xticks(ticks, minor=minor) + + labels_out: list[Text] = [] + if labels is None: + labels_out = ax.get_xticklabels(minor=minor) + for l in labels_out: + l._internal_update(kwargs) + else: + labels_out = ax.set_xticklabels(labels, minor=minor, **kwargs) + + return locs, labels_out + + +def yticks( + ticks: ArrayLike | None = None, + labels: Sequence[str] | None = None, + *, + minor: bool = False, + **kwargs +) -> tuple[list[Tick] | np.ndarray, list[Text]]: + """ + Get or set the current tick locations and labels of the y-axis. + + Pass no arguments to return the current values without modifying them. + + Parameters + ---------- + ticks : array-like, optional + The list of ytick locations. Passing an empty list removes all yticks. + labels : array-like, optional + The labels to place at the given *ticks* locations. This argument can + only be passed if *ticks* is passed as well. + minor : bool, default: False + If ``False``, get/set the major ticks/labels; if ``True``, the minor + ticks/labels. + **kwargs + `.Text` properties can be used to control the appearance of the labels. + + Returns + ------- + locs + The list of ytick locations. + labels + The list of ylabel `.Text` objects. + + Notes + ----- + Calling this function with no arguments (e.g. ``yticks()``) is the pyplot + equivalent of calling `~.Axes.get_yticks` and `~.Axes.get_yticklabels` on + the current Axes. + Calling this function with arguments is the pyplot equivalent of calling + `~.Axes.set_yticks` and `~.Axes.set_yticklabels` on the current Axes. + + Examples + -------- + >>> locs, labels = yticks() # Get the current locations and labels. + >>> yticks(np.arange(0, 1, step=0.2)) # Set label locations. + >>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels. + >>> yticks([0, 1, 2], ['January', 'February', 'March'], + ... rotation=45) # Set text labels and properties. + >>> yticks([]) # Disable yticks. + """ + ax = gca() + + locs: list[Tick] | np.ndarray + if ticks is None: + locs = ax.get_yticks(minor=minor) + if labels is not None: + raise TypeError("yticks(): Parameter 'labels' can't be set " + "without setting 'ticks'") + else: + locs = ax.set_yticks(ticks, minor=minor) + + labels_out: list[Text] = [] + if labels is None: + labels_out = ax.get_yticklabels(minor=minor) + for l in labels_out: + l._internal_update(kwargs) + else: + labels_out = ax.set_yticklabels(labels, minor=minor, **kwargs) + + return locs, labels_out + + +def rgrids( + radii: ArrayLike | None = None, + labels: Sequence[str | Text] | None = None, + angle: float | None = None, + fmt: str | None = None, + **kwargs +) -> tuple[list[Line2D], list[Text]]: + """ + Get or set the radial gridlines on the current polar plot. + + Call signatures:: + + lines, labels = rgrids() + lines, labels = rgrids(radii, labels=None, angle=22.5, fmt=None, **kwargs) + + When called with no arguments, `.rgrids` simply returns the tuple + (*lines*, *labels*). When called with arguments, the labels will + appear at the specified radial distances and angle. + + Parameters + ---------- + radii : tuple with floats + The radii for the radial gridlines + + labels : tuple with strings or None + The labels to use at each radial gridline. The + `matplotlib.ticker.ScalarFormatter` will be used if None. + + angle : float + The angular position of the radius labels in degrees. + + fmt : str or None + Format string used in `matplotlib.ticker.FormatStrFormatter`. + For example '%f'. + + Returns + ------- + lines : list of `.lines.Line2D` + The radial gridlines. + + labels : list of `.text.Text` + The tick labels. + + Other Parameters + ---------------- + **kwargs + *kwargs* are optional `.Text` properties for the labels. + + See Also + -------- + .pyplot.thetagrids + .projections.polar.PolarAxes.set_rgrids + .Axis.get_gridlines + .Axis.get_ticklabels + + Examples + -------- + :: + + # set the locations of the radial gridlines + lines, labels = rgrids( (0.25, 0.5, 1.0) ) + + # set the locations and labels of the radial gridlines + lines, labels = rgrids( (0.25, 0.5, 1.0), ('Tom', 'Dick', 'Harry' )) + """ + ax = gca() + if not isinstance(ax, PolarAxes): + raise RuntimeError('rgrids only defined for polar Axes') + if all(p is None for p in [radii, labels, angle, fmt]) and not kwargs: + lines_out: list[Line2D] = ax.yaxis.get_gridlines() + labels_out: list[Text] = ax.yaxis.get_ticklabels() + elif radii is None: + raise TypeError("'radii' cannot be None when other parameters are passed") + else: + lines_out, labels_out = ax.set_rgrids( + radii, labels=labels, angle=angle, fmt=fmt, **kwargs) + return lines_out, labels_out + + +def thetagrids( + angles: ArrayLike | None = None, + labels: Sequence[str | Text] | None = None, + fmt: str | None = None, + **kwargs +) -> tuple[list[Line2D], list[Text]]: + """ + Get or set the theta gridlines on the current polar plot. + + Call signatures:: + + lines, labels = thetagrids() + lines, labels = thetagrids(angles, labels=None, fmt=None, **kwargs) + + When called with no arguments, `.thetagrids` simply returns the tuple + (*lines*, *labels*). When called with arguments, the labels will + appear at the specified angles. + + Parameters + ---------- + angles : tuple with floats, degrees + The angles of the theta gridlines. + + labels : tuple with strings or None + The labels to use at each radial gridline. The + `.projections.polar.ThetaFormatter` will be used if None. + + fmt : str or None + Format string used in `matplotlib.ticker.FormatStrFormatter`. + For example '%f'. Note that the angle in radians will be used. + + Returns + ------- + lines : list of `.lines.Line2D` + The theta gridlines. + + labels : list of `.text.Text` + The tick labels. + + Other Parameters + ---------------- + **kwargs + *kwargs* are optional `.Text` properties for the labels. + + See Also + -------- + .pyplot.rgrids + .projections.polar.PolarAxes.set_thetagrids + .Axis.get_gridlines + .Axis.get_ticklabels + + Examples + -------- + :: + + # set the locations of the angular gridlines + lines, labels = thetagrids(range(45, 360, 90)) + + # set the locations and labels of the angular gridlines + lines, labels = thetagrids(range(45, 360, 90), ('NE', 'NW', 'SW', 'SE')) + """ + ax = gca() + if not isinstance(ax, PolarAxes): + raise RuntimeError('thetagrids only defined for polar Axes') + if all(param is None for param in [angles, labels, fmt]) and not kwargs: + lines_out: list[Line2D] = ax.xaxis.get_ticklines() + labels_out: list[Text] = ax.xaxis.get_ticklabels() + elif angles is None: + raise TypeError("'angles' cannot be None when other parameters are passed") + else: + lines_out, labels_out = ax.set_thetagrids(angles, + labels=labels, fmt=fmt, + **kwargs) + return lines_out, labels_out + + +@_api.deprecated("3.7", pending=True) +def get_plot_commands() -> list[str]: + """ + Get a sorted list of all of the plotting commands. + """ + NON_PLOT_COMMANDS = { + 'connect', 'disconnect', 'get_current_fig_manager', 'ginput', + 'new_figure_manager', 'waitforbuttonpress'} + return [name for name in _get_pyplot_commands() + if name not in NON_PLOT_COMMANDS] + + +def _get_pyplot_commands() -> list[str]: + # This works by searching for all functions in this module and removing + # a few hard-coded exclusions, as well as all of the colormap-setting + # functions, and anything marked as private with a preceding underscore. + exclude = {'colormaps', 'colors', 'get_plot_commands', *colormaps} + this_module = inspect.getmodule(get_plot_commands) + return sorted( + name for name, obj in globals().items() + if not name.startswith('_') and name not in exclude + and inspect.isfunction(obj) + and inspect.getmodule(obj) is this_module) + + +## Plotting part 1: manually generated functions and wrappers ## + + +@_copy_docstring_and_deprecators(Figure.colorbar) +def colorbar( + mappable: ScalarMappable | None = None, + cax: matplotlib.axes.Axes | None = None, + ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None = None, + **kwargs +) -> Colorbar: + if mappable is None: + mappable = gci() + if mappable is None: + raise RuntimeError('No mappable was found to use for colorbar ' + 'creation. First define a mappable such as ' + 'an image (with imshow) or a contour set (' + 'with contourf).') + ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs) + return ret + + +def clim(vmin: float | None = None, vmax: float | None = None) -> None: + """ + Set the color limits of the current image. + + If either *vmin* or *vmax* is None, the image min/max respectively + will be used for color scaling. + + If you want to set the clim of multiple images, use + `~.ScalarMappable.set_clim` on every image, for example:: + + for im in gca().get_images(): + im.set_clim(0, 0.5) + + """ + im = gci() + if im is None: + raise RuntimeError('You must first define an image, e.g., with imshow') + + im.set_clim(vmin, vmax) + + +def get_cmap(name: Colormap | str | None = None, lut: int | None = None) -> Colormap: + """ + Get a colormap instance, defaulting to rc values if *name* is None. + + Parameters + ---------- + name : `~matplotlib.colors.Colormap` or str or None, default: None + If a `.Colormap` instance, it will be returned. Otherwise, the name of + a colormap known to Matplotlib, which will be resampled by *lut*. The + default, None, means :rc:`image.cmap`. + lut : int or None, default: None + If *name* is not already a Colormap instance and *lut* is not None, the + colormap will be resampled to have *lut* entries in the lookup table. + + Returns + ------- + Colormap + """ + if name is None: + name = rcParams['image.cmap'] + if isinstance(name, Colormap): + return name + _api.check_in_list(sorted(_colormaps), name=name) + if lut is None: + return _colormaps[name] + else: + return _colormaps[name].resampled(lut) + + +def set_cmap(cmap: Colormap | str) -> None: + """ + Set the default colormap, and applies it to the current image if any. + + Parameters + ---------- + cmap : `~matplotlib.colors.Colormap` or str + A colormap instance or the name of a registered colormap. + + See Also + -------- + colormaps + get_cmap + """ + cmap = get_cmap(cmap) + + rc('image', cmap=cmap.name) + im = gci() + + if im is not None: + im.set_cmap(cmap) + + +@_copy_docstring_and_deprecators(matplotlib.image.imread) +def imread( + fname: str | pathlib.Path | BinaryIO, format: str | None = None +) -> np.ndarray: + return matplotlib.image.imread(fname, format) + + +@_copy_docstring_and_deprecators(matplotlib.image.imsave) +def imsave( + fname: str | os.PathLike | BinaryIO, arr: ArrayLike, **kwargs +) -> None: + matplotlib.image.imsave(fname, arr, **kwargs) + + +def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage: + """ + Display a 2D array as a matrix in a new figure window. + + The origin is set at the upper left hand corner. + The indexing is ``(row, column)`` so that the first index runs vertically + and the second index runs horizontally in the figure: + + .. code-block:: none + + A[0, 0] ⋯ A[0, M-1] + ⋮ ⋮ + A[N-1, 0] ⋯ A[N-1, M-1] + + The aspect ratio of the figure window is that of the array, + unless this would make an excessively short or narrow figure. + + Tick labels for the xaxis are placed on top. + + Parameters + ---------- + A : 2D array-like + The matrix to be displayed. + + fignum : None or int + If *None*, create a new, appropriately sized figure window. + + If 0, use the current Axes (creating one if there is none, without ever + adjusting the figure size). + + Otherwise, create a new Axes on the figure with the given number + (creating it at the appropriate size if it does not exist, but not + adjusting the figure size otherwise). Note that this will be drawn on + top of any preexisting Axes on the figure. + + Returns + ------- + `~matplotlib.image.AxesImage` + + Other Parameters + ---------------- + **kwargs : `~matplotlib.axes.Axes.imshow` arguments + + """ + A = np.asanyarray(A) + if fignum == 0: + ax = gca() + else: + # Extract actual aspect ratio of array and make appropriately sized + # figure. + fig = figure(fignum, figsize=figaspect(A)) + ax = fig.add_axes((0.15, 0.09, 0.775, 0.775)) + im = ax.matshow(A, **kwargs) + sci(im) + return im + + +def polar(*args, **kwargs) -> list[Line2D]: + """ + Make a polar plot. + + call signature:: + + polar(theta, r, **kwargs) + + Multiple *theta*, *r* arguments are supported, with format strings, as in + `plot`. + """ + # If an axis already exists, check if it has a polar projection + if gcf().get_axes(): + ax = gca() + if not isinstance(ax, PolarAxes): + _api.warn_external('Trying to create polar plot on an Axes ' + 'that does not have a polar projection.') + else: + ax = axes(projection="polar") + return ax.plot(*args, **kwargs) + + +# If rcParams['backend_fallback'] is true, and an interactive backend is +# requested, ignore rcParams['backend'] and force selection of a backend that +# is compatible with the current running interactive framework. +if (rcParams["backend_fallback"] + and rcParams._get_backend_or_none() in ( # type: ignore[attr-defined] + set(backend_registry.list_builtin(BackendFilter.INTERACTIVE)) - + {'webagg', 'nbagg'}) + and cbook._get_running_interactive_framework()): + rcParams._set("backend", rcsetup._auto_backend_sentinel) + +# fmt: on + +################# REMAINING CONTENT GENERATED BY boilerplate.py ############## + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.figimage) +def figimage( + X: ArrayLike, + xo: int = 0, + yo: int = 0, + alpha: float | None = None, + norm: str | Normalize | None = None, + cmap: str | Colormap | None = None, + vmin: float | None = None, + vmax: float | None = None, + origin: Literal["upper", "lower"] | None = None, + resize: bool = False, + **kwargs, +) -> FigureImage: + return gcf().figimage( + X, + xo=xo, + yo=yo, + alpha=alpha, + norm=norm, + cmap=cmap, + vmin=vmin, + vmax=vmax, + origin=origin, + resize=resize, + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.text) +def figtext( + x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs +) -> Text: + return gcf().text(x, y, s, fontdict=fontdict, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.gca) +def gca() -> Axes: + return gcf().gca() + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure._gci) +def gci() -> ScalarMappable | None: + return gcf()._gci() + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.ginput) +def ginput( + n: int = 1, + timeout: float = 30, + show_clicks: bool = True, + mouse_add: MouseButton = MouseButton.LEFT, + mouse_pop: MouseButton = MouseButton.RIGHT, + mouse_stop: MouseButton = MouseButton.MIDDLE, +) -> list[tuple[int, int]]: + return gcf().ginput( + n=n, + timeout=timeout, + show_clicks=show_clicks, + mouse_add=mouse_add, + mouse_pop=mouse_pop, + mouse_stop=mouse_stop, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.subplots_adjust) +def subplots_adjust( + left: float | None = None, + bottom: float | None = None, + right: float | None = None, + top: float | None = None, + wspace: float | None = None, + hspace: float | None = None, +) -> None: + gcf().subplots_adjust( + left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.suptitle) +def suptitle(t: str, **kwargs) -> Text: + return gcf().suptitle(t, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.tight_layout) +def tight_layout( + *, + pad: float = 1.08, + h_pad: float | None = None, + w_pad: float | None = None, + rect: tuple[float, float, float, float] | None = None, +) -> None: + gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Figure.waitforbuttonpress) +def waitforbuttonpress(timeout: float = -1) -> None | bool: + return gcf().waitforbuttonpress(timeout=timeout) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.acorr) +def acorr( + x: ArrayLike, *, data=None, **kwargs +) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: + return gca().acorr(x, **({"data": data} if data is not None else {}), **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.angle_spectrum) +def angle_spectrum( + x: ArrayLike, + Fs: float | None = None, + Fc: int | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, Line2D]: + return gca().angle_spectrum( + x, + Fs=Fs, + Fc=Fc, + window=window, + pad_to=pad_to, + sides=sides, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.annotate) +def annotate( + text: str, + xy: tuple[float, float], + xytext: tuple[float, float] | None = None, + xycoords: str + | Artist + | Transform + | Callable[[RendererBase], Bbox | Transform] + | tuple[float, float] = "data", + textcoords: str + | Artist + | Transform + | Callable[[RendererBase], Bbox | Transform] + | tuple[float, float] + | None = None, + arrowprops: dict[str, Any] | None = None, + annotation_clip: bool | None = None, + **kwargs, +) -> Annotation: + return gca().annotate( + text, + xy, + xytext=xytext, + xycoords=xycoords, + textcoords=textcoords, + arrowprops=arrowprops, + annotation_clip=annotation_clip, + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.arrow) +def arrow(x: float, y: float, dx: float, dy: float, **kwargs) -> FancyArrow: + return gca().arrow(x, y, dx, dy, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.autoscale) +def autoscale( + enable: bool = True, + axis: Literal["both", "x", "y"] = "both", + tight: bool | None = None, +) -> None: + gca().autoscale(enable=enable, axis=axis, tight=tight) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axhline) +def axhline(y: float = 0, xmin: float = 0, xmax: float = 1, **kwargs) -> Line2D: + return gca().axhline(y=y, xmin=xmin, xmax=xmax, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axhspan) +def axhspan( + ymin: float, ymax: float, xmin: float = 0, xmax: float = 1, **kwargs +) -> Polygon: + return gca().axhspan(ymin, ymax, xmin=xmin, xmax=xmax, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axis) +def axis( + arg: tuple[float, float, float, float] | bool | str | None = None, + /, + *, + emit: bool = True, + **kwargs, +) -> tuple[float, float, float, float]: + return gca().axis(arg, emit=emit, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axline) +def axline( + xy1: tuple[float, float], + xy2: tuple[float, float] | None = None, + *, + slope: float | None = None, + **kwargs, +) -> AxLine: + return gca().axline(xy1, xy2=xy2, slope=slope, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axvline) +def axvline(x: float = 0, ymin: float = 0, ymax: float = 1, **kwargs) -> Line2D: + return gca().axvline(x=x, ymin=ymin, ymax=ymax, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.axvspan) +def axvspan( + xmin: float, xmax: float, ymin: float = 0, ymax: float = 1, **kwargs +) -> Polygon: + return gca().axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.bar) +def bar( + x: float | ArrayLike, + height: float | ArrayLike, + width: float | ArrayLike = 0.8, + bottom: float | ArrayLike | None = None, + *, + align: Literal["center", "edge"] = "center", + data=None, + **kwargs, +) -> BarContainer: + return gca().bar( + x, + height, + width=width, + bottom=bottom, + align=align, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.barbs) +def barbs(*args, data=None, **kwargs) -> Barbs: + return gca().barbs(*args, **({"data": data} if data is not None else {}), **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.barh) +def barh( + y: float | ArrayLike, + width: float | ArrayLike, + height: float | ArrayLike = 0.8, + left: float | ArrayLike | None = None, + *, + align: Literal["center", "edge"] = "center", + data=None, + **kwargs, +) -> BarContainer: + return gca().barh( + y, + width, + height=height, + left=left, + align=align, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.bar_label) +def bar_label( + container: BarContainer, + labels: ArrayLike | None = None, + *, + fmt: str | Callable[[float], str] = "%g", + label_type: Literal["center", "edge"] = "edge", + padding: float = 0, + **kwargs, +) -> list[Annotation]: + return gca().bar_label( + container, + labels=labels, + fmt=fmt, + label_type=label_type, + padding=padding, + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.boxplot) +def boxplot( + x: ArrayLike | Sequence[ArrayLike], + notch: bool | None = None, + sym: str | None = None, + vert: bool | None = None, + whis: float | tuple[float, float] | None = None, + positions: ArrayLike | None = None, + widths: float | ArrayLike | None = None, + patch_artist: bool | None = None, + bootstrap: int | None = None, + usermedians: ArrayLike | None = None, + conf_intervals: ArrayLike | None = None, + meanline: bool | None = None, + showmeans: bool | None = None, + showcaps: bool | None = None, + showbox: bool | None = None, + showfliers: bool | None = None, + boxprops: dict[str, Any] | None = None, + tick_labels: Sequence[str] | None = None, + flierprops: dict[str, Any] | None = None, + medianprops: dict[str, Any] | None = None, + meanprops: dict[str, Any] | None = None, + capprops: dict[str, Any] | None = None, + whiskerprops: dict[str, Any] | None = None, + manage_ticks: bool = True, + autorange: bool = False, + zorder: float | None = None, + capwidths: float | ArrayLike | None = None, + label: Sequence[str] | None = None, + *, + data=None, +) -> dict[str, Any]: + return gca().boxplot( + x, + notch=notch, + sym=sym, + vert=vert, + whis=whis, + positions=positions, + widths=widths, + patch_artist=patch_artist, + bootstrap=bootstrap, + usermedians=usermedians, + conf_intervals=conf_intervals, + meanline=meanline, + showmeans=showmeans, + showcaps=showcaps, + showbox=showbox, + showfliers=showfliers, + boxprops=boxprops, + tick_labels=tick_labels, + flierprops=flierprops, + medianprops=medianprops, + meanprops=meanprops, + capprops=capprops, + whiskerprops=whiskerprops, + manage_ticks=manage_ticks, + autorange=autorange, + zorder=zorder, + capwidths=capwidths, + label=label, + **({"data": data} if data is not None else {}), + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.broken_barh) +def broken_barh( + xranges: Sequence[tuple[float, float]], + yrange: tuple[float, float], + *, + data=None, + **kwargs, +) -> PolyCollection: + return gca().broken_barh( + xranges, yrange, **({"data": data} if data is not None else {}), **kwargs + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.clabel) +def clabel(CS: ContourSet, levels: ArrayLike | None = None, **kwargs) -> list[Text]: + return gca().clabel(CS, levels=levels, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.cohere) +def cohere( + x: ArrayLike, + y: ArrayLike, + NFFT: int = 256, + Fs: float = 2, + Fc: int = 0, + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike], ArrayLike] = mlab.detrend_none, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike = mlab.window_hanning, + noverlap: int = 0, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] = "default", + scale_by_freq: bool | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray]: + return gca().cohere( + x, + y, + NFFT=NFFT, + Fs=Fs, + Fc=Fc, + detrend=detrend, + window=window, + noverlap=noverlap, + pad_to=pad_to, + sides=sides, + scale_by_freq=scale_by_freq, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.contour) +def contour(*args, data=None, **kwargs) -> QuadContourSet: + __ret = gca().contour( + *args, **({"data": data} if data is not None else {}), **kwargs + ) + if __ret._A is not None: # type: ignore[attr-defined] + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.contourf) +def contourf(*args, data=None, **kwargs) -> QuadContourSet: + __ret = gca().contourf( + *args, **({"data": data} if data is not None else {}), **kwargs + ) + if __ret._A is not None: # type: ignore[attr-defined] + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.csd) +def csd( + x: ArrayLike, + y: ArrayLike, + NFFT: int | None = None, + Fs: float | None = None, + Fc: int | None = None, + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike], ArrayLike] + | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + noverlap: int | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + scale_by_freq: bool | None = None, + return_line: bool | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: + return gca().csd( + x, + y, + NFFT=NFFT, + Fs=Fs, + Fc=Fc, + detrend=detrend, + window=window, + noverlap=noverlap, + pad_to=pad_to, + sides=sides, + scale_by_freq=scale_by_freq, + return_line=return_line, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.ecdf) +def ecdf( + x: ArrayLike, + weights: ArrayLike | None = None, + *, + complementary: bool = False, + orientation: Literal["vertical", "horizonatal"] = "vertical", + compress: bool = False, + data=None, + **kwargs, +) -> Line2D: + return gca().ecdf( + x, + weights=weights, + complementary=complementary, + orientation=orientation, + compress=compress, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.errorbar) +def errorbar( + x: float | ArrayLike, + y: float | ArrayLike, + yerr: float | ArrayLike | None = None, + xerr: float | ArrayLike | None = None, + fmt: str = "", + ecolor: ColorType | None = None, + elinewidth: float | None = None, + capsize: float | None = None, + barsabove: bool = False, + lolims: bool | ArrayLike = False, + uplims: bool | ArrayLike = False, + xlolims: bool | ArrayLike = False, + xuplims: bool | ArrayLike = False, + errorevery: int | tuple[int, int] = 1, + capthick: float | None = None, + *, + data=None, + **kwargs, +) -> ErrorbarContainer: + return gca().errorbar( + x, + y, + yerr=yerr, + xerr=xerr, + fmt=fmt, + ecolor=ecolor, + elinewidth=elinewidth, + capsize=capsize, + barsabove=barsabove, + lolims=lolims, + uplims=uplims, + xlolims=xlolims, + xuplims=xuplims, + errorevery=errorevery, + capthick=capthick, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.eventplot) +def eventplot( + positions: ArrayLike | Sequence[ArrayLike], + orientation: Literal["horizontal", "vertical"] = "horizontal", + lineoffsets: float | Sequence[float] = 1, + linelengths: float | Sequence[float] = 1, + linewidths: float | Sequence[float] | None = None, + colors: ColorType | Sequence[ColorType] | None = None, + alpha: float | Sequence[float] | None = None, + linestyles: LineStyleType | Sequence[LineStyleType] = "solid", + *, + data=None, + **kwargs, +) -> EventCollection: + return gca().eventplot( + positions, + orientation=orientation, + lineoffsets=lineoffsets, + linelengths=linelengths, + linewidths=linewidths, + colors=colors, + alpha=alpha, + linestyles=linestyles, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.fill) +def fill(*args, data=None, **kwargs) -> list[Polygon]: + return gca().fill(*args, **({"data": data} if data is not None else {}), **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.fill_between) +def fill_between( + x: ArrayLike, + y1: ArrayLike | float, + y2: ArrayLike | float = 0, + where: Sequence[bool] | None = None, + interpolate: bool = False, + step: Literal["pre", "post", "mid"] | None = None, + *, + data=None, + **kwargs, +) -> PolyCollection: + return gca().fill_between( + x, + y1, + y2=y2, + where=where, + interpolate=interpolate, + step=step, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.fill_betweenx) +def fill_betweenx( + y: ArrayLike, + x1: ArrayLike | float, + x2: ArrayLike | float = 0, + where: Sequence[bool] | None = None, + step: Literal["pre", "post", "mid"] | None = None, + interpolate: bool = False, + *, + data=None, + **kwargs, +) -> PolyCollection: + return gca().fill_betweenx( + y, + x1, + x2=x2, + where=where, + step=step, + interpolate=interpolate, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.grid) +def grid( + visible: bool | None = None, + which: Literal["major", "minor", "both"] = "major", + axis: Literal["both", "x", "y"] = "both", + **kwargs, +) -> None: + gca().grid(visible=visible, which=which, axis=axis, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.hexbin) +def hexbin( + x: ArrayLike, + y: ArrayLike, + C: ArrayLike | None = None, + gridsize: int | tuple[int, int] = 100, + bins: Literal["log"] | int | Sequence[float] | None = None, + xscale: Literal["linear", "log"] = "linear", + yscale: Literal["linear", "log"] = "linear", + extent: tuple[float, float, float, float] | None = None, + cmap: str | Colormap | None = None, + norm: str | Normalize | None = None, + vmin: float | None = None, + vmax: float | None = None, + alpha: float | None = None, + linewidths: float | None = None, + edgecolors: Literal["face", "none"] | ColorType = "face", + reduce_C_function: Callable[[np.ndarray | list[float]], float] = np.mean, + mincnt: int | None = None, + marginals: bool = False, + *, + data=None, + **kwargs, +) -> PolyCollection: + __ret = gca().hexbin( + x, + y, + C=C, + gridsize=gridsize, + bins=bins, + xscale=xscale, + yscale=yscale, + extent=extent, + cmap=cmap, + norm=norm, + vmin=vmin, + vmax=vmax, + alpha=alpha, + linewidths=linewidths, + edgecolors=edgecolors, + reduce_C_function=reduce_C_function, + mincnt=mincnt, + marginals=marginals, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.hist) +def hist( + x: ArrayLike | Sequence[ArrayLike], + bins: int | Sequence[float] | str | None = None, + range: tuple[float, float] | None = None, + density: bool = False, + weights: ArrayLike | None = None, + cumulative: bool | float = False, + bottom: ArrayLike | float | None = None, + histtype: Literal["bar", "barstacked", "step", "stepfilled"] = "bar", + align: Literal["left", "mid", "right"] = "mid", + orientation: Literal["vertical", "horizontal"] = "vertical", + rwidth: float | None = None, + log: bool = False, + color: ColorType | Sequence[ColorType] | None = None, + label: str | Sequence[str] | None = None, + stacked: bool = False, + *, + data=None, + **kwargs, +) -> tuple[ + np.ndarray | list[np.ndarray], + np.ndarray, + BarContainer | Polygon | list[BarContainer | Polygon], +]: + return gca().hist( + x, + bins=bins, + range=range, + density=density, + weights=weights, + cumulative=cumulative, + bottom=bottom, + histtype=histtype, + align=align, + orientation=orientation, + rwidth=rwidth, + log=log, + color=color, + label=label, + stacked=stacked, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.stairs) +def stairs( + values: ArrayLike, + edges: ArrayLike | None = None, + *, + orientation: Literal["vertical", "horizontal"] = "vertical", + baseline: float | ArrayLike | None = 0, + fill: bool = False, + data=None, + **kwargs, +) -> StepPatch: + return gca().stairs( + values, + edges=edges, + orientation=orientation, + baseline=baseline, + fill=fill, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.hist2d) +def hist2d( + x: ArrayLike, + y: ArrayLike, + bins: None | int | tuple[int, int] | ArrayLike | tuple[ArrayLike, ArrayLike] = 10, + range: ArrayLike | None = None, + density: bool = False, + weights: ArrayLike | None = None, + cmin: float | None = None, + cmax: float | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]: + __ret = gca().hist2d( + x, + y, + bins=bins, + range=range, + density=density, + weights=weights, + cmin=cmin, + cmax=cmax, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret[-1]) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.hlines) +def hlines( + y: float | ArrayLike, + xmin: float | ArrayLike, + xmax: float | ArrayLike, + colors: ColorType | Sequence[ColorType] | None = None, + linestyles: LineStyleType = "solid", + label: str = "", + *, + data=None, + **kwargs, +) -> LineCollection: + return gca().hlines( + y, + xmin, + xmax, + colors=colors, + linestyles=linestyles, + label=label, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.imshow) +def imshow( + X: ArrayLike | PIL.Image.Image, + cmap: str | Colormap | None = None, + norm: str | Normalize | None = None, + *, + aspect: Literal["equal", "auto"] | float | None = None, + interpolation: str | None = None, + alpha: float | ArrayLike | None = None, + vmin: float | None = None, + vmax: float | None = None, + origin: Literal["upper", "lower"] | None = None, + extent: tuple[float, float, float, float] | None = None, + interpolation_stage: Literal["data", "rgba"] | None = None, + filternorm: bool = True, + filterrad: float = 4.0, + resample: bool | None = None, + url: str | None = None, + data=None, + **kwargs, +) -> AxesImage: + __ret = gca().imshow( + X, + cmap=cmap, + norm=norm, + aspect=aspect, + interpolation=interpolation, + alpha=alpha, + vmin=vmin, + vmax=vmax, + origin=origin, + extent=extent, + interpolation_stage=interpolation_stage, + filternorm=filternorm, + filterrad=filterrad, + resample=resample, + url=url, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.legend) +def legend(*args, **kwargs) -> Legend: + return gca().legend(*args, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.locator_params) +def locator_params( + axis: Literal["both", "x", "y"] = "both", tight: bool | None = None, **kwargs +) -> None: + gca().locator_params(axis=axis, tight=tight, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.loglog) +def loglog(*args, **kwargs) -> list[Line2D]: + return gca().loglog(*args, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.magnitude_spectrum) +def magnitude_spectrum( + x: ArrayLike, + Fs: float | None = None, + Fc: int | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + scale: Literal["default", "linear", "dB"] | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, Line2D]: + return gca().magnitude_spectrum( + x, + Fs=Fs, + Fc=Fc, + window=window, + pad_to=pad_to, + sides=sides, + scale=scale, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.margins) +def margins( + *margins: float, + x: float | None = None, + y: float | None = None, + tight: bool | None = True, +) -> tuple[float, float] | None: + return gca().margins(*margins, x=x, y=y, tight=tight) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.minorticks_off) +def minorticks_off() -> None: + gca().minorticks_off() + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.minorticks_on) +def minorticks_on() -> None: + gca().minorticks_on() + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.pcolor) +def pcolor( + *args: ArrayLike, + shading: Literal["flat", "nearest", "auto"] | None = None, + alpha: float | None = None, + norm: str | Normalize | None = None, + cmap: str | Colormap | None = None, + vmin: float | None = None, + vmax: float | None = None, + data=None, + **kwargs, +) -> Collection: + __ret = gca().pcolor( + *args, + shading=shading, + alpha=alpha, + norm=norm, + cmap=cmap, + vmin=vmin, + vmax=vmax, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.pcolormesh) +def pcolormesh( + *args: ArrayLike, + alpha: float | None = None, + norm: str | Normalize | None = None, + cmap: str | Colormap | None = None, + vmin: float | None = None, + vmax: float | None = None, + shading: Literal["flat", "nearest", "gouraud", "auto"] | None = None, + antialiased: bool = False, + data=None, + **kwargs, +) -> QuadMesh: + __ret = gca().pcolormesh( + *args, + alpha=alpha, + norm=norm, + cmap=cmap, + vmin=vmin, + vmax=vmax, + shading=shading, + antialiased=antialiased, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.phase_spectrum) +def phase_spectrum( + x: ArrayLike, + Fs: float | None = None, + Fc: int | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, Line2D]: + return gca().phase_spectrum( + x, + Fs=Fs, + Fc=Fc, + window=window, + pad_to=pad_to, + sides=sides, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.pie) +def pie( + x: ArrayLike, + explode: ArrayLike | None = None, + labels: Sequence[str] | None = None, + colors: ColorType | Sequence[ColorType] | None = None, + autopct: str | Callable[[float], str] | None = None, + pctdistance: float = 0.6, + shadow: bool = False, + labeldistance: float | None = 1.1, + startangle: float = 0, + radius: float = 1, + counterclock: bool = True, + wedgeprops: dict[str, Any] | None = None, + textprops: dict[str, Any] | None = None, + center: tuple[float, float] = (0, 0), + frame: bool = False, + rotatelabels: bool = False, + *, + normalize: bool = True, + hatch: str | Sequence[str] | None = None, + data=None, +) -> tuple[list[Wedge], list[Text]] | tuple[list[Wedge], list[Text], list[Text]]: + return gca().pie( + x, + explode=explode, + labels=labels, + colors=colors, + autopct=autopct, + pctdistance=pctdistance, + shadow=shadow, + labeldistance=labeldistance, + startangle=startangle, + radius=radius, + counterclock=counterclock, + wedgeprops=wedgeprops, + textprops=textprops, + center=center, + frame=frame, + rotatelabels=rotatelabels, + normalize=normalize, + hatch=hatch, + **({"data": data} if data is not None else {}), + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.plot) +def plot( + *args: float | ArrayLike | str, + scalex: bool = True, + scaley: bool = True, + data=None, + **kwargs, +) -> list[Line2D]: + return gca().plot( + *args, + scalex=scalex, + scaley=scaley, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.plot_date) +def plot_date( + x: ArrayLike, + y: ArrayLike, + fmt: str = "o", + tz: str | datetime.tzinfo | None = None, + xdate: bool = True, + ydate: bool = False, + *, + data=None, + **kwargs, +) -> list[Line2D]: + return gca().plot_date( + x, + y, + fmt=fmt, + tz=tz, + xdate=xdate, + ydate=ydate, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.psd) +def psd( + x: ArrayLike, + NFFT: int | None = None, + Fs: float | None = None, + Fc: int | None = None, + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike], ArrayLike] + | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + noverlap: int | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + scale_by_freq: bool | None = None, + return_line: bool | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: + return gca().psd( + x, + NFFT=NFFT, + Fs=Fs, + Fc=Fc, + detrend=detrend, + window=window, + noverlap=noverlap, + pad_to=pad_to, + sides=sides, + scale_by_freq=scale_by_freq, + return_line=return_line, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.quiver) +def quiver(*args, data=None, **kwargs) -> Quiver: + __ret = gca().quiver( + *args, **({"data": data} if data is not None else {}), **kwargs + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.quiverkey) +def quiverkey( + Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs +) -> QuiverKey: + return gca().quiverkey(Q, X, Y, U, label, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.scatter) +def scatter( + x: float | ArrayLike, + y: float | ArrayLike, + s: float | ArrayLike | None = None, + c: ArrayLike | Sequence[ColorType] | ColorType | None = None, + marker: MarkerType | None = None, + cmap: str | Colormap | None = None, + norm: str | Normalize | None = None, + vmin: float | None = None, + vmax: float | None = None, + alpha: float | None = None, + linewidths: float | Sequence[float] | None = None, + *, + edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = None, + plotnonfinite: bool = False, + data=None, + **kwargs, +) -> PathCollection: + __ret = gca().scatter( + x, + y, + s=s, + c=c, + marker=marker, + cmap=cmap, + norm=norm, + vmin=vmin, + vmax=vmax, + alpha=alpha, + linewidths=linewidths, + edgecolors=edgecolors, + plotnonfinite=plotnonfinite, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.semilogx) +def semilogx(*args, **kwargs) -> list[Line2D]: + return gca().semilogx(*args, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.semilogy) +def semilogy(*args, **kwargs) -> list[Line2D]: + return gca().semilogy(*args, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.specgram) +def specgram( + x: ArrayLike, + NFFT: int | None = None, + Fs: float | None = None, + Fc: int | None = None, + detrend: Literal["none", "mean", "linear"] + | Callable[[ArrayLike], ArrayLike] + | None = None, + window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None, + noverlap: int | None = None, + cmap: str | Colormap | None = None, + xextent: tuple[float, float] | None = None, + pad_to: int | None = None, + sides: Literal["default", "onesided", "twosided"] | None = None, + scale_by_freq: bool | None = None, + mode: Literal["default", "psd", "magnitude", "angle", "phase"] | None = None, + scale: Literal["default", "linear", "dB"] | None = None, + vmin: float | None = None, + vmax: float | None = None, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]: + __ret = gca().specgram( + x, + NFFT=NFFT, + Fs=Fs, + Fc=Fc, + detrend=detrend, + window=window, + noverlap=noverlap, + cmap=cmap, + xextent=xextent, + pad_to=pad_to, + sides=sides, + scale_by_freq=scale_by_freq, + mode=mode, + scale=scale, + vmin=vmin, + vmax=vmax, + **({"data": data} if data is not None else {}), + **kwargs, + ) + sci(__ret[-1]) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.spy) +def spy( + Z: ArrayLike, + precision: float | Literal["present"] = 0, + marker: str | None = None, + markersize: float | None = None, + aspect: Literal["equal", "auto"] | float | None = "equal", + origin: Literal["upper", "lower"] = "upper", + **kwargs, +) -> AxesImage: + __ret = gca().spy( + Z, + precision=precision, + marker=marker, + markersize=markersize, + aspect=aspect, + origin=origin, + **kwargs, + ) + if isinstance(__ret, cm.ScalarMappable): + sci(__ret) # noqa + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.stackplot) +def stackplot( + x, *args, labels=(), colors=None, hatch=None, baseline="zero", data=None, **kwargs +): + return gca().stackplot( + x, + *args, + labels=labels, + colors=colors, + hatch=hatch, + baseline=baseline, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.stem) +def stem( + *args: ArrayLike | str, + linefmt: str | None = None, + markerfmt: str | None = None, + basefmt: str | None = None, + bottom: float = 0, + label: str | None = None, + orientation: Literal["vertical", "horizontal"] = "vertical", + data=None, +) -> StemContainer: + return gca().stem( + *args, + linefmt=linefmt, + markerfmt=markerfmt, + basefmt=basefmt, + bottom=bottom, + label=label, + orientation=orientation, + **({"data": data} if data is not None else {}), + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.step) +def step( + x: ArrayLike, + y: ArrayLike, + *args, + where: Literal["pre", "post", "mid"] = "pre", + data=None, + **kwargs, +) -> list[Line2D]: + return gca().step( + x, + y, + *args, + where=where, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.streamplot) +def streamplot( + x, + y, + u, + v, + density=1, + linewidth=None, + color=None, + cmap=None, + norm=None, + arrowsize=1, + arrowstyle="-|>", + minlength=0.1, + transform=None, + zorder=None, + start_points=None, + maxlength=4.0, + integration_direction="both", + broken_streamlines=True, + *, + data=None, +): + __ret = gca().streamplot( + x, + y, + u, + v, + density=density, + linewidth=linewidth, + color=color, + cmap=cmap, + norm=norm, + arrowsize=arrowsize, + arrowstyle=arrowstyle, + minlength=minlength, + transform=transform, + zorder=zorder, + start_points=start_points, + maxlength=maxlength, + integration_direction=integration_direction, + broken_streamlines=broken_streamlines, + **({"data": data} if data is not None else {}), + ) + sci(__ret.lines) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.table) +def table( + cellText=None, + cellColours=None, + cellLoc="right", + colWidths=None, + rowLabels=None, + rowColours=None, + rowLoc="left", + colLabels=None, + colColours=None, + colLoc="center", + loc="bottom", + bbox=None, + edges="closed", + **kwargs, +): + return gca().table( + cellText=cellText, + cellColours=cellColours, + cellLoc=cellLoc, + colWidths=colWidths, + rowLabels=rowLabels, + rowColours=rowColours, + rowLoc=rowLoc, + colLabels=colLabels, + colColours=colColours, + colLoc=colLoc, + loc=loc, + bbox=bbox, + edges=edges, + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.text) +def text( + x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs +) -> Text: + return gca().text(x, y, s, fontdict=fontdict, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.tick_params) +def tick_params(axis: Literal["both", "x", "y"] = "both", **kwargs) -> None: + gca().tick_params(axis=axis, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.ticklabel_format) +def ticklabel_format( + *, + axis: Literal["both", "x", "y"] = "both", + style: Literal["", "sci", "scientific", "plain"] | None = None, + scilimits: tuple[int, int] | None = None, + useOffset: bool | float | None = None, + useLocale: bool | None = None, + useMathText: bool | None = None, +) -> None: + gca().ticklabel_format( + axis=axis, + style=style, + scilimits=scilimits, + useOffset=useOffset, + useLocale=useLocale, + useMathText=useMathText, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.tricontour) +def tricontour(*args, **kwargs): + __ret = gca().tricontour(*args, **kwargs) + if __ret._A is not None: # type: ignore[attr-defined] + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.tricontourf) +def tricontourf(*args, **kwargs): + __ret = gca().tricontourf(*args, **kwargs) + if __ret._A is not None: # type: ignore[attr-defined] + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.tripcolor) +def tripcolor( + *args, + alpha=1.0, + norm=None, + cmap=None, + vmin=None, + vmax=None, + shading="flat", + facecolors=None, + **kwargs, +): + __ret = gca().tripcolor( + *args, + alpha=alpha, + norm=norm, + cmap=cmap, + vmin=vmin, + vmax=vmax, + shading=shading, + facecolors=facecolors, + **kwargs, + ) + sci(__ret) + return __ret + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.triplot) +def triplot(*args, **kwargs): + return gca().triplot(*args, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.violinplot) +def violinplot( + dataset: ArrayLike | Sequence[ArrayLike], + positions: ArrayLike | None = None, + vert: bool = True, + widths: float | ArrayLike = 0.5, + showmeans: bool = False, + showextrema: bool = True, + showmedians: bool = False, + quantiles: Sequence[float | Sequence[float]] | None = None, + points: int = 100, + bw_method: Literal["scott", "silverman"] + | float + | Callable[[GaussianKDE], float] + | None = None, + side: Literal["both", "low", "high"] = "both", + *, + data=None, +) -> dict[str, Collection]: + return gca().violinplot( + dataset, + positions=positions, + vert=vert, + widths=widths, + showmeans=showmeans, + showextrema=showextrema, + showmedians=showmedians, + quantiles=quantiles, + points=points, + bw_method=bw_method, + side=side, + **({"data": data} if data is not None else {}), + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.vlines) +def vlines( + x: float | ArrayLike, + ymin: float | ArrayLike, + ymax: float | ArrayLike, + colors: ColorType | Sequence[ColorType] | None = None, + linestyles: LineStyleType = "solid", + label: str = "", + *, + data=None, + **kwargs, +) -> LineCollection: + return gca().vlines( + x, + ymin, + ymax, + colors=colors, + linestyles=linestyles, + label=label, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.xcorr) +def xcorr( + x: ArrayLike, + y: ArrayLike, + normed: bool = True, + detrend: Callable[[ArrayLike], ArrayLike] = mlab.detrend_none, + usevlines: bool = True, + maxlags: int = 10, + *, + data=None, + **kwargs, +) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: + return gca().xcorr( + x, + y, + normed=normed, + detrend=detrend, + usevlines=usevlines, + maxlags=maxlags, + **({"data": data} if data is not None else {}), + **kwargs, + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes._sci) +def sci(im: ScalarMappable) -> None: + gca()._sci(im) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.set_title) +def title( + label: str, + fontdict: dict[str, Any] | None = None, + loc: Literal["left", "center", "right"] | None = None, + pad: float | None = None, + *, + y: float | None = None, + **kwargs, +) -> Text: + return gca().set_title(label, fontdict=fontdict, loc=loc, pad=pad, y=y, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.set_xlabel) +def xlabel( + xlabel: str, + fontdict: dict[str, Any] | None = None, + labelpad: float | None = None, + *, + loc: Literal["left", "center", "right"] | None = None, + **kwargs, +) -> Text: + return gca().set_xlabel( + xlabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.set_ylabel) +def ylabel( + ylabel: str, + fontdict: dict[str, Any] | None = None, + labelpad: float | None = None, + *, + loc: Literal["bottom", "center", "top"] | None = None, + **kwargs, +) -> Text: + return gca().set_ylabel( + ylabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs + ) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.set_xscale) +def xscale(value: str | ScaleBase, **kwargs) -> None: + gca().set_xscale(value, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +@_copy_docstring_and_deprecators(Axes.set_yscale) +def yscale(value: str | ScaleBase, **kwargs) -> None: + gca().set_yscale(value, **kwargs) + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def autumn() -> None: + """ + Set the colormap to 'autumn'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("autumn") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def bone() -> None: + """ + Set the colormap to 'bone'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("bone") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def cool() -> None: + """ + Set the colormap to 'cool'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("cool") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def copper() -> None: + """ + Set the colormap to 'copper'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("copper") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def flag() -> None: + """ + Set the colormap to 'flag'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("flag") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def gray() -> None: + """ + Set the colormap to 'gray'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("gray") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def hot() -> None: + """ + Set the colormap to 'hot'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("hot") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def hsv() -> None: + """ + Set the colormap to 'hsv'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("hsv") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def jet() -> None: + """ + Set the colormap to 'jet'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("jet") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def pink() -> None: + """ + Set the colormap to 'pink'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("pink") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def prism() -> None: + """ + Set the colormap to 'prism'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("prism") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def spring() -> None: + """ + Set the colormap to 'spring'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("spring") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def summer() -> None: + """ + Set the colormap to 'summer'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("summer") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def winter() -> None: + """ + Set the colormap to 'winter'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("winter") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def magma() -> None: + """ + Set the colormap to 'magma'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("magma") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def inferno() -> None: + """ + Set the colormap to 'inferno'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("inferno") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def plasma() -> None: + """ + Set the colormap to 'plasma'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("plasma") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def viridis() -> None: + """ + Set the colormap to 'viridis'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("viridis") + + +# Autogenerated by boilerplate.py. Do not edit as changes will be lost. +def nipy_spectral() -> None: + """ + Set the colormap to 'nipy_spectral'. + + This changes the default colormap as well as the colormap of the current + image if there is one. See ``help(colormaps)`` for more information. + """ + set_cmap("nipy_spectral") diff --git a/venv/lib/python3.10/site-packages/matplotlib/quiver.py b/venv/lib/python3.10/site-packages/matplotlib/quiver.py new file mode 100644 index 00000000..8fa1962d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/quiver.py @@ -0,0 +1,1181 @@ +""" +Support for plotting vector fields. + +Presently this contains Quiver and Barb. Quiver plots an arrow in the +direction of the vector, with the size of the arrow related to the +magnitude of the vector. + +Barbs are like quiver in that they point along a vector, but +the magnitude of the vector is given schematically by the presence of barbs +or flags on the barb. + +This will also become a home for things such as standard +deviation ellipses, which can and will be derived very easily from +the Quiver code. +""" + +import math + +import numpy as np +from numpy import ma + +from matplotlib import _api, cbook, _docstring +import matplotlib.artist as martist +import matplotlib.collections as mcollections +from matplotlib.patches import CirclePolygon +import matplotlib.text as mtext +import matplotlib.transforms as transforms + + +_quiver_doc = """ +Plot a 2D field of arrows. + +Call signature:: + + quiver([X, Y], U, V, [C], **kwargs) + +*X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and +*C* optionally sets the color. + +**Arrow length** + +The default settings auto-scales the length of the arrows to a reasonable size. +To change this behavior see the *scale* and *scale_units* parameters. + +**Arrow shape** + +The arrow shape is determined by *width*, *headwidth*, *headlength* and +*headaxislength*. See the notes below. + +**Arrow styling** + +Each arrow is internally represented by a filled polygon with a default edge +linewidth of 0. As a result, an arrow is rather a filled area, not a line with +a head, and `.PolyCollection` properties like *linewidth*, *edgecolor*, +*facecolor*, etc. act accordingly. + + +Parameters +---------- +X, Y : 1D or 2D array-like, optional + The x and y coordinates of the arrow locations. + + If not given, they will be generated as a uniform integer meshgrid based + on the dimensions of *U* and *V*. + + If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D + using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)`` + must match the column and row dimensions of *U* and *V*. + +U, V : 1D or 2D array-like + The x and y direction components of the arrow vectors. The interpretation + of these components (in data or in screen space) depends on *angles*. + + *U* and *V* must have the same number of elements, matching the number of + arrow locations in *X*, *Y*. *U* and *V* may be masked. Locations masked + in any of *U*, *V*, and *C* will not be drawn. + +C : 1D or 2D array-like, optional + Numeric data that defines the arrow colors by colormapping via *norm* and + *cmap*. + + This does not support explicit colors. If you want to set colors directly, + use *color* instead. The size of *C* must match the number of arrow + locations. + +angles : {'uv', 'xy'} or array-like, default: 'uv' + Method for determining the angle of the arrows. + + - 'uv': Arrow direction in screen coordinates. Use this if the arrows + symbolize a quantity that is not based on *X*, *Y* data coordinates. + + If *U* == *V* the orientation of the arrow on the plot is 45 degrees + counter-clockwise from the horizontal axis (positive to the right). + + - 'xy': Arrow direction in data coordinates, i.e. the arrows point from + (x, y) to (x+u, y+v). Use this e.g. for plotting a gradient field. + + - Arbitrary angles may be specified explicitly as an array of values + in degrees, counter-clockwise from the horizontal axis. + + In this case *U*, *V* is only used to determine the length of the + arrows. + + Note: inverting a data axis will correspondingly invert the + arrows only with ``angles='xy'``. + +pivot : {'tail', 'mid', 'middle', 'tip'}, default: 'tail' + The part of the arrow that is anchored to the *X*, *Y* grid. The arrow + rotates about this point. + + 'mid' is a synonym for 'middle'. + +scale : float, optional + Scales the length of the arrow inversely. + + Number of data units per arrow length unit, e.g., m/s per plot width; a + smaller scale parameter makes the arrow longer. Default is *None*. + + If *None*, a simple autoscaling algorithm is used, based on the average + vector length and the number of vectors. The arrow length unit is given by + the *scale_units* parameter. + +scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, optional + If the *scale* kwarg is *None*, the arrow length unit. Default is *None*. + + e.g. *scale_units* is 'inches', *scale* is 2.0, and ``(u, v) = (1, 0)``, + then the vector will be 0.5 inches long. + + If *scale_units* is 'width' or 'height', then the vector will be half the + width/height of the axes. + + If *scale_units* is 'x' then the vector will be 0.5 x-axis + units. To plot vectors in the x-y plane, with u and v having + the same units as x and y, use + ``angles='xy', scale_units='xy', scale=1``. + +units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width' + Affects the arrow size (except for the length). In particular, the shaft + *width* is measured in multiples of this unit. + + Supported values are: + + - 'width', 'height': The width or height of the Axes. + - 'dots', 'inches': Pixels or inches based on the figure dpi. + - 'x', 'y', 'xy': *X*, *Y* or :math:`\\sqrt{X^2 + Y^2}` in data units. + + The following table summarizes how these values affect the visible arrow + size under zooming and figure size changes: + + ================= ================= ================== + units zoom figure size change + ================= ================= ================== + 'x', 'y', 'xy' arrow size scales — + 'width', 'height' — arrow size scales + 'dots', 'inches' — — + ================= ================= ================== + +width : float, optional + Shaft width in arrow units. All head parameters are relative to *width*. + + The default depends on choice of *units* above, and number of vectors; + a typical starting value is about 0.005 times the width of the plot. + +headwidth : float, default: 3 + Head width as multiple of shaft *width*. See the notes below. + +headlength : float, default: 5 + Head length as multiple of shaft *width*. See the notes below. + +headaxislength : float, default: 4.5 + Head length at shaft intersection as multiple of shaft *width*. + See the notes below. + +minshaft : float, default: 1 + Length below which arrow scales, in units of head length. Do not + set this to less than 1, or small arrows will look terrible! + +minlength : float, default: 1 + Minimum length as a multiple of shaft width; if an arrow length + is less than this, plot a dot (hexagon) of this diameter instead. + +color : :mpltype:`color` or list :mpltype:`color`, optional + Explicit color(s) for the arrows. If *C* has been set, *color* has no + effect. + + This is a synonym for the `.PolyCollection` *facecolor* parameter. + +Other Parameters +---------------- +data : indexable object, optional + DATA_PARAMETER_PLACEHOLDER + +**kwargs : `~matplotlib.collections.PolyCollection` properties, optional + All other keyword arguments are passed on to `.PolyCollection`: + + %(PolyCollection:kwdoc)s + +Returns +------- +`~matplotlib.quiver.Quiver` + +See Also +-------- +.Axes.quiverkey : Add a key to a quiver plot. + +Notes +----- + +**Arrow shape** + +The arrow is drawn as a polygon using the nodes as shown below. The values +*headwidth*, *headlength*, and *headaxislength* are in units of *width*. + +.. image:: /_static/quiver_sizes.svg + :width: 500px + +The defaults give a slightly swept-back arrow. Here are some guidelines how to +get other head shapes: + +- To make the head a triangle, make *headaxislength* the same as *headlength*. +- To make the arrow more pointed, reduce *headwidth* or increase *headlength* + and *headaxislength*. +- To make the head smaller relative to the shaft, scale down all the head + parameters proportionally. +- To remove the head completely, set all *head* parameters to 0. +- To get a diamond-shaped head, make *headaxislength* larger than *headlength*. +- Warning: For *headaxislength* < (*headlength* / *headwidth*), the "headaxis" + nodes (i.e. the ones connecting the head with the shaft) will protrude out + of the head in forward direction so that the arrow head looks broken. +""" % _docstring.interpd.params + +_docstring.interpd.update(quiver_doc=_quiver_doc) + + +class QuiverKey(martist.Artist): + """Labelled arrow for use as a quiver plot scale key.""" + halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'} + valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'} + pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'} + + def __init__(self, Q, X, Y, U, label, + *, angle=0, coordinates='axes', color=None, labelsep=0.1, + labelpos='N', labelcolor=None, fontproperties=None, **kwargs): + """ + Add a key to a quiver plot. + + The positioning of the key depends on *X*, *Y*, *coordinates*, and + *labelpos*. If *labelpos* is 'N' or 'S', *X*, *Y* give the position of + the middle of the key arrow. If *labelpos* is 'E', *X*, *Y* positions + the head, and if *labelpos* is 'W', *X*, *Y* positions the tail; in + either of these two cases, *X*, *Y* is somewhere in the middle of the + arrow+label key object. + + Parameters + ---------- + Q : `~matplotlib.quiver.Quiver` + A `.Quiver` object as returned by a call to `~.Axes.quiver()`. + X, Y : float + The location of the key. + U : float + The length of the key. + label : str + The key label (e.g., length and units of the key). + angle : float, default: 0 + The angle of the key arrow, in degrees anti-clockwise from the + horizontal axis. + coordinates : {'axes', 'figure', 'data', 'inches'}, default: 'axes' + Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are + normalized coordinate systems with (0, 0) in the lower left and + (1, 1) in the upper right; 'data' are the axes data coordinates + (used for the locations of the vectors in the quiver plot itself); + 'inches' is position in the figure in inches, with (0, 0) at the + lower left corner. + color : :mpltype:`color` + Overrides face and edge colors from *Q*. + labelpos : {'N', 'S', 'E', 'W'} + Position the label above, below, to the right, to the left of the + arrow, respectively. + labelsep : float, default: 0.1 + Distance in inches between the arrow and the label. + labelcolor : :mpltype:`color`, default: :rc:`text.color` + Label color. + fontproperties : dict, optional + A dictionary with keyword arguments accepted by the + `~matplotlib.font_manager.FontProperties` initializer: + *family*, *style*, *variant*, *size*, *weight*. + **kwargs + Any additional keyword arguments are used to override vector + properties taken from *Q*. + """ + super().__init__() + self.Q = Q + self.X = X + self.Y = Y + self.U = U + self.angle = angle + self.coord = coordinates + self.color = color + self.label = label + self._labelsep_inches = labelsep + + self.labelpos = labelpos + self.labelcolor = labelcolor + self.fontproperties = fontproperties or dict() + self.kw = kwargs + self.text = mtext.Text( + text=label, + horizontalalignment=self.halign[self.labelpos], + verticalalignment=self.valign[self.labelpos], + fontproperties=self.fontproperties) + if self.labelcolor is not None: + self.text.set_color(self.labelcolor) + self._dpi_at_last_init = None + self.zorder = Q.zorder + 0.1 + + @property + def labelsep(self): + return self._labelsep_inches * self.Q.axes.figure.dpi + + def _init(self): + if True: # self._dpi_at_last_init != self.axes.figure.dpi + if self.Q._dpi_at_last_init != self.Q.axes.figure.dpi: + self.Q._init() + self._set_transform() + with cbook._setattr_cm(self.Q, pivot=self.pivot[self.labelpos], + # Hack: save and restore the Umask + Umask=ma.nomask): + u = self.U * np.cos(np.radians(self.angle)) + v = self.U * np.sin(np.radians(self.angle)) + self.verts = self.Q._make_verts([[0., 0.]], + np.array([u]), np.array([v]), 'uv') + kwargs = self.Q.polykw + kwargs.update(self.kw) + self.vector = mcollections.PolyCollection( + self.verts, + offsets=[(self.X, self.Y)], + offset_transform=self.get_transform(), + **kwargs) + if self.color is not None: + self.vector.set_color(self.color) + self.vector.set_transform(self.Q.get_transform()) + self.vector.set_figure(self.get_figure()) + self._dpi_at_last_init = self.Q.axes.figure.dpi + + def _text_shift(self): + return { + "N": (0, +self.labelsep), + "S": (0, -self.labelsep), + "E": (+self.labelsep, 0), + "W": (-self.labelsep, 0), + }[self.labelpos] + + @martist.allow_rasterization + def draw(self, renderer): + self._init() + self.vector.draw(renderer) + pos = self.get_transform().transform((self.X, self.Y)) + self.text.set_position(pos + self._text_shift()) + self.text.draw(renderer) + self.stale = False + + def _set_transform(self): + self.set_transform(_api.check_getitem({ + "data": self.Q.axes.transData, + "axes": self.Q.axes.transAxes, + "figure": self.Q.axes.figure.transFigure, + "inches": self.Q.axes.figure.dpi_scale_trans, + }, coordinates=self.coord)) + + def set_figure(self, fig): + super().set_figure(fig) + self.text.set_figure(fig) + + def contains(self, mouseevent): + if self._different_canvas(mouseevent): + return False, {} + # Maybe the dictionary should allow one to + # distinguish between a text hit and a vector hit. + if (self.text.contains(mouseevent)[0] or + self.vector.contains(mouseevent)[0]): + return True, {} + return False, {} + + +def _parse_args(*args, caller_name='function'): + """ + Helper function to parse positional parameters for colored vector plots. + + This is currently used for Quiver and Barbs. + + Parameters + ---------- + *args : list + list of 2-5 arguments. Depending on their number they are parsed to:: + + U, V + U, V, C + X, Y, U, V + X, Y, U, V, C + + caller_name : str + Name of the calling method (used in error messages). + """ + X = Y = C = None + + nargs = len(args) + if nargs == 2: + # The use of atleast_1d allows for handling scalar arguments while also + # keeping masked arrays + U, V = np.atleast_1d(*args) + elif nargs == 3: + U, V, C = np.atleast_1d(*args) + elif nargs == 4: + X, Y, U, V = np.atleast_1d(*args) + elif nargs == 5: + X, Y, U, V, C = np.atleast_1d(*args) + else: + raise _api.nargs_error(caller_name, takes="from 2 to 5", given=nargs) + + nr, nc = (1, U.shape[0]) if U.ndim == 1 else U.shape + + if X is not None: + X = X.ravel() + Y = Y.ravel() + if len(X) == nc and len(Y) == nr: + X, Y = [a.ravel() for a in np.meshgrid(X, Y)] + elif len(X) != len(Y): + raise ValueError('X and Y must be the same size, but ' + f'X.size is {X.size} and Y.size is {Y.size}.') + else: + indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) + X, Y = [np.ravel(a) for a in indexgrid] + # Size validation for U, V, C is left to the set_UVC method. + return X, Y, U, V, C + + +def _check_consistent_shapes(*arrays): + all_shapes = {a.shape for a in arrays} + if len(all_shapes) != 1: + raise ValueError('The shapes of the passed in arrays do not match') + + +class Quiver(mcollections.PolyCollection): + """ + Specialized PolyCollection for arrows. + + The only API method is set_UVC(), which can be used + to change the size, orientation, and color of the + arrows; their locations are fixed when the class is + instantiated. Possibly this method will be useful + in animations. + + Much of the work in this class is done in the draw() + method so that as much information as possible is available + about the plot. In subsequent draw() calls, recalculation + is limited to things that might have changed, so there + should be no performance penalty from putting the calculations + in the draw() method. + """ + + _PIVOT_VALS = ('tail', 'middle', 'tip') + + @_docstring.Substitution(_quiver_doc) + def __init__(self, ax, *args, + scale=None, headwidth=3, headlength=5, headaxislength=4.5, + minshaft=1, minlength=1, units='width', scale_units=None, + angles='uv', width=None, color='k', pivot='tail', **kwargs): + """ + The constructor takes one required argument, an Axes + instance, followed by the args and kwargs described + by the following pyplot interface documentation: + %s + """ + self._axes = ax # The attr actually set by the Artist.axes property. + X, Y, U, V, C = _parse_args(*args, caller_name='quiver') + self.X = X + self.Y = Y + self.XY = np.column_stack((X, Y)) + self.N = len(X) + self.scale = scale + self.headwidth = headwidth + self.headlength = float(headlength) + self.headaxislength = headaxislength + self.minshaft = minshaft + self.minlength = minlength + self.units = units + self.scale_units = scale_units + self.angles = angles + self.width = width + + if pivot.lower() == 'mid': + pivot = 'middle' + self.pivot = pivot.lower() + _api.check_in_list(self._PIVOT_VALS, pivot=self.pivot) + + self.transform = kwargs.pop('transform', ax.transData) + kwargs.setdefault('facecolors', color) + kwargs.setdefault('linewidths', (0,)) + super().__init__([], offsets=self.XY, offset_transform=self.transform, + closed=False, **kwargs) + self.polykw = kwargs + self.set_UVC(U, V, C) + self._dpi_at_last_init = None + + def _init(self): + """ + Initialization delayed until first draw; + allow time for axes setup. + """ + # It seems that there are not enough event notifications + # available to have this work on an as-needed basis at present. + if True: # self._dpi_at_last_init != self.axes.figure.dpi + trans = self._set_transform() + self.span = trans.inverted().transform_bbox(self.axes.bbox).width + if self.width is None: + sn = np.clip(math.sqrt(self.N), 8, 25) + self.width = 0.06 * self.span / sn + + # _make_verts sets self.scale if not already specified + if (self._dpi_at_last_init != self.axes.figure.dpi + and self.scale is None): + self._make_verts(self.XY, self.U, self.V, self.angles) + + self._dpi_at_last_init = self.axes.figure.dpi + + def get_datalim(self, transData): + trans = self.get_transform() + offset_trf = self.get_offset_transform() + full_transform = (trans - transData) + (offset_trf - transData) + XY = full_transform.transform(self.XY) + bbox = transforms.Bbox.null() + bbox.update_from_data_xy(XY, ignore=True) + return bbox + + @martist.allow_rasterization + def draw(self, renderer): + self._init() + verts = self._make_verts(self.XY, self.U, self.V, self.angles) + self.set_verts(verts, closed=False) + super().draw(renderer) + self.stale = False + + def set_UVC(self, U, V, C=None): + # We need to ensure we have a copy, not a reference + # to an array that might change before draw(). + U = ma.masked_invalid(U, copy=True).ravel() + V = ma.masked_invalid(V, copy=True).ravel() + if C is not None: + C = ma.masked_invalid(C, copy=True).ravel() + for name, var in zip(('U', 'V', 'C'), (U, V, C)): + if not (var is None or var.size == self.N or var.size == 1): + raise ValueError(f'Argument {name} has a size {var.size}' + f' which does not match {self.N},' + ' the number of arrow positions') + + mask = ma.mask_or(U.mask, V.mask, copy=False, shrink=True) + if C is not None: + mask = ma.mask_or(mask, C.mask, copy=False, shrink=True) + if mask is ma.nomask: + C = C.filled() + else: + C = ma.array(C, mask=mask, copy=False) + self.U = U.filled(1) + self.V = V.filled(1) + self.Umask = mask + if C is not None: + self.set_array(C) + self.stale = True + + def _dots_per_unit(self, units): + """Return a scale factor for converting from units to pixels.""" + bb = self.axes.bbox + vl = self.axes.viewLim + return _api.check_getitem({ + 'x': bb.width / vl.width, + 'y': bb.height / vl.height, + 'xy': np.hypot(*bb.size) / np.hypot(*vl.size), + 'width': bb.width, + 'height': bb.height, + 'dots': 1., + 'inches': self.axes.figure.dpi, + }, units=units) + + def _set_transform(self): + """ + Set the PolyCollection transform to go + from arrow width units to pixels. + """ + dx = self._dots_per_unit(self.units) + self._trans_scale = dx # pixels per arrow width unit + trans = transforms.Affine2D().scale(dx) + self.set_transform(trans) + return trans + + # Calculate angles and lengths for segment between (x, y), (x+u, y+v) + def _angles_lengths(self, XY, U, V, eps=1): + xy = self.axes.transData.transform(XY) + uv = np.column_stack((U, V)) + xyp = self.axes.transData.transform(XY + eps * uv) + dxy = xyp - xy + angles = np.arctan2(dxy[:, 1], dxy[:, 0]) + lengths = np.hypot(*dxy.T) / eps + return angles, lengths + + # XY is stacked [X, Y]. + # See quiver() doc for meaning of X, Y, U, V, angles. + def _make_verts(self, XY, U, V, angles): + uv = (U + V * 1j) + str_angles = angles if isinstance(angles, str) else '' + if str_angles == 'xy' and self.scale_units == 'xy': + # Here eps is 1 so that if we get U, V by diffing + # the X, Y arrays, the vectors will connect the + # points, regardless of the axis scaling (including log). + angles, lengths = self._angles_lengths(XY, U, V, eps=1) + elif str_angles == 'xy' or self.scale_units == 'xy': + # Calculate eps based on the extents of the plot + # so that we don't end up with roundoff error from + # adding a small number to a large. + eps = np.abs(self.axes.dataLim.extents).max() * 0.001 + angles, lengths = self._angles_lengths(XY, U, V, eps=eps) + + if str_angles and self.scale_units == 'xy': + a = lengths + else: + a = np.abs(uv) + + if self.scale is None: + sn = max(10, math.sqrt(self.N)) + if self.Umask is not ma.nomask: + amean = a[~self.Umask].mean() + else: + amean = a.mean() + # crude auto-scaling + # scale is typical arrow length as a multiple of the arrow width + scale = 1.8 * amean * sn / self.span + + if self.scale_units is None: + if self.scale is None: + self.scale = scale + widthu_per_lenu = 1.0 + else: + if self.scale_units == 'xy': + dx = 1 + else: + dx = self._dots_per_unit(self.scale_units) + widthu_per_lenu = dx / self._trans_scale + if self.scale is None: + self.scale = scale * widthu_per_lenu + length = a * (widthu_per_lenu / (self.scale * self.width)) + X, Y = self._h_arrows(length) + if str_angles == 'xy': + theta = angles + elif str_angles == 'uv': + theta = np.angle(uv) + else: + theta = ma.masked_invalid(np.deg2rad(angles)).filled(0) + theta = theta.reshape((-1, 1)) # for broadcasting + xy = (X + Y * 1j) * np.exp(1j * theta) * self.width + XY = np.stack((xy.real, xy.imag), axis=2) + if self.Umask is not ma.nomask: + XY = ma.array(XY) + XY[self.Umask] = ma.masked + # This might be handled more efficiently with nans, given + # that nans will end up in the paths anyway. + + return XY + + def _h_arrows(self, length): + """Length is in arrow width units.""" + # It might be possible to streamline the code + # and speed it up a bit by using complex (x, y) + # instead of separate arrays; but any gain would be slight. + minsh = self.minshaft * self.headlength + N = len(length) + length = length.reshape(N, 1) + # This number is chosen based on when pixel values overflow in Agg + # causing rendering errors + # length = np.minimum(length, 2 ** 16) + np.clip(length, 0, 2 ** 16, out=length) + # x, y: normal horizontal arrow + x = np.array([0, -self.headaxislength, + -self.headlength, 0], + np.float64) + x = x + np.array([0, 1, 1, 1]) * length + y = 0.5 * np.array([1, 1, self.headwidth, 0], np.float64) + y = np.repeat(y[np.newaxis, :], N, axis=0) + # x0, y0: arrow without shaft, for short vectors + x0 = np.array([0, minsh - self.headaxislength, + minsh - self.headlength, minsh], np.float64) + y0 = 0.5 * np.array([1, 1, self.headwidth, 0], np.float64) + ii = [0, 1, 2, 3, 2, 1, 0, 0] + X = x[:, ii] + Y = y[:, ii] + Y[:, 3:-1] *= -1 + X0 = x0[ii] + Y0 = y0[ii] + Y0[3:-1] *= -1 + shrink = length / minsh if minsh != 0. else 0. + X0 = shrink * X0[np.newaxis, :] + Y0 = shrink * Y0[np.newaxis, :] + short = np.repeat(length < minsh, 8, axis=1) + # Now select X0, Y0 if short, otherwise X, Y + np.copyto(X, X0, where=short) + np.copyto(Y, Y0, where=short) + if self.pivot == 'middle': + X -= 0.5 * X[:, 3, np.newaxis] + elif self.pivot == 'tip': + # numpy bug? using -= does not work here unless we multiply by a + # float first, as with 'mid'. + X = X - X[:, 3, np.newaxis] + elif self.pivot != 'tail': + _api.check_in_list(["middle", "tip", "tail"], pivot=self.pivot) + + tooshort = length < self.minlength + if tooshort.any(): + # Use a heptagonal dot: + th = np.arange(0, 8, 1, np.float64) * (np.pi / 3.0) + x1 = np.cos(th) * self.minlength * 0.5 + y1 = np.sin(th) * self.minlength * 0.5 + X1 = np.repeat(x1[np.newaxis, :], N, axis=0) + Y1 = np.repeat(y1[np.newaxis, :], N, axis=0) + tooshort = np.repeat(tooshort, 8, 1) + np.copyto(X, X1, where=tooshort) + np.copyto(Y, Y1, where=tooshort) + # Mask handling is deferred to the caller, _make_verts. + return X, Y + + +_barbs_doc = r""" +Plot a 2D field of wind barbs. + +Call signature:: + + barbs([X, Y], U, V, [C], **kwargs) + +Where *X*, *Y* define the barb locations, *U*, *V* define the barb +directions, and *C* optionally sets the color. + +All arguments may be 1D or 2D. *U*, *V*, *C* may be masked arrays, but masked +*X*, *Y* are not supported at present. + +Barbs are traditionally used in meteorology as a way to plot the speed +and direction of wind observations, but can technically be used to +plot any two dimensional vector quantity. As opposed to arrows, which +give vector magnitude by the length of the arrow, the barbs give more +quantitative information about the vector magnitude by putting slanted +lines or a triangle for various increments in magnitude, as show +schematically below:: + + : /\ \ + : / \ \ + : / \ \ \ + : / \ \ \ + : ------------------------------ + +The largest increment is given by a triangle (or "flag"). After those +come full lines (barbs). The smallest increment is a half line. There +is only, of course, ever at most 1 half line. If the magnitude is +small and only needs a single half-line and no full lines or +triangles, the half-line is offset from the end of the barb so that it +can be easily distinguished from barbs with a single full line. The +magnitude for the barb shown above would nominally be 65, using the +standard increments of 50, 10, and 5. + +See also https://en.wikipedia.org/wiki/Wind_barb. + +Parameters +---------- +X, Y : 1D or 2D array-like, optional + The x and y coordinates of the barb locations. See *pivot* for how the + barbs are drawn to the x, y positions. + + If not given, they will be generated as a uniform integer meshgrid based + on the dimensions of *U* and *V*. + + If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D + using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)`` + must match the column and row dimensions of *U* and *V*. + +U, V : 1D or 2D array-like + The x and y components of the barb shaft. + +C : 1D or 2D array-like, optional + Numeric data that defines the barb colors by colormapping via *norm* and + *cmap*. + + This does not support explicit colors. If you want to set colors directly, + use *barbcolor* instead. + +length : float, default: 7 + Length of the barb in points; the other parts of the barb + are scaled against this. + +pivot : {'tip', 'middle'} or float, default: 'tip' + The part of the arrow that is anchored to the *X*, *Y* grid. The barb + rotates about this point. This can also be a number, which shifts the + start of the barb that many points away from grid point. + +barbcolor : :mpltype:`color` or color sequence + The color of all parts of the barb except for the flags. This parameter + is analogous to the *edgecolor* parameter for polygons, which can be used + instead. However this parameter will override facecolor. + +flagcolor : :mpltype:`color` or color sequence + The color of any flags on the barb. This parameter is analogous to the + *facecolor* parameter for polygons, which can be used instead. However, + this parameter will override facecolor. If this is not set (and *C* has + not either) then *flagcolor* will be set to match *barbcolor* so that the + barb has a uniform color. If *C* has been set, *flagcolor* has no effect. + +sizes : dict, optional + A dictionary of coefficients specifying the ratio of a given + feature to the length of the barb. Only those values one wishes to + override need to be included. These features include: + + - 'spacing' - space between features (flags, full/half barbs) + - 'height' - height (distance from shaft to top) of a flag or full barb + - 'width' - width of a flag, twice the width of a full barb + - 'emptybarb' - radius of the circle used for low magnitudes + +fill_empty : bool, default: False + Whether the empty barbs (circles) that are drawn should be filled with + the flag color. If they are not filled, the center is transparent. + +rounding : bool, default: True + Whether the vector magnitude should be rounded when allocating barb + components. If True, the magnitude is rounded to the nearest multiple + of the half-barb increment. If False, the magnitude is simply truncated + to the next lowest multiple. + +barb_increments : dict, optional + A dictionary of increments specifying values to associate with + different parts of the barb. Only those values one wishes to + override need to be included. + + - 'half' - half barbs (Default is 5) + - 'full' - full barbs (Default is 10) + - 'flag' - flags (default is 50) + +flip_barb : bool or array-like of bool, default: False + Whether the lines and flags should point opposite to normal. + Normal behavior is for the barbs and lines to point right (comes from wind + barbs having these features point towards low pressure in the Northern + Hemisphere). + + A single value is applied to all barbs. Individual barbs can be flipped by + passing a bool array of the same size as *U* and *V*. + +Returns +------- +barbs : `~matplotlib.quiver.Barbs` + +Other Parameters +---------------- +data : indexable object, optional + DATA_PARAMETER_PLACEHOLDER + +**kwargs + The barbs can further be customized using `.PolyCollection` keyword + arguments: + + %(PolyCollection:kwdoc)s +""" % _docstring.interpd.params + +_docstring.interpd.update(barbs_doc=_barbs_doc) + + +class Barbs(mcollections.PolyCollection): + """ + Specialized PolyCollection for barbs. + + The only API method is :meth:`set_UVC`, which can be used to + change the size, orientation, and color of the arrows. Locations + are changed using the :meth:`set_offsets` collection method. + Possibly this method will be useful in animations. + + There is one internal function :meth:`_find_tails` which finds + exactly what should be put on the barb given the vector magnitude. + From there :meth:`_make_barbs` is used to find the vertices of the + polygon to represent the barb based on this information. + """ + + # This may be an abuse of polygons here to render what is essentially maybe + # 1 triangle and a series of lines. It works fine as far as I can tell + # however. + + @_docstring.interpd + def __init__(self, ax, *args, + pivot='tip', length=7, barbcolor=None, flagcolor=None, + sizes=None, fill_empty=False, barb_increments=None, + rounding=True, flip_barb=False, **kwargs): + """ + The constructor takes one required argument, an Axes + instance, followed by the args and kwargs described + by the following pyplot interface documentation: + %(barbs_doc)s + """ + self.sizes = sizes or dict() + self.fill_empty = fill_empty + self.barb_increments = barb_increments or dict() + self.rounding = rounding + self.flip = np.atleast_1d(flip_barb) + transform = kwargs.pop('transform', ax.transData) + self._pivot = pivot + self._length = length + + # Flagcolor and barbcolor provide convenience parameters for + # setting the facecolor and edgecolor, respectively, of the barb + # polygon. We also work here to make the flag the same color as the + # rest of the barb by default + + if None in (barbcolor, flagcolor): + kwargs['edgecolors'] = 'face' + if flagcolor: + kwargs['facecolors'] = flagcolor + elif barbcolor: + kwargs['facecolors'] = barbcolor + else: + # Set to facecolor passed in or default to black + kwargs.setdefault('facecolors', 'k') + else: + kwargs['edgecolors'] = barbcolor + kwargs['facecolors'] = flagcolor + + # Explicitly set a line width if we're not given one, otherwise + # polygons are not outlined and we get no barbs + if 'linewidth' not in kwargs and 'lw' not in kwargs: + kwargs['linewidth'] = 1 + + # Parse out the data arrays from the various configurations supported + x, y, u, v, c = _parse_args(*args, caller_name='barbs') + self.x = x + self.y = y + xy = np.column_stack((x, y)) + + # Make a collection + barb_size = self._length ** 2 / 4 # Empirically determined + super().__init__( + [], (barb_size,), offsets=xy, offset_transform=transform, **kwargs) + self.set_transform(transforms.IdentityTransform()) + + self.set_UVC(u, v, c) + + def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): + """ + Find how many of each of the tail pieces is necessary. + + Parameters + ---------- + mag : `~numpy.ndarray` + Vector magnitudes; must be non-negative (and an actual ndarray). + rounding : bool, default: True + Whether to round or to truncate to the nearest half-barb. + half, full, flag : float, defaults: 5, 10, 50 + Increments for a half-barb, a barb, and a flag. + + Returns + ------- + n_flags, n_barbs : int array + For each entry in *mag*, the number of flags and barbs. + half_flag : bool array + For each entry in *mag*, whether a half-barb is needed. + empty_flag : bool array + For each entry in *mag*, whether nothing is drawn. + """ + # If rounding, round to the nearest multiple of half, the smallest + # increment + if rounding: + mag = half * np.around(mag / half) + n_flags, mag = divmod(mag, flag) + n_barb, mag = divmod(mag, full) + half_flag = mag >= half + empty_flag = ~(half_flag | (n_flags > 0) | (n_barb > 0)) + return n_flags.astype(int), n_barb.astype(int), half_flag, empty_flag + + def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length, + pivot, sizes, fill_empty, flip): + """ + Create the wind barbs. + + Parameters + ---------- + u, v + Components of the vector in the x and y directions, respectively. + + nflags, nbarbs, half_barb, empty_flag + Respectively, the number of flags, number of barbs, flag for + half a barb, and flag for empty barb, ostensibly obtained from + :meth:`_find_tails`. + + length + The length of the barb staff in points. + + pivot : {"tip", "middle"} or number + The point on the barb around which the entire barb should be + rotated. If a number, the start of the barb is shifted by that + many points from the origin. + + sizes : dict + Coefficients specifying the ratio of a given feature to the length + of the barb. These features include: + + - *spacing*: space between features (flags, full/half barbs). + - *height*: distance from shaft of top of a flag or full barb. + - *width*: width of a flag, twice the width of a full barb. + - *emptybarb*: radius of the circle used for low magnitudes. + + fill_empty : bool + Whether the circle representing an empty barb should be filled or + not (this changes the drawing of the polygon). + + flip : list of bool + Whether the features should be flipped to the other side of the + barb (useful for winds in the southern hemisphere). + + Returns + ------- + list of arrays of vertices + Polygon vertices for each of the wind barbs. These polygons have + been rotated to properly align with the vector direction. + """ + + # These control the spacing and size of barb elements relative to the + # length of the shaft + spacing = length * sizes.get('spacing', 0.125) + full_height = length * sizes.get('height', 0.4) + full_width = length * sizes.get('width', 0.25) + empty_rad = length * sizes.get('emptybarb', 0.15) + + # Controls y point where to pivot the barb. + pivot_points = dict(tip=0.0, middle=-length / 2.) + + endx = 0.0 + try: + endy = float(pivot) + except ValueError: + endy = pivot_points[pivot.lower()] + + # Get the appropriate angle for the vector components. The offset is + # due to the way the barb is initially drawn, going down the y-axis. + # This makes sense in a meteorological mode of thinking since there 0 + # degrees corresponds to north (the y-axis traditionally) + angles = -(ma.arctan2(v, u) + np.pi / 2) + + # Used for low magnitude. We just get the vertices, so if we make it + # out here, it can be reused. The center set here should put the + # center of the circle at the location(offset), rather than at the + # same point as the barb pivot; this seems more sensible. + circ = CirclePolygon((0, 0), radius=empty_rad).get_verts() + if fill_empty: + empty_barb = circ + else: + # If we don't want the empty one filled, we make a degenerate + # polygon that wraps back over itself + empty_barb = np.concatenate((circ, circ[::-1])) + + barb_list = [] + for index, angle in np.ndenumerate(angles): + # If the vector magnitude is too weak to draw anything, plot an + # empty circle instead + if empty_flag[index]: + # We can skip the transform since the circle has no preferred + # orientation + barb_list.append(empty_barb) + continue + + poly_verts = [(endx, endy)] + offset = length + + # Handle if this barb should be flipped + barb_height = -full_height if flip[index] else full_height + + # Add vertices for each flag + for i in range(nflags[index]): + # The spacing that works for the barbs is a little to much for + # the flags, but this only occurs when we have more than 1 + # flag. + if offset != length: + offset += spacing / 2. + poly_verts.extend( + [[endx, endy + offset], + [endx + barb_height, endy - full_width / 2 + offset], + [endx, endy - full_width + offset]]) + + offset -= full_width + spacing + + # Add vertices for each barb. These really are lines, but works + # great adding 3 vertices that basically pull the polygon out and + # back down the line + for i in range(nbarbs[index]): + poly_verts.extend( + [(endx, endy + offset), + (endx + barb_height, endy + offset + full_width / 2), + (endx, endy + offset)]) + + offset -= spacing + + # Add the vertices for half a barb, if needed + if half_barb[index]: + # If the half barb is the first on the staff, traditionally it + # is offset from the end to make it easy to distinguish from a + # barb with a full one + if offset == length: + poly_verts.append((endx, endy + offset)) + offset -= 1.5 * spacing + poly_verts.extend( + [(endx, endy + offset), + (endx + barb_height / 2, endy + offset + full_width / 4), + (endx, endy + offset)]) + + # Rotate the barb according the angle. Making the barb first and + # then rotating it made the math for drawing the barb really easy. + # Also, the transform framework makes doing the rotation simple. + poly_verts = transforms.Affine2D().rotate(-angle).transform( + poly_verts) + barb_list.append(poly_verts) + + return barb_list + + def set_UVC(self, U, V, C=None): + # We need to ensure we have a copy, not a reference to an array that + # might change before draw(). + self.u = ma.masked_invalid(U, copy=True).ravel() + self.v = ma.masked_invalid(V, copy=True).ravel() + + # Flip needs to have the same number of entries as everything else. + # Use broadcast_to to avoid a bloated array of identical values. + # (can't rely on actual broadcasting) + if len(self.flip) == 1: + flip = np.broadcast_to(self.flip, self.u.shape) + else: + flip = self.flip + + if C is not None: + c = ma.masked_invalid(C, copy=True).ravel() + x, y, u, v, c, flip = cbook.delete_masked_points( + self.x.ravel(), self.y.ravel(), self.u, self.v, c, + flip.ravel()) + _check_consistent_shapes(x, y, u, v, c, flip) + else: + x, y, u, v, flip = cbook.delete_masked_points( + self.x.ravel(), self.y.ravel(), self.u, self.v, flip.ravel()) + _check_consistent_shapes(x, y, u, v, flip) + + magnitude = np.hypot(u, v) + flags, barbs, halves, empty = self._find_tails( + magnitude, self.rounding, **self.barb_increments) + + # Get the vertices for each of the barbs + + plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, + self._length, self._pivot, self.sizes, + self.fill_empty, flip) + self.set_verts(plot_barbs) + + # Set the color array + if C is not None: + self.set_array(c) + + # Update the offsets in case the masked data changed + xy = np.column_stack((x, y)) + self._offsets = xy + self.stale = True + + def set_offsets(self, xy): + """ + Set the offsets for the barb polygons. This saves the offsets passed + in and masks them as appropriate for the existing U/V data. + + Parameters + ---------- + xy : sequence of pairs of floats + """ + self.x = xy[:, 0] + self.y = xy[:, 1] + x, y, u, v = cbook.delete_masked_points( + self.x.ravel(), self.y.ravel(), self.u, self.v) + _check_consistent_shapes(x, y, u, v) + xy = np.column_stack((x, y)) + super().set_offsets(xy) + self.stale = True diff --git a/venv/lib/python3.10/site-packages/matplotlib/quiver.pyi b/venv/lib/python3.10/site-packages/matplotlib/quiver.pyi new file mode 100644 index 00000000..2a043a92 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/quiver.pyi @@ -0,0 +1,183 @@ +import matplotlib.artist as martist +import matplotlib.collections as mcollections +from matplotlib.axes import Axes +from matplotlib.figure import Figure +from matplotlib.text import Text +from matplotlib.transforms import Transform, Bbox + + +import numpy as np +from numpy.typing import ArrayLike +from collections.abc import Sequence +from typing import Any, Literal, overload +from matplotlib.typing import ColorType + +class QuiverKey(martist.Artist): + halign: dict[Literal["N", "S", "E", "W"], Literal["left", "center", "right"]] + valign: dict[Literal["N", "S", "E", "W"], Literal["top", "center", "bottom"]] + pivot: dict[Literal["N", "S", "E", "W"], Literal["middle", "tip", "tail"]] + Q: Quiver + X: float + Y: float + U: float + angle: float + coord: Literal["axes", "figure", "data", "inches"] + color: ColorType | None + label: str + labelpos: Literal["N", "S", "E", "W"] + labelcolor: ColorType | None + fontproperties: dict[str, Any] + kw: dict[str, Any] + text: Text + zorder: float + def __init__( + self, + Q: Quiver, + X: float, + Y: float, + U: float, + label: str, + *, + angle: float = ..., + coordinates: Literal["axes", "figure", "data", "inches"] = ..., + color: ColorType | None = ..., + labelsep: float = ..., + labelpos: Literal["N", "S", "E", "W"] = ..., + labelcolor: ColorType | None = ..., + fontproperties: dict[str, Any] | None = ..., + **kwargs + ) -> None: ... + @property + def labelsep(self) -> float: ... + def set_figure(self, fig: Figure) -> None: ... + +class Quiver(mcollections.PolyCollection): + X: ArrayLike + Y: ArrayLike + XY: ArrayLike + U: ArrayLike + V: ArrayLike + Umask: ArrayLike + N: int + scale: float | None + headwidth: float + headlength: float + headaxislength: float + minshaft: float + minlength: float + units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] + scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] | None + angles: Literal["uv", "xy"] | ArrayLike + width: float | None + pivot: Literal["tail", "middle", "tip"] + transform: Transform + polykw: dict[str, Any] + + @overload + def __init__( + self, + ax: Axes, + U: ArrayLike, + V: ArrayLike, + C: ArrayLike = ..., + *, + scale: float | None = ..., + headwidth: float = ..., + headlength: float = ..., + headaxislength: float = ..., + minshaft: float = ..., + minlength: float = ..., + units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] = ..., + scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] + | None = ..., + angles: Literal["uv", "xy"] | ArrayLike = ..., + width: float | None = ..., + color: ColorType | Sequence[ColorType] = ..., + pivot: Literal["tail", "mid", "middle", "tip"] = ..., + **kwargs + ) -> None: ... + @overload + def __init__( + self, + ax: Axes, + X: ArrayLike, + Y: ArrayLike, + U: ArrayLike, + V: ArrayLike, + C: ArrayLike = ..., + *, + scale: float | None = ..., + headwidth: float = ..., + headlength: float = ..., + headaxislength: float = ..., + minshaft: float = ..., + minlength: float = ..., + units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] = ..., + scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] + | None = ..., + angles: Literal["uv", "xy"] | ArrayLike = ..., + width: float | None = ..., + color: ColorType | Sequence[ColorType] = ..., + pivot: Literal["tail", "mid", "middle", "tip"] = ..., + **kwargs + ) -> None: ... + def get_datalim(self, transData: Transform) -> Bbox: ... + def set_UVC( + self, U: ArrayLike, V: ArrayLike, C: ArrayLike | None = ... + ) -> None: ... + +class Barbs(mcollections.PolyCollection): + sizes: dict[str, float] + fill_empty: bool + barb_increments: dict[str, float] + rounding: bool + flip: np.ndarray + x: ArrayLike + y: ArrayLike + u: ArrayLike + v: ArrayLike + + @overload + def __init__( + self, + ax: Axes, + U: ArrayLike, + V: ArrayLike, + C: ArrayLike = ..., + *, + pivot: str = ..., + length: int = ..., + barbcolor: ColorType | Sequence[ColorType] | None = ..., + flagcolor: ColorType | Sequence[ColorType] | None = ..., + sizes: dict[str, float] | None = ..., + fill_empty: bool = ..., + barb_increments: dict[str, float] | None = ..., + rounding: bool = ..., + flip_barb: bool | ArrayLike = ..., + **kwargs + ) -> None: ... + @overload + def __init__( + self, + ax: Axes, + X: ArrayLike, + Y: ArrayLike, + U: ArrayLike, + V: ArrayLike, + C: ArrayLike = ..., + *, + pivot: str = ..., + length: int = ..., + barbcolor: ColorType | Sequence[ColorType] | None = ..., + flagcolor: ColorType | Sequence[ColorType] | None = ..., + sizes: dict[str, float] | None = ..., + fill_empty: bool = ..., + barb_increments: dict[str, float] | None = ..., + rounding: bool = ..., + flip_barb: bool | ArrayLike = ..., + **kwargs + ) -> None: ... + def set_UVC( + self, U: ArrayLike, V: ArrayLike, C: ArrayLike | None = ... + ) -> None: ... + def set_offsets(self, xy: ArrayLike) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/rcsetup.py b/venv/lib/python3.10/site-packages/matplotlib/rcsetup.py new file mode 100644 index 00000000..b0cd2209 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/rcsetup.py @@ -0,0 +1,1377 @@ +""" +The rcsetup module contains the validation code for customization using +Matplotlib's rc settings. + +Each rc setting is assigned a function used to validate any attempted changes +to that setting. The validation functions are defined in the rcsetup module, +and are used to construct the rcParams global object which stores the settings +and is referenced throughout Matplotlib. + +The default values of the rc settings are set in the default matplotlibrc file. +Any additions or deletions to the parameter set listed here should also be +propagated to the :file:`lib/matplotlib/mpl-data/matplotlibrc` in Matplotlib's +root source directory. +""" + +import ast +from functools import lru_cache, reduce +from numbers import Real +import operator +import os +import re + +import numpy as np + +from matplotlib import _api, cbook +from matplotlib.backends import BackendFilter, backend_registry +from matplotlib.cbook import ls_mapper +from matplotlib.colors import Colormap, is_color_like +from matplotlib._fontconfig_pattern import parse_fontconfig_pattern +from matplotlib._enums import JoinStyle, CapStyle + +# Don't let the original cycler collide with our validating cycler +from cycler import Cycler, cycler as ccycler + + +@_api.caching_module_getattr +class __getattr__: + @_api.deprecated( + "3.9", + alternative="``matplotlib.backends.backend_registry.list_builtin" + "(matplotlib.backends.BackendFilter.INTERACTIVE)``") + @property + def interactive_bk(self): + return backend_registry.list_builtin(BackendFilter.INTERACTIVE) + + @_api.deprecated( + "3.9", + alternative="``matplotlib.backends.backend_registry.list_builtin" + "(matplotlib.backends.BackendFilter.NON_INTERACTIVE)``") + @property + def non_interactive_bk(self): + return backend_registry.list_builtin(BackendFilter.NON_INTERACTIVE) + + @_api.deprecated( + "3.9", + alternative="``matplotlib.backends.backend_registry.list_builtin()``") + @property + def all_backends(self): + return backend_registry.list_builtin() + + +class ValidateInStrings: + def __init__(self, key, valid, ignorecase=False, *, + _deprecated_since=None): + """*valid* is a list of legal strings.""" + self.key = key + self.ignorecase = ignorecase + self._deprecated_since = _deprecated_since + + def func(s): + if ignorecase: + return s.lower() + else: + return s + self.valid = {func(k): k for k in valid} + + def __call__(self, s): + if self._deprecated_since: + name, = (k for k, v in globals().items() if v is self) + _api.warn_deprecated( + self._deprecated_since, name=name, obj_type="function") + if self.ignorecase and isinstance(s, str): + s = s.lower() + if s in self.valid: + return self.valid[s] + msg = (f"{s!r} is not a valid value for {self.key}; supported values " + f"are {[*self.valid.values()]}") + if (isinstance(s, str) + and (s.startswith('"') and s.endswith('"') + or s.startswith("'") and s.endswith("'")) + and s[1:-1] in self.valid): + msg += "; remove quotes surrounding your string" + raise ValueError(msg) + + +@lru_cache +def _listify_validator(scalar_validator, allow_stringlist=False, *, + n=None, doc=None): + def f(s): + if isinstance(s, str): + try: + val = [scalar_validator(v.strip()) for v in s.split(',') + if v.strip()] + except Exception: + if allow_stringlist: + # Sometimes, a list of colors might be a single string + # of single-letter colornames. So give that a shot. + val = [scalar_validator(v.strip()) for v in s if v.strip()] + else: + raise + # Allow any ordered sequence type -- generators, np.ndarray, pd.Series + # -- but not sets, whose iteration order is non-deterministic. + elif np.iterable(s) and not isinstance(s, (set, frozenset)): + # The condition on this list comprehension will preserve the + # behavior of filtering out any empty strings (behavior was + # from the original validate_stringlist()), while allowing + # any non-string/text scalar values such as numbers and arrays. + val = [scalar_validator(v) for v in s + if not isinstance(v, str) or v] + else: + raise ValueError( + f"Expected str or other non-set iterable, but got {s}") + if n is not None and len(val) != n: + raise ValueError( + f"Expected {n} values, but there are {len(val)} values in {s}") + return val + + try: + f.__name__ = f"{scalar_validator.__name__}list" + except AttributeError: # class instance. + f.__name__ = f"{type(scalar_validator).__name__}List" + f.__qualname__ = f.__qualname__.rsplit(".", 1)[0] + "." + f.__name__ + f.__doc__ = doc if doc is not None else scalar_validator.__doc__ + return f + + +def validate_any(s): + return s +validate_anylist = _listify_validator(validate_any) + + +def _validate_date(s): + try: + np.datetime64(s) + return s + except ValueError: + raise ValueError( + f'{s!r} should be a string that can be parsed by numpy.datetime64') + + +def validate_bool(b): + """Convert b to ``bool`` or raise.""" + if isinstance(b, str): + b = b.lower() + if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True): + return True + elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False): + return False + else: + raise ValueError(f'Cannot convert {b!r} to bool') + + +def validate_axisbelow(s): + try: + return validate_bool(s) + except ValueError: + if isinstance(s, str): + if s == 'line': + return 'line' + raise ValueError(f'{s!r} cannot be interpreted as' + ' True, False, or "line"') + + +def validate_dpi(s): + """Confirm s is string 'figure' or convert s to float or raise.""" + if s == 'figure': + return s + try: + return float(s) + except ValueError as e: + raise ValueError(f'{s!r} is not string "figure" and ' + f'could not convert {s!r} to float') from e + + +def _make_type_validator(cls, *, allow_none=False): + """ + Return a validator that converts inputs to *cls* or raises (and possibly + allows ``None`` as well). + """ + + def validator(s): + if (allow_none and + (s is None or cbook._str_lower_equal(s, "none"))): + return None + if cls is str and not isinstance(s, str): + raise ValueError(f'Could not convert {s!r} to str') + try: + return cls(s) + except (TypeError, ValueError) as e: + raise ValueError( + f'Could not convert {s!r} to {cls.__name__}') from e + + validator.__name__ = f"validate_{cls.__name__}" + if allow_none: + validator.__name__ += "_or_None" + validator.__qualname__ = ( + validator.__qualname__.rsplit(".", 1)[0] + "." + validator.__name__) + return validator + + +validate_string = _make_type_validator(str) +validate_string_or_None = _make_type_validator(str, allow_none=True) +validate_stringlist = _listify_validator( + validate_string, doc='return a list of strings') +validate_int = _make_type_validator(int) +validate_int_or_None = _make_type_validator(int, allow_none=True) +validate_float = _make_type_validator(float) +validate_float_or_None = _make_type_validator(float, allow_none=True) +validate_floatlist = _listify_validator( + validate_float, doc='return a list of floats') + + +def _validate_marker(s): + try: + return validate_int(s) + except ValueError as e: + try: + return validate_string(s) + except ValueError as e: + raise ValueError('Supported markers are [string, int]') from e + + +_validate_markerlist = _listify_validator( + _validate_marker, doc='return a list of markers') + + +def _validate_pathlike(s): + if isinstance(s, (str, os.PathLike)): + # Store value as str because savefig.directory needs to distinguish + # between "" (cwd) and "." (cwd, but gets updated by user selections). + return os.fsdecode(s) + else: + return validate_string(s) + + +def validate_fonttype(s): + """ + Confirm that this is a Postscript or PDF font type that we know how to + convert to. + """ + fonttypes = {'type3': 3, + 'truetype': 42} + try: + fonttype = validate_int(s) + except ValueError: + try: + return fonttypes[s.lower()] + except KeyError as e: + raise ValueError('Supported Postscript/PDF font types are %s' + % list(fonttypes)) from e + else: + if fonttype not in fonttypes.values(): + raise ValueError( + 'Supported Postscript/PDF font types are %s' % + list(fonttypes.values())) + return fonttype + + +_auto_backend_sentinel = object() + + +def validate_backend(s): + if s is _auto_backend_sentinel or backend_registry.is_valid_backend(s): + return s + else: + msg = (f"'{s}' is not a valid value for backend; supported values are " + f"{backend_registry.list_all()}") + raise ValueError(msg) + + +def _validate_toolbar(s): + s = ValidateInStrings( + 'toolbar', ['None', 'toolbar2', 'toolmanager'], ignorecase=True)(s) + if s == 'toolmanager': + _api.warn_external( + "Treat the new Tool classes introduced in v1.5 as experimental " + "for now; the API and rcParam may change in future versions.") + return s + + +def validate_color_or_inherit(s): + """Return a valid color arg.""" + if cbook._str_equal(s, 'inherit'): + return s + return validate_color(s) + + +def validate_color_or_auto(s): + if cbook._str_equal(s, 'auto'): + return s + return validate_color(s) + + +def validate_color_for_prop_cycle(s): + # N-th color cycle syntax can't go into the color cycle. + if isinstance(s, str) and re.match("^C[0-9]$", s): + raise ValueError(f"Cannot put cycle reference ({s!r}) in prop_cycler") + return validate_color(s) + + +def _validate_color_or_linecolor(s): + if cbook._str_equal(s, 'linecolor'): + return s + elif cbook._str_equal(s, 'mfc') or cbook._str_equal(s, 'markerfacecolor'): + return 'markerfacecolor' + elif cbook._str_equal(s, 'mec') or cbook._str_equal(s, 'markeredgecolor'): + return 'markeredgecolor' + elif s is None: + return None + elif isinstance(s, str) and len(s) == 6 or len(s) == 8: + stmp = '#' + s + if is_color_like(stmp): + return stmp + if s.lower() == 'none': + return None + elif is_color_like(s): + return s + + raise ValueError(f'{s!r} does not look like a color arg') + + +def validate_color(s): + """Return a valid color arg.""" + if isinstance(s, str): + if s.lower() == 'none': + return 'none' + if len(s) == 6 or len(s) == 8: + stmp = '#' + s + if is_color_like(stmp): + return stmp + + if is_color_like(s): + return s + + # If it is still valid, it must be a tuple (as a string from matplotlibrc). + try: + color = ast.literal_eval(s) + except (SyntaxError, ValueError): + pass + else: + if is_color_like(color): + return color + + raise ValueError(f'{s!r} does not look like a color arg') + + +validate_colorlist = _listify_validator( + validate_color, allow_stringlist=True, doc='return a list of colorspecs') + + +def _validate_cmap(s): + _api.check_isinstance((str, Colormap), cmap=s) + return s + + +def validate_aspect(s): + if s in ('auto', 'equal'): + return s + try: + return float(s) + except ValueError as e: + raise ValueError('not a valid aspect specification') from e + + +def validate_fontsize_None(s): + if s is None or s == 'None': + return None + else: + return validate_fontsize(s) + + +def validate_fontsize(s): + fontsizes = ['xx-small', 'x-small', 'small', 'medium', 'large', + 'x-large', 'xx-large', 'smaller', 'larger'] + if isinstance(s, str): + s = s.lower() + if s in fontsizes: + return s + try: + return float(s) + except ValueError as e: + raise ValueError("%s is not a valid font size. Valid font sizes " + "are %s." % (s, ", ".join(fontsizes))) from e + + +validate_fontsizelist = _listify_validator(validate_fontsize) + + +def validate_fontweight(s): + weights = [ + 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', + 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'] + # Note: Historically, weights have been case-sensitive in Matplotlib + if s in weights: + return s + try: + return int(s) + except (ValueError, TypeError) as e: + raise ValueError(f'{s} is not a valid font weight.') from e + + +def validate_fontstretch(s): + stretchvalues = [ + 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', + 'normal', 'semi-expanded', 'expanded', 'extra-expanded', + 'ultra-expanded'] + # Note: Historically, stretchvalues have been case-sensitive in Matplotlib + if s in stretchvalues: + return s + try: + return int(s) + except (ValueError, TypeError) as e: + raise ValueError(f'{s} is not a valid font stretch.') from e + + +def validate_font_properties(s): + parse_fontconfig_pattern(s) + return s + + +def _validate_mathtext_fallback(s): + _fallback_fonts = ['cm', 'stix', 'stixsans'] + if isinstance(s, str): + s = s.lower() + if s is None or s == 'none': + return None + elif s.lower() in _fallback_fonts: + return s + else: + raise ValueError( + f"{s} is not a valid fallback font name. Valid fallback font " + f"names are {','.join(_fallback_fonts)}. Passing 'None' will turn " + "fallback off.") + + +def validate_whiskers(s): + try: + return _listify_validator(validate_float, n=2)(s) + except (TypeError, ValueError): + try: + return float(s) + except ValueError as e: + raise ValueError("Not a valid whisker value [float, " + "(float, float)]") from e + + +def validate_ps_distiller(s): + if isinstance(s, str): + s = s.lower() + if s in ('none', None, 'false', False): + return None + else: + return ValidateInStrings('ps.usedistiller', ['ghostscript', 'xpdf'])(s) + + +def _validate_papersize(s): + # Re-inline this validator when the 'auto' deprecation expires. + s = ValidateInStrings("ps.papersize", + ["figure", "auto", "letter", "legal", "ledger", + *[f"{ab}{i}" for ab in "ab" for i in range(11)]], + ignorecase=True)(s) + if s == "auto": + _api.warn_deprecated("3.8", name="ps.papersize='auto'", + addendum="Pass an explicit paper type, figure, or omit " + "the *ps.papersize* rcParam entirely.") + return s + + +# A validator dedicated to the named line styles, based on the items in +# ls_mapper, and a list of possible strings read from Line2D.set_linestyle +_validate_named_linestyle = ValidateInStrings( + 'linestyle', + [*ls_mapper.keys(), *ls_mapper.values(), 'None', 'none', ' ', ''], + ignorecase=True) + + +def _validate_linestyle(ls): + """ + A validator for all possible line styles, the named ones *and* + the on-off ink sequences. + """ + if isinstance(ls, str): + try: # Look first for a valid named line style, like '--' or 'solid'. + return _validate_named_linestyle(ls) + except ValueError: + pass + try: + ls = ast.literal_eval(ls) # Parsing matplotlibrc. + except (SyntaxError, ValueError): + pass # Will error with the ValueError at the end. + + def _is_iterable_not_string_like(x): + # Explicitly exclude bytes/bytearrays so that they are not + # nonsensically interpreted as sequences of numbers (codepoints). + return np.iterable(x) and not isinstance(x, (str, bytes, bytearray)) + + if _is_iterable_not_string_like(ls): + if len(ls) == 2 and _is_iterable_not_string_like(ls[1]): + # (offset, (on, off, on, off, ...)) + offset, onoff = ls + else: + # For backcompat: (on, off, on, off, ...); the offset is implicit. + offset = 0 + onoff = ls + + if (isinstance(offset, Real) + and len(onoff) % 2 == 0 + and all(isinstance(elem, Real) for elem in onoff)): + return (offset, onoff) + + raise ValueError(f"linestyle {ls!r} is not a valid on-off ink sequence.") + + +validate_fillstyle = ValidateInStrings( + 'markers.fillstyle', ['full', 'left', 'right', 'bottom', 'top', 'none']) + + +validate_fillstylelist = _listify_validator(validate_fillstyle) + + +def validate_markevery(s): + """ + Validate the markevery property of a Line2D object. + + Parameters + ---------- + s : None, int, (int, int), slice, float, (float, float), or list[int] + + Returns + ------- + None, int, (int, int), slice, float, (float, float), or list[int] + """ + # Validate s against type slice float int and None + if isinstance(s, (slice, float, int, type(None))): + return s + # Validate s against type tuple + if isinstance(s, tuple): + if (len(s) == 2 + and (all(isinstance(e, int) for e in s) + or all(isinstance(e, float) for e in s))): + return s + else: + raise TypeError( + "'markevery' tuple must be pair of ints or of floats") + # Validate s against type list + if isinstance(s, list): + if all(isinstance(e, int) for e in s): + return s + else: + raise TypeError( + "'markevery' list must have all elements of type int") + raise TypeError("'markevery' is of an invalid type") + + +validate_markeverylist = _listify_validator(validate_markevery) + + +def validate_bbox(s): + if isinstance(s, str): + s = s.lower() + if s == 'tight': + return s + if s == 'standard': + return None + raise ValueError("bbox should be 'tight' or 'standard'") + elif s is not None: + # Backwards compatibility. None is equivalent to 'standard'. + raise ValueError("bbox should be 'tight' or 'standard'") + return s + + +def validate_sketch(s): + + if isinstance(s, str): + s = s.lower().strip() + if s.startswith("(") and s.endswith(")"): + s = s[1:-1] + if s == 'none' or s is None: + return None + try: + return tuple(_listify_validator(validate_float, n=3)(s)) + except ValueError as exc: + raise ValueError("Expected a (scale, length, randomness) tuple") from exc + + +def _validate_greaterthan_minushalf(s): + s = validate_float(s) + if s > -0.5: + return s + else: + raise RuntimeError(f'Value must be >-0.5; got {s}') + + +def _validate_greaterequal0_lessequal1(s): + s = validate_float(s) + if 0 <= s <= 1: + return s + else: + raise RuntimeError(f'Value must be >=0 and <=1; got {s}') + + +def _validate_int_greaterequal0(s): + s = validate_int(s) + if s >= 0: + return s + else: + raise RuntimeError(f'Value must be >=0; got {s}') + + +def validate_hatch(s): + r""" + Validate a hatch pattern. + A hatch pattern string can have any sequence of the following + characters: ``\ / | - + * . x o O``. + """ + if not isinstance(s, str): + raise ValueError("Hatch pattern must be a string") + _api.check_isinstance(str, hatch_pattern=s) + unknown = set(s) - {'\\', '/', '|', '-', '+', '*', '.', 'x', 'o', 'O'} + if unknown: + raise ValueError("Unknown hatch symbol(s): %s" % list(unknown)) + return s + + +validate_hatchlist = _listify_validator(validate_hatch) +validate_dashlist = _listify_validator(validate_floatlist) + + +def _validate_minor_tick_ndivs(n): + """ + Validate ndiv parameter related to the minor ticks. + It controls the number of minor ticks to be placed between + two major ticks. + """ + + if cbook._str_lower_equal(n, 'auto'): + return n + try: + n = _validate_int_greaterequal0(n) + return n + except (RuntimeError, ValueError): + pass + + raise ValueError("'tick.minor.ndivs' must be 'auto' or non-negative int") + + +_prop_validators = { + 'color': _listify_validator(validate_color_for_prop_cycle, + allow_stringlist=True), + 'linewidth': validate_floatlist, + 'linestyle': _listify_validator(_validate_linestyle), + 'facecolor': validate_colorlist, + 'edgecolor': validate_colorlist, + 'joinstyle': _listify_validator(JoinStyle), + 'capstyle': _listify_validator(CapStyle), + 'fillstyle': validate_fillstylelist, + 'markerfacecolor': validate_colorlist, + 'markersize': validate_floatlist, + 'markeredgewidth': validate_floatlist, + 'markeredgecolor': validate_colorlist, + 'markevery': validate_markeverylist, + 'alpha': validate_floatlist, + 'marker': _validate_markerlist, + 'hatch': validate_hatchlist, + 'dashes': validate_dashlist, + } +_prop_aliases = { + 'c': 'color', + 'lw': 'linewidth', + 'ls': 'linestyle', + 'fc': 'facecolor', + 'ec': 'edgecolor', + 'mfc': 'markerfacecolor', + 'mec': 'markeredgecolor', + 'mew': 'markeredgewidth', + 'ms': 'markersize', + } + + +def cycler(*args, **kwargs): + """ + Create a `~cycler.Cycler` object much like :func:`cycler.cycler`, + but includes input validation. + + Call signatures:: + + cycler(cycler) + cycler(label=values[, label2=values2[, ...]]) + cycler(label, values) + + Form 1 copies a given `~cycler.Cycler` object. + + Form 2 creates a `~cycler.Cycler` which cycles over one or more + properties simultaneously. If multiple properties are given, their + value lists must have the same length. + + Form 3 creates a `~cycler.Cycler` for a single property. This form + exists for compatibility with the original cycler. Its use is + discouraged in favor of the kwarg form, i.e. ``cycler(label=values)``. + + Parameters + ---------- + cycler : Cycler + Copy constructor for Cycler. + + label : str + The property key. Must be a valid `.Artist` property. + For example, 'color' or 'linestyle'. Aliases are allowed, + such as 'c' for 'color' and 'lw' for 'linewidth'. + + values : iterable + Finite-length iterable of the property values. These values + are validated and will raise a ValueError if invalid. + + Returns + ------- + Cycler + A new :class:`~cycler.Cycler` for the given properties. + + Examples + -------- + Creating a cycler for a single property: + + >>> c = cycler(color=['red', 'green', 'blue']) + + Creating a cycler for simultaneously cycling over multiple properties + (e.g. red circle, green plus, blue cross): + + >>> c = cycler(color=['red', 'green', 'blue'], + ... marker=['o', '+', 'x']) + + """ + if args and kwargs: + raise TypeError("cycler() can only accept positional OR keyword " + "arguments -- not both.") + elif not args and not kwargs: + raise TypeError("cycler() must have positional OR keyword arguments") + + if len(args) == 1: + if not isinstance(args[0], Cycler): + raise TypeError("If only one positional argument given, it must " + "be a Cycler instance.") + return validate_cycler(args[0]) + elif len(args) == 2: + pairs = [(args[0], args[1])] + elif len(args) > 2: + raise _api.nargs_error('cycler', '0-2', len(args)) + else: + pairs = kwargs.items() + + validated = [] + for prop, vals in pairs: + norm_prop = _prop_aliases.get(prop, prop) + validator = _prop_validators.get(norm_prop, None) + if validator is None: + raise TypeError("Unknown artist property: %s" % prop) + vals = validator(vals) + # We will normalize the property names as well to reduce + # the amount of alias handling code elsewhere. + validated.append((norm_prop, vals)) + + return reduce(operator.add, (ccycler(k, v) for k, v in validated)) + + +class _DunderChecker(ast.NodeVisitor): + def visit_Attribute(self, node): + if node.attr.startswith("__") and node.attr.endswith("__"): + raise ValueError("cycler strings with dunders are forbidden") + self.generic_visit(node) + + +# A validator dedicated to the named legend loc +_validate_named_legend_loc = ValidateInStrings( + 'legend.loc', + [ + "best", + "upper right", "upper left", "lower left", "lower right", "right", + "center left", "center right", "lower center", "upper center", + "center"], + ignorecase=True) + + +def _validate_legend_loc(loc): + """ + Confirm that loc is a type which rc.Params["legend.loc"] supports. + + .. versionadded:: 3.8 + + Parameters + ---------- + loc : str | int | (float, float) | str((float, float)) + The location of the legend. + + Returns + ------- + loc : str | int | (float, float) or raise ValueError exception + The location of the legend. + """ + if isinstance(loc, str): + try: + return _validate_named_legend_loc(loc) + except ValueError: + pass + try: + loc = ast.literal_eval(loc) + except (SyntaxError, ValueError): + pass + if isinstance(loc, int): + if 0 <= loc <= 10: + return loc + if isinstance(loc, tuple): + if len(loc) == 2 and all(isinstance(e, Real) for e in loc): + return loc + raise ValueError(f"{loc} is not a valid legend location.") + + +def validate_cycler(s): + """Return a Cycler object from a string repr or the object itself.""" + if isinstance(s, str): + # TODO: We might want to rethink this... + # While I think I have it quite locked down, it is execution of + # arbitrary code without sanitation. + # Combine this with the possibility that rcparams might come from the + # internet (future plans), this could be downright dangerous. + # I locked it down by only having the 'cycler()' function available. + # UPDATE: Partly plugging a security hole. + # I really should have read this: + # https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html + # We should replace this eval with a combo of PyParsing and + # ast.literal_eval() + try: + _DunderChecker().visit(ast.parse(s)) + s = eval(s, {'cycler': cycler, '__builtins__': {}}) + except BaseException as e: + raise ValueError(f"{s!r} is not a valid cycler construction: {e}" + ) from e + # Should make sure what comes from the above eval() + # is a Cycler object. + if isinstance(s, Cycler): + cycler_inst = s + else: + raise ValueError(f"Object is not a string or Cycler instance: {s!r}") + + unknowns = cycler_inst.keys - (set(_prop_validators) | set(_prop_aliases)) + if unknowns: + raise ValueError("Unknown artist properties: %s" % unknowns) + + # Not a full validation, but it'll at least normalize property names + # A fuller validation would require v0.10 of cycler. + checker = set() + for prop in cycler_inst.keys: + norm_prop = _prop_aliases.get(prop, prop) + if norm_prop != prop and norm_prop in cycler_inst.keys: + raise ValueError(f"Cannot specify both {norm_prop!r} and alias " + f"{prop!r} in the same prop_cycle") + if norm_prop in checker: + raise ValueError(f"Another property was already aliased to " + f"{norm_prop!r}. Collision normalizing {prop!r}.") + checker.update([norm_prop]) + + # This is just an extra-careful check, just in case there is some + # edge-case I haven't thought of. + assert len(checker) == len(cycler_inst.keys) + + # Now, it should be safe to mutate this cycler + for prop in cycler_inst.keys: + norm_prop = _prop_aliases.get(prop, prop) + cycler_inst.change_key(prop, norm_prop) + + for key, vals in cycler_inst.by_key().items(): + _prop_validators[key](vals) + + return cycler_inst + + +def validate_hist_bins(s): + valid_strs = ["auto", "sturges", "fd", "doane", "scott", "rice", "sqrt"] + if isinstance(s, str) and s in valid_strs: + return s + try: + return int(s) + except (TypeError, ValueError): + pass + try: + return validate_floatlist(s) + except ValueError: + pass + raise ValueError(f"'hist.bins' must be one of {valid_strs}, an int or" + " a sequence of floats") + + +class _ignorecase(list): + """A marker class indicating that a list-of-str is case-insensitive.""" + + +def _convert_validator_spec(key, conv): + if isinstance(conv, list): + ignorecase = isinstance(conv, _ignorecase) + return ValidateInStrings(key, conv, ignorecase=ignorecase) + else: + return conv + + +# Mapping of rcParams to validators. +# Converters given as lists or _ignorecase are converted to ValidateInStrings +# immediately below. +# The rcParams defaults are defined in lib/matplotlib/mpl-data/matplotlibrc, which +# gets copied to matplotlib/mpl-data/matplotlibrc by the setup script. +_validators = { + "backend": validate_backend, + "backend_fallback": validate_bool, + "figure.hooks": validate_stringlist, + "toolbar": _validate_toolbar, + "interactive": validate_bool, + "timezone": validate_string, + + "webagg.port": validate_int, + "webagg.address": validate_string, + "webagg.open_in_browser": validate_bool, + "webagg.port_retries": validate_int, + + # line props + "lines.linewidth": validate_float, # line width in points + "lines.linestyle": _validate_linestyle, # solid line + "lines.color": validate_color, # first color in color cycle + "lines.marker": _validate_marker, # marker name + "lines.markerfacecolor": validate_color_or_auto, # default color + "lines.markeredgecolor": validate_color_or_auto, # default color + "lines.markeredgewidth": validate_float, + "lines.markersize": validate_float, # markersize, in points + "lines.antialiased": validate_bool, # antialiased (no jaggies) + "lines.dash_joinstyle": JoinStyle, + "lines.solid_joinstyle": JoinStyle, + "lines.dash_capstyle": CapStyle, + "lines.solid_capstyle": CapStyle, + "lines.dashed_pattern": validate_floatlist, + "lines.dashdot_pattern": validate_floatlist, + "lines.dotted_pattern": validate_floatlist, + "lines.scale_dashes": validate_bool, + + # marker props + "markers.fillstyle": validate_fillstyle, + + ## pcolor(mesh) props: + "pcolor.shading": ["auto", "flat", "nearest", "gouraud"], + "pcolormesh.snap": validate_bool, + + ## patch props + "patch.linewidth": validate_float, # line width in points + "patch.edgecolor": validate_color, + "patch.force_edgecolor": validate_bool, + "patch.facecolor": validate_color, # first color in cycle + "patch.antialiased": validate_bool, # antialiased (no jaggies) + + ## hatch props + "hatch.color": validate_color, + "hatch.linewidth": validate_float, + + ## Histogram properties + "hist.bins": validate_hist_bins, + + ## Boxplot properties + "boxplot.notch": validate_bool, + "boxplot.vertical": validate_bool, + "boxplot.whiskers": validate_whiskers, + "boxplot.bootstrap": validate_int_or_None, + "boxplot.patchartist": validate_bool, + "boxplot.showmeans": validate_bool, + "boxplot.showcaps": validate_bool, + "boxplot.showbox": validate_bool, + "boxplot.showfliers": validate_bool, + "boxplot.meanline": validate_bool, + + "boxplot.flierprops.color": validate_color, + "boxplot.flierprops.marker": _validate_marker, + "boxplot.flierprops.markerfacecolor": validate_color_or_auto, + "boxplot.flierprops.markeredgecolor": validate_color, + "boxplot.flierprops.markeredgewidth": validate_float, + "boxplot.flierprops.markersize": validate_float, + "boxplot.flierprops.linestyle": _validate_linestyle, + "boxplot.flierprops.linewidth": validate_float, + + "boxplot.boxprops.color": validate_color, + "boxplot.boxprops.linewidth": validate_float, + "boxplot.boxprops.linestyle": _validate_linestyle, + + "boxplot.whiskerprops.color": validate_color, + "boxplot.whiskerprops.linewidth": validate_float, + "boxplot.whiskerprops.linestyle": _validate_linestyle, + + "boxplot.capprops.color": validate_color, + "boxplot.capprops.linewidth": validate_float, + "boxplot.capprops.linestyle": _validate_linestyle, + + "boxplot.medianprops.color": validate_color, + "boxplot.medianprops.linewidth": validate_float, + "boxplot.medianprops.linestyle": _validate_linestyle, + + "boxplot.meanprops.color": validate_color, + "boxplot.meanprops.marker": _validate_marker, + "boxplot.meanprops.markerfacecolor": validate_color, + "boxplot.meanprops.markeredgecolor": validate_color, + "boxplot.meanprops.markersize": validate_float, + "boxplot.meanprops.linestyle": _validate_linestyle, + "boxplot.meanprops.linewidth": validate_float, + + ## font props + "font.family": validate_stringlist, # used by text object + "font.style": validate_string, + "font.variant": validate_string, + "font.stretch": validate_fontstretch, + "font.weight": validate_fontweight, + "font.size": validate_float, # Base font size in points + "font.serif": validate_stringlist, + "font.sans-serif": validate_stringlist, + "font.cursive": validate_stringlist, + "font.fantasy": validate_stringlist, + "font.monospace": validate_stringlist, + + # text props + "text.color": validate_color, + "text.usetex": validate_bool, + "text.latex.preamble": validate_string, + "text.hinting": ["default", "no_autohint", "force_autohint", + "no_hinting", "auto", "native", "either", "none"], + "text.hinting_factor": validate_int, + "text.kerning_factor": validate_int, + "text.antialiased": validate_bool, + "text.parse_math": validate_bool, + + "mathtext.cal": validate_font_properties, + "mathtext.rm": validate_font_properties, + "mathtext.tt": validate_font_properties, + "mathtext.it": validate_font_properties, + "mathtext.bf": validate_font_properties, + "mathtext.bfit": validate_font_properties, + "mathtext.sf": validate_font_properties, + "mathtext.fontset": ["dejavusans", "dejavuserif", "cm", "stix", + "stixsans", "custom"], + "mathtext.default": ["rm", "cal", "bfit", "it", "tt", "sf", "bf", "default", + "bb", "frak", "scr", "regular"], + "mathtext.fallback": _validate_mathtext_fallback, + + "image.aspect": validate_aspect, # equal, auto, a number + "image.interpolation": validate_string, + "image.interpolation_stage": ["data", "rgba"], + "image.cmap": _validate_cmap, # gray, jet, etc. + "image.lut": validate_int, # lookup table + "image.origin": ["upper", "lower"], + "image.resample": validate_bool, + # Specify whether vector graphics backends will combine all images on a + # set of Axes into a single composite image + "image.composite_image": validate_bool, + + # contour props + "contour.negative_linestyle": _validate_linestyle, + "contour.corner_mask": validate_bool, + "contour.linewidth": validate_float_or_None, + "contour.algorithm": ["mpl2005", "mpl2014", "serial", "threaded"], + + # errorbar props + "errorbar.capsize": validate_float, + + # axis props + # alignment of x/y axis title + "xaxis.labellocation": ["left", "center", "right"], + "yaxis.labellocation": ["bottom", "center", "top"], + + # Axes props + "axes.axisbelow": validate_axisbelow, + "axes.facecolor": validate_color, # background color + "axes.edgecolor": validate_color, # edge color + "axes.linewidth": validate_float, # edge linewidth + + "axes.spines.left": validate_bool, # Set visibility of axes spines, + "axes.spines.right": validate_bool, # i.e., the lines around the chart + "axes.spines.bottom": validate_bool, # denoting data boundary. + "axes.spines.top": validate_bool, + + "axes.titlesize": validate_fontsize, # Axes title fontsize + "axes.titlelocation": ["left", "center", "right"], # Axes title alignment + "axes.titleweight": validate_fontweight, # Axes title font weight + "axes.titlecolor": validate_color_or_auto, # Axes title font color + # title location, axes units, None means auto + "axes.titley": validate_float_or_None, + # pad from Axes top decoration to title in points + "axes.titlepad": validate_float, + "axes.grid": validate_bool, # display grid or not + "axes.grid.which": ["minor", "both", "major"], # which grids are drawn + "axes.grid.axis": ["x", "y", "both"], # grid type + "axes.labelsize": validate_fontsize, # fontsize of x & y labels + "axes.labelpad": validate_float, # space between label and axis + "axes.labelweight": validate_fontweight, # fontsize of x & y labels + "axes.labelcolor": validate_color, # color of axis label + # use scientific notation if log10 of the axis range is smaller than the + # first or larger than the second + "axes.formatter.limits": _listify_validator(validate_int, n=2), + # use current locale to format ticks + "axes.formatter.use_locale": validate_bool, + "axes.formatter.use_mathtext": validate_bool, + # minimum exponent to format in scientific notation + "axes.formatter.min_exponent": validate_int, + "axes.formatter.useoffset": validate_bool, + "axes.formatter.offset_threshold": validate_int, + "axes.unicode_minus": validate_bool, + # This entry can be either a cycler object or a string repr of a + # cycler-object, which gets eval()'ed to create the object. + "axes.prop_cycle": validate_cycler, + # If "data", axes limits are set close to the data. + # If "round_numbers" axes limits are set to the nearest round numbers. + "axes.autolimit_mode": ["data", "round_numbers"], + "axes.xmargin": _validate_greaterthan_minushalf, # margin added to xaxis + "axes.ymargin": _validate_greaterthan_minushalf, # margin added to yaxis + "axes.zmargin": _validate_greaterthan_minushalf, # margin added to zaxis + + "polaraxes.grid": validate_bool, # display polar grid or not + "axes3d.grid": validate_bool, # display 3d grid + "axes3d.automargin": validate_bool, # automatically add margin when + # manually setting 3D axis limits + + "axes3d.xaxis.panecolor": validate_color, # 3d background pane + "axes3d.yaxis.panecolor": validate_color, # 3d background pane + "axes3d.zaxis.panecolor": validate_color, # 3d background pane + + # scatter props + "scatter.marker": _validate_marker, + "scatter.edgecolors": validate_string, + + "date.epoch": _validate_date, + "date.autoformatter.year": validate_string, + "date.autoformatter.month": validate_string, + "date.autoformatter.day": validate_string, + "date.autoformatter.hour": validate_string, + "date.autoformatter.minute": validate_string, + "date.autoformatter.second": validate_string, + "date.autoformatter.microsecond": validate_string, + + 'date.converter': ['auto', 'concise'], + # for auto date locator, choose interval_multiples + 'date.interval_multiples': validate_bool, + + # legend properties + "legend.fancybox": validate_bool, + "legend.loc": _validate_legend_loc, + + # the number of points in the legend line + "legend.numpoints": validate_int, + # the number of points in the legend line for scatter + "legend.scatterpoints": validate_int, + "legend.fontsize": validate_fontsize, + "legend.title_fontsize": validate_fontsize_None, + # color of the legend + "legend.labelcolor": _validate_color_or_linecolor, + # the relative size of legend markers vs. original + "legend.markerscale": validate_float, + # using dict in rcParams not yet supported, so make sure it is bool + "legend.shadow": validate_bool, + # whether or not to draw a frame around legend + "legend.frameon": validate_bool, + # alpha value of the legend frame + "legend.framealpha": validate_float_or_None, + + ## the following dimensions are in fraction of the font size + "legend.borderpad": validate_float, # units are fontsize + # the vertical space between the legend entries + "legend.labelspacing": validate_float, + # the length of the legend lines + "legend.handlelength": validate_float, + # the length of the legend lines + "legend.handleheight": validate_float, + # the space between the legend line and legend text + "legend.handletextpad": validate_float, + # the border between the Axes and legend edge + "legend.borderaxespad": validate_float, + # the border between the Axes and legend edge + "legend.columnspacing": validate_float, + "legend.facecolor": validate_color_or_inherit, + "legend.edgecolor": validate_color_or_inherit, + + # tick properties + "xtick.top": validate_bool, # draw ticks on top side + "xtick.bottom": validate_bool, # draw ticks on bottom side + "xtick.labeltop": validate_bool, # draw label on top + "xtick.labelbottom": validate_bool, # draw label on bottom + "xtick.major.size": validate_float, # major xtick size in points + "xtick.minor.size": validate_float, # minor xtick size in points + "xtick.major.width": validate_float, # major xtick width in points + "xtick.minor.width": validate_float, # minor xtick width in points + "xtick.major.pad": validate_float, # distance to label in points + "xtick.minor.pad": validate_float, # distance to label in points + "xtick.color": validate_color, # color of xticks + "xtick.labelcolor": validate_color_or_inherit, # color of xtick labels + "xtick.minor.visible": validate_bool, # visibility of minor xticks + "xtick.minor.top": validate_bool, # draw top minor xticks + "xtick.minor.bottom": validate_bool, # draw bottom minor xticks + "xtick.major.top": validate_bool, # draw top major xticks + "xtick.major.bottom": validate_bool, # draw bottom major xticks + # number of minor xticks + "xtick.minor.ndivs": _validate_minor_tick_ndivs, + "xtick.labelsize": validate_fontsize, # fontsize of xtick labels + "xtick.direction": ["out", "in", "inout"], # direction of xticks + "xtick.alignment": ["center", "right", "left"], + + "ytick.left": validate_bool, # draw ticks on left side + "ytick.right": validate_bool, # draw ticks on right side + "ytick.labelleft": validate_bool, # draw tick labels on left side + "ytick.labelright": validate_bool, # draw tick labels on right side + "ytick.major.size": validate_float, # major ytick size in points + "ytick.minor.size": validate_float, # minor ytick size in points + "ytick.major.width": validate_float, # major ytick width in points + "ytick.minor.width": validate_float, # minor ytick width in points + "ytick.major.pad": validate_float, # distance to label in points + "ytick.minor.pad": validate_float, # distance to label in points + "ytick.color": validate_color, # color of yticks + "ytick.labelcolor": validate_color_or_inherit, # color of ytick labels + "ytick.minor.visible": validate_bool, # visibility of minor yticks + "ytick.minor.left": validate_bool, # draw left minor yticks + "ytick.minor.right": validate_bool, # draw right minor yticks + "ytick.major.left": validate_bool, # draw left major yticks + "ytick.major.right": validate_bool, # draw right major yticks + # number of minor yticks + "ytick.minor.ndivs": _validate_minor_tick_ndivs, + "ytick.labelsize": validate_fontsize, # fontsize of ytick labels + "ytick.direction": ["out", "in", "inout"], # direction of yticks + "ytick.alignment": [ + "center", "top", "bottom", "baseline", "center_baseline"], + + "grid.color": validate_color, # grid color + "grid.linestyle": _validate_linestyle, # solid + "grid.linewidth": validate_float, # in points + "grid.alpha": validate_float, + + ## figure props + # figure title + "figure.titlesize": validate_fontsize, + "figure.titleweight": validate_fontweight, + + # figure labels + "figure.labelsize": validate_fontsize, + "figure.labelweight": validate_fontweight, + + # figure size in inches: width by height + "figure.figsize": _listify_validator(validate_float, n=2), + "figure.dpi": validate_float, + "figure.facecolor": validate_color, + "figure.edgecolor": validate_color, + "figure.frameon": validate_bool, + "figure.autolayout": validate_bool, + "figure.max_open_warning": validate_int, + "figure.raise_window": validate_bool, + "macosx.window_mode": ["system", "tab", "window"], + + "figure.subplot.left": validate_float, + "figure.subplot.right": validate_float, + "figure.subplot.bottom": validate_float, + "figure.subplot.top": validate_float, + "figure.subplot.wspace": validate_float, + "figure.subplot.hspace": validate_float, + + "figure.constrained_layout.use": validate_bool, # run constrained_layout? + # wspace and hspace are fraction of adjacent subplots to use for space. + # Much smaller than above because we don't need room for the text. + "figure.constrained_layout.hspace": validate_float, + "figure.constrained_layout.wspace": validate_float, + # buffer around the Axes, in inches. + "figure.constrained_layout.h_pad": validate_float, + "figure.constrained_layout.w_pad": validate_float, + + ## Saving figure's properties + 'savefig.dpi': validate_dpi, + 'savefig.facecolor': validate_color_or_auto, + 'savefig.edgecolor': validate_color_or_auto, + 'savefig.orientation': ['landscape', 'portrait'], + "savefig.format": validate_string, + "savefig.bbox": validate_bbox, # "tight", or "standard" (= None) + "savefig.pad_inches": validate_float, + # default directory in savefig dialog box + "savefig.directory": _validate_pathlike, + "savefig.transparent": validate_bool, + + "tk.window_focus": validate_bool, # Maintain shell focus for TkAgg + + # Set the papersize/type + "ps.papersize": _validate_papersize, + "ps.useafm": validate_bool, + # use ghostscript or xpdf to distill ps output + "ps.usedistiller": validate_ps_distiller, + "ps.distiller.res": validate_int, # dpi + "ps.fonttype": validate_fonttype, # 3 (Type3) or 42 (Truetype) + "pdf.compression": validate_int, # 0-9 compression level; 0 to disable + "pdf.inheritcolor": validate_bool, # skip color setting commands + # use only the 14 PDF core fonts embedded in every PDF viewing application + "pdf.use14corefonts": validate_bool, + "pdf.fonttype": validate_fonttype, # 3 (Type3) or 42 (Truetype) + + "pgf.texsystem": ["xelatex", "lualatex", "pdflatex"], # latex variant used + "pgf.rcfonts": validate_bool, # use mpl's rc settings for font config + "pgf.preamble": validate_string, # custom LaTeX preamble + + # write raster image data into the svg file + "svg.image_inline": validate_bool, + "svg.fonttype": ["none", "path"], # save text as text ("none") or "paths" + "svg.hashsalt": validate_string_or_None, + + # set this when you want to generate hardcopy docstring + "docstring.hardcopy": validate_bool, + + "path.simplify": validate_bool, + "path.simplify_threshold": _validate_greaterequal0_lessequal1, + "path.snap": validate_bool, + "path.sketch": validate_sketch, + "path.effects": validate_anylist, + "agg.path.chunksize": validate_int, # 0 to disable chunking + + # key-mappings (multi-character mappings should be a list/tuple) + "keymap.fullscreen": validate_stringlist, + "keymap.home": validate_stringlist, + "keymap.back": validate_stringlist, + "keymap.forward": validate_stringlist, + "keymap.pan": validate_stringlist, + "keymap.zoom": validate_stringlist, + "keymap.save": validate_stringlist, + "keymap.quit": validate_stringlist, + "keymap.quit_all": validate_stringlist, # e.g.: "W", "cmd+W", "Q" + "keymap.grid": validate_stringlist, + "keymap.grid_minor": validate_stringlist, + "keymap.yscale": validate_stringlist, + "keymap.xscale": validate_stringlist, + "keymap.help": validate_stringlist, + "keymap.copy": validate_stringlist, + + # Animation settings + "animation.html": ["html5", "jshtml", "none"], + # Limit, in MB, of size of base64 encoded animation in HTML + # (i.e. IPython notebook) + "animation.embed_limit": validate_float, + "animation.writer": validate_string, + "animation.codec": validate_string, + "animation.bitrate": validate_int, + # Controls image format when frames are written to disk + "animation.frame_format": ["png", "jpeg", "tiff", "raw", "rgba", "ppm", + "sgi", "bmp", "pbm", "svg"], + # Path to ffmpeg binary. If just binary name, subprocess uses $PATH. + "animation.ffmpeg_path": _validate_pathlike, + # Additional arguments for ffmpeg movie writer (using pipes) + "animation.ffmpeg_args": validate_stringlist, + # Path to convert binary. If just binary name, subprocess uses $PATH. + "animation.convert_path": _validate_pathlike, + # Additional arguments for convert movie writer (using pipes) + "animation.convert_args": validate_stringlist, + + # Classic (pre 2.0) compatibility mode + # This is used for things that are hard to make backward compatible + # with a sane rcParam alone. This does *not* turn on classic mode + # altogether. For that use `matplotlib.style.use("classic")`. + "_internal.classic_mode": validate_bool +} +_hardcoded_defaults = { # Defaults not inferred from + # lib/matplotlib/mpl-data/matplotlibrc... + # ... because they are private: + "_internal.classic_mode": False, + # ... because they are deprecated: + # No current deprecations. + # backend is handled separately when constructing rcParamsDefault. +} +_validators = {k: _convert_validator_spec(k, conv) + for k, conv in _validators.items()} diff --git a/venv/lib/python3.10/site-packages/matplotlib/rcsetup.pyi b/venv/lib/python3.10/site-packages/matplotlib/rcsetup.pyi new file mode 100644 index 00000000..1538dac7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/rcsetup.pyi @@ -0,0 +1,159 @@ +from cycler import Cycler + +from collections.abc import Callable, Iterable +from typing import Any, Literal, TypeVar +from matplotlib.typing import ColorType, LineStyleType, MarkEveryType + +interactive_bk: list[str] +non_interactive_bk: list[str] +all_backends: list[str] + +_T = TypeVar("_T") + +def _listify_validator(s: Callable[[Any], _T]) -> Callable[[Any], list[_T]]: ... + +class ValidateInStrings: + key: str + ignorecase: bool + valid: dict[str, str] + def __init__( + self, + key: str, + valid: Iterable[str], + ignorecase: bool = ..., + *, + _deprecated_since: str | None = ... + ) -> None: ... + def __call__(self, s: Any) -> str: ... + +def validate_any(s: Any) -> Any: ... +def validate_anylist(s: Any) -> list[Any]: ... +def validate_bool(b: Any) -> bool: ... +def validate_axisbelow(s: Any) -> bool | Literal["line"]: ... +def validate_dpi(s: Any) -> Literal["figure"] | float: ... +def validate_string(s: Any) -> str: ... +def validate_string_or_None(s: Any) -> str | None: ... +def validate_stringlist(s: Any) -> list[str]: ... +def validate_int(s: Any) -> int: ... +def validate_int_or_None(s: Any) -> int | None: ... +def validate_float(s: Any) -> float: ... +def validate_float_or_None(s: Any) -> float | None: ... +def validate_floatlist(s: Any) -> list[float]: ... +def _validate_marker(s: Any) -> int | str: ... +def _validate_markerlist(s: Any) -> list[int | str]: ... +def validate_fonttype(s: Any) -> int: ... + +_auto_backend_sentinel: object + +def validate_backend(s: Any) -> str: ... +def validate_color_or_inherit(s: Any) -> Literal["inherit"] | ColorType: ... +def validate_color_or_auto(s: Any) -> ColorType | Literal["auto"]: ... +def validate_color_for_prop_cycle(s: Any) -> ColorType: ... +def validate_color(s: Any) -> ColorType: ... +def validate_colorlist(s: Any) -> list[ColorType]: ... +def _validate_color_or_linecolor( + s: Any, +) -> ColorType | Literal["linecolor", "markerfacecolor", "markeredgecolor"] | None: ... +def validate_aspect(s: Any) -> Literal["auto", "equal"] | float: ... +def validate_fontsize_None( + s: Any, +) -> Literal[ + "xx-small", + "x-small", + "small", + "medium", + "large", + "x-large", + "xx-large", + "smaller", + "larger", +] | float | None: ... +def validate_fontsize( + s: Any, +) -> Literal[ + "xx-small", + "x-small", + "small", + "medium", + "large", + "x-large", + "xx-large", + "smaller", + "larger", +] | float: ... +def validate_fontsizelist( + s: Any, +) -> list[ + Literal[ + "xx-small", + "x-small", + "small", + "medium", + "large", + "x-large", + "xx-large", + "smaller", + "larger", + ] + | float +]: ... +def validate_fontweight( + s: Any, +) -> Literal[ + "ultralight", + "light", + "normal", + "regular", + "book", + "medium", + "roman", + "semibold", + "demibold", + "demi", + "bold", + "heavy", + "extra bold", + "black", +] | int: ... +def validate_fontstretch( + s: Any, +) -> Literal[ + "ultra-condensed", + "extra-condensed", + "condensed", + "semi-condensed", + "normal", + "semi-expanded", + "expanded", + "extra-expanded", + "ultra-expanded", +] | int: ... +def validate_font_properties(s: Any) -> dict[str, Any]: ... +def validate_whiskers(s: Any) -> list[float] | float: ... +def validate_ps_distiller(s: Any) -> None | Literal["ghostscript", "xpdf"]: ... + +validate_fillstyle: ValidateInStrings + +def validate_fillstylelist( + s: Any, +) -> list[Literal["full", "left", "right", "bottom", "top", "none"]]: ... +def validate_markevery(s: Any) -> MarkEveryType: ... +def _validate_linestyle(s: Any) -> LineStyleType: ... +def validate_markeverylist(s: Any) -> list[MarkEveryType]: ... +def validate_bbox(s: Any) -> Literal["tight", "standard"] | None: ... +def validate_sketch(s: Any) -> None | tuple[float, float, float]: ... +def validate_hatch(s: Any) -> str: ... +def validate_hatchlist(s: Any) -> list[str]: ... +def validate_dashlist(s: Any) -> list[list[float]]: ... + +# TODO: copy cycler overloads? +def cycler(*args, **kwargs) -> Cycler: ... +def validate_cycler(s: Any) -> Cycler: ... +def validate_hist_bins( + s: Any, +) -> Literal["auto", "sturges", "fd", "doane", "scott", "rice", "sqrt"] | int | list[ + float +]: ... + +# At runtime is added in __init__.py +defaultParams: dict[str, Any] diff --git a/venv/lib/python3.10/site-packages/matplotlib/sankey.py b/venv/lib/python3.10/site-packages/matplotlib/sankey.py new file mode 100644 index 00000000..665b9d6d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/sankey.py @@ -0,0 +1,814 @@ +""" +Module for creating Sankey diagrams using Matplotlib. +""" + +import logging +from types import SimpleNamespace + +import numpy as np + +import matplotlib as mpl +from matplotlib.path import Path +from matplotlib.patches import PathPatch +from matplotlib.transforms import Affine2D +from matplotlib import _docstring + +_log = logging.getLogger(__name__) + +__author__ = "Kevin L. Davies" +__credits__ = ["Yannick Copin"] +__license__ = "BSD" +__version__ = "2011/09/16" + +# Angles [deg/90] +RIGHT = 0 +UP = 1 +# LEFT = 2 +DOWN = 3 + + +class Sankey: + """ + Sankey diagram. + + Sankey diagrams are a specific type of flow diagram, in which + the width of the arrows is shown proportionally to the flow + quantity. They are typically used to visualize energy or + material or cost transfers between processes. + `Wikipedia (6/1/2011) `_ + + """ + + def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25, + radius=0.1, shoulder=0.03, offset=0.15, head_angle=100, + margin=0.4, tolerance=1e-6, **kwargs): + """ + Create a new Sankey instance. + + The optional arguments listed below are applied to all subdiagrams so + that there is consistent alignment and formatting. + + In order to draw a complex Sankey diagram, create an instance of + `Sankey` by calling it without any kwargs:: + + sankey = Sankey() + + Then add simple Sankey sub-diagrams:: + + sankey.add() # 1 + sankey.add() # 2 + #... + sankey.add() # n + + Finally, create the full diagram:: + + sankey.finish() + + Or, instead, simply daisy-chain those calls:: + + Sankey().add().add... .add().finish() + + Other Parameters + ---------------- + ax : `~matplotlib.axes.Axes` + Axes onto which the data should be plotted. If *ax* isn't + provided, new Axes will be created. + scale : float + Scaling factor for the flows. *scale* sizes the width of the paths + in order to maintain proper layout. The same scale is applied to + all subdiagrams. The value should be chosen such that the product + of the scale and the sum of the inputs is approximately 1.0 (and + the product of the scale and the sum of the outputs is + approximately -1.0). + unit : str + The physical unit associated with the flow quantities. If *unit* + is None, then none of the quantities are labeled. + format : str or callable + A Python number formatting string or callable used to label the + flows with their quantities (i.e., a number times a unit, where the + unit is given). If a format string is given, the label will be + ``format % quantity``. If a callable is given, it will be called + with ``quantity`` as an argument. + gap : float + Space between paths that break in/break away to/from the top or + bottom. + radius : float + Inner radius of the vertical paths. + shoulder : float + Size of the shoulders of output arrows. + offset : float + Text offset (from the dip or tip of the arrow). + head_angle : float + Angle, in degrees, of the arrow heads (and negative of the angle of + the tails). + margin : float + Minimum space between Sankey outlines and the edge of the plot + area. + tolerance : float + Acceptable maximum of the magnitude of the sum of flows. The + magnitude of the sum of connected flows cannot be greater than + *tolerance*. + **kwargs + Any additional keyword arguments will be passed to `add`, which + will create the first subdiagram. + + See Also + -------- + Sankey.add + Sankey.finish + + Examples + -------- + .. plot:: gallery/specialty_plots/sankey_basics.py + """ + # Check the arguments. + if gap < 0: + raise ValueError( + "'gap' is negative, which is not allowed because it would " + "cause the paths to overlap") + if radius > gap: + raise ValueError( + "'radius' is greater than 'gap', which is not allowed because " + "it would cause the paths to overlap") + if head_angle < 0: + raise ValueError( + "'head_angle' is negative, which is not allowed because it " + "would cause inputs to look like outputs and vice versa") + if tolerance < 0: + raise ValueError( + "'tolerance' is negative, but it must be a magnitude") + + # Create Axes if necessary. + if ax is None: + import matplotlib.pyplot as plt + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[]) + + self.diagrams = [] + + # Store the inputs. + self.ax = ax + self.unit = unit + self.format = format + self.scale = scale + self.gap = gap + self.radius = radius + self.shoulder = shoulder + self.offset = offset + self.margin = margin + self.pitch = np.tan(np.pi * (1 - head_angle / 180.0) / 2.0) + self.tolerance = tolerance + + # Initialize the vertices of tight box around the diagram(s). + self.extent = np.array((np.inf, -np.inf, np.inf, -np.inf)) + + # If there are any kwargs, create the first subdiagram. + if len(kwargs): + self.add(**kwargs) + + def _arc(self, quadrant=0, cw=True, radius=1, center=(0, 0)): + """ + Return the codes and vertices for a rotated, scaled, and translated + 90 degree arc. + + Other Parameters + ---------------- + quadrant : {0, 1, 2, 3}, default: 0 + Uses 0-based indexing (0, 1, 2, or 3). + cw : bool, default: True + If True, the arc vertices are produced clockwise; counter-clockwise + otherwise. + radius : float, default: 1 + The radius of the arc. + center : (float, float), default: (0, 0) + (x, y) tuple of the arc's center. + """ + # Note: It would be possible to use matplotlib's transforms to rotate, + # scale, and translate the arc, but since the angles are discrete, + # it's just as easy and maybe more efficient to do it here. + ARC_CODES = [Path.LINETO, + Path.CURVE4, + Path.CURVE4, + Path.CURVE4, + Path.CURVE4, + Path.CURVE4, + Path.CURVE4] + # Vertices of a cubic Bezier curve approximating a 90 deg arc + # These can be determined by Path.arc(0, 90). + ARC_VERTICES = np.array([[1.00000000e+00, 0.00000000e+00], + [1.00000000e+00, 2.65114773e-01], + [8.94571235e-01, 5.19642327e-01], + [7.07106781e-01, 7.07106781e-01], + [5.19642327e-01, 8.94571235e-01], + [2.65114773e-01, 1.00000000e+00], + # Insignificant + # [6.12303177e-17, 1.00000000e+00]]) + [0.00000000e+00, 1.00000000e+00]]) + if quadrant in (0, 2): + if cw: + vertices = ARC_VERTICES + else: + vertices = ARC_VERTICES[:, ::-1] # Swap x and y. + else: # 1, 3 + # Negate x. + if cw: + # Swap x and y. + vertices = np.column_stack((-ARC_VERTICES[:, 1], + ARC_VERTICES[:, 0])) + else: + vertices = np.column_stack((-ARC_VERTICES[:, 0], + ARC_VERTICES[:, 1])) + if quadrant > 1: + radius = -radius # Rotate 180 deg. + return list(zip(ARC_CODES, radius * vertices + + np.tile(center, (ARC_VERTICES.shape[0], 1)))) + + def _add_input(self, path, angle, flow, length): + """ + Add an input to a path and return its tip and label locations. + """ + if angle is None: + return [0, 0], [0, 0] + else: + x, y = path[-1][1] # Use the last point as a reference. + dipdepth = (flow / 2) * self.pitch + if angle == RIGHT: + x -= length + dip = [x + dipdepth, y + flow / 2.0] + path.extend([(Path.LINETO, [x, y]), + (Path.LINETO, dip), + (Path.LINETO, [x, y + flow]), + (Path.LINETO, [x + self.gap, y + flow])]) + label_location = [dip[0] - self.offset, dip[1]] + else: # Vertical + x -= self.gap + if angle == UP: + sign = 1 + else: + sign = -1 + + dip = [x - flow / 2, y - sign * (length - dipdepth)] + if angle == DOWN: + quadrant = 2 + else: + quadrant = 1 + + # Inner arc isn't needed if inner radius is zero + if self.radius: + path.extend(self._arc(quadrant=quadrant, + cw=angle == UP, + radius=self.radius, + center=(x + self.radius, + y - sign * self.radius))) + else: + path.append((Path.LINETO, [x, y])) + path.extend([(Path.LINETO, [x, y - sign * length]), + (Path.LINETO, dip), + (Path.LINETO, [x - flow, y - sign * length])]) + path.extend(self._arc(quadrant=quadrant, + cw=angle == DOWN, + radius=flow + self.radius, + center=(x + self.radius, + y - sign * self.radius))) + path.append((Path.LINETO, [x - flow, y + sign * flow])) + label_location = [dip[0], dip[1] - sign * self.offset] + + return dip, label_location + + def _add_output(self, path, angle, flow, length): + """ + Append an output to a path and return its tip and label locations. + + .. note:: *flow* is negative for an output. + """ + if angle is None: + return [0, 0], [0, 0] + else: + x, y = path[-1][1] # Use the last point as a reference. + tipheight = (self.shoulder - flow / 2) * self.pitch + if angle == RIGHT: + x += length + tip = [x + tipheight, y + flow / 2.0] + path.extend([(Path.LINETO, [x, y]), + (Path.LINETO, [x, y + self.shoulder]), + (Path.LINETO, tip), + (Path.LINETO, [x, y - self.shoulder + flow]), + (Path.LINETO, [x, y + flow]), + (Path.LINETO, [x - self.gap, y + flow])]) + label_location = [tip[0] + self.offset, tip[1]] + else: # Vertical + x += self.gap + if angle == UP: + sign, quadrant = 1, 3 + else: + sign, quadrant = -1, 0 + + tip = [x - flow / 2.0, y + sign * (length + tipheight)] + # Inner arc isn't needed if inner radius is zero + if self.radius: + path.extend(self._arc(quadrant=quadrant, + cw=angle == UP, + radius=self.radius, + center=(x - self.radius, + y + sign * self.radius))) + else: + path.append((Path.LINETO, [x, y])) + path.extend([(Path.LINETO, [x, y + sign * length]), + (Path.LINETO, [x - self.shoulder, + y + sign * length]), + (Path.LINETO, tip), + (Path.LINETO, [x + self.shoulder - flow, + y + sign * length]), + (Path.LINETO, [x - flow, y + sign * length])]) + path.extend(self._arc(quadrant=quadrant, + cw=angle == DOWN, + radius=self.radius - flow, + center=(x - self.radius, + y + sign * self.radius))) + path.append((Path.LINETO, [x - flow, y + sign * flow])) + label_location = [tip[0], tip[1] + sign * self.offset] + return tip, label_location + + def _revert(self, path, first_action=Path.LINETO): + """ + A path is not simply reversible by path[::-1] since the code + specifies an action to take from the **previous** point. + """ + reverse_path = [] + next_code = first_action + for code, position in path[::-1]: + reverse_path.append((next_code, position)) + next_code = code + return reverse_path + # This might be more efficient, but it fails because 'tuple' object + # doesn't support item assignment: + # path[1] = path[1][-1:0:-1] + # path[1][0] = first_action + # path[2] = path[2][::-1] + # return path + + @_docstring.dedent_interpd + def add(self, patchlabel='', flows=None, orientations=None, labels='', + trunklength=1.0, pathlengths=0.25, prior=None, connect=(0, 0), + rotation=0, **kwargs): + """ + Add a simple Sankey diagram with flows at the same hierarchical level. + + Parameters + ---------- + patchlabel : str + Label to be placed at the center of the diagram. + Note that *label* (not *patchlabel*) can be passed as keyword + argument to create an entry in the legend. + + flows : list of float + Array of flow values. By convention, inputs are positive and + outputs are negative. + + Flows are placed along the top of the diagram from the inside out + in order of their index within *flows*. They are placed along the + sides of the diagram from the top down and along the bottom from + the outside in. + + If the sum of the inputs and outputs is + nonzero, the discrepancy will appear as a cubic Bézier curve along + the top and bottom edges of the trunk. + + orientations : list of {-1, 0, 1} + List of orientations of the flows (or a single orientation to be + used for all flows). Valid values are 0 (inputs from + the left, outputs to the right), 1 (from and to the top) or -1 + (from and to the bottom). + + labels : list of (str or None) + List of labels for the flows (or a single label to be used for all + flows). Each label may be *None* (no label), or a labeling string. + If an entry is a (possibly empty) string, then the quantity for the + corresponding flow will be shown below the string. However, if + the *unit* of the main diagram is None, then quantities are never + shown, regardless of the value of this argument. + + trunklength : float + Length between the bases of the input and output groups (in + data-space units). + + pathlengths : list of float + List of lengths of the vertical arrows before break-in or after + break-away. If a single value is given, then it will be applied to + the first (inside) paths on the top and bottom, and the length of + all other arrows will be justified accordingly. The *pathlengths* + are not applied to the horizontal inputs and outputs. + + prior : int + Index of the prior diagram to which this diagram should be + connected. + + connect : (int, int) + A (prior, this) tuple indexing the flow of the prior diagram and + the flow of this diagram which should be connected. If this is the + first diagram or *prior* is *None*, *connect* will be ignored. + + rotation : float + Angle of rotation of the diagram in degrees. The interpretation of + the *orientations* argument will be rotated accordingly (e.g., if + *rotation* == 90, an *orientations* entry of 1 means to/from the + left). *rotation* is ignored if this diagram is connected to an + existing one (using *prior* and *connect*). + + Returns + ------- + Sankey + The current `.Sankey` instance. + + Other Parameters + ---------------- + **kwargs + Additional keyword arguments set `matplotlib.patches.PathPatch` + properties, listed below. For example, one may want to use + ``fill=False`` or ``label="A legend entry"``. + + %(Patch:kwdoc)s + + See Also + -------- + Sankey.finish + """ + # Check and preprocess the arguments. + flows = np.array([1.0, -1.0]) if flows is None else np.array(flows) + n = flows.shape[0] # Number of flows + if rotation is None: + rotation = 0 + else: + # In the code below, angles are expressed in deg/90. + rotation /= 90.0 + if orientations is None: + orientations = 0 + try: + orientations = np.broadcast_to(orientations, n) + except ValueError: + raise ValueError( + f"The shapes of 'flows' {np.shape(flows)} and 'orientations' " + f"{np.shape(orientations)} are incompatible" + ) from None + try: + labels = np.broadcast_to(labels, n) + except ValueError: + raise ValueError( + f"The shapes of 'flows' {np.shape(flows)} and 'labels' " + f"{np.shape(labels)} are incompatible" + ) from None + if trunklength < 0: + raise ValueError( + "'trunklength' is negative, which is not allowed because it " + "would cause poor layout") + if abs(np.sum(flows)) > self.tolerance: + _log.info("The sum of the flows is nonzero (%f; patchlabel=%r); " + "is the system not at steady state?", + np.sum(flows), patchlabel) + scaled_flows = self.scale * flows + gain = sum(max(flow, 0) for flow in scaled_flows) + loss = sum(min(flow, 0) for flow in scaled_flows) + if prior is not None: + if prior < 0: + raise ValueError("The index of the prior diagram is negative") + if min(connect) < 0: + raise ValueError( + "At least one of the connection indices is negative") + if prior >= len(self.diagrams): + raise ValueError( + f"The index of the prior diagram is {prior}, but there " + f"are only {len(self.diagrams)} other diagrams") + if connect[0] >= len(self.diagrams[prior].flows): + raise ValueError( + "The connection index to the source diagram is {}, but " + "that diagram has only {} flows".format( + connect[0], len(self.diagrams[prior].flows))) + if connect[1] >= n: + raise ValueError( + f"The connection index to this diagram is {connect[1]}, " + f"but this diagram has only {n} flows") + if self.diagrams[prior].angles[connect[0]] is None: + raise ValueError( + f"The connection cannot be made, which may occur if the " + f"magnitude of flow {connect[0]} of diagram {prior} is " + f"less than the specified tolerance") + flow_error = (self.diagrams[prior].flows[connect[0]] + + flows[connect[1]]) + if abs(flow_error) >= self.tolerance: + raise ValueError( + f"The scaled sum of the connected flows is {flow_error}, " + f"which is not within the tolerance ({self.tolerance})") + + # Determine if the flows are inputs. + are_inputs = [None] * n + for i, flow in enumerate(flows): + if flow >= self.tolerance: + are_inputs[i] = True + elif flow <= -self.tolerance: + are_inputs[i] = False + else: + _log.info( + "The magnitude of flow %d (%f) is below the tolerance " + "(%f).\nIt will not be shown, and it cannot be used in a " + "connection.", i, flow, self.tolerance) + + # Determine the angles of the arrows (before rotation). + angles = [None] * n + for i, (orient, is_input) in enumerate(zip(orientations, are_inputs)): + if orient == 1: + if is_input: + angles[i] = DOWN + elif is_input is False: + # Be specific since is_input can be None. + angles[i] = UP + elif orient == 0: + if is_input is not None: + angles[i] = RIGHT + else: + if orient != -1: + raise ValueError( + f"The value of orientations[{i}] is {orient}, " + f"but it must be -1, 0, or 1") + if is_input: + angles[i] = UP + elif is_input is False: + angles[i] = DOWN + + # Justify the lengths of the paths. + if np.iterable(pathlengths): + if len(pathlengths) != n: + raise ValueError( + f"The lengths of 'flows' ({n}) and 'pathlengths' " + f"({len(pathlengths)}) are incompatible") + else: # Make pathlengths into a list. + urlength = pathlengths + ullength = pathlengths + lrlength = pathlengths + lllength = pathlengths + d = dict(RIGHT=pathlengths) + pathlengths = [d.get(angle, 0) for angle in angles] + # Determine the lengths of the top-side arrows + # from the middle outwards. + for i, (angle, is_input, flow) in enumerate(zip(angles, are_inputs, + scaled_flows)): + if angle == DOWN and is_input: + pathlengths[i] = ullength + ullength += flow + elif angle == UP and is_input is False: + pathlengths[i] = urlength + urlength -= flow # Flow is negative for outputs. + # Determine the lengths of the bottom-side arrows + # from the middle outwards. + for i, (angle, is_input, flow) in enumerate(reversed(list(zip( + angles, are_inputs, scaled_flows)))): + if angle == UP and is_input: + pathlengths[n - i - 1] = lllength + lllength += flow + elif angle == DOWN and is_input is False: + pathlengths[n - i - 1] = lrlength + lrlength -= flow + # Determine the lengths of the left-side arrows + # from the bottom upwards. + has_left_input = False + for i, (angle, is_input, spec) in enumerate(reversed(list(zip( + angles, are_inputs, zip(scaled_flows, pathlengths))))): + if angle == RIGHT: + if is_input: + if has_left_input: + pathlengths[n - i - 1] = 0 + else: + has_left_input = True + # Determine the lengths of the right-side arrows + # from the top downwards. + has_right_output = False + for i, (angle, is_input, spec) in enumerate(zip( + angles, are_inputs, list(zip(scaled_flows, pathlengths)))): + if angle == RIGHT: + if is_input is False: + if has_right_output: + pathlengths[i] = 0 + else: + has_right_output = True + + # Begin the subpaths, and smooth the transition if the sum of the flows + # is nonzero. + urpath = [(Path.MOVETO, [(self.gap - trunklength / 2.0), # Upper right + gain / 2.0]), + (Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0, + gain / 2.0]), + (Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0, + gain / 2.0]), + (Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0, + -loss / 2.0]), + (Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0, + -loss / 2.0]), + (Path.LINETO, [(trunklength / 2.0 - self.gap), + -loss / 2.0])] + llpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower left + loss / 2.0]), + (Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0, + loss / 2.0]), + (Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0, + loss / 2.0]), + (Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0, + -gain / 2.0]), + (Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0, + -gain / 2.0]), + (Path.LINETO, [(self.gap - trunklength / 2.0), + -gain / 2.0])] + lrpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower right + loss / 2.0])] + ulpath = [(Path.LINETO, [self.gap - trunklength / 2.0, # Upper left + gain / 2.0])] + + # Add the subpaths and assign the locations of the tips and labels. + tips = np.zeros((n, 2)) + label_locations = np.zeros((n, 2)) + # Add the top-side inputs and outputs from the middle outwards. + for i, (angle, is_input, spec) in enumerate(zip( + angles, are_inputs, list(zip(scaled_flows, pathlengths)))): + if angle == DOWN and is_input: + tips[i, :], label_locations[i, :] = self._add_input( + ulpath, angle, *spec) + elif angle == UP and is_input is False: + tips[i, :], label_locations[i, :] = self._add_output( + urpath, angle, *spec) + # Add the bottom-side inputs and outputs from the middle outwards. + for i, (angle, is_input, spec) in enumerate(reversed(list(zip( + angles, are_inputs, list(zip(scaled_flows, pathlengths)))))): + if angle == UP and is_input: + tip, label_location = self._add_input(llpath, angle, *spec) + tips[n - i - 1, :] = tip + label_locations[n - i - 1, :] = label_location + elif angle == DOWN and is_input is False: + tip, label_location = self._add_output(lrpath, angle, *spec) + tips[n - i - 1, :] = tip + label_locations[n - i - 1, :] = label_location + # Add the left-side inputs from the bottom upwards. + has_left_input = False + for i, (angle, is_input, spec) in enumerate(reversed(list(zip( + angles, are_inputs, list(zip(scaled_flows, pathlengths)))))): + if angle == RIGHT and is_input: + if not has_left_input: + # Make sure the lower path extends + # at least as far as the upper one. + if llpath[-1][1][0] > ulpath[-1][1][0]: + llpath.append((Path.LINETO, [ulpath[-1][1][0], + llpath[-1][1][1]])) + has_left_input = True + tip, label_location = self._add_input(llpath, angle, *spec) + tips[n - i - 1, :] = tip + label_locations[n - i - 1, :] = label_location + # Add the right-side outputs from the top downwards. + has_right_output = False + for i, (angle, is_input, spec) in enumerate(zip( + angles, are_inputs, list(zip(scaled_flows, pathlengths)))): + if angle == RIGHT and is_input is False: + if not has_right_output: + # Make sure the upper path extends + # at least as far as the lower one. + if urpath[-1][1][0] < lrpath[-1][1][0]: + urpath.append((Path.LINETO, [lrpath[-1][1][0], + urpath[-1][1][1]])) + has_right_output = True + tips[i, :], label_locations[i, :] = self._add_output( + urpath, angle, *spec) + # Trim any hanging vertices. + if not has_left_input: + ulpath.pop() + llpath.pop() + if not has_right_output: + lrpath.pop() + urpath.pop() + + # Concatenate the subpaths in the correct order (clockwise from top). + path = (urpath + self._revert(lrpath) + llpath + self._revert(ulpath) + + [(Path.CLOSEPOLY, urpath[0][1])]) + + # Create a patch with the Sankey outline. + codes, vertices = zip(*path) + vertices = np.array(vertices) + + def _get_angle(a, r): + if a is None: + return None + else: + return a + r + + if prior is None: + if rotation != 0: # By default, none of this is needed. + angles = [_get_angle(angle, rotation) for angle in angles] + rotate = Affine2D().rotate_deg(rotation * 90).transform_affine + tips = rotate(tips) + label_locations = rotate(label_locations) + vertices = rotate(vertices) + text = self.ax.text(0, 0, s=patchlabel, ha='center', va='center') + else: + rotation = (self.diagrams[prior].angles[connect[0]] - + angles[connect[1]]) + angles = [_get_angle(angle, rotation) for angle in angles] + rotate = Affine2D().rotate_deg(rotation * 90).transform_affine + tips = rotate(tips) + offset = self.diagrams[prior].tips[connect[0]] - tips[connect[1]] + translate = Affine2D().translate(*offset).transform_affine + tips = translate(tips) + label_locations = translate(rotate(label_locations)) + vertices = translate(rotate(vertices)) + kwds = dict(s=patchlabel, ha='center', va='center') + text = self.ax.text(*offset, **kwds) + if mpl.rcParams['_internal.classic_mode']: + fc = kwargs.pop('fc', kwargs.pop('facecolor', '#bfd1d4')) + lw = kwargs.pop('lw', kwargs.pop('linewidth', 0.5)) + else: + fc = kwargs.pop('fc', kwargs.pop('facecolor', None)) + lw = kwargs.pop('lw', kwargs.pop('linewidth', None)) + if fc is None: + fc = self.ax._get_patches_for_fill.get_next_color() + patch = PathPatch(Path(vertices, codes), fc=fc, lw=lw, **kwargs) + self.ax.add_patch(patch) + + # Add the path labels. + texts = [] + for number, angle, label, location in zip(flows, angles, labels, + label_locations): + if label is None or angle is None: + label = '' + elif self.unit is not None: + if isinstance(self.format, str): + quantity = self.format % abs(number) + self.unit + elif callable(self.format): + quantity = self.format(number) + else: + raise TypeError( + 'format must be callable or a format string') + if label != '': + label += "\n" + label += quantity + texts.append(self.ax.text(x=location[0], y=location[1], + s=label, + ha='center', va='center')) + # Text objects are placed even they are empty (as long as the magnitude + # of the corresponding flow is larger than the tolerance) in case the + # user wants to provide labels later. + + # Expand the size of the diagram if necessary. + self.extent = (min(np.min(vertices[:, 0]), + np.min(label_locations[:, 0]), + self.extent[0]), + max(np.max(vertices[:, 0]), + np.max(label_locations[:, 0]), + self.extent[1]), + min(np.min(vertices[:, 1]), + np.min(label_locations[:, 1]), + self.extent[2]), + max(np.max(vertices[:, 1]), + np.max(label_locations[:, 1]), + self.extent[3])) + # Include both vertices _and_ label locations in the extents; there are + # where either could determine the margins (e.g., arrow shoulders). + + # Add this diagram as a subdiagram. + self.diagrams.append( + SimpleNamespace(patch=patch, flows=flows, angles=angles, tips=tips, + text=text, texts=texts)) + + # Allow a daisy-chained call structure (see docstring for the class). + return self + + def finish(self): + """ + Adjust the Axes and return a list of information about the Sankey + subdiagram(s). + + Returns a list of subdiagrams with the following fields: + + ======== ============================================================= + Field Description + ======== ============================================================= + *patch* Sankey outline (a `~matplotlib.patches.PathPatch`). + *flows* Flow values (positive for input, negative for output). + *angles* List of angles of the arrows [deg/90]. + For example, if the diagram has not been rotated, + an input to the top side has an angle of 3 (DOWN), + and an output from the top side has an angle of 1 (UP). + If a flow has been skipped (because its magnitude is less + than *tolerance*), then its angle will be *None*. + *tips* (N, 2)-array of the (x, y) positions of the tips (or "dips") + of the flow paths. + If the magnitude of a flow is less the *tolerance* of this + `Sankey` instance, the flow is skipped and its tip will be at + the center of the diagram. + *text* `.Text` instance for the diagram label. + *texts* List of `.Text` instances for the flow labels. + ======== ============================================================= + + See Also + -------- + Sankey.add + """ + self.ax.axis([self.extent[0] - self.margin, + self.extent[1] + self.margin, + self.extent[2] - self.margin, + self.extent[3] + self.margin]) + self.ax.set_aspect('equal', adjustable='datalim') + return self.diagrams diff --git a/venv/lib/python3.10/site-packages/matplotlib/sankey.pyi b/venv/lib/python3.10/site-packages/matplotlib/sankey.pyi new file mode 100644 index 00000000..4a40c31e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/sankey.pyi @@ -0,0 +1,61 @@ +from matplotlib.axes import Axes + +from collections.abc import Callable, Iterable +from typing import Any + +import numpy as np + +__license__: str +__credits__: list[str] +__author__: str +__version__: str + +RIGHT: int +UP: int +DOWN: int + +# TODO typing units +class Sankey: + diagrams: list[Any] + ax: Axes + unit: Any + format: str | Callable[[float], str] + scale: float + gap: float + radius: float + shoulder: float + offset: float + margin: float + pitch: float + tolerance: float + extent: np.ndarray + def __init__( + self, + ax: Axes | None = ..., + scale: float = ..., + unit: Any = ..., + format: str | Callable[[float], str] = ..., + gap: float = ..., + radius: float = ..., + shoulder: float = ..., + offset: float = ..., + head_angle: float = ..., + margin: float = ..., + tolerance: float = ..., + **kwargs + ) -> None: ... + def add( + self, + patchlabel: str = ..., + flows: Iterable[float] | None = ..., + orientations: Iterable[int] | None = ..., + labels: str | Iterable[str | None] = ..., + trunklength: float = ..., + pathlengths: float | Iterable[float] = ..., + prior: int | None = ..., + connect: tuple[int, int] = ..., + rotation: float = ..., + **kwargs + # Replace return with Self when py3.9 is dropped + ) -> Sankey: ... + def finish(self) -> list[Any]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/scale.py b/venv/lib/python3.10/site-packages/matplotlib/scale.py new file mode 100644 index 00000000..7f90362b --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/scale.py @@ -0,0 +1,756 @@ +""" +Scales define the distribution of data values on an axis, e.g. a log scaling. +They are defined as subclasses of `ScaleBase`. + +See also `.axes.Axes.set_xscale` and the scales examples in the documentation. + +See :doc:`/gallery/scales/custom_scale` for a full example of defining a custom +scale. + +Matplotlib also supports non-separable transformations that operate on both +`~.axis.Axis` at the same time. They are known as projections, and defined in +`matplotlib.projections`. +""" + +import inspect +import textwrap + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, _docstring +from matplotlib.ticker import ( + NullFormatter, ScalarFormatter, LogFormatterSciNotation, LogitFormatter, + NullLocator, LogLocator, AutoLocator, AutoMinorLocator, + SymmetricalLogLocator, AsinhLocator, LogitLocator) +from matplotlib.transforms import Transform, IdentityTransform + + +class ScaleBase: + """ + The base class for all scales. + + Scales are separable transformations, working on a single dimension. + + Subclasses should override + + :attr:`name` + The scale's name. + :meth:`get_transform` + A method returning a `.Transform`, which converts data coordinates to + scaled coordinates. This transform should be invertible, so that e.g. + mouse positions can be converted back to data coordinates. + :meth:`set_default_locators_and_formatters` + A method that sets default locators and formatters for an `~.axis.Axis` + that uses this scale. + :meth:`limit_range_for_scale` + An optional method that "fixes" the axis range to acceptable values, + e.g. restricting log-scaled axes to positive values. + """ + + def __init__(self, axis): + r""" + Construct a new scale. + + Notes + ----- + The following note is for scale implementers. + + For back-compatibility reasons, scales take an `~matplotlib.axis.Axis` + object as first argument. However, this argument should not + be used: a single scale object should be usable by multiple + `~matplotlib.axis.Axis`\es at the same time. + """ + + def get_transform(self): + """ + Return the `.Transform` object associated with this scale. + """ + raise NotImplementedError() + + def set_default_locators_and_formatters(self, axis): + """ + Set the locators and formatters of *axis* to instances suitable for + this scale. + """ + raise NotImplementedError() + + def limit_range_for_scale(self, vmin, vmax, minpos): + """ + Return the range *vmin*, *vmax*, restricted to the + domain supported by this scale (if any). + + *minpos* should be the minimum positive value in the data. + This is used by log scales to determine a minimum value. + """ + return vmin, vmax + + +class LinearScale(ScaleBase): + """ + The default linear scale. + """ + + name = 'linear' + + def __init__(self, axis): + # This method is present only to prevent inheritance of the base class' + # constructor docstring, which would otherwise end up interpolated into + # the docstring of Axis.set_scale. + """ + """ # noqa: D419 + + def set_default_locators_and_formatters(self, axis): + # docstring inherited + axis.set_major_locator(AutoLocator()) + axis.set_major_formatter(ScalarFormatter()) + axis.set_minor_formatter(NullFormatter()) + # update the minor locator for x and y axis based on rcParams + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): + axis.set_minor_locator(AutoMinorLocator()) + else: + axis.set_minor_locator(NullLocator()) + + def get_transform(self): + """ + Return the transform for linear scaling, which is just the + `~matplotlib.transforms.IdentityTransform`. + """ + return IdentityTransform() + + +class FuncTransform(Transform): + """ + A simple transform that takes and arbitrary function for the + forward and inverse transform. + """ + + input_dims = output_dims = 1 + + def __init__(self, forward, inverse): + """ + Parameters + ---------- + forward : callable + The forward function for the transform. This function must have + an inverse and, for best behavior, be monotonic. + It must have the signature:: + + def forward(values: array-like) -> array-like + + inverse : callable + The inverse of the forward function. Signature as ``forward``. + """ + super().__init__() + if callable(forward) and callable(inverse): + self._forward = forward + self._inverse = inverse + else: + raise ValueError('arguments to FuncTransform must be functions') + + def transform_non_affine(self, values): + return self._forward(values) + + def inverted(self): + return FuncTransform(self._inverse, self._forward) + + +class FuncScale(ScaleBase): + """ + Provide an arbitrary scale with user-supplied function for the axis. + """ + + name = 'function' + + def __init__(self, axis, functions): + """ + Parameters + ---------- + axis : `~matplotlib.axis.Axis` + The axis for the scale. + functions : (callable, callable) + two-tuple of the forward and inverse functions for the scale. + The forward function must be monotonic. + + Both functions must have the signature:: + + def forward(values: array-like) -> array-like + """ + forward, inverse = functions + transform = FuncTransform(forward, inverse) + self._transform = transform + + def get_transform(self): + """Return the `.FuncTransform` associated with this scale.""" + return self._transform + + def set_default_locators_and_formatters(self, axis): + # docstring inherited + axis.set_major_locator(AutoLocator()) + axis.set_major_formatter(ScalarFormatter()) + axis.set_minor_formatter(NullFormatter()) + # update the minor locator for x and y axis based on rcParams + if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or + axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): + axis.set_minor_locator(AutoMinorLocator()) + else: + axis.set_minor_locator(NullLocator()) + + +class LogTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, base, nonpositive='clip'): + super().__init__() + if base <= 0 or base == 1: + raise ValueError('The log base cannot be <= 0 or == 1') + self.base = base + self._clip = _api.check_getitem( + {"clip": True, "mask": False}, nonpositive=nonpositive) + + def __str__(self): + return "{}(base={}, nonpositive={!r})".format( + type(self).__name__, self.base, "clip" if self._clip else "mask") + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + # Ignore invalid values due to nans being passed to the transform. + with np.errstate(divide="ignore", invalid="ignore"): + log = {np.e: np.log, 2: np.log2, 10: np.log10}.get(self.base) + if log: # If possible, do everything in a single call to NumPy. + out = log(values) + else: + out = np.log(values) + out /= np.log(self.base) + if self._clip: + # SVG spec says that conforming viewers must support values up + # to 3.4e38 (C float); however experiments suggest that + # Inkscape (which uses cairo for rendering) runs into cairo's + # 24-bit limit (which is apparently shared by Agg). + # Ghostscript (used for pdf rendering appears to overflow even + # earlier, with the max value around 2 ** 15 for the tests to + # pass. On the other hand, in practice, we want to clip beyond + # np.log10(np.nextafter(0, 1)) ~ -323 + # so 1000 seems safe. + out[values <= 0] = -1000 + return out + + def inverted(self): + return InvertedLogTransform(self.base) + + +class InvertedLogTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, base): + super().__init__() + self.base = base + + def __str__(self): + return f"{type(self).__name__}(base={self.base})" + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + return np.power(self.base, values) + + def inverted(self): + return LogTransform(self.base) + + +class LogScale(ScaleBase): + """ + A standard logarithmic scale. Care is taken to only plot positive values. + """ + name = 'log' + + def __init__(self, axis, *, base=10, subs=None, nonpositive="clip"): + """ + Parameters + ---------- + axis : `~matplotlib.axis.Axis` + The axis for the scale. + base : float, default: 10 + The base of the logarithm. + nonpositive : {'clip', 'mask'}, default: 'clip' + Determines the behavior for non-positive values. They can either + be masked as invalid, or clipped to a very small positive number. + subs : sequence of int, default: None + Where to place the subticks between each major tick. For example, + in a log10 scale, ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place 8 + logarithmically spaced minor ticks between each major tick. + """ + self._transform = LogTransform(base, nonpositive) + self.subs = subs + + base = property(lambda self: self._transform.base) + + def set_default_locators_and_formatters(self, axis): + # docstring inherited + axis.set_major_locator(LogLocator(self.base)) + axis.set_major_formatter(LogFormatterSciNotation(self.base)) + axis.set_minor_locator(LogLocator(self.base, self.subs)) + axis.set_minor_formatter( + LogFormatterSciNotation(self.base, + labelOnlyBase=(self.subs is not None))) + + def get_transform(self): + """Return the `.LogTransform` associated with this scale.""" + return self._transform + + def limit_range_for_scale(self, vmin, vmax, minpos): + """Limit the domain to positive values.""" + if not np.isfinite(minpos): + minpos = 1e-300 # Should rarely (if ever) have a visible effect. + + return (minpos if vmin <= 0 else vmin, + minpos if vmax <= 0 else vmax) + + +class FuncScaleLog(LogScale): + """ + Provide an arbitrary scale with user-supplied function for the axis and + then put on a logarithmic axes. + """ + + name = 'functionlog' + + def __init__(self, axis, functions, base=10): + """ + Parameters + ---------- + axis : `~matplotlib.axis.Axis` + The axis for the scale. + functions : (callable, callable) + two-tuple of the forward and inverse functions for the scale. + The forward function must be monotonic. + + Both functions must have the signature:: + + def forward(values: array-like) -> array-like + + base : float, default: 10 + Logarithmic base of the scale. + """ + forward, inverse = functions + self.subs = None + self._transform = FuncTransform(forward, inverse) + LogTransform(base) + + @property + def base(self): + return self._transform._b.base # Base of the LogTransform. + + def get_transform(self): + """Return the `.Transform` associated with this scale.""" + return self._transform + + +class SymmetricalLogTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, base, linthresh, linscale): + super().__init__() + if base <= 1.0: + raise ValueError("'base' must be larger than 1") + if linthresh <= 0.0: + raise ValueError("'linthresh' must be positive") + if linscale <= 0.0: + raise ValueError("'linscale' must be positive") + self.base = base + self.linthresh = linthresh + self.linscale = linscale + self._linscale_adj = (linscale / (1.0 - self.base ** -1)) + self._log_base = np.log(base) + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + abs_a = np.abs(values) + with np.errstate(divide="ignore", invalid="ignore"): + out = np.sign(values) * self.linthresh * ( + self._linscale_adj + + np.log(abs_a / self.linthresh) / self._log_base) + inside = abs_a <= self.linthresh + out[inside] = values[inside] * self._linscale_adj + return out + + def inverted(self): + return InvertedSymmetricalLogTransform(self.base, self.linthresh, + self.linscale) + + +class InvertedSymmetricalLogTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, base, linthresh, linscale): + super().__init__() + symlog = SymmetricalLogTransform(base, linthresh, linscale) + self.base = base + self.linthresh = linthresh + self.invlinthresh = symlog.transform(linthresh) + self.linscale = linscale + self._linscale_adj = (linscale / (1.0 - self.base ** -1)) + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + abs_a = np.abs(values) + with np.errstate(divide="ignore", invalid="ignore"): + out = np.sign(values) * self.linthresh * ( + np.power(self.base, + abs_a / self.linthresh - self._linscale_adj)) + inside = abs_a <= self.invlinthresh + out[inside] = values[inside] / self._linscale_adj + return out + + def inverted(self): + return SymmetricalLogTransform(self.base, + self.linthresh, self.linscale) + + +class SymmetricalLogScale(ScaleBase): + """ + The symmetrical logarithmic scale is logarithmic in both the + positive and negative directions from the origin. + + Since the values close to zero tend toward infinity, there is a + need to have a range around zero that is linear. The parameter + *linthresh* allows the user to specify the size of this range + (-*linthresh*, *linthresh*). + + Parameters + ---------- + base : float, default: 10 + The base of the logarithm. + + linthresh : float, default: 2 + Defines the range ``(-x, x)``, within which the plot is linear. + This avoids having the plot go to infinity around zero. + + subs : sequence of int + Where to place the subticks between each major tick. + For example, in a log10 scale: ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place + 8 logarithmically spaced minor ticks between each major tick. + + linscale : float, optional + This allows the linear range ``(-linthresh, linthresh)`` to be + stretched relative to the logarithmic range. Its value is the number of + decades to use for each half of the linear range. For example, when + *linscale* == 1.0 (the default), the space used for the positive and + negative halves of the linear range will be equal to one decade in + the logarithmic range. + """ + name = 'symlog' + + def __init__(self, axis, *, base=10, linthresh=2, subs=None, linscale=1): + self._transform = SymmetricalLogTransform(base, linthresh, linscale) + self.subs = subs + + base = property(lambda self: self._transform.base) + linthresh = property(lambda self: self._transform.linthresh) + linscale = property(lambda self: self._transform.linscale) + + def set_default_locators_and_formatters(self, axis): + # docstring inherited + axis.set_major_locator(SymmetricalLogLocator(self.get_transform())) + axis.set_major_formatter(LogFormatterSciNotation(self.base)) + axis.set_minor_locator(SymmetricalLogLocator(self.get_transform(), + self.subs)) + axis.set_minor_formatter(NullFormatter()) + + def get_transform(self): + """Return the `.SymmetricalLogTransform` associated with this scale.""" + return self._transform + + +class AsinhTransform(Transform): + """Inverse hyperbolic-sine transformation used by `.AsinhScale`""" + input_dims = output_dims = 1 + + def __init__(self, linear_width): + super().__init__() + if linear_width <= 0.0: + raise ValueError("Scale parameter 'linear_width' " + + "must be strictly positive") + self.linear_width = linear_width + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + return self.linear_width * np.arcsinh(values / self.linear_width) + + def inverted(self): + return InvertedAsinhTransform(self.linear_width) + + +class InvertedAsinhTransform(Transform): + """Hyperbolic sine transformation used by `.AsinhScale`""" + input_dims = output_dims = 1 + + def __init__(self, linear_width): + super().__init__() + self.linear_width = linear_width + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + return self.linear_width * np.sinh(values / self.linear_width) + + def inverted(self): + return AsinhTransform(self.linear_width) + + +class AsinhScale(ScaleBase): + """ + A quasi-logarithmic scale based on the inverse hyperbolic sine (asinh) + + For values close to zero, this is essentially a linear scale, + but for large magnitude values (either positive or negative) + it is asymptotically logarithmic. The transition between these + linear and logarithmic regimes is smooth, and has no discontinuities + in the function gradient in contrast to + the `.SymmetricalLogScale` ("symlog") scale. + + Specifically, the transformation of an axis coordinate :math:`a` is + :math:`a \\rightarrow a_0 \\sinh^{-1} (a / a_0)` where :math:`a_0` + is the effective width of the linear region of the transformation. + In that region, the transformation is + :math:`a \\rightarrow a + \\mathcal{O}(a^3)`. + For large values of :math:`a` the transformation behaves as + :math:`a \\rightarrow a_0 \\, \\mathrm{sgn}(a) \\ln |a| + \\mathcal{O}(1)`. + + .. note:: + + This API is provisional and may be revised in the future + based on early user feedback. + """ + + name = 'asinh' + + auto_tick_multipliers = { + 3: (2, ), + 4: (2, ), + 5: (2, ), + 8: (2, 4), + 10: (2, 5), + 16: (2, 4, 8), + 64: (4, 16), + 1024: (256, 512) + } + + def __init__(self, axis, *, linear_width=1.0, + base=10, subs='auto', **kwargs): + """ + Parameters + ---------- + linear_width : float, default: 1 + The scale parameter (elsewhere referred to as :math:`a_0`) + defining the extent of the quasi-linear region, + and the coordinate values beyond which the transformation + becomes asymptotically logarithmic. + base : int, default: 10 + The number base used for rounding tick locations + on a logarithmic scale. If this is less than one, + then rounding is to the nearest integer multiple + of powers of ten. + subs : sequence of int + Multiples of the number base used for minor ticks. + If set to 'auto', this will use built-in defaults, + e.g. (2, 5) for base=10. + """ + super().__init__(axis) + self._transform = AsinhTransform(linear_width) + self._base = int(base) + if subs == 'auto': + self._subs = self.auto_tick_multipliers.get(self._base) + else: + self._subs = subs + + linear_width = property(lambda self: self._transform.linear_width) + + def get_transform(self): + return self._transform + + def set_default_locators_and_formatters(self, axis): + axis.set(major_locator=AsinhLocator(self.linear_width, + base=self._base), + minor_locator=AsinhLocator(self.linear_width, + base=self._base, + subs=self._subs), + minor_formatter=NullFormatter()) + if self._base > 1: + axis.set_major_formatter(LogFormatterSciNotation(self._base)) + else: + axis.set_major_formatter('{x:.3g}') + + +class LogitTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, nonpositive='mask'): + super().__init__() + _api.check_in_list(['mask', 'clip'], nonpositive=nonpositive) + self._nonpositive = nonpositive + self._clip = {"clip": True, "mask": False}[nonpositive] + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + """logit transform (base 10), masked or clipped""" + with np.errstate(divide="ignore", invalid="ignore"): + out = np.log10(values / (1 - values)) + if self._clip: # See LogTransform for choice of clip value. + out[values <= 0] = -1000 + out[1 <= values] = 1000 + return out + + def inverted(self): + return LogisticTransform(self._nonpositive) + + def __str__(self): + return f"{type(self).__name__}({self._nonpositive!r})" + + +class LogisticTransform(Transform): + input_dims = output_dims = 1 + + def __init__(self, nonpositive='mask'): + super().__init__() + self._nonpositive = nonpositive + + @_api.rename_parameter("3.8", "a", "values") + def transform_non_affine(self, values): + """logistic transform (base 10)""" + return 1.0 / (1 + 10**(-values)) + + def inverted(self): + return LogitTransform(self._nonpositive) + + def __str__(self): + return f"{type(self).__name__}({self._nonpositive!r})" + + +class LogitScale(ScaleBase): + """ + Logit scale for data between zero and one, both excluded. + + This scale is similar to a log scale close to zero and to one, and almost + linear around 0.5. It maps the interval ]0, 1[ onto ]-infty, +infty[. + """ + name = 'logit' + + def __init__(self, axis, nonpositive='mask', *, + one_half=r"\frac{1}{2}", use_overline=False): + r""" + Parameters + ---------- + axis : `~matplotlib.axis.Axis` + Currently unused. + nonpositive : {'mask', 'clip'} + Determines the behavior for values beyond the open interval ]0, 1[. + They can either be masked as invalid, or clipped to a number very + close to 0 or 1. + use_overline : bool, default: False + Indicate the usage of survival notation (\overline{x}) in place of + standard notation (1-x) for probability close to one. + one_half : str, default: r"\frac{1}{2}" + The string used for ticks formatter to represent 1/2. + """ + self._transform = LogitTransform(nonpositive) + self._use_overline = use_overline + self._one_half = one_half + + def get_transform(self): + """Return the `.LogitTransform` associated with this scale.""" + return self._transform + + def set_default_locators_and_formatters(self, axis): + # docstring inherited + # ..., 0.01, 0.1, 0.5, 0.9, 0.99, ... + axis.set_major_locator(LogitLocator()) + axis.set_major_formatter( + LogitFormatter( + one_half=self._one_half, + use_overline=self._use_overline + ) + ) + axis.set_minor_locator(LogitLocator(minor=True)) + axis.set_minor_formatter( + LogitFormatter( + minor=True, + one_half=self._one_half, + use_overline=self._use_overline + ) + ) + + def limit_range_for_scale(self, vmin, vmax, minpos): + """ + Limit the domain to values between 0 and 1 (excluded). + """ + if not np.isfinite(minpos): + minpos = 1e-7 # Should rarely (if ever) have a visible effect. + return (minpos if vmin <= 0 else vmin, + 1 - minpos if vmax >= 1 else vmax) + + +_scale_mapping = { + 'linear': LinearScale, + 'log': LogScale, + 'symlog': SymmetricalLogScale, + 'asinh': AsinhScale, + 'logit': LogitScale, + 'function': FuncScale, + 'functionlog': FuncScaleLog, + } + + +def get_scale_names(): + """Return the names of the available scales.""" + return sorted(_scale_mapping) + + +def scale_factory(scale, axis, **kwargs): + """ + Return a scale class by name. + + Parameters + ---------- + scale : {%(names)s} + axis : `~matplotlib.axis.Axis` + """ + scale_cls = _api.check_getitem(_scale_mapping, scale=scale) + return scale_cls(axis, **kwargs) + + +if scale_factory.__doc__: + scale_factory.__doc__ = scale_factory.__doc__ % { + "names": ", ".join(map(repr, get_scale_names()))} + + +def register_scale(scale_class): + """ + Register a new kind of scale. + + Parameters + ---------- + scale_class : subclass of `ScaleBase` + The scale to register. + """ + _scale_mapping[scale_class.name] = scale_class + + +def _get_scale_docs(): + """ + Helper function for generating docstrings related to scales. + """ + docs = [] + for name, scale_class in _scale_mapping.items(): + docstring = inspect.getdoc(scale_class.__init__) or "" + docs.extend([ + f" {name!r}", + "", + textwrap.indent(docstring, " " * 8), + "" + ]) + return "\n".join(docs) + + +_docstring.interpd.update( + scale_type='{%s}' % ', '.join([repr(x) for x in get_scale_names()]), + scale_docs=_get_scale_docs().rstrip(), + ) diff --git a/venv/lib/python3.10/site-packages/matplotlib/scale.pyi b/venv/lib/python3.10/site-packages/matplotlib/scale.pyi new file mode 100644 index 00000000..7fec8e68 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/scale.pyi @@ -0,0 +1,178 @@ +from matplotlib.axis import Axis +from matplotlib.transforms import Transform + +from collections.abc import Callable, Iterable +from typing import Literal +from numpy.typing import ArrayLike + +class ScaleBase: + def __init__(self, axis: Axis | None) -> None: ... + def get_transform(self) -> Transform: ... + def set_default_locators_and_formatters(self, axis: Axis) -> None: ... + def limit_range_for_scale( + self, vmin: float, vmax: float, minpos: float + ) -> tuple[float, float]: ... + +class LinearScale(ScaleBase): + name: str + +class FuncTransform(Transform): + input_dims: int + output_dims: int + def __init__( + self, + forward: Callable[[ArrayLike], ArrayLike], + inverse: Callable[[ArrayLike], ArrayLike], + ) -> None: ... + def inverted(self) -> FuncTransform: ... + +class FuncScale(ScaleBase): + name: str + def __init__( + self, + axis: Axis | None, + functions: tuple[ + Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike] + ], + ) -> None: ... + +class LogTransform(Transform): + input_dims: int + output_dims: int + base: float + def __init__( + self, base: float, nonpositive: Literal["clip", "mask"] = ... + ) -> None: ... + def inverted(self) -> InvertedLogTransform: ... + +class InvertedLogTransform(Transform): + input_dims: int + output_dims: int + base: float + def __init__(self, base: float) -> None: ... + def inverted(self) -> LogTransform: ... + +class LogScale(ScaleBase): + name: str + subs: Iterable[int] | None + def __init__( + self, + axis: Axis | None, + *, + base: float = ..., + subs: Iterable[int] | None = ..., + nonpositive: Literal["clip", "mask"] = ... + ) -> None: ... + @property + def base(self) -> float: ... + def get_transform(self) -> Transform: ... + +class FuncScaleLog(LogScale): + def __init__( + self, + axis: Axis | None, + functions: tuple[ + Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike] + ], + base: float = ..., + ) -> None: ... + @property + def base(self) -> float: ... + def get_transform(self) -> Transform: ... + +class SymmetricalLogTransform(Transform): + input_dims: int + output_dims: int + base: float + linthresh: float + linscale: float + def __init__(self, base: float, linthresh: float, linscale: float) -> None: ... + def inverted(self) -> InvertedSymmetricalLogTransform: ... + +class InvertedSymmetricalLogTransform(Transform): + input_dims: int + output_dims: int + base: float + linthresh: float + invlinthresh: float + linscale: float + def __init__(self, base: float, linthresh: float, linscale: float) -> None: ... + def inverted(self) -> SymmetricalLogTransform: ... + +class SymmetricalLogScale(ScaleBase): + name: str + subs: Iterable[int] | None + def __init__( + self, + axis: Axis | None, + *, + base: float = ..., + linthresh: float = ..., + subs: Iterable[int] | None = ..., + linscale: float = ... + ) -> None: ... + @property + def base(self) -> float: ... + @property + def linthresh(self) -> float: ... + @property + def linscale(self) -> float: ... + def get_transform(self) -> SymmetricalLogTransform: ... + +class AsinhTransform(Transform): + input_dims: int + output_dims: int + linear_width: float + def __init__(self, linear_width: float) -> None: ... + def inverted(self) -> InvertedAsinhTransform: ... + +class InvertedAsinhTransform(Transform): + input_dims: int + output_dims: int + linear_width: float + def __init__(self, linear_width: float) -> None: ... + def inverted(self) -> AsinhTransform: ... + +class AsinhScale(ScaleBase): + name: str + auto_tick_multipliers: dict[int, tuple[int, ...]] + def __init__( + self, + axis: Axis | None, + *, + linear_width: float = ..., + base: float = ..., + subs: Iterable[int] | Literal["auto"] | None = ..., + **kwargs + ) -> None: ... + @property + def linear_width(self) -> float: ... + def get_transform(self) -> AsinhTransform: ... + +class LogitTransform(Transform): + input_dims: int + output_dims: int + def __init__(self, nonpositive: Literal["mask", "clip"] = ...) -> None: ... + def inverted(self) -> LogisticTransform: ... + +class LogisticTransform(Transform): + input_dims: int + output_dims: int + def __init__(self, nonpositive: Literal["mask", "clip"] = ...) -> None: ... + def inverted(self) -> LogitTransform: ... + +class LogitScale(ScaleBase): + name: str + def __init__( + self, + axis: Axis | None, + nonpositive: Literal["mask", "clip"] = ..., + *, + one_half: str = ..., + use_overline: bool = ... + ) -> None: ... + def get_transform(self) -> LogitTransform: ... + +def get_scale_names() -> list[str]: ... +def scale_factory(scale: str, axis: Axis, **kwargs) -> ScaleBase: ... +def register_scale(scale_class: type[ScaleBase]) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/sphinxext/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/venv/lib/python3.10/site-packages/matplotlib/sphinxext/figmpl_directive.py b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/figmpl_directive.py new file mode 100644 index 00000000..5ef34f4d --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/figmpl_directive.py @@ -0,0 +1,288 @@ +""" +Add a ``figure-mpl`` directive that is a responsive version of ``figure``. + +This implementation is very similar to ``.. figure::``, except it also allows a +``srcset=`` argument to be passed to the image tag, hence allowing responsive +resolution images. + +There is no particular reason this could not be used standalone, but is meant +to be used with :doc:`/api/sphinxext_plot_directive_api`. + +Note that the directory organization is a bit different than ``.. figure::``. +See the *FigureMpl* documentation below. + +""" +from docutils import nodes + +from docutils.parsers.rst import directives +from docutils.parsers.rst.directives.images import Figure, Image + +import os +from os.path import relpath +from pathlib import PurePath, Path +import shutil + +from sphinx.errors import ExtensionError + +import matplotlib + + +class figmplnode(nodes.General, nodes.Element): + pass + + +class FigureMpl(Figure): + """ + Implements a directive to allow an optional hidpi image. + + Meant to be used with the *plot_srcset* configuration option in conf.py, + and gets set in the TEMPLATE of plot_directive.py + + e.g.:: + + .. figure-mpl:: plot_directive/some_plots-1.png + :alt: bar + :srcset: plot_directive/some_plots-1.png, + plot_directive/some_plots-1.2x.png 2.00x + :class: plot-directive + + The resulting html (at ``some_plots.html``) is:: + + bar + + Note that the handling of subdirectories is different than that used by the sphinx + figure directive:: + + .. figure-mpl:: plot_directive/nestedpage/index-1.png + :alt: bar + :srcset: plot_directive/nestedpage/index-1.png + plot_directive/nestedpage/index-1.2x.png 2.00x + :class: plot_directive + + The resulting html (at ``nestedpage/index.html``):: + + bar + + where the subdirectory is included in the image name for uniqueness. + """ + + has_content = False + required_arguments = 1 + optional_arguments = 2 + final_argument_whitespace = False + option_spec = { + 'alt': directives.unchanged, + 'height': directives.length_or_unitless, + 'width': directives.length_or_percentage_or_unitless, + 'scale': directives.nonnegative_int, + 'align': Image.align, + 'class': directives.class_option, + 'caption': directives.unchanged, + 'srcset': directives.unchanged, + } + + def run(self): + + image_node = figmplnode() + + imagenm = self.arguments[0] + image_node['alt'] = self.options.get('alt', '') + image_node['align'] = self.options.get('align', None) + image_node['class'] = self.options.get('class', None) + image_node['width'] = self.options.get('width', None) + image_node['height'] = self.options.get('height', None) + image_node['scale'] = self.options.get('scale', None) + image_node['caption'] = self.options.get('caption', None) + + # we would like uri to be the highest dpi version so that + # latex etc will use that. But for now, lets just make + # imagenm... maybe pdf one day? + + image_node['uri'] = imagenm + image_node['srcset'] = self.options.get('srcset', None) + + return [image_node] + + +def _parse_srcsetNodes(st): + """ + parse srcset... + """ + entries = st.split(',') + srcset = {} + for entry in entries: + spl = entry.strip().split(' ') + if len(spl) == 1: + srcset[0] = spl[0] + elif len(spl) == 2: + mult = spl[1][:-1] + srcset[float(mult)] = spl[0] + else: + raise ExtensionError(f'srcset argument "{entry}" is invalid.') + return srcset + + +def _copy_images_figmpl(self, node): + + # these will be the temporary place the plot-directive put the images eg: + # ../../../build/html/plot_directive/users/explain/artists/index-1.png + if node['srcset']: + srcset = _parse_srcsetNodes(node['srcset']) + else: + srcset = None + + # the rst file's location: eg /Users/username/matplotlib/doc/users/explain/artists + docsource = PurePath(self.document['source']).parent + + # get the relpath relative to root: + srctop = self.builder.srcdir + rel = relpath(docsource, srctop).replace('.', '').replace(os.sep, '-') + if len(rel): + rel += '-' + # eg: users/explain/artists + + imagedir = PurePath(self.builder.outdir, self.builder.imagedir) + # eg: /Users/username/matplotlib/doc/build/html/_images/users/explain/artists + + Path(imagedir).mkdir(parents=True, exist_ok=True) + + # copy all the sources to the imagedir: + if srcset: + for src in srcset.values(): + # the entries in srcset are relative to docsource's directory + abspath = PurePath(docsource, src) + name = rel + abspath.name + shutil.copyfile(abspath, imagedir / name) + else: + abspath = PurePath(docsource, node['uri']) + name = rel + abspath.name + shutil.copyfile(abspath, imagedir / name) + + return imagedir, srcset, rel + + +def visit_figmpl_html(self, node): + + imagedir, srcset, rel = _copy_images_figmpl(self, node) + + # /doc/examples/subd/plot_1.rst + docsource = PurePath(self.document['source']) + # /doc/ + # make sure to add the trailing slash: + srctop = PurePath(self.builder.srcdir, '') + # examples/subd/plot_1.rst + relsource = relpath(docsource, srctop) + # /doc/build/html + desttop = PurePath(self.builder.outdir, '') + # /doc/build/html/examples/subd + dest = desttop / relsource + + # ../../_images/ for dirhtml and ../_images/ for html + imagerel = PurePath(relpath(imagedir, dest.parent)).as_posix() + if self.builder.name == "dirhtml": + imagerel = f'..{imagerel}' + + # make uri also be relative... + nm = PurePath(node['uri'][1:]).name + uri = f'{imagerel}/{rel}{nm}' + + # make srcset str. Need to change all the prefixes! + maxsrc = uri + srcsetst = '' + if srcset: + maxmult = -1 + for mult, src in srcset.items(): + nm = PurePath(src[1:]).name + # ../../_images/plot_1_2_0x.png + path = f'{imagerel}/{rel}{nm}' + srcsetst += path + if mult == 0: + srcsetst += ', ' + else: + srcsetst += f' {mult:1.2f}x, ' + + if mult > maxmult: + maxmult = mult + maxsrc = path + + # trim trailing comma and space... + srcsetst = srcsetst[:-2] + + alt = node['alt'] + if node['class'] is not None: + classst = ' '.join(node['class']) + classst = f'class="{classst}"' + + else: + classst = '' + + stylers = ['width', 'height', 'scale'] + stylest = '' + for style in stylers: + if node[style]: + stylest += f'{style}: {node[style]};' + + figalign = node['align'] if node['align'] else 'center' + +#
+# +# _images/index-1.2x.png +# +#
+#

Figure caption is here.... +# #

+#
+#
+ img_block = (f'') + html_block = f'
\n' + html_block += f' \n' + html_block += f' {img_block}\n \n' + if node['caption']: + html_block += '
\n' + html_block += f'

{node["caption"]}

\n' + html_block += '
\n' + html_block += '
\n' + self.body.append(html_block) + + +def visit_figmpl_latex(self, node): + + if node['srcset'] is not None: + imagedir, srcset = _copy_images_figmpl(self, node) + maxmult = -1 + # choose the highest res version for latex: + maxmult = max(srcset, default=-1) + node['uri'] = PurePath(srcset[maxmult]).name + + self.visit_figure(node) + + +def depart_figmpl_html(self, node): + pass + + +def depart_figmpl_latex(self, node): + self.depart_figure(node) + + +def figurempl_addnode(app): + app.add_node(figmplnode, + html=(visit_figmpl_html, depart_figmpl_html), + latex=(visit_figmpl_latex, depart_figmpl_latex)) + + +def setup(app): + app.add_directive("figure-mpl", FigureMpl) + figurempl_addnode(app) + metadata = {'parallel_read_safe': True, 'parallel_write_safe': True, + 'version': matplotlib.__version__} + return metadata diff --git a/venv/lib/python3.10/site-packages/matplotlib/sphinxext/mathmpl.py b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/mathmpl.py new file mode 100644 index 00000000..3e0d562e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/mathmpl.py @@ -0,0 +1,239 @@ +r""" +A role and directive to display mathtext in Sphinx +================================================== + +The ``mathmpl`` Sphinx extension creates a mathtext image in Matplotlib and +shows it in html output. Thus, it is a true and faithful representation of what +you will see if you pass a given LaTeX string to Matplotlib (see +:ref:`mathtext`). + +.. warning:: + In most cases, you will likely want to use one of `Sphinx's builtin Math + extensions + `__ + instead of this one. The builtin Sphinx math directive uses MathJax to + render mathematical expressions, and addresses accessibility concerns that + ``mathmpl`` doesn't address. + +Mathtext may be included in two ways: + +1. Inline, using the role:: + + This text uses inline math: :mathmpl:`\alpha > \beta`. + + which produces: + + This text uses inline math: :mathmpl:`\alpha > \beta`. + +2. Standalone, using the directive:: + + Here is some standalone math: + + .. mathmpl:: + + \alpha > \beta + + which produces: + + Here is some standalone math: + + .. mathmpl:: + + \alpha > \beta + +Options +------- + +The ``mathmpl`` role and directive both support the following options: + +fontset : str, default: 'cm' + The font set to use when displaying math. See :rc:`mathtext.fontset`. + +fontsize : float + The font size, in points. Defaults to the value from the extension + configuration option defined below. + +Configuration options +--------------------- + +The mathtext extension has the following configuration options: + +mathmpl_fontsize : float, default: 10.0 + Default font size, in points. + +mathmpl_srcset : list of str, default: [] + Additional image sizes to generate when embedding in HTML, to support + `responsive resolution images + `__. + The list should contain additional x-descriptors (``'1.5x'``, ``'2x'``, + etc.) to generate (1x is the default and always included.) + +""" + +import hashlib +from pathlib import Path + +from docutils import nodes +from docutils.parsers.rst import Directive, directives +import sphinx +from sphinx.errors import ConfigError, ExtensionError + +import matplotlib as mpl +from matplotlib import _api, mathtext +from matplotlib.rcsetup import validate_float_or_None + + +# Define LaTeX math node: +class latex_math(nodes.General, nodes.Element): + pass + + +def fontset_choice(arg): + return directives.choice(arg, mathtext.MathTextParser._font_type_mapping) + + +def math_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): + i = rawtext.find('`') + latex = rawtext[i+1:-1] + node = latex_math(rawtext) + node['latex'] = latex + node['fontset'] = options.get('fontset', 'cm') + node['fontsize'] = options.get('fontsize', + setup.app.config.mathmpl_fontsize) + return [node], [] +math_role.options = {'fontset': fontset_choice, + 'fontsize': validate_float_or_None} + + +class MathDirective(Directive): + """ + The ``.. mathmpl::`` directive, as documented in the module's docstring. + """ + has_content = True + required_arguments = 0 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = {'fontset': fontset_choice, + 'fontsize': validate_float_or_None} + + def run(self): + latex = ''.join(self.content) + node = latex_math(self.block_text) + node['latex'] = latex + node['fontset'] = self.options.get('fontset', 'cm') + node['fontsize'] = self.options.get('fontsize', + setup.app.config.mathmpl_fontsize) + return [node] + + +# This uses mathtext to render the expression +def latex2png(latex, filename, fontset='cm', fontsize=10, dpi=100): + with mpl.rc_context({'mathtext.fontset': fontset, 'font.size': fontsize}): + try: + depth = mathtext.math_to_image( + f"${latex}$", filename, dpi=dpi, format="png") + except Exception: + _api.warn_external(f"Could not render math expression {latex}") + depth = 0 + return depth + + +# LaTeX to HTML translation stuff: +def latex2html(node, source): + inline = isinstance(node.parent, nodes.TextElement) + latex = node['latex'] + fontset = node['fontset'] + fontsize = node['fontsize'] + name = 'math-{}'.format( + hashlib.md5(f'{latex}{fontset}{fontsize}'.encode()).hexdigest()[-10:]) + + destdir = Path(setup.app.builder.outdir, '_images', 'mathmpl') + destdir.mkdir(parents=True, exist_ok=True) + + dest = destdir / f'{name}.png' + depth = latex2png(latex, dest, fontset, fontsize=fontsize) + + srcset = [] + for size in setup.app.config.mathmpl_srcset: + filename = f'{name}-{size.replace(".", "_")}.png' + latex2png(latex, destdir / filename, fontset, fontsize=fontsize, + dpi=100 * float(size[:-1])) + srcset.append( + f'{setup.app.builder.imgpath}/mathmpl/{filename} {size}') + if srcset: + srcset = (f'srcset="{setup.app.builder.imgpath}/mathmpl/{name}.png, ' + + ', '.join(srcset) + '" ') + + if inline: + cls = '' + else: + cls = 'class="center" ' + if inline and depth != 0: + style = 'style="position: relative; bottom: -%dpx"' % (depth + 1) + else: + style = '' + + return (f'') + + +def _config_inited(app, config): + # Check for srcset hidpi images + for i, size in enumerate(app.config.mathmpl_srcset): + if size[-1] == 'x': # "2x" = "2.0" + try: + float(size[:-1]) + except ValueError: + raise ConfigError( + f'Invalid value for mathmpl_srcset parameter: {size!r}. ' + 'Must be a list of strings with the multiplicative ' + 'factor followed by an "x". e.g. ["2.0x", "1.5x"]') + else: + raise ConfigError( + f'Invalid value for mathmpl_srcset parameter: {size!r}. ' + 'Must be a list of strings with the multiplicative ' + 'factor followed by an "x". e.g. ["2.0x", "1.5x"]') + + +def setup(app): + setup.app = app + app.add_config_value('mathmpl_fontsize', 10.0, True) + app.add_config_value('mathmpl_srcset', [], True) + try: + app.connect('config-inited', _config_inited) # Sphinx 1.8+ + except ExtensionError: + app.connect('env-updated', lambda app, env: _config_inited(app, None)) + + # Add visit/depart methods to HTML-Translator: + def visit_latex_math_html(self, node): + source = self.document.attributes['source'] + self.body.append(latex2html(node, source)) + + def depart_latex_math_html(self, node): + pass + + # Add visit/depart methods to LaTeX-Translator: + def visit_latex_math_latex(self, node): + inline = isinstance(node.parent, nodes.TextElement) + if inline: + self.body.append('$%s$' % node['latex']) + else: + self.body.extend(['\\begin{equation}', + node['latex'], + '\\end{equation}']) + + def depart_latex_math_latex(self, node): + pass + + app.add_node(latex_math, + html=(visit_latex_math_html, depart_latex_math_html), + latex=(visit_latex_math_latex, depart_latex_math_latex)) + app.add_role('mathmpl', math_role) + app.add_directive('mathmpl', MathDirective) + if sphinx.version_info < (1, 8): + app.add_role('math', math_role) + app.add_directive('math', MathDirective) + + metadata = {'parallel_read_safe': True, 'parallel_write_safe': True} + return metadata diff --git a/venv/lib/python3.10/site-packages/matplotlib/sphinxext/plot_directive.py b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/plot_directive.py new file mode 100644 index 00000000..65b25fb9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/sphinxext/plot_directive.py @@ -0,0 +1,933 @@ +""" +A directive for including a Matplotlib plot in a Sphinx document +================================================================ + +This is a Sphinx extension providing a reStructuredText directive +``.. plot::`` for including a plot in a Sphinx document. + +In HTML output, ``.. plot::`` will include a .png file with a link +to a high-res .png and .pdf. In LaTeX output, it will include a .pdf. + +The plot content may be defined in one of three ways: + +1. **A path to a source file** as the argument to the directive:: + + .. plot:: path/to/plot.py + + When a path to a source file is given, the content of the + directive may optionally contain a caption for the plot:: + + .. plot:: path/to/plot.py + + The plot caption. + + Additionally, one may specify the name of a function to call (with + no arguments) immediately after importing the module:: + + .. plot:: path/to/plot.py plot_function1 + +2. Included as **inline content** to the directive:: + + .. plot:: + + import matplotlib.pyplot as plt + plt.plot([1, 2, 3], [4, 5, 6]) + plt.title("A plotting exammple") + +3. Using **doctest** syntax:: + + .. plot:: + + A plotting example: + >>> import matplotlib.pyplot as plt + >>> plt.plot([1, 2, 3], [4, 5, 6]) + +Options +------- + +The ``.. plot::`` directive supports the following options: + +``:format:`` : {'python', 'doctest'} + The format of the input. If unset, the format is auto-detected. + +``:include-source:`` : bool + Whether to display the source code. The default can be changed using + the ``plot_include_source`` variable in :file:`conf.py` (which itself + defaults to False). + +``:show-source-link:`` : bool + Whether to show a link to the source in HTML. The default can be + changed using the ``plot_html_show_source_link`` variable in + :file:`conf.py` (which itself defaults to True). + +``:context:`` : bool or str + If provided, the code will be run in the context of all previous plot + directives for which the ``:context:`` option was specified. This only + applies to inline code plot directives, not those run from files. If + the ``:context: reset`` option is specified, the context is reset + for this and future plots, and previous figures are closed prior to + running the code. ``:context: close-figs`` keeps the context but closes + previous figures before running the code. + +``:nofigs:`` : bool + If specified, the code block will be run, but no figures will be + inserted. This is usually useful with the ``:context:`` option. + +``:caption:`` : str + If specified, the option's argument will be used as a caption for the + figure. This overwrites the caption given in the content, when the plot + is generated from a file. + +Additionally, this directive supports all the options of the `image directive +`_, +except for ``:target:`` (since plot will add its own target). These include +``:alt:``, ``:height:``, ``:width:``, ``:scale:``, ``:align:`` and ``:class:``. + +Configuration options +--------------------- + +The plot directive has the following configuration options: + +plot_include_source + Default value for the include-source option (default: False). + +plot_html_show_source_link + Whether to show a link to the source in HTML (default: True). + +plot_pre_code + Code that should be executed before each plot. If None (the default), + it will default to a string containing:: + + import numpy as np + from matplotlib import pyplot as plt + +plot_basedir + Base directory, to which ``plot::`` file names are relative to. + If None or empty (the default), file names are relative to the + directory where the file containing the directive is. + +plot_formats + File formats to generate (default: ['png', 'hires.png', 'pdf']). + List of tuples or strings:: + + [(suffix, dpi), suffix, ...] + + that determine the file format and the DPI. For entries whose + DPI was omitted, sensible defaults are chosen. When passing from + the command line through sphinx_build the list should be passed as + suffix:dpi,suffix:dpi, ... + +plot_html_show_formats + Whether to show links to the files in HTML (default: True). + +plot_rcparams + A dictionary containing any non-standard rcParams that should + be applied before each plot (default: {}). + +plot_apply_rcparams + By default, rcParams are applied when ``:context:`` option is not used + in a plot directive. If set, this configuration option overrides this + behavior and applies rcParams before each plot. + +plot_working_directory + By default, the working directory will be changed to the directory of + the example, so the code can get at its data files, if any. Also its + path will be added to `sys.path` so it can import any helper modules + sitting beside it. This configuration option can be used to specify + a central directory (also added to `sys.path`) where data files and + helper modules for all code are located. + +plot_template + Provide a customized template for preparing restructured text. + +plot_srcset + Allow the srcset image option for responsive image resolutions. List of + strings with the multiplicative factors followed by an "x". + e.g. ["2.0x", "1.5x"]. "2.0x" will create a png with the default "png" + resolution from plot_formats, multiplied by 2. If plot_srcset is + specified, the plot directive uses the + :doc:`/api/sphinxext_figmpl_directive_api` (instead of the usual figure + directive) in the intermediary rst file that is generated. + The plot_srcset option is incompatible with *singlehtml* builds, and an + error will be raised. + +Notes on how it works +--------------------- + +The plot directive runs the code it is given, either in the source file or the +code under the directive. The figure created (if any) is saved in the sphinx +build directory under a subdirectory named ``plot_directive``. It then creates +an intermediate rst file that calls a ``.. figure:`` directive (or +``.. figmpl::`` directive if ``plot_srcset`` is being used) and has links to +the ``*.png`` files in the ``plot_directive`` directory. These translations can +be customized by changing the *plot_template*. See the source of +:doc:`/api/sphinxext_plot_directive_api` for the templates defined in *TEMPLATE* +and *TEMPLATE_SRCSET*. +""" + +import contextlib +import doctest +from io import StringIO +import itertools +import os +from os.path import relpath +from pathlib import Path +import re +import shutil +import sys +import textwrap +import traceback + +from docutils.parsers.rst import directives, Directive +from docutils.parsers.rst.directives.images import Image +import jinja2 # Sphinx dependency. + +from sphinx.errors import ExtensionError + +import matplotlib +from matplotlib.backend_bases import FigureManagerBase +import matplotlib.pyplot as plt +from matplotlib import _pylab_helpers, cbook + +matplotlib.use("agg") + +__version__ = 2 + + +# ----------------------------------------------------------------------------- +# Registration hook +# ----------------------------------------------------------------------------- + + +def _option_boolean(arg): + if not arg or not arg.strip(): + # no argument given, assume used as a flag + return True + elif arg.strip().lower() in ('no', '0', 'false'): + return False + elif arg.strip().lower() in ('yes', '1', 'true'): + return True + else: + raise ValueError(f'{arg!r} unknown boolean') + + +def _option_context(arg): + if arg in [None, 'reset', 'close-figs']: + return arg + raise ValueError("Argument should be None or 'reset' or 'close-figs'") + + +def _option_format(arg): + return directives.choice(arg, ('python', 'doctest')) + + +def mark_plot_labels(app, document): + """ + To make plots referenceable, we need to move the reference from the + "htmlonly" (or "latexonly") node to the actual figure node itself. + """ + for name, explicit in document.nametypes.items(): + if not explicit: + continue + labelid = document.nameids[name] + if labelid is None: + continue + node = document.ids[labelid] + if node.tagname in ('html_only', 'latex_only'): + for n in node: + if n.tagname == 'figure': + sectname = name + for c in n: + if c.tagname == 'caption': + sectname = c.astext() + break + + node['ids'].remove(labelid) + node['names'].remove(name) + n['ids'].append(labelid) + n['names'].append(name) + document.settings.env.labels[name] = \ + document.settings.env.docname, labelid, sectname + break + + +class PlotDirective(Directive): + """The ``.. plot::`` directive, as documented in the module's docstring.""" + + has_content = True + required_arguments = 0 + optional_arguments = 2 + final_argument_whitespace = False + option_spec = { + 'alt': directives.unchanged, + 'height': directives.length_or_unitless, + 'width': directives.length_or_percentage_or_unitless, + 'scale': directives.nonnegative_int, + 'align': Image.align, + 'class': directives.class_option, + 'include-source': _option_boolean, + 'show-source-link': _option_boolean, + 'format': _option_format, + 'context': _option_context, + 'nofigs': directives.flag, + 'caption': directives.unchanged, + } + + def run(self): + """Run the plot directive.""" + try: + return run(self.arguments, self.content, self.options, + self.state_machine, self.state, self.lineno) + except Exception as e: + raise self.error(str(e)) + + +def _copy_css_file(app, exc): + if exc is None and app.builder.format == 'html': + src = cbook._get_data_path('plot_directive/plot_directive.css') + dst = app.outdir / Path('_static') + dst.mkdir(exist_ok=True) + # Use copyfile because we do not want to copy src's permissions. + shutil.copyfile(src, dst / Path('plot_directive.css')) + + +def setup(app): + setup.app = app + setup.config = app.config + setup.confdir = app.confdir + app.add_directive('plot', PlotDirective) + app.add_config_value('plot_pre_code', None, True) + app.add_config_value('plot_include_source', False, True) + app.add_config_value('plot_html_show_source_link', True, True) + app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True) + app.add_config_value('plot_basedir', None, True) + app.add_config_value('plot_html_show_formats', True, True) + app.add_config_value('plot_rcparams', {}, True) + app.add_config_value('plot_apply_rcparams', False, True) + app.add_config_value('plot_working_directory', None, True) + app.add_config_value('plot_template', None, True) + app.add_config_value('plot_srcset', [], True) + app.connect('doctree-read', mark_plot_labels) + app.add_css_file('plot_directive.css') + app.connect('build-finished', _copy_css_file) + metadata = {'parallel_read_safe': True, 'parallel_write_safe': True, + 'version': matplotlib.__version__} + return metadata + + +# ----------------------------------------------------------------------------- +# Doctest handling +# ----------------------------------------------------------------------------- + + +def contains_doctest(text): + try: + # check if it's valid Python as-is + compile(text, '', 'exec') + return False + except SyntaxError: + pass + r = re.compile(r'^\s*>>>', re.M) + m = r.search(text) + return bool(m) + + +def _split_code_at_show(text, function_name): + """Split code at plt.show().""" + + is_doctest = contains_doctest(text) + if function_name is None: + parts = [] + part = [] + for line in text.split("\n"): + if ((not is_doctest and line.startswith('plt.show(')) or + (is_doctest and line.strip() == '>>> plt.show()')): + part.append(line) + parts.append("\n".join(part)) + part = [] + else: + part.append(line) + if "\n".join(part).strip(): + parts.append("\n".join(part)) + else: + parts = [text] + return is_doctest, parts + + +# ----------------------------------------------------------------------------- +# Template +# ----------------------------------------------------------------------------- + +_SOURCECODE = """ +{{ source_code }} + +.. only:: html + + {% if src_name or (html_show_formats and not multi_image) %} + ( + {%- if src_name -%} + :download:`Source code <{{ build_dir }}/{{ src_name }}>` + {%- endif -%} + {%- if html_show_formats and not multi_image -%} + {%- for img in images -%} + {%- for fmt in img.formats -%} + {%- if src_name or not loop.first -%}, {% endif -%} + :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>` + {%- endfor -%} + {%- endfor -%} + {%- endif -%} + ) + {% endif %} +""" + +TEMPLATE_SRCSET = _SOURCECODE + """ + {% for img in images %} + .. figure-mpl:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }} + {% for option in options -%} + {{ option }} + {% endfor %} + {%- if caption -%} + {{ caption }} {# appropriate leading whitespace added beforehand #} + {% endif -%} + {%- if srcset -%} + :srcset: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }} + {%- for sr in srcset -%} + , {{ build_dir }}/{{ img.basename }}.{{ sr }}.{{ default_fmt }} {{sr}} + {%- endfor -%} + {% endif %} + + {% if html_show_formats and multi_image %} + ( + {%- for fmt in img.formats -%} + {%- if not loop.first -%}, {% endif -%} + :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>` + {%- endfor -%} + ) + {% endif %} + + + {% endfor %} + +.. only:: not html + + {% for img in images %} + .. figure-mpl:: {{ build_dir }}/{{ img.basename }}.* + {% for option in options -%} + {{ option }} + {% endfor -%} + + {{ caption }} {# appropriate leading whitespace added beforehand #} + {% endfor %} + +""" + +TEMPLATE = _SOURCECODE + """ + + {% for img in images %} + .. figure:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }} + {% for option in options -%} + {{ option }} + {% endfor %} + + {% if html_show_formats and multi_image -%} + ( + {%- for fmt in img.formats -%} + {%- if not loop.first -%}, {% endif -%} + :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>` + {%- endfor -%} + ) + {%- endif -%} + + {{ caption }} {# appropriate leading whitespace added beforehand #} + {% endfor %} + +.. only:: not html + + {% for img in images %} + .. figure:: {{ build_dir }}/{{ img.basename }}.* + {% for option in options -%} + {{ option }} + {% endfor -%} + + {{ caption }} {# appropriate leading whitespace added beforehand #} + {% endfor %} + +""" + +exception_template = """ +.. only:: html + + [`source code <%(linkdir)s/%(basename)s.py>`__] + +Exception occurred rendering plot. + +""" + +# the context of the plot for all directives specified with the +# :context: option +plot_context = dict() + + +class ImageFile: + def __init__(self, basename, dirname): + self.basename = basename + self.dirname = dirname + self.formats = [] + + def filename(self, format): + return os.path.join(self.dirname, f"{self.basename}.{format}") + + def filenames(self): + return [self.filename(fmt) for fmt in self.formats] + + +def out_of_date(original, derived, includes=None): + """ + Return whether *derived* is out-of-date relative to *original* or any of + the RST files included in it using the RST include directive (*includes*). + *derived* and *original* are full paths, and *includes* is optionally a + list of full paths which may have been included in the *original*. + """ + if not os.path.exists(derived): + return True + + if includes is None: + includes = [] + files_to_check = [original, *includes] + + def out_of_date_one(original, derived_mtime): + return (os.path.exists(original) and + derived_mtime < os.stat(original).st_mtime) + + derived_mtime = os.stat(derived).st_mtime + return any(out_of_date_one(f, derived_mtime) for f in files_to_check) + + +class PlotError(RuntimeError): + pass + + +def _run_code(code, code_path, ns=None, function_name=None): + """ + Import a Python module from a path, and run the function given by + name, if function_name is not None. + """ + + # Change the working directory to the directory of the example, so + # it can get at its data files, if any. Add its path to sys.path + # so it can import any helper modules sitting beside it. + pwd = os.getcwd() + if setup.config.plot_working_directory is not None: + try: + os.chdir(setup.config.plot_working_directory) + except OSError as err: + raise OSError(f'{err}\n`plot_working_directory` option in ' + f'Sphinx configuration file must be a valid ' + f'directory path') from err + except TypeError as err: + raise TypeError(f'{err}\n`plot_working_directory` option in ' + f'Sphinx configuration file must be a string or ' + f'None') from err + elif code_path is not None: + dirname = os.path.abspath(os.path.dirname(code_path)) + os.chdir(dirname) + + with cbook._setattr_cm( + sys, argv=[code_path], path=[os.getcwd(), *sys.path]), \ + contextlib.redirect_stdout(StringIO()): + try: + if ns is None: + ns = {} + if not ns: + if setup.config.plot_pre_code is None: + exec('import numpy as np\n' + 'from matplotlib import pyplot as plt\n', ns) + else: + exec(str(setup.config.plot_pre_code), ns) + if "__main__" in code: + ns['__name__'] = '__main__' + + # Patch out non-interactive show() to avoid triggering a warning. + with cbook._setattr_cm(FigureManagerBase, show=lambda self: None): + exec(code, ns) + if function_name is not None: + exec(function_name + "()", ns) + + except (Exception, SystemExit) as err: + raise PlotError(traceback.format_exc()) from err + finally: + os.chdir(pwd) + return ns + + +def clear_state(plot_rcparams, close=True): + if close: + plt.close('all') + matplotlib.rc_file_defaults() + matplotlib.rcParams.update(plot_rcparams) + + +def get_plot_formats(config): + default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200} + formats = [] + plot_formats = config.plot_formats + for fmt in plot_formats: + if isinstance(fmt, str): + if ':' in fmt: + suffix, dpi = fmt.split(':') + formats.append((str(suffix), int(dpi))) + else: + formats.append((fmt, default_dpi.get(fmt, 80))) + elif isinstance(fmt, (tuple, list)) and len(fmt) == 2: + formats.append((str(fmt[0]), int(fmt[1]))) + else: + raise PlotError('invalid image format "%r" in plot_formats' % fmt) + return formats + + +def _parse_srcset(entries): + """ + Parse srcset for multiples... + """ + srcset = {} + for entry in entries: + entry = entry.strip() + if len(entry) >= 2: + mult = entry[:-1] + srcset[float(mult)] = entry + else: + raise ExtensionError(f'srcset argument {entry!r} is invalid.') + return srcset + + +def render_figures(code, code_path, output_dir, output_base, context, + function_name, config, context_reset=False, + close_figs=False, + code_includes=None): + """ + Run a pyplot script and save the images in *output_dir*. + + Save the images under *output_dir* with file names derived from + *output_base* + """ + + if function_name is not None: + output_base = f'{output_base}_{function_name}' + formats = get_plot_formats(config) + + # Try to determine if all images already exist + + is_doctest, code_pieces = _split_code_at_show(code, function_name) + # Look for single-figure output files first + img = ImageFile(output_base, output_dir) + for format, dpi in formats: + if context or out_of_date(code_path, img.filename(format), + includes=code_includes): + all_exists = False + break + img.formats.append(format) + else: + all_exists = True + + if all_exists: + return [(code, [img])] + + # Then look for multi-figure output files + results = [] + for i, code_piece in enumerate(code_pieces): + images = [] + for j in itertools.count(): + if len(code_pieces) > 1: + img = ImageFile('%s_%02d_%02d' % (output_base, i, j), + output_dir) + else: + img = ImageFile('%s_%02d' % (output_base, j), output_dir) + for fmt, dpi in formats: + if context or out_of_date(code_path, img.filename(fmt), + includes=code_includes): + all_exists = False + break + img.formats.append(fmt) + + # assume that if we have one, we have them all + if not all_exists: + all_exists = (j > 0) + break + images.append(img) + if not all_exists: + break + results.append((code_piece, images)) + else: + all_exists = True + + if all_exists: + return results + + # We didn't find the files, so build them + + results = [] + ns = plot_context if context else {} + + if context_reset: + clear_state(config.plot_rcparams) + plot_context.clear() + + close_figs = not context or close_figs + + for i, code_piece in enumerate(code_pieces): + + if not context or config.plot_apply_rcparams: + clear_state(config.plot_rcparams, close_figs) + elif close_figs: + plt.close('all') + + _run_code(doctest.script_from_examples(code_piece) if is_doctest + else code_piece, + code_path, ns, function_name) + + images = [] + fig_managers = _pylab_helpers.Gcf.get_all_fig_managers() + for j, figman in enumerate(fig_managers): + if len(fig_managers) == 1 and len(code_pieces) == 1: + img = ImageFile(output_base, output_dir) + elif len(code_pieces) == 1: + img = ImageFile("%s_%02d" % (output_base, j), output_dir) + else: + img = ImageFile("%s_%02d_%02d" % (output_base, i, j), + output_dir) + images.append(img) + + for fmt, dpi in formats: + try: + figman.canvas.figure.savefig(img.filename(fmt), dpi=dpi) + if fmt == formats[0][0] and config.plot_srcset: + # save a 2x, 3x etc version of the default... + srcset = _parse_srcset(config.plot_srcset) + for mult, suffix in srcset.items(): + fm = f'{suffix}.{fmt}' + img.formats.append(fm) + figman.canvas.figure.savefig(img.filename(fm), + dpi=int(dpi * mult)) + except Exception as err: + raise PlotError(traceback.format_exc()) from err + img.formats.append(fmt) + + results.append((code_piece, images)) + + if not context or config.plot_apply_rcparams: + clear_state(config.plot_rcparams, close=not context) + + return results + + +def run(arguments, content, options, state_machine, state, lineno): + document = state_machine.document + config = document.settings.env.config + nofigs = 'nofigs' in options + + if config.plot_srcset and setup.app.builder.name == 'singlehtml': + raise ExtensionError( + 'plot_srcset option not compatible with single HTML writer') + + formats = get_plot_formats(config) + default_fmt = formats[0][0] + + options.setdefault('include-source', config.plot_include_source) + options.setdefault('show-source-link', config.plot_html_show_source_link) + + if 'class' in options: + # classes are parsed into a list of string, and output by simply + # printing the list, abusing the fact that RST guarantees to strip + # non-conforming characters + options['class'] = ['plot-directive'] + options['class'] + else: + options.setdefault('class', ['plot-directive']) + keep_context = 'context' in options + context_opt = None if not keep_context else options['context'] + + rst_file = document.attributes['source'] + rst_dir = os.path.dirname(rst_file) + + if len(arguments): + if not config.plot_basedir: + source_file_name = os.path.join(setup.app.builder.srcdir, + directives.uri(arguments[0])) + else: + source_file_name = os.path.join(setup.confdir, config.plot_basedir, + directives.uri(arguments[0])) + # If there is content, it will be passed as a caption. + caption = '\n'.join(content) + + # Enforce unambiguous use of captions. + if "caption" in options: + if caption: + raise ValueError( + 'Caption specified in both content and options.' + ' Please remove ambiguity.' + ) + # Use caption option + caption = options["caption"] + + # If the optional function name is provided, use it + if len(arguments) == 2: + function_name = arguments[1] + else: + function_name = None + + code = Path(source_file_name).read_text(encoding='utf-8') + output_base = os.path.basename(source_file_name) + else: + source_file_name = rst_file + code = textwrap.dedent("\n".join(map(str, content))) + counter = document.attributes.get('_plot_counter', 0) + 1 + document.attributes['_plot_counter'] = counter + base, ext = os.path.splitext(os.path.basename(source_file_name)) + output_base = '%s-%d.py' % (base, counter) + function_name = None + caption = options.get('caption', '') + + base, source_ext = os.path.splitext(output_base) + if source_ext in ('.py', '.rst', '.txt'): + output_base = base + else: + source_ext = '' + + # ensure that LaTeX includegraphics doesn't choke in foo.bar.pdf filenames + output_base = output_base.replace('.', '-') + + # is it in doctest format? + is_doctest = contains_doctest(code) + if 'format' in options: + if options['format'] == 'python': + is_doctest = False + else: + is_doctest = True + + # determine output directory name fragment + source_rel_name = relpath(source_file_name, setup.confdir) + source_rel_dir = os.path.dirname(source_rel_name).lstrip(os.path.sep) + + # build_dir: where to place output files (temporarily) + build_dir = os.path.join(os.path.dirname(setup.app.doctreedir), + 'plot_directive', + source_rel_dir) + # get rid of .. in paths, also changes pathsep + # see note in Python docs for warning about symbolic links on Windows. + # need to compare source and dest paths at end + build_dir = os.path.normpath(build_dir) + os.makedirs(build_dir, exist_ok=True) + + # how to link to files from the RST file + try: + build_dir_link = relpath(build_dir, rst_dir).replace(os.path.sep, '/') + except ValueError: + # on Windows, relpath raises ValueError when path and start are on + # different mounts/drives + build_dir_link = build_dir + + # get list of included rst files so that the output is updated when any + # plots in the included files change. These attributes are modified by the + # include directive (see the docutils.parsers.rst.directives.misc module). + try: + source_file_includes = [os.path.join(os.getcwd(), t[0]) + for t in state.document.include_log] + except AttributeError: + # the document.include_log attribute only exists in docutils >=0.17, + # before that we need to inspect the state machine + possible_sources = {os.path.join(setup.confdir, t[0]) + for t in state_machine.input_lines.items} + source_file_includes = [f for f in possible_sources + if os.path.isfile(f)] + # remove the source file itself from the includes + try: + source_file_includes.remove(source_file_name) + except ValueError: + pass + + # save script (if necessary) + if options['show-source-link']: + Path(build_dir, output_base + source_ext).write_text( + doctest.script_from_examples(code) + if source_file_name == rst_file and is_doctest + else code, + encoding='utf-8') + + # make figures + try: + results = render_figures(code=code, + code_path=source_file_name, + output_dir=build_dir, + output_base=output_base, + context=keep_context, + function_name=function_name, + config=config, + context_reset=context_opt == 'reset', + close_figs=context_opt == 'close-figs', + code_includes=source_file_includes) + errors = [] + except PlotError as err: + reporter = state.memo.reporter + sm = reporter.system_message( + 2, "Exception occurred in plotting {}\n from {}:\n{}".format( + output_base, source_file_name, err), + line=lineno) + results = [(code, [])] + errors = [sm] + + # Properly indent the caption + if caption and config.plot_srcset: + caption = f':caption: {caption}' + elif caption: + caption = '\n' + '\n'.join(' ' + line.strip() + for line in caption.split('\n')) + # generate output restructuredtext + total_lines = [] + for j, (code_piece, images) in enumerate(results): + if options['include-source']: + if is_doctest: + lines = ['', *code_piece.splitlines()] + else: + lines = ['.. code-block:: python', '', + *textwrap.indent(code_piece, ' ').splitlines()] + source_code = "\n".join(lines) + else: + source_code = "" + + if nofigs: + images = [] + + opts = [ + f':{key}: {val}' for key, val in options.items() + if key in ('alt', 'height', 'width', 'scale', 'align', 'class')] + + # Not-None src_name signals the need for a source download in the + # generated html + if j == 0 and options['show-source-link']: + src_name = output_base + source_ext + else: + src_name = None + if config.plot_srcset: + srcset = [*_parse_srcset(config.plot_srcset).values()] + template = TEMPLATE_SRCSET + else: + srcset = None + template = TEMPLATE + + result = jinja2.Template(config.plot_template or template).render( + default_fmt=default_fmt, + build_dir=build_dir_link, + src_name=src_name, + multi_image=len(images) > 1, + options=opts, + srcset=srcset, + images=images, + source_code=source_code, + html_show_formats=config.plot_html_show_formats and len(images), + caption=caption) + total_lines.extend(result.split("\n")) + total_lines.extend("\n") + + if total_lines: + state_machine.insert_input(total_lines, source=source_file_name) + + return errors diff --git a/venv/lib/python3.10/site-packages/matplotlib/spines.py b/venv/lib/python3.10/site-packages/matplotlib/spines.py new file mode 100644 index 00000000..39cb99c5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/spines.py @@ -0,0 +1,595 @@ +from collections.abc import MutableMapping +import functools + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, _docstring +from matplotlib.artist import allow_rasterization +import matplotlib.transforms as mtransforms +import matplotlib.patches as mpatches +import matplotlib.path as mpath + + +class Spine(mpatches.Patch): + """ + An axis spine -- the line noting the data area boundaries. + + Spines are the lines connecting the axis tick marks and noting the + boundaries of the data area. They can be placed at arbitrary + positions. See `~.Spine.set_position` for more information. + + The default position is ``('outward', 0)``. + + Spines are subclasses of `.Patch`, and inherit much of their behavior. + + Spines draw a line, a circle, or an arc depending on if + `~.Spine.set_patch_line`, `~.Spine.set_patch_circle`, or + `~.Spine.set_patch_arc` has been called. Line-like is the default. + + For examples see :ref:`spines_examples`. + """ + def __str__(self): + return "Spine" + + @_docstring.dedent_interpd + def __init__(self, axes, spine_type, path, **kwargs): + """ + Parameters + ---------- + axes : `~matplotlib.axes.Axes` + The `~.axes.Axes` instance containing the spine. + spine_type : str + The spine type. + path : `~matplotlib.path.Path` + The `.Path` instance used to draw the spine. + + Other Parameters + ---------------- + **kwargs + Valid keyword arguments are: + + %(Patch:kwdoc)s + """ + super().__init__(**kwargs) + self.axes = axes + self.set_figure(self.axes.figure) + self.spine_type = spine_type + self.set_facecolor('none') + self.set_edgecolor(mpl.rcParams['axes.edgecolor']) + self.set_linewidth(mpl.rcParams['axes.linewidth']) + self.set_capstyle('projecting') + self.axis = None + + self.set_zorder(2.5) + self.set_transform(self.axes.transData) # default transform + + self._bounds = None # default bounds + + # Defer initial position determination. (Not much support for + # non-rectangular axes is currently implemented, and this lets + # them pass through the spines machinery without errors.) + self._position = None + _api.check_isinstance(mpath.Path, path=path) + self._path = path + + # To support drawing both linear and circular spines, this + # class implements Patch behavior three ways. If + # self._patch_type == 'line', behave like a mpatches.PathPatch + # instance. If self._patch_type == 'circle', behave like a + # mpatches.Ellipse instance. If self._patch_type == 'arc', behave like + # a mpatches.Arc instance. + self._patch_type = 'line' + + # Behavior copied from mpatches.Ellipse: + # Note: This cannot be calculated until this is added to an Axes + self._patch_transform = mtransforms.IdentityTransform() + + def set_patch_arc(self, center, radius, theta1, theta2): + """Set the spine to be arc-like.""" + self._patch_type = 'arc' + self._center = center + self._width = radius * 2 + self._height = radius * 2 + self._theta1 = theta1 + self._theta2 = theta2 + self._path = mpath.Path.arc(theta1, theta2) + # arc drawn on axes transform + self.set_transform(self.axes.transAxes) + self.stale = True + + def set_patch_circle(self, center, radius): + """Set the spine to be circular.""" + self._patch_type = 'circle' + self._center = center + self._width = radius * 2 + self._height = radius * 2 + # circle drawn on axes transform + self.set_transform(self.axes.transAxes) + self.stale = True + + def set_patch_line(self): + """Set the spine to be linear.""" + self._patch_type = 'line' + self.stale = True + + # Behavior copied from mpatches.Ellipse: + def _recompute_transform(self): + """ + Notes + ----- + This cannot be called until after this has been added to an Axes, + otherwise unit conversion will fail. This makes it very important to + call the accessor method and not directly access the transformation + member variable. + """ + assert self._patch_type in ('arc', 'circle') + center = (self.convert_xunits(self._center[0]), + self.convert_yunits(self._center[1])) + width = self.convert_xunits(self._width) + height = self.convert_yunits(self._height) + self._patch_transform = mtransforms.Affine2D() \ + .scale(width * 0.5, height * 0.5) \ + .translate(*center) + + def get_patch_transform(self): + if self._patch_type in ('arc', 'circle'): + self._recompute_transform() + return self._patch_transform + else: + return super().get_patch_transform() + + def get_window_extent(self, renderer=None): + """ + Return the window extent of the spines in display space, including + padding for ticks (but not their labels) + + See Also + -------- + matplotlib.axes.Axes.get_tightbbox + matplotlib.axes.Axes.get_window_extent + """ + # make sure the location is updated so that transforms etc are correct: + self._adjust_location() + bb = super().get_window_extent(renderer=renderer) + if self.axis is None or not self.axis.get_visible(): + return bb + bboxes = [bb] + drawn_ticks = self.axis._update_ticks() + + major_tick = next(iter({*drawn_ticks} & {*self.axis.majorTicks}), None) + minor_tick = next(iter({*drawn_ticks} & {*self.axis.minorTicks}), None) + for tick in [major_tick, minor_tick]: + if tick is None: + continue + bb0 = bb.frozen() + tickl = tick._size + tickdir = tick._tickdir + if tickdir == 'out': + padout = 1 + padin = 0 + elif tickdir == 'in': + padout = 0 + padin = 1 + else: + padout = 0.5 + padin = 0.5 + padout = padout * tickl / 72 * self.figure.dpi + padin = padin * tickl / 72 * self.figure.dpi + + if tick.tick1line.get_visible(): + if self.spine_type == 'left': + bb0.x0 = bb0.x0 - padout + bb0.x1 = bb0.x1 + padin + elif self.spine_type == 'bottom': + bb0.y0 = bb0.y0 - padout + bb0.y1 = bb0.y1 + padin + + if tick.tick2line.get_visible(): + if self.spine_type == 'right': + bb0.x1 = bb0.x1 + padout + bb0.x0 = bb0.x0 - padin + elif self.spine_type == 'top': + bb0.y1 = bb0.y1 + padout + bb0.y0 = bb0.y0 - padout + bboxes.append(bb0) + + return mtransforms.Bbox.union(bboxes) + + def get_path(self): + return self._path + + def _ensure_position_is_set(self): + if self._position is None: + # default position + self._position = ('outward', 0.0) # in points + self.set_position(self._position) + + def register_axis(self, axis): + """ + Register an axis. + + An axis should be registered with its corresponding spine from + the Axes instance. This allows the spine to clear any axis + properties when needed. + """ + self.axis = axis + self.stale = True + + def clear(self): + """Clear the current spine.""" + self._clear() + if self.axis is not None: + self.axis.clear() + + def _clear(self): + """ + Clear things directly related to the spine. + + In this way it is possible to avoid clearing the Axis as well when calling + from library code where it is known that the Axis is cleared separately. + """ + self._position = None # clear position + + def _adjust_location(self): + """Automatically set spine bounds to the view interval.""" + + if self.spine_type == 'circle': + return + + if self._bounds is not None: + low, high = self._bounds + elif self.spine_type in ('left', 'right'): + low, high = self.axes.viewLim.intervaly + elif self.spine_type in ('top', 'bottom'): + low, high = self.axes.viewLim.intervalx + else: + raise ValueError(f'unknown spine spine_type: {self.spine_type}') + + if self._patch_type == 'arc': + if self.spine_type in ('bottom', 'top'): + try: + direction = self.axes.get_theta_direction() + except AttributeError: + direction = 1 + try: + offset = self.axes.get_theta_offset() + except AttributeError: + offset = 0 + low = low * direction + offset + high = high * direction + offset + if low > high: + low, high = high, low + + self._path = mpath.Path.arc(np.rad2deg(low), np.rad2deg(high)) + + if self.spine_type == 'bottom': + rmin, rmax = self.axes.viewLim.intervaly + try: + rorigin = self.axes.get_rorigin() + except AttributeError: + rorigin = rmin + scaled_diameter = (rmin - rorigin) / (rmax - rorigin) + self._height = scaled_diameter + self._width = scaled_diameter + + else: + raise ValueError('unable to set bounds for spine "%s"' % + self.spine_type) + else: + v1 = self._path.vertices + assert v1.shape == (2, 2), 'unexpected vertices shape' + if self.spine_type in ['left', 'right']: + v1[0, 1] = low + v1[1, 1] = high + elif self.spine_type in ['bottom', 'top']: + v1[0, 0] = low + v1[1, 0] = high + else: + raise ValueError('unable to set bounds for spine "%s"' % + self.spine_type) + + @allow_rasterization + def draw(self, renderer): + self._adjust_location() + ret = super().draw(renderer) + self.stale = False + return ret + + def set_position(self, position): + """ + Set the position of the spine. + + Spine position is specified by a 2 tuple of (position type, + amount). The position types are: + + * 'outward': place the spine out from the data area by the specified + number of points. (Negative values place the spine inwards.) + * 'axes': place the spine at the specified Axes coordinate (0 to 1). + * 'data': place the spine at the specified data coordinate. + + Additionally, shorthand notations define a special positions: + + * 'center' -> ``('axes', 0.5)`` + * 'zero' -> ``('data', 0.0)`` + + Examples + -------- + :doc:`/gallery/spines/spine_placement_demo` + """ + if position in ('center', 'zero'): # special positions + pass + else: + if len(position) != 2: + raise ValueError("position should be 'center' or 2-tuple") + if position[0] not in ['outward', 'axes', 'data']: + raise ValueError("position[0] should be one of 'outward', " + "'axes', or 'data' ") + self._position = position + self.set_transform(self.get_spine_transform()) + if self.axis is not None: + self.axis.reset_ticks() + self.stale = True + + def get_position(self): + """Return the spine position.""" + self._ensure_position_is_set() + return self._position + + def get_spine_transform(self): + """Return the spine transform.""" + self._ensure_position_is_set() + + position = self._position + if isinstance(position, str): + if position == 'center': + position = ('axes', 0.5) + elif position == 'zero': + position = ('data', 0) + assert len(position) == 2, 'position should be 2-tuple' + position_type, amount = position + _api.check_in_list(['axes', 'outward', 'data'], + position_type=position_type) + if self.spine_type in ['left', 'right']: + base_transform = self.axes.get_yaxis_transform(which='grid') + elif self.spine_type in ['top', 'bottom']: + base_transform = self.axes.get_xaxis_transform(which='grid') + else: + raise ValueError(f'unknown spine spine_type: {self.spine_type!r}') + + if position_type == 'outward': + if amount == 0: # short circuit commonest case + return base_transform + else: + offset_vec = {'left': (-1, 0), 'right': (1, 0), + 'bottom': (0, -1), 'top': (0, 1), + }[self.spine_type] + # calculate x and y offset in dots + offset_dots = amount * np.array(offset_vec) / 72 + return (base_transform + + mtransforms.ScaledTranslation( + *offset_dots, self.figure.dpi_scale_trans)) + elif position_type == 'axes': + if self.spine_type in ['left', 'right']: + # keep y unchanged, fix x at amount + return (mtransforms.Affine2D.from_values(0, 0, 0, 1, amount, 0) + + base_transform) + elif self.spine_type in ['bottom', 'top']: + # keep x unchanged, fix y at amount + return (mtransforms.Affine2D.from_values(1, 0, 0, 0, 0, amount) + + base_transform) + elif position_type == 'data': + if self.spine_type in ('right', 'top'): + # The right and top spines have a default position of 1 in + # axes coordinates. When specifying the position in data + # coordinates, we need to calculate the position relative to 0. + amount -= 1 + if self.spine_type in ('left', 'right'): + return mtransforms.blended_transform_factory( + mtransforms.Affine2D().translate(amount, 0) + + self.axes.transData, + self.axes.transData) + elif self.spine_type in ('bottom', 'top'): + return mtransforms.blended_transform_factory( + self.axes.transData, + mtransforms.Affine2D().translate(0, amount) + + self.axes.transData) + + def set_bounds(self, low=None, high=None): + """ + Set the spine bounds. + + Parameters + ---------- + low : float or None, optional + The lower spine bound. Passing *None* leaves the limit unchanged. + + The bounds may also be passed as the tuple (*low*, *high*) as the + first positional argument. + + .. ACCEPTS: (low: float, high: float) + + high : float or None, optional + The higher spine bound. Passing *None* leaves the limit unchanged. + """ + if self.spine_type == 'circle': + raise ValueError( + 'set_bounds() method incompatible with circular spines') + if high is None and np.iterable(low): + low, high = low + old_low, old_high = self.get_bounds() or (None, None) + if low is None: + low = old_low + if high is None: + high = old_high + self._bounds = (low, high) + self.stale = True + + def get_bounds(self): + """Get the bounds of the spine.""" + return self._bounds + + @classmethod + def linear_spine(cls, axes, spine_type, **kwargs): + """Create and return a linear `Spine`.""" + # all values of 0.999 get replaced upon call to set_bounds() + if spine_type == 'left': + path = mpath.Path([(0.0, 0.999), (0.0, 0.999)]) + elif spine_type == 'right': + path = mpath.Path([(1.0, 0.999), (1.0, 0.999)]) + elif spine_type == 'bottom': + path = mpath.Path([(0.999, 0.0), (0.999, 0.0)]) + elif spine_type == 'top': + path = mpath.Path([(0.999, 1.0), (0.999, 1.0)]) + else: + raise ValueError('unable to make path for spine "%s"' % spine_type) + result = cls(axes, spine_type, path, **kwargs) + result.set_visible(mpl.rcParams[f'axes.spines.{spine_type}']) + + return result + + @classmethod + def arc_spine(cls, axes, spine_type, center, radius, theta1, theta2, + **kwargs): + """Create and return an arc `Spine`.""" + path = mpath.Path.arc(theta1, theta2) + result = cls(axes, spine_type, path, **kwargs) + result.set_patch_arc(center, radius, theta1, theta2) + return result + + @classmethod + def circular_spine(cls, axes, center, radius, **kwargs): + """Create and return a circular `Spine`.""" + path = mpath.Path.unit_circle() + spine_type = 'circle' + result = cls(axes, spine_type, path, **kwargs) + result.set_patch_circle(center, radius) + return result + + def set_color(self, c): + """ + Set the edgecolor. + + Parameters + ---------- + c : :mpltype:`color` + + Notes + ----- + This method does not modify the facecolor (which defaults to "none"), + unlike the `.Patch.set_color` method defined in the parent class. Use + `.Patch.set_facecolor` to set the facecolor. + """ + self.set_edgecolor(c) + self.stale = True + + +class SpinesProxy: + """ + A proxy to broadcast ``set_*()`` and ``set()`` method calls to contained `.Spines`. + + The proxy cannot be used for any other operations on its members. + + The supported methods are determined dynamically based on the contained + spines. If not all spines support a given method, it's executed only on + the subset of spines that support it. + """ + def __init__(self, spine_dict): + self._spine_dict = spine_dict + + def __getattr__(self, name): + broadcast_targets = [spine for spine in self._spine_dict.values() + if hasattr(spine, name)] + if (name != 'set' and not name.startswith('set_')) or not broadcast_targets: + raise AttributeError( + f"'SpinesProxy' object has no attribute '{name}'") + + def x(_targets, _funcname, *args, **kwargs): + for spine in _targets: + getattr(spine, _funcname)(*args, **kwargs) + x = functools.partial(x, broadcast_targets, name) + x.__doc__ = broadcast_targets[0].__doc__ + return x + + def __dir__(self): + names = [] + for spine in self._spine_dict.values(): + names.extend(name + for name in dir(spine) if name.startswith('set_')) + return list(sorted(set(names))) + + +class Spines(MutableMapping): + r""" + The container of all `.Spine`\s in an Axes. + + The interface is dict-like mapping names (e.g. 'left') to `.Spine` objects. + Additionally, it implements some pandas.Series-like features like accessing + elements by attribute:: + + spines['top'].set_visible(False) + spines.top.set_visible(False) + + Multiple spines can be addressed simultaneously by passing a list:: + + spines[['top', 'right']].set_visible(False) + + Use an open slice to address all spines:: + + spines[:].set_visible(False) + + The latter two indexing methods will return a `SpinesProxy` that broadcasts all + ``set_*()`` and ``set()`` calls to its members, but cannot be used for any other + operation. + """ + def __init__(self, **kwargs): + self._dict = kwargs + + @classmethod + def from_dict(cls, d): + return cls(**d) + + def __getstate__(self): + return self._dict + + def __setstate__(self, state): + self.__init__(**state) + + def __getattr__(self, name): + try: + return self._dict[name] + except KeyError: + raise AttributeError( + f"'Spines' object does not contain a '{name}' spine") + + def __getitem__(self, key): + if isinstance(key, list): + unknown_keys = [k for k in key if k not in self._dict] + if unknown_keys: + raise KeyError(', '.join(unknown_keys)) + return SpinesProxy({k: v for k, v in self._dict.items() + if k in key}) + if isinstance(key, tuple): + raise ValueError('Multiple spines must be passed as a single list') + if isinstance(key, slice): + if key.start is None and key.stop is None and key.step is None: + return SpinesProxy(self._dict) + else: + raise ValueError( + 'Spines does not support slicing except for the fully ' + 'open slice [:] to access all spines.') + return self._dict[key] + + def __setitem__(self, key, value): + # TODO: Do we want to deprecate adding spines? + self._dict[key] = value + + def __delitem__(self, key): + # TODO: Do we want to deprecate deleting spines? + del self._dict[key] + + def __iter__(self): + return iter(self._dict) + + def __len__(self): + return len(self._dict) diff --git a/venv/lib/python3.10/site-packages/matplotlib/spines.pyi b/venv/lib/python3.10/site-packages/matplotlib/spines.pyi new file mode 100644 index 00000000..0f06a6d1 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/spines.pyi @@ -0,0 +1,83 @@ +from collections.abc import Callable, Iterator, MutableMapping +from typing import Any, Literal, TypeVar, overload + +import matplotlib.patches as mpatches +from matplotlib.axes import Axes +from matplotlib.axis import Axis +from matplotlib.path import Path +from matplotlib.transforms import Transform +from matplotlib.typing import ColorType + +class Spine(mpatches.Patch): + axes: Axes + spine_type: str + axis: Axis | None + def __init__(self, axes: Axes, spine_type: str, path: Path, **kwargs) -> None: ... + def set_patch_arc( + self, center: tuple[float, float], radius: float, theta1: float, theta2: float + ) -> None: ... + def set_patch_circle(self, center: tuple[float, float], radius: float) -> None: ... + def set_patch_line(self) -> None: ... + def get_patch_transform(self) -> Transform: ... + def get_path(self) -> Path: ... + def register_axis(self, axis: Axis) -> None: ... + def clear(self) -> None: ... + def set_position( + self, + position: Literal["center", "zero"] + | tuple[Literal["outward", "axes", "data"], float], + ) -> None: ... + def get_position( + self, + ) -> Literal["center", "zero"] | tuple[ + Literal["outward", "axes", "data"], float + ]: ... + def get_spine_transform(self) -> Transform: ... + def set_bounds(self, low: float | None = ..., high: float | None = ...) -> None: ... + def get_bounds(self) -> tuple[float, float]: ... + + _T = TypeVar("_T", bound=Spine) + @classmethod + def linear_spine( + cls: type[_T], + axes: Axes, + spine_type: Literal["left", "right", "bottom", "top"], + **kwargs + ) -> _T: ... + @classmethod + def arc_spine( + cls: type[_T], + axes: Axes, + spine_type: Literal["left", "right", "bottom", "top"], + center: tuple[float, float], + radius: float, + theta1: float, + theta2: float, + **kwargs + ) -> _T: ... + @classmethod + def circular_spine( + cls: type[_T], axes: Axes, center: tuple[float, float], radius: float, **kwargs + ) -> _T: ... + def set_color(self, c: ColorType | None) -> None: ... + +class SpinesProxy: + def __init__(self, spine_dict: dict[str, Spine]) -> None: ... + def __getattr__(self, name: str) -> Callable[..., None]: ... + def __dir__(self) -> list[str]: ... + +class Spines(MutableMapping[str, Spine]): + def __init__(self, **kwargs: Spine) -> None: ... + @classmethod + def from_dict(cls, d: dict[str, Spine]) -> Spines: ... + def __getattr__(self, name: str) -> Spine: ... + @overload + def __getitem__(self, key: str) -> Spine: ... + @overload + def __getitem__(self, key: list[str]) -> SpinesProxy: ... + @overload + def __getitem__(self, key: slice) -> SpinesProxy: ... + def __setitem__(self, key: str, value: Spine) -> None: ... + def __delitem__(self, key: str) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/stackplot.py b/venv/lib/python3.10/site-packages/matplotlib/stackplot.py new file mode 100644 index 00000000..dd579bcd --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/stackplot.py @@ -0,0 +1,144 @@ +""" +Stacked area plot for 1D arrays inspired by Douglas Y'barbo's stackoverflow +answer: +https://stackoverflow.com/q/2225995/ + +(https://stackoverflow.com/users/66549/doug) +""" + +import itertools + +import numpy as np + +from matplotlib import _api + +__all__ = ['stackplot'] + + +def stackplot(axes, x, *args, + labels=(), colors=None, hatch=None, baseline='zero', + **kwargs): + """ + Draw a stacked area plot or a streamgraph. + + Parameters + ---------- + x : (N,) array-like + + y : (M, N) array-like + The data is assumed to be unstacked. Each of the following + calls is legal:: + + stackplot(x, y) # where y has shape (M, N) + stackplot(x, y1, y2, y3) # where y1, y2, y3, y4 have length N + + baseline : {'zero', 'sym', 'wiggle', 'weighted_wiggle'} + Method used to calculate the baseline: + + - ``'zero'``: Constant zero baseline, i.e. a simple stacked plot. + - ``'sym'``: Symmetric around zero and is sometimes called + 'ThemeRiver'. + - ``'wiggle'``: Minimizes the sum of the squared slopes. + - ``'weighted_wiggle'``: Does the same but weights to account for + size of each layer. It is also called 'Streamgraph'-layout. More + details can be found at http://leebyron.com/streamgraph/. + + labels : list of str, optional + A sequence of labels to assign to each data series. If unspecified, + then no labels will be applied to artists. + + colors : list of :mpltype:`color`, optional + A sequence of colors to be cycled through and used to color the stacked + areas. The sequence need not be exactly the same length as the number + of provided *y*, in which case the colors will repeat from the + beginning. + + If not specified, the colors from the Axes property cycle will be used. + + hatch : list of str, default: None + A sequence of hatching styles. See + :doc:`/gallery/shapes_and_collections/hatch_style_reference`. + The sequence will be cycled through for filling the + stacked areas from bottom to top. + It need not be exactly the same length as the number + of provided *y*, in which case the styles will repeat from the + beginning. + + data : indexable object, optional + DATA_PARAMETER_PLACEHOLDER + + **kwargs + All other keyword arguments are passed to `.Axes.fill_between`. + + Returns + ------- + list of `.PolyCollection` + A list of `.PolyCollection` instances, one for each element in the + stacked area plot. + """ + + y = np.vstack(args) + + labels = iter(labels) + if colors is not None: + colors = itertools.cycle(colors) + else: + colors = (axes._get_lines.get_next_color() for _ in y) + + if hatch is None or isinstance(hatch, str): + hatch = itertools.cycle([hatch]) + else: + hatch = itertools.cycle(hatch) + + # Assume data passed has not been 'stacked', so stack it here. + # We'll need a float buffer for the upcoming calculations. + stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32)) + + _api.check_in_list(['zero', 'sym', 'wiggle', 'weighted_wiggle'], + baseline=baseline) + if baseline == 'zero': + first_line = 0. + + elif baseline == 'sym': + first_line = -np.sum(y, 0) * 0.5 + stack += first_line[None, :] + + elif baseline == 'wiggle': + m = y.shape[0] + first_line = (y * (m - 0.5 - np.arange(m)[:, None])).sum(0) + first_line /= -m + stack += first_line + + elif baseline == 'weighted_wiggle': + total = np.sum(y, 0) + # multiply by 1/total (or zero) to avoid infinities in the division: + inv_total = np.zeros_like(total) + mask = total > 0 + inv_total[mask] = 1.0 / total[mask] + increase = np.hstack((y[:, 0:1], np.diff(y))) + below_size = total - stack + below_size += 0.5 * y + move_up = below_size * inv_total + move_up[:, 0] = 0.5 + center = (move_up - 0.5) * increase + center = np.cumsum(center.sum(0)) + first_line = center - 0.5 * total + stack += first_line + + # Color between x = 0 and the first array. + coll = axes.fill_between(x, first_line, stack[0, :], + facecolor=next(colors), + hatch=next(hatch), + label=next(labels, None), + **kwargs) + coll.sticky_edges.y[:] = [0] + r = [coll] + + # Color between array i-1 and array i + for i in range(len(y) - 1): + r.append(axes.fill_between(x, stack[i, :], stack[i + 1, :], + facecolor=next(colors), + hatch=next(hatch), + label=next(labels, None), + **kwargs)) + return r diff --git a/venv/lib/python3.10/site-packages/matplotlib/stackplot.pyi b/venv/lib/python3.10/site-packages/matplotlib/stackplot.pyi new file mode 100644 index 00000000..2981d449 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/stackplot.pyi @@ -0,0 +1,18 @@ +from matplotlib.axes import Axes +from matplotlib.collections import PolyCollection + +from collections.abc import Iterable +from typing import Literal +from numpy.typing import ArrayLike +from matplotlib.typing import ColorType + +def stackplot( + axes: Axes, + x: ArrayLike, + *args: ArrayLike, + labels: Iterable[str] = ..., + colors: Iterable[ColorType] | None = ..., + hatch: Iterable[str] | str | None = ..., + baseline: Literal["zero", "sym", "wiggle", "weighted_wiggle"] = ..., + **kwargs +) -> list[PolyCollection]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/streamplot.py b/venv/lib/python3.10/site-packages/matplotlib/streamplot.py new file mode 100644 index 00000000..84f99732 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/streamplot.py @@ -0,0 +1,712 @@ +""" +Streamline plotting for 2D vector fields. + +""" + +import numpy as np + +import matplotlib as mpl +from matplotlib import _api, cm, patches +import matplotlib.colors as mcolors +import matplotlib.collections as mcollections +import matplotlib.lines as mlines + + +__all__ = ['streamplot'] + + +def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, + cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', + minlength=0.1, transform=None, zorder=None, start_points=None, + maxlength=4.0, integration_direction='both', + broken_streamlines=True): + """ + Draw streamlines of a vector flow. + + Parameters + ---------- + x, y : 1D/2D arrays + Evenly spaced strictly increasing arrays to make a grid. If 2D, all + rows of *x* must be equal and all columns of *y* must be equal; i.e., + they must be as if generated by ``np.meshgrid(x_1d, y_1d)``. + u, v : 2D arrays + *x* and *y*-velocities. The number of rows and columns must match + the length of *y* and *x*, respectively. + density : float or (float, float) + Controls the closeness of streamlines. When ``density = 1``, the domain + is divided into a 30x30 grid. *density* linearly scales this grid. + Each cell in the grid can have, at most, one traversing streamline. + For different densities in each direction, use a tuple + (density_x, density_y). + linewidth : float or 2D array + The width of the streamlines. With a 2D array the line width can be + varied across the grid. The array must have the same shape as *u* + and *v*. + color : :mpltype:`color` or 2D array + The streamline color. If given an array, its values are converted to + colors using *cmap* and *norm*. The array must have the same shape + as *u* and *v*. + cmap, norm + Data normalization and colormapping parameters for *color*; only used + if *color* is an array of floats. See `~.Axes.imshow` for a detailed + description. + arrowsize : float + Scaling factor for the arrow size. + arrowstyle : str + Arrow style specification. + See `~matplotlib.patches.FancyArrowPatch`. + minlength : float + Minimum length of streamline in axes coordinates. + start_points : (N, 2) array + Coordinates of starting points for the streamlines in data coordinates + (the same coordinates as the *x* and *y* arrays). + zorder : float + The zorder of the streamlines and arrows. + Artists with lower zorder values are drawn first. + maxlength : float + Maximum length of streamline in axes coordinates. + integration_direction : {'forward', 'backward', 'both'}, default: 'both' + Integrate the streamline in forward, backward or both directions. + data : indexable object, optional + DATA_PARAMETER_PLACEHOLDER + broken_streamlines : boolean, default: True + If False, forces streamlines to continue until they + leave the plot domain. If True, they may be terminated if they + come too close to another streamline. + + Returns + ------- + StreamplotSet + Container object with attributes + + - ``lines``: `.LineCollection` of streamlines + + - ``arrows``: `.PatchCollection` containing `.FancyArrowPatch` + objects representing the arrows half-way along streamlines. + + This container will probably change in the future to allow changes + to the colormap, alpha, etc. for both lines and arrows, but these + changes should be backward compatible. + """ + grid = Grid(x, y) + mask = StreamMask(density) + dmap = DomainMap(grid, mask) + + if zorder is None: + zorder = mlines.Line2D.zorder + + # default to data coordinates + if transform is None: + transform = axes.transData + + if color is None: + color = axes._get_lines.get_next_color() + + if linewidth is None: + linewidth = mpl.rcParams['lines.linewidth'] + + line_kw = {} + arrow_kw = dict(arrowstyle=arrowstyle, mutation_scale=10 * arrowsize) + + _api.check_in_list(['both', 'forward', 'backward'], + integration_direction=integration_direction) + + if integration_direction == 'both': + maxlength /= 2. + + use_multicolor_lines = isinstance(color, np.ndarray) + if use_multicolor_lines: + if color.shape != grid.shape: + raise ValueError("If 'color' is given, it must match the shape of " + "the (x, y) grid") + line_colors = [[]] # Empty entry allows concatenation of zero arrays. + color = np.ma.masked_invalid(color) + else: + line_kw['color'] = color + arrow_kw['color'] = color + + if isinstance(linewidth, np.ndarray): + if linewidth.shape != grid.shape: + raise ValueError("If 'linewidth' is given, it must match the " + "shape of the (x, y) grid") + line_kw['linewidth'] = [] + else: + line_kw['linewidth'] = linewidth + arrow_kw['linewidth'] = linewidth + + line_kw['zorder'] = zorder + arrow_kw['zorder'] = zorder + + # Sanity checks. + if u.shape != grid.shape or v.shape != grid.shape: + raise ValueError("'u' and 'v' must match the shape of the (x, y) grid") + + u = np.ma.masked_invalid(u) + v = np.ma.masked_invalid(v) + + integrate = _get_integrator(u, v, dmap, minlength, maxlength, + integration_direction) + + trajectories = [] + if start_points is None: + for xm, ym in _gen_starting_points(mask.shape): + if mask[ym, xm] == 0: + xg, yg = dmap.mask2grid(xm, ym) + t = integrate(xg, yg, broken_streamlines) + if t is not None: + trajectories.append(t) + else: + sp2 = np.asanyarray(start_points, dtype=float).copy() + + # Check if start_points are outside the data boundaries + for xs, ys in sp2: + if not (grid.x_origin <= xs <= grid.x_origin + grid.width and + grid.y_origin <= ys <= grid.y_origin + grid.height): + raise ValueError(f"Starting point ({xs}, {ys}) outside of " + "data boundaries") + + # Convert start_points from data to array coords + # Shift the seed points from the bottom left of the data so that + # data2grid works properly. + sp2[:, 0] -= grid.x_origin + sp2[:, 1] -= grid.y_origin + + for xs, ys in sp2: + xg, yg = dmap.data2grid(xs, ys) + # Floating point issues can cause xg, yg to be slightly out of + # bounds for xs, ys on the upper boundaries. Because we have + # already checked that the starting points are within the original + # grid, clip the xg, yg to the grid to work around this issue + xg = np.clip(xg, 0, grid.nx - 1) + yg = np.clip(yg, 0, grid.ny - 1) + + t = integrate(xg, yg, broken_streamlines) + if t is not None: + trajectories.append(t) + + if use_multicolor_lines: + if norm is None: + norm = mcolors.Normalize(color.min(), color.max()) + cmap = cm._ensure_cmap(cmap) + + streamlines = [] + arrows = [] + for t in trajectories: + tgx, tgy = t.T + # Rescale from grid-coordinates to data-coordinates. + tx, ty = dmap.grid2data(tgx, tgy) + tx += grid.x_origin + ty += grid.y_origin + + # Create multiple tiny segments if varying width or color is given + if isinstance(linewidth, np.ndarray) or use_multicolor_lines: + points = np.transpose([tx, ty]).reshape(-1, 1, 2) + streamlines.extend(np.hstack([points[:-1], points[1:]])) + else: + points = np.transpose([tx, ty]) + streamlines.append(points) + + # Add arrows halfway along each trajectory. + s = np.cumsum(np.hypot(np.diff(tx), np.diff(ty))) + n = np.searchsorted(s, s[-1] / 2.) + arrow_tail = (tx[n], ty[n]) + arrow_head = (np.mean(tx[n:n + 2]), np.mean(ty[n:n + 2])) + + if isinstance(linewidth, np.ndarray): + line_widths = interpgrid(linewidth, tgx, tgy)[:-1] + line_kw['linewidth'].extend(line_widths) + arrow_kw['linewidth'] = line_widths[n] + + if use_multicolor_lines: + color_values = interpgrid(color, tgx, tgy)[:-1] + line_colors.append(color_values) + arrow_kw['color'] = cmap(norm(color_values[n])) + + p = patches.FancyArrowPatch( + arrow_tail, arrow_head, transform=transform, **arrow_kw) + arrows.append(p) + + lc = mcollections.LineCollection( + streamlines, transform=transform, **line_kw) + lc.sticky_edges.x[:] = [grid.x_origin, grid.x_origin + grid.width] + lc.sticky_edges.y[:] = [grid.y_origin, grid.y_origin + grid.height] + if use_multicolor_lines: + lc.set_array(np.ma.hstack(line_colors)) + lc.set_cmap(cmap) + lc.set_norm(norm) + axes.add_collection(lc) + + ac = mcollections.PatchCollection(arrows) + # Adding the collection itself is broken; see #2341. + for p in arrows: + axes.add_patch(p) + + axes.autoscale_view() + stream_container = StreamplotSet(lc, ac) + return stream_container + + +class StreamplotSet: + + def __init__(self, lines, arrows): + self.lines = lines + self.arrows = arrows + + +# Coordinate definitions +# ======================== + +class DomainMap: + """ + Map representing different coordinate systems. + + Coordinate definitions: + + * axes-coordinates goes from 0 to 1 in the domain. + * data-coordinates are specified by the input x-y coordinates. + * grid-coordinates goes from 0 to N and 0 to M for an N x M grid, + where N and M match the shape of the input data. + * mask-coordinates goes from 0 to N and 0 to M for an N x M mask, + where N and M are user-specified to control the density of streamlines. + + This class also has methods for adding trajectories to the StreamMask. + Before adding a trajectory, run `start_trajectory` to keep track of regions + crossed by a given trajectory. Later, if you decide the trajectory is bad + (e.g., if the trajectory is very short) just call `undo_trajectory`. + """ + + def __init__(self, grid, mask): + self.grid = grid + self.mask = mask + # Constants for conversion between grid- and mask-coordinates + self.x_grid2mask = (mask.nx - 1) / (grid.nx - 1) + self.y_grid2mask = (mask.ny - 1) / (grid.ny - 1) + + self.x_mask2grid = 1. / self.x_grid2mask + self.y_mask2grid = 1. / self.y_grid2mask + + self.x_data2grid = 1. / grid.dx + self.y_data2grid = 1. / grid.dy + + def grid2mask(self, xi, yi): + """Return nearest space in mask-coords from given grid-coords.""" + return round(xi * self.x_grid2mask), round(yi * self.y_grid2mask) + + def mask2grid(self, xm, ym): + return xm * self.x_mask2grid, ym * self.y_mask2grid + + def data2grid(self, xd, yd): + return xd * self.x_data2grid, yd * self.y_data2grid + + def grid2data(self, xg, yg): + return xg / self.x_data2grid, yg / self.y_data2grid + + def start_trajectory(self, xg, yg, broken_streamlines=True): + xm, ym = self.grid2mask(xg, yg) + self.mask._start_trajectory(xm, ym, broken_streamlines) + + def reset_start_point(self, xg, yg): + xm, ym = self.grid2mask(xg, yg) + self.mask._current_xy = (xm, ym) + + def update_trajectory(self, xg, yg, broken_streamlines=True): + if not self.grid.within_grid(xg, yg): + raise InvalidIndexError + xm, ym = self.grid2mask(xg, yg) + self.mask._update_trajectory(xm, ym, broken_streamlines) + + def undo_trajectory(self): + self.mask._undo_trajectory() + + +class Grid: + """Grid of data.""" + def __init__(self, x, y): + + if np.ndim(x) == 1: + pass + elif np.ndim(x) == 2: + x_row = x[0] + if not np.allclose(x_row, x): + raise ValueError("The rows of 'x' must be equal") + x = x_row + else: + raise ValueError("'x' can have at maximum 2 dimensions") + + if np.ndim(y) == 1: + pass + elif np.ndim(y) == 2: + yt = np.transpose(y) # Also works for nested lists. + y_col = yt[0] + if not np.allclose(y_col, yt): + raise ValueError("The columns of 'y' must be equal") + y = y_col + else: + raise ValueError("'y' can have at maximum 2 dimensions") + + if not (np.diff(x) > 0).all(): + raise ValueError("'x' must be strictly increasing") + if not (np.diff(y) > 0).all(): + raise ValueError("'y' must be strictly increasing") + + self.nx = len(x) + self.ny = len(y) + + self.dx = x[1] - x[0] + self.dy = y[1] - y[0] + + self.x_origin = x[0] + self.y_origin = y[0] + + self.width = x[-1] - x[0] + self.height = y[-1] - y[0] + + if not np.allclose(np.diff(x), self.width / (self.nx - 1)): + raise ValueError("'x' values must be equally spaced") + if not np.allclose(np.diff(y), self.height / (self.ny - 1)): + raise ValueError("'y' values must be equally spaced") + + @property + def shape(self): + return self.ny, self.nx + + def within_grid(self, xi, yi): + """Return whether (*xi*, *yi*) is a valid index of the grid.""" + # Note that xi/yi can be floats; so, for example, we can't simply check + # `xi < self.nx` since *xi* can be `self.nx - 1 < xi < self.nx` + return 0 <= xi <= self.nx - 1 and 0 <= yi <= self.ny - 1 + + +class StreamMask: + """ + Mask to keep track of discrete regions crossed by streamlines. + + The resolution of this grid determines the approximate spacing between + trajectories. Streamlines are only allowed to pass through zeroed cells: + When a streamline enters a cell, that cell is set to 1, and no new + streamlines are allowed to enter. + """ + + def __init__(self, density): + try: + self.nx, self.ny = (30 * np.broadcast_to(density, 2)).astype(int) + except ValueError as err: + raise ValueError("'density' must be a scalar or be of length " + "2") from err + if self.nx < 0 or self.ny < 0: + raise ValueError("'density' must be positive") + self._mask = np.zeros((self.ny, self.nx)) + self.shape = self._mask.shape + + self._current_xy = None + + def __getitem__(self, args): + return self._mask[args] + + def _start_trajectory(self, xm, ym, broken_streamlines=True): + """Start recording streamline trajectory""" + self._traj = [] + self._update_trajectory(xm, ym, broken_streamlines) + + def _undo_trajectory(self): + """Remove current trajectory from mask""" + for t in self._traj: + self._mask[t] = 0 + + def _update_trajectory(self, xm, ym, broken_streamlines=True): + """ + Update current trajectory position in mask. + + If the new position has already been filled, raise `InvalidIndexError`. + """ + if self._current_xy != (xm, ym): + if self[ym, xm] == 0: + self._traj.append((ym, xm)) + self._mask[ym, xm] = 1 + self._current_xy = (xm, ym) + else: + if broken_streamlines: + raise InvalidIndexError + else: + pass + + +class InvalidIndexError(Exception): + pass + + +class TerminateTrajectory(Exception): + pass + + +# Integrator definitions +# ======================= + +def _get_integrator(u, v, dmap, minlength, maxlength, integration_direction): + + # rescale velocity onto grid-coordinates for integrations. + u, v = dmap.data2grid(u, v) + + # speed (path length) will be in axes-coordinates + u_ax = u / (dmap.grid.nx - 1) + v_ax = v / (dmap.grid.ny - 1) + speed = np.ma.sqrt(u_ax ** 2 + v_ax ** 2) + + def forward_time(xi, yi): + if not dmap.grid.within_grid(xi, yi): + raise OutOfBounds + ds_dt = interpgrid(speed, xi, yi) + if ds_dt == 0: + raise TerminateTrajectory() + dt_ds = 1. / ds_dt + ui = interpgrid(u, xi, yi) + vi = interpgrid(v, xi, yi) + return ui * dt_ds, vi * dt_ds + + def backward_time(xi, yi): + dxi, dyi = forward_time(xi, yi) + return -dxi, -dyi + + def integrate(x0, y0, broken_streamlines=True): + """ + Return x, y grid-coordinates of trajectory based on starting point. + + Integrate both forward and backward in time from starting point in + grid coordinates. + + Integration is terminated when a trajectory reaches a domain boundary + or when it crosses into an already occupied cell in the StreamMask. The + resulting trajectory is None if it is shorter than `minlength`. + """ + + stotal, xy_traj = 0., [] + + try: + dmap.start_trajectory(x0, y0, broken_streamlines) + except InvalidIndexError: + return None + if integration_direction in ['both', 'backward']: + s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength, + broken_streamlines) + stotal += s + xy_traj += xyt[::-1] + + if integration_direction in ['both', 'forward']: + dmap.reset_start_point(x0, y0) + s, xyt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength, + broken_streamlines) + stotal += s + xy_traj += xyt[1:] + + if stotal > minlength: + return np.broadcast_arrays(xy_traj, np.empty((1, 2)))[0] + else: # reject short trajectories + dmap.undo_trajectory() + return None + + return integrate + + +class OutOfBounds(IndexError): + pass + + +def _integrate_rk12(x0, y0, dmap, f, maxlength, broken_streamlines=True): + """ + 2nd-order Runge-Kutta algorithm with adaptive step size. + + This method is also referred to as the improved Euler's method, or Heun's + method. This method is favored over higher-order methods because: + + 1. To get decent looking trajectories and to sample every mask cell + on the trajectory we need a small timestep, so a lower order + solver doesn't hurt us unless the data is *very* high resolution. + In fact, for cases where the user inputs + data smaller or of similar grid size to the mask grid, the higher + order corrections are negligible because of the very fast linear + interpolation used in `interpgrid`. + + 2. For high resolution input data (i.e. beyond the mask + resolution), we must reduce the timestep. Therefore, an adaptive + timestep is more suited to the problem as this would be very hard + to judge automatically otherwise. + + This integrator is about 1.5 - 2x as fast as RK4 and RK45 solvers (using + similar Python implementations) in most setups. + """ + # This error is below that needed to match the RK4 integrator. It + # is set for visual reasons -- too low and corners start + # appearing ugly and jagged. Can be tuned. + maxerror = 0.003 + + # This limit is important (for all integrators) to avoid the + # trajectory skipping some mask cells. We could relax this + # condition if we use the code which is commented out below to + # increment the location gradually. However, due to the efficient + # nature of the interpolation, this doesn't boost speed by much + # for quite a bit of complexity. + maxds = min(1. / dmap.mask.nx, 1. / dmap.mask.ny, 0.1) + + ds = maxds + stotal = 0 + xi = x0 + yi = y0 + xyf_traj = [] + + while True: + try: + if dmap.grid.within_grid(xi, yi): + xyf_traj.append((xi, yi)) + else: + raise OutOfBounds + + # Compute the two intermediate gradients. + # f should raise OutOfBounds if the locations given are + # outside the grid. + k1x, k1y = f(xi, yi) + k2x, k2y = f(xi + ds * k1x, yi + ds * k1y) + + except OutOfBounds: + # Out of the domain during this step. + # Take an Euler step to the boundary to improve neatness + # unless the trajectory is currently empty. + if xyf_traj: + ds, xyf_traj = _euler_step(xyf_traj, dmap, f) + stotal += ds + break + except TerminateTrajectory: + break + + dx1 = ds * k1x + dy1 = ds * k1y + dx2 = ds * 0.5 * (k1x + k2x) + dy2 = ds * 0.5 * (k1y + k2y) + + ny, nx = dmap.grid.shape + # Error is normalized to the axes coordinates + error = np.hypot((dx2 - dx1) / (nx - 1), (dy2 - dy1) / (ny - 1)) + + # Only save step if within error tolerance + if error < maxerror: + xi += dx2 + yi += dy2 + try: + dmap.update_trajectory(xi, yi, broken_streamlines) + except InvalidIndexError: + break + if stotal + ds > maxlength: + break + stotal += ds + + # recalculate stepsize based on step error + if error == 0: + ds = maxds + else: + ds = min(maxds, 0.85 * ds * (maxerror / error) ** 0.5) + + return stotal, xyf_traj + + +def _euler_step(xyf_traj, dmap, f): + """Simple Euler integration step that extends streamline to boundary.""" + ny, nx = dmap.grid.shape + xi, yi = xyf_traj[-1] + cx, cy = f(xi, yi) + if cx == 0: + dsx = np.inf + elif cx < 0: + dsx = xi / -cx + else: + dsx = (nx - 1 - xi) / cx + if cy == 0: + dsy = np.inf + elif cy < 0: + dsy = yi / -cy + else: + dsy = (ny - 1 - yi) / cy + ds = min(dsx, dsy) + xyf_traj.append((xi + cx * ds, yi + cy * ds)) + return ds, xyf_traj + + +# Utility functions +# ======================== + +def interpgrid(a, xi, yi): + """Fast 2D, linear interpolation on an integer grid""" + + Ny, Nx = np.shape(a) + if isinstance(xi, np.ndarray): + x = xi.astype(int) + y = yi.astype(int) + # Check that xn, yn don't exceed max index + xn = np.clip(x + 1, 0, Nx - 1) + yn = np.clip(y + 1, 0, Ny - 1) + else: + x = int(xi) + y = int(yi) + # conditional is faster than clipping for integers + if x == (Nx - 1): + xn = x + else: + xn = x + 1 + if y == (Ny - 1): + yn = y + else: + yn = y + 1 + + a00 = a[y, x] + a01 = a[y, xn] + a10 = a[yn, x] + a11 = a[yn, xn] + xt = xi - x + yt = yi - y + a0 = a00 * (1 - xt) + a01 * xt + a1 = a10 * (1 - xt) + a11 * xt + ai = a0 * (1 - yt) + a1 * yt + + if not isinstance(xi, np.ndarray): + if np.ma.is_masked(ai): + raise TerminateTrajectory + + return ai + + +def _gen_starting_points(shape): + """ + Yield starting points for streamlines. + + Trying points on the boundary first gives higher quality streamlines. + This algorithm starts with a point on the mask corner and spirals inward. + This algorithm is inefficient, but fast compared to rest of streamplot. + """ + ny, nx = shape + xfirst = 0 + yfirst = 1 + xlast = nx - 1 + ylast = ny - 1 + x, y = 0, 0 + direction = 'right' + for i in range(nx * ny): + yield x, y + + if direction == 'right': + x += 1 + if x >= xlast: + xlast -= 1 + direction = 'up' + elif direction == 'up': + y += 1 + if y >= ylast: + ylast -= 1 + direction = 'left' + elif direction == 'left': + x -= 1 + if x <= xfirst: + xfirst += 1 + direction = 'down' + elif direction == 'down': + y -= 1 + if y <= yfirst: + yfirst += 1 + direction = 'right' diff --git a/venv/lib/python3.10/site-packages/matplotlib/streamplot.pyi b/venv/lib/python3.10/site-packages/matplotlib/streamplot.pyi new file mode 100644 index 00000000..9da83096 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/streamplot.pyi @@ -0,0 +1,82 @@ +from matplotlib.axes import Axes +from matplotlib.colors import Normalize, Colormap +from matplotlib.collections import LineCollection, PatchCollection +from matplotlib.patches import ArrowStyle +from matplotlib.transforms import Transform + +from typing import Literal +from numpy.typing import ArrayLike +from .typing import ColorType + +def streamplot( + axes: Axes, + x: ArrayLike, + y: ArrayLike, + u: ArrayLike, + v: ArrayLike, + density: float | tuple[float, float] = ..., + linewidth: float | ArrayLike | None = ..., + color: ColorType | ArrayLike | None = ..., + cmap: str | Colormap | None = ..., + norm: str | Normalize | None = ..., + arrowsize: float = ..., + arrowstyle: str | ArrowStyle = ..., + minlength: float = ..., + transform: Transform | None = ..., + zorder: float | None = ..., + start_points: ArrayLike | None = ..., + maxlength: float = ..., + integration_direction: Literal["forward", "backward", "both"] = ..., + broken_streamlines: bool = ..., +) -> StreamplotSet: ... + +class StreamplotSet: + lines: LineCollection + arrows: PatchCollection + def __init__(self, lines: LineCollection, arrows: PatchCollection) -> None: ... + +class DomainMap: + grid: Grid + mask: StreamMask + x_grid2mask: float + y_grid2mask: float + x_mask2grid: float + y_mask2grid: float + x_data2grid: float + y_data2grid: float + def __init__(self, grid: Grid, mask: StreamMask) -> None: ... + def grid2mask(self, xi: float, yi: float) -> tuple[int, int]: ... + def mask2grid(self, xm: float, ym: float) -> tuple[float, float]: ... + def data2grid(self, xd: float, yd: float) -> tuple[float, float]: ... + def grid2data(self, xg: float, yg: float) -> tuple[float, float]: ... + def start_trajectory( + self, xg: float, yg: float, broken_streamlines: bool = ... + ) -> None: ... + def reset_start_point(self, xg: float, yg: float) -> None: ... + def update_trajectory(self, xg, yg, broken_streamlines: bool = ...) -> None: ... + def undo_trajectory(self) -> None: ... + +class Grid: + nx: int + ny: int + dx: float + dy: float + x_origin: float + y_origin: float + width: float + height: float + def __init__(self, x: ArrayLike, y: ArrayLike) -> None: ... + @property + def shape(self) -> tuple[int, int]: ... + def within_grid(self, xi: float, yi: float) -> bool: ... + +class StreamMask: + nx: int + ny: int + shape: tuple[int, int] + def __init__(self, density: float | tuple[float, float]) -> None: ... + def __getitem__(self, args): ... + +class InvalidIndexError(Exception): ... +class TerminateTrajectory(Exception): ... +class OutOfBounds(IndexError): ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/style/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/style/__init__.py new file mode 100644 index 00000000..488c6d6a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/style/__init__.py @@ -0,0 +1,4 @@ +from .core import available, context, library, reload_library, use + + +__all__ = ["available", "context", "library", "reload_library", "use"] diff --git a/venv/lib/python3.10/site-packages/matplotlib/style/core.py b/venv/lib/python3.10/site-packages/matplotlib/style/core.py new file mode 100644 index 00000000..7e9008c5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/style/core.py @@ -0,0 +1,245 @@ +""" +Core functions and attributes for the matplotlib style library: + +``use`` + Select style sheet to override the current matplotlib settings. +``context`` + Context manager to use a style sheet temporarily. +``available`` + List available style sheets. +``library`` + A dictionary of style names and matplotlib settings. +""" + +import contextlib +import logging +import os +from pathlib import Path +import sys +import warnings + +if sys.version_info >= (3, 10): + import importlib.resources as importlib_resources +else: + # Even though Py3.9 has importlib.resources, it doesn't properly handle + # modules added in sys.path. + import importlib_resources + +import matplotlib as mpl +from matplotlib import _api, _docstring, _rc_params_in_file, rcParamsDefault + +_log = logging.getLogger(__name__) + +__all__ = ['use', 'context', 'available', 'library', 'reload_library'] + + +BASE_LIBRARY_PATH = os.path.join(mpl.get_data_path(), 'stylelib') +# Users may want multiple library paths, so store a list of paths. +USER_LIBRARY_PATHS = [os.path.join(mpl.get_configdir(), 'stylelib')] +STYLE_EXTENSION = 'mplstyle' +# A list of rcParams that should not be applied from styles +STYLE_BLACKLIST = { + 'interactive', 'backend', 'webagg.port', 'webagg.address', + 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', + 'toolbar', 'timezone', 'figure.max_open_warning', + 'figure.raise_window', 'savefig.directory', 'tk.window_focus', + 'docstring.hardcopy', 'date.epoch'} + + +@_docstring.Substitution( + "\n".join(map("- {}".format, sorted(STYLE_BLACKLIST, key=str.lower))) +) +def use(style): + """ + Use Matplotlib style settings from a style specification. + + The style name of 'default' is reserved for reverting back to + the default style settings. + + .. note:: + + This updates the `.rcParams` with the settings from the style. + `.rcParams` not defined in the style are kept. + + Parameters + ---------- + style : str, dict, Path or list + + A style specification. Valid options are: + + str + - One of the style names in `.style.available` (a builtin style or + a style installed in the user library path). + + - A dotted name of the form "package.style_name"; in that case, + "package" should be an importable Python package name, e.g. at + ``/path/to/package/__init__.py``; the loaded style file is + ``/path/to/package/style_name.mplstyle``. (Style files in + subpackages are likewise supported.) + + - The path or URL to a style file, which gets loaded by + `.rc_params_from_file`. + + dict + A mapping of key/value pairs for `matplotlib.rcParams`. + + Path + The path to a style file, which gets loaded by + `.rc_params_from_file`. + + list + A list of style specifiers (str, Path or dict), which are applied + from first to last in the list. + + Notes + ----- + The following `.rcParams` are not related to style and will be ignored if + found in a style specification: + + %s + """ + if isinstance(style, (str, Path)) or hasattr(style, 'keys'): + # If name is a single str, Path or dict, make it a single element list. + styles = [style] + else: + styles = style + + style_alias = {'mpl20': 'default', 'mpl15': 'classic'} + + for style in styles: + if isinstance(style, str): + style = style_alias.get(style, style) + if style == "default": + # Deprecation warnings were already handled when creating + # rcParamsDefault, no need to reemit them here. + with _api.suppress_matplotlib_deprecation_warning(): + # don't trigger RcParams.__getitem__('backend') + style = {k: rcParamsDefault[k] for k in rcParamsDefault + if k not in STYLE_BLACKLIST} + elif style in library: + style = library[style] + elif "." in style: + pkg, _, name = style.rpartition(".") + try: + path = (importlib_resources.files(pkg) + / f"{name}.{STYLE_EXTENSION}") + style = _rc_params_in_file(path) + except (ModuleNotFoundError, OSError, TypeError) as exc: + # There is an ambiguity whether a dotted name refers to a + # package.style_name or to a dotted file path. Currently, + # we silently try the first form and then the second one; + # in the future, we may consider forcing file paths to + # either use Path objects or be prepended with "./" and use + # the slash as marker for file paths. + pass + if isinstance(style, (str, Path)): + try: + style = _rc_params_in_file(style) + except OSError as err: + raise OSError( + f"{style!r} is not a valid package style, path of style " + f"file, URL of style file, or library style name (library " + f"styles are listed in `style.available`)") from err + filtered = {} + for k in style: # don't trigger RcParams.__getitem__('backend') + if k in STYLE_BLACKLIST: + _api.warn_external( + f"Style includes a parameter, {k!r}, that is not " + f"related to style. Ignoring this parameter.") + else: + filtered[k] = style[k] + mpl.rcParams.update(filtered) + + +@contextlib.contextmanager +def context(style, after_reset=False): + """ + Context manager for using style settings temporarily. + + Parameters + ---------- + style : str, dict, Path or list + A style specification. Valid options are: + + str + - One of the style names in `.style.available` (a builtin style or + a style installed in the user library path). + + - A dotted name of the form "package.style_name"; in that case, + "package" should be an importable Python package name, e.g. at + ``/path/to/package/__init__.py``; the loaded style file is + ``/path/to/package/style_name.mplstyle``. (Style files in + subpackages are likewise supported.) + + - The path or URL to a style file, which gets loaded by + `.rc_params_from_file`. + dict + A mapping of key/value pairs for `matplotlib.rcParams`. + + Path + The path to a style file, which gets loaded by + `.rc_params_from_file`. + + list + A list of style specifiers (str, Path or dict), which are applied + from first to last in the list. + + after_reset : bool + If True, apply style after resetting settings to their defaults; + otherwise, apply style on top of the current settings. + """ + with mpl.rc_context(): + if after_reset: + mpl.rcdefaults() + use(style) + yield + + +def update_user_library(library): + """Update style library with user-defined rc files.""" + for stylelib_path in map(os.path.expanduser, USER_LIBRARY_PATHS): + styles = read_style_directory(stylelib_path) + update_nested_dict(library, styles) + return library + + +def read_style_directory(style_dir): + """Return dictionary of styles defined in *style_dir*.""" + styles = dict() + for path in Path(style_dir).glob(f"*.{STYLE_EXTENSION}"): + with warnings.catch_warnings(record=True) as warns: + styles[path.stem] = _rc_params_in_file(path) + for w in warns: + _log.warning('In %s: %s', path, w.message) + return styles + + +def update_nested_dict(main_dict, new_dict): + """ + Update nested dict (only level of nesting) with new values. + + Unlike `dict.update`, this assumes that the values of the parent dict are + dicts (or dict-like), so you shouldn't replace the nested dict if it + already exists. Instead you should update the sub-dict. + """ + # update named styles specified by user + for name, rc_dict in new_dict.items(): + main_dict.setdefault(name, {}).update(rc_dict) + return main_dict + + +# Load style library +# ================== +_base_library = read_style_directory(BASE_LIBRARY_PATH) +library = {} +available = [] + + +def reload_library(): + """Reload the style library.""" + library.clear() + library.update(update_user_library(_base_library)) + available[:] = sorted(library.keys()) + + +reload_library() diff --git a/venv/lib/python3.10/site-packages/matplotlib/style/core.pyi b/venv/lib/python3.10/site-packages/matplotlib/style/core.pyi new file mode 100644 index 00000000..73400492 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/style/core.pyi @@ -0,0 +1,19 @@ +from collections.abc import Generator +import contextlib + +from matplotlib import RcParams +from matplotlib.typing import RcStyleType + +USER_LIBRARY_PATHS: list[str] = ... +STYLE_EXTENSION: str = ... + +def use(style: RcStyleType) -> None: ... +@contextlib.contextmanager +def context( + style: RcStyleType, after_reset: bool = ... +) -> Generator[None, None, None]: ... + +library: dict[str, RcParams] +available: list[str] + +def reload_library() -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/table.py b/venv/lib/python3.10/site-packages/matplotlib/table.py new file mode 100644 index 00000000..7d8c8ec4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/table.py @@ -0,0 +1,830 @@ +# Original code by: +# John Gill +# Copyright 2004 John Gill and John Hunter +# +# Subsequent changes: +# The Matplotlib development team +# Copyright The Matplotlib development team + +""" +Tables drawing. + +.. note:: + The table implementation in Matplotlib is lightly maintained. For a more + featureful table implementation, you may wish to try `blume + `_. + +Use the factory function `~matplotlib.table.table` to create a ready-made +table from texts. If you need more control, use the `.Table` class and its +methods. + +The table consists of a grid of cells, which are indexed by (row, column). +The cell (0, 0) is positioned at the top left. + +Thanks to John Gill for providing the class and table. +""" + +import numpy as np + +from . import _api, _docstring +from .artist import Artist, allow_rasterization +from .patches import Rectangle +from .text import Text +from .transforms import Bbox +from .path import Path + + +class Cell(Rectangle): + """ + A cell is a `.Rectangle` with some associated `.Text`. + + As a user, you'll most likely not creates cells yourself. Instead, you + should use either the `~matplotlib.table.table` factory function or + `.Table.add_cell`. + """ + + PAD = 0.1 + """Padding between text and rectangle.""" + + _edges = 'BRTL' + _edge_aliases = {'open': '', + 'closed': _edges, # default + 'horizontal': 'BT', + 'vertical': 'RL' + } + + def __init__(self, xy, width, height, *, + edgecolor='k', facecolor='w', + fill=True, + text='', + loc='right', + fontproperties=None, + visible_edges='closed', + ): + """ + Parameters + ---------- + xy : 2-tuple + The position of the bottom left corner of the cell. + width : float + The cell width. + height : float + The cell height. + edgecolor : :mpltype:`color`, default: 'k' + The color of the cell border. + facecolor : :mpltype:`color`, default: 'w' + The cell facecolor. + fill : bool, default: True + Whether the cell background is filled. + text : str, optional + The cell text. + loc : {'right', 'center', 'left'} + The alignment of the text within the cell. + fontproperties : dict, optional + A dict defining the font properties of the text. Supported keys and + values are the keyword arguments accepted by `.FontProperties`. + visible_edges : {'closed', 'open', 'horizontal', 'vertical'} or \ +substring of 'BRTL' + The cell edges to be drawn with a line: a substring of 'BRTL' + (bottom, right, top, left), or one of 'open' (no edges drawn), + 'closed' (all edges drawn), 'horizontal' (bottom and top), + 'vertical' (right and left). + """ + + # Call base + super().__init__(xy, width=width, height=height, fill=fill, + edgecolor=edgecolor, facecolor=facecolor) + self.set_clip_on(False) + self.visible_edges = visible_edges + + # Create text object + self._loc = loc + self._text = Text(x=xy[0], y=xy[1], clip_on=False, + text=text, fontproperties=fontproperties, + horizontalalignment=loc, verticalalignment='center') + + @_api.rename_parameter("3.8", "trans", "t") + def set_transform(self, t): + super().set_transform(t) + # the text does not get the transform! + self.stale = True + + def set_figure(self, fig): + super().set_figure(fig) + self._text.set_figure(fig) + + def get_text(self): + """Return the cell `.Text` instance.""" + return self._text + + def set_fontsize(self, size): + """Set the text fontsize.""" + self._text.set_fontsize(size) + self.stale = True + + def get_fontsize(self): + """Return the cell fontsize.""" + return self._text.get_fontsize() + + def auto_set_font_size(self, renderer): + """Shrink font size until the text fits into the cell width.""" + fontsize = self.get_fontsize() + required = self.get_required_width(renderer) + while fontsize > 1 and required > self.get_width(): + fontsize -= 1 + self.set_fontsize(fontsize) + required = self.get_required_width(renderer) + + return fontsize + + @allow_rasterization + def draw(self, renderer): + if not self.get_visible(): + return + # draw the rectangle + super().draw(renderer) + # position the text + self._set_text_position(renderer) + self._text.draw(renderer) + self.stale = False + + def _set_text_position(self, renderer): + """Set text up so it is drawn in the right place.""" + bbox = self.get_window_extent(renderer) + # center vertically + y = bbox.y0 + bbox.height / 2 + # position horizontally + loc = self._text.get_horizontalalignment() + if loc == 'center': + x = bbox.x0 + bbox.width / 2 + elif loc == 'left': + x = bbox.x0 + bbox.width * self.PAD + else: # right. + x = bbox.x0 + bbox.width * (1 - self.PAD) + self._text.set_position((x, y)) + + def get_text_bounds(self, renderer): + """ + Return the text bounds as *(x, y, width, height)* in table coordinates. + """ + return (self._text.get_window_extent(renderer) + .transformed(self.get_data_transform().inverted()) + .bounds) + + def get_required_width(self, renderer): + """Return the minimal required width for the cell.""" + l, b, w, h = self.get_text_bounds(renderer) + return w * (1.0 + (2.0 * self.PAD)) + + @_docstring.dedent_interpd + def set_text_props(self, **kwargs): + """ + Update the text properties. + + Valid keyword arguments are: + + %(Text:kwdoc)s + """ + self._text._internal_update(kwargs) + self.stale = True + + @property + def visible_edges(self): + """ + The cell edges to be drawn with a line. + + Reading this property returns a substring of 'BRTL' (bottom, right, + top, left'). + + When setting this property, you can use a substring of 'BRTL' or one + of {'open', 'closed', 'horizontal', 'vertical'}. + """ + return self._visible_edges + + @visible_edges.setter + def visible_edges(self, value): + if value is None: + self._visible_edges = self._edges + elif value in self._edge_aliases: + self._visible_edges = self._edge_aliases[value] + else: + if any(edge not in self._edges for edge in value): + raise ValueError('Invalid edge param {}, must only be one of ' + '{} or string of {}'.format( + value, + ", ".join(self._edge_aliases), + ", ".join(self._edges))) + self._visible_edges = value + self.stale = True + + def get_path(self): + """Return a `.Path` for the `.visible_edges`.""" + codes = [Path.MOVETO] + codes.extend( + Path.LINETO if edge in self._visible_edges else Path.MOVETO + for edge in self._edges) + if Path.MOVETO not in codes[1:]: # All sides are visible + codes[-1] = Path.CLOSEPOLY + return Path( + [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]], + codes, + readonly=True + ) + + +CustomCell = Cell # Backcompat. alias. + + +class Table(Artist): + """ + A table of cells. + + The table consists of a grid of cells, which are indexed by (row, column). + + For a simple table, you'll have a full grid of cells with indices from + (0, 0) to (num_rows-1, num_cols-1), in which the cell (0, 0) is positioned + at the top left. However, you can also add cells with negative indices. + You don't have to add a cell to every grid position, so you can create + tables that have holes. + + *Note*: You'll usually not create an empty table from scratch. Instead use + `~matplotlib.table.table` to create a table from data. + """ + codes = {'best': 0, + 'upper right': 1, # default + 'upper left': 2, + 'lower left': 3, + 'lower right': 4, + 'center left': 5, + 'center right': 6, + 'lower center': 7, + 'upper center': 8, + 'center': 9, + 'top right': 10, + 'top left': 11, + 'bottom left': 12, + 'bottom right': 13, + 'right': 14, + 'left': 15, + 'top': 16, + 'bottom': 17, + } + """Possible values where to place the table relative to the Axes.""" + + FONTSIZE = 10 + + AXESPAD = 0.02 + """The border between the Axes and the table edge in Axes units.""" + + def __init__(self, ax, loc=None, bbox=None, **kwargs): + """ + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The `~.axes.Axes` to plot the table into. + loc : str, optional + The position of the cell with respect to *ax*. This must be one of + the `~.Table.codes`. + bbox : `.Bbox` or [xmin, ymin, width, height], optional + A bounding box to draw the table into. If this is not *None*, this + overrides *loc*. + + Other Parameters + ---------------- + **kwargs + `.Artist` properties. + """ + + super().__init__() + + if isinstance(loc, str): + if loc not in self.codes: + raise ValueError( + "Unrecognized location {!r}. Valid locations are\n\t{}" + .format(loc, '\n\t'.join(self.codes))) + loc = self.codes[loc] + self.set_figure(ax.figure) + self._axes = ax + self._loc = loc + self._bbox = bbox + + # use axes coords + ax._unstale_viewLim() + self.set_transform(ax.transAxes) + + self._cells = {} + self._edges = None + self._autoColumns = [] + self._autoFontsize = True + self._internal_update(kwargs) + + self.set_clip_on(False) + + def add_cell(self, row, col, *args, **kwargs): + """ + Create a cell and add it to the table. + + Parameters + ---------- + row : int + Row index. + col : int + Column index. + *args, **kwargs + All other parameters are passed on to `Cell`. + + Returns + ------- + `.Cell` + The created cell. + + """ + xy = (0, 0) + cell = Cell(xy, visible_edges=self.edges, *args, **kwargs) + self[row, col] = cell + return cell + + def __setitem__(self, position, cell): + """ + Set a custom cell in a given position. + """ + _api.check_isinstance(Cell, cell=cell) + try: + row, col = position[0], position[1] + except Exception as err: + raise KeyError('Only tuples length 2 are accepted as ' + 'coordinates') from err + cell.set_figure(self.figure) + cell.set_transform(self.get_transform()) + cell.set_clip_on(False) + self._cells[row, col] = cell + self.stale = True + + def __getitem__(self, position): + """Retrieve a custom cell from a given position.""" + return self._cells[position] + + @property + def edges(self): + """ + The default value of `~.Cell.visible_edges` for newly added + cells using `.add_cell`. + + Notes + ----- + This setting does currently only affect newly created cells using + `.add_cell`. + + To change existing cells, you have to set their edges explicitly:: + + for c in tab.get_celld().values(): + c.visible_edges = 'horizontal' + + """ + return self._edges + + @edges.setter + def edges(self, value): + self._edges = value + self.stale = True + + def _approx_text_height(self): + return (self.FONTSIZE / 72.0 * self.figure.dpi / + self._axes.bbox.height * 1.2) + + @allow_rasterization + def draw(self, renderer): + # docstring inherited + + # Need a renderer to do hit tests on mouseevent; assume the last one + # will do + if renderer is None: + renderer = self.figure._get_renderer() + if renderer is None: + raise RuntimeError('No renderer defined') + + if not self.get_visible(): + return + renderer.open_group('table', gid=self.get_gid()) + self._update_positions(renderer) + + for key in sorted(self._cells): + self._cells[key].draw(renderer) + + renderer.close_group('table') + self.stale = False + + def _get_grid_bbox(self, renderer): + """ + Get a bbox, in axes coordinates for the cells. + + Only include those in the range (0, 0) to (maxRow, maxCol). + """ + boxes = [cell.get_window_extent(renderer) + for (row, col), cell in self._cells.items() + if row >= 0 and col >= 0] + bbox = Bbox.union(boxes) + return bbox.transformed(self.get_transform().inverted()) + + def contains(self, mouseevent): + # docstring inherited + if self._different_canvas(mouseevent): + return False, {} + # TODO: Return index of the cell containing the cursor so that the user + # doesn't have to bind to each one individually. + renderer = self.figure._get_renderer() + if renderer is not None: + boxes = [cell.get_window_extent(renderer) + for (row, col), cell in self._cells.items() + if row >= 0 and col >= 0] + bbox = Bbox.union(boxes) + return bbox.contains(mouseevent.x, mouseevent.y), {} + else: + return False, {} + + def get_children(self): + """Return the Artists contained by the table.""" + return list(self._cells.values()) + + def get_window_extent(self, renderer=None): + # docstring inherited + if renderer is None: + renderer = self.figure._get_renderer() + self._update_positions(renderer) + boxes = [cell.get_window_extent(renderer) + for cell in self._cells.values()] + return Bbox.union(boxes) + + def _do_cell_alignment(self): + """ + Calculate row heights and column widths; position cells accordingly. + """ + # Calculate row/column widths + widths = {} + heights = {} + for (row, col), cell in self._cells.items(): + height = heights.setdefault(row, 0.0) + heights[row] = max(height, cell.get_height()) + width = widths.setdefault(col, 0.0) + widths[col] = max(width, cell.get_width()) + + # work out left position for each column + xpos = 0 + lefts = {} + for col in sorted(widths): + lefts[col] = xpos + xpos += widths[col] + + ypos = 0 + bottoms = {} + for row in sorted(heights, reverse=True): + bottoms[row] = ypos + ypos += heights[row] + + # set cell positions + for (row, col), cell in self._cells.items(): + cell.set_x(lefts[col]) + cell.set_y(bottoms[row]) + + def auto_set_column_width(self, col): + """ + Automatically set the widths of given columns to optimal sizes. + + Parameters + ---------- + col : int or sequence of ints + The indices of the columns to auto-scale. + """ + col1d = np.atleast_1d(col) + if not np.issubdtype(col1d.dtype, np.integer): + _api.warn_deprecated("3.8", name="col", + message="%(name)r must be an int or sequence of ints. " + "Passing other types is deprecated since %(since)s " + "and will be removed %(removal)s.") + return + for cell in col1d: + self._autoColumns.append(cell) + + self.stale = True + + def _auto_set_column_width(self, col, renderer): + """Automatically set width for column.""" + cells = [cell for key, cell in self._cells.items() if key[1] == col] + max_width = max((cell.get_required_width(renderer) for cell in cells), + default=0) + for cell in cells: + cell.set_width(max_width) + + def auto_set_font_size(self, value=True): + """Automatically set font size.""" + self._autoFontsize = value + self.stale = True + + def _auto_set_font_size(self, renderer): + + if len(self._cells) == 0: + return + fontsize = next(iter(self._cells.values())).get_fontsize() + cells = [] + for key, cell in self._cells.items(): + # ignore auto-sized columns + if key[1] in self._autoColumns: + continue + size = cell.auto_set_font_size(renderer) + fontsize = min(fontsize, size) + cells.append(cell) + + # now set all fontsizes equal + for cell in self._cells.values(): + cell.set_fontsize(fontsize) + + def scale(self, xscale, yscale): + """Scale column widths by *xscale* and row heights by *yscale*.""" + for c in self._cells.values(): + c.set_width(c.get_width() * xscale) + c.set_height(c.get_height() * yscale) + + def set_fontsize(self, size): + """ + Set the font size, in points, of the cell text. + + Parameters + ---------- + size : float + + Notes + ----- + As long as auto font size has not been disabled, the value will be + clipped such that the text fits horizontally into the cell. + + You can disable this behavior using `.auto_set_font_size`. + + >>> the_table.auto_set_font_size(False) + >>> the_table.set_fontsize(20) + + However, there is no automatic scaling of the row height so that the + text may exceed the cell boundary. + """ + for cell in self._cells.values(): + cell.set_fontsize(size) + self.stale = True + + def _offset(self, ox, oy): + """Move all the artists by ox, oy (axes coords).""" + for c in self._cells.values(): + x, y = c.get_x(), c.get_y() + c.set_x(x + ox) + c.set_y(y + oy) + + def _update_positions(self, renderer): + # called from renderer to allow more precise estimates of + # widths and heights with get_window_extent + + # Do any auto width setting + for col in self._autoColumns: + self._auto_set_column_width(col, renderer) + + if self._autoFontsize: + self._auto_set_font_size(renderer) + + # Align all the cells + self._do_cell_alignment() + + bbox = self._get_grid_bbox(renderer) + l, b, w, h = bbox.bounds + + if self._bbox is not None: + # Position according to bbox + if isinstance(self._bbox, Bbox): + rl, rb, rw, rh = self._bbox.bounds + else: + rl, rb, rw, rh = self._bbox + self.scale(rw / w, rh / h) + ox = rl - l + oy = rb - b + self._do_cell_alignment() + else: + # Position using loc + (BEST, UR, UL, LL, LR, CL, CR, LC, UC, C, + TR, TL, BL, BR, R, L, T, B) = range(len(self.codes)) + # defaults for center + ox = (0.5 - w / 2) - l + oy = (0.5 - h / 2) - b + if self._loc in (UL, LL, CL): # left + ox = self.AXESPAD - l + if self._loc in (BEST, UR, LR, R, CR): # right + ox = 1 - (l + w + self.AXESPAD) + if self._loc in (BEST, UR, UL, UC): # upper + oy = 1 - (b + h + self.AXESPAD) + if self._loc in (LL, LR, LC): # lower + oy = self.AXESPAD - b + if self._loc in (LC, UC, C): # center x + ox = (0.5 - w / 2) - l + if self._loc in (CL, CR, C): # center y + oy = (0.5 - h / 2) - b + + if self._loc in (TL, BL, L): # out left + ox = - (l + w) + if self._loc in (TR, BR, R): # out right + ox = 1.0 - l + if self._loc in (TR, TL, T): # out top + oy = 1.0 - b + if self._loc in (BL, BR, B): # out bottom + oy = - (b + h) + + self._offset(ox, oy) + + def get_celld(self): + r""" + Return a dict of cells in the table mapping *(row, column)* to + `.Cell`\s. + + Notes + ----- + You can also directly index into the Table object to access individual + cells:: + + cell = table[row, col] + + """ + return self._cells + + +@_docstring.dedent_interpd +def table(ax, + cellText=None, cellColours=None, + cellLoc='right', colWidths=None, + rowLabels=None, rowColours=None, rowLoc='left', + colLabels=None, colColours=None, colLoc='center', + loc='bottom', bbox=None, edges='closed', + **kwargs): + """ + Add a table to an `~.axes.Axes`. + + At least one of *cellText* or *cellColours* must be specified. These + parameters must be 2D lists, in which the outer lists define the rows and + the inner list define the column values per row. Each row must have the + same number of elements. + + The table can optionally have row and column headers, which are configured + using *rowLabels*, *rowColours*, *rowLoc* and *colLabels*, *colColours*, + *colLoc* respectively. + + For finer grained control over tables, use the `.Table` class and add it to + the Axes with `.Axes.add_table`. + + Parameters + ---------- + cellText : 2D list of str, optional + The texts to place into the table cells. + + *Note*: Line breaks in the strings are currently not accounted for and + will result in the text exceeding the cell boundaries. + + cellColours : 2D list of :mpltype:`color`, optional + The background colors of the cells. + + cellLoc : {'right', 'center', 'left'} + The alignment of the text within the cells. + + colWidths : list of float, optional + The column widths in units of the axes. If not given, all columns will + have a width of *1 / ncols*. + + rowLabels : list of str, optional + The text of the row header cells. + + rowColours : list of :mpltype:`color`, optional + The colors of the row header cells. + + rowLoc : {'left', 'center', 'right'} + The text alignment of the row header cells. + + colLabels : list of str, optional + The text of the column header cells. + + colColours : list of :mpltype:`color`, optional + The colors of the column header cells. + + colLoc : {'center', 'left', 'right'} + The text alignment of the column header cells. + + loc : str, default: 'bottom' + The position of the cell with respect to *ax*. This must be one of + the `~.Table.codes`. + + bbox : `.Bbox` or [xmin, ymin, width, height], optional + A bounding box to draw the table into. If this is not *None*, this + overrides *loc*. + + edges : {'closed', 'open', 'horizontal', 'vertical'} or substring of 'BRTL' + The cell edges to be drawn with a line. See also + `~.Cell.visible_edges`. + + Returns + ------- + `~matplotlib.table.Table` + The created table. + + Other Parameters + ---------------- + **kwargs + `.Table` properties. + + %(Table:kwdoc)s + """ + + if cellColours is None and cellText is None: + raise ValueError('At least one argument from "cellColours" or ' + '"cellText" must be provided to create a table.') + + # Check we have some cellText + if cellText is None: + # assume just colours are needed + rows = len(cellColours) + cols = len(cellColours[0]) + cellText = [[''] * cols] * rows + + rows = len(cellText) + cols = len(cellText[0]) + for row in cellText: + if len(row) != cols: + raise ValueError(f"Each row in 'cellText' must have {cols} " + "columns") + + if cellColours is not None: + if len(cellColours) != rows: + raise ValueError(f"'cellColours' must have {rows} rows") + for row in cellColours: + if len(row) != cols: + raise ValueError("Each row in 'cellColours' must have " + f"{cols} columns") + else: + cellColours = ['w' * cols] * rows + + # Set colwidths if not given + if colWidths is None: + colWidths = [1.0 / cols] * cols + + # Fill in missing information for column + # and row labels + rowLabelWidth = 0 + if rowLabels is None: + if rowColours is not None: + rowLabels = [''] * rows + rowLabelWidth = colWidths[0] + elif rowColours is None: + rowColours = 'w' * rows + + if rowLabels is not None: + if len(rowLabels) != rows: + raise ValueError(f"'rowLabels' must be of length {rows}") + + # If we have column labels, need to shift + # the text and colour arrays down 1 row + offset = 1 + if colLabels is None: + if colColours is not None: + colLabels = [''] * cols + else: + offset = 0 + elif colColours is None: + colColours = 'w' * cols + + # Set up cell colours if not given + if cellColours is None: + cellColours = ['w' * cols] * rows + + # Now create the table + table = Table(ax, loc, bbox, **kwargs) + table.edges = edges + height = table._approx_text_height() + + # Add the cells + for row in range(rows): + for col in range(cols): + table.add_cell(row + offset, col, + width=colWidths[col], height=height, + text=cellText[row][col], + facecolor=cellColours[row][col], + loc=cellLoc) + # Do column labels + if colLabels is not None: + for col in range(cols): + table.add_cell(0, col, + width=colWidths[col], height=height, + text=colLabels[col], facecolor=colColours[col], + loc=colLoc) + + # Do row labels + if rowLabels is not None: + for row in range(rows): + table.add_cell(row + offset, -1, + width=rowLabelWidth or 1e-15, height=height, + text=rowLabels[row], facecolor=rowColours[row], + loc=rowLoc) + if rowLabelWidth == 0: + table.auto_set_column_width(-1) + + ax.add_table(table) + return table diff --git a/venv/lib/python3.10/site-packages/matplotlib/table.pyi b/venv/lib/python3.10/site-packages/matplotlib/table.pyi new file mode 100644 index 00000000..0108ecd9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/table.pyi @@ -0,0 +1,85 @@ +from .artist import Artist +from .axes import Axes +from .backend_bases import RendererBase +from .patches import Rectangle +from .path import Path +from .text import Text +from .transforms import Bbox +from .typing import ColorType + +from collections.abc import Sequence +from typing import Any, Literal + +class Cell(Rectangle): + PAD: float + def __init__( + self, + xy: tuple[float, float], + width: float, + height: float, + *, + edgecolor: ColorType = ..., + facecolor: ColorType = ..., + fill: bool = ..., + text: str = ..., + loc: Literal["left", "center", "right"] = ..., + fontproperties: dict[str, Any] | None = ..., + visible_edges: str | None = ... + ) -> None: ... + def get_text(self) -> Text: ... + def set_fontsize(self, size: float) -> None: ... + def get_fontsize(self) -> float: ... + def auto_set_font_size(self, renderer: RendererBase) -> float: ... + def get_text_bounds( + self, renderer: RendererBase + ) -> tuple[float, float, float, float]: ... + def get_required_width(self, renderer: RendererBase) -> float: ... + def set_text_props(self, **kwargs) -> None: ... + @property + def visible_edges(self) -> str: ... + @visible_edges.setter + def visible_edges(self, value: str | None) -> None: ... + def get_path(self) -> Path: ... + +CustomCell = Cell + +class Table(Artist): + codes: dict[str, int] + FONTSIZE: float + AXESPAD: float + def __init__( + self, ax: Axes, loc: str | None = ..., bbox: Bbox | None = ..., **kwargs + ) -> None: ... + def add_cell(self, row: int, col: int, *args, **kwargs) -> Cell: ... + def __setitem__(self, position: tuple[int, int], cell: Cell) -> None: ... + def __getitem__(self, position: tuple[int, int]) -> Cell: ... + @property + def edges(self) -> str | None: ... + @edges.setter + def edges(self, value: str | None) -> None: ... + def draw(self, renderer) -> None: ... + def get_children(self) -> list[Artist]: ... + def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... + def auto_set_column_width(self, col: int | Sequence[int]) -> None: ... + def auto_set_font_size(self, value: bool = ...) -> None: ... + def scale(self, xscale: float, yscale: float) -> None: ... + def set_fontsize(self, size: float) -> None: ... + def get_celld(self) -> dict[tuple[int, int], Cell]: ... + +def table( + ax: Axes, + cellText: Sequence[Sequence[str]] | None = ..., + cellColours: Sequence[Sequence[ColorType]] | None = ..., + cellLoc: Literal["left", "center", "right"] = ..., + colWidths: Sequence[float] | None = ..., + rowLabels: Sequence[str] | None = ..., + rowColours: Sequence[ColorType] | None = ..., + rowLoc: Literal["left", "center", "right"] = ..., + colLabels: Sequence[str] | None = ..., + colColours: Sequence[ColorType] | None = ..., + colLoc: Literal["left", "center", "right"] = ..., + loc: str = ..., + bbox: Bbox | None = ..., + edges: str = ..., + **kwargs +) -> Table: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.py new file mode 100644 index 00000000..8e60267e --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.py @@ -0,0 +1,213 @@ +""" +Helper functions for testing. +""" +from pathlib import Path +from tempfile import TemporaryDirectory +import locale +import logging +import os +import subprocess +import sys + +import matplotlib as mpl +from matplotlib import _api + +_log = logging.getLogger(__name__) + + +def set_font_settings_for_testing(): + mpl.rcParams['font.family'] = 'DejaVu Sans' + mpl.rcParams['text.hinting'] = 'none' + mpl.rcParams['text.hinting_factor'] = 8 + + +def set_reproducibility_for_testing(): + mpl.rcParams['svg.hashsalt'] = 'matplotlib' + + +def setup(): + # The baseline images are created in this locale, so we should use + # it during all of the tests. + + try: + locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') + except locale.Error: + try: + locale.setlocale(locale.LC_ALL, 'English_United States.1252') + except locale.Error: + _log.warning( + "Could not set locale to English/United States. " + "Some date-related tests may fail.") + + mpl.use('Agg') + + with _api.suppress_matplotlib_deprecation_warning(): + mpl.rcdefaults() # Start with all defaults + + # These settings *must* be hardcoded for running the comparison tests and + # are not necessarily the default values as specified in rcsetup.py. + set_font_settings_for_testing() + set_reproducibility_for_testing() + + +def subprocess_run_for_testing(command, env=None, timeout=60, stdout=None, + stderr=None, check=False, text=True, + capture_output=False): + """ + Create and run a subprocess. + + Thin wrapper around `subprocess.run`, intended for testing. Will + mark fork() failures on Cygwin as expected failures: not a + success, but not indicating a problem with the code either. + + Parameters + ---------- + args : list of str + env : dict[str, str] + timeout : float + stdout, stderr + check : bool + text : bool + Also called ``universal_newlines`` in subprocess. I chose this + name since the main effect is returning bytes (`False`) vs. str + (`True`), though it also tries to normalize newlines across + platforms. + capture_output : bool + Set stdout and stderr to subprocess.PIPE + + Returns + ------- + proc : subprocess.Popen + + See Also + -------- + subprocess.run + + Raises + ------ + pytest.xfail + If platform is Cygwin and subprocess reports a fork() failure. + """ + if capture_output: + stdout = stderr = subprocess.PIPE + try: + proc = subprocess.run( + command, env=env, + timeout=timeout, check=check, + stdout=stdout, stderr=stderr, + text=text + ) + except BlockingIOError: + if sys.platform == "cygwin": + # Might want to make this more specific + import pytest + pytest.xfail("Fork failure") + raise + return proc + + +def subprocess_run_helper(func, *args, timeout, extra_env=None): + """ + Run a function in a sub-process. + + Parameters + ---------- + func : function + The function to be run. It must be in a module that is importable. + *args : str + Any additional command line arguments to be passed in + the first argument to ``subprocess.run``. + extra_env : dict[str, str] + Any additional environment variables to be set for the subprocess. + """ + target = func.__name__ + module = func.__module__ + file = func.__code__.co_filename + proc = subprocess_run_for_testing( + [ + sys.executable, + "-c", + f"import importlib.util;" + f"_spec = importlib.util.spec_from_file_location({module!r}, {file!r});" + f"_module = importlib.util.module_from_spec(_spec);" + f"_spec.loader.exec_module(_module);" + f"_module.{target}()", + *args + ], + env={**os.environ, "SOURCE_DATE_EPOCH": "0", **(extra_env or {})}, + timeout=timeout, check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True + ) + return proc + + +def _check_for_pgf(texsystem): + """ + Check if a given TeX system + pgf is available + + Parameters + ---------- + texsystem : str + The executable name to check + """ + with TemporaryDirectory() as tmpdir: + tex_path = Path(tmpdir, "test.tex") + tex_path.write_text(r""" + \documentclass{article} + \usepackage{pgf} + \begin{document} + \typeout{pgfversion=\pgfversion} + \makeatletter + \@@end + """, encoding="utf-8") + try: + subprocess.check_call( + [texsystem, "-halt-on-error", str(tex_path)], cwd=tmpdir, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + except (OSError, subprocess.CalledProcessError): + return False + return True + + +def _has_tex_package(package): + try: + mpl.dviread.find_tex_file(f"{package}.sty") + return True + except FileNotFoundError: + return False + + +def ipython_in_subprocess(requested_backend_or_gui_framework, all_expected_backends): + import pytest + IPython = pytest.importorskip("IPython") + + if sys.platform == "win32": + pytest.skip("Cannot change backend running IPython in subprocess on Windows") + + if (IPython.version_info[:3] == (8, 24, 0) and + requested_backend_or_gui_framework == "osx"): + pytest.skip("Bug using macosx backend in IPython 8.24.0 fixed in 8.24.1") + + # This code can be removed when Python 3.12, the latest version supported + # by IPython < 8.24, reaches end-of-life in late 2028. + for min_version, backend in all_expected_backends.items(): + if IPython.version_info[:2] >= min_version: + expected_backend = backend + break + + code = ("import matplotlib as mpl, matplotlib.pyplot as plt;" + "fig, ax=plt.subplots(); ax.plot([1, 3, 2]); mpl.get_backend()") + proc = subprocess_run_for_testing( + [ + "ipython", + "--no-simple-prompt", + f"--matplotlib={requested_backend_or_gui_framework}", + "-c", code, + ], + check=True, + capture_output=True, + ) + + assert proc.stdout.strip().endswith(f"'{expected_backend}'") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.pyi b/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.pyi new file mode 100644 index 00000000..1f52a8cc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/__init__.pyi @@ -0,0 +1,53 @@ +from collections.abc import Callable +import subprocess +from typing import Any, IO, Literal, overload + +def set_font_settings_for_testing() -> None: ... +def set_reproducibility_for_testing() -> None: ... +def setup() -> None: ... +@overload +def subprocess_run_for_testing( + command: list[str], + env: dict[str, str] | None = ..., + timeout: float | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., + check: bool = ..., + *, + text: Literal[True], + capture_output: bool = ..., +) -> subprocess.CompletedProcess[str]: ... +@overload +def subprocess_run_for_testing( + command: list[str], + env: dict[str, str] | None = ..., + timeout: float | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., + check: bool = ..., + text: Literal[False] = ..., + capture_output: bool = ..., +) -> subprocess.CompletedProcess[bytes]: ... +@overload +def subprocess_run_for_testing( + command: list[str], + env: dict[str, str] | None = ..., + timeout: float | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., + check: bool = ..., + text: bool = ..., + capture_output: bool = ..., +) -> subprocess.CompletedProcess[bytes] | subprocess.CompletedProcess[str]: ... +def subprocess_run_helper( + func: Callable[[], None], + *args: Any, + timeout: float, + extra_env: dict[str, str] | None = ..., +) -> subprocess.CompletedProcess[str]: ... +def _check_for_pgf(texsystem: str) -> bool: ... +def _has_tex_package(package: str) -> bool: ... +def ipython_in_subprocess( + requested_backend_or_gui_framework: str, + all_expected_backends: dict[tuple[int, int], str], +) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/_markers.py b/venv/lib/python3.10/site-packages/matplotlib/testing/_markers.py new file mode 100644 index 00000000..c7ef8687 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/_markers.py @@ -0,0 +1,49 @@ +""" +pytest markers for the internal Matplotlib test suite. +""" + +import logging +import shutil + +import pytest + +import matplotlib.testing +import matplotlib.testing.compare +from matplotlib import _get_executable_info, ExecutableNotFoundError + + +_log = logging.getLogger(__name__) + + +def _checkdep_usetex() -> bool: + if not shutil.which("tex"): + _log.warning("usetex mode requires TeX.") + return False + try: + _get_executable_info("dvipng") + except ExecutableNotFoundError: + _log.warning("usetex mode requires dvipng.") + return False + try: + _get_executable_info("gs") + except ExecutableNotFoundError: + _log.warning("usetex mode requires ghostscript.") + return False + return True + + +needs_ghostscript = pytest.mark.skipif( + "eps" not in matplotlib.testing.compare.converter, + reason="This test needs a ghostscript installation") +needs_pgf_lualatex = pytest.mark.skipif( + not matplotlib.testing._check_for_pgf('lualatex'), + reason='lualatex + pgf is required') +needs_pgf_pdflatex = pytest.mark.skipif( + not matplotlib.testing._check_for_pgf('pdflatex'), + reason='pdflatex + pgf is required') +needs_pgf_xelatex = pytest.mark.skipif( + not matplotlib.testing._check_for_pgf('xelatex'), + reason='xelatex + pgf is required') +needs_usetex = pytest.mark.skipif( + not _checkdep_usetex(), + reason="This test needs a TeX installation") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/compare.py b/venv/lib/python3.10/site-packages/matplotlib/testing/compare.py new file mode 100644 index 00000000..ee930614 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/compare.py @@ -0,0 +1,520 @@ +""" +Utilities for comparing image results. +""" + +import atexit +import functools +import hashlib +import logging +import os +from pathlib import Path +import shutil +import subprocess +import sys +from tempfile import TemporaryDirectory, TemporaryFile +import weakref + +import numpy as np +from PIL import Image + +import matplotlib as mpl +from matplotlib import cbook +from matplotlib.testing.exceptions import ImageComparisonFailure + +_log = logging.getLogger(__name__) + +__all__ = ['calculate_rms', 'comparable_formats', 'compare_images'] + + +def make_test_filename(fname, purpose): + """ + Make a new filename by inserting *purpose* before the file's extension. + """ + base, ext = os.path.splitext(fname) + return f'{base}-{purpose}{ext}' + + +def _get_cache_path(): + cache_dir = Path(mpl.get_cachedir(), 'test_cache') + cache_dir.mkdir(parents=True, exist_ok=True) + return cache_dir + + +def get_cache_dir(): + return str(_get_cache_path()) + + +def get_file_hash(path, block_size=2 ** 20): + md5 = hashlib.md5() + with open(path, 'rb') as fd: + while True: + data = fd.read(block_size) + if not data: + break + md5.update(data) + + if Path(path).suffix == '.pdf': + md5.update(str(mpl._get_executable_info("gs").version) + .encode('utf-8')) + elif Path(path).suffix == '.svg': + md5.update(str(mpl._get_executable_info("inkscape").version) + .encode('utf-8')) + + return md5.hexdigest() + + +class _ConverterError(Exception): + pass + + +class _Converter: + def __init__(self): + self._proc = None + # Explicitly register deletion from an atexit handler because if we + # wait until the object is GC'd (which occurs later), then some module + # globals (e.g. signal.SIGKILL) has already been set to None, and + # kill() doesn't work anymore... + atexit.register(self.__del__) + + def __del__(self): + if self._proc: + self._proc.kill() + self._proc.wait() + for stream in filter(None, [self._proc.stdin, + self._proc.stdout, + self._proc.stderr]): + stream.close() + self._proc = None + + def _read_until(self, terminator): + """Read until the prompt is reached.""" + buf = bytearray() + while True: + c = self._proc.stdout.read(1) + if not c: + raise _ConverterError(os.fsdecode(bytes(buf))) + buf.extend(c) + if buf.endswith(terminator): + return bytes(buf) + + +class _GSConverter(_Converter): + def __call__(self, orig, dest): + if not self._proc: + self._proc = subprocess.Popen( + [mpl._get_executable_info("gs").executable, + "-dNOSAFER", "-dNOPAUSE", "-dEPSCrop", "-sDEVICE=png16m"], + # As far as I can see, ghostscript never outputs to stderr. + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + try: + self._read_until(b"\nGS") + except _ConverterError as e: + raise OSError(f"Failed to start Ghostscript:\n\n{e.args[0]}") from None + + def encode_and_escape(name): + return (os.fsencode(name) + .replace(b"\\", b"\\\\") + .replace(b"(", br"\(") + .replace(b")", br"\)")) + + self._proc.stdin.write( + b"<< /OutputFile (" + + encode_and_escape(dest) + + b") >> setpagedevice (" + + encode_and_escape(orig) + + b") run flush\n") + self._proc.stdin.flush() + # GS> if nothing left on the stack; GS if n items left on the stack. + err = self._read_until((b"GS<", b"GS>")) + stack = self._read_until(b">") if err.endswith(b"GS<") else b"" + if stack or not os.path.exists(dest): + stack_size = int(stack[:-1]) if stack else 0 + self._proc.stdin.write(b"pop\n" * stack_size) + # Using the systemencoding should at least get the filenames right. + raise ImageComparisonFailure( + (err + stack).decode(sys.getfilesystemencoding(), "replace")) + + +class _SVGConverter(_Converter): + def __call__(self, orig, dest): + old_inkscape = mpl._get_executable_info("inkscape").version.major < 1 + terminator = b"\n>" if old_inkscape else b"> " + if not hasattr(self, "_tmpdir"): + self._tmpdir = TemporaryDirectory() + # On Windows, we must make sure that self._proc has terminated + # (which __del__ does) before clearing _tmpdir. + weakref.finalize(self._tmpdir, self.__del__) + if (not self._proc # First run. + or self._proc.poll() is not None): # Inkscape terminated. + if self._proc is not None and self._proc.poll() is not None: + for stream in filter(None, [self._proc.stdin, + self._proc.stdout, + self._proc.stderr]): + stream.close() + env = { + **os.environ, + # If one passes e.g. a png file to Inkscape, it will try to + # query the user for conversion options via a GUI (even with + # `--without-gui`). Unsetting `DISPLAY` prevents this (and + # causes GTK to crash and Inkscape to terminate, but that'll + # just be reported as a regular exception below). + "DISPLAY": "", + # Do not load any user options. + "INKSCAPE_PROFILE_DIR": self._tmpdir.name, + } + # Old versions of Inkscape (e.g. 0.48.3.1) seem to sometimes + # deadlock when stderr is redirected to a pipe, so we redirect it + # to a temporary file instead. This is not necessary anymore as of + # Inkscape 0.92.1. + stderr = TemporaryFile() + self._proc = subprocess.Popen( + ["inkscape", "--without-gui", "--shell"] if old_inkscape else + ["inkscape", "--shell"], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr, + env=env, cwd=self._tmpdir.name) + # Slight abuse, but makes shutdown handling easier. + self._proc.stderr = stderr + try: + self._read_until(terminator) + except _ConverterError as err: + raise OSError( + "Failed to start Inkscape in interactive mode:\n\n" + + err.args[0]) from err + + # Inkscape's shell mode does not support escaping metacharacters in the + # filename ("\n", and ":;" for inkscape>=1). Avoid any problems by + # running from a temporary directory and using fixed filenames. + inkscape_orig = Path(self._tmpdir.name, os.fsdecode(b"f.svg")) + inkscape_dest = Path(self._tmpdir.name, os.fsdecode(b"f.png")) + try: + inkscape_orig.symlink_to(Path(orig).resolve()) + except OSError: + shutil.copyfile(orig, inkscape_orig) + self._proc.stdin.write( + b"f.svg --export-png=f.png\n" if old_inkscape else + b"file-open:f.svg;export-filename:f.png;export-do;file-close\n") + self._proc.stdin.flush() + try: + self._read_until(terminator) + except _ConverterError as err: + # Inkscape's output is not localized but gtk's is, so the output + # stream probably has a mixed encoding. Using the filesystem + # encoding should at least get the filenames right... + self._proc.stderr.seek(0) + raise ImageComparisonFailure( + self._proc.stderr.read().decode( + sys.getfilesystemencoding(), "replace")) from err + os.remove(inkscape_orig) + shutil.move(inkscape_dest, dest) + + def __del__(self): + super().__del__() + if hasattr(self, "_tmpdir"): + self._tmpdir.cleanup() + + +class _SVGWithMatplotlibFontsConverter(_SVGConverter): + """ + A SVG converter which explicitly adds the fonts shipped by Matplotlib to + Inkspace's font search path, to better support `svg.fonttype = "none"` + (which is in particular used by certain mathtext tests). + """ + + def __call__(self, orig, dest): + if not hasattr(self, "_tmpdir"): + self._tmpdir = TemporaryDirectory() + shutil.copytree(cbook._get_data_path("fonts/ttf"), + Path(self._tmpdir.name, "fonts")) + return super().__call__(orig, dest) + + +def _update_converter(): + try: + mpl._get_executable_info("gs") + except mpl.ExecutableNotFoundError: + pass + else: + converter['pdf'] = converter['eps'] = _GSConverter() + try: + mpl._get_executable_info("inkscape") + except mpl.ExecutableNotFoundError: + pass + else: + converter['svg'] = _SVGConverter() + + +#: A dictionary that maps filename extensions to functions which themselves +#: convert between arguments `old` and `new` (filenames). +converter = {} +_update_converter() +_svg_with_matplotlib_fonts_converter = _SVGWithMatplotlibFontsConverter() + + +def comparable_formats(): + """ + Return the list of file formats that `.compare_images` can compare + on this system. + + Returns + ------- + list of str + E.g. ``['png', 'pdf', 'svg', 'eps']``. + + """ + return ['png', *converter] + + +def convert(filename, cache): + """ + Convert the named file to png; return the name of the created file. + + If *cache* is True, the result of the conversion is cached in + `matplotlib.get_cachedir() + '/test_cache/'`. The caching is based on a + hash of the exact contents of the input file. Old cache entries are + automatically deleted as needed to keep the size of the cache capped to + twice the size of all baseline images. + """ + path = Path(filename) + if not path.exists(): + raise OSError(f"{path} does not exist") + if path.suffix[1:] not in converter: + import pytest + pytest.skip(f"Don't know how to convert {path.suffix} files to png") + newpath = path.parent / f"{path.stem}_{path.suffix[1:]}.png" + + # Only convert the file if the destination doesn't already exist or + # is out of date. + if not newpath.exists() or newpath.stat().st_mtime < path.stat().st_mtime: + cache_dir = _get_cache_path() if cache else None + + if cache_dir is not None: + _register_conversion_cache_cleaner_once() + hash_value = get_file_hash(path) + cached_path = cache_dir / (hash_value + newpath.suffix) + if cached_path.exists(): + _log.debug("For %s: reusing cached conversion.", filename) + shutil.copyfile(cached_path, newpath) + return str(newpath) + + _log.debug("For %s: converting to png.", filename) + convert = converter[path.suffix[1:]] + if path.suffix == ".svg": + contents = path.read_text() + # NOTE: This check should be kept in sync with font styling in + # `lib/matplotlib/backends/backend_svg.py`. If it changes, then be sure to + # re-generate any SVG test files using this mode, or else such tests will + # fail to use the converter for the expected images (but will for the + # results), and the tests will fail strangely. + if 'style="font:' in contents: + # for svg.fonttype = none, we explicitly patch the font search + # path so that fonts shipped by Matplotlib are found. + convert = _svg_with_matplotlib_fonts_converter + convert(path, newpath) + + if cache_dir is not None: + _log.debug("For %s: caching conversion result.", filename) + shutil.copyfile(newpath, cached_path) + + return str(newpath) + + +def _clean_conversion_cache(): + # This will actually ignore mpl_toolkits baseline images, but they're + # relatively small. + baseline_images_size = sum( + path.stat().st_size + for path in Path(mpl.__file__).parent.glob("**/baseline_images/**/*")) + # 2x: one full copy of baselines, and one full copy of test results + # (actually an overestimate: we don't convert png baselines and results). + max_cache_size = 2 * baseline_images_size + # Reduce cache until it fits. + with cbook._lock_path(_get_cache_path()): + cache_stat = { + path: path.stat() for path in _get_cache_path().glob("*")} + cache_size = sum(stat.st_size for stat in cache_stat.values()) + paths_by_atime = sorted( # Oldest at the end. + cache_stat, key=lambda path: cache_stat[path].st_atime, + reverse=True) + while cache_size > max_cache_size: + path = paths_by_atime.pop() + cache_size -= cache_stat[path].st_size + path.unlink() + + +@functools.cache # Ensure this is only registered once. +def _register_conversion_cache_cleaner_once(): + atexit.register(_clean_conversion_cache) + + +def crop_to_same(actual_path, actual_image, expected_path, expected_image): + # clip the images to the same size -- this is useful only when + # comparing eps to pdf + if actual_path[-7:-4] == 'eps' and expected_path[-7:-4] == 'pdf': + aw, ah, ad = actual_image.shape + ew, eh, ed = expected_image.shape + actual_image = actual_image[int(aw / 2 - ew / 2):int( + aw / 2 + ew / 2), int(ah / 2 - eh / 2):int(ah / 2 + eh / 2)] + return actual_image, expected_image + + +def calculate_rms(expected_image, actual_image): + """ + Calculate the per-pixel errors, then compute the root mean square error. + """ + if expected_image.shape != actual_image.shape: + raise ImageComparisonFailure( + f"Image sizes do not match expected size: {expected_image.shape} " + f"actual size {actual_image.shape}") + # Convert to float to avoid overflowing finite integer types. + return np.sqrt(((expected_image - actual_image).astype(float) ** 2).mean()) + + +# NOTE: compare_image and save_diff_image assume that the image does not have +# 16-bit depth, as Pillow converts these to RGB incorrectly. + + +def _load_image(path): + img = Image.open(path) + # In an RGBA image, if the smallest value in the alpha channel is 255, all + # values in it must be 255, meaning that the image is opaque. If so, + # discard the alpha channel so that it may compare equal to an RGB image. + if img.mode != "RGBA" or img.getextrema()[3][0] == 255: + img = img.convert("RGB") + return np.asarray(img) + + +def compare_images(expected, actual, tol, in_decorator=False): + """ + Compare two "image" files checking differences within a tolerance. + + The two given filenames may point to files which are convertible to + PNG via the `.converter` dictionary. The underlying RMS is calculated + with the `.calculate_rms` function. + + Parameters + ---------- + expected : str + The filename of the expected image. + actual : str + The filename of the actual image. + tol : float + The tolerance (a color value difference, where 255 is the + maximal difference). The test fails if the average pixel + difference is greater than this value. + in_decorator : bool + Determines the output format. If called from image_comparison + decorator, this should be True. (default=False) + + Returns + ------- + None or dict or str + Return *None* if the images are equal within the given tolerance. + + If the images differ, the return value depends on *in_decorator*. + If *in_decorator* is true, a dict with the following entries is + returned: + + - *rms*: The RMS of the image difference. + - *expected*: The filename of the expected image. + - *actual*: The filename of the actual image. + - *diff_image*: The filename of the difference image. + - *tol*: The comparison tolerance. + + Otherwise, a human-readable multi-line string representation of this + information is returned. + + Examples + -------- + :: + + img1 = "./baseline/plot.png" + img2 = "./output/plot.png" + compare_images(img1, img2, 0.001) + + """ + actual = os.fspath(actual) + if not os.path.exists(actual): + raise Exception(f"Output image {actual} does not exist.") + if os.stat(actual).st_size == 0: + raise Exception(f"Output image file {actual} is empty.") + + # Convert the image to png + expected = os.fspath(expected) + if not os.path.exists(expected): + raise OSError(f'Baseline image {expected!r} does not exist.') + extension = expected.split('.')[-1] + if extension != 'png': + actual = convert(actual, cache=True) + expected = convert(expected, cache=True) + + # open the image files + expected_image = _load_image(expected) + actual_image = _load_image(actual) + + actual_image, expected_image = crop_to_same( + actual, actual_image, expected, expected_image) + + diff_image = make_test_filename(actual, 'failed-diff') + + if tol <= 0: + if np.array_equal(expected_image, actual_image): + return None + + # convert to signed integers, so that the images can be subtracted without + # overflow + expected_image = expected_image.astype(np.int16) + actual_image = actual_image.astype(np.int16) + + rms = calculate_rms(expected_image, actual_image) + + if rms <= tol: + return None + + save_diff_image(expected, actual, diff_image) + + results = dict(rms=rms, expected=str(expected), + actual=str(actual), diff=str(diff_image), tol=tol) + + if not in_decorator: + # Then the results should be a string suitable for stdout. + template = ['Error: Image files did not match.', + 'RMS Value: {rms}', + 'Expected: \n {expected}', + 'Actual: \n {actual}', + 'Difference:\n {diff}', + 'Tolerance: \n {tol}', ] + results = '\n '.join([line.format(**results) for line in template]) + return results + + +def save_diff_image(expected, actual, output): + """ + Parameters + ---------- + expected : str + File path of expected image. + actual : str + File path of actual image. + output : str + File path to save difference image to. + """ + expected_image = _load_image(expected) + actual_image = _load_image(actual) + actual_image, expected_image = crop_to_same( + actual, actual_image, expected, expected_image) + expected_image = np.array(expected_image, float) + actual_image = np.array(actual_image, float) + if expected_image.shape != actual_image.shape: + raise ImageComparisonFailure( + f"Image sizes do not match expected size: {expected_image.shape} " + f"actual size {actual_image.shape}") + abs_diff = np.abs(expected_image - actual_image) + + # expand differences in luminance domain + abs_diff *= 10 + abs_diff = np.clip(abs_diff, 0, 255).astype(np.uint8) + + if abs_diff.shape[2] == 4: # Hard-code the alpha channel to fully solid + abs_diff[:, :, 3] = 255 + + Image.fromarray(abs_diff).save(output, format="png") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/compare.pyi b/venv/lib/python3.10/site-packages/matplotlib/testing/compare.pyi new file mode 100644 index 00000000..8f11b3be --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/compare.pyi @@ -0,0 +1,32 @@ +from collections.abc import Callable +from typing import Literal, overload + +from numpy.typing import NDArray + +__all__ = ["calculate_rms", "comparable_formats", "compare_images"] + +def make_test_filename(fname: str, purpose: str) -> str: ... +def get_cache_dir() -> str: ... +def get_file_hash(path: str, block_size: int = ...) -> str: ... + +converter: dict[str, Callable[[str, str], None]] = {} + +def comparable_formats() -> list[str]: ... +def convert(filename: str, cache: bool) -> str: ... +def crop_to_same( + actual_path: str, actual_image: NDArray, expected_path: str, expected_image: NDArray +) -> tuple[NDArray, NDArray]: ... +def calculate_rms(expected_image: NDArray, actual_image: NDArray) -> float: ... +@overload +def compare_images( + expected: str, actual: str, tol: float, in_decorator: Literal[True] +) -> None | dict[str, float | str]: ... +@overload +def compare_images( + expected: str, actual: str, tol: float, in_decorator: Literal[False] +) -> None | str: ... +@overload +def compare_images( + expected: str, actual: str, tol: float, in_decorator: bool = ... +) -> None | str | dict[str, float | str]: ... +def save_diff_image(expected: str, actual: str, output: str) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.py b/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.py new file mode 100644 index 00000000..c285c247 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.py @@ -0,0 +1,100 @@ +import pytest +import sys +import matplotlib +from matplotlib import _api + + +def pytest_configure(config): + # config is initialized here rather than in pytest.ini so that `pytest + # --pyargs matplotlib` (which would not find pytest.ini) works. The only + # entries in pytest.ini set minversion (which is checked earlier), + # testpaths/python_files, as they are required to properly find the tests + for key, value in [ + ("markers", "flaky: (Provided by pytest-rerunfailures.)"), + ("markers", "timeout: (Provided by pytest-timeout.)"), + ("markers", "backend: Set alternate Matplotlib backend temporarily."), + ("markers", "baseline_images: Compare output against references."), + ("markers", "pytz: Tests that require pytz to be installed."), + ("filterwarnings", "error"), + ("filterwarnings", + "ignore:.*The py23 module has been deprecated:DeprecationWarning"), + ("filterwarnings", + r"ignore:DynamicImporter.find_spec\(\) not found; " + r"falling back to find_module\(\):ImportWarning"), + ]: + config.addinivalue_line(key, value) + + matplotlib.use('agg', force=True) + matplotlib._called_from_pytest = True + matplotlib._init_tests() + + +def pytest_unconfigure(config): + matplotlib._called_from_pytest = False + + +@pytest.fixture(autouse=True) +def mpl_test_settings(request): + from matplotlib.testing.decorators import _cleanup_cm + + with _cleanup_cm(): + + backend = None + backend_marker = request.node.get_closest_marker('backend') + prev_backend = matplotlib.get_backend() + if backend_marker is not None: + assert len(backend_marker.args) == 1, \ + "Marker 'backend' must specify 1 backend." + backend, = backend_marker.args + skip_on_importerror = backend_marker.kwargs.get( + 'skip_on_importerror', False) + + # special case Qt backend importing to avoid conflicts + if backend.lower().startswith('qt5'): + if any(sys.modules.get(k) for k in ('PyQt4', 'PySide')): + pytest.skip('Qt4 binding already imported') + + matplotlib.testing.setup() + with _api.suppress_matplotlib_deprecation_warning(): + if backend is not None: + # This import must come after setup() so it doesn't load the + # default backend prematurely. + import matplotlib.pyplot as plt + try: + plt.switch_backend(backend) + except ImportError as exc: + # Should only occur for the cairo backend tests, if neither + # pycairo nor cairocffi are installed. + if 'cairo' in backend.lower() or skip_on_importerror: + pytest.skip("Failed to switch to backend " + f"{backend} ({exc}).") + else: + raise + # Default of cleanup and image_comparison too. + matplotlib.style.use(["classic", "_classic_test_patch"]) + try: + yield + finally: + if backend is not None: + plt.close("all") + matplotlib.use(prev_backend) + + +@pytest.fixture +def pd(): + """Fixture to import and configure pandas.""" + pd = pytest.importorskip('pandas') + try: + from pandas.plotting import ( + deregister_matplotlib_converters as deregister) + deregister() + except ImportError: + pass + return pd + + +@pytest.fixture +def xr(): + """Fixture to import xarray.""" + xr = pytest.importorskip('xarray') + return xr diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.pyi b/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.pyi new file mode 100644 index 00000000..2af0eb93 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/conftest.pyi @@ -0,0 +1,12 @@ +from types import ModuleType + +import pytest + +def pytest_configure(config: pytest.Config) -> None: ... +def pytest_unconfigure(config: pytest.Config) -> None: ... +@pytest.fixture +def mpl_test_settings(request: pytest.FixtureRequest) -> None: ... +@pytest.fixture +def pd() -> ModuleType: ... +@pytest.fixture +def xr() -> ModuleType: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.py b/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.py new file mode 100644 index 00000000..49ac4a15 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.py @@ -0,0 +1,464 @@ +import contextlib +import functools +import inspect +import os +from platform import uname +from pathlib import Path +import shutil +import string +import sys +import warnings + +from packaging.version import parse as parse_version + +import matplotlib.style +import matplotlib.units +import matplotlib.testing +from matplotlib import _pylab_helpers, cbook, ft2font, pyplot as plt, ticker +from .compare import comparable_formats, compare_images, make_test_filename +from .exceptions import ImageComparisonFailure + + +@contextlib.contextmanager +def _cleanup_cm(): + orig_units_registry = matplotlib.units.registry.copy() + try: + with warnings.catch_warnings(), matplotlib.rc_context(): + yield + finally: + matplotlib.units.registry.clear() + matplotlib.units.registry.update(orig_units_registry) + plt.close("all") + + +def _check_freetype_version(ver): + if ver is None: + return True + + if isinstance(ver, str): + ver = (ver, ver) + ver = [parse_version(x) for x in ver] + found = parse_version(ft2font.__freetype_version__) + + return ver[0] <= found <= ver[1] + + +def _checked_on_freetype_version(required_freetype_version): + import pytest + return pytest.mark.xfail( + not _check_freetype_version(required_freetype_version), + reason=f"Mismatched version of freetype. " + f"Test requires '{required_freetype_version}', " + f"you have '{ft2font.__freetype_version__}'", + raises=ImageComparisonFailure, strict=False) + + +def remove_ticks_and_titles(figure): + figure.suptitle("") + null_formatter = ticker.NullFormatter() + def remove_ticks(ax): + """Remove ticks in *ax* and all its child Axes.""" + ax.set_title("") + ax.xaxis.set_major_formatter(null_formatter) + ax.xaxis.set_minor_formatter(null_formatter) + ax.yaxis.set_major_formatter(null_formatter) + ax.yaxis.set_minor_formatter(null_formatter) + try: + ax.zaxis.set_major_formatter(null_formatter) + ax.zaxis.set_minor_formatter(null_formatter) + except AttributeError: + pass + for child in ax.child_axes: + remove_ticks(child) + for ax in figure.get_axes(): + remove_ticks(ax) + + +@contextlib.contextmanager +def _collect_new_figures(): + """ + After:: + + with _collect_new_figures() as figs: + some_code() + + the list *figs* contains the figures that have been created during the + execution of ``some_code``, sorted by figure number. + """ + managers = _pylab_helpers.Gcf.figs + preexisting = [manager for manager in managers.values()] + new_figs = [] + try: + yield new_figs + finally: + new_managers = sorted([manager for manager in managers.values() + if manager not in preexisting], + key=lambda manager: manager.num) + new_figs[:] = [manager.canvas.figure for manager in new_managers] + + +def _raise_on_image_difference(expected, actual, tol): + __tracebackhide__ = True + + err = compare_images(expected, actual, tol, in_decorator=True) + if err: + for key in ["actual", "expected", "diff"]: + err[key] = os.path.relpath(err[key]) + raise ImageComparisonFailure( + ('images not close (RMS %(rms).3f):' + '\n\t%(actual)s\n\t%(expected)s\n\t%(diff)s') % err) + + +class _ImageComparisonBase: + """ + Image comparison base class + + This class provides *just* the comparison-related functionality and avoids + any code that would be specific to any testing framework. + """ + + def __init__(self, func, tol, remove_text, savefig_kwargs): + self.func = func + self.baseline_dir, self.result_dir = _image_directories(func) + self.tol = tol + self.remove_text = remove_text + self.savefig_kwargs = savefig_kwargs + + def copy_baseline(self, baseline, extension): + baseline_path = self.baseline_dir / baseline + orig_expected_path = baseline_path.with_suffix(f'.{extension}') + if extension == 'eps' and not orig_expected_path.exists(): + orig_expected_path = orig_expected_path.with_suffix('.pdf') + expected_fname = make_test_filename( + self.result_dir / orig_expected_path.name, 'expected') + try: + # os.symlink errors if the target already exists. + with contextlib.suppress(OSError): + os.remove(expected_fname) + try: + if 'microsoft' in uname().release.lower(): + raise OSError # On WSL, symlink breaks silently + os.symlink(orig_expected_path, expected_fname) + except OSError: # On Windows, symlink *may* be unavailable. + shutil.copyfile(orig_expected_path, expected_fname) + except OSError as err: + raise ImageComparisonFailure( + f"Missing baseline image {expected_fname} because the " + f"following file cannot be accessed: " + f"{orig_expected_path}") from err + return expected_fname + + def compare(self, fig, baseline, extension, *, _lock=False): + __tracebackhide__ = True + + if self.remove_text: + remove_ticks_and_titles(fig) + + actual_path = (self.result_dir / baseline).with_suffix(f'.{extension}') + kwargs = self.savefig_kwargs.copy() + if extension == 'pdf': + kwargs.setdefault('metadata', + {'Creator': None, 'Producer': None, + 'CreationDate': None}) + + lock = (cbook._lock_path(actual_path) + if _lock else contextlib.nullcontext()) + with lock: + try: + fig.savefig(actual_path, **kwargs) + finally: + # Matplotlib has an autouse fixture to close figures, but this + # makes things more convenient for third-party users. + plt.close(fig) + expected_path = self.copy_baseline(baseline, extension) + _raise_on_image_difference(expected_path, actual_path, self.tol) + + +def _pytest_image_comparison(baseline_images, extensions, tol, + freetype_version, remove_text, savefig_kwargs, + style): + """ + Decorate function with image comparison for pytest. + + This function creates a decorator that wraps a figure-generating function + with image comparison code. + """ + import pytest + + KEYWORD_ONLY = inspect.Parameter.KEYWORD_ONLY + + def decorator(func): + old_sig = inspect.signature(func) + + @functools.wraps(func) + @pytest.mark.parametrize('extension', extensions) + @matplotlib.style.context(style) + @_checked_on_freetype_version(freetype_version) + @functools.wraps(func) + def wrapper(*args, extension, request, **kwargs): + __tracebackhide__ = True + if 'extension' in old_sig.parameters: + kwargs['extension'] = extension + if 'request' in old_sig.parameters: + kwargs['request'] = request + + if extension not in comparable_formats(): + reason = { + 'pdf': 'because Ghostscript is not installed', + 'eps': 'because Ghostscript is not installed', + 'svg': 'because Inkscape is not installed', + }.get(extension, 'on this system') + pytest.skip(f"Cannot compare {extension} files {reason}") + + img = _ImageComparisonBase(func, tol=tol, remove_text=remove_text, + savefig_kwargs=savefig_kwargs) + matplotlib.testing.set_font_settings_for_testing() + + with _collect_new_figures() as figs: + func(*args, **kwargs) + + # If the test is parametrized in any way other than applied via + # this decorator, then we need to use a lock to prevent two + # processes from touching the same output file. + needs_lock = any( + marker.args[0] != 'extension' + for marker in request.node.iter_markers('parametrize')) + + if baseline_images is not None: + our_baseline_images = baseline_images + else: + # Allow baseline image list to be produced on the fly based on + # current parametrization. + our_baseline_images = request.getfixturevalue( + 'baseline_images') + + assert len(figs) == len(our_baseline_images), ( + f"Test generated {len(figs)} images but there are " + f"{len(our_baseline_images)} baseline images") + for fig, baseline in zip(figs, our_baseline_images): + img.compare(fig, baseline, extension, _lock=needs_lock) + + parameters = list(old_sig.parameters.values()) + if 'extension' not in old_sig.parameters: + parameters += [inspect.Parameter('extension', KEYWORD_ONLY)] + if 'request' not in old_sig.parameters: + parameters += [inspect.Parameter("request", KEYWORD_ONLY)] + new_sig = old_sig.replace(parameters=parameters) + wrapper.__signature__ = new_sig + + # Reach a bit into pytest internals to hoist the marks from our wrapped + # function. + new_marks = getattr(func, 'pytestmark', []) + wrapper.pytestmark + wrapper.pytestmark = new_marks + + return wrapper + + return decorator + + +def image_comparison(baseline_images, extensions=None, tol=0, + freetype_version=None, remove_text=False, + savefig_kwarg=None, + # Default of mpl_test_settings fixture and cleanup too. + style=("classic", "_classic_test_patch")): + """ + Compare images generated by the test with those specified in + *baseline_images*, which must correspond, else an `ImageComparisonFailure` + exception will be raised. + + Parameters + ---------- + baseline_images : list or None + A list of strings specifying the names of the images generated by + calls to `.Figure.savefig`. + + If *None*, the test function must use the ``baseline_images`` fixture, + either as a parameter or with `pytest.mark.usefixtures`. This value is + only allowed when using pytest. + + extensions : None or list of str + The list of extensions to test, e.g. ``['png', 'pdf']``. + + If *None*, defaults to all supported extensions: png, pdf, and svg. + + When testing a single extension, it can be directly included in the + names passed to *baseline_images*. In that case, *extensions* must not + be set. + + In order to keep the size of the test suite from ballooning, we only + include the ``svg`` or ``pdf`` outputs if the test is explicitly + exercising a feature dependent on that backend (see also the + `check_figures_equal` decorator for that purpose). + + tol : float, default: 0 + The RMS threshold above which the test is considered failed. + + Due to expected small differences in floating-point calculations, on + 32-bit systems an additional 0.06 is added to this threshold. + + freetype_version : str or tuple + The expected freetype version or range of versions for this test to + pass. + + remove_text : bool + Remove the title and tick text from the figure before comparison. This + is useful to make the baseline images independent of variations in text + rendering between different versions of FreeType. + + This does not remove other, more deliberate, text, such as legends and + annotations. + + savefig_kwarg : dict + Optional arguments that are passed to the savefig method. + + style : str, dict, or list + The optional style(s) to apply to the image test. The test itself + can also apply additional styles if desired. Defaults to ``["classic", + "_classic_test_patch"]``. + """ + + if baseline_images is not None: + # List of non-empty filename extensions. + baseline_exts = [*filter(None, {Path(baseline).suffix[1:] + for baseline in baseline_images})] + if baseline_exts: + if extensions is not None: + raise ValueError( + "When including extensions directly in 'baseline_images', " + "'extensions' cannot be set as well") + if len(baseline_exts) > 1: + raise ValueError( + "When including extensions directly in 'baseline_images', " + "all baselines must share the same suffix") + extensions = baseline_exts + baseline_images = [ # Chop suffix out from baseline_images. + Path(baseline).stem for baseline in baseline_images] + if extensions is None: + # Default extensions to test, if not set via baseline_images. + extensions = ['png', 'pdf', 'svg'] + if savefig_kwarg is None: + savefig_kwarg = dict() # default no kwargs to savefig + if sys.maxsize <= 2**32: + tol += 0.06 + return _pytest_image_comparison( + baseline_images=baseline_images, extensions=extensions, tol=tol, + freetype_version=freetype_version, remove_text=remove_text, + savefig_kwargs=savefig_kwarg, style=style) + + +def check_figures_equal(*, extensions=("png", "pdf", "svg"), tol=0): + """ + Decorator for test cases that generate and compare two figures. + + The decorated function must take two keyword arguments, *fig_test* + and *fig_ref*, and draw the test and reference images on them. + After the function returns, the figures are saved and compared. + + This decorator should be preferred over `image_comparison` when possible in + order to keep the size of the test suite from ballooning. + + Parameters + ---------- + extensions : list, default: ["png", "pdf", "svg"] + The extensions to test. + tol : float + The RMS threshold above which the test is considered failed. + + Raises + ------ + RuntimeError + If any new figures are created (and not subsequently closed) inside + the test function. + + Examples + -------- + Check that calling `.Axes.plot` with a single argument plots it against + ``[0, 1, 2, ...]``:: + + @check_figures_equal() + def test_plot(fig_test, fig_ref): + fig_test.subplots().plot([1, 3, 5]) + fig_ref.subplots().plot([0, 1, 2], [1, 3, 5]) + + """ + ALLOWED_CHARS = set(string.digits + string.ascii_letters + '_-[]()') + KEYWORD_ONLY = inspect.Parameter.KEYWORD_ONLY + + def decorator(func): + import pytest + + _, result_dir = _image_directories(func) + old_sig = inspect.signature(func) + + if not {"fig_test", "fig_ref"}.issubset(old_sig.parameters): + raise ValueError("The decorated function must have at least the " + "parameters 'fig_test' and 'fig_ref', but your " + f"function has the signature {old_sig}") + + @pytest.mark.parametrize("ext", extensions) + def wrapper(*args, ext, request, **kwargs): + if 'ext' in old_sig.parameters: + kwargs['ext'] = ext + if 'request' in old_sig.parameters: + kwargs['request'] = request + + file_name = "".join(c for c in request.node.name + if c in ALLOWED_CHARS) + try: + fig_test = plt.figure("test") + fig_ref = plt.figure("reference") + with _collect_new_figures() as figs: + func(*args, fig_test=fig_test, fig_ref=fig_ref, **kwargs) + if figs: + raise RuntimeError('Number of open figures changed during ' + 'test. Make sure you are plotting to ' + 'fig_test or fig_ref, or if this is ' + 'deliberate explicitly close the ' + 'new figure(s) inside the test.') + test_image_path = result_dir / (file_name + "." + ext) + ref_image_path = result_dir / (file_name + "-expected." + ext) + fig_test.savefig(test_image_path) + fig_ref.savefig(ref_image_path) + _raise_on_image_difference( + ref_image_path, test_image_path, tol=tol + ) + finally: + plt.close(fig_test) + plt.close(fig_ref) + + parameters = [ + param + for param in old_sig.parameters.values() + if param.name not in {"fig_test", "fig_ref"} + ] + if 'ext' not in old_sig.parameters: + parameters += [inspect.Parameter("ext", KEYWORD_ONLY)] + if 'request' not in old_sig.parameters: + parameters += [inspect.Parameter("request", KEYWORD_ONLY)] + new_sig = old_sig.replace(parameters=parameters) + wrapper.__signature__ = new_sig + + # reach a bit into pytest internals to hoist the marks from + # our wrapped function + new_marks = getattr(func, "pytestmark", []) + wrapper.pytestmark + wrapper.pytestmark = new_marks + + return wrapper + + return decorator + + +def _image_directories(func): + """ + Compute the baseline and result image directories for testing *func*. + + For test module ``foo.bar.test_baz``, the baseline directory is at + ``foo/bar/baseline_images/test_baz`` and the result directory at + ``$(pwd)/result_images/test_baz``. The result directory is created if it + doesn't exist. + """ + module_path = Path(inspect.getfile(func)) + baseline_dir = module_path.parent / "baseline_images" / module_path.stem + result_dir = Path().resolve() / "result_images" / module_path.stem + result_dir.mkdir(parents=True, exist_ok=True) + return baseline_dir, result_dir diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.pyi b/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.pyi new file mode 100644 index 00000000..f1b6c5e5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/decorators.pyi @@ -0,0 +1,25 @@ +from collections.abc import Callable, Sequence +from pathlib import Path +from typing import Any, TypeVar +from typing_extensions import ParamSpec + +from matplotlib.figure import Figure +from matplotlib.typing import RcStyleType + +_P = ParamSpec("_P") +_R = TypeVar("_R") + +def remove_ticks_and_titles(figure: Figure) -> None: ... +def image_comparison( + baseline_images: list[str] | None, + extensions: list[str] | None = ..., + tol: float = ..., + freetype_version: tuple[str, str] | str | None = ..., + remove_text: bool = ..., + savefig_kwarg: dict[str, Any] | None = ..., + style: RcStyleType = ..., +) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... +def check_figures_equal( + *, extensions: Sequence[str] = ..., tol: float = ... +) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... +def _image_directories(func: Callable) -> tuple[Path, Path]: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/exceptions.py b/venv/lib/python3.10/site-packages/matplotlib/testing/exceptions.py new file mode 100644 index 00000000..c39a3920 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/exceptions.py @@ -0,0 +1,4 @@ +class ImageComparisonFailure(AssertionError): + """ + Raise this exception to mark a test as a comparison between two images. + """ diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Duration.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Duration.py new file mode 100644 index 00000000..052c5a47 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Duration.py @@ -0,0 +1,138 @@ +"""Duration module.""" + +import functools +import operator + +from matplotlib import _api + + +class Duration: + """Class Duration in development.""" + + allowed = ["ET", "UTC"] + + def __init__(self, frame, seconds): + """ + Create a new Duration object. + + = ERROR CONDITIONS + - If the input frame is not in the allowed list, an error is thrown. + + = INPUT VARIABLES + - frame The frame of the duration. Must be 'ET' or 'UTC' + - seconds The number of seconds in the Duration. + """ + _api.check_in_list(self.allowed, frame=frame) + self._frame = frame + self._seconds = seconds + + def frame(self): + """Return the frame the duration is in.""" + return self._frame + + def __abs__(self): + """Return the absolute value of the duration.""" + return Duration(self._frame, abs(self._seconds)) + + def __neg__(self): + """Return the negative value of this Duration.""" + return Duration(self._frame, -self._seconds) + + def seconds(self): + """Return the number of seconds in the Duration.""" + return self._seconds + + def __bool__(self): + return self._seconds != 0 + + def _cmp(self, op, rhs): + """ + Check that *self* and *rhs* share frames; compare them using *op*. + """ + self.checkSameFrame(rhs, "compare") + return op(self._seconds, rhs._seconds) + + __eq__ = functools.partialmethod(_cmp, operator.eq) + __ne__ = functools.partialmethod(_cmp, operator.ne) + __lt__ = functools.partialmethod(_cmp, operator.lt) + __le__ = functools.partialmethod(_cmp, operator.le) + __gt__ = functools.partialmethod(_cmp, operator.gt) + __ge__ = functools.partialmethod(_cmp, operator.ge) + + def __add__(self, rhs): + """ + Add two Durations. + + = ERROR CONDITIONS + - If the input rhs is not in the same frame, an error is thrown. + + = INPUT VARIABLES + - rhs The Duration to add. + + = RETURN VALUE + - Returns the sum of ourselves and the input Duration. + """ + # Delay-load due to circular dependencies. + import matplotlib.testing.jpl_units as U + + if isinstance(rhs, U.Epoch): + return rhs + self + + self.checkSameFrame(rhs, "add") + return Duration(self._frame, self._seconds + rhs._seconds) + + def __sub__(self, rhs): + """ + Subtract two Durations. + + = ERROR CONDITIONS + - If the input rhs is not in the same frame, an error is thrown. + + = INPUT VARIABLES + - rhs The Duration to subtract. + + = RETURN VALUE + - Returns the difference of ourselves and the input Duration. + """ + self.checkSameFrame(rhs, "sub") + return Duration(self._frame, self._seconds - rhs._seconds) + + def __mul__(self, rhs): + """ + Scale a UnitDbl by a value. + + = INPUT VARIABLES + - rhs The scalar to multiply by. + + = RETURN VALUE + - Returns the scaled Duration. + """ + return Duration(self._frame, self._seconds * float(rhs)) + + __rmul__ = __mul__ + + def __str__(self): + """Print the Duration.""" + return f"{self._seconds:g} {self._frame}" + + def __repr__(self): + """Print the Duration.""" + return f"Duration('{self._frame}', {self._seconds:g})" + + def checkSameFrame(self, rhs, func): + """ + Check to see if frames are the same. + + = ERROR CONDITIONS + - If the frame of the rhs Duration is not the same as our frame, + an error is thrown. + + = INPUT VARIABLES + - rhs The Duration to check for the same frame + - func The name of the function doing the check. + """ + if self._frame != rhs._frame: + raise ValueError( + f"Cannot {func} Durations with different frames.\n" + f"LHS: {self._frame}\n" + f"RHS: {rhs._frame}") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Epoch.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Epoch.py new file mode 100644 index 00000000..501b7fa3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Epoch.py @@ -0,0 +1,211 @@ +"""Epoch module.""" + +import functools +import operator +import math +import datetime as DT + +from matplotlib import _api +from matplotlib.dates import date2num + + +class Epoch: + # Frame conversion offsets in seconds + # t(TO) = t(FROM) + allowed[ FROM ][ TO ] + allowed = { + "ET": { + "UTC": +64.1839, + }, + "UTC": { + "ET": -64.1839, + }, + } + + def __init__(self, frame, sec=None, jd=None, daynum=None, dt=None): + """ + Create a new Epoch object. + + Build an epoch 1 of 2 ways: + + Using seconds past a Julian date: + # Epoch('ET', sec=1e8, jd=2451545) + + or using a matplotlib day number + # Epoch('ET', daynum=730119.5) + + = ERROR CONDITIONS + - If the input units are not in the allowed list, an error is thrown. + + = INPUT VARIABLES + - frame The frame of the epoch. Must be 'ET' or 'UTC' + - sec The number of seconds past the input JD. + - jd The Julian date of the epoch. + - daynum The matplotlib day number of the epoch. + - dt A python datetime instance. + """ + if ((sec is None and jd is not None) or + (sec is not None and jd is None) or + (daynum is not None and + (sec is not None or jd is not None)) or + (daynum is None and dt is None and + (sec is None or jd is None)) or + (daynum is not None and dt is not None) or + (dt is not None and (sec is not None or jd is not None)) or + ((dt is not None) and not isinstance(dt, DT.datetime))): + raise ValueError( + "Invalid inputs. Must enter sec and jd together, " + "daynum by itself, or dt (must be a python datetime).\n" + "Sec = %s\n" + "JD = %s\n" + "dnum= %s\n" + "dt = %s" % (sec, jd, daynum, dt)) + + _api.check_in_list(self.allowed, frame=frame) + self._frame = frame + + if dt is not None: + daynum = date2num(dt) + + if daynum is not None: + # 1-JAN-0001 in JD = 1721425.5 + jd = float(daynum) + 1721425.5 + self._jd = math.floor(jd) + self._seconds = (jd - self._jd) * 86400.0 + + else: + self._seconds = float(sec) + self._jd = float(jd) + + # Resolve seconds down to [ 0, 86400) + deltaDays = math.floor(self._seconds / 86400) + self._jd += deltaDays + self._seconds -= deltaDays * 86400.0 + + def convert(self, frame): + if self._frame == frame: + return self + + offset = self.allowed[self._frame][frame] + + return Epoch(frame, self._seconds + offset, self._jd) + + def frame(self): + return self._frame + + def julianDate(self, frame): + t = self + if frame != self._frame: + t = self.convert(frame) + + return t._jd + t._seconds / 86400.0 + + def secondsPast(self, frame, jd): + t = self + if frame != self._frame: + t = self.convert(frame) + + delta = t._jd - jd + return t._seconds + delta * 86400 + + def _cmp(self, op, rhs): + """Compare Epochs *self* and *rhs* using operator *op*.""" + t = self + if self._frame != rhs._frame: + t = self.convert(rhs._frame) + if t._jd != rhs._jd: + return op(t._jd, rhs._jd) + return op(t._seconds, rhs._seconds) + + __eq__ = functools.partialmethod(_cmp, operator.eq) + __ne__ = functools.partialmethod(_cmp, operator.ne) + __lt__ = functools.partialmethod(_cmp, operator.lt) + __le__ = functools.partialmethod(_cmp, operator.le) + __gt__ = functools.partialmethod(_cmp, operator.gt) + __ge__ = functools.partialmethod(_cmp, operator.ge) + + def __add__(self, rhs): + """ + Add a duration to an Epoch. + + = INPUT VARIABLES + - rhs The Epoch to subtract. + + = RETURN VALUE + - Returns the difference of ourselves and the input Epoch. + """ + t = self + if self._frame != rhs.frame(): + t = self.convert(rhs._frame) + + sec = t._seconds + rhs.seconds() + + return Epoch(t._frame, sec, t._jd) + + def __sub__(self, rhs): + """ + Subtract two Epoch's or a Duration from an Epoch. + + Valid: + Duration = Epoch - Epoch + Epoch = Epoch - Duration + + = INPUT VARIABLES + - rhs The Epoch to subtract. + + = RETURN VALUE + - Returns either the duration between to Epoch's or the a new + Epoch that is the result of subtracting a duration from an epoch. + """ + # Delay-load due to circular dependencies. + import matplotlib.testing.jpl_units as U + + # Handle Epoch - Duration + if isinstance(rhs, U.Duration): + return self + -rhs + + t = self + if self._frame != rhs._frame: + t = self.convert(rhs._frame) + + days = t._jd - rhs._jd + sec = t._seconds - rhs._seconds + + return U.Duration(rhs._frame, days*86400 + sec) + + def __str__(self): + """Print the Epoch.""" + return f"{self.julianDate(self._frame):22.15e} {self._frame}" + + def __repr__(self): + """Print the Epoch.""" + return str(self) + + @staticmethod + def range(start, stop, step): + """ + Generate a range of Epoch objects. + + Similar to the Python range() method. Returns the range [ + start, stop) at the requested step. Each element will be a + Epoch object. + + = INPUT VARIABLES + - start The starting value of the range. + - stop The stop value of the range. + - step Step to use. + + = RETURN VALUE + - Returns a list containing the requested Epoch values. + """ + elems = [] + + i = 0 + while True: + d = start + i * step + if d >= stop: + break + + elems.append(d) + i += 1 + + return elems diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/EpochConverter.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/EpochConverter.py new file mode 100644 index 00000000..1edc2acf --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/EpochConverter.py @@ -0,0 +1,94 @@ +"""EpochConverter module containing class EpochConverter.""" + +from matplotlib import cbook, units +import matplotlib.dates as date_ticker + +__all__ = ['EpochConverter'] + + +class EpochConverter(units.ConversionInterface): + """ + Provides Matplotlib conversion functionality for Monte Epoch and Duration + classes. + """ + + jdRef = 1721425.5 + + @staticmethod + def axisinfo(unit, axis): + # docstring inherited + majloc = date_ticker.AutoDateLocator() + majfmt = date_ticker.AutoDateFormatter(majloc) + return units.AxisInfo(majloc=majloc, majfmt=majfmt, label=unit) + + @staticmethod + def float2epoch(value, unit): + """ + Convert a Matplotlib floating-point date into an Epoch of the specified + units. + + = INPUT VARIABLES + - value The Matplotlib floating-point date. + - unit The unit system to use for the Epoch. + + = RETURN VALUE + - Returns the value converted to an Epoch in the specified time system. + """ + # Delay-load due to circular dependencies. + import matplotlib.testing.jpl_units as U + + secPastRef = value * 86400.0 * U.UnitDbl(1.0, 'sec') + return U.Epoch(unit, secPastRef, EpochConverter.jdRef) + + @staticmethod + def epoch2float(value, unit): + """ + Convert an Epoch value to a float suitable for plotting as a python + datetime object. + + = INPUT VARIABLES + - value An Epoch or list of Epochs that need to be converted. + - unit The units to use for an axis with Epoch data. + + = RETURN VALUE + - Returns the value parameter converted to floats. + """ + return value.julianDate(unit) - EpochConverter.jdRef + + @staticmethod + def duration2float(value): + """ + Convert a Duration value to a float suitable for plotting as a python + datetime object. + + = INPUT VARIABLES + - value A Duration or list of Durations that need to be converted. + + = RETURN VALUE + - Returns the value parameter converted to floats. + """ + return value.seconds() / 86400.0 + + @staticmethod + def convert(value, unit, axis): + # docstring inherited + + # Delay-load due to circular dependencies. + import matplotlib.testing.jpl_units as U + + if not cbook.is_scalar_or_string(value): + return [EpochConverter.convert(x, unit, axis) for x in value] + if unit is None: + unit = EpochConverter.default_units(value, axis) + if isinstance(value, U.Duration): + return EpochConverter.duration2float(value) + else: + return EpochConverter.epoch2float(value, unit) + + @staticmethod + def default_units(value, axis): + # docstring inherited + if cbook.is_scalar_or_string(value): + return value.frame() + else: + return EpochConverter.default_units(value[0], axis) diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/StrConverter.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/StrConverter.py new file mode 100644 index 00000000..a62d4981 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/StrConverter.py @@ -0,0 +1,97 @@ +"""StrConverter module containing class StrConverter.""" + +import numpy as np + +import matplotlib.units as units + +__all__ = ['StrConverter'] + + +class StrConverter(units.ConversionInterface): + """ + A Matplotlib converter class for string data values. + + Valid units for string are: + - 'indexed' : Values are indexed as they are specified for plotting. + - 'sorted' : Values are sorted alphanumerically. + - 'inverted' : Values are inverted so that the first value is on top. + - 'sorted-inverted' : A combination of 'sorted' and 'inverted' + """ + + @staticmethod + def axisinfo(unit, axis): + # docstring inherited + return None + + @staticmethod + def convert(value, unit, axis): + # docstring inherited + + if value == []: + return [] + + # we delay loading to make matplotlib happy + ax = axis.axes + if axis is ax.xaxis: + isXAxis = True + else: + isXAxis = False + + axis.get_major_ticks() + ticks = axis.get_ticklocs() + labels = axis.get_ticklabels() + + labels = [l.get_text() for l in labels if l.get_text()] + + if not labels: + ticks = [] + labels = [] + + if not np.iterable(value): + value = [value] + + newValues = [] + for v in value: + if v not in labels and v not in newValues: + newValues.append(v) + + labels.extend(newValues) + + # DISABLED: This is disabled because matplotlib bar plots do not + # DISABLED: recalculate the unit conversion of the data values + # DISABLED: this is due to design and is not really a bug. + # DISABLED: If this gets changed, then we can activate the following + # DISABLED: block of code. Note that this works for line plots. + # DISABLED if unit: + # DISABLED if unit.find("sorted") > -1: + # DISABLED labels.sort() + # DISABLED if unit.find("inverted") > -1: + # DISABLED labels = labels[::-1] + + # add padding (so they do not appear on the axes themselves) + labels = [''] + labels + [''] + ticks = list(range(len(labels))) + ticks[0] = 0.5 + ticks[-1] = ticks[-1] - 0.5 + + axis.set_ticks(ticks) + axis.set_ticklabels(labels) + # we have to do the following lines to make ax.autoscale_view work + loc = axis.get_major_locator() + loc.set_bounds(ticks[0], ticks[-1]) + + if isXAxis: + ax.set_xlim(ticks[0], ticks[-1]) + else: + ax.set_ylim(ticks[0], ticks[-1]) + + result = [ticks[labels.index(v)] for v in value] + + ax.viewLim.ignore(-1) + return result + + @staticmethod + def default_units(value, axis): + # docstring inherited + # The default behavior for string indexing. + return "indexed" diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDbl.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDbl.py new file mode 100644 index 00000000..5226c06a --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDbl.py @@ -0,0 +1,180 @@ +"""UnitDbl module.""" + +import functools +import operator + +from matplotlib import _api + + +class UnitDbl: + """Class UnitDbl in development.""" + + # Unit conversion table. Small subset of the full one but enough + # to test the required functions. First field is a scale factor to + # convert the input units to the units of the second field. Only + # units in this table are allowed. + allowed = { + "m": (0.001, "km"), + "km": (1, "km"), + "mile": (1.609344, "km"), + + "rad": (1, "rad"), + "deg": (1.745329251994330e-02, "rad"), + + "sec": (1, "sec"), + "min": (60.0, "sec"), + "hour": (3600, "sec"), + } + + _types = { + "km": "distance", + "rad": "angle", + "sec": "time", + } + + def __init__(self, value, units): + """ + Create a new UnitDbl object. + + Units are internally converted to km, rad, and sec. The only + valid inputs for units are [m, km, mile, rad, deg, sec, min, hour]. + + The field UnitDbl.value will contain the converted value. Use + the convert() method to get a specific type of units back. + + = ERROR CONDITIONS + - If the input units are not in the allowed list, an error is thrown. + + = INPUT VARIABLES + - value The numeric value of the UnitDbl. + - units The string name of the units the value is in. + """ + data = _api.check_getitem(self.allowed, units=units) + self._value = float(value * data[0]) + self._units = data[1] + + def convert(self, units): + """ + Convert the UnitDbl to a specific set of units. + + = ERROR CONDITIONS + - If the input units are not in the allowed list, an error is thrown. + + = INPUT VARIABLES + - units The string name of the units to convert to. + + = RETURN VALUE + - Returns the value of the UnitDbl in the requested units as a floating + point number. + """ + if self._units == units: + return self._value + data = _api.check_getitem(self.allowed, units=units) + if self._units != data[1]: + raise ValueError(f"Error trying to convert to different units.\n" + f" Invalid conversion requested.\n" + f" UnitDbl: {self}\n" + f" Units: {units}\n") + return self._value / data[0] + + def __abs__(self): + """Return the absolute value of this UnitDbl.""" + return UnitDbl(abs(self._value), self._units) + + def __neg__(self): + """Return the negative value of this UnitDbl.""" + return UnitDbl(-self._value, self._units) + + def __bool__(self): + """Return the truth value of a UnitDbl.""" + return bool(self._value) + + def _cmp(self, op, rhs): + """Check that *self* and *rhs* share units; compare them using *op*.""" + self.checkSameUnits(rhs, "compare") + return op(self._value, rhs._value) + + __eq__ = functools.partialmethod(_cmp, operator.eq) + __ne__ = functools.partialmethod(_cmp, operator.ne) + __lt__ = functools.partialmethod(_cmp, operator.lt) + __le__ = functools.partialmethod(_cmp, operator.le) + __gt__ = functools.partialmethod(_cmp, operator.gt) + __ge__ = functools.partialmethod(_cmp, operator.ge) + + def _binop_unit_unit(self, op, rhs): + """Check that *self* and *rhs* share units; combine them using *op*.""" + self.checkSameUnits(rhs, op.__name__) + return UnitDbl(op(self._value, rhs._value), self._units) + + __add__ = functools.partialmethod(_binop_unit_unit, operator.add) + __sub__ = functools.partialmethod(_binop_unit_unit, operator.sub) + + def _binop_unit_scalar(self, op, scalar): + """Combine *self* and *scalar* using *op*.""" + return UnitDbl(op(self._value, scalar), self._units) + + __mul__ = functools.partialmethod(_binop_unit_scalar, operator.mul) + __rmul__ = functools.partialmethod(_binop_unit_scalar, operator.mul) + + def __str__(self): + """Print the UnitDbl.""" + return f"{self._value:g} *{self._units}" + + def __repr__(self): + """Print the UnitDbl.""" + return f"UnitDbl({self._value:g}, '{self._units}')" + + def type(self): + """Return the type of UnitDbl data.""" + return self._types[self._units] + + @staticmethod + def range(start, stop, step=None): + """ + Generate a range of UnitDbl objects. + + Similar to the Python range() method. Returns the range [ + start, stop) at the requested step. Each element will be a + UnitDbl object. + + = INPUT VARIABLES + - start The starting value of the range. + - stop The stop value of the range. + - step Optional step to use. If set to None, then a UnitDbl of + value 1 w/ the units of the start is used. + + = RETURN VALUE + - Returns a list containing the requested UnitDbl values. + """ + if step is None: + step = UnitDbl(1, start._units) + + elems = [] + + i = 0 + while True: + d = start + i * step + if d >= stop: + break + + elems.append(d) + i += 1 + + return elems + + def checkSameUnits(self, rhs, func): + """ + Check to see if units are the same. + + = ERROR CONDITIONS + - If the units of the rhs UnitDbl are not the same as our units, + an error is thrown. + + = INPUT VARIABLES + - rhs The UnitDbl to check for the same units + - func The name of the function doing the check. + """ + if self._units != rhs._units: + raise ValueError(f"Cannot {func} units of different types.\n" + f"LHS: {self._units}\n" + f"RHS: {rhs._units}") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblConverter.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblConverter.py new file mode 100644 index 00000000..23065379 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblConverter.py @@ -0,0 +1,85 @@ +"""UnitDblConverter module containing class UnitDblConverter.""" + +import numpy as np + +from matplotlib import cbook, units +import matplotlib.projections.polar as polar + +__all__ = ['UnitDblConverter'] + + +# A special function for use with the matplotlib FuncFormatter class +# for formatting axes with radian units. +# This was copied from matplotlib example code. +def rad_fn(x, pos=None): + """Radian function formatter.""" + n = int((x / np.pi) * 2.0 + 0.25) + if n == 0: + return str(x) + elif n == 1: + return r'$\pi/2$' + elif n == 2: + return r'$\pi$' + elif n % 2 == 0: + return fr'${n//2}\pi$' + else: + return fr'${n}\pi/2$' + + +class UnitDblConverter(units.ConversionInterface): + """ + Provides Matplotlib conversion functionality for the Monte UnitDbl class. + """ + # default for plotting + defaults = { + "distance": 'km', + "angle": 'deg', + "time": 'sec', + } + + @staticmethod + def axisinfo(unit, axis): + # docstring inherited + + # Delay-load due to circular dependencies. + import matplotlib.testing.jpl_units as U + + # Check to see if the value used for units is a string unit value + # or an actual instance of a UnitDbl so that we can use the unit + # value for the default axis label value. + if unit: + label = unit if isinstance(unit, str) else unit.label() + else: + label = None + + if label == "deg" and isinstance(axis.axes, polar.PolarAxes): + # If we want degrees for a polar plot, use the PolarPlotFormatter + majfmt = polar.PolarAxes.ThetaFormatter() + else: + majfmt = U.UnitDblFormatter(useOffset=False) + + return units.AxisInfo(majfmt=majfmt, label=label) + + @staticmethod + def convert(value, unit, axis): + # docstring inherited + if not cbook.is_scalar_or_string(value): + return [UnitDblConverter.convert(x, unit, axis) for x in value] + # If no units were specified, then get the default units to use. + if unit is None: + unit = UnitDblConverter.default_units(value, axis) + # Convert the incoming UnitDbl value/values to float/floats + if isinstance(axis.axes, polar.PolarAxes) and value.type() == "angle": + # Guarantee that units are radians for polar plots. + return value.convert("rad") + return value.convert(unit) + + @staticmethod + def default_units(value, axis): + # docstring inherited + # Determine the default units based on the user preferences set for + # default units when printing a UnitDbl. + if cbook.is_scalar_or_string(value): + return UnitDblConverter.defaults[value.type()] + else: + return UnitDblConverter.default_units(value[0], axis) diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblFormatter.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblFormatter.py new file mode 100644 index 00000000..30a99140 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDblFormatter.py @@ -0,0 +1,28 @@ +"""UnitDblFormatter module containing class UnitDblFormatter.""" + +import matplotlib.ticker as ticker + +__all__ = ['UnitDblFormatter'] + + +class UnitDblFormatter(ticker.ScalarFormatter): + """ + The formatter for UnitDbl data types. + + This allows for formatting with the unit string. + """ + + def __call__(self, x, pos=None): + # docstring inherited + if len(self.locs) == 0: + return '' + else: + return f'{x:.12}' + + def format_data_short(self, value): + # docstring inherited + return f'{value:.12}' + + def format_data(self, value): + # docstring inherited + return f'{value:.12}' diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/__init__.py new file mode 100644 index 00000000..b8caa9a8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/__init__.py @@ -0,0 +1,76 @@ +""" +A sample set of units for use with testing unit conversion +of Matplotlib routines. These are used because they use very strict +enforcement of unitized data which will test the entire spectrum of how +unitized data might be used (it is not always meaningful to convert to +a float without specific units given). + +UnitDbl is essentially a unitized floating point number. It has a +minimal set of supported units (enough for testing purposes). All +of the mathematical operation are provided to fully test any behaviour +that might occur with unitized data. Remember that unitized data has +rules as to how it can be applied to one another (a value of distance +cannot be added to a value of time). Thus we need to guard against any +accidental "default" conversion that will strip away the meaning of the +data and render it neutered. + +Epoch is different than a UnitDbl of time. Time is something that can be +measured where an Epoch is a specific moment in time. Epochs are typically +referenced as an offset from some predetermined epoch. + +A difference of two epochs is a Duration. The distinction between a Duration +and a UnitDbl of time is made because an Epoch can have different frames (or +units). In the case of our test Epoch class the two allowed frames are 'UTC' +and 'ET' (Note that these are rough estimates provided for testing purposes +and should not be used in production code where accuracy of time frames is +desired). As such a Duration also has a frame of reference and therefore needs +to be called out as different that a simple measurement of time since a delta-t +in one frame may not be the same in another. +""" + +from .Duration import Duration +from .Epoch import Epoch +from .UnitDbl import UnitDbl + +from .StrConverter import StrConverter +from .EpochConverter import EpochConverter +from .UnitDblConverter import UnitDblConverter + +from .UnitDblFormatter import UnitDblFormatter + + +__version__ = "1.0" + +__all__ = [ + 'register', + 'Duration', + 'Epoch', + 'UnitDbl', + 'UnitDblFormatter', + ] + + +def register(): + """Register the unit conversion classes with matplotlib.""" + import matplotlib.units as mplU + + mplU.registry[str] = StrConverter() + mplU.registry[Epoch] = EpochConverter() + mplU.registry[Duration] = EpochConverter() + mplU.registry[UnitDbl] = UnitDblConverter() + + +# Some default unit instances +# Distances +m = UnitDbl(1.0, "m") +km = UnitDbl(1.0, "km") +mile = UnitDbl(1.0, "mile") +# Angles +deg = UnitDbl(1.0, "deg") +rad = UnitDbl(1.0, "rad") +# Time +sec = UnitDbl(1.0, "sec") +min = UnitDbl(1.0, "min") +hr = UnitDbl(1.0, "hour") +day = UnitDbl(24.0, "hour") +sec = UnitDbl(1.0, "sec") diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.py b/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.py new file mode 100644 index 00000000..748cdacc --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.py @@ -0,0 +1,119 @@ +""" +======================== +Widget testing utilities +======================== + +See also :mod:`matplotlib.tests.test_widgets`. +""" + +from unittest import mock + +import matplotlib.pyplot as plt + + +def get_ax(): + """Create a plot and return its Axes.""" + fig, ax = plt.subplots(1, 1) + ax.plot([0, 200], [0, 200]) + ax.set_aspect(1.0) + ax.figure.canvas.draw() + return ax + + +def noop(*args, **kwargs): + pass + + +def mock_event(ax, button=1, xdata=0, ydata=0, key=None, step=1): + r""" + Create a mock event that can stand in for `.Event` and its subclasses. + + This event is intended to be used in tests where it can be passed into + event handling functions. + + Parameters + ---------- + ax : `~matplotlib.axes.Axes` + The Axes the event will be in. + xdata : float + x coord of mouse in data coords. + ydata : float + y coord of mouse in data coords. + button : None or `MouseButton` or {'up', 'down'} + The mouse button pressed in this event (see also `.MouseEvent`). + key : None or str + The key pressed when the mouse event triggered (see also `.KeyEvent`). + step : int + Number of scroll steps (positive for 'up', negative for 'down'). + + Returns + ------- + event + A `.Event`\-like Mock instance. + """ + event = mock.Mock() + event.button = button + event.x, event.y = ax.transData.transform([(xdata, ydata), + (xdata, ydata)])[0] + event.xdata, event.ydata = xdata, ydata + event.inaxes = ax + event.canvas = ax.figure.canvas + event.key = key + event.step = step + event.guiEvent = None + event.name = 'Custom' + return event + + +def do_event(tool, etype, button=1, xdata=0, ydata=0, key=None, step=1): + """ + Trigger an event on the given tool. + + Parameters + ---------- + tool : matplotlib.widgets.AxesWidget + etype : str + The event to trigger. + xdata : float + x coord of mouse in data coords. + ydata : float + y coord of mouse in data coords. + button : None or `MouseButton` or {'up', 'down'} + The mouse button pressed in this event (see also `.MouseEvent`). + key : None or str + The key pressed when the mouse event triggered (see also `.KeyEvent`). + step : int + Number of scroll steps (positive for 'up', negative for 'down'). + """ + event = mock_event(tool.ax, button, xdata, ydata, key, step) + func = getattr(tool, etype) + func(event) + + +def click_and_drag(tool, start, end, key=None): + """ + Helper to simulate a mouse drag operation. + + Parameters + ---------- + tool : `~matplotlib.widgets.Widget` + start : [float, float] + Starting point in data coordinates. + end : [float, float] + End point in data coordinates. + key : None or str + An optional key that is pressed during the whole operation + (see also `.KeyEvent`). + """ + if key is not None: + # Press key + do_event(tool, 'on_key_press', xdata=start[0], ydata=start[1], + button=1, key=key) + # Click, move, and release mouse + do_event(tool, 'press', xdata=start[0], ydata=start[1], button=1) + do_event(tool, 'onmove', xdata=end[0], ydata=end[1], button=1) + do_event(tool, 'release', xdata=end[0], ydata=end[1], button=1) + if key is not None: + # Release key + do_event(tool, 'on_key_release', xdata=end[0], ydata=end[1], + button=1, key=key) diff --git a/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.pyi b/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.pyi new file mode 100644 index 00000000..858ff457 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.pyi @@ -0,0 +1,31 @@ +from typing import Any, Literal + +from matplotlib.axes import Axes +from matplotlib.backend_bases import Event, MouseButton +from matplotlib.widgets import AxesWidget, Widget + +def get_ax() -> Axes: ... +def noop(*args: Any, **kwargs: Any) -> None: ... +def mock_event( + ax: Axes, + button: MouseButton | int | Literal["up", "down"] | None = ..., + xdata: float = ..., + ydata: float = ..., + key: str | None = ..., + step: int = ..., +) -> Event: ... +def do_event( + tool: AxesWidget, + etype: str, + button: MouseButton | int | Literal["up", "down"] | None = ..., + xdata: float = ..., + ydata: float = ..., + key: str | None = ..., + step: int = ..., +) -> None: ... +def click_and_drag( + tool: Widget, + start: tuple[float, float], + end: tuple[float, float], + key: str | None = ..., +) -> None: ... diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/__init__.py b/venv/lib/python3.10/site-packages/matplotlib/tests/__init__.py new file mode 100644 index 00000000..8cce4fe4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/__init__.py @@ -0,0 +1,10 @@ +from pathlib import Path + + +# Check that the test directories exist. +if not (Path(__file__).parent / 'baseline_images').exists(): + raise OSError( + 'The baseline image directory does not exist. ' + 'This is most likely because the test data is not installed. ' + 'You may need to install matplotlib from source to get the ' + 'test data.') diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/conftest.py b/venv/lib/python3.10/site-packages/matplotlib/tests/conftest.py new file mode 100644 index 00000000..54a1bc6c --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/conftest.py @@ -0,0 +1,2 @@ +from matplotlib.testing.conftest import ( # noqa + mpl_test_settings, pytest_configure, pytest_unconfigure, pd, xr) diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/test_afm.py b/venv/lib/python3.10/site-packages/matplotlib/tests/test_afm.py new file mode 100644 index 00000000..e5c6a839 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/test_afm.py @@ -0,0 +1,137 @@ +from io import BytesIO +import pytest +import logging + +from matplotlib import _afm +from matplotlib import font_manager as fm + + +# See note in afm.py re: use of comma as decimal separator in the +# UnderlineThickness field and re: use of non-ASCII characters in the Notice +# field. +AFM_TEST_DATA = b"""StartFontMetrics 2.0 +Comment Comments are ignored. +Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017 +FontName MyFont-Bold +EncodingScheme FontSpecific +FullName My Font Bold +FamilyName Test Fonts +Weight Bold +ItalicAngle 0.0 +IsFixedPitch false +UnderlinePosition -100 +UnderlineThickness 56,789 +Version 001.000 +Notice Copyright \xa9 2017 No one. +FontBBox 0 -321 1234 369 +StartCharMetrics 3 +C 0 ; WX 250 ; N space ; B 0 0 0 0 ; +C 42 ; WX 1141 ; N foo ; B 40 60 800 360 ; +C 99 ; WX 583 ; N bar ; B 40 -10 543 210 ; +EndCharMetrics +EndFontMetrics +""" + + +def test_nonascii_str(): + # This tests that we also decode bytes as utf-8 properly. + # Else, font files with non ascii characters fail to load. + inp_str = "привет" + byte_str = inp_str.encode("utf8") + + ret = _afm._to_str(byte_str) + assert ret == inp_str + + +def test_parse_header(): + fh = BytesIO(AFM_TEST_DATA) + header = _afm._parse_header(fh) + assert header == { + b'StartFontMetrics': 2.0, + b'FontName': 'MyFont-Bold', + b'EncodingScheme': 'FontSpecific', + b'FullName': 'My Font Bold', + b'FamilyName': 'Test Fonts', + b'Weight': 'Bold', + b'ItalicAngle': 0.0, + b'IsFixedPitch': False, + b'UnderlinePosition': -100, + b'UnderlineThickness': 56.789, + b'Version': '001.000', + b'Notice': b'Copyright \xa9 2017 No one.', + b'FontBBox': [0, -321, 1234, 369], + b'StartCharMetrics': 3, + } + + +def test_parse_char_metrics(): + fh = BytesIO(AFM_TEST_DATA) + _afm._parse_header(fh) # position + metrics = _afm._parse_char_metrics(fh) + assert metrics == ( + {0: (250.0, 'space', [0, 0, 0, 0]), + 42: (1141.0, 'foo', [40, 60, 800, 360]), + 99: (583.0, 'bar', [40, -10, 543, 210]), + }, + {'space': (250.0, 'space', [0, 0, 0, 0]), + 'foo': (1141.0, 'foo', [40, 60, 800, 360]), + 'bar': (583.0, 'bar', [40, -10, 543, 210]), + }) + + +def test_get_familyname_guessed(): + fh = BytesIO(AFM_TEST_DATA) + font = _afm.AFM(fh) + del font._header[b'FamilyName'] # remove FamilyName, so we have to guess + assert font.get_familyname() == 'My Font' + + +def test_font_manager_weight_normalization(): + font = _afm.AFM(BytesIO( + AFM_TEST_DATA.replace(b"Weight Bold\n", b"Weight Custom\n"))) + assert fm.afmFontProperty("", font).weight == "normal" + + +@pytest.mark.parametrize( + "afm_data", + [ + b"""nope +really nope""", + b"""StartFontMetrics 2.0 +Comment Comments are ignored. +Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017 +FontName MyFont-Bold +EncodingScheme FontSpecific""", + ], +) +def test_bad_afm(afm_data): + fh = BytesIO(afm_data) + with pytest.raises(RuntimeError): + _afm._parse_header(fh) + + +@pytest.mark.parametrize( + "afm_data", + [ + b"""StartFontMetrics 2.0 +Comment Comments are ignored. +Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017 +Aardvark bob +FontName MyFont-Bold +EncodingScheme FontSpecific +StartCharMetrics 3""", + b"""StartFontMetrics 2.0 +Comment Comments are ignored. +Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017 +ItalicAngle zero degrees +FontName MyFont-Bold +EncodingScheme FontSpecific +StartCharMetrics 3""", + ], +) +def test_malformed_header(afm_data, caplog): + fh = BytesIO(afm_data) + with caplog.at_level(logging.ERROR): + _afm._parse_header(fh) + + assert len(caplog.records) == 1 diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg.py b/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg.py new file mode 100644 index 00000000..6ca74ed4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg.py @@ -0,0 +1,338 @@ +import io + +import numpy as np +from numpy.testing import assert_array_almost_equal +from PIL import Image, TiffTags +import pytest + + +from matplotlib import ( + collections, patheffects, pyplot as plt, transforms as mtransforms, + rcParams, rc_context) +from matplotlib.backends.backend_agg import RendererAgg +from matplotlib.figure import Figure +from matplotlib.image import imread +from matplotlib.path import Path +from matplotlib.testing.decorators import image_comparison +from matplotlib.transforms import IdentityTransform + + +def test_repeated_save_with_alpha(): + # We want an image which has a background color of bluish green, with an + # alpha of 0.25. + + fig = Figure([1, 0.4]) + fig.set_facecolor((0, 1, 0.4)) + fig.patch.set_alpha(0.25) + + # The target color is fig.patch.get_facecolor() + + buf = io.BytesIO() + + fig.savefig(buf, + facecolor=fig.get_facecolor(), + edgecolor='none') + + # Save the figure again to check that the + # colors don't bleed from the previous renderer. + buf.seek(0) + fig.savefig(buf, + facecolor=fig.get_facecolor(), + edgecolor='none') + + # Check the first pixel has the desired color & alpha + # (approx: 0, 1.0, 0.4, 0.25) + buf.seek(0) + assert_array_almost_equal(tuple(imread(buf)[0, 0]), + (0.0, 1.0, 0.4, 0.250), + decimal=3) + + +def test_large_single_path_collection(): + buff = io.BytesIO() + + # Generates a too-large single path in a path collection that + # would cause a segfault if the draw_markers optimization is + # applied. + f, ax = plt.subplots() + collection = collections.PathCollection( + [Path([[-10, 5], [10, 5], [10, -5], [-10, -5], [-10, 5]])]) + ax.add_artist(collection) + ax.set_xlim(10**-3, 1) + plt.savefig(buff) + + +def test_marker_with_nan(): + # This creates a marker with nans in it, which was segfaulting the + # Agg backend (see #3722) + fig, ax = plt.subplots(1) + steps = 1000 + data = np.arange(steps) + ax.semilogx(data) + ax.fill_between(data, data*0.8, data*1.2) + buf = io.BytesIO() + fig.savefig(buf, format='png') + + +def test_long_path(): + buff = io.BytesIO() + fig = Figure() + ax = fig.subplots() + points = np.ones(100_000) + points[::2] *= -1 + ax.plot(points) + fig.savefig(buff, format='png') + + +@image_comparison(['agg_filter.png'], remove_text=True) +def test_agg_filter(): + def smooth1d(x, window_len): + # copied from https://scipy-cookbook.readthedocs.io/ + s = np.r_[ + 2*x[0] - x[window_len:1:-1], x, 2*x[-1] - x[-1:-window_len:-1]] + w = np.hanning(window_len) + y = np.convolve(w/w.sum(), s, mode='same') + return y[window_len-1:-window_len+1] + + def smooth2d(A, sigma=3): + window_len = max(int(sigma), 3) * 2 + 1 + A = np.apply_along_axis(smooth1d, 0, A, window_len) + A = np.apply_along_axis(smooth1d, 1, A, window_len) + return A + + class BaseFilter: + + def get_pad(self, dpi): + return 0 + + def process_image(self, padded_src, dpi): + raise NotImplementedError("Should be overridden by subclasses") + + def __call__(self, im, dpi): + pad = self.get_pad(dpi) + padded_src = np.pad(im, [(pad, pad), (pad, pad), (0, 0)], + "constant") + tgt_image = self.process_image(padded_src, dpi) + return tgt_image, -pad, -pad + + class OffsetFilter(BaseFilter): + + def __init__(self, offsets=(0, 0)): + self.offsets = offsets + + def get_pad(self, dpi): + return int(max(self.offsets) / 72 * dpi) + + def process_image(self, padded_src, dpi): + ox, oy = self.offsets + a1 = np.roll(padded_src, int(ox / 72 * dpi), axis=1) + a2 = np.roll(a1, -int(oy / 72 * dpi), axis=0) + return a2 + + class GaussianFilter(BaseFilter): + """Simple Gaussian filter.""" + + def __init__(self, sigma, alpha=0.5, color=(0, 0, 0)): + self.sigma = sigma + self.alpha = alpha + self.color = color + + def get_pad(self, dpi): + return int(self.sigma*3 / 72 * dpi) + + def process_image(self, padded_src, dpi): + tgt_image = np.empty_like(padded_src) + tgt_image[:, :, :3] = self.color + tgt_image[:, :, 3] = smooth2d(padded_src[:, :, 3] * self.alpha, + self.sigma / 72 * dpi) + return tgt_image + + class DropShadowFilter(BaseFilter): + + def __init__(self, sigma, alpha=0.3, color=(0, 0, 0), offsets=(0, 0)): + self.gauss_filter = GaussianFilter(sigma, alpha, color) + self.offset_filter = OffsetFilter(offsets) + + def get_pad(self, dpi): + return max(self.gauss_filter.get_pad(dpi), + self.offset_filter.get_pad(dpi)) + + def process_image(self, padded_src, dpi): + t1 = self.gauss_filter.process_image(padded_src, dpi) + t2 = self.offset_filter.process_image(t1, dpi) + return t2 + + fig, ax = plt.subplots() + + # draw lines + line1, = ax.plot([0.1, 0.5, 0.9], [0.1, 0.9, 0.5], "bo-", + mec="b", mfc="w", lw=5, mew=3, ms=10, label="Line 1") + line2, = ax.plot([0.1, 0.5, 0.9], [0.5, 0.2, 0.7], "ro-", + mec="r", mfc="w", lw=5, mew=3, ms=10, label="Line 1") + + gauss = DropShadowFilter(4) + + for line in [line1, line2]: + + # draw shadows with same lines with slight offset. + xx = line.get_xdata() + yy = line.get_ydata() + shadow, = ax.plot(xx, yy) + shadow.update_from(line) + + # offset transform + transform = mtransforms.offset_copy(line.get_transform(), ax.figure, + x=4.0, y=-6.0, units='points') + shadow.set_transform(transform) + + # adjust zorder of the shadow lines so that it is drawn below the + # original lines + shadow.set_zorder(line.get_zorder() - 0.5) + shadow.set_agg_filter(gauss) + shadow.set_rasterized(True) # to support mixed-mode renderers + + ax.set_xlim(0., 1.) + ax.set_ylim(0., 1.) + + ax.xaxis.set_visible(False) + ax.yaxis.set_visible(False) + + +def test_too_large_image(): + fig = plt.figure(figsize=(300, 1000)) + buff = io.BytesIO() + with pytest.raises(ValueError): + fig.savefig(buff) + + +def test_chunksize(): + x = range(200) + + # Test without chunksize + fig, ax = plt.subplots() + ax.plot(x, np.sin(x)) + fig.canvas.draw() + + # Test with chunksize + fig, ax = plt.subplots() + rcParams['agg.path.chunksize'] = 105 + ax.plot(x, np.sin(x)) + fig.canvas.draw() + + +@pytest.mark.backend('Agg') +def test_jpeg_dpi(): + # Check that dpi is set correctly in jpg files. + plt.plot([0, 1, 2], [0, 1, 0]) + buf = io.BytesIO() + plt.savefig(buf, format="jpg", dpi=200) + im = Image.open(buf) + assert im.info['dpi'] == (200, 200) + + +def test_pil_kwargs_png(): + from PIL.PngImagePlugin import PngInfo + buf = io.BytesIO() + pnginfo = PngInfo() + pnginfo.add_text("Software", "test") + plt.figure().savefig(buf, format="png", pil_kwargs={"pnginfo": pnginfo}) + im = Image.open(buf) + assert im.info["Software"] == "test" + + +def test_pil_kwargs_tiff(): + buf = io.BytesIO() + pil_kwargs = {"description": "test image"} + plt.figure().savefig(buf, format="tiff", pil_kwargs=pil_kwargs) + im = Image.open(buf) + tags = {TiffTags.TAGS_V2[k].name: v for k, v in im.tag_v2.items()} + assert tags["ImageDescription"] == "test image" + + +def test_pil_kwargs_webp(): + plt.plot([0, 1, 2], [0, 1, 0]) + buf_small = io.BytesIO() + pil_kwargs_low = {"quality": 1} + plt.savefig(buf_small, format="webp", pil_kwargs=pil_kwargs_low) + assert len(pil_kwargs_low) == 1 + buf_large = io.BytesIO() + pil_kwargs_high = {"quality": 100} + plt.savefig(buf_large, format="webp", pil_kwargs=pil_kwargs_high) + assert len(pil_kwargs_high) == 1 + assert buf_large.getbuffer().nbytes > buf_small.getbuffer().nbytes + + +def test_webp_alpha(): + plt.plot([0, 1, 2], [0, 1, 0]) + buf = io.BytesIO() + plt.savefig(buf, format="webp", transparent=True) + im = Image.open(buf) + assert im.mode == "RGBA" + + +def test_draw_path_collection_error_handling(): + fig, ax = plt.subplots() + ax.scatter([1], [1]).set_paths(Path([(0, 1), (2, 3)])) + with pytest.raises(TypeError): + fig.canvas.draw() + + +def test_chunksize_fails(): + # NOTE: This test covers multiple independent test scenarios in a single + # function, because each scenario uses ~2GB of memory and we don't + # want parallel test executors to accidentally run multiple of these + # at the same time. + + N = 100_000 + dpi = 500 + w = 5*dpi + h = 6*dpi + + # make a Path that spans the whole w-h rectangle + x = np.linspace(0, w, N) + y = np.ones(N) * h + y[::2] = 0 + path = Path(np.vstack((x, y)).T) + # effectively disable path simplification (but leaving it "on") + path.simplify_threshold = 0 + + # setup the minimal GraphicsContext to draw a Path + ra = RendererAgg(w, h, dpi) + gc = ra.new_gc() + gc.set_linewidth(1) + gc.set_foreground('r') + + gc.set_hatch('/') + with pytest.raises(OverflowError, match='cannot split hatched path'): + ra.draw_path(gc, path, IdentityTransform()) + gc.set_hatch(None) + + with pytest.raises(OverflowError, match='cannot split filled path'): + ra.draw_path(gc, path, IdentityTransform(), (1, 0, 0)) + + # Set to zero to disable, currently defaults to 0, but let's be sure. + with rc_context({'agg.path.chunksize': 0}): + with pytest.raises(OverflowError, match='Please set'): + ra.draw_path(gc, path, IdentityTransform()) + + # Set big enough that we do not try to chunk. + with rc_context({'agg.path.chunksize': 1_000_000}): + with pytest.raises(OverflowError, match='Please reduce'): + ra.draw_path(gc, path, IdentityTransform()) + + # Small enough we will try to chunk, but big enough we will fail to render. + with rc_context({'agg.path.chunksize': 90_000}): + with pytest.raises(OverflowError, match='Please reduce'): + ra.draw_path(gc, path, IdentityTransform()) + + path.should_simplify = False + with pytest.raises(OverflowError, match="should_simplify is False"): + ra.draw_path(gc, path, IdentityTransform()) + + +def test_non_tuple_rgbaface(): + # This passes rgbaFace as a ndarray to draw_path. + fig = plt.figure() + fig.add_subplot(projection="3d").scatter( + [0, 1, 2], [0, 1, 2], path_effects=[patheffects.Stroke(linewidth=4)]) + fig.canvas.draw() diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg_filter.py b/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg_filter.py new file mode 100644 index 00000000..dc8cff68 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/test_agg_filter.py @@ -0,0 +1,33 @@ +import numpy as np + +import matplotlib.pyplot as plt +from matplotlib.testing.decorators import image_comparison + + +@image_comparison(baseline_images=['agg_filter_alpha'], + extensions=['png', 'pdf']) +def test_agg_filter_alpha(): + # Remove this line when this test image is regenerated. + plt.rcParams['pcolormesh.snap'] = False + + ax = plt.axes() + x, y = np.mgrid[0:7, 0:8] + data = x**2 - y**2 + mesh = ax.pcolormesh(data, cmap='Reds', zorder=5) + + def manual_alpha(im, dpi): + im[:, :, 3] *= 0.6 + print('CALLED') + return im, 0, 0 + + # Note: Doing alpha like this is not the same as setting alpha on + # the mesh itself. Currently meshes are drawn as independent patches, + # and we see fine borders around the blocks of color. See the SO + # question for an example: https://stackoverflow.com/q/20678817/ + mesh.set_agg_filter(manual_alpha) + + # Currently we must enable rasterization for this to have an effect in + # the PDF backend. + mesh.set_rasterized(True) + + ax.plot([0, 4, 7], [1, 3, 8]) diff --git a/venv/lib/python3.10/site-packages/matplotlib/tests/test_animation.py b/venv/lib/python3.10/site-packages/matplotlib/tests/test_animation.py new file mode 100644 index 00000000..d026dae5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/matplotlib/tests/test_animation.py @@ -0,0 +1,553 @@ +import os +from pathlib import Path +import platform +import re +import shutil +import subprocess +import sys +import weakref + +import numpy as np +import pytest + +import matplotlib as mpl +from matplotlib import pyplot as plt +from matplotlib import animation +from matplotlib.testing.decorators import check_figures_equal + + +@pytest.fixture() +def anim(request): + """Create a simple animation (with options).""" + fig, ax = plt.subplots() + line, = ax.plot([], []) + + ax.set_xlim(0, 10) + ax.set_ylim(-1, 1) + + def init(): + line.set_data([], []) + return line, + + def animate(i): + x = np.linspace(0, 10, 100) + y = np.sin(x + i) + line.set_data(x, y) + return line, + + # "klass" can be passed to determine the class returned by the fixture + kwargs = dict(getattr(request, 'param', {})) # make a copy + klass = kwargs.pop('klass', animation.FuncAnimation) + if 'frames' not in kwargs: + kwargs['frames'] = 5 + return klass(fig=fig, func=animate, init_func=init, **kwargs) + + +class NullMovieWriter(animation.AbstractMovieWriter): + """ + A minimal MovieWriter. It doesn't actually write anything. + It just saves the arguments that were given to the setup() and + grab_frame() methods as attributes, and counts how many times + grab_frame() is called. + + This class doesn't have an __init__ method with the appropriate + signature, and it doesn't define an isAvailable() method, so + it cannot be added to the 'writers' registry. + """ + + def setup(self, fig, outfile, dpi, *args): + self.fig = fig + self.outfile = outfile + self.dpi = dpi + self.args = args + self._count = 0 + + def grab_frame(self, **savefig_kwargs): + from matplotlib.animation import _validate_grabframe_kwargs + _validate_grabframe_kwargs(savefig_kwargs) + self.savefig_kwargs = savefig_kwargs + self._count += 1 + + def finish(self): + pass + + +def test_null_movie_writer(anim): + # Test running an animation with NullMovieWriter. + plt.rcParams["savefig.facecolor"] = "auto" + filename = "unused.null" + dpi = 50 + savefig_kwargs = dict(foo=0) + writer = NullMovieWriter() + + anim.save(filename, dpi=dpi, writer=writer, + savefig_kwargs=savefig_kwargs) + + assert writer.fig == plt.figure(1) # The figure used by anim fixture + assert writer.outfile == filename + assert writer.dpi == dpi + assert writer.args == () + # we enrich the savefig kwargs to ensure we composite transparent + # output to an opaque background + for k, v in savefig_kwargs.items(): + assert writer.savefig_kwargs[k] == v + assert writer._count == anim._save_count + + +@pytest.mark.parametrize('anim', [dict(klass=dict)], indirect=['anim']) +def test_animation_delete(anim): + if platform.python_implementation() == 'PyPy': + # Something in the test setup fixture lingers around into the test and + # breaks pytest.warns on PyPy. This garbage collection fixes it. + # https://foss.heptapod.net/pypy/pypy/-/issues/3536 + np.testing.break_cycles() + anim = animation.FuncAnimation(**anim) + with pytest.warns(Warning, match='Animation was deleted'): + del anim + np.testing.break_cycles() + + +def test_movie_writer_dpi_default(): + class DummyMovieWriter(animation.MovieWriter): + def _run(self): + pass + + # Test setting up movie writer with figure.dpi default. + fig = plt.figure() + + filename = "unused.null" + fps = 5 + codec = "unused" + bitrate = 1 + extra_args = ["unused"] + + writer = DummyMovieWriter(fps, codec, bitrate, extra_args) + writer.setup(fig, filename) + assert writer.dpi == fig.dpi + + +@animation.writers.register('null') +class RegisteredNullMovieWriter(NullMovieWriter): + + # To be able to add NullMovieWriter to the 'writers' registry, + # we must define an __init__ method with a specific signature, + # and we must define the class method isAvailable(). + # (These methods are not actually required to use an instance + # of this class as the 'writer' argument of Animation.save().) + + def __init__(self, fps=None, codec=None, bitrate=None, + extra_args=None, metadata=None): + pass + + @classmethod + def isAvailable(cls): + return True + + +WRITER_OUTPUT = [ + ('ffmpeg', 'movie.mp4'), + ('ffmpeg_file', 'movie.mp4'), + ('imagemagick', 'movie.gif'), + ('imagemagick_file', 'movie.gif'), + ('pillow', 'movie.gif'), + ('html', 'movie.html'), + ('null', 'movie.null') +] + + +def gen_writers(): + for writer, output in WRITER_OUTPUT: + if not animation.writers.is_available(writer): + mark = pytest.mark.skip( + f"writer '{writer}' not available on this system") + yield pytest.param(writer, None, output, marks=[mark]) + yield pytest.param(writer, None, Path(output), marks=[mark]) + continue + + writer_class = animation.writers[writer] + for frame_format in getattr(writer_class, 'supported_formats', [None]): + yield writer, frame_format, output + yield writer, frame_format, Path(output) + + +# Smoke test for saving animations. In the future, we should probably +# design more sophisticated tests which compare resulting frames a-la +# matplotlib.testing.image_comparison +@pytest.mark.parametrize('writer, frame_format, output', gen_writers()) +@pytest.mark.parametrize('anim', [dict(klass=dict)], indirect=['anim']) +def test_save_animation_smoketest(tmpdir, writer, frame_format, output, anim): + if frame_format is not None: + plt.rcParams["animation.frame_format"] = frame_format + anim = animation.FuncAnimation(**anim) + dpi = None + codec = None + if writer == 'ffmpeg': + # Issue #8253 + anim._fig.set_size_inches((10.85, 9.21)) + dpi = 100. + codec = 'h264' + + # Use temporary directory for the file-based writers, which produce a file + # per frame with known names. + with tmpdir.as_cwd(): + anim.save(output, fps=30, writer=writer, bitrate=500, dpi=dpi, + codec=codec) + + del anim + + +@pytest.mark.parametrize('writer, frame_format, output', gen_writers()) +def test_grabframe(tmpdir, writer, frame_format, output): + WriterClass = animation.writers[writer] + + if frame_format is not None: + plt.rcParams["animation.frame_format"] = frame_format + + fig, ax = plt.subplots() + + dpi = None + codec = None + if writer == 'ffmpeg': + # Issue #8253 + fig.set_size_inches((10.85, 9.21)) + dpi = 100. + codec = 'h264' + + test_writer = WriterClass() + # Use temporary directory for the file-based writers, which produce a file + # per frame with known names. + with tmpdir.as_cwd(): + with test_writer.saving(fig, output, dpi): + # smoke test it works + test_writer.grab_frame() + for k in {'dpi', 'bbox_inches', 'format'}: + with pytest.raises( + TypeError, + match=f"grab_frame got an unexpected keyword argument {k!r}" + ): + test_writer.grab_frame(**{k: object()}) + + +@pytest.mark.parametrize('writer', [ + pytest.param( + 'ffmpeg', marks=pytest.mark.skipif( + not animation.FFMpegWriter.isAvailable(), + reason='Requires FFMpeg')), + pytest.param( + 'imagemagick', marks=pytest.mark.skipif( + not animation.ImageMagickWriter.isAvailable(), + reason='Requires ImageMagick')), +]) +@pytest.mark.parametrize('html, want', [ + ('none', None), + ('html5', '