Comments (12)
我好像看到了很多可能性,比如用FontManagerService
直接修改fonts.xml
至于你说的无法更新fallback family和需要正确的postScriptName
这两点我还没看出来
# cmd font help
Font service (font) commands
help
Print this help text.
dump [family name]
Dump all font files in the specified family name.
Dump current system font configuration if no family name was specified.
update [font file path] [signature file path]
Update installed font files with new font file.
update-family [family definition XML path]
Update font families with the new definitions.
install-debug-cert [cert file path]
Install debug certificate file. This command can be used only on userdebug
or eng device with root user.
clear
Remove all installed font files and reset to the initial state.
restart
Restart FontManagerService emulating device reboot.
WARNING: this is not a safe operation. Other processes may misbehave if
they are using fonts updated by FontManagerService.
This command exists merely for testing.
status
Prints status of current system font configuration.
# cmd font dump sans-serif | egrep 'Hans|Hant|Jpan|Kore|CJK'
Family: langTag = zh-Hans-CN
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSansCJK-Regular.ttc, index = 2
Family: langTag = zh-Hant-TW,zh-Bopo-TW
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSansCJK-Regular.ttc, index = 3
Family: langTag = ja-Jpan-JP
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSansCJK-Regular.ttc
Family: langTag = ko-Kore-KR
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSansCJK-Regular.ttc, index = 1
# cmd font dump serif | egrep 'Hans|Hant|Jpan|Kore|CJK'
Family: langTag = zh-Hans-CN
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSerifCJK-Regular.ttc, index = 2
Family: langTag = zh-Hant-TW,zh-Bopo-TW
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSerifCJK-Regular.ttc, index = 3
Family: langTag = ja-Jpan-JP
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSerifCJK-Regular.ttc
Family: langTag = ko-Kore-KR
FontStyle { weight=400, slant=0}, path = /system/fonts/NotoSerifCJK-Regular.ttc, index = 1
from notocjk.
update-family
的具体用法
/**
* Parses XML representing {@link android.graphics.fonts.FontFamilyUpdateRequest}.
*
* <p>The format is like:
* <pre>{@code
* <fontFamilyUpdateRequest>
* <family name="family-name">
* <font name="postScriptName"/>
* </family>
* </fontFamilyUpdateRequest>
* }</pre>
*/
/**
* Read a {@link Family} instance from <family> element in XML
*
* For the XML format, see {@link Font} class comment.
*
* @param parser an XML parser that points <family> element.
* @return an {@link Family} instance
*/
/**
* Font object used for update.
*
* Here is an example of Family/Font XML.
* <family name="my-sans">
* <font name="MySans" weight="400" slant="0" axis="'wght' 400 'ital' 0" index="0" />
* <font name="MySans" weight="400" slant="0" axis="'wght' 400 'ital' 1" index="0" />
* <font name="MySans" weight="400" slant="0" axis="'wght' 700 'ital' 0" index="0" />
* <font name="MySans" weight="400" slant="0" axis="'wght' 700 'ital' 1" index="0" />
* </family>
*
* @see Font#readFromXml(XmlPullParser)
* @see Font#writeToXml(TypedXmlSerializer, Font)
* @see Family#readFromXml(XmlPullParser)
* @see Family#writeFamilyToXml(TypedXmlSerializer, Family)
*/
from notocjk.
看来读取postScriptName
靠的是TTC index为0时,OpenType name table中的数据
fontFileName = mParser.buildFontFileName(tempNewFontFile);
UpdatableFontDir(File filesDir, FontFileParser parser, FsverityUtil fsverityUtil,
File configFile) {
this(filesDir, parser, fsverityUtil, configFile,
System::currentTimeMillis,
(map) -> SystemFonts.getSystemFontConfig(map, 0, 0)
);
}
// For unit testing
UpdatableFontDir(File filesDir, FontFileParser parser, FsverityUtil fsverityUtil,
File configFile, Supplier<Long> currentTimeSupplier,
Function<Map<String, File>, FontConfig> configSupplier) {
mFilesDir = filesDir;
mParser = parser;
mFsverityUtil = fsverityUtil;
mConfigFile = new AtomicFile(configFile);
mCurrentTimeSupplier = currentTimeSupplier;
mConfigSupplier = configSupplier;
}
@Nullable
private UpdatableFontDir createUpdatableFontDir() {
// Never read updatable font files in safe mode.
if (mIsSafeMode) return null;
// If apk verity is supported, fs-verity should be available.
if (!VerityUtils.isFsVeritySupported()) return null;
String[] certs = mContext.getResources().getStringArray(
R.array.config_fontManagerServiceCerts);
if (mDebugCertFilePath != null && (Build.IS_USERDEBUG || Build.IS_ENG)) {
String[] tmp = new String[certs.length + 1];
System.arraycopy(certs, 0, tmp, 0, certs.length);
tmp[certs.length] = mDebugCertFilePath;
certs = tmp;
}
return new UpdatableFontDir(new File(FONT_FILES_DIR), new OtfFontFileParser(),
new FsverityUtilImpl(certs), new File(CONFIG_XML_FILE));
}
// ...
private void initialize() {
synchronized (mUpdatableFontDirLock) {
mUpdatableFontDir = createUpdatableFontDir();
if (mUpdatableFontDir == null) {
setSerializedFontMap(serializeSystemServerFontMap());
return;
}
mUpdatableFontDir.loadFontFileMap();
updateSerializedFontMap();
}
}
@Override
public String getPostScriptName(File file) throws IOException {
ByteBuffer buffer = mmap(file);
try {
return FontFileUtil.getPostScriptName(buffer, 0);
} finally {
unmap(buffer);
}
}
/**
* Analyze name OpenType table and return PostScript name.
*
* IllegalArgumentException will be thrown for invalid font data.
* null will be returned if not found or the PostScript name is invalid.
*
* @param buffer a buffer of OpenType font
* @param index a font index
* @return a post script name or null if it is invalid or not found.
*/
from notocjk.
我知道为啥说fallback改不了了(((
// We should keep the first font family (config.getFontFamilies().get(0)) because it's used
// as a fallback font. See SystemFonts.java.
from notocjk.
fontRevision
是版本号吧?
<head>
<!-- Most of this table will be recalculated by the compiler -->
<tableVersion value="1.0"/>
<fontRevision value="2.002"/>
<!-- ... -->
</head>
from notocjk.
# cmd font dump sans-serif | grep Droid
FontStyle { weight=400, slant=0}, path = /system/fonts/DroidSansFallback.ttf
FontStyle { weight=400, slant=0}, path = /system/fonts/DroidSansFallbackFull.ttf
from notocjk.
fontRevision
是版本号吧?<head> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="1.0"/> <fontRevision value="2.002"/> <!-- ... --> </head>
https://learn.microsoft.com/en-us/typography/opentype/spec/head
是一个定点数,而且整个文件有 checksum。
可能要写点 java 然后用 app_process 跑,顺便把现在那堆正则 xml 换掉(
from notocjk.
好了,我研究完了,我现在的猜测是你想不再通过替换或新增任何文件的方式,修改字体?
目前我们替换和新增的文件有:
/system/etc/fonts.xml
/system_ext/etc/fonts.xml
(一加氧OS/氢OS)/system/fonts/DroidSansFallback.ttf
/system/fonts/DroidSansFallbackFull.ttf
/system/fonts/NotoSansCJK-Regular.ttc
/system/fonts/NotoSansCJK-VF.otf.ttc
/system/fonts/NotoSerifCJK-Regular.ttc
/system/fonts/NotoSerifCJK-VF.otf.ttc
如果想不修改任何文件,那是不可能的。至少fonts.xml
要修改。然后字体如果你不想放到/system
里,可以在fonts.xml
里指定换个位置放
from notocjk.
fontRevision
是版本号吧?<head> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="1.0"/> <fontRevision value="2.002"/> <!-- ... --> </head>
https://learn.microsoft.com/en-us/typography/opentype/spec/head
是一个定点数,而且整个文件有 checksum。
可能要写点 java 然后用 app_process 跑,顺便把现在那堆正则 xml 换掉(
这个2.002的fontRevision是我用fonttool跑出来的,我很确定他是字体版本号
from notocjk.
如果你想隐藏这个模块的话,是不是可以用Zygisk来做这个模块?可惜我完全不会Zygisk
from notocjk.
我重新思考了一下,你只是希望在/proc/self/maps
里让文件的路径指向/data
?
我想的是用户可以装一个旧版的notocjk模块进去,然后写一个模块或脚本执行cmd font update
XDDDDD
from notocjk.
我重新思考了一下,你只是希望在
/proc/self/maps
里让文件的路径指向/data
?
对,主要是要在 /data 里找个应用能访问的地方
不过我又想了一下,应用还是可以在 /system 下面随便找一堆文件 stat 拿设备号,感觉意义不是太大(
真要藏模块可能要上增量更新的同款 dm-snapshot 了
from notocjk.
Related Issues (20)
- android12 调用Google Sans Text的地方都没有多字重 HOT 21
- Android 12开启Magisk Hide及本模块后闪退 HOT 13
- (建议)Regular字重不使用可变字体(使用自带的NotoCJK文件) HOT 14
- [Feature] Add updateJson support HOT 3
- Google Sans customization xml 检查出错 HOT 11
- Android12的MIUI13 HOT 2
- 在不借助magisk的情况下可能实现本模块的效果吗 HOT 4
- 刷入模块时报错 HOT 1
- 一加 coloros 12 适配 HOT 8
- MIUI EU 套用失敗 HOT 2
- 在 Android 13 QPR1 Beta 2 上导致锁屏数字变为 Roboto HOT 7
- 能否向 LinageOS 等常见 Android ROM 提交补丁? HOT 8
- Noto Serif CJK发布2.002版本 HOT 2
- version.json里面的zipUrl还是指向的22版本
- 一加修改 font.xml 修改到注释里 导致中文部分不生效
- Magisk Canary 不再支持从内部挂载点读取未经修改的文件
- 在Apatch上引起了一些崩溃
- Google Play Store crashes with the module enabled HOT 4
- 在KernelSU上引起部分应用闪退
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notocjk.