Last active
December 5, 2020 23:07
-
-
Save shuymn/46a2ffc4b17cf25ac9a8ce55c1fc79e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fontforge | |
import argparse | |
KATAKANA_LOWER_BOUND = 0x30A0 | |
KATAKANA_UPPER_BOUND = 0x30FF | |
def remove_katakana_glyphs(input: str, output: str): | |
font = fontforge.open(input) | |
for glyph in font.glyphs(): | |
point: int = glyph.unicode | |
if KATAKANA_LOWER_BOUND <= point <= KATAKANA_UPPER_BOUND: | |
font.removeGlyph(glyph) | |
font.fontname += '-Without-Katakana' | |
font.fullname += ' Without Katakana' | |
font.generate(output) | |
font.close() | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('input', nargs=1, help='path to input font file') | |
parser.add_argument('output', nargs=1, help='path to output font file') | |
args = parser.parse_args() | |
input_file_path = args.input[0] | |
output_file_path = args.output[0] | |
remove_katakana_glyphs(input_file_path, output_file_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage