mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
feat(提升性能): 减少无效粗体检查,提升文字渲染性能
This commit is contained in:
1 parent
565b7f6db4
commit
0fd4954547
2 files changed
+5
-2
No files matched your search
+4
-1
@@ -318,8 +318,11 @@ func fontDefaultSystemNames() []string {
|
|||||||
func fontNoSyntheticBold(names ...string) bool {
|
func fontNoSyntheticBold(names ...string) bool {
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
for _, rule := range fontMatchRules {
|
for _, rule := range fontMatchRules {
|
||||||
|
if !rule.NoSyntheticBold {
|
||||||
|
continue
|
||||||
|
}
|
||||||
level := fontRuleMatchLevel(rule, name)
|
level := fontRuleMatchLevel(rule, name)
|
||||||
if rule.NoSyntheticBold && level >= fontMatchExact && level <= fontMatchPartial {
|
if level >= fontMatchExact && level <= fontMatchPartial {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
|
|||||||
embeddedFont := false
|
embeddedFont := false
|
||||||
if of, ok := r.Reader.fontCache[fontID]; ok {
|
if of, ok := r.Reader.fontCache[fontID]; ok {
|
||||||
embeddedFont = of.FontFile != ""
|
embeddedFont = of.FontFile != ""
|
||||||
if !embeddedFont && fontNoSyntheticBold(of.FontName, of.FamilyName) {
|
if syntheticBold && !embeddedFont && fontNoSyntheticBold(of.FontName, of.FamilyName) {
|
||||||
syntheticBold = false
|
syntheticBold = false
|
||||||
}
|
}
|
||||||
if of.Bold {
|
if of.Bold {
|
||||||
|
|||||||
Reference in new issue
Block a user