def main(argv): """Test vertical extents to make sure they stay within specified bounds.""" font_file_name = argv[1] if len(argv) > 2: language = argv[2] else: language = None if len(argv) > 4: ymin = int(argv[3]) ymax = int(argv[4]) else: font = font_caching.open_font(font_file_name) ymin = -font["OS/2"].usWinDescent ymax = font["OS/2"].usWinAscent if _is_noto_ui_font(font_file_name): ymin = max(ymin, -555) ymax = min(ymax, 2163) exceeding_lines = test_rendering_from_file(sys.stdin, font_file_name, ymin, ymax, language) for line_bounds, text_piece in exceeding_lines: print(text_piece.encode("UTF-8"), line_bounds)
def main(argv): """Test vertical extents to make sure they stay within specified bounds.""" if len(argv) <= 1: print( "test_vertical_extents.py font.ttf [language [ymin ymax]] < sample_text.[txt|xtb]" ) return font_file_name = argv[1] if len(argv) > 2: language = argv[2] else: language = None if len(argv) > 4: ymin = int(argv[3]) ymax = int(argv[4]) else: font = font_caching.open_font(font_file_name) ymin = -font["OS/2"].usWinDescent ymax = font["OS/2"].usWinAscent if _is_noto_ui_font(font_file_name): ymin = max(ymin, -555) ymax = min(ymax, 2163) exceeding_lines = test_rendering_from_file(sys.stdin, font_file_name, ymin, ymax, language) for line_bounds, text_piece in exceeding_lines: print(text_piece, line_bounds)
def get_glyph_vertical_extents(glyph_id, font_file_name): """Returns visible vertical extents given a glyph ID and font name.""" font = font_caching.open_font(font_file_name) glyf_set = font.getGlyphSet() glyph_name = font.getGlyphName(glyph_id) ttglyph = glyf_set[glyph_name] return get_glyph_cleaned_extents(ttglyph, glyf_set)