Commit 814eb3a5 authored by gijs's avatar gijs
Browse files
parents 6e1350e5 0c2cd8e1
......@@ -4,3 +4,6 @@ meta-elastique.*
rsync.sh
glyphs.*
présentation-OSP
snapshots-archive
snapshots-generator/
Fonts/
import fontforge as ff
import lxml.etree as et
import glob
import os
from svg.path import parse_path
import psMat
import json
import urllib
import subprocess
from datetime import datetime
def getInfoPath(f, pattern):
file = open(f, "r")
elem = et.parse(file)
root = elem.getroot()
for child in root:
for child in root:
if child.tag == '{http://www.w3.org/2000/svg}path':
if child.attrib['style'].startswith(pattern):
dparse = parse_path(child.attrib['d'])
for point in dparse:
type = str(point)[0:4]
x = dparse[1].start.real
y = dparse[2].end.imag * -1
h = dparse[1].start.imag
w = dparse[1].end.real
return [x, y, w, h]
def removeCadra(g, pattern):
file = open(g, "r")
elem = et.parse(file)
root = elem.getroot()
for child in root:
if child.tag == '{http://www.w3.org/2000/svg}path':
if child.attrib['style'].startswith(pattern):
b = child
root.remove(b)
et.dump(root)
return et.tostring(root, encoding='utf8', method='xml').decode()
def buildFont():
# compositeChar = [192, 193, 194, 195, 196, 199, 200, 201, 202, 203, 204, 205, 206, 207, 210, 211, 212, 213, 214, 217, 218, 219, 220, 224, 225, 226, 227, 231, 232, 233, 234, 235, 236, 237, 238, 239, 242, 243, 244, 249, 250, 251, 252, 350, 351]
SVG_DIR = glob.glob('svg/*.svg')
font = ff.font()
for g in SVG_DIR:
print('\n---------------------------------------------------------\n')
print(g)
print('\n---------------------------------------------------------\n')
gkey = g.split("/")[-1].replace(".svg", "")
if gkey.isdigit() == True:
with open(g, 'rt') as gp:
treeLet = et.parse(gp)
rootLet = treeLet.getroot()
gwidth = rootLet.get('width')
gheight = rootLet.get('height')
gwidth = round(float(gwidth))
gclean = removeCadra(g, 'stroke:rgb(100.000000%,0.000000%,0.000000%);')
pos = getInfoPath(g, 'stroke:rgb(100.000000%,0.000000%,0.000000%);')
print(pos)
scaleValue = 1000 / pos[3]
f = open('svg/clean/'+gkey+'.svg', 'w')
f.write(str(gclean))
f.close()
# if outline == 'true':
# subprocess.call(['bash', 'lib/outline.sh', 'files/fonts/archive/temp/output-svg/' + gkey + '.svg'])
letter_char = font.createChar(int(gkey))
letter_char.importOutlines('svg/clean/' + gkey + '.svg')
letter_char.left_side_bearing = letter_char.right_side_bearing = 10
letter_char.removeOverlap()
letter_char.width = (gwidth * scaleValue)
# for letter_comp in compositeChar:
# glyphAcc = font.createChar(letter_comp)
# glyphAcc.build()
#
trs = psMat.translate(0, -70)
font.selection.all()
font.transform(trs)
font.correctDirection()
font.removeOverlap()
font.simplify()
font.round()
# font.ascent = ascent
# font.descent = descent
font.generate('temp.otf')
font.generate('temp.ufo')
# font.close()
subprocess.call(['fontforge', 'temp.otf'])
#
buildFont()
File added
@GDEF_Simple = [\o \S \Q \V \F \two \d \f \y \m \x \G \A \h \less \one \a \germandbls \O \B \e \W
\U \n \w \seven \E \g \eight \Z \P \s \L \z \at \R \D \i \K \three \b \J \nine \I \T \l
\question \j \p \N \X \Y \r \t \six \u \M \H \five \four \k \q \C ];
table GDEF {
GlyphClassDef @GDEF_Simple, , , ;
} GDEF;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>familyName</key>
<string>Untitled1</string>
<key>styleName</key>
<string>Regular</string>
<key>styleMapFamilyName</key>
<string>Untitled1</string>
<key>versionMajor</key>
<integer>1</integer>
<key>versionMinor</key>
<integer>0</integer>
<key>copyright</key>
<string>Copyright (c) 2020, antoine</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>ascender</key>
<integer>800</integer>
<key>descender</key>
<integer>-200</integer>
<key>italicAngle</key>
<real>0</real>
<key>note</key>
<string>2020-11-7: Created with FontForge (http://fontforge.org)</string>
<key>openTypeHeadCreated</key>
<string>2020/11/07 18:27:11</string>
<key>openTypeHheaAscender</key>
<integer>483</integer>
<key>openTypeHheaDescender</key>
<integer>-154</integer>
<key>openTypeHheaLineGap</key>
<integer>90</integer>
<key>openTypeNameVersion</key>
<string>Version 1.000</string>
<key>postscriptFontName</key>
<string>Untitled1</string>
<key>postscriptFullName</key>
<string>Untitled1</string>
<key>postscriptWeightName</key>
<string>Regular</string>
<key>postscriptUnderlineThickness</key>
<integer>50</integer>
<key>postscriptUnderlinePosition</key>
<integer>-100</integer>
<key>guidelines</key>
<array/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="A" format="2">
<advance width="500"/>
<unicode hex="0041"/>
<outline>
<contour>
<point x="300" y="172" type="line"/>
<point x="215" y="376" type="line"/>
<point x="131" y="172" type="line"/>
</contour>
<contour>
<point x="12" y="27" type="curve" smooth="yes"/>
<point x="191" y="455" type="line" smooth="yes"/>
<point x="195" y="465"/>
<point x="204" y="472"/>
<point x="215" y="472" type="curve" smooth="yes"/>
<point x="226" y="472"/>
<point x="236" y="465"/>
<point x="240" y="455" type="curve" smooth="yes"/>
<point x="300" y="312"/>
<point x="359" y="170"/>
<point x="419" y="27" type="curve" smooth="yes"/>
<point x="427" y="8"/>
<point x="412" y="-10"/>
<point x="394" y="-10" type="curve" smooth="yes"/>
<point x="383" y="-10"/>
<point x="373" y="-4"/>
<point x="369" y="6" type="curve" smooth="yes"/>
<point x="323" y="118" type="line"/>
<point x="108" y="118" type="line"/>
<point x="62" y="6" type="line" smooth="yes"/>
<point x="58" y="-4"/>
<point x="48" y="-10"/>
<point x="37" y="-10" type="curve" smooth="yes"/>
<point x="19" y="-10"/>
<point x="4" y="8"/>
</contour>
</outline>
<lib>
<dict>
<key>com.fontlab.hintData</key>
<dict>
<key>hhints</key>
<array>
<dict>
<key>position</key>
<integer>-10</integer>
<key>width</key>
<integer>21</integer>
</dict>
<dict>
<key>position</key>
<integer>118</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>452</integer>
<key>width</key>
<integer>20</integer>
</dict>
</array>
</dict>
</dict>
</lib>
</glyph>
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="B" format="2">
<advance width="428"/>
<unicode hex="0042"/>
<outline>
<contour>
<point x="180" y="472" type="line" smooth="yes"/>
<point x="257" y="472"/>
<point x="332" y="417"/>
<point x="332" y="332" type="curve" smooth="yes"/>
<point x="332" y="294"/>
<point x="316" y="260"/>
<point x="289" y="236" type="curve"/>
<point x="326" y="212"/>
<point x="349" y="171"/>
<point x="349" y="124" type="curve" smooth="yes"/>
<point x="349" y="50"/>
<point x="289" y="-10"/>
<point x="215" y="-10" type="curve" smooth="yes"/>
<point x="37" y="-10" type="line" smooth="yes"/>
<point x="22" y="-10"/>
<point x="10" y="2"/>
<point x="10" y="17" type="curve" smooth="yes"/>
<point x="10" y="445" type="line" smooth="yes"/>
<point x="10" y="460"/>
<point x="22" y="472"/>
<point x="37" y="472" type="curve" smooth="yes"/>
</contour>
<contour>
<point x="64" y="43" type="line"/>
<point x="215" y="43" type="line" smooth="yes"/>
<point x="259" y="43"/>
<point x="296" y="80"/>
<point x="296" y="124" type="curve" smooth="yes"/>
<point x="296" y="168"/>
<point x="259" y="204"/>
<point x="215" y="204" type="curve" smooth="yes"/>
<point x="64" y="204" type="line"/>
</contour>
<contour>
<point x="64" y="418" type="line"/>
<point x="64" y="258" type="line"/>
<point x="214" y="258" type="line"/>
<point x="252" y="263"/>
<point x="280" y="296"/>
<point x="278" y="336" type="curve" smooth="yes"/>
<point x="275" y="382"/>
<point x="233" y="418"/>
<point x="180" y="418" type="curve" smooth="yes"/>
</contour>
</outline>
<lib>
<dict>
<key>com.fontlab.hintData</key>
<dict>
<key>hhints</key>
<array>
<dict>
<key>position</key>
<integer>-10</integer>
<key>width</key>
<integer>53</integer>
</dict>
<dict>
<key>position</key>
<integer>204</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>418</integer>
<key>width</key>
<integer>54</integer>
</dict>
</array>
<key>vhints</key>
<array>
<dict>
<key>position</key>
<integer>10</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>278</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>296</integer>
<key>width</key>
<integer>53</integer>
</dict>
</array>
</dict>
</dict>
</lib>
</glyph>
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="C" format="2">
<advance width="464"/>
<unicode hex="0043"/>
<outline>
<contour>
<point x="299" y="383" type="line"/>
<point x="274" y="411"/>
<point x="238" y="429"/>
<point x="197" y="429" type="curve" smooth="yes"/>
<point x="156" y="429"/>
<point x="121" y="411"/>
<point x="96" y="383" type="curve"/>
</contour>
<contour>
<point x="299" y="79" type="curve"/>
<point x="96" y="79" type="line"/>
<point x="121" y="51"/>
<point x="156" y="33"/>
<point x="197" y="33" type="curve" smooth="yes"/>
<point x="243" y="33"/>
<point x="276" y="52"/>
</contour>
<contour>
<point x="365" y="79" type="curve" smooth="yes"/>
<point x="363" y="79" type="line"/>
<point x="332" y="20"/>
<point x="269" y="-21"/>
<point x="197" y="-21" type="curve" smooth="yes"/>
<point x="123" y="-21"/>
<point x="60" y="21"/>
<point x="29" y="83" type="curve"/>
<point x="22" y="88"/>
<point x="17" y="97"/>
<point x="17" y="106" type="curve" smooth="yes"/>
<point x="17" y="108"/>
<point x="17" y="110"/>
<point x="18" y="112" type="curve" smooth="yes"/>
<point x="13" y="129"/>
<point x="10" y="148"/>
<point x="10" y="167" type="curve" smooth="yes"/>
<point x="10" y="295" type="line" smooth="yes"/>
<point x="10" y="314"/>
<point x="13" y="332"/>
<point x="18" y="349" type="curve" smooth="yes"/>
<point x="17" y="351"/>
<point x="17" y="354"/>
<point x="17" y="356" type="curve" smooth="yes"/>
<point x="17" y="365"/>
<point x="22" y="373"/>
<point x="29" y="378" type="curve"/>
<point x="60" y="440"/>
<point x="123" y="483"/>
<point x="197" y="483" type="curve" smooth="yes"/>
<point x="269" y="483"/>
<point x="332" y="442"/>
<point x="363" y="383" type="curve"/>
<point x="365" y="383" type="line" smooth="yes"/>
<point x="380" y="383"/>
<point x="392" y="371"/>
<point x="392" y="356" type="curve" smooth="yes"/>
<point x="392" y="347"/>
<point x="388" y="339"/>
<point x="381" y="334" type="curve"/>
<point x="384" y="321"/>
<point x="385" y="308"/>
<point x="385" y="295" type="curve" smooth="yes"/>
<point x="385" y="280"/>
<point x="373" y="268"/>
<point x="358" y="268" type="curve" smooth="yes"/>
<point x="343" y="268"/>
<point x="331" y="280"/>
<point x="331" y="295" type="curve" smooth="yes"/>
<point x="331" y="307"/>
<point x="330" y="318"/>
<point x="327" y="329" type="curve"/>
<point x="68" y="329" type="line"/>
<point x="65" y="318"/>
<point x="64" y="307"/>
<point x="64" y="295" type="curve" smooth="yes"/>
<point x="64" y="167" type="line" smooth="yes"/>
<point x="64" y="155"/>
<point x="65" y="144"/>
<point x="68" y="133" type="curve"/>
<point x="327" y="133" type="line"/>
<point x="330" y="144"/>
<point x="331" y="155"/>
<point x="331" y="167" type="curve" smooth="yes"/>
<point x="331" y="182"/>
<point x="343" y="193"/>
<point x="358" y="193" type="curve" smooth="yes"/>
<point x="373" y="193"/>
<point x="385" y="182"/>
<point x="385" y="167" type="curve" smooth="yes"/>
<point x="385" y="154"/>
<point x="384" y="141"/>
<point x="381" y="128" type="curve"/>
<point x="388" y="123"/>
<point x="392" y="115"/>
<point x="392" y="106" type="curve" smooth="yes"/>
<point x="392" y="91"/>
<point x="380" y="79"/>
</contour>
</outline>
<lib>
<dict>
<key>com.fontlab.hintData</key>
<dict>
<key>hhints</key>
<array>
<dict>
<key>position</key>
<integer>-21</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>79</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>329</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>429</integer>
<key>width</key>
<integer>54</integer>
</dict>
</array>
<key>vhints</key>
<array>
<dict>
<key>position</key>
<integer>10</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>331</integer>
<key>width</key>
<integer>54</integer>
</dict>
</array>
</dict>
</dict>
</lib>
</glyph>
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="D" format="2">
<advance width="428"/>
<unicode hex="0044"/>
<outline>
<contour>
<point x="37" y="-10" type="line" smooth="yes"/>
<point x="22" y="-10"/>
<point x="10" y="2"/>
<point x="10" y="17" type="curve" smooth="yes"/>
<point x="10" y="445" type="line" smooth="yes"/>
<point x="10" y="460"/>
<point x="22" y="472"/>
<point x="37" y="472" type="curve" smooth="yes"/>
<point x="144" y="472" type="line" smooth="yes"/>
<point x="257" y="472"/>
<point x="349" y="380"/>
<point x="349" y="267" type="curve" smooth="yes"/>
<point x="349" y="195" type="line" smooth="yes"/>
<point x="349" y="82"/>
<point x="257" y="-10"/>
<point x="144" y="-10" type="curve" smooth="yes"/>
</contour>
<contour>
<point x="64" y="418" type="line"/>
<point x="64" y="43" type="line"/>
<point x="144" y="43" type="line" smooth="yes"/>
<point x="228" y="43"/>
<point x="296" y="111"/>
<point x="296" y="195" type="curve" smooth="yes"/>
<point x="296" y="267" type="line" smooth="yes"/>
<point x="296" y="351"/>
<point x="228" y="418"/>
<point x="144" y="418" type="curve" smooth="yes"/>
</contour>
</outline>
<lib>
<dict>
<key>com.fontlab.hintData</key>
<dict>
<key>hhints</key>
<array>
<dict>
<key>position</key>
<integer>-10</integer>
<key>width</key>
<integer>53</integer>
</dict>
<dict>
<key>position</key>
<integer>418</integer>
<key>width</key>
<integer>54</integer>
</dict>
</array>
<key>vhints</key>
<array>
<dict>
<key>position</key>
<integer>10</integer>
<key>width</key>
<integer>54</integer>
</dict>
<dict>
<key>position</key>
<integer>296</integer>
<key>width</key>
<integer>53</integer>
</dict>
</array>
</dict>
</dict>
</lib>
</glyph>
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="E" format="2">
<advance width="428"/>
<unicode hex="0045"/>
<outline>
<contour>
<point x="10" y="17" type="curve" smooth="yes"/>
<point x="10" y="445" type="line" smooth="yes"/>
<point x="10" y="460"/>
<point x="22" y="472"/>
<point x="37" y="472" type="curve" smooth="yes"/>
<point x="322" y="472" type="line" smooth="yes"/>
<point x="337" y="472"/>
<point x="349" y="460"/>
<point x="349" y="445" type="curve" smooth="yes"/>
<point x="349" y="430"/>
<point x="337" y="418"/>
<point x="322" y="418" type="curve" smooth="yes"/>
<point x="64" y="418" type="line"/>
<point x="64" y="258" type="line"/>
<point x="251" y="258" type="line" smooth="yes"/>
<point x="266" y="258"/>
<point x="278" y="246"/>
<point x="278" y="231" type="curve" smooth="yes"/>
<point x="278" y="216"/>
<point x="266" y="204"/>
<point x="251" y="204" type="curve" smooth="yes"/>
<point x="64" y="204" type="line"/>