Closed AmirHmZz closed 2 years ago
@AmirHmZz , excuse me for the late reply. You have to add a resource folder, and put the font file in it. Additionally you have to override the default style.css file, linking in it to the new font.
In the following example I have the following directories:
myfolder/
|_ myscript.py
|_ res/
|_ style.css
|_ allison-v1-latin-regular.woff2
This is the python script
import remi.gui as gui
from remi import start, App
import os
class MyApp(App):
def __init__(self, *args):
res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
# static_file_path can be an array of strings allowing to define
# multiple resource path in where the resources will be placed
super(MyApp, self).__init__(*args, static_file_path={'res':res_path})
def main(self):
# creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.VBox(width=300, height=200, style={'margin': '0px auto'})
main_container.append(gui.Label("Hello world!"))
# returning the root widget
return main_container
if __name__ == "__main__":
# starts the webserver
start(MyApp, address='0.0.0.0', port=0, start_browser=True, username=None, password=None)
This is the css
@charset "UTF-8";
/* latin */
@font-face {
font-family: 'Allison';
font-style: normal;
font-weight: 400;
/*src: local('Roboto'), local('Roboto-Regular'), url('/res:font.woff2') format('woff2');*/
src: local('Allison'), url('/res:allison-v1-latin-regular.woff2') format('woff2');
}
.remi-main textarea:focus,
.remi-main input[type='checkbox']:focus,
.remi-main input[type='color']:focus,
.remi-main input[type='number']:focus,
.remi-main input[type='text']:focus,
.remi-main input[type='date']:focus,
.remi-main select:focus {
border: 0px;
outline: 0px;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .14);
border-bottom: 1px solid rgba(2, 70, 147, 0.26);
}
::-moz-selection {
background: rgba(2, 70, 147, 0.26);
text-shadow: none
}
::selection {
background: rgba(2, 70, 147, 0.26);
text-shadow: none
}
.remi-main audio,
.remi-main canvas,
.remi-main iframe,
.remi-main img,
.remi-main svg,
.remi-main video {
vertical-align: middle
}
.remi-main textarea {
resize: vertical
}
.remi-main a,
.remi-main a:visited {
text-decoration: underline
}
html{
height: 100%;
}
.remi-main{
width: 100%;
margin: 0px;
padding: 0px;
height: 100%;
font-family: "Allison", "Helvetica", "Arial", sans-serif;
font-size: 14px;
font-weight: 400;
min-height: 100%;
}
*[hidden] {
display: none!important
}
.remi-main h1,
.remi-main h2,
.remi-main h3,
.remi-main h4,
.remi-main h5,
.remi-main h6,
.remi-main p {
padding: 0
}
.remi-main h1 small,
.remi-main h2 small,
.remi-main h3 small,
.remi-main h4 small,
.remi-main h5 small,
.remi-main h6 small {
font-family: "Allison", "Helvetica", "Arial", sans-serif;
font-weight: 400;
line-height: 1.35;
letter-spacing: -.02em;
opacity: .54;
font-size: .6em
}
.remi-main h1 {
font-size: 400%;
line-height: 1.35;
letter-spacing: -.02em;
margin: 24px 0
}
.remi-main h1,
.remi-main h2 {
font-family: "Allison", "Helvetica", "Arial", sans-serif;
font-weight: 400
}
.remi-main h2 {
font-size: 320%;
line-height: 48px
}
.remi-main h2,
.remi-main h3 {
margin: 24px 0
}
.remi-main h3 {
font-size: 240%;
line-height: 40px
}
.remi-main h3,
.remi-main h4 {
font-family: "Allison", "Helvetica", "Arial", sans-serif;
font-weight: 400
}
.remi-main h4 {
font-size: 170%;
line-height: 32px;
-moz-osx-font-smoothing: grayscale;
margin: 24px 0 16px
}
.remi-main h5 {
font-size: 140%;
font-weight: 500;
line-height: 1;
letter-spacing: .02em
}
.remi-main h5,
.remi-main h6 {
font-family: "Allison", "Helvetica", "Arial", sans-serif;
margin: 24px 0 16px
}
.remi-main h6 {
font-size: 114%;
letter-spacing: .04em
}
.remi-main h6,
.remi-main p {
font-weight: 400;
/*line-height: 24px*/
}
.remi-main p {
letter-spacing: 0;
margin: 0px
}
.remi-main a {
color: rgba(2, 70, 147, 0.8);
font-weight: 500
}
.remi-main blockquote {
font-family: "Allison", "Helvetica", "Arial", sans-serif;
position: relative;
font-size: 170%;
font-weight: 300;
font-style: italic;
line-height: 1.35;
letter-spacing: .08em
}
.remi-main blockquote:before {
position: absolute;
left: -.5em;
content: '�'
}
.remi-main blockquote:after {
content: '�';
margin-left: -.05em
}
.remi-main mark {
background-color: #f4ff81
}
.remi-main dt {
font-weight: 700
}
.remi-main address {
font-size: 86%;
line-height: 1;
font-style: normal
}
.remi-main address,
.remi-main ul,
.remi-main ol {
font-weight: 400;
letter-spacing: 0
}
.remi-main ul,
.remi-main ol {
line-height: 24px
}
.remi-main .RaisedFrame {
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
z-index: 1;
}
body.remi-main > div {
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
}
.remi-main div {
background-color: white;
z-index: 0;
}
.remi-main *[disabled='True']{
filter: grayscale(100%) opacity(0.6);
pointer-events: none;
}
.remi-main .ListView {
border: none;
padding: 0;
background-color: white;
cursor: default;
overflow: auto;
list-style: none;
}
.remi-main option:hover {
background: rgba(2, 70, 147, 0.26);
outline: 1px solid red;
}
.remi-main .ListItem:hover {
background: rgba(4, 90, 188, 0.26);
}
.remi-main .ListItem[selected='True'] {
background: rgba(4, 90, 188, 0.26);
}
.remi-main input[type='number'],
.remi-main input[type='text'],
.remi-main input[type='date'],
.remi-main input[type='color'],
.remi-main textarea,
.remi-main li,
.remi-main select {
border: none;
border-bottom: 1px solid rgba(0, 0, 0, .12);
display: block;
font-size: 95%;
margin: 0;
width: 100%;
background: 0 0;
text-align: left;
color: inherit;
padding: 0;
background-color: rgb(245, 245, 245);
}
.remi-main textarea:disabled,
.remi-main input[type='checkbox']:disabled,
.remi-main input[type='color']:disabled,
.remi-main input[type='number']:disabled,
.remi-main input[type='text']:disabled,
.remi-main input[type='date']:disabled {
color: rgba(0,0,0,0.3);
cursor: default;
border-bottom: 1px solid rgba(0,0,0,0.3);
}
.remi-main select {
border-bottom: 2px solid rgba(0, 0, 0, .12);
}
.remi-main input[type='checkbox'] {
height: 100%;
min-height: 20px;
min-width: 20px;
}
.remi-main button {
background: 0 0;
border: none;
border-radius: 0px;
color: #000;
position: relative;
margin: 0;
padding: 0 0px;
display: inline-block;
font-weight: 500;
letter-spacing: 0;
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
will-change: box-shadow;
outline: none;
cursor: pointer;
text-decoration: none;
text-align: center;
vertical-align: middle;
background: rgb(4, 90, 188);
color: rgb(255, 255, 255);
box-shadow: 3px 3px 5px rgb(150,150,150);
}
@keyframes remi-main-outline-animation {
0% {outline: 1px dashed lightgray;}
100% {outline: 1px dashed white;}
}
.remi-main button:focus {
box-shadow: 3px 3px 5px rgb(130,130,130);
outline: 1px dashed lightgray;
animation-name: remi-main-outline-animation;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-direction: alternate;
}
.remi-main button:disabled {
background-color: #ddd;
background: #ddd;
border: 1px solid #ddd;
box-shadow: none;
cursor: default;
color: #9F9F9F;
}
.remi-main button:active{
background: rgb(2, 70, 147);
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .2), 0 1px 1px 0 rgba(0, 0, 0, .12), 0 2px 0px -1px rgba(0, 0, 0, .2);
}
.remi-main .TextInput {
border: none;
border-bottom: 1px solid rgba(0, 0, 0, .12);
display: block;
font-family: "Allison", "Helvetica", "Arial", sans-serif;
margin: 0;
padding: 0;
width: 100%;
/*background: 0 0;*/
text-align: left;
color: inherit;
}
.remi-main table {
border-spacing: 0;
overflow: scroll;
border-collapse: collapse;
text-align: center;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .1);
}
.remi-main .TableItem {
padding: 0px;
border: 1px solid white;
outline: 0px;
}
.remi-main .TableEditableItem>.TextInput {
height: 100%;
}
.remi-main td {
border: 1px solid white;
outline: 0px;
background-color: rgb(245,245,245);
}
.remi-main th {
border: 1px solid white;
outline: 0px;
background: rgba(19, 108, 209, .6);
color: rgb(255, 255, 255);
font-weight: normal;
}
.remi-main p.DialogTitle {
background: rgba(19, 108, 209, .6);
border: 0px;
margin: 0px;
color: white;
font-weight: bold;
text-align: center;
margin: 0px;
}
.remi-main p.Title {
border: 0px;
color: inherit;
font-weight: bold;
}
.remi-main nav > ul.Menu {
background: rgb(19, 108, 209);
border: 0px;
color: white;
margin: 0px;
}
.remi-main ul.Menu {
list-style-type: none;
padding: 0;
position: relative;
}
.remi-main .MenuItem {
cursor: default;
text-align: center;
position: relative;
}
.remi-main .Menu .Menu {
position: absolute;
}
.remi-main .Menu .Menu .Menu {
top: 5%;
left: 95%;
position: absolute;
}
.remi-main .MenuItem .Menu {
display: none;
background-color: white;
/*border: 1px solid #9C9B9B;*/
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
color: black;
height: auto !important;
position: absolute;
top: 100%;
z-index: 1;
}
.remi-main .MenuBar>.Menu>.MenuItem {
border-bottom: 0;
background: rgb(19, 108, 209);
}
.remi-main .MenuBar {
border-bottom: 1px solid rgba(0, 0, 0, .26);
}
.remi-main .Menu > .MenuItem:hover {
background: rgb(2, 70, 147);
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
}
.remi-main .MenuItem .MenuItem:hover {
background: rgba(4, 90, 188, 0.4);
}
.remi-main .Menu::after {
content: "";
clear: both;
}
.remi-main .MenuItem:hover > .Menu {
display: block;
}
.remi-main input.file {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
outline: 0;
border: 0;
padding: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: rgb(2, 70, 147);
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
}
.remi-main input[type='range'] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: 0 0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
outline: 0;
padding: 0;
color: rgb(2, 70, 147);
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
z-index: 1;
cursor: pointer;
height: 100%;
}
.remi-main input[type='range']::-moz-focus-outer {
border: 0
}
.remi-main input[type='range']::-ms-tooltip {
display: none
}
.remi-main input[type='range']::-webkit-slider-runnable-track {
background: rgba(2, 70, 147, 0.26);
height: 2px;
}
.remi-main input[type='range']::-moz-range-track {
background: rgba(2, 70, 147, 0.26);
height: 2px;
border: none;
}
.remi-main input[type='range']::-ms-track {
background: rgba(2, 70, 147, 0.26);
height: 2px;
color: transparent;
width: 100%;
border: none;
}
.remi-main input[type='range']::-ms-fill-lower {
padding: 0;
background: linear-gradient(to right, transparent, transparent 16px, rgb(15, 113, 225), rgb(15, 113, 225))
}
.remi-main input[type='range']::-ms-fill-upper {
padding: 0;
background: linear-gradient(to left, transparent, transparent 16px, rgba(0, 0, 0, .26), rgba(0, 0, 0, .26)0)
}
.remi-main input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
top: -5px;
width: 12px;
height: 12px;
position: relative;
box-sizing: border-box;
border-radius: 100%;
background: rgb(2, 70, 147);
border: none;
transition: transform .18s cubic-bezier(.4, 0, .2, 1), border .18s cubic-bezier(.4, 0, .2, 1), box-shadow .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1);
transition: transform .18s cubic-bezier(.4, 0, .2, 1), border .18s cubic-bezier(.4, 0, .2, 1), box-shadow .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1), -webkit-transform .18s cubic-bezier(.4, 0, .2, 1)
}
.remi-main input[type='range']::-moz-range-thumb {
-moz-appearance: none;
width: 12px;
height: 12px;
box-sizing: border-box;
border-radius: 100%;
background-image: none;
background: rgb(2, 70, 147);
border: none
}
.remi-main input[type='range']:focus:not(:active)::-webkit-slider-thumb {
box-shadow: 0 0 0 10px rgba(4, 90, 188, 0.26);
}
.remi-main input[type='range']:focus:not(:active)::-moz-range-thumb {
box-shadow: 0 0 0 10px rgba(4, 90, 188, 0.26);
}
.remi-main input[type='range']:active::-webkit-slider-thumb {
background-image: none;
background: rgb(2, 70, 147);
/*-webkit-transform: scale(1.5);*/
/*transform: scale(1.5)*/
}
.remi-main input[type='range']:active::-moz-range-thumb {
background-image: none;
background: rgb(2, 70, 147);
/*transform: scale(1.5)*/
}
.remi-main input[type='range']::-ms-thumb {
width: 15px;
height: 15px;
border: none;
border-radius: 50%;
background: rgb(2, 70, 147);
/*transform: scale(.375);*/
transition: transform .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1);
transition: transform .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1), -webkit-transform .18s cubic-bezier(.4, 0, .2, 1)
}
.remi-main input[type='range']:focus:not(:active)::-ms-thumb {
background: radial-gradient(circle closest-side, rgb(15, 113, 225) 0%, rgb(15, 113, 225) 37.5%, rgba(4, 90, 188, 0.26); 37.5%, rgba(4, 90, 188, 0.26);100%);
transform: scale(1)
}
.remi-main input[type='range']:active::-ms-thumb {
background: rgb(2, 70, 147);
/*transform: scale(.5625)*/
}
.remi-main input[type='range']:disabled:focus::-webkit-slider-thumb,
.remi-main input[type='range']:disabled:active::-webkit-slider-thumb,
.remi-main input[type='range']:disabled::-webkit-slider-thumb {
-webkit-transform: scale(.667);
/*transform: scale(.667);*/
background: rgba(0, 0, 0, .26)
}
.remi-main input[type='range']:disabled:focus::-moz-range-thumb,
.remi-main input[type='range']:disabled:active::-moz-range-thumb,
.remi-main input[type='range']:disabled::-moz-range-thumb {
/*transform: scale(.667);*/
background: rgba(0, 0, 0, .26)
}
.remi-main #loading {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 10;
background: #000;
opacity: 0.8;
}
.remi-main #loading-animation {
width: 40px;
height: 40px;
background-color: rgb(2, 70, 147);
margin: 100px auto;
-webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
animation: sk-rotateplane 1.2s infinite ease-in-out;
}
@-webkit-keyframes sk-rotateplane {
0% { -webkit-transform: perspective(120px) }
50% { -webkit-transform: perspective(120px) rotateY(180deg) }
100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) }
}
@keyframes sk-rotateplane {
0% {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
} 50% {
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
} 100% {
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
}
}
.remi-main .TabBox{
box-shadow: 3px 3px 5px rgb(150,150,150);
}
.remi-main .TabBox ul {
padding-left: 0;
margin: 0px;
}
.remi-main .TabBox ul li {
list-style-type: none;
text-align: center;
text-decoration: none;
color: #888;
padding: 20px 0;
outline: 1px solid #888;
background: #e7e7e7;
}
.remi-main .TabBox ul li.active {
background: white;
outline: none;
}
.remi-main .clearfix:after {
content: "";
display: table;
clear: both;
}
@media only screen and (max-width: 320px) {
.remi-main {
font-size: 12px;
}
.remi-main button {
padding: 0 2px;
font-size: 12px;
}
.remi-main select {
font-size: 12px;
}
}
@media only screen and (max-width: 360px) {
.remi-main {
font-size: 13px;
}
.remi-main button {
padding: 0 2px;
font-size: 13px;
}
.remi-main select {
font-size: 13px;
}
}
.remi-main ul.TreeView{
list-style-type: none;
padding: 0;
position: relative;
display: block;
}
.remi-main .TreeItem{
background-repeat: no-repeat;
text-indent: 18px;
display: block;
}
.remi-main .TreeItem[has-subtree='true'][treeopen='false']{
background-image: url('/res:plus.png');
background-position: 0px 4px;
}
.remi-main .TreeItem[has-subtree='true'][treeopen='true']{
background-image: url('/res:minus.png');
background-position: 0px 4px;
border-bottom: 0;
}
.remi-main .TreeItem[treeopen="false"] .TreeView .TreeItem{
display: none;
}
.remi-main .TreeItem[treeopen="false"] .TreeView{
display: none;
}
.remi-main .TreeItem[treeopen="true"] .TreeView{
padding-left: 18px;
}
.remi-main .TreeItem:hover {
background-color: rgba(2, 70, 147, 0.26);
}
.remi-main .TreeItem[has-subtree='true'][treeopen='true']:hover {
background-color: transparent;
}
.remi-main a {
outline:none;
}
.remi-main .FileFolderItem {
margin:2px;
display:flex;
flex-direction:row;
align-items:center;
justify-content: flex-start;
}
.remi-main .FileFolderItem .Label{
margin:0px;
}
.remi-main .FileFolderItemIcon {
width:30px;
height:30px;
}
I hope this will help. Have a nice day ;-)
how to change font of text in remi ? I know fontfamily can be set but my main question is how to add a custom font family from a woff file ?