Make SkTypeface::Style and FromOldStyle private.

These are no longer used outside of Skia, so make them private.

Change-Id: I735bb39c10553885cc6051aebddeff150ba4caa9
Reviewed-on: https://skia-review.googlesource.com/59180
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/gn/core.gni b/gn/core.gni
index ca02782..21dcff4 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -139,7 +139,6 @@
   "$_src/core/SkFont.cpp",
   "$_src/core/SkFontLCDConfig.cpp",
   "$_src/core/SkFontMgr.cpp",
-  "$_src/core/SkFontStyle.cpp",
   "$_src/core/SkFontDescriptor.cpp",
   "$_src/core/SkFontDescriptor.h",
   "$_src/core/SkFontStream.cpp",
diff --git a/include/core/SkFontStyle.h b/include/core/SkFontStyle.h
index a5e3034..b619c36 100644
--- a/include/core/SkFontStyle.h
+++ b/include/core/SkFontStyle.h
@@ -52,8 +52,6 @@
 
     constexpr SkFontStyle() : SkFontStyle{kNormal_Weight, kNormal_Width, kUpright_Slant} { }
 
-    static SkFontStyle FromOldStyle(unsigned oldStyle);
-
     bool operator==(const SkFontStyle& rhs) const {
         return fValue == rhs.fValue;
     }
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 5a82171..61620a4 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -42,17 +42,6 @@
 */
 class SK_API SkTypeface : public SkWeakRefCnt {
 public:
-    /** Style specifies the intrinsic style attributes of a given typeface
-    */
-    enum Style {
-        kNormal = 0,
-        kBold   = 0x01,
-        kItalic = 0x02,
-
-        // helpers
-        kBoldItalic = 0x03
-    };
-
     /** Returns the typeface's intrinsic style attributes. */
     SkFontStyle fontStyle() const {
         return fStyle;
@@ -318,9 +307,6 @@
     /** Sets the font style. If used, must be called in the constructor. */
     void setFontStyle(SkFontStyle style) { fStyle = style; }
 
-    friend class SkScalerContext;
-    static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
-
     virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
                                                    const SkDescriptor*) const = 0;
     virtual void onFilterRec(SkScalerContextRec*) const = 0;
@@ -363,13 +349,26 @@
     virtual void* onGetCTFontRef() const { return nullptr; }
 
 private:
-    friend class SkRandomTypeface;
-    friend class SkPDFFont;
-    friend class GrPathRendering;
-    friend class GrGLPathRendering;
-
     /** Retrieve detailed typeface metrics.  Used by the PDF backend.  */
     std::unique_ptr<SkAdvancedTypefaceMetrics> getAdvancedMetrics() const;
+    friend class SkRandomTypeface; // getAdvancedMetrics
+    friend class SkPDFFont;        // getAdvancedMetrics
+
+    /** Style specifies the intrinsic style attributes of a given typeface */
+    enum Style {
+        kNormal = 0,
+        kBold   = 0x01,
+        kItalic = 0x02,
+
+        // helpers
+        kBoldItalic = 0x03
+    };
+    static SkFontStyle FromOldStyle(Style oldStyle);
+    static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
+    friend class GrPathRendering;  // GetDefaultTypeface
+    friend class SkGlyphCache;     // GetDefaultTypeface
+    friend class SkPaint;          // GetDefaultTypeface
+    friend class SkScalerContext;  // GetDefaultTypeface
 
 private:
     SkFontID            fUniqueID;
@@ -378,9 +377,6 @@
     mutable SkOnce      fBoundsOnce;
     bool                fIsFixedPitch;
 
-    friend class SkPaint;
-    friend class SkGlyphCache;  // GetDefaultTypeface
-
     typedef SkWeakRefCnt INHERITED;
 };
 #endif
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp
index 519e8f2..14b0318 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -20,7 +20,6 @@
     // defines for names in its 'name' table.
     kFontAxes       = 0xFC,
     kFontIndex      = 0xFD,
-    kFontFileName   = 0xFE,  // Remove when MIN_PICTURE_VERSION > 41
     kSentinel       = 0xFF,
 };
 
@@ -34,14 +33,6 @@
     }
 }
 
-// Remove when MIN_PICTURE_VERSION > 41
-static void skip_string(SkStream* stream) {
-    const uint32_t length = SkToU32(stream->readPackedUInt());
-    if (length > 0) {
-        stream->skip(length);
-    }
-}
-
 static void write_string(SkWStream* stream, const SkString& string, uint32_t id) {
     if (!string.isEmpty()) {
         stream->writePackedUInt(id);
@@ -61,14 +52,9 @@
 
 bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
     size_t styleBits = stream->readPackedUInt();
-    if (styleBits <= 2) {
-        // Remove this branch when MIN_PICTURE_VERSION > 45
-        result->fStyle = SkFontStyle::FromOldStyle(styleBits);
-    } else {
-        result->fStyle = SkFontStyle((styleBits >> 16) & 0xFFFF,
-                                     (styleBits >> 8 ) & 0xFF,
-                                     static_cast<SkFontStyle::Slant>(styleBits & 0xFF));
-    }
+    result->fStyle = SkFontStyle((styleBits >> 16) & 0xFFFF,
+                                 (styleBits >> 8 ) & 0xFF,
+                                 static_cast<SkFontStyle::Slant>(styleBits & 0xFF));
 
     SkAutoSTMalloc<4, SkFixed> axis;
     size_t axisCount = 0;
@@ -94,9 +80,6 @@
             case kFontIndex:
                 index = read_uint(stream);
                 break;
-            case kFontFileName:  // Remove when MIN_PICTURE_VERSION > 41
-                skip_string(stream);
-                break;
             default:
                 SkDEBUGFAIL("Unknown id used by a font descriptor");
                 return false;
diff --git a/src/core/SkFontStyle.cpp b/src/core/SkFontStyle.cpp
deleted file mode 100644
index 996d383..0000000
--- a/src/core/SkFontStyle.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkFontStyle.h"
-#include "SkTypeface.h"
-#include "SkTypes.h"
-
-/*static*/SkFontStyle SkFontStyle::FromOldStyle(unsigned oldStyle) {
-    return SkFontStyle((oldStyle & SkTypeface::kBold) ? SkFontStyle::kBold_Weight
-                                                      : SkFontStyle::kNormal_Weight,
-                       SkFontStyle::kNormal_Width,
-                       (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_Slant
-                                                        : SkFontStyle::kUpright_Slant);
-}
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index a41e6b5..fe26c0f 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1869,7 +1869,7 @@
     // since the other process may have a different notion of default.
     SkTypeface* tf = this->getTypeface();
     if (!tf && buffer.isCrossProcess()) {
-        tf = SkTypeface::GetDefaultTypeface(SkTypeface::kNormal);
+        tf = SkTypeface::GetDefaultTypeface();
     }
 
     uint8_t flatFlags = 0;
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 0c8c4b9..d5ed70a 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -86,6 +86,14 @@
 
 }
 
+SkFontStyle SkTypeface::FromOldStyle(Style oldStyle) {
+    return SkFontStyle((oldStyle & SkTypeface::kBold) ? SkFontStyle::kBold_Weight
+                                                      : SkFontStyle::kNormal_Weight,
+                       SkFontStyle::kNormal_Width,
+                       (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_Slant
+                                                        : SkFontStyle::kUpright_Slant);
+}
+
 SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
     static SkOnce once[4];
     static sk_sp<SkTypeface> defaults[4];
@@ -93,14 +101,14 @@
     SkASSERT((int)style < 4);
     once[style]([style] {
         sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
-        auto t = fm->legacyMakeTypeface(nullptr, SkFontStyle::FromOldStyle(style));
+        auto t = fm->legacyMakeTypeface(nullptr, FromOldStyle(style));
         defaults[style] = t ? t : SkEmptyTypeface::Make();
     });
     return defaults[style].get();
 }
 
 sk_sp<SkTypeface> SkTypeface::MakeDefault() {
-    return sk_ref_sp(GetDefaultTypeface(SkTypeface::kNormal));
+    return sk_ref_sp(GetDefaultTypeface());
 }
 
 uint32_t SkTypeface::UniqueID(const SkTypeface* face) {