Re: How to use FcFontMatch to find a font with a given character

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 1 Jul 2018 00:41:01 +0800, Elias Mårtenson wrote:

> I've been testing with U+03C6 GREEK SMALL LETTER PHI, and
> it does exist in DejaVu Sans, Fontconfig correctly finds it when I
> query for fonts that contain this character, but when I use
> FcCharSetFirstPage and FcCharSetNextPage, the resulting bitmaps
> indicates that this character does not exist.

Not sure what you’re doing differently. Here’s a sample Python script I
tried with <https://github.com/ldo/python_fontconfig/>:

    #!/usr/bin/python3

    import sys
    import getopt
    import fontconfig as fc
    from fontconfig import \
        FC

    opts, args = getopt.getopt \
      (
        sys.argv[1:],
        "",
        []
      )

    if len(args) < 2 :
        raise getopt.GetoptError("usage: %s pat prop [prop ...]" % sys.argv[0])
    #end if

    conf = fc.Config.get_current()
    pat = fc.Pattern.name_parse(args[0])
    if True :
        conf.substitute(pat, FC.MatchPattern)
        pat.default_substitute()
    #end if
    props = args[1:]
    sys.stdout.write("matching: %s\n" % pat.name_unparse())

    i = 0
    for f in conf.font_sort(pat, trim = False, want_coverage = False)[0] :
        sys.stdout.write \
          (
                "found[%d]: %s\n"
            %
                (i, "; ".join("%s=%s" % (prop, f.get(prop, 0)) for prop in props))
          )
        i += 1
    #end for
    if i == 0 :
        sys.stdout.write("(none found)\n")
    #end if

invoking it with a command like

    ./font_list dejavu\ sans family charset

and I get output like (abbreviated)

    found[0]: family=('DejaVu Sans', 0); charset=({32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
    ... 966, ...
    ... }, 0)

As you can see, the character in question is listed.
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux