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

Files: 
CommentFileSizeAuthor
#2 fontyourface-local_fonts_metadata-1796736-2.patch4.18 KBmondrake
PASSED: [[SimpleTest]]: [MySQL] 9 pass(es).
[ View ]

Comments

sreynen’s picture

I 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.

mondrake’s picture

Status:Active» Needs review
StatusFileSize
new4.18 KB
PASSED: [[SimpleTest]]: [MySQL] 9 pass(es).
[ View ]

Hi, 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

Drave Robber’s picture

Status:Needs review» Reviewed & tested by the community

Looks good to me.

sreynen’s picture

Status:Reviewed & tested by the community» Fixed

Committed. Thanks everyone!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.