mirror of
https://github.com/gedoor/legado.git
synced 2024-06-30 23:06:46 +08:00
Compare commits
8 Commits
5a289b64b7
...
aa4fcb2906
Author | SHA1 | Date | |
---|---|---|---|
|
aa4fcb2906 | ||
|
85b1e7b548 | ||
|
d7ae1d4f0a | ||
|
c907ed51b7 | ||
|
576a370da1 | ||
|
d6c2b5eceb | ||
|
da7093214f | ||
|
dc9ce168c1 |
|
@ -1,20 +1,19 @@
|
|||
# -------- Config Path: base/android/proguard/chromium_code.flags --------
|
||||
# -------- Config Path: base/android/proguard/shared_with_cronet.flags --------
|
||||
# Copyright 2016 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Contains flags that can be safely shared with Cronet, and thus would be
|
||||
# appropriate for third-party apps to include.
|
||||
# Contains flags that we want to apply not only to Chromium APKs, but also to
|
||||
# third-party apps that bundle the Cronet library.
|
||||
|
||||
# Allow unused native methods to be removed, but prevent renaming on those that are kept.
|
||||
-keepclasseswithmembernames,includedescriptorclasses,allowaccessmodification class !cr_allowunused,** {
|
||||
native <methods>;
|
||||
}
|
||||
# WARNING: rules in this file are applied to entire third-party APKs, not just
|
||||
# Chromium code. They MUST be scoped appropriately to avoid side effects on app
|
||||
# code that we do not own.
|
||||
|
||||
# Use assumevalues block instead of assumenosideeffects block because Google3 proguard cannot parse
|
||||
# assumenosideeffects blocks which overwrite return value.
|
||||
# chromium_code.flags rather than remove_logging.flags so that it's included
|
||||
# in cronet.
|
||||
# Use assumevalues block instead of assumenosideeffects block because Google3
|
||||
# proguard cannot parse assumenosideeffects blocks which overwrite return
|
||||
# value. Keep this in shared_with_cronet.flags rather than remove_logging.flags
|
||||
# so that it's included in cronet.
|
||||
-assumevalues class org.chromium.base.Log {
|
||||
static boolean isDebug() return false;
|
||||
}
|
||||
|
@ -37,21 +36,10 @@
|
|||
public static **[] values();
|
||||
}
|
||||
|
||||
# -identifiernamestring doesn't keep the module impl around, we have to
|
||||
# explicitly keep it.
|
||||
-if @org.chromium.components.module_installer.builder.ModuleInterface interface *
|
||||
-keep,allowobfuscation,allowaccessmodification class !cr_allowunused,** extends <1> {
|
||||
<init>();
|
||||
}
|
||||
|
||||
# Required to remove fields until b/274802355 is resolved.
|
||||
-assumevalues class !cr_allowunused,** {
|
||||
final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_;
|
||||
}
|
||||
|
||||
# TODO(agrieve): Remove once we start to use Android U SDK.
|
||||
-dontwarn android.window.BackEvent
|
||||
-dontwarn android.window.OnBackAnimationCallback
|
||||
# -------- Config Path: build/android/chromium_annotations.flags --------
|
||||
# Copyright 2022 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
|
@ -113,6 +101,22 @@
|
|||
-identifiernamestring class * {
|
||||
@org.chromium.build.annotations.IdentifierNameString *;
|
||||
}
|
||||
|
||||
# Mark fields with this to help R8 figure out that they cannot be null.
|
||||
# Use assumevalues in addition to assumenosideeffects block because Google3 proguard cannot parse
|
||||
# assumenosideeffects blocks which overwrite return value.
|
||||
-assumevalues class ** {
|
||||
@org.chromium.build.annotations.AssumeNonNull *** *(...) return _NONNULL_;
|
||||
}
|
||||
-assumenosideeffects class ** {
|
||||
@org.chromium.build.annotations.AssumeNonNull *** *(...);
|
||||
}
|
||||
-assumevalues class ** {
|
||||
@org.chromium.build.annotations.AssumeNonNull *** * return _NONNULL_;
|
||||
}
|
||||
-assumenosideeffects class ** {
|
||||
@org.chromium.build.annotations.AssumeNonNull *** *;
|
||||
}
|
||||
# -------- Config Path: components/cronet/android/cronet_impl_common_proguard.cfg --------
|
||||
# Proguard config for apps that depend on cronet_impl_common_java.jar.
|
||||
|
||||
|
@ -227,3 +231,10 @@
|
|||
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
|
||||
@org.jni_zero.CalledByNativeUnchecked <methods>;
|
||||
}
|
||||
|
||||
# Allow unused native methods to be removed, but prevent renaming on those that
|
||||
# are kept.
|
||||
# TODO(crbug.com/315973491): Restrict the broad scope of this rule.
|
||||
-keepclasseswithmembernames,includedescriptorclasses,allowaccessmodification class ** {
|
||||
native <methods>;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
{"arm64-v8a":"bbf2c50d1ebf0763d451b08e290a3244","armeabi-v7a":"ecb872f7b1b5342f4d7c36262bec0600","x86":"4da4832b89e2412d808c5b1ecdc24e3d","x86_64":"62080f051db02ed0e939affb39ce67fb","version":"123.0.6312.80"}
|
||||
{"x86_64":"70374d614c6370f39ecc33c3a4a71886","arm64-v8a":"4231b5852366a17ef66bfc47c9e1e9bd","armeabi-v7a":"3c6edf29c6cc021e2a335f17c80c9a18","x86":"d0d33c9f93b4be1141214456757db621","version":"126.0.6478.72"}
|
|
@ -13,6 +13,7 @@
|
|||
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
|
||||
|
||||
**2024/02/27**
|
||||
* 更新cronet: 126.0.6478.72
|
||||
* 更新cronet: 123.0.6312.80
|
||||
* 更新cronet: 123.0.6312.40
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ import java.io.File
|
|||
import java.io.FileOutputStream
|
||||
import java.net.URLEncoder
|
||||
import java.nio.charset.Charset
|
||||
import java.security.MessageDigest
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
@ -748,45 +749,68 @@ interface JsExtensions : JsEncodeUtils {
|
|||
//******************文件操作************************//
|
||||
|
||||
/**
|
||||
* 解析字体,返回字体解析类
|
||||
* 解析字体Base64数据,返回字体解析类
|
||||
*/
|
||||
fun queryBase64TTF(base64: String?): QueryTTF? {
|
||||
base64DecodeToByteArray(base64)?.let {
|
||||
return QueryTTF(it)
|
||||
}
|
||||
return null
|
||||
fun queryBase64TTF(data: String?): QueryTTF? {
|
||||
log("queryBase64TTF(String)方法已过时,并将在未来删除;请无脑使用queryTTF(Any)替代,新方法支持传入 url、本地文件、base64、ByteArray 自动判断&自动缓存,特殊情况需禁用缓存请传入第二可选参数false:Boolean")
|
||||
return queryTTF(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回字体解析类
|
||||
* @param str 支持url,本地文件,base64,自动判断,自动缓存
|
||||
* @param data 支持url,本地文件,base64,ByteArray,自动判断,自动缓存
|
||||
* @param useCache 可选开关缓存,不传入该值默认开启缓存
|
||||
*/
|
||||
fun queryTTF(str: String?): QueryTTF? {
|
||||
str ?: return null
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun queryTTF(data: Any?, useCache: Boolean): QueryTTF? {
|
||||
try {
|
||||
val key = md5Encode16(str)
|
||||
var qTTF = CacheManager.getQueryTTF(key)
|
||||
if (qTTF != null) return qTTF
|
||||
val font: ByteArray? = when {
|
||||
str.isAbsUrl() -> AnalyzeUrl(str, source = getSource()).getByteArray()
|
||||
str.isContentScheme() -> Uri.parse(str).readBytes(appCtx)
|
||||
str.startsWith("/storage") -> File(str).readBytes()
|
||||
else -> base64DecodeToByteArray(str)
|
||||
var key: String? = null
|
||||
var qTTF: QueryTTF?
|
||||
when (data) {
|
||||
is String -> {
|
||||
if (useCache) {
|
||||
key = MessageDigest.getInstance("SHA-256").digest(data.toByteArray()).toHexString()
|
||||
qTTF = CacheManager.getQueryTTF(key)
|
||||
if (qTTF != null) return qTTF
|
||||
}
|
||||
val font: ByteArray? = when {
|
||||
data.isContentScheme() -> Uri.parse(data).readBytes(appCtx)
|
||||
data.startsWith("/storage") -> File(data).readBytes()
|
||||
data.isAbsUrl() -> AnalyzeUrl(data, source = getSource()).getByteArray()
|
||||
else -> base64DecodeToByteArray(data)
|
||||
}
|
||||
font ?: return null
|
||||
qTTF = QueryTTF(font)
|
||||
}
|
||||
|
||||
is ByteArray -> {
|
||||
if (useCache) {
|
||||
key = MessageDigest.getInstance("SHA-256").digest(data).toHexString()
|
||||
qTTF = CacheManager.getQueryTTF(key)
|
||||
if (qTTF != null) return qTTF
|
||||
}
|
||||
qTTF = QueryTTF(data)
|
||||
}
|
||||
|
||||
else -> return null
|
||||
}
|
||||
font ?: return null
|
||||
qTTF = QueryTTF(font)
|
||||
CacheManager.put(key, qTTF) // debug注释掉
|
||||
if (key != null) CacheManager.put(key, qTTF)
|
||||
return qTTF
|
||||
} catch (e: Exception) {
|
||||
AppLog.put("获取字体处理类出错", e)
|
||||
AppLog.put("[queryTTF] 获取字体处理类出错", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
fun queryTTF(data: Any?): QueryTTF? {
|
||||
return queryTTF(data, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text 包含错误字体的内容
|
||||
* @param errorQueryTTF 错误的字体
|
||||
* @param correctQueryTTF 正确的字体
|
||||
* @param filter 删除 errorQueryTTF 中不存在的字符
|
||||
*/
|
||||
fun replaceFont(
|
||||
text: String,
|
||||
|
@ -802,8 +826,9 @@ interface JsExtensions : JsEncodeUtils {
|
|||
if (errorQueryTTF.isBlankUnicode(oldCode)) {
|
||||
return@forEachIndexed
|
||||
}
|
||||
val glyf = errorQueryTTF.getGlyfByUnicode(oldCode)
|
||||
// 删除轮廓数据不存在的字符
|
||||
var glyf = errorQueryTTF.getGlyfByUnicode(oldCode) // 轮廓数据不存在
|
||||
if (errorQueryTTF.getGlyfIdByUnicode(oldCode) == 0) glyf = null // 轮廓数据指向保留索引0
|
||||
if (filter && (glyf == null)) {
|
||||
contentArray[index] = ""
|
||||
return@forEachIndexed
|
||||
|
@ -817,6 +842,11 @@ interface JsExtensions : JsEncodeUtils {
|
|||
return contentArray.joinToString("")
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text 包含错误字体的内容
|
||||
* @param errorQueryTTF 错误的字体
|
||||
* @param correctQueryTTF 正确的字体
|
||||
*/
|
||||
fun replaceFont(
|
||||
text: String,
|
||||
errorQueryTTF: QueryTTF?,
|
||||
|
|
|
@ -648,6 +648,8 @@ public class QueryTTF {
|
|||
var reader = new BufferReader(buffer, dataTable.offset);
|
||||
if (head.indexToLocFormat == 0) {
|
||||
loca = reader.ReadUInt16Array(dataTable.length / 2);
|
||||
// 当loca表数据长度为Uint16时,需要翻倍
|
||||
for (var i = 0; i < loca.length; i++) loca[i] *= 2;
|
||||
} else {
|
||||
loca = reader.ReadInt32Array(dataTable.length / 4);
|
||||
}
|
||||
|
@ -683,6 +685,7 @@ public class QueryTTF {
|
|||
int unicodeInclusive = 0;
|
||||
int unicodeExclusive = f.glyphIdArray.length;
|
||||
for (; unicodeInclusive < unicodeExclusive; unicodeInclusive++) {
|
||||
if (f.glyphIdArray[unicodeInclusive] == 0) continue; // 排除轮廓索引为0的Unicode
|
||||
unicodeToGlyphId.put(unicodeInclusive, f.glyphIdArray[unicodeInclusive]);
|
||||
}
|
||||
break;
|
||||
|
@ -709,12 +712,15 @@ public class QueryTTF {
|
|||
int idDelta = f.idDelta[segmentIndex];
|
||||
int idRangeOffset = f.idRangeOffsets[segmentIndex];
|
||||
for (int unicode = unicodeInclusive; unicode <= unicodeExclusive; unicode++) {
|
||||
int glyphId = 0;
|
||||
if (idRangeOffset == 0) {
|
||||
unicodeToGlyphId.put(unicode, (unicode + idDelta) & 0xFFFF);
|
||||
glyphId = (unicode + idDelta) & 0xFFFF;
|
||||
} else {
|
||||
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex;
|
||||
unicodeToGlyphId.put(unicode, gIndex < glyphIdArrayLength ? f.glyphIdArray[gIndex] + idDelta : 0);
|
||||
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex - segCount;
|
||||
if (gIndex < glyphIdArrayLength) glyphId = f.glyphIdArray[gIndex] + idDelta;
|
||||
}
|
||||
if (glyphId == 0) continue; // 排除轮廓索引为0的Unicode
|
||||
unicodeToGlyphId.put(unicode, glyphId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -771,21 +777,24 @@ public class QueryTTF {
|
|||
var dataTable = directorys.get("glyf");
|
||||
assert dataTable != null;
|
||||
int glyfCount = maxp.numGlyphs;
|
||||
glyfArray = new GlyfLayout[glyfCount + 1]; // 创建容器时,多创建一个作为保留区
|
||||
glyfArray = new GlyfLayout[glyfCount]; // 创建字形容器
|
||||
|
||||
var reader = new BufferReader(buffer, 0);
|
||||
for (int index = 1; index <= glyfCount; index++) {
|
||||
if (loca[index - 1] == loca[index]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
||||
int offset = dataTable.offset + loca[index - 1];
|
||||
for (int index = 0; index < glyfCount; index++) {
|
||||
if (loca[index] == loca[index + 1]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
||||
int offset = dataTable.offset + loca[index];
|
||||
// 读GlyphHeaders
|
||||
var glyph = new GlyfLayout();
|
||||
reader.position(offset);
|
||||
glyph.numberOfContours = reader.ReadInt16();
|
||||
if (glyph.numberOfContours > maxp.maxContours) continue; // 如果字形轮廓数大于非复合字形中包含的最大轮廓数,则说明该字形无效。
|
||||
glyph.xMin = reader.ReadInt16();
|
||||
glyph.yMin = reader.ReadInt16();
|
||||
glyph.xMax = reader.ReadInt16();
|
||||
glyph.yMax = reader.ReadInt16();
|
||||
|
||||
// 轮廓数为0时,不需要解析轮廓数据
|
||||
if (glyph.numberOfContours == 0) continue;
|
||||
// 读Glyph轮廓数据
|
||||
if (glyph.numberOfContours > 0) {
|
||||
// 简单轮廓
|
||||
|
@ -888,7 +897,7 @@ public class QueryTTF {
|
|||
if ((glyphTableComponent.flags & 0x20) == 0) break;
|
||||
}
|
||||
}
|
||||
glyfArray[index] = glyph; // 根据文档 glyfId=0 作为保留区使用,这里赋值从索引1开始
|
||||
glyfArray[index] = glyph;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -914,7 +923,15 @@ public class QueryTTF {
|
|||
// 复合字形
|
||||
LinkedList<String> glyphIdList = new LinkedList<>();
|
||||
for (var g : glyph.glyphComponent) {
|
||||
glyphIdList.add(String.valueOf(g.glyphIndex));
|
||||
glyphIdList.add("{" +
|
||||
"flags:" + g.flags + "," +
|
||||
"glyphIndex:" + g.glyphIndex + "," +
|
||||
"arg1:" + g.argument1 + "," +
|
||||
"arg2:" + g.argument2 + "," +
|
||||
"xScale:" + g.xScale + "," +
|
||||
"scale01:" + g.scale01 + "," +
|
||||
"scale10:" + g.scale10 + "," +
|
||||
"yScale:" + g.yScale + "}");
|
||||
}
|
||||
glyphString = "[" + String.join(",", glyphIdList) + "]";
|
||||
}
|
||||
|
@ -960,10 +977,11 @@ public class QueryTTF {
|
|||
int glyfArrayLength = glyfArray.length;
|
||||
for (var item : unicodeToGlyphId.entrySet()) {
|
||||
int key = item.getKey();
|
||||
int val = item.getValue() + 1; // glyphArray已根据TTF文档将索引0作为保留位,这里从1开始索引
|
||||
int val = item.getValue();
|
||||
if (val >= glyfArrayLength) continue;
|
||||
String glyfString = getGlyfById(val);
|
||||
unicodeToGlyph.put(key, glyfString);
|
||||
if (glyfString == null) continue; // null 不能用作hashmap的key
|
||||
glyphToUnicode.put(glyfString, key);
|
||||
}
|
||||
// Log.i("QueryTTF", "字体处理完成");
|
||||
|
@ -981,8 +999,8 @@ public class QueryTTF {
|
|||
*/
|
||||
public int getGlyfIdByUnicode(int unicode) {
|
||||
var result = unicodeToGlyphId.get(unicode);
|
||||
if (result == null) return 0;
|
||||
return result + 1; // 根据TTF文档,轮廓索引的定义从1开始
|
||||
if (result == null) return 0; // 如果找不到Unicode对应的轮廓索引,就返回默认值0
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1003,7 +1021,7 @@ public class QueryTTF {
|
|||
*/
|
||||
public int getUnicodeByGlyf(String glyph) {
|
||||
var result = glyphToUnicode.get(glyph);
|
||||
if (result == null) return 0;
|
||||
if (result == null) return 0; // 如果轮廓数据找不到对应的Unicode,就返回默认值0
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ android.defaults.buildfeatures.shaders=false
|
|||
# and none from the library's dependencies, thereby reducing the size of the R class for that library.
|
||||
android.nonTransitiveRClass=true
|
||||
# https://chromiumdash.appspot.com/releases?platform=Android
|
||||
CronetVersion=123.0.6312.80
|
||||
CronetMainVersion=123.0.0.0
|
||||
CronetVersion=126.0.6478.72
|
||||
CronetMainVersion=126.0.0.0
|
||||
android.injected.testOnly=false
|
||||
android.nonFinalResIds=true
|
Loading…
Reference in New Issue
Block a user