|
Packit |
b749da |
/*
|
|
Packit |
b749da |
* Copyright © 2000 Keith Packard
|
|
Packit |
b749da |
*
|
|
Packit |
b749da |
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
b749da |
* documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
b749da |
* the above copyright notice appear in all copies and that both that
|
|
Packit |
b749da |
* copyright notice and this permission notice appear in supporting
|
|
Packit |
b749da |
* documentation, and that the name of Keith Packard not be used in
|
|
Packit |
b749da |
* advertising or publicity pertaining to distribution of the software without
|
|
Packit |
b749da |
* specific, written prior permission. Keith Packard makes no
|
|
Packit |
b749da |
* representations about the suitability of this software for any purpose. It
|
|
Packit |
b749da |
* is provided "as is" without express or implied warranty.
|
|
Packit |
b749da |
*
|
|
Packit |
b749da |
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
Packit |
b749da |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
Packit |
b749da |
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
Packit |
b749da |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
Packit |
b749da |
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
Packit |
b749da |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
Packit |
b749da |
* PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
b749da |
*/
|
|
Packit |
b749da |
|
|
Packit |
b749da |
#include "xftint.h"
|
|
Packit |
b749da |
|
|
Packit |
b749da |
_X_EXPORT FcPattern *
|
|
Packit |
b749da |
XftFontMatch (Display *dpy,
|
|
Packit |
b749da |
int screen,
|
|
Packit |
b749da |
_Xconst FcPattern *pattern,
|
|
Packit |
b749da |
FcResult *result)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
FcPattern *new;
|
|
Packit |
b749da |
FcPattern *match;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
if (!XftInit (NULL))
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
new = FcPatternDuplicate (pattern);
|
|
Packit |
b749da |
if (!new)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPENV)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontMatch pattern ");
|
|
Packit |
b749da |
FcPatternPrint (new);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
FcConfigSubstitute (NULL, new, FcMatchPattern);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPENV)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontMatch after FcConfig substitutions ");
|
|
Packit |
b749da |
FcPatternPrint (new);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
XftDefaultSubstitute (dpy, screen, new);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPENV)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontMatch after X resource substitutions ");
|
|
Packit |
b749da |
FcPatternPrint (new);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
match = FcFontMatch (NULL, new, result);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPENV)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontMatch result ");
|
|
Packit |
b749da |
FcPatternPrint (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
FcPatternDestroy (new);
|
|
Packit |
b749da |
return match;
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
_X_EXPORT XftFont *
|
|
Packit |
b749da |
XftFontOpen (Display *dpy, int screen, ...)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
va_list va;
|
|
Packit |
b749da |
FcPattern *pat;
|
|
Packit |
b749da |
FcPattern *match;
|
|
Packit |
b749da |
FcResult result;
|
|
Packit |
b749da |
XftFont *font;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
va_start (va, screen);
|
|
Packit |
b749da |
pat = FcPatternVaBuild (NULL, va);
|
|
Packit |
b749da |
va_end (va);
|
|
Packit |
b749da |
if (!pat)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
printf ("XftFontOpen: Invalid pattern argument\n");
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
match = XftFontMatch (dpy, screen, pat, &result);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("Pattern ");
|
|
Packit |
b749da |
FcPatternPrint (pat);
|
|
Packit |
b749da |
if (match)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("Match ");
|
|
Packit |
b749da |
FcPatternPrint (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
else
|
|
Packit |
b749da |
printf ("No Match\n");
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
FcPatternDestroy (pat);
|
|
Packit |
b749da |
if (!match)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
font = XftFontOpenPattern (dpy, match);
|
|
Packit |
b749da |
if (!font)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
printf ("No Font\n");
|
|
Packit |
b749da |
FcPatternDestroy (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
return font;
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
_X_EXPORT XftFont *
|
|
Packit |
b749da |
XftFontOpenName (Display *dpy, int screen, const char *name)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
FcPattern *pat;
|
|
Packit |
b749da |
FcPattern *match;
|
|
Packit |
b749da |
FcResult result;
|
|
Packit |
b749da |
XftFont *font;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
pat = FcNameParse ((FcChar8 *) name);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontOpenName \"%s\": ", name);
|
|
Packit |
b749da |
if (pat)
|
|
Packit |
b749da |
FcPatternPrint (pat);
|
|
Packit |
b749da |
else
|
|
Packit |
b749da |
printf ("Invalid name\n");
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
if (!pat)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
match = XftFontMatch (dpy, screen, pat, &result);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (match)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("Match ");
|
|
Packit |
b749da |
FcPatternPrint (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
else
|
|
Packit |
b749da |
printf ("No Match\n");
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
FcPatternDestroy (pat);
|
|
Packit |
b749da |
if (!match)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
font = XftFontOpenPattern (dpy, match);
|
|
Packit |
b749da |
if (!font)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
printf ("No Font\n");
|
|
Packit |
b749da |
FcPatternDestroy (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
return font;
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
_X_EXPORT XftFont *
|
|
Packit |
b749da |
XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
FcPattern *pat;
|
|
Packit |
b749da |
FcPattern *match;
|
|
Packit |
b749da |
FcResult result;
|
|
Packit |
b749da |
XftFont *font;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("XftFontOpenXlfd \"%s\": ", xlfd);
|
|
Packit |
b749da |
if (pat)
|
|
Packit |
b749da |
printf ("Invalid xlfd\n");
|
|
Packit |
b749da |
else
|
|
Packit |
b749da |
FcPatternPrint (pat);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
if (!pat)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
match = XftFontMatch (dpy, screen, pat, &result);
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (match)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
printf ("Match ");
|
|
Packit |
b749da |
FcPatternPrint (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
else
|
|
Packit |
b749da |
printf ("No Match\n");
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
FcPatternDestroy (pat);
|
|
Packit |
b749da |
if (!match)
|
|
Packit |
b749da |
return NULL;
|
|
Packit |
b749da |
|
|
Packit |
b749da |
font = XftFontOpenPattern (dpy, match);
|
|
Packit |
b749da |
if (!font)
|
|
Packit |
b749da |
{
|
|
Packit |
b749da |
if (XftDebug () & XFT_DBG_OPEN)
|
|
Packit |
b749da |
printf ("No Font\n");
|
|
Packit |
b749da |
FcPatternDestroy (match);
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|
|
Packit |
b749da |
return font;
|
|
Packit |
b749da |
}
|
|
Packit |
b749da |
|