8000 Allow builder to change version and add gftools version · googlefonts/gftools@12821a8 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 12821a8

Browse files
simoncozensm4rc1e
authored andcommitted
Allow builder to change version and add gftools version
Fixes #394 Fixes #380
1 parent 850757c commit 12821a8

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed

Lib/gftools/builder/__init__.py

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- wght
1616
outputDir: "../fonts"
1717
familyName: Texturina
18+
version: 1.005
1819
stat:
1920
- name: Width
2021
tag: wdth
@@ -111,6 +112,7 @@
111112
from fontTools.otlLib.builder import buildStatTable
112113
from fontTools.ttLib import TTFont, newTable
113114
from fontTools.ttLib.woff2 import main as woff2_main
115+
from fontv.libfv import FontVersion
114116
from gftools.builder.schema import schema
115117
from gftools.builder.autohint import autohint
116118
from gftools.fix import fix_font
@@ -125,6 +127,7 @@
125127
from vttLib.transfer import merge_from_file as merge_vtt_hinting
126128
from vttLib import compile_instructions as compile_vtt_hinting
127129
import difflib
130+
import gftools
128131
import glyphsLib
129132
from defcon import Font
130133
import argparse
@@ -301,6 +304,8 @@ def fill_config_defaults(self):
301304
self.config["fvarInstanceAxisDflts"] = None
302305
if "flattenComponents" not in self.config:
303306
self.config["flattenComponents"] = True
307+
if "addGftoolsVersion" not in self.config:
308+
self.config["addGftoolsVersion"] = True
304309
if "decomposeTransformedComponents" not in self.config:
305310
self.config["decomposeTransformedComponents"] = True
306311

@@ -512,6 +517,7 @@ def mkdir(self, directory, clean=False):
512517

513518
def post_process(self, filename):
514519
self.logger.info("Postprocessing font %s" % filename)
520+
self.set_version(filename)
515521
font = TTFont(filename)
516522
fix_font(
517523
font,
@@ -530,6 +536,17 @@ def post_process_ttf(self, filename):
530536
woff2_main(["compress", filename])
531537
self.move_webfont(filename)
532538

539+
def set_version(self, filename):
540+
if "version" not in self.config and not self.config["addGftoolsVersion"]:
541+
return
542+
fv = FontVersion(filename)
543+
if "version" in self.config:
544+
fv.set_version_number(self.config["version"])
545+
if self.config["addGftoolsVersion"]:
546+
fv.version_string_parts.append(f"gftools[{gftools.__version__}]")
547+
fv.write_version_string()
548+
549+
533550
def build_vtt(self, font_dir):
534551
for font, vtt_source in self.config['vttSources'].items():
535552
if font not in os.listdir(font_dir):

Lib/gftools/builder/schema.py

+2
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,7 @@
8484
Optional("reverseOutlineDirection"): Bool(),
8585
Optional("removeOutlineOverlaps"): Bool(),
8686
Optional("expandFeaturesToInstances"): Bool(),
87+
Optional("version"): Str(),
88+
Optional("addGftoolsVersion"): Bool(),
8789
}
8890
)

requirements.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
fonttools[ufo]
2+
#google-apputils
3+
axisregistry>=0.3.1
4+
absl-py
5+
protobuf==3.19.4
6+
PyGithub
7+
vttLib
8+
statmake
9+
PyYAML
10+
babelfont
11+
ttfautohint-py
12+
fontmake
13+
brotli
14+
browserstack-local==1.2.2
15+
pybrowserstack-screenshots==0.1
16+
gflanguages>=0.4.0
17+
glyphslib
18+
glyphsets>=0.2.1
19+
opentype-sanitizer
20+
pygit2
21+
requests
22+
strictyaml
23+
tabulate
24+
unidecode
25+
skia-pathops
26+
jinja2
27+
hyperglot
28+
fontFeatures>=1.6.2
29+
vharfbuzz
30+
bumpfontversion
31+
nanoemoji>=0.15.0
32+
font-v

setup.py

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# coding: utf-8
2+
# Copyright 2013 The Font Bakery Authors.
3+
# Copyright 2017 The Google Fonts Tools Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
18+
import os
19+
from setuptools import setup
20+
21+
def gftools_scripts():
22+
scripts = [os.path.join('bin', f) for f in os.listdir('bin') if f.startswith('gftools-')]
23+
scripts.append(os.path.join('bin', 'gftools'))
24+
return scripts
25+
26+
# Read the contents of the README file
27+
with open('README.md') as f:
28+
long_description = f.read()
29+
30+
setup(
31+
name="gftools",
32+
use_scm_version={"write_to": "Lib/gftools/_version.py"},
33+
url='https://github.com/googlefonts/tools/',
34+
description='Google Fonts Tools is a set of command-line tools'
35+
' for testing font projects',
36+
long_description=long_description,
37+
long_description_content_type='text/markdown', # This is important!
38+
author=('Google Fonts Tools Authors: '
39+
'Dave Crossland, '
40+
'Felipe Sanches, '
41+
'Lasse Fister, '
42+
'Marc Foley, '
43+
'Eli Heuer, '
44+
'Roderick Sheeter'),
45+
author_email='dave@lab6.com',
46+
package_dir={'': 'Lib'},
47+
packages=['gftools',
48+
'gftools.actions',
49+
'gftools.util',
50+
'gftools.builder'],
51+
package_data={'gftools.util': ["GlyphsInfo/*.xml", "UnicodeSections/*.json"],
52+
'gftools': [
53+
'template.upstream.yaml',
54+
"udhr_all.txt",
55+
"templates/*.html",
56+
"push-templates/*.html"
57+
]
58+
},
59+
scripts=gftools_scripts(),
60+
zip_safe=False,
61+
classifiers=[
62+
'Environment :: Console',
63+
'Intended Audience :: Developers',
64+
'Topic :: Text Processing :: Fonts',
65+
'License :: OSI Approved :: Apache Software License',
66+
'Operating System :: OS Independent',
67+
'Programming Language :: Python :: 2',
68+
'Programming Language :: Python :: 3'
69+
],
70+
python_requires=">=3.7",
71+
setup_requires=['setuptools_scm>=4,<6.1'],
72+
# Dependencies needed for gftools qa.
73+
extras_require={"qa": ['fontbakery', 'fontdiffenator', 'gfdiffbrowsers']},
74+
install_requires=[
75+
# 'fontforge', # needed by build-font2ttf script
76+
# but there's no fontforge package on pypi
77+
# see: https://github.com/fontforge/fontforge/issues/2048
78+
'setuptools',
79+
'FontTools[ufo]',
80+
'axisregistry>=0.3.1', # API update removed fallback names pre-processing
81+
'absl-py',
82+
'glyphsLib',
83+
'gflanguages>=0.4.0',
84+
'glyphsets>=0.2.1',
85+
'PyGithub',
86+
'pillow',
87+
'protobuf==3.19.4',
88+
'requests',
89+
'tabulate',
90+
'unidecode',
91+
'opentype-sanitizer',
92+
'vttlib',
93+
'pygit2',
94+
'strictyaml',
95+
'fontmake>=3.3.0',
96+
'skia-pathops',
97+
'statmake',
98+
'PyYAML',
99+
'babelfont',
100+
'ttfautohint-py',
101+
'brotli',
102+
'browserstack-local==1.2.2',
103+
'pybrowserstack-screenshots==0.1',
104+
'jinja2',
105+
'hyperglot',
106+
'fontFeatures',
107+
'vharfbuzz',
108+
'bumpfontversion',
109+
'nanoemoji>=0.15.0',
110+
'font-v',
111+
]
112+
)

0 commit comments

Comments
 (0)
0