android 12添加系统字体并且设置为默认字体
需求:在11.0 12.0系统定制化开发中,在产品定制中,有产品需求对于系统字体风格不太满意,所以想要更换系统的默认字体,对于系统字体的修改也是常有的功能,而系统默认也支持增加字体,所以就来添加楷体字体为系统字体,并替换为系统默认字体。
添加系统字体并且设置为默认字体的核心类
frameworks/base/data/fonts/
frameworks/base/data/fonts/fonts.mk
frameworks/base/data/fonts/Android.mk
frameworks/base/data/fonts/fonts.xml
添加系统字体并且设置为默认字体核心功能实现和分析
对于系统添加新字体功能,是默认支持的但是有些字体会导致系统的支持性不是太好,所以要选择好系统字体也是比较关键的
具体步骤如下:
2.1fonts下增加新字体
在目录frameworks/base/data/fonts/ 添加 KTFont.ttf
2.2 在frameworks/base/data/fonts/fonts.mk中添加新的字体
具体先看fonts.mk文件
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.# Warning: this is actually a product definition, to be inherited fromPRODUCT_PACKAGES := \DroidSansMono.ttf \AndroidClock.ttf \fonts.xml
增加新字体如下:
PRODUCT_PACKAGES := \DroidSansMono.ttf \AndroidClock.ttf \
+ KTFont.ttf \fonts.xml
2.3 在frameworks/base/data/fonts/Android.mk中添加新的字体
在font_src_files 添加新增的字体格式,如下
################################# Build the rest of font files as prebuilt.# $(1): The source file name in LOCAL_PATH.# It also serves as the module name and the dest file name.define build-one-font-module$(eval include $(CLEAR_VARS))\$(eval LOCAL_MODULE := $(1))\$(eval LOCAL_SRC_FILES := $(1))\$(eval LOCAL_MODULE_CLASS := ETC)\$(eval LOCAL_MODULE_TAGS := optional)\$(eval LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts)\$(eval include $(BUILD_PREBUILT))endef
font_src_files := \AndroidClock.ttf \KTFont.ttf
2.4fonts.xml配置默认字体作为默认系统字体
frameworks/base/data/fonts/fonts.xml 中替换默认字体
先来看下 fonts.xml
<?xml version="1.0" encoding="utf-8"?>
<!--WARNING: Parsing of this file by third-party apps is not supported. Thefile, and the font files it refers to, will be renamed and/or moved outfrom their respective location in the next Android release, and/or theformat or syntax of the file may change significantly. If you parse thisfile for information about system fonts, do it at your own risk. Yourapplication will almost certainly break with the next major Androidrelease.In this file, all fonts without names are added to the default list.Fonts are chosen based on a match: full BCP-47 language tag includingscript, then just language, and finally order (the first font containingthe glyph).Order of appearance is also the tiebreaker for weight matching. This isthe reason why the 900 weights of Roboto precede the 700 weights - weprefer the former when an 800 weight is requested. Since bold spanseffectively add 300 to the weight, this ensures that 900 is the boldpaired with the 500 weight, ensuring adequate contrast.
-->
<familyset version="23"><!-- first font is default --><family name="sans-serif"><font weight="100" style="normal">Roboto-Thin.ttf</font><font weight="100" style="italic">Roboto-ThinItalic.ttf</font><font weight="300" style="normal">Roboto-Light.ttf</font><font weight="300" style="italic">Roboto-LightItalic.ttf</font><font weight="400" style="normal">Roboto-Regular.ttf</font><font weight="400" style="italic">Roboto-Italic.ttf</font><font weight="500" style="normal">Roboto-Medium.ttf</font><font weight="500" style="italic">Roboto-MediumItalic.ttf</font><font weight="900" style="normal">Roboto-Black.ttf</font><font weight="900" style="italic">Roboto-BlackItalic.ttf</font><font weight="700" style="normal">Roboto-Bold.ttf</font><font weight="700" style="italic">Roboto-BoldItalic.ttf</font></family><!-- Note that aliases must come after the fonts they reference. --><alias name="sans-serif-thin" to="sans-serif" weight="100" /><alias name="sans-serif-light" to="sans-serif" weight="300" /><alias name="sans-serif-medium" to="sans-serif" weight="500" /><alias name="sans-serif-black" to="sans-serif" weight="900" /><alias name="arial" to="sans-serif" /><alias name="helvetica" to="sans-serif" /><alias name="tahoma" to="sans-serif" /><alias name="verdana" to="sans-serif" /><family name="sans-serif-condensed"><font weight="300" style="normal">RobotoCondensed-Light.ttf</font><font weight="300" style="italic">RobotoCondensed-LightItalic.ttf</font><font weight="400" style="normal">RobotoCondensed-Regular.ttf</font><font weight="400" style="italic">RobotoCondensed-Italic.ttf</font><font weight="500" style="normal">RobotoCondensed-Medium.ttf</font><font weight="500" style="italic">RobotoCondensed-MediumItalic.ttf</font><font weight="700" style="normal">RobotoCondensed-Bold.ttf</font><font weight="700" style="italic">RobotoCondensed-BoldItalic.ttf</font></family>。。。。。
通过阅读代码发现第一个family 就是默认的字体KTFont.ttf 所以要把添加在一条就行了
所以修改如下:
<familyset version="23"><!-- first font is default --><family name="sans-serif">
+ <font weight="400" style="normal">KTFont.ttf</font><font weight="100" style="normal">Roboto-Thin.ttf</font><font weight="100" style="italic">Roboto-ThinItalic.ttf</font><font weight="300" style="normal">Roboto-Light.ttf</font><font weight="300" style="italic">Roboto-LightItalic.ttf</font>
- <font weight="400" style="normal">Roboto-Regular.ttf</font>
+ <!--font weight="400" style="normal">Roboto-Regular.ttf</font--><font weight="400" style="italic">Roboto-Italic.ttf</font><font weight="500" style="normal">Roboto-Medium.ttf</font><font weight="500" style="italic">Roboto-MediumItalic.ttf</font>
@@ -545,10 +546,7 @@<family>
同时注意要注释掉相同属性的 Roboto-Regular.ttf的字体 不然系统会抛异常开不了机
在加载系统默认字体的时候 weight 400的字体已经存在了 所以要注释掉一个即可
相关文章:
android 12添加系统字体并且设置为默认字体
需求:在11.0 12.0系统定制化开发中,在产品定制中,有产品需求对于系统字体风格不太满意,所以想要更换系统的默认字体,对于系统字体的修改也是常有的功能,而系统默认也支持增加字体,所以就来添加楷…...
LeetCode刷题系列 -- 1094. 拼车
车上最初有 capacity 个空座位。车 只能 向一个方向行驶(也就是说,不允许掉头或改变方向)给定整数 capacity 和一个数组 trips , trip[i] [numPassengersi, fromi, toi] 表示第 i 次旅行有 numPassengersi 乘客,接他们和放他们的…...
二叉查找树的应用 —— K模型和KV模型
文章目录前言1. K模型2. KV模型🍑 构建KV模型的树🍑 英汉词典🍑 统计水果出现的次数3. 总结前言 在上一篇文章中,我们进行了二叉查找树的实现(文章链接),那么今天主要探讨一下二叉查找树的应用…...
深度学习实战(11):使用多层感知器分类器对手写数字进行分类
使用多层感知器分类器对手写数字进行分类 1.简介 1.1 什么是多层感知器(MLP)? MLP 是一种监督机器学习 (ML) 算法,属于前馈人工神经网络 [1] 类。该算法本质上是在数据上进行训练以学习函数。给定一组特征和一个目标变量&#x…...
ThingsBoard-警报
1、使用 IoT 设备警报 ThingsBoard 提供了创建和管理与您的实体相关的警报的能力:设备、资产、客户等。例如,您可以将 ThingsBoard 配置为在温度传感器读数高于某个阈值时自动创建警报。当然,这是一个非常简化的案例,实际场景可能要复杂得多。 2、主要概念 下面让我们回…...
如何去阅读源码,我总结了18条心法
在聊如何去阅读源码之前,先来简单说一下为什么要去阅读源码,大致可分为以下几点原因:最直接的原因,就是面试需要,面试喜欢问源码,读完源码才可以跟面试官battle提升自己的编程水平,学习编程思想…...
排序:归并排序
一、归并 li[2,4,5,7,//1,3,6,8]#归并的前提是必须两部分排好序 def merge(li,low,mid,high):ilowjmid1ltmp[]while i<mid and j<high: #只要左右两边都有数if li[i]<li[j]:ltmp.append(li[i])i1else:ltmp.append(li[j])j1#while执行完,肯定有一部分没数…...
Allegro172版本线到铜皮不按照设定值避让的原因和解决办法
Allegro172版本线到铜皮不按照设定值避让的原因和解决办法 用Allegro做PCB设计的时候,有时会单独给某块铜皮附上线到铜皮额外再增加一个数值,如下图 在规则的基础上,额外再避让10mil 规则避让line到铜皮10.02mil 额外设置多避让10mil,避让的结果却是30.02mil,正确的是20.…...
小白该从哪方面入手学习大数据
大数据本质上是海量数据。 以往的数据开发,需要一定的Java基础和工作经验,门槛高,入门难。 如果零基础入门数据开发行业的小伙伴,可以从Python语言入手。 Python语言简单易懂,适合零基础入门,在编程语言…...
尚医通(十)数据字典加Redis缓存 | MongoDB
目录一、Redis介绍二、数据字典模块添加Redis缓存1、service_cmn模块,添加redis依赖2、service_cmn模块,添加Redis配置类3、在service_cmn模块,配置文件添加redis配置4、通过注解添加redis缓存5、查询数据字典列表添加Redis缓存6、bug&#x…...
为什么我们不再发明编程语言了?
上个世纪,数百种编程语言被发明出来,但是进入21世纪,当我们都进入互联网时代时,只剩那么寥寥几个了。 如果你翻一下TIOBE得编程语言排行榜,就会发现20年来,上蹿下跳的就是那几张老面孔:C , Java…...
预处理指令详解
预处理指令详解**1.预定义符号****2.#define****2.1 #define 定义标识符****2.2 #define 定义宏****2.3 #define 替换规则****2.4 #和##****#的作用****##的作用****2.5 带副作用的宏参数****2.6 宏和函数的对比****宏和函数对比图****2.7 命名约定****3.#undef**4.条件编译4.1…...
Redis
一.认识NoSQL 1.SQL 关系型数据库 结构化: 定义主键,无符号型数据等关联的:结构化表和表之间的关系通过外键进行关联,节省存储空间SQL查询:语法固定 SELECT id,name,age FROM tb_user WHERE id1 ACID 2.NoSQL 非关系型数据库 Re…...
Elasticsearch5.5.1 自定义评分插件开发
文本相似度插件开发,本文基于Elasticsearch5.5.1,Kibana5.5.1 下载地址为: Past Releases of Elastic Stack Software | Elastic 本地启动两个服务后,localhost:5601打开Kibana界面,点击devTools,效果图…...
4.4 序列化与反序列化
文章目录1.概述2.特点/应用场景3.涉及到的流对象4.代码实现序列化与反序列化4.1 步骤1:创建学生类Student24.2 步骤2:创建序列化测试类5.测试案例中常见的几种编译错误类型6.为什么反序列化版本号需要与序列化版本号一致?7.自动提示 生成UID …...
647. 回文子串 516. 最长回文子序列
647. 回文子串 方法一:动态规划 dp[i][j]:[i,j]范围的下标字符串s是否为回文子串 遍历字符串,每次判断s[i]与s[j]是否相等 ①若相等,j-i0 即单个字符串s[i],那么一定为回文子串,赋值为1 ②若相等,j-i1…...
实用小妙招
记录一些实用小妙招,都是收藏夹里收藏的各种文章,总结在一起,持续更新 实用小妙招LinuxUbuntu修改终端语言安装 Node.js (nvm)git 记住账号密码WSL迁移默认用户修改Linux Ubuntu 修改终端语言 apt update apt install -y language-pack-zh…...
别让猴子跳回背上
1.管理者的贡献来自于他们的判断力与影响力,而非他们所投入的个人时间与埋头苦干 2.管理者的绩效表现则是许多人群策群力的结果 3.管理者的时间管理: 老板占用的时间;组织占用的时间;自己占用的时间;外界占用的时间; 4.管理者的策略在于增加自己的时间,…...
数据结构 | 线性表
🔥Go for it!🔥 📝个人主页:按键难防 📫 如果文章知识点有错误的地方,请指正!和大家一起学习,一起进步👀 📖系列专栏:数据结构与算法 ὒ…...
Deepwalk深度游走算法
主要思想 Deepwalk是一种将随机游走和word2vec两种算法相结合的图结构数据的挖掘算法。该算法可以学习网络的隐藏信息,能够将图中的节点表示为一个包含潜在信息的向量, Deepwalk算法 该算法主要分为随机游走和生成表示向量两个部分,首先…...
SDXL-Turbo快速上手:AutoDL开箱即用,零配置体验实时AI绘画
SDXL-Turbo快速上手:AutoDL开箱即用,零配置体验实时AI绘画 1. 什么是SDXL-Turbo SDXL-Turbo是StabilityAI推出的新一代实时AI绘画模型,它彻底改变了传统AI绘画需要等待数秒甚至数十秒才能看到结果的工作方式。基于创新的对抗扩散蒸馏技术(A…...
3MF格式与Blender从入门到精通:重塑3D打印工作流
3MF格式与Blender从入门到精通:重塑3D打印工作流 【免费下载链接】Blender3mfFormat Blender add-on to import/export 3MF files 项目地址: https://gitcode.com/gh_mirrors/bl/Blender3mfFormat 概念解析:为什么3MF正在取代STL成为行业新标准 …...
Python实战:5分钟搞定小红书自动点赞脚本(附完整代码)
Python实战:5分钟实现小红书自动化互动工具开发指南 在当今内容爆炸的时代,社交媒体运营已成为个人品牌和商业推广的重要阵地。小红书作为国内领先的生活方式分享平台,其互动数据直接影响内容曝光和账号权重。对于开发者而言,掌握…...
jcifs-ng:Java SMB客户端库如何简化企业文件共享?
jcifs-ng:Java SMB客户端库如何简化企业文件共享? 【免费下载链接】jcifs-ng A cleaned-up and improved version of the jCIFS library 项目地址: https://gitcode.com/gh_mirrors/jc/jcifs-ng jcifs-ng是一个经过清理和改进的jCIFS库版本&#…...
Pixel Dream Workshop生成图像的自动化软件测试方案
Pixel Dream Workshop生成图像的自动化软件测试方案 1. 当AI艺术遇上软件测试 最近在帮一个电商客户部署Pixel Dream Workshop时,遇到了一个有趣的问题:他们需要批量生成商品展示图,但发现AI生成的质量时好时坏。有时候图片完美符合要求&am…...
开源大模型落地趋势一文详解:Youtu-2B轻量化实践
开源大模型落地趋势一文详解:Youtu-2B轻量化实践 最近和不少做AI应用的朋友聊天,大家普遍有个感受:大模型是好,但用起来太“重”了。动辄几十上百G的模型,对算力要求高,部署成本也大,很多中小团…...
深度学习项目训练环境多场景落地:中小企业AI研发团队低成本GPU训练环境方案
深度学习项目训练环境多场景落地:中小企业AI研发团队低成本GPU训练环境方案 1. 环境准备与快速上手 对于中小企业的AI研发团队来说,搭建一个稳定可靠的深度学习训练环境往往是个头疼的问题。硬件成本高、环境配置复杂、依赖库冲突等问题经常让团队望而…...
FOC算法避坑指南:克拉克变换的‘等幅值’与‘等功率’到底选哪个?基于AS5600编码器的实测对比
FOC算法避坑指南:克拉克变换的‘等幅值’与‘等功率’到底选哪个?基于AS5600编码器的实测对比 在无刷电机控制领域,FOC(Field Oriented Control)算法因其优异的动态性能和效率表现,已成为工业驱动和高精度…...
别再手动敲代码了!用Tesseract-OCR在Linux上批量处理图片转文字(附Python脚本)
从图片到结构化数据:基于Tesseract-OCR的Linux批量文本提取实战 在数字化办公和自动化流程中,我们经常需要处理大量图片中的文字信息——可能是扫描的合同文档、会议白板照片或是PDF中的非可编辑页面。传统的手动录入不仅效率低下,还容易出错…...
luci-app-unblockneteasemusic 插件完整技术指南:实现网易云音乐播放限制解除
luci-app-unblockneteasemusic 插件完整技术指南:实现网易云音乐播放限制解除 【免费下载链接】luci-app-unblockneteasemusic [OpenWrt] 解除网易云音乐播放限制 项目地址: https://gitcode.com/gh_mirrors/lu/luci-app-unblockneteasemusic luci-app-unblo…...
