KanjiVGを使ってフォントを作る

2024年12月19日

KanjiVG

KanjiVG is copyright © 2009-2024 Ulrich Apel. It is released under the Creative Commons Attribution-Share Alike 3.0 license.

The Kanji Vector Graphics (KanjiVG) project – KanjiVG

フォント

このフォントは次のデータを元に作られています

KanjiVG is copyright c 2009-2024 Ulrich Apel. It is released under the Creative Commons Attribution-Share Alike 3.0 license.
(https://kanjivg.tagaini.net/)
(https://creativecommons.org/licenses/by-sa/3.0/)
Copyright eightban

marker

markerを使って先端の形を変更できます


set para=gcd_despeckle 20,10

call "D:\WinPython\scripts\env_for_icons.bat"

::goto:e

md y:\input_svg
md y:\output_svg
md y:\input_png
md y:\output_png
@echo off
set zipFile="D:\data2\kanjivg-20240807-main.zip"
set destFolder="Y:\data2\kanjivg-extracted"

if not exist %destFolder% (
    powershell -Command "Expand-Archive -Path %zipFile% -DestinationPath %destFolder%"
    echo ZIPファイルの解凍が完了しました。
) else (
    echo フォルダ %destFolder% はすでに存在します。
)

setlocal enabledelayedexpansion

set srcFolder="Y:\data2\kanjivg-extracted\kanji"
set destFolder="y:\output_svg"

if not exist %destFolder% (
    mkdir %destFolder%
)

for %%f in (%srcFolder%\*.svg) do (
    set "filename=%%~nxf"
    set "basename=%%~nf"
    if "!basename:~0,1!"=="0" (
        set "newbasename=!basename:~1!"
    ) else (
        set "newbasename=!basename!"
    )
    set "newfilename=0x!newbasename!%%~xf"
    copy /y  "%%f" "%destFolder%\!newfilename!"
)
set name=heart


del /q y:\output_png\*.svg

for %%f in (%destFolder%\*.svg) do (
echo %%~nf
rem 
"C:\app\busybox\sed.exe" -e "s/stroke-width:3;stroke-linecap:round;stroke-linejoin:round/stroke-width:4;stroke-linecap:round;stroke-linejoin:round/g" -e "s/height=\"[0-9]\+\"/height=\"200\"/g"  -e "s/width=\"[0-9]\+\"/width=\"200\"/g"  "%%f" > y:\output_png\%%~nf.svg 
rem pwsh -command "Get-Content y:\output_svg\%%~nf.svg| %%{ $_ -replace '""109','""1000'} | %%{ $_ -replace 'stroke-width:3;stroke-linecap:round;stroke-linejoin:round','stroke-width:1;stroke-linecap:round;stroke-linejoin:round'}  | %%{ $_ -replace '',''}  | Out-File y:\output_png\%%~nf.svg " 
rem 
"C:\app\busybox\sed.exe"  -e "1,/path / s/path /path style=\""marker-start:url(#%name%);marker-mid:;marker-end:\"" /"  y:\output_png\%%~nf.svg  > y:\output_png\%%~nfk.svg 
rem "C:\app\busybox\sed.exe" -e "s/path /path style=\""marker-start:url(#%name%);marker-mid:url(#%name%);marker-end:url(#%name%)\"" /g" y:\output_png\%%~nf.svg  > y:\output_png\%%~nfk.svg 
rem "C:\app\busybox\sed.exe" -e "s/path /path style=\""marker-start:url(#%name%);marker-mid:;marker-end:url(#%name%)\"" /g" y:\output_png\%%~nf.svg  > y:\output_png\%%~nfk.svg 
findstr /v "text transform" y:\output_png\%%~nfk.svg >y:\output_png\%%~nfm.svg 
rem pwsh -command "(Get-Content -Path 'y:\output_png\%%~nfm.svg')[0..((Get-Content -Path 'y:\output_png\%%~nfm.svg').Length - 2)] | Set-Content -Path 'y:\output_png\%%~nfp.svg'" 
rem 
"C:\app\busybox\sed.exe"  -e "$d" y:\output_png\%%~nfm.svg >y:\output_png\%%~nfp.svg 
type "D:\data2\eightban-Font-KanjiVG\marker.txt" >>y:\output_png\%%~nfp.svg 
copy /y y:\output_png\%%~nfp.svg y:\output_svg\%%~nf.svg

::
del /q y:\output_png\*.svg
)
:e

echo ファイルのコピーが完了しました。
for /r y:\output_svg %%f in (*.svg) do (
echo %%~nf
rem 
cairosvg  -o  y:/output_svg/%%~nf.png y:/output_svg/%%~nf.svg
rem  rsvg-convert  -f png  -o  y:/output_svg/%%~nf.png y:/output_svg/%%~nf.svg
rem "D:\app2\inkscape\bin\inkscape" --export-type=png %%f
)
:: 
move /y y:\output_svg\*.png y:\output_png

for /r y:\output_svg %%f in (*.png) do (
D:\app2\gmic\gmic.exe -input   %%f  -%para%  -output  y:\output_png\%%~nf%%~xf
)


::del /q y:\output_svg\*.png

for /r y:\output_png %%f in (*.png) do (
"C:\app\ImageMagick\convert.exe"  "%%f" -strip -flatten -resize x1000   y:\input_png\%%~nf.bmp
"C:\app\potrace\potrace.exe" y:\input_png\%%~nf.bmp -o y:\input_png\%%~nf.svg --svg --flat --opttolerance 0.8 --alphamax 1.4 --blacklevel 0.5
rem 

scour -i y:\input_png\%%~nf.svg  -o y:\input_svg\%%~nf.svg
del y:\input_png\%%~nf.svg
del y:\input_png\%%~nf.bmp
)

::"D:\WinPython\python-3.10.11.amd64\python.exe" "D:\WinPython\notebooks\hex0.py"
"D:\app2\FontForgePortable\App\FontForge\bin\ffpython.exe" "D:\WinPython\notebooks\svgs2ttf\svgs2ttf3cc.py" 

timeout /t 55&goto:eof

DEF

<?xml version="1.0" encoding="UTF-8" standalone="no"?>



  <defs
     id="defs3">

    <marker
       style="overflow:visible"
       id="marker"
       refX="0"
       refY="0"
       orient="auto"
       markerWidth="0.001"
       markerHeight="0.001"
       viewBox="0 0 1 1"
       preserveAspectRatio="xMidYMid">
      <path
         transform="scale(0.5)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:none"
         d="M 5,0 C 5,2.76 2.76,5 0,5 -2.76,5 -5,2.76 -5,0 c 0,-2.76 2.3,-5 5,-5 2.76,0 5,2.24 5,5 z"
         id="path10" />
    </marker>

</svg>

svg要素の基本的な使い方まとめ

Favorite SVG Shape Generator

font

Posted by eightban