Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1613)

Unified Diff: core/fxge/apple/fx_mac_imp.cpp

Issue 2119983002: Mac: Improve font substitution. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/apple/fx_mac_imp.cpp
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp
index 4ddc7db8ad56bbe1bde3e4d0fd2fd8e4c70469f8..8940896901f28700ada40243cf77f74ef869dbe6 100644
--- a/core/fxge/apple/fx_mac_imp.cpp
+++ b/core/fxge/apple/fx_mac_imp.cpp
@@ -67,10 +67,27 @@ void* CFX_MacFontInfo::MapFont(int weight,
face = g_Base14Substs[i].m_pSubstName;
iExact = TRUE;
return GetFont(face.c_str());
- break;
}
}
+ // The request may not ask for the bold and/or italic version of a font by
+ // name. So try to construct the appropriate name. This is not 100% foolproof
+ // as there are fonts that have "Oblique" or "BoldOblique" or "Heavy" in their
+ // names instead. But this at least works for common fonts like Arial and
+ // Times New Roman. A more sophisticated approach would be to find all the
+ // fonts in |m_FontList| with |face| in the name, and examine the fonts to
+ // see which best matches the requested characteristics.
+ if (face.Find("Bold") == -1 && face.Find("Italic") == -1) {
+ CFX_ByteString new_face = face;
+ if (weight > 400)
+ new_face += " Bold";
+ if (bItalic)
+ new_face += " Italic";
+ auto it = m_FontList.find(new_face);
+ if (it != m_FontList.end())
+ return it->second;
+ }
+
auto it = m_FontList.find(face);
if (it != m_FontList.end())
return it->second;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698