Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new --license-allows-edit parameter to open protected font files #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The font weight will be inherited from the original file; the font name will be

`ligatures.py` supports some additional command line options to (e.g.) change which font ligatures are copied from or enable copying of individual character glyphs; run `fontforge -lang=py ligaturize.py --help` to list them.

Pass `--license-allows-edit` if the font file is protected and you own a license that allows you to edit it.

## Misc. ##
### Credit ###
This script was originally written by [IlyaSkriblovsky](https://github.com/IlyaSkriblovsky) for adding ligatures to DejaVuSans Mono ([dv-code-font](https://github.com/IlyaSkriblovsky/dv-code-font)). [Navid Rojiani](https://github.com/rojiani) made a few changes to generalize the script so that it works for any font. [ToxicFrog](https://github.com/ToxicFrog) has made a large number of contributions.
Expand Down
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
ligaturize_font(
input_file, ligature_font_file=None, output_dir=OUTPUT_DIR,
prefix=LIGATURIZED_FONT_NAME_PREFIX, output_name=None,
copy_character_glyphs=COPY_CHARACTER_GLYPHS,
license_allows_edit=False, copy_character_glyphs=COPY_CHARACTER_GLYPHS,
scale_character_glyphs_threshold=SCALE_CHARACTER_GLYPHS_THRESHOLD)

for pattern,name in renamed_fonts.items():
Expand All @@ -118,6 +118,6 @@
for input_file in files:
ligaturize_font(
input_file, ligature_font_file=None, output_dir=OUTPUT_DIR,
prefix=None, output_name=name,
prefix=None, output_name=name, license_allows_edit=False,
copy_character_glyphs=COPY_CHARACTER_GLYPHS,
scale_character_glyphs_threshold=SCALE_CHARACTER_GLYPHS_THRESHOLD)
9 changes: 7 additions & 2 deletions ligaturize.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ def update_font_metadata(font, new_name):
replace_sfnt(font, 'WWS Family', new_name)

def ligaturize_font(input_font_file, output_dir, ligature_font_file,
output_name, prefix, **kwargs):
font = fontforge.open(input_font_file)
output_name, prefix, license_allows_edit, **kwargs):
fontforge_open_flags = 1 if license_allows_edit else 0 # 1 = fstypepermitted
font = fontforge.open(input_font_file, fontforge_open_flags)

if not ligature_font_file:
ligature_font_file = get_ligature_source(font.fontname)
Expand Down Expand Up @@ -327,6 +328,10 @@ def parse_args():
parser.add_argument("--output-name",
type=str, default="",
help="Name of the generated font. Completely replaces the original.")
parser.add_argument("--license-allows-edit",
default=False, action="store_true",
help="The user has the appropriate license to examine the font no matter"
"what the fstype setting is.")
return parser.parse_args()

def main():
Expand Down