Add font family choice to the text widget, move toolbar below the editor
Six more vendored families alongside the existing Noto Sans (Inter, Source Sans 3, Noto Serif, Crimson Text, Arvo, IBM Plex Mono -- sans/ serif/slab/mono variety), all OFL-licensed with their own per-family license file in app/fonts/ since each has a different copyright holder. Static Regular/Bold/Italic/BoldItalic builds only -- variable-font-only families (Inter and Source Sans's current Google Fonts releases, plus Playfair Display/Lora/Merriweather) were skipped in favor of static builds from their own upstream repos, keeping every family's loading code uniform with what was already there. Considered but deliberately left out: Georgia -- a proprietary Microsoft core font, not freely redistributable, unlike everything else vendored here. Also moves the bold/italic/underline/color toolbar below the contenteditable box per request, and reorders the dialog's Settings card to a more natural family-then-size order. Fixes a latent migration bug this surfaced: migration 20 (static image widget) used Base.metadata.create_all, which creates every table declared in Base.metadata that's missing, not just its own new one -- harmless when nothing else pending, but once TextWidgetConfig existed it would silently pre-create text_widget_configs (in whatever shape models.py currently declares) before migration 21 got a turn, so migration 21's own CREATE TABLE (or a later ALTER TABLE adding font_family) would collide with a table create_all had already leaked into existence. Both migrations 20 and 21 now use raw, frozen CREATE TABLE SQL instead, matching migration 17's existing precedent for exactly this reason.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
Copyright (c) 2010-2013, Anton Koovit ([email protected]), with Reserved Font Name 'Arvo'
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2010 The Crimson Text Project Authors (https://github.com/googlefonts/Crimson)
|
||||
|
||||
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:
|
||||
https://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.
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,92 @@
|
||||
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
||||
|
||||
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 AND 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.
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2010-2020 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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+46
-6
@@ -505,18 +505,57 @@ def _migration_20(conn) -> None:
|
||||
image (or a PDF's first page) the user last uploaded (see
|
||||
app/image_upload.py, routers/api_widgets.py's api_widget_static_
|
||||
upload) -- no live upstream to poll, unlike every other widget type.
|
||||
Brand new table with no existing data to carry forward, so this is
|
||||
just create_all's usual "creates the one new table; existing ones
|
||||
untouched" shape (see _migration_2)."""
|
||||
Base.metadata.create_all(bind=conn)
|
||||
|
||||
Raw CREATE TABLE, not Base.metadata.create_all (this migration
|
||||
originally used create_all -- switched retroactively once it turned
|
||||
out to matter): create_all creates every table declared in Base.
|
||||
metadata that's missing, not just this migration's own new one, so
|
||||
it would just as happily create text_widget_configs (a LATER
|
||||
migration's model, once TextWidgetConfig existed in models.py) years
|
||||
before migration 21 gets a turn -- and then migration 21's own
|
||||
CREATE TABLE collides with the one create_all already snuck in. Same
|
||||
fix, same reasoning as migration 21's own comment about migration
|
||||
22's ALTER TABLE -- see that one for the fuller explanation."""
|
||||
conn.execute(text(
|
||||
"CREATE TABLE static_widget_configs ("
|
||||
"widget_id INTEGER PRIMARY KEY REFERENCES widgets(id) ON DELETE CASCADE, "
|
||||
"image BLOB, "
|
||||
"original_filename TEXT NOT NULL DEFAULT '', "
|
||||
"uploaded_at REAL NOT NULL DEFAULT 0.0, "
|
||||
"display_mode TEXT NOT NULL DEFAULT 'crop_fill')"
|
||||
))
|
||||
|
||||
|
||||
def _migration_21(conn) -> None:
|
||||
"""New widget type: a text widget shows user-authored rich text (see
|
||||
app/text_content.py, app/widgets/text.py, models.TextWidgetConfig)
|
||||
-- another no-live-upstream type like migration 20's static image.
|
||||
Same brand-new-table create_all shape."""
|
||||
Base.metadata.create_all(bind=conn)
|
||||
|
||||
Raw CREATE TABLE (not Base.metadata.create_all, unlike migration 20's
|
||||
static_widget_configs) because migration 22 adds a column to this
|
||||
same table right after -- create_all always reflects models.py's
|
||||
CURRENT shape, so replaying the full migration chain on an old
|
||||
database would have it already include that later column and
|
||||
collide with migration 22's ALTER TABLE. Same reason migration 17's
|
||||
task_widget_configs CREATE TABLE is raw SQL rather than create_all,
|
||||
ahead of migration 19's ALTER TABLE ADD COLUMN name."""
|
||||
conn.execute(text(
|
||||
"CREATE TABLE text_widget_configs ("
|
||||
"widget_id INTEGER PRIMARY KEY REFERENCES widgets(id) ON DELETE CASCADE, "
|
||||
"content TEXT, "
|
||||
"font_size INTEGER NOT NULL DEFAULT 28, "
|
||||
"align TEXT NOT NULL DEFAULT 'left', "
|
||||
"background_color TEXT NOT NULL DEFAULT '#ffffff')"
|
||||
))
|
||||
|
||||
|
||||
def _migration_22(conn) -> None:
|
||||
"""Adds a font family choice to the text widget (app/widgets/text.py's
|
||||
FONT_FAMILIES) alongside its existing font_size -- both whole-widget
|
||||
settings, not per-run. "sans" (Noto Sans) matches the column default
|
||||
so existing text widgets keep rendering in the same font they always
|
||||
have."""
|
||||
conn.execute(text("ALTER TABLE text_widget_configs ADD COLUMN font_family TEXT NOT NULL DEFAULT 'sans'"))
|
||||
|
||||
|
||||
MIGRATIONS = [
|
||||
@@ -541,6 +580,7 @@ MIGRATIONS = [
|
||||
(19, _migration_19),
|
||||
(20, _migration_20),
|
||||
(21, _migration_21),
|
||||
(22, _migration_22),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -580,6 +580,9 @@ class TextWidgetConfig(Base):
|
||||
# per-run (see app/text_content.py) -- keeps the wrap/shrink-to-fit
|
||||
# layout in app/widgets/text.py to one size per render pass.
|
||||
font_size: Mapped[int] = mapped_column(Integer, default=28)
|
||||
# A key into app/widgets/text.py's FONT_FAMILIES, also whole-widget
|
||||
# not per-run (see font_size above for why).
|
||||
font_family: Mapped[str] = mapped_column(String, default="sans")
|
||||
align: Mapped[str] = mapped_column(String, default="left") # "left" | "center" | "right"
|
||||
background_color: Mapped[str] = mapped_column(String, default="#ffffff")
|
||||
|
||||
|
||||
@@ -280,6 +280,7 @@ def api_widget_config_save(
|
||||
# text
|
||||
text_html: str | None = Form(None),
|
||||
text_font_size: int | None = Form(None),
|
||||
text_font_family: str | None = Form(None),
|
||||
text_align: str | None = Form(None),
|
||||
text_background_color: str | None = Form(None),
|
||||
):
|
||||
@@ -367,6 +368,11 @@ def api_widget_config_save(
|
||||
xcfg.content = parse_rich_text(text_html)
|
||||
if text_font_size is not None:
|
||||
xcfg.font_size = max(MIN_TEXT_FONT_SIZE, min(MAX_TEXT_FONT_SIZE, text_font_size))
|
||||
if text_font_family is not None:
|
||||
xcfg.font_family = (
|
||||
text_font_family if text_font_family in text_widget.FONT_FAMILIES
|
||||
else text_widget.DEFAULT_FONT_FAMILY
|
||||
)
|
||||
if text_align is not None:
|
||||
xcfg.align = text_align if text_align in ("left", "center", "right") else "left"
|
||||
if text_background_color is not None:
|
||||
|
||||
@@ -42,6 +42,7 @@ from ..models import (
|
||||
Widget,
|
||||
)
|
||||
from ..quiet_hours import ALL_TIMEZONES
|
||||
from ..widgets import text as text_widget
|
||||
from .common import shell_context, widget_of_type
|
||||
|
||||
router = APIRouter()
|
||||
@@ -250,6 +251,7 @@ def widget_dialog(frame_id: int, widget_id: int, request: Request, db: Session =
|
||||
text_cfg = db.get(TextWidgetConfig, widget.id)
|
||||
return templates.TemplateResponse("_widget_dialog_text.html", {
|
||||
"request": request, "frame": frame, "widget": widget, "text_cfg": text_cfg,
|
||||
"text_font_families": text_widget.FONT_FAMILIES,
|
||||
})
|
||||
|
||||
if widget.widget_type == "whiteboard":
|
||||
|
||||
@@ -109,6 +109,7 @@ function initTextDialog() {
|
||||
e.preventDefault();
|
||||
const body = new URLSearchParams({
|
||||
text_html: editor.innerHTML,
|
||||
text_font_family: document.getElementById('text_font_family').value,
|
||||
text_font_size: document.getElementById('text_font_size').value,
|
||||
text_align: document.getElementById('text_align').value,
|
||||
text_background_color: document.getElementById('text_background_color').value,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
<p class="sub">A short block of styled text -- select some and use the
|
||||
toolbar, or just type. Saved as plain text plus style flags, not raw
|
||||
HTML.</p>
|
||||
<div class="richtext-editor" id="text-editor" contenteditable="true"
|
||||
data-content='{{ (text_cfg.content if text_cfg else none) | tojson }}'></div>
|
||||
<div class="richtext-toolbar" id="text-toolbar">
|
||||
<button type="button" class="richtext-btn" id="text-bold" title="Bold" data-cmd="bold"><b>B</b></button>
|
||||
<button type="button" class="richtext-btn" id="text-italic" title="Italic" data-cmd="italic"><i>I</i></button>
|
||||
@@ -14,13 +16,18 @@
|
||||
<label class="richtext-color-label" title="Highlight color">▣<input type="color" id="text-highlight" value="#ffff00"></label>
|
||||
<button type="button" class="richtext-btn" id="text-highlight-clear" title="Remove highlight">×</button>
|
||||
</div>
|
||||
<div class="richtext-editor" id="text-editor" contenteditable="true"
|
||||
data-content='{{ (text_cfg.content if text_cfg else none) | tojson }}'></div>
|
||||
</section>
|
||||
|
||||
<section class="card" style="margin-top: 20px;">
|
||||
<h2 class="card-title">Settings</h2>
|
||||
<form id="text-config-form">
|
||||
<label>Font family
|
||||
<select id="text_font_family">
|
||||
{% for value, label in text_font_families.items() %}
|
||||
<option value="{{ value }}" {% if text_cfg and text_cfg.font_family == value %}selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>Font size
|
||||
<input type="range" id="text_font_size" min="10" max="96" step="2"
|
||||
value="{{ text_cfg.font_size if text_cfg else 28 }}">
|
||||
|
||||
+75
-24
@@ -6,10 +6,13 @@ text instead of an uploaded image. See app/text_content.py for how the
|
||||
dialog's contenteditable HTML becomes models.TextWidgetConfig.content
|
||||
(the sanitization boundary; this module never sees raw HTML).
|
||||
|
||||
Bold/italic use real vendored font weights (app/fonts/NotoSans-*.ttf,
|
||||
OFL-licensed like the emoji fonts already there) rather than every other
|
||||
widget's single ImageFont.load_default() -- the one widget type where
|
||||
that distinction is the whole point.
|
||||
Bold/italic use real vendored font weights (app/fonts/*.ttf, OFL-
|
||||
licensed like the emoji fonts already there) across a small curated set
|
||||
of families (FONT_FAMILIES) rather than every other widget's single
|
||||
ImageFont.load_default() -- the one widget type where that distinction
|
||||
is the whole point. Font family is a whole-widget setting like
|
||||
font_size/align, not per-run -- only bold/italic/underline/color/bg
|
||||
vary run-to-run (see app/text_content.py).
|
||||
|
||||
No button actions -- there's nothing to advance/back/check for a fixed
|
||||
block of authored text."""
|
||||
@@ -38,18 +41,63 @@ DEFAULT_FG = (0, 0, 0)
|
||||
DEFAULT_BG = (255, 255, 255)
|
||||
|
||||
_FONT_DIR = Path(__file__).resolve().parent.parent / "fonts"
|
||||
|
||||
# A small curated set, not an open-ended picker -- each entry needs a
|
||||
# real vendored Regular/Bold/Italic/BoldItalic file, so families that
|
||||
# only ship as a variable font (Playfair Display, Lora, Merriweather,
|
||||
# stock "Inter"/"Source Sans 3" from Google Fonts) were skipped in favor
|
||||
# of static builds from their own upstream repos where one exists (see
|
||||
# app/fonts/OFL-*.txt for each non-Noto family's own license/copyright --
|
||||
# they're all OFL, same as the Noto fonts already vendored here, but
|
||||
# each has a different copyright holder so gets its own license file
|
||||
# rather than sharing app/fonts/OFL.txt).
|
||||
DEFAULT_FONT_FAMILY = "sans"
|
||||
FONT_FAMILIES: dict[str, str] = {
|
||||
"sans": "Sans-serif (Noto Sans)",
|
||||
"inter": "Inter",
|
||||
"source_sans": "Source Sans",
|
||||
"serif": "Serif (Noto Serif)",
|
||||
"elegant": "Elegant serif (Crimson Text)",
|
||||
"slab": "Slab serif (Arvo)",
|
||||
"mono": "Monospace (IBM Plex Mono)",
|
||||
}
|
||||
_FONT_FILES = {
|
||||
(False, False): "NotoSans-Regular.ttf",
|
||||
(True, False): "NotoSans-Bold.ttf",
|
||||
(False, True): "NotoSans-Italic.ttf",
|
||||
(True, True): "NotoSans-BoldItalic.ttf",
|
||||
"sans": {
|
||||
(False, False): "NotoSans-Regular.ttf", (True, False): "NotoSans-Bold.ttf",
|
||||
(False, True): "NotoSans-Italic.ttf", (True, True): "NotoSans-BoldItalic.ttf",
|
||||
},
|
||||
"inter": {
|
||||
(False, False): "Inter-Regular.ttf", (True, False): "Inter-Bold.ttf",
|
||||
(False, True): "Inter-Italic.ttf", (True, True): "Inter-BoldItalic.ttf",
|
||||
},
|
||||
"source_sans": {
|
||||
(False, False): "SourceSans3-Regular.ttf", (True, False): "SourceSans3-Bold.ttf",
|
||||
(False, True): "SourceSans3-Italic.ttf", (True, True): "SourceSans3-BoldItalic.ttf",
|
||||
},
|
||||
"serif": {
|
||||
(False, False): "NotoSerif-Regular.ttf", (True, False): "NotoSerif-Bold.ttf",
|
||||
(False, True): "NotoSerif-Italic.ttf", (True, True): "NotoSerif-BoldItalic.ttf",
|
||||
},
|
||||
"elegant": {
|
||||
(False, False): "CrimsonText-Regular.ttf", (True, False): "CrimsonText-Bold.ttf",
|
||||
(False, True): "CrimsonText-Italic.ttf", (True, True): "CrimsonText-BoldItalic.ttf",
|
||||
},
|
||||
"slab": {
|
||||
(False, False): "Arvo-Regular.ttf", (True, False): "Arvo-Bold.ttf",
|
||||
(False, True): "Arvo-Italic.ttf", (True, True): "Arvo-BoldItalic.ttf",
|
||||
},
|
||||
"mono": {
|
||||
(False, False): "IBMPlexMono-Regular.ttf", (True, False): "IBMPlexMono-Bold.ttf",
|
||||
(False, True): "IBMPlexMono-Italic.ttf", (True, True): "IBMPlexMono-BoldItalic.ttf",
|
||||
},
|
||||
}
|
||||
_WORD_OR_SPACE = re.compile(r"\S+|\s+")
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def _font(bold: bool, italic: bool, size: int) -> ImageFont.FreeTypeFont:
|
||||
return ImageFont.truetype(str(_FONT_DIR / _FONT_FILES[(bold, italic)]), size)
|
||||
@lru_cache(maxsize=256)
|
||||
def _font(family: str, bold: bool, italic: bool, size: int) -> ImageFont.FreeTypeFont:
|
||||
files = _FONT_FILES.get(family) or _FONT_FILES[DEFAULT_FONT_FAMILY]
|
||||
return ImageFont.truetype(str(_FONT_DIR / files[(bold, italic)]), size)
|
||||
|
||||
|
||||
def _paragraph_word_groups(paragraph: list[dict]) -> list[list[dict]]:
|
||||
@@ -75,11 +123,12 @@ def _paragraph_word_groups(paragraph: list[dict]) -> list[list[dict]]:
|
||||
return groups
|
||||
|
||||
|
||||
def _group_width(draw: ImageDraw.ImageDraw, group: list[dict], size: int) -> float:
|
||||
return sum(draw.textlength(tok["text"], font=_font(tok["bold"], tok["italic"], size)) for tok in group)
|
||||
def _group_width(draw: ImageDraw.ImageDraw, group: list[dict], family: str, size: int) -> float:
|
||||
return sum(draw.textlength(tok["text"], font=_font(family, tok["bold"], tok["italic"], size))
|
||||
for tok in group)
|
||||
|
||||
|
||||
def _wrap_paragraph(draw: ImageDraw.ImageDraw, groups: list[list[dict]], size: int,
|
||||
def _wrap_paragraph(draw: ImageDraw.ImageDraw, groups: list[list[dict]], family: str, size: int,
|
||||
max_width: int, space_width: float) -> list[list[list[dict]]]:
|
||||
"""Greedy word wrap -> list of lines, each a list of word groups.
|
||||
An empty `groups` (a blank authored line) still produces one empty
|
||||
@@ -88,7 +137,7 @@ def _wrap_paragraph(draw: ImageDraw.ImageDraw, groups: list[list[dict]], size: i
|
||||
current: list[list[dict]] = []
|
||||
current_w = 0.0
|
||||
for group in groups:
|
||||
gw = _group_width(draw, group, size)
|
||||
gw = _group_width(draw, group, family, size)
|
||||
add_w = gw + (space_width if current else 0)
|
||||
if current and current_w + add_w > max_width:
|
||||
lines.append(current)
|
||||
@@ -102,7 +151,7 @@ def _wrap_paragraph(draw: ImageDraw.ImageDraw, groups: list[list[dict]], size: i
|
||||
return lines
|
||||
|
||||
|
||||
def _fit(draw: ImageDraw.ImageDraw, paragraphs: list[list[dict]], start_size: int,
|
||||
def _fit(draw: ImageDraw.ImageDraw, paragraphs: list[list[dict]], family: str, start_size: int,
|
||||
max_width: int, max_height: int) -> tuple[int, list[list[list[dict]]]]:
|
||||
"""Shrinks font size (down to MIN_FONT_SIZE) until the wrapped
|
||||
content's total height fits max_height, or gives up at the floor --
|
||||
@@ -112,10 +161,11 @@ def _fit(draw: ImageDraw.ImageDraw, paragraphs: list[list[dict]], start_size: in
|
||||
size = max(MIN_FONT_SIZE, start_size)
|
||||
lines: list[list[list[dict]]] = []
|
||||
while True:
|
||||
space_width = draw.textlength(" ", font=_font(False, False, size))
|
||||
space_width = draw.textlength(" ", font=_font(family, False, False, size))
|
||||
lines = []
|
||||
for paragraph in paragraphs:
|
||||
lines.extend(_wrap_paragraph(draw, _paragraph_word_groups(paragraph), size, max_width, space_width))
|
||||
lines.extend(_wrap_paragraph(draw, _paragraph_word_groups(paragraph), family, size,
|
||||
max_width, space_width))
|
||||
line_h = round(size * LINE_HEIGHT_FACTOR)
|
||||
total_h = len(lines) * line_h
|
||||
if total_h <= max_height or size <= MIN_FONT_SIZE:
|
||||
@@ -124,8 +174,8 @@ def _fit(draw: ImageDraw.ImageDraw, paragraphs: list[list[dict]], start_size: in
|
||||
|
||||
|
||||
def _draw_line(img: Image.Image, draw: ImageDraw.ImageDraw, line: list[list[dict]], y: int,
|
||||
size: int, line_h: int, max_width: int, align: str, space_width: float) -> None:
|
||||
line_width = sum(_group_width(draw, g, size) for g in line) + space_width * max(0, len(line) - 1)
|
||||
family: str, size: int, line_h: int, max_width: int, align: str, space_width: float) -> None:
|
||||
line_width = sum(_group_width(draw, g, family, size) for g in line) + space_width * max(0, len(line) - 1)
|
||||
if align == "center":
|
||||
x = MARGIN + max(0, (max_width - line_width) / 2)
|
||||
elif align == "right":
|
||||
@@ -135,7 +185,7 @@ def _draw_line(img: Image.Image, draw: ImageDraw.ImageDraw, line: list[list[dict
|
||||
underline_h = max(1, size // 16)
|
||||
for gi, group in enumerate(line):
|
||||
for tok in group:
|
||||
font = _font(tok["bold"], tok["italic"], size)
|
||||
font = _font(family, tok["bold"], tok["italic"], size)
|
||||
w = draw.textlength(tok["text"], font=font)
|
||||
if tok["bg"]:
|
||||
bg_rgb = hex_to_rgb(tok["bg"])
|
||||
@@ -156,11 +206,12 @@ def _render_text(cfg: TextWidgetConfig, target_w: int, target_h: int) -> Image.I
|
||||
img = Image.new("RGB", (target_w, target_h), bg)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
family = cfg.font_family if cfg.font_family in FONT_FAMILIES else DEFAULT_FONT_FAMILY
|
||||
max_width = max(10, target_w - 2 * MARGIN)
|
||||
max_height = max(10, target_h - 2 * MARGIN)
|
||||
size, lines = _fit(draw, cfg.content or [], cfg.font_size, max_width, max_height)
|
||||
size, lines = _fit(draw, cfg.content or [], family, cfg.font_size, max_width, max_height)
|
||||
line_h = round(size * LINE_HEIGHT_FACTOR)
|
||||
space_width = draw.textlength(" ", font=_font(False, False, size))
|
||||
space_width = draw.textlength(" ", font=_font(family, False, False, size))
|
||||
|
||||
total_h = len(lines) * line_h
|
||||
y = MARGIN + max(0, (max_height - total_h) // 2)
|
||||
@@ -168,7 +219,7 @@ def _render_text(cfg: TextWidgetConfig, target_w: int, target_h: int) -> Image.I
|
||||
for line in lines:
|
||||
if y + line_h > target_h:
|
||||
break # ran out of room even at the smallest size -- clip remaining lines rather than overflow
|
||||
_draw_line(img, draw, line, y, size, line_h, max_width, align, space_width)
|
||||
_draw_line(img, draw, line, y, family, size, line_h, max_width, align, space_width)
|
||||
y += line_h
|
||||
return img
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ def test_expected_columns_exist_on_current_schema():
|
||||
assert "name" in task_widget_columns # migration 19
|
||||
assert "static_widget_configs" in inspector.get_table_names() # migration 20
|
||||
assert "text_widget_configs" in inspector.get_table_names() # migration 21
|
||||
text_widget_columns = {c["name"] for c in inspector.get_columns("text_widget_configs")}
|
||||
assert "font_family" in text_widget_columns # migration 22
|
||||
|
||||
|
||||
# --- widget system backfill (migration 16 + _ensure_widgets_backfilled) ---
|
||||
@@ -185,8 +187,21 @@ def test_migration_16_raw_sql_path_applies_to_an_existing_pre_widget_database(db
|
||||
_ensure_frame_calendars_rekeyed has a real frame_id-shaped table to
|
||||
migrate."""
|
||||
with db_module.engine.begin() as conn:
|
||||
# static_widget_configs/text_widget_configs are migration 20/21
|
||||
# tables (also post-16, like the rest of this list) -- dropped
|
||||
# here too so a real version-15 database is what's actually
|
||||
# being simulated, not "version 15 plus two tables that
|
||||
# wouldn't exist yet". Harmless to omit as long as no migration
|
||||
# after the one that creates a table also ALTERs it (that's
|
||||
# what let static_widget_configs go unlisted safely so far --
|
||||
# Base.metadata.create_all is idempotent against an
|
||||
# already-present table with no later ALTER to collide with),
|
||||
# but text_widget_configs' migration 22 ALTER makes the gap a
|
||||
# real "table already exists"/"duplicate column" collision
|
||||
# instead of a silent no-op.
|
||||
for table in ("frame_button_actions", "whiteboard_widget_configs", "task_widget_configs", "frame_task_lists",
|
||||
"calendar_widget_configs", "photo_widget_configs", "widgets"):
|
||||
"calendar_widget_configs", "photo_widget_configs", "static_widget_configs",
|
||||
"text_widget_configs", "widgets"):
|
||||
conn.execute(text(f"DROP TABLE {table}"))
|
||||
conn.execute(text("DROP TABLE frame_calendars"))
|
||||
conn.execute(text(
|
||||
@@ -253,9 +268,18 @@ def test_migration_17_and_18_extract_tasks_into_a_standalone_multi_list_widget(d
|
||||
tasks_* columns and TaskWidgetConfig no longer having user_id/
|
||||
calendar_key columns either."""
|
||||
with db_module.engine.begin() as conn:
|
||||
# static_widget_configs/text_widget_configs dropped too -- see
|
||||
# the comment on the identical setup in
|
||||
# test_migration_16_raw_sql_path_applies_to_an_existing_pre_widget_database above (migrations
|
||||
# 20/21's raw CREATE TABLE collides with an already-present table
|
||||
# otherwise, since this test replays 17 through 22 and neither
|
||||
# table would really exist yet at a genuine pre-migration-17
|
||||
# schema_version).
|
||||
conn.execute(text("DROP TABLE task_widget_configs"))
|
||||
conn.execute(text("DROP TABLE frame_task_lists"))
|
||||
conn.execute(text("DROP TABLE calendar_widget_configs"))
|
||||
conn.execute(text("DROP TABLE static_widget_configs"))
|
||||
conn.execute(text("DROP TABLE text_widget_configs"))
|
||||
conn.execute(text(
|
||||
"CREATE TABLE calendar_widget_configs ("
|
||||
"widget_id INTEGER PRIMARY KEY REFERENCES widgets(id) ON DELETE CASCADE, "
|
||||
@@ -350,8 +374,12 @@ def test_frame_calendars_rekey_attaches_existing_rows_to_their_calendar_widget(d
|
||||
the widget backfill, not as a numbered migration racing ahead of
|
||||
it (see _ensure_frame_calendars_rekeyed's own docstring)."""
|
||||
with db_module.engine.begin() as conn:
|
||||
# static_widget_configs/text_widget_configs dropped too -- see
|
||||
# the comment on the identical setup in
|
||||
# test_migration_16_raw_sql_path_applies_to_an_existing_pre_widget_database above.
|
||||
for table in ("frame_button_actions", "whiteboard_widget_configs", "task_widget_configs", "frame_task_lists",
|
||||
"calendar_widget_configs", "photo_widget_configs", "widgets"):
|
||||
"calendar_widget_configs", "photo_widget_configs", "static_widget_configs",
|
||||
"text_widget_configs", "widgets"):
|
||||
conn.execute(text(f"DROP TABLE {table}"))
|
||||
conn.execute(text("DROP TABLE frame_calendars"))
|
||||
conn.execute(text(
|
||||
|
||||
@@ -206,6 +206,7 @@ def test_config_save_updates_a_text_widget(client, db_session):
|
||||
data={
|
||||
"text_html": '<div>Hello <b>world</b></div>',
|
||||
"text_font_size": "40",
|
||||
"text_font_family": "serif",
|
||||
"text_align": "center",
|
||||
"text_background_color": "#ffdb00",
|
||||
},
|
||||
@@ -219,23 +220,26 @@ def test_config_save_updates_a_text_widget(client, db_session):
|
||||
{"text": "world", "bold": True, "italic": False, "underline": False, "color": None, "bg": None},
|
||||
]]
|
||||
assert cfg.font_size == 40
|
||||
assert cfg.font_family == "serif"
|
||||
assert cfg.align == "center"
|
||||
assert cfg.background_color == "#ffdb00"
|
||||
|
||||
|
||||
def test_config_save_clamps_text_font_size_and_rejects_bad_align_and_color(client, db_session):
|
||||
def test_config_save_clamps_text_font_size_and_rejects_bad_family_align_and_color(client, db_session):
|
||||
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
||||
widget = _add_text_widget(db_session)
|
||||
|
||||
resp = client.post(
|
||||
f"/api/frames/1/widgets/{widget.id}/config",
|
||||
data={"text_font_size": "500", "text_align": "diagonal", "text_background_color": "not-a-color"},
|
||||
data={"text_font_size": "500", "text_font_family": "comic-sans", "text_align": "diagonal",
|
||||
"text_background_color": "not-a-color"},
|
||||
headers=csrf_headers(client),
|
||||
)
|
||||
assert resp.status_code == 200, resp.text
|
||||
|
||||
cfg = db_session.get(TextWidgetConfig, widget.id)
|
||||
assert cfg.font_size == 96 # clamped to MAX_TEXT_FONT_SIZE
|
||||
assert cfg.font_family == "sans" # fell back to DEFAULT_FONT_FAMILY
|
||||
assert cfg.align == "left" # fell back to the default
|
||||
assert cfg.background_color == "#ffffff" # fell back to the default
|
||||
|
||||
|
||||
@@ -100,6 +100,23 @@ def test_render_respects_alignment(db_session):
|
||||
assert img.size == (200, 100)
|
||||
|
||||
|
||||
def test_render_supports_every_font_family(db_session):
|
||||
for family in widgets.text.FONT_FAMILIES:
|
||||
frame, widget = _make_widget(db_session, content=[[_run("The quick brown fox")]], font_family=family)
|
||||
img = widgets.text.render(db_session, frame, widget, 250, 100)
|
||||
assert img.size == (250, 100)
|
||||
|
||||
|
||||
def test_render_falls_back_to_default_family_for_an_unrecognized_value(db_session):
|
||||
"""A stale/tampered font_family value (e.g. a family removed in a
|
||||
later release) never crashes render() -- falls back to the default
|
||||
the same way an unrecognized align/display_mode value does
|
||||
elsewhere in this codebase."""
|
||||
frame, widget = _make_widget(db_session, content=[[_run("hi")]], font_family="does-not-exist")
|
||||
img = widgets.text.render(db_session, frame, widget, 200, 100)
|
||||
assert img.size == (200, 100)
|
||||
|
||||
|
||||
def test_no_button_actions():
|
||||
"""Fixed authored text -- nothing to advance/back/check."""
|
||||
assert widgets.text.ACTIONS == {}
|
||||
|
||||
Reference in New Issue
Block a user