{"size": 1289, "ext": "js", "max_stars_repo_path": "FontUtils.js", "max_stars_repo_name": "gittymo/PForms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FontUtils.js", "max_issues_repo_name": "gittymo/PForms", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FontUtils.js", "max_forks_repo_name": "gittymo/PForms", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 40.28125, "max_line_length": 84, "alphanum_fraction": 0.705973623}
/*	FontUtils.js
		Various utility classes and methods for working with elements that use fonts.
		(C)2020 Morgan Evans */

export class FontDimensions {
	constructor(element) {
		this.width = this.height = -1;
		if (element != undefined && element != null && element instanceof HTMLElement) {
			var measureBox = document.createElement("div");
			document.body.appendChild(measureBox);
			measureBox.style.padding = "0px";
			measureBox.style.border = "0px";
			measureBox.style.display = "inline-block";
			measureBox.style.fontFamily = window.getComputedStyle(element).fontFamily;
			measureBox.style.fontSize = window.getComputedStyle(element).fontSize;
			measureBox.style.fontWeight = window.getComputedStyle(element).fontWeight;
			const boxString =
				"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\"@.,-+*()£$?!";
			var sets = 0;
			for (var i = 0; i < boxString.length; i += 5) {
				const lastChar = i + 5 < boxString.length ? i + 5 : boxString.length;
				measureBox.innerHTML = boxString.substring(i, lastChar);
				this.width += measureBox.clientWidth / (lastChar - i);
				this.height += measureBox.clientHeight;
				sets += 1;
			}
			this.width = this.width / sets;
			this.height = this.height / sets;
			document.body.removeChild(measureBox);
		}
	}
}