Re: Granular synthetic emboldening possible ?

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

 





On Fri, 25 Jan 2019 at 09:35, Lawrence D'Oliveiro <ldo@xxxxxxxxxxxxxxxxxxx> wrote:
On Thu, 24 Jan 2019 12:37:31 +0530, Jay Aurabind wrote:

> This begs the question, are there any FreeType Supported font formats
> that can actually do granular weight rendering if requested by
> fontconfig?

As I understand it, what you really want to do is get a list of all the
weights available for a particular family, and choose the next higher
one from a given one?

Fontconfig has no API for directly returning this, but it is easy
enough to implement the function for yourself.

Following is an example Python script that, given a font spec, finds
all weights available for the best matching font family. For example,
on my current system setup,

    family_weights palatino

returns

    family 'P052' members [{'weight': 80, 'file': '/usr/share/fonts/type1/urw-base35/P052-Italic.t1'}, {'weight': 100, 'file': '/usr/share/fonts/type1/urw-base35/P052-Roman.t1'}, {'weight': 200, 'file': '/usr/share/fonts/type1/urw-base35/P052-Bold.t1'}, {'weight': 200, 'file': '/usr/share/fonts/type1/urw-base35/P052-BoldItalic.t1'}]

Adapt as appropriate.

Thank you very much for sharing this.
----
#!/usr/bin/python3
#+
# Find all weights for a given family. Invoke this script as follows:
#
#     family_weights «font-spec»
#
# and it will return a list of all fonts with a common family name
# matching «font-spec», in order of increasing weight.
#-

import sys
import getopt
import freetype2 as ft # <https://github.com/ldo/python_freetype>
import fontconfig as fc # <https://github.com/ldo/python_fontconfig>
from fontconfig import \
    FC

if len(sys.argv) != 2 :
    raise getopt.GetoptError("need exactly one arg, the Fontconfig pattern to match")
#end if

conf = fc.Config.get_current()
pat = fc.Pattern.name_parse(sys.argv[1])
conf.substitute(pat, FC.MatchPattern)
pat.default_substitute()
family_name = None
found = []
for entry in conf.font_sort(pat, trim = False, want_coverage = False)[0] :
    this_family = entry.get(FC.FAMILY, 0)[0]
    if family_name == None or this_family == family_name :
        if family_name == None :
            family_name = this_family
        #end if
        found.append({"weight" : entry.get(FC.WEIGHT, 0)[0], "file" : entry.get(FC.FILE, 0)[0]})
    #end if
#end for
found = sorted(found, key = lambda x : x["weight"])
sys.stdout.write("family %s members %s\n" % (repr(family_name), repr(found)))
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig


--

Thanks and Regards,
Aurabindo J
_______________________________________________
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