|
| 1 | +@@warning("-30") |
| 2 | + |
| 3 | +open Event |
| 4 | + |
| 5 | +type fontDisplay = |
| 6 | + | @as("auto") Auto |
| 7 | + | @as("block") Block |
| 8 | + | @as("fallback") Fallback |
| 9 | + | @as("optional") Optional |
| 10 | + | @as("swap") Swap |
| 11 | + |
| 12 | +type fontFaceLoadStatus = |
| 13 | + | @as("error") Error |
| 14 | + | @as("loaded") Loaded |
| 15 | + | @as("loading") Loading |
| 16 | + | @as("unloaded") Unloaded |
| 17 | + |
| 18 | +type fontFaceSetLoadStatus = |
| 19 | + | @as("loaded") Loaded |
| 20 | + | @as("loading") Loading |
| 21 | + |
| 22 | +/** |
| 23 | +[See FontFace on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) |
| 24 | +*/ |
| 25 | +type rec fontFace = { |
| 26 | + /** |
| 27 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/family) |
| 28 | + */ |
| 29 | + mutable family: string, |
| 30 | + /** |
| 31 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/style) |
| 32 | + */ |
| 33 | + mutable style: string, |
| 34 | + /** |
| 35 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/weight) |
| 36 | + */ |
| 37 | + mutable weight: string, |
| 38 | + /** |
| 39 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/stretch) |
| 40 | + */ |
| 41 | + mutable stretch: string, |
| 42 | + /** |
| 43 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/unicodeRange) |
| 44 | + */ |
| 45 | + mutable unicodeRange: string, |
| 46 | + /** |
| 47 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/featureSettings) |
| 48 | + */ |
| 49 | + mutable featureSettings: string, |
| 50 | + /** |
| 51 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/display) |
| 52 | + */ |
| 53 | + mutable display: fontDisplay, |
| 54 | + /** |
| 55 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/ascentOverride) |
| 56 | + */ |
| 57 | + mutable ascentOverride: string, |
| 58 | + /** |
| 59 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/descentOverride) |
| 60 | + */ |
| 61 | + mutable descentOverride: string, |
| 62 | + /** |
| 63 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/lineGapOverride) |
| 64 | + */ |
| 65 | + mutable lineGapOverride: string, |
| 66 | + /** |
| 67 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/status) |
| 68 | + */ |
| 69 | + status: fontFaceLoadStatus, |
| 70 | + /** |
| 71 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/loaded) |
| 72 | + */ |
| 73 | + loaded: Promise.t<fontFace>, |
| 74 | +} |
| 75 | + |
| 76 | +/** |
| 77 | +[See FontFaceSet on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet) |
| 78 | +*/ |
| 79 | +type rec fontFaceSet = { |
| 80 | + ...eventTarget, |
| 81 | + /** |
| 82 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/ready) |
| 83 | + */ |
| 84 | + ready: Promise.t<fontFaceSet>, |
| 85 | + /** |
| 86 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/status) |
| 87 | + */ |
| 88 | + status: fontFaceSetLoadStatus, |
| 89 | +} |
| 90 | + |
| 91 | +type fontFaceDescriptors = { |
| 92 | + mutable style: string, |
| 93 | + mutable weight: string, |
| 94 | + mutable stretch: string, |
| 95 | + mutable unicodeRange: string, |
| 96 | + mutable featureSettings: string, |
| 97 | + mutable display: fontDisplay, |
| 98 | + mutable ascentOverride: string, |
| 99 | + mutable descentOverride: string, |
| 100 | + mutable lineGapOverride: string, |
| 101 | +} |
| 102 | + |
| 103 | +module FontFace = { |
| 104 | + /** |
| 105 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) |
| 106 | + */ |
| 107 | + @new |
| 108 | + external make: (string, unknown, fontFaceDescriptors) => fontFace = "FontFace" |
| 109 | + /** |
| 110 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/load) |
| 111 | + */ |
| 112 | + @send |
| 113 | + external load: fontFace => Promise.t<fontFace> = "load" |
| 114 | +} |
| 115 | + |
| 116 | +module FontFaceSet = { |
| 117 | + /** |
| 118 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/add) |
| 119 | + */ |
| 120 | + @send |
| 121 | + external add: (fontFaceSet, fontFace) => fontFaceSet = "add" |
| 122 | + |
| 123 | + /** |
| 124 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/delete) |
| 125 | + */ |
| 126 | + @send |
| 127 | + external delete: (fontFaceSet, fontFace) => bool = "delete" |
| 128 | + |
| 129 | + /** |
| 130 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/clear) |
| 131 | + */ |
| 132 | + @send |
| 133 | + external clear: fontFaceSet => unit = "clear" |
| 134 | + |
| 135 | + /** |
| 136 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/load) |
| 137 | + */ |
| 138 | + @send |
| 139 | + external load: (fontFaceSet, string, string) => Promise.t<array<fontFace>> = "load" |
| 140 | + |
| 141 | + /** |
| 142 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/check) |
| 143 | + */ |
| 144 | + @send |
| 145 | + external check: (fontFaceSet, string, string) => bool = "check" |
| 146 | +} |
0 commit comments