Remove fc-glyphname

This commit is contained in:
Behdad Esfahbod 2017-08-04 16:17:17 +01:00
parent c7ef8808c4
commit 3bd4dd27bd
7 changed files with 1 additions and 600 deletions

View File

@ -21,7 +21,7 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
SUBDIRS=fontconfig fc-blanks fc-case fc-lang fc-glyphname src \
SUBDIRS=fontconfig fc-blanks fc-case fc-lang src \
fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \
fc-validate conf.d test
if ENABLE_DOCS

View File

@ -760,7 +760,6 @@ AC_CONFIG_FILES([
Makefile
fontconfig/Makefile
fc-lang/Makefile
fc-glyphname/Makefile
fc-blanks/Makefile
fc-case/Makefile
src/Makefile

View File

@ -1,33 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2003 Keith Packard
# Copyright © 2013 Google, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of the author(s) not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. The authors make no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# Google Author(s): Behdad Esfahbod
TAG = glyphname
DEPS = $(srcdir)/zapfdingbats.txt
ARGS = $(srcdir)/zapfdingbats.txt
DIST = $(srcdir)/zapfdingbats.txt
include $(top_srcdir)/Tools.mk
-include $(top_srcdir)/git.mk

View File

@ -1,325 +0,0 @@
/*
* fontconfig/fc-glyphname/fc-glyphname.c
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the author(s) not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The authors make no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "fcint.h"
static int
rawindex (const FcGlyphName *gn);
static void
scan (FILE *f, char *filename);
static int
isprime (int i);
static void
find_hash (void);
static FcChar32
FcHashGlyphName (const FcChar8 *name);
static void
insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h);
static void
dump (FcGlyphName * const *table, const char *name);
static FcGlyphName *
FcAllocGlyphName (FcChar32 ucs, FcChar8 *name)
{
FcGlyphName *gn;
gn = malloc (sizeof (FcGlyphName) + strlen ((char *) name));
if (!gn)
return 0;
gn->ucs = ucs;
strcpy ((char *) gn->name, (char *) name);
return gn;
}
static void
fatal (const char *file, int lineno, const char *msg)
{
if (lineno)
fprintf (stderr, "%s:%d: %s\n", file, lineno, msg);
else
fprintf (stderr, "%s: %s\n", file, msg);
exit (1);
}
#define MAX_GLYPHFILE 256
#define MAX_GLYPHNAME 10240
#define MAX_NAMELEN 1024
static FcGlyphName *raw[MAX_GLYPHNAME];
static int nraw;
static int max_name_len;
static FcGlyphName *name_to_ucs[MAX_GLYPHNAME*2];
static FcGlyphName *ucs_to_name[MAX_GLYPHNAME*2];
static unsigned int hash, rehash;
static int
rawindex (const FcGlyphName *gn)
{
int i;
for (i = 0; i < nraw; i++)
if (raw[i] == gn)
return i;
return -1;
}
static void
scan (FILE *f, char *filename)
{
char buf[MAX_NAMELEN];
char name[MAX_NAMELEN];
unsigned long ucs;
FcGlyphName *gn;
int lineno = 0;
int len;
while (fgets (buf, sizeof (buf), f))
{
lineno++;
if (sscanf (buf, "%[^;];%lx\n", name, &ucs) != 2)
continue;
gn = FcAllocGlyphName ((FcChar32) ucs, (FcChar8 *) name);
if (!gn)
fatal (filename, lineno, "out of memory");
len = strlen (name);
if (len > max_name_len)
max_name_len = len;
raw[nraw++] = gn;
}
}
static int compare_string (const void *a, const void *b)
{
const char *const *as = a, *const *bs = b;
return strcmp (*as, *bs);
}
static int compare_glyphname (const void *a, const void *b)
{
const FcGlyphName *const *ag = a, *const *bg = b;
return strcmp ((char *) (*ag)->name, (char *) (*bg)->name);
}
static int
isqrt (int a)
{
int l, h, m;
l = 2;
h = a/2;
while ((h-l) > 1)
{
m = (h+l) >> 1;
if (m * m < a)
l = m;
else
h = m;
}
return h;
}
static int
isprime (int i)
{
int l, t;
if (i < 2)
return FcFalse;
if ((i & 1) == 0)
{
if (i == 2)
return FcTrue;
return FcFalse;
}
l = isqrt (i) + 1;
for (t = 3; t <= l; t += 2)
if (i % t == 0)
return 0;
return 1;
}
/*
* Find a prime pair that leaves at least 25% of the hash table empty
*/
static void
find_hash (void)
{
int h;
h = nraw + nraw / 4;
if ((h & 1) == 0)
h++;
while (!isprime(h-2) || !isprime(h))
h += 2;
hash = h;
rehash = h-2;
}
static FcChar32
FcHashGlyphName (const FcChar8 *name)
{
FcChar32 h = 0;
FcChar8 c;
while ((c = *name++))
{
h = ((h << 1) | (h >> 31)) ^ c;
}
return h;
}
static void
insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
{
unsigned int i, r = 0;
i = (int) (h % hash);
while (table[i])
{
if (!r) r = (h % rehash + 1);
i += r;
if (i >= hash)
i -= hash;
}
table[i] = gn;
}
static void
dump (FcGlyphName * const *table, const char *name)
{
unsigned int i;
printf ("static const FcGlyphId %s[%d] = {\n", name, hash);
for (i = 0; i < hash; i++)
if (table[i])
printf (" %d,\n", rawindex(table[i]));
else
printf (" -1,\n");
printf ("};\n");
}
int
main (int argc FC_UNUSED, char **argv)
{
char *files[MAX_GLYPHFILE + 1];
char line[1024];
FILE *f;
int i;
const char *type;
i = 0;
while (argv[i+1])
{
if (i == MAX_GLYPHFILE)
fatal (*argv, 0, "Too many glyphname files");
files[i] = argv[i+1];
i++;
}
files[i] = 0;
qsort (files, i, sizeof (char *), compare_string);
for (i = 0; files[i]; i++)
{
f = fopen (files[i], "r");
if (!f)
fatal (files[i], 0, strerror (errno));
scan (f, files[i]);
fclose (f);
}
qsort (raw, nraw, sizeof (FcGlyphName *), compare_glyphname);
find_hash ();
for (i = 0; i < nraw; i++)
{
insert (raw[i], name_to_ucs, FcHashGlyphName (raw[i]->name));
insert (raw[i], ucs_to_name, raw[i]->ucs);
}
/*
* Scan the input until the marker is found
*/
while (fgets (line, sizeof (line), stdin))
{
if (!strncmp (line, "@@@", 3))
break;
fputs (line, stdout);
}
printf ("/* %d glyphnames in %d entries, %d%% occupancy */\n\n",
nraw, hash, nraw * 100 / hash);
printf ("#define FC_GLYPHNAME_HASH %u\n", hash);
printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash);
printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len);
if (nraw < 128)
type = "int8_t";
else if (nraw < 32768)
type = "int16_t";
else
type = "int32_t";
printf ("typedef %s FcGlyphId;\n\n", type);
/*
* Dump out entries
*/
printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } _fc_glyph_names[%d] = {\n",
max_name_len + 1, nraw);
for (i = 0; i < nraw; i++)
printf (" { 0x%lx, \"%s\" },\n",
(unsigned long) raw[i]->ucs, raw[i]->name);
printf ("};\n");
/*
* Dump out name_to_ucs table
*/
dump (name_to_ucs, "_fc_name_to_ucs");
/*
* Dump out ucs_to_name table
*/
dump (ucs_to_name, "_fc_ucs_to_name");
while (fgets (line, sizeof (line), stdin))
fputs (line, stdout);
fflush (stdout);
exit (ferror (stdout));
}

View File

@ -1,25 +0,0 @@
/*
* fontconfig/fc-glyphname/fcglyphname.tmpl.h
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the author(s) not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The authors make no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
@@@

View File

@ -1,212 +0,0 @@
# Name: ITC Zapf Dingbats Glyph List
# Table version: 2.0
# Date: September 20, 2002
#
# See http://partners.adobe.com/asn/developer/typeforum/unicodegn.html
#
# Format: Semicolon-delimited fields:
# (1) glyph name
# (2) Unicode scalar value
#
a100;275E
a101;2761
a102;2762
a103;2763
a104;2764
a105;2710
a106;2765
a107;2766
a108;2767
a109;2660
a10;2721
a110;2665
a111;2666
a112;2663
a117;2709
a118;2708
a119;2707
a11;261B
a120;2460
a121;2461
a122;2462
a123;2463
a124;2464
a125;2465
a126;2466
a127;2467
a128;2468
a129;2469
a12;261E
a130;2776
a131;2777
a132;2778
a133;2779
a134;277A
a135;277B
a136;277C
a137;277D
a138;277E
a139;277F
a13;270C
a140;2780
a141;2781
a142;2782
a143;2783
a144;2784
a145;2785
a146;2786
a147;2787
a148;2788
a149;2789
a14;270D
a150;278A
a151;278B
a152;278C
a153;278D
a154;278E
a155;278F
a156;2790
a157;2791
a158;2792
a159;2793
a15;270E
a160;2794
a161;2192
a162;27A3
a163;2194
a164;2195
a165;2799
a166;279B
a167;279C
a168;279D
a169;279E
a16;270F
a170;279F
a171;27A0
a172;27A1
a173;27A2
a174;27A4
a175;27A5
a176;27A6
a177;27A7
a178;27A8
a179;27A9
a17;2711
a180;27AB
a181;27AD
a182;27AF
a183;27B2
a184;27B3
a185;27B5
a186;27B8
a187;27BA
a188;27BB
a189;27BC
a18;2712
a190;27BD
a191;27BE
a192;279A
a193;27AA
a194;27B6
a195;27B9
a196;2798
a197;27B4
a198;27B7
a199;27AC
a19;2713
a1;2701
a200;27AE
a201;27B1
a202;2703
a203;2750
a204;2752
a205;276E
a206;2770
a20;2714
a21;2715
a22;2716
a23;2717
a24;2718
a25;2719
a26;271A
a27;271B
a28;271C
a29;2722
a2;2702
a30;2723
a31;2724
a32;2725
a33;2726
a34;2727
a35;2605
a36;2729
a37;272A
a38;272B
a39;272C
a3;2704
a40;272D
a41;272E
a42;272F
a43;2730
a44;2731
a45;2732
a46;2733
a47;2734
a48;2735
a49;2736
a4;260E
a50;2737
a51;2738
a52;2739
a53;273A
a54;273B
a55;273C
a56;273D
a57;273E
a58;273F
a59;2740
a5;2706
a60;2741
a61;2742
a62;2743
a63;2744
a64;2745
a65;2746
a66;2747
a67;2748
a68;2749
a69;274A
a6;271D
a70;274B
a71;25CF
a72;274D
a73;25A0
a74;274F
a75;2751
a76;25B2
a77;25BC
a78;25C6
a79;2756
a7;271E
a81;25D7
a82;2758
a83;2759
a84;275A
a85;276F
a86;2771
a87;2772
a88;2773
a89;2768
a8;271F
a90;2769
a91;276C
a92;276D
a93;276A
a94;276B
a95;2774
a96;2775
a97;275B
a98;275C
a99;275D
a9;2720
#-- end

View File

@ -89,7 +89,6 @@ ALIAS_FILES = fcalias.h fcaliastail.h fcftalias.h fcftaliastail.h
BUILT_SOURCES = $(ALIAS_FILES) \
../fc-case/fccase.h \
../fc-glyphname/fcglyphname.h \
../fc-lang/fclang.h \
stamp-fcstdint \
fcobjshash.h \
@ -99,8 +98,6 @@ noinst_PROGRAMS = fcarch
../fc-case/fccase.h:
cd ../fc-case && $(MAKE) $(AM_MAKEFLAGS) fccase.h
../fc-glyphname/fcglyphname.h:
cd ../fc-glyphname && $(MAKE) $(AM_MAKEFLAGS) fcglyphname.h
../fc-lang/fclang.h:
cd ../fc-lang && $(MAKE) $(AM_MAKEFLAGS) fclang.h