[pmwiki-users] script to make images and extract information out of True Type Fonts (TTF)

Patrick R. Michaud pmichaud at pobox.com
Sun Dec 4 11:59:50 CST 2005


On Sat, Dec 03, 2005 at 07:56:29PM -0200, Carlos AB wrote:
> This is my first post and I have some questions on how to program for
> PmWiki. I made a script that make an image out of TTF fonts uploaded to
> pmwiki, based on the pagename, and another one that reads the information
> stored inside those fonts, also based on pagename.
>  
> What I want to do but can't (yet):
>  
> * A markup that could deliver an intact html line without replace/change
> anything. ie: "&" changed into "&" . I have tried some things like the
> helper functions PZZ(), Keep() and some others, but no success so far. Here
> is the markup:
>  
> Markup("ttfimg", "directive", '/\\(:ttfimg:\\)/e', "Keep(ttfUrl())");

Keep() does what you want: it protects the string -- in this case
the return value of ttfUrl() -- from any further processing by PmWiki.  
But if getting values from the markup text, remember that PmWiki
htmlencodes all '&', '<', and '>' before the markup rules are ever
called.

> *Change the output of/or append text to "$EditText" inside an "EditForm" for
> a especific group, just like when you edit new pages on
> http://www.pmwiki.org/wiki/Cookbook/NewpageAsExample?action=edit , so I
> don't have to type in the markups everytime I upload new TTF fonts.

You probably want $ROSPatterns ("Replace On Save Patterns") -- these
are transformations to be made to the $EditText just before it is saved.

> *Change the header and the output of PmWiki to deliver the images made by
> the first script (ttf image), the get line would be:
> http://localhost/index.php?n=Fonts.PEPSI&action=ttfimg&format=.png .The last
> pair "format=.png" is used so you can display the image from a PmWiki page,
> as explained in http://www.pmwiki.org/wiki/PmWiki/Images , at the end of the
> page on section "Notes" .

To get this to work you'll want to define a new ?action that
processes the parameters.  However, it seems to me that if it's
just generating an image from the pagename, it'd be a lot more
efficient to create a separate script to do it instead of hooking  
into PmWiki's ?action= handler.  For example, you could write a
standalone ttfimg.php script that does:

    http://localhost/ttfimg.php?s=Fonts.PEPSI&format=.png

where the s= parameter can be any string to be formatted, not just the 
pagename.  Then the ttf markup can just convert

    (:ttf Some string:)

into <img src='http://localhost/ttfimg.php?s=Some%20string&format=.png' /> .

Anyway, the code to hook into ?action= is

    $HandleActions['ttfimg'] = 'MyTTFImgFunction';
    $HandleAuth['ttfimg'] = 'read';

    function MyTTFImgFunction($pagename, $auth = 'read') {
      # your custom handler here
    }

Pm




More information about the pmwiki-users mailing list