Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
skiagm::FontationsTypefaceGM Class Reference
Inheritance diagram for skiagm::FontationsTypefaceGM:
skiagm::GM

Public Types

enum class  TypefaceConstruction { kMakeWithFontArguments , kCloneWithFontArguments }
 
- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 

Public Member Functions

 FontationsTypefaceGM (const char *testName, const char *testFontFilename, std::initializer_list< SkFontArguments::VariationPosition::Coordinate > specifiedVariations, TypefaceConstruction construction=TypefaceConstruction::kMakeWithFontArguments)
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

void onOnceBeforeDraw () override
 
SkString getName () const override
 
SkISize getISize () override
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 82 of file fontations.cpp.

Member Enumeration Documentation

◆ TypefaceConstruction

Enumerator
kMakeWithFontArguments 
kCloneWithFontArguments 

Definition at line 84 of file fontations.cpp.

84 {
85 kMakeWithFontArguments,
86 kCloneWithFontArguments,
87 };

Constructor & Destructor Documentation

◆ FontationsTypefaceGM()

skiagm::FontationsTypefaceGM::FontationsTypefaceGM ( const char *  testName,
const char *  testFontFilename,
std::initializer_list< SkFontArguments::VariationPosition::Coordinate specifiedVariations,
TypefaceConstruction  construction = TypefaceConstruction::kMakeWithFontArguments 
)
inline

Definition at line 88 of file fontations.cpp.

93 : fTestName(testName)
94 , fTestFontFilename(testFontFilename)
95 , fConstruction(construction) {
97 fVariationPosition.coordinateCount = specifiedVariations.size();
98 fCoordinates = std::make_unique<SkFontArguments::VariationPosition::Coordinate[]>(
99 specifiedVariations.size());
100 for (size_t i = 0; i < specifiedVariations.size(); ++i) {
101 fCoordinates[i] = std::data(specifiedVariations)[i];
102 }
103
104 fVariationPosition.coordinates = fCoordinates.get();
105 }
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void setBGColor(SkColor)
Definition: gm.cpp:159
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

Member Function Documentation

◆ getISize()

SkISize skiagm::FontationsTypefaceGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 127 of file fontations.cpp.

127{ return SkISize::Make(400, 200); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::FontationsTypefaceGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 123 of file fontations.cpp.

123 {
124 return SkStringPrintf("typeface_fontations_%s", fTestName.c_str());
125 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
const char * c_str() const
Definition: SkString.h:133

◆ onDraw()

DrawResult skiagm::FontationsTypefaceGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 129 of file fontations.cpp.

129 {
131 paint.setColor(SK_ColorBLACK);
132
133 if (!fTestTypeface) {
134 *errorMsg = "Unable to initialize typeface.";
135 return DrawResult::kSkip;
136 }
137
138 SkFont font(fTestTypeface);
139 const char32_t testText[] = U"abc";
140 size_t testTextBytesize = std::char_traits<char32_t>::length(testText) * sizeof(char32_t);
141 SkScalar x = 100;
142 SkScalar y = 150;
143
144 for (SkScalar textSize : kTextSizes) {
145 font.setSize(textSize);
146 y += font.getSpacing();
147
148 /* Draw origin marker as a green dot. */
149 paint.setColor(SK_ColorGREEN);
150 canvas->drawRect(SkRect::MakeXYWH(x, y, 2, 2), paint);
151 paint.setColor(SK_ColorBLACK);
152
153 canvas->drawSimpleText(
154 testText, testTextBytesize, SkTextEncoding::kUTF32, x, y, font, paint);
155 }
156
157 canvas->translate(100, 470);
158 dumpGlyphCount(canvas, fTestTypeface, fReportTypeface);
159 canvas->translate(0, kDumpFontSize * 1.2);
160 dumpLocalizedStrings(canvas, fTestTypeface, fReportTypeface);
161 canvas->translate(0, kDumpFontSize * 1.2);
162 dumpFamilyAndPostscriptName(canvas, fTestTypeface, fReportTypeface);
163
164 return DrawResult::kOk;
165 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
@ kUTF32
uses four byte words to represent all of Unicode
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.cpp:2413
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
Definition: SkFont.h:35
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
size_t length
double y
double x
font
Font Metadata and Metrics.
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onOnceBeforeDraw()

void skiagm::FontationsTypefaceGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 108 of file fontations.cpp.

108 {
110 fTestTypeface = SkTypeface_Make_Fontations(
111 GetResourceAsStream(fTestFontFilename),
112 SkFontArguments().setVariationDesignPosition(fVariationPosition));
113 } else {
114 fTestTypeface = SkTypeface_Make_Fontations(GetResourceAsStream(fTestFontFilename),
116 ->makeClone(SkFontArguments().setVariationDesignPosition(
117 fVariationPosition));
118 }
119 fReportTypeface =
121 }
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
Definition: Resources.cpp:31
SK_API sk_sp< SkTypeface > SkTypeface_Make_Fontations(std::unique_ptr< SkStreamAsset > fontData, const SkFontArguments &args)
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
Definition: SkTypeface.cpp:190

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