aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-09-20 13:11:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-20 13:11:01 -0700
commit4ecf0d484373b806b41f7ff1747ed380ee3be817 (patch)
tree8e2fa3976210840ef62c2aa57f748d0c428ca847
parent7517e45e78f1ddae86cae255d36f54732eac4f89 (diff)
GM: add test for type1 font
-rw-r--r--gm/typeface.cpp66
-rw-r--r--resources/fonts/Roboto2-Regular.pfa133
-rw-r--r--resources/fonts/Roboto2-Regular.pfbbin0 -> 4956 bytes
3 files changed, 171 insertions, 28 deletions
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 8303b37358..4ed3956986 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -154,25 +154,13 @@ private:
typedef skiagm::GM INHERITED;
};
-class TypefaceRenderingGM : public skiagm::GM {
- sk_sp<SkTypeface> fFace;
-
-protected:
- void onOnceBeforeDraw() override {
- fFace = MakeResourceAsTypeface("/fonts/hintgasp.ttf");
- }
-
- SkString onShortName() override {
- SkString name("typefacerendering");
- name.append(sk_tool_utils::major_platform_os_name());
- return name;
- }
+DEF_GM( return new TypefaceStylesGM(false); )
+DEF_GM( return new TypefaceStylesGM(true); )
- SkISize onISize() override {
- return SkISize::Make(640, 680);
- }
+////////////////////////////////////////////////////////////////////////////////
- void onDraw(SkCanvas* canvas) override {
+static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
+ char character = 'A') {
struct AliasType {
bool antiAlias;
bool subpixelAntitalias;
@@ -226,7 +214,7 @@ protected:
constexpr bool rotateABitTypes[] = { false, true };
SkPaint paint;
- paint.setTypeface(fFace);
+ paint.setTypeface(face);
paint.setEmbeddedBitmapText(true);
SkScalar x = 0;
@@ -260,10 +248,12 @@ protected:
canvas->rotate(2, x + subpixel.offset.x(),
y + subpixel.offset.y());
}
- canvas->drawText("A", 1, x + subpixel.offset.x(),
- y + subpixel.offset.y(), paint);
+ canvas->drawText(&character, 1,
+ x + subpixel.offset.x(),
+ y + subpixel.offset.y(), paint);
- SkScalar dx = SkScalarCeilToScalar(paint.measureText("A", 1)) + 5;
+ SkScalar dx = SkScalarCeilToScalar(
+ paint.measureText(&character, 1)) + 5;
x += dx;
xMax = SkTMax(x, xMax);
}
@@ -273,14 +263,34 @@ protected:
}
xBase = xMax;
}
+}
+
+DEF_SIMPLE_GM_BG_NAME(typefacerendering, canvas, 640, 680, SK_ColorWHITE,
+ SkStringPrintf("typefacerendering%s",
+ sk_tool_utils::major_platform_os_name().c_str())) {
+ if (sk_sp<SkTypeface> face = MakeResourceAsTypeface("/fonts/hintgasp.ttf")) {
+ draw_typeface_rendering_gm(canvas, std::move(face));
}
+}
-private:
- typedef skiagm::GM INHERITED;
-};
+// Type1 fonts don't currently work in Skia on Windows.
+#ifndef SK_BUILD_FOR_WIN
+
+DEF_SIMPLE_GM_BG_NAME(typefacerendering_pfa, canvas, 640, 680, SK_ColorWHITE,
+ SkStringPrintf("typefacerendering_pfa%s",
+ sk_tool_utils::major_platform_os_name().c_str())) {
+ if (sk_sp<SkTypeface> face = MakeResourceAsTypeface("fonts/Roboto2-Regular.pfa")) {
+ // This subsetted typeface doesn't have the character 'A'.
+ draw_typeface_rendering_gm(canvas, std::move(face), 'O');
+ }
+}
-///////////////////////////////////////////////////////////////////////////////
+DEF_SIMPLE_GM_BG_NAME(typefacerendering_pfb, canvas, 640, 680, SK_ColorWHITE,
+ SkStringPrintf("typefacerendering_pfb%s",
+ sk_tool_utils::major_platform_os_name().c_str())) {
+ if (sk_sp<SkTypeface> face = MakeResourceAsTypeface("fonts/Roboto2-Regular.pfb")) {
+ draw_typeface_rendering_gm(canvas, std::move(face), 'O');
+ }
+}
-DEF_GM( return new TypefaceStylesGM(false); )
-DEF_GM( return new TypefaceStylesGM(true); )
-DEF_GM( return new TypefaceRenderingGM(); )
+#endif
diff --git a/resources/fonts/Roboto2-Regular.pfa b/resources/fonts/Roboto2-Regular.pfa
new file mode 100644
index 0000000000..fe714f57ee
--- /dev/null
+++ b/resources/fonts/Roboto2-Regular.pfa
@@ -0,0 +1,133 @@
+%!PS-AdobeFont-1.0: Roboto2-Regular 2.000981-w3; 2014; ttfautohint (v1.1) -l 5 -r 24 -G 0 -x 11 -D latn -f grek -w gG
+%%Title: Roboto2-Regular
+%Version: 2.000981-w3; 2014; ttfautohint (v1.1) -l 5 -r 24 -G 0 -x 11 -D latn -f grek -w gG
+%%CreationDate: Fri Sep 16 15:10:48 2016
+%%Creator: Hal Canary
+%Copyright: Font data copyright Google 2014
+% Generated by FontForge 20120731 (http://fontforge.sf.net/)
+%%EndComments
+
+10 dict begin
+/FontType 1 def
+/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def
+/FontName /Roboto2-Regular def
+/FontBBox {15 -151 892 782 }readonly def
+/PaintType 0 def
+/FontInfo 11 dict dup begin
+ /version (2.000981-w3; 2014; ttfautohint (v1.1) -l 5 -r 24 -G 0 -x 11 -D latn -f grek -w gG) readonly def
+ /Notice (Font data copyright Google 2014) readonly def
+ /FullName (Roboto2) readonly def
+ /FamilyName (Roboto2) readonly def
+ /Weight (Book) readonly def
+ /FSType 0 def
+ /ItalicAngle 0 def
+ /isFixedPitch false def
+ /UnderlinePosition -48 def
+ /UnderlineThickness 48 def
+ /ascent 750 def
+end readonly def
+/Encoding StandardEncoding def
+currentdict end
+currentfile eexec
+69D900414434C93D12731064FD536C430F04FEB120E0FC88BB9F3FD77491D6FFFBB3112B
+0F384F17754AFC439FDF2548F3F269F10A9F35552B8FB25F773A111E7C92B4E939EE3DDC
+5D894466C7E0D83ABD55ADD51B7C63F62EC98BC6A6611787DEAE27E245F888FD1008F8E3
+C6A6AE392C9CFE2393CE097D4AD9F0CBCB1094FE9CD29B2F2FE490775E8E80E6B07FAAFA
+3B7A5719330902A7849CE145E2936F54EB0746BF944F08EB18CB8663BAC28C52707920ED
+FAA30B80077900D3FF9B4FF0E6970B6384FAB1C57D57F93DD12C85A21399885A70C3051A
+534A75E565B4889B69BE360CF66CBC51A5777B6AF3670193F8A5034B6708A56538E6D2F9
+9DCCDB1C399F2BAA7DA70E6631FD97471CD9D8406D111FD9FC29B975BDFF04959D4552B5
+6AB63B54C05B04140C1D584564FAD7FF4A9CBC257E302F520BA4F8CD89D7CF47AED8E5B2
+7F7AE90E2C7F48919AA02A40EC126F5A6932F6308590799EDF60A1581DCA89FF04F786E6
+CE861912EBEA2748022D84C626B6EB0EA26E2B211A8F031AFAE8097B4C1F91280B63B644
+BFBB9DC73AAD68946482720AA7B4547FF1E801D07CA623D75346837235F9515FBAF55FBE
+7F23A0DB9D27C74B068B8560E21667FC3536DECDA966630EDF58E3F163E04476058BB8A5
+F71C8062055D4730A5B0F38BF9739F8DBF0FA93100CB0E96C1299D9420271938254413CC
+95BAAE06528C02340410E50B3063C430D62CBFFA40991F486616252580CAF43F5514B32F
+4541473AC90F167B325AEE13E2A5F15B21FFFA56B86B9CD9C84E0DDB98FCECFCB312338F
+F9A3CB0C724C21C10531EC97CA8C80E646EC80D786CE7BCDBAFC765B5CC8DF7FC1792470
+ED95AD2681AF11D441FE5AD380BDE9028E0ED830CC646E011DB856B950E74F451CD79407
+8059DCDD7D69950D890C36559B85C44DBB2D7F3C3D22D02BB2A5A272728FBD9C6DB033F6
+E50E1DCB2717946FFFF9B117C01C390C312D3738D6F06493ED32E471554519A6E6F989D2
+79899F037A0C6581963668697D8F3E3E8A257253A7069222754B983CDF73481EC171275F
+F1852619C325E17212B45CF0DF0644B2E16BD3BE399B8750C26FA3B5B3424608FBEC881E
+F325D36256E07D6265B76D54C3BB744E73FB27AFF25832F1FD6FEE889EABDFFFA23C2DAB
+B342792A64FBCF2AA036C73C4F7C6C1C8CA33BCCF5C8EC8D254CA7B3F63708B630B3ADCA
+193097B4F8328056A746C9A83572BA421B0B68F4B049D3284D79AE77924CB2B82D4E3CD2
+19CB8940F1080EF0D7A7DEEEC5D0B0D5BBCFC06DCDB9D389C551BFF567386FABF149D6C8
+866EDCF8C096795320100F981325DB2EC840B2908546E76F3C48D65B093CF5D1E2FB8596
+0C52B4D4A3C9CD012477B29B1951AC9CC4B05338ADF923F7633617CFC429F62E24002464
+69AC44EDBE7FC845DDA868BCBE0A40896368E7B5508A1BF9544BFEE39CB351915FFD5697
+FE4A076BC7AAE7F33A98A003E83426614F6CA86FDF35972787558DEF13FAEE0DEE57F906
+8B216D4083DCC3F2D595945244C637ACD19E724BC0418485BC4043747ECA19E425266F5D
+97FE2ECFE65315D4D9DA73D58AFCEE1EE61EFF3EA7B1CF8DF6421C27E75328309030D1F3
+CEFC52F92091A794C91952097033DE661FC857C5F5ADA8F56DE484994069D8EDE9316F97
+BBA65E65B1352A141041DE7820EDC9F7D497DDCDD2B7F736C9C163DC2F1AE8AA160CF74C
+7007DB573EEE5377DAD5871DDF2ABCDCA27A255EE00369BC65E5496170CD1A7073F4AC45
+6D1DAB670855318D3ED58D2A57C1E0D029B759FED65882E7713117B9B7DDCDAD0328E7B8
+48B0016BE5A99AA73B279D06952C8977A027D07CB8F0FB56A84C347E647702B09C986BD3
+673F3F08CC0281D593906FB523A5BF239DCE25D0D2842B87C04C53B330019373E4DB1BE2
+A626C9E41284FBB35DFAC32B95A166BA72E8C1AF6C113F23491BFD6093B68E685822BE25
+3878EED1AA83F07050384CFD1802A4BF628A4106AC0509CC34A39C114A8326258CAD4C0D
+CF01C50413047150ED01BEFF433735F5218E12EA4166673657956E5A43388A60EB8786A4
+DDDA0FF232FB4882B63BDB57B194AD09E200FA01BCE68DEC06E7C29B7847DEA595FF8BCB
+68B902E07E3079391C2DD2B7FFE740C0F0A1691DC44F42694139D75EB9E21266F12F72B4
+F65C8E1AA8872682726B3DB94132EF57D255C8AF7AC4DB09917F3CC9F035B3074B15BEFF
+9E7A598CE24925D66D25F54372F00C67542177511D2B268EFF714CC79A3DAFECD02DBA0E
+5BE0D680D8543B0C3551BB37856EE548848225CE5FDD727FFB7EBDDC69B51309537CE8FB
+E4BDCE2AC7F6206EB7C760A991EA47B2A96721E5E058922DEC592C16BB7B13F5C83136D5
+864B3FC7B8F1DD68523291F1504276636AA1A66B5B049D1BB1FBF252B1D5BBAAE26B960B
+85E26022B799CB30BADBB27CBA989EF7DB3EDFEA2E14354887A487D587062A3B9A2CBCD9
+8A6B1B55188888ECB4A314A3720E258DB5B38074AA25F114835D6DC00AD80215791F5D6E
+395D09453D2600A93C9E0C54785E0CDBD204F4D8550ADE6C055C65014B70BD1BFD8CA062
+2009745E87C77E6413053ED867E90D9FE8D47551CC3774C5A7E039DB620DF82AABB0CB9A
+AC763B6CBA5F6DC4878AB9EAB119CF49681E3F838892708052ABEE0A7CB1FB429415AADB
+480401CBE314976F64590BDF65F35CC576C45CD730A2F40380F77EE1AE8A3702406DC95B
+1F57C0D279CF1CFD47AF9FBB994BB35DEF4208600B23DF1B84B762FA3A8E0E36830BED1F
+B82A2322873F80D016268CA24C5C3DDA2A98FB09E086AD67DDEB7048DB97BE272BCD7C85
+7E5AABC2918EDD2AEF80DB3F23440746D9B2E80D589539E12D378E459B3CB5802DCD4BED
+1597B6EBB47C5916C1F22DB213D7AB145E8B08AF28A995EC26025FB79E5DC702D91A3003
+3B61CA9785B9E06E0E6F6E97BDBF183DA3CE7AD137CC910B6D69282E6D9C4E7F28F6490B
+24B53A76690D08CD42417EAA003F6111B5EC0EEA34544835C8C401E018F177EC0C2D7D78
+F7A88818A08429A56A3DC4FF0D882B32FA6E5406AEEA7FE41A6CCCE6BA6589B19AE3BF83
+C7CCB86D159DC0020AFA31D5931E00EABC22EDCDD986871E51CC16FF67E97F2C6FE91BCD
+E5BD6505B36F3B96113F493C309B2130CF057F19F44A27375DB534D5F75FC3B3211EA04F
+6ED2FD342F6F055450241865A8105B986CFF5BE491A10D8EA93A5DFF49E90170EB532D1D
+EC99C3F1A58C3D90FCA28A14B31F0AB5F2C3A05D3699EE4611BC26AF3F32D8B3F5744F0C
+107C610F050024952B7BA7765437488477327EC53FA8F3B637713A1AAC94448A28F7C379
+B25FB5D6AB0B7F289F492DB8478D17FB64328D1B15988C2C4D650501A6A37BD44A9DD176
+97AD8FE5ABD5039B90400C8C3F4BF4E6AEF854826996B9741D2D0E6C9F8A6138DA975428
+C3B735B990CAE0B0EDD0A3645357FB9A2C64595B43FBDBD985B98F8AF3FFA835BB9EC8D7
+1972D3E667618B5EF0CBDEEA65325A23755C923A3BD7F5EB7ACD69E2EC99B0CD0E64A48B
+694AEC64D0BC2D1141F556A2F760019C5F215ACA744FE3C8366B46C1987040BECABBCDC4
+B7D5939D54681CDAD0E39366574D9BEAB768F35E0E1FA8DF2CCD7CC879FC2BFF341129EB
+EDF4506A47AB5DF71B0BF1C71817A43F0778CE90381887631161203F702ABB8A57FCBA2E
+E2FB5584369B203B79FAC5E39A7AA7C28CB744C2B32B7945F21EDE2FCF073F3A483F77B3
+DA36F7C5F7CD8307315A7DB3D3624B8BC8ECECEBB4160757E320B4309BBB14CCFB73F927
+9C5A3EEB610F370B86D9B321E52CB583DD10746FD73D556F58FBE14AB44692D483815F0E
+28B9AE95B90F2CDC583E7630326F7C66A77D5F77996924C3F92B4FA1CFA4566BC870796B
+010D03040C8B82BEEBC39C6657F935CF841E1CC86A940F9796C524C4F55B7E62FAAB089C
+3DAF483065676E9FDFD587C79797F4703F0A5A4D2E34C502EC518EE2CBB7F6715B66FE7C
+28441D1773E5A37B43F79179DB04E9330EC6109B231A0D4D8A8C84B41504EA4DAE249229
+149D4BF8E9A415079B64B968B1B88F0B3C87AF471467BD8C6E78EE0E03C89B404B96424E
+A7B293786AA2074FDA85BD6588AABFB4972854CD5156993156252CA71ECC9D94446946FE
+4B4E8A236879E88386D7A668DFCAE2448C6BEA1AEB8257BA92A19754D244BE06698890E8
+4BF28ABDD280782C0B48ECDFE9A031F8A025F27CF7CEB51778FCAC4DEDA3D129BAEB8BE3
+9F4CDD7DA06D09B8B62FB4BD1C844B0844789E4D104CF3553FF6C2E8B4408E3C3CDD4635
+EDF9F97EF24F54BB2C21DA8A61618ECD06DD9475DEBBE42D54BD9A3A330A346E89131739
+0F769B065AFDEFBAF3252E03FB8A2CDC266B5C779F685BC4DEB105C8BC0009185A7CA296
+EEB34D94B9E64DB52AA2C89EADC686AC2DAFE9AB9283F148A02A1A915709FBE09C56C97C
+CB358277EA316E217477FA577DFA067828B38BE618FEA2BB747E70BB576E2ACB13E6DE5E
+3635F7B61CDD4633E5A6C479F5A9D1230DC2E635A15EAA944BE84D4B83F1B1777BD6684E
+782670A3F4C65ED63C7CC8F7EBB3CE092AA21D4F1E91AF1D4D8037D83316A5FA87E3069F
+ED76C6DC9BF11F5D53E3612C293452B815B8BE6BE07FF33688514EB1DD82D69FE1573E24
+2CA7
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
diff --git a/resources/fonts/Roboto2-Regular.pfb b/resources/fonts/Roboto2-Regular.pfb
new file mode 100644
index 0000000000..154adae962
--- /dev/null
+++ b/resources/fonts/Roboto2-Regular.pfb
Binary files differ