Skip to content

Commit 26757a6

Browse files
add variable fntWeight, #215
1 parent 92d480f commit 26757a6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/fontdebug.html

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
.visual {
1515
font-size: 96px !important;
1616
font-style: normal !important;
17-
font-weight: normal !important;
1817
letter-spacing: normal !important;
1918
line-break: auto !important;
2019
line-height: 50% !important;
@@ -74,6 +73,7 @@
7473
let fntStrA = "mmmLLLmmmWWWwwwmmmllliii"
7574
let fntStrB = "ImLwWil"
7675
let isEverDetected = false // track across all four basefonts compares
76+
let fntWeight = "normal"
7777

7878
let fntSystem = ["caption","icon","menu","message-box","small-caption","status-bar",
7979
"-moz-window", "-moz-desktop", "-moz-document", "-moz-workspace", "-moz-info",
@@ -131,7 +131,7 @@
131131
// only use the first one
132132
setTimeout(function() {
133133
let font = fntList[0].toLowerCase()
134-
dom.visual = fntStrB
134+
dom.visual.innerHTML = "<span style ='font-weight:"+ fntWeight +"'>"+ fntStrB +"</span>"
135135
if (fntSystem.includes(font)) {
136136
dom.visual.style.setProperty('--font', "")
137137
dom.visual.style.font = font
@@ -143,7 +143,7 @@
143143
fntList = [font]
144144
getFonts()
145145
let strDetected = (isEverDetected ? sg +" [" : sb +" [NOT ") + "DETECTED]" + sc
146-
dom.font.innerHTML = "<br><hr><br>" + s12 + "FONT: " + sc + font + strDetected +"<br><br>"
146+
dom.font.innerHTML = "<br><hr><br>" + s12 + "FONT: " + sc + font +" [font-weight: "+ fntWeight +"] " + strDetected +"<br><br>"
147147
}, 150)
148148
}
149149
} else {
@@ -154,6 +154,12 @@
154154

155155
function getFonts() {
156156
try {
157+
158+
// check fntWeight
159+
fntWeight += ""
160+
let fntWeightValid = ["100","200","300","400","500","600","700","800","900","950"]
161+
if (!fntWeightValid.includes(fntWeight)) {fntWeight = "normal"}
162+
157163
const doc = document
158164
const id = `font-fingerprint`
159165
const div = doc.createElement('div')
@@ -167,7 +173,7 @@
167173
left: -9999px!important;
168174
font-size: 256px !important;
169175
font-style: normal !important;
170-
font-weight: normal !important;
176+
font-weight: ` + fntWeight + ` !important;
171177
letter-spacing: normal !important;
172178
line-break: auto !important;
173179
line-height: normal !important;

0 commit comments

Comments
 (0)