Repository navigation
fix(pdfium): resolve installed CJK fonts referenced by PostScript name #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,13 @@ void* CFX_LinuxFontInfo::MapFont(int weight, | |
| break; | ||
| } | ||
| case FX_CHARSET_ChineseSimplified: { | ||
| // 优先按请求的族名精确匹配,而不是直接落入硬编码回退列表:PDF 常以 | ||
| // 某个已安装 CJK 字体的族名引用它(例如 "FZXiaoBiaoSong-B05S"), | ||
| // 该名字往往不在下方任何旧回退列表中;若不先做精确匹配,下方列表 | ||
| // 会无条件替换为列表中第一个找到的字体,完全忽略请求的族名。 | ||
| auto exact_it = m_FontList.find(family); | ||
| if (exact_it != m_FontList.end()) | ||
|
Comment on lines
+121
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Installed Japanese font is ignored When a PDF requests ShiftJIS text in an installed Japanese family that is absent from the hardcoded Japanese fallback lists, Check Prompt for AI agentsIn `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp` at lines 121-122:
**Installed Japanese font is ignored**
When a PDF requests ShiftJIS text in an installed Japanese family that is absent from the hardcoded Japanese fallback lists, `MapFont()` searches `g_LinuxJpFontList` without checking `m_FontList` for the requested family, so it selects a generic fallback instead of the installed font.
Check `m_FontList` for the requested family before searching the Japanese fallback lists. |
||
| return exact_it->second.get(); | ||
|
Comment on lines
+122
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High · CJK text loses glyphs When a requested CJK family is installed but its face lacks the requested charset, Return the exact match only when it supports the requested charset; otherwise continue to the CJK fallback list. Also at Prompt for AI agentsIn `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp` at lines 122-123:
**CJK text loses glyphs**
When a requested CJK family is installed but its face lacks the requested charset, `MapFont()` returns `exact_it` without checking charset support, bypassing the CJK fallback list and rendering the text with a face that lacks the required glyphs.
Return the exact match only when it supports the requested charset; otherwise continue to the CJK fallback list.
Also at `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp:133-135`, `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp:145-147`.
Comment on lines
+121
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Requested font style is ignored When the family has an exact regular face and the request calls for a different weight or italic style, the exact-family branch returns the regular face without considering Apply the requested weight and italic style when selecting an exact-family match. Also at Prompt for AI agentsIn `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp` at lines 121-123:
**Requested font style is ignored**
When the family has an exact regular face and the request calls for a different weight or italic style, the exact-family branch returns the regular face without considering `weight` or `bItalic`, even when the requested styled face is installed.
Apply the requested weight and italic style when selecting an exact-family match.
Also at `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp:133-135`, `3rdparty/deepin-pdfium/src/3rdparty/pdfium/pdfium/core/fxge/fx_ge_linux.cpp:145-147`. |
||
| for (const char* name : g_LinuxGbFontList) { | ||
| auto it = m_FontList.find(name); | ||
| if (it != m_FontList.end()) | ||
|
|
@@ -122,6 +129,10 @@ void* CFX_LinuxFontInfo::MapFont(int weight, | |
| break; | ||
| } | ||
| case FX_CHARSET_ChineseTraditional: { | ||
| // 参见上方 FX_CHARSET_ChineseSimplified 分支的注释。 | ||
| auto exact_it = m_FontList.find(family); | ||
| if (exact_it != m_FontList.end()) | ||
| return exact_it->second.get(); | ||
| for (const char* name : g_LinuxB5FontList) { | ||
| auto it = m_FontList.find(name); | ||
| if (it != m_FontList.end()) | ||
|
|
@@ -130,6 +141,10 @@ void* CFX_LinuxFontInfo::MapFont(int weight, | |
| break; | ||
| } | ||
| case FX_CHARSET_Hangul: { | ||
| // 参见上方 FX_CHARSET_ChineseSimplified 分支的注释。 | ||
| auto exact_it = m_FontList.find(family); | ||
| if (exact_it != m_FontList.end()) | ||
| return exact_it->second.get(); | ||
| for (const char* name : g_LinuxHGFontList) { | ||
| auto it = m_FontList.find(name); | ||
| if (it != m_FontList.end()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · PostScript font name is not indexed
When an external provider cannot resolve an ASCII family through
GetFont()but can open it throughMapFont(),AddInstalledFont()callsMapFont()only whenbLocalizedis true, so it never reads the font’s differing PostScript name and requests using that name fail to resolve to the installed family.Try
MapFont()whenGetFont()returns null for an ASCII family as well.Prompt for AI agents