generated from Seekra/repository-template
feat(fonts): load all fonts specified in font configuration
This commit is contained in:
+20
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { getAssetsUrl } from './config/env';
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia';
|
import { createPinia } from 'pinia';
|
||||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||||
@@ -25,10 +26,29 @@ import './styles/common.css'
|
|||||||
import './styles/variables/colors.css'
|
import './styles/variables/colors.css'
|
||||||
import './styles/variables/dimensions.css';
|
import './styles/variables/dimensions.css';
|
||||||
|
|
||||||
|
import rawFonts from './styles/fonts.json';
|
||||||
import './styles/common.css';
|
import './styles/common.css';
|
||||||
import './styles/variables/colors.css';
|
import './styles/variables/colors.css';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const fonts = rawFonts.map((font) => new FontFace(
|
||||||
|
font.family ?? '',
|
||||||
|
Array.isArray(font.source)
|
||||||
|
? font.source.map(
|
||||||
|
(source) => `url('${source.url
|
||||||
|
? new URL(source.url, getAssetsUrl()).href
|
||||||
|
: ''
|
||||||
|
}') format('${source.format ?? ''}')`
|
||||||
|
).join(',')
|
||||||
|
: '',
|
||||||
|
{
|
||||||
|
weight: font.weight ?? undefined,
|
||||||
|
style: font.style ?? undefined
|
||||||
|
}
|
||||||
|
));
|
||||||
|
await Promise.all(fonts.map((font) => font.load()));
|
||||||
|
fonts.forEach((font) => document.fonts.add(font));
|
||||||
|
|
||||||
await loadLanguage(fallbackLocale);
|
await loadLanguage(fallbackLocale);
|
||||||
await loadLanguage(getCurrentLanguage());
|
await loadLanguage(getCurrentLanguage());
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
Reference in New Issue
Block a user