I'm in the midst of finishing up a Perl/Tk module which
mingles a bit of GD to render things pTk Canvas can't.
I need to render some text via GD::Text, but GD::Text
needs a TTF font file path, rather than the family/weight/etc.
that Perl/Tk uses, so I need to go fishing in the registry
to extract the info. I'm wondering if there's already
a CPAN module out there that does this ? I haven't found
anything, and if there's nothing out there yet, I thought
I'd whip up a little module that
1. Takes font family, weight, etc., (as from a pTk font object)
2. Forms a Win32 font name (e.g., capitalize the fontname
pieces, append Bold and/or Italic if the weight/slant
indicate it)
3. Use that result as a key to lookup and return the font file
via Win32::TieRegistry
Obviously its not too complicated, but it seems like something
that might be generally useful.
If anyone knows of a module that already does this, please advise.
Otherwise, if anyone can suggest a namespace for this, that'd be
great as well. I'm thinking it should be under Win32, not Tk or GD;
maybe Win32::Font::NameToFile ?
Update:
Done. Uploaded to CPAN as Win32-Font-NameToFile-0.10.tar.gz.
Also available here.
I ran some quick tests with the demo app from GD::Text and it behaves as desired (at least for my configuration). Given the vagueries of Win32 fonts, YMMV.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.