-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add * add * add * add * add * Fix tests * Delete test.py * a * add
- Loading branch information
1 parent
3714232
commit 83c2e47
Showing
14 changed files
with
172 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,7 @@ | ||
Resvg Module | ||
============ | ||
|
||
.. currentmodule:: resvg_py.svg_to_base64 | ||
.. currentmodule:: resvg_py | ||
|
||
.. function:: svg_to_base64(svg_str:str,svg_path:str,width:int|None=None,height:int|None=None,zoom:int|None=None,dpi:int|None=None,resources_dir:width:str|None=None,languages:list[str]|None=None,font_size:float|None=None,font_family:str|None=None,serif_family:str|None=None,sans_serif_family:str|None=None,cursive_family:str|None=None,fantasy_family:str|None=None,monospace_family:str|None=None,font_files:list[str]|None=None,font_dirs:list[str]|None=None,shape_rendering:"optimize_speed"|"crisp_edges"|"geometric_precision"="geometric_precision",text_rendering:"optimize_speed"|"optimize_legibility"|"geometric_precision"="optimize_legibility",image_rendering:"optimize_quality"|"optimize_speed"="optimize_quality",background:str|None=None) -> str | ||
.. autofunction:: svg_to_bytes | ||
|
||
:param svg_str: A string containing valid svg. | ||
:type svg_str: string | ||
|
||
:param svg_path: A path to a valid svg. | ||
:type svg_str: string | ||
|
||
:param width: An Integer containing the pixels size for width. | ||
:type width: int or None | ||
|
||
:param height: An Integer containing the pixels size for height. | ||
:type height: int or None | ||
|
||
:param zoom: An Integer containing the zoom percentage. | ||
:type zoom: int or None | ||
|
||
:param dpi: An Integer containing DPI size for the svg rendering. | ||
:type dpi: int or None | ||
|
||
:param resources_dir: A directory that contains resources for svg rendering. Such as `foreign objects <https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject>`_. | ||
:type resources_dir: string or None | ||
|
||
:param languages: A list of string containing the languages used for `svg` rendering | ||
:type languages: list[str] or None | ||
|
||
:param font_size: An integer describing the font_size. | ||
:type font_size: float or None | ||
|
||
:param font_family: A string that describes the font family used in SVG. | ||
:type font_family: str or None | ||
|
||
:param serif_family: A string that describes the serif font family used in SVG. | ||
:type serif_family: str or None | ||
|
||
:param sans_serif_family: A string that describes the sans serif font family used in SVG. | ||
:type sans_serif_family: str or None | ||
|
||
:param cursive_family: A string that describes the cursive font family used in SVG. | ||
:type cursive_family: str or None | ||
|
||
:param fantasy_family: A string that describes the fantasy font family used in SVG. | ||
:type fantasy_family: str or None | ||
|
||
:param monospace_family: A string that describes the monospace font family used in SVG. | ||
:type monospace_family: str or None | ||
|
||
:param font_files: A list of paths that contain the font file. | ||
:type font_files: list[str] or None | ||
|
||
:param font_dirs: A list of directories that contain the font file. This parameter will add all the present files in the directory. | ||
:type font_dirs: list[str] or None | ||
|
||
:param shape_rendering: The `shape rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering>`_ used in resvg. **Defaults to "geometric_precision"**. | ||
:type shape_rendering: "optimize_speed" or "crisp_edges" or **"geometric_precision"** | ||
|
||
:param text_rendering: The `text rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-rendering>`_ used in resvg. **Defaults to "optimize_legibility"**. | ||
:type text_rendering: "optimize_speed" or **"optimize_legibility"** or "geometric_precision" | ||
|
||
:param image_rendering: The `image rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering>`_ used in resvg. **Defaults to "optimize_quality"**. | ||
:type image_rendering: **"optimize_quality"** or "optimize_speed" | ||
|
||
:param background: A `CSS color <https://developer.mozilla.org/en-US/docs/Web/CSS/color_value>`_ value that describes the canvas size. | ||
:type background: str or None | ||
|
||
:return: base64 encoded string. | ||
:rtype: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "resvg-py" | ||
version = "0.1.3" | ||
version = "0.1.4" | ||
description = "" | ||
authors = ["baseplate-admin <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -15,6 +15,7 @@ pytest = "^8.1.1" | |
[tool.poetry.group.docs.dependencies] | ||
sphinx = "^7.2.6" | ||
furo = "^2024.1.29" | ||
sphinx-reload = "^0.2.0" | ||
|
||
[build-system] | ||
requires = ["maturin>=1.4,<2.0"] | ||
|
@@ -37,3 +38,4 @@ Documentation = "https://resvg-py.readthedocs.io/" | |
|
||
[tool.maturin] | ||
features = ["pyo3/extension-module"] | ||
python-source = "src/python" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Literal | ||
|
||
def svg_to_bytes( | ||
svg_string: str | None = None, | ||
svg_path: str | None = None, | ||
width: int | None = None, | ||
height: int | None = None, | ||
resources_dir: str | None = None, | ||
languages: list[str] | None = None, | ||
font_size: int | None = None, | ||
font_family: str | None = None, | ||
serif_family: str | None = None, | ||
sans_serif_family: str | None = None, | ||
cursive_family: str | None = None, | ||
fantasy_family: str | None = None, | ||
monospace_family: str | None = None, | ||
font_files: list[str] | None = None, | ||
font_dirs: list[str] | None = None, | ||
shape_rendering: Literal["optimize_speed"] | ||
| Literal["crisp_edges"] | ||
| Literal["geometric_precision"] = Literal["geometric_precision"], | ||
text_rendering: Literal["optimize_speed"] | ||
| Literal["optimize_legibility"] | ||
| Literal["geometric_precision"] = Literal["optimize_legibility"], | ||
image_rendering: Literal["optimize_quality"] | Literal["optimize_speed"] = Literal[ | ||
"optimize_quality" | ||
], | ||
background: str | None = None, | ||
) -> list[bytes]: | ||
""" | ||
:param svg_str: A string containing valid svg. | ||
:param svg_path: A path to a valid svg. | ||
:param width: An Integer containing the pixels size for width. | ||
:param height: An Integer containing the pixels size for height. | ||
:param zoom: An Integer containing the zoom percentage. | ||
:param dpi: An Integer containing DPI size for the svg rendering. | ||
:param resources_dir: A directory that contains resources for svg rendering. Such as `foreign objects <https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject>`_. | ||
:param languages: A list of string containing the languages used for `svg` rendering | ||
:param font_size: An integer describing the font_size. | ||
:param font_family: A string that describes the font family used in SVG. | ||
:param serif_family: A string that describes the serif font family used in SVG. | ||
:param sans_serif_family: A string that describes the sans serif font family used in SVG. | ||
:param cursive_family: A string that describes the cursive font family used in SVG. | ||
:param fantasy_family: A string that describes the fantasy font family used in SVG. | ||
:param monospace_family: A string that describes the monospace font family used in SVG. | ||
:param font_files: A list of paths that contain the font file. | ||
:param font_dirs: A list of directories that contain the font file. This parameter will add all the present files in the directory. | ||
:param shape_rendering: The `shape rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering>`_ used in resvg. **Defaults to "geometric_precision"**. | ||
:param text_rendering: The `text rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-rendering>`_ used in resvg. **Defaults to "optimize_legibility"**. | ||
:param image_rendering: The `image rendering method <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering>`_ used in resvg. **Defaults to "optimize_quality"**. | ||
:param background: A `CSS color <https://developer.mozilla.org/en-US/docs/Web/CSS/color_value>`_ value that describes the canvas size. | ||
""" | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.