Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
FuzzCOLRv1.cpp File Reference
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypeface.h"
#include "tools/fonts/FontToolUtils.h"
#include <algorithm>

Go to the source code of this file.

Functions

void FuzzCOLRv1 (const uint8_t *data, size_t size)
 

Function Documentation

◆ FuzzCOLRv1()

void FuzzCOLRv1 ( const uint8_t *  data,
size_t  size 
)

Definition at line 19 of file FuzzCOLRv1.cpp.

19 {
20 // We do not want the portable fontmgr here, as it does not allow creation of fonts from bytes.
22 std::unique_ptr<SkStreamAsset> stream = SkMemoryStream::MakeDirect(data, size);
23 sk_sp<SkTypeface> typeface = mgr->makeFromStream(std::move(stream), 0);
24
25 if (!typeface) {
26 return;
27 }
28
30 if (!s) {
31 return;
32 }
33
34 // Place at a baseline in the lower part of the canvas square, but canvas size and baseline
35 // placement are chosen arbitrarily and we just need to cover colrv1 rendering in this
36 // fuzz test.
37 SkFont colrv1Font = SkFont(typeface, 120);
38 SkCanvas* canvas = s->getCanvas();
40 int numGlyphs = typeface->countGlyphs();
41
42 for (int i = 0; i < std::min(numGlyphs, 10); ++i) {
43 SkPoint origin = SkPoint::Make(10, 108);
44 SkPoint position = SkPoint::Make(0, 0);
45 SkGlyphID glyphId = i;
46 canvas->drawGlyphs(1, &glyphId, &position, origin, colrv1Font, paint);
47 }
48}
uint16_t SkGlyphID
Definition SkTypes.h:179
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
static std::unique_ptr< SkMemoryStream > MakeDirect(const void *data, size_t length)
Definition SkStream.cpp:310
const Paint & paint
struct MyStruct s
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkFontMgr > TestFontMgr()
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkPoint Make(float x, float y)