吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3163|回复: 40
上一主题 下一主题
收起左侧

[Windows] 字体名称编辑器 v1.00

  [复制链接]
跳转到指定楼层
楼主
百里吟风 发表于 2025-1-14 13:58 回帖奖励
有些字体安装后在软件上显示的名称与安装名称不一致,此工具用于规范字体名称。

只支持windows10及以上系统,只支持修改ttf格式中文字体的名称。


下载地址:https://wwqh.lanzn.com/ilmT22kw65ja



PixPin_2025-01-14_13-56-25.png (33.82 KB, 下载次数: 3)

PixPin_2025-01-14_13-56-25.png

免费评分

参与人数 11吾爱币 +9 热心值 +10 收起 理由
Dreamguykyle + 1 + 1 谢谢@Thanks!
hwh425 + 1 我很赞同!
lough_007 + 1 + 1 谢谢@Thanks!
yanglinman + 1 谢谢@Thanks!
王金彪 + 1 + 1 谢谢@Thanks!
weiwei321 + 1 + 1 我很赞同!
施施乐 + 1 + 1 工具是好工具,如果原字体名称自动读取就好了
freckle + 1 + 1 谢谢@Thanks!
daiguixu + 1 + 1 正好能用上
vitrel + 1 + 1 谢谢@Thanks!
wuloveyou + 1 我很赞同!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
施施乐 发表于 2025-1-14 18:07
工具是好工具,如果原字体名称自动读取就好了,选择字体支持拖入就更好了,希望后面可以更新
推荐
hebeijianke 发表于 2025-1-15 01:40
施施乐 发表于 2025-1-14 18:07
工具是好工具,如果原字体名称自动读取就好了,选择字体支持拖入就更好了,希望后面可以更新

[Python] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import tkinterdnd2 as dnd2
from tkinterdnd2 import DND_FILES
from tkinter import filedialog, messagebox, ttk, simpledialog, font as tkFont
from fontTools.ttLib import TTFont
import os
import tkinter as tk
 
 
def select_font_file():
    font_path = filedialog.askopenfilename(filetypes=[("TTF 字体文件", "*.ttf")])
    if font_path:
        update_entries(font_path=font_path)
        fetch_original_font_name(font_path)
 
 
def select_export_path():
    export_path = filedialog.askdirectory()
    if export_path:
        update_entries(export_path=export_path)
 
 
def modify_and_export_font():
    font_path = font_path_entry.get()
    new_name = new_name_entry.get().strip()
    export_path = export_path_entry.get() or os.getcwd()
    if not font_path:
        messagebox.showwarning("警告", "请选择一个字体文件。")
    elif not new_name:
        messagebox.showwarning("警告", "请输入新的字体名称。")
    else:
        try:
            with TTFont(font_path) as font:
                font['name'].setName(new_name, 1, 3, 1, 2052)
                font['name'].removeNames(nameID=[2, 4], platformID=3, platEncID=1, langID=2052)
                new_font_file_path = os.path.join(export_path, f"{os.path.splitext(os.path.basename(font_path))[0]}_new.ttf")
                font.save(new_font_file_path)
                messagebox.showinfo("成功", f"字体名称修改为[{new_name}],保存到:{new_font_file_path}")
                update_font_preview(new_font_file_path)
        except Exception as e:
            messagebox.showerror("错误", f"修改字体文件时出错:{str(e)}")
 
 
def fetch_original_font_name(font_path):
    try:
        with TTFont(font_path) as font:
            original_name = font['name'].getName(1, 3, 1, 2052)
            if original_name:
                update_entries(font_path=font_path, original_name=original_name.string.decode('utf-16-be'))
                update_font_preview(font_path)
            else:
                messagebox.showwarning("警告", "字体文件有问题。无法获取原名,您可以直接修改。")
    except Exception as e:
        messagebox.showerror("错误", f"读取字体文件时出错:{str(e)}")
 
 
def update_entries(font_path=None, original_name=None, export_path=None):
    if font_path:
        font_path_entry.config(state='normal')
        font_path_entry.delete(0, tk.END)
        font_path_entry.insert(0, font_path)
        font_path_entry.config(state='readonly')
    if original_name:
        original_name_entry.delete(0, tk.END)
        original_name_entry.insert(0, original_name)
    if export_path:
        export_path_entry.delete(0, tk.END)
        export_path_entry.insert(0, export_path)
 
 
def on_drop(event):
    file_path = event.data.strip('{}')
    if os.path.isfile(file_path) and file_path.lower().endswith('.ttf'):
        update_entries(font_path=file_path)
        fetch_original_font_name(file_path)
    else:
        messagebox.showwarning("警告", "请拖拽一个TTF字体文件。")
 
 
def center_window(window, width, height):
    x = (window.winfo_screenwidth() / 2) - (width / 2)
    y = (window.winfo_screenheight() / 2) - (height / 2)
    window.geometry('%dx%d+%d+%d' % (width, height, x, y))
 
 
def update_font_preview(font_path):
    try:
        font_preview_label.config(font=(os.path.splitext(os.path.basename(font_path))[0], 20))
    except Exception as e:
        messagebox.showerror("错误", f"加载字体文件时出错:{str(e)}")
 
 
win = dnd2.Tk()
win.title('TTF字体名称编辑器V1.00')
win.geometry('410x250')
center_window(win, 400, 200)
win.attributes('-topmost', True)
win.resizable(False, False)
win.drop_target_register(DND_FILES)
win.dnd_bind('<<Drop>>', on_drop)
font_path_frame = tk.Frame(win)
font_path_frame.pack(pady=2)
font_path_entry = ttk.Entry(font_path_frame, width=45, state='readonly')
font_path_entry.pack(side=tk.LEFT)
font_path_entry.config(state='normal')
font_path_entry.insert(0, "支持拖放操作")
font_path_entry.config(state='readonly')
ttk.Button(font_path_frame, text='选择字体', command=select_font_file).pack(side=tk.LEFT)
names_frame = tk.Frame(win)
names_frame.pack(pady=2)
original_name_frame = tk.Frame(names_frame)
original_name_frame.pack(side=tk.LEFT)
original_name_label = tk.Label(original_name_frame, text='原字体名称')
original_name_label.pack(side=tk.TOP)
original_name_entry = ttk.Entry(original_name_frame, width=26)
original_name_entry.pack(side=tk.TOP)
new_name_frame = tk.Frame(names_frame)
new_name_frame.pack(side=tk.RIGHT)
new_name_label = tk.Label(new_name_frame, text='新字体名称')
new_name_label.pack(side=tk.TOP)
new_name_entry = ttk.Entry(new_name_frame, width=26)
new_name_entry.pack(side=tk.TOP)
tk.Label(names_frame, text='&#11157;', font=('', 12, 'bold'), fg='blue').pack(side=tk.BOTTOM)
export_path_frame = tk.Frame(win)
export_path_frame.pack(pady=2)
export_path_entry = ttk.Entry(export_path_frame, width=45)
export_path_entry.pack(side=tk.LEFT)
export_path_entry.insert(0, os.getcwd())
ttk.Button(export_path_frame, text='导出路径', command=select_export_path).pack(side=tk.LEFT)
ttk.Button(win, text='修改并导出', command=modify_and_export_font).pack(pady=5)
font_preview_frame = tk.Frame(win)
font_preview_frame.pack(pady=5)
font_preview_label = ttk.Label(font_preview_frame, text="此行显示字体预览文本", font=('', 20, 'bold'), foreground='blue')
font_preview_label.pack()
 
win.mainloop()

以上代码支持拖拽ttf字体,并显示字体预览

沙发
Stive1233 发表于 2025-1-14 14:05
3#
linlin01 发表于 2025-1-14 14:06
好软件,很小很厉害
4#
李亲顾 发表于 2025-1-14 14:11
大神厉害,下载了
5#
kaixin15A 发表于 2025-1-14 14:16
谢谢分享,试试看看
6#
一抹斜阳0 发表于 2025-1-14 14:19
好东西
之前一直在找
7#
malaxiangguo 发表于 2025-1-14 14:23
好厉害,页面简洁,内存小,i了
8#
weilin2012 发表于 2025-1-14 14:24
不错,看看。。。
9#
xxa 发表于 2025-1-14 14:59
好的谢谢
10#
Amo52 发表于 2025-1-14 15:12
前一段时间正想改字体名称,现在倒是没这需求了,如果可以批量就更好了,感谢大佬分享。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-2 00:30

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表