version = sys.argv[4]

	isOldstyle = region == 'OSF'
	
	if isOldstyle:
		region2 = 'Oldstyle'
	else:
		region2 = 'Classic' if region == 'CL' else region

	with open("noto/{}/NotoRounded{}-Condensed{}.otd".format('osf' if isOldstyle else 'rounded', 'OSF' if isOldstyle else '', weight), 'rb') as baseFile:
		baseFont = json.loads(baseFile.read().decode('UTF-8', errors='replace'))

	with open("rhr/ResourceHanRounded{}-{}.otd".format(region, weight), 'rb') as asianFile:
		asianFont = json.loads(asianFile.read().decode('UTF-8', errors = 'replace'))

	with open("noto/emoji/NotoEmoji-Regular.otd", 'rb') as emojiFile:
		emojiFont = json.loads(emojiFile.read().decode('UTF-8', errors = 'replace'))

	baseFont['OS_2']['ulCodePageRange1'][encoding] = True
	NameFont(baseFont, region2, weight, version)

	ApplyPalt(asianFont)
	MergeBelow(baseFont, asianFont)
	for _, glyph in emojiFont['glyf'].items():
		Transform(glyph, 1000 / 2048, 0, 0, 1000 / 2048, 0, 0)
	MergeBelow(baseFont, emojiFont)

	outStr = json.dumps(baseFont, ensure_ascii=False)
	with open("nowar/{}-NowarCompactRoundedUI-{}-{}.otd".format(encoding, region, weight), 'w') as outFile:
		outFile.write(outStr)
		# pre-apply `palt` in UI family
		if "UI" in param.family:
			ApplyPalt(asianFont)

		# pseudo-SC, remap characters
		if param.pseudosc:
			cmap = asianFont['cmap']

			for trad, simp in OpenCC_T2S.items():
				usimp = str(ord(simp))
				if usimp in cmap:
					utrad = str(ord(trad))
					cmap[utrad] = cmap[usimp]

		MergeBelow(baseFont, asianFont)

		# use CJK middle dots, quotes, em-dash and ellipsis in non-UI family
		if "UI" not in param.family:
			for u in [
				0x00B7, # MIDDLE DOT
				0x2014, # EM DASH
				0x2018, # LEFT SINGLE QUOTATION MARK
				0x2019, # RIGHT SINGLE QUOTATION MARK
				0x201C, # LEFT DOUBLE QUOTATION MARK
				0x201D, # RIGHT DOUBLE QUOTATION MARK
				0x2026, # HORIZONTAL ELLIPSIS
				0x2027, # HYPHENATION POINT
			]:
				if str(u) in asianFont['cmap']:
					baseFont['glyf'][baseFont['cmap'][str(u)]] = asianFont['glyf'][asianFont['cmap'][str(u)]]