我在一个总是在谷歌字体加载方面出错的系统上工作,但我看不到加载字体的时候因为我在本地(对于Photoshop)有所有这些字体所以我的计算机上的字体看起来很好
所以,我想在Chrome中禁用所有这些字体,这样我就可以快速看到谷歌字体是否正确加载。
你认为这可能吗?
谢谢
PS:请原谅我的英语,我是法国人。答案 0 :(得分:5)
为什么不在Chrome或Opera中使用font API并运行已经指定的所有字体,而不是禁用您身边的字体?
document.fonts.ready.then(function(set) {
// Log that the fonts are loaded
console.log(set);
var t;
for(var t of set.entries()) {
console.log(t);
}
});
FontFaceSet
会告诉您字体是否已加载。
答案 1 :(得分:1)
在Chrome / Brave上,您现在可以看到字体的加载位置。转到let synth = window.speechSynthesis;
const inputForm = document.querySelector('form');
const inputTxt = document.querySelector('input');
const voiceSelect = document.querySelector('select');
let voices;
function populateVoiceList(){
voices = synth.getVoices();
for(var i=0; i< voices.length; i++){
let option = document.createElement('option');
option.textContent = voices[i].name + ' (' + voices[i].lang + ')';
option.setAttribute('data-lang', voices[i].lang);
option.setAttribute('data-name', voices[i].name);
voiceSelect.appendChild(option);
}
}
populateVoiceList();
if (speechSynthesis.onvoiceschanged !== undefined) {
speechSynthesis.onvoiceschanged = populateVoiceList;
}
inputForm.onsubmit = function(event){
event.preventDefault();
let utterThis = new SpeechSynthesisUtterance(inputTxt.value);
var selectedOption = voiceSelect.selectedOptions[0].getAttribute('data-name');
for(let i=0; i < voices.length; i++){
if(voices[i].name === selectedOption){
utterThis.voice = voices[i];
}
}
synth.speak(utterThis);
inputTxt.blur();
}
–> view
–> developer
–>确保选择了inspect elements
标签–>选择elements
子标签–>滚动到在底部并寻找computed
。如果它是本地文件,则会显示rendered fonts
。
如果使用Mac,则可以在“字体簿”应用程序中禁用本地字体。只需打开该应用程序,然后找到要禁用的字体,右键单击并选择YOUR_FONT – local file
。然后刷新页面,您应该看到没有该字体的用户会看到什么。