figurekit 0.5.1__py3-none-any.whl

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.
figkit/export.py ADDED
@@ -0,0 +1,366 @@
1
+ """Writing figures: file names, formats, sizes and reproducible metadata.
2
+
3
+ Every figure exists for a light and a dark page. The light file is ``<name>.<format>`` and the dark
4
+ one ``<name>-dark.<format>``, the convention of the portfolio's ``Figure`` component and of
5
+ ``<picture>`` in a README. The default output :data:`WEB` writes a transparent SVG and a
6
+ transparent 250 dpi PNG of each, so the same file sits on any page colour of its mode.
7
+
8
+ Web outputs have a fixed canvas: every file is exactly 6.4 in wide, 1600 px as PNG. Pages scale
9
+ images to their column, so equal widths give the same text size in every figure, and titles start
10
+ at the same left edge. A narrower drawing leaves empty space on the right.
11
+ """
12
+
13
+ import base64
14
+ import hashlib
15
+ import io
16
+ import re
17
+ import struct
18
+ import zlib
19
+ from collections.abc import Callable, Sequence
20
+ from dataclasses import dataclass, replace
21
+ from itertools import groupby
22
+ from pathlib import Path
23
+ from typing import Any
24
+
25
+ import matplotlib.pyplot as plt
26
+ import numpy as np
27
+ from matplotlib.figure import Figure
28
+ from matplotlib.text import Text
29
+ from matplotlib.transforms import Bbox
30
+ from PIL import Image
31
+
32
+ from figkit.language import localize_ticks, speaking
33
+ from figkit.theme import DEFAULT, TYPE, Style, Theme, styled
34
+
35
+ Draw = Callable[[Theme], Figure]
36
+
37
+
38
+ @dataclass(frozen=True, slots=True)
39
+ class Output:
40
+ """How a figure is written.
41
+
42
+ Attributes:
43
+ format: ``svg``, ``png`` or ``webp``.
44
+ transparent: Leave the background empty instead of filling it with the theme surface.
45
+ width: Width of the canvas in inches. With ``tight``, the file is exactly this wide: a
46
+ drawing that sticks out is narrowed until it fits, a smaller one is padded on the
47
+ right. Without ``tight``, a wider figure is resized to this width; text keeps its size.
48
+ pixels: Width of a raster image in pixels; without it, ``dpi`` decides.
49
+ dpi: Resolution of raster formats when ``pixels`` is not set.
50
+ tight: Crop to the drawn content plus a small margin. Off for fixed sizes such as a
51
+ social card, whose pixel size must not change.
52
+ """
53
+
54
+ format: str
55
+ transparent: bool = True
56
+ width: float | None = None
57
+ pixels: int | None = None
58
+ dpi: float = 150
59
+ tight: bool = True
60
+
61
+
62
+ # 6.4 inches shown in a column of 800 CSS pixels enlarge 9 pt text to about 15 px. Every web file
63
+ # has this width, so the text has this size in every figure; at 250 dpi a PNG is 1600 pixels wide,
64
+ # sharp at twice that column.
65
+ WEB_WIDTH = 6.4
66
+ RASTER_DPI = 250
67
+ SVG = Output("svg", width=WEB_WIDTH)
68
+ PNG = Output("png", width=WEB_WIDTH, dpi=RASTER_DPI)
69
+ WEB = (SVG, PNG)
70
+ # Photographs and heatmaps over images: SVG would embed them as a large raster anyway.
71
+ PHOTO = (Output("webp", width=WEB_WIDTH, dpi=RASTER_DPI), PNG)
72
+ # Open Graph and LinkedIn previews are opaque and exactly 1200 x 630 pixels.
73
+ CARD_INCHES = (8.0, 4.2)
74
+ CARD = (Output("png", transparent=False, dpi=150, tight=False),)
75
+ PAD = 0.15
76
+
77
+ # Metadata without dates or versions, so that the files change only with their content.
78
+ _SAVE_OPTIONS: dict[str, dict[str, Any]] = {
79
+ "svg": {"metadata": {"Date": None, "Creator": None}},
80
+ }
81
+
82
+
83
+ def path_for(
84
+ directory: Path,
85
+ name: str,
86
+ theme: Theme,
87
+ output: Output,
88
+ language: str | None = None,
89
+ style: Style | None = None,
90
+ ) -> Path:
91
+ """File of one figure in one theme and format, ``<name>[.<language>][-<theme>].<format>``.
92
+
93
+ The default theme of ``style``, light in the bundled one, has no suffix. Every other theme
94
+ gets its name as the suffix, ``-dark``, so that two themes never write the same file.
95
+ """
96
+ stem = f"{name}.{language}" if language else name
97
+ suffix = (style or DEFAULT).suffix(theme.name)
98
+ return directory / f"{stem}{suffix}.{output.format}"
99
+
100
+
101
+ def save(figure: Figure, path: Path, output: Output) -> Path:
102
+ """Write the figure to ``path`` in the given output; the figure stays open."""
103
+ path.parent.mkdir(parents=True, exist_ok=True)
104
+ width, height = figure.get_size_inches()
105
+ bbox: Bbox | str | None = None
106
+ if output.tight and output.width is not None:
107
+ bbox = canvas(figure, output.width)
108
+ elif output.width is not None and width > output.width:
109
+ figure.set_size_inches(output.width, height * output.width / width)
110
+ if output.tight and bbox is None:
111
+ bbox = "tight"
112
+ dpi = output.dpi
113
+ if output.pixels is not None:
114
+ if isinstance(bbox, Bbox):
115
+ drawn = bbox.width
116
+ elif bbox == "tight":
117
+ figure.draw_without_rendering()
118
+ drawn = figure.get_tightbbox().width + 2 * PAD
119
+ else:
120
+ drawn = figure.get_figwidth()
121
+ dpi = output.pixels / drawn
122
+ options: dict[str, Any] = {"bbox_inches": bbox, "pad_inches": PAD} if bbox is not None else {}
123
+ if output.format == "svg":
124
+ # Saving to a path opens the file in text mode, which writes CRLF on Windows. A binary
125
+ # buffer keeps LF, so the files are byte-identical on every platform.
126
+ svg = io.BytesIO()
127
+ figure.savefig(
128
+ svg, format="svg", transparent=output.transparent, **options, **_SAVE_OPTIONS["svg"]
129
+ )
130
+ path.write_bytes(_portable_images(svg.getvalue()))
131
+ return path
132
+ buffer = io.BytesIO()
133
+ figure.savefig(buffer, format="png", dpi=dpi, transparent=output.transparent, **options)
134
+ buffer.seek(0)
135
+ with Image.open(buffer) as image:
136
+ _write_raster(image, path, output)
137
+ return path
138
+
139
+
140
+ # An image that matplotlib embeds in an SVG, with the id it derives from the PNG bytes.
141
+ _EMBEDDED = re.compile(rb'data:image/png;base64,\n([A-Za-z0-9+/=]+)"(?: id="(image[0-9a-f]{10})")?')
142
+ _PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n"
143
+
144
+
145
+ def _portable_images(svg: bytes) -> bytes:
146
+ """The SVG with every embedded PNG written again by :func:`_png`.
147
+
148
+ matplotlib embeds images, such as a heatmap drawn with ``imshow``, as PNGs that Pillow
149
+ compresses with the zlib of its build. Linux and Windows builds compress the same pixels to
150
+ different bytes, and matplotlib derives the image id from them. Writing the PNG again with
151
+ Python's zlib and deriving the id from that PNG keeps the file the same on every platform.
152
+ """
153
+
154
+ def rewrite(match: re.Match[bytes]) -> bytes:
155
+ with Image.open(io.BytesIO(base64.b64decode(match[1]))) as image:
156
+ png = _png(np.asarray(image.convert("RGBA")))
157
+ text = b"data:image/png;base64,\n" + base64.b64encode(png) + b'"'
158
+ if match[2] is None:
159
+ return text
160
+ salt = str(plt.rcParams["svg.hashsalt"] or "").encode()
161
+ return text + b' id="image' + hashlib.sha256(salt + png).hexdigest()[:10].encode() + b'"'
162
+
163
+ return _EMBEDDED.sub(rewrite, svg)
164
+
165
+
166
+ def _png(rgba: np.ndarray[Any, np.dtype[np.uint8]]) -> bytes:
167
+ """An 8-bit RGBA PNG of ``rgba`` without metadata, every row with the filter ``Up``."""
168
+ height, width = rgba.shape[:2]
169
+ rows = rgba.reshape(height, width * 4).astype(np.int16)
170
+ # Up stores each row as its difference to the row above, which turns the flat cells of a
171
+ # heatmap into runs of zeros; the first row is compared with zeros.
172
+ up = (rows - np.vstack([np.zeros_like(rows[:1]), rows[:-1]])) % 256
173
+ raw = np.hstack([np.full((height, 1), 2), up]).astype(np.uint8).tobytes()
174
+
175
+ def chunk(kind: bytes, data: bytes) -> bytes:
176
+ return (
177
+ struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data))
178
+ )
179
+
180
+ header = struct.pack(">IIBBBBB", width, height, 8, 6, 0, 0, 0)
181
+ return (
182
+ _PNG_SIGNATURE
183
+ + chunk(b"IHDR", header)
184
+ + chunk(b"IDAT", zlib.compress(raw, 9))
185
+ + chunk(b"IEND", b"")
186
+ )
187
+
188
+
189
+ def canvas(figure: Figure, width: float, pad: float = PAD) -> Bbox:
190
+ """Box of exactly ``width`` inches around the drawn content, starting at its left edge.
191
+
192
+ Text keeps its size when the figure gets narrower, so a drawing that sticks out is narrowed
193
+ by the excess and measured again, a few times until it fits. The height follows the content.
194
+
195
+ Raises:
196
+ ValueError: If the content cannot be fitted, for example a fixed text wider than the canvas.
197
+ """
198
+ for _ in range(8):
199
+ figure.draw_without_rendering()
200
+ box = figure.get_tightbbox().padded(pad)
201
+ excess = box.width - width
202
+ # Up to a fortieth of an inch of the margin may be cut, the padding absorbs it.
203
+ if excess <= pad / 6:
204
+ return Bbox.from_extents(box.x0, box.y0, box.x0 + width, box.y1)
205
+ w, h = figure.get_size_inches()
206
+ if w - excess <= 1:
207
+ break
208
+ # Only the axes shrink with the figure, so step a little further than the excess.
209
+ figure.set_size_inches(w - 1.25 * excess, h)
210
+ msg = f"the drawing is {box.width:.2f} in wide and does not fit a canvas of {width} in"
211
+ raise ValueError(msg)
212
+
213
+
214
+ def _write_raster(image: Image.Image, path: Path, output: Output) -> None:
215
+ rgba = image.convert("RGBA")
216
+ if output.pixels is not None and rgba.width != output.pixels:
217
+ # The tight box is measured before the final draw, so the width can be off by a pixel.
218
+ height = round(rgba.height * output.pixels / rgba.width)
219
+ rgba = rgba.resize((output.pixels, height), Image.Resampling.LANCZOS)
220
+ if output.format == "webp":
221
+ rgba.save(path, format="webp", quality=88, method=6)
222
+ return
223
+ # A 256-colour palette with alpha makes the PNG several times smaller; Pillow writes no date
224
+ # or version into it.
225
+ palette(rgba).save(path, format="png", optimize=True)
226
+
227
+
228
+ # Palette entries of fully opaque pixels; the rest hold the semi-transparent edges of text and lines
229
+ # and, in the last entry, the empty background.
230
+ _SOLID = 224
231
+ _CLEAR = 255
232
+
233
+
234
+ def palette(rgba: Image.Image) -> Image.Image:
235
+ """The image in at most 256 colours with alpha, without visible banding in photographs.
236
+
237
+ Pillow's only RGBA quantiser, the fast octree, keeps a few dozen greys of a photograph, which
238
+ shows as contour lines. So the opaque pixels get a median-cut palette of their own, and only
239
+ the semi-transparent pixels, the anti-aliased edges on the empty background, use the octree.
240
+ """
241
+ data = np.asarray(rgba.convert("RGBA"))
242
+ alpha = data[..., 3]
243
+ solid = alpha == 255
244
+ edges = (alpha > 0) & ~solid
245
+ index = np.full(alpha.shape, _CLEAR, dtype=np.uint8)
246
+ colours: list[int] = []
247
+ alphas: list[int] = []
248
+ if solid.any():
249
+ # The other pixels take the colour of an opaque one, so they use no palette entries.
250
+ # Quantising the image itself keeps full precision; mapping it onto a given palette
251
+ # would round to 6 bits per channel.
252
+ rgb = data[..., :3].copy()
253
+ rgb[~solid] = data[..., :3][solid][0]
254
+ solid_palette = Image.fromarray(rgb).quantize(
255
+ _SOLID, method=Image.Quantize.MEDIANCUT, dither=Image.Dither.NONE
256
+ )
257
+ index[solid] = np.asarray(solid_palette)[solid]
258
+ colours = _entries(solid_palette.getpalette() or [], 3, _SOLID)
259
+ alphas = [255] * _SOLID
260
+ offset = len(alphas)
261
+ free = _CLEAR - offset
262
+ if edges.any():
263
+ sample = Image.fromarray(np.ascontiguousarray(data[edges].reshape(-1, 1, 4)), "RGBA")
264
+ edge_palette = sample.quantize(
265
+ free, method=Image.Quantize.FASTOCTREE, dither=Image.Dither.NONE
266
+ )
267
+ index[edges] = offset + np.asarray(edge_palette).reshape(-1)
268
+ rgba_entries = _entries(edge_palette.getpalette(rawmode="RGBA") or [], 4, free)
269
+ for i in range(free):
270
+ colours += rgba_entries[4 * i : 4 * i + 3]
271
+ alphas.append(rgba_entries[4 * i + 3])
272
+ colours += [0] * (3 * _CLEAR - len(colours)) + [0, 0, 0]
273
+ alphas += [0] * (_CLEAR - len(alphas)) + [0]
274
+ result = Image.fromarray(index, "P")
275
+ result.putpalette(colours)
276
+ result.info["transparency"] = bytes(alphas)
277
+ return result
278
+
279
+
280
+ def _entries(values: list[int], channels: int, count: int) -> list[int]:
281
+ """The first ``count`` palette entries, padded with zeros."""
282
+ values = values[: channels * count]
283
+ return values + [0] * (channels * count - len(values))
284
+
285
+
286
+ def check_text(figure: Figure, minimum: float | None = None) -> None:
287
+ """Fail on visible text below the smallest size of the style, which pages make unreadable.
288
+
289
+ Raises:
290
+ ValueError: If a text is smaller than ``minimum``, by default the minimum of the bundled
291
+ style.
292
+ """
293
+ if minimum is None:
294
+ minimum = TYPE.minimum
295
+ for text in figure.findobj(Text):
296
+ size = float(text.get_fontsize())
297
+ if text.get_visible() and text.get_text().strip() and size < minimum:
298
+ msg = f"text {text.get_text()!r} is {size:g} pt, the minimum is {minimum:g}"
299
+ raise ValueError(msg)
300
+
301
+
302
+ def render(
303
+ directory: Path,
304
+ name: str,
305
+ draw: Draw,
306
+ outputs: Sequence[Output] = WEB,
307
+ themes: Sequence[Theme] | None = None,
308
+ *,
309
+ language: str | None = None,
310
+ headless: bool = False,
311
+ style: Style | None = None,
312
+ ) -> list[Path]:
313
+ """Draw one figure in every theme and write it in every output.
314
+
315
+ ``draw`` receives the theme and returns a new figure. For transparent outputs its surface is
316
+ ``none``, so fills that use ``theme.surface`` as a gap colour become empty as well. The figure
317
+ is drawn once per theme and transparency and closed after writing.
318
+
319
+ Args:
320
+ directory: Folder of the files.
321
+ name: Name of the figure, the start of every file name.
322
+ draw: Function of the theme that returns a new figure.
323
+ outputs: Formats to write.
324
+ themes: Themes to draw, by default all themes of ``style``.
325
+ language: Code such as ``de``. It goes into the file names, ``<name>.de.svg``, and
326
+ :func:`figkit.language` returns it while ``draw`` runs; numeric tick labels and
327
+ :func:`figkit.number` follow it. Without it the figure is English and unmarked.
328
+ headless: Leave out the title and subtitle of :func:`figkit.title`, for a page that
329
+ shows them as text.
330
+ style: Style that names the files, see :func:`path_for`; by default the bundled one.
331
+
332
+ Returns:
333
+ The written files, in the order of ``themes`` and then ``outputs``.
334
+
335
+ Raises:
336
+ ValueError: If the drawing does not fit the canvas or has text below the minimum size;
337
+ the message names the figure.
338
+ """
339
+ style = style or DEFAULT
340
+ paths: list[Path] = []
341
+ for theme in style.themes if themes is None else themes:
342
+ for transparent, group in groupby(outputs, key=lambda o: o.transparent):
343
+ used = replace(theme, surface="none") if transparent else theme
344
+ with (
345
+ styled(used),
346
+ plt.rc_context({"svg.hashsalt": name}),
347
+ speaking(language, without_title=headless),
348
+ ):
349
+ figure = draw(used)
350
+ try:
351
+ localize_ticks(figure, language or "en")
352
+ check_text(figure, theme.type.minimum)
353
+ paths.extend(
354
+ save(
355
+ figure,
356
+ path_for(directory, name, theme, output, language, style),
357
+ output,
358
+ )
359
+ for output in group
360
+ )
361
+ except ValueError as error:
362
+ error.add_note(f"while writing figure {name!r} in the {theme.name} theme")
363
+ raise
364
+ finally:
365
+ plt.close(figure)
366
+ return paths
Binary file
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2022 The Bricolage Grotesque Project Authors (https://github.com/ateliertriay/bricolage)
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
+ https://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.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
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: https://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.