mirror of
https://github.com/gedoor/legado.git
synced 2024-07-02 23:17:32 +08:00
Compare commits
8 Commits
1a0f82be20
...
ce5f9d39bc
Author | SHA1 | Date | |
---|---|---|---|
|
ce5f9d39bc | ||
|
aa4fcb2906 | ||
|
85b1e7b548 | ||
|
d7ae1d4f0a | ||
|
c907ed51b7 | ||
|
576a370da1 | ||
|
d6c2b5eceb | ||
|
da7093214f |
|
@ -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
|
# Copyright 2016 The Chromium Authors
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
# Contains flags that can be safely shared with Cronet, and thus would be
|
# Contains flags that we want to apply not only to Chromium APKs, but also to
|
||||||
# appropriate for third-party apps to include.
|
# third-party apps that bundle the Cronet library.
|
||||||
|
|
||||||
# Allow unused native methods to be removed, but prevent renaming on those that are kept.
|
# WARNING: rules in this file are applied to entire third-party APKs, not just
|
||||||
-keepclasseswithmembernames,includedescriptorclasses,allowaccessmodification class !cr_allowunused,** {
|
# Chromium code. They MUST be scoped appropriately to avoid side effects on app
|
||||||
native <methods>;
|
# code that we do not own.
|
||||||
}
|
|
||||||
|
|
||||||
# Use assumevalues block instead of assumenosideeffects block because Google3 proguard cannot parse
|
# Use assumevalues block instead of assumenosideeffects block because Google3
|
||||||
# assumenosideeffects blocks which overwrite return value.
|
# proguard cannot parse assumenosideeffects blocks which overwrite return
|
||||||
# chromium_code.flags rather than remove_logging.flags so that it's included
|
# value. Keep this in shared_with_cronet.flags rather than remove_logging.flags
|
||||||
# in cronet.
|
# so that it's included in cronet.
|
||||||
-assumevalues class org.chromium.base.Log {
|
-assumevalues class org.chromium.base.Log {
|
||||||
static boolean isDebug() return false;
|
static boolean isDebug() return false;
|
||||||
}
|
}
|
||||||
|
@ -37,21 +36,10 @@
|
||||||
public static **[] values();
|
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.
|
# Required to remove fields until b/274802355 is resolved.
|
||||||
-assumevalues class !cr_allowunused,** {
|
-assumevalues class !cr_allowunused,** {
|
||||||
final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_;
|
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 --------
|
# -------- Config Path: build/android/chromium_annotations.flags --------
|
||||||
# Copyright 2022 The Chromium Authors
|
# Copyright 2022 The Chromium Authors
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
@ -113,6 +101,22 @@
|
||||||
-identifiernamestring class * {
|
-identifiernamestring class * {
|
||||||
@org.chromium.build.annotations.IdentifierNameString *;
|
@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 --------
|
# -------- Config Path: components/cronet/android/cronet_impl_common_proguard.cfg --------
|
||||||
# Proguard config for apps that depend on cronet_impl_common_java.jar.
|
# Proguard config for apps that depend on cronet_impl_common_java.jar.
|
||||||
|
|
||||||
|
@ -227,3 +231,10 @@
|
||||||
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
|
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
|
||||||
@org.jni_zero.CalledByNativeUnchecked <methods>;
|
@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**
|
**2024/02/27**
|
||||||
|
* 更新cronet: 126.0.6478.72
|
||||||
* 更新cronet: 123.0.6312.80
|
* 更新cronet: 123.0.6312.80
|
||||||
* 更新cronet: 123.0.6312.40
|
* 更新cronet: 123.0.6312.40
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
import java.security.MessageDigest
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -748,45 +749,68 @@ interface JsExtensions : JsEncodeUtils {
|
||||||
//******************文件操作************************//
|
//******************文件操作************************//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析字体,返回字体解析类
|
* 解析字体Base64数据,返回字体解析类
|
||||||
*/
|
*/
|
||||||
fun queryBase64TTF(base64: String?): QueryTTF? {
|
fun queryBase64TTF(data: String?): QueryTTF? {
|
||||||
base64DecodeToByteArray(base64)?.let {
|
log("queryBase64TTF(String)方法已过时,并将在未来删除;请无脑使用queryTTF(Any)替代,新方法支持传入 url、本地文件、base64、ByteArray 自动判断&自动缓存,特殊情况需禁用缓存请传入第二可选参数false:Boolean")
|
||||||
return QueryTTF(it)
|
return queryTTF(data)
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回字体解析类
|
* 返回字体解析类
|
||||||
* @param str 支持url,本地文件,base64,自动判断,自动缓存
|
* @param data 支持url,本地文件,base64,ByteArray,自动判断,自动缓存
|
||||||
|
* @param useCache 可选开关缓存,不传入该值默认开启缓存
|
||||||
*/
|
*/
|
||||||
fun queryTTF(str: String?): QueryTTF? {
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
str ?: return null
|
fun queryTTF(data: Any?, useCache: Boolean): QueryTTF? {
|
||||||
try {
|
try {
|
||||||
val key = md5Encode16(str)
|
var key: String? = null
|
||||||
var qTTF = CacheManager.getQueryTTF(key)
|
var qTTF: QueryTTF?
|
||||||
if (qTTF != null) return qTTF
|
when (data) {
|
||||||
val font: ByteArray? = when {
|
is String -> {
|
||||||
str.isAbsUrl() -> AnalyzeUrl(str, source = getSource()).getByteArray()
|
if (useCache) {
|
||||||
str.isContentScheme() -> Uri.parse(str).readBytes(appCtx)
|
key = MessageDigest.getInstance("SHA-256").digest(data.toByteArray()).toHexString()
|
||||||
str.startsWith("/storage") -> File(str).readBytes()
|
qTTF = CacheManager.getQueryTTF(key)
|
||||||
else -> base64DecodeToByteArray(str)
|
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
|
if (key != null) CacheManager.put(key, qTTF)
|
||||||
qTTF = QueryTTF(font)
|
|
||||||
CacheManager.put(key, qTTF) // debug注释掉
|
|
||||||
return qTTF
|
return qTTF
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
AppLog.put("获取字体处理类出错", e)
|
AppLog.put("[queryTTF] 获取字体处理类出错", e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun queryTTF(data: Any?): QueryTTF? {
|
||||||
|
return queryTTF(data, true)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param text 包含错误字体的内容
|
* @param text 包含错误字体的内容
|
||||||
* @param errorQueryTTF 错误的字体
|
* @param errorQueryTTF 错误的字体
|
||||||
* @param correctQueryTTF 正确的字体
|
* @param correctQueryTTF 正确的字体
|
||||||
|
* @param filter 删除 errorQueryTTF 中不存在的字符
|
||||||
*/
|
*/
|
||||||
fun replaceFont(
|
fun replaceFont(
|
||||||
text: String,
|
text: String,
|
||||||
|
@ -802,8 +826,9 @@ interface JsExtensions : JsEncodeUtils {
|
||||||
if (errorQueryTTF.isBlankUnicode(oldCode)) {
|
if (errorQueryTTF.isBlankUnicode(oldCode)) {
|
||||||
return@forEachIndexed
|
return@forEachIndexed
|
||||||
}
|
}
|
||||||
val glyf = errorQueryTTF.getGlyfByUnicode(oldCode)
|
|
||||||
// 删除轮廓数据不存在的字符
|
// 删除轮廓数据不存在的字符
|
||||||
|
var glyf = errorQueryTTF.getGlyfByUnicode(oldCode) // 轮廓数据不存在
|
||||||
|
if (errorQueryTTF.getGlyfIdByUnicode(oldCode) == 0) glyf = null // 轮廓数据指向保留索引0
|
||||||
if (filter && (glyf == null)) {
|
if (filter && (glyf == null)) {
|
||||||
contentArray[index] = ""
|
contentArray[index] = ""
|
||||||
return@forEachIndexed
|
return@forEachIndexed
|
||||||
|
@ -817,6 +842,11 @@ interface JsExtensions : JsEncodeUtils {
|
||||||
return contentArray.joinToString("")
|
return contentArray.joinToString("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text 包含错误字体的内容
|
||||||
|
* @param errorQueryTTF 错误的字体
|
||||||
|
* @param correctQueryTTF 正确的字体
|
||||||
|
*/
|
||||||
fun replaceFont(
|
fun replaceFont(
|
||||||
text: String,
|
text: String,
|
||||||
errorQueryTTF: QueryTTF?,
|
errorQueryTTF: QueryTTF?,
|
||||||
|
|
|
@ -685,6 +685,7 @@ public class QueryTTF {
|
||||||
int unicodeInclusive = 0;
|
int unicodeInclusive = 0;
|
||||||
int unicodeExclusive = f.glyphIdArray.length;
|
int unicodeExclusive = f.glyphIdArray.length;
|
||||||
for (; unicodeInclusive < unicodeExclusive; unicodeInclusive++) {
|
for (; unicodeInclusive < unicodeExclusive; unicodeInclusive++) {
|
||||||
|
if (f.glyphIdArray[unicodeInclusive] == 0) continue; // 排除轮廓索引为0的Unicode
|
||||||
unicodeToGlyphId.put(unicodeInclusive, f.glyphIdArray[unicodeInclusive]);
|
unicodeToGlyphId.put(unicodeInclusive, f.glyphIdArray[unicodeInclusive]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -711,12 +712,15 @@ public class QueryTTF {
|
||||||
int idDelta = f.idDelta[segmentIndex];
|
int idDelta = f.idDelta[segmentIndex];
|
||||||
int idRangeOffset = f.idRangeOffsets[segmentIndex];
|
int idRangeOffset = f.idRangeOffsets[segmentIndex];
|
||||||
for (int unicode = unicodeInclusive; unicode <= unicodeExclusive; unicode++) {
|
for (int unicode = unicodeInclusive; unicode <= unicodeExclusive; unicode++) {
|
||||||
|
int glyphId = 0;
|
||||||
if (idRangeOffset == 0) {
|
if (idRangeOffset == 0) {
|
||||||
unicodeToGlyphId.put(unicode, (unicode + idDelta) & 0xFFFF);
|
glyphId = (unicode + idDelta) & 0xFFFF;
|
||||||
} else {
|
} else {
|
||||||
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex;
|
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex - segCount;
|
||||||
unicodeToGlyphId.put(unicode, gIndex < glyphIdArrayLength ? f.glyphIdArray[gIndex] + idDelta : 0);
|
if (gIndex < glyphIdArrayLength) glyphId = f.glyphIdArray[gIndex] + idDelta;
|
||||||
}
|
}
|
||||||
|
if (glyphId == 0) continue; // 排除轮廓索引为0的Unicode
|
||||||
|
unicodeToGlyphId.put(unicode, glyphId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -773,12 +777,12 @@ public class QueryTTF {
|
||||||
var dataTable = directorys.get("glyf");
|
var dataTable = directorys.get("glyf");
|
||||||
assert dataTable != null;
|
assert dataTable != null;
|
||||||
int glyfCount = maxp.numGlyphs;
|
int glyfCount = maxp.numGlyphs;
|
||||||
glyfArray = new GlyfLayout[glyfCount + 1]; // 创建容器时,多创建一个作为保留区
|
glyfArray = new GlyfLayout[glyfCount]; // 创建字形容器
|
||||||
|
|
||||||
var reader = new BufferReader(buffer, 0);
|
var reader = new BufferReader(buffer, 0);
|
||||||
for (int index = 1; index <= glyfCount; index++) {
|
for (int index = 0; index < glyfCount; index++) {
|
||||||
if (loca[index - 1] == loca[index]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
if (loca[index] == loca[index + 1]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
||||||
int offset = dataTable.offset + loca[index - 1];
|
int offset = dataTable.offset + loca[index];
|
||||||
// 读GlyphHeaders
|
// 读GlyphHeaders
|
||||||
var glyph = new GlyfLayout();
|
var glyph = new GlyfLayout();
|
||||||
reader.position(offset);
|
reader.position(offset);
|
||||||
|
@ -893,7 +897,7 @@ public class QueryTTF {
|
||||||
if ((glyphTableComponent.flags & 0x20) == 0) break;
|
if ((glyphTableComponent.flags & 0x20) == 0) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glyfArray[index] = glyph; // 根据文档 glyfId=0 作为保留区使用,这里赋值从索引1开始
|
glyfArray[index] = glyph;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +923,15 @@ public class QueryTTF {
|
||||||
// 复合字形
|
// 复合字形
|
||||||
LinkedList<String> glyphIdList = new LinkedList<>();
|
LinkedList<String> glyphIdList = new LinkedList<>();
|
||||||
for (var g : glyph.glyphComponent) {
|
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) + "]";
|
glyphString = "[" + String.join(",", glyphIdList) + "]";
|
||||||
}
|
}
|
||||||
|
@ -965,10 +977,11 @@ public class QueryTTF {
|
||||||
int glyfArrayLength = glyfArray.length;
|
int glyfArrayLength = glyfArray.length;
|
||||||
for (var item : unicodeToGlyphId.entrySet()) {
|
for (var item : unicodeToGlyphId.entrySet()) {
|
||||||
int key = item.getKey();
|
int key = item.getKey();
|
||||||
int val = item.getValue() + 1; // glyphArray已根据TTF文档将索引0作为保留位,这里从1开始索引
|
int val = item.getValue();
|
||||||
if (val >= glyfArrayLength) continue;
|
if (val >= glyfArrayLength) continue;
|
||||||
String glyfString = getGlyfById(val);
|
String glyfString = getGlyfById(val);
|
||||||
unicodeToGlyph.put(key, glyfString);
|
unicodeToGlyph.put(key, glyfString);
|
||||||
|
if (glyfString == null) continue; // null 不能用作hashmap的key
|
||||||
glyphToUnicode.put(glyfString, key);
|
glyphToUnicode.put(glyfString, key);
|
||||||
}
|
}
|
||||||
// Log.i("QueryTTF", "字体处理完成");
|
// Log.i("QueryTTF", "字体处理完成");
|
||||||
|
@ -986,8 +999,8 @@ public class QueryTTF {
|
||||||
*/
|
*/
|
||||||
public int getGlyfIdByUnicode(int unicode) {
|
public int getGlyfIdByUnicode(int unicode) {
|
||||||
var result = unicodeToGlyphId.get(unicode);
|
var result = unicodeToGlyphId.get(unicode);
|
||||||
if (result == null) return 0;
|
if (result == null) return 0; // 如果找不到Unicode对应的轮廓索引,就返回默认值0
|
||||||
return result + 1; // 根据TTF文档,轮廓索引的定义从1开始
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1008,7 +1021,7 @@ public class QueryTTF {
|
||||||
*/
|
*/
|
||||||
public int getUnicodeByGlyf(String glyph) {
|
public int getUnicodeByGlyf(String glyph) {
|
||||||
var result = glyphToUnicode.get(glyph);
|
var result = glyphToUnicode.get(glyph);
|
||||||
if (result == null) return 0;
|
if (result == null) return 0; // 如果轮廓数据找不到对应的Unicode,就返回默认值0
|
||||||
return result;
|
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.
|
# and none from the library's dependencies, thereby reducing the size of the R class for that library.
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
# https://chromiumdash.appspot.com/releases?platform=Android
|
# https://chromiumdash.appspot.com/releases?platform=Android
|
||||||
CronetVersion=123.0.6312.80
|
CronetVersion=126.0.6478.72
|
||||||
CronetMainVersion=123.0.0.0
|
CronetMainVersion=126.0.0.0
|
||||||
android.injected.testOnly=false
|
android.injected.testOnly=false
|
||||||
android.nonFinalResIds=true
|
android.nonFinalResIds=true
|
Loading…
Reference in New Issue
Block a user