def getPackages(self, filterByFontPurpose=[]):
    packageKeywords = []
    packages = []
    packageByKeyword = {}

    def passedFilter(font):
        return ((not filterByFontPurpose) or (font.purpose in filterByFontPurpose))
    for font in self.fonts:
        if passedFilter(font):
            for keyword in font.getPackageKeywords():
                if (keyword not in packageKeywords):
                    packageKeywords.append(keyword)
    if (DEFAULT in packageKeywords):
        defaultPackage = FontPackage()
        defaultPackage.keyword = DEFAULT
        defaultPackage.name.en = DEFAULT
        packages.append(defaultPackage)
        packageByKeyword[DEFAULT] = defaultPackage
    for package in self.packages:
        if (package.keyword in packageKeywords):
            packages.append(package)
            packageByKeyword[package.keyword] = package
    for package in packages:
        package.fonts = []
    for font in self.fonts:
        if passedFilter(font):
            for keyword in font.getPackageKeywords():
                packageByKeyword[keyword].fonts.append(font)
    return packages
def getPackages(self, filterByFontPurpose=[]):
    packageKeywords = []
    packages = []
    packageByKeyword = {}

    def passedFilter(font):
        return ((not filterByFontPurpose) or (font.purpose in filterByFontPurpose))
    for font in self.fonts:
        if passedFilter(font):
            for keyword in font.getPackageKeywords():
                if (keyword not in packageKeywords):
                    packageKeywords.append(keyword)
    if (DEFAULT in packageKeywords):
        defaultPackage = FontPackage()
        defaultPackage.keyword = DEFAULT
        defaultPackage.name.en = DEFAULT
        packages.append(defaultPackage)
        packageByKeyword[DEFAULT] = defaultPackage
    for package in self.packages:
        if (package.keyword in packageKeywords):
            packages.append(package)
            packageByKeyword[package.keyword] = package
    for package in packages:
        package.fonts = []
    for font in self.fonts:
        if passedFilter(font):
            for keyword in font.getPackageKeywords():
                packageByKeyword[keyword].fonts.append(font)
    return packages