diff --git a/quad2/attr.rkt b/quad2/attr.rkt index 14ab1c4e..61df2d31 100644 --- a/quad2/attr.rkt +++ b/quad2/attr.rkt @@ -8,14 +8,20 @@ "quad.rkt") (provide (all-defined-out)) -(define (do-attr-iteration qs #:which-key predicate #:value-proc proc) +(define (do-attr-iteration qs #:which-key which-arg #:value-proc proc) + (define key-predicate + (match which-arg + [(? symbol? sym) (λ (k) (eq? k sym))] + [(and (list (? symbol?) ...) syms) (λ (k) (memq k syms))] + [(? procedure? pred) pred] + [other (raise-argument-error 'do-attr-iteration "key predicate" other)])) (define attrs-seen (make-hasheq)) (for ([q (in-list qs)]) (define attrs (quad-attrs q)) (hash-ref! attrs-seen attrs (λ () (for ([k (in-hash-keys attrs)] - #:when (predicate k)) + #:when (key-predicate k)) (hash-update! attrs k (λ (val) (proc val attrs)))) #t))) qs) diff --git a/quad2/default-fonts/blockquote/LICENSE.txt b/quad2/default-fonts/blockquote/LICENSE.txt new file mode 100755 index 00000000..b4a39671 --- /dev/null +++ b/quad2/default-fonts/blockquote/LICENSE.txt @@ -0,0 +1,99 @@ +Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ +with Reserved Font Name Fira Sans. + +Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ +with Reserved Font Name Fira Mono. + +Copyright (c) 2014, Telefonica S.A. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/blockquote/bold-italic/fira-sans-bold-italic.otf b/quad2/default-fonts/blockquote/bold-italic/fira-sans-bold-italic.otf new file mode 100755 index 00000000..211d6e8d Binary files /dev/null and b/quad2/default-fonts/blockquote/bold-italic/fira-sans-bold-italic.otf differ diff --git a/quad2/default-fonts/blockquote/bold/fira-sans-bold.otf b/quad2/default-fonts/blockquote/bold/fira-sans-bold.otf new file mode 100755 index 00000000..3e586b42 Binary files /dev/null and b/quad2/default-fonts/blockquote/bold/fira-sans-bold.otf differ diff --git a/quad2/default-fonts/blockquote/italic/fira-sans-italic.otf b/quad2/default-fonts/blockquote/italic/fira-sans-italic.otf new file mode 100755 index 00000000..948c96f4 Binary files /dev/null and b/quad2/default-fonts/blockquote/italic/fira-sans-italic.otf differ diff --git a/quad2/default-fonts/blockquote/regular/fira-sans.otf b/quad2/default-fonts/blockquote/regular/fira-sans.otf new file mode 100755 index 00000000..20bc9a19 Binary files /dev/null and b/quad2/default-fonts/blockquote/regular/fira-sans.otf differ diff --git a/quad2/default-fonts/code/LICENSE.txt b/quad2/default-fonts/code/LICENSE.txt new file mode 100755 index 00000000..37c4a30b --- /dev/null +++ b/quad2/default-fonts/code/LICENSE.txt @@ -0,0 +1,94 @@ +Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. +with Reserved Font Name < Fira >, + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/code/fira-mono.otf b/quad2/default-fonts/code/fira-mono.otf new file mode 100755 index 00000000..c30b25b9 Binary files /dev/null and b/quad2/default-fonts/code/fira-mono.otf differ diff --git a/quad2/default-fonts/default/SourceSerifPro-Regular.otf b/quad2/default-fonts/default/SourceSerifPro-Regular.otf new file mode 100755 index 00000000..4ff89331 Binary files /dev/null and b/quad2/default-fonts/default/SourceSerifPro-Regular.otf differ diff --git a/quad2/default-fonts/fallback-emoji/LICENSE_OFL.txt b/quad2/default-fonts/fallback-emoji/LICENSE_OFL.txt new file mode 100644 index 00000000..d952d62c --- /dev/null +++ b/quad2/default-fonts/fallback-emoji/LICENSE_OFL.txt @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/fallback-emoji/NotoEmoji-Regular.ttf b/quad2/default-fonts/fallback-emoji/NotoEmoji-Regular.ttf new file mode 100644 index 00000000..19b7badf Binary files /dev/null and b/quad2/default-fonts/fallback-emoji/NotoEmoji-Regular.ttf differ diff --git a/quad2/default-fonts/fallback-emoji/README b/quad2/default-fonts/fallback-emoji/README new file mode 100644 index 00000000..15abba24 --- /dev/null +++ b/quad2/default-fonts/fallback-emoji/README @@ -0,0 +1,15 @@ +This package is part of the noto project. Visit +google.com/get/noto for more information. + +Built on 2017-10-24 from the following noto repository: +----- +Repo: noto-emoji +Tag: v2017-09-13-design-refresh +Date: 2017-09-20 10:08:23 GMT +Commit: d5ac67b140cc63aa512bbb3d164e15737dd97564 + +Update color emoji font and assets for new design. + +This design is the one used in Android O. + +The blobs are dead. Long live the blobs. diff --git a/quad2/default-fonts/fallback-math/LICENSE_OFL.txt b/quad2/default-fonts/fallback-math/LICENSE_OFL.txt new file mode 100644 index 00000000..d952d62c --- /dev/null +++ b/quad2/default-fonts/fallback-math/LICENSE_OFL.txt @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/fallback-math/NotoSansMath-Regular.ttf b/quad2/default-fonts/fallback-math/NotoSansMath-Regular.ttf new file mode 100644 index 00000000..55012c03 Binary files /dev/null and b/quad2/default-fonts/fallback-math/NotoSansMath-Regular.ttf differ diff --git a/quad2/default-fonts/fallback/LICENSE_OFL.txt b/quad2/default-fonts/fallback/LICENSE_OFL.txt new file mode 100644 index 00000000..d952d62c --- /dev/null +++ b/quad2/default-fonts/fallback/LICENSE_OFL.txt @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/fallback/bold-italic/NotoSans-BoldItalic.ttf b/quad2/default-fonts/fallback/bold-italic/NotoSans-BoldItalic.ttf new file mode 100644 index 00000000..385e6acb Binary files /dev/null and b/quad2/default-fonts/fallback/bold-italic/NotoSans-BoldItalic.ttf differ diff --git a/quad2/default-fonts/fallback/bold/NotoSans-Bold.ttf b/quad2/default-fonts/fallback/bold/NotoSans-Bold.ttf new file mode 100644 index 00000000..1db7886e Binary files /dev/null and b/quad2/default-fonts/fallback/bold/NotoSans-Bold.ttf differ diff --git a/quad2/default-fonts/fallback/italic/NotoSans-Italic.ttf b/quad2/default-fonts/fallback/italic/NotoSans-Italic.ttf new file mode 100644 index 00000000..6d2c71c8 Binary files /dev/null and b/quad2/default-fonts/fallback/italic/NotoSans-Italic.ttf differ diff --git a/quad2/default-fonts/fallback/regular/NotoSans-Regular.ttf b/quad2/default-fonts/fallback/regular/NotoSans-Regular.ttf new file mode 100644 index 00000000..0a01a062 Binary files /dev/null and b/quad2/default-fonts/fallback/regular/NotoSans-Regular.ttf differ diff --git a/quad2/default-fonts/heading/LICENSE.txt b/quad2/default-fonts/heading/LICENSE.txt new file mode 100755 index 00000000..b4a39671 --- /dev/null +++ b/quad2/default-fonts/heading/LICENSE.txt @@ -0,0 +1,99 @@ +Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ +with Reserved Font Name Fira Sans. + +Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ +with Reserved Font Name Fira Mono. + +Copyright (c) 2014, Telefonica S.A. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/heading/bold-italic/fira-sans-light-bold-italic.otf b/quad2/default-fonts/heading/bold-italic/fira-sans-light-bold-italic.otf new file mode 100755 index 00000000..661511a7 Binary files /dev/null and b/quad2/default-fonts/heading/bold-italic/fira-sans-light-bold-italic.otf differ diff --git a/quad2/default-fonts/heading/bold/fira-sans-light-bold.otf b/quad2/default-fonts/heading/bold/fira-sans-light-bold.otf new file mode 100755 index 00000000..f077fff9 Binary files /dev/null and b/quad2/default-fonts/heading/bold/fira-sans-light-bold.otf differ diff --git a/quad2/default-fonts/heading/italic/fira-sans-light-italic.otf b/quad2/default-fonts/heading/italic/fira-sans-light-italic.otf new file mode 100755 index 00000000..6ccf6f53 Binary files /dev/null and b/quad2/default-fonts/heading/italic/fira-sans-light-italic.otf differ diff --git a/quad2/default-fonts/heading/regular/fira-sans-light.otf b/quad2/default-fonts/heading/regular/fira-sans-light.otf new file mode 100755 index 00000000..02fa6073 Binary files /dev/null and b/quad2/default-fonts/heading/regular/fira-sans-light.otf differ diff --git a/quad2/default-fonts/text/LICENSE.md b/quad2/default-fonts/text/LICENSE.md new file mode 100755 index 00000000..09be3f61 --- /dev/null +++ b/quad2/default-fonts/text/LICENSE.md @@ -0,0 +1,93 @@ +Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/quad2/default-fonts/text/bold-italic/SourceSerifPro-BoldIt.otf b/quad2/default-fonts/text/bold-italic/SourceSerifPro-BoldIt.otf new file mode 100755 index 00000000..7da8ec15 Binary files /dev/null and b/quad2/default-fonts/text/bold-italic/SourceSerifPro-BoldIt.otf differ diff --git a/quad2/default-fonts/text/bold/SourceSerifPro-Bold.otf b/quad2/default-fonts/text/bold/SourceSerifPro-Bold.otf new file mode 100755 index 00000000..bb640dca Binary files /dev/null and b/quad2/default-fonts/text/bold/SourceSerifPro-Bold.otf differ diff --git a/quad2/default-fonts/text/italic/SourceSerifPro-It.otf b/quad2/default-fonts/text/italic/SourceSerifPro-It.otf new file mode 100755 index 00000000..f2d4c157 Binary files /dev/null and b/quad2/default-fonts/text/italic/SourceSerifPro-It.otf differ diff --git a/quad2/default-fonts/text/regular/SourceSerifPro-Regular.otf b/quad2/default-fonts/text/regular/SourceSerifPro-Regular.otf new file mode 100755 index 00000000..4ff89331 Binary files /dev/null and b/quad2/default-fonts/text/regular/SourceSerifPro-Regular.otf differ diff --git a/quad2/font.rkt b/quad2/font.rkt new file mode 100644 index 00000000..7313d90d --- /dev/null +++ b/quad2/font.rkt @@ -0,0 +1,153 @@ +#lang debug racket/base +(require racket/path + racket/match + racket/runtime-path + racket/list + racket/string + fontland/font-path + "quad.rkt" + "pipeline.rkt" + "attr.rkt") +(provide (all-defined-out)) + +(define :font-family 'font-family) +(define :font-path 'font-path) +(define :font-bold 'font-bold) +(define :font-italic 'font-italic) + +(define-runtime-path quad2-fonts-dir "default-fonts") +(define-runtime-path default-font-face "default-fonts/default/SourceSerifPro-Regular.otf") +(define top-font-directory "fonts") +(define font-file-extensions '(#".otf" #".ttf" #".woff" #".woff2")) +(define default-font-family "text") + +(define (fonts-in-directory dir) + (for/list ([font-path (in-directory dir)] + #:when (member (path-get-extension font-path) font-file-extensions)) + font-path)) + +(define (setup-font-path-table [base-path (current-directory)]) + ;; create a table of font paths that we can use to resolve references to font names. + ;; rules for font naming + ;; "fonts" subdirectory on top + ;; family directories inside: each named with font family name + ;; this makes it possible to give font families generic names (e.g., "body-text") + ;; and change the font files without disturbing anything else. + (define doc-fonts-dir + (simple-form-path + (build-path (match/values (split-path base-path) + [(base name #true) (build-path base name)] + [(dir _ _) dir]) top-font-directory))) + ;; run doc-fonts-dir first because earlier fonts take precedence (using hash-ref! below) + (define font-paths (make-hash)) + (for* ([fonts-dir (in-list (list doc-fonts-dir quad2-fonts-dir))] + #:when (directory-exists? fonts-dir) + [font-family-subdir (in-list (directory-list fonts-dir #:build? #t))] + #:when (directory-exists? font-family-subdir) + [fonts-in-this-directory (in-value (fonts-in-directory font-family-subdir))] + [font-path (in-list fonts-in-this-directory)]) + (match-define (list font-path-string family-name) + (for/list ([x (list font-path font-family-subdir)]) + (path->string (find-relative-path fonts-dir x)))) + (define path-parts (for/list ([part (in-list (explode-path (string->path (string-downcase font-path-string))))]) + (path->string part))) + (define key + (cons (string-downcase family-name) + (cond + ;; special case: if there's only one style in the family directory, + ;; treat it as the regular style, regardless of name + [(= (length fonts-in-this-directory) 1) 'r] + ;; cases where fonts are in subdirectories named by style + ;; infer style from subdir name + [(member "bold-italic" path-parts) 'bi] + [(member "bold" path-parts) 'b] + [(member "italic" path-parts) 'i] + [else + ;; try to infer from filename alone + ;; TODO: what happens when there is no regular style? + (define filename (string-downcase (last path-parts))) + (define filename-contains-bold? (string-contains? filename "bold")) + (define filename-contains-italic? (string-contains? filename "italic")) + (cond + [(and filename-contains-bold? filename-contains-italic?) 'bi] + [filename-contains-bold? 'b] + [filename-contains-italic? 'i] + [else 'r])]))) + ;; only set value if there's not one there already. + ;; this means that we only use the first eligible font we find. + (hash-ref! font-paths key font-path)) + font-paths) + +(define (make-key font-family [bold #f] [italic #f]) + (cons (string-downcase font-family) + (cond + [(and bold italic) 'bi] + [bold 'b] + [italic 'i] + [else 'r]))) + +(define (font-attrs->path font-paths font-family bold italic) + ;; find the font-path corresponding to a certain family name and style. + (define regular-key (make-key font-family)) + + ;; if it's not already in font paths, it might be a system font + ;; we use `family->path` to try to resolve the ribbi styles + ;; if the font is a system font, we will end up with paths. + ;; if it's not, we will end up with #false for those entries in `font-paths`, + ;; and fall through to the default font when we do the `cond` below. + ;; TODO: family->path doesn't work because it relies on ffi into fontconfig + ;; which has broken in cs, I guess + #| +(unless (hash-has-key? font-paths regular-key) + (for* ([bold (in-list (list #false #true))] + [italic (in-list (list #false #true))]) + (hash-set! font-paths + (make-key font-family bold italic) + (family->path font-family #:bold bold #:italic italic)))) +|# + (cond + [(hash-ref font-paths (make-key font-family bold italic) #false)] + ;; try regular style if style-specific key isn't there for b i or bi + [(and (or bold italic) (hash-ref font-paths regular-key #false))] + ;; otherwise use default + [else default-font-face])) + +(define (font-path-string? x) + (and (path-string? x) + (member (path-get-extension (string->path x)) font-file-extensions) + #true)) + +(define (resolve-font-path font-paths val attrs) + ;; convert references to a font family and style to an font path on disk + ;; we trust it exists because we used `setup-font-path-table` earlier, + ;; but if not, fallback fonts will kick in, on the idea that a missing font shouldn't stop the show + (define this-font-family (hash-ref! attrs :font-family default-font-family)) + (match (string-downcase this-font-family) + [(? font-path-string? ps) (path->complete-path ps)] + [_ + (define this-bold (hash-ref! attrs :font-bold #false)) + (define this-italic (hash-ref! attrs :font-italic #false)) + (font-attrs->path font-paths this-font-family this-bold this-italic)])) + +(define-pass (resolve-font-paths qs) + ;; convert references to a font family and style to an font path on disk + ;; we trust it exists because we used `setup-font-path-table!` earlier, + ;; but if not, fallback fonts will kick in, on the idea that a missing font shouldn't stop the show + #:pre (list-of quad?) + #:post (list-of quad?) + (define font-paths (setup-font-path-table)) + (do-attr-iteration qs + #:which-key :font-family + #:value-proc (λ (val attrs) (resolve-font-path font-paths val attrs)))) + +(module+ test + (require rackunit) + (define q (make-quad #:attrs (make-hasheq '((font-family . "Heading"))))) + (define qs (list q)) + (define (resolved-font-for-family val #:bold [bold #f] #:italic [italic #f]) + (last (explode-path (quad-ref (car (resolve-font-paths (list (make-quad #:attrs (make-hasheq (list (cons :font-family val) (cons :font-bold bold) + (cons :font-italic italic))))))) :font-family)))) + (check-equal? (resolved-font-for-family "Heading") (string->path "fira-sans-light.otf")) + (check-equal? (resolved-font-for-family "CODE") (string->path "fira-mono.otf")) + (check-equal? (resolved-font-for-family "blockquote" #:bold #t) (string->path "fira-sans-bold.otf")) + (check-equal? (resolved-font-for-family "nonexistent-fam") (string->path "SourceSerifPro-Regular.otf"))) \ No newline at end of file diff --git a/quad2/main.rkt b/quad2/main.rkt index 674a9670..59055b7d 100644 --- a/quad2/main.rkt +++ b/quad2/main.rkt @@ -8,6 +8,7 @@ "draw.rkt" "struct.rkt" "attr.rkt" + "font.rkt" racket/string racket/match) @@ -26,16 +27,14 @@ #:post (list-of simple-quad?) (apply append (for/list ([q (in-list qs)]) - (match q - [(quad _ _ (list (? string? str)) _) - (for/list ([c (in-string str)]) - (struct-copy quad q [elems (list (string c))]))] - [_ (list q)])))) + (match q + [(quad _ _ (list (? string? str)) _) + (for/list ([c (in-string str)]) + (struct-copy quad q [elems (list (string c))]))] + [_ (list q)])))) (define quad-compile (make-pipeline (list bootstrap-input - ;; TODO: resolve font paths - ;; TODO: missing glyphs linearize-quad ;; TODO: maybe we shouldn't downcase values? ;; we have to track attrs that are case sensitive @@ -43,12 +42,14 @@ ;; but will it always be apparent whether it's suitable? ;; or will we have to still track which attrs are case-sensitive? downcase-attr-values + ;; TODO: convert booleanized attrs + ;; TODO: convert numerical attrs ;; upgrade relative paths to complete for ease of handling later ;; TODO: we have to track which attrs take a path ;; (to distinguish them from attrs that might have path-like values ;; that should be left alone) complete-attr-paths - ;; TODO: resolve font paths + resolve-font-paths ;; TODO: resolve font sizes ;; we resolve dimension strings after font size ;; because they can be denoted relative to em size @@ -58,6 +59,7 @@ merge-adjacent-strings split-whitespace split-into-single-char-quads + ;; TODO: missing glyphs layout make-drawing-insts stackify)))