1515 */
1616
1717#include " flutter/fml/logging.h"
18- #include " gmock/gmock.h"
1918#include " gtest/gtest.h"
2019#include " third_party/skia/include/utils/SkCustomTypeface.h"
2120#include " txt/font_collection.h"
@@ -34,64 +33,67 @@ void PopulateUserTypeface(SkCustomTypefaceBuilder* builder) {
3433 constexpr float upem = 200 ;
3534
3635 {
37- SkFontMetrics metrics;
38- metrics.fFlags = 0 ;
39- metrics.fTop = -200 ;
40- metrics.fAscent = -150 ;
41- metrics.fDescent = 50 ;
42- metrics.fBottom = -75 ;
43- metrics.fLeading = 10 ;
44- metrics.fAvgCharWidth = 150 ;
45- metrics.fMaxCharWidth = 300 ;
46- metrics.fXMin = -20 ;
47- metrics.fXMax = 290 ;
48- metrics.fXHeight = -100 ;
49- metrics.fCapHeight = 0 ;
50- metrics.fUnderlineThickness = 5 ;
51- metrics.fUnderlinePosition = 2 ;
52- metrics.fStrikeoutThickness = 5 ;
53- metrics.fStrikeoutPosition = -50 ;
54- builder->setMetrics (metrics, 1 .0f / upem);
55- }
36+ SkFontMetrics metrics;
37+ metrics.fFlags = 0 ;
38+ metrics.fTop = -200 ;
39+ metrics.fAscent = -150 ;
40+ metrics.fDescent = 50 ;
41+ metrics.fBottom = -75 ;
42+ metrics.fLeading = 10 ;
43+ metrics.fAvgCharWidth = 150 ;
44+ metrics.fMaxCharWidth = 300 ;
45+ metrics.fXMin = -20 ;
46+ metrics.fXMax = 290 ;
47+ metrics.fXHeight = -100 ;
48+ metrics.fCapHeight = 0 ;
49+ metrics.fUnderlineThickness = 5 ;
50+ metrics.fUnderlinePosition = 2 ;
51+ metrics.fStrikeoutThickness = 5 ;
52+ metrics.fStrikeoutPosition = -50 ;
53+ builder->setMetrics (metrics, 1 .0f / upem);
54+ }
5655
57- const SkMatrix scale = SkMatrix::Scale (1 .0f / upem, 1 .0f / upem);
58- for (SkGlyphID index = 0 ; index <= 67 ; ++index) {
59- SkScalar width;
60- width = 100 ;
61- SkPath path;
62- path.addCircle (50 , -50 , 75 );
56+ const SkMatrix scale = SkMatrix::Scale (1 .0f / upem, 1 .0f / upem);
57+ for (SkGlyphID index = 0 ; index <= 67 ; ++index) {
58+ SkScalar width;
59+ width = 100 ;
60+ SkPath path;
61+ path.addCircle (50 , -50 , 75 );
6362
64- builder->setGlyph (index, width/upem, path.makeTransform (scale));
65- }
66- }
63+ builder->setGlyph (index, width / upem, path.makeTransform (scale));
64+ }
6765}
66+ } // namespace
6867
6968TEST (FontCollectionTest, CheckSkTypefacesSorting) {
7069 // We have to make a real SkTypeface here. Not all the structs from the
7170 // SkTypeface headers are fully declared to be able to gmock.
7271 // SkCustomTypefaceBuilder is the simplest way to get a simple SkTypeface.
7372 SkCustomTypefaceBuilder typefaceBuilder1;
74- typefaceBuilder1.setFontStyle (SkFontStyle (SkFontStyle::kThin_Weight , SkFontStyle::kExpanded_Width ,
75- SkFontStyle::kItalic_Slant ));
73+ typefaceBuilder1.setFontStyle (SkFontStyle (SkFontStyle::kThin_Weight ,
74+ SkFontStyle::kExpanded_Width ,
75+ SkFontStyle::kItalic_Slant ));
7676 // For the purpose of this test, we need to fill this to make the SkTypeface
7777 // build but it doesn't matter. We only care about the SkFontStyle.
7878 PopulateUserTypeface (&typefaceBuilder1);
7979 sk_sp<SkTypeface> typeface1{typefaceBuilder1.detach ()};
8080
8181 SkCustomTypefaceBuilder typefaceBuilder2;
82- typefaceBuilder2.setFontStyle (SkFontStyle (SkFontStyle::kLight_Weight , SkFontStyle::kNormal_Width ,
83- SkFontStyle::kUpright_Slant ));
82+ typefaceBuilder2.setFontStyle (SkFontStyle (SkFontStyle::kLight_Weight ,
83+ SkFontStyle::kNormal_Width ,
84+ SkFontStyle::kUpright_Slant ));
8485 PopulateUserTypeface (&typefaceBuilder2);
8586 sk_sp<SkTypeface> typeface2{typefaceBuilder2.detach ()};
8687
8788 SkCustomTypefaceBuilder typefaceBuilder3;
88- typefaceBuilder3.setFontStyle (SkFontStyle (SkFontStyle::kNormal_Weight , SkFontStyle::kNormal_Width ,
89- SkFontStyle::kUpright_Slant ));
89+ typefaceBuilder3.setFontStyle (SkFontStyle (SkFontStyle::kNormal_Weight ,
90+ SkFontStyle::kNormal_Width ,
91+ SkFontStyle::kUpright_Slant ));
9092 PopulateUserTypeface (&typefaceBuilder3);
9193 sk_sp<SkTypeface> typeface3{typefaceBuilder3.detach ()};
9294
9395 std::vector<sk_sp<SkTypeface>> candidateTypefaces = {typeface1, typeface2,
94- typeface3};
96+ typeface3};
9597
9698 // This sorts the vector in-place.
9799 txt::FontCollection::SortSkTypefaces (candidateTypefaces);
0 commit comments