Bug 50733 - Add font-file hash?
Summary: Add font-file hash?
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.7
Hardware: Other All
: medium normal
Assignee: Akira TAGOH
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-05 07:53 UTC by Behdad Esfahbod
Modified: 2013-02-05 06:36 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Behdad Esfahbod 2012-06-05 07:53:31 UTC
Would be useful I guess to add a sha256 or similar hash of the font file to the pattern.  Applications can use it as some kind of a "unique id" across processes for caching and other purposes.  I personally would happily consider two fonts with the same sha256 hash to be the same file...  Also, may not need to specify what hashing algorithm is used, just that it's "strong".  Then we can upgrade to sha384, sha512, ... over time as we see fit.
Comment 1 Alan Coopersmith 2012-06-05 08:36:44 UTC
Right, the important part is that which hashing algorithm is used can be
changed over time, which may mean including the algorithm name in the
data with the hash value.
Comment 2 Akira TAGOH 2013-02-04 07:08:41 UTC
proposed implementation for this feature:
  http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz50733

In this proposal, I just added the hash value as string. wondering if I should add it as the array of Integer or kind of FcHash?
Comment 3 Akira TAGOH 2013-02-04 07:22:01 UTC
sample output...

$ ./fc-query/fc-query /usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf | grep hash
        hash: "26f470356f6130e802bafea3b23805cf59b83cb60c566bb982792c6ad3d73306"(s)

$ sha256sum /usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf
26f470356f6130e802bafea3b23805cf59b83cb60c566bb982792c6ad3d73306  /usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf
Comment 4 Behdad Esfahbod 2013-02-04 18:59:22 UTC
String is adequate.  Perhaps prepend the string with "sha256:"?
Comment 5 Behdad Esfahbod 2013-02-04 19:01:09 UTC
I think you can also get rid of some of the internal API.  Just have a function that returns a string that has the hash type and the hash itself.  No need for differentiating the type in the library really.
Comment 6 Akira TAGOH 2013-02-05 03:54:24 UTC
Thanks for the comment. cleaned up and improved.
Comment 7 Akira TAGOH 2013-02-05 05:05:21 UTC
looks like this:

$ ./fc-query/fc-query /usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf | grep hash                                                                   hash: "sha256:26f470356f6130e802bafea3b23805cf59b83cb60c566bb982792c6ad3d73306"(s)
Comment 8 Behdad Esfahbod 2013-02-05 05:17:49 UTC
Looks good to me.  Lets get in.
Comment 9 Akira TAGOH 2013-02-05 06:36:04 UTC
Thanks for the review. merged into master.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.