Use @font-face to implement special characters on web pages (create custom fonts)

Use @font-face to implement special characters on web pages (create custom fonts)

A few days ago, I wrote an article about using CSS to implement a triangular arrow. Although the desired effect was achieved, there are still some problems. For example, the position of the arrow still needs to be located. And currently only triangular arrows can be realized. If you want to use some other characters, you still have to use pictures. So I have been looking for a better way recently, and finally I found it...

First, we go to the Fonts folder on the C drive to find the WEBDINGS.TTF font and copy it to the desktop. Next, we need a software called "fontforge", which can realize the function of creating custom fonts. We will use it to make a font library suitable for our own.

After downloading, unzip it, copy the WEBDINGS.TTF font into it, run fontforge.bat and select the font file, and then this interface will appear:

There are a lot of graphic characters. Did you find that many of them have been used before, but they were implemented with pictures at that time?

The next thing we need to do is to select the characters we need and save them to another font file. Since most of the characters in the WEBDINGS.TTF file are not used, it is a bit too large to use this file directly as our character library. So we only need to select the ones we need. To operate, we first create a blank font file, click File->New, then select the characters we need and copy them to the newly created font file, such as:

Then save and select Generate Fonts:

Then save the file with the .ttf extension:

In this way, our font file is ready. However, it is not over yet, because IE only recognizes .eof and not .ttf, so we still need to generate other font files. Regarding this issue, I wrote an article a long time ago, and the operation methods are explained, so I will not introduce them in detail. The article link is: "The actual operation of using arbitrary fonts in web pages".

Finally, if you find the operation too troublesome, you can download a character library I compiled, which mainly focuses on arrows because they are so commonly used.
Download

In general, although this thing will increase the total size of the loaded page file, if you have your own character library, the operability will be more diversified. Because we can control the size and color of the characters, and even CSS3 effects such as shadows and flipping, but if we want to change the color of a picture, we have to modify it or make a new one, which is not very flexible.

PS: In my EonerCMS, the buttons on the upper right and lower right sides of the window have been replaced with characters, and the effect is quite good.

PS2: Thanks to @小熊 for the idea. Since character rotation can be achieved through CSS3 & filters, when making the character library, we can only record one arrow in the four directions and rotate it through code to reduce the size of the character library file.

<<:  Detailed example of installing FastDfs file server using docker compose

>>:  What is the function of !-- -- in HTML page style?

Recommend

In-depth understanding of javascript class array

js array is probably familiar to everyone, becaus...

Introduction to HTML link anchor tags and their role in SEO

The <a> tag is mainly used to define links ...

Detailed steps to install mysql 8.0.18-winx64 on win10

1. First go to the official website to download t...

Detailed steps to install RabbitMQ in docker

Table of contents 1. Find the mirror 2. Download ...

MySQL column to row conversion and year-month grouping example

As shown below: SELECT count(DISTINCT(a.rect_id))...

vue uses Ele.me UI to imitate the filtering function of teambition

Table of contents Problem Description The general...

Tutorial on installing DAMO database on Centos7

1. Preparation After installing the Linux operati...

How to operate MySQL database with ORM model framework

What is ORM? ORM stands for Object Relational Map...

Vue.js implements calendar function

This article example shares the specific code of ...

How to query duplicate data in mysql table

INSERT INTO hk_test(username, passwd) VALUES (...

SpringBoot integrates Activiti7 implementation code

After the official release of Activiti7, it has f...

MySQL scheduled full database backup

Table of contents 1. MySQL data backup 1.1, mysql...

A brief discussion of four commonly used storage engines in MySQL

Introduction to four commonly used MySQL engines ...