Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Packaging fonts in configuration profiles for installing on iOS
# coding: utf-8
import re
import hashlib
import sys
from base64 import b64encode
from random import choice
items = ['8', '9', 'a', 'b']
names = sys.argv
assert len(names) > 1
def replace(m):
return "-".join([,, '5' +, choice(items) +,])
for name in names[1:]:
with open(name, "rb") as f:
font_data =
sha1_font_data = hashlib.sha1(font_data).hexdigest()
UUID = replace("([a-f0-9]{8})([a-f0-9]{4})([a-f0-9]{3})([a-f0-9]{3})([a-f0-9]{12})", sha1_font_data))
encoded_font_data = b64encode(font_data)
xml = f"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>{ UUID }</string>
<string>geniuscqy.font-{ UUID }</string>
<string>{ name }</string>
<string>Font Profile</string>
<string>Make the font available to iOS applications.</string>
<string>{ UUID }</string>
<data>{ encoded_font_data.decode() }</data>
with open(name+".mobileconfig", "w", encoding="utf-8") as f:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment