Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I need to have access to the url of .ttf files stored locally (I use the uploaded fonts for GD manipulations), and was wondering whether there could be a chance to have the URLs returned in the metadata property of the font object returned by fontyourface_get_fonts().
Currently I am doing the following workaround (for 'local_fonts')
... get a font object via fontyourface_get_fonts() ...
$metadata = unserialize($font->metadata);
$dirname = drupal_dirname($metadata['path']);
if ($handle = opendir($dirname)) {
while ($file = readdir($handle)) {
if (preg_match("/\.ttf/i", $file) == 1) {
return $dirname . '/' . $file;
break;
}
}
closedir($handle);
}
return NULL;
but this requires scanning the entire directory of the font each time.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#2 | fontyourface-local_fonts_metadata-1796736-2.patch | 4.18 KB | mondrake |
Comments
Comment #1
sreynen CreditAttribution: sreynen commentedI don't see any problem with putting the paths in the metadata on upload. If you want to write a patch for that, I'll review and commit it.
Comment #2
mondrakeHi, here's a patch. It adds to metadata, at upload time, an array with a key for each font file uri.
I also implemented in .install a hook_update_7200() to retrofit metadata at release update.
Thanks
Comment #3
Drave Robber CreditAttribution: Drave Robber commentedLooks good to me.
Comment #4
sreynen CreditAttribution: sreynen commentedCommitted. Thanks everyone!