diff --git a/src/assets/fonts/Caladea-Bold.ttf b/src/assets/fonts/Caladea-Bold.ttf new file mode 100644 index 0000000..a4a9703 Binary files /dev/null and b/src/assets/fonts/Caladea-Bold.ttf differ diff --git a/src/assets/fonts/Caladea-BoldItalic.ttf b/src/assets/fonts/Caladea-BoldItalic.ttf new file mode 100644 index 0000000..a9bb487 Binary files /dev/null and b/src/assets/fonts/Caladea-BoldItalic.ttf differ diff --git a/src/assets/fonts/Caladea-Italic.ttf b/src/assets/fonts/Caladea-Italic.ttf new file mode 100644 index 0000000..2c910c6 Binary files /dev/null and b/src/assets/fonts/Caladea-Italic.ttf differ diff --git a/src/assets/fonts/Caladea-Regular.ttf b/src/assets/fonts/Caladea-Regular.ttf new file mode 100644 index 0000000..a490e8f Binary files /dev/null and b/src/assets/fonts/Caladea-Regular.ttf differ diff --git a/src/assets/fonts/Carlito-Bold.ttf b/src/assets/fonts/Carlito-Bold.ttf new file mode 100644 index 0000000..67543b5 Binary files /dev/null and b/src/assets/fonts/Carlito-Bold.ttf differ diff --git a/src/assets/fonts/Carlito-BoldItalic.ttf b/src/assets/fonts/Carlito-BoldItalic.ttf new file mode 100644 index 0000000..e2c5d88 Binary files /dev/null and b/src/assets/fonts/Carlito-BoldItalic.ttf differ diff --git a/src/assets/fonts/Carlito-Italic.ttf b/src/assets/fonts/Carlito-Italic.ttf new file mode 100644 index 0000000..8dc3c84 Binary files /dev/null and b/src/assets/fonts/Carlito-Italic.ttf differ diff --git a/src/assets/fonts/Carlito-Regular.ttf b/src/assets/fonts/Carlito-Regular.ttf new file mode 100644 index 0000000..427b959 Binary files /dev/null and b/src/assets/fonts/Carlito-Regular.ttf differ diff --git a/src/assets/fonts/LICENSE-Caladea.txt b/src/assets/fonts/LICENSE-Caladea.txt new file mode 100644 index 0000000..b9d685b --- /dev/null +++ b/src/assets/fonts/LICENSE-Caladea.txt @@ -0,0 +1,93 @@ +Copyright 2012 The Caladea Project Authors (https://github.com/huertatipografica/Caladea) + +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/src/assets/fonts/LICENSE-Carlito.txt b/src/assets/fonts/LICENSE-Carlito.txt new file mode 100644 index 0000000..8d6b170 --- /dev/null +++ b/src/assets/fonts/LICENSE-Carlito.txt @@ -0,0 +1,94 @@ +Copyright 2013 The Carlito Project Authors (https://github.com/googlefonts/carlito), with Reserved Font Name "Carlito" + + +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. diff --git a/src/assets/fonts/LiberationMono-Bold.ttf b/src/assets/fonts/LiberationMono-Bold.ttf new file mode 100644 index 0000000..2e46737 Binary files /dev/null and b/src/assets/fonts/LiberationMono-Bold.ttf differ diff --git a/src/assets/fonts/LiberationMono-BoldItalic.ttf b/src/assets/fonts/LiberationMono-BoldItalic.ttf new file mode 100644 index 0000000..d1f46d7 Binary files /dev/null and b/src/assets/fonts/LiberationMono-BoldItalic.ttf differ diff --git a/src/assets/fonts/LiberationMono-Italic.ttf b/src/assets/fonts/LiberationMono-Italic.ttf new file mode 100644 index 0000000..954c394 Binary files /dev/null and b/src/assets/fonts/LiberationMono-Italic.ttf differ diff --git a/src/assets/fonts/LiberationMono-Regular.ttf b/src/assets/fonts/LiberationMono-Regular.ttf new file mode 100644 index 0000000..e774859 Binary files /dev/null and b/src/assets/fonts/LiberationMono-Regular.ttf differ diff --git a/src/assets/fonts/LiberationSans-Bold.ttf b/src/assets/fonts/LiberationSans-Bold.ttf new file mode 100644 index 0000000..dc5d57f Binary files /dev/null and b/src/assets/fonts/LiberationSans-Bold.ttf differ diff --git a/src/assets/fonts/LiberationSans-BoldItalic.ttf b/src/assets/fonts/LiberationSans-BoldItalic.ttf new file mode 100644 index 0000000..158488a Binary files /dev/null and b/src/assets/fonts/LiberationSans-BoldItalic.ttf differ diff --git a/src/assets/fonts/LiberationSans-Italic.ttf b/src/assets/fonts/LiberationSans-Italic.ttf new file mode 100644 index 0000000..25970d9 Binary files /dev/null and b/src/assets/fonts/LiberationSans-Italic.ttf differ diff --git a/src/assets/fonts/LiberationSans-Regular.ttf b/src/assets/fonts/LiberationSans-Regular.ttf new file mode 100644 index 0000000..e633985 Binary files /dev/null and b/src/assets/fonts/LiberationSans-Regular.ttf differ diff --git a/src/lib/components/ToolbarExpanded.svelte b/src/lib/components/ToolbarExpanded.svelte index bc11750..dc27280 100644 --- a/src/lib/components/ToolbarExpanded.svelte +++ b/src/lib/components/ToolbarExpanded.svelte @@ -52,9 +52,18 @@ try { localStorage.setItem(RECENT_FONTS_KEY, JSON.stringify(fonts)); } catch { /* quota or disabled */ } } - function ensureDetectionRan() { + // The bundled metric-twin @font-faces (Calibri/Arial/Cambria/Courier New) only + // load on first use; force them so canvas measurement can see them as available. + const BUNDLED_TWINS = ['Calibri', 'Arial', 'Cambria', 'Courier New']; + + async function ensureDetectionRan() { if (detectionRan) return; detectionRan = true; + if (typeof document !== 'undefined' && document.fonts) { + try { + await Promise.all(BUNDLED_TWINS.map((f) => document.fonts.load(`12px "${f}"`))); + } catch { /* detect with whatever loaded */ } + } detectedFonts = detectAvailableFonts(CANDIDATE_FONTS); } diff --git a/src/styles/global.css b/src/styles/global.css index a009357..c9a2aa9 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -40,13 +40,169 @@ src: url('../assets/fonts/LiberationSerif-BoldItalic.ttf') format('truetype'); } +/* Metric-compatible substitutes for the common MS-Office fonts that imported + .odt files reference. Each face is keyed to the MS name but prefers a real + local copy, then a system twin, then the bundled open-source twin — so text + renders with matching metrics (like LibreOffice) instead of dropping to the + browser's default serif. (OFL — see src/assets/fonts/LICENSE-*.) */ + +/* Calibri → Carlito */ +@font-face { + font-family: 'Calibri'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: local('Calibri'), local('Carlito'), url('../assets/fonts/Carlito-Regular.ttf') format('truetype'); +} +@font-face { + font-family: 'Calibri'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: local('Calibri Bold'), local('Carlito Bold'), url('../assets/fonts/Carlito-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Calibri'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: local('Calibri Italic'), local('Carlito Italic'), url('../assets/fonts/Carlito-Italic.ttf') format('truetype'); +} +@font-face { + font-family: 'Calibri'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: local('Calibri Bold Italic'), local('Carlito Bold Italic'), url('../assets/fonts/Carlito-BoldItalic.ttf') format('truetype'); +} + +/* Arial → Liberation Sans */ +@font-face { + font-family: 'Arial'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: local('Arial'), local('Liberation Sans'), url('../assets/fonts/LiberationSans-Regular.ttf') format('truetype'); +} +@font-face { + font-family: 'Arial'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: local('Arial Bold'), local('Liberation Sans Bold'), url('../assets/fonts/LiberationSans-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Arial'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: local('Arial Italic'), local('Liberation Sans Italic'), url('../assets/fonts/LiberationSans-Italic.ttf') format('truetype'); +} +@font-face { + font-family: 'Arial'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: local('Arial Bold Italic'), local('Liberation Sans Bold Italic'), url('../assets/fonts/LiberationSans-BoldItalic.ttf') format('truetype'); +} + +/* Cambria → Caladea */ +@font-face { + font-family: 'Cambria'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: local('Cambria'), local('Caladea'), url('../assets/fonts/Caladea-Regular.ttf') format('truetype'); +} +@font-face { + font-family: 'Cambria'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: local('Cambria Bold'), local('Caladea Bold'), url('../assets/fonts/Caladea-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Cambria'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: local('Cambria Italic'), local('Caladea Italic'), url('../assets/fonts/Caladea-Italic.ttf') format('truetype'); +} +@font-face { + font-family: 'Cambria'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: local('Cambria Bold Italic'), local('Caladea Bold Italic'), url('../assets/fonts/Caladea-BoldItalic.ttf') format('truetype'); +} + +/* Courier New → Liberation Mono */ +@font-face { + font-family: 'Courier New'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: local('Courier New'), local('Liberation Mono'), url('../assets/fonts/LiberationMono-Regular.ttf') format('truetype'); +} +@font-face { + font-family: 'Courier New'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: local('Courier New Bold'), local('Liberation Mono Bold'), url('../assets/fonts/LiberationMono-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Courier New'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: local('Courier New Italic'), local('Liberation Mono Italic'), url('../assets/fonts/LiberationMono-Italic.ttf') format('truetype'); +} +@font-face { + font-family: 'Courier New'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: local('Courier New Bold Italic'), local('Liberation Mono Bold Italic'), url('../assets/fonts/LiberationMono-BoldItalic.ttf') format('truetype'); +} + +/* Times New Roman → Liberation Serif (reuses the bundled Serif files) */ +@font-face { + font-family: 'Times New Roman'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: local('Times New Roman'), local('Liberation Serif'), url('../assets/fonts/LiberationSerif-Regular.ttf') format('truetype'); +} +@font-face { + font-family: 'Times New Roman'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: local('Times New Roman Bold'), local('Liberation Serif Bold'), url('../assets/fonts/LiberationSerif-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Times New Roman'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: local('Times New Roman Italic'), local('Liberation Serif Italic'), url('../assets/fonts/LiberationSerif-Italic.ttf') format('truetype'); +} +@font-face { + font-family: 'Times New Roman'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: local('Times New Roman Bold Italic'), local('Liberation Serif Bold Italic'), url('../assets/fonts/LiberationSerif-BoldItalic.ttf') format('truetype'); +} + :root { --radius: 6px; --shadow: 0 1px 3px rgba(0, 0, 0, 0.08); --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; --font-serif: 'Liberation Serif', 'Times New Roman', Georgia, serif; } - + [data-theme="light"] { --color-bg: #e6e9eb; --color-surface: #ffffff; @@ -60,7 +216,7 @@ --color-page-text: #1e293b; --color-page-border: #e2e8f0; } - + [data-theme="dark"] { --color-bg: #0d1117; --color-surface: #161b22;