Beispiel #1
0
 def __init__(self, old_family, embedded_families, parent=None):
     self.old_family = old_family
     self.local_families = {icu_lower(f) for f in font_scanner.find_font_families()} | {
         icu_lower(f) for f in embedded_families}
     Dialog.__init__(self, _('Change font'), 'change-font-family', parent=parent)
     self.setMinimumWidth(300)
     self.resize(self.sizeHint())
 def __init__(self, old_family, embedded_families, parent=None):
     self.old_family = old_family
     self.local_families = {icu_lower(f) for f in font_scanner.find_font_families()} | {
         icu_lower(f) for f in embedded_families}
     Dialog.__init__(self, _('Change font'), 'change-font-family', parent=parent)
     self.setMinimumWidth(300)
     self.resize(self.sizeHint())
Beispiel #3
0
def all():
    from calibre.utils.fonts.scanner import font_scanner
    failed = []
    unsupported = []
    warnings = {}
    total = 0
    averages = []
    for family in font_scanner.find_font_families():
        for font in font_scanner.fonts_for_family(family):
            raw = font_scanner.get_font_data(font)
            print('Subsetting', font['full_name'], end='\t')
            total += 1
            try:
                w = []
                sf, old_stats, new_stats = subset(raw, set(('a', 'b', 'c')),
                                                  (), w)
                if w:
                    warnings[font['full_name'] + ' (%s)' % font['path']] = w
            except NoGlyphs:
                print('No glyphs!')
                continue
            except UnsupportedFont as e:
                unsupported.append(
                    (font['full_name'], font['path'], unicode_type(e)))
                print('Unsupported!')
                continue
            except Exception as e:
                print('Failed!')
                failed.append(
                    (font['full_name'], font['path'], unicode_type(e)))
            else:
                averages.append(
                    sum(itervalues(new_stats)) / sum(itervalues(old_stats)) *
                    100)
                print('Reduced to:', '%.1f' % averages[-1], '%')
    if unsupported:
        print('\n\nUnsupported:')
        for name, path, err in unsupported:
            print(name, path, err)
            print()
    if warnings:
        print('\n\nWarnings:')
    for name, w in iteritems(warnings):
        if w:
            print(name)
            print('', '\n\t'.join(w), sep='\t')
    if failed:
        print('\n\nFailures:')
        for name, path, err in failed:
            print(name, path, err)
            print()

    print('Average reduction to: %.1f%%' % (sum(averages) / len(averages)))
    print('Total:', total, 'Unsupported:', len(unsupported), 'Failed:',
          len(failed), 'Warnings:', len(warnings))
Beispiel #4
0
def all():
    from calibre.utils.fonts.scanner import font_scanner
    failed = []
    unsupported = []
    warnings = {}
    total = 0
    averages = []
    for family in font_scanner.find_font_families():
        for font in font_scanner.fonts_for_family(family):
            raw = font_scanner.get_font_data(font)
            print ('Subsetting', font['full_name'], end='\t')
            total += 1
            try:
                w = []
                sf, old_stats, new_stats = subset(raw, set(('a', 'b', 'c')),
                        (), w)
                if w:
                    warnings[font['full_name'] + ' (%s)'%font['path']] = w
            except NoGlyphs:
                print('No glyphs!')
                continue
            except UnsupportedFont as e:
                unsupported.append((font['full_name'], font['path'], unicode(e)))
                print ('Unsupported!')
                continue
            except Exception as e:
                print ('Failed!')
                failed.append((font['full_name'], font['path'], unicode(e)))
            else:
                averages.append(sum(new_stats.itervalues())/sum(old_stats.itervalues())
                        * 100)
                print ('Reduced to:', '%.1f'%averages[-1] , '%')
    if unsupported:
        print ('\n\nUnsupported:')
        for name, path, err in unsupported:
            print (name, path, err)
            print()
    if warnings:
        print ('\n\nWarnings:')
    for name, w in warnings.iteritems():
        if w:
            print (name)
            print('', '\n\t'.join(w), sep='\t')
    if failed:
        print ('\n\nFailures:')
        for name, path, err in failed:
            print (name, path, err)
            print()

    print ('Average reduction to: %.1f%%'%( sum(averages)/len(averages)))
    print('Total:', total, 'Unsupported:', len(unsupported), 'Failed:',
            len(failed), 'Warnings:', len(warnings))