I defined custom font for my application because by default characters like 'č' did render with Arial font while rest of application rendered with "Open Sans Light". In styles.scss:
#include v-font('LocalFont', '../../../../mytheme/fonts/open-sans-v15-latin-ext_latin-300');
...
...
From rendered webpage I see font family used depends on styles.css:
.mytheme.v-app, .mytheme.v-app-loading {
font: 300 16px/1.55 "Open Sans", sans-serif;
but I see no way affecting it. In mytheme.scss within #mixin mytheme { I tried to define:
.v-app, .v-app-loading {
font: 300 16px/1.55 LocalFont, sans-serif;
}
.mytheme.v-app, .mytheme.v-app-loading {
font: 300 16px/1.55 LocalFont, sans-serif;
}
but in styles.css it is build as:
.mytheme .v-app, .mytheme .v-app-loading {
font: 300 16px/1.55 LocalFont, sans-serif;
}
.mytheme .mytheme.v-app, .mytheme .mytheme.v-app-loading {
font: 300 16px/1.55 LocalFont, sans-serif;
}
and that will not use my local fonts (unless I remove spaces after .mytheme).
Is there a way to affect font family in .mytheme.v-app, .mytheme.v-app-loading {?
As a workaround I defined this in my theme:
.v-ui{
font: 300 16px/1.55 LocalFont, sans-serif;
}
.v-tooltip{
font: 300 16px/1.55 LocalFont, sans-serif;
}
.v-window{
font: 300 16px/1.55 LocalFont, sans-serif;
}
.v-Notification{
font: 300 16px/1.55 LocalFont, sans-serif;
}
This covers probably all cases, but I am not sure if vaadin could add element that is direct child of element with v-app css class and uses other css class. Is this workaround applying to all cases - does vaadin use other css classes that are direct child of v-app class?
Notes:
Vaadin documentation only states to use font family in my styles.
I am using server fonts because application is behind proxy and using web fonts for rendering characters like 'č' fails because some clients have no access outside application server.
Initally I tried to define my fonts in styles.scss like:
#include v-font('Open Sans', '../../../../mytheme/fonts/open-sans-v15-latin-ext_latin-300');
...
#include v-font('Open Sans Light', '../../../../mytheme/fonts/open-sans-v15-latin-ext_latin-300');
...
But it did not used my fonts for rendering 'č', not sure why.
So.. if you've called your theme: my-theme
In the file: my-theme.scss
You need to add at the top the file: $v-font-family: "Open Sans", sans-serif;
Here's a link to the other Valo Theme variables
This Question is about the older version 7 of Vaadin. Here's an Answer for those with the same need in current Vaadin 14.
Vaadin Flow
The newer generation of Vaadin version 10 and later is known as Flow. This revamp of Vaadin now uses the Lumo theme by default. The theme is designed to be easy to alter, changing font, size, color, spacing, and so on.
The Vaadin team now offers an online editor to make changing the theme easy, with a palette of settings to tweak, and a visual display to see the effects. When you are satisfied, you can download the theme settings for use in your Vaadin project.
In particular, on the Typography tab with its Font family pop-up menu, you can choose a default font for the entire app. For finer control of your Web typography, you can open the Advanced section to edit the CSS font stack.
By the way, Lumo has both a light and a dark mode, the dark shown here.
I have specifics fonts that will be tied to user layouts. When a user logs in, they will see their selected fonts which will be loaded from the server.
I will be using Angular to style the specific elements. How can I use #font-face in ng-style? Is it possible?
font-family works if I type all the possible font-faces prior which is tedious and hard to maintain. the CSS is the section I want to load dynamically based on the user's fonts
**CSS**
#font-face {
font-family: CustomFontName;
src: url('CustomFont.ttf');
}
#font-face {
font-family: CustomFontName2;
src: url('CustomFont2.ttf');
}
**JS**
textbox.style = {
'font-family': CustomFontName
}
**HTML**
<p ng-style="textbox.style">{{ textbox.placeholder }}</p>
The website is here, you can test it out with validation code "ImprintPlus" and then change templates. the user will want their customized fonts in there.
I have this as style used in google app script webapp where we setup style sheet also as html page (with style tags included) and include them in main html page. It uses default font instead of snippet below.
#font-face
{
font-family: myFirstFont;
src: url('https://dl.dropbox.com/s/g2lk505elj1aamj/MISTV___.TTF')
}
div.happy {
font-family: 'myFirstFont';
}
Regards,
Miten.
Font-faces are not allowed with HTMLService and Caja Sanitization, ran into the same problem last week myself.
https://groups.google.com/forum/#!topic/google-caja-discuss/WhqEZqfFn6g
I am trying to load ttf font before the page load so that user can type with that font in the form but no luck, I did create a folder called 'font' in the root of site and did add the line below in css but no luck, pls help
<style>
##font-face {
font-family: myfont !important;
src: url('/fonts/myfont.ttf') format("truetype"); }
</style>
Note: I am not doing MVC, just asp.net web page, thanks
How can I embed a custom bitmap font into my website using CSS? I've tried the following but it just reverts to the fallback font:
#font-face {
font-family:'AgendaSemibold';
src: url('Agenda-Semibold.bmap') format('bitmap');
}
I'm trying to call it using the usual way:
font-family: 'AgendaSemibold', Times New Roman, Sans-Serif;
The font has been uploaded to my webspace but it's just reverting to Times.