rapier-math 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/index.mjs +164 -95
- package/math-components.json +6 -6
- package/package.json +3 -3
- package/rapier-math-1.0.2.js +2952 -0
- package/src/math/FONT-SOURCE.md +32 -6
- package/src/math/api.js +4 -3
- package/src/math/browser.js +60 -29
- package/src/math/build-font.py +237 -95
- package/src/math/fallbacks.js +5 -5
- package/src/math/font.js +59 -26
- package/src/math/layout.js +36 -32
- package/src/package.json +1 -1
- package/src/shell/math-resources.json +22 -22
- package/src/tools/build-math.mjs +5 -2
- package/rapier-math-1.0.1.js +0 -2883
package/src/math/fallbacks.js
CHANGED
|
@@ -14,7 +14,7 @@ function mathFallbackGlyph(value,c,extra={}) {
|
|
|
14
14
|
{left:-radius,right:width*unit+radius,inkTop:-high*unit-radius,inkBottom:-low*unit+radius,...extra});
|
|
15
15
|
};
|
|
16
16
|
if(value==='ϝ') {
|
|
17
|
-
const b=draw('𝑓'),g=MATH_FONT.
|
|
17
|
+
const b=draw('𝑓'),g=MATH_FONT.glyph(b.glyph),path=g[7],bars=[...path.matchAll(/H(\d+)/g)],
|
|
18
18
|
start=bars[1],end=bars[2],cut=Number(path.slice(0,start.index).match(/-?\d+/g).at(-1)),
|
|
19
19
|
left=Number(start[1]),right=Number(path.slice(start.index,end.index).match(/-?\d+/g).at(-2)),
|
|
20
20
|
body='M'+left+' '+cut+path.slice(start.index+start[0].length,end.index)+'Z',unit=b.unitScale,
|
|
@@ -39,7 +39,7 @@ function mathFallbackGlyph(value,c,extra={}) {
|
|
|
39
39
|
return centered(draw('⋄',factor));
|
|
40
40
|
}
|
|
41
41
|
if(value==='◆') {
|
|
42
|
-
const b=draw('◊'),path=MATH_FONT.
|
|
42
|
+
const b=draw('◊'),path=MATH_FONT.glyph(b.glyph)[7],contours=path.match(/M[^M]+/g);
|
|
43
43
|
const range=part=>{const numbers=part.match(/-?\d+(?:\.\d+)?/g).map(Number);return Math.max(...numbers)-Math.min(...numbers);};
|
|
44
44
|
const outer=contours.reduce((a,b)=>range(a)>range(b)?a:b);
|
|
45
45
|
return {...b,svg:b.svg.replace('d="'+path+'"','d="'+outer+'"'),glyph:undefined,...extra};
|
|
@@ -51,7 +51,7 @@ function mathFallbackGlyph(value,c,extra={}) {
|
|
|
51
51
|
return contour(800,-75-t,575,'M'+points.map(point=>point.map(mathNumber).join(' ')).join('L')+'Z');
|
|
52
52
|
}
|
|
53
53
|
if(value==='⋔') {
|
|
54
|
-
const b=draw('∩',.86),g=MATH_FONT.
|
|
54
|
+
const b=draw('∩',.86),g=MATH_FONT.glyph(b.glyph),x=(g[1]+g[3])/2,t=MATH_FONT.constants.FractionRuleThickness,
|
|
55
55
|
stem=contour(g[0],g[2],g[4]+100,'M'+mathNumber(x-t/2)+' '+g[2]+'V'+(g[4]+100)+'H'+mathNumber(x+t/2)+'V'+g[2]+'Z',.86);
|
|
56
56
|
return centered(mathCompose([[b,0,0],[stem,0,0]],b.w));
|
|
57
57
|
}
|
|
@@ -72,7 +72,7 @@ function mathFallbackGlyph(value,c,extra={}) {
|
|
|
72
72
|
return mathCompose(items,width,extra);
|
|
73
73
|
}
|
|
74
74
|
if(value==='⇠'||value==='⇢') {
|
|
75
|
-
const right=value==='⇢',b=draw(right?'→':'←'),g=MATH_FONT.
|
|
75
|
+
const right=value==='⇢',b=draw(right?'→':'←'),g=MATH_FONT.glyph(b.glyph),unit=b.unitScale,
|
|
76
76
|
width=Math.max(b.w,extra.stretchAxis==='horizontal'?extra.stretchTarget || 0:0),added=width-b.w,
|
|
77
77
|
split=g[0]*(right?.65:.35);let command='',coordinate=0;
|
|
78
78
|
const path=g[7].replace(/[MLHVCZ]|-?\d+(?:\.\d+)?/g,token=>{
|
|
@@ -100,7 +100,7 @@ function mathFallbackGlyph(value,c,extra={}) {
|
|
|
100
100
|
total=Math.max(target,top.h+bottom.h),gap=Math.max(0,total-top.h-bottom.h),width=top.w,
|
|
101
101
|
ty=-axis-total/2-top.inkTop,by=ty+top.inkBottom+gap-bottom.inkTop,items=[[top,0,ty],[bottom,0,by]];
|
|
102
102
|
if(gap>0) {
|
|
103
|
-
const part=MATH_FONT.
|
|
103
|
+
const part=MATH_FONT.glyph(MATH_FONT.chars['⎪'.codePointAt(0)]),unit=s*factor/MATH_FONT.units,
|
|
104
104
|
overlap=Math.max(MATH_FONT.minConnectorOverlap,40),height=gap/unit+2*overlap,
|
|
105
105
|
stem=contour(part[0],0,height,'M'+part[1]+' 0V'+mathNumber(height)+'H'+part[3]+'V0Z',factor);
|
|
106
106
|
items.push([stem,0,ty+top.inkBottom+gap+overlap*unit]);
|