コード例 #1
0
ファイル: gftools-qa.py プロジェクト: graphicore/gftools
 def browser_previews(self, **kwargs):
     """Use GFR and diffbrowsers to take screenshots of how the fonts
     will look on different browsers. A Browserstack account is
     required."""
     logger.info("Running browser previews")
     if not self._bstack_auth:
         logger.info("Skipping. No Browserstack credentials. "
                     "See https://github.com/googlefonts/"
                     "diffbrowsers#installation on how to add them.")
         return
     out = os.path.join(self.out, "browser_previews")
     mkdir(out)
     browsers_to_test = test_browsers["vf_browsers"]
     font_groups = self.chunkify(
         list([i['filename'] for i in self.instances.values()]), 4)
     name_groups = self.chunkify(list(self.instances.keys()), 4)
     for name_group, font_group in zip(name_groups, font_groups):
         name = "_".join(sorted(name_group))
         diff_browsers = DiffBrowsers(
             auth=self._bstack_auth,
             gfr_instance_url=FontQA.GFR_URL,
             dst_dir=os.path.join(out, name),
             browsers=browsers_to_test,
             gfr_is_local=False,
         )
         diff_browsers.new_session(font_group, font_group)
         diff_browsers.diff_view("waterfall", styles=name_group)
         diff_browsers.diff_view("glyphs_all", styles=name_group, pt=15)
コード例 #2
0
ファイル: test_gf_vf.py プロジェクト: bghryct/Gelasio
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--fonts', nargs="+", required=True)
    parser.add_argument('-u',
                        '--gfr-url',
                        default=GF_PRODUCTION_URL,
                        help="Url to GFR instance")
    parser.add_argument('-l',
                        '--gfr-local',
                        action="store_true",
                        default=False)
    parser.add_argument('-o',
                        '--output-dir',
                        help="Directory for output images",
                        required=True)
    args = parser.parse_args()

    browsers_to_test = test_browsers['vf_browsers']
    if not os.path.isdir(args.output_dir):
        os.mkdir(args.output_dir)

    diffbrowsers = DiffBrowsers(gfr_instance_url=args.gfr_url,
                                gfr_is_local=args.gfr_local,
                                dst_dir=args.output_dir,
                                browsers=browsers_to_test)

    diffbrowsers.new_session("from-googlefonts", args.fonts)
    logger.info("Generating waterfall diff")
    diffbrowsers.diff_view("waterfall")
    for pt_size in [13, 14, 15, 16]:
        logger.info("Generating images for glyphs_all at {}".format(pt_size))
        diffbrowsers.diff_view("glyphs_all", pt=pt_size)
    logger.info("Images saved to {}".format(args.output_dir))
コード例 #3
0
ファイル: gftools-qa.py プロジェクト: graphicore/gftools
 def diffbrowsers(self, **kwargs):
     """Test fonts on GFR regression and take screenshots using
     diffbrowsers. A browserstack account is required."""
     logger.info("Running Diffbrowsers")
     if not self._bstack_auth:
         logger.info("Skipping. No Browserstack credentials. "
                     "See https://github.com/googlefonts/"
                     "diffbrowsers#installation on how to add them.")
         return
     dst = os.path.join(self.out, "Diffbrowsers")
     mkdir(dst)
     browsers_to_test = test_browsers["vf_browsers"]
     fonts = [(k, self.instances_before[k]['filename'],
               self.instances[k]['filename'])
              for k in self.matching_instances]
     font_groups = self.chunkify(sorted(fonts), 4)
     for group in font_groups:
         styles = [i[0] for i in group]
         dir_name = "_".join(styles)
         fonts_before = [i[1] for i in group]
         fonts_after = [i[2] for i in group]
         out = os.path.join(dst, dir_name)
         diff_browsers = DiffBrowsers(
             auth=self._bstack_auth,
             gfr_instance_url=self.GFR_URL,
             dst_dir=out,
             browsers=browsers_to_test,
         )
         diff_browsers.new_session(set(fonts_before), set(fonts_after))
         diff_browsers.diff_view("waterfall", styles=styles)
         info = os.path.join(out, "info.json")
         json.dump(diff_browsers.stats, open(info, "w"))
         diff_browsers.diff_view("glyphs_all", pt=16, styles=styles)
コード例 #4
0
ファイル: qa.py プロジェクト: m4rc1e/gf-dispatcher
    def diffbrowsers_new_family(self):
        fonts_to_test = self._select_fonts_for_diffbrowsers()
        diffbrowsers = DiffBrowsers(self.bstack_auth, self.path)
        diffbrowsers.new_session(
            fonts_to_test,
            fonts_to_test,
        )
        self.gfr_url = 'http://www.gf-regression.com/compare/' + diffbrowsers.gf_regression.uuid
        diffbrowsers.diff_view('waterfall', gen_gifs=True)

        diffbrowsers.update_browsers(test_browsers['osx_browser'])
        diffbrowsers.diff_view('glyphs-all', 26, gen_gifs=True)
        self._get_images()
        self.diffbrowsers_report = cli_reporter(diffbrowsers.stats)
コード例 #5
0
ファイル: qa.py プロジェクト: m4rc1e/gf-dispatcher
    def diffbrowsers_new_family(self):
        fonts_to_test = self._select_fonts_for_diffbrowsers()
        diffbrowsers = DiffBrowsers(self.bstack_auth, self.path)
        diffbrowsers.new_session(fonts_to_test, fonts_to_test,)
        self.gfr_url = 'http://www.gf-regression.com/compare/' + diffbrowsers.gf_regression.uuid
        diffbrowsers.diff_view('waterfall', gen_gifs=True)

        diffbrowsers.update_browsers(test_browsers['osx_browser'])
        diffbrowsers.diff_view('glyphs-all', 26, gen_gifs=True)
        self._get_images()
        self.diffbrowsers_report = cli_reporter(diffbrowsers.stats)
コード例 #6
0
ファイル: __main__.py プロジェクト: bghryct/Gelasio
def main():
    parent_parser = argparse.ArgumentParser(add_help=False)
    parent_parser.add_argument('-u', '--gfr-url', default=GF_PRODUCTION_URL,
                               help="Url to GFR instance")
    parent_parser.add_argument('-l', '--gfr-local', action="store_true", default=False,
                               help="Enable this if GFR is being run locally.")
    parent_parser.add_argument('-o', '--output-dir', help="Directory for output images",
                            required=True)
    parent_parser.add_argument('-pt', '--type-point-size',
                            help="In some views, users can control type sample size")
    parent_parser.add_argument('-b', '--browsers',
                        choices=list(test_browsers.keys()),
                        default='all_browsers',
                        help="Which set of browsers to test on")
    parent_parser.add_argument('-v', '--view', choices=VIEWS, default='waterfall')
    parent_parser.add_argument('-gif', '--output-gifs', action='store_true', default=True,
                        help="Output before and after gifs")

    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers(dest='command')

    upload_parser = subparsers.add_parser('new', parents=[parent_parser])
    upload_parser.add_argument('fonts_after', nargs="+", help="Fonts after paths")
    before_group = upload_parser.add_argument_group(title="Fonts before input")
    before_input_group = before_group.add_mutually_exclusive_group(required=True)
    before_input_group.add_argument('-fb', '--fonts-before', nargs="+",
                                  help="Fonts before paths")
    before_input_group.add_argument('-gf', '--from-googlefonts', action='store_true',
                               help="Diff against GoogleFonts instead of fonts_before")

    load_parser = subparsers.add_parser('load', parents=[parent_parser])
    load_parser.add_argument("url")

    args = parser.parse_args()

    browsers_to_test = test_browsers[args.browsers]

    diffbrowsers = DiffBrowsers(gfr_instance_url=args.gfr_url,
                                gfr_is_local=args.gfr_local,
                                dst_dir=args.output_dir,
                                browsers=browsers_to_test)

    if args.command == 'new':
        fonts_before = 'from-googlefonts' if args.from_googlefonts \
                       else args.fonts_before
        diffbrowsers.new_session(fonts_before, args.fonts_after)
    elif args.command == 'load':
        diffbrowsers.load_session(args.url)

    diffbrowsers.diff_view(args.view, args.type_point_size, args.output_gifs)

    report_path = os.path.join(args.output_dir, 'report.txt')
    with open(report_path, 'w') as doc:
        report = cli_reporter(diffbrowsers.stats)
        doc.write(report)
        print(report)
コード例 #7
0
ファイル: test_gf_autohint.py プロジェクト: bghryct/Gelasio
def main():
    parser = argparse.ArgumentParser(description=__doc__)

    parser.add_argument('fonts_after', nargs="+", help="Fonts after paths")
    before_group = parser.add_argument_group(title="Fonts before input")
    before_input_group = before_group.add_mutually_exclusive_group(
        required=True)
    before_input_group.add_argument('-fb',
                                    '--fonts-before',
                                    nargs="+",
                                    help="Fonts before paths")
    before_input_group.add_argument(
        '-gf',
        '--from-googlefonts',
        action='store_true',
        help="Diff against GoogleFonts instead of fonts_before")
    parser.add_argument('-o',
                        '--output-dir',
                        help="Directory for output images",
                        required=True)

    args = parser.parse_args()
    auth = load_browserstack_credentials()

    browsers_to_test = test_browsers['all_browsers']

    fonts_before = 'from-googlefonts' if args.from_googlefonts \
                    else args.fonts_before

    diffbrowsers = DiffBrowsers(dst_dir=args.output_dir,
                                browsers=browsers_to_test)
    diffbrowsers.new_session(fonts_before, args.fonts_after)

    diffbrowsers.diff_view('waterfall', gen_gifs=True)
    logger.info("Sleeping for 10 secs. Giving Browserstack api a rest")
    time.sleep(10)

    diffbrowsers.update_browsers(test_browsers['osx_browser'])
    diffbrowsers.diff_view('glyphs-modified', gen_gifs=True)

    report = cli_reporter(diffbrowsers.stats)
    report_path = os.path.join(args.output_dir, 'report.txt')
    with open(report_path, 'w') as doc:
        doc.write(report)

    print(report)
コード例 #8
0
def run_browser_previews(font_path, out, auth, gfr_url):
    browsers_to_test = test_browsers["vf_browsers"]
    font_name = os.path.basename(font_path)[:-4]
    diff_browsers = DiffBrowsers(auth=auth,
                                 gfr_instance_url=gfr_url,
                                 dst_dir=os.path.join(out, font_name),
                                 browsers=browsers_to_test,
                                 gfr_is_local=False)
    diff_browsers.new_session([font_path], [font_path])
    diff_browsers.diff_view("waterfall")
    diff_browsers.diff_view("glyphs_all", pt=15)
コード例 #9
0
def main(font_before, font_after, out_dir):
    """Due to the fonts containing so many glyphs, style on style
    comparisons are needed."""
    auth = load_browserstack_credentials()
    logger.info('Comparing %s' % os.path.basename(font_before))
    fullname = font_before[:-4]
    font_dir = os.path.join(out_dir, fullname)
    diffbrowsers = DiffBrowsers(auth, font_dir,
                              [font_after],
                              [font_before],
                              test_browsers['all_browsers'])

    diffbrowsers.diff_view('waterfall', gen_gifs=True)
    logger.info('Resting Browserstack screenshot api')
    time.sleep(10)
    
    # Generate glyph plots for Material Design sp sizes
    for n in [11, 12, 13, 14, 16, 15, 20, 24, 34, 45, 56, 112]:
        diffbrowsers.diff_view('glyphs-all', pt=n, gen_gifs=True)
        logger.info('Resting Browserstack screenshot api')
        time.sleep(10)

    report = cli_reporter(diffbrowsers.report)
    report_path = os.path.join(font_dir, 'report.txt')
    with open(report_path, 'w') as doc:
        doc.write(report)
コード例 #10
0
def run_browser_diffs(font_before, font_after, out, auth, gfr_url):
    browsers_to_test = test_browsers["vf_browsers"]
    diff_browsers = DiffBrowsers(auth=auth,
                                 gfr_instance_url=gfr_url,
                                 dst_dir=out,
                                 browsers=browsers_to_test,
                                 gfr_is_local=False)
    diff_browsers.new_session([font_before], [font_after])
    diff_browsers.diff_view("waterfall")
    has_vfs = any([
        'fvar' in TTFont(font_before).keys(), 'fvar'
        in TTFont(font_after).keys()
    ])
    info = os.path.join(out, "info.json")
    json.dump(diff_browsers.stats, open(info, "w"))
    if has_vfs:
        for i in range(15, 17):
            diff_browsers.diff_view("glyphs_all", pt=i)
コード例 #11
0
ファイル: viz_diffenator.py プロジェクト: bghryct/Gelasio
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('fonts_after', nargs="+", help="Fonts after paths")
    before_group = parser.add_argument_group(title="Fonts before input")
    before_input_group = before_group.add_mutually_exclusive_group(
        required=True)
    before_input_group.add_argument('-fb',
                                    '--fonts-before',
                                    nargs="+",
                                    help="Fonts before paths")
    before_input_group.add_argument(
        '-gf',
        '--from-googlefonts',
        action='store_true',
        help="Diff against GoogleFonts instead of fonts_before")

    parser.add_argument('-u',
                        '--gfr-url',
                        default=GF_PRODUCTION_URL,
                        help="Url to GFR instance")
    parser.add_argument('-l',
                        '--gfr-local',
                        action="store_true",
                        default=False)
    parser.add_argument('-o',
                        '--output-dir',
                        help="Directory for output images",
                        required=True)
    args = parser.parse_args()

    browsers_to_test = test_browsers['safari_latest']

    diffbrowsers = DiffBrowsers(gfr_instance_url=args.gfr_url,
                                gfr_is_local=args.gfr_local,
                                dst_dir=args.output_dir,
                                browsers=browsers_to_test)

    fonts_before = 'from-googlefonts' if args.from_googlefonts \
                    else args.fonts_before

    diffbrowsers.new_session(fonts_before, args.fonts_after)

    views_to_diff = diffbrowsers.gf_regression.info['diffs']
    logger.info("Following diffs have been found [%s]. Genning images." %
                ', '.join(views_to_diff))
    for view in views_to_diff:
        logger.info("Generating images for {}".format(view))
        if view not in VIEWS:
            logger.info("Skipping view {}".format(view))
        else:
            diffbrowsers.diff_view(view, pt=32)

    logger.info("Images saved to {}".format(args.output_dir))
コード例 #12
0
ファイル: gftools-qa.py プロジェクト: vdedyukhin/gftools
 def diffbrowsers(self, **kwargs):
     """Test fonts on GFR regression and take screenshots using
     diffbrowsers. A browserstack account is required."""
     logger.info("Running Diffbrowsers")
     if not self._bstack_auth:
         logger.info("Skipping. No Browserstack credentials. "
                 "See https://github.com/googlefonts/"
                 "diffbrowsers#installation on how to add them.")
         return
     dst = os.path.join(self._out, "Diffbrowsers")
     mkdir(dst)
     browsers_to_test = test_browsers["vf_browsers"]
     fonts = sorted(
         [v for k, v in self._instances.items() if k in self._shared_instances]
     )
     fonts_before = sorted(
         [
             v
             for k, v in self._instances_before.items()
             if k in self._shared_instances
         ]
     )
     fonts_before_groups = self.chunkify(fonts_before, 4)
     fonts_groups = self.chunkify(fonts, 4)
     name_groups = self.chunkify(sorted([k for k in self._shared_instances]), 4)
     for name_group, before, after in zip(name_groups, fonts_before_groups, fonts_groups):
         name = "_".join(name_group)
         out = os.path.join(dst, name)
         diff_browsers = DiffBrowsers(
             auth=self._bstack_auth,
             gfr_instance_url=self.GFR_URL,
             dst_dir=out,
             browsers=browsers_to_test,
         )
         diff_browsers.new_session(set(before), set(after))
         diff_browsers.diff_view("waterfall")
         info = os.path.join(out, "info.json")
         json.dump(diff_browsers.stats, open(info, "w"))
         diff_browsers.diff_view("glyphs_all", pt=16)
コード例 #13
0
ファイル: qa.py プロジェクト: m4rc1e/gf-dispatcher
    def diffbrowsers_family_update(self, fonts_before='from-googlefonts'):
        """Compare and regression test the fonts on different browsers.

        If the family contains more than 3 weights, select the thinnest,
        heaviest and median styles. Proofing more than 3 styles leads to
        huge images. The median style will likely pick up any multiple
        master compatibility issues."""
        fonts_to_test = self._select_fonts_for_diffbrowsers()
        diffbrowsers = DiffBrowsers(self.bstack_auth, self.path)
        diffbrowsers.new_session(fonts_before, fonts_to_test)
        self.gfr_url = 'http://www.gf-regression.com/compare/' + diffbrowsers.gf_regression.uuid

        diffbrowsers.diff_view('waterfall', gen_gifs=True)
        diffbrowsers.update_browsers(test_browsers['osx_browser'])
        diffbrowsers.diff_view('glyphs-modified', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-missing', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-new', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-all', 26, gen_gifs=True)
        self._get_images()
        self.diffbrowsers_report = cli_reporter(diffbrowsers.stats)
コード例 #14
0
ファイル: qa.py プロジェクト: m4rc1e/gf-dispatcher
    def diffbrowsers_family_update(self, fonts_before='from-googlefonts'):
        """Compare and regression test the fonts on different browsers.

        If the family contains more than 3 weights, select the thinnest,
        heaviest and median styles. Proofing more than 3 styles leads to
        huge images. The median style will likely pick up any multiple
        master compatibility issues."""
        fonts_to_test = self._select_fonts_for_diffbrowsers()
        diffbrowsers = DiffBrowsers(self.bstack_auth, self.path)
        diffbrowsers.new_session(fonts_before, fonts_to_test)
        self.gfr_url = 'http://www.gf-regression.com/compare/' + diffbrowsers.gf_regression.uuid

        diffbrowsers.diff_view('waterfall', gen_gifs=True)
        diffbrowsers.update_browsers(test_browsers['osx_browser'])
        diffbrowsers.diff_view('glyphs-modified', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-missing', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-new', gen_gifs=True)
        diffbrowsers.diff_view('glyphs-all', 26, gen_gifs=True)
        self._get_images()
        self.diffbrowsers_report = cli_reporter(diffbrowsers.stats)