forked from a3ammar/arabic-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the way fonts are loaded to allow FOUT
FOUT is Flash Of Unstyled Text, it's a method to initially show a built in font and then change the font once our custom one is loaded. Using FontFaceObserver allows us to do this easily.
- Loading branch information
Showing
6 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var notoNaskhRegular = new FontFaceObserver("Noto Naskh Arabic", { weight: 400 }); | ||
var notoNaskhBold = new FontFaceObserver("Noto Naskh Arabic", { weight: 700 }); | ||
var notoKufiRegular = new FontFaceObserver("Noto Kufi Arabic", { weight: 400 }); | ||
var notoKufiBold = new FontFaceObserver("Noto Kufi Arabic", { weight: 700 }); | ||
var kawkabMono = new FontFaceObserver("Kawkab Mono", { weight: 400 }); | ||
|
||
var arabicTest = "اهلا"; | ||
var fontLoadTimeout = 5000; | ||
|
||
Promise.all([ | ||
notoNaskhRegular.load(arabicTest, fontLoadTimeout), | ||
notoNaskhBold.load(arabicTest, fontLoadTimeout) | ||
]).then(function() { | ||
document.documentElement.className += " naskh-font-loaded"; | ||
}, function() { | ||
console.log("Could not load Noto Naskh Arabic font"); | ||
}); | ||
|
||
Promise.all([ | ||
notoKufiRegular.load(arabicTest, fontLoadTimeout), | ||
notoKufiBold.load(arabicTest, fontLoadTimeout) | ||
]).then(function() { | ||
document.documentElement.className += " kufi-font-loaded"; | ||
}, function() { | ||
console.log("Could not load Noto Kufi Arabi font"); | ||
}); | ||
|
||
Promise.all([ | ||
kawkabMono.load(arabicTest, fontLoadTimeout) | ||
]).then(function() { | ||
document.documentElement.className += " kawkab-font-loaded"; | ||
}, function() { | ||
console.log("could not load KawkabMono font"); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters