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

Vue implements file upload and download

This article example shares the specific code of ...

Centos builds chrony time synchronization server process diagram

My environment: 3 centos7.5 1804 master 192.168.1...

Detailed installation process of nodejs management tool nvm

nvm nvm is responsible for managing multiple vers...

17 404 Pages You'll Want to Experience

How can we say that we should avoid 404? The reas...

Introduction to keyword design methods in web design

Many times, we ignore the setting of the web page ...

MySQL transaction control flow and ACID characteristics

Table of contents 1. ACID Characteristics Transac...

The most common mistakes in HTML tag writing

We better start paying attention, because HTML Po...

Detailed explanation of bash command usage

On Linux, bash is adopted as the standard, which ...

Detailed steps for installing Harbor, a private Docker repository

The installation of Harbor is pretty simple, but ...

CentOS 6 uses Docker to deploy redis master-slave database operation example

This article describes how to use docker to deplo...

Docker adds a bridge and sets the IP address range

I don't know if it's because the binary d...

JS realizes the automatic playback effect of pictures

This article shares the specific code of JS to ac...