当前位置: 首页>>代码示例>>C++>>正文


C++ SkTDArray::reset方法代码示例

本文整理汇总了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();
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例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;
}
开发者ID:molikto,项目名称:Skia,代码行数:48,代码来源:SkPDFFont.cpp


注:本文中的SkTDArray::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。