ctx.font

Jofre

Erfahrenes Mitglied
Hallo

warum kann ich unten statt

Javascript:
ctx.font =(schriftGroesse + "px "+ schriftTyp);
ctx.font=schriftDicke + ctx.font;

nicht schreiben:

Javascript:
ctx.font =schriftDicke + (schriftGroesse + "px "+ schriftTyp);



meldung(( "Anzahl Treffer :  0"),"bold","16","Arial","#5a617b",xBasis, 400);

function meldung(text,schriftDicke,schriftGroesse,schriftTyp,farbe,xm,ym)
   {
     
       var lg = 10 + ctx.measureText(text).width
       ctx.clearRect(xm, ym-schriftGroesse+2,lg,25);
        ctx.fillStyle = farbe;      
        ctx.font =(schriftGroesse + "px "+ schriftTyp);
        ctx.font=schriftDicke + ctx.font;
        console.log(ctx.font);    
        ctx.fillText(text, xm ,ym);
    }

LG
Joachim
 
Zuletzt bearbeitet von einem Moderator:
Da braucht es ein Leerzeichen zwischen schriftDicke und schriftGroesse:
ctx.font = schriftDicke + ' ' + schriftGroesse + "px " + schriftTyp;
Bei diesem:
Code:
            ctx.font = (schriftGroesse + "px " + schriftTyp);
            ctx.font = schriftDicke + ctx.font;
fällt die schriftDicke unter den Tisch. Es hat den Anschein, dass die API nur gültige Spezifikationen für den Font übernimmt. Stellt sich die Frage, warum dann keine Fehlermeldung ausgeben wird.
 
Zurück