Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkTypeface_FreeType::FaceRec Class Reference

Public Member Functions

 ~FaceRec ()
 

Static Public Member Functions

static std::unique_ptr< FaceRecMake (const SkTypeface_FreeType *typeface)
 

Public Attributes

SkUniqueFTFace fFace
 
FT_StreamRec fFTStream
 
std::unique_ptr< SkStreamAssetfSkStream
 
FT_UShort fFTPaletteEntryCount = 0
 
std::unique_ptr< SkColor[]> fSkPalette
 

Detailed Description

Definition at line 202 of file SkFontHost_FreeType.cpp.

Constructor & Destructor Documentation

◆ ~FaceRec()

SkTypeface_FreeType::FaceRec::~FaceRec ( )

Definition at line 282 of file SkFontHost_FreeType.cpp.

282 {
283 f_t_mutex().assertHeld();
284 fFace.reset(); // Must release face before the library, the library frees existing faces.
285 unref_ft_library();
286}
static SkMutex & f_t_mutex()

Member Function Documentation

◆ Make()

std::unique_ptr< SkTypeface_FreeType::FaceRec > SkTypeface_FreeType::FaceRec::Make ( const SkTypeface_FreeType typeface)
static

Definition at line 372 of file SkFontHost_FreeType.cpp.

372 {
373 f_t_mutex().assertHeld();
374
375 std::unique_ptr<SkFontData> data = typeface->makeFontData();
376 if (nullptr == data || !data->hasStream()) {
377 return nullptr;
378 }
379
380 std::unique_ptr<FaceRec> rec(new FaceRec(data->detachStream()));
381
382 FT_Open_Args args;
383 memset(&args, 0, sizeof(args));
384 const void* memoryBase = rec->fSkStream->getMemoryBase();
385 if (memoryBase) {
386 args.flags = FT_OPEN_MEMORY;
387 args.memory_base = (const FT_Byte*)memoryBase;
388 args.memory_size = rec->fSkStream->getLength();
389 } else {
390 args.flags = FT_OPEN_STREAM;
391 args.stream = &rec->fFTStream;
392 }
393
394 {
395 FT_Face rawFace;
396 FT_Error err = FT_Open_Face(gFTLibrary->library(), &args, data->getIndex(), &rawFace);
397 if (err) {
398 SK_TRACEFTR(err, "unable to open font '%x'", (uint32_t)typeface->uniqueID());
399 return nullptr;
400 }
401 rec->fFace.reset(rawFace);
402 }
403 SkASSERT(rec->fFace);
404
405 rec->setupAxes(*data);
406 rec->setupPalette(*data);
407
408 // FreeType will set the charmap to the "most unicode" cmap if it exists.
409 // If there are no unicode cmaps, the charmap is set to nullptr.
410 // However, "symbol" cmaps should also be considered "fallback unicode" cmaps
411 // because they are effectively private use area only (even if they aren't).
412 // This is the last on the fallback list at
413 // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
414 if (!rec->fFace->charmap) {
415 FT_Select_Charmap(rec->fFace.get(), FT_ENCODING_MS_SYMBOL);
416 }
417
418 return rec;
419}
#define SkASSERT(cond)
Definition SkAssert.h:116
static FreeTypeLibrary * gFTLibrary
#define SK_TRACEFTR(ERR,...)
struct FT_FaceRec_ * FT_Face
std::unique_ptr< SkFontData > makeFontData() const
SkTypefaceID uniqueID() const
Definition SkTypeface.h:101
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

Member Data Documentation

◆ fFace

SkUniqueFTFace SkTypeface_FreeType::FaceRec::fFace

Definition at line 204 of file SkFontHost_FreeType.cpp.

◆ fFTPaletteEntryCount

FT_UShort SkTypeface_FreeType::FaceRec::fFTPaletteEntryCount = 0

Definition at line 207 of file SkFontHost_FreeType.cpp.

◆ fFTStream

FT_StreamRec SkTypeface_FreeType::FaceRec::fFTStream

Definition at line 205 of file SkFontHost_FreeType.cpp.

◆ fSkPalette

std::unique_ptr<SkColor[]> SkTypeface_FreeType::FaceRec::fSkPalette

Definition at line 208 of file SkFontHost_FreeType.cpp.

◆ fSkStream

std::unique_ptr<SkStreamAsset> SkTypeface_FreeType::FaceRec::fSkStream

Definition at line 206 of file SkFontHost_FreeType.cpp.


The documentation for this class was generated from the following file: