├── .gcloudignore ├── .gitignore ├── .gitmodules ├── .htaccess ├── LICENSE ├── README.md ├── VCSSVideo.pdf ├── app.yaml ├── favicon-32x32.png ├── fonts ├── example-axes.json ├── example.woff └── repos │ └── README.md ├── form-controls.css ├── form-controls.css.map ├── form-controls.scss ├── glyph-groups.json ├── glyph-groups.yaml ├── images ├── tn-logo.svg └── typenetwork-logo.svg ├── index.html ├── index.php ├── layouts ├── composition.css ├── composition.js ├── contextual.css ├── contextual.js ├── grid.css ├── grid.js ├── type-your-own.css └── type-your-own.js ├── legacy.php ├── lib ├── css │ ├── fonts.css │ └── videoproof.css └── js │ ├── content-editable.mjs │ ├── diff_match_patch │ ├── build.sh │ └── diff_match_patch.mjs │ ├── domTool.mjs │ ├── layouts │ ├── vartools-grid.mjs │ ├── vartools-typespec.mjs │ ├── vartools-waterfall.mjs │ ├── videoproof-array.mjs │ ├── videoproof-contextual.mjs │ └── videoproof-type-your-own.mjs │ ├── local-font-storage.mjs │ ├── main.mjs │ ├── ot-feature-info.mjs │ ├── text-selection.mjs │ └── videoproof-controller.mjs ├── make-webfonts.py ├── old_tn_assets └── assets_content │ ├── css │ ├── adobe-blank.css │ ├── fonts │ │ ├── AdobeBlank.ttf │ │ ├── AdobeBlank.ttf.1 │ │ ├── AdobeBlank.woff │ │ ├── AdobeBlank.woff.1 │ │ ├── AdobeBlank.woff2 │ │ ├── AdobeBlank.woff2.1 │ │ └── fonts.txt │ ├── reset.css │ └── style.css │ └── img │ ├── icon_account.svg │ ├── icon_arrow-search.svg │ ├── icon_cart-buy-gray.svg │ ├── icon_cart-buy-white.svg │ ├── icon_cart-buy-white.svg.1 │ ├── icon_cart-empty-white.svg │ ├── icon_close.svg │ ├── icon_filter-selected.svg │ ├── icon_menu-white.svg │ ├── icon_menu-white.svg.1 │ ├── icon_menu-white.svg.2 │ ├── icon_search-white.svg │ ├── icon_star-gray.svg │ ├── icon_star-white.svg │ ├── icon_star-white.svg.1 │ └── images.txt ├── text-to-width.js ├── texts ├── pangram-words.txt ├── pangrams.txt └── paragraphs.txt ├── updatefonts.sh ├── user-guide.css ├── user-guide.js ├── videoproof.css ├── videoproof.inc └── videoproof.js /.gcloudignore: -------------------------------------------------------------------------------- 1 | # This file specifies files that are *not* uploaded to Google Cloud 2 | # using gcloud. It follows the same syntax as .gitignore, with the addition of 3 | # "#!include" directives (which insert the entries of the given .gitignore-style 4 | # file at that point). 5 | # 6 | # For more information, run: 7 | # $ gcloud topic gcloudignore 8 | # 9 | .gcloudignore 10 | # If you would like to upload your .git directory, .gitignore file or files 11 | # from your .gitignore file, remove the corresponding line 12 | # below: 13 | .git 14 | .git/ 15 | .gitignore 16 | */.git 17 | */.git/ 18 | */.gitignore 19 | venv/ 20 | venv 21 | /venv 22 | /venv/ 23 | # ignore as this is not the default, but a local specialty 24 | /fonts/repos/ 25 | # fonts/RobotoFlex* 26 | # fonts/axes.json 27 | 28 | # PHP Composer dependencies: 29 | /vendor/ 30 | 31 | # submodules or unnecessary parts of submodules 32 | /diff-match-patch/ 33 | /opentype.js/examples/ 34 | /opentype.js/g/ 35 | node_modules 36 | package-lock.json 37 | /opentype.js/test 38 | /opentype.js/bin 39 | /opentype.js/externs 40 | /opentype.js/fonts 41 | /opentype.js/src 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | fonts/*.woff* 3 | fonts/axes.json 4 | !fonts/example.woff 5 | !fonts/example-axes.json 6 | fonts/repos/* 7 | !fonts/repos/README.md 8 | php.ini 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "opentype.js"] 2 | path = opentype.js 3 | url = https://github.com/graphicore/opentype.js.git 4 | [submodule "spectrum"] 5 | path = spectrum 6 | url = https://github.com/bgrins/spectrum.git 7 | [submodule "intro.js"] 8 | path = intro.js 9 | url = https://github.com/usablica/intro.js 10 | [submodule "diff-match-patch"] 11 | path = diff-match-patch 12 | url = https://github.com/google/diff-match-patch.git 13 | [submodule "lib/js/wawoff2"] 14 | path = lib/js/wawoff2 15 | url = https://github.com/graphicore/wawoff2.git 16 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | RewriteBase "/" 3 | RewriteRule (^\.|/\.) - [F] 4 | RewriteRule ^(typespec|logopogo|proof)/(index.+)?$ / [R=301] 5 | 6 | 7 | Header set Access-Control-Allow-Origin "*" 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Video Proof 2 | 3 | Experimental tools for creating animated proofs for variable fonts. 4 | 5 | https://videoproof.graphicore.de/ 6 | SOME DEVELOPERS need more sophisticated composition tools for variable fonts; To exercise, proof and, annotate, demo and share 7 | 8 | CREATE AND DEMONSTRATE options for integration of registered and parametric axes with the value systems and processes of composition and composers. 9 | 10 | >Proof and adjust the integration via a combination of css, js, and Ui developments 11 | 12 | >Analyze both visually and with filtering and sorting of the data-rich CSS environment now available 13 | 14 | >Annotate issues on glyp, gvar, gpos and other font tables uses with css, js in compostion. 15 | 16 | >Share via fonts, css, js, urls of still and motion proofs notes and code. 17 | 18 | And this should be done with the option of a limited number of inputs from the user, or have access to all composition variables. 19 | 20 | Typetools was developed as a web-based proofing tool for variable fonts made to test fonts during development and in simulated web use for static instances of fonts. 21 | 22 | typetools.typenetwork.com 23 | 24 | (Repo link: https://github.com/TypeNetwork/variable-type-tools) 25 | 26 | The variable fonts it was made to test, include those made to specifications for additional registration of axes proposed by TN, summarized here as containing parametric and registered axes. 27 | 28 | (Repo link: https://github.com/microsoft/OpenTypeDesignVariationAxisTags/blob/master/Proposals/TypeNetwork_ParametricAxes/Overview.md) 29 | 30 | (Publication Site link: https://variationsguide.typenetwork.com) 31 | 32 | Development showed users needed the composition formats, sliders, and other options that are currently evident and defined in the user documentation. 33 | 34 | (Publication link: https://variationsguide.typenetwork.com !! Put actual user guide link here ¡¡ 35 | 36 | User experience showed a repeated user journey including use of sliders to examine a variable font’s designspace, and the need to capture and communicate locations and ranges of design space within the designspace. 37 | 38 | Other develpers have confirmed the usefulness of tagging "KEYFRAMES" of varible instances ranges relative to composition of responsive pages. 39 | 40 | Development is only a month old and all development is only a month old and all big reports and suggestions are welcome. 41 | -------------------------------------------------------------------------------- /VCSSVideo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/VCSSVideo.pdf -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | runtime: php74 2 | 3 | handlers: 4 | # Serve a directory as a static resource. 5 | - url: /(.+\.php)$ 6 | script: auto 7 | secure: always 8 | - url: /images 9 | static_dir: images 10 | - url: /fonts 11 | static_dir: fonts 12 | - url: /intro.js 13 | static_dir: intro.js 14 | - url: /layouts 15 | static_dir: layouts 16 | - url: /intro.js 17 | static_dir: opentype.js 18 | - url: /spectrum 19 | static_dir: spectrum 20 | - url: /texts 21 | static_dir: texts 22 | 23 | - url: /(.*\.mjs) 24 | mime_type: text/javascript 25 | static_files: \1 26 | upload: .+\.(mjs)$ 27 | 28 | # Serve files as static resources. 29 | - url: /(.+\.(gif|png|jpg|svg|js|pdf|css|map|scss|yaml|json))$ 30 | static_files: \1 31 | upload: .+\.(gif|png|jpg|svg|js|pdf|css|map|scss|yaml|json)$ 32 | 33 | # Serve your app through a front controller at index.php or public/index.php. 34 | #- url: .* 35 | # script: auto 36 | # secure: always 37 | -------------------------------------------------------------------------------- /favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/favicon-32x32.png -------------------------------------------------------------------------------- /fonts/example-axes.json: -------------------------------------------------------------------------------- 1 | { 2 | "example": { 3 | "order": [ 4 | "wght", 5 | "opsz", 6 | "wdth", 7 | "XTRA", 8 | "XOPQ", 9 | "YOPQ" 10 | ], 11 | "wght": { 12 | "max": 900.0, 13 | "min": 100.0, 14 | "name": "weight", 15 | "default": 400.0 16 | }, 17 | "opsz": { 18 | "max": 144.0, 19 | "min": 8.0, 20 | "name": "opsize", 21 | "default": 14.0 22 | }, 23 | "wdth": { 24 | "max": 125.0, 25 | "min": 50.0, 26 | "name": "width", 27 | "default": 100.0 28 | }, 29 | "XTRA": { 30 | "max": 1104.0, 31 | "min": 444.0, 32 | "name": "XTRA", 33 | "default": 980.0 34 | }, 35 | "XOPQ": { 36 | "max": 526.0, 37 | "min": 36.0, 38 | "name": "XOPQ", 39 | "default": 176.0 40 | }, 41 | "YOPQ": { 42 | "max": 224.0, 43 | "min": 29.0, 44 | "name": "YOPQ", 45 | "default": 124.0 46 | }, 47 | "instances": [] 48 | } 49 | } -------------------------------------------------------------------------------- /fonts/example.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/fonts/example.woff -------------------------------------------------------------------------------- /fonts/repos/README.md: -------------------------------------------------------------------------------- 1 | To semi-automatically track font development in remote Git repositories, clone them here, 2 | then run /updatefonts.sh or click the `Grab new fonts` link in the sidebar. 3 | -------------------------------------------------------------------------------- /form-controls.css: -------------------------------------------------------------------------------- 1 | input[type='range'] { 2 | -webkit-appearance: none; 3 | margin: 8px 0; 4 | width: 2in; } 5 | input[type='range']:focus::-webkit-slider-runnable-track { 6 | background: #DAD9D7; } 7 | input[type='range']:focus::-ms-fill-lower { 8 | background: #DAD9D7; } 9 | input[type='range']:focus::-ms-fill-upper { 10 | background: #DAD9D7; } 11 | input[type='range']::-webkit-slider-runnable-track { 12 | cursor: pointer; 13 | height: 0.1875rem; 14 | transition: all 0.2s ease; 15 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 16 | background: #DAD9D7; 17 | border: 0; 18 | border-radius: 0; } 19 | input[type='range']::-webkit-slider-thumb { 20 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 21 | background: #3867ff; 22 | box-sizing: border-box; 23 | border: 0.125rem solid white; 24 | border-radius: 1rem; 25 | cursor: pointer; 26 | height: 1rem; 27 | width: 1rem; 28 | -webkit-appearance: none; 29 | margin-top: calc(-1rem / 2 + 1px); } 30 | input[type='range']::-moz-range-track { 31 | cursor: pointer; 32 | height: 0.1875rem; 33 | transition: all 0.2s ease; 34 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 35 | background: #DAD9D7; 36 | border: 0; 37 | border-radius: 0; } 38 | input[type='range']::-moz-range-thumb { 39 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 40 | background: #3867ff; 41 | box-sizing: border-box; 42 | border: 0.125rem solid white; 43 | border-radius: 1rem; 44 | cursor: pointer; 45 | height: 1rem; 46 | width: 1rem; } 47 | input[type='range']::-ms-track { 48 | cursor: pointer; 49 | height: 0.1875rem; 50 | transition: all 0.2s ease; 51 | background: transparent; 52 | border-color: transparent; 53 | border-width: 8px 0; 54 | color: transparent; } 55 | input[type='range']::-ms-fill-lower { 56 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 57 | background: #DAD9D7; 58 | border: 0; 59 | border-radius: 0; } 60 | input[type='range']::-ms-fill-upper { 61 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 62 | background: #DAD9D7; 63 | border: 0; 64 | border-radius: 0; } 65 | input[type='range']::-ms-thumb { 66 | box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(13, 13, 13, 0.2); 67 | background: #3867ff; 68 | box-sizing: border-box; 69 | border: 0.125rem solid white; 70 | border-radius: 1rem; 71 | cursor: pointer; 72 | height: 1rem; 73 | width: 1rem; 74 | margin-top: 0; } 75 | 76 | /*# sourceMappingURL=form-controls.css.map */ 77 | -------------------------------------------------------------------------------- /form-controls.css.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "mappings": "AAAA,mBAAoB;EAOnB,kBAAkB,EAAE,IAAI;EACxB,MAAM,EAAE,KAAK;EACb,KAAK,EAAE,GAAG;EAMV,wDAAuC;IACtC,UAAU,EAbE,OAAO;EAgBpB,yCAAwB;IACvB,UAAU,EAjBE,OAAO;EAoBpB,yCAAwB;IACvB,UAAU,EArBE,OAAO;EAwBpB,kDAAiC;IAChC,MAAM,EAAE,OAAO;IACf,MAAM,EA3BC,SAAQ;IA4Bf,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EA7BE,OAAO;IA8BnB,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,CAAC;EAGjB,yCAAwB;IACvB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EAnCK,OAAO;IAoCtB,UAAU,EAAE,UAAU;IACtB,MAAM,EApCU,oBAAmB;IAqCnC,aAAa,EAzCN,IAAI;IA0CX,MAAM,EAAE,OAAO;IACf,MAAM,EA3CC,IAAI;IA4CX,KAAK,EA5CE,IAAI;IA6CX,kBAAkB,EAAE,IAAI;IACxB,UAAU,EAAE,qBAA0B;EAGvC,qCAAoB;IACnB,MAAM,EAAE,OAAO;IACf,MAAM,EAlDC,SAAQ;IAmDf,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EApDE,OAAO;IAqDnB,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,CAAC;EAGjB,qCAAoB;IACnB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EA1DK,OAAO;IA2DtB,UAAU,EAAE,UAAU;IACtB,MAAM,EA3DU,oBAAmB;IA4DnC,aAAa,EAhEN,IAAI;IAiEX,MAAM,EAAE,OAAO;IACf,MAAM,EAlEC,IAAI;IAmEX,KAAK,EAnEE,IAAI;EAsEZ,8BAAa;IACZ,MAAM,EAAE,OAAO;IACf,MAAM,EAvEC,SAAQ;IAwEf,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,WAAW;IACvB,YAAY,EAAE,WAAW;IACzB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,WAAW;EAGnB,mCAAkB;IACjB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EAhFE,OAAO;IAiFnB,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,CAAC;EAGjB,mCAAkB;IACjB,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EAvFE,OAAO;IAwFnB,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,CAAC;EAGjB,8BAAa;IACZ,UAAU,EAAE,qDAAmD;IAC/D,UAAU,EA7FK,OAAO;IA8FtB,UAAU,EAAE,UAAU;IACtB,MAAM,EA9FU,oBAAmB;IA+FnC,aAAa,EAnGN,IAAI;IAoGX,MAAM,EAAE,OAAO;IACf,MAAM,EArGC,IAAI;IAsGX,KAAK,EAtGE,IAAI;IAuGX,UAAU,EAAE,CAAC", 4 | "sources": ["form-controls.scss"], 5 | "names": [], 6 | "file": "form-controls.css" 7 | } -------------------------------------------------------------------------------- /form-controls.scss: -------------------------------------------------------------------------------- 1 | input[type='range'] { 2 | $thumb: 1rem; 3 | $track: .1875rem; 4 | $line-color: #DAD9D7; 5 | $gnubbel-color: #3867ff; 6 | $gnubbel-border: .125rem solid white; 7 | 8 | -webkit-appearance: none; 9 | margin: 8px 0; 10 | width: 2in; 11 | 12 | &:focus { 13 | // outline: 0; 14 | } 15 | 16 | &:focus::-webkit-slider-runnable-track { 17 | background: $line-color; 18 | } 19 | 20 | &:focus::-ms-fill-lower { 21 | background: $line-color; 22 | } 23 | 24 | &:focus::-ms-fill-upper { 25 | background: $line-color; 26 | } 27 | 28 | &::-webkit-slider-runnable-track { 29 | cursor: pointer; 30 | height: $track; 31 | transition: all 0.2s ease; 32 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 33 | background: $line-color; 34 | border: 0; 35 | border-radius: 0; 36 | } 37 | 38 | &::-webkit-slider-thumb { 39 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 40 | background: $gnubbel-color; 41 | box-sizing: border-box; 42 | border: $gnubbel-border; 43 | border-radius: $thumb; 44 | cursor: pointer; 45 | height: $thumb; 46 | width: $thumb; 47 | -webkit-appearance: none; 48 | margin-top: calc(-#{$thumb} / 2 + 1px); 49 | } 50 | 51 | &::-moz-range-track { 52 | cursor: pointer; 53 | height: $track; 54 | transition: all 0.2s ease; 55 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 56 | background: $line-color; 57 | border: 0; 58 | border-radius: 0; 59 | } 60 | 61 | &::-moz-range-thumb { 62 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 63 | background: $gnubbel-color; 64 | box-sizing: border-box; 65 | border: $gnubbel-border; 66 | border-radius: $thumb; 67 | cursor: pointer; 68 | height: $thumb; 69 | width: $thumb; 70 | } 71 | 72 | &::-ms-track { 73 | cursor: pointer; 74 | height: $track; 75 | transition: all 0.2s ease; 76 | background: transparent; 77 | border-color: transparent; 78 | border-width: 8px 0; 79 | color: transparent; 80 | } 81 | 82 | &::-ms-fill-lower { 83 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 84 | background: $line-color; 85 | border: 0; 86 | border-radius: 0; 87 | } 88 | 89 | &::-ms-fill-upper { 90 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 91 | background: $line-color; 92 | border: 0; 93 | border-radius: 0; 94 | } 95 | 96 | &::-ms-thumb { 97 | box-shadow: 0 0 0 rgba(0, 0, 0, .2), 0 0 0 rgba(13, 13, 13, .2); 98 | background: $gnubbel-color; 99 | box-sizing: border-box; 100 | border: $gnubbel-border; 101 | border-radius: $thumb; 102 | cursor: pointer; 103 | height: $thumb; 104 | width: $thumb; 105 | margin-top: 0; 106 | } 107 | } -------------------------------------------------------------------------------- /glyph-groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "Latin": { 3 | "Uppercase": "ABCDEFGHIJKLMNOPQRSTUVWXYZ&", 4 | "Lowercase": "abcdefghijklmnopqrstuvwxyz", 5 | "Mixed": "DžLjNjlj", 6 | "ASCII": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789<([{@#$%&?!/|\\\"~`*^':;.,)]}>", 7 | "Symbols": { 8 | "Punctuation": ",-.:;…∙·!¡?¿–—―‐", 9 | "Reference": "*§¶†‡•", 10 | "Quotation": "\"'“”‚„‹›«»′″", 11 | "Parenthetical": "()[]{}", 12 | "Math": "+÷×−±<>≤≥≈≠=^~¬∕­/", 13 | "Commercial": "®©™#@⁒ʹʺ/\\¦|_№⟨⟩µ⁄" 14 | } 15 | }, 16 | "Greek": { 17 | "Uppercase": "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", 18 | "Lowercase": "αβγδεζηθικλμνξοπρστυφχψως" 19 | }, 20 | "Cyrillic": { 21 | "Uppercase": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 22 | "Lowercase": "абвгдежзийклмнопрстуфхцчшщъыьэюя" 23 | }, 24 | "World": { 25 | "Figures": { 26 | "_default": "0123456789", 27 | "_extended": "⁰¹²³⁴⁵⁶⁷⁸⁹⅛⅙⅕¼⅓⅜⅖½⅗⅔⅝¾⅘⅚⅞%‰" 28 | }, 29 | "Monetary": { 30 | "_default": "$¢£¥", 31 | "_extended": "₡₣₤₦₧₩₫€ƒ₭₱₲₵₹₺₼₽¤" 32 | }, 33 | "Accents": { 34 | "_default": "`¨¯°´ˆˇ˘˙˚˛˜˝‘’¸ʼ", 35 | "_extended": "ˉ̧̨̛̣̤̦̮̱̀́̂̃̄̆̇̈̉̊̋̌̏̑" 36 | } 37 | }, 38 | "_extended": { 39 | "A": "ÀÁÂÃÄÅĀĂǺȀȂĄẠẢẤẦẨẪẬẮẰẲẴẶÆǼ", 40 | "C": "ÇĆĈĊČ", 41 | "D": "ĎÐĐDŽDž", 42 | "E": "ÈÉÊËĒĔĖĘĚȄȆẸẺẼẾỀỂỄỆÆǼŒƏ", 43 | "G": "ĜĞĠĢǦ", 44 | "H": "ĤĦ", 45 | "I": "ÌÍÎÏĨĪĬĮİȈȊỈỊIJljLJNJ", 46 | "J": "ĴIJ", 47 | "K": "Ķ", 48 | "L": "ĹĻĽĿŁLJLj", 49 | "N": "ÑŃŅŇŊNJNj", 50 | "O": "ÒÓÔÕÖŌŎŐƠǪȌȎȪȬȰỌỎỐỒỔỖỘỚỜỞỠỢØǾŒ", 51 | "P": "Þ", 52 | "R": "ŔŖŘȐȒ", 53 | "S": "ŚŜŞŠȘẞ", 54 | "T": "ŢŤȚŦ", 55 | "U": "ÙÚÛÜŨŪŬŮŰŲƯȔȖỤỦỨỪỬỮỰ", 56 | "W": "ŴẀẂẄ", 57 | "Y": "ÝŶŸȲỲỴỶỸ", 58 | "Z": "ŹŻŽDŽ", 59 | "a": "àáâãäåāăąǻȁȃạảấầẩẫậắằẳẵặæǽª", 60 | "c": "çćĉċč", 61 | "d": "ďđdžð", 62 | "e": "èéêëēĕėęěȅȇẹẻẽếềểễệəæǽœ", 63 | "f": "fffiflffiffl", 64 | "g": "ĝğġģǧ", 65 | "h": "ĥħ", 66 | "i": "ıĩīĭįȉȋỉịìíîïijfiffi", 67 | "j": "ȷĵljijnjLj", 68 | "k": "ķĸ", 69 | "l": "ĺļľŀłflffl", 70 | "n": "ñńņňʼnŋnj", 71 | "o": "òóôõöōŏőơǫȍȏȫȭȱọỏốồổỗộớờởỡợøǿœº", 72 | "p": "þ", 73 | "r": "ŕŗřȑȓ", 74 | "s": "śŝşšșß", 75 | "t": "ţťțŧ", 76 | "u": "ùúûüũūŭůűųưȕȗụủứừửữự", 77 | "w": "ŵẁẃẅ", 78 | "y": "ýÿŷȳỳỵỷỹ", 79 | "z": "źżžDž", 80 | "Α": "Ά", 81 | "Ε": "Έ", 82 | "Η": "Ή", 83 | "Ι": "ΊΪ", 84 | "Ο": "Ό", 85 | "Υ": "ΎΫ", 86 | "Ω": "Ώ", 87 | "α": "ά", 88 | "ε": "έ", 89 | "η": "ή", 90 | "ι": "ίΐϊ", 91 | "ο": "ό", 92 | "υ": "ύΰϋ", 93 | "ω": "ώ", 94 | "А": "ӒӐӘӔ", 95 | "Г": "ЃҐҒҔ", 96 | "Д": "ЂЋ", 97 | "Е": "ЀЁӖЄ", 98 | "Ж": "ӜӁҖ", 99 | "З": "ӞҘЅ", 100 | "И": "ӤЍӢӀІЇЈ", 101 | "К": "ЌҚҜҠ", 102 | "Л": "Љ", 103 | "Н": "ҢЊҤ", 104 | "О": "ӦѲӨ", 105 | "С": "Ҫ", 106 | "У": "ӮӰӲЎҮҰЏ", 107 | "Х": "ҲҺ", 108 | "Ч": "ӴҶҸ", 109 | "Ы": "Ӹ", 110 | "а": "ӓӑәӕ", 111 | "г": "ѓґғҕ", 112 | "д": "ђћ", 113 | "е": "ѐёӗє", 114 | "ж": "ӝӂҗ", 115 | "з": "ӟҙѕ", 116 | "и": "ӥѝӣӏіїј", 117 | "к": "ќқҝҡ", 118 | "л": "љ", 119 | "н": "ңњҥ", 120 | "о": "ӧѳө", 121 | "с": "ҫ", 122 | "у": "ӯӱӳўүұџ", 123 | "х": "ҳһ", 124 | "ч": "ӵҷҹ", 125 | "ы": "ӹ" 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /glyph-groups.yaml: -------------------------------------------------------------------------------- 1 | # Format tips: 2 | # * Indentation is important! Four spaces. 3 | # * Most strings can be unquoted, unless they contain quotes or some other punctuation. If in doubt, you can quote (single or double) 4 | # * Unquoted single characters Y/N/y/n are synonyms for True and False in YAML, so they should be quoted if used 5 | # 6 | # Character groupings can be one or two levels deep (see Latin > Symbols) 7 | # 8 | # Two ways of handling "extended" character sets: 9 | # 1. For simple one-to-many character extensions (e.g. accented Latin letters), add them to the global "_extended" list at the bottom. 10 | # These will be expanded "in place" automatically whenever that character is encountered in a character set. 11 | # 2. For custom extensions (e.g. currency symbols) include "_default" and "_extended" strings under each label 12 | 13 | Latin: 14 | Uppercase: ABCDEFGHIJKLMNOPQRSTUVWXYZ& 15 | Lowercase: abcdefghijklmnopqrstuvwxyz 16 | Mixed: DžLjNjlj 17 | ASCII: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789<([{@#$%&?!/|\\\"~`*^':;.,)]}>" 18 | Symbols: 19 | Punctuation: ',-.:;…∙·!¡?¿–—―‐' 20 | Reference: '*§¶†‡•' 21 | Quotation: "\"'“”‚„‹›«»′″" 22 | Parenthetical: '()[]{}' 23 | Math: '+÷×−±<>≤≥≈≠=^~¬∕­/' 24 | Commercial: '®©™#@⁒ʹʺ/\¦|_№⟨⟩µ⁄' 25 | Greek: 26 | Uppercase: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 27 | Lowercase: αβγδεζηθικλμνξοπρστυφχψως 28 | Cyrillic: 29 | Uppercase: АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ 30 | Lowercase: абвгдежзийклмнопрстуфхцчшщъыьэюя 31 | World: 32 | Figures: 33 | _default: 0123456789 34 | _extended: ⁰¹²³⁴⁵⁶⁷⁸⁹⅛⅙⅕¼⅓⅜⅖½⅗⅔⅝¾⅘⅚⅞%‰ 35 | Monetary: 36 | _default: $¢£¥ 37 | _extended: ₡₣₤₦₧₩₫€ƒ₭₱₲₵₹₺₼₽¤ 38 | Accents: 39 | _default: '`¨¯°´ˆˇ˘˙˚˛˜˝‘’¸ʼ' 40 | _extended: 'ˉ̧̨̛̣̤̦̮̱̀́̂̃̄̆̇̈̉̊̋̌̏̑' 41 | _extended: 42 | # YAML evaluates Y/N/y/n as true and false, so we have to put quotes around those 43 | A: ÀÁÂÃÄÅĀĂǺȀȂĄẠẢẤẦẨẪẬẮẰẲẴẶÆǼ 44 | C: ÇĆĈĊČ 45 | D: ĎÐĐDŽDž 46 | E: ÈÉÊËĒĔĖĘĚȄȆẸẺẼẾỀỂỄỆÆǼŒƏ 47 | G: ĜĞĠĢǦ 48 | H: ĤĦ 49 | I: ÌÍÎÏĨĪĬĮİȈȊỈỊIJljLJNJ # /IJacute  50 | J: ĴIJ # /IJacute 51 | K: Ķ 52 | L: ĹĻĽĿŁLJLj 53 | "N": ÑŃŅŇŊNJNj 54 | O: ÒÓÔÕÖŌŎŐƠǪȌȎȪȬȰỌỎỐỒỔỖỘỚỜỞỠỢØǾŒ 55 | P: Þ 56 | R: ŔŖŘȐȒ 57 | S: ŚŜŞŠȘẞ 58 | T: ŢŤȚŦ 59 | U: ÙÚÛÜŨŪŬŮŰŲƯȔȖỤỦỨỪỬỮỰ 60 | W: ŴẀẂẄ 61 | "Y": ÝŶŸȲỲỴỶỸ 62 | Z: ŹŻŽDŽ 63 | a: àáâãäåāăąǻȁȃạảấầẩẫậắằẳẵặæǽª 64 | c: çćĉċč 65 | d: ďđdžð 66 | e: èéêëēĕėęěȅȇẹẻẽếềểễệəæǽœ 67 | f: fffiflffiffl # /f_f_ij /f_ij  68 | g: ĝğġģǧ 69 | h: ĥħ 70 | i: ıĩīĭįȉȋỉịìíîïijfiffi # /idotaccent /ijacute /f_ij /f_f_ij 71 | j: ȷĵljijnjLj #/f_ij  /f_f_ij 72 | k: ķĸ 73 | l: ĺļľŀłflffl 74 | "n": ñńņňʼnŋnj 75 | o: òóôõöōŏőơǫȍȏȫȭȱọỏốồổỗộớờởỡợøǿœº 76 | p: þ 77 | r: ŕŗřȑȓ 78 | s: śŝşšșß 79 | t: ţťțŧ 80 | u: ùúûüũūŭůűųưȕȗụủứừửữự 81 | w: ŵẁẃẅ 82 | "y": ýÿŷȳỳỵỷỹ 83 | z: źżžDž 84 | #Greek 85 | #Uppercase: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 86 | #Lowercase: αβγδεζηθικλμνξοπρστυφχψως 87 | Α: Ά 88 | Ε: Έ 89 | Η: Ή 90 | Ι: ΊΪ 91 | Ο: Ό 92 | Υ: ΎΫ 93 | Ω: Ώ 94 | α: ά 95 | ε: έ 96 | η: ή 97 | ι: ίΐϊ 98 | ο: ό 99 | υ: ύΰϋ 100 | ω: ώ 101 | #Cyrillic 102 | #Uppercase: АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ 103 | #Lowercase: абвгдежзийклмнопрстуфхцчшщъыьэюя 104 | А: ӒӐӘӔ 105 | Г: ЃҐҒҔ 106 | Д: ЂЋ 107 | Е: ЀЁӖЄ 108 | Ж: ӜӁҖ 109 | З: ӞҘЅ 110 | И: ӤЍӢӀІЇЈ 111 | К: ЌҚҜҠ 112 | Л: Љ 113 | Н: ҢЊҤ 114 | О: ӦѲӨ 115 | С: Ҫ 116 | У: ӮӰӲЎҮҰЏ 117 | Х: ҲҺ 118 | Ч: ӴҶҸ 119 | Ы: Ӹ 120 | а: ӓӑәӕ 121 | г: ѓґғҕ 122 | д: ђћ 123 | е: ѐёӗє 124 | ж: ӝӂҗ 125 | з: ӟҙѕ 126 | и: ӥѝӣӏіїј 127 | к: ќқҝҡ 128 | л: љ 129 | н: ңњҥ 130 | о: ӧѳө 131 | с: ҫ 132 | у: ӯӱӳўүұџ 133 | х: ҳһ 134 | ч: ӵҷҹ 135 | ы: ӹ 136 | 137 | -------------------------------------------------------------------------------- /images/tn-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/typenetwork-logo.svg: -------------------------------------------------------------------------------- 1 | TypeNetwork-LogoType_MSD-100_18pt-30-24 -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TypeRoof 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 |
47 |

TypeRoof

48 |
49 | 50 | 51 | 157 | 158 |
159 | Sidebar 160 | 161 |
162 | 172 |
173 | 174 |
175 | 176 | sec 177 |
178 | This animation will eat your CPU alive (depending on browser), so it doesn’t auto-start. Ready? ▶️ 179 | 180 |
181 | 182 |
183 | 189 |
190 | 191 | 192 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | Small ', 9 | }, 10 | 'init': function(proof) { 11 | var sizecontrols = $('input[name="composition-size"]'); 12 | var paragraphs, pangrams; 13 | 14 | function getChunks(src, num) { 15 | if (isNaN(num) || num <= 0) { 16 | num = 1; 17 | } 18 | 19 | var result = []; 20 | var i, j; 21 | for (i=0; i$2$3'); 70 | p.appendChild(input); 71 | p.appendChild(label); 72 | (parent || wrapper).appendChild(p); 73 | 74 | p.setAttribute('data-size', ''); 75 | } 76 | 77 | proof.textContent = ""; 78 | if (currentSize === 'small') { 79 | wrapper = document.createElement('div'); 80 | wrapper.className = 'small-container'; 81 | 82 | addPara('p', getChunks(pangrams, 3).join(". ") + ".", 'pull-quote'); 83 | 84 | [1.3, 1, 1.2, 0.9, 1.1, 0.8].forEach(function(size) { 85 | addPara('p', getChunk(paragraphs), null, size); 86 | }); 87 | 88 | proof.appendChild(wrapper); 89 | } else { 90 | wrapper = document.createElement('div'); 91 | wrapper.className = 'large-container'; 92 | 93 | ['regular', 'bold'].forEach(function(weight) { 94 | var pane = document.createElement('div'); 95 | pane.className = 'pane ' + weight; 96 | 97 | ['h1', 'h2', 'h3', 'h4', 'h5'].forEach(function(h) { 98 | addPara(h, '', null, null, pane); 99 | }); 100 | 101 | wrapper.appendChild(pane); 102 | }); 103 | 104 | proof.appendChild(wrapper); 105 | 106 | setTimeout(doTTW, 500); 107 | } 108 | 109 | $(proof).find('[data-size]').each(function() { 110 | var p = this; 111 | var fontsize = parseFloat(getComputedStyle(p).fontSize); 112 | var rem = parseFloat(getComputedStyle(document.body).fontSize); 113 | 114 | var sizeLabel = Math.round(fontsize / rem * 100)/100 + 'em / ' + Math.round(fontsize * 72/96) + 'pt'; 115 | p.setAttribute('data-size', sizeLabel); 116 | }); 117 | }); 118 | sizecontrols.filter(':checked').trigger('change'); 119 | 120 | //select text blocks 121 | proof.addEventListener('change', function() { 122 | var para = document.querySelector('input[name="para-select"]:checked').parentNode; 123 | 124 | //freeze current settings on previously selected para 125 | $('#the-proof .animation-target').each(function() { 126 | var style = getComputedStyle(this); 127 | this.style.fontVariationSettings = style.fontVariationSettings; 128 | this.setAttribute('data-timestamp', VideoProof.getTimestamp()); 129 | $(this).removeClass('animation-target'); 130 | }); 131 | 132 | //restore the previous settings if it had been modified before 133 | para.style.removeProperty('font-variation-settings'); 134 | 135 | var tol = currentSize === 'small' ? { 'wght': [-100, +100], 'wdth': [0.8, 1.2] } : { 'wght': [-1000000, +10000000], 'wdth': [-100000000, +10000000] }; 136 | 137 | VideoProof.bracketRap(para, tol); 138 | $(para).addClass('animation-target'); 139 | if (para.hasAttribute('data-timestamp')) { 140 | VideoProof.jumpToTimestamp(para.getAttribute('data-timestamp')); 141 | } 142 | }); 143 | 144 | if (!document.querySelector('input[name="para-select"]:checked')) { 145 | document.querySelector('input[name="para-select"]').checked = true; 146 | trigger(proof, 'change'); 147 | } 148 | }).catch(function(e) { 149 | console.log(e); 150 | alert("Error loading composition text file(s)"); 151 | }); 152 | }, 153 | 'deinit': function(proof) { 154 | } 155 | }; 156 | -------------------------------------------------------------------------------- /layouts/contextual.css: -------------------------------------------------------------------------------- 1 | 2 | #contextual-custom-pad { 3 | box-sizing: content-box; 4 | width: 2em; 5 | } 6 | 7 | #the-proof.contextual > span { 8 | white-space: nowrap; 9 | } -------------------------------------------------------------------------------- /layouts/contextual.js: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 7, laxcomma: true, laxbreak: true */ 2 | 3 | export default { 4 | 'sizeToSpace': true, 5 | 'controls': { 6 | 'Pad': '', 7 | 'Custom pad': '' 8 | }, 9 | 'init': function(proof) { 10 | function populateGrid() { 11 | var glyphset = VideoProof.getGlyphString(); 12 | 13 | /* 14 | if (typeof glyphset === 'object' && glyphset.chars && glyphset.feature) { 15 | proof.css('font-feature-settings', '"' + glyphset.feature + '" 1'); 16 | glyphset = glyphset.chars; 17 | } else { 18 | proof.css('font-feature-settings', ''); 19 | } 20 | */ 21 | 22 | var ucre = /[A-Z]/; 23 | var lcre = /[a-z]/; 24 | var numre = /[0-9]/; 25 | function isGeneral(c, re) { 26 | if (re.test(c)) { return true; } 27 | var isExt = false; 28 | $.each(glyphsets._extended, function(k, v) { 29 | if (re.test(k) && v.indexOf(c) >= 0) { 30 | isExt = true; 31 | return false; 32 | } 33 | }); 34 | return isExt; 35 | } 36 | 37 | function isUppercase(c) { 38 | return isGeneral(c, ucre); 39 | } 40 | 41 | function isLowercase(c) { 42 | return isGeneral(c, lcre); 43 | } 44 | 45 | function isNumeric(c) { 46 | return isGeneral(c, numre); 47 | } 48 | 49 | var autopad = $('#contextual-pad').val(); 50 | var custompad = $('#contextual-custom-pad').val(); 51 | var words = []; 52 | var extended = document.getElementById('show-extended-glyphs').checked; 53 | 54 | if (custompad.length || !autopad.match(/^kern/)) { 55 | Array.from(glyphset).forEach(function(c) { 56 | if (custompad.length) { 57 | words.push(custompad + c + custompad); 58 | } else switch (autopad) { 59 | case 'auto-short': 60 | if (isNumeric(c)) { 61 | words.push("00" + c + "00"); 62 | } else if (isLowercase(c)) { 63 | words.push("nn" + c + "nn"); 64 | } else { 65 | words.push("HH" + c + "HH"); 66 | } 67 | break; 68 | case 'auto-long': 69 | if (isNumeric(c)) { 70 | words.push("00" + c + "0101" + c + "11"); 71 | } else if (isLowercase(c)) { 72 | words.push("nn" + c + "nono" + c + "oo"); 73 | } else { 74 | words.push("HH" + c + "HOHO" + c + "OO"); 75 | } 76 | break; 77 | default: 78 | words.push(autopad.replace(/\?/g, c)); 79 | } 80 | }); 81 | } else { 82 | //kern pads 83 | switch (autopad) { 84 | case 'kern-upper': 85 | var glyphselect = document.getElementById('select-glyphs'); 86 | glyphselect.querySelector('option[value^="ABC"]').selected = true; 87 | var outer = VideoProof.getGlyphString(null, false); 88 | var inner = extended ? VideoProof.getGlyphString(null, true) : outer; 89 | 90 | outer = Array.from(outer); 91 | inner = Array.from(inner); 92 | 93 | var c =0; 94 | outer.forEach(function(o) { 95 | inner.forEach(function(i) { 96 | words.push("HO" + o + i + o + "OLA"); 97 | }); 98 | }); 99 | words.push(c); 100 | break; 101 | case 'kern-mixed': 102 | var glyphselect = document.getElementById('select-glyphs'); 103 | glyphselect.querySelector('option[value^="abc"]').selected = true; 104 | var outer = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 105 | var inner = VideoProof.getGlyphString(null, extended); 106 | 107 | outer = Array.from(outer); 108 | inner = Array.from(inner); 109 | 110 | var c =0; 111 | outer.forEach(function(o) { 112 | inner.forEach(function(i) { 113 | words.push(o + i + "nnoy"); 114 | }); 115 | }); 116 | words.push(c); 117 | break; 118 | case 'kern-lower': 119 | var glyphselect = document.getElementById('select-glyphs'); 120 | glyphselect.querySelector('option[value^="abc"]').selected = true; 121 | 122 | var outer = VideoProof.getGlyphString(null, false); 123 | var inner = extended ? VideoProof.getGlyphString(null, true) : outer; 124 | 125 | outer = Array.from(outer); 126 | inner = Array.from(inner); 127 | 128 | var c =0; 129 | outer.forEach(function(o) { 130 | inner.forEach(function(i) { 131 | words.push("no" + o + i + o + "ony"); 132 | }); 133 | }); 134 | words.push(c); 135 | break; 136 | } 137 | } 138 | 139 | proof.innerHTML = ""; 140 | words.forEach(function(word, i) { 141 | var span = document.createElement('span'); 142 | span.textContent = word; 143 | if (i > 0) { 144 | proof.appendChild(document.createTextNode(" ")); 145 | } 146 | proof.appendChild(span); 147 | }); 148 | VideoProof.sizeToSpace(); 149 | } 150 | 151 | setTimeout(populateGrid); 152 | $(document).on('videoproof:fontLoaded.contextual', populateGrid); 153 | $('#select-glyphs').on('change.contextual', populateGrid); 154 | $('#show-extended-glyphs').on('change.contextual', populateGrid); 155 | $('#contextual-pad').on('change', function() { 156 | $('#contextual-custom-pad').val(''); 157 | }); 158 | $('#layout-specific-controls').on('input.contextual change.contextual', populateGrid); 159 | }, 160 | 'deinit': function(proof) { 161 | $(document).off('.contextual'); 162 | $('#select-glyphs').off('.contextual'); 163 | $('#show-extended-glyphs').off('.contextual'); 164 | $('#layout-specific-controls').off('.contextual'); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /layouts/grid.css: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /layouts/grid.js: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 7, laxcomma: true, laxbreak: true */ 2 | 3 | export default { 4 | 'fixedLineBreaks': true, 5 | 'init': function(proof) { 6 | function populateGrid() { 7 | var glyphset = VideoProof.getGlyphString(); 8 | 9 | /* 10 | if (typeof glyphset === 'object' && glyphset.chars && glyphset.feature) { 11 | proof.css('font-feature-settings', '"' + glyphset.feature + '" 1'); 12 | glyphset = glyphset.chars; 13 | } else { 14 | proof.css('font-feature-settings', ''); 15 | } 16 | */ 17 | 18 | proof.innerHTML = ""; 19 | Array.from(glyphset).forEach(function(c) { 20 | var span = document.createElement('span'); 21 | span.textContent = c; 22 | proof.appendChild(span); 23 | }); 24 | VideoProof.fixLineBreaks(); 25 | } 26 | 27 | setTimeout(populateGrid); 28 | $(document).on('videoproof:fontLoaded.grid', populateGrid); 29 | $('#select-glyphs').on('change.grid', populateGrid); 30 | $('#show-extended-glyphs').on('change.grid', populateGrid); 31 | }, 32 | 'deinit': function(proof) { 33 | $(document).off('.grid'); 34 | $('#select-glyphs').off('.grid'); 35 | $('#show-extended-glyphs').off('.grid'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /layouts/type-your-own.css: -------------------------------------------------------------------------------- 1 | 2 | #the-proof.type-your-own { 3 | font-size: 0.5in; 4 | } 5 | -------------------------------------------------------------------------------- /layouts/type-your-own.js: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 7, laxcomma: true, laxbreak: true */ 2 | 3 | export default { 4 | 'controls': { 5 | 'Text': '' 6 | }, 7 | 'init': function(proof) { 8 | 9 | var selectGlyphs = document.getElementById('select-glyphs'); 10 | var showExtended = document.getElementById('show-extended-glyphs'); 11 | 12 | setTimeout(function() { 13 | selectGlyphs.disabled = true; 14 | showExtended.disabled = false; 15 | }); 16 | 17 | function fitToSpace() { 18 | if (proof.textContent.trim().length === 0) { 19 | return; 20 | } 21 | 22 | //VideoProof.setWidest(); 23 | 24 | var winHeight = window.innerHeight - 96; 25 | var gridBox = proof.getBoundingClientRect(); 26 | var gridHeight = gridBox.height; 27 | var fullWidth = gridBox.width; 28 | var fontsize = parseFloat(getComputedStyle(proof).fontSize); 29 | 30 | while (gridHeight < winHeight && proof.scrollWidth <= fullWidth) { 31 | fontsize *= 1.5; 32 | proof.style.fontSize = Math.floor(fontsize) + 'px'; 33 | gridHeight = proof.getBoundingClientRect().height; 34 | } 35 | 36 | while (gridHeight > winHeight || proof.scrollWidth > fullWidth) { 37 | fontsize *= 0.9; 38 | proof.style.fontSize = Math.floor(fontsize) + 'px'; 39 | gridHeight = proof.getBoundingClientRect().height; 40 | if (fontsize < 24) { 41 | break; 42 | } 43 | } 44 | 45 | //VideoProof.unsetWidest(); 46 | } 47 | 48 | function updateProof() { 49 | proof.textContent = document.getElementById('custom-text').value; 50 | if (showExtended.checked) { 51 | var chars = Array.from(proof.textContent.trim()); 52 | var seen = {}; 53 | var extended = ""; 54 | chars.forEach(function(c) { 55 | if (c in seen) { 56 | return; 57 | } 58 | seen[c] = true; 59 | if (c in window.glyphsets._extended) { 60 | extended += window.glyphsets._extended[c]; 61 | } 62 | }); 63 | if (extended.length) { 64 | var span = document.createElement('span'); 65 | span.className = 'extended-chars'; 66 | span.textContent = extended; 67 | proof.appendChild(span); 68 | } 69 | fitToSpace(); 70 | } else { 71 | //fit to width up to window height 72 | proof.style.whiteSpace = 'nowrap'; 73 | fitToSpace(); 74 | proof.style.whiteSpace = ''; 75 | } 76 | } 77 | 78 | $('#custom-text').on('keyup.typeyourown input.typeyourown', updateProof).trigger('change'); 79 | $('#show-extended-glyphs').on('change.typeyourown', updateProof).trigger('change'); 80 | $(document).on('videoproof:fontLoaded.typeyourown', updateProof); 81 | }, 82 | 'deinit': function(proof) { 83 | $('#custom-text').off('.typeyourown'); 84 | $('#show-extended-glyphs').off('.typeyourown'); 85 | $(document).off('.typeyourown'); 86 | document.getElementById('select-glyphs').disabled = false; 87 | } 88 | }; 89 | -------------------------------------------------------------------------------- /legacy.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | Video Proof 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 32 | 33 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | pageHead(); ?> 56 | 57 | 58 |
59 |
60 |

Video Proof

61 | 64 |
65 | 66 | 77 | 78 | 88 | 89 | 90 | 125 | 126 |
127 | Sidebar 128 | 129 | animationControls(); ?> 130 | This animation will eat your CPU alive (depending on browser), so it doesn’t auto-start. Ready? ▶️ 131 | 132 |
133 | Leave a comment here, it will be shared together with the page link.
134 | 135 |
136 | 137 |
138 | 139 | 146 |
147 |
148 | 149 | 150 | -------------------------------------------------------------------------------- /lib/css/fonts.css: -------------------------------------------------------------------------------- 1 | 2 | @font-face { 3 | font-family:'AdobeBlank'; 4 | src:url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2") format("woff2"), 5 | url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.woff") format("woff"), 6 | url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf") format("truetype"); 7 | font-style: normal; 8 | font-weight: 100 900; 9 | } 10 | 11 | @font-face { 12 | font-family:'AdobeBlank'; 13 | src:url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2") format("woff2"), 14 | url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.woff") format("woff"), 15 | url("../../old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf") format("truetype"); 16 | font-style: italic; 17 | font-weight: 100 900; 18 | } 19 | 20 | 21 | @font-face { 22 | font-family: RobotoFlex; 23 | src:url("../../fonts/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].woff") format("woff"); 24 | font-weight:100 900; 25 | } 26 | 27 | @font-face { 28 | font-family: RobotoFlex; 29 | src:url("../../fonts/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].woff") format("woff"); 30 | font-style:italic; 31 | font-weight:100 900; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /lib/js/content-editable.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 9, laxcomma: true, laxbreak: true, unused:true, undef:true */ 2 | 3 | function _compareByStartContainerPosition(rangeA, rangeB) { 4 | const { DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINED_BY 5 | , DOCUMENT_POSITION_PRECEDING, DOCUMENT_POSITION_CONTAINS 6 | } = rangeA.startContainer.ownerDocument.defaultView.Node 7 | , position = rangeA.startContainer.compareDocumentPosition(rangeB.startContainer) 8 | ; 9 | 10 | if (position & DOCUMENT_POSITION_FOLLOWING || position & DOCUMENT_POSITION_CONTAINED_BY) 11 | return -1; 12 | else if (position & DOCUMENT_POSITION_PRECEDING || position & DOCUMENT_POSITION_CONTAINS) 13 | return 1; 14 | // else 0 ... same node 15 | return rangeA.startOffset - rangeB.startOffset; 16 | } 17 | 18 | function* _getAllElementsInBetween(startNode, endNode) { 19 | const { DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINED_BY 20 | , DOCUMENT_POSITION_PRECEDING /*, DOCUMENT_POSITION_CONTAINS*/ 21 | } = startNode.ownerDocument.defaultView.Node; 22 | 23 | let nextNode = startNode; 24 | while(true) { 25 | if(nextNode === endNode) { 26 | yield nextNode; 27 | return; 28 | } 29 | const position = nextNode.compareDocumentPosition(endNode) 30 | // nextNode must be considered deleted after the yield, thus we must 31 | // find next nextNode before yielding current nextNode; 32 | , yieldNode = nextNode 33 | ; 34 | 35 | if(position & DOCUMENT_POSITION_PRECEDING) { 36 | // Happens if endNode is the container node/the editable host 37 | // shouldn't have called this method probably. 38 | return; 39 | // throw new Error('ASSERTION FAILED Node must never be DOCUMENT_POSITION_PRECEDING.'); 40 | } 41 | if(!(position & DOCUMENT_POSITION_FOLLOWING)) // && nextNode !== endNode => returned already 42 | throw new Error('ASSERTION FAILED When node is not DOCUMENT_POSITION_FOLLOWING it must be endNode.'); 43 | 44 | // all are DOCUMENT_POSITION_FOLLOWING 45 | if( position & DOCUMENT_POSITION_CONTAINED_BY) 46 | nextNode = nextNode.firstChild; 47 | else if(!nextNode.nextSibling) { 48 | // Go to `nextNode.parenNode.nextSibling`, but there may be 49 | // no nextSibling then go to 50 | // `nextNode.parenNode.parenNode.nextSibling` and so on. 51 | nextNode = nextNode.parentNode; 52 | while(true) { 53 | if(nextNode.nextSibling) { 54 | nextNode = nextNode.nextSibling; 55 | break; 56 | } 57 | else 58 | nextNode = nextNode.parenNode; 59 | } 60 | } 61 | else 62 | nextNode = nextNode.nextSibling; 63 | 64 | yield yieldNode; 65 | } 66 | } 67 | 68 | function _getCommonAncestorSilblings(range) { 69 | let startAncestorSibling, endAncestorSibling 70 | , { Node } = range.commonAncestorContainer.ownerDocument.defaultView 71 | , commonAncestorElement = range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE 72 | ? range.commonAncestorContainer 73 | : range.commonAncestorContainer.parentElement 74 | ; 75 | for(let elem of [...commonAncestorElement.children, commonAncestorElement]) { 76 | if(!startAncestorSibling && elem.contains(range.startContainer)) { 77 | startAncestorSibling = elem; 78 | } 79 | if(!endAncestorSibling && elem.contains(range.endContainer)) { 80 | endAncestorSibling = elem; 81 | } 82 | if(startAncestorSibling && endAncestorSibling) 83 | break; 84 | } 85 | return [startAncestorSibling, endAncestorSibling]; 86 | } 87 | 88 | function _clearEmptyAncestorsUntil(node, stopNode) { 89 | const { Node } = node.ownerDocument.defaultView; 90 | if(!node.parentElement || !stopNode.contains(node)) 91 | return [null, null]; 92 | let offset = 0; 93 | if(node === stopNode) 94 | return [node, offset];// what to return for offset? 95 | 96 | while(node !== stopNode && ( 97 | node.nodeType === Node.TEXT_NODE && node.data.length === 0 98 | || node.nodeType === Node.ELEMENT_NODE && node.childNodes.length === 0)) { 99 | // is not stopNode and empty 100 | // we wan't to have an offset for the node that is about to be removed 101 | // as in a Range, the startOffset is within startContainer. 102 | offset = Math.max(0, [...node.parentElement.childNodes].indexOf(node)-1); 103 | let remove = node; 104 | node = node.parentElement; 105 | remove.parentNode.removeChild(remove); 106 | } 107 | // first none empty ancestor 108 | return [node, offset]; 109 | } 110 | 111 | // Return the closest startContainer/startOffset for a new cursor position 112 | // after this operation. 113 | function _deleteRange(domTool, range) { 114 | const { Node } = domTool.window 115 | , { startContainer, endContainer, startOffset, endOffset } = range 116 | // these share the same parent and respectiveley contain start 117 | // and end container. 118 | , [startAncestorSibling, endAncestorSibling] = _getCommonAncestorSilblings(range) 119 | , editableHost = (startContainer.closest 120 | ? startContainer 121 | : startContainer.parentElement 122 | ).closest('[contenteditable]') 123 | , commonParentElement = startAncestorSibling.parentElement 124 | , startAncestorSiblingOffset = [...commonParentElement.childNodes].indexOf(startAncestorSibling) 125 | ; 126 | 127 | // make sure all containers are within editableHost ... 128 | for(const node of _getAllElementsInBetween(startContainer, endContainer)) { 129 | const isElement = node.nodeType === Node.ELEMENT_NODE; 130 | // If node is not an element or a text: delete it. 131 | if(!isElement && node.nodeType !== Node.TEXT_NODE) { 132 | node.parentNode.removeChild(node); 133 | continue; 134 | } 135 | // is element or text node; 136 | 137 | // Don't delete ancestors of startContainer or endContainer, 138 | // so maybe we shouldn't yield them either.... 139 | // Eventually we will delete ancestors if they are empty. 140 | if(node !== startContainer && node !== endContainer) { 141 | if(isElement && !(node.contains(startContainer) || node.contains(endContainer))) { 142 | node.parentNode.removeChild(node); 143 | } 144 | continue; 145 | } 146 | 147 | // is startContainer or endContainer 148 | const nodeStartOfffset = node === startContainer 149 | ? startOffset 150 | : 0 151 | , nodeEndOffset = node === endContainer 152 | ? endOffset 153 | : (isElement 154 | ? node.childNodes.length 155 | : node.data.length 156 | ) 157 | ; 158 | // delete contents 159 | if(isElement) { 160 | if(node.contains(endContainer)) 161 | // Special case, not sure, if this is the full/a good enough 162 | // handling of the issue. Case was: 163 | // startContainer:
offset: 0 164 | // endContainer: first textNode in first

of startContainer offset: 1 165 | // And, subsequently, nodeEndOffset was node.childNodes.length 166 | // and deleting everything in startContainer 167 | // 168 | continue; 169 | for(let i=nodeEndOffset-1;i>=nodeStartOfffset;i--){ 170 | node.removeChild(node.childNodes[i]); 171 | } 172 | } 173 | else { 174 | // is TextNode 175 | node.deleteData(nodeStartOfffset, nodeEndOffset - nodeStartOfffset); 176 | } 177 | } 178 | 179 | let commonStopNode = commonParentElement.contains(editableHost) 180 | ? editableHost 181 | : commonParentElement 182 | ; 183 | let [noneEmptyStartAncestor, noneEmptyStartAncestorOffset] = _clearEmptyAncestorsUntil(startContainer, commonStopNode); 184 | _clearEmptyAncestorsUntil(endContainer, commonStopNode); 185 | 186 | // merging 187 | if( // both still in DOM 188 | startAncestorSibling.parentNode && endAncestorSibling.parentNode 189 | // no need to merge otherwise 190 | && startAncestorSibling !== endAncestorSibling 191 | // No need to merge textNodes, as we have element.normalize 192 | && startAncestorSibling.nodeType === Node.ELEMENT_NODE 193 | && endAncestorSibling.nodeType === Node.ELEMENT_NODE 194 | // And both are "compatible" The following should/could be a check 195 | // injected into this function, as compatibility depends on 196 | // content semantics. 197 | // 198 | // In this case, we want to merge paragaphs in order to remove 199 | // the line break withing the range... 200 | && startAncestorSibling.tagName === 'P' 201 | && endAncestorSibling.tagName === 'P') { 202 | // Can use Element API, because we checked nodeType. 203 | startAncestorSibling.append(...endAncestorSibling.childNodes); 204 | endAncestorSibling.remove(); 205 | } 206 | // could keep for cursor position, but this normalizes between FireFox/Chromium. 207 | if(!startAncestorSibling.childNodes.length && startAncestorSibling !== editableHost){ 208 | startAncestorSibling.remove(); 209 | return [commonParentElement, startAncestorSiblingOffset]; 210 | } 211 | if(startContainer.parentNode) { 212 | // startContainer is still there! 213 | return [startContainer, startOffset]; 214 | } 215 | if(noneEmptyStartAncestor && noneEmptyStartAncestor.parentNode){ 216 | return [noneEmptyStartAncestor, noneEmptyStartAncestorOffset]; 217 | } 218 | return [startAncestorSibling, startAncestorSiblingOffset]; 219 | } 220 | 221 | 222 | function _deleteRanges(domTool, editableHost, ranges) { 223 | // In reverse order, so previous ranges stay valid. 224 | // ASSERT: ranges don't overlap 225 | // ASSERT: ranges are not sorted 226 | // because ranges don't overlap, they can be sorted by means of 227 | // their startContainer position 228 | ranges.sort(_compareByStartContainerPosition); 229 | let lastResult; 230 | for(let i=ranges.length-1;i>=0;i--) 231 | lastResult = _deleteRange(domTool, ranges[i]); 232 | return lastResult; 233 | } 234 | 235 | /** 236 | * Includes node as first element in the returned array 237 | */ 238 | function _getNextSiblings(node) { 239 | let siblings = []; 240 | while(node) { 241 | siblings.push(node); 242 | node = node.nextSibling; 243 | } 244 | return siblings; 245 | } 246 | 247 | /** 248 | * That's the most comprehensive explanation of how InputEvents 249 | * are constituted: 250 | * https://w3c.github.io/input-events/#interface-InputEvent 251 | */ 252 | export function handleEditableDiv(domTool, event) { 253 | // This destroys the native undo/redo mechanism. 254 | // E.g. ctrl+z, ctrl+y don't do anything anymore and "historyUndo", 255 | // "historyRedo" don't appear in here anymore; However, that stuff is 256 | // not scriptable/available as API, so we can hardly do anything about 257 | // it. Instead, the overall app state could be used for history management. 258 | // 259 | // Using https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand 260 | // would actually keep that history management feature working, but 261 | // it is deprecated and a peculiar API anyways. 262 | event.preventDefault(); 263 | 264 | const { Range, Node } = domTool.window 265 | , editableHost = event.target.closest('[contenteditable]') 266 | ; 267 | let textContent; 268 | 269 | // In contenteditable, these use event.dataTransfer 270 | // and event.getTargetRanges() returns a "Non-empty Array" 271 | // "insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop", "insertReplacementText", "insertFromYank" 272 | 273 | // In contenteditable, these use event.data 274 | // and event.getTargetRanges() returns a "Non-emp ty Array" 275 | // "insertText", "insertCompositionText", "formatSetBlockTextDirection", "formatSetInlineTextDirection", "formatBackColor", "formatFontColor", "formatFontName", "insertLink" 276 | 277 | const hasDataTransfer = new Set(["insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop", "insertReplacementText", "insertFromYank"]) 278 | , hasData = new Set(["insertText", "insertCompositionText", "formatSetBlockTextDirection", "formatSetInlineTextDirection", "formatBackColor", "formatFontColor", "formatFontName", "insertLink"]) 279 | ; 280 | 281 | if(hasDataTransfer.has(event.inputType)) { 282 | textContent = event.dataTransfer.getData('text/plain'); 283 | } 284 | else if(hasData.has(event.inputType)) { 285 | // These are going to insert only text anyways, should be a bit 286 | // simpler to handle ... 287 | textContent = event.data; 288 | } 289 | else if(event.inputType === 'insertLineBreak') 290 | textContent = '\n'; 291 | 292 | 293 | // In contenteditable and plain text input fields: 294 | // event.dataTransfer === event.data === null 295 | // and event.getTargetRanges() returns an "Empty Array" 296 | // "historyUndo", "historyRedo" 297 | 298 | // In contenteditable and plain text input fields: 299 | // event.dataTransfer === event.data === null 300 | // and event.getTargetRanges() returns an "Non-empty Array" 301 | // All Remaining ??? 302 | 303 | let selection = event.target.ownerDocument.getSelection() 304 | , staticRanges = event.getTargetRanges() 305 | ; 306 | 307 | // Firefox will happily delete multiple ranges, // "historyUndo", "historyRedo" 308 | 309 | // but, it will collapse to the end of the first Range, while 310 | // it now collapses to the end of the last range. Inserting is then 311 | // done at the first range cursor. This seems to be not and 312 | // issue, can keep as it or change later. 313 | 314 | const liveRanges = []; 315 | for(let staticRange of staticRanges) { 316 | let liveRange = new Range() 317 | , [startContainer, startOffset] = editableHost.contains(staticRange.startContainer) 318 | ? [staticRange.startContainer, staticRange.startOffset] 319 | : [editableHost.firstChild, 0] 320 | , [endContainer, endOffset] = editableHost.contains(staticRange.endContainer) 321 | ? [staticRange.endContainer, staticRange.endOffset] 322 | : [editableHost.lastChild, editableHost.childNodes.length] 323 | ; 324 | liveRange.setStart(startContainer, startOffset); 325 | liveRange.setEnd(endContainer, endOffset); 326 | liveRanges.push(liveRange); 327 | } 328 | 329 | // delete 330 | let [startContainerAfterDelete, startOffsetAfterDelete] = _deleteRanges(domTool, editableHost, liveRanges) 331 | , rangeAfterDelete = new Range() 332 | ; 333 | // Set the cursor to the position from where to insert next. 334 | rangeAfterDelete.setStart(startContainerAfterDelete, startOffsetAfterDelete); 335 | rangeAfterDelete.collapse(); 336 | selection.removeAllRanges(); 337 | 338 | selection.addRange(rangeAfterDelete); 339 | 340 | // and insert 341 | if(event.inputType === 'insertParagraph') { 342 | let cursor = selection.getRangeAt(0) 343 | , startContainer = cursor.startContainer 344 | , startOffset = cursor.startOffset 345 | , firstInsertedNode, lastInsertedNode 346 | ; 347 | 348 | while(true) { 349 | if(startContainer.nodeType === Node.TEXT_NODE) { 350 | // startOffset references a position in the Text 351 | lastInsertedNode = startContainer.splitText(startOffset); 352 | if(!firstInsertedNode) 353 | firstInsertedNode = lastInsertedNode; 354 | startContainer = startContainer.parentElement; 355 | startOffset = [...startContainer.childNodes].indexOf(lastInsertedNode); 356 | continue; 357 | } 358 | if(startContainer.nodeType !== Node.ELEMENT_NODE) 359 | // It's also a failed assertion! 360 | throw new Error(`ASSERTION FAILED/NOT SUPPORTED insertParagraph into ` 361 | +`${startContainer.nodeName}/${startContainer.nodeType}`); 362 | // startContainer is an Element 363 | if(startContainer !== editableHost) { 364 | // If it is a

it should be a direct child of editableHost, 365 | // but we don't assert that! It could also be a span within a 366 | // p or even be nested further down within other inline elements. 367 | 368 | lastInsertedNode = startContainer.cloneNode(false); 369 | if(!firstInsertedNode) 370 | firstInsertedNode = lastInsertedNode; 371 | // split it at startOffset 372 | const children = _getNextSiblings(startContainer.childNodes[startOffset]); 373 | lastInsertedNode.append(...children); 374 | startContainer.after(lastInsertedNode); 375 | startOffset = [...startContainer.childNodes].indexOf(lastInsertedNode); 376 | startContainer = startContainer.parentElement; 377 | continue; 378 | } 379 | 380 | // startContainer === editableHost 381 | if(!lastInsertedNode) { 382 | let newP = domTool.createElement('p'); 383 | newP.append(''); 384 | 385 | // insert newP at startOffset 386 | if(startContainer.childNodes[startOffset]) 387 | domTool.insertAfter(newP, startContainer.childNodes[startOffset]); 388 | else 389 | startContainer.insertBefore(newP, null); 390 | 391 | firstInsertedNode = newP; 392 | } 393 | else if(lastInsertedNode.nodeType !== Node.ELEMENT_NODE || lastInsertedNode.tagName !== 'P') { 394 | let newP = domTool.createElement('p') 395 | , children = _getNextSiblings(lastInsertedNode) 396 | , indexOfFirstP = children.findIndex(element => element.tagName === 'P') 397 | ; 398 | if(indexOfFirstP !== -1) 399 | children = children.slice(0, indexOfFirstP); 400 | 401 | startContainer.replaceChild(newP, lastInsertedNode); 402 | newP.append(...children); 403 | } 404 | //else: all good already 405 | 406 | cursor.setStart(firstInsertedNode, 0); 407 | break; 408 | } 409 | } 410 | else if(textContent) { 411 | let cursor = selection.getRangeAt(0) 412 | , newContentsFragement = domTool.createTextNode(textContent) 413 | ; 414 | // TODO: 415 | // * make sure cursor is withing the contenteditable (let's take this as granted) 416 | // * maybe, e.g. on paste, insert multiple paragraphs in an orderly 417 | // fashion. 418 | 419 | // If the cursor is not within a

now, we should move it into one. 420 | // the easiest is to just to `Range.surroundContents(aNewP);` and later 421 | // clean up possible empty remaining

, as we have to do so anyways. 422 | // 423 | // This test works if the structure in editableHost is only flat 424 | //

elements and nothing else... 425 | let cursorElement = cursor.startContainer.nodeType === Node.ELEMENT_NODE 426 | ? cursor.startContainer 427 | : cursor.startContainer.parentElement 428 | ; 429 | 430 | if(!cursorElement.closest('[contenteditable] p')) { 431 | let newP = domTool.createElement('p'); 432 | cursor.surroundContents(newP); 433 | if(!newP.childNodes.length) { 434 | let newText = domTool.createTextNode(''); 435 | newP.append(newText); 436 | } 437 | cursor.setEnd(newP.lastChild, newP.lastChild.textContent.length); 438 | cursor.collapse(); 439 | } 440 | // cursor is now within a

! 441 | let parentElement = cursor.endContainer.parentElement 442 | , endOffset = cursor.endOffset 443 | ; 444 | cursor.insertNode(newContentsFragement); 445 | // Extra effort to move the cursor after the insertion for 446 | // iOS: see issue https://github.com/FontBureau/videoproof/issues/29 447 | // "Text is Inputting backwards" 448 | parentElement.normalize(); 449 | cursor.setEnd(parentElement.firstChild, endOffset+textContent.length); 450 | selection.removeAllRanges(); 451 | selection.addRange(cursor); 452 | } 453 | // use selection.collapseToStart() and experience the cursor moving 454 | // in the wrong direction when typing! 455 | // It's interesting, on iOS the cursor still moves backwards, on 456 | // entering text. 457 | selection.collapseToEnd(); 458 | } 459 | 460 | export function handleEditableLine(domTool, event) { 461 | // This destroys the native undo/redo mechanism. 462 | // E.g. ctrl+z, ctrl+y don't do anything anymore and "historyUndo", 463 | // "historyRedo" don't appear in here anymore; However, that stuff is 464 | // not scriptable/available as API, so we can hardly do anything about 465 | // it. Instead, the overall app state could be used for history management. 466 | // 467 | // Using https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand 468 | // would actually keep that history management feature working, but 469 | // it is deprecated and a peculiar API anyways. 470 | event.preventDefault(); 471 | 472 | const { Range } = domTool.window 473 | , editableHost = event.target.closest('[contenteditable]') 474 | ; 475 | let textContent; 476 | 477 | // In contenteditable, these use event.dataTransfer 478 | // and event.getTargetRanges() returns a "Non-empty Array" 479 | // "insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop", "insertReplacementText", "insertFromYank" 480 | 481 | // In contenteditable, these use event.data 482 | // and event.getTargetRanges() returns a "Non-emp ty Array" 483 | // "insertText", "insertCompositionText", "formatSetBlockTextDirection", "formatSetInlineTextDirection", "formatBackColor", "formatFontColor", "formatFontName", "insertLink" 484 | 485 | const hasDataTransfer = new Set(["insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop", "insertReplacementText", "insertFromYank"]) 486 | , hasData = new Set(["insertText", "insertCompositionText", "formatSetBlockTextDirection", "formatSetInlineTextDirection", "formatBackColor", "formatFontColor", "formatFontName", "insertLink"]) 487 | ; 488 | 489 | if(hasDataTransfer.has(event.inputType)) { 490 | textContent = event.dataTransfer.getData('text/plain'); 491 | } 492 | else if(hasData.has(event.inputType)) { 493 | // These are going to insert only text anyways, should be a bit 494 | // simpler to handle ... 495 | textContent = event.data; 496 | } 497 | else if(['insertLineBreak', 'insertParagraph'].includes(event.inputType)) 498 | textContent = '\n'; 499 | 500 | // In contenteditable and plain text input fields: 501 | // event.dataTransfer === event.data === null 502 | // and event.getTargetRanges() returns an "Empty Array" 503 | // "historyUndo", "historyRedo" 504 | 505 | // In contenteditable and plain text input fields: 506 | // event.dataTransfer === event.data === null 507 | // and event.getTargetRanges() returns an "Non-empty Array" 508 | // All Remaining ??? 509 | 510 | let selection = event.target.ownerDocument.getSelection() 511 | , staticRanges = event.getTargetRanges() 512 | ; 513 | 514 | // Firefox will happily delete multiple ranges, // "historyUndo", "historyRedo" 515 | 516 | // but, it will collapse to the end of the first Range, while 517 | // it now collapses to the end of the last range. Inserting is then 518 | // done at the first range cursor. This seems to be not and 519 | // issue, can keep as it or change later. 520 | 521 | const liveRanges = []; 522 | for(let staticRange of staticRanges) { 523 | let liveRange = new Range() 524 | , [startContainer, startOffset] = editableHost.contains(staticRange.startContainer) 525 | ? [staticRange.startContainer, staticRange.startOffset] 526 | : [editableHost.firstChild, 0] 527 | , [endContainer, endOffset] = editableHost.contains(staticRange.endContainer) 528 | ? [staticRange.endContainer, staticRange.endOffset] 529 | : [editableHost.lastChild, editableHost.childNodes.length] 530 | ; 531 | liveRange.setStart(startContainer, startOffset); 532 | liveRange.setEnd(endContainer, endOffset); 533 | liveRanges.push(liveRange); 534 | } 535 | 536 | // delete 537 | let [startContainerAfterDelete, startOffsetAfterDelete] = _deleteRanges(domTool, editableHost, liveRanges) 538 | , rangeAfterDelete = new Range() 539 | ; 540 | // Set the cursor to the position from where to insert next. 541 | rangeAfterDelete.setStart(startContainerAfterDelete, startOffsetAfterDelete); 542 | rangeAfterDelete.collapse(); 543 | selection.removeAllRanges(); 544 | 545 | selection.addRange(rangeAfterDelete); 546 | 547 | if(textContent) { 548 | let cursor = selection.getRangeAt(0) 549 | , newContentsFragement = domTool.createTextNode(textContent) 550 | , parentElement = cursor.endContainer.parentElement 551 | , endOffset = cursor.endOffset 552 | ; 553 | // Extra effort to move the cursor after the insertion for 554 | // iOS: see issue https://github.com/FontBureau/videoproof/issues/29 555 | // "Text is Inputting backwards" 556 | cursor.insertNode(newContentsFragement); 557 | parentElement.normalize(); 558 | // This failed sometimes, had an out og range error, 559 | // but even adding the Math.min didn't help. 560 | // the cursor.collapse(false) however works so far, I'm 561 | // leaving the failing line in case another issue comes up. 562 | // cursor.setEnd(parentElement.firstChild, Math.min(endOffset+textContent.length, parentElement.firstChild.textContent.length)); 563 | cursor.collapse(false); 564 | selection.removeAllRanges(); 565 | selection.addRange(cursor); 566 | } 567 | // use selection.collapseToStart() and experience the cursor moving 568 | // in the wrong direction when typing! 569 | // It's interesting, on iOS the cursor still moves backwards, on 570 | // entering text. 571 | selection.collapseToEnd(); 572 | } 573 | 574 | 575 | -------------------------------------------------------------------------------- /lib/js/diff_match_patch/build.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # Create an JavaScript/ECMAScript Module from the plain JavaScript file. 4 | # This requires the original diff_match_patch as a git submodule (or copy) 5 | # in the root directory: 6 | # $ git submodule add https://github.com/google/diff-match-patch.git diff-match-patch 7 | 8 | # There's a line: 9 | # '// CLOSURE:begin_strip' 10 | # After that line definitons to the global namespace are attempted. 11 | # Exclude everything after that line. 12 | # 13 | # These lines: 14 | # 'var DIFF_DELETE = -1;' 15 | # 'var DIFF_INSERT = 1;' 16 | # 'var DIFF_EQUAL = 0;' 17 | # Should become: 18 | # 'export const DIFF_DELETE = -1;' 19 | # 'export const DIFF_INSERT = 1;' 20 | # 'export const DIFF_EQUAL = 0;' 21 | # Thus find 'var DIFF_' and replace with 'export const DIFF_'. 22 | # 23 | # Finally add the line 24 | # 'export default diff_match_patch;' 25 | 26 | 27 | 28 | SOURCE=../../../diff-match-patch/javascript/diff_match_patch_uncompressed.js; 29 | TARGET=diff_match_patch.mjs; 30 | 31 | cat $SOURCE | \ 32 | awk ' 33 | BEGIN { print "// CAUTION - DONT EDIT: this file has been created automatically!" } 34 | # exit when this line occurs 35 | /^\/\/ CLOSURE:begin_strip$/ {exit} 36 | # find and replace: 37 | { sub(/^var DIFF_/,"export const DIFF_"); print } 38 | # finally add default export 39 | END { print "export default diff_match_patch;" } 40 | ' > $TARGET; 41 | 42 | -------------------------------------------------------------------------------- /lib/js/domTool.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 7, laxcomma: true, laxbreak: true */ 2 | 3 | // I took this from googlefonts/fontbakery-dashboard and made it into a es module. 4 | // `document` is not required/expected to be global anymore, it's injected 5 | 6 | // skip markdown parsing for now 7 | // import marked from 'marked.mjs'; 8 | function marked(){ 9 | throw new Error('Markdown parser `marked` is not available'); 10 | } 11 | 12 | function ValueError(message) { 13 | this.name = 'ValueError'; 14 | this.message = message || '(No message for ValueError)'; 15 | this.stack = (new Error()).stack; 16 | } 17 | ValueError.prototype = Object.create(Error.prototype); 18 | ValueError.prototype.constructor = ValueError; 19 | 20 | export default class DOMTool { 21 | constructor(document){ 22 | this.document = document; 23 | } 24 | 25 | get window(){ 26 | return this.document.defaultView; // fancy way to do this 27 | } 28 | 29 | get documentElement() { 30 | return this.document.documentElement; // fancy way to do this 31 | } 32 | 33 | static appendChildren(elem, contents, cloneChildNodes) { 34 | var _contents = (contents === undefined || contents === null) 35 | ? [] 36 | : (contents instanceof Array ? contents : [contents]) 37 | ; 38 | for(let child of _contents) { 39 | if(!child || typeof child.nodeType !== 'number') 40 | child = DOMTool.createTextNode(elem.ownerDocument, child); 41 | else if(cloneChildNodes) 42 | child = child.cloneNode(true);//always a deep clone 43 | elem.appendChild(child); 44 | } 45 | } 46 | 47 | static createTextNode(document, text) { 48 | return document.createTextNode(text); 49 | } 50 | 51 | createTextNode(text) { 52 | return DOMTool.createTextNode(this.document, text); 53 | } 54 | 55 | static createElement(document, tagname, attr, contents, cloneChildNodes) { 56 | var elem = attr && 'xmlns' in attr 57 | ? document.createElementNS(attr.xmlns, tagname) 58 | : document.createElement(tagname) 59 | ; 60 | 61 | if(attr) for(let k in attr) { 62 | if(k === 'xmlns') 63 | continue; 64 | elem.setAttribute(k, attr[k]); 65 | } 66 | 67 | DOMTool.appendChildren(elem, contents, cloneChildNodes); 68 | return elem; 69 | } 70 | 71 | createElement(tagname, attr, contents, cloneChildNodes) { 72 | return DOMTool.createElement(this.document, tagname, attr, 73 | contents, cloneChildNodes); 74 | } 75 | 76 | static createChildElement(parent, tagname, attr, contents, cloneChildNodes) { 77 | var elem = DOMTool.createElement(parent.ownerDocument, tagname, attr, contents, cloneChildNodes); 78 | parent.appendChild(elem); 79 | return elem; 80 | } 81 | 82 | createChildElement(parent, tagname, attr, contents, cloneChildNodes){ 83 | return DOMTool.createChildElement(parent, tagname, attr, contents, cloneChildNodes); 84 | } 85 | 86 | static createElementFromHTML(document, tag, attr, innerHTMl) { 87 | var frag = DOMTool.createFragmentFromHTML(document, innerHTMl); 88 | return DOMTool.createElement(document, tag, attr, frag); 89 | } 90 | 91 | static createElementfromHTML(...args) { 92 | return this.createElementFromHTML(...args); 93 | } 94 | 95 | createElementFromHTML(tag, attr, innerHTMl) { 96 | return DOMTool.createElementFromHTML(this.document, tag, attr, innerHTMl); 97 | } 98 | 99 | createElementfromHTML(...args) { 100 | return this.createElementFromHTML(...args); 101 | } 102 | 103 | static createElementFromMarkdown(document, tag, attr, markdownText) { 104 | return DOMTool.createElementfromHTML(document, tag, attr, marked(markdownText, {gfm: true})); 105 | } 106 | 107 | static createElementfromMarkdown(...args) { 108 | return this.createElementfromMarkdown(...args); 109 | } 110 | 111 | createElementFromMarkdown(document, tag, attr, markdownText) { 112 | return DOMTool.createElementfromMarkdown(this.document, tag, attr, markdownText); 113 | } 114 | 115 | createElementfromMarkdown(...args) { 116 | return this.createElementFromMarkdown(...args); 117 | } 118 | 119 | static createFragmentFromMarkdown(document, mardownText) { 120 | return DOMTool.createFragmentFromHTML(document, marked(mardownText, {gfm: true})); 121 | } 122 | 123 | createFragmentFromMarkdown(mardownText) { 124 | return DOMTool.createFragmentFromMarkdown(this.document, mardownText); 125 | } 126 | 127 | static appendHTML(document, elem, html) { 128 | var frag = DOMTool.createFragmentFromHTML(document, html); 129 | elem.appendChild(frag); 130 | } 131 | appendHTML(elem, html) { 132 | DOMTool.appendHTML(this.document, elem, html); 133 | } 134 | 135 | static appendMarkdown(document, elem, markdown) { 136 | DOMTool.appendHTML(document, elem, marked(markdown, {gfm: true})); 137 | } 138 | 139 | appendMarkdown(elem, markdown) { 140 | return DOMTool.appendMarkdown(this.document, elem, markdown); 141 | } 142 | 143 | static createFragmentFromHTML(document, html) { 144 | return document.createRange().createContextualFragment(html); 145 | } 146 | 147 | createFragmentFromHTML(html) { 148 | return DOMTool.createFragmentFromHTML(this.document, html); 149 | } 150 | 151 | static createFragment(document, contents, cloneChildNodes) { 152 | var frag = document.createDocumentFragment(); 153 | DOMTool.appendChildren(frag, contents, cloneChildNodes); 154 | return frag; 155 | } 156 | 157 | createFragment(contents, cloneChildNodes) { 158 | return DOMTool.createFragment(this.document, contents, cloneChildNodes); 159 | } 160 | 161 | static createComment(document, text) { 162 | return document.createComment(text); 163 | } 164 | 165 | createComment(document, text){ 166 | return DOMTool.createComment(this.document, text); 167 | } 168 | 169 | 170 | static isDOMElement(node) { 171 | return node && node.nodeType && node.nodeType === 1; 172 | } 173 | 174 | static replaceNode(newNode, oldNode) { 175 | if(oldNode.parentNode) // replace has no effect if oldNode has no place 176 | oldNode.parentNode.replaceChild(newNode, oldNode); 177 | } 178 | 179 | static removeNode(node) { 180 | if(node.parentNode) 181 | node.parentNode.removeChild(node); 182 | } 183 | 184 | static insertBefore(newElement, referenceElement) { 185 | if(referenceElement.parentElement && newElement !== referenceElement) 186 | referenceElement.parentElement.insertBefore(newElement 187 | , referenceElement); 188 | } 189 | 190 | static insertAfter(newElement, referenceElement) { 191 | // there is no element.insertAfter() in the DOM 192 | if(!referenceElement.nextSibling) 193 | referenceElement.parentElement.appendChild(newElement); 194 | else 195 | DOMTool.insertBefore(newElement, referenceElement.nextSibling); 196 | } 197 | 198 | static insert(element, position, child) { 199 | if(typeof child === 'string') 200 | child = DOMTool.createTextNode(element.ownerDocument, child); 201 | switch(position) { 202 | case 'append': 203 | element.appendChild(child); 204 | break; 205 | case 'prepend': 206 | if(element.firstChild) 207 | DOMTool.insertBefore(child, element.firstChild); 208 | else 209 | element.appendChild(child); 210 | break; 211 | case 'before': 212 | DOMTool.insertBefore(child, element); 213 | break; 214 | case 'after': 215 | DOMTool.insertAfter(child, element); 216 | break; 217 | default: 218 | throw new ValueError('Unknown position keyword "'+position+'".'); 219 | } 220 | } 221 | 222 | static getChildElementForSelector(element, selector, deep) { 223 | var elements = Array.prototype.slice 224 | .call(element.querySelectorAll(selector)); 225 | if(!deep) 226 | // I don't know an easier way to only allow 227 | // direct children. 228 | elements = elements.filter(elem=>elem.parentNode === element); 229 | return elements[0] || null; 230 | } 231 | 232 | static getMarkerComment(element, marker) { 233 | var frames = [[element && element.childNodes, 0]] 234 | , frame, nodelist, i, l, childNode 235 | ; 236 | main: 237 | while((frame = frames.pop()) !== undefined){ 238 | nodelist = frame[0]; 239 | for(i=frame[1],l=nodelist.length;i not found'); 264 | } 265 | 266 | static dispatchEvent(target, eventName, eventOptions) { 267 | const { Event } = target.ownerDocument.defaultView; 268 | return target.dispatchEvent(new Event(eventName, eventOptions)); 269 | } 270 | 271 | static clear(target, destroyEventName) { 272 | while(target.lastChild) { 273 | if(destroyEventName) 274 | // children can listen for the event and cleanup if needed 275 | // activatedElement.addEventListener('destroy', function (e) { //... }, false); 276 | DOMTool.dispatchEvent(target.lastChild, destroyEventName); 277 | DOMTool.removeNode(target.lastChild); 278 | } 279 | } 280 | 281 | // TODO: document what this is for. 282 | static validateChildEvent(event, stopElement, ...searchAttributes) { 283 | var elem = event.target 284 | , results 285 | ; 286 | if(event.defaultPrevented) return; 287 | 288 | search: 289 | while(true) { 290 | if(elem === stopElement.parentElement || !elem) 291 | return; 292 | 293 | for(let searchAttribute of searchAttributes){ 294 | if(elem.hasAttribute(searchAttribute)) 295 | // found! 296 | break search; 297 | } 298 | elem = elem.parentElement; 299 | } 300 | event.preventDefault(); 301 | 302 | if(searchAttributes.length === 1) 303 | return elem.getAttribute(searchAttributes[0]); 304 | 305 | results = {}; 306 | for(let attr of searchAttributes) 307 | results[attr] = elem.getAttribute(attr); 308 | return results; 309 | } 310 | 311 | static getComputedStyle(elem) { 312 | return elem.ownerDocument.defaultView.getComputedStyle(elem); 313 | } 314 | 315 | static getComputedPropertyValues(elem, ...properties) { 316 | var style = DOMTool.getComputedStyle(elem) 317 | , result = [] 318 | ; 319 | for(let p of properties) { 320 | result.push(style.getPropertyValue(p)); 321 | } 322 | return result; 323 | } 324 | 325 | static getElementSizesInPx(elem, ...properties) { 326 | // At the moment asserting expecting all queried properties 327 | // to return "px" values. 328 | var result = []; 329 | for(let [i, vStr] of DOMTool.getComputedPropertyValues(elem, ...properties).entries()){ 330 | let p = properties[i]; 331 | if(vStr.slice(-2) !== 'px') 332 | throw new Error(`Computed style of "${p}" did not yield a "px" value: ${vStr}`); 333 | let val = parseFloat(vStr.slice(0, -2)); 334 | if(val !== val) 335 | throw new Error(`Computed style of "${p}" did not parse to a float: ${vStr}`); 336 | result.push(val); 337 | } 338 | return result; 339 | } 340 | 341 | 342 | } 343 | 344 | // static functions to methods, these don't require the `this` state 345 | DOMTool.prototype.appendChildren = DOMTool.appendChildren; 346 | DOMTool.prototype.isDOMElement = DOMTool.isDOMElement; 347 | DOMTool.prototype.replaceNode = DOMTool.replaceNode; 348 | DOMTool.prototype.removeNode = DOMTool.removeNode; 349 | DOMTool.prototype.insertBefore = DOMTool.insertBefore; 350 | DOMTool.prototype.insertAfter = DOMTool.insertAfter; 351 | DOMTool.prototype.insert = DOMTool.insert; 352 | DOMTool.prototype.getChildElementForSelector = DOMTool.getChildElementForSelector; 353 | DOMTool.prototype.getMarkerComment = DOMTool.getMarkerComment; 354 | DOMTool.prototype.insertAtMarkerComment = DOMTool.insertAtMarkerComment; 355 | DOMTool.prototype.dispatchEvent = DOMTool.dispatchEvent; 356 | DOMTool.prototype.clear = DOMTool.clear; 357 | DOMTool.prototype.validateChildEvent = DOMTool.validateChildEvent; 358 | DOMTool.prototype.getElementSizesInPx = DOMTool.getElementSizesInPx; 359 | 360 | export const getComputedStyle = DOMTool.getComputedStyle; // jshint ignore:line 361 | export const getComputedPropertyValues = DOMTool.getComputedPropertyValues; 362 | export const getElementSizesInPx = DOMTool.getElementSizesInPx; 363 | -------------------------------------------------------------------------------- /lib/js/layouts/vartools-grid.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 9, laxcomma: true, laxbreak: true, unused:true, undef:true */ 2 | import { handleEditableLine } from '../content-editable.mjs'; 3 | 4 | function* gridDimensionGenerator({axisTag, stepping, from, to, steppingValue}) { 5 | if(axisTag === 'disabled' || steppingValue <= 0){ 6 | yield null; 7 | return; 8 | } 9 | 10 | const stepSize = (stepping === 'steps') 11 | ? Math.abs(from - to) / steppingValue 12 | : steppingValue 13 | , step = to < from ? -stepSize : stepSize 14 | , change = to > from 15 | // the last step may be smaller 16 | ? value=>Math.min(value+step, to) 17 | : value=>Math.max(value+step, to) 18 | ; 19 | 20 | let value=from; 21 | while(true) { 22 | const yieldValue = Math.round(value * 100) / 100; 23 | yield yieldValue; 24 | if(yieldValue === to) break; 25 | // Not based on yieldValue because it could cause a 26 | // never ending loop. 27 | value=change(value); 28 | } 29 | } 30 | 31 | function _fontVariationSettingsFromProperties(varProperties) { 32 | return varProperties 33 | .map(([axisTag, propertyName])=>{ 34 | return axisTag === 'opsz' 35 | ? `"${axisTag}" var(${propertyName}, var(${FONT_SIZE_CUSTOM_PROPERTY}))` 36 | : `"${axisTag}" var(${propertyName}, 0)` 37 | ; 38 | }).join(', '); 39 | } 40 | 41 | const GRID_CONTAINER_CLASS = 'grid-container' 42 | , ROW_CLASS = 'grid-row' 43 | , CELL_CLASS = 'grid-cell' 44 | , CELL_CONTENT_CLASS = 'grid-cell_content' 45 | , SHOW_PARAMETERS_CLASS = 'grid-show_parameters' 46 | , TOGGLE_EDIT_CLASS = 'grid-toggle_edit' 47 | // Selectors for classes 48 | , CELL_SELECTOR = `.${CELL_CLASS}` 49 | , CELL_CONTENT_SELECTOR = `.${CELL_CONTENT_CLASS}` 50 | , SHOW_PARAMETERS_SELECTOR = `.${SHOW_PARAMETERS_CLASS}` 51 | , TOGGLE_EDIT_SELECTOR = `.${TOGGLE_EDIT_CLASS}` 52 | // something completely different 53 | , FONT_SIZE_CUSTOM_PROPERTY = '--font-size' 54 | , FONT_SIZE_PLACEHOLDER = '{font-size}' 55 | , DEFAULT_CONTENT = 'H' 56 | ; 57 | 58 | function _filterLocations(applyDefaultsExplicitly, state) { 59 | return state.filter(([axisTag, {location, 'default':def}])=> 60 | axisTag === 'opsz' // browsers set the wron default opsz, always apply explicitly 61 | || ( applyDefaultsExplicitly 62 | // Keep all 63 | ? true 64 | // Keep only locations that are not the default. 65 | : location !== def ) 66 | ); 67 | } 68 | 69 | // Duplicates from typespec! 70 | function _keyToProperty(key) { 71 | // 'HeLloWORLD'.replaceAll(/([A-Z])/g, (_, a)=> `-${a.toLowerCase()}`); 72 | // '-he-llo-w-o-r-l-d 73 | 74 | let property = key.startsWith('font-var-') 75 | ? key.toLowerCase() 76 | : key.replaceAll(/([A-Z])/g, (_, a)=> `-${a.toLowerCase()}`); 77 | return `--${property}`; 78 | } 79 | 80 | 81 | const ALIGNMENT2CSS = { 82 | 'l': 'left' 83 | , 'c': 'center' 84 | , 'r': 'right' 85 | // FIXME: "white-space: pre-wrap" on 86 | // #the-proof.typespec div[contenteditable] kills of justify! 87 | // In the legacy tool, "white-space: pre-wrap" was not used, 88 | // instead, the untampered content editable mechanisms would insert 89 | // non-breaking space characters and
tags. To achieve cleaner 90 | // contents, I prefer pre-wrap, but it could be turned off when 91 | // text-align is justify. Also, when we'll apply varla-varfo 92 | // parametric font justifiction, all this will become much more 93 | // complicated anyways! 94 | , 'j': 'justify' 95 | }; 96 | 97 | function _propertyValueToCSSValue(key, value) { 98 | if(key === 'alignment') 99 | return value in ALIGNMENT2CSS 100 | ? ALIGNMENT2CSS[value] 101 | : value 102 | ; 103 | return value; 104 | } 105 | 106 | 107 | function _setProperty(elem, key, value) { 108 | const propertyName = _keyToProperty(key); 109 | let propertyValue; 110 | if(value === null){ 111 | propertyValue = null; 112 | elem.style.removeProperty(propertyName); 113 | } 114 | else { 115 | propertyValue = _propertyValueToCSSValue(key, value); 116 | elem.style.setProperty(propertyName, propertyValue); 117 | } 118 | return [propertyName, propertyValue]; 119 | } 120 | 121 | function keyFromAxisTag(axisTag) { 122 | return `font-var-${axisTag}`; 123 | } 124 | 125 | function applyPropertyChanges(contentElement, fontSize, manualAxisLocations, gridDimensionControls, variationSettingsFlags) { 126 | const applyDefaultsExplicitly = variationSettingsFlags.has('applyDefaultsExplicitly') 127 | , locations = _filterLocations(applyDefaultsExplicitly, manualAxisLocations) 128 | .map(([axisTag, {location, autoOPSZ}])=>[axisTag, location, autoOPSZ]) 129 | , varProperties = [] 130 | , gridDimensionAxisTags = Object.values(gridDimensionControls) 131 | .filter(({axisTag})=>axisTag!=='disabled') 132 | .map(({axisTag})=>axisTag) 133 | , seen = new Set() 134 | ; 135 | 136 | for(const [axisTag, location, autoOPSZ] of locations) { 137 | const key = keyFromAxisTag(axisTag); 138 | let propertyValue = gridDimensionAxisTags.includes(axisTag) 139 | ? null 140 | : location 141 | ; 142 | if(axisTag === 'opsz' && autoOPSZ) { 143 | // Don't set property, fallback to --font-size (FONT_SIZE_CUSTOM_PROPERTY) directly 144 | propertyValue = null; // deletes/removes 145 | } 146 | seen.add(axisTag); 147 | const [propertyName, ] = _setProperty(contentElement, key, propertyValue); 148 | varProperties.push([axisTag, propertyName, location, autoOPSZ]); 149 | } 150 | 151 | for(const {axisTag} of Object.values(gridDimensionControls)) { 152 | if(seen.has(axisTag)) 153 | continue; 154 | if(['disabled', 'font-size'].includes(axisTag)) 155 | continue; 156 | 157 | const key = keyFromAxisTag(axisTag) 158 | , [propertyName, ] = _setProperty(contentElement, key, null) 159 | ; 160 | varProperties.push([axisTag, propertyName]); 161 | } 162 | 163 | contentElement.style.setProperty(FONT_SIZE_CUSTOM_PROPERTY, fontSize); 164 | return varProperties; 165 | } 166 | 167 | function _parametersTextFromProperties(varProperties, gridDimensionControls) { 168 | const gridAxesTags = Object.values(gridDimensionControls).map(({axisTag})=>axisTag) 169 | , explicitFontSize = gridAxesTags.includes('font-size') 170 | ; 171 | let parametersText = varProperties 172 | .map(([axisTag, /*propertyName*/, location, autoOPSZ])=>{ 173 | if(gridAxesTags.includes(axisTag)) 174 | return `${axisTag} {${axisTag}}`; 175 | 176 | return axisTag === 'opsz' && autoOPSZ 177 | ? `${axisTag} (auto ${FONT_SIZE_PLACEHOLDER})` 178 | : `${axisTag} ${location}`; 179 | }) 180 | .join(', ') 181 | ; 182 | 183 | if(explicitFontSize) 184 | parametersText += ` Font size: ${FONT_SIZE_PLACEHOLDER} pt`; 185 | return parametersText; 186 | } 187 | 188 | function _getParametersTextForFontSize(parametersText, proofFontSize, cellProperties) { 189 | const fontSize = 'font-size' in cellProperties 190 | ? cellProperties['font-size'] 191 | : proofFontSize 192 | ; 193 | parametersText = parametersText.replaceAll(FONT_SIZE_PLACEHOLDER, fontSize); 194 | for(let [axisTag, value] of Object.entries(cellProperties)) 195 | parametersText = parametersText.replaceAll(`{${axisTag}}`, value); 196 | 197 | return parametersText; 198 | } 199 | 200 | function _getParametersTextForCell(parametersText, cell) { 201 | const fontSize = cell.style.getPropertyValue(FONT_SIZE_CUSTOM_PROPERTY) 202 | , cellProperties = {} 203 | , propertyStart = '--font-var-' 204 | ; 205 | for(let propertyName of Array.from(cell.style)){ 206 | if(!propertyName.startsWith(propertyStart)) 207 | continue; 208 | const axisTag = propertyName.slice(propertyStart.length); 209 | cellProperties[axisTag] = cell.style.getPropertyValue(propertyName); 210 | } 211 | return _getParametersTextForFontSize(parametersText, fontSize, cellProperties); 212 | } 213 | 214 | 215 | function updateDisplayParameters(domTool, contentElement, varProperties, gridDimensionControls) { 216 | const parametersText = _parametersTextFromProperties(varProperties, gridDimensionControls); 217 | for(const cell of contentElement.querySelectorAll(CELL_SELECTOR)) { 218 | let parameters = cell.querySelector(SHOW_PARAMETERS_SELECTOR) 219 | , cellContent = cell.querySelector(CELL_CONTENT_SELECTOR) 220 | ; 221 | // Assert there's a parameters element! 222 | parameters.textContent = _getParametersTextForCell(parametersText, cellContent); 223 | } 224 | } 225 | 226 | function updateFontVariationsSettings(domTool, contentElement, varProperties) { 227 | const fontVariationSettings = _fontVariationSettingsFromProperties(varProperties); 228 | for(const cell of contentElement.querySelectorAll(CELL_CONTENT_SELECTOR)) 229 | cell.style.setProperty('font-variation-settings', fontVariationSettings); 230 | } 231 | 232 | function makeCell(domTool, cellTextContent, proofFontSize, fontVariationSettings 233 | , parametersTextTemplate, variationSettingsFlags, cellProperties) { 234 | 235 | const parametersText = _getParametersTextForFontSize(parametersTextTemplate, proofFontSize, cellProperties) 236 | , cellContent = domTool.createElement('div', 237 | {'class': CELL_CONTENT_CLASS, title:parametersText}, cellTextContent) 238 | , cellElement = domTool.createElement('div', {'class': CELL_CLASS}, [ 239 | domTool.createElement('span', {'class': TOGGLE_EDIT_CLASS, title: 'click here to edit line'}) 240 | , cellContent 241 | ]) 242 | ; 243 | 244 | if('font-size' in cellProperties) 245 | cellContent.style.setProperty(FONT_SIZE_CUSTOM_PROPERTY, `${cellProperties['font-size']}`); 246 | cellContent.style.setProperty('font-variation-settings', fontVariationSettings); 247 | 248 | for(const [axisTag, value] of Object.entries(cellProperties)) 249 | _setProperty(cellContent, keyFromAxisTag(axisTag), value); 250 | 251 | 252 | 253 | if(variationSettingsFlags.has('displayParameters')) { 254 | // enable parameters 255 | const parameters = domTool.createElement( 256 | 'div', {'class': SHOW_PARAMETERS_CLASS}, parametersText); 257 | cellElement.append(parameters); 258 | } 259 | return cellElement; 260 | } 261 | 262 | function makeGrid(domTool, contentElement, userText, fontSize, alignment 263 | , gridDimensionControls, varProperties, variationSettingsFlags 264 | , manualFontLeading) { 265 | const cellTextContent = userText || DEFAULT_CONTENT 266 | , fontVariationSettings = _fontVariationSettingsFromProperties(varProperties) 267 | , parametersTextTemplate = _parametersTextFromProperties(varProperties, gridDimensionControls) 268 | , rows = [] 269 | ; 270 | domTool.clear(contentElement); 271 | 272 | const {x, y} = gridDimensionControls 273 | , MAX_CELLS = 1000 274 | ; 275 | let i = 0; 276 | y: 277 | for(const yValue of gridDimensionGenerator(y)) { 278 | const cells = []; 279 | for(const xValue of gridDimensionGenerator(x)) { 280 | // both disabled or bot stepsSize === 0 281 | if(xValue === null && yValue === null) break y; 282 | if(i >= MAX_CELLS) 283 | break ; 284 | i++; 285 | cells.push(makeCell(domTool, cellTextContent, fontSize 286 | , fontVariationSettings, parametersTextTemplate, variationSettingsFlags 287 | , {[x.axisTag]: xValue, [y.axisTag]: yValue})); 288 | } 289 | rows.push(domTool.createElement('div', {'class': ROW_CLASS}, cells)); 290 | if(i >= MAX_CELLS) { 291 | // Could add a a button to "load more ..." ! 292 | rows.push(domTool.createElementFromHTML('div', {'class': 'to-many-cells'}, 293 | `

Cell creation aborted!

The maximum cell amount was created. ` 294 | + `Too many cells can affect the website performance negatively` 295 | + ` (MAX_CELLS ${MAX_CELLS}).`)); 296 | break; 297 | } 298 | } 299 | contentElement.style.setProperty(FONT_SIZE_CUSTOM_PROPERTY, `${fontSize}`); 300 | contentElement.style.setProperty('line-height', `${manualFontLeading}`); 301 | contentElement.append(...rows); 302 | } 303 | 304 | function _handleBeforeInput(domTool, event) { 305 | handleEditableLine(domTool, event); 306 | domTool.dispatchEvent(event.target, 'edited', {bubbles: true}); 307 | } 308 | 309 | function _handleClick(domTool, e) { 310 | if(!e.target.matches(`${CELL_SELECTOR} ${TOGGLE_EDIT_SELECTOR}`)) 311 | return; 312 | e.preventDefault(); 313 | // Turning contentEditable on only when required has the advantage 314 | // that text selection works better, it's otherwise limited within 315 | // each contenteditable element and one cannot select accross elements. 316 | const line = e.target.closest(CELL_SELECTOR) 317 | , lineContent = line.querySelector(CELL_CONTENT_SELECTOR) 318 | ; 319 | lineContent.contentEditable = true; 320 | lineContent.focus(); 321 | } 322 | 323 | function _handleDblclick(domTool, e) { 324 | if(!e.target.matches(`${CELL_SELECTOR} *`)) 325 | return; 326 | e.preventDefault(); 327 | // Turning contentEditable on only when required has the advantage 328 | // that text selection works better, it's otherwise limited within 329 | // each contenteditable element and one cannot select accross elements. 330 | const line = e.target.closest(CELL_SELECTOR) 331 | , lineContent = line.querySelector(CELL_CONTENT_SELECTOR) 332 | ; 333 | lineContent.contentEditable = true; 334 | lineContent.focus(); 335 | } 336 | 337 | function _handleFocusOut(domTool, e) { 338 | if(!e.target.matches(CELL_CONTENT_SELECTOR)) 339 | return; 340 | const lineContent = e.target; 341 | lineContent.contentEditable = false; 342 | } 343 | 344 | function updateTextContent(container, newText) { 345 | // Update all lines 346 | const cellContents = container.querySelectorAll(CELL_CONTENT_SELECTOR); 347 | for(const elem of cellContents) { 348 | if(elem.textContent === newText) continue; 349 | elem.textContent = newText; 350 | } 351 | } 352 | 353 | function _handleEdited(updateTextHandler, event) { 354 | // Update all lines 355 | const newText = event.target.textContent; 356 | updateTextHandler(newText); 357 | } 358 | 359 | export function init(proofElement, domTool, updateTextHandler, fontSize 360 | , manualAxisLocations, alignment, variationSettingsFlags 361 | , gridDimensionControls, userText, manualFontLeading) { 362 | 363 | console.log(`VARTOOLS_GRID init!`, variationSettingsFlags); 364 | 365 | const contentElement = domTool.createElement('div', {'class': GRID_CONTAINER_CLASS}); 366 | proofElement.append(contentElement); 367 | 368 | const handleDestroy = (/*event*/)=>{ 369 | for(const eventListener of eventListeners) 370 | proofElement.removeEventListener(...eventListener); 371 | } 372 | , eventListeners = [ 373 | ['beforeinput', _handleBeforeInput.bind(null, domTool), false] 374 | , ['focusout', _handleFocusOut.bind(null, domTool), false] 375 | , ['edited', _handleEdited.bind(null, updateTextHandler), false] 376 | , ['click', _handleClick.bind(null, domTool), false] 377 | , ['dblclick', _handleDblclick.bind(null, domTool), false] 378 | , ['destroy', handleDestroy, false] 379 | ] 380 | ; 381 | 382 | for(const eventListener of eventListeners) 383 | proofElement.addEventListener(...eventListener); 384 | 385 | 386 | _setProperty(contentElement, 'alignment', alignment); 387 | 388 | const varProperties = applyPropertyChanges(contentElement, fontSize 389 | , manualAxisLocations, gridDimensionControls 390 | , variationSettingsFlags, userText); 391 | makeGrid(domTool, contentElement, userText, fontSize, alignment 392 | , gridDimensionControls, varProperties, variationSettingsFlags 393 | , manualFontLeading); 394 | 395 | return { 396 | 397 | // Update will run if the proof is not re-initalized anyways. 398 | update: (changedDependencyNamesSet, fontSize 399 | , manualAxisLocations, alignment, variationSettingsFlags 400 | , gridDimensionControls, userText, manualFontLeading)=>{ 401 | _setProperty(contentElement, 'alignment', alignment); 402 | const varProperties = applyPropertyChanges(contentElement, fontSize, manualAxisLocations 403 | , gridDimensionControls, variationSettingsFlags); 404 | 405 | 406 | if(['fontName', 'variationSettingsFlags', 'gridDimensionControls'].some(k=>changedDependencyNamesSet.has(k))) { 407 | makeGrid(domTool, contentElement, userText, fontSize, alignment 408 | , gridDimensionControls, varProperties, variationSettingsFlags 409 | , manualFontLeading); 410 | return; 411 | } 412 | if(changedDependencyNamesSet.has('fontSizeGrid')) 413 | contentElement.style.setProperty(FONT_SIZE_CUSTOM_PROPERTY, `${fontSize}`); 414 | 415 | if(changedDependencyNamesSet.has('manualFontLeading')) 416 | contentElement.style.setProperty('line-height', `${manualFontLeading}`); 417 | 418 | if(changedDependencyNamesSet.has('userText') ) 419 | updateTextContent(contentElement, userText); 420 | // What follows is covered in makeLines as well 421 | if(!variationSettingsFlags.has('applyDefaultsExplicitly')) { 422 | // When the default are not explicitly applied, font-variation-settings 423 | // must be updated when the variation properties change, as 424 | // they may contain more or less axis than before.. 425 | updateFontVariationsSettings(domTool, contentElement, varProperties); 426 | } 427 | if(changedDependencyNamesSet.has('manualAxisLocations') && variationSettingsFlags.has('displayParameters')){ 428 | updateDisplayParameters(domTool, contentElement, varProperties, gridDimensionControls); 429 | } 430 | 431 | } 432 | }; 433 | } 434 | 435 | -------------------------------------------------------------------------------- /lib/js/layouts/vartools-waterfall.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 9, laxcomma: true, laxbreak: true, unused:true, undef:true */ 2 | import { handleEditableLine } from '../content-editable.mjs'; 3 | 4 | // Duplicates from typespec! 5 | function _keyToProperty(key) { 6 | // 'HeLloWORLD'.replaceAll(/([A-Z])/g, (_, a)=> `-${a.toLowerCase()}`); 7 | // '-he-llo-w-o-r-l-d 8 | 9 | let property = key.startsWith('font-var-') 10 | ? key.toLowerCase() 11 | : key.replaceAll(/([A-Z])/g, (_, a)=> `-${a.toLowerCase()}`); 12 | return `--${property}`; 13 | } 14 | 15 | const ALIGNMENT2CSS = { 16 | 'l': 'left' 17 | , 'c': 'center' 18 | , 'r': 'right' 19 | // FIXME: "white-space: pre-wrap" on 20 | // #the-proof.typespec div[contenteditable] kills of justify! 21 | // In the legacy tool, "white-space: pre-wrap" was not used, 22 | // instead, the untampered content editable mechanisms would insert 23 | // non-breaking space characters and
tags. To achieve cleaner 24 | // contents, I prefer pre-wrap, but it could be turned off when 25 | // text-align is justify. Also, when we'll apply varla-varfo 26 | // parametric font justifiction, all this will become much more 27 | // complicated anyways! 28 | , 'j': 'justify' 29 | }; 30 | 31 | function _propertyValueToCSSValue(key, value) { 32 | if(key === 'alignment') 33 | return value in ALIGNMENT2CSS 34 | ? ALIGNMENT2CSS[value] 35 | : value 36 | ; 37 | return value; 38 | } 39 | 40 | function _setProperty(elem, key, value) { 41 | const propertyName = _keyToProperty(key); 42 | let propertyValue; 43 | if(value === null){ 44 | propertyValue = null; 45 | elem.style.removeProperty(propertyName); 46 | } 47 | else { 48 | propertyValue = _propertyValueToCSSValue(key, value); 49 | elem.style.setProperty(propertyName, propertyValue); 50 | } 51 | return [propertyName, propertyValue]; 52 | } 53 | 54 | function _filterLocations(applyDefaultsExplicitly, state) { 55 | return state.filter(([axisTag, {location, 'default':def}])=> 56 | axisTag === 'opsz' // browsers set the wron default opsz, always apply explicitly 57 | || ( applyDefaultsExplicitly 58 | // Keep all 59 | ? true 60 | // Keep only locations that are not the default. 61 | : location !== def ) 62 | ); 63 | } 64 | 65 | function applyPropertyChanges(contentElement, manualAxisLocations, variationSettingsFlags) { 66 | const applyDefaultsExplicitly = variationSettingsFlags.has('applyDefaultsExplicitly') 67 | , locations = _filterLocations(applyDefaultsExplicitly, manualAxisLocations) 68 | .map(([axisTag, {location, autoOPSZ}])=>[axisTag, location, autoOPSZ]) 69 | , varProperties = [] 70 | ; 71 | 72 | for(const [axisTag, location, autoOPSZ] of locations) { 73 | const key = `font-var-${axisTag}`; 74 | let propertyValue = location; 75 | if(axisTag === 'opsz' && autoOPSZ) { 76 | // Don't set property, fallback to --font-size (FONT_SIZE_CUSTOM_PROPERTY) directly 77 | propertyValue = null; // deletes/removes 78 | } 79 | const [propertyName, ] = _setProperty(contentElement, key, propertyValue); 80 | varProperties.push([axisTag, propertyName, location, autoOPSZ]); 81 | } 82 | 83 | return varProperties; 84 | } 85 | 86 | const WATERFALL_CONTAINER_CLASS = 'waterfall-container' 87 | , LINE_CLASS = `waterfall-line` 88 | , LINE_CONTENT_CLASS = `waterfall-line_content` 89 | , TOGGLE_EDIT_CLASS = `waterfall-toggle_edit` 90 | , SHOW_PARAMETERS_CLASS = `waterfall-show_parameters` 91 | // Selectors for classes 92 | , LINE_SELECTOR = `.${LINE_CLASS}` 93 | , LINE_CONTENT_SELECTOR = `.${LINE_CONTENT_CLASS}` 94 | , TOGGLE_EDIT_SELECTOR = `.${TOGGLE_EDIT_CLASS}` 95 | , SHOW_PARAMETERS_SELECTOR = `.${SHOW_PARAMETERS_CLASS}` 96 | // something completely different 97 | , FONT_SIZE_PLACEHOLDER = '{font-size}' 98 | , FONT_SIZE_CUSTOM_PROPERTY = '--font-size' 99 | , DEFAULT_CONTENT = 'ABCDEFGHIJKLOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890' 100 | ; 101 | 102 | function _parametersTextFromProperties(varProperties) { 103 | return varProperties 104 | .map(([axisTag, /*propertyName*/, location, autoOPSZ])=>{ 105 | return axisTag === 'opsz' && autoOPSZ 106 | ? `${axisTag} (auto ${FONT_SIZE_PLACEHOLDER})` 107 | : `${axisTag} ${location}`; 108 | }) 109 | .join(', '); 110 | } 111 | 112 | function _getParametersTextForFontSize(parametersText, fontSize) { 113 | return parametersText.replace(FONT_SIZE_PLACEHOLDER, fontSize); 114 | } 115 | 116 | function _getParametersTextForLine(parametersText, line) { 117 | const fontSize = line.style.getPropertyValue(FONT_SIZE_CUSTOM_PROPERTY); 118 | return _getParametersTextForFontSize(parametersText, fontSize); 119 | } 120 | 121 | 122 | function updateDisplayParameters(domTool, contentElement, varProperties) { 123 | const parametersText = _parametersTextFromProperties(varProperties) 124 | , lines = contentElement.querySelectorAll(LINE_SELECTOR) 125 | ; 126 | for(const line of lines) { 127 | let parameters = line.querySelector(SHOW_PARAMETERS_SELECTOR); 128 | // Assert there's a parameters element! 129 | parameters.textContent = _getParametersTextForLine(parametersText, line); 130 | } 131 | } 132 | 133 | function _fontVariationSettingsFromProperties(varProperties) { 134 | return varProperties 135 | .map(([axisTag, propertyName])=>{ 136 | return axisTag === 'opsz' 137 | ? `"${axisTag}" var(${propertyName}, var(${FONT_SIZE_CUSTOM_PROPERTY}))` 138 | : `"${axisTag}" var(${propertyName}, 0)` 139 | ; 140 | }).join(', '); 141 | } 142 | 143 | function updateFontVariationsSettings(domTool, contentElement, varProperties) { 144 | const fontVariationSettings = _fontVariationSettingsFromProperties(varProperties) 145 | , lines = contentElement.querySelectorAll(LINE_SELECTOR) 146 | ; 147 | for(const line of lines) 148 | line.style.setProperty('font-variation-settings', fontVariationSettings); 149 | } 150 | 151 | function makeLines(domTool, contentElement, userText, fontSize, fontSizeTo, varProperties, variationSettingsFlags) { 152 | const waterfallContent = userText || DEFAULT_CONTENT 153 | , lines = [] 154 | ; 155 | domTool.clear(contentElement); 156 | 157 | const fontVariationSettings = _fontVariationSettingsFromProperties(varProperties) 158 | , parametersText = variationSettingsFlags.has('displayParameters') 159 | ? _parametersTextFromProperties(varProperties) 160 | : '' 161 | , fromFontSize = parseInt(fontSize) 162 | , toFontSize = parseInt(fontSizeTo) 163 | , step = toFontSize < fromFontSize ? -1 : 1 164 | , endCondition = toFontSize < fromFontSize 165 | ? (i, l)=>i >= l 166 | : (i, l)=>i <= l 167 | ; 168 | 169 | for(let i=fromFontSize; endCondition(i, toFontSize); i+=step) { 170 | let line = domTool.createElement('div', {'class': LINE_CLASS}, [ 171 | domTool.createElement('span', {'class': TOGGLE_EDIT_CLASS, title: 'click here to edit line'}) 172 | , domTool.createElement('span', {'class': LINE_CONTENT_CLASS}, waterfallContent) 173 | ]); 174 | line.style.setProperty(FONT_SIZE_CUSTOM_PROPERTY, `${i}`); 175 | line.style.setProperty('font-variation-settings', fontVariationSettings); 176 | 177 | if(variationSettingsFlags.has('displayParameters')) { 178 | // enable parameters 179 | const parameters = domTool.createElement( 180 | 'div' 181 | , {'class': SHOW_PARAMETERS_CLASS} 182 | , _getParametersTextForFontSize(parametersText, i) 183 | ); 184 | line.append(parameters); 185 | } 186 | lines.push(line); 187 | } 188 | contentElement.append(...lines); 189 | } 190 | 191 | function _handleBeforeInput(domTool, event) { 192 | handleEditableLine(domTool, event); 193 | domTool.dispatchEvent(event.target, 'edited', {bubbles: true}); 194 | } 195 | 196 | function _handleClick(domTool, e) { 197 | if(!e.target.matches(`${LINE_SELECTOR} ${TOGGLE_EDIT_SELECTOR}`)) 198 | return; 199 | e.preventDefault(); 200 | // Turning contentEditable on only when required has the advantage 201 | // that text selection works better, it's otherwise limited within 202 | // each contenteditable element and one cannot select accross elements. 203 | const line = e.target.closest(LINE_SELECTOR) 204 | , lineContent = line.querySelector(LINE_CONTENT_SELECTOR) 205 | ; 206 | lineContent.contentEditable = true; 207 | lineContent.focus(); 208 | } 209 | 210 | function _handleDblclick(domTool, e) { 211 | if(!e.target.matches(`${LINE_SELECTOR} *`)) 212 | return; 213 | e.preventDefault(); 214 | // Turning contentEditable on only when required has the advantage 215 | // that text selection works better, it's otherwise limited within 216 | // each contenteditable element and one cannot select accross elements. 217 | const line = e.target.closest(LINE_SELECTOR) 218 | , lineContent = line.querySelector(LINE_CONTENT_SELECTOR) 219 | ; 220 | lineContent.contentEditable = true; 221 | lineContent.focus(); 222 | } 223 | 224 | function _handleFocusOut(domTool, e) { 225 | if(!e.target.matches(LINE_CONTENT_SELECTOR)) 226 | return; 227 | const lineContent = e.target; 228 | lineContent.contentEditable = false; 229 | } 230 | 231 | function updateTextContent(container, newText) { 232 | // Update all lines 233 | const lineContents = container.querySelectorAll(LINE_CONTENT_SELECTOR); 234 | for(const elem of lineContents) { 235 | if(elem.textContent === newText) continue; 236 | elem.textContent = newText; 237 | } 238 | } 239 | 240 | function _handleEdited(updateTextHandler, event) { 241 | const newText = event.target.textContent; 242 | updateTextHandler(newText); 243 | } 244 | 245 | export function init(proofElement, domTool, updateTextHandler, fontSize, fontSizeTo 246 | , manualAxisLocations, alignment, variationSettingsFlags 247 | , userText, manualFontLeading) { 248 | 249 | console.log(`WATERFALL init!`, { 250 | fontSize, fontSizeTo, manualAxisLocations}); 251 | 252 | const contentElement = domTool.createElement('div', {'class': WATERFALL_CONTAINER_CLASS}); 253 | proofElement.append(contentElement); 254 | 255 | 256 | const handleDestroy = (/*event*/)=>{ 257 | for(const eventListener of eventListeners) 258 | proofElement.removeEventListener(...eventListener); 259 | } 260 | , eventListeners = [ 261 | ['beforeinput', _handleBeforeInput.bind(null, domTool), false] 262 | , ['focusout', _handleFocusOut.bind(null, domTool), false] 263 | , ['edited', _handleEdited.bind(null, updateTextHandler), false] 264 | //, ['focusin', _handleFocusIn.bind(null, domTool, setActiveTypoTarget), false] 265 | , ['click', _handleClick.bind(null, domTool), false] 266 | , ['dblclick', _handleDblclick.bind(null, domTool), false] 267 | , ['destroy', handleDestroy, false] 268 | ] 269 | ; 270 | 271 | for(const eventListener of eventListeners) 272 | proofElement.addEventListener(...eventListener); 273 | 274 | 275 | _setProperty(contentElement, 'alignment', alignment); 276 | contentElement.style.setProperty('line-height', `${manualFontLeading}`); 277 | const varProperties = applyPropertyChanges(contentElement, manualAxisLocations, 278 | variationSettingsFlags); 279 | makeLines(domTool, contentElement, userText, fontSize, fontSizeTo, varProperties, variationSettingsFlags); 280 | 281 | return { 282 | // Update will run if the proof is no re-initalized anyways. 283 | update: (changedDependencyNamesSet, fontSize, fontSizeTo 284 | , manualAxisLocations, alignment, variationSettingsFlags 285 | , userText, manualFontLeading)=>{ 286 | _setProperty(contentElement, 'alignment', alignment); 287 | const varProperties = applyPropertyChanges(contentElement, manualAxisLocations, 288 | variationSettingsFlags); 289 | if(['fontSizeFrom', 'fontSizeTo', 'fontName', 'variationSettingsFlags'].some(k=>changedDependencyNamesSet.has(k))) { 290 | contentElement.style.setProperty('line-height', `${manualFontLeading}`); 291 | makeLines(domTool, contentElement, userText, fontSize, fontSizeTo, varProperties, variationSettingsFlags); 292 | return; 293 | } 294 | if(changedDependencyNamesSet.has('userText')) 295 | updateTextContent(contentElement, userText); 296 | // What follows is covered in makeLines as well 297 | if(!variationSettingsFlags.has('applyDefaultsExplicitly')) { 298 | // When the default are not explicitly applied, font-variation-settings 299 | // must be updated when the variation properties change, as 300 | // they may contain more or less axis than before.. 301 | updateFontVariationsSettings(domTool, contentElement, varProperties); 302 | } 303 | if(changedDependencyNamesSet.has('manualAxisLocations') && variationSettingsFlags.has('displayParameters')){ 304 | updateDisplayParameters(domTool, contentElement, varProperties); 305 | } 306 | 307 | if(changedDependencyNamesSet.has('manualFontLeading')) 308 | contentElement.style.setProperty('line-height', `${manualFontLeading}`); 309 | 310 | } 311 | }; 312 | } 313 | 314 | -------------------------------------------------------------------------------- /lib/js/layouts/videoproof-array.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 8, laxcomma: true, laxbreak: true */ 2 | 3 | /** 4 | * TODO: the controller should take care of these events: 5 | * $(document).on('videoproof:fontLoaded.grid', populateGrid); 6 | * $('#select-glyphs').on('change.grid', populateGrid); 7 | * $('#show-extended-glyphs').on('change.grid', populateGrid); 8 | */ 9 | export function init(proofElement, glyphset, fixLineBreaksFunc) { 10 | let cells = []; 11 | for(let char of glyphset) { 12 | var cell = proofElement.ownerDocument.createElement('span'); 13 | cell.textContent = char; 14 | cells.push(cell); 15 | } 16 | proofElement.append(...cells); 17 | fixLineBreaksFunc(proofElement); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /lib/js/layouts/videoproof-contextual.mjs: -------------------------------------------------------------------------------- 1 | /* jshint esversion: 11, browser: true, unused:true, undef:true, laxcomma: true, laxbreak: true */ 2 | 3 | import DOMTool from '../domTool.mjs'; 4 | 5 | function _testCharType(extendedCharGroups, c, re) { 6 | if (re.test(c)) 7 | return true; 8 | //checks all items in extendedCharGroups 9 | for(let [k, extChars] of Object.entries(extendedCharGroups)) { 10 | if (!re.test(k)) 11 | continue; 12 | if(extChars.indexOf(c) != -1) 13 | return true; 14 | } 15 | return false; 16 | } 17 | 18 | function _formatAuto(mode, autoFormatter, c) { 19 | for(let [test, format] of autoFormatter) { 20 | if(test(c)) 21 | return format(c); 22 | } 23 | throw new Error(`Don't know how to format "${c}" in mode: ${mode}.`); 24 | } 25 | 26 | function _formatCustom(customPad, c) { 27 | return `${customPad}${c}${customPad}`; 28 | } 29 | 30 | function* _kernPaddingGen(outer, inner) { 31 | for(let o of outer) 32 | for(let i of inner) 33 | yield [o, i]; 34 | } 35 | 36 | const _autoFormatters = { 37 | 'auto-short': [ 38 | ['isNumeric', c=>`00${c}00`] 39 | , ['isLowercase', c=>`nn${c}nn`] 40 | // default, also isUppercase: 41 | , ['default', c=>`HH${c}HH`] 42 | ] 43 | , 'auto-long': [ 44 | ['isNumeric', c=>`00${c}0101${c}11`] 45 | , ['isLowercase', c=>`nn${c}nono${c}oo`] 46 | // default, also isUppercase: 47 | , ['default', c=>`HH${c}HOHO${c}OO`] 48 | ] 49 | } 50 | , _kernFormatters = { 51 | 'kern-upper': ([o, i])=>`HO${o}${i}${o}OLA` 52 | , 'kern-mixed': ([o, i])=>`${o}${i}nnoy` 53 | , 'kern-lower': ([o, i])=>`no${o}${i}${o}ony` 54 | } 55 | , _kernModesCharsConfig = { // mode: [charsKey, outer] 56 | 'kern-upper': ['Latin.Uppercase', undefined] 57 | // CUSTOM! outer 58 | , 'kern-mixed': ['Latin.Lowercase', [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"]] 59 | , 'kern-lower': ['Latin.Lowercase', undefined] 60 | } 61 | ; 62 | 63 | function _getKernChars(getCharsForKey, showExtended, mode) { 64 | if(!(mode in _kernModesCharsConfig)) 65 | throw new Error(`Don't now how to get chars for mode: "${mode}".`); 66 | const [charsKey, customOuter] = _kernModesCharsConfig[mode] 67 | , [chars, extendedCharset] = getCharsForKey(charsKey) 68 | , outer = customOuter !== undefined ? customOuter : chars 69 | , inner = showExtended 70 | ? [...chars, ...extendedCharset] 71 | : chars 72 | ; 73 | return [outer, inner]; 74 | } 75 | 76 | function _getWords(selectedChars, getCharsForKey, showExtended 77 | , extendedCharGroups, padMode, customPad) { 78 | 79 | // All only latin! 80 | let _formatterTests = { 81 | 'isNumeric': c=>_testCharType(extendedCharGroups, c, /[0-9]/) 82 | // , 'isUppercase': = c=>_testCharType(extendedCharGroups, c, /[A-Z]/) 83 | , 'isLowercase': c=>_testCharType(extendedCharGroups, c, /[a-z]/) 84 | , 'default': ()=>true 85 | } 86 | , _getAutoFormatter = padMode=>{ 87 | let description = _autoFormatters[padMode] 88 | , result = [] 89 | ; 90 | for(let [testName, format] of description) { 91 | result.push([_formatterTests[testName], format]); 92 | } 93 | return result; 94 | } 95 | , words = [] 96 | ; 97 | 98 | let chars, formatter; 99 | if(padMode in _kernFormatters) { 100 | let [outerChars, innerChars] = _getKernChars(getCharsForKey, showExtended, padMode); 101 | chars = _kernPaddingGen(outerChars, innerChars); 102 | formatter = _kernFormatters[padMode]; 103 | } 104 | else if(padMode === 'custom') { 105 | chars = selectedChars; 106 | formatter = c=>_formatCustom(customPad, c); 107 | } 108 | else if(padMode in _autoFormatters) { 109 | chars = selectedChars; 110 | formatter = c=>_formatAuto(padMode, _getAutoFormatter(padMode), c); 111 | } 112 | else 113 | throw new Error(`Don't know how to handle mode: "${padMode}".`); 114 | 115 | for(let c of chars) 116 | words.push(formatter(c)); 117 | if(padMode in _kernFormatters) 118 | // Dunno why! Behavior form legacy code. 119 | words.push(0); 120 | return words; 121 | } 122 | 123 | export function init(proofElement, selectedChars, getCharsForKey 124 | , fixLineBreaks, showExtended, extendedCharGroups 125 | , padMode, customPad) { 126 | const domTool = new DOMTool(proofElement.ownerDocument) 127 | , words = _getWords(selectedChars, getCharsForKey, showExtended 128 | , extendedCharGroups, padMode, customPad) 129 | , cells = [] 130 | ; 131 | 132 | domTool.clear(proofElement); 133 | for(let i=0,l=words.length;i{ 7 | eventTarget.onsuccess = resolve; 8 | eventTarget.onerror = reject; 9 | }); 10 | } 11 | 12 | 13 | function promiseWrapOpenDBRequest(dbOpenRequest, onUpgradeNeededHandler) { 14 | return new Promise((resolve, reject)=>{ 15 | dbOpenRequest.onsuccess = evt=>resolve(evt.target.result); 16 | dbOpenRequest.onerror = reject; 17 | 18 | // If the below all end up in either onsuccess or onerror 19 | // we can put them in init and use just promiseWrap. 20 | // 21 | // Fired when an open connection to a database is blocking a 22 | // versionchange transaction on the same database. 23 | // Also available via the onblocked property. 24 | dbOpenRequest.onblocked = evt=>{ 25 | reject(evt); 26 | }; 27 | // Fired when an attempt was made to open a database with a 28 | // version number higher than its current version. Also available 29 | // via the onupgradeneeded property. 30 | // If this fails, is onerror fired? 31 | // If this succeeds is onsuccess fired? => it says so at mdn! 32 | dbOpenRequest.onupgradeneeded = evt=>onUpgradeNeededHandler(evt); 33 | }); 34 | } 35 | 36 | 37 | export default class LocalFontStorage { 38 | // Trying to create an object store with a name that already exists 39 | // (or trying to delete an object store with a name that does not 40 | // already exist) will throw an error. 41 | // 42 | // If the onupgradeneeded event exits successfully, the onsuccess 43 | // handler of the open database request will then be triggered. 44 | static _onUpgradeNeededHandler(event) { 45 | const db = event.target.result; 46 | // prefer if I don't need this! 47 | // will the promise receive this issue 48 | db.onerror = event => console.warn(`CAUTION: _onUpgradeNeeded onerror: ${event}. IS this handler required?`); 49 | // Create an objectStore for this database 50 | // will have a blob and `fullName`, where fullName equals 51 | // VideproofFont.fullName which is used as the unique id for 52 | // the available fonts. 53 | // 'nameVersion' which is used as the label. 54 | // `serializationNameParticles` => required to know if the font matches the serialized font 55 | /*const objectStore = */ 56 | 57 | // Raises directly e.g.: Uncaught DOMException: IDBDatabase.createObjectStore: Object store named 'fonts' already exists at index '0' 58 | db.createObjectStore('fonts', { keyPath: 'fullName' }); 59 | // could create another store with the same name right away to 60 | // see how and where this fails. 61 | } 62 | 63 | static init(window) { 64 | const dbOpenRequest = window.indexedDB.open("LocalFontStorage", 1) 65 | , promise = promiseWrapOpenDBRequest(dbOpenRequest, this._onUpgradeNeededHandler) 66 | ; 67 | 68 | return promise.then((db)=>{ 69 | // const db = evt.target.result; 70 | // TODO: also load the initial list of fonts {fullName, nameVersion} 71 | // new this(db) 72 | // return this.loadFontList() // would store fontList, so could return promise(db) 73 | return new this(db); 74 | }) 75 | .catch(errorEvt=>{ 76 | 77 | // Can be something cryptic like: LocalFontStorage init failed with [object Event]: 78 | // event.type = 'error' in this case 79 | // In FireFox in private browsing, this fails currently! 80 | // However, in private browsing there's no persistence anyways. 81 | // We could just fake the API.? 82 | const message = `${this.name} init failed.`; 83 | console.error(`${message} with ${errorEvt}:`, errorEvt); 84 | // not handled here so far! 85 | throw new Error(message); 86 | }); 87 | } 88 | 89 | constructor(db) { 90 | this.db = db; 91 | } 92 | 93 | async put(font) { 94 | const request = this.db.transaction(['fonts'], 'readwrite') 95 | .objectStore('fonts') 96 | .put({ 97 | fullName: font.fullName 98 | , nameVersion: font.nameVersion 99 | , serializationNameParticles: font.serializationNameParticles 100 | , buffer: font.buffer 101 | , origin: font.origin.toDB() 102 | }) 103 | , result = await promiseWrap(request) 104 | ; 105 | // This returns just the key, i.e. the same as font.fullName 106 | return result.target.result; 107 | } 108 | 109 | async delete(fullName) { 110 | const request = this.db.transaction(['fonts'], 'readwrite') 111 | .objectStore('fonts') 112 | .delete(fullName) 113 | , result = await promiseWrap(request) 114 | ; 115 | // This returns just the key, i.e. the same as font.fullName 116 | return result.target.result; 117 | } 118 | 119 | async get (fullName) { 120 | const request = this.db.transaction(['fonts'], 'readonly') 121 | .objectStore('fonts') 122 | .get(fullName) 123 | , result = await promiseWrap(request) 124 | ; 125 | return result.target.result; 126 | } 127 | 128 | async* getAll() { 129 | const request = this.db.transaction(['fonts'], 'readonly') 130 | .objectStore('fonts') 131 | .openCursor() 132 | , resolvers = {} 133 | ; 134 | // iterate through cursor 135 | request.onsuccess = event=>{ 136 | const cursor = event.target.result; 137 | if (cursor) { 138 | // cursor.value contains the current record being iterated through 139 | // this is where you'd do something with the result 140 | // could be an async yield as well! 141 | resolvers.resolve(cursor.value); 142 | cursor.continue(); 143 | } 144 | else 145 | // no more results 146 | resolvers.resolve(null); 147 | }; 148 | request.onerror = event=>resolvers.reject(event); 149 | 150 | while(true) { 151 | const value = await new Promise((resolve, reject)=>{ 152 | resolvers.resolve = resolve; 153 | resolvers.reject = reject; 154 | }); 155 | if(value !== null) 156 | yield value; 157 | else 158 | break; 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /lib/js/main.mjs: -------------------------------------------------------------------------------- 1 | /* jshint browser: true, esversion: 8, laxcomma: true, laxbreak: true */ 2 | 3 | import { VideoproofController } from './videoproof-controller.mjs' 4 | 5 | // Should not require to wait until load (all resources, images etc are loaded), 6 | // so this would make it much quicker at startup. 7 | function main() { 8 | // This is the new world, after some bottom up rewriting/refactoring 9 | // this is the top down adoption. 10 | let controllerElement = document.querySelector('#controls') 11 | videoproofCtrl.setUIDependency('mainUIElement', controllerElement); 12 | } 13 | const videoproofCtrl = new VideoproofController(window); 14 | 15 | if(document.readyState === 'loading') 16 | window.addEventListener('DOMContentLoaded', main); 17 | else 18 | main(); 19 | -------------------------------------------------------------------------------- /make-webfonts.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division, unicode_literals 2 | import glob, json, io, re, os, sys 3 | from fontTools.ttLib import TTFont 4 | from datetime import datetime, timedelta 5 | from collections import OrderedDict 6 | 7 | infiles = "fonts/repos/*/fonts/*.?tf" 8 | outdir = "fonts" 9 | fileAxes = {} 10 | 11 | def getName(ttf, nameid): 12 | names = [n for n in ttf['name'].names if n.nameID==nameid] 13 | return names[0].toUnicode() 14 | 15 | def getVarAxes(ttf): 16 | axes = OrderedDict() 17 | if 'STAT' in ttf and hasattr(ttf['STAT'], 'table'): 18 | axes['order'] = [a.AxisTag for a in sorted(ttf['STAT'].table.DesignAxisRecord.Axis, key=lambda a:a.AxisOrdering)] 19 | 20 | if 'fvar' in ttf: 21 | for axis in ttf['fvar'].axes: 22 | axes[axis.axisTag] = { 23 | 'name': getName(ttf, axis.nameID if hasattr(axis, 'nameID') else axis.axisNameID), 24 | 'min': axis.minValue, 25 | 'max': axis.maxValue, 26 | 'default': axis.defaultValue 27 | } 28 | axes['instances'] = [] 29 | if hasattr(ttf['fvar'], 'instances'): 30 | for instance in ttf['fvar'].instances: 31 | axes['instances'].append({ 32 | 'axes': instance.coordinates, 33 | 'name': getName(ttf, instance.nameID if hasattr(instance, 'nameID') else instance.subfamilyNameID), 34 | }) 35 | return axes 36 | 37 | for fontfile in glob.glob(infiles): 38 | fontfilebase = os.path.basename(fontfile)[:-4] 39 | outbase = os.path.join(outdir, fontfilebase) 40 | 41 | ttf = TTFont(fontfile, recalcBBoxes=False) 42 | 43 | #list axes 44 | fileAxes[fontfilebase] = getVarAxes(ttf) 45 | 46 | if 'DSIG' in ttf: 47 | del(ttf['DSIG']) 48 | 49 | wofffile = outbase + ".woff" 50 | ttf.flavor = 'woff' 51 | ttf.save(wofffile) 52 | 53 | #using binary here because json.dumps returns raw bytes 54 | with io.open(os.path.join(outdir, 'axes.json'), 'wb') as axesfile: 55 | jsonbytes = json.dumps(fileAxes, indent=2, ensure_ascii=False) 56 | if not isinstance(jsonbytes, bytes): 57 | jsonbytes = jsonbytes.encode('utf-8') 58 | axesfile.write(jsonbytes) 59 | 60 | sys.exit(0) 61 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.ttf.1 -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.woff -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.woff.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.woff.1 -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2 -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FontBureau/videoproof/e7dbc8e2d92b137163850d58936b08fe05707976/old_tn_assets/assets_content/css/fonts/AdobeBlank.woff2.1 -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/fonts/fonts.txt: -------------------------------------------------------------------------------- 1 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank?iefix 2 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.woff2 3 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.woff 4 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.ttf 5 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank?iefix 6 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.woff2 7 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.woff 8 | http://old.typenetwork.com/assets_content/css/fonts/AdobeBlank.ttf 9 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-350?iefix 10 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-350.woff2 11 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-350.woff 12 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-350.ttf 13 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-350.svg#web 14 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-400?iefix 15 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-400.woff2 16 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-400.woff 17 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-400.ttf 18 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-400.svg#web 19 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-700?iefix 20 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-700.woff2 21 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-700.woff 22 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-700.ttf 23 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-12-wdth-100-wght-700.svg#web 24 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-16-wdth-100-wght-350?iefix 25 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-16-wdth-100-wght-350.woff2 26 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-16-wdth-100-wght-350.woff 27 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-16-wdth-100-wght-350.ttf 28 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-16-wdth-100-wght-350.svg#web 29 | old 30 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-350?iefix 31 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-350.woff2 32 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-350.woff 33 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-350.ttf 34 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-350.svg#web 35 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-400?iefix 36 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-400.woff2 37 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-400.woff 38 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-400.ttf 39 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-Italic-opsz-36-wdth-100-wght-400.svg#web 40 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-36-wdth-100-wght-400?iefix 41 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-36-wdth-100-wght-400.woff2 42 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-36-wdth-100-wght-400.woff 43 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-36-wdth-100-wght-400.ttf 44 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-36-wdth-100-wght-400.svg#web 45 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-350?iefix 46 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-350.woff2 47 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-350.woff 48 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-350.ttf 49 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-350.svg#web 50 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-400?iefix 51 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-400.woff2 52 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-400.woff 53 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-400.ttf 54 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-400.svg#web 55 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-600?iefix 56 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-600.woff2 57 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-600.woff 58 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-600.ttf 59 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-90-wght-600.svg#web 60 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-275?iefix 61 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-275.woff2 62 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-275.woff 63 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-275.ttf 64 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-275.svg#web 65 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-300?iefix 66 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-300.woff2 67 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-300.woff 68 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-300.ttf 69 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-300.svg#web 70 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-350?iefix 71 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-350.woff2 72 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-350.woff 73 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-350.ttf 74 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-350.svg#web 75 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-400?iefix 76 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-400.woff2 77 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-400.woff 78 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-400.ttf 79 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-400.svg#web 80 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-500?iefix 81 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-500.woff2 82 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-500.woff 83 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-500.ttf 84 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-500.svg#web 85 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-600?iefix 86 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-600.woff2 87 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-600.woff 88 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-600.ttf 89 | http://old.typenetwork.com/assets_content/css/fonts/Momentum-opsz-44-wdth-100-wght-600.svg#web 90 | http://old.typenetwork.com/assets_content/css/fonts/MomentumSans-VF.woff2 91 | http://old.typenetwork.com/assets_content/css/fonts/MomentumSans-VF.woff 92 | http://old.typenetwork.com/assets_content/css/fonts/MomentumSansItalic-VF.woff2 93 | http://old.typenetwork.com/assets_content/css/fonts/MomentumSansItalic-VF.woff 94 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/css/reset.css: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Reset :: style.css 3 | ---------------------------------------------------------- 4 | We have learned much from/been inspired by/taken code where offered from: 5 | 6 | Eric Meyer :: http://meyerweb.com 7 | HTML5 Doctor :: http://html5doctor.com 8 | and the HTML5 Boilerplate :: http://html5boilerplate.com 9 | 10 | -------------------------------------------------------------------------------*/ 11 | 12 | /* Let's default this puppy out 13 | -------------------------------------------------------------------------------*/ 14 | 15 | html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, menu, nav, section, time, mark, audio, video, details, summary { 16 | margin: 0; 17 | padding: 0; 18 | border: 0; 19 | font-size: 100%; 20 | font-weight: normal; 21 | vertical-align: baseline; 22 | background: transparent; 23 | } 24 | 25 | article, aside, figure, footer, header, nav, section, details, summary {display: block;} 26 | 27 | /* Handle box-sizing while better addressing child elements: 28 | http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */ 29 | html { 30 | box-sizing: border-box; 31 | } 32 | 33 | *, 34 | *:before, 35 | *:after { 36 | box-sizing: inherit; 37 | } 38 | 39 | /* consider resetting the default cursor: https://gist.github.com/murtaugh/5247154 */ 40 | 41 | /* Responsive images and other embedded objects 42 | */ 43 | img, 44 | object, 45 | embed {max-width: 100%;} 46 | 47 | /* 48 | Note: keeping IMG here will cause problems if you're using foreground images as sprites. 49 | In fact, it *will* cause problems with Google Maps' controls at small size. 50 | If this is the case for you, try uncommenting the following: 51 | 52 | #map img { 53 | max-width: none; 54 | } 55 | */ 56 | 57 | /* force a vertical scrollbar to prevent a jumpy page */ 58 | html {overflow-y: scroll;} 59 | 60 | /* we use a lot of ULs that aren't bulleted. 61 | don't forget to restore the bullets within content. */ 62 | ul {list-style: none;} 63 | 64 | blockquote, q {quotes: none;} 65 | 66 | blockquote:before, 67 | blockquote:after, 68 | q:before, 69 | q:after {content: ''; content: none;} 70 | 71 | a {margin: 0; padding: 0; font-size: 100%; vertical-align: baseline; background: transparent;} 72 | 73 | del {text-decoration: line-through;} 74 | 75 | abbr[title], dfn[title] {border-bottom: 1px dotted #000; cursor: help;} 76 | 77 | /* tables still need cellspacing="0" in the markup */ 78 | table {border-collapse: collapse; border-spacing: 0;} 79 | th {font-weight: bold; vertical-align: bottom;} 80 | td {font-weight: normal; vertical-align: top;} 81 | 82 | hr {display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0;} 83 | 84 | input, select {vertical-align: middle;} 85 | 86 | pre { 87 | white-space: pre; /* CSS2 */ 88 | white-space: pre-wrap; /* CSS 2.1 */ 89 | white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */ 90 | word-wrap: break-word; /* IE */ 91 | } 92 | 93 | input[type="radio"] {vertical-align: text-bottom;} 94 | input[type="checkbox"] {vertical-align: bottom;} 95 | .ie7 input[type="checkbox"] {vertical-align: baseline;} 96 | .ie6 input {vertical-align: text-bottom;} 97 | 98 | select, input, textarea {font: 99% sans-serif;} 99 | 100 | table {font-size: inherit; font: 100%;} 101 | 102 | small {font-size: 85%;} 103 | 104 | strong {font-weight: bold;} 105 | 106 | td, td img {vertical-align: top;} 107 | 108 | /* Make sure sup and sub don't mess with your line-heights http://gist.github.com/413930 */ 109 | sub, sup {font-size: 75%; line-height: 0; position: relative;} 110 | sup {top: -0.5em;} 111 | sub {bottom: -0.25em;} 112 | 113 | /* standardize any monospaced elements */ 114 | pre, code, kbd, samp {font-family: monospace, sans-serif;} 115 | 116 | /* hand cursor on clickable elements */ 117 | .clickable, 118 | label, 119 | input[type=button], 120 | input[type=submit], 121 | input[type=file], 122 | button {cursor: pointer;} 123 | 124 | /* Webkit browsers add a 2px margin outside the chrome of form elements */ 125 | button, input, select, textarea {margin: 0;} 126 | 127 | /* make buttons play nice in IE */ 128 | button, 129 | input[type=button] {width: auto; overflow: visible;} 130 | 131 | /* scale images in IE7 more attractively */ 132 | .ie7 img {-ms-interpolation-mode: bicubic;} 133 | 134 | /* prevent BG image flicker upon hover 135 | (commented out as usage is rare, and the filter syntax messes with some pre-processors) 136 | .ie6 html {filter: expression(document.execCommand("BackgroundImageCache", false, true));} 137 | */ 138 | 139 | /* let's clear some floats */ 140 | .clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; } 141 | .clearfix:after { clear: both; } 142 | .clearfix { zoom: 1; } 143 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_account.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_arrow-search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_cart-buy-gray.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_cart-buy-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_cart-buy-white.svg.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_cart-empty-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_filter-selected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_menu-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_menu-white.svg.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_menu-white.svg.2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_search-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_star-gray.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_star-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/icon_star-white.svg.1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /old_tn_assets/assets_content/img/images.txt: -------------------------------------------------------------------------------- 1 | http://old.typenetwork.com/assets_content/img/icon_star-gray.svg 2 | http://old.typenetwork.com/assets_content/img/icon_star-white.svg 3 | http://old.typenetwork.com/assets_content/img/icon_cart-buy-white.svg 4 | http://old.typenetwork.com/assets_content/img/icon_cart-buy-gray.svg 5 | http://old.typenetwork.com/assets_content/img/icon_cart-buy-white.svg 6 | http://old.typenetwork.com/assets_content/img/icon_arrow-search.svg 7 | http://old.typenetwork.com/assets_content/img/TypeNetwork_Mark_Inverse.svg 8 | http://old.typenetwork.com/assets_content/img/icon_menu-white.svg 9 | http://old.typenetwork.com/assets_content/img/icon_menu-white.svg 10 | http://old.typenetwork.com/assets_content/img/icon_star-white.svg 11 | http://old.typenetwork.com/assets_content/img/icon_cart-empty-white.svg 12 | http://old.typenetwork.com/assets_content/img/icon_account.svg 13 | http://old.typenetwork.com/assets_content/img/icon_search-white.svg 14 | http://old.typenetwork.com/assets_content/img/icon_menu-white.svg 15 | http://old.typenetwork.com/assets_content/img/icon_close.svg 16 | http://old.typenetwork.com/assets_content/img/icon_filter-selected.svg 17 | http://old.typenetwork.com/assets_content/img/TypeNetwork-LogoType_MSD-100_18pt.svg 18 | http://old.typenetwork.com/assets_content/img/TypeNetwork-LogoType_MSD-100_18pt.svg 19 | http://old.typenetwork.com/assets_content/img/TypeNetwork-LogoType_MSD-100_18pt.svg 20 | http://old.typenetwork.com/assets_content/img/TypeNetwork-LogoType_MSD-100_18pt.svg 21 | https://boldmonday.typenetwork.com/assets_content/img/TypeNetwork_Mark_Inverse.svg 22 | -------------------------------------------------------------------------------- /texts/pangram-words.txt: -------------------------------------------------------------------------------- 1 | A 2 | Above 3 | All 4 | Amaze 5 | Antique 6 | Are 7 | Arrive 8 | Asked 9 | Back 10 | Baking 11 | Beautiful 12 | Bed 13 | Before 14 | Big 15 | Blue 16 | Bog 17 | Box 18 | Boxing 19 | Brew 20 | Brown 21 | Buckles 22 | By 23 | Delivered 24 | Diva 25 | Dog 26 | Dozen 27 | Driven 28 | Dwarf 29 | Dwarves 30 | Equipment 31 | Exchanged 32 | Expensive 33 | Experts 34 | Fax 35 | Fickle 36 | Five 37 | For 38 | Fought 39 | Fox 40 | Foxy 41 | Girl 42 | Gnomes 43 | Goblin 44 | Gowns 45 | Grumpy 46 | Help 47 | Hug 48 | In 49 | Ivory 50 | Jackets 51 | Jennifer 52 | Jewelry 53 | Jim 54 | Jinx 55 | Jinxed 56 | Jocks 57 | Jolt 58 | Jovial 59 | Judge 60 | Judged 61 | Jugs 62 | Jump 63 | Jumps 64 | June 65 | Junk 66 | Lazy 67 | Linked 68 | Liquor 69 | Lopez 70 | Make 71 | Math 72 | My 73 | Next 74 | Nightly 75 | Of 76 | Onyx 77 | Over 78 | Oxygen 79 | Pack 80 | Pat 81 | Plaid 82 | Prize 83 | Promptly 84 | Public 85 | Pyjamas 86 | Quacking 87 | Quartz 88 | Queen 89 | Questions 90 | Quiche 91 | Quick 92 | Quickly 93 | Quit 94 | Quivering 95 | Quiz 96 | Realized 97 | Republic 98 | Same 99 | She 100 | Silk 101 | Six 102 | Size 103 | Spy 104 | Texas 105 | That 106 | The 107 | They 108 | Toxic 109 | Two 110 | Vaporized 111 | Wasn’t 112 | Watched 113 | Wax 114 | We 115 | When 116 | With 117 | Wizard 118 | Wizards 119 | Wove 120 | Woven 121 | Zephyrs 122 | Zombie 123 | Zombies 124 | -------------------------------------------------------------------------------- /texts/pangrams.txt: -------------------------------------------------------------------------------- 1 | Two driven jocks help fax my big quiz 2 | Fickle jinx bog dwarves spy math quiz 3 | Public junk dwarves hug my quartz fox 4 | Quick fox jumps nightly above wizard 5 | Five quacking zephyrs jolt my wax bed 6 | The five boxing wizards jump quickly 7 | Pack my box with five dozen liquor jugs 8 | The quick brown fox jumps over the lazy dog 9 | When zombies arrive, quickly fax judge Pat 10 | Woven silk pyjamas exchanged for blue quartz 11 | The quick onyx goblin jumps over the lazy dwarf 12 | Foxy diva Jennifer Lopez wasn’t baking my quiche 13 | My girl wove six dozen plaid jackets before she quit 14 | Grumpy wizards make a toxic brew for the jovial queen 15 | A quivering Texas zombie fought republic linked jewelry 16 | All questions asked by five watched experts amaze the judge 17 | Back in June we delivered oxygen equipment of the same size 18 | The wizard quickly jinxed the gnomes before they vaporized 19 | We promptly judged antique ivory buckles for the next prize 20 | Jim quickly realized that the beautiful gowns are expensive 21 | -------------------------------------------------------------------------------- /updatefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for d in fonts/repos/*; do 4 | if [ -d $d ]; then 5 | pushd $d 6 | git pull 7 | popd 8 | fi 9 | done 10 | 11 | python3 make-webfonts.py 12 | -------------------------------------------------------------------------------- /user-guide.css: -------------------------------------------------------------------------------- 1 | /* fix for tooltip overlay obscuring the target element */ 2 | /* https://github.com/usablica/intro.js/issues/109#issuecomment-512441508 */ 3 | 4 | .introjs-helperLayer { 5 | background: transparent; 6 | } 7 | 8 | .introjs-overlay { 9 | opacity: 0 !important; 10 | z-index: 99999999!important; 11 | } 12 | 13 | .introjs-helperLayer::before { 14 | opacity: 0; 15 | content: ''; 16 | position: absolute; 17 | width: inherit; 18 | height: inherit; 19 | /* 20 | border-radius: 0.5em; 21 | border: .2em solid rgba(255, 217, 68, 0.8); 22 | */ 23 | box-shadow: 0 0 0 1000em rgba(0,0,0, .7); 24 | opacity: 1; 25 | } 26 | 27 | .introjs-helperLayer::after { 28 | content: ''; 29 | left: 0; 30 | right: 0; 31 | top: 0; 32 | bottom: 0; 33 | position: absolute; 34 | z-index: 1000; 35 | } 36 | -------------------------------------------------------------------------------- /user-guide.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | "use strict"; 3 | 4 | function viewedAlready() { 5 | if (window.location.hash === '#view-intro') { 6 | return false; 7 | } 8 | try { 9 | return window.localStorage.getItem('user-guide') === 'viewed'; 10 | } catch (e) { 11 | //sometimes localStorage is blocked by security settings. try cookies 12 | return document.cookie.indexOf('userguide=viewed') >= 0; 13 | } 14 | } 15 | 16 | function setViewed() { 17 | try { 18 | window.localStorage.setItem('user-guide', 'viewed'); 19 | } catch (e) { 20 | document.cookie = "userguide=viewed;max-age=31536000;path=/"; 21 | } 22 | if (window.location.hash === '#view-intro') { 23 | window.location.hash = ''; 24 | } 25 | } 26 | 27 | function setup(force) { 28 | if (viewedAlready() && force !== true) { 29 | return Promise.reject(); 30 | } 31 | 32 | if ('introJs' in window) { 33 | return Promise.resolve(); 34 | } 35 | 36 | return Promise.all([ 37 | new Promise(function(r1) { 38 | var link = document.createElement('link'); 39 | link.rel = "stylesheet"; 40 | link.href = "/intro.js/introjs.css"; 41 | link.addEventListener('load', r1); 42 | document.head.insertBefore(link, document.getElementById('typetools-main-css')) 43 | }), 44 | 45 | new Promise(function(r2) { 46 | var link = document.createElement('link'); 47 | link.rel = "stylesheet"; 48 | link.href = "/user-guide.css"; 49 | link.addEventListener('load', r2); 50 | document.head.insertBefore(link, document.getElementById('typetools-main-css')) 51 | }), 52 | 53 | new Promise(function(r3) { 54 | var script = document.createElement('script'); 55 | script.src="/intro.js/intro.js"; 56 | script.addEventListener('load', r3); 57 | document.head.appendChild(script); 58 | }) 59 | ]); 60 | } 61 | 62 | function viewHints(force) { 63 | setup(force).then(function() { 64 | var intro = introJs(); 65 | intro.setOptions({ 66 | 'scrollToElement': false, 67 | 'steps': [ 68 | { 69 | 'intro': "Welcome to Video Proof! This is a tool for type designers and users to quickly explore the design space of OpenType variable fonts in a variety of settings." 70 | }, { 71 | 'element': document.getElementById('select-font-container'), 72 | 'intro': "Choose from a selection of Open Source fonts, or drag-and-drop your own TTF, OTF, or WOFF file onto the window to load your own variable font." 73 | }, { 74 | 'element': document.getElementById('select-glyphs-container'), 75 | 'intro': "Choose a set of characters/glyphs to view. Glyph lists will fit themselves into the available window space." 76 | }, { 77 | 'element': document.getElementById('keyframes-display-container'), 78 | 'intro': "Video Proof will automatically build a “tour” through the font’s design space, using the registered axes of weight, width, slant, italic, and optical size. Extra axes will appear below, if present, with their own mini-tours. Click any keyframe to jump to that spot in the tour." 79 | }, { 80 | 'element': document.getElementById('animation-controls'), 81 | 'intro': "Use these animation controls to naviagate the design-space tour. Forward and back controls jump to next/previous keyframes listed in the sidebar." 82 | /* 83 | }, { 84 | 'element': document.getElementById('meta-stuff-container'), 85 | 'intro': "Options to show various output information about the currently configured axes." 86 | */ 87 | } 88 | ] 89 | }); 90 | intro.start(); 91 | setViewed(); 92 | }).catch(function() { 93 | //already viewed 94 | }); 95 | } 96 | 97 | window.videoproofViewIntroHints = function() { 98 | viewHints(true); 99 | }; 100 | 101 | $(document).on('videoproof:fontLoaded', viewHints); 102 | })(); -------------------------------------------------------------------------------- /videoproof.css: -------------------------------------------------------------------------------- 1 | 2 | /* override a few global TN styles */ 3 | footer.footer-global { 4 | position: fixed; 5 | bottom: 0; 6 | width: 100%; 7 | } 8 | 9 | @media screen and (min-width: 56.25rem) { 10 | footer.footer-global { 11 | width: calc(100vw - 15.625rem); 12 | } 13 | } 14 | 15 | @media (min-width: 78.75rem) { 16 | footer.footer-global { 17 | width: calc(100vw - 17.375rem); 18 | } 19 | } 20 | 21 | .content-main { 22 | padding-bottom: 4em; 23 | } 24 | 25 | 26 | body.dropzone::after { 27 | position: fixed; 28 | top: 0; 29 | left: 0; 30 | width: 100vw; 31 | height: 100vh; 32 | background-color: rgba(64, 64, 64, 0.9); 33 | color: white; 34 | font-size: 3rem; 35 | text-align: center; 36 | vertical-align: middle; 37 | padding: 40% 1rem; 38 | content: "Drop your own font file(s) here"; 39 | z-index: 1000; 40 | } 41 | 42 | #reset { 43 | color: red; 44 | } 45 | 46 | #bookmark { 47 | color: blue; 48 | } 49 | 50 | #videoproof *:focus { 51 | outline: none; 52 | } 53 | 54 | /* CONTROLS */ 55 | 56 | #videoproof aside.content-filters { 57 | padding-top: 2.625rem; 58 | } 59 | 60 | #controls > * { 61 | margin: 1em 0; 62 | } 63 | 64 | #controls select { 65 | font-size: 80%; 66 | } 67 | 68 | #controls input { 69 | vertical-align: baseline; 70 | } 71 | 72 | #controls label { 73 | display: inline; 74 | line-height: inherit; 75 | } 76 | 77 | #controls h3 { 78 | border: none; 79 | margin-bottom: 0; 80 | } 81 | 82 | #controls h3 + * { 83 | margin-top: 0; 84 | } 85 | 86 | #controls h3.inline { 87 | display: inline; 88 | } 89 | 90 | #controls h3 label { 91 | font: inherit; 92 | color: inherit; 93 | line-height: inherit; 94 | text-transform: inherit; 95 | letter-spacing: inherit; 96 | } 97 | 98 | #controls #add-your-own-button { 99 | font-size: 0.8rem; 100 | display: block; 101 | text-align: right; 102 | } 103 | 104 | #controls #custom-fonts { 105 | position: absolute; 106 | left: -200vw; 107 | } 108 | 109 | 110 | /* sliders */ 111 | 112 | #controls .slider { 113 | display: grid; 114 | grid-template-columns: auto 3.5em; 115 | grid-template-rows: auto auto; 116 | grid-gap: 0.5em 0; 117 | align-items: baseline; 118 | width: 100%; 119 | padding: 0; 120 | text-indent: 0; 121 | margin: 1em 0; 122 | } 123 | 124 | #controls label { 125 | text-transform: none; 126 | color: black; 127 | font-weight: bold; 128 | letter-spacing: 0; 129 | } 130 | 131 | #controls .slider label abbr { 132 | color: #999; 133 | } 134 | 135 | #controls .slider label abbr::before { 136 | content: "("; 137 | } 138 | 139 | #controls .slider label abbr::after { 140 | content: ")"; 141 | } 142 | 143 | #controls .slider input[type=number] { 144 | border: none; 145 | color: #999; 146 | width: 100%; 147 | max-width: 4em; 148 | text-align: right; 149 | } 150 | 151 | #controls .slider input[type=range] { 152 | grid-column: 1/3; 153 | grid-row: 2; 154 | width: 100%; 155 | /* 156 | width: calc(100% - 6em); 157 | margin: 0 3em; 158 | */ 159 | } 160 | 161 | 162 | /* SLIDERS see form-controls.scss */ 163 | 164 | /* 165 | input[type=range]::before { 166 | display: none; 167 | position: absolute; 168 | right: 105%; 169 | content: attr(min); 170 | } 171 | 172 | input[type=range]::after { 173 | display: none; 174 | position: absolute; 175 | left: 105%; 176 | content: attr(max); 177 | } 178 | */ 179 | 180 | input[type=range][disabled] { 181 | opacity: 0.5; 182 | } 183 | 184 | 185 | /* alignment - color */ 186 | 187 | #colors > * { 188 | display: inline-block; 189 | vertical-align: middle; 190 | } 191 | 192 | #colors button { 193 | background: transparent; 194 | padding: 0; 195 | font-size: 1.2rem; 196 | width: 1.5em; 197 | line-height: 1; 198 | text-align: center; 199 | color: black; 200 | border: 0; 201 | box-shadow: none; 202 | } 203 | 204 | #colors input[type=color] { 205 | -webkit-appearance: none; 206 | position: relative; 207 | height: 0.24in; 208 | width: 0.25in; 209 | padding: 0; 210 | border: 0; 211 | margin: 0 0.333em; 212 | vertical-align: middle; 213 | } 214 | 215 | /* GLYPH GROUPS */ 216 | 217 | #show-extended-glyphs:disabled ~ * { 218 | opacity: 0.25; 219 | } 220 | 221 | #layout-specific-controls { 222 | display: block; 223 | margin: 0; 224 | padding: 0; 225 | } 226 | 227 | #layout-specific-controls > li { 228 | margin: 0; 229 | padding: 0; 230 | text-indent: 0; 231 | } 232 | 233 | 234 | /* ANIMATIION */ 235 | 236 | #animation-controls { 237 | display: inline-block; 238 | margin-top: 0.5rem; 239 | font-size: 100%; 240 | } 241 | 242 | #animation-controls > * { 243 | width: 2em; 244 | text-align: center; 245 | font-size: 100%; 246 | } 247 | 248 | #animation-controls button { 249 | border: none; 250 | background: transparent; 251 | box-shadow: none; 252 | padding: 0; 253 | } 254 | 255 | #animation-controls button.start { 256 | } 257 | 258 | #animation-controls button.back { 259 | } 260 | 261 | #animation-controls button.play-pause { 262 | vertical-align: middle; 263 | font-size: 200%; 264 | } 265 | 266 | #animation-controls button.forward { 267 | } 268 | 269 | #animation-controls button.end { 270 | } 271 | 272 | #animation-duration-container { 273 | font-size: smaller; 274 | display: inline-block; 275 | margin: 0 1em; 276 | } 277 | 278 | input#animation-duration { 279 | width: 3em; 280 | } 281 | 282 | 283 | output#aniparams { 284 | display: inline-block; 285 | color: #09f; 286 | font-size: 0.75rem; 287 | font-family: Verdana; 288 | font-weight: normal; 289 | font-style: normal; 290 | font-feature-settings: normal; 291 | line-height: 1.2; 292 | padding-left: 1rem; 293 | } 294 | 295 | 296 | ul.sidebar-list { 297 | white-space: nowrap; 298 | overflow: auto; 299 | } 300 | 301 | ul.sidebar-list li { 302 | font-family: RobotoFlex !important; 303 | font-size: 10px; 304 | -webkit-font-smoothing: antialiased; 305 | -moz-osx-font-smoothing: grayscale; 306 | } 307 | 308 | 309 | ul.sidebar-list li.current { 310 | color: red; 311 | font-weight: bold; 312 | } 313 | 314 | ul.sidebar-list a { 315 | color: inherit; 316 | cursor: pointer; 317 | font-variation-settings: normal !important; 318 | } 319 | 320 | ul.sidebar-list a:hover { 321 | color: red; 322 | } 323 | 324 | /* CONTENT */ 325 | 326 | #the-proof { 327 | /* width: 100%; */ 328 | max-width: none; 329 | margin: 0; 330 | padding: 1rem; 331 | } 332 | 333 | #the-proof.fixed-line-breaks { 334 | word-break: break-all; 335 | word-wrap: break-word; 336 | overflow-wrap: break-word; 337 | font-size: 36pt; 338 | line-height: 1.5; 339 | text-align: left; 340 | } 341 | 342 | #the-proof.fixed-line-breaks div, #the-proof.fixed-line-breaks span { 343 | display: block; 344 | white-space: nowrap; 345 | word-break: normal; 346 | word-wrap: normal; 347 | overflow-wrap: normal; 348 | } 349 | 350 | #the-proof.fixed-line-breaks span { 351 | display: inline-block; 352 | min-width: 1em; 353 | /* font: inherit; */ 354 | text-align: left; 355 | margin-right: 0.3em; 356 | } 357 | 358 | 359 | /* ANIMATION */ 360 | 361 | #the-proof, #the-proof .animation-target, #keyframes-display a { 362 | animation-name: videoproof; 363 | animation-timing-function: linear; 364 | animation-iteration-count: infinite; 365 | animation-duration: 60s; 366 | /* this is a standin for percent of animation cycle 367 | * TODO: I don't really understand how this is used. 368 | * It has the same numeric value as the percentage progress of 369 | * the the animation, but I can't find where it is used. Maybe 370 | * it's intended for debugging to read in the web-developer tool. 371 | */ 372 | outline-offset: 100px; 373 | outline-style: solid; 374 | outline-color: transparent; 375 | outline-width: 1px; 376 | } 377 | 378 | .paused #the-proof, .paused #the-proof .animation-target, .paused #keyframes-display a { 379 | animation-play-state: paused; 380 | } 381 | 382 | .moar #the-proof, .moar #the-proof .animation-target { 383 | animation-name: moar; 384 | animation-duration: 6s; 385 | animation-iteration-count: infinite; 386 | } 387 | 388 | .moar #keyframes-display a { 389 | animation-play-state: paused; 390 | } 391 | 392 | 393 | #comment-box textarea { 394 | width: 100%; 395 | } 396 | -------------------------------------------------------------------------------- /videoproof.inc: -------------------------------------------------------------------------------- 1 | "Ramp", 9 | 'grid' => "Array", 10 | // 'waterfall' => "Waterfall", 11 | // 'grid' => "Grid", 12 | 'type-your-own' => "Input", 13 | 'contextual' => "Contextual", 14 | 'composition' => "Composition", 15 | ); 16 | 17 | private $registeredAxes = array('opsz', 'wdth', 'wght'); //, 'ital', 'slnt', 'grad', 'GRAD'); 18 | 19 | private $glyphsets; 20 | 21 | public static function requireLogin($user, $password) { 22 | if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $user || $_SERVER['PHP_AUTH_PW'] !== $password) { 23 | header('HTTP/1.1 401 Unauthorized'); 24 | header('WWW-Authenticate: Basic realm="TN Video Proof"'); 25 | echo 'Varfontnügen'; 26 | exit; 27 | } 28 | } 29 | 30 | function __construct() { 31 | // $this->glyphsets = yaml_parse_file(__DIR__ . '/glyph-groups.yaml'); 32 | $this->glyphsets = json_decode(file_get_contents(__DIR__ . '/glyph-groups.json'), true); 33 | $this->axesFile = __DIR__ . "/fonts/axes.json"; 34 | if (!file_exists($this->axesFile)) { 35 | $this->axesFile = __DIR__ . "/fonts/example-axes.json"; 36 | } 37 | 38 | $this->fontinfo = json_decode(file_get_contents($this->axesFile)); 39 | $this->fontinfo = get_object_vars($this->fontinfo); 40 | ksort($this->fontinfo); 41 | 42 | $specific_font = false; 43 | if (isset($_SERVER['HTTP_HOST']) and preg_match('/^(.+)-videoproof\./', $_SERVER['HTTP_HOST'], $matches)) { 44 | $specific_font = strtolower($matches[1]); 45 | } 46 | 47 | foreach ($this->fontinfo as $filebase => $axes) { 48 | if ($specific_font) { 49 | if (strpos(strtolower($filebase), $specific_font) !== 0) { 50 | unset($this->fontinfo[$filebase]); 51 | continue; 52 | } 53 | } 54 | 55 | if (!isset($axes->wght) || !isset($axes->wdth)) { 56 | unset($this->fontinfo[$filebase]); 57 | continue; 58 | } 59 | 60 | #take off dev stuff from the end of the filename 61 | //$fontname = preg_replace('/(?:[Vv]\d+|[Aa]lpha|[Bb]eta)?-VF$/', '', $filebase); 62 | //$fontname = preg_replace('/(?:[Vv]\d+)?-VF$/', '', $filebase); 63 | $fontname = preg_replace('/-VF$/', '', $filebase); 64 | 65 | #separate into words 66 | $fontname = preg_replace('/(?<=[a-z])[_-]?(?=[A-Z])/', ' ', $fontname); 67 | 68 | //figure out axis order 69 | $order = array(); 70 | 71 | if (isset($axes->order)) { 72 | if (!$order) { 73 | $order = $axes->order; 74 | } 75 | unset($axes->order); 76 | } 77 | 78 | if (isset($axes->instances)) { 79 | unset($axes->instances); 80 | } 81 | 82 | if (in_array('instances', $order)) { 83 | $order = array_diff($order, array('instances')); 84 | } 85 | 86 | //sanity check on axis order 87 | foreach ($order as $oaxis) { 88 | if (!isset($axes->$oaxis)) { 89 | $order = array(); 90 | break; 91 | } 92 | foreach (get_object_vars($axes) as $k => $v) { 93 | if (!in_array($k, $order)) { 94 | $order = array(); 95 | break; 96 | } 97 | } 98 | } 99 | 100 | if (!$order) { 101 | $order = array_keys(get_object_vars($axes)); 102 | usort($order, function($a, $b) { 103 | //registered, then lowercase, then alphabetic 104 | // i.e. wght, wdth, opsz, XOPQ, XTRA, YOPQ, YTRA 105 | $aRegistered = in_array($a, $this->registeredAxes); 106 | $bRegistered = in_array($b, $this->registeredAxes); 107 | $aLower = preg_match('/[a-z]/', $a); 108 | $bLower = preg_match('/[a-z]/', $b); 109 | if ($aRegistered and !$bRegistered) return -1; 110 | if ($bRegistered and !$aRegistered) return 1; 111 | if ($aLower and !$bLower) return -1; 112 | if ($bLower and !$aLower) return 1; 113 | if ($a < $b) -1; 114 | if ($a > $b) 1; 115 | return 0; 116 | }); 117 | } 118 | 119 | $this->fontinfo[$filebase] = (object)array( 120 | 'name' => $fontname, 121 | 'axes' => $axes, 122 | 'axisOrder' => $order, 123 | ); 124 | } 125 | } 126 | 127 | public function pageHead() { 128 | foreach ($this->fontinfo as $filebase => $info) { 129 | print << 131 | @font-face { 132 | font-family: "$filebase-VP"; 133 | src: url("./fonts/$filebase.woff") format("woff"); 134 | font-weight: 100 900; 135 | } 136 | 137 | EOD; 138 | } 139 | 140 | foreach ($this->tools as $tool => $name) { 141 | print "\n"; 142 | } 143 | 144 | print "\n"; 149 | 150 | //foreach ($this->tools as $tool => $name) { 151 | // print "\n"; 152 | //} 153 | 154 | return ""; 155 | } 156 | 157 | public function selectMode() { 158 | ?> 159 |
160 |

161 | 166 |
167 | 173 |
174 |

175 | 180 | 181 | + Add your own 182 |
183 | 190 | 199 |
200 | 201 |
202 | 209 |

210 | 265 |
266 | 267 |
268 |
269 | EOD; 270 | return ""; 271 | } 272 | 273 | public function animationControls() { 274 | ?> 275 |
276 | 277 | 278 | 279 | 280 | 281 | 285 |
286 | 287 |
288 | 289 | sec 290 |
291 | 297 |
298 | 299 | 301 | 302 | 303 | 305 |
306 | axesFile); 313 | $date = date("M j", $then); 314 | $time = date("H:i", $then); 315 | $diff = $now - $then; 316 | if ($diff < 60) { 317 | return $diff == 1 ? "just now" : "$diff seconds ago"; 318 | } 319 | $diff = floor($diff/60); 320 | if ($diff < 60) { 321 | return $diff == 1 ? "1 minute ago" : "$diff minutes ago"; 322 | } 323 | $diff = floor($diff/24); 324 | if ($diff < 24) { 325 | return $diff == 1 ? "1 hour ago" : "$diff hours ago"; 326 | } 327 | if ($diff < 48) { 328 | return "yesterday $time"; 329 | } 330 | return $date; 331 | } 332 | } 333 | --------------------------------------------------------------------------------