Switch fc-cat to use FcPatternFormat()
Added the a builtin "fccat" to FcPatternFormat().
This commit is contained in:
parent
a15ac5d384
commit
e61eba94ef
|
@ -201,6 +201,13 @@ Expands to the output of the default output format of the fc-list
|
||||||
command on the pattern, without the final newline.
|
command on the pattern, without the final newline.
|
||||||
</para></listitem></varlistentry>
|
</para></listitem></varlistentry>
|
||||||
|
|
||||||
|
<varlistentry><term>
|
||||||
|
fccat
|
||||||
|
</term><listitem><para>
|
||||||
|
Expands to the output of the default output format of the fc-cat
|
||||||
|
command on the pattern, without the final newline.
|
||||||
|
</para></listitem></varlistentry>
|
||||||
|
|
||||||
<varlistentry><term>
|
<varlistentry><term>
|
||||||
pkgkit
|
pkgkit
|
||||||
</term><listitem><para>
|
</term><listitem><para>
|
||||||
|
|
|
@ -194,11 +194,9 @@ file_base_name (const FcChar8 *cache, const FcChar8 *file)
|
||||||
static FcBool
|
static FcBool
|
||||||
cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose)
|
cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose)
|
||||||
{
|
{
|
||||||
FcChar8 *name, *dir;
|
FcChar8 *dir;
|
||||||
const FcChar8 *file, *base;
|
const FcChar8 *base;
|
||||||
int ret;
|
|
||||||
int n;
|
int n;
|
||||||
int id;
|
|
||||||
int ndir = 0;
|
int ndir = 0;
|
||||||
FcStrList *list;
|
FcStrList *list;
|
||||||
|
|
||||||
|
@ -227,37 +225,22 @@ cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBoo
|
||||||
for (n = 0; n < set->nfont; n++)
|
for (n = 0; n < set->nfont; n++)
|
||||||
{
|
{
|
||||||
FcPattern *font = set->fonts[n];
|
FcPattern *font = set->fonts[n];
|
||||||
|
FcChar8 *s;
|
||||||
|
|
||||||
if (FcPatternGetString (font, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch)
|
s = FcPatternFormat (font, "%{=fccat}\n");
|
||||||
goto bail3;
|
if (s)
|
||||||
base = file_base_name (base_name, file);
|
{
|
||||||
if (FcPatternGetInteger (font, FC_INDEX, 0, &id) != FcResultMatch)
|
printf ("%s", s);
|
||||||
goto bail3;
|
free (s);
|
||||||
if (!write_string (stdout, base))
|
}
|
||||||
goto bail3;
|
|
||||||
if (PUTC (' ', stdout) == EOF)
|
|
||||||
goto bail3;
|
|
||||||
if (!write_int (stdout, id))
|
|
||||||
goto bail3;
|
|
||||||
if (PUTC (' ', stdout) == EOF)
|
|
||||||
goto bail3;
|
|
||||||
name = FcNameUnparse (font);
|
|
||||||
if (!name)
|
|
||||||
goto bail3;
|
|
||||||
ret = write_string (stdout, name);
|
|
||||||
FcStrFree (name);
|
|
||||||
if (!ret)
|
|
||||||
goto bail3;
|
|
||||||
if (PUTC ('\n', stdout) == EOF)
|
|
||||||
goto bail3;
|
|
||||||
}
|
}
|
||||||
if (verbose && !set->nfont && !ndir)
|
if (verbose && !set->nfont && !ndir)
|
||||||
printf ("<empty>\n");
|
printf ("<empty>\n");
|
||||||
|
|
||||||
FcStrListDone (list);
|
FcStrListDone (list);
|
||||||
|
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
|
||||||
bail3:
|
bail3:
|
||||||
FcStrListDone (list);
|
FcStrListDone (list);
|
||||||
bail2:
|
bail2:
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
* unparse FcNameUnparse
|
* unparse FcNameUnparse
|
||||||
* fcmatch fc-match default
|
* fcmatch fc-match default
|
||||||
* fclist fc-list default
|
* fclist fc-list default
|
||||||
|
* fccat fc-cat default
|
||||||
* pkgkit PackageKit package tag format
|
* pkgkit PackageKit package tag format
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define FCCAT_FORMAT "\"%{file|basename|cescape}\" %{index} \"%{-file{%{=unparse|cescape}}}\""
|
||||||
#define FCMATCH_FORMAT "%{file:-<unknown filename>|basename}: \"%{family[0]:-<unknown family>}\" \"%{style[0]:-<unknown style>}\""
|
#define FCMATCH_FORMAT "%{file:-<unknown filename>|basename}: \"%{family[0]:-<unknown family>}\" \"%{style[0]:-<unknown style>}\""
|
||||||
#define FCLIST_FORMAT "%{?file{%{file}: }}%{-file{%{=unparse}}}"
|
#define FCLIST_FORMAT "%{?file{%{file}: }}%{-file{%{=unparse}}}"
|
||||||
#define PKGKIT_FORMAT "%{[]family{font(%{family|downcase|delete( )})\n}}%{[]lang{font(:lang=%{lang|downcase|translate(_,-)})\n}}"
|
#define PKGKIT_FORMAT "%{[]family{font(%{family|downcase|delete( )})\n}}%{[]lang{font(:lang=%{lang|downcase|translate(_,-)})\n}}"
|
||||||
|
@ -304,6 +306,7 @@ interpret_builtin (FcFormatContext *c,
|
||||||
#define BUILTIN(name, format) \
|
#define BUILTIN(name, format) \
|
||||||
else if (0 == strcmp ((const char *) c->word, name))\
|
else if (0 == strcmp ((const char *) c->word, name))\
|
||||||
ret = FcPatternFormatToBuf (pat, (const FcChar8 *) format, buf)
|
ret = FcPatternFormatToBuf (pat, (const FcChar8 *) format, buf)
|
||||||
|
BUILTIN ("fccat", FCCAT_FORMAT);
|
||||||
BUILTIN ("fcmatch", FCMATCH_FORMAT);
|
BUILTIN ("fcmatch", FCMATCH_FORMAT);
|
||||||
BUILTIN ("fclist", FCLIST_FORMAT);
|
BUILTIN ("fclist", FCLIST_FORMAT);
|
||||||
BUILTIN ("pkgkit", PKGKIT_FORMAT);
|
BUILTIN ("pkgkit", PKGKIT_FORMAT);
|
||||||
|
|
Loading…
Reference in New Issue