Tôi đã nhận thấy khi sử dụng phông chữ web mà ban đầu họ có thể mất một giây để xuất hiện; giống như khi bạn tạo menu thả xuống, khi bạn di chuột qua trình đơn lần đầu tiên, toàn bộ menu sẽ xuất hiện dưới dạng màu nền trong một giây và sau đó văn bản sẽ xuất hiện.Khi nào tải phông chữ trên web và bạn có thể tải trước chúng không?
Điều này không thực sự lý tưởng và điều này khiến tôi tin rằng các webfont không được tải xuống khi tệp CSS được tải, mà là khi bạn xem chúng lần đầu trên trang.
Nhưng mặt khác, tôi đã có các phông chữ được cài đặt trên máy tính của tôi để chúng không cần phải được tải xuống, do đó, cho vay câu hỏi về lý do tại sao họ làm điều này !?
Đây là CSS Tôi sử dụng để tải phông chữ web của tôi:
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Regular-webfont.eot');
src: url('../fonts/Roboto-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Regular-webfont.woff') format('woff'),
url('../fonts/Roboto-Regular-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Regular-webfont.svg#RobotoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Italic-webfont.eot');
src: url('../fonts/Roboto-Italic-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Italic-webfont.woff') format('woff'),
url('../fonts/Roboto-Italic-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Italic-webfont.svg#RobotoItalic') format('svg');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Bold-webfont.eot');
src: url('../fonts/Roboto-Bold-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Bold-webfont.woff') format('woff'),
url('../fonts/Roboto-Bold-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Bold-webfont.svg#RobotoBold') format('svg');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Light-webfont.eot');
src: url('../fonts/Roboto-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Light-webfont.woff') format('woff'),
url('../fonts/Roboto-Light-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Light-webfont.svg#RobotoLight') format('svg');
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Medium-webfont.eot');
src: url('../fonts/Roboto-Medium-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Medium-webfont.woff') format('woff'),
url('../fonts/Roboto-Medium-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Medium-webfont.svg#RobotoMedium') format('svg');
font-weight: 500;
font-style: normal;
}
Bạn có thể đăng mã bạn đang sử dụng để tải lên phông chữ của mình không? –
@BillyMoat Woops xin lỗi, được đăng ngay bây giờ. :) – Brett
sử dụng 'src: local()'. Xem thêm: http://stackoverflow.com/questions/12312323/how-to-know-if-a-font-font-face-has-already-been-loaded – Patrick