pax_global_header00006660000000000000000000000064150665104140014514gustar00rootroot0000000000000052 comment=39cc80d40b046765a46f77771430622d6e11d179 notobuilder-39cc80d40b046765a46f77771430622d6e11d179/000077500000000000000000000000001506651041400204105ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/.github/000077500000000000000000000000001506651041400217505ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/.github/workflows/000077500000000000000000000000001506651041400240055ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/.github/workflows/build.yaml000066400000000000000000000314401506651041400257720ustar00rootroot00000000000000name: Build, QA, release on: workflow_call: secrets: USER_GITHUB_TOKEN: description: "A github token representing the Google Fonts onboarder's account" required: false SSH_KEY: description: "An SSH key for the Google Fonts onboarder" required: false env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: build-all: runs-on: ubuntu-latest name: Build main TTFs steps: - uses: actions/checkout@v4 - name: Set up latest harfbuzz uses: notofonts/install-harfbuzz-action@main - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Do first-run script if necessary run: make .init.stamp if: github.repository != 'notofonts/noto-project-template' - uses: stefanzweifel/git-auto-commit-action@v5 name: First-run setup if: github.repository != 'notofonts/noto-project-template' with: file_pattern: .init.stamp README.md requirements.txt OFL.txt commit_message: "Personalize for this repo" - name: Build fonts run: make build - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: fontbuild path: fonts fontspector-googlefonts: name: Check with fontspector runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Set up Fontspector uses: fonttools/setup-fontspector@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Make directories run: mkdir -p out/fontspector out/badges continue-on-error: true - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Check with fontspector run: | . venv/bin/activate ; python3 -m notoqa continue-on-error: true - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: fontspector-googlefonts path: out proof: name: Create proof documents runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Make proof run: | . venv/bin/activate; mkdir -p out/ out/proof; for i in fonts/* ; do family=`basename $i`; diffenator2 proof $(find fonts/$family/unhinted/ttf -type f) -o out/proof/$family; done - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: proof path: out regression: name: Regression test runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Set up diffenator3 uses: notofonts/install-diffenator3-action@main - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Regression test run: . venv/bin/activate; python3 -m notoqa.regression env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: regression path: out report: name: Rebuild website if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: - fontspector-googlefonts - proof - regression steps: - uses: actions/checkout@v4 - name: Download font zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Download fontspector-googlefonts zip uses: actions/download-artifact@v4 with: name: fontspector-googlefonts path: out - name: Download proof zip uses: actions/download-artifact@v4 with: name: proof path: out continue-on-error: true - name: Download regression test zip uses: actions/download-artifact@v4 with: name: regression path: out continue-on-error: true - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Rebuild website run: . venv/bin/activate; python3 -m notobuilder.ghpages - name: Copy fonts to gh-pages dir run: cp -r fonts out - name: Deploy uses: actions/upload-pages-artifact@v3.0.1 if: ${{ github.ref == 'refs/heads/main' }} with: path: ./out - name: gen zip file name id: zip-name shell: bash # Set the archive name to repo name + "-assets" e.g "MavenPro-assets" run: echo "ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-fonts" >> $GITHUB_ENV - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: ${{ env.ZIP_NAME }} path: out deploy: name: Deploy website to GitHub Pages needs: report runs-on: ubuntu-latest permissions: pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 create_release: if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') needs: - build-all runs-on: ubuntu-latest name: Create release outputs: url: ${{ steps.upload.outputs.browser_download_url }} config_file: ${{ steps.check_tag.outputs.config_file }} family: ${{ steps.check_tag.outputs.family }} steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - run: pip3 install 'git+https://github.com/googlefonts/gftools' - name: Download font zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Check for appropriate tag id: check_tag run: . venv/bin/activate; python3 scripts/check-tag.py ${{ github.ref_name }} - name: Set release body from tag run: | echo 'RELEASE_NOTES<> "$GITHUB_ENV" git show -s --format=%B ${{ github.ref_name }} | tail -n +4 >> "$GITHUB_ENV" echo 'EOF' >> "$GITHUB_ENV" - name: Create release id: release uses: actions/create-release@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref_name }} release_name: ${{ github.ref_name }} body: ${{ env.RELEASE_NOTES }} - name: Tell user about release run: | echo '::warning file=sources/config.yaml,title=A new release ${{ github.ref_name }} has been created' git show -s --format=%B ${{ github.ref_name }} | tail -n +4 echo "$RELEASE_NOTES" - name: Find a DESCRIPTION.en_us.html run: cp documentation/${{ steps.check_tag.outputs.family}}.html fonts/DESCRIPTION.en_us.html continue-on-error: true - name: Find an ARTICLE.en_us.html run: cp documentation/${{ steps.check_tag.outputs.family}}.article.html fonts/ARTICLE.en_us.html continue-on-error: true - name: Create release bundle run: cd fonts; cp ../*.txt . ; zip -x requirements.txt -r ../${{ github.ref_name }}.zip ${{ steps.check_tag.outputs.family}}/ *.txt DESCRIPTION.en_us.html ARTICLE.en_us.html - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 id: upload with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ github.ref_name }}.zip asset_name: ${{ github.ref_name }}.zip tag: ${{ github.ref_name }} overwrite: true body: ${{ env.RELEASE_NOTES }} google_fonts_pr: runs-on: ubuntu-latest environment: googlefonts name: Submit PR to Google Fonts needs: create_release steps: - name: Check SSH_KEY is set run: | if [[ "${{ secrets.SSH_KEY }}" == "" ]]; then echo "::error file=sources/config.yaml,title=SSH_KEY was not set in repository secrets::Generate an SSH key (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key), add the public key to your GitHub account (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) and add the private key to an environment secret called SSH_KEY in an environment called 'googlefonts' by going to $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/settings/secrets/actions"; exit 1 fi - name: Check USER_GITHUB_TOKEN is set run: | if [[ "${{ secrets.USER_GITHUB_TOKEN }}" == "" ]]; then echo "::error file=sources/config.yaml,title=USER_GITHUB_TOKEN was not set in repository secrets::Generate a personal access token with a repo scope by visiting https://github.com/settings/tokens/new and add it to an environment secret called USER_GITHUB_TOKEN in an environment called 'googlefonts' by going to $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/settings/secrets/actions"; exit 1 fi - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - run: pip3 install 'git+https://github.com/googlefonts/gftools#egg=gftools' - uses: actions/checkout@v4 name: Check out Google Fonts repository with: fetch-depth: 0 repository: google/fonts path: "googlefonts" ssh-key: ${{ secrets.SSH_KEY }} - name: Set git username and email run: | git config --global user.email "${GH_USERNAME}@users.noreply.github.com" git config --global user.name "${GH_USERNAME}" env: GH_USERNAME: ${{ github.actor }} - name: Do SSH magic run: cd googlefonts; git remote add googlefonts git@github.com:google/fonts.git ; cd .. - name: Test fetch run: cd googlefonts; git fetch googlefonts main ; cd .. - name: Run the packager run: gftools-packager `echo ${{needs.create_release.outputs.family}} | tr 'A-Z' 'a-z'` googlefonts --latest-release -p --show-tracebacks env: GH_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }} notobuilder-39cc80d40b046765a46f77771430622d6e11d179/LICENSE000066400000000000000000000261351506651041400214240ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/000077500000000000000000000000001506651041400211165ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/000077500000000000000000000000001506651041400234445ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/__init__.py000066400000000000000000000000001506651041400255430ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/__main__.py000066400000000000000000000030061506651041400255350ustar00rootroot00000000000000import subprocess from os import chdir import os from pathlib import Path import yaml import sys from gftools.builder import GFBuilder, BASE_SCHEMA # These days I'm just gftools-builder in a funny hat. def main(args=None): import argparse parser = argparse.ArgumentParser() parser.add_argument( "--graph", help="Draw a graph of the build process", action="store_true" ) parser.add_argument("--no-ninja", help="Do not run ninja", action="store_true") parser.add_argument("--no-static", help="Do not build statics", action="store_true") parser.add_argument( "--generate", help="Just generate and output recipe from recipe builder", action="store_true", ) parser.add_argument("config", help="Path to config file") args = parser.parse_args(args) with open(args.config, "r") as file: config = yaml.safe_load(file.read()) chdir(Path(args.config).resolve().parent) config["recipeProvider"] = "noto" if args.no_static: config["buildStatic"] = False # Only build OTFs if it's a release if "refs/tags" not in os.environ.get("GITHUB_REF", ""): config["buildOTF"] = False pd = GFBuilder(config) if args.generate: print(yaml.dump(pd.config)) return pd.config_to_objects() pd.build_graph() pd.walk_graph() if args.graph: pd.draw_graph() if not args.no_ninja: result = subprocess.run(["ninja"]) sys.exit(result.returncode) if __name__ == "__main__": main() notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/builduivf.py000066400000000000000000000154721506651041400260200ustar00rootroot00000000000000import argparse from dataclasses import replace import sys import glyphsLib from fontTools.ttLib import TTFont from fontTools.pens.transformPen import TransformPen from fontTools.pens.ttGlyphPen import TTGlyphPen def transform(ttfont, x, y): glyphset = ttfont.getGlyphSet() for glyphname in glyphset.keys(): glyph = glyphset[glyphname] if glyph._getGlyphAndOffset()[0].numberOfContours < 1: continue pen = TTGlyphPen(glyphset) transformpen = TransformPen(pen, (1, 0, 0, 1, x, y)) glyph.draw(transformpen) transformed = pen.glyph() ttfont['glyf'].glyphs[glyphname] = transformed def reencode(ttfont, glyph, cp): for subtable in ttfont["cmap"].tables: subtable.cmap[cp] = glyph def grovel_substitutions(font, lookup, glyphmap): if lookup.LookupType == 7: raise NotImplementedError gmap = lambda g: glyphmap.get(g,g) go = font.getGlyphOrder() def do_coverage(c): c.glyphs = list(sorted([gmap(g) for g in c.glyphs], key=lambda g:go.index(g))) return c for st in lookup.SubTable: if lookup.LookupType == 1: newmap = {} for inglyph, outglyph in st.mapping.items(): newmap[gmap(inglyph)] = gmap(outglyph) st.mapping = newmap elif lookup.LookupType == 2: newmap = {} for inglyph, outglyphs in st.mapping.items(): newmap[gmap(inglyph)] = [gmap(g) for g in outglyphs] st.mapping = newmap elif lookup.LookupType == 4: newligatures = {} for outglyph, inglyphs in st.ligatures.items(): for ig in inglyphs: ig.LigGlyph = gmap(ig.LigGlyph) ig.Component = [gmap(c) for c in ig.Component] newligatures[gmap(outglyph)] = inglyphs st.ligatures = newligatures elif lookup.LookupType == 5: if st.Format == 1: do_coverage(st.Coverage) for srs in st.SubRuleSet: for subrule in srs.SubRule: subrule.Input = [gmap(c) for c in subrule.Input] elif st.Format == 2: do_coverage(st.Coverage) st.ClassDef.classDefs = {gmap(k):v for k,v in st.ClassDef.classDefs.items()} else: st.Coverage = [do_coverage(c) for c in st.Coverage] elif lookup.LookupType == 6: if st.Format == 1: do_coverage(st.Coverage) for srs in st.ChainSubRuleSet: for subrule in srs.ChainSubRule: subrule.Backtrack = [gmap(c) for c in subrule.Backtrack] subrule.Input = [gmap(c) for c in subrule.Input] subrule.LookAhead = [gmap(c) for c in subrule.LookAhead] elif st.Format == 2: do_coverage(st.Coverage) st.BacktrackClassDef.classDefs = {gmap(k):v for k,v in st.BacktrackClassDef.classDefs.items()} st.InputClassDef.classDefs = {gmap(k):v for k,v in st.InputClassDef.classDefs.items()} st.LookAheadClassDef.classDefs = {gmap(k):v for k,v in st.LookAheadClassDef.classDefs.items()} elif st.Format == 3: st.BacktrackCoverage = [ do_coverage(c) for c in st.BacktrackCoverage] st.InputCoverage = [ do_coverage(c) for c in st.InputCoverage] st.LookAheadCoverage = [ do_coverage(c) for c in st.LookAheadCoverage] if __name__ == "__main__": # Parse command line arguments parser = argparse.ArgumentParser(description='Generate a UI font from existing binary and Glyphs file') parser.add_argument('--output', '-o', help='Output font file') parser.add_argument('binary', help='Binary font file') parser.add_argument('glyphs', help='Glyphs file') args = parser.parse_args() if not args.output: if "-VF.ttf" not in args.binary: print("Error: Output file not specified") sys.exit(1) args.output = args.binary.replace('-VF.ttf', 'UI-VF.ttf') gsfont = glyphsLib.GSFont(args.glyphs) ttfont = TTFont(args.binary) # Find UI instances cp = None for instance in gsfont.instances: if "UI" in instance.familyName: cp = instance.customParameters break if cp is None: print("No UI instance found") sys.exit(1) cp = { p.name: p.value for p in cp } print("Creating UI font with custom parameters %s" % cp) if "typoAscender" in cp: ttfont['OS/2'].sTypoAscender = int(cp["typoAscender"]) if "typoDescender" in cp: ttfont['OS/2'].sTypoDescender = int(cp["typoDescender"]) if "typoLineGap" in cp: ttfont['OS/2'].sTypoLineGap = int(cp["typoLineGap"]) if "winAscent" in cp: ttfont['OS/2'].usWinAscent = int(cp["winAscent"]) if "winDescent" in cp: ttfont['OS/2'].usWinDescent = int(cp["winDescent"]) if "hheaAscender" in cp: ttfont['hhea'].ascent = int(cp["hheaAscender"]) if "hheaDescender" in cp: ttfont['hhea'].descent = int(cp["hheaDescender"]) if "hheaLineGap" in cp: ttfont['hhea'].lineGap = int(cp["hheaLineGap"]) if "xHeight" in cp: ttfont['OS/2'].sxHeight = int(cp["xHeight"]) if "Filter" in cp: assert cp["Filter"].startswith("Transformations;") filter_args = cp["Filter"].split(";") filter_args = filter_args[1:-1] filter_args = { arg.split(":")[0]: arg.split(":")[1] for arg in filter_args } if "ScaleX" in filter_args or "ScaleY" in filter_args: print("ScaleX and ScaleY are not supported") sys.exit(1) offset_x = int(filter_args.get("OffsetX", "0")) offset_y = int(filter_args.get("OffsetY", "0")) if offset_x or offset_y: print("Transforming glyphs by %d, %d" % (offset_x, offset_y)) transform(ttfont, offset_x, offset_y) if "Reencode Glyphs" in cp: for parm in cp["Reencode Glyphs"]: glyph, codepoint = parm.split("=") reencode(ttfont, glyph, int(codepoint, 16)) # Mash the GSUB table uis = [ x for x in ttfont.getGlyphOrder() if "UI" in x and x.replace("UI", "") in ttfont.getGlyphOrder() ] glyphmap = { g.replace("UI", ""): g for g in uis} for lookup in ttfont["GSUB"].table.LookupList.Lookup: grovel_substitutions(ttfont, lookup, glyphmap) # Mash the name table name = ttfont["name"] name.setName(name.getName(1,3,1).toUnicode()+" UI", 1, 3, 1, 0x409) name.setName(name.getName(3,3,1).toUnicode().replace("-","UI-"), 3, 3, 1, 0x409) name.setName(name.getName(4,3,1).toUnicode().replace(" Regular","UI Regular"), 4, 3, 1, 0x409) name.setName(name.getName(6,3,1).toUnicode().replace("-Regular","UI-Regular"), 6, 3, 1, 0x409) ttfont.save(args.output) notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/documentation.py000077500000000000000000000177041506651041400267030ustar00rootroot00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import logging from collections import OrderedDict from pathlib import Path import fontTools.ttLib import youseedee import markdown from gftools.utils import primary_script from gflanguages import LoadScripts import yaml from jinja2 import Environment, PackageLoader, select_autoescape from tidylib import tidy_document jinja = Environment( loader=PackageLoader(__package__, "templates"), autoescape=select_autoescape() ) jinja.trim_blocks = True jinja.lstrip_blocks = True script_aliases = {} with open(Path(youseedee.ucd_dir()) / "PropertyValueAliases.txt", "r") as f: for line in f: if line.startswith("#"): continue line = line.strip() if not line: continue parts = line.split(";") if parts[0].strip() == "sc": script_aliases[parts[2].strip()] = parts[1].strip() logging.basicConfig(level=logging.WARN) base_folder = Path(Path(__file__).parent) update_odd_scripts = { "Aran": "Arab", "Jpan": "Hani", "Kore": "Hani", "Hans": "Hani", "Hant": "Hani", "Zsym": "Zyyy", } scripts_info = LoadScripts() class FontDescription(object): def __init__(self, path, config, noto=True): self.path = path article = config.get("article", {}) self.stub = article.get("stub") self.variant = article.get("variant") self.style = article.get("style") if not self.style: if "SERIF" in config.get("category", ["SANS"]): self.style = "Serif" else: self.style = "Sans" self.is_UI = "UI" in path.name self.is_mono = "Mono" in path.name self.has_italic = False self.font = fontTools.ttLib.TTFont(path) self.noto_script = article.get( "script", primary_script(self.font, ignore_latin=True) ) if "STAT" in self.font: stat_tags = [ axis.AxisTag for axis in self.font["STAT"].table.DesignAxisRecord.Axis ] if "ital" in stat_tags: self.has_italic = True self.unicodes = list(self.font.getBestCmap().keys()) self.scripts = OrderedDict() self.blocks = OrderedDict() self.family_name = self.font["name"].getDebugName(16) or self.font[ "name" ].getDebugName(1) self.glyphs_count = len(self.font.getGlyphOrder()) self.features_count = 0 self.art = "" self.desc = "" self.build_features_count() self.build_axes() self.build_scripts() self.build_blocks() self.build_desc() def build_scripts(self): for u in self.unicodes: data = youseedee.ucd_data(u) if data["General_Category"][0] not in ("N", "C"): script = script_aliases[data["Script"]] self.scripts[script] = self.scripts.get(script, 0) + 1 self.scripts = OrderedDict( sorted(self.scripts.items(), key=lambda t: t[1], reverse=True) ) if self.noto_script in update_odd_scripts.keys(): self.scripts[self.noto_script] = self.scripts.pop( update_odd_scripts[self.noto_script] ) if self.noto_script == "SYM2": self.scripts["Zyyy"] = self.scripts.pop("Zsym") if self.family_name == "Noto Music": self.scripts["Grek"] = self.scripts.pop("Zyyy") if self.family_name == "Noto Sans Mono": self.scripts["Grek"] = self.scripts["Cyrl"] for k in ("Zyyy", "Zinh", "Zzzz"): if k in self.scripts.keys(): del self.scripts[k] if "Zmth" in list(self.scripts.keys())[1:]: del self.scripts["Zmth"] if len(self.unicodes) < 10000: for k in list(self.scripts.keys()): if self.scripts[k] / len(self.unicodes) < 0.11: del self.scripts[k] def build_blocks(self): for u in self.unicodes: data = youseedee.ucd_data(u) if data["General_Category"][0] not in ("N", "C"): block = data["Block"] self.blocks[block] = self.blocks.get(block, 0) + 1 self.blocks = OrderedDict( sorted(self.blocks.items(), key=lambda t: t[1], reverse=True) ) for k in list(self.blocks.keys()): if self.blocks[k] < 4: del self.blocks[k] def build_axes(self): self.axes = "" axes_text = "" italic_text = "" if self.has_italic: italic_text = "italic styles, " axes_simple = [] axes_custom = [] fvar = self.font.get("fvar", None) name = self.font["name"] comma = "" if fvar: for axis in fvar.axes: if axis.maxValue > axis.minValue: axisname = name.getName(axis.axisNameID, 3, 1).toUnicode().lower() if axisname in ("weight", "width"): axes_simple.append(axisname + "s") else: axes_custom.append(axisname) if len(axes_simple): axes_simple_text = " and ".join(axes_simple) if len(axes_custom): axes_custom_text = "variations in" + ", ".join(axes_custom) if len(axes_simple): axes_text += axes_simple_text if len(axes_custom): axes_text += ", and " if len(axes_custom): axes_text += axes_custom_text if len(axes_simple) + len(axes_custom) > 1: comma = "," if len(axes_simple) or len(axes_custom): self.axes = f"{italic_text}multiple {axes_text}{comma}" def build_features_count(self): features = set() for table in [self.font.get("GSUB"), self.font.get("GPOS")]: if not table: continue features.update( set( [ FeatureRecord.FeatureTag for FeatureRecord in table.table.FeatureList.FeatureRecord ] ) ) self.features_count = len(sorted(list(features))) def build_desc(self): variables = dict( family_name=self.family_name, stub=self.stub, glyphs_count=self.glyphs_count, features_count=self.features_count, unicodes_count=len(self.unicodes), style=self.style, variant=self.variant, is_mono=self.is_mono, is_UI=self.is_UI, axes=self.axes, scripts=list(self.scripts.keys()), scripts_info=scripts_info, blocks=list(self.blocks.keys()), ) self.art = jinja.get_template("font_article.md").render(**variables) self.desc = jinja.get_template("font_desc.md").render(**variables) def save(self, path, md): logging.info(f"Saving {path}") with open(path, "w", encoding="utf-8") as f: document, errors = tidy_document( markdown.markdown(md), {"show-body-only": "y"} ) f.write(document) def main(): parser = argparse.ArgumentParser() parser.add_argument("-c", "--config", help="YAML configuration file", required=True) parser.add_argument( "-f", "--font", help="Path to best font file", required=True, type=Path ) args = parser.parse_args() config = yaml.safe_load(open(args.config, "r")) art_desc = FontDescription(args.font, config, noto=True) if args.font.parts[0] != "fonts": print("Expected a path of the form fonts/NotoSansWhatever/...") family_path = args.font.parts[1] art_path = Path("documentation") / (family_path + ".article.html") desc_path = Path("documentation") / (family_path + ".html") art_desc.save(art_path, art_desc.art) art_desc.save(desc_path, art_desc.desc) if __name__ == "__main__": main() notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/ghpages/000077500000000000000000000000001506651041400250625ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/ghpages/__init__.py000066400000000000000000000000001506651041400271610ustar00rootroot00000000000000notobuilder-39cc80d40b046765a46f77771430622d6e11d179/Lib/notobuilder/ghpages/__main__.py000066400000000000000000000115331506651041400271570ustar00rootroot00000000000000from collections import defaultdict import os import re from glob import glob from pathlib import Path from urllib.parse import quote from importlib.resources import files import chevron from fontTools.ttLib import TTFont from gftools.utils import font_sample_text from sh import git DIFFBROWSERS_PROOF_RE = r"^(.*)-diffbrowsers_(.*).html$" class FileTreeMaker(object): def _recurse(self, parent_path, file_list, prefix, output_buf, level): if len(file_list) == 0: return else: file_list.sort(key=lambda f: os.path.isfile(os.path.join(parent_path, f))) for idx, sub_path in enumerate(file_list): full_path = os.path.join(parent_path, sub_path) if os.path.isdir(full_path): output_buf.append(f'
  • {sub_path}" % (prefix)) def make(self, root): self.root = root buf = ["