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

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

Issue 1882063002: Add OpenTypeCapsSupport class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@caseMapHbBufferFillerLand
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * ***** END LICENSE BLOCK ***** */
8
9 #include "platform/fonts/opentype/OpenTypeCapsSupport.h"
10
11 #include <hb-ot.h>
12
13 namespace blink {
14
15 bool OpenTypeCapsSupport::supportsOpenTypeFeature(
16 hb_script_t script,
17 uint32_t tag) const
18 {
19
20 hb_face_t* face = m_harfBuzzFace->face();
21 ASSERT(face);
22
23 ASSERT((tag == HB_TAG('s', 'm', 'c', 'p')
24 || tag == HB_TAG('c', '2', 's', 'c')
25 || tag == HB_TAG('p', 'c', 'a', 'p')
26 || tag == HB_TAG('c', '2', 'p', 'c')
27 || tag == HB_TAG('s', 'u', 'p', 's')
28 || tag == HB_TAG('s', 'u', 'b', 's')
29 || tag == HB_TAG('t', 'i', 't', 'l')
30 || tag == HB_TAG('u', 'n', 'i', 'c')
31 || tag == HB_TAG('v', 'e', 'r', 't')));
32
33 bool result = false;
34
35 if (!hb_ot_layout_has_substitution(face))
36 return false;
37
38 // Get the OpenType tag(s) that match this script code
39 const size_t kMaxScriptTags = 4;
40 hb_tag_t scriptTags[kMaxScriptTags] = {
41 HB_TAG_NONE,
42 HB_TAG_NONE,
43 HB_TAG_NONE,
44 HB_TAG_NONE
45 };
46 hb_ot_tags_from_script(static_cast<hb_script_t>(script),
47 &scriptTags[0],
48 &scriptTags[1]);
49
50 // Replace the first remaining NONE with DEFAULT
51 for (size_t i = 0; i < kMaxScriptTags; ++i) {
52 if (scriptTags[i] == HB_TAG_NONE) {
53 scriptTags[i] = HB_OT_TAG_DEFAULT_SCRIPT;
54 break;
55 }
56 }
57
58 // Now check for 'smcp' under the first of those scripts that is present
59 const hb_tag_t kGSUB = HB_TAG('G', 'S', 'U', 'B');
60 for (size_t j = 0; j < kMaxScriptTags; ++j) {
61 if (scriptTags[j] == HB_TAG_NONE)
62 break;
63
64 unsigned scriptIndex;
65 if (hb_ot_layout_table_find_script(face,
behdad 2016/04/13 05:32:50 Using hb_ot_layout_table_choose_script instead of
66 kGSUB,
67 scriptTags[j],
68 &scriptIndex)) {
69 if (hb_ot_layout_language_find_feature(face, kGSUB,
70 scriptIndex,
71 HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
72 tag, nullptr)) {
73 result = true;
74 }
75 break;
76 }
77 }
78 return result;
79 }
80
81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698