├── .github ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── macos-build.yml │ ├── release.yml │ └── windows-build.yml ├── .gitignore ├── CHANGELOG.md ├── COC.md ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── dev-requirements.txt ├── docs └── MAINTAINER.md ├── icons ├── 1024.png ├── 128.png ├── 16.png ├── 256.png ├── 32.png ├── 512.png ├── 64.png ├── Icon.icns ├── Icon.ico └── Icon.iconset │ ├── icon_1024x1024.png │ ├── icon_128x128.png │ ├── icon_128x128@2x.png │ ├── icon_16x16.png │ ├── icon_16x16@2x.png │ ├── icon_256x256.png │ ├── icon_256x256@2x.png │ ├── icon_32x32.png │ ├── icon_32x32@2x.png │ ├── icon_512x512.png │ ├── icon_512x512@2x.png │ ├── icon_64x64.png │ └── icon_64x64@2x.png ├── requirements.in ├── requirements.txt ├── setup.cfg ├── setup.py ├── src ├── build │ └── settings │ │ ├── base.json │ │ └── macos.json ├── resources │ ├── fonts │ │ ├── IBMPlexMono-Regular.ttf │ │ ├── RecursiveSans-Slice_mod.subset.ttf │ │ └── font-resources.qrc │ └── img │ │ ├── image-resources.qrc │ │ └── slice-icon.svg ├── run.py └── slice │ ├── __init__.py │ ├── __main__.py │ ├── fontresources.py │ ├── imageresources.py │ ├── instanceworker.py │ ├── models.py │ └── ui │ ├── __init__.py │ ├── dialogs.py │ └── widgets.py ├── target ├── InnoSetup-Windows │ └── Slice-Installer.iss ├── PyInstaller-Windows │ └── Slice-Windows.spec └── PyInstaller-macOS │ └── Slice-macOS.spec ├── tests ├── assets │ └── fonts │ │ ├── Recursive-Sliced.subset.ttf │ │ ├── Recursive-VF.subset.ttf │ │ ├── Recursive-VF.subset.woff │ │ └── Recursive-VF.subset.woff2 ├── test_instanceworker.py ├── test_models_designaxis.py ├── test_models_fontbitflag.py ├── test_models_fontmodel.py ├── test_models_fontname.py └── test_widgets.py ├── thirdparty ├── Flaticon-License.txt ├── IBMPlex-OFL.txt ├── README.md └── Recursive-OFL.txt └── tox.ini /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '40 10 * * 1' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | language: [ 'python' ] 32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 33 | # Learn more: 34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v2 39 | 40 | # Initializes the CodeQL tools for scanning. 41 | - name: Initialize CodeQL 42 | uses: github/codeql-action/init@v1 43 | with: 44 | languages: ${{ matrix.language }} 45 | # If you wish to specify custom queries, you can do so here or in a config file. 46 | # By default, queries listed here will override any specified in a config file. 47 | # Prefix the list here with "+" to use these queries and those in the config file. 48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 49 | 50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 51 | # If this step fails, then you should remove it and run the build manually (see below) 52 | - name: Autobuild 53 | uses: github/codeql-action/autobuild@v1 54 | 55 | # ℹ️ Command-line programs to run using the OS shell. 56 | # 📚 https://git.io/JvXDl 57 | 58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 59 | # and modify them (or add more) to build your code if your project 60 | # uses a compiled language 61 | 62 | #- run: | 63 | # make bootstrap 64 | # make release 65 | 66 | - name: Perform CodeQL Analysis 67 | uses: github/codeql-action/analyze@v1 68 | -------------------------------------------------------------------------------- /.github/workflows/macos-build.yml: -------------------------------------------------------------------------------- 1 | name: macOS Build 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | os: [macos-latest] 11 | python-version: [3.9] 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up Python ${{ matrix.python-version }} 16 | uses: actions/setup-python@v2 17 | with: 18 | python-version: ${{ matrix.python-version }} 19 | - name: Display Python version & architecture 20 | run: | 21 | python -c "import sys; print(sys.version)" 22 | python -c "import struct; print(struct.calcsize('P') * 8)" 23 | - name: Install dependencies 24 | run: | 25 | pip install --upgrade pip wheel setuptools 26 | pip install -r requirements.txt 27 | - name: PyInstaller build 28 | run: make build-macos 29 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | # Sequence of patterns matched against refs/tags 4 | tags: 5 | - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 6 | 7 | name: Create and Publish Release 8 | 9 | jobs: 10 | build: 11 | name: Create and Publish Release 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | python-version: [3.9] 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Set up Python ${{ matrix.python-version }} 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install --upgrade setuptools wheel twine 26 | - name: Create GitHub release 27 | id: create_release 28 | uses: actions/create-release@v1 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | with: 32 | tag_name: ${{ github.ref }} 33 | release_name: ${{ github.ref }} 34 | body: | 35 | Please see the CHANGELOG.md in the root of the repository for the release notes 36 | draft: true 37 | prerelease: false 38 | - name: Build and publish to PyPI 39 | env: 40 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 41 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 42 | run: | 43 | make dist-build 44 | twine upload dist/* 45 | -------------------------------------------------------------------------------- /.github/workflows/windows-build.yml: -------------------------------------------------------------------------------- 1 | name: Windows Build 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | os: [windows-latest] 11 | python-version: [3.9] 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up Python ${{ matrix.python-version }} 16 | uses: actions/setup-python@v2 17 | with: 18 | python-version: ${{ matrix.python-version }} 19 | - name: Display Python version & architecture 20 | run: | 21 | python -c "import sys; print(sys.version)" 22 | python -c "import struct; print(struct.calcsize('P') * 8)" 23 | - name: Install dependencies 24 | run: | 25 | pip install --upgrade pip wheel setuptools 26 | pip install -r requirements.txt 27 | - name: PyInstaller build 28 | run: pyinstaller --noconfirm .\target\PyInstaller-Windows\Slice-Windows.spec 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | /build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | db.sqlite3-journal 62 | 63 | # Flask stuff: 64 | instance/ 65 | .webassets-cache 66 | 67 | # Scrapy stuff: 68 | .scrapy 69 | 70 | # Sphinx documentation 71 | docs/_build/ 72 | 73 | # Jupyter Notebook 74 | .ipynb_checkpoints 75 | 76 | # IPython 77 | profile_default/ 78 | ipython_config.py 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # pipenv 84 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 85 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 86 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 87 | # install all needed dependencies. 88 | #Pipfile.lock 89 | 90 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 91 | __pypackages__/ 92 | 93 | # Celery stuff 94 | celerybeat-schedule 95 | celerybeat.pid 96 | 97 | # SageMath parsed files 98 | *.sage.py 99 | 100 | # Environments 101 | .env 102 | .venv 103 | env/ 104 | venv/ 105 | ENV/ 106 | env.bak/ 107 | venv.bak/ 108 | 109 | # Spyder project settings 110 | .spyderproject 111 | .spyproject 112 | 113 | # Rope project settings 114 | .ropeproject 115 | 116 | # mkdocs documentation 117 | /site 118 | 119 | # mypy 120 | .mypy_cache/ 121 | .dmypy.json 122 | dmypy.json 123 | 124 | # Pyre type checker 125 | .pyre/ 126 | 127 | # VS Code config 128 | .vscode 129 | 130 | # Project-specific 131 | .venv 132 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v0.7.1 4 | 5 | - Updated: bump embedded cPython interpreter version to 3.9.5 6 | - Updated: bump fonttools dependency to v4.23.0 7 | 8 | ## v0.7.0 9 | 10 | - add support for Level 3 restricted axis range sub-spacing to make fonts that include smaller variable axis ranges, can be defined in combination with other static instance location and full variable axis range axes in the same output font (note: Level 3 support requires the default axis value to be contained in the new, smaller variable axis range) 11 | - add default zopfli compression on woff file compiles (uses default zopfli compression level 6) 12 | 13 | ## v0.6.1 14 | 15 | - Updated: add woff and woff2 file extension filters in the Save and Open File dialog windows 16 | - Fix: Adjust app size for display height 17 | 18 | ## v0.6.0 19 | 20 | - add woff font format support 21 | - add woff2 font format support 22 | - add zopfli package dependency @ v0.1.8 23 | - add brotli package dependency @ v1.0.9 24 | 25 | ## v0.5.1 26 | 27 | - Fix: Application crash when a user attempts to enter invalid axis value data 28 | - Updated: bump fonttools dependency to v4.22.1 from v4.22.0 29 | 30 | ## v0.5.0 31 | 32 | - New: add support for slicing to files that have a subset of variable axes (commonly known as partial instantiation or sub-spacing) 33 | - New: add new validation that at least one axis value is defined (else user is requesting the input font design space with the new definition approach) 34 | - New: add indefinite progress indicator during slicing operation 35 | - New: add axis editor tag tooltips with full axis names that are derived from (1) OpenType registered axes; (2) Google Fonts axis registry; (3) font's fvar table definitions 36 | - New: add embedded Recursive typeface instance subset for formatting of the in-app view of application name (SIL OFL) 37 | - New: add embedded IBM Plex typeface for formatting of the axis and name table editor text (SIL OFL) 38 | - New: add Code of Conduct 39 | - Fixed: address (some) of the VirusTotal false positive flags for the Win executable build (required PyInstaller update) 40 | - Fixed: axis editor table view max height 41 | - Updated: Changed "Axis Definitions" view title to "Axis Editor" 42 | - Updated: Changed "Name Table Definitions" view title to "Name Editor" 43 | - Updated: Changed "Bit Flag Settings" view title to "Bit Flag Editor" 44 | - Updated: improve application launch center position 45 | - Updated: About dialog window width increased 46 | - Updated: About dialog dependencies list text size increased 47 | - Updated: change axis and name table editor field header strings to "Edit Values" from "Instance Values" 48 | - Updated: change Makefile `run` target with build of automated fontresources and imageresources on each execution 49 | - Updated: pin the PyInstaller build dependency at production release v4.3 50 | - Updated: bump fonttools dependency to v4.22.0 from v4.21.1 51 | - Removed: embedded Monoton typeface 52 | 53 | ## v0.4.0 54 | 55 | - add macOS code signed / installer notarization support 56 | - add new macOS code signing, notarization, and code signing/notary validation make targets 57 | - add Arch Linux AUR package support and documentation (thanks Caleb!) 58 | - add Homebrew cask tap install/uninstall/upgrade support and documentation 59 | - add maintainer docs on path `docs/MAINTAINER.md` 60 | 61 | ## v0.3.1 62 | 63 | - minor patch for Homebrew distribution testing 64 | - minor patch for macOS code sign testing 65 | 66 | ## v0.3.0 67 | 68 | - add Windows installer support to releases 69 | - add Inno Setup Windows installer configuration 70 | - fix: axis value editor table vertical header spacing for all caps axis tags, the axis tag column should now automatically resize to the max width axis tag in the list 71 | - fix: set the window icon to the Slice icon on Windows views 72 | - fix: set the About dialog title and icon on Windows views 73 | - fix: update image conversion approach to maintain alpha transparency in Windows application icon 74 | 75 | ## v0.2.1 76 | 77 | - update FontNameModel model flags definitions based on qabstractitemmodel.cpp fails 78 | 79 | ## v0.2.0 80 | 81 | - update macOS app bundle embedded cPython interpreter to v3.9.2 from v3.8.2 82 | - update SliceBaseTableModel model row and column count approaches based on qabstractitemmodel.cpp fails 83 | - update DesignAxisModel model flags definitions based on qabstractitemmodel.cpp fails 84 | 85 | ## v0.1.3 86 | 87 | - Add fonttools version number in the About dialog 88 | - Add Windows .ico icon generator Makefile target 89 | - Add Python packaging configuration/support 90 | - Add PyPI distribution packaging and release support 91 | - Add GitHub Actions based GitHub release automation 92 | - Add GitHub Actions based PyPI release automation 93 | - Add CodeQL testing 94 | 95 | ## v0.1.2 96 | 97 | - Push the PyInstaller spec file to support PyInstaller Makefile target compiles (sorry GitHub snuck it into the default Python .gitignore file) 98 | - Update .gitignore to remove `target` dir and `.spec` files 99 | 100 | ## v0.1.1 101 | 102 | - Fix: drag and drop support on the Windows platform (#1) 103 | - Add new format Makefile target with isort and black executables 104 | 105 | ## v0.1.0 106 | 107 | - initial release 108 | -------------------------------------------------------------------------------- /COC.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at the 63 | Source Foundry organization. All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series 85 | of actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or 92 | permanent ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within 112 | the community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.0, available at 118 | [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. 119 | 120 | Community Impact Guidelines were inspired by 121 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 122 | 123 | For answers to common questions about this code of conduct, see the FAQ at 124 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available 125 | at [https://www.contributor-covenant.org/translations][translations]. 126 | 127 | [homepage]: https://www.contributor-covenant.org 128 | [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html 129 | [Mozilla CoC]: https://github.com/mozilla/diversity 130 | [FAQ]: https://www.contributor-covenant.org/faq 131 | [translations]: https://www.contributor-covenant.org/translations -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CHANGELOG.md 2 | include LICENSE 3 | include README.md 4 | 5 | include *requirements.txt 6 | 7 | include src/build/settings/*.json -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | 17 | 18 | # -------------------- 19 | # Resource file builds 20 | # -------------------- 21 | 22 | build-image-resource: 23 | cd src/resources/img && pyrcc5 -o ../../slice/imageresources.py image-resources.qrc 24 | 25 | build-font-resource: 26 | cd src/resources/fonts && pyrcc5 -o ../../slice/fontresources.py font-resources.qrc 27 | 28 | # --------------------- 29 | # macOS platform builds 30 | # --------------------- 31 | 32 | # Updates the Icon.icns file from the icon images in icons/Icon.iconset 33 | macos-iconset: 34 | cd icons && iconutil -c icns Icon.iconset 35 | 36 | build-macos: macos-iconset build-image-resource build-font-resource 37 | pyinstaller --noconfirm "target/PyInstaller-macOS/Slice-macOS.spec" 38 | cp LICENSE dist/license.txt 39 | 40 | build-macos-installer: 41 | # https://github.com/sindresorhus/create-dmg 42 | - rm dist/*.dmg 43 | cd dist && create-dmg --identity="BOGUS" Slice.app 44 | 45 | # ------------------------------------------- 46 | # macOS platform distribution code signatures 47 | # ------------------------------------------- 48 | 49 | # code sign the application distribution bundle 50 | codesign-macos: 51 | codesign --deep --timestamp --force --options runtime -s "Developer ID Application: Christopher Simpkins" dist/Slice.app 52 | 53 | # verify code signature on the distribution bundle 54 | verify-codesign-macos: 55 | spctl -a -v dist/Slice.app 56 | 57 | # code sign the macOS installer 58 | codesign-macos-installer: 59 | codesign --timestamp --force --options runtime -s "Developer ID Application: Christopher Simpkins" dist/*.dmg 60 | 61 | upload-macos-installer-for-notarize: 62 | # Requires Apple Developer account user name to be exported as the environment variable 63 | # APPLDEV_USERNAME before this target is executed 64 | # This will prompt for an app-specific password to be entered in stdin 65 | xcrun altool --notarize-app --type osx --primary-bundle-id "org.sourcefoundry.slice" --username @env:APPLEDEV_USERNAME --file dist/*.dmg 66 | 67 | notarize-macos-installer: 68 | # Must export the notarization ID returned by upload-macos-installer-for-notarize 69 | # make target before this target is executed 70 | xcrun altool --notarization-info @env:SLICE_NOTARIZE_ID --username @env:APPLEDEV_USERNAME 71 | 72 | staple-notary-macos: 73 | # requires successful notarize-macos-installer step completion 74 | xcrun stapler staple -v dist/*.dmg 75 | 76 | # verify code signature on the macOS installer 77 | verify-notarize-macos-installer: 78 | spctl -a -t open --context context:primary-signature -v dist/*.dmg 79 | 80 | 81 | # ----------------------- 82 | # Windows platform builds 83 | # ----------------------- 84 | 85 | win-ico: 86 | magick convert icons/1024.png -alpha on -resize 256x256 \ 87 | -define icon:auto-resize="256,128,96,64,48,32,16" \ 88 | icons/Icon.ico 89 | 90 | 91 | # ------------------------------- 92 | # PyPI packaging and distribution 93 | # ------------------------------- 94 | 95 | clean: 96 | - rm dist/*.whl dist/*.tar.gz dist/*.zip 97 | 98 | dist-build: clean 99 | python3 setup.py sdist bdist_wheel 100 | 101 | dist-push: 102 | twine upload dist/*.whl dist/*.tar.gz 103 | 104 | # --------------------- 105 | # Testing/debugging 106 | # --------------------- 107 | 108 | # directly execute the application without a PyInstaller build 109 | run: build-image-resource build-font-resource 110 | python src/run.py 111 | 112 | 113 | # --------------------- 114 | # Source formatting 115 | # --------------------- 116 | format: 117 | isort src 118 | black --exclude=".*fontresources\.py|.*imageresources\.py" src 119 | 120 | 121 | .PHONY: build-image-resource build-font-resource\ 122 | build-macos macos-iconset codesign-macos build-macos-installer\ 123 | run -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Slice 2 | 3 | ### An open-source application to create custom font design spaces from variable fonts 4 | 5 | 6 | 7 | ## About 8 | 9 | Slice is an open-source, cross-platform GUI app that generates fonts with custom design sub-spaces from variable font inputs. 10 | 11 | ## Install 12 | 13 | * macOS: [Slice.0.7.1.dmg](https://github.com/source-foundry/Slice/releases/download/v0.7.1/Slice.0.7.1.dmg) 14 | * Windows: [Slice-0.7.1-Installer.exe](https://github.com/source-foundry/Slice/releases/download/v0.7.1/Slice-0.7.1-Installer.exe) 15 | 16 | Please see the [Installation docs](https://slice-gui.netlify.app/docs/install/) for additional details, including available package manager installation/upgrade approaches. 17 | 18 | ## User documentation 19 | 20 | User docs are available at https://slice-gui.netlify.app/docs/ 21 | 22 | - [Installation](https://slice-gui.netlify.app/docs/install/) 23 | - [Usage](https://slice-gui.netlify.app/docs/usage/) 24 | 25 | ## Axis definitions 26 | 27 | Slice currently supports combinations of the following axis definition types in output fonts: 28 | 29 | - Fixed instance locations 30 | - Level 3 restricted axis ranges (must include original axis default value in the new, smaller axis range)[[1](#footnote1)] 31 | - Full, original variable axis ranges 32 | 33 | Define your font axes with the syntax in the table below. 34 | 35 | |Axis definition | Axis Editor Syntax | Example | 36 | | --- | --- | --- | 37 | | Fixed axis location| Integer or float value | `400.0` | 38 | | Restricted axis range | Colon-delimited min:max integer or float range | `200:700` | 39 | | Full axis range | Leave editor row blank | n/a | 40 | 41 | ## Issues 42 | 43 | Please file issues on the [project tracker](https://github.com/source-foundry/Slice/issues). 44 | 45 | ## Contributing 46 | 47 | Source contributions are welcome. Please see the [Slice application developer documentation](https://slice-gui.netlify.app/docs/developer/#slice-source-code-contributions) for instructions on how to set up a local development environment and test your source changes. Submit a pull request with any changes that you would like to share upstream. 48 | 49 | The Slice documentation is maintained in a separate GitHub repository. Please see the [Slice documentation developer docs](https://slice-gui.netlify.app/docs/developer/#slice-documentation-contributions) for additional details about how to modify documentation content and set up a local testing environment. 50 | 51 | Contributions to this project are accepted under the licenses specified in the [Licenses](#Licenses) section below. 52 | 53 | ## Licenses 54 | 55 | The Slice project is licensed under the GNU General Public License version 3. Please see the [LICENSE](LICENSE) document for details. 56 | 57 | Please see the [thirdparty directory](https://github.com/source-foundry/Slice/tree/main/thirdparty) for additional details about third-party licenses. 58 | 59 | ## Acknowledgments 60 | 61 | ❤️ Slice slices with the fantastic [fonttools Python library](https://github.com/fonttools/fonttools). 62 | 63 | ❤️ Slice uses the wonderful [Recursive](https://github.com/arrowtype/recursive) (sliced with Slice!) and [IBM Plex](https://github.com/IBM/plex) typefaces in the UI. 64 | 65 | ⚡ [Slice docs](https://slice-gui.netlify.app/) are powered by Netlify ([doc sources](https://github.com/source-foundry/Slice-docs)). 66 | 67 | 68 | Deploys by Netlify 69 | 70 | 71 | 72 | --- 73 | 74 | 1: Default axis locations are required to compile valid variable font format files. The default axis value defined in the original font must be included in the restricted axis range due to the lack of compiler support for default axis location moves during the slicing process. We intend to support default axis location moves when it is possible to do so. [This issue is being tracked on our GitHub tracker](https://github.com/source-foundry/Slice/issues/32). 75 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements.txt 2 | pytest 3 | pytest-qt 4 | tox 5 | black 6 | flake8 7 | isort 8 | -------------------------------------------------------------------------------- /docs/MAINTAINER.md: -------------------------------------------------------------------------------- 1 | # Maintainer Documentation 2 | 3 | ## Create Draft GitHub Release 4 | 5 | The GitHub release is automatically generated by GitHub Actions when a version formatted git tag is pushed to the remote. This is configured to push a release in draft format so that installers can be uploaded and the release text can be updated with SHA hashes, VirusTotal scan links. 6 | 7 | ## Release Process 8 | 9 | The application release version is updated in the following source files: 10 | 11 | - `src/build/settings/base.json` 12 | - `src/slice/__main__.py` 13 | 14 | ### macOS Release 15 | 16 | #### References 17 | 18 | - https://developer.apple.com/developer-id/ 19 | - https://help.apple.com/xcode/mac/current/#/dev033e997ca 20 | - https://stackoverflow.com/a/53121755/2848172 21 | - https://successfulsoftware.net/2018/11/16/how-to-notarize-your-software-on-macos/ 22 | - https://help.apple.com/xcode/mac/current/#/dev1cc22a95c 23 | 24 | #### macOS Release Prep Process 25 | 26 | In Python venv with project dev-requirements.txt dependencies installed: 27 | 28 | ##### Build the code signed app bundle and installer 29 | 30 | ```sh 31 | make build-macos 32 | make codesign-macos 33 | make verify-codesign-macos 34 | make build-macos-installer 35 | make codesign-macos-installer 36 | ``` 37 | 38 | ##### Push the installer to Apple for notarization 39 | 40 | ```sh 41 | xcrun altool --notarize-app --type osx --primary-bundle-id "org.sourcefoundry.slice" --username [USERNAME] --password [APP-SPECIFIC PASSWORD] --file dist/*.dmg 42 | ``` 43 | 44 | ##### Check the status of the notarization 45 | 46 | ```sh 47 | xcrun altool --notarization-info [NOTARIZATION UUID] --username [USERNAME] --password [APP-SPECIFIC PASSWORD] 48 | ``` 49 | 50 | ##### Staple the installer after notarization passes 51 | 52 | After the notarization passes, enter: 53 | 54 | ```sh 55 | xcrun stapler staple -v dist/*.dmg 56 | ``` 57 | 58 | Note that this does not require entry of data from the previous steps. The notary data stapling is automated when you run this command after the notarization step passes. 59 | 60 | The installer file is located on the path `dist/Slice[VERSION].dmg`. This must be the dmg installer file that is released. If any edits are made, start back at step 1 of the code signing and notarization process and begin again... 61 | 62 | ##### Push to VirusTotal 63 | 64 | Upload installer to [VirusTotal](https://www.virustotal.com/gui/) 65 | 66 | Copy VirusTotal URL and installer SHA256 hash to the GitHub release. 67 | 68 | ##### Upload installer to the GitHub release 69 | 70 | Upload installer to the release. 71 | 72 | ##### Update the source-foundry/taproom Homebrew tap 73 | 74 | Update the source-foundry/homebrew-taproom `Casks/sourcefoundry-slice` cask version number and SHA256 hash. Commit and push to the repository to trigger user updates when they run `brew update && brew upgrade`. 75 | 76 | ### Windows Release 77 | 78 | Powershell 7 on Win 10 79 | 80 | In a Python venv with project dev-requirements.txt dependencies installed: 81 | 82 | Activate venv on Windows: 83 | 84 | ```sh 85 | .\venv\Scripts\activate 86 | ``` 87 | 88 | PyInstaller build of the application binary: 89 | 90 | ```sh 91 | pyinstaller --noconfirm .\target\PyInstaller-Windows\Slice-Windows.spec 92 | ``` 93 | 94 | Generate the Windows Inno Setup installer: 95 | 96 | - Launch Inno Setup 97 | - Open the `target\InnoSetup-Windows\Slice-Installer.iss` ISS configuration file in the application 98 | - Edit the Slice version string in the .iss configuration file 99 | - Build the installer 100 | 101 | The installer file is located on the path `dist\Windows-Installer\Slice-[VERSION]-Installer.exe`. 102 | 103 | Upload installer to [VirusTotal](https://www.virustotal.com/gui/). 104 | 105 | Copy VirusTotal URL and installer SHA256 hash to the GitHub release. 106 | 107 | Upload installer to the GitHub release. 108 | 109 | ## Assets 110 | 111 | ### Fonts 112 | 113 | The Recursive typeface is used for the application GUI title. The v1.077 variable font was sliced @ MONO=0, CASL=0.5, wght=800, slnt=0, CRSV=1 settings to produce this instance. It was subsequently subset with the pyftsubset executable to the character set "Slice". 114 | -------------------------------------------------------------------------------- /icons/1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/1024.png -------------------------------------------------------------------------------- /icons/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/128.png -------------------------------------------------------------------------------- /icons/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/16.png -------------------------------------------------------------------------------- /icons/256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/256.png -------------------------------------------------------------------------------- /icons/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/32.png -------------------------------------------------------------------------------- /icons/512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/512.png -------------------------------------------------------------------------------- /icons/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/64.png -------------------------------------------------------------------------------- /icons/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.icns -------------------------------------------------------------------------------- /icons/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.ico -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_1024x1024.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_128x128.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_16x16.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_256x256.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_32x32.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_512x512.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_64x64.png -------------------------------------------------------------------------------- /icons/Icon.iconset/icon_64x64@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/icons/Icon.iconset/icon_64x64@2x.png -------------------------------------------------------------------------------- /requirements.in: -------------------------------------------------------------------------------- 1 | PyQt5 2 | fontTools[woff] 3 | # https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz 4 | pyinstaller -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile 3 | # To update, run: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | altgraph==0.17 8 | # via pyinstaller 9 | brotli==1.0.9 10 | # via fonttools 11 | fonttools[woff]==4.23.0 12 | # via -r requirements.in 13 | pyinstaller-hooks-contrib==2021.1 14 | # via pyinstaller 15 | pyinstaller==4.3 16 | # via -r requirements.in 17 | pyqt5-qt==5.15.2 18 | # via pyqt5 19 | pyqt5-sip==12.8.1 20 | # via pyqt5 21 | pyqt5==5.15.3 22 | # via -r requirements.in 23 | zopfli==0.1.8 24 | # via fonttools 25 | 26 | # The following packages are considered to be unsafe in a requirements file: 27 | # setuptools 28 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 0 3 | 4 | [flake8] 5 | max-line-length = 90 6 | 7 | [tool:pytest] 8 | minversion = 3.0 9 | testpaths = tests 10 | qt_log_level_fail = CRITICAL 11 | qt_api=pyqt5 12 | addopts = 13 | -r a 14 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import io 2 | import json 3 | import os 4 | import sys 5 | from pathlib import Path 6 | from setuptools import setup, find_packages 7 | 8 | # Package meta-data. 9 | NAME = "slicegui" 10 | DESCRIPTION = "An open-source GUI application to create custom font design spaces from variable fonts" 11 | LICENSE = "GNU General Public License v3 (GPLv3)" 12 | URL = "https://github.com/source-foundry/Slice" 13 | EMAIL = "chris@sourcefoundry.org" 14 | AUTHOR = "Source Foundry Authors" 15 | REQUIRES_PYTHON = ">=3.6.0" 16 | 17 | INSTALL_REQUIRES = [ 18 | "fontTools >= 4.21.1", 19 | ] 20 | # Optional packages 21 | EXTRAS_REQUIRES = { 22 | # for developer installs 23 | "dev": ["coverage", "pytest", "pytest-qt", "tox", "flake8", "black", "isort"], 24 | # for maintainer installs 25 | "maintain": ["wheel", "setuptools", "twine"], 26 | } 27 | 28 | this_file_path = os.path.abspath(os.path.dirname(__file__)) 29 | 30 | # Version 31 | with open(Path("src/build/settings/base.json")) as f: 32 | base_json = json.load(f) 33 | VERSION = base_json["version"] 34 | 35 | # Use repository Markdown README.md for PyPI long description 36 | try: 37 | with io.open("README.md", encoding="utf-8") as f: 38 | readme = f.read() 39 | except IOError as readme_e: 40 | sys.stderr.write( 41 | "[ERROR] setup.py: Failed to read the README.md file for the long description definition: {}".format( 42 | str(readme_e) 43 | ) 44 | ) 45 | raise readme_e 46 | 47 | setup( 48 | name=NAME, 49 | version=VERSION, 50 | description=DESCRIPTION, 51 | author=AUTHOR, 52 | author_email=EMAIL, 53 | url=URL, 54 | license=LICENSE, 55 | platforms=["Any"], 56 | long_description=readme, 57 | long_description_content_type="text/markdown", 58 | package_dir={"": "src"}, 59 | packages=find_packages("src"), 60 | include_package_data=True, 61 | install_requires=INSTALL_REQUIRES, 62 | extras_require=EXTRAS_REQUIRES, 63 | python_requires=REQUIRES_PYTHON, 64 | entry_points={"console_scripts": ["slicegui = slice.__main__:main"]}, 65 | classifiers=[ 66 | "Development Status :: 4 - Beta", 67 | "Intended Audience :: Developers", 68 | "Intended Audience :: End Users/Desktop", 69 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 70 | "Natural Language :: English", 71 | "Operating System :: OS Independent", 72 | "Programming Language :: Python", 73 | "Programming Language :: Python :: 3", 74 | "Programming Language :: Python :: 3.6", 75 | "Programming Language :: Python :: 3.7", 76 | "Programming Language :: Python :: 3.8", 77 | "Programming Language :: Python :: 3.9", 78 | "Topic :: Multimedia", 79 | ], 80 | ) -------------------------------------------------------------------------------- /src/build/settings/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "app_name": "Slice", 3 | "version": "0.7.1", 4 | "author": "Christopher Simpkins", 5 | "main_module": "src/run.py", 6 | "license": "GNU General Public License Version 3" 7 | } 8 | -------------------------------------------------------------------------------- /src/build/settings/macos.json: -------------------------------------------------------------------------------- 1 | { 2 | "bundle_identifier": "org.sourcefoundry.slice" 3 | } 4 | -------------------------------------------------------------------------------- /src/resources/fonts/IBMPlexMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/src/resources/fonts/IBMPlexMono-Regular.ttf -------------------------------------------------------------------------------- /src/resources/fonts/RecursiveSans-Slice_mod.subset.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/src/resources/fonts/RecursiveSans-Slice_mod.subset.ttf -------------------------------------------------------------------------------- /src/resources/fonts/font-resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | RecursiveSans-Slice_mod.subset.ttf 4 | IBMPlexMono-Regular.ttf 5 | 6 | -------------------------------------------------------------------------------- /src/resources/img/image-resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | slice-icon.svg 4 | 5 | -------------------------------------------------------------------------------- /src/resources/img/slice-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/run.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | from slice.__main__ import main 17 | 18 | main() 19 | -------------------------------------------------------------------------------- /src/slice/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/src/slice/__init__.py -------------------------------------------------------------------------------- /src/slice/__main__.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | import sys 17 | import traceback 18 | from pathlib import Path 19 | 20 | from PyQt5.QtCore import Qt, QThreadPool, QUrl 21 | from PyQt5.QtGui import ( 22 | QDesktopServices, 23 | QFont, 24 | QFontDatabase, 25 | QIcon, 26 | QImage, 27 | QKeySequence, 28 | QPixmap, 29 | ) 30 | from PyQt5.QtWidgets import ( 31 | QAction, 32 | QApplication, 33 | QCheckBox, 34 | QDesktopWidget, 35 | QFormLayout, 36 | QGridLayout, 37 | QGroupBox, 38 | QHBoxLayout, 39 | QHeaderView, 40 | QLabel, 41 | QMainWindow, 42 | QPushButton, 43 | QSizePolicy, 44 | QTableView, 45 | QVBoxLayout, 46 | QWidget, 47 | ) 48 | 49 | from .fontresources import * 50 | from .imageresources import * 51 | from .instanceworker import InstanceWorker 52 | from .models import DesignAxisModel, FontBitFlagModel, FontModel, FontNameModel 53 | from .ui.dialogs import ( 54 | SliceAboutDialog, 55 | SliceErrorDialog, 56 | SliceOpenFileDialog, 57 | SliceProgressDialog, 58 | SliceSaveFileDialog, 59 | ) 60 | from .ui.widgets import DragDropLineEdit 61 | 62 | __VERSION__ = "0.7.1" 63 | 64 | 65 | class MainWindow(QMainWindow): 66 | def __init__(self, parent=None): 67 | super().__init__(parent) 68 | 69 | # get the user screen dimensions for UI layout 70 | self.screen_dimensions = QDesktopWidget().screenGeometry(0) 71 | print( 72 | f"Screen dimensions: {self.screen_dimensions.height()}, {self.screen_dimensions.width()}" 73 | ) 74 | 75 | # default FontModel 76 | self.font_model = FontModel(None) 77 | 78 | # defined with axis widgets used in the 79 | # axis editor view 80 | self.axis_data_dict = {} 81 | 82 | # set up thread pool 83 | self.setupThreadPool() 84 | 85 | # set up the UI 86 | self.setWindowIcon(QIcon(":/img/slice-icon.svg")) 87 | self.setUIMenuBar() 88 | self.setUIMainWindow() 89 | self.setUIMainLayout() 90 | self.setUIAppIconTitle() 91 | self.setUIFontPathDataEntry() 92 | self.setUIAxisValueDataEntry() 93 | self.setUINameTableDataEntry() 94 | self.setUIBitSettingsDataEntry() 95 | self.setUISliceButton() 96 | # self.addStretch() 97 | self.setUIStatusBar() 98 | 99 | # Define main layout on central widget 100 | w = QWidget() 101 | w.setLayout(self.main_layout) 102 | self.setCentralWidget(w) 103 | # adjust to center position on view 104 | self.setWindowCenterPosition() 105 | 106 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 107 | # 108 | # Thread Pool 109 | # 110 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | 112 | def setupThreadPool(self): 113 | self.threadpool = QThreadPool() 114 | 115 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | # 117 | # UI definitions 118 | # 119 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 120 | 121 | # 122 | # Menus 123 | # 124 | 125 | def setUIMenuBar(self): 126 | menuBar = self.menuBar() 127 | 128 | # 129 | # File menu 130 | # 131 | fileMenu = menuBar.addMenu("File") 132 | 133 | # Open 134 | self.openAction = QAction("&Open Font...", self) 135 | self.openAction.setShortcut(QKeySequence.Open) 136 | self.openAction.triggered.connect(self.menu_clicked_open) 137 | fileMenu.addAction(self.openAction) 138 | 139 | fileMenu.addSeparator() 140 | 141 | # Quit 142 | self.quitAction = QAction("&Quit", self) 143 | self.quitAction.setShortcut(QKeySequence.Quit) 144 | self.quitAction.triggered.connect(self.menu_clicked_quit) 145 | fileMenu.addAction(self.quitAction) 146 | 147 | # 148 | # Resources menu 149 | # 150 | resourcesMenu = menuBar.addMenu("References") 151 | 152 | openTypeSpecMenu = resourcesMenu.addMenu("OpenType Specification") 153 | 154 | # fvar table spec link 155 | self.fvarReferenceAction = QAction("fvar Table") 156 | self.fvarReferenceAction.triggered.connect(self.menu_clicked_fvar) 157 | openTypeSpecMenu.addAction(self.fvarReferenceAction) 158 | 159 | # head table spec link 160 | self.headReferenceAction = QAction("head Table") 161 | self.headReferenceAction.triggered.connect(self.menu_clicked_head) 162 | openTypeSpecMenu.addAction(self.headReferenceAction) 163 | 164 | # name table spec link 165 | self.nameReferenceAction = QAction("name Table") 166 | self.nameReferenceAction.triggered.connect(self.menu_clicked_name) 167 | openTypeSpecMenu.addAction(self.nameReferenceAction) 168 | 169 | # OS/2 table spec link 170 | self.os2ReferenceAction = QAction("OS/2 Table") 171 | self.os2ReferenceAction.triggered.connect(self.menu_clicked_os2) 172 | openTypeSpecMenu.addAction(self.os2ReferenceAction) 173 | 174 | # 175 | # Help menu 176 | # 177 | helpMenu = menuBar.addMenu("Help") 178 | 179 | # About 180 | self.aboutAction = QAction("&About...", self) 181 | self.aboutAction.triggered.connect(self.menu_clicked_about) 182 | helpMenu.addAction(self.aboutAction) 183 | 184 | # Check for updates 185 | self.updateCheckAction = QAction("Check for Updates", self) 186 | self.updateCheckAction.triggered.connect(self.menu_clicked_updatecheck) 187 | helpMenu.addAction(self.updateCheckAction) 188 | 189 | # Release notes 190 | self.releaseNotesAction = QAction("Release Notes", self) 191 | self.releaseNotesAction.triggered.connect(self.menu_clicked_releasenotes) 192 | helpMenu.addAction(self.releaseNotesAction) 193 | 194 | helpMenu.addSeparator() 195 | 196 | # Documentation 197 | self.documentationAction = QAction("Documentation", self) 198 | self.documentationAction.triggered.connect(self.menu_clicked_documentation) 199 | helpMenu.addAction(self.documentationAction) 200 | 201 | helpMenu.addSeparator() 202 | 203 | # License 204 | self.licenseAction = QAction("View &License", self) 205 | self.licenseAction.triggered.connect(self.menu_clicked_license) 206 | helpMenu.addAction(self.licenseAction) 207 | 208 | # Source 209 | self.sourceAction = QAction("View Source", self) 210 | self.sourceAction.triggered.connect(self.menu_clicked_source) 211 | helpMenu.addAction(self.sourceAction) 212 | 213 | helpMenu.addSeparator() 214 | 215 | # Issue Tracker 216 | self.issueTrackerAction = QAction("Issue Tracker", self) 217 | self.issueTrackerAction.triggered.connect(self.menu_clicked_issuetracker) 218 | helpMenu.addAction(self.issueTrackerAction) 219 | 220 | # Report a Bug 221 | self.bugReportAction = QAction("Report a Bug", self) 222 | self.bugReportAction.triggered.connect(self.menu_clicked_bugreport) 223 | helpMenu.addAction(self.bugReportAction) 224 | 225 | # 226 | # Main window and main layout 227 | # 228 | 229 | def setUIMainWindow(self): 230 | self.setWindowTitle("Slice") 231 | # self.resize(850, 950) 232 | 233 | def setUIMainLayout(self): 234 | self.main_layout = QVBoxLayout() 235 | 236 | # 237 | # Application icon and title row 238 | # 239 | 240 | def setUIAppIconTitle(self): 241 | # add the app logo and name view if screen dimensions permit it 242 | if self.screen_dimensions.height() >= 1000: 243 | recursive_id = QFontDatabase.addApplicationFont(":/font/RecursiveSans.ttf") 244 | font_family = QFontDatabase.applicationFontFamilies(recursive_id)[0] 245 | recursive = QFont(font_family) 246 | outerHBox = QHBoxLayout() 247 | titleLabel = QLabel("

Slice

") 248 | titleLabel.setStyleSheet("QLabel { font-size: 36px;}") 249 | titleLabel.setFont(recursive) 250 | titleLabel.setAlignment(Qt.AlignLeft | Qt.AlignBottom) 251 | iconLabel = QLabel() 252 | # note: commented block below shows how to use 253 | # svg embedded as a Python string literal 254 | # for QImage instantiation. The current 255 | # approach is better 256 | # svg_bytes = bytearray(svg_icon, encoding="utf-8") 257 | # qimage = QImage.fromData(svg_bytes) 258 | qimage = QImage(":/img/slice-icon.svg") 259 | pixmap = QPixmap.fromImage(qimage) 260 | iconLabel.setPixmap(pixmap) 261 | iconLabel.setFixedHeight(60) 262 | iconLabel.setFixedWidth(75) 263 | outerHBox.addWidget(iconLabel) 264 | outerHBox.addWidget(titleLabel) 265 | 266 | # add widget to main layout 267 | self.main_layout.addLayout(outerHBox) 268 | 269 | # 270 | # Font path free text entry field view (with DnD support) 271 | # 272 | 273 | def setUIFontPathDataEntry(self): 274 | self.fontpathLineEdit = DragDropLineEdit(self) 275 | self.fontpathLineEdit.returnPressed.connect( 276 | self.key_pressed_return_fontpath_data_entry 277 | ) 278 | dataEntryForm = QFormLayout() 279 | dataEntryForm.setAlignment(Qt.AlignLeft) 280 | dataEntryForm.addRow(QLabel("

Font Path:

"), self.fontpathLineEdit) 281 | dataEntryForm.setContentsMargins(0, 0, 0, 0) 282 | 283 | self.openFontPathButton = QPushButton("Open", self) 284 | self.openFontPathButton.pressed.connect(self.btn_clicked_open_fontpath) 285 | row_layout = QHBoxLayout() 286 | row_layout.addLayout(dataEntryForm) 287 | row_layout.addWidget(self.openFontPathButton) 288 | row_layout.addStretch() 289 | 290 | # add the widgets and layout to a QGroupBox 291 | fontpathGroupBox = QGroupBox("") # empty string param = no group box title 292 | fontpathGroupBox.setLayout(row_layout) 293 | # add widget to main layout 294 | self.main_layout.addWidget(fontpathGroupBox) 295 | 296 | # 297 | # Axis instance value editor table view 298 | # 299 | 300 | def setUIAxisValueDataEntry(self): 301 | outerVBox = QVBoxLayout() 302 | axisEditLabel = QLabel("

Axis Editor

") 303 | axisEditLabel.setStyleSheet("QLabel { padding-left: 5px;}") 304 | axisEditGroupBox = QGroupBox("") 305 | axisEditGroupBox.setMinimumHeight(200) 306 | axisEditGroupBox.setSizePolicy( 307 | QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding 308 | ) 309 | 310 | self.fvar_table_view = QTableView() 311 | self.fvar_table_model = DesignAxisModel() 312 | self.fvar_table_view.setModel(self.fvar_table_model) 313 | self.fvar_table_view.horizontalHeader().setStretchLastSection(True) 314 | self.fvar_table_view.resizeColumnToContents(0) 315 | self.fvar_table_view.setAlternatingRowColors(True) 316 | axisEditGroupBox.setLayout(QVBoxLayout()) 317 | axisEditGroupBox.layout().addWidget(self.fvar_table_view) 318 | axisEditGroupBox.setMinimumHeight(205) 319 | axisEditGroupBox.setMaximumHeight(350) 320 | 321 | ibmplex_id = QFontDatabase.addApplicationFont(":/font/IBMPlexMono-Regular.ttf") 322 | font_family = QFontDatabase.applicationFontFamilies(ibmplex_id)[0] 323 | ibmplex = QFont(font_family) 324 | self.fvar_table_view.setFont(ibmplex) 325 | self.fvar_table_view.resizeColumnToContents(0) 326 | 327 | outerVBox.addWidget(axisEditLabel) 328 | outerVBox.addWidget(axisEditGroupBox) 329 | # add to main layout 330 | # self.main_layout.addSpacing(10) 331 | self.main_layout.addLayout(outerVBox) 332 | 333 | # 334 | # Name table record editor table view 335 | # 336 | 337 | def setUINameTableDataEntry(self): 338 | outerVBox = QVBoxLayout() 339 | nameTableLabel = QLabel("

Name Editor

") 340 | nameTableLabel.setStyleSheet("QLabel { padding-left: 5px;}") 341 | nameTableGroupBox = QGroupBox("") 342 | 343 | self.nameTableView = QTableView() 344 | self.name_table_model = FontNameModel() 345 | self.nameTableView.setModel(self.name_table_model) 346 | self.nameTableView.horizontalHeader().setStretchLastSection(True) 347 | self.nameTableView.setAlternatingRowColors(True) 348 | 349 | ibmplex_id = QFontDatabase.addApplicationFont(":/font/IBMPlexMono-Regular.ttf") 350 | font_family = QFontDatabase.applicationFontFamilies(ibmplex_id)[0] 351 | ibmplex = QFont(font_family) 352 | self.nameTableView.setFont(ibmplex) 353 | 354 | nameTableGroupBox.setLayout(QVBoxLayout()) 355 | nameTableGroupBox.layout().addWidget(self.nameTableView) 356 | nameTableGroupBox.setMinimumHeight(210) 357 | 358 | outerVBox.addWidget(nameTableLabel) 359 | outerVBox.addWidget(nameTableGroupBox) 360 | # self.main_layout.addSpacing(10) 361 | self.main_layout.addLayout(outerVBox) 362 | 363 | # 364 | # Bit flag settings editor table view 365 | # 366 | 367 | def setUIBitSettingsDataEntry(self): 368 | outerVBox = QVBoxLayout() 369 | outerHBox = QHBoxLayout() 370 | bitSettingsLabel = QLabel("

Bit Flag Editor

") 371 | bitSettingsLabel.setStyleSheet("QLabel { padding-left: 5px;}") 372 | 373 | bitSettingsOuterGroupBox = QGroupBox("") 374 | bitSettingsOS2GroupBox = QGroupBox("OS/2.fsSelection") 375 | bitSettingsHeadGroupBox = QGroupBox("head.macStyle") 376 | 377 | # OS/2.fsSelection bit check boxes 378 | self.os2_fsselection_bit_0_checkbox = QCheckBox("bit 0 (ITALIC)") 379 | self.os2_fsselection_bit_5_checkbox = QCheckBox("bit 5 (BOLD)") 380 | self.os2_fsselection_bit_6_checkbox = QCheckBox("bit 6 (REGULAR)") 381 | self.os2_fsselection_bit_8_checkbox = QCheckBox("bit 8 (WWS)") 382 | 383 | # head.macStyle bit check boxes 384 | self.head_macstyle_bit_0_checkbox = QCheckBox("bit 0 (BOLD)") 385 | self.head_macstyle_bit_1_checkbox = QCheckBox("bit 1 (ITALIC)") 386 | 387 | # add check boxes to OS/2 grid layout 388 | bitSettingsOS2GridLayout = QGridLayout() 389 | bitSettingsOS2GridLayout.addWidget(self.os2_fsselection_bit_0_checkbox, 0, 0) 390 | bitSettingsOS2GridLayout.addWidget(self.os2_fsselection_bit_5_checkbox, 0, 1) 391 | bitSettingsOS2GridLayout.addWidget(self.os2_fsselection_bit_6_checkbox, 1, 0) 392 | bitSettingsOS2GridLayout.addWidget(self.os2_fsselection_bit_8_checkbox, 1, 1) 393 | 394 | # add check boxes to head grid layout 395 | bitSettingsHeadGridLayout = QGridLayout() 396 | bitSettingsHeadGridLayout.addWidget(self.head_macstyle_bit_0_checkbox, 0, 0) 397 | bitSettingsHeadGridLayout.addWidget(self.head_macstyle_bit_1_checkbox, 0, 1) 398 | 399 | # add OS/2 and head grid layouts to table group boxes 400 | bitSettingsOS2GroupBox.setLayout(bitSettingsOS2GridLayout) 401 | bitSettingsHeadGroupBox.setLayout(bitSettingsHeadGridLayout) 402 | 403 | # add table group boxes to outer H box layout 404 | outerHBox.addWidget(bitSettingsOS2GroupBox) 405 | outerHBox.addWidget(bitSettingsHeadGroupBox) 406 | 407 | # add outer H box layout to outer group box layout 408 | bitSettingsOuterGroupBox.setLayout(outerHBox) 409 | 410 | outerVBox.addWidget(bitSettingsLabel) 411 | outerVBox.addWidget(bitSettingsOuterGroupBox) 412 | 413 | # self.main_layout.addSpacing(10) 414 | self.main_layout.addLayout(outerVBox) 415 | 416 | # 417 | # Slice execution button 418 | # 419 | 420 | def setUISliceButton(self): 421 | self.sliceButton = QPushButton("Slice", self) 422 | self.sliceButton.setMaximumWidth(250) 423 | self.sliceButton.setMinimumWidth(200) 424 | # add to main layout 425 | # self.main_layout.addSpacing(3) 426 | self.main_layout.addWidget(self.sliceButton, alignment=Qt.AlignCenter) 427 | # self.main_layout.addSpacing(3) 428 | # add slot to clicked event 429 | self.sliceButton.clicked.connect(self.btn_clicked_slice) 430 | 431 | # 432 | # Status bar view 433 | # 434 | 435 | def setUIStatusBar(self): 436 | # messages are managed with 437 | # .clearMessage() and .showMessage() 438 | self.statusbar = self.statusBar() 439 | self.statusbar.showMessage("Ready") 440 | 441 | # Version info 442 | status_version_label = QLabel(f"v{__VERSION__}") 443 | self.statusbar.addPermanentWidget(status_version_label) 444 | self.statusbar.update() 445 | 446 | # 447 | # UI utilities 448 | # 449 | 450 | def addStretch(self): 451 | self.main_layout.addStretch() 452 | 453 | def setWindowCenterPosition(self): 454 | # scale dimensions based upon available display size 455 | if self.screen_dimensions.height() >= 1000: 456 | self.setGeometry(0, 0, 850, 900) 457 | else: 458 | self.setGeometry(0, 0, 850, 750) 459 | rect = self.frameGeometry() 460 | centerCoord = QDesktopWidget().availableGeometry().center() 461 | rect.moveCenter(centerCoord) 462 | self.move(rect.topLeft()) 463 | 464 | # 465 | # Data control 466 | # 467 | 468 | def collect_os2_bit_checkbox_fields(self): 469 | return { 470 | "bit0": self.os2_fsselection_bit_0_checkbox.isChecked(), 471 | "bit5": self.os2_fsselection_bit_5_checkbox.isChecked(), 472 | "bit6": self.os2_fsselection_bit_6_checkbox.isChecked(), 473 | "bit8": self.os2_fsselection_bit_8_checkbox.isChecked(), 474 | } 475 | 476 | def collect_head_bit_checkbox_fields(self): 477 | return { 478 | "bit0": self.head_macstyle_bit_0_checkbox.isChecked(), 479 | "bit1": self.head_macstyle_bit_1_checkbox.isChecked(), 480 | } 481 | 482 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 483 | # 484 | # Event slots 485 | # 486 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 487 | 488 | # 489 | # Menu click events 490 | # 491 | 492 | def menu_clicked_about(self): 493 | SliceAboutDialog(f"{__VERSION__}") 494 | 495 | def menu_clicked_bugreport(self): 496 | QDesktopServices.openUrl( 497 | QUrl("https://github.com/source-foundry/Slice/issues/new") 498 | ) 499 | 500 | def menu_clicked_documentation(self): 501 | QDesktopServices.openUrl(QUrl("https://slice-gui.netlify.app/docs/")) 502 | 503 | def menu_clicked_fvar(self): 504 | QDesktopServices.openUrl( 505 | QUrl("https://docs.microsoft.com/en-us/typography/opentype/spec/fvar") 506 | ) 507 | 508 | def menu_clicked_head(self): 509 | QDesktopServices.openUrl( 510 | QUrl("https://docs.microsoft.com/en-us/typography/opentype/spec/head") 511 | ) 512 | 513 | def menu_clicked_issuetracker(self): 514 | QDesktopServices.openUrl(QUrl("https://github.com/source-foundry/Slice/issues")) 515 | 516 | def menu_clicked_license(self): 517 | QDesktopServices.openUrl( 518 | QUrl("https://github.com/source-foundry/Slice/blob/main/LICENSE") 519 | ) 520 | 521 | def menu_clicked_name(self): 522 | QDesktopServices.openUrl( 523 | QUrl("https://docs.microsoft.com/en-us/typography/opentype/spec/name") 524 | ) 525 | 526 | def menu_clicked_open(self): 527 | self.openFontPathButton.setEnabled(False) 528 | self._open_font_file_action() 529 | 530 | def menu_clicked_os2(self): 531 | QDesktopServices.openUrl( 532 | QUrl("https://docs.microsoft.com/en-us/typography/opentype/spec/os2") 533 | ) 534 | 535 | def menu_clicked_quit(self): 536 | self.close() 537 | 538 | def menu_clicked_releasenotes(self): 539 | QDesktopServices.openUrl( 540 | QUrl("https://github.com/source-foundry/Slice/blob/main/CHANGELOG.md") 541 | ) 542 | 543 | def menu_clicked_source(self): 544 | QDesktopServices.openUrl(QUrl("https://github.com/source-foundry/Slice")) 545 | 546 | def menu_clicked_updatecheck(self): 547 | QDesktopServices.openUrl( 548 | QUrl("https://github.com/source-foundry/Slice/releases") 549 | ) 550 | 551 | # 552 | # Button click events 553 | # 554 | 555 | def btn_clicked_open_fontpath(self): 556 | self.openFontPathButton.setEnabled(False) 557 | self._open_font_file_action() 558 | 559 | def btn_clicked_slice(self): 560 | # user did not load font data 561 | if not self.font_model.fontpath: 562 | self.statusbar.showMessage("Requires a font path") 563 | self.statusbar.update() 564 | # must keep this return statement to abort execution! 565 | return 566 | 567 | # validate axis editor instance values 568 | # returns True/False response for test of 569 | # at least one instance value 570 | # raises ValueError on attempt to cast to float 571 | # if the entry is a non-numeric value 572 | try: 573 | instance_values_are_present = ( 574 | self.fvar_table_model.instance_data_validates_missing_data() 575 | ) 576 | except ValueError as e: 577 | SliceErrorDialog(f"{e}") 578 | return 579 | 580 | if not instance_values_are_present: 581 | SliceErrorDialog( 582 | "You requested the same design space that is supported in the " 583 | "font path that you are processing. Please define at least one " 584 | "axis location or restricted axis range." 585 | ) 586 | else: 587 | # validation: confirm that the user did not edit the 588 | # file path in the text edit field without initiation 589 | # of a font re-load (e.g., manual edit of text without 590 | # clicking Return button) 591 | if self.fontpathLineEdit.text() != self.font_model.fontpath: 592 | SliceErrorDialog( 593 | "The file path in the font path field does not match the " 594 | "loaded font path. Please load your font again." 595 | ) 596 | else: 597 | outpath = SliceSaveFileDialog( 598 | root_directory=str(Path(self.font_model.fontpath).parent) 599 | ).get_file_path() 600 | 601 | # the user did not select a save path 602 | # abort instantiation 603 | if not outpath: 604 | self.statusbar.showMessage("Canceled") 605 | self.statusbar.update() 606 | return 607 | 608 | # Define the FontBitFlagModel 609 | bit_model = FontBitFlagModel( 610 | self.collect_os2_bit_checkbox_fields(), 611 | self.collect_head_bit_checkbox_fields(), 612 | ) 613 | try: 614 | # set up instance worker 615 | instance_worker = InstanceWorker( 616 | outpath, 617 | self.font_model, 618 | self.fvar_table_model, 619 | self.name_table_model, 620 | bit_model, 621 | ) 622 | 623 | # launch progress bar dialog 624 | self.progress_dialog = SliceProgressDialog( 625 | instance_worker.signals.finished 626 | ) 627 | 628 | # attach InstanceWorker signals / slots 629 | instance_worker.signals.result.connect(self._instance_worker_output) 630 | instance_worker.signals.finished.connect( 631 | self._instance_worker_complete 632 | ) 633 | instance_worker.signals.error.connect(self._instance_worker_error) 634 | 635 | # start the worker thread 636 | self.threadpool.start(instance_worker) 637 | self.statusbar.showMessage("Slicing...") 638 | self.sliceButton.setDisabled(True) 639 | except Exception as e: 640 | # hide progress dialog if exception occurred 641 | self.progress_dialog.hide() 642 | SliceErrorDialog( 643 | "Font processing failed with an error. See details below.", 644 | detailed_text=str(e), 645 | ) 646 | self.statusbar.showMessage("Error") 647 | self.statusbar.update() 648 | # print trace to std error 649 | sys.stderr.write(f"{traceback.format_exc()}\n") 650 | 651 | # enable the Slice button at end of instantiation 652 | # attempt irrespective of the error/success outcome 653 | self.sliceButton.setEnabled(True) 654 | 655 | # 656 | # Keyboard input press events 657 | # 658 | 659 | def key_pressed_return_fontpath_data_entry(self): 660 | self.load_font(self.fontpathLineEdit.text()) 661 | 662 | # 663 | # Event private methods 664 | # 665 | 666 | def _open_font_file_action(self): 667 | self.statusbar.showMessage("Select variable font file path") 668 | filepath_dialog = SliceOpenFileDialog() 669 | filepath = filepath_dialog.get_file_path() 670 | if filepath: 671 | self.fontpathLineEdit.setText(filepath) 672 | self.load_font(filepath) 673 | 674 | self.openFontPathButton.setEnabled(True) 675 | 676 | # 677 | # Instance worker thread events 678 | # 679 | 680 | def _instance_worker_output(self, result_string): 681 | # InstanceWorker successfully completed file write 682 | # prints the out file path to stdout stream on success 683 | print(f"Write path: {result_string}") 684 | 685 | def _instance_worker_complete(self): 686 | # Instance worker ended execution 687 | self.sliceButton.setEnabled(True) 688 | self.statusbar.showMessage("Complete") 689 | 690 | def _instance_worker_error(self, error_string): 691 | # hide progress dialog before presentation of error dialog 692 | self.progress_dialog.hide() 693 | # Instance worker errored 694 | # Propagate the exception to an error dialog 695 | SliceErrorDialog( 696 | "Font processing failed with an error. See details below.", 697 | detailed_text=error_string, 698 | ) 699 | self.sliceButton.setEnabled(True) 700 | self.statusbar.showMessage("Failed") 701 | 702 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 703 | # 704 | # Font load 705 | # 706 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 707 | def load_font(self, filepath): 708 | """Instantiates default data model values and writes font data to UI.""" 709 | try: 710 | self.font_model = FontModel(filepath) 711 | if not self.font_model.is_variable_font(): 712 | SliceErrorDialog( 713 | "The file does not appear to be a variable font. See details below.", 714 | "The font is missing the OpenType fvar table and is not recognized " 715 | "as a variable font. Please try again with a font that includes the " 716 | "fvar table.", 717 | ) 718 | return False 719 | except Exception as e: 720 | SliceErrorDialog( 721 | "An error was encountered during the attempt to load your font. " 722 | "See details below.", 723 | detailed_text=str(e), 724 | ) 725 | return False 726 | 727 | name_table_was_set = self.name_table_model.load_font(self.font_model) 728 | axis_value_table_was_set = self.fvar_table_model.load_font(self.font_model) 729 | 730 | self.fvar_table_view.resizeColumnToContents(0) 731 | self.fvar_table_view.verticalHeader().resizeSections( 732 | QHeaderView.ResizeToContents 733 | ) 734 | 735 | # uncheck all bit flag setting check boxes 736 | self.os2_fsselection_bit_0_checkbox.setChecked(False) 737 | self.os2_fsselection_bit_5_checkbox.setChecked(False) 738 | self.os2_fsselection_bit_6_checkbox.setChecked(False) 739 | self.os2_fsselection_bit_8_checkbox.setChecked(False) 740 | self.head_macstyle_bit_0_checkbox.setChecked(False) 741 | self.head_macstyle_bit_1_checkbox.setChecked(False) 742 | 743 | if name_table_was_set and axis_value_table_was_set: 744 | # Update status bar with font family name, 745 | # version, and number of axes 746 | self.statusbar.showMessage( 747 | f"{self.name_table_model.get_family_name()} " 748 | f"{self.name_table_model.get_version()} " 749 | f"loaded ({self.fvar_table_model.get_number_of_axes()} axes)" 750 | ) 751 | 752 | 753 | def main(): 754 | app = QApplication(sys.argv) 755 | # fusion_style = QStyleFactory.create("Fusion") 756 | # app.setStyle(fusion_style) 757 | window = MainWindow() 758 | window.show() 759 | sys.exit(app.exec_()) 760 | 761 | 762 | if __name__ == "__main__": 763 | main() 764 | -------------------------------------------------------------------------------- /src/slice/imageresources.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created by: The Resource Compiler for PyQt5 (Qt v5.15.2) 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore 10 | 11 | qt_resource_data = b"\ 12 | \x00\x00\x0a\xed\ 13 | \x3c\ 14 | \x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\ 15 | \x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\ 16 | \x2d\x38\x22\x3f\x3e\x0a\x3c\x73\x76\x67\x20\x77\x69\x64\x74\x68\ 17 | \x3d\x22\x37\x35\x70\x78\x22\x20\x68\x65\x69\x67\x68\x74\x3d\x22\ 18 | \x36\x30\x70\x78\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x30\ 19 | \x20\x30\x20\x37\x35\x20\x36\x30\x22\x20\x76\x65\x72\x73\x69\x6f\ 20 | \x6e\x3d\x22\x31\x2e\x31\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\ 21 | \x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\ 22 | \x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x20\x78\x6d\x6c\x6e\x73\ 23 | \x3a\x78\x6c\x69\x6e\x6b\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\ 24 | \x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\x39\x2f\x78\ 25 | \x6c\x69\x6e\x6b\x22\x3e\x0a\x20\x20\x20\x20\x3c\x67\x20\x73\x74\ 26 | \x72\x6f\x6b\x65\x3d\x22\x6e\x6f\x6e\x65\x22\x20\x73\x74\x72\x6f\ 27 | \x6b\x65\x2d\x77\x69\x64\x74\x68\x3d\x22\x31\x22\x20\x66\x69\x6c\ 28 | \x6c\x3d\x22\x6e\x6f\x6e\x65\x22\x20\x66\x69\x6c\x6c\x2d\x72\x75\ 29 | \x6c\x65\x3d\x22\x65\x76\x65\x6e\x6f\x64\x64\x22\x3e\x0a\x20\x20\ 30 | \x20\x20\x20\x20\x20\x20\x3c\x67\x20\x66\x69\x6c\x6c\x2d\x72\x75\ 31 | \x6c\x65\x3d\x22\x6e\x6f\x6e\x7a\x65\x72\x6f\x22\x3e\x0a\x20\x20\ 32 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x67\x3e\x0a\x20\x20\ 33 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x70\ 34 | \x61\x74\x68\x20\x64\x3d\x22\x4d\x37\x32\x2e\x38\x30\x32\x37\x33\ 35 | \x34\x34\x2c\x34\x31\x2e\x31\x32\x35\x20\x4c\x32\x2e\x31\x39\x37\ 36 | \x32\x36\x35\x36\x32\x2c\x34\x31\x2e\x31\x32\x35\x20\x43\x30\x2e\ 37 | \x39\x38\x33\x37\x38\x39\x30\x36\x32\x2c\x34\x31\x2e\x31\x32\x35\ 38 | \x20\x30\x2c\x34\x32\x2e\x31\x38\x31\x33\x37\x30\x38\x20\x30\x2c\ 39 | \x34\x33\x2e\x34\x38\x34\x33\x37\x35\x20\x4c\x30\x2c\x35\x37\x2e\ 40 | \x36\x34\x30\x36\x32\x35\x20\x43\x30\x2c\x35\x38\x2e\x39\x34\x33\ 41 | \x36\x32\x39\x32\x20\x30\x2e\x39\x38\x33\x37\x38\x39\x30\x36\x32\ 42 | \x2c\x36\x30\x20\x32\x2e\x31\x39\x37\x32\x36\x35\x36\x32\x2c\x36\ 43 | \x30\x20\x4c\x37\x32\x2e\x38\x30\x32\x37\x33\x34\x34\x2c\x36\x30\ 44 | \x20\x43\x37\x34\x2e\x30\x31\x36\x32\x31\x30\x39\x2c\x36\x30\x20\ 45 | \x37\x35\x2c\x35\x38\x2e\x39\x34\x33\x36\x32\x39\x32\x20\x37\x35\ 46 | \x2c\x35\x37\x2e\x36\x34\x30\x36\x32\x35\x20\x4c\x37\x35\x2c\x34\ 47 | \x33\x2e\x34\x38\x34\x33\x37\x35\x20\x43\x37\x35\x2c\x34\x32\x2e\ 48 | \x31\x38\x31\x32\x31\x33\x35\x20\x37\x34\x2e\x30\x31\x36\x32\x31\ 49 | \x30\x39\x2c\x34\x31\x2e\x31\x32\x35\x20\x37\x32\x2e\x38\x30\x32\ 50 | \x37\x33\x34\x34\x2c\x34\x31\x2e\x31\x32\x35\x20\x5a\x22\x20\x69\ 51 | \x64\x3d\x22\x50\x61\x74\x68\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\ 52 | \x46\x46\x45\x31\x42\x41\x22\x3e\x3c\x2f\x70\x61\x74\x68\x3e\x0a\ 53 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ 54 | \x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x4d\x37\x32\x2e\x38\x30\x36\ 55 | \x35\x31\x36\x32\x2c\x34\x31\x2e\x31\x32\x35\x20\x4c\x33\x37\x2e\ 56 | \x35\x36\x34\x35\x34\x33\x39\x2c\x34\x31\x2e\x31\x32\x35\x20\x4c\ 57 | \x33\x37\x2e\x35\x36\x34\x35\x34\x33\x39\x2c\x36\x30\x20\x4c\x37\ 58 | \x32\x2e\x38\x30\x36\x35\x31\x36\x32\x2c\x36\x30\x20\x43\x37\x34\ 59 | \x2e\x30\x31\x37\x39\x30\x34\x32\x2c\x36\x30\x20\x37\x35\x2c\x35\ 60 | \x38\x2e\x39\x34\x33\x36\x32\x39\x32\x20\x37\x35\x2c\x35\x37\x2e\ 61 | \x36\x34\x30\x36\x32\x35\x20\x4c\x37\x35\x2c\x34\x33\x2e\x34\x38\ 62 | \x34\x33\x37\x35\x20\x43\x37\x35\x2c\x34\x32\x2e\x31\x38\x31\x32\ 63 | \x31\x33\x35\x20\x37\x34\x2e\x30\x31\x37\x39\x30\x34\x32\x2c\x34\ 64 | \x31\x2e\x31\x32\x35\x20\x37\x32\x2e\x38\x30\x36\x35\x31\x36\x32\ 65 | \x2c\x34\x31\x2e\x31\x32\x35\x20\x5a\x22\x20\x69\x64\x3d\x22\x50\ 66 | \x61\x74\x68\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x46\x46\x44\x33\ 67 | \x39\x31\x22\x3e\x3c\x2f\x70\x61\x74\x68\x3e\x0a\x20\x20\x20\x20\ 68 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x70\x61\x74\ 69 | \x68\x20\x64\x3d\x22\x4d\x37\x32\x2e\x38\x30\x32\x37\x33\x34\x34\ 70 | \x2c\x32\x37\x20\x4c\x32\x2e\x31\x39\x37\x32\x36\x35\x36\x32\x2c\ 71 | \x32\x37\x20\x43\x30\x2e\x39\x38\x33\x37\x38\x39\x30\x36\x32\x2c\ 72 | \x32\x37\x20\x30\x2c\x32\x38\x2e\x30\x35\x31\x32\x20\x30\x2c\x32\ 73 | \x39\x2e\x33\x34\x37\x38\x32\x36\x31\x20\x4c\x30\x2c\x34\x35\x20\ 74 | \x4c\x37\x35\x2c\x34\x35\x20\x4c\x37\x35\x2c\x32\x39\x2e\x33\x34\ 75 | \x37\x38\x32\x36\x31\x20\x43\x37\x35\x2c\x32\x38\x2e\x30\x35\x31\ 76 | \x30\x34\x33\x35\x20\x37\x34\x2e\x30\x31\x36\x32\x31\x30\x39\x2c\ 77 | \x32\x37\x20\x37\x32\x2e\x38\x30\x32\x37\x33\x34\x34\x2c\x32\x37\ 78 | \x20\x4c\x37\x32\x2e\x38\x30\x32\x37\x33\x34\x34\x2c\x32\x37\x20\ 79 | \x5a\x22\x20\x69\x64\x3d\x22\x50\x61\x74\x68\x22\x20\x66\x69\x6c\ 80 | \x6c\x3d\x22\x23\x46\x46\x44\x33\x39\x31\x22\x3e\x3c\x2f\x70\x61\ 81 | \x74\x68\x3e\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ 82 | \x20\x20\x20\x20\x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x4d\x37\x33\ 83 | \x2e\x36\x30\x33\x37\x32\x30\x33\x2c\x32\x37\x2e\x32\x30\x31\x30\ 84 | \x38\x33\x34\x20\x4c\x31\x39\x2e\x36\x30\x36\x30\x31\x38\x32\x2c\ 85 | \x34\x2e\x35\x33\x37\x32\x31\x35\x20\x43\x31\x38\x2e\x39\x39\x37\ 86 | \x39\x36\x32\x37\x2c\x34\x2e\x32\x38\x31\x38\x38\x30\x32\x20\x31\ 87 | \x38\x2e\x33\x31\x35\x37\x38\x36\x32\x2c\x34\x2e\x33\x32\x39\x39\ 88 | \x33\x32\x31\x34\x20\x31\x37\x2e\x37\x34\x34\x34\x39\x38\x32\x2c\ 89 | \x34\x2e\x36\x36\x37\x35\x35\x31\x39\x35\x20\x43\x31\x32\x2e\x32\ 90 | \x33\x35\x30\x38\x34\x36\x2c\x37\x2e\x39\x32\x32\x33\x36\x33\x39\ 91 | \x37\x20\x37\x2e\x39\x31\x33\x38\x30\x33\x36\x31\x2c\x31\x31\x2e\ 92 | \x36\x31\x36\x33\x39\x35\x38\x20\x34\x2e\x39\x30\x30\x36\x32\x35\ 93 | \x36\x33\x2c\x31\x35\x2e\x36\x34\x37\x31\x30\x35\x33\x20\x43\x31\ 94 | \x2e\x36\x34\x38\x38\x32\x35\x30\x35\x2c\x31\x39\x2e\x39\x39\x37\ 95 | \x32\x31\x38\x38\x20\x30\x2c\x32\x34\x2e\x36\x32\x32\x34\x35\x33\ 96 | \x32\x20\x30\x2c\x32\x39\x2e\x33\x39\x34\x35\x31\x32\x39\x20\x4c\ 97 | \x30\x2c\x33\x31\x2e\x37\x35\x20\x4c\x37\x35\x2c\x33\x31\x2e\x37\ 98 | \x35\x20\x43\x37\x35\x2c\x33\x31\x2e\x37\x35\x20\x37\x34\x2e\x37\ 99 | \x36\x35\x37\x37\x38\x37\x2c\x33\x30\x2e\x39\x34\x34\x32\x36\x36\ 100 | \x34\x20\x37\x34\x2e\x39\x36\x31\x36\x32\x37\x39\x2c\x32\x39\x2e\ 101 | \x38\x33\x31\x33\x37\x37\x33\x20\x43\x37\x35\x2e\x31\x35\x37\x36\ 102 | \x32\x33\x36\x2c\x32\x38\x2e\x37\x31\x38\x36\x34\x35\x32\x20\x37\ 103 | \x34\x2e\x35\x38\x37\x33\x36\x31\x2c\x32\x37\x2e\x36\x31\x33\x39\ 104 | \x32\x31\x38\x20\x37\x33\x2e\x36\x30\x33\x37\x32\x30\x33\x2c\x32\ 105 | \x37\x2e\x32\x30\x31\x30\x38\x33\x34\x20\x5a\x22\x20\x69\x64\x3d\ 106 | \x22\x50\x61\x74\x68\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x43\x35\ 107 | \x30\x30\x34\x38\x22\x3e\x3c\x2f\x70\x61\x74\x68\x3e\x0a\x20\x20\ 108 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x70\ 109 | \x61\x74\x68\x20\x64\x3d\x22\x4d\x37\x35\x2c\x32\x39\x2e\x33\x34\ 110 | \x37\x38\x32\x36\x31\x20\x43\x37\x35\x2c\x32\x38\x2e\x30\x35\x31\ 111 | \x32\x20\x37\x34\x2e\x30\x31\x37\x39\x30\x34\x32\x2c\x32\x37\x20\ 112 | \x37\x32\x2e\x38\x30\x36\x35\x31\x36\x32\x2c\x32\x37\x20\x4c\x33\ 113 | \x37\x2e\x35\x36\x34\x35\x34\x33\x39\x2c\x32\x37\x20\x4c\x33\x37\ 114 | \x2e\x35\x36\x34\x35\x34\x33\x39\x2c\x34\x35\x20\x4c\x37\x35\x2c\ 115 | \x34\x35\x20\x4c\x37\x35\x2c\x32\x39\x2e\x33\x34\x37\x38\x32\x36\ 116 | \x31\x20\x5a\x22\x20\x69\x64\x3d\x22\x50\x61\x74\x68\x22\x20\x66\ 117 | \x69\x6c\x6c\x3d\x22\x23\x46\x46\x42\x36\x34\x43\x22\x3e\x3c\x2f\ 118 | \x70\x61\x74\x68\x3e\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ 119 | \x20\x20\x20\x20\x20\x20\x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x4d\ 120 | \x37\x34\x2e\x39\x36\x31\x37\x30\x30\x36\x2c\x32\x39\x2e\x38\x33\ 121 | \x38\x39\x31\x33\x38\x20\x43\x37\x35\x2e\x31\x35\x37\x33\x35\x38\ 122 | \x37\x2c\x32\x38\x2e\x37\x33\x30\x35\x35\x32\x37\x20\x37\x34\x2e\ 123 | \x35\x38\x37\x39\x33\x32\x33\x2c\x32\x37\x2e\x36\x33\x30\x31\x36\ 124 | \x38\x37\x20\x37\x33\x2e\x36\x30\x36\x31\x33\x32\x35\x2c\x32\x37\ 125 | \x2e\x32\x31\x38\x39\x35\x32\x20\x4c\x33\x37\x2e\x35\x36\x34\x35\ 126 | \x34\x33\x39\x2c\x31\x32\x2e\x31\x32\x35\x20\x4c\x33\x37\x2e\x35\ 127 | \x36\x34\x35\x34\x33\x39\x2c\x33\x31\x2e\x37\x35\x20\x4c\x37\x35\ 128 | \x2c\x33\x31\x2e\x37\x35\x20\x43\x37\x35\x2c\x33\x31\x2e\x37\x35\ 129 | \x20\x37\x34\x2e\x37\x36\x36\x31\x38\x38\x38\x2c\x33\x30\x2e\x39\ 130 | \x34\x37\x34\x33\x31\x34\x20\x37\x34\x2e\x39\x36\x31\x37\x30\x30\ 131 | \x36\x2c\x32\x39\x2e\x38\x33\x38\x39\x31\x33\x38\x20\x5a\x22\x20\ 132 | \x69\x64\x3d\x22\x50\x61\x74\x68\x22\x20\x66\x69\x6c\x6c\x3d\x22\ 133 | \x23\x38\x31\x30\x30\x32\x46\x22\x3e\x3c\x2f\x70\x61\x74\x68\x3e\ 134 | \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ 135 | \x20\x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x4d\x34\x31\x2e\x33\x30\ 136 | \x36\x39\x31\x30\x37\x2c\x39\x2e\x33\x37\x35\x20\x43\x34\x30\x2e\ 137 | \x39\x35\x39\x35\x35\x35\x2c\x39\x2e\x33\x37\x35\x20\x34\x30\x2e\ 138 | \x36\x30\x37\x30\x37\x38\x31\x2c\x39\x2e\x32\x38\x36\x33\x33\x30\ 139 | \x30\x38\x20\x34\x30\x2e\x32\x37\x39\x30\x33\x36\x32\x2c\x39\x2e\ 140 | \x30\x39\x39\x32\x36\x30\x30\x39\x20\x43\x33\x39\x2e\x32\x30\x38\ 141 | \x35\x38\x33\x35\x2c\x38\x2e\x34\x38\x39\x30\x38\x35\x34\x39\x20\ 142 | \x33\x38\x2e\x38\x30\x31\x38\x32\x33\x32\x2c\x37\x2e\x30\x36\x33\ 143 | \x39\x33\x32\x33\x32\x20\x33\x39\x2e\x33\x37\x30\x37\x30\x32\x33\ 144 | \x2c\x35\x2e\x39\x31\x35\x39\x33\x31\x35\x20\x43\x34\x32\x2e\x32\ 145 | \x36\x38\x32\x31\x31\x32\x2c\x30\x2e\x30\x36\x37\x31\x36\x39\x34\ 146 | \x32\x36\x20\x35\x30\x2e\x31\x33\x39\x34\x36\x32\x32\x2c\x30\x20\ 147 | \x35\x30\x2e\x34\x37\x33\x30\x36\x34\x32\x2c\x30\x20\x43\x35\x31\ 148 | \x2e\x36\x38\x35\x31\x35\x31\x34\x2c\x30\x20\x35\x32\x2e\x36\x36\ 149 | \x37\x38\x31\x34\x31\x2c\x31\x2e\x30\x35\x33\x39\x39\x35\x30\x31\ 150 | \x20\x35\x32\x2e\x36\x36\x37\x38\x31\x34\x31\x2c\x32\x2e\x33\x35\ 151 | \x34\x30\x36\x38\x36\x37\x20\x43\x35\x32\x2e\x36\x36\x37\x38\x31\ 152 | \x34\x31\x2c\x33\x2e\x36\x35\x34\x31\x34\x32\x33\x32\x20\x35\x31\ 153 | \x2e\x36\x38\x35\x31\x35\x31\x34\x2c\x34\x2e\x37\x30\x38\x31\x33\ 154 | \x37\x33\x34\x20\x35\x30\x2e\x34\x37\x33\x30\x36\x34\x32\x2c\x34\ 155 | \x2e\x37\x30\x38\x31\x33\x37\x33\x34\x20\x43\x34\x38\x2e\x39\x33\ 156 | \x33\x36\x36\x36\x36\x2c\x34\x2e\x37\x31\x37\x37\x31\x30\x35\x35\ 157 | \x20\x34\x34\x2e\x36\x32\x31\x38\x36\x31\x2c\x35\x2e\x33\x34\x39\ 158 | \x38\x35\x36\x34\x35\x20\x34\x33\x2e\x32\x34\x36\x39\x32\x33\x33\ 159 | \x2c\x38\x2e\x31\x32\x34\x39\x38\x39\x35\x34\x20\x43\x34\x32\x2e\ 160 | \x38\x35\x32\x34\x35\x33\x36\x2c\x38\x2e\x39\x32\x31\x31\x33\x35\ 161 | \x35\x36\x20\x34\x32\x2e\x30\x39\x32\x36\x33\x31\x32\x2c\x39\x2e\ 162 | \x33\x37\x35\x20\x34\x31\x2e\x33\x30\x36\x39\x31\x30\x37\x2c\x39\ 163 | \x2e\x33\x37\x35\x20\x5a\x22\x20\x69\x64\x3d\x22\x50\x61\x74\x68\ 164 | \x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x38\x30\x42\x34\x30\x35\x22\ 165 | \x3e\x3c\x2f\x70\x61\x74\x68\x3e\x0a\x20\x20\x20\x20\x20\x20\x20\ 166 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x65\x6c\x6c\x69\x70\x73\ 167 | \x65\x20\x69\x64\x3d\x22\x4f\x76\x61\x6c\x22\x20\x66\x69\x6c\x6c\ 168 | \x3d\x22\x23\x46\x46\x34\x31\x35\x42\x22\x20\x63\x78\x3d\x22\x33\ 169 | \x37\x2e\x34\x33\x35\x34\x35\x36\x31\x22\x20\x63\x79\x3d\x22\x31\ 170 | \x32\x2e\x39\x33\x37\x35\x22\x20\x72\x78\x3d\x22\x38\x2e\x37\x37\ 171 | \x37\x39\x36\x39\x30\x32\x22\x20\x72\x79\x3d\x22\x39\x2e\x34\x33\ 172 | \x37\x35\x22\x3e\x3c\x2f\x65\x6c\x6c\x69\x70\x73\x65\x3e\x0a\x20\ 173 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\ 174 | \x70\x61\x74\x68\x20\x64\x3d\x22\x4d\x33\x37\x2e\x34\x33\x35\x34\ 175 | \x35\x36\x31\x2c\x33\x2e\x35\x20\x4c\x33\x37\x2e\x34\x33\x35\x34\ 176 | \x35\x36\x31\x2c\x32\x32\x2e\x33\x37\x35\x20\x43\x34\x32\x2e\x32\ 177 | \x37\x35\x36\x32\x38\x32\x2c\x32\x32\x2e\x33\x37\x35\x20\x34\x36\ 178 | \x2e\x32\x31\x33\x34\x32\x35\x31\x2c\x31\x38\x2e\x31\x34\x31\x33\ 179 | \x33\x37\x35\x20\x34\x36\x2e\x32\x31\x33\x34\x32\x35\x31\x2c\x31\ 180 | \x32\x2e\x39\x33\x37\x35\x20\x43\x34\x36\x2e\x32\x31\x33\x34\x32\ 181 | \x35\x31\x2c\x37\x2e\x37\x33\x33\x36\x36\x32\x35\x20\x34\x32\x2e\ 182 | \x32\x37\x35\x36\x32\x38\x32\x2c\x33\x2e\x35\x20\x33\x37\x2e\x34\ 183 | \x33\x35\x34\x35\x36\x31\x2c\x33\x2e\x35\x20\x5a\x22\x20\x69\x64\ 184 | \x3d\x22\x50\x61\x74\x68\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x43\ 185 | \x35\x30\x30\x34\x38\x22\x3e\x3c\x2f\x70\x61\x74\x68\x3e\x0a\x20\ 186 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x2f\x67\x3e\x0a\ 187 | \x20\x20\x20\x20\x20\x20\x20\x20\x3c\x2f\x67\x3e\x0a\x20\x20\x20\ 188 | \x20\x3c\x2f\x67\x3e\x0a\x3c\x2f\x73\x76\x67\x3e\ 189 | " 190 | 191 | qt_resource_name = b"\ 192 | \x00\x03\ 193 | \x00\x00\x70\x37\ 194 | \x00\x69\ 195 | \x00\x6d\x00\x67\ 196 | \x00\x0e\ 197 | \x0f\xd2\x43\xa7\ 198 | \x00\x73\ 199 | \x00\x6c\x00\x69\x00\x63\x00\x65\x00\x2d\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x73\x00\x76\x00\x67\ 200 | " 201 | 202 | qt_resource_struct_v1 = b"\ 203 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 204 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 205 | \x00\x00\x00\x0c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 206 | " 207 | 208 | qt_resource_struct_v2 = b"\ 209 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 210 | \x00\x00\x00\x00\x00\x00\x00\x00\ 211 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 212 | \x00\x00\x00\x00\x00\x00\x00\x00\ 213 | \x00\x00\x00\x0c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 214 | \x00\x00\x01\x78\x3d\xed\x6c\x59\ 215 | " 216 | 217 | qt_version = [int(v) for v in QtCore.qVersion().split('.')] 218 | if qt_version < [5, 8, 0]: 219 | rcc_version = 1 220 | qt_resource_struct = qt_resource_struct_v1 221 | else: 222 | rcc_version = 2 223 | qt_resource_struct = qt_resource_struct_v2 224 | 225 | def qInitResources(): 226 | QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 227 | 228 | def qCleanupResources(): 229 | QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 230 | 231 | qInitResources() 232 | -------------------------------------------------------------------------------- /src/slice/instanceworker.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | import datetime 17 | import sys 18 | import traceback 19 | 20 | from fontTools.misc.textTools import num2binary 21 | from fontTools.ttLib import sfnt 22 | from fontTools.ttLib.ttFont import TTFont 23 | from fontTools.varLib.instancer import instantiateVariableFont 24 | from PyQt5.QtCore import QObject, QRunnable, pyqtSignal, pyqtSlot 25 | 26 | 27 | class InstanceWorkerSignals(QObject): 28 | finished = pyqtSignal() # no return type, only signal that complete 29 | error = pyqtSignal(str) # returns the error message 30 | result = pyqtSignal(str) # returns file path for the new file write 31 | 32 | 33 | class InstanceWorker(QRunnable): 34 | def __init__( 35 | self, 36 | outpath=None, 37 | font_model=None, 38 | axis_model=None, 39 | name_model=None, 40 | bit_model=None, 41 | ): 42 | super().__init__() 43 | self.signals = InstanceWorkerSignals() 44 | self.outpath = outpath 45 | self.font_model = font_model 46 | self.axis_model = axis_model 47 | self.name_model = name_model 48 | self.bit_model = bit_model 49 | self.ttfont = None 50 | 51 | @pyqtSlot() 52 | def run(self): 53 | try: 54 | # Debugging in stdout 55 | print(f"\n\n{datetime.datetime.now()}") 56 | # set class fontTools.ttLib.TTFont object 57 | self.instantiate_ttfont() 58 | # gen the static font instance from a variable font 59 | self.instantiate_variable_font() 60 | # edit name table records 61 | self.edit_name_table() 62 | # edit bit flags 63 | self.edit_bit_flags() 64 | # write to disk 65 | # set fonttools to use zopfli compression on woff files 66 | sfnt.USE_ZOPFLI = True 67 | # sfnt.ZLIB_COMPRESSION_LEVEL = 9 68 | self.ttfont.save(self.outpath) 69 | except Exception as e: 70 | self.signals.error.emit(f"{e}") 71 | sys.stderr.write(f"{traceback.format_exc()}\n") 72 | else: 73 | # returns the file out file path on success 74 | self.signals.result.emit(self.outpath) 75 | 76 | self.signals.finished.emit() 77 | 78 | def instantiate_ttfont(self): 79 | self.ttfont = TTFont(self.font_model.fontpath) 80 | 81 | def instantiate_variable_font(self): 82 | axis_instance_data = self.axis_model.get_instance_data() 83 | instantiateVariableFont( 84 | self.ttfont, axis_instance_data, inplace=True, optimize=True 85 | ) 86 | print("\nAXIS INSTANCE VALUES") 87 | print( 88 | f"Instantiated variable font with axis definitions:\n{axis_instance_data}" 89 | ) 90 | 91 | def edit_name_table(self): 92 | # string, nameID, platformID, platEncID, langID 93 | name_record_plat_enc_lang = (3, 1, 1033) 94 | name_instance_data = self.name_model.get_instance_data() 95 | name_table = self.ttfont["name"] 96 | # set 3, 1, 1033 name records (only!) 97 | # mandatory writes 98 | name_table.setName(name_instance_data["nameID1"], 1, *name_record_plat_enc_lang) 99 | name_table.setName(name_instance_data["nameID2"], 2, *name_record_plat_enc_lang) 100 | name_table.setName(name_instance_data["nameID3"], 3, *name_record_plat_enc_lang) 101 | name_table.setName(name_instance_data["nameID4"], 4, *name_record_plat_enc_lang) 102 | name_table.setName(name_instance_data["nameID6"], 6, *name_record_plat_enc_lang) 103 | 104 | # optional writes 105 | # Approach: 106 | # (1) if user text data exists, write it 107 | # (2) if user text data does not exist but record does, delete it 108 | # (3) otherwise do nothing 109 | if name_instance_data["nameID16"] != "": 110 | name_table.setName( 111 | name_instance_data["nameID16"], 16, *name_record_plat_enc_lang 112 | ) 113 | elif name_table.getName(16, *name_record_plat_enc_lang): 114 | name_table.removeNames(16, *name_record_plat_enc_lang) 115 | 116 | if name_instance_data["nameID17"] != "": 117 | name_table.setName( 118 | name_instance_data["nameID17"], 17, *name_record_plat_enc_lang 119 | ) 120 | elif name_table.getName(17, *name_record_plat_enc_lang): 121 | name_table.removeNames(17, *name_record_plat_enc_lang) 122 | 123 | if name_instance_data["nameID21"] != "": 124 | name_table.setName( 125 | name_instance_data["nameID21"], 21, *name_record_plat_enc_lang 126 | ) 127 | elif name_table.getName(21, *name_record_plat_enc_lang): 128 | name_table.removeNames(21, *name_record_plat_enc_lang) 129 | 130 | if name_instance_data["nameID22"] != "": 131 | name_table.setName( 132 | name_instance_data["nameID22"], 22, *name_record_plat_enc_lang 133 | ) 134 | elif name_table.getName(22, *name_record_plat_enc_lang): 135 | name_table.removeNames(22, *name_record_plat_enc_lang) 136 | 137 | # update name table data 138 | self.ttfont["name"] = name_table 139 | 140 | # print name table report 141 | print("\nNAME TABLE EDITS") 142 | print("Name records at write time:\n") 143 | print(f"nameID1: {self.ttfont['name'].getName(1, *name_record_plat_enc_lang)}") 144 | print(f"nameID2: {self.ttfont['name'].getName(2, *name_record_plat_enc_lang)}") 145 | print(f"nameID3: {self.ttfont['name'].getName(3, *name_record_plat_enc_lang)}") 146 | print(f"nameID4: {self.ttfont['name'].getName(4, *name_record_plat_enc_lang)}") 147 | print(f"nameID6: {self.ttfont['name'].getName(6, *name_record_plat_enc_lang)}") 148 | print( 149 | f"nameID16: {self.ttfont['name'].getName(16, *name_record_plat_enc_lang)}" 150 | ) 151 | print( 152 | f"nameID17: {self.ttfont['name'].getName(17, *name_record_plat_enc_lang)}" 153 | ) 154 | print( 155 | f"nameID21: {self.ttfont['name'].getName(21, *name_record_plat_enc_lang)}" 156 | ) 157 | print( 158 | f"nameID22: {self.ttfont['name'].getName(22, *name_record_plat_enc_lang)}" 159 | ) 160 | 161 | def edit_bit_flags(self): 162 | # edit the OS/2.fsSelection bit flag 163 | pre_os2_fsselection_int = self.ttfont["OS/2"].fsSelection 164 | edited_os2_fsselection_int = self.bit_model.edit_os2_fsselection_bits( 165 | pre_os2_fsselection_int 166 | ) 167 | # edit OS/2.fsSelection in the TTFont attribute 168 | self.ttfont["OS/2"].fsSelection = edited_os2_fsselection_int 169 | 170 | # edit head.macstyle bit flag 171 | pre_head_macstyle_int = self.ttfont["head"].macStyle 172 | edited_head_macstyle_int = self.bit_model.edit_head_macstyle_bits( 173 | pre_head_macstyle_int 174 | ) 175 | self.ttfont["head"].macStyle = edited_head_macstyle_int 176 | 177 | # bit flag debugging stdout report 178 | print("\nBIT FLAGS") 179 | print( 180 | f"\nOS/2.fsSelection updated with the following data:\n" 181 | f"{self.bit_model.get_os2_instance_data()}" 182 | ) 183 | print(f"Pre OS/2.fsSelection: {num2binary(pre_os2_fsselection_int, bits=16)}") 184 | print( 185 | f"Post OS/2.fsSelection: {num2binary(self.ttfont['OS/2'].fsSelection, bits=16)}" 186 | ) 187 | print( 188 | f"\nhead.macStyle bit flag updated with the following data:\n" 189 | f"{self.bit_model.get_head_instance_data()}" 190 | ) 191 | print(f"Pre head.macStyle: {num2binary(pre_head_macstyle_int, bits=16)}") 192 | print( 193 | f"Post head.macStyle: {num2binary(self.ttfont['head'].macStyle, bits=16)}" 194 | ) 195 | -------------------------------------------------------------------------------- /src/slice/models.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | import re 17 | 18 | from fontTools.ttLib import TTFont 19 | from PyQt5.QtCore import QAbstractTableModel, Qt 20 | 21 | 22 | class SliceBaseTableModel(QAbstractTableModel): 23 | def __init__(self, *args): 24 | QAbstractTableModel.__init__(self, *args) 25 | self._data = [[]] 26 | self._v_header = [] 27 | 28 | def data(self, index, role): 29 | if role in (Qt.DisplayRole, Qt.EditRole): 30 | return self._data[index.row()][index.column()] 31 | 32 | def setData(self, index, value, role): 33 | if index.isValid() and role == Qt.EditRole: 34 | self._data[index.row()][index.column()] = value 35 | self.dataChanged.emit(index, index, [role]) 36 | return True 37 | else: 38 | return False 39 | 40 | def rowCount(self, index): 41 | # the index validity check approach addresses the qabstractitemmodel.cpp check: 42 | # QtWarningMsg: FAIL! model->hasChildren(topIndex) () returned FALSE (qabstractitemmodeltester.cpp:366) 43 | # See https://stackoverflow.com/a/50988188/2848172 44 | if index.isValid(): 45 | return 0 46 | else: 47 | return len(self._data) 48 | 49 | def columnCount(self, index): 50 | # the index validity check approach addresses the qabstractitemmodel.cpp check: 51 | # QtWarningMsg: FAIL! model->hasChildren(topIndex) () returned FALSE (qabstractitemmodeltester.cpp:366) 52 | # See https://stackoverflow.com/a/50988188/2848172 53 | if index.isValid(): 54 | return 0 55 | else: 56 | return len(self._data[0]) 57 | 58 | def get_data(self): 59 | return self._data 60 | 61 | 62 | class FontNameModel(SliceBaseTableModel): 63 | def __init__(self, *args): 64 | SliceBaseTableModel.__init__(self, *args) 65 | self.font_version = None 66 | self.font_family_name = None 67 | self._data = [ 68 | [""], # nameID 1 (index 0) 69 | [""], # nameID 2 (index 1) 70 | [""], # nameID 3 (index 2) 71 | [""], # nameID 4 (index 3) 72 | [""], # nameID 6 (index 4) 73 | [""], # nameID 16 (index 5) 74 | [""], # nameID 17 (index 6) 75 | [""], # nameID 21 (index 7) 76 | [""], # nameID 22 (index 8) 77 | ] 78 | self._v_header = [ 79 | "01 Family", 80 | "02 Subfamily", 81 | "03 Unique", 82 | "04 Full", 83 | "06 Postscript", 84 | "16 Typo Family", 85 | "17 Typo Subfamily", 86 | "21 WWS Family", 87 | "22 WWS Subfamily", 88 | ] 89 | 90 | def load_font(self, font_model): 91 | ttfont = TTFont(font_model.fontpath) 92 | name = ttfont["name"] 93 | plat_id = 3 94 | plat_enc_id = 1 95 | lang_id = 1033 96 | for record in name.names: 97 | if ( 98 | record.nameID == 1 99 | and record.platformID == plat_id 100 | and record.platEncID == plat_enc_id 101 | and record.langID == lang_id 102 | ): 103 | self._data[0][0] = record.toUnicode() 104 | self.font_family_name = record.toUnicode() 105 | elif ( 106 | record.nameID == 2 107 | and record.platformID == plat_id 108 | and record.platEncID == plat_enc_id 109 | and record.langID == lang_id 110 | ): 111 | self._data[1][0] = record.toUnicode() 112 | elif ( 113 | record.nameID == 3 114 | and record.platformID == plat_id 115 | and record.platEncID == plat_enc_id 116 | and record.langID == lang_id 117 | ): 118 | self._data[2][0] = record.toUnicode() 119 | elif ( 120 | record.nameID == 4 121 | and record.platformID == plat_id 122 | and record.platEncID == plat_enc_id 123 | and record.langID == lang_id 124 | ): 125 | self._data[3][0] = record.toUnicode() 126 | elif ( 127 | record.nameID == 5 128 | and record.platformID == plat_id 129 | and record.platEncID == plat_enc_id 130 | and record.langID == lang_id 131 | ): 132 | self.font_version = record.toUnicode() 133 | elif ( 134 | record.nameID == 6 135 | and record.platformID == plat_id 136 | and record.platEncID == plat_enc_id 137 | and record.langID == lang_id 138 | ): 139 | self._data[4][0] = record.toUnicode() 140 | 141 | self.layoutChanged.emit() 142 | return True 143 | 144 | def headerData(self, section, orientation, role): 145 | if orientation == Qt.Vertical and role == Qt.DisplayRole: 146 | return self._v_header[section] 147 | elif orientation == Qt.Horizontal and role == Qt.DisplayRole: 148 | return "Edit Values" 149 | 150 | def flags(self, index): 151 | # Note: index validity checks in this block address qabstractitemmodeltester error: 152 | # QtWarningMsg: FAIL! flags == Qt::ItemIsDropEnabled || flags == 0 () returned FALSE (qabstractitemmodeltester.cpp:329) 153 | 154 | # all indices are editable in this table 155 | if index.isValid(): 156 | return super().flags(index) | Qt.ItemIsEditable 157 | else: 158 | return super().flags(index) 159 | 160 | def get_version(self): 161 | return self.font_version.split(";")[0] 162 | 163 | def get_family_name(self): 164 | return self.font_family_name 165 | 166 | def get_instance_data(self): 167 | return { 168 | "nameID1": self._data[0][0], 169 | "nameID2": self._data[1][0], 170 | "nameID3": self._data[2][0], 171 | "nameID4": self._data[3][0], 172 | "nameID6": self._data[4][0], 173 | "nameID16": self._data[5][0], 174 | "nameID17": self._data[6][0], 175 | "nameID21": self._data[7][0], 176 | "nameID22": self._data[8][0], 177 | } 178 | 179 | 180 | class DesignAxisModel(SliceBaseTableModel): 181 | def __init__(self, *args): 182 | SliceBaseTableModel.__init__(self, *args) 183 | self.fvar_axes = {} 184 | self.fvar_name_map = {} 185 | self.ordered_axis_tags = [] 186 | self._data = [ 187 | ["", ""], 188 | ["", ""], 189 | ["", ""], 190 | ["", ""], 191 | ["", ""], 192 | ] 193 | # temp fields on load 194 | self._v_header = [ 195 | "Axis 1", 196 | "Axis 2", 197 | "Axis 3", 198 | "Axis 4", 199 | "Axis 5", 200 | ] 201 | self._h_header = ["Min : Max [Default]", "Edit Values"] 202 | self.axis_range_regex = re.compile( 203 | r"(?P\-?\d+(\.\d+)?)\s*\:\s*(?P\-?\d+(\.\d+)?)\s*(\[\s*(?P\-?\d+(\.?\d+)?)\s*\])?" 204 | ) 205 | 206 | def data(self, index, role): 207 | if role in (Qt.DisplayRole, Qt.EditRole): 208 | return self._data[index.row()][index.column()] 209 | 210 | if role == Qt.TextAlignmentRole: 211 | return Qt.AlignCenter 212 | 213 | def headerData(self, section, orientation, role): 214 | if orientation == Qt.Vertical and role == Qt.DisplayRole: 215 | return self._v_header[section] 216 | elif orientation == Qt.Horizontal and role == Qt.DisplayRole: 217 | return self._h_header[section] 218 | 219 | if orientation == Qt.Vertical and role == Qt.TextAlignmentRole: 220 | return Qt.AlignCenter 221 | 222 | # add full registered axis strings in tooltips 223 | if role == Qt.ToolTipRole: 224 | if orientation == Qt.Vertical: 225 | axis_name = self.get_axis_name_string(self._v_header[section]) 226 | # if we receive a axis name string value, create a tooltip 227 | # with the full axis name. The method returns None if the 228 | # axis name is not available. Skip tooltip gen if that is 229 | # the case 230 | if axis_name: 231 | return axis_name 232 | 233 | def flags(self, index): 234 | # Note: index validity checks in this block address qabstractitemmodeltester error: 235 | # QtWarningMsg: FAIL! flags == Qt::ItemIsDropEnabled || flags == 0 () returned FALSE (qabstractitemmodeltester.cpp:329) 236 | 237 | # column 0 (axis value range and default) is set 238 | # to non-editable 239 | if index.isValid() and index.column() == 0: 240 | return super().flags(index) | Qt.ItemIsSelectable 241 | # column 1 (instance value) is set to editable 242 | elif index.isValid() and index.column() == 1: 243 | return super().flags(index) | Qt.ItemIsEditable 244 | else: 245 | return super().flags(index) 246 | 247 | def load_font(self, font_model): 248 | ttfont = TTFont(font_model.fontpath) 249 | fvar = ttfont["fvar"] 250 | # used to re-define the model data on each 251 | # new font load 252 | new_data = [] 253 | # clear the axis tag list attribute 254 | self.ordered_axis_tags = [] 255 | for axis in fvar.axes: 256 | # maintain order of axes in the font 257 | self.ordered_axis_tags.append(axis.axisTag) 258 | # create a map of the min, default, max axis values 259 | self.fvar_axes[axis.axisTag] = [ 260 | axis.minValue, 261 | axis.defaultValue, 262 | axis.maxValue, 263 | ] 264 | new_data.append( 265 | [f"{axis.minValue} : {axis.maxValue} [{axis.defaultValue}]", ""] 266 | ) 267 | # use the axisID to locate the axis name in the name table 268 | # if it does not exist, the getName method returns None 269 | self.fvar_name_map[axis.axisTag] = ( 270 | ttfont["name"].getName(axis.axisNameID, 3, 1, 1033).toUnicode() 271 | ) 272 | 273 | # set header with ordered axis tags 274 | self._v_header = self.ordered_axis_tags 275 | self._data = new_data 276 | self.layoutChanged.emit() 277 | return True 278 | 279 | def get_number_of_axes(self): 280 | return len(self.ordered_axis_tags) 281 | 282 | def get_instance_data(self): 283 | instance_data = {} 284 | # return a dictionary with map "axis_tag": "value" 285 | # value is cast to a float from a str 286 | for x, axistag in enumerate(self._v_header): 287 | axis_value = self._data[x][1] 288 | if axis_value == "": 289 | # if user did not define the axis value, then 290 | # it remains a variable axis 291 | pass 292 | elif ":" in axis_value: 293 | subspace_range = self.parse_subspace_range(axis_value, axistag)[0] 294 | # for future L4 sub-space support 295 | # subspace_default = self.parse_subspace_range(axis_value, axistag)[1] 296 | instance_data[axistag] = subspace_range 297 | else: 298 | # else use the numeric value set in the editor 299 | try: 300 | instance_data[axistag] = float(self._data[x][1]) 301 | except ValueError: 302 | raise ValueError( 303 | f"'{axis_value}' is not a valid {axistag} axis value. " 304 | f"Please enter a single numeric value and try again." 305 | ) 306 | 307 | return instance_data 308 | 309 | def parse_subspace_range(self, range_string, axistag): 310 | match = self.axis_range_regex.search(range_string) 311 | 312 | # confirm that we match on the regular expression parser 313 | # and that there will be group methods to execute on the regex 314 | if not match: 315 | raise ValueError( 316 | f"{range_string} is not a valid axis range definition for {axistag}." 317 | ) 318 | 319 | start_string = match.group("start") 320 | end_string = match.group("end") 321 | default_string = match.group("default") 322 | 323 | if not start_string or not end_string: 324 | raise ValueError( 325 | f"{range_string} is not a valid axis range definition for {axistag}." 326 | ) 327 | 328 | float_range_list = [] 329 | 330 | # cast to float with numeric type validations 331 | try: 332 | float_range_list.append(float(start_string)) 333 | except ValueError: 334 | raise ValueError(f"{start_string} is not a valid axis value for {axistag}.") 335 | 336 | try: 337 | float_range_list.append(float(end_string)) 338 | except ValueError: 339 | raise ValueError(f"{end_string} is not a valid axis value for {axistag}.") 340 | # sort the values in case they were entered in reverse numeric order 341 | # e.g., 800:400, not 400:800 342 | sorted_range_list = sorted(float_range_list) 343 | # We only support Level 3 sub-spacing now due to the support 344 | # that is available in fontTools lib. Let's check that user 345 | # included the default axis value in the range request 346 | self.subspace_data_validates_includes_default_value(sorted_range_list, axistag) 347 | # return the tuple range required for L3 support at index 0 348 | # return the default value (currently as string or None) required for 349 | # (future) L4 support at index 1 350 | return ((sorted_range_list[0], sorted_range_list[1]), default_string) 351 | 352 | def subspace_data_validates_includes_default_value(self, range_list, axistag): 353 | """Validates Level 3 sub-space requirement that restricted axis range 354 | includes the default axis value.""" 355 | default = self.get_default_axis_value(axistag) 356 | if default < range_list[0] or default > range_list[1]: 357 | raise ValueError( 358 | f"The {axistag} range {range_list[0]}:{range_list[1]} does not " 359 | f"include the default axis value ({default}). This is currently a " 360 | f"requirement." 361 | ) 362 | 363 | def instance_data_validates_missing_data(self): 364 | # validator that returns True if there is at least one 365 | # axis tag with a defined instance, and False if all 366 | # axis tags have blank entry fields = the original variable 367 | # font that the user entered 368 | try: 369 | return len(self.get_instance_data()) != 0 370 | except ValueError as e: 371 | raise e 372 | 373 | def get_default_axis_value(self, axistag): 374 | if axistag in self.fvar_axes: 375 | # field that contains the default axis value 376 | return self.fvar_axes[axistag][1] 377 | else: 378 | return None 379 | 380 | def get_axis_name_string(self, needle): 381 | registered_axes = { 382 | "ital": "Italic", 383 | "opsz": "Optical size", 384 | "slnt": "Slant", 385 | "wdth": "Width", 386 | "wght": "Weight", 387 | } 388 | # Uses Google Fonts axis registry 389 | # https://fonts.google.com/variablefonts#axis-definitions 390 | unregistered_axes = { 391 | "CASL": "Casual", 392 | "CRSV": "Cursive", 393 | "XPRN": "Expression", 394 | "GRAD": "Grade", 395 | "MONO": "Monospace", 396 | "SOFT": "Softness", 397 | "WONK": "Wonky", 398 | } 399 | if needle in registered_axes: 400 | return registered_axes[needle] 401 | elif needle in unregistered_axes: 402 | return unregistered_axes[needle] 403 | else: 404 | if needle in self.fvar_name_map: 405 | return self.fvar_name_map[needle] 406 | else: 407 | return None 408 | 409 | 410 | class FontBitFlagModel(object): 411 | def __init__(self, os2_dict, head_dict): 412 | self._os2_dict = os2_dict 413 | self._head_dict = head_dict 414 | 415 | def _set_bit(self, int_type, offset): 416 | mask = 1 << offset 417 | return int_type | mask 418 | 419 | def _clear_bit(self, int_type, offset): 420 | mask = ~(1 << offset) 421 | return int_type & mask 422 | 423 | def _get_bit_offset_from_key(self, bitkey): 424 | # dict key formatted as e.g., `bit0` 425 | # grab the integer portion and cast to int 426 | return int(bitkey.replace("bit", "")) 427 | 428 | def _edit_bits(self, integer, bit_dict): 429 | for bitkey, is_set in bit_dict.items(): 430 | offset = self._get_bit_offset_from_key(bitkey) 431 | if is_set: 432 | integer = self._set_bit(integer, offset) 433 | else: 434 | integer = self._clear_bit(integer, offset) 435 | return integer 436 | 437 | def get_os2_instance_data(self): 438 | return self._os2_dict 439 | 440 | def get_head_instance_data(self): 441 | return self._head_dict 442 | 443 | def edit_os2_fsselection_bits(self, integer): 444 | return self._edit_bits(integer, self._os2_dict) 445 | 446 | def edit_head_macstyle_bits(self, integer): 447 | return self._edit_bits(integer, self._head_dict) 448 | 449 | 450 | class FontModel(object): 451 | def __init__(self, fontpath): 452 | self.fontpath = fontpath 453 | 454 | def is_variable_font(self): 455 | """Check for fvar table to validate that a TTFont is a variable font""" 456 | return "fvar" in TTFont(self.fontpath) 457 | -------------------------------------------------------------------------------- /src/slice/ui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/src/slice/ui/__init__.py -------------------------------------------------------------------------------- /src/slice/ui/dialogs.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | from fontTools import __version__ as fonttools_version 16 | from PyQt5.QtCore import QDir, Qt 17 | from PyQt5.QtGui import QFont, QFontDatabase, QIcon, QImage, QPixmap 18 | from PyQt5.QtWidgets import ( 19 | QDesktopWidget, 20 | QDialog, 21 | QDialogButtonBox, 22 | QFileDialog, 23 | QLabel, 24 | QMessageBox, 25 | QProgressBar, 26 | QTextBrowser, 27 | QVBoxLayout, 28 | QWidget, 29 | ) 30 | 31 | from ..imageresources import * 32 | 33 | 34 | class SliceOpenFileDialog(QFileDialog): 35 | def __init__(self): 36 | QFileDialog.__init__(self) 37 | self.file_path = None 38 | self.root_directory = QDir.homePath() 39 | 40 | self.setWindowTitle("Open File") 41 | self.setWindowIcon(QIcon(":/img/slice-icon.svg")) 42 | # options |= QFileDialog.DontUseNativeDialog 43 | 44 | file_path, _ = self.getOpenFileName( 45 | self, 46 | "Open File", 47 | self.root_directory, 48 | "All Files (*);;ttf Files(*.ttf);;otf Files (*.otf);;" 49 | "woff Files (*.woff);;woff2 Files (*.woff2)", 50 | options=self.Options(), 51 | ) 52 | 53 | if file_path: 54 | self.file_path = file_path 55 | 56 | def get_file_path(self): 57 | return self.file_path 58 | 59 | 60 | class SliceSaveFileDialog(QFileDialog): 61 | def __init__(self, root_directory=None): 62 | QFileDialog.__init__(self) 63 | self.file_path = None 64 | self.root_directory = None 65 | 66 | self.setWindowTitle("Save File") 67 | self.setWindowIcon(QIcon(":/img/slice-icon.svg")) 68 | 69 | if root_directory: 70 | self.root_directory = root_directory 71 | else: 72 | self.root_directory = QDir.homePath() 73 | 74 | file_path, _ = self.getSaveFileName( 75 | self, 76 | "Save File", 77 | self.root_directory, 78 | "All Files (*);;ttf Files(*.ttf);;otf Files (*.otf);;" 79 | "woff Files (*.woff);;woff2 Files (*.woff2)", 80 | options=self.Options(), 81 | ) 82 | 83 | if file_path: 84 | self.file_path = file_path 85 | 86 | def get_file_path(self): 87 | return self.file_path 88 | 89 | 90 | class SliceAboutDialog(QDialog): 91 | def __init__(self, version): 92 | QDialog.__init__(self) 93 | 94 | self.setGeometry(0, 0, 375, 425) 95 | rect = self.frameGeometry() 96 | centerCoord = QDesktopWidget().availableGeometry().center() 97 | rect.moveCenter(centerCoord) 98 | self.move(rect.topLeft()) 99 | 100 | self.setWindowTitle("About Slice") 101 | self.setWindowIcon(QIcon(":/img/slice-icon.svg")) 102 | 103 | QBtn = QDialogButtonBox.Ok 104 | self.buttonBox = QDialogButtonBox(QBtn) 105 | self.buttonBox.accepted.connect(self.accept) 106 | self.buttonBox.rejected.connect(self.reject) 107 | 108 | layout = QVBoxLayout() 109 | 110 | title = QLabel("Slice") 111 | 112 | recursive_id = QFontDatabase.addApplicationFont(":/font/RecursiveSans.ttf") 113 | font_family = QFontDatabase.applicationFontFamilies(recursive_id)[0] 114 | recursive = QFont(font_family) 115 | recursive.setPointSize(30) 116 | title.setFont(recursive) 117 | 118 | layout.addWidget(title) 119 | 120 | logoLabel = QLabel() 121 | qimage = QImage(":/img/slice-icon.svg") 122 | pixmap = QPixmap.fromImage(qimage) 123 | logoLabel.setPixmap(pixmap) 124 | logoLabel.setFixedHeight(60) 125 | logoLabel.setFixedWidth(75) 126 | 127 | layout.addWidget(logoLabel) 128 | 129 | layout.addWidget(QLabel(f"Version {version}")) 130 | layout.addWidget(QLabel("Copyright 2021 Christopher Simpkins")) 131 | licenseLink = QLabel( 132 | "

GPLv3 License

" 133 | ) 134 | licenseLink.setOpenExternalLinks(True) 135 | layout.addWidget(licenseLink) 136 | sourceLink = QLabel( 137 | "

Source

" 138 | ) 139 | sourceLink.setOpenExternalLinks(True) 140 | layout.addWidget(sourceLink) 141 | layout.addWidget(QLabel("❤️ Built with these fine tools ❤️")) 142 | 143 | attributionTextField = QTextBrowser() 144 | attributionTextField.setOpenExternalLinks(True) 145 | 146 | attributionTextField.setHtml( 147 | f"" 153 | ) 154 | attributionTextField.setMaximumHeight(200) 155 | attributionTextField.setMinimumWidth(350) 156 | layout.addWidget(attributionTextField) 157 | 158 | for i in range(0, layout.count()): 159 | layout.itemAt(i).setAlignment(Qt.AlignHCenter) 160 | 161 | layout.addWidget(self.buttonBox) 162 | 163 | self.setLayout(layout) 164 | self.exec_() 165 | 166 | 167 | class SliceProgressDialog(QWidget): 168 | def __init__(self, close_signal): 169 | QWidget.__init__(self) 170 | 171 | layout = QVBoxLayout() 172 | 173 | self.setGeometry(0, 0, 200, 75) 174 | rect = self.frameGeometry() 175 | centerCoord = QDesktopWidget().availableGeometry().center() 176 | rect.moveCenter(centerCoord) 177 | self.move(rect.topLeft()) 178 | 179 | self.message = QLabel("Slicing...") 180 | self.progress_bar = QProgressBar(self) 181 | self.progress_bar.setRange(0, 0) 182 | 183 | layout.addWidget(self.message) 184 | layout.addWidget(self.progress_bar) 185 | 186 | self.setLayout(layout) 187 | close_signal.connect(self.close_progress_dialog) 188 | self.show() 189 | 190 | def close_progress_dialog(self): 191 | self.message.setText("Complete") 192 | self.progress_bar.setRange(0, 1) 193 | self.hide() 194 | 195 | 196 | class SliceErrorDialog(QMessageBox): 197 | def __init__(self, inform_text, detailed_text=None): 198 | QMessageBox.__init__(self) 199 | self.setIcon(QMessageBox.Critical) 200 | self.setText("Error") 201 | self.setWindowTitle("Error") 202 | self.setInformativeText(f"{inform_text}") 203 | if detailed_text: 204 | self.setDetailedText(f"{detailed_text}") 205 | self.setStandardButtons(QMessageBox.Ok) 206 | self.exec_() 207 | -------------------------------------------------------------------------------- /src/slice/ui/widgets.py: -------------------------------------------------------------------------------- 1 | # This file is part of Slice. 2 | # 3 | # Slice is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Slice is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with Slice. If not, see . 15 | 16 | from PyQt5.QtWidgets import QLineEdit, QSizePolicy 17 | 18 | 19 | class DragDropLineEdit(QLineEdit): 20 | def __init__(self, parent, *args): 21 | QLineEdit.__init__(self, *args) 22 | # sets widget to accept drag and drop 23 | self.parent = parent 24 | self.setAcceptDrops(True) 25 | self.setClearButtonEnabled(True) 26 | self.setTextMargins(5, 5, 5, 5) 27 | self.setMinimumWidth(625) 28 | self.setMaximumWidth(2500) 29 | self.setMinimumHeight(35) 30 | self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) 31 | self.setPlaceholderText("Drop a variable font here or click the Open button") 32 | 33 | def dragEnterEvent(self, e): 34 | if e.mimeData().hasUrls(): 35 | e.accept() 36 | else: 37 | e.ignore() 38 | 39 | def dropEvent(self, e): 40 | file_path = e.mimeData().urls()[0].toLocalFile() 41 | # set the text entry area 42 | self.setText(file_path) 43 | # call the parent method to load font on UI 44 | self.parent.load_font(file_path) 45 | -------------------------------------------------------------------------------- /target/InnoSetup-Windows/Slice-Installer.iss: -------------------------------------------------------------------------------- 1 | ; -- Slice-Installer.iss -- 2 | ; Creates a minimal Windows installer for the Slice application 3 | 4 | ; Copyright (C) 2021 Christopher Simpkins 5 | ; 6 | ; This program is free software: you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation, either version 3 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program. If not, see . 18 | 19 | #define BUILDPATH "..\..\dist\Slice.exe" 20 | #define SliceVersion "0.7.1" 21 | 22 | [Setup] 23 | AppName=Slice 24 | AppVersion={#SliceVersion} 25 | AppPublisher="Christopher Simpkins" 26 | AppPublisherURL=https://github.com/source-foundry/Slice 27 | AppReadmeFile=https://github.com/source-foundry/Slice/blob/main/README.md 28 | AppSupportURL=https://github.com/source-foundry/Slice/issues 29 | AppUpdatesURL=https://github.com/source-foundry/Slice/releases 30 | AppCopyright="Copyright 2021 Christopher Simpkins. GPLv3 License" 31 | WizardStyle=modern 32 | DefaultDirName={autopf}\Slice 33 | DisableProgramGroupPage=yes 34 | SetupIconFile=..\..\icons\Icon.ico 35 | UninstallDisplayIcon={app}\Slice.exe 36 | Compression=lzma2 37 | SolidCompression=yes 38 | OutputBaseFilename=Slice-{#SliceVersion}-Installer 39 | OutputDir=..\..\dist\Windows-Installer 40 | LicenseFile=..\..\LICENSE 41 | 42 | [Files] 43 | Source: {#BUILDPATH}; DestDir: "{app}" 44 | 45 | [Tasks] 46 | Name: desktopicon; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:" 47 | Name: desktopicon\common; Description: "For all users"; GroupDescription: "Additional icons:"; Flags: exclusive 48 | Name: desktopicon\user; Description: "For the current user only"; GroupDescription: "Additional icons:"; Flags: exclusive unchecked 49 | 50 | [Icons] 51 | Name: "{autoprograms}\Slice"; Filename: "{app}\Slice.exe" 52 | Name: "{commondesktop}\Slice"; Filename: "{app}\Slice.exe"; Tasks: desktopicon -------------------------------------------------------------------------------- /target/PyInstaller-Windows/Slice-Windows.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | # This file is part of Slice. 4 | # 5 | # Slice is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Slice is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Slice. If not, see . 17 | 18 | import json 19 | from pathlib import Path 20 | 21 | 22 | with open(Path("src/build/settings/base.json")) as f: 23 | base_json = json.load(f) 24 | VERSION = base_json["version"] 25 | APP_NAME = base_json["app_name"] 26 | MAIN_MODULE_PATH = base_json["main_module"] 27 | 28 | ICON_PATH = Path("icons/Icon.ico").resolve() 29 | 30 | block_cipher = None 31 | 32 | 33 | a = Analysis([Path(MAIN_MODULE_PATH).resolve()], 34 | pathex=[Path('target/PyInstaller-Windows').resolve()], 35 | binaries=[], 36 | datas=[], 37 | hiddenimports=[], 38 | hookspath=[], 39 | runtime_hooks=[], 40 | excludes=[], 41 | win_no_prefer_redirects=False, 42 | win_private_assemblies=False, 43 | cipher=block_cipher, 44 | noarchive=False) 45 | pyz = PYZ(a.pure, a.zipped_data, 46 | cipher=block_cipher) 47 | exe = EXE(pyz, 48 | a.scripts, 49 | a.binaries, 50 | a.zipfiles, 51 | a.datas, 52 | [], 53 | name=APP_NAME, 54 | debug=False, 55 | bootloader_ignore_signals=False, 56 | strip=False, 57 | upx=False, 58 | console=False , 59 | runtime_tmpdir=None, 60 | icon=[str(ICON_PATH)], ) 61 | -------------------------------------------------------------------------------- /target/PyInstaller-macOS/Slice-macOS.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | # This file is part of Slice. 4 | # 5 | # Slice is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Slice is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Slice. If not, see . 17 | 18 | import json 19 | from pathlib import Path 20 | 21 | 22 | with open(Path("src/build/settings/base.json")) as f: 23 | base_json = json.load(f) 24 | VERSION = base_json["version"] 25 | APP_NAME = base_json["app_name"] 26 | MAIN_MODULE_PATH = base_json["main_module"] 27 | 28 | with open(Path("src/build/settings/macos.json")) as f_macos: 29 | macos_json = json.load(f_macos) 30 | BUNDLE_ID = macos_json["bundle_identifier"] 31 | 32 | ICON_PATH = Path("icons/Icon.icns").resolve() 33 | 34 | 35 | block_cipher = None 36 | 37 | 38 | a = Analysis([Path(MAIN_MODULE_PATH).resolve()], 39 | pathex=[Path('target/PyInstaller-macOS').resolve()], 40 | binaries=[], 41 | datas=[], 42 | hiddenimports=[], 43 | excludes=[], 44 | win_no_prefer_redirects=False, 45 | win_private_assemblies=False, 46 | cipher=block_cipher, 47 | noarchive=False) 48 | pyz = PYZ(a.pure, a.zipped_data, 49 | cipher=block_cipher) 50 | exe = EXE(pyz, 51 | a.scripts, 52 | [], 53 | exclude_binaries=True, 54 | name=APP_NAME, 55 | debug=False, 56 | bootloader_ignore_signals=False, 57 | strip=False, 58 | upx=False, 59 | console=False , 60 | icon=ICON_PATH, 61 | ) 62 | coll = COLLECT(exe, 63 | a.binaries, 64 | a.zipfiles, 65 | a.datas, 66 | strip=False, 67 | upx=False, 68 | upx_exclude=[], 69 | name=APP_NAME) 70 | app = BUNDLE(coll, 71 | name=f'{APP_NAME}.app', 72 | icon=ICON_PATH, 73 | bundle_identifier=BUNDLE_ID, 74 | info_plist={ 75 | 'NSPrincipalClass': 'NSApplication', 76 | 'NSRequiresAquaSystemAppearance': False, 77 | 'CFBundleShortVersionString': VERSION, 78 | }, 79 | ) 80 | -------------------------------------------------------------------------------- /tests/assets/fonts/Recursive-Sliced.subset.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/tests/assets/fonts/Recursive-Sliced.subset.ttf -------------------------------------------------------------------------------- /tests/assets/fonts/Recursive-VF.subset.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/tests/assets/fonts/Recursive-VF.subset.ttf -------------------------------------------------------------------------------- /tests/assets/fonts/Recursive-VF.subset.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/tests/assets/fonts/Recursive-VF.subset.woff -------------------------------------------------------------------------------- /tests/assets/fonts/Recursive-VF.subset.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/Slice/074ee9448d2b5e4ede44c1104db73239f38bfca8/tests/assets/fonts/Recursive-VF.subset.woff2 -------------------------------------------------------------------------------- /tests/test_models_designaxis.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import pytest 4 | 5 | from PyQt5.QtWidgets import QTableView 6 | 7 | from slice.models import DesignAxisModel, FontModel 8 | 9 | 10 | def get_font_model(): 11 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve()) 12 | 13 | 14 | def get_font_model_woff(): 15 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.woff").resolve()) 16 | 17 | 18 | def get_font_model_woff2(): 19 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.woff2").resolve()) 20 | 21 | 22 | def test_designaxis_model_default(qtbot, qtmodeltester): 23 | tableview = QTableView() 24 | model = DesignAxisModel() 25 | tableview.setModel(model) 26 | qtbot.addWidget(tableview) 27 | # check model with default instantiation 28 | qtmodeltester.check(model) 29 | 30 | 31 | def test_designaxis_model_filled(qtbot, qtmodeltester): 32 | tableview = QTableView() 33 | model = DesignAxisModel() 34 | tableview.setModel(model) 35 | qtbot.addWidget(tableview) 36 | model.load_font(get_font_model()) 37 | 38 | # test with qtmodeltester 39 | qtmodeltester.check(model) 40 | 41 | # confirm that font data loaded appropriately 42 | assert model._h_header == ["Min : Max [Default]", "Edit Values"] 43 | assert model.ordered_axis_tags == ["MONO", "CASL", "wght", "slnt", "CRSV"] 44 | assert model._v_header == ["MONO", "CASL", "wght", "slnt", "CRSV"] 45 | assert model.fvar_axes == { 46 | "MONO": [0.0, 0.0, 1.0], 47 | "CASL": [0.0, 0.0, 1.0], 48 | "wght": [300.0, 300.0, 1000.0], 49 | "slnt": [-15.0, 0.0, 0.0], 50 | "CRSV": [0.0, 0.5, 1.0], 51 | } 52 | assert model._data == [ 53 | ["0.0 : 1.0 [0.0]", ""], 54 | ["0.0 : 1.0 [0.0]", ""], 55 | ["300.0 : 1000.0 [300.0]", ""], 56 | ["-15.0 : 0.0 [0.0]", ""], 57 | ["0.0 : 1.0 [0.5]", ""], 58 | ] 59 | 60 | 61 | def test_designaxis_model_filled_woff(qtbot, qtmodeltester): 62 | tableview = QTableView() 63 | model = DesignAxisModel() 64 | tableview.setModel(model) 65 | qtbot.addWidget(tableview) 66 | model.load_font(get_font_model_woff()) 67 | 68 | # test with qtmodeltester 69 | qtmodeltester.check(model) 70 | 71 | # confirm that font data loaded appropriately 72 | assert model._h_header == ["Min : Max [Default]", "Edit Values"] 73 | assert model.ordered_axis_tags == ["MONO", "CASL", "wght", "slnt", "CRSV"] 74 | assert model._v_header == ["MONO", "CASL", "wght", "slnt", "CRSV"] 75 | assert model.fvar_axes == { 76 | "MONO": [0.0, 0.0, 1.0], 77 | "CASL": [0.0, 0.0, 1.0], 78 | "wght": [300.0, 300.0, 1000.0], 79 | "slnt": [-15.0, 0.0, 0.0], 80 | "CRSV": [0.0, 0.5, 1.0], 81 | } 82 | assert model._data == [ 83 | ["0.0 : 1.0 [0.0]", ""], 84 | ["0.0 : 1.0 [0.0]", ""], 85 | ["300.0 : 1000.0 [300.0]", ""], 86 | ["-15.0 : 0.0 [0.0]", ""], 87 | ["0.0 : 1.0 [0.5]", ""], 88 | ] 89 | 90 | 91 | def test_designaxis_model_filled_woff2(qtbot, qtmodeltester): 92 | tableview = QTableView() 93 | model = DesignAxisModel() 94 | tableview.setModel(model) 95 | qtbot.addWidget(tableview) 96 | model.load_font(get_font_model_woff2()) 97 | 98 | # test with qtmodeltester 99 | qtmodeltester.check(model) 100 | 101 | # confirm that font data loaded appropriately 102 | assert model._h_header == ["Min : Max [Default]", "Edit Values"] 103 | assert model.ordered_axis_tags == ["MONO", "CASL", "wght", "slnt", "CRSV"] 104 | assert model._v_header == ["MONO", "CASL", "wght", "slnt", "CRSV"] 105 | assert model.fvar_axes == { 106 | "MONO": [0.0, 0.0, 1.0], 107 | "CASL": [0.0, 0.0, 1.0], 108 | "wght": [300.0, 300.0, 1000.0], 109 | "slnt": [-15.0, 0.0, 0.0], 110 | "CRSV": [0.0, 0.5, 1.0], 111 | } 112 | assert model._data == [ 113 | ["0.0 : 1.0 [0.0]", ""], 114 | ["0.0 : 1.0 [0.0]", ""], 115 | ["300.0 : 1000.0 [300.0]", ""], 116 | ["-15.0 : 0.0 [0.0]", ""], 117 | ["0.0 : 1.0 [0.5]", ""], 118 | ] 119 | 120 | 121 | def test_designaxis_model_get_instance_data(qtbot): 122 | tableview = QTableView() 123 | model = DesignAxisModel() 124 | tableview.setModel(model) 125 | qtbot.addWidget(tableview) 126 | model.load_font(get_font_model()) 127 | 128 | # without user entered definitions, we should get 129 | # an empty axis tag / value dict 130 | # this is intentional so that these axes remain 131 | # variable 132 | assert model.get_instance_data() == {} 133 | 134 | # simulate update of model data with user input 135 | # and check again to confirm that it is present 136 | model._data[0][1] = "1.0" 137 | model._data[1][1] = "1.0" 138 | model._data[2][1] = "1000.0" 139 | model._data[3][1] = "-15.0" 140 | model._data[4][1] = "1.0" 141 | model.layoutChanged.emit() 142 | 143 | assert model.get_instance_data() == { 144 | "MONO": 1.0, 145 | "CASL": 1.0, 146 | "wght": 1000.0, 147 | "slnt": -15.0, 148 | "CRSV": 1.0, 149 | } 150 | 151 | 152 | def test_designaxis_model_get_partial_instance_data(qtbot): 153 | tableview = QTableView() 154 | model = DesignAxisModel() 155 | tableview.setModel(model) 156 | qtbot.addWidget(tableview) 157 | model.load_font(get_font_model()) 158 | 159 | # without user entered definitions, we should get 160 | # empty set 161 | assert model.get_instance_data() == {} 162 | 163 | # simulate update of model data with user input 164 | # that requests sub-space that maintains 165 | # variable "MONO" and "slnt" axes 166 | # (i.e. these fields are empty) 167 | model._data[0][1] = "" 168 | model._data[1][1] = "1.0" 169 | model._data[2][1] = "1000.0" 170 | model._data[3][1] = "" 171 | model._data[4][1] = "1.0" 172 | model.layoutChanged.emit() 173 | 174 | # should not include instance values for: "MONO", "slnt" 175 | # the instantiation function maintains variable 176 | # axes for any axis tag that is present in font 177 | # and not included in this dict 178 | assert model.get_instance_data() == { 179 | "CASL": 1.0, 180 | "wght": 1000.0, 181 | "CRSV": 1.0, 182 | } 183 | 184 | 185 | def test_designaxis_model_instance_data_validates_missing_data(qtbot): 186 | tableview = QTableView() 187 | model = DesignAxisModel() 188 | tableview.setModel(model) 189 | qtbot.addWidget(tableview) 190 | model.load_font(get_font_model()) 191 | 192 | # without user entered definitions, we should get 193 | # an empty axis tag / value dict 194 | # this is intentional so that these axes remain 195 | # variable 196 | assert model.get_instance_data() == {} 197 | 198 | assert model.instance_data_validates_missing_data() is False 199 | 200 | # fill model and try again 201 | # this requires at least one axis to have a value 202 | model._data[0][1] = "" 203 | model._data[1][1] = "1.0" 204 | model._data[2][1] = "" 205 | model._data[3][1] = "" 206 | model._data[4][1] = "" 207 | model.layoutChanged.emit() 208 | 209 | assert model.instance_data_validates_missing_data() is True 210 | 211 | 212 | def test_designaxis_model_instance_data_validates_invalid_data(qtbot): 213 | tableview = QTableView() 214 | model = DesignAxisModel() 215 | tableview.setModel(model) 216 | qtbot.addWidget(tableview) 217 | model.load_font(get_font_model()) 218 | 219 | # without user entered definitions, we should get 220 | # an empty axis tag / value dict 221 | # this is intentional so that these axes remain 222 | # variable 223 | assert model.get_instance_data() == {} 224 | 225 | assert model.instance_data_validates_missing_data() is False 226 | 227 | # fill model and try again 228 | # but this time add invalid data 229 | # this should prompt a ValueError exception 230 | model._data[0][1] = "" 231 | model._data[1][1] = "BOGUSVALUE" 232 | model._data[2][1] = "" 233 | model._data[3][1] = "" 234 | model._data[4][1] = "" 235 | model.layoutChanged.emit() 236 | 237 | with pytest.raises(ValueError): 238 | model.instance_data_validates_missing_data() 239 | 240 | 241 | def test_designaxis_model_subspace_data_validates_includes_default(qtbot): 242 | tableview = QTableView() 243 | model = DesignAxisModel() 244 | tableview.setModel(model) 245 | qtbot.addWidget(tableview) 246 | model.load_font(get_font_model()) 247 | 248 | # all values include the default axis value (300) in range 249 | passing_values = ( 250 | [100, 300], 251 | [200, 400], 252 | [300, 700], 253 | [100.0, 300.0], 254 | [200.0, 400.0], 255 | [300.0, 700.0], 256 | ) 257 | 258 | # these should not raise exception 259 | for passing_value in passing_values: 260 | model.subspace_data_validates_includes_default_value(passing_value, "wght") 261 | 262 | failing_values = [ 263 | [100, 200], 264 | [400, 700], 265 | [100.0, 299.9], 266 | [300.1, 400.0], 267 | [100, 299.9], 268 | [300.1, 700], 269 | ] 270 | 271 | # these should raise exceptions because default value is not included in range 272 | for failing_value in failing_values: 273 | with pytest.raises(ValueError): 274 | model.subspace_data_validates_includes_default_value(failing_value, "wght") 275 | 276 | 277 | def test_designaxis_model_parse_subspace_range_pass(qtbot): 278 | tableview = QTableView() 279 | model = DesignAxisModel() 280 | tableview.setModel(model) 281 | qtbot.addWidget(tableview) 282 | model.load_font(get_font_model()) 283 | 284 | # The following list includes valid, supported axis range 285 | # restriction values for the requested syntax `min_val:max_val [default_val]` 286 | # the test font includes wght axis range with 300 default value 287 | # this must be included in the range until L4 sub-spacing support 288 | # is added 289 | passing_values = [ 290 | ("100:300", (100.0, 300.0), None), 291 | ("100 : 300", (100.0, 300.0), None), 292 | (" 100 : 300 ", (100.0, 300.0), None), 293 | ("300:100", (100.0, 300.0), None), 294 | ("300 : 100", (100.0, 300.0), None), 295 | (" 300 : 100 ", (100.0, 300.0), None), 296 | ("100.0:300.0", (100.0, 300.0), None), 297 | ("100.0 : 300.0", (100.0, 300.0), None), 298 | (" 100.0 : 300.0 ", (100.0, 300.0), None), 299 | ("100:300 [300]", (100.0, 300.0), "300"), 300 | ("100 : 300 [300]", (100.0, 300.0), "300"), 301 | (" 100 : 300 [ 300 ]", (100.0, 300.0), "300"), 302 | ("100.0:300.0 [300.0]", (100.0, 300.0), "300.0"), 303 | ("100.0 : 300.0 [300.0]", (100.0, 300.0), "300.0"), 304 | (" 100.0 : 300.0 [300.0]", (100.0, 300.0), "300.0"), 305 | ("100.0:300.0 [ 300.0 ]", (100.0, 300.0), "300.0"), 306 | ("300.0:100.0 [ 300.0 ]", (100.0, 300.0), "300.0"), 307 | ("300:100 [ 300 ]", (100.0, 300.0), "300"), 308 | # the following is not recommended because default will not match in the future 309 | ("(100:300)", (100.0, 300.0), None), 310 | ] 311 | 312 | for passing_value in passing_values: 313 | match = model.parse_subspace_range(passing_value[0], "wght") 314 | # range should match tuple 315 | assert match[0] == passing_value[1] 316 | # default value should match string 317 | assert match[1] == passing_value[2] 318 | 319 | negative_values = [ 320 | # negative values on slnt axis 321 | ("-10:0", (-10.0, 0.0), None), 322 | ("-10.0:0", (-10.0, 0.0), None), 323 | ("-10 : 0", (-10.0, 0.0), None), 324 | # mock negative max end using signed zero 325 | ("-10:-0", (-10.0, -0.0), None), 326 | ("-10.0:-0.0", (-10.0, -0.0), None), 327 | ("-10.0 : -0.0", (-10.0, -0.0), None), 328 | # test negative default 329 | ("-10:-0 [-5]", (-10.0, -0.0), "-5"), 330 | ("-10:-0 [ -5 ]", (-10.0, -0.0), "-5"), 331 | ("-10.0 : -0.0 [ -5.0 ]", (-10.0, -0.0), "-5.0"), 332 | ] 333 | 334 | for negative_value in negative_values: 335 | # switch to slnt axis for these tests 336 | match = model.parse_subspace_range(negative_value[0], "slnt") 337 | # range should match tuple 338 | assert match[0] == negative_value[1] 339 | # default value should match string 340 | assert match[1] == negative_value[2] 341 | 342 | 343 | def test_designaxis_model_parse_subspace_range_fail_invalid_syntax(qtbot): 344 | tableview = QTableView() 345 | model = DesignAxisModel() 346 | tableview.setModel(model) 347 | qtbot.addWidget(tableview) 348 | model.load_font(get_font_model()) 349 | 350 | # The following list includes invalid values that 351 | # raise errors during execution 352 | failing_values = [ 353 | # invalid syntax 354 | "100,300", 355 | "(100,300)", 356 | "100,300 [300]", 357 | "(100,300) [300]", 358 | # invalid types 359 | "100:bogus", 360 | "bogus:100", 361 | ] 362 | 363 | for failing_value in failing_values: 364 | with pytest.raises(ValueError): 365 | model.parse_subspace_range(failing_value, "wght") 366 | 367 | 368 | def test_designaxis_model_parse_subspace_range_fail_invalid_range_without_default(qtbot): 369 | tableview = QTableView() 370 | model = DesignAxisModel() 371 | tableview.setModel(model) 372 | qtbot.addWidget(tableview) 373 | model.load_font(get_font_model()) 374 | 375 | # The following list includes invalid values that 376 | # raise errors during execution b/c axis default not in range 377 | # this applies until L4 support is available 378 | failing_values = [ 379 | "100:200", 380 | "400:700", 381 | "100.0:299.9", 382 | "300.1:400.0", 383 | "100:299.9", 384 | "300.1:700", 385 | "200:100", 386 | "299.9 : 100.0", 387 | ] 388 | 389 | for failing_value in failing_values: 390 | with pytest.raises(ValueError): 391 | model.parse_subspace_range(failing_value, "wght") 392 | 393 | 394 | def test_designaxis_model_get_number_of_axes(qtbot): 395 | tableview = QTableView() 396 | model = DesignAxisModel() 397 | tableview.setModel(model) 398 | qtbot.addWidget(tableview) 399 | model.load_font(get_font_model()) 400 | 401 | assert model.get_number_of_axes() == 5 402 | 403 | 404 | def test_designaxis_model_get_default_axis_value(qtbot): 405 | tableview = QTableView() 406 | model = DesignAxisModel() 407 | tableview.setModel(model) 408 | qtbot.addWidget(tableview) 409 | model.load_font(get_font_model()) 410 | 411 | assert model.get_default_axis_value("MONO") == 0.0 412 | assert model.get_default_axis_value("CASL") == 0.0 413 | assert model.get_default_axis_value("wght") == 300.0 414 | assert model.get_default_axis_value("slnt") == 0.0 415 | assert model.get_default_axis_value("CRSV") == 0.5 416 | 417 | 418 | def test_designaxis_model_get_axis_name_string(qtbot): 419 | tableview = QTableView() 420 | model = DesignAxisModel() 421 | tableview.setModel(model) 422 | qtbot.addWidget(tableview) 423 | model.load_font(get_font_model()) 424 | 425 | # registered axes 426 | assert model.get_axis_name_string("ital") == "Italic" 427 | assert model.get_axis_name_string("opsz") == "Optical size" 428 | assert model.get_axis_name_string("slnt") == "Slant" 429 | assert model.get_axis_name_string("wdth") == "Width" 430 | assert model.get_axis_name_string("wght") == "Weight" 431 | 432 | # unregistered axes 433 | assert model.get_axis_name_string("CASL") == "Casual" 434 | assert model.get_axis_name_string("CRSV") == "Cursive" 435 | assert model.get_axis_name_string("XPRN") == "Expression" 436 | assert model.get_axis_name_string("GRAD") == "Grade" 437 | assert model.get_axis_name_string("MONO") == "Monospace" 438 | assert model.get_axis_name_string("SOFT") == "Softness" 439 | assert model.get_axis_name_string("WONK") == "Wonky" 440 | 441 | # not a known (to this application) axis tag 442 | assert model.get_axis_name_string("ZXYJ") is None 443 | -------------------------------------------------------------------------------- /tests/test_models_fontbitflag.py: -------------------------------------------------------------------------------- 1 | from slice.models import FontBitFlagModel 2 | 3 | # 4 | # Utilities 5 | # 6 | 7 | 8 | def get_os2_default_dict(): 9 | return { 10 | "bit0": False, 11 | "bit5": False, 12 | "bit6": False, 13 | "bit8": False, 14 | } 15 | 16 | 17 | def get_os2_default_dict_true(): 18 | return { 19 | "bit0": True, 20 | "bit5": True, 21 | "bit6": True, 22 | "bit8": True, 23 | } 24 | 25 | 26 | def get_head_default_dict(): 27 | return { 28 | "bit0": False, 29 | "bit1": False, 30 | } 31 | 32 | 33 | def get_head_default_dict_true(): 34 | return { 35 | "bit0": True, 36 | "bit1": True, 37 | } 38 | 39 | 40 | # ~~~~~~~~~~~~~~~ 41 | # 42 | # Tests 43 | # 44 | # ~~~~~~~~~~~~~~~ 45 | 46 | 47 | def test_bitflag_model_default(): 48 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 49 | assert fm._os2_dict == get_os2_default_dict() 50 | assert fm._head_dict == get_head_default_dict() 51 | 52 | 53 | def test_bitflag_model_set_bit(): 54 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 55 | assert fm._set_bit(0, 0) == 1 56 | 57 | 58 | def test_bitflag_model_clear_bit(): 59 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 60 | assert fm._clear_bit(1, 0) == 0 61 | 62 | 63 | def test_bitflag_model_get_offset_from_key(): 64 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 65 | assert fm._get_bit_offset_from_key("bit0") == 0 66 | assert fm._get_bit_offset_from_key("bit1") == 1 67 | assert fm._get_bit_offset_from_key("bit10") == 10 68 | 69 | 70 | def test_bitflag_model_get_os2_instance_data(): 71 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 72 | assert fm.get_os2_instance_data() == get_os2_default_dict() 73 | 74 | 75 | def test_bitflag_model_get_head_instance_data(): 76 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 77 | assert fm.get_head_instance_data() == get_head_default_dict() 78 | 79 | 80 | def test_bitflag_model_edit_os2_fsselection_bits(): 81 | # set all bits that will be cleared 82 | test_int = 353 83 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 84 | # confirm that they are all cleared 85 | assert fm.edit_os2_fsselection_bits(test_int) == 0 86 | 87 | # clear all bits that will be set 88 | test_int2 = 0 89 | fm2 = FontBitFlagModel(get_os2_default_dict_true(), get_head_default_dict()) 90 | # confirm that they are all set 91 | assert fm2.edit_os2_fsselection_bits(test_int2) == 353 92 | 93 | 94 | def test_bitflag_model_edit_head_macstyle_bits(): 95 | # set all bits that will be cleared 96 | test_int = 3 97 | fm = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict()) 98 | # confirm that they are all cleared 99 | assert fm.edit_head_macstyle_bits(test_int) == 0 100 | 101 | # clear all bits that will be set 102 | test_int2 = 0 103 | fm2 = FontBitFlagModel(get_os2_default_dict(), get_head_default_dict_true()) 104 | # confirm that they are all set 105 | assert fm2.edit_head_macstyle_bits(test_int2) == 3 106 | -------------------------------------------------------------------------------- /tests/test_models_fontmodel.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from slice.models import FontModel 4 | 5 | # 6 | # Utilities 7 | # 8 | 9 | 10 | def get_font_path_vf(): 11 | return Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve() 12 | 13 | 14 | def get_font_path_vf_woff(): 15 | return Path("tests/assets/fonts/Recursive-VF.subset.woff").resolve() 16 | 17 | 18 | def get_font_path_vf_woff2(): 19 | return Path("tests/assets/fonts/Recursive-VF.subset.woff2").resolve() 20 | 21 | 22 | def get_font_string_vf(): 23 | return str(Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve()) 24 | 25 | 26 | def get_font_path_static(): 27 | return Path("tests/assets/fonts/Recursive-Sliced.subset.ttf").resolve() 28 | 29 | 30 | def get_font_string_static(): 31 | return str(Path("tests/assets/fonts/Recursive-Sliced.subset.ttf").resolve()) 32 | 33 | 34 | # ~~~~~~~~~~~ 35 | # 36 | # Tests 37 | # 38 | # ~~~~~~~~~~~ 39 | 40 | 41 | def test_font_model_default_with_path(): 42 | fm = FontModel(get_font_path_vf()) 43 | assert fm.fontpath == Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve() 44 | 45 | 46 | def test_font_model_default_with_string(): 47 | fm = FontModel(get_font_string_vf()) 48 | assert fm.fontpath == str( 49 | Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve() 50 | ) 51 | 52 | 53 | def test_font_model_is_variable_font_true_with_path(): 54 | fm = FontModel(get_font_path_vf()) 55 | assert fm.is_variable_font() is True 56 | 57 | 58 | def test_font_model_is_variable_font_true_with_path_woff(): 59 | fm = FontModel(get_font_path_vf_woff()) 60 | assert fm.is_variable_font() is True 61 | 62 | 63 | def test_font_model_is_variable_font_true_with_path_woff2(): 64 | fm = FontModel(get_font_path_vf_woff2()) 65 | assert fm.is_variable_font() is True 66 | 67 | 68 | def test_font_model_is_variable_font_false_with_path(): 69 | fm = FontModel(get_font_path_static()) 70 | assert fm.is_variable_font() is False 71 | 72 | 73 | def test_font_model_is_variable_font_true_with_string(): 74 | fm = FontModel(get_font_string_vf()) 75 | assert fm.is_variable_font() is True 76 | 77 | 78 | def test_font_model_is_variable_font_false_with_string(): 79 | fm = FontModel(get_font_string_static()) 80 | assert fm.is_variable_font() is False 81 | -------------------------------------------------------------------------------- /tests/test_models_fontname.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from PyQt5.QtWidgets import QTableView 4 | 5 | from slice.models import FontNameModel, FontModel 6 | 7 | 8 | def get_font_model(): 9 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.ttf").resolve()) 10 | 11 | 12 | def get_font_model_woff(): 13 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.woff").resolve()) 14 | 15 | 16 | def get_font_model_woff2(): 17 | return FontModel(Path("tests/assets/fonts/Recursive-VF.subset.woff2").resolve()) 18 | 19 | 20 | def test_fontname_model_default(qtbot, qtmodeltester): 21 | tableview = QTableView() 22 | model = FontNameModel() 23 | tableview.setModel(model) 24 | qtbot.addWidget(tableview) 25 | # check model with default instantiation 26 | qtmodeltester.check(model) 27 | 28 | # confirm that font data loaded appropriately 29 | assert model._v_header == [ 30 | "01 Family", 31 | "02 Subfamily", 32 | "03 Unique", 33 | "04 Full", 34 | "06 Postscript", 35 | "16 Typo Family", 36 | "17 Typo Subfamily", 37 | "21 WWS Family", 38 | "22 WWS Subfamily", 39 | ] 40 | assert model._data == [ 41 | [""], # nameID 1 (index 0) 42 | [""], # nameID 2 (index 1) 43 | [""], # nameID 3 (index 2) 44 | [""], # nameID 4 (index 3) 45 | [""], # nameID 6 (index 4) 46 | [""], # nameID 16 (index 5) 47 | [""], # nameID 17 (index 6) 48 | [""], # nameID 21 (index 7) 49 | [""], # nameID 22 (index 8) 50 | ] 51 | 52 | 53 | def test_fontname_model_filled(qtbot, qtmodeltester): 54 | tableview = QTableView() 55 | model = FontNameModel() 56 | tableview.setModel(model) 57 | qtbot.addWidget(tableview) 58 | model.load_font(get_font_model()) 59 | 60 | # test with qtmodeltester 61 | qtmodeltester.check(model) 62 | 63 | # confirm that font data loaded appropriately 64 | # The vertical headers should not change 65 | assert model._v_header == [ 66 | "01 Family", 67 | "02 Subfamily", 68 | "03 Unique", 69 | "04 Full", 70 | "06 Postscript", 71 | "16 Typo Family", 72 | "17 Typo Subfamily", 73 | "21 WWS Family", 74 | "22 WWS Subfamily", 75 | ] 76 | # default name table data from test font 77 | assert model._data == [ 78 | ["Recursive Sans Linear Light"], # nameID 1 (index 0) 79 | ["Regular"], # nameID 2 (index 1) 80 | ["1.077;ARRW;Recursive-SansLinearLight"], # nameID 3 (index 2) 81 | ["Recursive Sans Linear Light"], # nameID 4 (index 3) 82 | ["Recursive-SansLinearLight"], # nameID 6 (index 4) 83 | [""], # nameID 16 (index 5) 84 | [""], # nameID 17 (index 6) 85 | [""], # nameID 21 (index 7) 86 | [""], # nameID 22 (index 8) 87 | ] 88 | 89 | 90 | def test_fontname_model_filled_woff(qtbot, qtmodeltester): 91 | tableview = QTableView() 92 | model = FontNameModel() 93 | tableview.setModel(model) 94 | qtbot.addWidget(tableview) 95 | model.load_font(get_font_model_woff()) 96 | 97 | # test with qtmodeltester 98 | qtmodeltester.check(model) 99 | 100 | # confirm that font data loaded appropriately 101 | # The vertical headers should not change 102 | assert model._v_header == [ 103 | "01 Family", 104 | "02 Subfamily", 105 | "03 Unique", 106 | "04 Full", 107 | "06 Postscript", 108 | "16 Typo Family", 109 | "17 Typo Subfamily", 110 | "21 WWS Family", 111 | "22 WWS Subfamily", 112 | ] 113 | # default name table data from test font 114 | assert model._data == [ 115 | ["Recursive Sans Linear Light"], # nameID 1 (index 0) 116 | ["Regular"], # nameID 2 (index 1) 117 | ["1.077;ARRW;Recursive-SansLinearLight"], # nameID 3 (index 2) 118 | ["Recursive Sans Linear Light"], # nameID 4 (index 3) 119 | ["Recursive-SansLinearLight"], # nameID 6 (index 4) 120 | [""], # nameID 16 (index 5) 121 | [""], # nameID 17 (index 6) 122 | [""], # nameID 21 (index 7) 123 | [""], # nameID 22 (index 8) 124 | ] 125 | 126 | 127 | def test_fontname_model_filled_woff2(qtbot, qtmodeltester): 128 | tableview = QTableView() 129 | model = FontNameModel() 130 | tableview.setModel(model) 131 | qtbot.addWidget(tableview) 132 | model.load_font(get_font_model_woff2()) 133 | 134 | # test with qtmodeltester 135 | qtmodeltester.check(model) 136 | 137 | # confirm that font data loaded appropriately 138 | # The vertical headers should not change 139 | assert model._v_header == [ 140 | "01 Family", 141 | "02 Subfamily", 142 | "03 Unique", 143 | "04 Full", 144 | "06 Postscript", 145 | "16 Typo Family", 146 | "17 Typo Subfamily", 147 | "21 WWS Family", 148 | "22 WWS Subfamily", 149 | ] 150 | # default name table data from test font 151 | assert model._data == [ 152 | ["Recursive Sans Linear Light"], # nameID 1 (index 0) 153 | ["Regular"], # nameID 2 (index 1) 154 | ["1.077;ARRW;Recursive-SansLinearLight"], # nameID 3 (index 2) 155 | ["Recursive Sans Linear Light"], # nameID 4 (index 3) 156 | ["Recursive-SansLinearLight"], # nameID 6 (index 4) 157 | [""], # nameID 16 (index 5) 158 | [""], # nameID 17 (index 6) 159 | [""], # nameID 21 (index 7) 160 | [""], # nameID 22 (index 8) 161 | ] 162 | 163 | 164 | def test_fontname_model_get_version(qtbot): 165 | tableview = QTableView() 166 | model = FontNameModel() 167 | tableview.setModel(model) 168 | qtbot.addWidget(tableview) 169 | model.load_font(get_font_model()) 170 | 171 | assert model.get_version() == "Version 1.077" 172 | 173 | 174 | def test_fontname_model_get_family_name(qtbot): 175 | tableview = QTableView() 176 | model = FontNameModel() 177 | tableview.setModel(model) 178 | qtbot.addWidget(tableview) 179 | model.load_font(get_font_model()) 180 | 181 | assert model.get_family_name() == "Recursive Sans Linear Light" 182 | 183 | 184 | def test_fontname_model_get_instance_data(qtbot): 185 | tableview = QTableView() 186 | model = FontNameModel() 187 | tableview.setModel(model) 188 | qtbot.addWidget(tableview) 189 | model.load_font(get_font_model()) 190 | 191 | assert model.get_instance_data() == { 192 | "nameID1": "Recursive Sans Linear Light", 193 | "nameID2": "Regular", 194 | "nameID3": "1.077;ARRW;Recursive-SansLinearLight", 195 | "nameID4": "Recursive Sans Linear Light", 196 | "nameID6": "Recursive-SansLinearLight", 197 | "nameID16": "", 198 | "nameID17": "", 199 | "nameID21": "", 200 | "nameID22": "", 201 | } 202 | 203 | # simulate update of model data with user input 204 | # and check again to confirm that it is present 205 | model._data = [ 206 | ["One"], 207 | ["Two"], 208 | ["Three"], 209 | ["Four"], 210 | ["Six"], 211 | ["Sixteen"], 212 | ["Seventeen"], 213 | ["Twenty-one"], 214 | ["Twenty-two"], 215 | ] 216 | model.layoutChanged.emit() 217 | 218 | assert model.get_instance_data() == { 219 | "nameID1": "One", 220 | "nameID2": "Two", 221 | "nameID3": "Three", 222 | "nameID4": "Four", 223 | "nameID6": "Six", 224 | "nameID16": "Sixteen", 225 | "nameID17": "Seventeen", 226 | "nameID21": "Twenty-one", 227 | "nameID22": "Twenty-two", 228 | } 229 | -------------------------------------------------------------------------------- /tests/test_widgets.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QWidget 2 | from PyQt5.QtTest import QTest 3 | 4 | from slice.ui.widgets import DragDropLineEdit 5 | 6 | 7 | def test_drag_drop_line_edit(qtbot): 8 | widget1 = QWidget() 9 | widget2 = DragDropLineEdit(widget1) 10 | qtbot.addWidget(widget1) 11 | qtbot.addWidget(widget2) 12 | # placeholder text 13 | assert ( 14 | widget2.placeholderText() == "Drop a variable font here or click the Open button" 15 | ) 16 | assert widget2.isEnabled() is True 17 | # accepts drops 18 | assert widget2.acceptDrops() is True 19 | # uses a clear button 20 | assert widget2.isClearButtonEnabled() is True 21 | # test text entry 22 | assert widget2.text() == "" 23 | QTest.keyClicks(widget2, "test") 24 | assert widget2.text() == "test" 25 | -------------------------------------------------------------------------------- /thirdparty/Flaticon-License.txt: -------------------------------------------------------------------------------- 1 | License summary 2 | Our license allows you to use the content: 3 | 4 | For commercial and personal projects 5 | On digital or printed media 6 | For an unlimited number of times and perpetually 7 | Anywhere in the world 8 | To make modifications and derived works -------------------------------------------------------------------------------- /thirdparty/IBMPlex-OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2017 IBM Corp. with Reserved Font Name "Plex" 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. -------------------------------------------------------------------------------- /thirdparty/README.md: -------------------------------------------------------------------------------- 1 | # Third Party Licenses 2 | 3 | The Slice project uses and distributes a derivative of the ["cheesecake" icon](https://www.flaticon.com/free-icon/cheesecake_3400263) released by flaticon.com. This image is used and distributed under the Flaticon license. Please see [Flaticon-License.txt](https://github.com/source-foundry/Slice/blob/main/thirdparty/Flaticon-License.txt) for additional details. 4 | 5 | The Slice project uses and distributes subset derivatives of the [Recursive typeface](https://github.com/arrowtype/recursive) by Stephen Nixon as test fonts and in the application UI. The software is used and distributed under the SIL Open Font License, Version 1.1. Please see [Recursive-OFL.txt](https://github.com/source-foundry/Slice/blob/main/thirdparty/Recursive-OFL.txt) for additional details. 6 | 7 | The Slice project uses and distributes the [IBM Plex Mono typeface](https://github.com/arrowtype/recursive) by IBM in the application UI. The software is used and distributed under the SIL Open Font License, Version 1.1. Please see [IBMPlex-OFL.txt](https://github.com/source-foundry/Slice/blob/main/thirdparty/IBMPlex-OFL.txt) for additional details. 8 | -------------------------------------------------------------------------------- /thirdparty/Recursive-OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 The Recursive Project Authors (https://github.com/arrowtype/recursive) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py39 3 | 4 | [testenv] 5 | commands = 6 | pytest {posargs} 7 | deps = 8 | -rdev-requirements.txt 9 | 10 | [gh-actions] 11 | python = 12 | 3.6: py36 13 | 3.7: py37 14 | 3.8: py38 15 | 3.9: py39 --------------------------------------------------------------------------------