How might I portably determine the TrueType Font filespecs for 'Generic' font specifications like 'sans-serif'?by ozboomer (Pilgrim)
|on Feb 14, 2017 at 00:38 UTC||Need Help??|
ozboomer has asked for the
wisdom of the Perl Monks concerning the following question:
I have a Perl program that runs under both Windows (ActiveState v5.16.3 32-bit) and Linux (Puppy Linux v5.6.4 Slacko ... but others as well) which calls the video manipulation program 'ffmpeg' to modify the content of a video file. The current issue revolves around the adding of some text to the video image.
'ffmpeg' is called via `` (backticks) and system()... and in both cases, the executed command is something like:-
Note that this command is fairly generic and includes some "filter clauses" that are required for .flv files, .mp4 files, etc.
With the command as it stands, the font file "arial.ttf" must reside in the current directory... but I can fix that problem by using some perl code like:-
...and then use '$font_file' in the 'ffmpeg' command string.
The real problem comes from the situation where the TTF files don't exist. The files I've selected are fairly common... but is there a simple, robust, *portable* way to select some 'sans serif' -style fonts (font files) in Perl?
Some of what is done in HTML markup comes to mind... where a font is often declared in HTML or CSS files as 'sans serif' and the user's browser is set-up to translate 'sans serif' into a specified *actual* font. Is something like that available in a Perl module? ... or can I call the O/S (system32.dll or Linux equivalent)? I'm looking for the simplest solution here... and modules like Font::TTF are as clear as mud to me :(
I'd appreciate any thoughts on how to deal with this...
Edit: Note the spec for $font_file under MSWin32 as shown will not work. Still trying to find a spec that will...(!)
Edit: The pathing under Windows is horrendous... the 'normal' Perl internal magic that allows us to use '/' under Windows causes grief for 'ffmpeg'... and the 'ffmpeg' filtering items use '\' and ':' in a special way. *Ugh!* Note that the MSWin32 filespec shown *now* DOES work - it's just ugly.