After reading the font series of articles, do you still think I am talking about fonts?

After reading the font series of articles, do you still think I am talking about fonts?

[[208286]]

Recently, I have been writing a series of articles about modifying App fonts. I have written nine articles so far, which has almost explained everything I think is related to fonts. Now, it should be considered finished.

I have spent so much energy and space to explain all the details of replacing Android fonts. I believe that there will be no more font-related articles in the Android technology circle that can surpass this.

Of course, I am not saying how good it is or how deep the technology is, but there are only so many points to know when modifying fonts, and this series of articles has already covered all the content involved in modifying fonts. It is difficult to make any substantial improvement if we spend energy and time to rewrite it. The cost-benefit of time and energy is not balanced, and it is not meaningful. Of course, it is not ruled out that more disruptive technologies will emerge, which is another matter.

But what I want to talk about today is not the feelings after the end of this series. What I really want to say is, have you really understood the articles in this series?

Since I started writing this series of articles, there have been some voices in the group or comments. Some people say that Google has released a solution for font in xml in Support v26; some people say that there are already mature open source projects, and you say that these are meaningless. At first, I would say, oh, I will write about this later, and then slowly I will stop paying attention to it.

[[208287]]

But is it really meaningless?

Technology is constantly being updated and new technologies are being released every day. As a technician, if you just keep chasing after how to use these new technologies, when will it end?

If you want to stay in this industry, what you really need to do is to build your own technical knowledge system, abstract the new technologies, core technologies and concepts you have learned, form your own technical circuit, solidify it in your consciousness, and be able to radiate these experiences horizontally to other technical points. Of course, it's a bit mysterious to say this.

What we really need to care about is the core of these technologies, where is its essence, why is it designed this way, and what are the shortcomings of such implementation. Only by abstracting the technology and looking through the appearance to see the essence can you apply it to other technologies. Of course, this level is usually difficult to achieve without more than five years of experience.

It is not difficult to know the fact, but we must know the reason. If we know the reason of one thing, we can know the reason of a hundred things. I wrote these articles, and you can draw conclusions after reading them, but the thinking path of obtaining, proving, deriving and verifying these technologies is what I want you to know more.

Google just announced Kotlin as the main development language for Android at the Google I/O conference, and many people have put a lot of effort into learning it. But I have seen someone spend half a day reading Kotlin's documentation and some key points, and then spent two weeks writing a complete app from scratch. It is now on the shelves and has good advertising revenue. These are the people who have mastered the core technology. No matter how the technology develops, as long as they are still in this industry, they will not be eliminated, because they have their own technical system, and they can analyze the general principles of many things even if they have never been exposed to them. And these are the abilities that technical people who really want to go the technical path really need to cultivate.

Let’s look back at the articles in this font series. What can you see through them? In fact, the entire series is mainly divided into four parts.

1. Understand the basic knowledge related to font modification.

1. Modify the font on Android, detailed overview.

2. Modify the Typeface required by the font.

These two articles mainly explain some of the properties you need to use to modify the font, as well as the details of the system default font, and the source code details of the Typeface class needed to load custom fonts.

When you decide that you need to use a solution to implement a certain function, you need to understand the solution and all the details involved in advance to avoid pitfalls for yourself in the future.

You can't say that using an API is easy to use and you can implement it by calling setXxx(). If you stop here, you will always be a beginner.

At least you need to know what exactly is done inside the setXxx() method? Is it thread safe? Are there any things you need to pay attention to when using it? These details can only be found by reading the source code.

2. Some solutions that can solve the problem but are not perfect

3. A rough way to replace the global font.

4. Modify Typeface through reflection and replace the global font.

These two articles talk about some inelegant solutions, such as globally replacing custom controls, traversing ViewTree during onCreate(), and modifying a default font of Typeface through reflection, and then modifying the global font in conjunction with the theme settings.

In fact, these will not be used in commercial projects in the end. In addition to being inelegant, limitations and efficiency issues are all things that commercial projects need to consider, but this does not prevent us from understanding these methods.

There are actually better solutions for the font modification function, but it does not rule out other needs, and no better solutions can be found for the time being. So, the solution that can solve the problem at this time is a good solution, and what needs to be solved is to make these bad solutions have less impact.

[[208288]]

3. Low-cost and fast replacement of controls

5. Use AppCompatDelegate to replace fonts globally.

6. Modify LayoutInflater and modify the font globally.

7. Add multiple fonts at low cost through custom attributes.

In fact, when you get to the end, you will find that the ultimate problem is how to replace the controls quickly and elegantly at low cost, or to uniformly add font information to the controls.

If you look at these solutions horizontally, you will find that they are not only applicable to replacing fonts. To replace controls globally, you do not need to modify each layout file manually. You can also use AppCompatDelegate or LayoutInflater to quickly replace them globally. Custom attributes are not only applicable to custom controls.

These concepts can be used wherever controls need to be replaced. For example, skinning and no-buffer statistics can all be used. If you simply use it as a solution to replace fonts, then it can only replace fonts.

4. Other new or mature solutions

8. Android Oreo can download fonts.

9. Use mature open source libraries to replace global fonts.

The newly added downloadable fonts in Support v26 are also a good solution. However, in commercial projects, it is cautious to upgrade the versions of these libraries. Using mature open source libraries is also a good solution.

Open source libraries are very fun to use. You can import them and change some key points according to the documentation to achieve the function. However, as long as it is a solution, it will have limitations. When you use it, you must understand all its details clearly, know what its core principle is and where the technical blind spots are.

If you finally choose an open source library to replace the font, if you read the previous articles, you will find that in fact this open source library is just a different way of using the technical points introduced in the previous articles. You can use it with more confidence and know where the problem is and how to solve it quickly.

There are many mature open source libraries, but if you still only use them, when you go out for an interview again, the interviewer asks you why you chose it? What is its core principle? Are there any other alternatives? How do you answer? Is it because everyone uses it?

These are the embodiment of your core competitiveness.

***, I want to say that the road of technology is long, so cherish every step.

Don't just stay on the surface, abstractly understand the technical principles, solidify them in your own consciousness, and form your own technical circuit. In this way, you can maintain the value of your experience in this era of technological explosion and not be afraid of changes.

The conclusion is important, but the thinking path of acquiring, proving, deducing and verifying these technologies is what I want you to know more.

[This article is an original article by 51CTO columnist "Zhang Yang". Please contact the author through WeChat official account to obtain authorization for reprinting]

Click here to read more articles by this author

<<:  Some works of the first 51CTO Developer Competition have been revealed, waiting for you to add to it!

>>:  Why can iPhone X only store one face at a time? Apple responds

Recommend

How to plan an operational topic by taking advantage of hot topics?

Following hot topics is an essential skill for co...

As a community product, what is the future of QQ Interest Tribes?

In 2014, QQ, which has always been considered the...

E-commerce product pricing guide!

The pricing of e-commerce products is very critic...

Community operation: How to create a community marketing campaign?

How to use the five-step method of social marketi...

Practical examples of new media traffic acquisition methods!

In 2016, the argument for the second half of the ...

Brand Marketing Promotion丨Why does IKEA sell products for free?

When it comes to marketing, IKEA has a lot to be ...

Lao Wang created a profitable headline account from 0 to 1

Lao Wang created a profitable headline account fr...

The Mystery of the Eighth Continent

© getty images Leviathan Press: Learning that we ...

Eight car brands suddenly recalled 770,000 vehicles on the eve of March 15

March 15 is a Chinese event, especially for the a...