3 * Copyright 2012 The Android Open Source Project
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #include "SkPaintOptionsAndroid.h"
10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h"
16 SkLanguage SkLanguage::getParent() const {
17 SkASSERT(!fTag.isEmpty());
18 const char* tag = fTag.c_str();
20 // strip off the rightmost "-.*"
21 const char* parentTagEnd = strrchr(tag, '-');
22 if (parentTagEnd == NULL) {
25 size_t parentTagLen = parentTagEnd - tag;
26 return SkLanguage(tag, parentTagLen);
29 void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const {
30 buffer.writeUInt(fFontVariant);
31 buffer.writeString(fLanguage.getTag().c_str());
32 buffer.writeBool(fUseFontFallbacks);
35 void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) {
36 fFontVariant = (FontVariant)buffer.readUInt();
38 buffer.readString(&tag);
39 fLanguage = SkLanguage(tag);
40 fUseFontFallbacks = buffer.readBool();