本文整理汇总了C++中SkTDArray::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTDArray::reset方法的具体用法?C++ SkTDArray::reset怎么用?C++ SkTDArray::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTDArray
的用法示例。
在下文中一共展示了SkTDArray::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFamilies
void
SkFontData::loadXml( SkTDArray<FontInitRec> &info )
{
SkTDArray<FontFamily*> families;
getFamilies( families );
info.reset();
for( int i = 0 ; i < families.count() ; ++i )
{
FontFamily * family = families[i];
for( int j = 0 ; j < family->fFontFileArray.count() ; ++j )
{
const char * filename = family->fFontFileArray[j]->fFileName;
#ifndef DEPRECATED_CODE
HyLogif( "DEPRECATED_CODE" );
if( haveSystemFont( filename ) )
continue;
#endif
FontInitRec fontInfoRecord;
fontInfoRecord.fFileName = filename;
if( j == 0 )
{
if( family->fNames.count() == 0 )
fontInfoRecord.fNames = ( char ** )gFBNames; // fallback.
else
{
SkTDArray<const char*> names = family->fNames;
const char ** nameList = ( const char ** )calloc( ( names.count() + 1 ), sizeof( char * ) );
if( nameList == NULL )
{
break;
}
for( int n = 0 ; n < names.count() ; ++n )
{
nameList[n] = names[n];
}
nameList[names.count()] = NULL;
fontInfoRecord.fNames = nameList;
}
}
else
{
fontInfoRecord.fNames = NULL;
}
*info.append() = fontInfoRecord;
}
}
families.deleteAll();
}
示例2: fontData
static sk_sp<SkPDFStream> get_subset_font_stream(
std::unique_ptr<SkStreamAsset> fontAsset,
const SkBitSet& glyphUsage,
const char* fontName,
int ttcIndex) {
// Generate glyph id array in format needed by sfntly.
// TODO(halcanary): sfntly should take a more compact format.
SkTDArray<unsigned> subset;
if (!glyphUsage.has(0)) {
subset.push(0); // Always include glyph 0.
}
glyphUsage.exportTo(&subset);
unsigned char* subsetFont{nullptr};
sk_sp<SkData> fontData(stream_to_data(std::move(fontAsset)));
#if defined(SK_BUILD_FOR_GOOGLE3)
// TODO(halcanary): update SK_BUILD_FOR_GOOGLE3 to newest version of Sfntly.
(void)ttcIndex;
int subsetFontSize = SfntlyWrapper::SubsetFont(fontName,
fontData->bytes(),
fontData->size(),
subset.begin(),
subset.count(),
&subsetFont);
#else
(void)fontName;
int subsetFontSize = SfntlyWrapper::SubsetFont(ttcIndex,
fontData->bytes(),
fontData->size(),
subset.begin(),
subset.count(),
&subsetFont);
#endif
fontData.reset();
subset.reset();
SkASSERT(subsetFontSize > 0 || subsetFont == nullptr);
if (subsetFontSize < 1) {
return nullptr;
}
SkASSERT(subsetFont != nullptr);
auto subsetStream = sk_make_sp<SkPDFStream>(
SkData::MakeWithProc(
subsetFont, subsetFontSize,
[](const void* p, void*) { delete[] (unsigned char*)p; },
nullptr));
subsetStream->dict()->insertInt("Length1", subsetFontSize);
return subsetStream;
}