gjtorikian / mathematical

Convert mathematical equations to SVGs, PNGs, or MathML. A general wrapper to Lasem and mtex2MML.
https://gjtorikian.github.io/mathematical/
MIT License
164 stars 31 forks source link

Rendering issues #51

Closed AndorChen closed 8 years ago

AndorChen commented 9 years ago

Some issues came up when rendering. First, in svg mode, the output data has no content:

>> render = Mathematical.new
=> #<Mathematical:0x007f94fb9719d0 @config={:ppi=>72.0, :zoom=>1.0, :base64=>false, :maxsize=>0, :format=>:svg, :delimiter=>3, :formatInt=>0}, @processer=#<Mathematical::Process:0x007f94fb971278 @ppi=72.0, @zoom=1.0, @maxsize=0, @format=0, @delimiter=3, @png=nil, @svg=nil>>
>> render.render '$a \ne b$'
=> {:data=>"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"27.688152pt\" height=\"8.361328pt\" viewBox=\"0 0 27.688152 8.361328\" version=\"1.1\">\n</svg>\n", :width=>27, :height=>8}

There's just a newline within svg tag.

Second, in png mode, "Failed to read PNG contents" error:

>> render =  Mathematical.new format: :png
=> #<Mathematical:0x007f94fb9616c0 @config={:ppi=>72.0, :zoom=>1.0, :base64=>false, :maxsize=>0, :format=>:png, :delimiter=>3, :formatInt=>1}, @processer=#<Mathematical::Process:0x007f94fb95b6d0 @ppi=72.0, @zoom=1.0, @maxsize=0, @format=1, @delimiter=3, @png=nil, @svg=nil>>
>> render.render '$a \ne b$'
Failed to read PNG contents=> {:data=>"$a \\ne b$", :exception=>#<Mathematical::DocumentReadError: Failed to read PNG contents>}

I tried and installed XQuartz, but the issues still.

And also installed Cairo@1.12.16 , but got this error:

Incompatible library version: libpangocairo-1.0.0.dylib requires version 11403.0.0 or later, but libcairo.2.dylib provides version 11203.0.0

It just seems like there are some libs missed.

gjtorikian commented 9 years ago

Hi! What's your operating system? Did you run script/bootstrap to fetch all the dependencies? It does seem like something is missing.

AndorChen commented 9 years ago

@gjtorikian My system is Mac OS X Yosemite. I had all the dependencies list in script/bootstrap installed manually via homebrew.

gjtorikian commented 9 years ago

Very very weird. Can you try the following?

render = Mathematical.new format: :mathml
render.render '$a \ne b$'

If MathML doesn't work, then that suggests the core problem is in https://github.com/gjtorikian/mtex2MML. If it does work then perhaps Cairo/Pango needs to be uninstalled and reinstalled?

tstumm commented 9 years ago

The core problem is not mtex2MML (which gives me no error at all)

irb(main):003:0> render.render '$a \ne b$'
=> {:data=>"<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>a</mi><mo>&ne;</mo><mi>b</mi></mrow><annotation encoding='application/x-tex'>a \\ne b</annotation></semantics></math>"}

I also reinstalled Cairo and Pango. The main problem is, that even with the downgraded version of cairo, pango automatically installs the newest cairo (and therefore the libraries of pango are linked to the newer cairo version). Still I can't seem to find the problem why svgs and pngs are empty.

gjtorikian commented 9 years ago

@tstumm Which versions are you running? I have currently:

Also, which version of OS X are you on? Does it still spit out Incompatible library version?

paulvickers commented 9 years ago

I'm running this on OS X 10.9.5 (Mavericks) and am getting the same problems. I have the following versions:

tstumm commented 9 years ago

Hey @gjtorikian sorry for the late response. I'm running the same versions but on Yosemite.

gjtorikian commented 9 years ago

I am going to look for a clean Mac and try to sort this out.

gjtorikian commented 9 years ago

So I spent an obscene amount of time trying to track down rendering issues. Could someone on this thread try mathematical@1.5.8 and see if the issue's been solved?

tstumm commented 9 years ago

I'm getting this when using gem install mathematical:

[100%] Linking C shared library liblasem.dylib
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [liblasem.dylib] Error 1
make[1]: *** [CMakeFiles/lasem.dir/all] Error 2
make: *** [all] Error 2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
tstumm commented 9 years ago

I guess lasem does not build correctly / isn't built at all.

gjtorikian commented 9 years ago

Well, at least it's something! Can you try brew install gettext first, and then the same gem install?

tstumm commented 9 years ago

BTW this is the full log of the first install: http://paste.ubuntu.com/12519530/

tstumm commented 9 years ago

gettext-0.19.5.1 already installed

gjtorikian commented 9 years ago

Cool, I can reproduce your problem. Try brew link gettext --force, and then the same gem install. If you don't like it, you can brew unlink gettext once it's done.

I'm trying to now figure out why libintl is a dependency, though it may always have been.

tstumm commented 9 years ago

Now it's working. Gettext is a dependency of cairo or pango afaik. But why does brew not link the libs?

gjtorikian commented 9 years ago

But why does brew not link the libs?

Who knows. Computers are weird.

Does the rendering work as well?

tstumm commented 9 years ago

We should make sure to open an issue over at homebrew afterwards ;)

tstumm commented 9 years ago

It's working thank you very much!

gjtorikian commented 9 years ago

Yesssss.

I'll leave this open a bit for @AndorChen and/or @paulvickers to comment. I'll look a bit into the intl mystery too.

paulvickers commented 9 years ago

Hmmm... I just got a new machine at work, so I have just installed homebrew, asciidoctor and asciidoctor-odf. I then tried installing asciidoctor-mathematical. I followed the instructions at: https://github.com/tstumm/asciidoctor-mathematical That is, I did:

brew install glib gdk-pixbuf cairo pango cmake

I installed the fonts I installed a working JDK (version 8):

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Then I tried:

gem install asciidoctor-mathematical

Which gave me the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing asciidoctor-mathematical:
    ERROR: Failed to build gem native extension.

    /usr/local/opt/ruby/bin/ruby -r ./siteconf20150922-63211-e8z4nl.rb extconf.rb
tstumm commented 9 years ago

Can you provide a full log?

paulvickers commented 9 years ago
Building native extensions.  This could take a while...
ERROR:  Error installing asciidoctor-mathematical:
    ERROR: Failed to build gem native extension.

    /usr/local/opt/ruby/bin/ruby -r ./siteconf20150922-63211-e8z4nl.rb extconf.rb
checking for cmake... yes
checking for main() in -lxml2... yes
checking for main() in -lpangocairo-1.0... yes
checking for libxml/tree.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/parser.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpath.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpathInternals.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
-- The C compiler identification is AppleClang 7.0.0.7000072
-- The CXX compiler identification is AppleClang 7.0.0.7000072
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found BISON: /usr/bin/bison (found version "2.3") 
-- Found FLEX: /usr/bin/flex (found version "2.5.35") 
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Found PythonInterp: /usr/bin/python (found version "2.7.10") 
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/mtex2MML/build
[ 11%] [FLEX][MTEX2MMLSCANNER] Building scanner with flex 2.5.35
[ 22%] [BISON][MTEX2MMLPARSER] Building parser with bison 2.3
conflicts: 5209 shift/reduce, 412 reduce/reduce
Scanning dependencies of target libmtex2MML_static
[ 33%] Building C object CMakeFiles/libmtex2MML_static.dir/src/colors.c.o
[ 44%] Building C object CMakeFiles/libmtex2MML_static.dir/src/em.c.o
[ 55%] Building C object CMakeFiles/libmtex2MML_static.dir/src/environment.c.o
[ 66%] Building C object CMakeFiles/libmtex2MML_static.dir/src/string_extras.c.o
[ 77%] Building C object CMakeFiles/libmtex2MML_static.dir/parser.c.o
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/mtex2MML/src/parser.y:54:30: warning: unused parameter 'ret_str' [-Wunused-parameter]
 static void yyerror (char **ret_str, const char * s)
                             ^
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/mtex2MML/src/parser.y:66:14: warning: unused function 'mtex2MML_default_write' [-Wunused-function]
 static void mtex2MML_default_write (const char * buffer, unsigned long length)
             ^
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/mtex2MML/src/parser.y:77:14: warning: unused function 'mtex2MML_default_write_mathml' [-Wunused-function]
 static void mtex2MML_default_write_mathml (const char * mathml)
             ^
3 warnings generated.
[ 88%] Building C object CMakeFiles/libmtex2MML_static.dir/lexer.c.o
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/mtex2MML/build/lexer.c:8186:16: warning: function 'input' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    static int input  (void)
               ^
1 warning generated.
[100%] Linking C static library libmtex2MML.a
[100%] Built target libmtex2MML_static
-- The C compiler identification is AppleClang 7.0.0.7000072
-- The CXX compiler identification is AppleClang 7.0.0.7000072
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28") 
-- REQUIRED_VARS
-- checking for module 'glib-2.0'
--   found glib-2.0, version 2.46.0
-- checking for module 'cairo'
--   found cairo, version 1.14.2
-- checking for module 'pango'
--   found pango, version 1.36.8
-- checking for module 'gdk-pixbuf-2.0'
--   found gdk-pixbuf-2.0, version 2.30.8
-- checking for module 'libxml-2.0'
--   found libxml-2.0, version 2.9.0
-- checking for module 'gio-2.0'
--   found gio-2.0, version 2.46.0
-- checking for module 'pangocairo'
--   found pangocairo, version 1.36.8
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   lasem

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/lasem/build
Scanning dependencies of target lasem
[  0%] Building C object CMakeFiles/lasem.dir/lasem/src/lsm.c.o
[  1%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmattributes.c.o
[  2%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmcairo.c.o
[  3%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdebug.c.o
[  4%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomcharacterdata.c.o
[  5%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomdocument.c.o
[  6%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomdocumentfragment.c.o
[  7%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomelement.c.o
[  8%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomentities.c.o
[  9%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomimplementation.c.o
[  9%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomnamednodemap.c.o
[ 10%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomnode.c.o
[ 11%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomnodelist.c.o
[ 12%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomparser.c.o
[ 13%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomtext.c.o
[ 14%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmdomview.c.o
[ 15%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlactionelement.c.o
[ 16%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlaligngroupelement.c.o
[ 17%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlalignmarkelement.c.o
[ 18%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlattributes.c.o
[ 18%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmldocument.c.o
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/lasem/src/lsmmathmldocument.c:259:52: warning: passing 'gssize *' (aka 'long *') to parameter of type 'gsize *' (aka 'unsigned long *') converts between pointers to integer types with different sign [-Wpointer-sign]
        if (!g_file_load_contents (file, NULL, &contents, &size, NULL, error))
                                                          ^~~~~
/usr/local/Cellar/glib/2.46.0/include/glib-2.0/gio/gfile.h:1185:36: note: passing argument to parameter 'length' here
                                              gsize                  *length,
                                                                      ^
1 warning generated.
[ 19%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlelement.c.o
[ 20%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlencloseelement.c.o
[ 21%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlenums.c.o
[ 22%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlerrorelement.c.o
[ 23%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlfencedelement.c.o
[ 24%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlfractionelement.c.o
[ 25%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlglyphtableams.c.o
[ 26%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlitexelement.c.o
[ 27%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmllayoututils.c.o
[ 27%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlmathelement.c.o
[ 28%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmloperatordictionary.c.o
[ 29%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmloperatorelement.c.o
[ 30%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlpaddedelement.c.o
[ 31%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlphantomelement.c.o
[ 32%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlpresentationcontainer.c.o
[ 33%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlpresentationtoken.c.o
[ 34%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlradicalelement.c.o
[ 35%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlrowelement.c.o
[ 36%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlscriptelement.c.o
[ 36%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlsemanticselement.c.o
[ 37%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlspaceelement.c.o
[ 38%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlstringelement.c.o
[ 39%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlstyle.c.o
[ 40%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlstyleelement.c.o
[ 41%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmltablecellelement.c.o
[ 42%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmltableelement.c.o
[ 43%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmltablerowelement.c.o
[ 44%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmltraits.c.o
[ 45%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlunderoverelement.c.o
[ 45%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlutils.c.o
[ 46%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmmathmlview.c.o
[ 47%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmproperties.c.o
[ 48%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmstr.c.o
[ 49%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgaelement.c.o
[ 50%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgcircleelement.c.o
[ 51%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgclippathelement.c.o
[ 52%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgcolors.c.o
[ 53%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgdefselement.c.o
[ 54%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgdocument.c.o
[ 54%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgelement.c.o
[ 55%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgellipseelement.c.o
[ 56%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgenums.c.o
[ 57%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterblend.c.o
[ 58%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltercolormatrix.c.o
[ 59%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltercomposite.c.o
[ 60%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterconvolvematrix.c.o
[ 61%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterdisplacementmap.c.o
[ 62%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterelement.c.o
[ 63%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterflood.c.o
[ 63%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltergaussianblur.c.o
[ 64%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterimage.c.o
[ 65%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltermerge.c.o
[ 66%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltermergenode.c.o
[ 67%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltermorphology.c.o
[ 68%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilteroffset.c.o
[ 69%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterprimitive.c.o
[ 70%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterspecularlighting.c.o
[ 71%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltersurface.c.o
[ 72%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfiltertile.c.o
[ 72%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgfilterturbulence.c.o
[ 73%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvggelement.c.o
[ 74%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvggradientelement.c.o
[ 75%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgimageelement.c.o
[ 76%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvglength.c.o
[ 77%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvglineargradientelement.c.o
[ 78%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvglineelement.c.o
[ 79%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgmarkerelement.c.o
[ 80%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgmaskelement.c.o
[ 81%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgmatrix.c.o
[ 81%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgpathelement.c.o
[ 82%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgpatternelement.c.o
[ 83%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgpolygonelement.c.o
[ 84%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgpolylineelement.c.o
[ 85%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgradialgradientelement.c.o
[ 86%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgrectelement.c.o
[ 87%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgstopelement.c.o
[ 88%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgstyle.c.o
[ 89%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgsvgelement.c.o
[ 90%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgswitchelement.c.o
[ 90%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgsymbolelement.c.o
[ 91%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgtextelement.c.o
[ 92%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgtraits.c.o
[ 93%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgtransformable.c.o
[ 94%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgtspanelement.c.o
[ 95%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvguseelement.c.o
[ 96%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmsvgview.c.o
[ 97%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmtraits.c.o
[ 98%] Building C object CMakeFiles/lasem.dir/lasem/src/lsmutils.c.o
[ 99%] Building C object CMakeFiles/lasem.dir/lasem_overrides.c.o
/usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/lasem_overrides.c:23:54: warning: control reaches end of non-void function [-Wreturn-type]
lsm_itex_to_mathml (const char *itex, gssize size) { }
                                                     ^
1 warning generated.
[100%] Linking C shared library liblasem.dylib
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [liblasem.dylib] Error 1
make[1]: *** [CMakeFiles/lasem.dir/all] Error 2
make: *** [all] Error 2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/Cellar/ruby/2.2.3/bin/$(RUBY_BASE_NAME)
    --with-xml2lib
    --without-xml2lib
    --with-pangocairo-1.0lib
    --without-pangocairo-1.0lib
/usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1386:in `copy': unknown file type: /usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8/ext/mathematical/lasem/build/liblasem.dylib (RuntimeError)
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:471:in `block in copy_entry'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1497:in `call'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1497:in `wrap_traverse'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:468:in `copy_entry'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:443:in `block in cp_r'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1570:in `block in fu_each_src_dest'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1584:in `fu_each_src_dest0'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:1568:in `fu_each_src_dest'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/fileutils.rb:442:in `cp_r'
    from extconf.rb:71:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/mathematical-1.5.8 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/mathematical-1.5.8/gem_make.out
tstumm commented 9 years ago

brew link gettext --force

paulvickers commented 9 years ago

Okay, that did it! Thanks. :-)

paulvickers commented 9 years ago

@gjtorikian

Yesssss.

I'll leave this open a bit for @AndorChen and/or @paulvickers to comment. I'll look a bit into the intl >mystery too.

On this new machine (OS X Yosemite) with a fresh install of homebrew and the asciidoctor tools it does, at last work. :-) But the rendered math seems a bit fuzzy. output

tstumm commented 9 years ago

Try zooming. asciidoctor-mathematical generates pngs @ 300dpi by default. Scaling them down will make the graphics fuzzy.

paulvickers commented 9 years ago

Yes, I did think of that, given Yosemite's Preview seems to not like LaTeX pdfs without zooming. Still looks a bit fuzzy though:

zoomed

The above image was taken from being zoomed in pretty close

tstumm commented 9 years ago

Sorry I can't reproduce this. stem-4e4cad74f2dc2eb92cc5b8fbf76de692

paulvickers commented 9 years ago

stem-4e4cad74f2dc2eb92cc5b8fbf76de692 Even in your example the variable names appear to have had the tops and bottoms cropped -- notice the flat bottoms of a, b, and c, and the flattened tops of the 2s?

tstumm commented 9 years ago

While investigating I switched to svgs and those are complete garbage. @gjtorikian can you confirm?

paulvickers commented 9 years ago

Interesting, I tried it too and the svg doesn't work. So, I opened the svg up in Illustrator and this is what appears in the editing window:

svg

Besides the character positioning, it looks like the bounding box is in the wrong place too.

tstumm commented 9 years ago

This looks like a Mathematical issue.

ProgramFan commented 9 years ago

@tstumm @paulvickers When first implementing the zooming support, I choose 300ppi since it's often used in printing, but this decision is not fully justified. Is the fuzzy formula caused by low resolution? If your Mac has retina display, the pdf may get scaled beyond the usually resolution on my laptop (1600x900 in resolution). If necessary, we may provide an attribute for it, so users can change the ppi of generated pngs on demand.

gjtorikian commented 9 years ago

You can absolutely provide the ppi as an option: https://github.com/gjtorikian/mathematical#options

This looks like a Mathematical issue.

But it's not. I've run into this before, but newer versions of Cairo are messed up on OS X: http://lists.cairographics.org/archives/cairo/2015-May/026257.html

It took me a long time to figure out the right incantation, but

brew install https://raw.githubusercontent.com/Homebrew/homebrew/26d5775494b3535820c48442c23af44f72974880/Library/Formula/cairo.rb
brew install https://raw.githubusercontent.com/Homebrew/homebrew/e8a4de3960191c5726084416a3b78c5fcd5a3b05/Library/Formula/pango.rb

should work. Obviously you'll want to remove/unlink the previous versions.

Let me know how that goes for rendering and I'll update the gem.

paulvickers commented 9 years ago

Okay. I uninstalled cairo and pango. Then:

brew install https://raw.githubusercontent.com/Homebrew/homebrew/26d5775494b3535820c48442c23af44f72974880/Library/Formula/cairo.rb

OK. Cairo now at version 1.12.16_1

brew install https://raw.githubusercontent.com/Homebrew/homebrew/e8a4de3960191c5726084416a3b78c5fcd5a3b05/Library/Formula/pango.rb

Fails with:

make[3]: *** [viewer-cairo.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

READ THIS: https://git.io/brew-troubleshooting

These open issues may also help:
pango-1.36.8 failed to build on 10.10.3 https://github.com/Homebrew/homebrew/issues/44260
pango-1.36.8 failed to build on 10.10.3 (14D136) https://github.com/Homebrew/homebrew/issues/40853

Running brew gist-logs pango gives https://gist.github.com/5a0e4908184e39f91539

A regular brew install pango works, but that forces an upgrade of Cairo to 1.14.

ps, my version of OS X is 10.10.5. It's a new machine with a clean homebrew installation yesterday. No Macports installed.

So, I did:

 brew rm gobject-introspection

And then retried

brew install https://raw.githubusercontent.com/Homebrew/homebrew/e8a4de3960191c5726084416a3b78c5fcd5a3b05/Library/Formula/pango.rb

Same error. Running brew gist-logs pango gives https://gist.github.com/bb78b8733a93e0f15f2a

pps, I've just noticed that installing Pango with the above command still forces a download of Cairo 1.14:

/Library/Formula/pango.rb
######################################################################## 100.0%
==> Installing dependencies for pango: cairo
==> Installing pango dependency: cairo
==> Downloading https://homebrew.bintray.com/bottles/cairo-1.14.2_1.yosemite.bottle.3.tar.gz
######################################################################## 100.0%
==> Pouring cairo-1.14.2_1.yosemite.bottle.3.tar.gz
🍺  /usr/local/Cellar/cairo/1.14.2_1: 111 files, 6.1M
==> Installing pango
==> Downloading http://ftp.gnome.org/pub/GNOME/sources/pango/1.36/pango-1.36.5.tar.xz
Already downloaded: /Library/Caches/Homebrew/pango-1.36.5.tar.xz
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/pango/1.36.5 --enable-man --with-html-dir=/usr/local/Cellar/pango/
==> make
make[3]: *** [viewer-cairo.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

So, I tried brew switch cairo 1.12.16_1 which yielded:

Cleaning /usr/local/Cellar/cairo/1.12.16_1
Cleaning /usr/local/Cellar/cairo/1.14.2_1
28 links created for /usr/local/Cellar/cairo/1.12.16_1

I then tried a reinstallation of Pango:

C15003588:opt paulvickers$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/e8a4de3960191c5726084416a3b78c5fcd5a3b05/Library/Formula/pango.rb
######################################################################## 100.0%
==> Downloading http://ftp.gnome.org/pub/GNOME/sources/pango/1.36/pango-1.36.5.tar.xz
Already downloaded: /Library/Caches/Homebrew/pango-1.36.5.tar.xz
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/pango/1.36.5 --enable-man --with-html-dir=/usr/local/Cellar/pango/
==> make
==> make install
🍺  /usr/local/Cellar/pango/1.36.5: 132 files, 4.7M, built in 30 seconds

A reinstall of asciidoctor-mathematical installs mathematical v 1.5.8 and asciidoctor-mathematical 0.0.5.

So, I now have the following setup:

brew info pango
pango: stable 1.38.0 (bottled), HEAD
Framework for layout and rendering of i18n text
http://www.pango.org/
/usr/local/Cellar/pango/1.36.5 (132 files, 4.7M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/pango.rb Cairo 1.12.16_1 and Pango 1.1

brew info cairo
cairo: stable 1.14.2 (bottled)
Vector graphics library with cross-device output support
http://cairographics.org/
/usr/local/Cellar/cairo/1.12.16_1 (105 files, 7.4M) *
  Built from source
/usr/local/Cellar/cairo/1.14.2_1 (111 files, 6.1M)
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/cairo.rb

*** LOCAL GEMS ***

addressable (2.3.8)
afm (0.2.2)
Ascii85 (1.0.2)
asciidoctor (1.5.2)
asciidoctor-mathematical (0.0.5)
asciidoctor-pdf (1.5.0.alpha.9)
bigdecimal (1.2.6)
coderay (1.1.0)
css_parser (1.3.6)
hashery (2.1.1)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.1)
mathematical (1.5.8)
minitest (5.4.3)
pdf-core (0.6.0)
pdf-reader (1.3.3)
polyglot (0.3.5)
posix-spawn (0.3.11)
power_assert (0.2.2)
prawn (2.0.2)
prawn-icon (0.6.4)
prawn-svg (0.21.0)
prawn-table (0.2.2)
prawn-templates (0.0.3)
psych (2.0.8)
pygments.rb (0.6.3)
rake (10.4.2)
rdoc (4.2.0)
rouge (1.10.1)
ruby-enum (0.4.0)
ruby-rc4 (0.1.5)
safe_yaml (1.0.4)
test-unit (3.0.8)
thread_safe (0.3.5)
treetop (1.5.3)
ttfunk (1.4.0)
yajl-ruby (1.2.1)

Ready to try again I executed the following command:

 asciidoctor-pdf -r asciidoctor-mathematical -o math.pdf math.ad

And got the following error:

Failed to read PNG contentsFailed to read PNG contentsFailed to read PNG contentsasciidoctor: WARNING: could not embed image: /Users/paulvickers/Desktop/images/stem-d881ea909920c838a98ff43c5f1ffb41.png; image file is an unrecognised format
asciidoctor: WARNING: could not embed image: /Users/paulvickers/Desktop/images/stem-7ad57f57f7601fadff003f5376571237.png; image file is an unrecognised format
 image file is an unrecognised format
 Use --trace for backtrace

This looks to be back to the original problem...

paulvickers commented 9 years ago

And to make matters worse, even uninstalling all the brew packages and trying a fresh install with

brew install glib gdk-pixbuf cairo pango cmake

Still results in the unrecognised graphics error. Why did it work yesterday but not today? I have even tried removing homebrew and reinstalling it but get the same graphics error. Sigh.

I removed all the directories in usr/local that homebrew had created. I reinstalled brew, and then everything else same as yesterday but now the graphics file format error persists. I am utterly confused! :-)

gjtorikian commented 9 years ago

I appreciate the logs; I'm not sure how much I can help without actually being there. :sweat_smile:

You could try brew unlink --forceing all the packages you just mentioned. If pango tried to download the newer cairo, it would imply that the older cairo version was not linked correctly.

I'm really sorry for all of this, BTW. If you follow the messages on the mailing list I linked to above, this Cairo problem on Yosemite is a known issue. The latest version of Cairo is reported to fix the problem, but it's not released yet.

paulvickers commented 9 years ago

@gjtorikian Yes, I have seen the thread about Cairo 1.14. What I don't understand is why uninstalling everything and then reinstalling all the new versions still doesn't work. Before I tried downgrading Cairo it did at least produce PNG output. Before I went home yesterday I rolled back my /usr/ folder to how it was at the end of last week before I installed homebrew, etc. I am going to try a fresh install on that and see what happens.

paulvickers commented 9 years ago

No joy. Still:

asciidoctor-pdf -r asciidoctor-mathematical -o math2.pdf math2.ad
Failed to read PNG contentsimage file is an unrecognised format
  Use --trace for backtrace

Contents of math2.ad

:math:
:imagesoutdir: images

latexmath:[a^2+b^2=c^2]
paulvickers commented 9 years ago

Tried on a different Yosemite based Mac. Same problem as above.

@gjtorikian In order to try and troubleshoot where this is going wrong, can you give an idea of what your environment is? For example, I notice on my system in /opt there is an X11 folder. In /opt/X11/include there is a directory called cairo which has lots of header files. Is there any chance this might be conflicting with the homebrew cairo? Where is your x11 installed?

Are there any other folders I should be looking into to see what might be causing conflicts with mathematical? I just cannot get asciidoctor-mathematical to render.

Even with Cairo 1.12.15_2 and Pango 1.36.5 installed and linked I am getting the error above the creates an invalid PNG file or an SVG with the text in all the wrong place.

gjtorikian commented 9 years ago

Yes, I too have some Cairo headers located in /opt/X11/include. After brew uninstall cairo, those headers are still there.

Can you tell me what your brew --env and brew --config results are? Here's mine:

~/Desktop brew --env
HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j8
CMAKE_PREFIX_PATH: /usr/local
CMAKE_INCLUDE_PATH: /usr/include/libxml2:/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Library/ENV/pkgconfig/10.10
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/Library/ENV/4.3:/usr/bin:/bin:/usr/sbin:/sbin

~/Desktop brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: 67bdf914fdb36a04717700d61cc0066b823b1631
Last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit haswell
OS X: 10.10.5-x86_64
Xcode: 7.0
CLT: 7.0.0.0.1.1441394355
couldn't understand kern.osversion `14.5.0'
GCC-4.2: build 5666
Clang: 7.0 build 700
X11: 2.7.8_rc1 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.8-boxen1/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /opt/boxen/rbenv/shims/ruby => /opt/rubies/2.1.6-github1/bin/ruby
Java: 1.8.0_25, 1.7.0_71, 1.7.0_67, 1.7.0_60, 1.7.0_55, 1.7.0_51, 1.7.0_13, 1.6.0_32-b05-420
paulvickers commented 9 years ago

brew --env gives:

~  $ brew --env
HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j8
CMAKE_PREFIX_PATH: /usr/local
CMAKE_INCLUDE_PATH: /usr/include/libxml2:/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Library/ENV/pkgconfig/10.10
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/Library/ENV/4.3:/usr/bin:/bin:/usr/sbin:/sbin

brew --config gives:

~  $ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: a21fcf022412ba9572180a89ce1ca7088f3bdac9
Last commit: 6 days ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit ivybridge
OS X: 10.10.5-x86_64
Xcode: 7.0.1
CLT: 7.0.0.0.1.1441394355
Clang: 7.0 build 700
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.2.3/bin/ruby
Java: 1.8.0_60, 1.6.0_65-b14-468
gjtorikian commented 8 years ago

Looks like there are a lot of new packages for cairo and such. Could you try a brew upgrade to get the new packages, and then reporting back if the rendering is still a problem?

paulvickers commented 8 years ago

Thanks for the update. :-) I've just reinstalled everything and forced brew to use the 1.15.2_1 devel version of Cairo. Running asciidoctor-mathematical on the sample.adoc file now works again inasmuch as it produces a pdf with some math in it. Woot woot!

Unfortunately, the math still seems to be misframed and pixellated as per the attached. test.pdf I notice the images directory has .png files in which would explain the pixellation I guess.

When I use svg instead: asciidoctor-pdf -r asciidoctor-mathematical -a mathematical-format=svg -o testsvg.pdf sample.adoc I get a much nicer result: testsvg.pdf

Note, though that while some of the variables are rendered very smoothly, others are more jagged. For example, in the quadratic formula notice how the b2 has a jagged b while the 4ac is very smooth.

I am very pleased that this is now (a) working and (b) almost perfect. Any ideas on why the svg output should be inconsistent in the smoothness of its curves?

gjtorikian commented 8 years ago

Indeed, I almost never use the PNG rendering option—I think it's meant as a fallback for SVG but the output is too unpleasent to use.

I have to admit, though, I don't see the smoothness issues in the SVG output that you're referring to. My vision isn't the greatest by any means, though. Could you elaborate? It might be a font issue, though I assume you've already got the required fonts, since I think nothing would render.

Either way I'm closing this issue out as the original issues with dependencies is resolved. 🎉

paulvickers commented 8 years ago

Attached is a screen grab of a zoomed portion showing the quadratic equation. svgSample.pdf Can you see the difference in smoothness between some of the letters in this?

On a related note, I tried opening the pdf generated by asciidoctor-mathematical in an Adobe PDF reader on both OS X and Windows and each time Acrobat reported an error with the file and only showed the first page and the first equation on the second page. I opened the quadratic .svg file in Illustrator and it appears all garbled.

akosma commented 6 years ago

This fails again in a clean install of macOS Mojave 10.14. The brew link gettext --force trick does not work.