Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32768807
text-utils.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
387 B
Referenced Files
None
Subscribers
None
text-utils.js
View Options
// @flow
let
canvas
;
function
calculateMaxTextWidth
(
texts
:
$ReadOnlyArray
<
string
>
,
font
:
string
,
)
:
number
{
if
(
!
canvas
)
{
canvas
=
document
.
createElement
(
'canvas'
);
}
const
context
=
canvas
.
getContext
(
'2d'
);
context
.
font
=
font
;
const
widths
=
texts
.
map
(
text
=>
context
.
measureText
(
text
).
width
);
return
Math
.
max
(...
widths
);
}
export
{
calculateMaxTextWidth
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 9, 12:28 PM (20 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5880843
Default Alt Text
text-utils.js (387 B)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment