videopython 0.35.1__tar.gz → 0.36.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {videopython-0.35.1 → videopython-0.36.0}/PKG-INFO +2 -2
- {videopython-0.35.1 → videopython-0.36.0}/README.md +1 -1
- {videopython-0.35.1 → videopython-0.36.0}/pyproject.toml +11 -3
- videopython-0.36.0/src/videopython/base/exceptions.py +123 -0
- videopython-0.36.0/src/videopython/base/fonts/Anton-OFL.txt +93 -0
- videopython-0.36.0/src/videopython/base/fonts/Anton-Regular.ttf +0 -0
- videopython-0.36.0/src/videopython/base/fonts/BebasNeue-OFL.txt +93 -0
- videopython-0.36.0/src/videopython/base/fonts/BebasNeue-Regular.ttf +0 -0
- videopython-0.36.0/src/videopython/base/fonts/Lato-Bold.ttf +0 -0
- videopython-0.36.0/src/videopython/base/fonts/Lato-OFL.txt +93 -0
- videopython-0.36.0/src/videopython/base/fonts/Poppins-Bold.ttf +0 -0
- videopython-0.36.0/src/videopython/base/fonts/Poppins-OFL.txt +93 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/fonts/__init__.py +28 -5
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/effects.py +20 -2
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/operation.py +69 -6
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/transcription_overlay.py +32 -7
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/transforms.py +36 -4
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/video_edit.py +267 -61
- videopython-0.35.1/src/videopython/base/exceptions.py +0 -73
- {videopython-0.35.1 → videopython-0.36.0}/.gitignore +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/LICENSE +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/_device.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/config.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/dubber.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/expressiveness.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/loudness.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/models.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/pipeline.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/quality.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/remux.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/timing.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/dubbing/voice_sample.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/audio.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/image.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/qwen3.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/translation.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/generation/video.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/transforms.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/audio.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/faces.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/image.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/separation.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/understanding/temporal.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/video_analysis/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/video_analysis/analyzer.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/video_analysis/models.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/video_analysis/sampling.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/ai/video_analysis/stages.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/audio/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/audio/analysis.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/audio/audio.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/_dimensions.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/_ffmpeg.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/_video_io.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/description.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/fonts/DejaVuSans.ttf +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/fonts/LICENSE_DEJAVU +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/image_text.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/transcription.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/base/video.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/__init__.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/editing/streaming.py +0 -0
- {videopython-0.35.1 → videopython-0.36.0}/src/videopython/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: videopython
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.36.0
|
|
4
4
|
Summary: Minimal video generation and processing library.
|
|
5
5
|
Project-URL: Homepage, https://videopython.com
|
|
6
6
|
Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
|
|
@@ -109,7 +109,7 @@ video.add_audio(audio).save("ai_video.mp4")
|
|
|
109
109
|
|
|
110
110
|
## LLM & AI Agent Integration
|
|
111
111
|
|
|
112
|
-
Every operation is a Pydantic model whose fields ARE the JSON wire format. `VideoEdit.json_schema()` returns a JSON Schema with a discriminated union over every
|
|
112
|
+
Every operation is a Pydantic model whose fields ARE the JSON wire format. `VideoEdit.json_schema()` returns a JSON Schema with a discriminated union over every LLM-exposed `Operation` (server-only ops like `image_overlay` are excluded by default) — pass it straight to Anthropic tool use, OpenAI function calling, or any structured-output API. Then `edit.validate()` dry-runs the plan via metadata before any frames are loaded, raising a typed `PlanValidationError` (with structured `.errors`) that can be fed back to the LLM and retried cheaply.
|
|
113
113
|
|
|
114
114
|
See the [LLM Integration Guide](https://videopython.com/guides/llm-integration/) for end-to-end examples, validation error loops, and operation discovery patterns.
|
|
115
115
|
|
|
@@ -60,7 +60,7 @@ video.add_audio(audio).save("ai_video.mp4")
|
|
|
60
60
|
|
|
61
61
|
## LLM & AI Agent Integration
|
|
62
62
|
|
|
63
|
-
Every operation is a Pydantic model whose fields ARE the JSON wire format. `VideoEdit.json_schema()` returns a JSON Schema with a discriminated union over every
|
|
63
|
+
Every operation is a Pydantic model whose fields ARE the JSON wire format. `VideoEdit.json_schema()` returns a JSON Schema with a discriminated union over every LLM-exposed `Operation` (server-only ops like `image_overlay` are excluded by default) — pass it straight to Anthropic tool use, OpenAI function calling, or any structured-output API. Then `edit.validate()` dry-runs the plan via metadata before any frames are loaded, raising a typed `PlanValidationError` (with structured `.errors`) that can be fed back to the LLM and retried cheaply.
|
|
64
64
|
|
|
65
65
|
See the [LLM Integration Guide](https://videopython.com/guides/llm-integration/) for end-to-end examples, validation error loops, and operation discovery patterns.
|
|
66
66
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "videopython"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.36.0"
|
|
4
4
|
description = "Minimal video generation and processing library."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Bartosz Wójtowicz", email = "bartoszwojtowicz@outlook.com" },
|
|
@@ -186,11 +186,19 @@ build-backend = "hatchling.build"
|
|
|
186
186
|
|
|
187
187
|
[tool.hatch.build.targets.wheel]
|
|
188
188
|
packages = ["src/videopython"]
|
|
189
|
-
artifacts = [
|
|
189
|
+
artifacts = [
|
|
190
|
+
"src/videopython/base/fonts/*.ttf",
|
|
191
|
+
"src/videopython/base/fonts/LICENSE_DEJAVU",
|
|
192
|
+
"src/videopython/base/fonts/*-OFL.txt",
|
|
193
|
+
]
|
|
190
194
|
|
|
191
195
|
[tool.hatch.build.targets.sdist]
|
|
192
196
|
include = ["src/videopython", "src/videopython/py.typed"]
|
|
193
|
-
artifacts = [
|
|
197
|
+
artifacts = [
|
|
198
|
+
"src/videopython/base/fonts/*.ttf",
|
|
199
|
+
"src/videopython/base/fonts/LICENSE_DEJAVU",
|
|
200
|
+
"src/videopython/base/fonts/*-OFL.txt",
|
|
201
|
+
]
|
|
194
202
|
|
|
195
203
|
[tool.pytest.ini_options]
|
|
196
204
|
pythonpath = ["src/"]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Exception hierarchy for videopython.base module."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class VideoPythonError(Exception):
|
|
10
|
+
"""Base exception for all videopython errors."""
|
|
11
|
+
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FFmpegError(VideoPythonError):
|
|
16
|
+
"""Base exception for ffmpeg/ffprobe subprocess failures."""
|
|
17
|
+
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FFmpegProbeError(FFmpegError):
|
|
22
|
+
"""Raised when an ffprobe invocation or its JSON output fails."""
|
|
23
|
+
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class FFmpegRunError(FFmpegError):
|
|
28
|
+
"""Raised when a blocking ffmpeg run returns a non-zero exit code."""
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class VideoError(VideoPythonError):
|
|
34
|
+
"""Base exception for video-related errors."""
|
|
35
|
+
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class VideoLoadError(VideoError):
|
|
40
|
+
"""Raised when there's an error loading a video file."""
|
|
41
|
+
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class VideoMetadataError(VideoError):
|
|
46
|
+
"""Raised when there's an error getting video metadata."""
|
|
47
|
+
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class AudioError(VideoPythonError):
|
|
52
|
+
"""Base exception for audio-related errors."""
|
|
53
|
+
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class AudioLoadError(AudioError):
|
|
58
|
+
"""Raised when there's an error loading audio."""
|
|
59
|
+
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class TransformError(VideoPythonError):
|
|
64
|
+
"""Base exception for transformation errors."""
|
|
65
|
+
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class TextRenderError(VideoPythonError):
|
|
70
|
+
"""Base exception for text rendering errors."""
|
|
71
|
+
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class OutOfBoundsError(TextRenderError):
|
|
76
|
+
"""Raised when text would be rendered outside image bounds."""
|
|
77
|
+
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class PlanErrorCode(str, Enum):
|
|
82
|
+
"""Machine-readable failure classes raised while validating a ``VideoEdit``.
|
|
83
|
+
|
|
84
|
+
Scoped to what videopython owns. A consumer can branch on these codes
|
|
85
|
+
instead of substring-matching the human message text.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
SEGMENT_END_EXCEEDS_SOURCE = "segment_end_exceeds_source"
|
|
89
|
+
EFFECT_WINDOW_EXCEEDS_DURATION = "effect_window_exceeds_duration"
|
|
90
|
+
CUT_EXCEEDS_DURATION = "cut_exceeds_duration"
|
|
91
|
+
UNKNOWN_OP = "unknown_op"
|
|
92
|
+
CONCAT_MISMATCH = "concat_mismatch"
|
|
93
|
+
SUBTITLE_UNFITTABLE = "subtitle_unfittable"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass
|
|
97
|
+
class PlanError:
|
|
98
|
+
"""A single structured validation failure within a plan.
|
|
99
|
+
|
|
100
|
+
``location`` is a path into the plan (e.g. ``'segments[1].operations[0]'``);
|
|
101
|
+
the remaining fields are populated when meaningful for the ``code``.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
code: PlanErrorCode
|
|
105
|
+
location: str | None = None
|
|
106
|
+
op: str | None = None
|
|
107
|
+
field: str | None = None
|
|
108
|
+
value: float | None = None
|
|
109
|
+
limit: float | None = None
|
|
110
|
+
predicted_duration: float | None = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PlanValidationError(ValueError):
|
|
114
|
+
"""Typed plan-validation failure carrying structured :class:`PlanError`s.
|
|
115
|
+
|
|
116
|
+
Subclasses ``ValueError`` so ``str(e)`` stays byte-identical to the bare
|
|
117
|
+
``ValueError`` prose emitted before this type existed -- existing
|
|
118
|
+
``pytest.raises(match=...)`` and consumer substring fallbacks keep working.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(self, message: str, errors: list[PlanError]):
|
|
122
|
+
super().__init__(message)
|
|
123
|
+
self.errors = errors
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Anton Project Authors (https://github.com/googlefonts/AntonFont.git)
|
|
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.
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright © 2010 by Dharma Type.
|
|
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.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato"
|
|
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.
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Poppins Project Authors (https://github.com/itfoundry/Poppins)
|
|
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.
|
|
@@ -15,10 +15,22 @@ from importlib.resources import as_file, files
|
|
|
15
15
|
|
|
16
16
|
from PIL import ImageFont
|
|
17
17
|
|
|
18
|
-
__all__ = ["DEFAULT_FONT_FILENAME", "load_font"]
|
|
18
|
+
__all__ = ["BUNDLED_FONTS", "DEFAULT_FONT_FILENAME", "FONT_NAMES", "load_font"]
|
|
19
19
|
|
|
20
20
|
DEFAULT_FONT_FILENAME = "DejaVuSans.ttf"
|
|
21
21
|
|
|
22
|
+
# Registered short NAME -> bundled filename. The names are stable identifiers an
|
|
23
|
+
# LLM can emit (saved plans round-trip on these); ``load_font`` resolves a name
|
|
24
|
+
# to its bundled file before the path/DejaVu/PIL fallback chain.
|
|
25
|
+
BUNDLED_FONTS: dict[str, str] = {
|
|
26
|
+
"poppins-bold": "Poppins-Bold.ttf",
|
|
27
|
+
"lato-bold": "Lato-Bold.ttf",
|
|
28
|
+
"anton": "Anton-Regular.ttf",
|
|
29
|
+
"bebas-neue": "BebasNeue-Regular.ttf",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
FONT_NAMES: list[str] = sorted(BUNDLED_FONTS)
|
|
33
|
+
|
|
22
34
|
|
|
23
35
|
def _try_truetype(path: str, font_size: int) -> ImageFont.FreeTypeFont | None:
|
|
24
36
|
try:
|
|
@@ -30,19 +42,30 @@ def _try_truetype(path: str, font_size: int) -> ImageFont.FreeTypeFont | None:
|
|
|
30
42
|
def load_font(font_filename: str | None, font_size: int) -> ImageFont.FreeTypeFont | ImageFont.ImageFont:
|
|
31
43
|
"""Load a font, falling back gracefully when one is unavailable.
|
|
32
44
|
|
|
33
|
-
Resolution order:
|
|
34
|
-
Sans -> PIL's built-in
|
|
35
|
-
|
|
45
|
+
Resolution order: a registered bundled NAME (``BUNDLED_FONTS``) -> the
|
|
46
|
+
given ``font_filename`` -> the bundled DejaVu Sans -> PIL's built-in
|
|
47
|
+
bitmap font. Never raises for a missing, unknown, or unreadable font, so
|
|
48
|
+
callers may pass ``None`` (or an unrecognized name) to mean "use the
|
|
36
49
|
default".
|
|
37
50
|
|
|
38
51
|
Args:
|
|
39
|
-
font_filename:
|
|
52
|
+
font_filename: A registered bundled font name, a path to a
|
|
53
|
+
``.ttf``/``.otf`` file, or ``None``.
|
|
40
54
|
font_size: Font size in points.
|
|
41
55
|
|
|
42
56
|
Returns:
|
|
43
57
|
A loaded PIL font object.
|
|
44
58
|
"""
|
|
45
59
|
if font_filename:
|
|
60
|
+
bundled_filename = BUNDLED_FONTS.get(font_filename)
|
|
61
|
+
if bundled_filename is not None:
|
|
62
|
+
try:
|
|
63
|
+
with as_file(files(__package__).joinpath(bundled_filename)) as bundled:
|
|
64
|
+
font = _try_truetype(str(bundled), font_size)
|
|
65
|
+
if font is not None:
|
|
66
|
+
return font
|
|
67
|
+
except (FileNotFoundError, ModuleNotFoundError):
|
|
68
|
+
pass
|
|
46
69
|
font = _try_truetype(font_filename, font_size)
|
|
47
70
|
if font is not None:
|
|
48
71
|
return font
|