HTML输入文本字段自定义字体

时间:2022-11-13 19:09:13

I have try this code to set custom TTF font in teh input text filed:

我尝试使用此代码在输入文本中设置自定义TTF字体:

        <style type="text/css">
            @font-face {
                font-family: "JdLcd";
                src: url("jd_lcd_rounded.ttf");
                //src: url("jd_lcd_rounded.ttf") format('truetype');
            }

            input[name='email'] {
                font-family: "JdLcd";
            }
        </style>

Font is changed, but it's not the same like in TTF file. What is wrong?

字体已更改,但与TTF文件中的字体不同。怎么了?

2 个解决方案

#1


0  

Are you sure the font is in the root of your webserver?

您确定该字体位于您的网络服务器的根目录中吗?

You'd have to upload the proper font files to the server and then call them in your CSS, otherwise your browser will try to find this font on your current system and if it can't find either, it will fall back to the default font.

您必须将正确的字体文件上传到服务器,然后在您的CSS中调用它们,否则您的浏览器将尝试在您当前的系统上找到此字体,如果它也找不到,它将回退到默认值字体。

A good place to start is the Font Squirrel generator: http://www.fontsquirrel.com/tools/webfont-generator

一个好的起点是Font Squirrel发电机:http://www.fontsquirrel.com/tools/webfont-generator

#2


0  

You need to convert your TTF fonts to web fonts. You can use a service like Font Squirrel to do this.

您需要将TTF字体转换为Web字体。您可以使用Font Squirrel等服务来执行此操作。

http://www.fontsquirrel.com/tools/webfont-generator

#1


0  

Are you sure the font is in the root of your webserver?

您确定该字体位于您的网络服务器的根目录中吗?

You'd have to upload the proper font files to the server and then call them in your CSS, otherwise your browser will try to find this font on your current system and if it can't find either, it will fall back to the default font.

您必须将正确的字体文件上传到服务器,然后在您的CSS中调用它们,否则您的浏览器将尝试在您当前的系统上找到此字体,如果它也找不到,它将回退到默认值字体。

A good place to start is the Font Squirrel generator: http://www.fontsquirrel.com/tools/webfont-generator

一个好的起点是Font Squirrel发电机:http://www.fontsquirrel.com/tools/webfont-generator

#2


0  

You need to convert your TTF fonts to web fonts. You can use a service like Font Squirrel to do this.

您需要将TTF字体转换为Web字体。您可以使用Font Squirrel等服务来执行此操作。

http://www.fontsquirrel.com/tools/webfont-generator