Fix crash for offscreencanvas when setting font to Math

ConvertFontSize failed to find a font size for font Math. Created
a special case for offscreencanvas to handle Math.

Bug: 1207317

Change-Id: I5256fbecb922cd15521b7e5693ce7f1cbd8880ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3194662
Commit-Queue: Yi Xu <yiyix@chromium.org>
Reviewed-by: Fernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#926929}
diff --git a/html/canvas/offscreen/text/2d.text.setFont.mathFont.html b/html/canvas/offscreen/text/2d.text.setFont.mathFont.html
new file mode 100644
index 0000000..3ee2cc7
--- /dev/null
+++ b/html/canvas/offscreen/text/2d.text.setFont.mathFont.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
+<title>OffscreenCanvas test: 2d.text.setFont.mathFont</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/canvas/resources/canvas-tests.js"></script>
+
+<h1>2d.text.setFont.mathFont</h1>
+<p class="desc">crbug.com/1212190, make sure offscreencanvas doesn't crashh with Math Font</p>
+
+
+<script>
+var t = async_test("crbug.com/1212190, make sure offscreencanvas doesn't crashh with Math Font");
+var t_pass = t.done.bind(t);
+var t_fail = t.step_func(function(reason) {
+    throw reason;
+});
+t.step(function() {
+
+var offscreenCanvas = new OffscreenCanvas(100, 50);
+var ctx = offscreenCanvas.getContext('2d');
+
+ctx.font = "math serif";
+t.done();
+
+});
+</script>
diff --git a/html/canvas/offscreen/text/2d.text.setFont.mathFont.worker.js b/html/canvas/offscreen/text/2d.text.setFont.mathFont.worker.js
new file mode 100644
index 0000000..f45e1e4
--- /dev/null
+++ b/html/canvas/offscreen/text/2d.text.setFont.mathFont.worker.js
@@ -0,0 +1,23 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.setFont.mathFont
+// Description:crbug.com/1212190, make sure offscreencanvas doesn't crashh with Math Font
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+var t = async_test("crbug.com/1212190, make sure offscreencanvas doesn't crashh with Math Font");
+var t_pass = t.done.bind(t);
+var t_fail = t.step_func(function(reason) {
+    throw reason;
+});
+t.step(function() {
+
+var offscreenCanvas = new OffscreenCanvas(100, 50);
+var ctx = offscreenCanvas.getContext('2d');
+
+ctx.font = "math serif";
+t.done();
+
+});
+done();
diff --git a/html/canvas/tools/yaml/offscreen/the-offscreen-canvas.yaml b/html/canvas/tools/yaml/offscreen/the-offscreen-canvas.yaml
index 2bffbf2a..f985ae6 100644
--- a/html/canvas/tools/yaml/offscreen/the-offscreen-canvas.yaml
+++ b/html/canvas/tools/yaml/offscreen/the-offscreen-canvas.yaml
@@ -328,3 +328,10 @@
     @assert offscreenCanvas.height === n;
     t.done();
 
+- name: 2d.text.setFont.mathFont
+  desc: crbug.com/1212190, make sure offscreencanvas doesn't crashh with Math Font
+  testing:
+  - 2d.text.setFont.mathFont
+  code: |
+    ctx.font = "math serif";
+    t.done();