Change blend_method for transparency. "Dithered" looks more grany, and the new default "Blended" looks smoother.
update to typst 0.13.1
Added object indices support with blue numbered labels.
from typst_importer.typst_to_svg import typst_express
content = "$ a = b + c $"
c = typst_express(content, origin_to_char=True, show_indices=True,
position=(0, 2, 0), name="Simple")
content = "$ limits(integral)_a^b f(x) dif x $"
c = typst_express(content, origin_to_char=True, show_indices=True,
name="Integral")
Update to typst 0.13 https://typst.app/blog/2025/typst-0.13/
new position argument:
add "Allign Object" operator. Keyboard shortcut j, or "Object -> Allign Object (XY)"
add "Allign Collection". Keyboard shortcut l, or "Object -> Allign Collection (XY)"
typst_express(
"hi",
name="Example",
position=(2, 2, 0), # Place 2 units to the right
)
from typst_importer.typst_to_svg import typst_express
def eq(equation: str, name: str, color: str, position=(0, 0, 0)):
typst_code = f"""
#set text({color})
$ {equation} $
"""
collection = typst_express(
typst_code,
origin_to_char=True,
convert_to_mesh=True,
name=name,
position=position
)
return collection
eq("a -b = c", "Start", "aqua", (0, -4, 0.5))
eq("a - 3 r_(beta) = c", "End", "olive", (0, -4, 0));
add lxml dependency
convert_to_mesh
c = typst_express("$ . . . $", scale_factor=100, origin_to_char=False, convert_to_mesh=True)
c.processed_svg
from typst_importer.typst_to_svg import typst_express
from typst_importer.notebook_utils import display_svg
c = typst_express("""
#set math.lr(size: 80%)
$ integral.triple _V (nabla dot accent(F, arrow)) dif V = integral.surf_(partial V) (accent(F, arrow) dot accent(n, arrow)) dif A $
"""
)
display_svg(c.processed_svg, width="400px")
typst_express
:scale_factor
: Control the size of the rendered output (default: 100.0)origin_to_char
: Option to adjust origin point relative to characters (default: False)def typst_express(
content: str,
name: str = "typst_expr",
header: str = "",
scale_factor: float = 100.0,
origin_to_char: bool = False
)
For example
from typst_importer.typst_to_svg import typst_express
typst_express("$ a = b/d $" , scale_factor=200, origin_to_char=True)
get_curve_collection_bounds
will get the deminsons of a collection, e.g.from typst_importer.typst_to_svg import typst_express
from typst_importer.curve_utils import get_curve_collection_bounds
c = typst_express("$ a = b/d$", scale_factor=100, origin_to_char=False)
min_p, max_p = get_curve_collection_bounds(c)
print(min_p, max_p)
# out <Vector (0.0249, -0.2190, 0.0000)> <Vector (1.4839, 0.5474, 0.0000)>
shift_scene_content
will shift all scene_content to a new position except the given collection c.from typst_importer.typst_to_svg import typst_express
from typst_importer.curve_utils import shift_scene_content
c = typst_express("$ a = b/d$", scale_factor=100, origin_to_char=False)
shift_scene_content(c)
flatten_svg
will flatten the SVG structure fiststroke_to_filled_path
will convert all strokes to paths.Before <-> After:
from typst_importer.svg_preprocessing import flatten_svg, stroke_to_filled_path
svg_content = open("test.svg").read()
svg_content = flatten_svg(svg_content)
svg_content = stroke_to_filled_path(svg_content)
open("test_filled.svg", "w").write(svg_content)
or combined as preprocess_svg
from typst_importer.svg_preprocessing import preprocess_svg
svg_content = open("test.svg").read()
svg_content = preprocess_svg(svg_content)
open("test_filled.svg", "w").write(svg_content)
display_svg
function to display svgs in Jupyter.from typst_importer.notebook_utils import display_svg
display_svg(step1_content , width='500px')
from typst_importer.typst_to_svg import typst_express
from typst_importer.typst_to_svg import typst_to_blender_curves
for more, see https://github.com/kolibril13/blender_typst_importer/pull/4
better wheels packing