本文整理汇总了C++中SkString::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::resize方法的具体用法?C++ SkString::resize怎么用?C++ SkString::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseConfigFile
/**
* This function parses the given filename and stores the results in the given
* families array.
*/
static void parseConfigFile(const char *filename, SkTDArray<FontFamily*> &families) {
FILE* file = NULL;
#if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
// if we are using a version of Android prior to Android 4.2 (JellyBean MR1
// at API Level 17) then we need to look for files with a different suffix.
char sdkVersion[PROP_VALUE_MAX];
__system_property_get("ro.build.version.sdk", sdkVersion);
const int sdkVersionInt = atoi(sdkVersion);
if (0 != *sdkVersion && sdkVersionInt < 17) {
SkString basename;
SkString updatedFilename;
SkString locale = SkFontConfigParser::GetLocale();
basename.set(filename);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
// Try first with language and region
updatedFilename.printf("%s-%s.xml", basename.c_str(), locale.c_str());
file = fopen(updatedFilename.c_str(), "r");
if (!file) {
// If not found, try next with just language
updatedFilename.printf("%s-%.2s.xml", basename.c_str(), locale.c_str());
file = fopen(updatedFilename.c_str(), "r");
}
}
#endif
if (NULL == file) {
file = fopen(filename, "r");
}
// Some of the files we attempt to parse (in particular, /vendor/etc/fallback_fonts.xml)
// are optional - failure here is okay because one of these optional files may not exist.
if (NULL == file) {
return;
}
XML_Parser parser = XML_ParserCreate(NULL);
FamilyData *familyData = new FamilyData(&parser, families);
XML_SetUserData(parser, familyData);
XML_SetElementHandler(parser, startElementHandler, endElementHandler);
char buffer[512];
bool done = false;
while (!done) {
fgets(buffer, sizeof(buffer), file);
int len = strlen(buffer);
if (feof(file) != 0) {
done = true;
}
XML_Parse(parser, buffer, len, done);
}
XML_ParserFree(parser);
fclose(file);
}
示例2: openLocalizedFile
/**
* Use the current system locale (language and region) to open the best matching
* customization. For example, when the language is Japanese, the sequence might be:
* /system/etc/fallback_fonts-ja-JP.xml
* /system/etc/fallback_fonts-ja.xml
* /system/etc/fallback_fonts.xml
*/
FILE* openLocalizedFile(const char* origname) {
FILE* file = 0;
#if !defined(SK_BUILD_FOR_ANDROID_NDK)
SkString basename;
SkString filename;
char language[3] = "";
char region[3] = "";
basename.set(origname);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
getLocale(language, region);
// Try first with language and region
filename.printf("%s-%s-%s.xml", basename.c_str(), language, region);
file = fopen(filename.c_str(), "r");
if (!file) {
// If not found, try next with just language
filename.printf("%s-%s.xml", basename.c_str(), language);
file = fopen(filename.c_str(), "r");
}
#endif
if (!file) {
// If still not found, try just the original name
file = fopen(origname, "r");
}
return file;
}
示例3: Deserialize
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
load_system_fonts();
int style = stream->readU8();
int len = stream->readPackedUInt();
if (len > 0) {
SkString str;
str.resize(len);
stream->read(str.writable_str(), len);
const FontInitRec* rec = gSystemFonts;
for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
if (strcmp(rec[i].fFileName, str.c_str()) == 0) {
// backup until we hit the fNames
for (int j = i; j >= 0; --j) {
if (rec[j].fNames != NULL) {
return SkFontHost::CreateTypeface(NULL,
rec[j].fNames[0], (SkTypeface::Style)style);
}
}
}
}
}
return NULL;
}
示例4: openLocalizedFile
/**
* Use the current system locale (language and region) to open the best matching
* customization. For example, when the language is Japanese, the sequence might be:
* /system/etc/fallback_fonts-ja-JP.xml
* /system/etc/fallback_fonts-ja.xml
* /system/etc/fallback_fonts.xml
*/
FILE* openLocalizedFile(const char* origname) {
FILE* file = 0;
SkString basename;
SkString filename;
AndroidLocale locale;
basename.set(origname);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
getLocale(locale);
// Try first with language and region
filename.printf("%s-%s-%s.xml", basename.c_str(), locale.language, locale.region);
file = fopen(filename.c_str(), "r");
if (!file) {
// If not found, try next with just language
filename.printf("%s-%s.xml", basename.c_str(), locale.language);
file = fopen(filename.c_str(), "r");
if (!file) {
// If still not found, try just the original name
file = fopen(origname, "r");
}
}
return file;
}
示例5: loadKernelStream
bool SkCLImageDiffer::loadKernelStream(SkStream* stream, const char name[], cl_kernel* kernel) {
// Read the kernel source into memory
SkString sourceString;
sourceString.resize(stream->getLength());
size_t bytesRead = stream->read(sourceString.writable_str(), sourceString.size());
if (bytesRead != sourceString.size()) {
SkDebugf("Failed to read kernel source file");
return false;
}
return loadKernelSource(sourceString.c_str(), name, kernel);
}
示例6: addAttributeLen
void SkXMLWriter::addAttributeLen(const char name[], const char value[], size_t length) {
SkString valueStr;
if (fDoEscapeMarkup) {
size_t extra = escape_markup(nullptr, value, length);
if (extra) {
valueStr.resize(length + extra);
(void)escape_markup(valueStr.writable_str(), value, length);
value = valueStr.c_str();
length += extra;
}
}
this->onAddAttributeLen(name, value, length);
}
示例7: outputScalar
void SkDebugCanvas::outputScalar(SkScalar num) {
if (num == (int) num) {
fClipStackData.appendf("%d", (int) num);
} else {
SkString str;
str.printf("%1.9g", num);
int width = (int) str.size();
const char* cStr = str.c_str();
while (cStr[width - 1] == '0') {
--width;
}
str.resize(width);
fClipStackData.appendf("%sf", str.c_str());
}
}
示例8: output_scalar
static void output_scalar(SkScalar num) {
if (num == (int) num) {
SkDebugf("%d", (int) num);
} else {
SkString str;
str.printf("%1.9g", num);
int width = (int) str.size();
const char* cStr = str.c_str();
while (cStr[width - 1] == '0') {
--width;
}
str.resize(width);
SkDebugf("%sf", str.c_str());
}
}