We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Hm. Doesn’t have much in the way of instructions, does it? Wrote it a long time ago.

    First, the font you want to use has to be in the assets/files/fonts folder.

    [[Text2PNG?font=`fontname.ttf`&option=`value`]]


    There is a list of options in the comments at the top of the snippet.

    If you want, you can change the imagepng() function call near the end to imagegif(), depending on your version of GD (I think, I haven’t actually tried it). If you do, make sure to change the type="image/png" to type="image/gif" in the next-to-the-last line.

    http://il.php.net/imagegif
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 28346
      • 30 Posts
      I’ve been trying to implement Susan’s Text2PNG all morning and I’m getting the exact same error as Josh. Haven’t tried gtext, but I suspect I’ll just get the same error. Any idea what might cause it?
      -Rob

      Quote from: joshlfisher at Jul 11, 2006, 05:06 PM

      I am trying to implement Gtext in my template Like This:

      <div id="header">

      <h1><a href="[~[(site_start)]~]" title="[(site_name)]"><img alt="[(site_name)]" src="[[gtext? &font=`rage.ttf` &fontsize=`18` &color=`#ffffff` &bgcolor=`#000000` &text=`[(site_name)]`]]" /></a></h1>
      </div>
      <!-- close #header -->

      I have uploaded the font to /assets/files/fonts.

      I am getting this error:


      « MODx Parse Error »
      MODx encountered the following error while attempting to parse the requested resource:
      « PHP Parse Error »

      PHP error debug
      Error: imagettfbbox(): Could not find/open font
      Error type/ Nr.: Warning - 2
      File: /homepages/7/d165971201/htdocs/manager/includes/document.parser.class.inc.php(705) : eval()’d code
      Line: 208

      Parser timing
      MySQL: 0.0066 s s (3 Requests)
      PHP: 0.0699 s s
      Total: 0.0764 s s

      How can I fix This?
        • 22815
        • 1,097 Posts
        Right. Really any discussion of Text2PNG should be in a different thread, but as it is the same error:

        imagettfbbox(): Could not find/open font
        I will let you guys off.

        StainlessSteelRat, where have you put the font file? Does it have any spaces in it?
          No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
          MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
          Forum: Where to post threads about add-ons | Forum Rules
          Like MODx? donate (and/or share your resources)
          Like me? See my Amazon wishlist
          MODx "Most Promising CMS" - so appropriate!
          • 28346
          • 30 Posts
          Yes, thanks... I *was* going to put it in the Text2PNG thread, but thought it might be easier to address here since the error is identical to Josh’s using gtext. It might make sense to move it there though... your call. (that’s why they pay you the big Mod bucks, eh? wink )

          The ttf filename has no spaces... it’s htower.ttf and I put it in the assets/files/fonts.
          I called it with: [[Text2PNG? &font=’htower.ttf’ &text=’Testing...’]]

          More info that may or may not be relevant, straight from phpinfo:
          PHP ver = 5.1.2
          GD Version = bundled (2.0.28 compatible)
          FreeType Version = 2.1.7
            • 7923
            • 4,213 Posts
            Quote from: StainlessSteelRat at Jul 12, 2006, 10:27 AM

            I called it with: [[Text2PNG? &font=’htower.ttf’ &text=’Testing...’]]
            Use backticks in the snippet parameters, so it would be [[Text2PNG? &font=`htower.ttf` &text=`Testing...`]]


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 28346
              • 30 Posts
              embarrassed duh. Now THAT was embarrassing....

              Thanks for the help.
                • 14779
                • 256 Posts
                I am using backticks in my example, but I still have the error.
                  PM me to find out how you can get a FREE ipad 2!
                  • 7923
                  • 4,213 Posts
                  Quote from: joshlfisher at Jul 12, 2006, 12:43 PM

                  I am using backticks in my example, but I still have the error.
                  I tried this snippet my self too in local test enviroment and got same results. Did some searching around and it seems that there is/was some bugs in php imagettfbbox() function. First, it wants the full path to the font (what this snippet is giving, so that’s ok) but it doesn’t allow any spaces to be in the path to the font file. As my docroot was under "C:\Documents and settings\.." it didn’t work for me. Then I tried it with my linux box that has no spaces in docroot and it worked ok.

                  If this is the issue with you too, I’m afraid there’s not much that can be done to fix it as we can’t use relative paths..


                    "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                    • 14779
                    • 256 Posts
                    Hmm...
                    It seems that the font path is case-sensitive also.
                    My font path is /assets/files/fonts/RAGE.TTF
                    I changed it to: /assets/files/fonts/rage.ttf

                    Works!

                      PM me to find out how you can get a FREE ipad 2!
                      • 7923
                      • 4,213 Posts
                      Great!Quote from: joshlfisher at Jul 12, 2006, 03:23 PM

                      It seems that the font path is case-sensitive also.
                      Oh yeah, usually anything relating to paths and filenames are case sensitive, great that you got it working!


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."