Code Monkey home page Code Monkey logo

Comments (15)

naveen521kk avatar naveen521kk commented on May 14, 2024 2

Looks like my fault sorry. It needs to be pangocairo only then it will work.

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024 1

You can compile it with gcc <file-name> $(pkg-config --libs --cflags pango).

No luck. Must be some other problem, probably related to gcc/clang on OS X.

Oh!, you are forcing white on it, I see.

Actually, forcing it to whatever the user chose as their preferred color. This is because we do not set the color to the SVGMobject when MarkupText is used; that is a difference compared to Text. With MarkupText, the color is in the SVG and must not be changed from within Manim anymore.

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024 1

This is the error message:


$ gcc -v test.c $(pkg-config --libs --cflags pango) -o test

Undefined symbols for architecture x86_64:
  "_cairo_create", referenced from:
      _main in test-7a8efa.o
  "_cairo_destroy", referenced from:
      _main in test-7a8efa.o
  "_cairo_move_to", referenced from:
      _main in test-7a8efa.o
  "_cairo_surface_destroy", referenced from:
      _main in test-7a8efa.o
  "_cairo_svg_surface_create", referenced from:
      _main in test-7a8efa.o
  "_pango_cairo_create_layout", referenced from:
      _main in test-7a8efa.o
  "_pango_cairo_show_layout", referenced from:
      _main in test-7a8efa.o
  "_pango_cairo_update_layout", referenced from:
      _main in test-7a8efa.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I still think it is related to some Xcode / clang / gcc issue on OS X. It might work with Homebrew's gcc and build system.

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

While trying out the same with Text it shows up, the text's are black in colour rather than white.

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024

I'm not sure I get what you mean, but having white as the default color is expected, see

ManimCommunity/manim#1090
ManimCommunity/manim#1039

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

I thought black was the default color? Is there any problems on changing the default text color to black? Or is it a bug in Pango?

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024

Default color for MarkupText is WHITE to avoid text "not showing up" in the video.

https://github.com/ManimCommunity/manim/blob/71a05e82b954e3046e89100d8116412156495e8d/manim/mobject/svg/text_mobject.py#L1187-L1206

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

Default color for MarkupText is WHITE to avoid text "not showing up" in the video.

That's fine. I am considering the SVG file here, would there be any problems? Also, I can't reproduce this in C.

#include <cairo.h>
#include <cairo-svg.h>
#include <math.h>
#include <pango/pangocairo.h>

#define WIDTH 600
#define HEIGHT 400
#define TEXT "Hello"

int
main (void)
{
    cairo_surface_t* surface;
    cairo_t* cr;
    PangoFontDescription* font_desc;
    PangoLayout* layout;
    double width_layout = WIDTH;
    double font_size_c= 1;
    const char * filename="test.svg";


    surface = cairo_svg_surface_create (filename,WIDTH, HEIGHT);
    cr = cairo_create (surface);

    cairo_move_to(cr,20,20);

    layout = pango_cairo_create_layout(cr);


    pango_layout_set_width(layout, pango_units_from_double(width_layout));
    font_desc = pango_font_description_new();
    pango_font_description_set_size(font_desc, pango_units_from_double(font_size_c));
    pango_font_description_set_style(font_desc, PANGO_STYLE_ITALIC);
    pango_font_description_set_weight(font_desc, PANGO_WEIGHT_BOLD);
    pango_layout_set_font_description(layout, font_desc);
    pango_font_description_free(font_desc);

    cairo_move_to(cr,30,20);
    pango_cairo_update_layout(cr,layout);

    pango_layout_set_markup(layout, TEXT, -1);
    pango_cairo_show_layout(cr, layout);


    cairo_destroy (cr);
    cairo_surface_destroy (surface);
    g_object_unref(layout);
    return 0;
}

I think we are doing something wrong and because of that we get white coloured texts.

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024

I cannot currently compile the above code on my machine due to some linking error / library path issue. But IIRC it will yield black text, no?

I don't know whether we are doing something wrong, but white seems to be a sensible choice for the default color over at Manim. The white color in the SVG created by instantiating a MarkupText object comes from this code:

https://github.com/ManimCommunity/manim/blob/71a05e82b954e3046e89100d8116412156495e8d/manim/mobject/svg/text_mobject.py#L1324-L1337

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

I cannot currently compile the above code on my machine due to some linking error / library path issue.

You can compile it with gcc <file-name> $(pkg-config --libs --cflags pango).

But IIRC it will yield black text, no?

Yes, it did, I attach the file, test.svg

The white color in the SVG created by instantiating a MarkupText object comes from this code:

https://github.com/ManimCommunity/manim/blob/71a05e82b954e3046e89100d8116412156495e8d/manim/mobject/svg/text_mobject.py#L1324-L1337

Oh!, you are forcing white on it, I see.
https://github.com/ManimCommunity/manim/blob/71a05e82b954e3046e89100d8116412156495e8d/manim/mobject/svg/text_mobject.py#L1325
Now I understand what is happening. Thanks.

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

No luck. Must be some other problem, probably related to gcc/clang on OS X.

If you tell me what are the error I can help, or you can use meson here 😉, I uploaded a zip file with meson configuration

PangoTests.zip

to compile run:

pip install meson ninja
meson builddir --prefix='$PWD/prefix'
meson compile -C builddir

this should create an executable in prefix which will create an .svg file.

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

I think I got no idea on how to, sorry.

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024

FWIW, I was able to build it with gcc -o test `pkg-config --cflags --libs pangocairo` test.c using either the default GCC from OS X Catalina or the one from Homebrew. Usingpkg-config pango or pkg-config pango cairo is not sufficient, at least not on my Mac, no matter which gcc I used.

from manimpango.

naveen521kk avatar naveen521kk commented on May 14, 2024

Oh, this is because of a different shell and isn't about GCC. Essentially, $() in bash means it will execute the first and then the value gets substituted in the next statement. Maybe, you don't have bash shell?

from manimpango.

PhilippImhof avatar PhilippImhof commented on May 14, 2024

No, it's not about the shell. Backticks or $() are basically the same thing. It's about pango vs. pangocairo. They do not yield the same libs and includes:

$ pkg-config --libs-only-l pango      
-lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lharfbuzz

vs.

pkg-config --libs-only-l pango cairo
-lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lharfbuzz -lcairo

vs.

$ pkg-config --libs-only-l pangocairo 
-lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lharfbuzz -lcairo

The missing symbols were namely

"_pango_cairo_create_layout", referenced from:
      _main in test-c1d4ee.o
"_pango_cairo_show_layout", referenced from:
      _main in test-c1d4ee.o
"_pango_cairo_update_layout", referenced from:
      _main in test-c1d4ee.o

which must have been due to the missing -lpangocairo-1.0.

from manimpango.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.