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

Side by Side Diff: src/core/SkPaintOptionsAndroid.cpp

Issue 14761003: API modifications needed to upstream Android font changes. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: refactored for upstream Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2012 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "SkPaintOptionsAndroid.h"
10
11 #ifdef SK_BUILD_FOR_ANDROID // currently only for Android
12
13 #include "SkTDict.h"
14 #include "SkThread.h"
15 #include <cstring>
16
17 SkLanguage SkLanguage::getParent() const {
18 SkASSERT(fInfo != NULL);
19 const char* tag = fInfo->fTag.c_str();
20 SkASSERT(tag != NULL);
21
22 // strip off the rightmost "-.*"
23 char* parentTagEnd = strrchr(tag, '-');
24 if (parentTagEnd == NULL) {
25 return SkLanguage("");
26 }
27 size_t parentTagLen = parentTagEnd - tag;
28 char parentTag[parentTagLen + 1];
29 strncpy(parentTag, tag, parentTagLen);
30 parentTag[parentTagLen] = '\0';
31 return SkLanguage(parentTag);
32 }
33
34 SK_DECLARE_STATIC_MUTEX(gGetInfoMutex);
35 const SkLanguageInfo* SkLanguage::getInfo(const char* tag) {
36 SkAutoMutexAcquire lock(gGetInfoMutex);
37
38 static const size_t kDictSize = 128;
39 static SkTDict<SkLanguageInfo*> tagToInfo(kDictSize);
40
41 // try a lookup
42 SkLanguageInfo* info;
43 if (tagToInfo.find(tag, &info)) {
44 return info;
45 }
46
47 // no match - add this language
48 info = new SkLanguageInfo(tag);
49 tagToInfo.set(tag, info);
50 return info;
51 }
52
53 #endif
OLDNEW
« include/core/SkPaint.h ('K') | « src/core/SkPaint.cpp ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698