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

Unified Diff: third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp

Issue 2017533002: Simplify OpenType caps feature detection logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp
index de00748ea59c8a4a3d943d536de3e1d297ea96f4..3aab5b09f53dcdd49b60e705a876c4b9ab55f778 100644
--- a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp
+++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp
@@ -29,52 +29,37 @@ bool OpenTypeCapsSupport::supportsOpenTypeFeature(
|| tag == HB_TAG('u', 'n', 'i', 'c')
|| tag == HB_TAG('v', 'e', 'r', 't')));
- bool result = false;
-
if (!hb_ot_layout_has_substitution(face))
return false;
// Get the OpenType tag(s) that match this script code
- const size_t kMaxScriptTags = 4;
- hb_tag_t scriptTags[kMaxScriptTags] = {
+ hb_tag_t scriptTags[] = {
HB_TAG_NONE,
HB_TAG_NONE,
HB_TAG_NONE,
- HB_TAG_NONE
};
hb_ot_tags_from_script(static_cast<hb_script_t>(script),
&scriptTags[0],
&scriptTags[1]);
- // Replace the first remaining NONE with DEFAULT
- for (size_t i = 0; i < kMaxScriptTags; ++i) {
- if (scriptTags[i] == HB_TAG_NONE) {
- scriptTags[i] = HB_OT_TAG_DEFAULT_SCRIPT;
- break;
- }
- }
-
- // Now check for 'smcp' under the first of those scripts that is present
const hb_tag_t kGSUB = HB_TAG('G', 'S', 'U', 'B');
- for (size_t j = 0; j < kMaxScriptTags; ++j) {
- if (scriptTags[j] == HB_TAG_NONE)
- break;
+ unsigned scriptIndex = 0;
+ // Identify for which script a GSUB table is available.
+ if (!hb_ot_layout_table_choose_script(face,
+ kGSUB,
+ scriptTags,
+ &scriptIndex,
+ nullptr)) {
+ return false;
drott 2016/05/26 08:14:05 This was not in your original suggestion. I guess
behdad 2016/05/27 17:33:29 No no. The return value means something else. It
+ }
- unsigned scriptIndex;
- if (hb_ot_layout_table_find_script(face,
- kGSUB,
- scriptTags[j],
- &scriptIndex)) {
- if (hb_ot_layout_language_find_feature(face, kGSUB,
- scriptIndex,
- HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
- tag, nullptr)) {
- result = true;
- }
- break;
- }
+ if (hb_ot_layout_language_find_feature(face, kGSUB,
+ scriptIndex,
+ HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
+ tag, nullptr)) {
+ return true;
}
- return result;
+ return false;
}
} // namespace blink
« 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