Skip to content

Commit 06ac023

Browse files
committed
Add check/merge script
1 parent e76d6bf commit 06ac023

File tree

5 files changed

+859
-0
lines changed

5 files changed

+859
-0
lines changed

Taskfile.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://taskfile.dev
2+
3+
version: "3"
4+
5+
vars:
6+
GREETING: Hello, World! It provided by 'brew info go-task'
7+
8+
tasks:
9+
default:
10+
cmds:
11+
- echo "{{.GREETING}}"
12+
- task --list-all
13+
silent: true
14+
build-kr:
15+
cmds:
16+
- sh ./monoplex_kr_generator.sh
17+
- sh ./os2_patch.sh
18+
- mkdir -p ./build/MonoplexKR
19+
- mkdir -p ./build/MonoplexKRWide
20+
- mv -f ./MonoplexKRWide*.ttf ./build/MonoplexKRWide/
21+
- mv -f ./MonoplexKR*.ttf ./build/MonoplexKR/
22+
silent: true
23+
merge-kr:
24+
cmds:
25+
- fontforge --script ./check-glyphs.pe
26+
- fontforge --script ./merge-kr-into-jp.pe
27+
- ls -lt build
28+
silent: true
29+
clean:
30+
cmds:
31+
- rm -rf ./build
32+
silent: true

change-familyname.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import fontforge
4+
5+
def change_font_family_name(input_font, output_font, new_family_name):
6+
"""
7+
Change the font family name of a font file.
8+
9+
Args:
10+
input_font (str): Path to the input font file
11+
output_font (str): Path to save the modified font
12+
new_family_name (str): New family name for the font
13+
"""
14+
try:
15+
# Open the font
16+
font = fontforge.open(input_font)
17+
18+
# Get the current font information
19+
old_family_name = font.familyname
20+
print(f"Current font family name: {old_family_name}")
21+
22+
# Change the family name
23+
font.familyname = new_family_name
24+
25+
# Update related font names to maintain consistency
26+
if font.fontname:
27+
font.fontname = font.fontname.replace(old_family_name, new_family_name).replace(" ", "")
28+
29+
if font.fullname:
30+
font.fullname = font.fullname.replace(old_family_name, new_family_name)
31+
32+
# Update PostScript names if they exist
33+
for name_id in (1, 2, 3, 4, 6, 16, 17, 18, 20, 21, 22):
34+
try:
35+
if font.sfnt_names:
36+
for index, (lang, string_type, string_value) in enumerate(font.sfnt_names):
37+
if string_type == name_id:
38+
new_value = string_value.replace(old_family_name, new_family_name)
39+
font.sfnt_names = (font.sfnt_names[:index] +
40+
((lang, string_type, new_value),) +
41+
font.sfnt_names[index+1:])
42+
except:
43+
pass
44+
45+
# Save the modified font
46+
print(f"Saving font with new family name: {new_family_name}")
47+
font.generate(output_font)
48+
font.close()
49+
print(f"Font saved successfully to: {output_font}")
50+
51+
except Exception as e:
52+
print(f"Error: {e}")
53+
sys.exit(1)
54+
55+
if __name__ == "__main__":
56+
if len(sys.argv) != 4:
57+
print("Usage: python change_font_family.py <input_font> <output_font> <new_family_name>")
58+
sys.exit(1)
59+
60+
input_font = sys.argv[1]
61+
output_font = sys.argv[2]
62+
new_family_name = sys.argv[3]
63+
64+
change_font_family_name(input_font, output_font, new_family_name)

check-glyphs.pe

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Open the font file
2+
Open("build/PlemolJP35Console_NF/PlemolJP35ConsoleNF-Regular.ttf")
3+
# Open("MonoplexKRNerd-Regular.ttf")
4+
5+
# List of specific glyphs to check
6+
# "You’re unable to view this"
7+
# glyphs_to_check = ["’", "Right Single Quotation Mark", "C", "uniAC00", "uniAC01"] # Modify with your glyph names
8+
glyphs_to_check = ["U+00B0", "U+2019", "U+AC00", "uniAC01"] # Modify with your glyph names
9+
i = 0
10+
11+
# Loop through and check if glyph exists
12+
Print("Checking for specific glyphs: PlemolJP35ConsoleNF")
13+
while (i < SizeOf(glyphs_to_check))
14+
glyph = glyphs_to_check[i]
15+
16+
Select(glyph) # Select the glyph
17+
if (WorthOutputting()) # Check if glyph exists
18+
Print(glyph, " exists in the font.")
19+
else
20+
Print(glyph, " is missing.")
21+
endif
22+
23+
i = i + 1
24+
endloop
25+
26+
Close()
27+
28+
# Open the font file
29+
Open("build/MonoplexKRWide/MonoplexKRWide-Regular.ttf")
30+
31+
# List of specific glyphs to check
32+
# "You’re unable to view this"
33+
# glyphs_to_check = ["’", "Right Single Quotation Mark", "C", "uniAC00", "uniAC01"] # Modify with your glyph names
34+
glyphs_to_check = ["U+00B0", "U+2019", "U+AC00", "uniAC01"] # Modify with your glyph names
35+
i = 0
36+
37+
# Loop through and check if glyph exists
38+
Print("Checking for specific glyphs: MonoplexKRWide")
39+
while (i < SizeOf(glyphs_to_check))
40+
glyph = glyphs_to_check[i]
41+
42+
Select(glyph) # Select the glyph
43+
if (WorthOutputting()) # Check if glyph exists
44+
Print(glyph, " exists in the font.")
45+
else
46+
Print(glyph, " is missing.")
47+
endif
48+
49+
i = i + 1
50+
endloop
51+
52+
# Quit FontForge
53+
Quit()

0 commit comments

Comments
 (0)