Support » Allgemeine Fragen » Einbindung von Custom WebFont in Astra Theme

  • Hallo zusammen,

    um eine spezielle Schriftart in das Astra Theme (+ Spectra page builder) einzubinden, habe ich mittlerweile 2 Plugins getestet: „Custom Fonts“ und „Use Any Font“ leider mit dem Ergebnis, dass die Buchstaben verrutschen und teilweise übereinander liegen.

    Daraufhin habe ich begonnen, analog dieser Anleitung des Schriftdesigners, ein Webfont Kit zu erstellen, um ein Style sheet zu implementieren…

    You can create a webfont kit with this tool. https://www.fontsquirrel.com/tools/webfont-generator
    
    In the webfonts folder of your webfont kit, you’ll see a number of files in various formats
    
    These include files in TTF, WOFF, EOT and SVG format. Select all of the files in these formats and copy them to your website’s CSS folder. Also copy the stylesheet.css file to that same main CSS folder.
    
    In your website's main HTML folder, link your font’s stylesheet with this code:
    
    <link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
    
    (If you have renamed your font’s stylesheet to something else like, “fonts.css” make sure this line of code reflects that change.) 
    
    @font-face {
    
    font-family: 'capriccioplain';
    
    src: url('capriccio-plain-webfont.eot'); /* IE9+ */ 
    
    src: url('capriccio-plain-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
    
    url('capriccio-plain-webfont.woff2') format('woff2'), /* Modern browsers */
    
    url('capriccio-plain-webfont.woff') format('woff'), /* Modern browsers */
    
    url('capriccio-plain-webfont.ttf') format('truetype'), /* Most modern web + mobile browsers */
    
    url('capriccio-plain-webfont.svg#capriccioplain') format('svg'); /* iOS Safari 4.1 and below */
    
    }
    
    (Note: If you decide not to include certain formats (such as .svg), simply omit this line in your CSS.) 
    
    Copy the property found in the font-family: parameter (i.e. capriccioplain). You need to use this name to describe your font.
    
    In your main website stylesheet, you can use this font name if you want to add it to a specific css selector. For example, if you’d like to use this font on the h1 tag, create a declaration for h1 in your main stylesheet, like this:
    
    h1 {
    
    font-family: 'capriccioplain';
    
    color: blue;
    
    }

    Doch wo implementieren? es gibt mehrere Orte, an denen css Dateien abgelegt werden, welches der richtige Ort ist, entzieht sich meiner Kenntnis und dann kämen noch die Thematiken der Aktivierung und ob diese Implementierung nicht bei der nächsten Aktualisierung überschrieben wird. Ein Child Theme wäre wohl eine mögliche Lösung, aber erst mal würde ich die Schrift gerne vernünftig einbinden, ohne Buchstabensalat. Kann mir jemand einen Tipp geben? Ich bin momentan ratlos…

    Grüße ggans

Ansicht von 1 Antwort (von insgesamt 1)
  • „Doch wo implementieren? … Ein Child Theme wäre wohl eine mögliche Lösung, aber erst mal würde ich die Schrift gerne vernünftig einbinden …“

    Ein Child-Theme ist ein möglicher Weg, um Webfonts lokal (also vom eigenen Webserver) einzubinden. Ein eigenes Plugin zu schreiben geht auch, wobei du auch irgendwo fasthalten musst, dass Astra nicht die Google Fonts nutzen soll (sowas wie add_filter( 'astra_google_fonts_selected', '__return_empty_array' );).

    Alternativ kannst du auch im Customizer das Menü Zusätzliches CSS verwenden (und sparst dir, ein Child-Theme zu erstellen), musst dann aber die Fonts irgendwo hochladen (z.B. unter wp-content/fonts) und die Pfadangaben in deiner CSS-Regel entsprechend anpassen. Allerdings musst du dann noch die Code-Zeile irgendwo unterbringen (z.B. die Datei hier herunterladen und im Plugin-Verzeichnis wp-content/plugins hochladen: https://gist.github.com/deckerweb/528e9f64f09b15ed4d6729b77d87dc78).

Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „Einbindung von Custom WebFont in Astra Theme“ ist für neue Antworten geschlossen.