(font_in, font_out, unicodes, opts)
| 57 | |
| 58 | |
| 59 | def subset_font_raw(font_in, font_out, unicodes, opts): |
| 60 | if '--namelist' in opts: |
| 61 | # 2010-12-06 DC To allow setting namelist filenames, |
| 62 | # change getopt.gnu_getopt from namelist to namelist= |
| 63 | # and invert comments on following 2 lines |
| 64 | # name_fn = opts['--namelist'] |
| 65 | name_fn = f'{font_out}.name' |
| 66 | name = open(name_fn, 'w') |
| 67 | else: |
| 68 | name = None |
| 69 | if '--script' in opts: |
| 70 | pe_fn = "/tmp/script.pe" |
| 71 | pe = open(pe_fn, 'w') |
| 72 | else: |
| 73 | pe = None |
| 74 | font = fontforge.open(font_in) |
| 75 | if pe: |
| 76 | print(f'Open("{font_in}")', file=pe) |
| 77 | extract_vert_to_script(font_in, pe) |
| 78 | for i in unicodes: |
| 79 | select_with_refs(font, i, font, pe, name) |
| 80 | |
| 81 | addl_glyphs = [] |
| 82 | if '--nmr' in opts: |
| 83 | addl_glyphs.append('nonmarkingreturn') |
| 84 | if '--null' in opts: |
| 85 | addl_glyphs.append('.null') |
| 86 | if '--nd' in opts: |
| 87 | addl_glyphs.append('.notdef') |
| 88 | for glyph in addl_glyphs: |
| 89 | font.selection.select(('more',), glyph) |
| 90 | if name: |
| 91 | print(f"0x{fontforge.unicodeFromName(glyph):0.4X}", glyph, |
| 92 | file=name) |
| 93 | if pe: |
| 94 | print(f'SelectMore("{glyph}")', file=pe) |
| 95 | |
| 96 | flags = () |
| 97 | |
| 98 | if '--opentype-features' in opts: |
| 99 | flags += ('opentype',) |
| 100 | |
| 101 | if '--simplify' in opts: |
| 102 | font.simplify() |
| 103 | font.round() |
| 104 | flags += ('omit-instructions',) |
| 105 | |
| 106 | if '--strip_names' in opts: |
| 107 | font.sfnt_names = () |
| 108 | |
| 109 | if '--new' in opts: |
| 110 | font.copy() |
| 111 | new = fontforge.font() |
| 112 | new.encoding = font.encoding |
| 113 | new.em = font.em |
| 114 | new.layers['Fore'].is_quadratic = font.layers['Fore'].is_quadratic |
| 115 | for i in unicodes: |
| 116 | select_with_refs(font, i, new, pe, name) |
no test coverage detected
searching dependent graphs…