Skip to content

Commit 5338413

Browse files
committed
feat: only provide fonts which are available (shipped by us)
Prevents issues where fonts are offered that the user has not installed. Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent ad1a6ed commit 5338413

File tree

9 files changed

+432
-541
lines changed

9 files changed

+432
-541
lines changed

LICENSES/OFL-1.1.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
SIL OPEN FONT LICENSE
2+
3+
Version 1.1 - 26 February 2007
4+
5+
PREAMBLE
6+
7+
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.
8+
9+
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.
10+
11+
DEFINITIONS
12+
13+
"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.
14+
15+
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
16+
17+
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
18+
19+
"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.
20+
21+
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
22+
23+
PERMISSION & CONDITIONS
24+
25+
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:
26+
27+
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
28+
29+
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.
30+
31+
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.
32+
33+
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.
34+
35+
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.
36+
37+
TERMINATION
38+
39+
This license becomes null and void if any of the above conditions are not met.
40+
41+
DISCLAIMER
42+
43+
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.

package-lock.json

Lines changed: 316 additions & 531 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"@nextcloud/eslint-config": "^8.4.2",
8282
"@nextcloud/sharing": "^0.2.4",
8383
"@nextcloud/stylelint-config": "^3.1.0",
84-
"@nextcloud/vite-config": "^1.5.6",
84+
"@nextcloud/vite-config": "^1.7.0",
8585
"@types/dockerode": "^3.3.43",
8686
"@vue/tsconfig": "^0.5.1",
8787
"cypress": "^13.17.0",
@@ -91,7 +91,8 @@
9191
"eslint-plugin-cypress": "^3.6.0",
9292
"ts-node": "^10.9.2",
9393
"tslib": "^2.8.1",
94-
"typescript": "^5.7.3",
95-
"vite": "^5.4.19"
94+
"typescript": "^5.9.2",
95+
"vite": "^7.1.4",
96+
"vite-plugin-static-copy": "^3.1.2"
9697
}
9798
}
17.9 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2014 The Comic Neue Project Authors (https://github.com/crozynski/comicneue)
2+
SPDX-License-Identifier: OFL-1.1

src/assets/pt-serif-regular.woff2

22.6 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2010 ParaType Ltd. (http://www.paratype.com/public)
2+
SPDX-License-Identifier: OFL-1.1

src/components/ImageEditor.vue

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55
<template>
6-
<div ref="editor" class="viewer__image-editor" v-bind="themeDataAttr" />
6+
<div>
7+
<div ref="editor" class="viewer__image-editor" v-bind="themeDataAttr" />
8+
</div>
79
</template>
810
<script>
9-
import { basename, dirname, extname, join } from 'path'
11+
import { showError, showSuccess, DialogBuilder } from '@nextcloud/dialogs'
1012
import { emit } from '@nextcloud/event-bus'
1113
import { Node } from '@nextcloud/files'
12-
import { showError, showSuccess, DialogBuilder } from '@nextcloud/dialogs'
14+
import { linkTo } from '@nextcloud/router'
1315
import axios from '@nextcloud/axios'
14-
15-
import logger from '../services/logger.js'
16+
import { basename, dirname, extname, join } from 'path'
1617
import translations from '../models/editorTranslations.js'
1718
import { rawStat } from '../services/FileInfo.ts'
19+
import logger from '../services/logger.js'
1820
1921
let TABS, TOOLS
2022
@@ -95,6 +97,16 @@ export default {
9597
fontFamily: 'var(--font-face)',
9698
},
9799
},
100+
101+
Text: {
102+
// this must be the value of one of the fonts
103+
fontFamily: '"NotoSans", "Noto Sans", "Arial", "Roboto"',
104+
fonts: [
105+
{ label: 'Sans-serif', value: '"NotoSans", "Noto Sans", "Arial", "Roboto"' },
106+
{ label: 'Serif', value: '"PTSerif", "Georgia", "Times New Roman"' },
107+
{ label: 'Comic', value: '"Comic Neue", "Comic Sans"' },
108+
],
109+
},
98110
}
99111
},
100112
@@ -122,6 +134,41 @@ export default {
122134
},
123135
},
124136
137+
created() {
138+
// we need to apply our fonts on the root, but we cannot do this from Vue as we can only access the component.
139+
// so we do this manually
140+
if (document.getElementById('oca-viewer_image-editor-fonts')) {
141+
return
142+
}
143+
144+
const styleElement = document.createElement('style')
145+
styleElement.id = 'oca-viewer_image-editor-fonts'
146+
styleElement.appendChild(document.createTextNode(`
147+
@font-face {
148+
font-display: swap;
149+
font-family: 'Comic Neue';
150+
font-style: normal;
151+
font-weight: 400;
152+
src: url('${linkTo('viewer', 'css/fonts/comic-neue-regular.woff2')}') format('woff2');
153+
}
154+
@font-face {
155+
font-display: swap;
156+
font-family: 'NotoSans';
157+
font-style: normal;
158+
font-weight: 400;
159+
src: url('${linkTo('core', 'fonts/NotoSans-Regular-latin.woff2')}') format('woff2');
160+
}
161+
@font-face {
162+
font-display: swap;
163+
font-family: 'PTSerif';
164+
font-style: normal;
165+
font-weight: 400;
166+
src: url('${linkTo('viewer', 'css/fonts/pt-serif-regular.woff2')}') format('woff2');
167+
}
168+
`))
169+
document.head.appendChild(styleElement)
170+
},
171+
125172
async mounted() {
126173
// Lazy load the image editor
127174
const FilerobotImageEditor = (await import(/* webpackChunkName: 'filerobot' */'filerobot-image-editor')).default
@@ -328,7 +375,6 @@ export default {
328375
width: 100%;
329376
height: 100vh;
330377
}
331-
332378
</style>
333379
334380
<style lang="scss">
@@ -644,5 +690,4 @@ export default {
644690
645691
filter: var(--background-invert-if-dark);
646692
}
647-
648693
</style>

vite.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { createAppConfig } from '@nextcloud/vite-config'
66
import { readFileSync } from 'node:fs'
77
import { join } from 'node:path'
8+
import { viteStaticCopy } from 'vite-plugin-static-copy'
89

910
const isProduction = process.env.NODE_ENV === 'production'
1011
const plyrIcons = readFileSync(
@@ -32,4 +33,16 @@ export default createAppConfig({
3233
emptyOutputDirectory: {
3334
additionalDirectories: ['css'],
3435
},
36+
config: {
37+
plugins: [
38+
viteStaticCopy({
39+
targets: [
40+
{
41+
src: 'src/assets/*.woff2*',
42+
dest: 'css/fonts',
43+
},
44+
],
45+
}),
46+
],
47+
},
3548
})

0 commit comments

Comments
 (0)