Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fontconfig
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ben Wagner
fontconfig
Commits
0ab36ca8
Commit
0ab36ca8
authored
May 22, 2002
by
Keith Packard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace silly avl sort with qsort, add FcPatternEqual
parent
446bb9c9
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
162 additions
and
515 deletions
+162
-515
fontconfig/fontconfig.h
fontconfig/fontconfig.h
+7
-1
src/Imakefile
src/Imakefile
+3
-3
src/Makefile.in
src/Makefile.in
+1
-3
src/fcavl.c
src/fcavl.c
+0
-419
src/fcavl.h
src/fcavl.h
+0
-46
src/fcmatch.c
src/fcmatch.c
+39
-37
src/fcpat.c
src/fcpat.c
+104
-5
src/fcxml.c
src/fcxml.c
+8
-1
No files found.
fontconfig/fontconfig.h
View file @
0ab36ca8
/*
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.
5 2002/03/01 01:00:54
keithp Exp $
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.
8 2002/05/21 17:06:22
keithp Exp $
*
* Copyright 2001 Keith Packard, member of The XFree86 Project, Inc.
*
...
...
@@ -557,12 +557,18 @@ FcPatternDuplicate (FcPattern *p);
void
FcValueDestroy
(
FcValue
v
);
FcBool
FcValueEqual
(
FcValue
va
,
FcValue
vb
);
FcValue
FcValueSave
(
FcValue
v
);
void
FcPatternDestroy
(
FcPattern
*
p
);
FcBool
FcPatternEqual
(
FcPattern
*
pa
,
FcPattern
*
pb
);
FcBool
FcPatternAdd
(
FcPattern
*
p
,
const
char
*
object
,
FcValue
value
,
FcBool
append
);
...
...
src/Imakefile
View file @
0ab36ca8
...
...
@@ -23,16 +23,16 @@ SOFONTCONFIGREV=1.0
INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
DEFINES=-DFC_DEFAULT_FONTS='"$(FC_DEFAULT_FONTS)"'
DEFINES=-DFC_DEFAULT_FONTS='"$(FC_DEFAULT_FONTS)"'
-DHAVE_EXPAT
EXPATLIB=-lexpat
REQUIREDLIBS=$(LDPRELIBS) $(FREETYPE2LIB) $(EXPATLIB)
SRCS=fcatomic.c fc
avl.c fc
blanks.c fccache.c fccfg.c fccharset.c fcdbg.c \
SRCS=fcatomic.c fcblanks.c fccache.c fccfg.c fccharset.c fcdbg.c \
fcdefault.c fcdir.c fcfreetype.c fcfs.c fcinit.c fclist.c fcmatch.c \
fcmatrix.c fcname.c fcpat.c fcstr.c fcxml.c
OBJS=fcatomic.o fc
avl.o fc
blanks.o fccache.o fccfg.o fccharset.o fcdbg.o \
OBJS=fcatomic.o fcblanks.o fccache.o fccfg.o fccharset.o fcdbg.o \
fcdefault.o fcdir.o fcfreetype.o fcfs.o fcinit.o fclist.o fcmatch.o \
fcmatrix.o fcname.o fcpat.o fcstr.o fcxml.o
...
...
src/Makefile.in
View file @
0ab36ca8
#
# $XFree86$
# $XFree86
: xc/lib/fontconfig/src/Makefile.in,v 1.2 2002/05/21 17:48:15 keithp Exp
$
#
# Copyright 2002 Keith Packard, member of The XFree86 Project, Inc.
#
...
...
@@ -29,7 +29,6 @@ include $(TOPDIR)/config/Makedefs
LIBS
=
@LIBS@
SRCS
=
fcatomic.c
\
fcavl.c
\
fcblanks.c
\
fccache.c
\
fccfg.c
\
...
...
@@ -49,7 +48,6 @@ SRCS=fcatomic.c \
fcxml.c
OBJS
=
fcatomic.@OBJEXT@
\
fcavl.@OBJEXT@
\
fcblanks.@OBJEXT@
\
fccache.@OBJEXT@
\
fccfg.@OBJEXT@
\
...
...
src/fcavl.c
deleted
100644 → 0
View file @
446bb9c9
This diff is collapsed.
Click to expand it.
src/fcavl.h
deleted
100644 → 0
View file @
446bb9c9
/*
* $XFree86: $
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _FCAVL_H_
#define _FCAVL_H_
/*
* fcavl.h
*
* balanced binary tree
*/
typedef
struct
_FcAvlNode
FcAvlNode
;
struct
_FcAvlNode
{
FcAvlNode
*
left
,
*
right
;
short
balance
;
};
typedef
FcBool
(
*
FcAvlMore
)
(
FcAvlNode
*
a
,
FcAvlNode
*
b
);
FcBool
FcAvlInsert
(
FcAvlMore
more
,
FcAvlNode
**
tree
,
FcAvlNode
*
leaf
);
int
FcAvlDelete
(
FcAvlMore
more
,
FcAvlNode
**
tree
,
FcAvlNode
*
leaf
);
#endif
/* _FCAVL_H_ */
src/fcmatch.c
View file @
0ab36ca8
...
...
@@ -383,62 +383,57 @@ FcFontMatch (FcConfig *config,
return
FcFontSetMatch
(
config
,
sets
,
nsets
,
p
,
result
);
}
#include "fcavl.h"
typedef
struct
_FcSortNode
{
FcAvlNode
avl
;
FcPattern
*
pattern
;
double
score
[
NUM_MATCHER
];
}
FcSortNode
;
static
FcBool
FcSort
More
(
FcAvlNode
*
aa
,
FcAvlNode
*
ab
)
static
int
FcSort
Compare
(
const
void
*
aa
,
const
void
*
ab
)
{
FcSortNode
*
a
=
(
FcSortNode
*
)
aa
;
FcSortNode
*
b
=
(
FcSortNode
*
)
ab
;
int
i
;
FcSortNode
*
a
=
*
(
FcSortNode
*
*
)
aa
;
FcSortNode
*
b
=
*
(
FcSortNode
*
*
)
ab
;
int
i
;
for
(
i
=
0
;
i
<
NUM_MATCHER
;
i
++
)
{
if
(
a
->
score
[
i
]
>
b
->
score
[
i
])
return
FcTrue
;
return
-
1
;
if
(
a
->
score
[
i
]
<
b
->
score
[
i
])
return
FcFalse
;
return
1
;
}
if
(
aa
>
ab
)
return
FcTrue
;
return
FcFalse
;
return
0
;
}
static
FcBool
FcSortWalk
(
FcSortNode
*
n
,
FcFontSet
*
fs
,
FcCharSet
**
cs
,
FcBool
trim
)
FcSortWalk
(
FcSortNode
*
*
n
,
int
nnode
,
FcFontSet
*
fs
,
FcCharSet
**
cs
,
FcBool
trim
)
{
FcCharSet
*
ncs
;
if
(
!
n
)
return
FcTrue
;
if
(
!
FcSortWalk
((
FcSortNode
*
)
n
->
avl
.
left
,
fs
,
cs
,
trim
))
return
FcFalse
;
if
(
FcPatternGetCharSet
(
n
->
pattern
,
FC_CHARSET
,
0
,
&
ncs
)
==
FcResultMatch
)
FcSortNode
*
node
;
while
(
nnode
--
)
{
if
(
!
trim
||
!*
cs
||
FcCharSetSubtractCount
(
ncs
,
*
cs
)
!=
0
)
node
=
*
n
++
;
if
(
FcPatternGetCharSet
(
node
->
pattern
,
FC_CHARSET
,
0
,
&
ncs
)
==
FcResultMatch
)
{
if
(
*
cs
)
if
(
!
trim
||
!*
cs
||
FcCharSetSubtractCount
(
ncs
,
*
cs
)
!=
0
)
{
ncs
=
FcCharSetUnion
(
ncs
,
*
cs
);
if
(
!
ncs
)
if
(
*
cs
)
{
ncs
=
FcCharSetUnion
(
ncs
,
*
cs
);
if
(
!
ncs
)
return
FcFalse
;
FcCharSetDestroy
(
*
cs
);
}
else
ncs
=
FcCharSetCopy
(
ncs
);
*
cs
=
ncs
;
if
(
!
FcFontSetAdd
(
fs
,
node
->
pattern
))
return
FcFalse
;
FcCharSetDestroy
(
*
cs
);
}
else
ncs
=
FcCharSetCopy
(
ncs
);
*
cs
=
ncs
;
if
(
!
FcFontSetAdd
(
fs
,
n
->
pattern
))
return
FcFalse
;
}
}
if
(
!
FcSortWalk
((
FcSortNode
*
)
n
->
avl
.
right
,
fs
,
cs
,
trim
))
return
FcFalse
;
return
FcTrue
;
}
...
...
@@ -454,8 +449,8 @@ FcFontSetSort (FcConfig *config,
FcFontSet
*
ret
;
FcFontSet
*
s
;
FcSortNode
*
nodes
;
FcSortNode
**
nodeps
,
**
nodep
;
int
nnodes
;
FcSortNode
*
root
;
FcSortNode
*
new
;
FcCharSet
*
cs
;
int
set
;
...
...
@@ -472,12 +467,13 @@ FcFontSetSort (FcConfig *config,
}
if
(
!
nnodes
)
goto
bail0
;
nodes
=
malloc
(
nnodes
*
sizeof
(
FcSortNode
));
nodes
=
malloc
(
nnodes
*
sizeof
(
FcSortNode
)
+
nnodes
*
sizeof
(
FcSortNode
*
)
);
if
(
!
nodes
)
goto
bail0
;
nodeps
=
(
FcSortNode
**
)
nodes
+
nnodes
;
root
=
0
;
new
=
nodes
;
nodep
=
nodeps
;
for
(
set
=
0
;
set
<
nsets
;
set
++
)
{
s
=
sets
[
set
];
...
...
@@ -502,18 +498,24 @@ FcFontSetSort (FcConfig *config,
}
printf
(
"
\n
"
);
}
FcAvlInsert
(
FcSortMore
,
(
FcAvlNode
**
)
&
root
,
&
new
->
avl
)
;
*
nodep
=
new
;
new
++
;
nodep
++
;
}
}
nnodes
=
new
-
nodes
;
qsort
(
nodeps
,
sizeof
(
FcSortNode
*
),
nnodes
,
FcSortCompare
);
ret
=
FcFontSetCreate
();
if
(
!
ret
)
goto
bail1
;
cs
=
0
;
if
(
!
FcSortWalk
(
root
,
ret
,
&
cs
,
trim
))
if
(
!
FcSortWalk
(
nodeps
,
nnodes
,
ret
,
&
cs
,
trim
))
goto
bail2
;
*
csp
=
cs
;
...
...
src/fcpat.c
View file @
0ab36ca8
/*
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.
2 2002/02/15 06:01:28
keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.
3 2002/02/19 07:50:44
keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
*
...
...
@@ -109,6 +109,58 @@ FcValueListDestroy (FcValueList *l)
}
}
FcBool
FcValueEqual
(
FcValue
va
,
FcValue
vb
)
{
if
(
va
.
type
!=
vb
.
type
)
{
if
(
va
.
type
==
FcTypeInteger
)
{
va
.
type
=
FcTypeDouble
;
va
.
u
.
d
=
va
.
u
.
i
;
}
if
(
vb
.
type
==
FcTypeInteger
)
{
vb
.
type
=
FcTypeDouble
;
vb
.
u
.
d
=
vb
.
u
.
i
;
}
if
(
va
.
type
!=
vb
.
type
)
return
FcFalse
;
}
switch
(
va
.
type
)
{
case
FcTypeVoid
:
return
FcTrue
;
case
FcTypeInteger
:
return
va
.
u
.
i
==
vb
.
u
.
i
;
case
FcTypeDouble
:
return
va
.
u
.
d
==
vb
.
u
.
d
;
case
FcTypeString
:
return
FcStrCmpIgnoreCase
(
va
.
u
.
s
,
vb
.
u
.
s
)
==
0
;
case
FcTypeBool
:
return
va
.
u
.
b
==
vb
.
u
.
b
;
case
FcTypeMatrix
:
return
FcMatrixEqual
(
va
.
u
.
m
,
vb
.
u
.
m
);
case
FcTypeCharSet
:
return
FcCharSetEqual
(
va
.
u
.
c
,
vb
.
u
.
c
);
}
return
FcFalse
;
}
static
FcBool
FcValueListEqual
(
FcValueList
*
la
,
FcValueList
*
lb
)
{
while
(
la
&&
lb
)
{
if
(
!
FcValueEqual
(
la
->
value
,
lb
->
value
))
return
FcFalse
;
la
=
la
->
next
;
lb
=
lb
->
next
;
}
if
(
la
||
lb
)
return
FcFalse
;
return
FcTrue
;
}
void
FcPatternDestroy
(
FcPattern
*
p
)
{
...
...
@@ -136,18 +188,40 @@ FcPatternFind (FcPattern *p, const char *object, FcBool insert)
int
s
;
FcPatternElt
*
e
;
int
low
,
high
;
/* match existing */
for
(
i
=
0
;
i
<
p
->
num
;
i
++
)
low
=
0
;
high
=
p
->
num
;
while
(
low
+
1
<
high
)
{
i
=
(
low
+
high
)
>>
1
;
s
=
FcStrCmpIgnoreCase
((
FcChar8
*
)
object
,
(
FcChar8
*
)
p
->
elts
[
i
].
object
);
if
(
s
==
0
)
return
&
p
->
elts
[
i
];
if
(
s
<
0
)
low
=
i
;
else
high
=
i
;
}
i
=
low
;
while
(
i
<
high
)
{
if
(
!
FcStrCmpIgnoreCase
((
FcChar8
*
)
object
,
(
FcChar8
*
)
p
->
elts
[
i
].
object
))
s
=
FcStrCmpIgnoreCase
((
FcChar8
*
)
object
,
(
FcChar8
*
)
p
->
elts
[
i
].
object
);
if
(
s
==
0
)
return
&
p
->
elts
[
i
];
if
(
s
>
0
)
break
;
i
++
;
}
if
(
!
insert
)
return
FcFalse
;
return
0
;
/* grow array */
if
(
i
=
=
p
->
size
)
if
(
p
->
num
+
1
>
=
p
->
size
)
{
s
=
p
->
size
+
16
;
if
(
p
->
elts
)
...
...
@@ -168,14 +242,39 @@ FcPatternFind (FcPattern *p, const char *object, FcBool insert)
}
}
/* move elts up */
memmove
(
p
->
elts
+
i
+
1
,
p
->
elts
+
i
,
sizeof
(
FcPatternElt
)
*
(
p
->
num
-
i
));
/* bump count */
p
->
num
++
;
p
->
elts
[
i
].
object
=
object
;
p
->
elts
[
i
].
values
=
0
;
return
&
p
->
elts
[
i
];
}
FcBool
FcPatternEqual
(
FcPattern
*
pa
,
FcPattern
*
pb
)
{
int
i
;
if
(
pa
->
num
!=
pb
->
num
)
return
FcFalse
;
for
(
i
=
0
;
i
<
pa
->
num
;
i
++
)
{
if
(
FcStrCmpIgnoreCase
((
FcChar8
*
)
pa
->
elts
[
i
].
object
,
(
FcChar8
*
)
pb
->
elts
[
i
].
object
)
!=
0
)
return
FcFalse
;
if
(
!
FcValueListEqual
(
pa
->
elts
[
i
].
values
,
pb
->
elts
[
i
].
values
))
return
FcFalse
;
}
return
FcTrue
;
}
FcBool
FcPatternAdd
(
FcPattern
*
p
,
const
char
*
object
,
FcValue
value
,
FcBool
append
)
{
...
...
src/fcxml.c
View file @
0ab36ca8
/*
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.
6 2002/02/28 16:51:48
keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.
7 2002/05/21 17:06:22
keithp Exp $
*
* Copyright 2002 Keith Packard, member of The XFree86 Project, Inc.
*
...
...
@@ -24,11 +24,18 @@
#include <stdarg.h>
#include "fcint.h"
#if HAVE_EXPAT
#if HAVE_XMLPARSE_H
#include <xmlparse.h>
#else
#include <expat.h>
#endif
#endif
#if HAVE_XML2
#include "fclibxml2.h"
#endif
FcTest
*
FcTestCreate
(
FcQual
qual
,
const
FcChar8
*
field
,
FcOp
compare
,
FcExpr
*
expr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment