Revert the previous change and rework to not export freetype API outside fcfreetype.c
This commit is contained in:
parent
c93a8b8b54
commit
fc5a589aba
|
@ -1104,7 +1104,10 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
char psname[256];
|
char psname[256];
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
FcChar8 *hashstr;
|
FcChar8 *hashstr = NULL;
|
||||||
|
char *fontdata = NULL;
|
||||||
|
FT_Error err;
|
||||||
|
FT_ULong len = 0, alen;
|
||||||
|
|
||||||
pat = FcPatternCreate ();
|
pat = FcPatternCreate ();
|
||||||
if (!pat)
|
if (!pat)
|
||||||
|
@ -1662,12 +1665,22 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
if (!FcPatternAddBool (pat, FC_DECORATIVE, decorative))
|
if (!FcPatternAddBool (pat, FC_DECORATIVE, decorative))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
|
||||||
hashstr = FcHashGetSHA256DigestFromFace (face);
|
err = FT_Load_Sfnt_Table (face, 0, 0, NULL, &len);
|
||||||
|
if (err != FT_Err_Ok)
|
||||||
|
goto bail1;
|
||||||
|
alen = (len + 63) & ~63;
|
||||||
|
fontdata = malloc (alen);
|
||||||
|
if (!fontdata)
|
||||||
|
goto bail1;
|
||||||
|
err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)fontdata, &len);
|
||||||
|
if (err != FT_Err_Ok)
|
||||||
|
goto bail1;
|
||||||
|
memset (&fontdata[len], 0, alen - len);
|
||||||
|
hashstr = FcHashGetSHA256DigestFromMemory (fontdata, len);
|
||||||
if (!hashstr)
|
if (!hashstr)
|
||||||
goto bail1;
|
goto bail1;
|
||||||
if (!FcPatternAddString (pat, FC_HASH, hashstr))
|
if (!FcPatternAddString (pat, FC_HASH, hashstr))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
free (hashstr);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the unicode coverage for the font
|
* Compute the unicode coverage for the font
|
||||||
|
@ -1756,6 +1769,10 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
bail2:
|
bail2:
|
||||||
FcCharSetDestroy (cs);
|
FcCharSetDestroy (cs);
|
||||||
bail1:
|
bail1:
|
||||||
|
if (hashstr)
|
||||||
|
free (hashstr);
|
||||||
|
if (fontdata)
|
||||||
|
free (fontdata);
|
||||||
FcPatternDestroy (pat);
|
FcPatternDestroy (pat);
|
||||||
bail0:
|
bail0:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
47
src/fchash.c
47
src/fchash.c
|
@ -29,9 +29,6 @@
|
||||||
#include "fcint.h"
|
#include "fcint.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_TRUETYPE_TABLES_H
|
|
||||||
#include FT_TRUETYPE_TAGS_H
|
|
||||||
|
|
||||||
#define ROTRN(w, v, n) ((((FcChar32)v) >> n) | (((FcChar32)v) << (w - n)))
|
#define ROTRN(w, v, n) ((((FcChar32)v) >> n) | (((FcChar32)v) << (w - n)))
|
||||||
#define ROTR32(v, n) ROTRN(32, v, n)
|
#define ROTR32(v, n) ROTRN(32, v, n)
|
||||||
|
@ -207,40 +204,28 @@ FcHashGetSHA256Digest (const FcChar8 *input_strings,
|
||||||
}
|
}
|
||||||
|
|
||||||
FcChar8 *
|
FcChar8 *
|
||||||
FcHashGetSHA256DigestFromFace (const FT_Face face)
|
FcHashGetSHA256DigestFromMemory (const char *fontdata,
|
||||||
|
size_t length)
|
||||||
{
|
{
|
||||||
char ibuf[64], *buf = NULL;
|
char ibuf[64];
|
||||||
FcChar32 *ret;
|
FcChar32 *ret;
|
||||||
FT_Error err;
|
size_t i = 0;
|
||||||
FT_ULong len = 0, alen, i = 0;
|
|
||||||
|
|
||||||
err = FT_Load_Sfnt_Table (face, 0, 0, NULL, &len);
|
|
||||||
if (err != FT_Err_Ok)
|
|
||||||
return NULL;
|
|
||||||
alen = (len + 63) & ~63;
|
|
||||||
buf = malloc (alen);
|
|
||||||
if (!buf)
|
|
||||||
return NULL;
|
|
||||||
err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)buf, &len);
|
|
||||||
if (err != FT_Err_Ok)
|
|
||||||
goto bail0;
|
|
||||||
memset (&buf[len], 0, alen - len);
|
|
||||||
|
|
||||||
ret = FcHashInitSHA256Digest ();
|
ret = FcHashInitSHA256Digest ();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto bail0;
|
return NULL;
|
||||||
|
|
||||||
while (i <= len)
|
while (i <= length)
|
||||||
{
|
{
|
||||||
if ((len - i) < 64)
|
if ((length - i) < 64)
|
||||||
{
|
{
|
||||||
long v;
|
long v;
|
||||||
int n;
|
size_t n;
|
||||||
|
|
||||||
/* add a padding */
|
/* add a padding */
|
||||||
n = len - i;
|
n = length - i;
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
memcpy (ibuf, &buf[i], n);
|
memcpy (ibuf, &fontdata[i], n);
|
||||||
memset (&ibuf[n], 0, 64 - n);
|
memset (&ibuf[n], 0, 64 - n);
|
||||||
ibuf[n] = 0x80;
|
ibuf[n] = 0x80;
|
||||||
if ((64 - n) < 9)
|
if ((64 - n) < 9)
|
||||||
|
@ -250,7 +235,7 @@ FcHashGetSHA256DigestFromFace (const FT_Face face)
|
||||||
memset (ibuf, 0, 64);
|
memset (ibuf, 0, 64);
|
||||||
}
|
}
|
||||||
/* set input size at the end */
|
/* set input size at the end */
|
||||||
v = len * 8;
|
v = length * 8;
|
||||||
ibuf[63 - 0] = v & 0xff;
|
ibuf[63 - 0] = v & 0xff;
|
||||||
ibuf[63 - 1] = (v >> 8) & 0xff;
|
ibuf[63 - 1] = (v >> 8) & 0xff;
|
||||||
ibuf[63 - 2] = (v >> 16) & 0xff;
|
ibuf[63 - 2] = (v >> 16) & 0xff;
|
||||||
|
@ -264,18 +249,10 @@ FcHashGetSHA256DigestFromFace (const FT_Face face)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FcHashComputeSHA256Digest (ret, &buf[i]);
|
FcHashComputeSHA256Digest (ret, &fontdata[i]);
|
||||||
}
|
}
|
||||||
i += 64;
|
i += 64;
|
||||||
}
|
}
|
||||||
if (buf)
|
|
||||||
free (buf);
|
|
||||||
|
|
||||||
return FcHashSHA256ToString (ret);
|
return FcHashSHA256ToString (ret);
|
||||||
|
|
||||||
bail0:
|
|
||||||
if (buf)
|
|
||||||
free (buf);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@
|
||||||
#include "fcdeprecate.h"
|
#include "fcdeprecate.h"
|
||||||
#include "fcmutex.h"
|
#include "fcmutex.h"
|
||||||
#include "fcatomic.h"
|
#include "fcatomic.h"
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
|
|
||||||
#ifndef FC_CONFIG_PATH
|
#ifndef FC_CONFIG_PATH
|
||||||
#define FC_CONFIG_PATH "fonts.conf"
|
#define FC_CONFIG_PATH "fonts.conf"
|
||||||
|
@ -821,7 +819,8 @@ FcPrivate FcChar8 *
|
||||||
FcHashGetSHA256Digest (const FcChar8 *input_strings,
|
FcHashGetSHA256Digest (const FcChar8 *input_strings,
|
||||||
size_t len);
|
size_t len);
|
||||||
FcPrivate FcChar8 *
|
FcPrivate FcChar8 *
|
||||||
FcHashGetSHA256DigestFromFace (const FT_Face face);
|
FcHashGetSHA256DigestFromMemory (const char *fontdata,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
/* fcinit.c */
|
/* fcinit.c */
|
||||||
FcPrivate FcConfig *
|
FcPrivate FcConfig *
|
||||||
|
|
Loading…
Reference in New Issue