Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/canvas/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  test_canvas_font_setter.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/canvas/test/test_canvas_font_setter.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=
-->

<head>
  <title>Test for Bug </title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<canvas id="display" height="200" width="200"></canvas>
<pre id="test">
<script type="application/javascript">

var canvas = document.getElementById("display");
var cx = canvas.getContext("2d");

is(cx.font"10px sans-serif""initial font of canvas context");

cx.font = "italic 16px sans-serif";
is(cx.font"italic 16px sans-serif""valid font should round-trip");
cx.font = "bold 12px serif; background: green";
is(cx.font"italic 16px sans-serif""invalid font should be ignored");

cx.font = "bold 12px/3.0 serif";
is(cx.font"bold 12px serif""line-height should be dropped");
cx.font = "inherit";
is(cx.font"bold 12px serif""inherit should be ignored");
cx.font = "boold 18px sans-serif";
is(cx.font"bold 12px serif""syntax error should be ignored");

// FIXME(emilio): This disagrees with the WPT test: 2dcontext/text-styles/2d.text.font.parse.system.html
cx.font = "menu";
is(cx.font"menu""system fonts should work");

function textmeas() {
  return cx.measureText("hello").width;
}

cx.font = "66px serif";
var w_at_66 = textmeas();
cx.font = "20px serif";
var w_at_20 = textmeas();
ok(w_at_66 > w_at_20, "text should be wider at 66px than at 20px");

canvas.style.fontSize = "33px";
cx.font = "2em serif";
is(cx.font"66px serif""font size set using em units serializes to px");
is(textmeas(), w_at_66, "em should be relative to canvas font size");
canvas.style.fontSize = "16px";
is(cx.font"66px serif""font size set using em units serializes to px");
is(textmeas(), w_at_66,
   "em should be relative to canvas font size at time of setting");
document.body.removeChild(canvas);
is(cx.font"66px serif""font size set using em units serializes to px");
is(textmeas(), w_at_66,
   "em should be relative to canvas font size at time of setting");
canvas.style.fontSize = "33px";
cx.font = "2em serif";
is(cx.font"20px serif""font size set using em units serializes to px");
is(textmeas(), w_at_20,
   "em should be relative to 10px when canvas not in document");
document.body.appendChild(canvas);

</script>
</pre>
</body>
</html>

Messung V0.5
C=99 H=100 G=99

¤ Dauer der Verarbeitung: 0.21 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.