我正在使用谷歌浏览器的最新版本,它根本不会渲染字体。
我正在运行Debian Linux,而所有其他浏览器(包括Chromium)都会正确显示包含的字体。
我正在使用的字体面部声明是:
@font-face {
font-family: Dejaweb;
src: url('DejaWeb.ttf');
}
@font-face {
font-weight: bold;
font-family: Dejaweb;
src: url('DejaWeb-Bold.ttf');
}
答案 0 :(得分:9)
每当@ font-face莫名其妙地在我认为兼容的浏览器中对我不起作用时,我将其放在我的.htaccess文件中。据推测,一些浏览器不会加载托管在其他域上的字体,而这些代码会对此进行故障排除,但有时它也是强制加载托管在同一域上的字体的唯一补救措施。一般来说,Firefox的问题多于Chrome的问题,但我现在用它来强制Chrome中的字体,而Firefox运行正常。去图。
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
我使用@ font-face语法发生的另一个令人费解的奇怪事情是,它不会在名称中使用大写字母正确加载字体文件。这只是一个问题,经过反复敲击桌面故障排除@ font-face之后的一系列不同方式,作为最后的手段,我将所有字体文件和字体系列名称更改为小写字符,并且工作正常(我认为这是一个在挑剔的IE浏览器中的问题,我只做过一个网站,在另一个网站上完全相同的语法与大写和小写字符配合得很好)。
答案 1 :(得分:5)
试试这个
src:url('DejaWeb-Bold.ttf') format('truetype'),
此外,如果字体以其他不同格式提供,那么我建议以下列方式兼容地编写所有跨浏览器
@font-face {
font-family: "Dejaweb";
src: url("DejaWeb-Bol.eot") format('embedded-opentype'), /* EDIT correction on this line */
url('DejaWeb-Bol.woff') format('woff'), /* Modern Browsers */
url('DejaWeb-Bol.ttf') format('truetype'), /* Safari, Android, iOS */
url('DejaWeb-Bol.svg#Dejaweb') format('svg'); /* Legacy iOS; correction on this line */
font-weight:bold;
font-style:normal;
}
答案 2 :(得分:0)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.Statement;
import java.sql.*;
class Log extends imp implements ActionListener {
JButton login = new JButton("Login");
JPanel panel = new JPanel();
JTextField tx = new JTextField(15);
JPasswordField pass = new JPasswordField(15);
Log() {
//super("Login Autentification");
setSize(300, 200);
setLocation(500, 280);
panel.setLayout(null);
tx.setBounds(70, 30, 150, 20);
pass.setBounds(70, 65, 150, 20);
login.setBounds(110, 100, 80, 20);
panel.add(login);
panel.add(tx);
panel.add(pass);
getContentPane().add(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
actionlogin();
}
public void actionlogin() {
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String puname = tx.getText();
String ppaswd = pass.getText();
if (puname.equals("test") && ppaswd.equals("12345")) {
newframe regFace = new newframe(); // next GUI....
regFace.setVisible(true);
dispose();
} else {
JOptionPane.showMessageDialog(null, "Wrong Password / Username");
tx.setText("");
pass.setText("");
tx.requestFocus();
}
}
});
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}
class newframe extends imp {
JButton menu = new JButton("Customer");
JButton menu2 = new JButton("Reports");
JButton menu3 = new JButton("Settings");
JButton menu4 = new JButton("Rooms");
JPanel p2 = new JPanel();
//int p = Integer.parseInt(jButton.getText());
newframe() {
//super("MENU");
setSize(300, 200);
//setLocation(500,280);
p2.setLayout(null);
menu.setBounds(150, 10, 100, 50);
p2.add(menu);
menu2.setBounds(40, 10, 100, 50);
p2.add(menu2);
menu3.setBounds(150, 90, 100, 50);
p2.add(menu3);
menu4.setBounds(40, 90, 100, 50);
p2.add(menu4);
getContentPane().add(p2);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setVisible(true);
menu.setActionCommand("1");
menu2.setActionCommand("2");
menu3.setActionCommand("3");
menu4.setActionCommand("4");
System.out.println("Reached");
}
public void actionPerformed(ActionEvent ae) {
System.out.println("Yahadsdasfasfn bhi");
int a = Integer.parseInt(ae.getActionCommand());
switch (a) {
case 1:
System.out.println("CUSTOMER");
Customer C = new Customer();
C.setSize(400, 400);
C.setVisible(true);
C.isvissible(true);
break;
}
}
}
class Customer extends imp implements ActionListener {
JLabel jaddcustomer, jsearchcustomer, jdeletecustomer, jupdatecustomer;
JButton jb6, jb7, jb8, jb9;
Customer() {
//super("Customer");
Container c = getContentPane();
FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
c.setLayout(fl);
jb6 = new JButton("Adding New Customer");
jaddcustomer = new JLabel("");
jb6.addActionListener(this);
jb7 = new JButton("Search Customer Record");
jsearchcustomer = new JLabel("");
jb7.addActionListener(this);
jb8 = new JButton("Delete Customer Record");
jdeletecustomer = new JLabel("");
jb8.addActionListener(this);
jb9 = new JButton("Update Customer Record");
jupdatecustomer = new JLabel("");
jb9.addActionListener(this);
c.add(jb6);
c.add(jaddcustomer);
c.add(jb7);
c.add(jsearchcustomer);
c.add(jb8);
c.add(jdeletecustomer);
c.add(jb9);
c.add(jupdatecustomer);
}@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
class login {
public static void main(String[] args) {
try {
// execute.....
// login
Log l = new Log(); //displays login page
Jbuton b = new Jbuton();
// newframe f=newframe();
Customer c = new Customer();
//l.isvissible(false);
c.isvissible(true);
} catch (Exception e) {
System.out.println("Exception");
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}
为我添加正常值的font-weight和font-style。