Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BytesIO as an argument of file_name in text2svg method #42

Closed
shenjing023 opened this issue Mar 23, 2021 · 2 comments
Closed

Support BytesIO as an argument of file_name in text2svg method #42

shenjing023 opened this issue Mar 23, 2021 · 2 comments

Comments

@shenjing023
Copy link

In Manim Text class, if override the text2svg method use pycairo:

def text2svg(self):
        # anti-aliasing
        size = self.size * 10
        lsh = self.lsh * 10

        if self.font == '':
            raise Exception("text font can not be empty")

        # file_name as a writable file object 
        file_name = BytesIO()
        surface = cairo.SVGSurface(file_name, 600, 400)
        context = cairo.Context(surface)
        context.set_font_size(size)
        context.move_to(START_X, START_Y)

It can manipulate SVG in memory.
Here is the reference:
pycairo svgsurface
surface.c

@naveen521kk
Copy link
Member

I really don't understand the use case.

Manim creates the SVG file using ManimPango and later parses it. It should anyway save the file because Manim wants to Cache the SVG file for the future as well as the SVG parser doesn't support parsing file object directly (maybe you can make an issue about that in other repo).

In case, you are asking for use in any other project you should possibly wait until #28.

@naveen521kk
Copy link
Member

Closing this. I think it should be fine to add this support when #28 is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants