Menu

Text not appearing under mac when using default font

Anonymous
2014-05-26
2014-06-04
  • Anonymous

    Anonymous - 2014-05-26

    Hi,

    When I run the following code, only the line "asdfrandom font" appears in the png output.

    I compiled & installed mathgl 2.2.2.1 into a mac running OS X 10.9.3 Mavericks.

    We have a workaround in the code (i.e., loading a non-existent font when compiled for a mac), but we prefer to use the default font.

    Could you please advise the correct solution? Thanks.

    #include <iostream>
    #include <cstdlib>
    
    #include <mgl2/canvas_wnd.h>
    
    using namespace std;
    
    void smgl_fonts(mglGraph *gr)   // font typefaces
    {
        double h=1.1, d=0.25;
        gr->LoadFont("STIX");           gr->Puts(mglPoint(0,h), "default font (STIX)");
        gr->LoadFont("asdfrandom");       gr->Puts(mglPoint(0,h-d), "asdfrandom font");
    }
    
    int main()
    {
        unsigned int w=1024,h=768;
        mglGraph *grS;
        grS = new mglGraph(0,w,h);
        smgl_fonts(grS);
        grS->WritePNG("result.png");
    
        delete grS;
        return 0;
    }
    
     
  • Alexey Balakin

    Alexey Balakin - 2014-05-27

    Hmm, both lines appears. However, the second line (i.e. "asdfrandom font") still use STIX font (default one) because I have no "asdfrandom" font.

    For example, following function will produce the output in the attachment. This is the same function as yours with added line to test other font loading (i.e. "bonum" font which can be downloaded from MathGL).

    void smgl_fonts(mglGraph *gr)   // font typefaces
    {
      double h=1.1, d=0.25;
      gr->LoadFont("STIX");       gr->Puts(mglPoint(0,h), "default font (STIX)");
      gr->LoadFont("asdfrandom"); gr->Puts(mglPoint(0,h-d), "asdfrandom font");
      gr->LoadFont("bonum");      gr->Puts(mglPoint(0,h-2*d), "bonum font");
    }
    
     
  • Anonymous

    Anonymous - 2014-06-04

    Hi,

    This is the result.png that I get from my original code (notice it only has 1 line of text, not 2)

     

Anonymous
Anonymous

Add attachments
Cancel