如何使用文本列表生成svg文件?

发布于 2025-01-11 20:07:59 字数 123 浏览 0 评论 0原文

我在inkscape中制作了一个svg。这是平假名文本。 有没有办法从平假名文本列表中批量导出 svg 文件? 这可能是 46 个平假名 svg 文件。

id="tspan849">あ

I made a svg in inkscape. It's a Hiragana text.
Is there a way to batch export svg files from a list of Hiragana text?
That can be 46 Hiragana svg files.

id="tspan849">あ</tspan></text>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有木有妳兜一样 2025-01-18 20:07:59

我写了一个 py 脚本来完成任务
希望这个py脚本可以帮助到有需要的人。

#Check if the output folder is missing,it will create a new one, if output folder is not found.
import os
path = 'output'
if not os.path.isdir(path):
    os.mkdir(path)
#Create a List.
ListFileName='HiraganaList.txt'
with open(ListFileName, mode="r", encoding="utf-8") as f:
    #Read the contents of the file into a list.
    lines=f.readlines()   
#Read the sample file.
SampleFileName='Hiragana_01.svg'
with open(SampleFileName, mode="r", encoding="utf-8") as s:
    #Read the sample file contents into a list.
    sLines=s.readlines()
    #Output directory and named variables.
    OutFileFolder='Output'
    OutPixFileName='Hiragana_'
#Specifies the string to find.
sTokenString='あ'
iNum=1
#Cycle through List from first line to end line.
for line in lines:
    #Declares an output list.
    OutputContext=[]
    #Numbering
    sNum='0' + str(iNum)
    #Output file name + path
    OutFileName=OutFileFolder + '\\'+OutPixFileName+sNum[-2:]+'.svg'
    #Save a new file.
    with open(OutFileName, mode="w", encoding="utf-8") as w:
    #Cycle through sample contents
        for sLine in sLines:    
            #Determine whether it is consistent with sTokenString
            if sLine.find(sTokenString)>0:
                print('old->'+sLine)
                #Replaced by a new string
                sNew=sLine.replace(sTokenString,line.replace('\n',''))
                print('New->'+sNew)
                #write in to list
                OutputContext.append(sNew)          
            else:
                OutputContext.append(sLine)
        print(line)
        w.writelines(OutputContext)
    iNum+=1

I have write a py script to accomplish the task
Wish this py script can help people who need it.

#Check if the output folder is missing,it will create a new one, if output folder is not found.
import os
path = 'output'
if not os.path.isdir(path):
    os.mkdir(path)
#Create a List.
ListFileName='HiraganaList.txt'
with open(ListFileName, mode="r", encoding="utf-8") as f:
    #Read the contents of the file into a list.
    lines=f.readlines()   
#Read the sample file.
SampleFileName='Hiragana_01.svg'
with open(SampleFileName, mode="r", encoding="utf-8") as s:
    #Read the sample file contents into a list.
    sLines=s.readlines()
    #Output directory and named variables.
    OutFileFolder='Output'
    OutPixFileName='Hiragana_'
#Specifies the string to find.
sTokenString='あ'
iNum=1
#Cycle through List from first line to end line.
for line in lines:
    #Declares an output list.
    OutputContext=[]
    #Numbering
    sNum='0' + str(iNum)
    #Output file name + path
    OutFileName=OutFileFolder + '\\'+OutPixFileName+sNum[-2:]+'.svg'
    #Save a new file.
    with open(OutFileName, mode="w", encoding="utf-8") as w:
    #Cycle through sample contents
        for sLine in sLines:    
            #Determine whether it is consistent with sTokenString
            if sLine.find(sTokenString)>0:
                print('old->'+sLine)
                #Replaced by a new string
                sNew=sLine.replace(sTokenString,line.replace('\n',''))
                print('New->'+sNew)
                #write in to list
                OutputContext.append(sNew)          
            else:
                OutputContext.append(sLine)
        print(line)
        w.writelines(OutputContext)
    iNum+=1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文