Partage
  • Partager sur Facebook
  • Partager sur Twitter

@font-face avec Flask et python

    25 octobre 2016 à 15:58:42

    Mon fichier index :

    <html>
      <head>
        <link type="text/css" rel="stylesheet" href="{{url_for('static', filename='css/style.css')}}"/>
        <title>Video Streaming Demonstration</title>
      </head>
      <body>
        <div id="main">
            <h1>Video Streaming Demonstration</h1>
            
            <img id="bg" src="{{ url_for('video_feed') }}">
        </div>
      </body>
    </html>

    Le fichier css :

    /* init */
    
    @font-face{
        font-family : eraserregular;
        src: url('Eraser.ttf');
        font-weight: bold;
        }
    
    h1{
      font-family       : eraserregular;
      font-size         : 34px;
      color             : #FFF;
    }
    
    /* main */
    div#main {
      width : 1440px;
      height : 900px;
      position : relative;
      overflow : hidden;
      background-color : rgba(0, 0, 0, 1);
    }

    Le fichier main :

    from flask import Flask, render_template, Response
    from camera import VideoCamera
    
    app = Flask(__name__)
    
    @app.route('/')
    def index():
        return render_template('index.html')
    
    def gen(camera):
        while True:
            frame = camera.get_frame()
            yield (b'--frame\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
    
    @app.route('/video_feed')
    def video_feed():
        return Response(gen(VideoCamera()),
                        mimetype='multipart/x-mixed-replace; boundary=frame')
    
    if __name__ == '__main__':
        app.run(host='192.168.0.14', debug=True)

    Avec flask j'affiche le retour d'un flux OpenCv avec reconnaissance faciale. Cette partie fonctionne très bien mais je n'arrive pas à charger la police du texte que j'utilise sur la page.

    Mon fichier style.css est dans un répertoire static/css/ avec le fichier Eraser.tff.

    Il ne télécharge par le fichier de la police.

    Une idée? Merci

    Finalement :

    Bizarrement ça marche  avec des balise div (et pas h1)

    /* init */
    
    @font-face{
        font-family : eraserregular;
        src: url('Mechf.ttf');
    }
    /* main */
    div#main {
      width : 1440px;
      height : 900px;
      position : relative;
      overflow : hidden;
      background-color : rgba(0, 0, 0, 1);
      #background-image	: url(tableau.jpg);
    }
    
    }
    div#date, div#heure{
      font-family       : eraserregular;
      font-size         : 34px;
      font-weight       : normal;
      padding           : 0px;
      margin            : 0px;
      color             : #FFF;
    }

     Mais je ne sais pas pourquoi ...

    -
    Edité par Rasp-pi Gard 25 octobre 2016 à 21:52:44

    • Partager sur Facebook
    • Partager sur Twitter

    @font-face avec Flask et python

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown