当前位置:网站首页>How to gracefully solve the problem of platform font adaptation
How to gracefully solve the problem of platform font adaptation
2022-06-23 02:46:00 【Programming samadhi】
Preface
For a nice and comfortable front-end design , Uniform style is the basic requirement , It must include the unification of fonts .
Due to the continuous advancement of localization process , There have been a lot of problems based on Linux The domestic operating system of , This leads to our usual windows Good fonts used on , On these home-made operating systems, it fails , The reason is that the corresponding fonts are not installed on these operating systems .
ad locum , I will record a recent process to solve the font problem .
The phenomenon
When a customer runs our project on a domestic system , There is a cursor mismatch problem in the script editor .
analysis
We used in our project ace_editor Script editor , Through the roundness source code that , It calculates the cursor position , It depends on the font width , This requires that you must use the same width font , otherwise , The cursor will be misaligned due to the wrong calculation position .
The causes of the above phenomena , To put it bluntly, it is the operating system used by the customer , The fonts required by our project script editor are not installed .
CSS Font knowledge
be familiar with CSS I think all of you know that , We can go through CSS Import font file and define font name , such as :
// font.css
/* Define font name 、 Import constant width font file */
@font-face {
font-family: "bianchengsanmei";
src: url("./font/bianchengsanmei.ttf");
}
/* Using fonts */
.div{
font-family: "bianchengsanmei";
font-size: 14px;
font-weight: normal;
}Solution
For the above problems , Our solution includes the following steps :
First step : Download the constant width font file on the Internet , What we choose here is JetBrainsMono typeface ;
The second step : Select the appropriate font file , In this article, we choose JetBrainsMono-Regular.ttf :
The third step : take JetBrainsMono-Regular.ttf Copy to ./css/font/ Under the path , And in CSS The introduction and use of :
// ./css/font.css
/* Define font name 、 Import constant width font file */
@font-face {
font-family: "JetBrainsMono-Regular";
src: url("./font/JetBrainsMono-Regular.ttf");
}
/* Using fonts */
.div{
font-family: "JetBrainsMono-Regular";
font-size: 14px;
font-weight: normal;
}result
After refreshing the page , To test , Found that the font in the script editor is displayed as a constant width font , And the cursor position is displayed normally , Problem solved .
summary
The above solutions should be the most common and common font solutions , You can refer to this solution for similar problems in the future .
边栏推荐
- Solution to the problem of easycvr switching MySQL database traffic statistics cannot be displayed
- A penetration of an internal self built shooting range
- Third order magic cube formula
- Apache Druid's engineering practice in shopee
- Aikuai multi dialing + load balancing overlay bandwidth
- Deep analysis of time complexity
- Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.
- Troubleshooting and optimization of easynvr version 5.0 Video Square snapshot not displayed
- The commercial s2b2b e-commerce platform of aquatic industry improves the competitiveness of enterprises and creates a strong engine for industrial development
- Summary of easy-to-use MySQL interview questions (Part 1)
猜你喜欢

Performance test -- 14 detailed explanation of performance test report and precautions

WebService details

Performance test -- Jenkins environment construction for 15jmeter performance test
What is sitelock? What is the function?
![Buuctf misc-[bjdctf2020] Nani](/img/4e/ac6bf2f64cb68136581814da73db66.jpg)
Buuctf misc-[bjdctf2020] Nani

Deep learning environment configuration (III) pytorch GPU under Anaconda
![Buuctf misc-[actf freshman competition 2020]outline](/img/a4/ac9d14a69e0759d1e7c65740415bf7.jpg)
Buuctf misc-[actf freshman competition 2020]outline

Vulnhub DC-5

Microservice Optimization: internal communication of microservices using grpc

Performance testing -- Interpretation and practice of 16 enterprise level project framework
随机推荐
Exploit format string vulnerability in CDE
Handlebars dynamic adjustment
Summary of easy-to-use MySQL interview questions (Part 1)
Docker builds MySQL master-slave
Schedule tasks to periodically restart remote services or restart machines
Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027
Tencent cloud server CVM system tool configuration
5g spectrum
Goframe framework (RK boot): fast implementation of server-side JWT verification
A penetration of an internal self built shooting range
How to generate DataMatrix code in batch through TXT file
Capture passwords of all chrome versions
How to use pictures in Excel in PPT template
How PHP uses redis
Chapter 3 tensorflow linear regression
Reinforcement learning series (IV) -policygradient example
PNAs: power spectrum shows obvious bold resting state time process in white matter
You must know the type and method of urllib
Biological psychiatry: defining individualized functional neuroanatomy for precision psychiatry
Digital circuit logic design