remove platform_font_name()
It's used rarely and now that we're mostly using portable fonts, it only serves to confuse. Sans-serif doesn't seem to work anyway. Simplify gm/typeface.cpp to just test the default typeface. Change-Id: I091239ea91af9d9e01d3c76280636a6061b5fb5c Reviewed-on: https://skia-review.googlesource.com/71261 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
9592817042
commit
cb9fc4160e
@ -19,11 +19,6 @@ static sk_sp<SkShader> make_heatGradient(const SkPoint pts[2]) {
|
||||
SkShader::kClamp_TileMode);
|
||||
}
|
||||
|
||||
static bool setFont(SkPaint* paint, const char name[]) {
|
||||
paint->setTypeface(SkTypeface::MakeFromName(name, SkFontStyle()));
|
||||
return SkToBool(paint->getTypeface());
|
||||
}
|
||||
|
||||
/**
|
||||
Test a set of clipping problems discovered while writing blitAntiRect,
|
||||
and test all the code paths through the clipping blitters.
|
||||
@ -69,7 +64,6 @@ protected:
|
||||
size_t len = strlen(text);
|
||||
|
||||
SkPaint paint;
|
||||
setFont(&paint, sk_tool_utils::platform_font_name("serif"));
|
||||
paint.setTextSize(SkIntToScalar(16));
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLCDRenderText(true);
|
||||
|
@ -73,28 +73,17 @@ static void drawKernText(SkCanvas* canvas, const void* text, size_t len,
|
||||
canvas->drawPosText(glyphs, glyphCount * sizeof(uint16_t), pos, glyphPaint);
|
||||
}
|
||||
|
||||
constexpr struct {
|
||||
const char* fName;
|
||||
SkFontStyle fStyle;
|
||||
} gFaceStyles[] = {
|
||||
{ "sans-serif", SkFontStyle::Normal() },
|
||||
{ "sans-serif", SkFontStyle::Bold() },
|
||||
{ "sans-serif", SkFontStyle::Italic() },
|
||||
{ "sans-serif", SkFontStyle::BoldItalic() },
|
||||
{ "serif", SkFontStyle::Normal() },
|
||||
{ "serif", SkFontStyle::Bold() },
|
||||
{ "serif", SkFontStyle::Italic() },
|
||||
{ "serif", SkFontStyle::BoldItalic() },
|
||||
{ "monospace", SkFontStyle::Normal() },
|
||||
{ "monospace", SkFontStyle::Bold() },
|
||||
{ "monospace", SkFontStyle::Italic() },
|
||||
{ "monospace", SkFontStyle::BoldItalic() },
|
||||
static constexpr SkFontStyle gStyles[] = {
|
||||
SkFontStyle::Normal(),
|
||||
SkFontStyle::Bold(),
|
||||
SkFontStyle::Italic(),
|
||||
SkFontStyle::BoldItalic(),
|
||||
};
|
||||
|
||||
constexpr int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
|
||||
constexpr int gStylesCount = SK_ARRAY_COUNT(gStyles);
|
||||
|
||||
class TypefaceStylesGM : public skiagm::GM {
|
||||
sk_sp<SkTypeface> fFaces[gFaceStylesCount];
|
||||
sk_sp<SkTypeface> fFaces[gStylesCount];
|
||||
bool fApplyKerning;
|
||||
|
||||
public:
|
||||
@ -105,9 +94,8 @@ public:
|
||||
|
||||
protected:
|
||||
void onOnceBeforeDraw() override {
|
||||
for (int i = 0; i < gFaceStylesCount; i++) {
|
||||
fFaces[i] = SkTypeface::MakeFromName(
|
||||
sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFaceStyles[i].fStyle);
|
||||
for (int i = 0; i < gStylesCount; i++) {
|
||||
fFaces[i] = SkTypeface::MakeFromName(nullptr, gStyles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +129,7 @@ protected:
|
||||
} else {
|
||||
paint.setLinearText(true);
|
||||
}
|
||||
for (int i = 0; i < gFaceStylesCount; i++) {
|
||||
for (int i = 0; i < gStylesCount; i++) {
|
||||
paint.setTypeface(fFaces[i]);
|
||||
canvas->drawText(text, textLen, x, y, paint);
|
||||
if (fApplyKerning) {
|
||||
|
@ -24,10 +24,8 @@ protected:
|
||||
void onOnceBeforeDraw() override {
|
||||
const int pointSize = 24;
|
||||
textHeight = SkIntToScalar(pointSize);
|
||||
fProp = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("sans-serif"),
|
||||
SkFontStyle());
|
||||
fMono = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("monospace"),
|
||||
SkFontStyle());
|
||||
fProp = SkTypeface::MakeFromName("sans-serif", SkFontStyle());
|
||||
fMono = SkTypeface::MakeFromName("monospace", SkFontStyle());
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
|
@ -22,16 +22,6 @@
|
||||
|
||||
namespace sk_tool_utils {
|
||||
|
||||
/* these are the default fonts chosen by Chrome for serif, sans-serif, and monospace */
|
||||
static const char* gStandardFontNames[][3] = {
|
||||
{ "Times", "Helvetica", "Courier" }, // Mac
|
||||
{ "Times New Roman", "Helvetica", "Courier" }, // iOS
|
||||
{ "Times New Roman", "Arial", "Courier New" }, // Win
|
||||
{ "Times New Roman", "Arial", "Monospace" }, // Ubuntu
|
||||
{ "serif", "sans-serif", "monospace" }, // Android
|
||||
{ "Tinos", "Arimo", "Cousine" } // ChromeOS
|
||||
};
|
||||
|
||||
static bool starts_with(const char* str, const char* prefix) {
|
||||
return 0 == strncmp(str, prefix, strlen(prefix));
|
||||
}
|
||||
@ -45,41 +35,6 @@ static const char* platform_os_name() {
|
||||
return "";
|
||||
}
|
||||
|
||||
const char* platform_font_name(const char* name) {
|
||||
int index;
|
||||
if (!strcmp(name, "serif")) {
|
||||
index = 0;
|
||||
} else if (!strcmp(name, "san-serif")) {
|
||||
index = 1;
|
||||
} else if (!strcmp(name, "monospace")) {
|
||||
index = 2;
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char* platform = platform_os_name();
|
||||
|
||||
if (starts_with(platform, "Mac")) {
|
||||
return gStandardFontNames[0][index];
|
||||
}
|
||||
if (starts_with(platform, "iOS")) {
|
||||
return gStandardFontNames[1][index];
|
||||
}
|
||||
if (starts_with(platform, "Win")) {
|
||||
return gStandardFontNames[2][index];
|
||||
}
|
||||
if (starts_with(platform, "Ubuntu") || starts_with(platform, "Debian")) {
|
||||
return gStandardFontNames[3][index];
|
||||
}
|
||||
if (starts_with(platform, "Android")) {
|
||||
return gStandardFontNames[4][index];
|
||||
}
|
||||
if (starts_with(platform, "ChromeOS")) {
|
||||
return gStandardFontNames[5][index];
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const char* platform_os_emoji() {
|
||||
const char* osName = platform_os_name();
|
||||
if (starts_with(osName, "Android") ||
|
||||
|
@ -56,11 +56,6 @@ namespace sk_tool_utils {
|
||||
*/
|
||||
const char* platform_font_manager();
|
||||
|
||||
/**
|
||||
* Map serif, san-serif, and monospace to the platform-specific font name.
|
||||
*/
|
||||
const char* platform_font_name(const char* name);
|
||||
|
||||
/**
|
||||
* Sets the paint to use a platform-independent text renderer
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user