Style Change: NULL->nullptr
DOCS_PREVIEW= https://skia.org/?cl=1316233002

Review URL: https://codereview.chromium.org/1316233002
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index 3400aa9..8a8e4a1 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -77,7 +77,7 @@
                                int initValue) {
     SkFontConfigInterface::FontIdentity iden1;
 
-    size_t size0 = iden0.writeToMemory(NULL);
+    size_t size0 = iden0.writeToMemory(nullptr);
 
     SkAutoMalloc storage(size0);
     memset(storage.get(), initValue, size0);
@@ -131,8 +131,8 @@
 
 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBaseMutex* mutex) {
     SkAutoMutexAcquire ac(mutex);
-    static SkFontConfigInterfaceDirect* singleton = NULL;
-    if (singleton == NULL) {
+    static SkFontConfigInterfaceDirect* singleton = nullptr;
+    if (singleton == nullptr) {
         singleton = new SkFontConfigInterfaceDirect;
     }
     return singleton;
@@ -140,13 +140,13 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-// Returns the string from the pattern, or NULL
+// Returns the string from the pattern, or nullptr
 static const char* get_name(FcPattern* pattern, const char field[],
                             int index = 0) {
     const char* name;
     if (FcPatternGetString(pattern, field, index,
                            (FcChar8**)&name) != FcResultMatch) {
-        name = NULL;
+        name = nullptr;
     }
     return name;
 }
@@ -360,7 +360,7 @@
                      const SkString& family) {
   // Older versions of fontconfig have a bug where they cannot select
   // only scalable fonts so we have to manually filter the results.
-  FcPattern* match = NULL;
+  FcPattern* match = nullptr;
   for (int i = 0; i < font_set->nfont; ++i) {
     FcPattern* current = font_set->fonts[i];
     if (valid_pattern(current)) {
@@ -388,7 +388,7 @@
         break;
     }
     if (!acceptable_substitute)
-      return NULL;
+      return nullptr;
   }
 
   return match;
@@ -469,7 +469,7 @@
                                                       : FC_SLANT_ROMAN);
     FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
 
-    FcConfigSubstitute(NULL, pattern, FcMatchPattern);
+    FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
     FcDefaultSubstitute(pattern);
 
     // Font matching:
@@ -477,7 +477,7 @@
     //    font-family: a, b, c, serif;
     // However, fontconfig will always do its best to find *a* font when asked
     // for something so we need a way to tell if the match which it has found is
-    // "good enough" for us. Otherwise, we can return NULL which gets piped up
+    // "good enough" for us. Otherwise, we can return nullptr which gets piped up
     // and lets WebKit know to try the next CSS family name. However, fontconfig
     // configs allow substitutions (mapping "Arial -> Helvetica" etc) and we
     // wish to support that.
@@ -579,20 +579,20 @@
 
     FcPattern* pat = FcPatternCreate();
     SkAutoTCallVProc<FcPattern, FcPatternDestroy> autoDestroyPat(pat);
-    if (NULL == pat) {
-        return NULL;
+    if (nullptr == pat) {
+        return nullptr;
     }
 
     FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, (char *)0);
     SkAutoTCallVProc<FcObjectSet, FcObjectSetDestroy> autoDestroyOs(os);
-    if (NULL == os) {
-        return NULL;
+    if (nullptr == os) {
+        return nullptr;
     }
 
-    FcFontSet* fs = FcFontList(NULL, pat, os);
+    FcFontSet* fs = FcFontList(nullptr, pat, os);
     SkAutoTCallVProc<FcFontSet, FcFontSetDestroy> autoDestroyFs(fs);
-    if (NULL == fs) {
-        return NULL;
+    if (nullptr == fs) {
+        return nullptr;
     }
 
     SkTDArray<const char*> names;
@@ -630,7 +630,7 @@
     }
     FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
 
-    FcConfigSubstitute(NULL, pattern, FcMatchPattern);
+    FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
     FcDefaultSubstitute(pattern);
 
     // Font matching:
@@ -638,7 +638,7 @@
     //    font-family: a, b, c, serif;
     // However, fontconfig will always do its best to find *a* font when asked
     // for something so we need a way to tell if the match which it has found is
-    // "good enough" for us. Otherwise, we can return NULL which gets piped up
+    // "good enough" for us. Otherwise, we can return nullptr which gets piped up
     // and lets WebKit know to try the next CSS family name. However, fontconfig
     // configs allow substitutions (mapping "Arial -> Helvetica" etc) and we
     // wish to support that.
@@ -720,7 +720,7 @@
         if (!match) {
             FcPatternDestroy(pattern);
             FcFontSetDestroy(font_set);
-            return NULL;
+            return nullptr;
         }
 
         FcPatternDestroy(pattern);
diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h
index d207f08..a6dc6ca 100644
--- a/src/ports/SkFontConfigTypeface.h
+++ b/src/ports/SkFontConfigTypeface.h
@@ -48,7 +48,7 @@
             : INHERITED(style, SkTypefaceCache::NewFontID(), false)
             , fIdentity(fi)
             , fFamilyName(familyName)
-            , fLocalStream(NULL) {}
+            , fLocalStream(nullptr) {}
 
     FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* localStream)
             : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 860f320..32eafad 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -76,11 +76,11 @@
         return sk_realloc_throw(block, new_size);
     }
 };
-FT_MemoryRec_ gFTMemory = { NULL, sk_ft_alloc, sk_ft_free, sk_ft_realloc };
+FT_MemoryRec_ gFTMemory = { nullptr, sk_ft_alloc, sk_ft_free, sk_ft_realloc };
 
 class FreeTypeLibrary : SkNoncopyable {
 public:
-    FreeTypeLibrary() : fLibrary(NULL), fIsLCDSupported(false), fLCDExtra(0) {
+    FreeTypeLibrary() : fLibrary(nullptr), fIsLCDSupported(false), fLCDExtra(0) {
         if (FT_New_Library(&gFTMemory, &fLibrary)) {
             return;
         }
@@ -101,7 +101,7 @@
             FT_Library_SetLcdFilterWeights(fLibrary, gGaussianLikeHeavyWeights);
 #    elif SK_CAN_USE_DLOPEN == 1
             //The FreeType library is already loaded, so symbols are available in process.
-            void* self = dlopen(NULL, RTLD_LAZY);
+            void* self = dlopen(nullptr, RTLD_LAZY);
             if (self) {
                 FT_Library_SetLcdFilterWeightsProc setLcdFilterWeights;
                 //The following cast is non-standard, but safe for POSIX.
@@ -157,7 +157,7 @@
     SkASSERT(gFTCount >= 0);
 
     if (0 == gFTCount) {
-        SkASSERT(NULL == gFTLibrary);
+        SkASSERT(nullptr == gFTLibrary);
         gFTLibrary = new FreeTypeLibrary;
     }
     ++gFTCount;
@@ -171,9 +171,9 @@
 
     --gFTCount;
     if (0 == gFTCount) {
-        SkASSERT(NULL != gFTLibrary);
+        SkASSERT(nullptr != gFTLibrary);
         delete gFTLibrary;
-        SkDEBUGCODE(gFTLibrary = NULL;)
+        SkDEBUGCODE(gFTLibrary = nullptr;)
     }
 }
 
@@ -183,7 +183,7 @@
     virtual ~SkScalerContext_FreeType();
 
     bool success() const {
-        return fFTSize != NULL && fFace != NULL;
+        return fFTSize != nullptr && fFace != nullptr;
     }
 
 protected:
@@ -257,7 +257,7 @@
 }
 
 SkFaceRec::SkFaceRec(SkStreamAsset* stream, uint32_t fontID)
-        : fNext(NULL), fSkStream(stream), fRefCnt(1), fFontID(fontID)
+        : fNext(nullptr), fSkStream(stream), fRefCnt(1), fFontID(fontID)
 {
     sk_bzero(&fFTStream, sizeof(fFTStream));
     fFTStream.size = fSkStream->getLength();
@@ -272,7 +272,7 @@
     }
 
     SkDEBUGCODE(
-        FT_MM_Var* variations = NULL;
+        FT_MM_Var* variations = nullptr;
         if (FT_Get_MM_Var(face, &variations)) {
             SkDEBUGF(("INFO: font %s claims variations, but none found.\n", face->family_name));
             return;
@@ -314,8 +314,8 @@
     }
 
     SkAutoTDelete<SkFontData> data(typeface->createFontData());
-    if (NULL == data || !data->hasStream()) {
-        return NULL;
+    if (nullptr == data || !data->hasStream()) {
+        return nullptr;
     }
 
     // this passes ownership of stream to the rec
@@ -337,14 +337,14 @@
     if (err) {
         SkDEBUGF(("ERROR: unable to open font '%x'\n", fontID));
         delete rec;
-        return NULL;
+        return nullptr;
     }
     SkASSERT(rec->fFace);
 
     ft_face_setup_axes(rec->fFace, *data);
 
     // FreeType will set the charmap to the "most unicode" cmap if it exists.
-    // If there are no unicode cmaps, the charmap is set to NULL.
+    // If there are no unicode cmaps, the charmap is set to nullptr.
     // However, "symbol" cmaps should also be considered "fallback unicode" cmaps
     // because they are effectively private use area only (even if they aren't).
     // This is the last on the fallback list at
@@ -363,7 +363,7 @@
     gFTMutex.assertHeld();
 
     SkFaceRec*  rec = gFaceRecHead;
-    SkFaceRec*  prev = NULL;
+    SkFaceRec*  prev = nullptr;
     while (rec) {
         SkFaceRec* next = rec->fNext;
         if (rec->fFace == face) {
@@ -386,7 +386,7 @@
 
 class AutoFTAccess {
 public:
-    AutoFTAccess(const SkTypeface* tf) : fFace(NULL) {
+    AutoFTAccess(const SkTypeface* tf) : fFace(nullptr) {
         gFTMutex.acquire();
         if (!ref_ft_library()) {
             sk_throw();
@@ -458,12 +458,12 @@
         const uint32_t* glyphIDs,
         uint32_t glyphIDsCount) const {
 #if defined(SK_BUILD_FOR_MAC)
-    return NULL;
+    return nullptr;
 #else
     AutoFTAccess fta(this);
     FT_Face face = fta.face();
     if (!face) {
-        return NULL;
+        return nullptr;
     }
 
     SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
@@ -500,7 +500,7 @@
         cid = true;
         TT_Header* ttHeader;
         if ((ttHeader = (TT_Header*)FT_Get_Sfnt_Table(face,
-                                                      ft_sfnt_head)) != NULL) {
+                                                      ft_sfnt_head)) != nullptr) {
             info->fEmSize = ttHeader->Units_Per_EM;
         }
     } else {
@@ -519,7 +519,7 @@
         info->fItalicAngle = ps_info.italic_angle;
     } else if ((tt_info =
                 (TT_Postscript*)FT_Get_Sfnt_Table(face,
-                                                  ft_sfnt_post)) != NULL) {
+                                                  ft_sfnt_post)) != nullptr) {
         info->fItalicAngle = SkFixedToScalar(tt_info->italicAngle);
     } else {
         info->fItalicAngle = 0;
@@ -546,14 +546,14 @@
 
     TT_PCLT* pclt_info;
     TT_OS2* os2_table;
-    if ((pclt_info = (TT_PCLT*)FT_Get_Sfnt_Table(face, ft_sfnt_pclt)) != NULL) {
+    if ((pclt_info = (TT_PCLT*)FT_Get_Sfnt_Table(face, ft_sfnt_pclt)) != nullptr) {
         info->fCapHeight = pclt_info->CapHeight;
         uint8_t serif_style = pclt_info->SerifStyle & 0x3F;
         if (serif_style >= 2 && serif_style <= 6)
             info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style;
         else if (serif_style >= 9 && serif_style <= 12)
             info->fStyle |= SkAdvancedTypefaceMetrics::kScript_Style;
-    } else if (((os2_table = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2)) != NULL) &&
+    } else if (((os2_table = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2)) != nullptr) &&
                // sCapHeight is available only when version 2 or later.
                os2_table->version != 0xFFFF &&
                os2_table->version >= 2) {
@@ -666,7 +666,7 @@
             new SkScalerContext_FreeType(const_cast<SkTypeface_FreeType*>(this), desc);
     if (!c->success()) {
         delete c;
-        c = NULL;
+        c = nullptr;
     }
     return c;
 }
@@ -742,8 +742,8 @@
 
 static FT_Int chooseBitmapStrike(FT_Face face, SkFixed scaleY) {
     // early out if face is bad
-    if (face == NULL) {
-        SkDEBUGF(("chooseBitmapStrike aborted due to NULL face\n"));
+    if (face == nullptr) {
+        SkDEBUGF(("chooseBitmapStrike aborted due to nullptr face\n"));
         return -1;
     }
     // determine target ppem
@@ -795,9 +795,9 @@
 
     // load the font file
     fStrikeIndex = -1;
-    fFTSize = NULL;
+    fFTSize = nullptr;
     fFace = ref_ft_face(typeface);
-    if (NULL == fFace) {
+    if (nullptr == fFace) {
         return;
     }
 
@@ -886,14 +886,14 @@
     FT_Error err = FT_New_Size(fFace, &fFTSize);
     if (err != 0) {
         SkDEBUGF(("FT_New_Size returned %x for face %s\n", err, fFace->family_name));
-        fFace = NULL;
+        fFace = nullptr;
         return;
     }
     err = FT_Activate_Size(fFTSize);
     if (err != 0) {
         SkDEBUGF(("FT_Activate_Size(%08x, 0x%x, 0x%x) returned 0x%x\n", fFace, fScaleX, fScaleY,
                   err));
-        fFTSize = NULL;
+        fFTSize = nullptr;
         return;
     }
 
@@ -902,10 +902,10 @@
         if (err != 0) {
             SkDEBUGF(("FT_Set_CharSize(%08x, 0x%x, 0x%x) returned 0x%x\n",
                                     fFace, fScaleX, fScaleY,      err));
-            fFace = NULL;
+            fFace = nullptr;
             return;
         }
-        FT_Set_Transform(fFace, &fMatrix22, NULL);
+        FT_Set_Transform(fFace, &fMatrix22, nullptr);
     } else if (FT_HAS_FIXED_SIZES(fFace)) {
         fStrikeIndex = chooseBitmapStrike(fFace, fScaleY);
         if (fStrikeIndex == -1) {
@@ -934,11 +934,11 @@
 SkScalerContext_FreeType::~SkScalerContext_FreeType() {
     SkAutoMutexAcquire  ac(gFTMutex);
 
-    if (fFTSize != NULL) {
+    if (fFTSize != nullptr) {
         FT_Done_Size(fFTSize);
     }
 
-    if (fFace != NULL) {
+    if (fFace != nullptr) {
         unref_ft_face(fFace);
     }
 
@@ -953,13 +953,13 @@
     if (err != 0) {
         SkDEBUGF(("SkScalerContext_FreeType::FT_Activate_Size(%s %s, 0x%x, 0x%x) returned 0x%x\n",
                   fFace->family_name, fFace->style_name, fScaleX, fScaleY, err));
-        fFTSize = NULL;
+        fFTSize = nullptr;
         return err;
     }
 
     // seems we need to reset this every time (not sure why, but without it
     // I get random italics from some other fFTSize)
-    FT_Set_Transform(fFace, &fMatrix22, NULL);
+    FT_Set_Transform(fFace, &fMatrix22, nullptr);
     return 0;
 }
 
@@ -1258,7 +1258,7 @@
 }
 
 void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics) {
-    if (NULL == metrics) {
+    if (nullptr == metrics) {
         return;
     }
 
@@ -1473,7 +1473,7 @@
 
     EncodingProc next_uni_proc = find_encoding_proc(encoding);
 
-    if (NULL == glyphs) {
+    if (nullptr == glyphs) {
         for (int i = 0; i < glyphCount; ++i) {
             if (0 == FT_Get_Char_Index(face, next_uni_proc(&chars))) {
                 return i;
@@ -1507,7 +1507,7 @@
 SkTypeface::LocalizedStrings* SkTypeface_FreeType::onCreateFamilyNameIterator() const {
     SkTypeface::LocalizedStrings* nameIter =
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this);
-    if (NULL == nameIter) {
+    if (nullptr == nameIter) {
         SkString familyName;
         this->getFamilyName(&familyName);
         SkString language("und"); //undetermined
@@ -1523,8 +1523,8 @@
     FT_ULong tableCount = 0;
     FT_Error error;
 
-    // When 'tag' is NULL, returns number of tables in 'length'.
-    error = FT_Sfnt_Table_Info(face, 0, NULL, &tableCount);
+    // When 'tag' is nullptr, returns number of tables in 'length'.
+    error = FT_Sfnt_Table_Info(face, 0, nullptr, &tableCount);
     if (error) {
         return 0;
     }
@@ -1553,7 +1553,7 @@
     FT_Error error;
 
     // When 'length' is 0 it is overwritten with the full table length; 'offset' is ignored.
-    error = FT_Load_Sfnt_Table(face, tag, 0, NULL, &tableLength);
+    error = FT_Load_Sfnt_Table(face, tag, 0, nullptr, &tableLength);
     if (error) {
         return 0;
     }
@@ -1575,7 +1575,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
-SkTypeface_FreeType::Scanner::Scanner() : fLibrary(NULL) {
+SkTypeface_FreeType::Scanner::Scanner() : fLibrary(nullptr) {
     if (FT_New_Library(&gFTMemory, &fLibrary)) {
         return;
     }
@@ -1590,8 +1590,8 @@
 FT_Face SkTypeface_FreeType::Scanner::openFace(SkStream* stream, int ttcIndex,
                                                FT_Stream ftStream) const
 {
-    if (fLibrary == NULL) {
-        return NULL;
+    if (fLibrary == nullptr) {
+        return nullptr;
     }
 
     FT_Open_Args args;
@@ -1616,7 +1616,7 @@
 
     FT_Face face;
     if (FT_Open_Face(fLibrary, &args, ttcIndex, &face)) {
-        return NULL;
+        return nullptr;
     }
     return face;
 }
@@ -1626,7 +1626,7 @@
 
     FT_StreamRec streamRec;
     FT_Face face = this->openFace(stream, -1, &streamRec);
-    if (NULL == face) {
+    if (nullptr == face) {
         return false;
     }
 
@@ -1645,7 +1645,7 @@
 
     FT_StreamRec streamRec;
     FT_Face face = this->openFace(stream, ttcIndex, &streamRec);
-    if (NULL == face) {
+    if (nullptr == face) {
         return false;
     }
 
@@ -1716,7 +1716,7 @@
     }
 
     if (axes && face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) {
-        FT_MM_Var* variations = NULL;
+        FT_MM_Var* variations = nullptr;
         FT_Error err = FT_Get_MM_Var(face, &variations);
         if (err) {
             SkDEBUGF(("INFO: font %s claims to have variations, but none found.\n",
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp
index 5afe70a..245ded1 100644
--- a/src/ports/SkFontHost_FreeType_common.cpp
+++ b/src/ports/SkFontHost_FreeType_common.cpp
@@ -194,7 +194,7 @@
     const size_t height = srcFTBitmap.rows;
 
     if (SkMask::kLCD16_Format == dstFormat) {
-        copyFT2LCD16<false>(srcFTBitmap, dstMask, false, NULL, NULL, NULL);
+        copyFT2LCD16<false>(srcFTBitmap, dstMask, false, nullptr, nullptr, nullptr);
         return;
     }
 
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 540d805..5c9e896 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -88,8 +88,8 @@
                                                      SkTypeface::Style style)
 {
     SkAutoTUnref<SkFontConfigInterface> fci(RefFCI());
-    if (NULL == fci.get()) {
-        return NULL;
+    if (nullptr == fci.get()) {
+        return nullptr;
     }
 
     // Check if requested NameStyle is in the NameStyle cache.
@@ -107,7 +107,7 @@
     SkString outFamilyName;
     SkTypeface::Style outStyle;
     if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &outStyle)) {
-        return NULL;
+        return nullptr;
     }
 
     // Check if a typeface with this FontIdentity is already in the FontIdentity cache.
@@ -136,8 +136,8 @@
     }
 
     SkAutoTUnref<SkFontConfigInterface> fci(RefFCI());
-    if (NULL == fci.get()) {
-        return NULL;
+    if (nullptr == fci.get()) {
+        return nullptr;
     }
 
     *ttcIndex = this->getIdentity().fTTCIndex;
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index b144aee..343936c 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -68,7 +68,7 @@
 // provide a wrapper here that will return an empty array if need be.
 static CFArrayRef SkCTFontManagerCopyAvailableFontFamilyNames() {
 #ifdef SK_BUILD_FOR_IOS
-    return CFArrayCreate(NULL, NULL, 0, NULL);
+    return CFArrayCreate(nullptr, nullptr, 0, nullptr);
 #else
     return CTFontManagerCopyAvailableFontFamilyNames();
 #endif
@@ -94,10 +94,10 @@
 /** Acts like a CFRef, but calls CFSafeRelease when it goes out of scope. */
 template<typename CFRef> class AutoCFRelease : private SkNoncopyable {
 public:
-    explicit AutoCFRelease(CFRef cfRef = NULL) : fCFRef(cfRef) { }
+    explicit AutoCFRelease(CFRef cfRef = nullptr) : fCFRef(cfRef) { }
     ~AutoCFRelease() { CFSafeRelease(fCFRef); }
 
-    void reset(CFRef that = NULL) {
+    void reset(CFRef that = nullptr) {
         if (that != fCFRef) {
             CFSafeRelease(fCFRef);
             fCFRef = that;
@@ -106,20 +106,20 @@
 
     CFRef detach() {
         CFRef self = fCFRef;
-        fCFRef = NULL;
+        fCFRef = nullptr;
         return self;
     }
 
     operator CFRef() const { return fCFRef; }
     CFRef get() const { return fCFRef; }
 
-    CFRef* operator&() { SkASSERT(fCFRef == NULL); return &fCFRef; }
+    CFRef* operator&() { SkASSERT(fCFRef == nullptr); return &fCFRef; }
 private:
     CFRef fCFRef;
 };
 
 static CFStringRef make_CFString(const char str[]) {
-    return CFStringCreateWithCString(NULL, str, kCFStringEncodingUTF8);
+    return CFStringCreateWithCString(nullptr, str, kCFStringEncodingUTF8);
 }
 
 template<typename T> class AutoCGTable : SkNoncopyable {
@@ -127,7 +127,7 @@
     AutoCGTable(CGFontRef font)
     //Undocumented: the tag parameter in this call is expected in machine order and not BE order.
     : fCFData(CGFontCopyTableForTag(font, SkSetFourByteTag(T::TAG0, T::TAG1, T::TAG2, T::TAG3)))
-    , fData(fCFData ? reinterpret_cast<const T*>(CFDataGetBytePtr(fCFData)) : NULL)
+    , fData(fCFData ? reinterpret_cast<const T*>(CFDataGetBytePtr(fCFData)) : nullptr)
     { }
 
     const T* operator->() const { return fData; }
@@ -327,8 +327,8 @@
 class Offscreen {
 public:
     Offscreen()
-        : fRGBSpace(NULL)
-        , fCG(NULL)
+        : fRGBSpace(nullptr)
+        , fCG(nullptr)
         , fDoAA(false)
         , fDoLCD(false)
     {
@@ -389,7 +389,7 @@
 static SkFontStyle fontstyle_from_descriptor(CTFontDescriptorRef desc) {
     AutoCFRelease<CFDictionaryRef> dict(
             (CFDictionaryRef)CTFontDescriptorCopyAttribute(desc, kCTFontTraitsAttribute));
-    if (NULL == dict.get()) {
+    if (nullptr == dict.get()) {
         return SkFontStyle();
     }
 
@@ -528,7 +528,7 @@
                                       &kCFTypeDictionaryValueCallBacks));
 
     if (!cfFontName || !cfFontTraits || !cfAttributes || !cfTraits) {
-        return NULL;
+        return nullptr;
     }
 
     CFDictionaryAddValue(cfTraits, kCTFontSymbolicTrait, cfFontTraits);
@@ -539,17 +539,17 @@
     AutoCFRelease<CTFontDescriptorRef> ctFontDesc(
             CTFontDescriptorCreateWithAttributes(cfAttributes));
     if (!ctFontDesc) {
-        return NULL;
+        return nullptr;
     }
 
-    AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL));
+    AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(ctFontDesc, 0, nullptr));
     if (!ctFont) {
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_by_CTFontRef, (void*)ctFont.get());
     if (!face) {
-        face = NewFromFontRef(ctFont.detach(), NULL, NULL, false);
+        face = NewFromFontRef(ctFont.detach(), nullptr, nullptr, false);
         SkTypefaceCache::Add(face, face->fontStyle());
     }
     return face;
@@ -561,7 +561,7 @@
 
     static SkTypeface* gDefaultFace;
 
-    if (NULL == gDefaultFace) {
+    if (nullptr == gDefaultFace) {
         gDefaultFace = NewFromName(FONT_DEFAULT_NAME, SkFontStyle());
         SkTypefaceCache::Add(gDefaultFace, SkFontStyle());
     }
@@ -573,7 +573,7 @@
 extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face);
 CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face) {
     const SkTypeface_Mac* macface = (const SkTypeface_Mac*)face;
-    return macface ? macface->fFontRef.get() : NULL;
+    return macface ? macface->fFontRef.get() : nullptr;
 }
 
 /*  This function is visible on the outside. It first searches the cache, and if
@@ -586,7 +586,7 @@
         if (resourceRef) {
             CFRetain(resourceRef);
         }
-        face = NewFromFontRef(fontRef, resourceRef, NULL, false);
+        face = NewFromFontRef(fontRef, resourceRef, nullptr, false);
         SkTypefaceCache::Add(face, face->fontStyle());
     }
     return face;
@@ -736,7 +736,7 @@
     SkVector scale;
     SkMatrix skTransform;
     fRec.computeMatrices(SkScalerContextRec::kVertical_PreMatrixScale, &scale, &skTransform,
-                         NULL, NULL, &fFUnitMatrix);
+                         nullptr, nullptr, &fFUnitMatrix);
     fTransform = MatrixToCGAffineTransform(skTransform);
     fInvTransform = CGAffineTransformInvert(fTransform);
 
@@ -761,9 +761,9 @@
     CGFloat textSize = ScalarToCG(scale.y());
 
     fCTFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &fTransform, ctFontDesc));
-    fCGFont.reset(CTFontCopyGraphicsFont(fCTFont, NULL));
+    fCGFont.reset(CTFontCopyGraphicsFont(fCTFont, nullptr));
     fCTUnrotatedFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize,
-                                                          &CGAffineTransformIdentity, NULL));
+                                                          &CGAffineTransformIdentity, nullptr));
 
     // The fUnitMatrix includes the text size (and em) as it is used to scale the raw font data.
     SkScalar emPerFUnit = SkScalarInvert(SkIntToScalar(CGFontGetUnitsPerEm(fCGFont)));
@@ -1088,8 +1088,8 @@
         // empty path or not, and if so, we jam the bounds to 0. Hopefully a zero-advance
         // is rare, so we won't incur a big performance cost for this extra check.
         if (0 == cgAdvance.width && 0 == cgAdvance.height) {
-            AutoCFRelease<CGPathRef> path(CTFontCreatePathForGlyph(fCTFont, cgGlyph, NULL));
-            if (NULL == path || CGPathIsEmpty(path)) {
+            AutoCFRelease<CGPathRef> path(CTFontCreatePathForGlyph(fCTFont, cgGlyph, nullptr));
+            if (nullptr == path || CGPathIsEmpty(path)) {
                 return;
             }
         }
@@ -1253,7 +1253,7 @@
     // Draw the glyph
     size_t cgRowBytes;
     CGRGBPixel* cgPixels = fOffscreen.getCG(*this, glyph, cgGlyph, &cgRowBytes, generateA8FromLCD);
-    if (cgPixels == NULL) {
+    if (cgPixels == nullptr) {
         return;
     }
 
@@ -1372,14 +1372,14 @@
 
         CGAffineTransform xform = MatrixToCGAffineTransform(m, scaleX, scaleY);
         // need to release font when we're done
-        font = CTFontCreateCopyWithAttributes(fCTFont, 1, &xform, NULL);
+        font = CTFontCreateCopyWithAttributes(fCTFont, 1, &xform, nullptr);
     }
 
     CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID();
-    AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(font, cgGlyph, NULL));
+    AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(font, cgGlyph, nullptr));
 
     path->reset();
-    if (cgPath != NULL) {
+    if (cgPath != nullptr) {
         CGPathApply(cgPath, path, SkScalerContext_Mac::CTPathElement);
     }
 
@@ -1398,7 +1398,7 @@
 }
 
 void SkScalerContext_Mac::generateFontMetrics(SkPaint::FontMetrics* metrics) {
-    if (NULL == metrics) {
+    if (nullptr == metrics) {
         return;
     }
 
@@ -1461,15 +1461,15 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-// Returns NULL on failure
+// Returns nullptr on failure
 // Call must still manage its ownership of provider
 static SkTypeface* create_from_dataProvider(CGDataProviderRef provider) {
     AutoCFRelease<CGFontRef> cg(CGFontCreateWithDataProvider(provider));
-    if (NULL == cg) {
-        return NULL;
+    if (nullptr == cg) {
+        return nullptr;
     }
-    CTFontRef ct = CTFontCreateWithGraphicsFont(cg, 0, NULL, NULL);
-    return ct ? NewFromFontRef(ct, NULL, NULL, true) : NULL;
+    CTFontRef ct = CTFontCreateWithGraphicsFont(cg, 0, nullptr, nullptr);
+    return ct ? NewFromFontRef(ct, nullptr, nullptr, true) : nullptr;
 }
 
 // Web fonts added to the the CTFont registry do not return their character set.
@@ -1548,7 +1548,7 @@
     return true;
 }
 
-/** Assumes src and dst are not NULL. */
+/** Assumes src and dst are not nullptr. */
 static void CFStringToSkString(CFStringRef src, SkString* dst) {
     // Reserve enough room for the worst-case string,
     // plus 1 byte for the trailing null.
@@ -1569,7 +1569,7 @@
 
     CTFontRef originalCTFont = fFontRef.get();
     AutoCFRelease<CTFontRef> ctFont(CTFontCreateCopyWithAttributes(
-            originalCTFont, CTFontGetUnitsPerEm(originalCTFont), NULL, NULL));
+            originalCTFont, CTFontGetUnitsPerEm(originalCTFont), nullptr, nullptr));
     SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
 
     {
@@ -1699,7 +1699,7 @@
 SkStreamAsset* SkTypeface_Mac::onOpenStream(int* ttcIndex) const {
     SK_SFNT_ULONG fontType = get_font_type_tag(this);
     if (0 == fontType) {
-        return NULL;
+        return nullptr;
     }
 
     // get table tags
@@ -1811,12 +1811,12 @@
                            SkAutoSTMalloc<4, SkFixed>* axisValues)
 {
     // CTFontCopyVariationAxes and CTFontCopyVariation do not work when applied to fonts which
-    // started life with CGFontCreateWithDataProvider (they simply always return NULL).
+    // started life with CGFontCreateWithDataProvider (they simply always return nullptr).
     // As a result, we are limited to CGFontCopyVariationAxes and CGFontCopyVariations.
-    AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(fFontRef, NULL));
+    AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(fFontRef, nullptr));
 
     AutoCFRelease<CFDictionaryRef> cgVariations(CGFontCopyVariations(cgFont));
-    // If a font has no variations CGFontCopyVariations returns NULL (instead of an empty dict).
+    // If a font has no variations CGFontCopyVariations returns nullptr (instead of an empty dict).
     if (!cgVariations.get()) {
         return false;
     }
@@ -1868,21 +1868,21 @@
     if (get_variations(fFontRef, &cgAxisCount, &axisValues)) {
         return new SkFontData(stream.detach(), index, axisValues.get(), cgAxisCount);
     }
-    return new SkFontData(stream.detach(), index, NULL, 0);
+    return new SkFontData(stream.detach(), index, nullptr, 0);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
 int SkTypeface_Mac::onGetUPEM() const {
-    AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(fFontRef, NULL));
+    AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(fFontRef, nullptr));
     return CGFontGetUnitsPerEm(cgFont);
 }
 
 SkTypeface::LocalizedStrings* SkTypeface_Mac::onCreateFamilyNameIterator() const {
     SkTypeface::LocalizedStrings* nameIter =
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this);
-    if (NULL == nameIter) {
+    if (nullptr == nameIter) {
         AutoCFRelease<CFStringRef> cfLanguage;
         AutoCFRelease<CFStringRef> cfFamilyName(
             CTFontCopyLocalizedName(fFontRef, kCTFontFamilyNameKey, &cfLanguage));
@@ -1909,8 +1909,8 @@
 static CFDataRef copyTableFromFont(CTFontRef ctFont, SkFontTableTag tag) {
     CFDataRef data = CTFontCopyTable(ctFont, (CTFontTableTag) tag,
                                      kCTFontTableOptionNoOptions);
-    if (NULL == data) {
-        AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(ctFont, NULL));
+    if (nullptr == data) {
+        AutoCFRelease<CGFontRef> cgFont(CTFontCopyGraphicsFont(ctFont, nullptr));
         data = CGFontCopyTableForTag(cgFont, tag);
     }
     return data;
@@ -1919,7 +1919,7 @@
 int SkTypeface_Mac::onGetTableTags(SkFontTableTag tags[]) const {
     AutoCFRelease<CFArrayRef> cfArray(CTFontCopyAvailableTables(fFontRef,
                                                 kCTFontTableOptionNoOptions));
-    if (NULL == cfArray) {
+    if (nullptr == cfArray) {
         return 0;
     }
     int count = SkToInt(CFArrayGetCount(cfArray));
@@ -1935,7 +1935,7 @@
 size_t SkTypeface_Mac::onGetTableData(SkFontTableTag tag, size_t offset,
                                       size_t length, void* dstData) const {
     AutoCFRelease<CFDataRef> srcData(copyTableFromFont(fFontRef, tag));
-    if (NULL == srcData) {
+    if (nullptr == srcData) {
         return 0;
     }
 
@@ -2039,8 +2039,8 @@
 
 // we take ownership of the ref
 static const char* get_str(CFStringRef ref, SkString* str) {
-    if (NULL == ref) {
-        return NULL;
+    if (nullptr == ref) {
+        return nullptr;
     }
     CFStringToSkString(ref, str);
     CFSafeRelease(ref);
@@ -2106,22 +2106,22 @@
         }
     }
 
-    // If glyphs is NULL, CT still needs glyph storage for finding the first failure.
+    // If glyphs is nullptr, CT still needs glyph storage for finding the first failure.
     // Also, if there are any non-bmp code points, the provided 'glyphs' storage will be inadequate.
     SkAutoSTMalloc<1024, uint16_t> glyphStorage;
     uint16_t* macGlyphs = glyphs;
-    if (NULL == macGlyphs || srcCount > glyphCount) {
+    if (nullptr == macGlyphs || srcCount > glyphCount) {
         macGlyphs = glyphStorage.reset(srcCount);
     }
 
     bool allEncoded = CTFontGetGlyphsForCharacters(fFontRef, src, macGlyphs, srcCount);
 
     // If there were any non-bmp, then copy and compact.
-    // If 'glyphs' is NULL, then compact glyphStorage in-place.
-    // If all are bmp and 'glyphs' is non-NULL, 'glyphs' already contains the compact glyphs.
-    // If some are non-bmp and 'glyphs' is non-NULL, copy and compact into 'glyphs'.
+    // If 'glyphs' is nullptr, then compact glyphStorage in-place.
+    // If all are bmp and 'glyphs' is non-nullptr, 'glyphs' already contains the compact glyphs.
+    // If some are non-bmp and 'glyphs' is non-nullptr, copy and compact into 'glyphs'.
     uint16_t* compactedGlyphs = glyphs;
-    if (NULL == compactedGlyphs) {
+    if (nullptr == compactedGlyphs) {
         compactedGlyphs = macGlyphs;
     }
     if (srcCount > glyphCount) {
@@ -2157,7 +2157,7 @@
 
 static bool find_desc_str(CTFontDescriptorRef desc, CFStringRef name, SkString* value) {
     AutoCFRelease<CFStringRef> ref((CFStringRef)CTFontDescriptorCopyAttribute(desc, name));
-    if (NULL == ref.get()) {
+    if (nullptr == ref.get()) {
         return false;
     }
     CFStringToSkString(ref, value);
@@ -2190,15 +2190,15 @@
         return face;
     }
 
-    AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(desc, 0, NULL));
+    AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(desc, 0, nullptr));
     if (!ctFont) {
-        return NULL;
+        return nullptr;
     }
 
     bool isFixedPitch;
     (void)computeStyleBits(ctFont, &isFixedPitch);
 
-    face = new SkTypeface_Mac(ctFont.detach(), NULL, cacheRequest.fStyle, isFixedPitch,
+    face = new SkTypeface_Mac(ctFont.detach(), nullptr, cacheRequest.fStyle, isFixedPitch,
                               skFamilyName.c_str(), false);
     SkTypefaceCache::Add(face, face->fontStyle());
     return face;
@@ -2207,12 +2207,12 @@
 class SkFontStyleSet_Mac : public SkFontStyleSet {
 public:
     SkFontStyleSet_Mac(CFStringRef familyName, CTFontDescriptorRef desc)
-        : fArray(CTFontDescriptorCreateMatchingFontDescriptors(desc, NULL))
+        : fArray(CTFontDescriptorCreateMatchingFontDescriptors(desc, nullptr))
         , fFamilyName(familyName)
         , fCount(0) {
         CFRetain(familyName);
-        if (NULL == fArray) {
-            fArray = CFArrayCreate(NULL, NULL, 0, NULL);
+        if (nullptr == fArray) {
+            fArray = CFArrayCreate(nullptr, nullptr, 0, nullptr);
         }
         fCount = SkToInt(CFArrayGetCount(fArray));
     }
@@ -2248,7 +2248,7 @@
 
     SkTypeface* matchStyle(const SkFontStyle& pattern) override {
         if (0 == fCount) {
-            return NULL;
+            return nullptr;
         }
         return createFromDesc(fFamilyName, findMatchingDesc(pattern));
     }
@@ -2260,7 +2260,7 @@
 
     CTFontDescriptorRef findMatchingDesc(const SkFontStyle& pattern) const {
         int bestMetric = SK_MaxS32;
-        CTFontDescriptorRef bestDesc = NULL;
+        CTFontDescriptorRef bestDesc = nullptr;
 
         for (int i = 0; i < fCount; ++i) {
             CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fArray, i);
@@ -2324,7 +2324,7 @@
 
     SkFontStyleSet* onCreateStyleSet(int index) const override {
         if ((unsigned)index >= (unsigned)fCount) {
-            return NULL;
+            return nullptr;
         }
         return CreateSet(this->stringAt(index));
     }
@@ -2336,32 +2336,32 @@
 
     virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
                                            const SkFontStyle&) const override {
-        return NULL;
+        return nullptr;
     }
 
     virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
                                                     const char* bcp47[], int bcp47Count,
                                                     SkUnichar character) const override {
-        return NULL;
+        return nullptr;
     }
 
     virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
                                          const SkFontStyle&) const override {
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
         AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
-        if (NULL == pr) {
-            return NULL;
+        if (nullptr == pr) {
+            return nullptr;
         }
         return create_from_dataProvider(pr);
     }
 
     SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override {
         AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
-        if (NULL == pr) {
-            return NULL;
+        if (nullptr == pr) {
+            return nullptr;
         }
         return create_from_dataProvider(pr);
     }
@@ -2369,12 +2369,12 @@
     static CFDictionaryRef get_axes(CGFontRef cg, SkFontData* fontData) {
         AutoCFRelease<CFArrayRef> cgAxes(CGFontCopyVariationAxes(cg));
         if (!cgAxes) {
-            return NULL;
+            return nullptr;
         }
 
         CFIndex axisCount = CFArrayGetCount(cgAxes);
         if (0 == axisCount || axisCount != fontData->getAxisCount()) {
-            return NULL;
+            return nullptr;
         }
 
         CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault, axisCount,
@@ -2383,13 +2383,13 @@
         for (int i = 0; i < fontData->getAxisCount(); ++i) {
             CFTypeRef axisInfo = CFArrayGetValueAtIndex(cgAxes, i);
             if (CFDictionaryGetTypeID() != CFGetTypeID(axisInfo)) {
-                return NULL;
+                return nullptr;
             }
             CFDictionaryRef axisInfoDict = static_cast<CFDictionaryRef>(axisInfo);
 
             CFTypeRef axisName = CFDictionaryGetValue(axisInfoDict, kCGFontVariationAxisName);
             if (!axisName || CFGetTypeID(axisName) != CFStringGetTypeID()) {
-                return NULL;
+                return nullptr;
             }
 
             // The variation axes can be set to any value, but cg will effectively pin them.
@@ -2399,7 +2399,7 @@
             if (!min || CFGetTypeID(min) != CFNumberGetTypeID() ||
                 !max || CFGetTypeID(max) != CFNumberGetTypeID())
             {
-                return NULL;
+                return nullptr;
             }
             CFNumberRef minNumber = static_cast<CFNumberRef>(min);
             CFNumberRef maxNumber = static_cast<CFNumberRef>(max);
@@ -2408,7 +2408,7 @@
             if (!CFNumberGetValue(minNumber, kCFNumberDoubleType, &minDouble) ||
                 !CFNumberGetValue(maxNumber, kCFNumberDoubleType, &maxDouble))
             {
-                return NULL;
+                return nullptr;
             }
             double value = SkTPin(SkFixedToDouble(fontData->getAxis()[i]), minDouble, maxDouble);
             CFNumberRef valueNumber = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType,
@@ -2423,12 +2423,12 @@
         SkAutoTDelete<SkFontData> fontData(data);
         SkStreamAsset* stream = fontData->detachStream();
         AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(stream));
-        if (NULL == provider) {
-            return NULL;
+        if (nullptr == provider) {
+            return nullptr;
         }
         AutoCFRelease<CGFontRef> cg(CGFontCreateWithDataProvider(provider));
-        if (NULL == cg) {
-            return NULL;
+        if (nullptr == cg) {
+            return nullptr;
         }
 
         AutoCFRelease<CFDictionaryRef> cgVariations(get_axes(cg, fontData));
@@ -2442,17 +2442,17 @@
             cgVariant.reset(cg.detach());
         }
 
-        CTFontRef ct = CTFontCreateWithGraphicsFont(cgVariant, 0, NULL, NULL);
+        CTFontRef ct = CTFontCreateWithGraphicsFont(cgVariant, 0, nullptr, nullptr);
         if (!ct) {
-            return NULL;
+            return nullptr;
         }
-        return NewFromFontRef(ct, cg.detach(), NULL, true);
+        return NewFromFontRef(ct, cg.detach(), nullptr, true);
     }
 
     SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
         AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(path));
-        if (NULL == pr) {
-            return NULL;
+        if (nullptr == pr) {
+            return nullptr;
         }
         return create_from_dataProvider(pr);
     }
@@ -2472,7 +2472,7 @@
         NameStyle cacheRequest = { familyName, style };
         SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_by_NameStyle, &cacheRequest);
 
-        if (NULL == face) {
+        if (nullptr == face) {
             face = NewFromName(familyName, style);
             if (face) {
                 SkTypefaceCache::Add(face, style);
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 97e659e..e263cc2 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -87,9 +87,9 @@
 
 static void tchar_to_skstring(const TCHAR t[], SkString* s) {
 #ifdef UNICODE
-    size_t sSize = WideCharToMultiByte(CP_UTF8, 0, t, -1, NULL, 0, NULL, NULL);
+    size_t sSize = WideCharToMultiByte(CP_UTF8, 0, t, -1, nullptr, 0, nullptr, nullptr);
     s->resize(sSize);
-    WideCharToMultiByte(CP_UTF8, 0, t, -1, s->writable_str(), sSize, NULL, NULL);
+    WideCharToMultiByte(CP_UTF8, 0, t, -1, s->writable_str(), sSize, nullptr, nullptr);
 #else
     s->set(t);
 #endif
@@ -97,9 +97,9 @@
 
 static void dcfontname_to_skstring(HDC deviceContext, const LOGFONT& lf, SkString* familyName) {
     int fontNameLen; //length of fontName in TCHARS.
-    if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
+    if (0 == (fontNameLen = GetTextFace(deviceContext, 0, nullptr))) {
         call_ensure_accessible(lf);
-        if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
+        if (0 == (fontNameLen = GetTextFace(deviceContext, 0, nullptr))) {
             fontNameLen = 0;
         }
     }
@@ -169,7 +169,7 @@
     while (min < max) {
         int32_t mid = min + ((max - min) / 2);
         if (GetGlyphOutlineW(hdc, mid, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0,
-                             NULL, &mat2) == GDI_ERROR) {
+                             nullptr, &mat2) == GDI_ERROR) {
             max = mid;
         } else {
             min = mid + 1;
@@ -212,7 +212,7 @@
         // If the font has cubic outlines, it will not be rendered with ClearType.
         HFONT font = CreateFontIndirect(&lf);
 
-        HDC deviceContext = ::CreateCompatibleDC(NULL);
+        HDC deviceContext = ::CreateCompatibleDC(nullptr);
         HFONT savefont = (HFONT)SelectObject(deviceContext, font);
 
         TEXTMETRIC textMetric;
@@ -320,7 +320,7 @@
     LOGFONT lf = origLF;
     make_canonical(&lf);
     SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf);
-    if (NULL == face) {
+    if (nullptr == face) {
         face = LogFontTypeface::Create(lf);
         SkTypefaceCache::Add(face, get_style(lf));
     }
@@ -341,7 +341,7 @@
  *  This guy is public
  */
 void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) {
-    if (NULL == face) {
+    if (nullptr == face) {
         *lf = get_default_font();
     } else {
         *lf = static_cast<const LogFontTypeface*>(face)->fLogFont;
@@ -356,7 +356,7 @@
 // of calling GetFontUnicodeRange().
 static void populate_glyph_to_unicode(HDC fontHdc, const unsigned glyphCount,
                                       SkTDArray<SkUnichar>* glyphToUnicode) {
-    DWORD glyphSetBufferSize = GetFontUnicodeRanges(fontHdc, NULL);
+    DWORD glyphSetBufferSize = GetFontUnicodeRanges(fontHdc, nullptr);
     if (!glyphSetBufferSize) {
         return;
     }
@@ -416,7 +416,7 @@
         fFont = 0;
         fDC = 0;
         fBM = 0;
-        fBits = NULL;
+        fBits = nullptr;
         fWidth = fHeight = 0;
         fIsBW = false;
     }
@@ -455,7 +455,7 @@
     if (0 == fDC) {
         fDC = CreateCompatibleDC(0);
         if (0 == fDC) {
-            return NULL;
+            return nullptr;
         }
         SetGraphicsMode(fDC, GM_ADVANCED);
         SetBkMode(fDC, TRANSPARENT);
@@ -498,7 +498,7 @@
         }
         fBM = CreateDIBSection(fDC, &info, DIB_RGB_COLORS, &fBits, 0, 0);
         if (0 == fBM) {
-            return NULL;
+            return nullptr;
         }
         SelectObject(fDC, fBM);
     }
@@ -514,10 +514,10 @@
     SetWorldTransform(fDC, &xform);
 
     uint16_t glyphID = glyph.getGlyphID();
-    BOOL ret = ExtTextOutW(fDC, 0, 0, ETO_GLYPH_INDEX, NULL, reinterpret_cast<LPCWSTR>(&glyphID), 1, NULL);
+    BOOL ret = ExtTextOutW(fDC, 0, 0, ETO_GLYPH_INDEX, nullptr, reinterpret_cast<LPCWSTR>(&glyphID), 1, nullptr);
     GdiFlush();
     if (0 == ret) {
-        return NULL;
+        return nullptr;
     }
     *srcRBPtr = srcRB;
     // offset to the start of the image
@@ -606,7 +606,7 @@
 {
     LogFontTypeface* typeface = reinterpret_cast<LogFontTypeface*>(rawTypeface);
 
-    fDDC = ::CreateCompatibleDC(NULL);
+    fDDC = ::CreateCompatibleDC(nullptr);
     if (!fDDC) {
         return;
     }
@@ -806,13 +806,13 @@
         // Use uniscribe to detemine glyph index for non-BMP characters.
         static const int numWCHAR = 2;
         static const int maxItems = 2;
-        // MSDN states that this can be NULL, but some things don't work then.
+        // MSDN states that this can be nullptr, but some things don't work then.
         SCRIPT_CONTROL sc = { 0 };
         // Add extra item to SCRIPT_ITEM to work around a bug (now documented).
         // https://bugzilla.mozilla.org/show_bug.cgi?id=366643
         SCRIPT_ITEM si[maxItems + 1];
         int numItems;
-        HRZM(ScriptItemize(utf16, numWCHAR, maxItems, &sc, NULL, si, &numItems),
+        HRZM(ScriptItemize(utf16, numWCHAR, maxItems, &sc, nullptr, si, &numItems),
              "Could not itemize character.");
 
         // Sometimes ScriptShape cannot find a glyph for a non-BMP and returns 2 space glyphs.
@@ -883,10 +883,10 @@
     GLYPHMETRICS gm;
     sk_bzero(&gm, sizeof(gm));
 
-    DWORD status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
+    DWORD status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fMat22);
     if (GDI_ERROR == status) {
         LogFontTypeface::EnsureAccessible(this->getTypeface());
-        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
+        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fMat22);
         if (GDI_ERROR == status) {
             glyph->zeroMetrics();
             return;
@@ -899,7 +899,7 @@
     // is to be drawn, like a '.'. We need to outset '.' but do not wish to outset ' '.
     if (1 == gm.gmBlackBoxX && 1 == gm.gmBlackBoxY) {
         // If GetGlyphOutline with GGO_NATIVE returns 0, we know there was no outline.
-        DWORD bufferSize = GetGlyphOutlineW(fDDC, glyphId, GGO_NATIVE | GGO_GLYPH_INDEX, &gm, 0, NULL, &fMat22);
+        DWORD bufferSize = GetGlyphOutlineW(fDDC, glyphId, GGO_NATIVE | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fMat22);
         empty = (0 == bufferSize);
     }
 
@@ -925,7 +925,7 @@
 
     if (this->isSubpixel()) {
         sk_bzero(&gm, sizeof(gm));
-        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fHighResMat22);
+        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fHighResMat22);
         if (GDI_ERROR != status) {
             SkPoint advance;
             fHiResMatrix.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIncY), &advance);
@@ -933,7 +933,7 @@
             glyph->fAdvanceY = SkScalarToFixed(advance.fY);
         }
     } else if (!isAxisAligned(this->fRec)) {
-        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &fGsA);
+        status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fGsA);
         if (GDI_ERROR != status) {
             SkPoint advance;
             fG_inv.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIncY), &advance);
@@ -945,7 +945,7 @@
 
 static const MAT2 gMat2Identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}};
 void SkScalerContext_GDI::generateFontMetrics(SkPaint::FontMetrics* metrics) {
-    if (NULL == metrics) {
+    if (nullptr == metrics) {
         return;
     }
     sk_bzero(metrics, sizeof(*metrics));
@@ -1231,10 +1231,10 @@
 
     size_t srcRB;
     const void* bits = fOffscreen.draw(glyph, isBW, &srcRB);
-    if (NULL == bits) {
+    if (nullptr == bits) {
         LogFontTypeface::EnsureAccessible(this->getTypeface());
         bits = fOffscreen.draw(glyph, isBW, &srcRB);
-        if (NULL == bits) {
+        if (nullptr == bits) {
             sk_bzero(glyph.fImage, glyph.computeImageSize());
             return;
         }
@@ -1322,22 +1322,22 @@
 nextHeader:
         if (!fCurveIter.isSet()) {
             const TTPOLYGONHEADER* header = fHeaderIter.next();
-            if (NULL == header) {
-                return NULL;
+            if (nullptr == header) {
+                return nullptr;
             }
             fCurveIter.set(header);
             const TTPOLYCURVE* curve = fCurveIter.next();
-            if (NULL == curve) {
-                return NULL;
+            if (nullptr == curve) {
+                return nullptr;
             }
             fPointIter.set(curve);
             return &header->pfxStart;
         }
 
         const POINTFX* nextPoint = fPointIter.next();
-        if (NULL == nextPoint) {
+        if (nullptr == nextPoint) {
             const TTPOLYCURVE* curve = fCurveIter.next();
-            if (NULL == curve) {
+            if (nullptr == curve) {
                 fCurveIter.set();
                 goto nextHeader;
             } else {
@@ -1363,7 +1363,7 @@
 
         const TTPOLYGONHEADER* next() {
             if (fCurPolygon >= fEndPolygon) {
-                return NULL;
+                return nullptr;
             }
             const TTPOLYGONHEADER* thisPolygon = fCurPolygon;
             fCurPolygon = SkTAddOffset<const TTPOLYGONHEADER>(fCurPolygon, fCurPolygon->cb);
@@ -1377,27 +1377,27 @@
     /** Iterates over all of the polygon curves in a polygon header. */
     class GDIPolygonCurveIter {
     public:
-        GDIPolygonCurveIter() : fCurCurve(NULL), fEndCurve(NULL) { }
+        GDIPolygonCurveIter() : fCurCurve(nullptr), fEndCurve(nullptr) { }
 
         GDIPolygonCurveIter(const TTPOLYGONHEADER* curPolygon)
             : fCurCurve(SkTAddOffset<const TTPOLYCURVE>(curPolygon, sizeof(TTPOLYGONHEADER)))
             , fEndCurve(SkTAddOffset<const TTPOLYCURVE>(curPolygon, curPolygon->cb))
         { }
 
-        bool isSet() { return fCurCurve != NULL; }
+        bool isSet() { return fCurCurve != nullptr; }
 
         void set(const TTPOLYGONHEADER* curPolygon) {
             fCurCurve = SkTAddOffset<const TTPOLYCURVE>(curPolygon, sizeof(TTPOLYGONHEADER));
             fEndCurve = SkTAddOffset<const TTPOLYCURVE>(curPolygon, curPolygon->cb);
         }
         void set() {
-            fCurCurve = NULL;
-            fEndCurve = NULL;
+            fCurCurve = nullptr;
+            fEndCurve = nullptr;
         }
 
         const TTPOLYCURVE* next() {
             if (fCurCurve >= fEndCurve) {
-                return NULL;
+                return nullptr;
             }
             const TTPOLYCURVE* thisCurve = fCurCurve;
             fCurCurve = SkTAddOffset<const TTPOLYCURVE>(fCurCurve, size_of_TTPOLYCURVE(*fCurCurve));
@@ -1414,7 +1414,7 @@
     /** Iterates over all of the polygon points in a polygon curve. */
     class GDIPolygonCurvePointIter {
     public:
-        GDIPolygonCurvePointIter() : fCurveType(0), fCurPoint(NULL), fEndPoint(NULL) { }
+        GDIPolygonCurvePointIter() : fCurveType(0), fCurPoint(nullptr), fEndPoint(nullptr) { }
 
         GDIPolygonCurvePointIter(const TTPOLYCURVE* curPolygon)
             : fCurveType(curPolygon->wType)
@@ -1422,7 +1422,7 @@
             , fEndPoint(&curPolygon->apfx[curPolygon->cpfx])
         { }
 
-        bool isSet() { return fCurPoint != NULL; }
+        bool isSet() { return fCurPoint != nullptr; }
 
         void set(const TTPOLYCURVE* curPolygon) {
             fCurveType = curPolygon->wType;
@@ -1430,13 +1430,13 @@
             fEndPoint = &curPolygon->apfx[curPolygon->cpfx];
         }
         void set() {
-            fCurPoint = NULL;
-            fEndPoint = NULL;
+            fCurPoint = nullptr;
+            fEndPoint = nullptr;
         }
 
         const POINTFX* next() {
             if (fCurPoint >= fEndPoint) {
-                return NULL;
+                return nullptr;
             }
             const POINTFX* thisPoint = fCurPoint;
             ++fCurPoint;
@@ -1505,7 +1505,7 @@
 
 #define move_next_expected_hinted_point(iter, pElem) do {\
     pElem = iter.next(); \
-    if (NULL == pElem) return false; \
+    if (nullptr == pElem) return false; \
 } while(0)
 
 // It is possible for the hinted and unhinted versions of the same path to have
@@ -1591,10 +1591,10 @@
         // GDI_ERROR because the BUFFERSIZE was too small, or because the data was not accessible.
         // When the data is not accessable GetGlyphOutlineW fails rather quickly,
         // so just try to get the size. If that fails then ensure the data is accessible.
-        total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, NULL, &fMat22);
+        total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, nullptr, &fMat22);
         if (GDI_ERROR == total_size) {
             LogFontTypeface::EnsureAccessible(this->getTypeface());
-            total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, NULL, &fMat22);
+            total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, nullptr, &fMat22);
             if (GDI_ERROR == total_size) {
                 // GetGlyphOutlineW is known to fail for some characters, such as spaces.
                 // In these cases, just return that the glyph does not have a shape.
@@ -1668,7 +1668,7 @@
 #ifdef UNICODE
     // Get the buffer size needed first.
     size_t str_len = ::MultiByteToWideChar(CP_UTF8, 0, familyName,
-                                            -1, NULL, 0);
+                                            -1, nullptr, 0);
     // Allocate a buffer (str_len already has terminating null
     // accounted for).
     wchar_t *wideFamilyName = new wchar_t[str_len];
@@ -1688,7 +1688,7 @@
     // Get the actual name of the typeface. The logfont may not know this.
     HFONT font = CreateFontIndirect(&fLogFont);
 
-    HDC deviceContext = ::CreateCompatibleDC(NULL);
+    HDC deviceContext = ::CreateCompatibleDC(nullptr);
     HFONT savefont = (HFONT)SelectObject(deviceContext, font);
 
     dcfontname_to_skstring(deviceContext, fLogFont, familyName);
@@ -1716,7 +1716,7 @@
                         SkScalarToFIXED(0), SkScalarToFIXED(1)};
     int flags = GGO_METRICS | GGO_GLYPH_INDEX;
     GLYPHMETRICS gm;
-    if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, NULL, &mat2)) {
+    if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, nullptr, &mat2)) {
         return false;
     }
     SkASSERT(advance);
@@ -1729,12 +1729,12 @@
         const uint32_t* glyphIDs,
         uint32_t glyphIDsCount) const {
     LOGFONT lf = fLogFont;
-    SkAdvancedTypefaceMetrics* info = NULL;
+    SkAdvancedTypefaceMetrics* info = nullptr;
 
-    HDC hdc = CreateCompatibleDC(NULL);
+    HDC hdc = CreateCompatibleDC(nullptr);
     HFONT font = CreateFontIndirect(&lf);
     HFONT savefont = (HFONT)SelectObject(hdc, font);
-    HFONT designFont = NULL;
+    HFONT designFont = nullptr;
 
     const char stem_chars[] = {'i', 'I', '!', '1'};
     int16_t min_width;
@@ -1852,7 +1852,7 @@
 
 //Dummy representation of a Base64 encoded GUID from create_unique_font_name.
 #define BASE64_GUID_ID "XXXXXXXXXXXXXXXXXXXXXXXX"
-//Length of GUID representation from create_id, including NULL terminator.
+//Length of GUID representation from create_id, including nullptr terminator.
 #define BASE64_GUID_ID_LEN SK_ARRAY_COUNT(BASE64_GUID_ID)
 
 static_assert(BASE64_GUID_ID_LEN < LF_FACESIZE, "GUID_longer_than_facesize");
@@ -1899,7 +1899,7 @@
 }
 
 /**
-   Introduces a font to GDI. On failure will return NULL. The returned handle
+   Introduces a font to GDI. On failure will return nullptr. The returned handle
    should eventually be passed to RemoveFontMemResourceEx.
 */
 static HANDLE activate_font(SkData* fontData) {
@@ -1910,9 +1910,9 @@
                                              0,
                                              &numFonts);
 
-    if (fontHandle != NULL && numFonts < 1) {
+    if (fontHandle != nullptr && numFonts < 1) {
         RemoveFontMemResourceEx(fontHandle);
-        return NULL;
+        return nullptr;
     }
 
     return fontHandle;
@@ -1925,19 +1925,19 @@
     char familyName[BASE64_GUID_ID_LEN];
     const int familyNameSize = SK_ARRAY_COUNT(familyName);
     if (FAILED(create_unique_font_name(familyName, familyNameSize))) {
-        return NULL;
+        return nullptr;
     }
 
     // Change the name of the font.
     SkAutoTUnref<SkData> rewrittenFontData(SkOTUtils::RenameFont(stream, familyName, familyNameSize-1));
-    if (NULL == rewrittenFontData.get()) {
-        return NULL;
+    if (nullptr == rewrittenFontData.get()) {
+        return nullptr;
     }
 
     // Register the font with GDI.
     HANDLE fontReference = activate_font(rewrittenFontData.get());
-    if (NULL == fontReference) {
-        return NULL;
+    if (nullptr == fontReference) {
+        return nullptr;
     }
 
     // Create the typeface.
@@ -1954,17 +1954,17 @@
         SkEndian_SwapBE32(SkSetFourByteTag('t', 't', 'c', 'f'));
     LOGFONT lf = fLogFont;
 
-    HDC hdc = ::CreateCompatibleDC(NULL);
+    HDC hdc = ::CreateCompatibleDC(nullptr);
     HFONT font = CreateFontIndirect(&lf);
     HFONT savefont = (HFONT)SelectObject(hdc, font);
 
-    SkMemoryStream* stream = NULL;
+    SkMemoryStream* stream = nullptr;
     DWORD tables[2] = {kTTCTag, 0};
     for (int i = 0; i < SK_ARRAY_COUNT(tables); i++) {
-        DWORD bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0);
+        DWORD bufferSize = GetFontData(hdc, tables[i], 0, nullptr, 0);
         if (bufferSize == GDI_ERROR) {
             call_ensure_accessible(lf);
-            bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0);
+            bufferSize = GetFontData(hdc, tables[i], 0, nullptr, 0);
         }
         if (bufferSize != GDI_ERROR) {
             stream = new SkMemoryStream(bufferSize);
@@ -1972,7 +1972,7 @@
                 break;
             } else {
                 delete stream;
-                stream = NULL;
+                stream = nullptr;
             }
         }
     }
@@ -2015,13 +2015,13 @@
     // Use uniscribe to detemine glyph index for non-BMP characters.
     static const int numWCHAR = 2;
     static const int maxItems = 2;
-    // MSDN states that this can be NULL, but some things don't work then.
+    // MSDN states that this can be nullptr, but some things don't work then.
     SCRIPT_CONTROL scriptControl = { 0 };
     // Add extra item to SCRIPT_ITEM to work around a bug (now documented).
     // https://bugzilla.mozilla.org/show_bug.cgi?id=366643
     SCRIPT_ITEM si[maxItems + 1];
     int numItems;
-    HRZM(ScriptItemize(utf16, numWCHAR, maxItems, &scriptControl, NULL, si, &numItems),
+    HRZM(ScriptItemize(utf16, numWCHAR, maxItems, &scriptControl, nullptr, si, &numItems),
          "Could not itemize character.");
 
     // Sometimes ScriptShape cannot find a glyph for a non-BMP and returns 2 space glyphs.
@@ -2042,7 +2042,7 @@
 class SkAutoHDC {
 public:
     SkAutoHDC(const LOGFONT& lf)
-        : fHdc(::CreateCompatibleDC(NULL))
+        : fHdc(::CreateCompatibleDC(nullptr))
         , fFont(::CreateFontIndirect(&lf))
         , fSavefont((HFONT)SelectObject(fHdc, fFont))
     { }
@@ -2075,7 +2075,7 @@
 
     SkAutoSTMalloc<256, uint16_t> scratchGlyphs;
     uint16_t* glyphs;
-    if (userGlyphs != NULL) {
+    if (userGlyphs != nullptr) {
         glyphs = userGlyphs;
     } else {
         glyphs = scratchGlyphs.reset(glyphCount);
@@ -2189,7 +2189,7 @@
 }
 
 int LogFontTypeface::onCountGlyphs() const {
-    HDC hdc = ::CreateCompatibleDC(NULL);
+    HDC hdc = ::CreateCompatibleDC(nullptr);
     HFONT font = CreateFontIndirect(&fLogFont);
     HFONT savefont = (HFONT)SelectObject(hdc, font);
 
@@ -2203,7 +2203,7 @@
 }
 
 int LogFontTypeface::onGetUPEM() const {
-    HDC hdc = ::CreateCompatibleDC(NULL);
+    HDC hdc = ::CreateCompatibleDC(nullptr);
     HFONT font = CreateFontIndirect(&fLogFont);
     HFONT savefont = (HFONT)SelectObject(hdc, font);
 
@@ -2219,7 +2219,7 @@
 SkTypeface::LocalizedStrings* LogFontTypeface::onCreateFamilyNameIterator() const {
     SkTypeface::LocalizedStrings* nameIter =
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this);
-    if (NULL == nameIter) {
+    if (nullptr == nameIter) {
         SkString familyName;
         this->getFamilyName(&familyName);
         SkString language("und"); //undetermined
@@ -2255,12 +2255,12 @@
 {
     LOGFONT lf = fLogFont;
 
-    HDC hdc = ::CreateCompatibleDC(NULL);
+    HDC hdc = ::CreateCompatibleDC(nullptr);
     HFONT font = CreateFontIndirect(&lf);
     HFONT savefont = (HFONT)SelectObject(hdc, font);
 
     tag = SkEndian_SwapBE32(tag);
-    if (NULL == data) {
+    if (nullptr == data) {
         length = 0;
     }
     DWORD bufferSize = GetFontData(hdc, tag, (DWORD) offset, data, (DWORD) length);
@@ -2280,7 +2280,7 @@
     SkScalerContext_GDI* ctx = new SkScalerContext_GDI(const_cast<LogFontTypeface*>(this), desc);
     if (!ctx->isValid()) {
         delete ctx;
-        ctx = NULL;
+        ctx = nullptr;
     }
     return ctx;
 }
@@ -2378,7 +2378,7 @@
         lf.lfCharSet = DEFAULT_CHARSET;
         _tcscpy_s(lf.lfFaceName, familyName);
 
-        HDC hdc = ::CreateCompatibleDC(NULL);
+        HDC hdc = ::CreateCompatibleDC(nullptr);
         ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fArray, 0);
         ::DeleteDC(hdc);
     }
@@ -2424,7 +2424,7 @@
         sk_bzero(&lf, sizeof(lf));
         lf.lfCharSet = DEFAULT_CHARSET;
 
-        HDC hdc = ::CreateCompatibleDC(NULL);
+        HDC hdc = ::CreateCompatibleDC(nullptr);
         ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fLogFontArray, 0);
         ::DeleteDC(hdc);
     }
@@ -2445,7 +2445,7 @@
     }
 
     SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
-        if (NULL == familyName) {
+        if (nullptr == familyName) {
             familyName = "";    // do we need this check???
         }
         LOGFONT lf;
@@ -2463,7 +2463,7 @@
     virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
                                                     const char* bcp47[], int bcp47Count,
                                                     SkUnichar character) const override {
-        return NULL;
+        return nullptr;
     }
 
     virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
@@ -2492,7 +2492,7 @@
     virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
                                                unsigned styleBits) const override {
         LOGFONT lf;
-        if (NULL == familyName) {
+        if (nullptr == familyName) {
             lf = get_default_font();
         } else {
             logfont_for_name(familyName, &lf);
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index dc89d91..0fd121e 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -124,7 +124,7 @@
 
 public:
     explicit SkFontStyleSet_Android(const FontFamily& family, const Scanner& scanner) {
-        const SkString* cannonicalFamilyName = NULL;
+        const SkString* cannonicalFamilyName = nullptr;
         if (family.fNames.count() > 0) {
             cannonicalFamilyName = &family.fNames[0];
         }
@@ -174,7 +174,7 @@
             // The first specified family name overrides the family name found in the font.
             // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return
             // all of the specified family names in addition to the names found in the font.
-            if (cannonicalFamilyName != NULL) {
+            if (cannonicalFamilyName != nullptr) {
                 familyName = *cannonicalFamilyName;
             }
 
@@ -244,7 +244,7 @@
     }
     SkTypeface_AndroidSystem* createTypeface(int index) override {
         if (index < 0 || fStyles.count() <= index) {
-            return NULL;
+            return nullptr;
         }
         return SkRef(fStyles[index].get());
     }
@@ -255,7 +255,7 @@
      */
     SkTypeface_AndroidSystem* matchStyle(const SkFontStyle& pattern) override {
         if (0 == fStyles.count()) {
-            return NULL;
+            return nullptr;
         }
         SkTypeface_AndroidSystem* closest = fStyles[0];
         int minScore = std::numeric_limits<int>::max();
@@ -342,14 +342,14 @@
 
     SkFontStyleSet* onCreateStyleSet(int index) const override {
         if (index < 0 || fNameToFamilyMap.count() <= index) {
-            return NULL;
+            return nullptr;
         }
         return SkRef(fNameToFamilyMap[index].styleSet);
     }
 
     SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
         if (!familyName) {
-            return NULL;
+            return nullptr;
         }
         SkAutoAsciiToLC tolc(familyName);
         for (int i = 0; i < fNameToFamilyMap.count(); ++i) {
@@ -363,7 +363,7 @@
                 return SkRef(fFallbackNameToFamilyMap[i].styleSet);
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
@@ -381,7 +381,7 @@
                 }
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     static SkTypeface_AndroidSystem* find_family_style_character(
@@ -411,7 +411,7 @@
                 return face.detach();
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
@@ -449,7 +449,7 @@
                 return matchingTypeface;
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
@@ -458,7 +458,7 @@
 
     SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
         SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
-        return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL;
+        return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr;
     }
 
     SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
@@ -466,10 +466,10 @@
         bool isFixedPitch;
         SkFontStyle style;
         SkString name;
-        if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, NULL)) {
-            return NULL;
+        if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nullptr)) {
+            return nullptr;
         }
-        SkFontData* data(new SkFontData(stream.detach(), ttcIndex, NULL, 0));
+        SkFontData* data(new SkFontData(stream.detach(), ttcIndex, nullptr, 0));
         return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
     }
 
@@ -478,8 +478,8 @@
         bool isFixedPitch;
         SkFontStyle style;
         SkString name;
-        if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixedPitch, NULL)) {
-            return NULL;
+        if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixedPitch, nullptr)) {
+            return nullptr;
         }
         return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
     }
@@ -490,7 +490,7 @@
         SkFontStyle style = SkFontStyle(styleBits);
 
         if (familyName) {
-            // On Android, we must return NULL when we can't find the requested
+            // On Android, we must return nullptr when we can't find the requested
             // named typeface so that the system/app can provide their own recovery
             // mechanism. On other platforms we'd provide a typeface from the
             // default family instead.
@@ -546,18 +546,18 @@
         static const char* gDefaultNames[] = { "sans-serif" };
         for (size_t i = 0; i < SK_ARRAY_COUNT(gDefaultNames); ++i) {
             SkFontStyleSet* set = this->onMatchFamily(gDefaultNames[i]);
-            if (NULL == set) {
+            if (nullptr == set) {
                 continue;
             }
             SkTypeface* tf = set->matchStyle(SkFontStyle());
-            if (NULL == tf) {
+            if (nullptr == tf) {
                 continue;
             }
             fDefaultFamily = set;
             fDefaultTypeface = tf;
             break;
         }
-        if (NULL == fDefaultTypeface) {
+        if (nullptr == fDefaultTypeface) {
             fDefaultFamily = fFontStyleSets[0];
             fDefaultTypeface = fDefaultFamily->createTypeface(0);
         }
diff --git a/src/ports/SkFontMgr_android_factory.cpp b/src/ports/SkFontMgr_android_factory.cpp
index 7f48561..96d8931 100644
--- a/src/ports/SkFontMgr_android_factory.cpp
+++ b/src/ports/SkFontMgr_android_factory.cpp
@@ -9,9 +9,9 @@
 #include "SkFontMgr_android.h"
 
 // For test only.
-static const char* gTestFontsXml = NULL;
-static const char* gTestFallbackFontsXml = NULL;
-static const char* gTestBasePath = NULL;
+static const char* gTestFontsXml = nullptr;
+static const char* gTestFallbackFontsXml = nullptr;
+static const char* gTestBasePath = nullptr;
 
 void SkUseTestFontConfigFile(const char* fontsXml, const char* fallbackFontsXml,
                              const char* basePath)
@@ -39,5 +39,5 @@
         return SkFontMgr_New_Android(&custom);
     }
 
-    return SkFontMgr_New_Android(NULL);
+    return SkFontMgr_New_Android(nullptr);
 }
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp
index 53decf3..83b1c4a 100644
--- a/src/ports/SkFontMgr_android_parser.cpp
+++ b/src/ports/SkFontMgr_android_parser.cpp
@@ -51,28 +51,28 @@
     /** Called at the start tag.
      *  Called immediately after the parent tag retuns this handler from a call to 'tag'.
      *  Allows setting up for handling the tag content and processing attributes.
-     *  If NULL, will not be called.
+     *  If nullptr, will not be called.
      */
     void (*start)(FamilyData* data, const char* tag, const char** attributes);
 
     /** Called at the end tag.
      *  Allows post-processing of any accumulated information.
      *  This will be the last call made in relation to the current tag.
-     *  If NULL, will not be called.
+     *  If nullptr, will not be called.
      */
     void (*end)(FamilyData* data, const char* tag);
 
     /** Called when a nested tag is encountered.
      *  This is responsible for determining how to handle the tag.
-     *  If the tag is not recognized, return NULL to skip the tag.
-     *  If NULL, all nested tags will be skipped.
+     *  If the tag is not recognized, return nullptr to skip the tag.
+     *  If nullptr, all nested tags will be skipped.
      */
     const TagHandler* (*tag)(FamilyData* data, const char* tag, const char** attributes);
 
     /** The character handler for this tag.
      *  This is only active for character data contained directly in this tag (not sub-tags).
      *  The first parameter will be castable to a FamilyData*.
-     *  If NULL, any character data in this tag will be ignored.
+     *  If nullptr, any character data in this tag will be ignored.
      */
     XML_CharacterDataHandler chars;
 };
@@ -84,8 +84,8 @@
                const TagHandler* topLevelHandler)
         : fParser(parser)
         , fFamilies(families)
-        , fCurrentFamily(NULL)
-        , fCurrentFontInfo(NULL)
+        , fCurrentFamily(nullptr)
+        , fCurrentFontInfo(nullptr)
         , fVersion(0)
         , fBasePath(basePath)
         , fIsFallback(isFallback)
@@ -114,7 +114,7 @@
 }
 #define MEMEQ(c, s, n) memeq(c, s, sizeof(c) - 1, n)
 
-#define ATTS_NON_NULL(a, i) (a[i] != NULL && a[i+1] != NULL)
+#define ATTS_NON_NULL(a, i) (a[i] != nullptr && a[i+1] != nullptr)
 
 #define SK_FONTMGR_ANDROID_PARSER_PREFIX "[SkFontMgr Android Parser] "
 
@@ -178,9 +178,9 @@
             }
         }
     },
-    /*end*/NULL,
-    /*tag*/NULL,
-    /*chars*/NULL,
+    /*end*/nullptr,
+    /*tag*/nullptr,
+    /*chars*/nullptr,
 };
 
 static const TagHandler fontHandler = {
@@ -221,7 +221,7 @@
         if (MEMEQ("axis", tag, len)) {
             return &axisHandler;
         }
-        return NULL;
+        return nullptr;
     },
     /*chars*/[](void* data, const char* s, int len) {
         FamilyData* self = static_cast<FamilyData*>(data);
@@ -265,9 +265,9 @@
         if (MEMEQ("font", tag, len)) {
             return &fontHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 static FontFamily* find_family(FamilyData* self, const SkString& familyName) {
@@ -279,7 +279,7 @@
             }
         }
     }
-    return NULL;
+    return nullptr;
 }
 
 static const TagHandler aliasHandler = {
@@ -331,14 +331,14 @@
             targetFamily->fNames.push_back().set(aliasName);
         }
     },
-    /*end*/NULL,
-    /*tag*/NULL,
-    /*chars*/NULL,
+    /*end*/nullptr,
+    /*tag*/nullptr,
+    /*chars*/nullptr,
 };
 
 static const TagHandler familySetHandler = {
     /*start*/[](FamilyData* self, const char* tag, const char** attributes) { },
-    /*end*/NULL,
+    /*end*/nullptr,
     /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
         size_t len = strlen(tag);
         if (MEMEQ("family", tag, len)) {
@@ -346,9 +346,9 @@
         } else if (MEMEQ("alias", tag, len)) {
             return &aliasHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 } // lmpParser
@@ -400,8 +400,8 @@
         }
         self->fCurrentFontInfo = &newFileInfo;
     },
-    /*end*/NULL,
-    /*tag*/NULL,
+    /*end*/nullptr,
+    /*tag*/nullptr,
     /*chars*/[](void* data, const char* s, int len) {
         FamilyData* self = static_cast<FamilyData*>(data);
         self->fCurrentFontInfo->fFileName.append(s, len);
@@ -409,16 +409,16 @@
 };
 
 static const TagHandler fileSetHandler = {
-    /*start*/NULL,
-    /*end*/NULL,
+    /*start*/nullptr,
+    /*end*/nullptr,
     /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
         size_t len = strlen(tag);
         if (MEMEQ("file", tag, len)) {
             return &fileHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 static const TagHandler nameHandler = {
@@ -426,8 +426,8 @@
         // The character data should be a name for the font.
         self->fCurrentFamily->fNames.push_back();
     },
-    /*end*/NULL,
-    /*tag*/NULL,
+    /*end*/nullptr,
+    /*tag*/nullptr,
     /*chars*/[](void* data, const char* s, int len) {
         FamilyData* self = static_cast<FamilyData*>(data);
         SkAutoAsciiToLC tolc(s, len);
@@ -436,16 +436,16 @@
 };
 
 static const TagHandler nameSetHandler = {
-    /*start*/NULL,
-    /*end*/NULL,
+    /*start*/nullptr,
+    /*end*/nullptr,
     /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
         size_t len = strlen(tag);
         if (MEMEQ("name", tag, len)) {
             return &nameHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 static const TagHandler familyHandler = {
@@ -467,29 +467,29 @@
         } else if (MEMEQ("fileset", tag, len)) {
             return &fileSetHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 static const TagHandler familySetHandler = {
-    /*start*/NULL,
-    /*end*/NULL,
+    /*start*/nullptr,
+    /*end*/nullptr,
     /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
         size_t len = strlen(tag);
         if (MEMEQ("family", tag, len)) {
             return &familyHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 } // namespace jbParser
 
 static const TagHandler topLevelHandler = {
-    /*start*/NULL,
-    /*end*/NULL,
+    /*start*/nullptr,
+    /*end*/nullptr,
     /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
         size_t len = strlen(tag);
         if (MEMEQ("familyset", tag, len)) {
@@ -508,9 +508,9 @@
             }
             return &jbParser::familySetHandler;
         }
-        return NULL;
+        return nullptr;
     },
-    /*chars*/NULL,
+    /*chars*/nullptr,
 };
 
 static void XMLCALL start_element_handler(void *data, const char *tag, const char **attributes) {
@@ -518,7 +518,7 @@
 
     if (!self->fSkip) {
         const TagHandler* parent = self->fHandler.top();
-        const TagHandler* child = parent->tag ? parent->tag(self, tag, attributes) : NULL;
+        const TagHandler* child = parent->tag ? parent->tag(self, tag, attributes) : nullptr;
         if (child) {
             if (child->start) {
                 child->start(self, tag, attributes);
@@ -527,7 +527,7 @@
             XML_SetCharacterDataHandler(self->fParser, child->chars);
         } else {
             SK_FONTCONFIGPARSER_WARNING("'%s' tag not recognized, skipping", tag);
-            XML_SetCharacterDataHandler(self->fParser, NULL);
+            XML_SetCharacterDataHandler(self->fParser, nullptr);
             self->fSkip = self->fDepth;
         }
     }
@@ -597,7 +597,7 @@
     }
 
     SkAutoTCallVProc<remove_ptr<XML_Parser>::type, XML_ParserFree> parser(
-        XML_ParserCreate_MM(NULL, &sk_XML_alloc, NULL));
+        XML_ParserCreate_MM(nullptr, &sk_XML_alloc, nullptr));
     if (!parser) {
         SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "could not create XML parser\n");
         return -1;
@@ -669,7 +669,7 @@
 #endif
 
     SkAutoTCallIProc<DIR, closedir> fontDirectory(opendir(dir));
-    if (NULL == fontDirectory) {
+    if (nullptr == fontDirectory) {
         return;
     }
 
@@ -789,7 +789,7 @@
 
     // strip off the rightmost "-.*"
     const char* parentTagEnd = strrchr(tag, '-');
-    if (parentTagEnd == NULL) {
+    if (parentTagEnd == nullptr) {
         return SkLanguage();
     }
     size_t parentTagLen = parentTagEnd - tag;
diff --git a/src/ports/SkFontMgr_android_parser.h b/src/ports/SkFontMgr_android_parser.h
index ca66c43..aca1573 100644
--- a/src/ports/SkFontMgr_android_parser.h
+++ b/src/ports/SkFontMgr_android_parser.h
@@ -115,7 +115,7 @@
                            const SkString& basePath,
                            const char* fontsXml,
                            const char* fallbackFontsXml,
-                           const char* langFallbackFontsDir = NULL);
+                           const char* langFallbackFontsDir = nullptr);
 
 } // SkFontMgr_Android_Parser namespace
 
diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
index 496a54c..7f3ce6b 100644
--- a/src/ports/SkFontMgr_custom.cpp
+++ b/src/ports/SkFontMgr_custom.cpp
@@ -63,7 +63,7 @@
     SkTypeface_Empty() : INHERITED(SkFontStyle(), false, true, SkString(), 0) {}
 
 protected:
-    SkStreamAsset* onOpenStream(int*) const override { return NULL; }
+    SkStreamAsset* onOpenStream(int*) const override { return nullptr; }
 
 private:
     typedef SkTypeface_Custom INHERITED;
@@ -156,7 +156,7 @@
 
     SkTypeface* matchStyle(const SkFontStyle& pattern) override {
         if (0 == fStyles.count()) {
-            return NULL;
+            return nullptr;
         }
 
         SkTypeface_Custom* closest = fStyles[0];
@@ -203,30 +203,30 @@
         virtual ~SystemFontLoader() { }
         virtual void loadSystemFonts(const SkTypeface_FreeType::Scanner&, Families*) const = 0;
     };
-    explicit SkFontMgr_Custom(const SystemFontLoader& loader) : fDefaultFamily(NULL) {
+    explicit SkFontMgr_Custom(const SystemFontLoader& loader) : fDefaultFamily(nullptr) {
         loader.loadSystemFonts(fScanner, &fFamilies);
 
         // Try to pick a default font.
         static const char* defaultNames[] = {
-            "Arial", "Verdana", "Times New Roman", "Droid Sans", NULL
+            "Arial", "Verdana", "Times New Roman", "Droid Sans", nullptr
         };
         for (size_t i = 0; i < SK_ARRAY_COUNT(defaultNames); ++i) {
             SkFontStyleSet_Custom* set = this->onMatchFamily(defaultNames[i]);
-            if (NULL == set) {
+            if (nullptr == set) {
                 continue;
             }
 
             SkTypeface* tf = set->matchStyle(SkFontStyle(SkFontStyle::kNormal_Weight,
                                                          SkFontStyle::kNormal_Width,
                                                          SkFontStyle::kUpright_Slant));
-            if (NULL == tf) {
+            if (nullptr == tf) {
                 continue;
             }
 
             fDefaultFamily = set;
             break;
         }
-        if (NULL == fDefaultFamily) {
+        if (nullptr == fDefaultFamily) {
             fDefaultFamily = fFamilies[0];
         }
     }
@@ -252,7 +252,7 @@
                 return SkRef(fFamilies[i].get());
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* onMatchFamilyStyle(const char familyName[],
@@ -266,7 +266,7 @@
                                             const char* bcp47[], int bcp47Count,
                                             SkUnichar character) const override
     {
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
@@ -279,7 +279,7 @@
                 }
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
@@ -288,24 +288,24 @@
 
     SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
         SkAutoTDelete<SkStreamAsset> stream(bareStream);
-        if (NULL == stream || stream->getLength() <= 0) {
-            return NULL;
+        if (nullptr == stream || stream->getLength() <= 0) {
+            return nullptr;
         }
 
         bool isFixedPitch;
         SkFontStyle style;
         SkString name;
-        if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, NULL)) {
+        if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nullptr)) {
             return new SkTypeface_Stream(style, isFixedPitch, false, name, stream.detach(),
                                          ttcIndex);
         } else {
-            return NULL;
+            return nullptr;
         }
     }
 
     SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
         SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
-        return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL;
+        return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr;
     }
 
     SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const override {
@@ -317,13 +317,13 @@
                                         oldStyle & SkTypeface::kItalic
                                                  ? SkFontStyle::kItalic_Slant
                                                  : SkFontStyle::kUpright_Slant);
-        SkTypeface* tf = NULL;
+        SkTypeface* tf = nullptr;
 
         if (familyName) {
             tf = this->onMatchFamilyStyle(familyName, style);
         }
 
-        if (NULL == tf) {
+        if (nullptr == tf) {
             tf = fDefaultFamily->matchStyle(style);
         }
 
@@ -366,7 +366,7 @@
                 return families[i].get();
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     static void load_directory_fonts(const SkTypeface_FreeType::Scanner& scanner,
@@ -394,7 +394,7 @@
                 bool isFixedPitch;
                 SkString realname;
                 SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
-                if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, NULL)) {
+                if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, nullptr)) {
                     SkDebugf("---- failed to open <%s> <%d> as a font\n",
                              filename.c_str(), faceIndex);
                     continue;
@@ -405,7 +405,7 @@
                                                             realname, filename.c_str(), faceIndex);
 
                 SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
-                if (NULL == addTo) {
+                if (nullptr == addTo) {
                     addTo = new SkFontStyleSet_Custom(realname);
                     families->push_back().reset(addTo);
                 }
@@ -463,7 +463,7 @@
                 return families[i].get();
             }
         }
-        return NULL;
+        return nullptr;
     }
 
     static void load_embedded_font(const SkTypeface_FreeType::Scanner& scanner,
@@ -482,7 +482,7 @@
             bool isFixedPitch;
             SkString realname;
             SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
-            if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, NULL)) {
+            if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, nullptr)) {
                 SkDebugf("---- failed to open <%d> <%d> as a font\n", index, faceIndex);
                 return;
             }
@@ -492,7 +492,7 @@
                                           realname, stream.detach(), faceIndex);
 
             SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
-            if (NULL == addTo) {
+            if (nullptr == addTo) {
                 addTo = new SkFontStyleSet_Custom(realname);
                 families->push_back().reset(addTo);
             }
diff --git a/src/ports/SkFontMgr_empty_factory.cpp b/src/ports/SkFontMgr_empty_factory.cpp
index ceed8f3..b4232cd 100644
--- a/src/ports/SkFontMgr_empty_factory.cpp
+++ b/src/ports/SkFontMgr_empty_factory.cpp
@@ -8,6 +8,6 @@
 #include "SkFontMgr.h"
 
 SkFontMgr* SkFontMgr::Factory() {
-    // Always return NULL, an empty SkFontMgr will be used.
-    return NULL;
+    // Always return nullptr, an empty SkFontMgr will be used.
+    return nullptr;
 }
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 3dc1ea0..7682523 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -113,7 +113,7 @@
 public:
     SkAutoFc() : SkAutoTCallVProc<T, FcTDestroy<T, D> >(C()) {
         T* obj = this->operator T*();
-        SK_ALWAYSBREAK(NULL != obj);
+        SK_ALWAYSBREAK(nullptr != obj);
     }
     explicit SkAutoFc(T* obj) : SkAutoTCallVProc<T, FcTDestroy<T, D> >(obj) {}
 };
@@ -162,7 +162,7 @@
 
     // Create a copy of the pattern with only the value 'pattern'['object'['id']] in it.
     // Internally, FontConfig pattern objects are linked lists, so faster to remove from head.
-    SkAutoFcObjectSet requestedObjectOnly(FcObjectSetBuild(object, NULL));
+    SkAutoFcObjectSet requestedObjectOnly(FcObjectSetBuild(object, nullptr));
     SkAutoFcPattern minimal(FcPatternFilter(pattern, requestedObjectOnly));
     FcBool hasId = true;
     for (int i = 0; hasId && i < id; ++i) {
@@ -226,7 +226,7 @@
 static void remove_weak(FcPattern* pattern, const char object[]) {
     FCLocker::AssertHeld();
 
-    SkAutoFcObjectSet requestedObjectOnly(FcObjectSetBuild(object, NULL));
+    SkAutoFcObjectSet requestedObjectOnly(FcObjectSetBuild(object, nullptr));
     SkAutoFcPattern minimal(FcPatternFilter(pattern, requestedObjectOnly));
 
     int lastStrongId = -1;
@@ -512,8 +512,8 @@
             SkAutoFcPattern match(FcFontSetMatch(fFontMgr->fFC,
                                                  fontSets, SK_ARRAY_COUNT(fontSets),
                                                  pattern, &result));
-            if (NULL == match) {
-                return NULL;
+            if (nullptr == match) {
+                return nullptr;
             }
 
             return fFontMgr->createTypefaceFromFcPattern(match);
@@ -544,7 +544,7 @@
         for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setIndex) {
             // Return value of FcConfigGetFonts must not be destroyed.
             FcFontSet* allFonts(FcConfigGetFonts(fcconfig, fcNameSet[setIndex]));
-            if (NULL == allFonts) {
+            if (nullptr == allFonts) {
                 continue;
             }
 
@@ -587,7 +587,7 @@
         FCLocker::AssertHeld();
         SkAutoMutexAcquire ama(fTFCacheMutex);
         SkTypeface* face = fTFCache.findByProcAndRef(FindByFcPattern, pattern);
-        if (NULL == face) {
+        if (nullptr == face) {
             FcPatternReference(pattern);
             face = SkTypeface_fontconfig::Create(pattern);
             if (face) {
@@ -658,8 +658,8 @@
 
     static bool FontAccessible(FcPattern* font) {
         // FontConfig can return fonts which are unreadable.
-        const char* filename = get_string(font, FC_FILE, NULL);
-        if (NULL == filename) {
+        const char* filename = get_string(font, FC_FILE, nullptr);
+        if (nullptr == filename) {
             return false;
         }
         return sk_exists(filename, kRead_SkFILE_Flag);
@@ -696,7 +696,7 @@
         FcDefaultSubstitute(pattern);
 
         FcPattern* matchPattern;
-        SkAutoFcPattern strongPattern(NULL);
+        SkAutoFcPattern strongPattern(nullptr);
         if (familyName) {
             strongPattern.reset(FcPatternDuplicate(pattern));
             remove_weak(strongPattern, FC_FAMILY);
@@ -713,7 +713,7 @@
         for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setIndex) {
             // Return value of FcConfigGetFonts must not be destroyed.
             FcFontSet* allFonts(FcConfigGetFonts(fFC, fcNameSet[setIndex]));
-            if (NULL == allFonts) {
+            if (nullptr == allFonts) {
                 continue;
             }
 
@@ -748,7 +748,7 @@
         // In aliases, bindings are weak by default, so this is easy and common.
         // If no family name was specified, we'll probably only get weak matches, but that's ok.
         FcPattern* matchPattern;
-        SkAutoFcPattern strongPattern(NULL);
+        SkAutoFcPattern strongPattern(nullptr);
         if (familyName) {
             strongPattern.reset(FcPatternDuplicate(pattern));
             remove_weak(strongPattern, FC_FAMILY);
@@ -759,8 +759,8 @@
 
         FcResult result;
         SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result));
-        if (NULL == font || !FontAccessible(font) || !FontFamilyNameMatches(font, matchPattern)) {
-            return NULL;
+        if (nullptr == font || !FontAccessible(font) || !FontFamilyNameMatches(font, matchPattern)) {
+            return nullptr;
         }
 
         return createTypefaceFromFcPattern(font);
@@ -801,8 +801,8 @@
 
         FcResult result;
         SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result));
-        if (NULL == font || !FontAccessible(font) || !FontContainsCharacter(font, character)) {
-            return NULL;
+        if (nullptr == font || !FontAccessible(font) || !FontContainsCharacter(font, character)) {
+            return nullptr;
         }
 
         return createTypefaceFromFcPattern(font);
@@ -821,16 +821,16 @@
         SkAutoTDelete<SkStreamAsset> stream(bareStream);
         const size_t length = stream->getLength();
         if (length <= 0 || (1u << 30) < length) {
-            return NULL;
+            return nullptr;
         }
 
         SkFontStyle style;
         bool isFixedWidth = false;
-        if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth, NULL)) {
-            return NULL;
+        if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) {
+            return nullptr;
         }
 
-        return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, NULL, 0), style,
+        return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, nullptr, 0), style,
                                      isFixedWidth);
     }
 
@@ -846,14 +846,14 @@
         SkStreamAsset* stream(fontData->getStream());
         const size_t length = stream->getLength();
         if (length <= 0 || (1u << 30) < length) {
-            return NULL;
+            return nullptr;
         }
 
         const int ttcIndex = fontData->getIndex();
         SkFontStyle style;
         bool isFixedWidth = false;
-        if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth, NULL)) {
-            return NULL;
+        if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) {
+            return nullptr;
         }
 
         return new SkTypeface_stream(fontData, style, isFixedWidth);
@@ -873,7 +873,7 @@
             return typeface.detach();
         }
 
-        return this->matchFamilyStyle(NULL, style);
+        return this->matchFamilyStyle(nullptr, style);
     }
 };
 
diff --git a/src/ports/SkFontMgr_fontconfig_factory.cpp b/src/ports/SkFontMgr_fontconfig_factory.cpp
index 78792fa..cdf0556 100644
--- a/src/ports/SkFontMgr_fontconfig_factory.cpp
+++ b/src/ports/SkFontMgr_fontconfig_factory.cpp
@@ -10,5 +10,5 @@
 #include "SkTypes.h"
 
 SkFontMgr* SkFontMgr::Factory() {
-    return SkFontMgr_New_FontConfig(NULL);
+    return SkFontMgr_New_FontConfig(nullptr);
 }
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index df51764..e40c5e4 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -42,7 +42,7 @@
     // Takes ownership of stream.
     static HRESULT Create(SkStreamAsset* stream, StreamFontFileLoader** streamFontFileLoader) {
         *streamFontFileLoader = new StreamFontFileLoader(stream);
-        if (NULL == streamFontFileLoader) {
+        if (nullptr == streamFontFileLoader) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
@@ -63,7 +63,7 @@
         AddRef();
         return S_OK;
     } else {
-        *ppvObject = NULL;
+        *ppvObject = nullptr;
         return E_NOINTERFACE;
     }
 }
@@ -107,7 +107,7 @@
     static HRESULT Create(IDWriteFactory* factory, IDWriteFontFileLoader* fontFileLoader,
                           StreamFontFileEnumerator** streamFontFileEnumerator) {
         *streamFontFileEnumerator = new StreamFontFileEnumerator(factory, fontFileLoader);
-        if (NULL == streamFontFileEnumerator) {
+        if (nullptr == streamFontFileEnumerator) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
@@ -139,7 +139,7 @@
         AddRef();
         return S_OK;
     } else {
-        *ppvObject = NULL;
+        *ppvObject = nullptr;
         return E_NOINTERFACE;
     }
 }
@@ -166,7 +166,7 @@
 
     UINT32 dummy = 0;
     HR(fFactory->CreateCustomFontFileReference(
-            &dummy, //cannot be NULL
+            &dummy, //cannot be nullptr
             sizeof(dummy), //even if this is 0
             fFontFileLoader.get(),
             &fCurrentFile));
@@ -176,8 +176,8 @@
 }
 
 HRESULT StreamFontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** fontFile) {
-    if (fCurrentFile.get() == NULL) {
-        *fontFile = NULL;
+    if (fCurrentFile.get() == nullptr) {
+        *fontFile = nullptr;
         return E_FAIL;
     }
 
@@ -204,7 +204,7 @@
     static HRESULT Create(IDWriteFontFileLoader* fontFileLoader,
                           StreamFontCollectionLoader** streamFontCollectionLoader) {
         *streamFontCollectionLoader = new StreamFontCollectionLoader(fontFileLoader);
-        if (NULL == streamFontCollectionLoader) {
+        if (nullptr == streamFontCollectionLoader) {
             return E_OUTOFMEMORY;
         }
         return S_OK;
@@ -226,7 +226,7 @@
         AddRef();
         return S_OK;
     } else {
-        *ppvObject = NULL;
+        *ppvObject = nullptr;
         return E_NOINTERFACE;
     }
 }
@@ -268,9 +268,9 @@
     {
 #if SK_HAS_DWRITE_2_H
         if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) {
-            // IUnknown::QueryInterface states that if it fails, punk will be set to NULL.
+            // IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
             // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
-            SK_ALWAYSBREAK(NULL == fFactory2.get());
+            SK_ALWAYSBREAK(nullptr == fFactory2.get());
         }
 #endif
         memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR));
@@ -370,8 +370,8 @@
     //Check if the two fonts share the same loader and have the same key.
     UINT32 cshNumFiles;
     UINT32 ctxNumFiles;
-    HRB(cshFace->fDWriteFontFace->GetFiles(&cshNumFiles, NULL));
-    HRB(ctxFace->fDWriteFontFace->GetFiles(&ctxNumFiles, NULL));
+    HRB(cshFace->fDWriteFontFace->GetFiles(&cshNumFiles, nullptr));
+    HRB(ctxFace->fDWriteFontFace->GetFiles(&ctxNumFiles, nullptr));
     if (cshNumFiles != ctxNumFiles) {
         return false;
     }
@@ -452,7 +452,7 @@
     SkAutoMutexAcquire ama(fTFCacheMutex);
     ProtoDWriteTypeface spec = { fontFace, font, fontFamily };
     SkTypeface* face = fTFCache.findByProcAndRef(FindByDWriteFont, &spec);
-    if (NULL == face) {
+    if (nullptr == face) {
         face = DWriteFontTypeface::Create(fFactory.get(), fontFace, font, fontFamily);
         if (face) {
             fTFCache.add(face, get_style(font));
@@ -491,7 +491,7 @@
     HRNM(fFontCollection->FindFamilyName(dwFamilyName.get(), &index, &exists),
             "Failed while finding family by name.");
     if (!exists) {
-        return NULL;
+        return nullptr;
     }
 
     return this->onCreateStyleSet(index);
@@ -506,7 +506,7 @@
 class FontFallbackRenderer : public IDWriteTextRenderer {
 public:
     FontFallbackRenderer(const SkFontMgr_DirectWrite* outer, UINT32 character)
-        : fRefCount(1), fOuter(SkSafeRef(outer)), fCharacter(character), fResolvedTypeface(NULL) {
+        : fRefCount(1), fOuter(SkSafeRef(outer)), fCharacter(character), fResolvedTypeface(nullptr) {
     }
 
     virtual ~FontFallbackRenderer() { }
@@ -616,7 +616,7 @@
             this->AddRef();
             return S_OK;
         }
-        *ppvObject = NULL;
+        *ppvObject = nullptr;
         return E_FAIL;
     }
 
@@ -648,7 +648,7 @@
         UINT32* textLength) override
     {
         if (fLength <= textPosition) {
-            *textString = NULL;
+            *textString = nullptr;
             *textLength = 0;
             return S_OK;
         }
@@ -663,7 +663,7 @@
         UINT32* textLength) override
     {
         if (textPosition < 1 || fLength <= textPosition) {
-            *textString = NULL;
+            *textString = nullptr;
             *textLength = 0;
             return S_OK;
         }
@@ -716,7 +716,7 @@
             this->AddRef();
             return S_OK;
         }
-        *ppvObject = NULL;
+        *ppvObject = nullptr;
         return E_FAIL;
     }
 
@@ -735,7 +735,7 @@
 {
     const DWriteStyle dwStyle(style);
 
-    const WCHAR* dwFamilyName = NULL;
+    const WCHAR* dwFamilyName = nullptr;
     SkSMallocWCHAR dwFamilyNameLocal;
     if (familyName) {
         HRN(sk_cstring_to_wchar(familyName, &dwFamilyNameLocal));
@@ -764,7 +764,7 @@
         HRNM(fFactory2->GetSystemFontFallback(&fontFallback), "Could not get system fallback.");
 
         SkTScopedComPtr<IDWriteNumberSubstitution> numberSubstitution;
-        HRNM(fFactory2->CreateNumberSubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, NULL, TRUE,
+        HRNM(fFactory2->CreateNumberSubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, nullptr, TRUE,
                                                  &numberSubstitution),
              "Could not create number substitution.");
         SkTScopedComPtr<FontFallbackSource> fontFallbackSource(
@@ -786,7 +786,7 @@
                                          &scale),
              "Could not map characters");
         if (!font.get()) {
-            return NULL;
+            return nullptr;
         }
 
         SkTScopedComPtr<IDWriteFontFace> fontFace;
@@ -820,7 +820,7 @@
     SkTScopedComPtr<FontFallbackRenderer> fontFallbackRenderer(
         new FontFallbackRenderer(this, character));
 
-    HRNM(fallbackLayout->Draw(NULL, fontFallbackRenderer.get(), 50.0f, 50.0f),
+    HRNM(fallbackLayout->Draw(nullptr, fontFallbackRenderer.get(), 50.0f, 50.0f),
          "Could not draw layout with renderer.");
 
     return fontFallbackRenderer->FallbackTypeface();
@@ -849,7 +849,7 @@
 
     T* detatch() {
         T* old = fUnregister;
-        fUnregister = NULL;
+        fUnregister = nullptr;
         return old;
     }
 
@@ -881,7 +881,7 @@
         fFactory.get(), fontCollectionLoader.get());
 
     SkTScopedComPtr<IDWriteFontCollection> fontCollection;
-    HRN(fFactory->CreateCustomFontCollection(fontCollectionLoader.get(), NULL, 0, &fontCollection));
+    HRN(fFactory->CreateCustomFontCollection(fontCollectionLoader.get(), nullptr, 0, &fontCollection));
 
     // Find the first non-simulated font which has the given ttc index.
     UINT32 familyCount = fontCollection->GetFontFamilyCount();
@@ -910,7 +910,7 @@
         }
     }
 
-    return NULL;
+    return nullptr;
 }
 
 SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex) const {
@@ -957,12 +957,12 @@
         }
     }
 
-    if (NULL == fontFamily.get()) {
+    if (nullptr == fontFamily.get()) {
         // No family with given name, try default.
         HRNM(this->getDefaultFontFamily(&fontFamily), "Could not get default font family.");
     }
 
-    if (NULL == fontFamily.get()) {
+    if (nullptr == fontFamily.get()) {
         // Could not obtain the default font.
         HRNM(fFontCollection->GetFontFamily(0, &fontFamily),
              "Could not get default-default font family.");
@@ -1065,10 +1065,10 @@
 #include "SkTypeface_win.h"
 
 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
-    if (NULL == factory) {
+    if (nullptr == factory) {
         factory = sk_get_dwrite_factory();
-        if (NULL == factory) {
-            return NULL;
+        if (nullptr == factory) {
+            return nullptr;
         }
     }
 
@@ -1077,13 +1077,13 @@
          "Could not get system font collection.");
 
     WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
-    WCHAR* localeName = NULL;
+    WCHAR* localeName = nullptr;
     int localeNameLen = 0;
 
     // Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
-    SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = NULL;
+    SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr;
     HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc);
-    if (NULL == getUserDefaultLocaleNameProc) {
+    if (nullptr == getUserDefaultLocaleNameProc) {
         SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
     } else {
         localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
@@ -1098,8 +1098,8 @@
 #include "SkFontMgr_indirect.h"
 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) {
     SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite());
-    if (impl.get() == NULL) {
-        return NULL;
+    if (impl.get() == nullptr) {
+        return nullptr;
     }
     return new SkFontMgr_Indirect(impl.get(), proxy);
 }
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index e1e6dc1..bd94764 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -41,7 +41,7 @@
 static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) {
     CGDataProviderRef data = SkStreamToDataProvider(stream);
     if (!data) {
-        return NULL;
+        return nullptr;
     }
     CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0);
     CGDataProviderRelease(data);
@@ -134,13 +134,13 @@
 SkImageDecoder::Result SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
     CGImageSourceRef imageSrc = SkStreamToCGImageSource(stream);
 
-    if (NULL == imageSrc) {
+    if (nullptr == imageSrc) {
         return kFailure;
     }
     SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc);
 
-    CGImageRef image = CGImageSourceCreateImageAtIndex(imageSrc, 0, NULL);
-    if (NULL == image) {
+    CGImageRef image = CGImageSourceCreateImageAtIndex(imageSrc, 0, nullptr);
+    if (nullptr == image) {
         return kFailure;
     }
     SkAutoTCallVProc<CGImage, CGImageRelease> arimage(image);
@@ -173,7 +173,7 @@
         return kSuccess;
     }
 
-    if (!this->allocPixelRef(bm, NULL)) {
+    if (!this->allocPixelRef(bm, nullptr)) {
         return kFailure;
     }
 
@@ -219,7 +219,7 @@
 
 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) {
     SkImageDecoder* decoder = image_decoder_from_stream(stream);
-    if (NULL == decoder) {
+    if (nullptr == decoder) {
         // If no image decoder specific to the stream exists, use SkImageDecoder_CG.
         return new SkImageDecoder_CG;
     } else {
@@ -230,7 +230,7 @@
 /////////////////////////////////////////////////////////////////////////
 
 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
-    return NULL;
+    return nullptr;
 }
 
 /////////////////////////////////////////////////////////////////////////
@@ -256,12 +256,12 @@
 static CGImageDestinationRef SkStreamToImageDestination(SkWStream* stream,
                                                         CFStringRef type) {
     CGDataConsumerRef consumer = SkStreamToCGDataConsumer(stream);
-    if (NULL == consumer) {
-        return NULL;
+    if (nullptr == consumer) {
+        return nullptr;
     }
     SkAutoTCallVProc<const void, CFRelease> arconsumer(consumer);
 
-    return CGImageDestinationCreateWithDataConsumer(consumer, type, 1, NULL);
+    return CGImageDestinationCreateWithDataConsumer(consumer, type, 1, nullptr);
 }
 
 class SkImageEncoder_CG : public SkImageEncoder {
@@ -316,18 +316,18 @@
     }
 
     CGImageDestinationRef dst = SkStreamToImageDestination(stream, type);
-    if (NULL == dst) {
+    if (nullptr == dst) {
         return false;
     }
     SkAutoTCallVProc<const void, CFRelease> ardst(dst);
 
     CGImageRef image = SkCreateCGImageRef(*bmPtr);
-    if (NULL == image) {
+    if (nullptr == image) {
         return false;
     }
     SkAutoTCallVProc<CGImage, CGImageRelease> agimage(image);
 
-    CGImageDestinationAddImage(dst, image, NULL);
+    CGImageDestinationAddImage(dst, image, nullptr);
     return CGImageDestinationFinalize(dst);
 }
 
@@ -342,7 +342,7 @@
         case SkImageEncoder::kPNG_Type:
             break;
         default:
-            return NULL;
+            return nullptr;
     }
     return new SkImageEncoder_CG(t);
 }
@@ -388,13 +388,13 @@
 static SkImageDecoder::Format get_format_cg(SkStreamRewindable* stream) {
     CGImageSourceRef imageSrc = SkStreamToCGImageSource(stream);
 
-    if (NULL == imageSrc) {
+    if (nullptr == imageSrc) {
         return SkImageDecoder::kUnknown_Format;
     }
 
     SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc);
     const CFStringRef name = CGImageSourceGetType(imageSrc);
-    if (NULL == name) {
+    if (nullptr == name) {
         return SkImageDecoder::kUnknown_Format;
     }
     return UTType_to_Format(name);
diff --git a/src/ports/SkImageDecoder_WIC.cpp b/src/ports/SkImageDecoder_WIC.cpp
index 9194831..3cc9a32 100644
--- a/src/ports/SkImageDecoder_WIC.cpp
+++ b/src/ports/SkImageDecoder_WIC.cpp
@@ -60,7 +60,7 @@
      *  Helper function to decode an SkStream.
      *  @param stream SkStream to decode. Must be at the beginning.
      *  @param bm   SkBitmap to decode into. Only used if wicMode is kDecodeBounds_WICMode or
-     *      kDecodePixels_WICMode, in which case it must not be NULL.
+     *      kDecodePixels_WICMode, in which case it must not be nullptr.
      *  @param format Out parameter for the SkImageDecoder::Format of the SkStream. Only used if
      *      wicMode is kDecodeFormat_WICMode.
      */
@@ -102,7 +102,7 @@
             wicMode = kDecodePixels_WICMode;
             break;
     }
-    return this->decodeStream(stream, bm, wicMode, NULL) ? kSuccess : kFailure;
+    return this->decodeStream(stream, bm, wicMode, nullptr) ? kSuccess : kFailure;
 }
 
 bool SkImageDecoder_WIC::decodeStream(SkStream* stream, SkBitmap* bm, WICModes wicMode,
@@ -120,7 +120,7 @@
     if (SUCCEEDED(hr)) {
         hr = CoCreateInstance(
             CLSID_WICImagingFactory
-            , NULL
+            , nullptr
             , CLSCTX_INPROC_SERVER
             , IID_PPV_ARGS(&piImagingFactory)
         );
@@ -135,7 +135,7 @@
     //Make sure we're at the beginning of the stream.
     if (SUCCEEDED(hr)) {
         LARGE_INTEGER liBeginning = { 0 };
-        hr = piStream->Seek(liBeginning, STREAM_SEEK_SET, NULL);
+        hr = piStream->Seek(liBeginning, STREAM_SEEK_SET, nullptr);
     }
 
     //Create the decoder from the stream content.
@@ -143,14 +143,14 @@
     if (SUCCEEDED(hr)) {
         hr = piImagingFactory->CreateDecoderFromStream(
             piStream.get()                    //Image to be decoded
-            , NULL                            //No particular vendor
+            , nullptr                            //No particular vendor
             , WICDecodeMetadataCacheOnDemand  //Cache metadata when needed
             , &piBitmapDecoder                //Pointer to the decoder
         );
     }
 
     if (kDecodeFormat_WICMode == wicMode) {
-        SkASSERT(format != NULL);
+        SkASSERT(format != nullptr);
         //Get the format
         if (SUCCEEDED(hr)) {
             GUID guidFormat;
@@ -190,7 +190,7 @@
         if (kDecodeBounds_WICMode == wicMode) {
             return true;
         }
-        if (!this->allocPixelRef(bm, NULL)) {
+        if (!this->allocPixelRef(bm, nullptr)) {
             return false;
         }
     }
@@ -213,7 +213,7 @@
             piBitmapSourceOriginal.get()      //Input bitmap to convert
             , destinationPixelFormat          //Destination pixel format
             , WICBitmapDitherTypeNone         //Specified dither patterm
-            , NULL                            //Specify a particular palette
+            , nullptr                            //Specify a particular palette
             , 0.f                             //Alpha threshold
             , WICBitmapPaletteTypeCustom      //Palette translation type
         );
@@ -233,7 +233,7 @@
         bm->eraseColor(SK_ColorTRANSPARENT);
         const UINT stride = (UINT) bm->rowBytes();
         hr = piBitmapSourceConverted->CopyPixels(
-            NULL,                             //Get all the pixels
+            nullptr,                             //Get all the pixels
             stride,
             stride * height,
             reinterpret_cast<BYTE *>(bm->getPixels())
@@ -254,7 +254,7 @@
 
 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) {
     SkImageDecoder* decoder = image_decoder_from_stream(stream);
-    if (NULL == decoder) {
+    if (nullptr == decoder) {
         // If no image decoder specific to the stream exists, use SkImageDecoder_WIC.
         return new SkImageDecoder_WIC;
     } else {
@@ -265,7 +265,7 @@
 /////////////////////////////////////////////////////////////////////////
 
 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
-    return NULL;
+    return nullptr;
 }
 
 /////////////////////////////////////////////////////////////////////////
@@ -345,7 +345,7 @@
     if (SUCCEEDED(hr)) {
         hr = CoCreateInstance(
             CLSID_WICImagingFactory
-            , NULL
+            , nullptr
             , CLSCTX_INPROC_SERVER
             , IID_PPV_ARGS(&piImagingFactory)
         );
@@ -360,7 +360,7 @@
     //Create an encode of the appropriate type.
     SkTScopedComPtr<IWICBitmapEncoder> piEncoder;
     if (SUCCEEDED(hr)) {
-        hr = piImagingFactory->CreateEncoder(type, NULL, &piEncoder);
+        hr = piImagingFactory->CreateEncoder(type, nullptr, &piEncoder);
     }
 
     if (SUCCEEDED(hr)) {
@@ -445,7 +445,7 @@
         case SkImageEncoder::kPNG_Type:
             break;
         default:
-            return NULL;
+            return nullptr;
     }
     return new SkImageEncoder_WIC(t);
 }
@@ -455,7 +455,7 @@
 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) {
     SkImageDecoder::Format format;
     SkImageDecoder_WIC codec;
-    if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICMode, &format)) {
+    if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_WICMode, &format)) {
         format = SkImageDecoder::kUnknown_Format;
     }
     return format;
diff --git a/src/ports/SkImageDecoder_empty.cpp b/src/ports/SkImageDecoder_empty.cpp
index e6cca08..d248f14 100644
--- a/src/ports/SkImageDecoder_empty.cpp
+++ b/src/ports/SkImageDecoder_empty.cpp
@@ -22,7 +22,7 @@
 SkImageDecoder::~SkImageDecoder() {}
 
 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable*) {
-    return NULL;
+    return nullptr;
 }
 
 void SkImageDecoder::copyFieldsToOther(SkImageDecoder* ) {}
@@ -67,15 +67,15 @@
 }
 
 const char* SkImageDecoder::GetFormatName(Format) {
-    return NULL;
+    return nullptr;
 }
 
 SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker*) {
-    return NULL;
+    return nullptr;
 }
 
 SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator*) {
-    return NULL;
+    return nullptr;
 }
 
 void SkImageDecoder::setSampleSize(int) {}
@@ -94,7 +94,7 @@
 // Empty implementation for SkMovie.
 
 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
-    return NULL;
+    return nullptr;
 }
 
 /////////////////////////////////////////////////////////////////////////
@@ -102,7 +102,7 @@
 // Empty implementations for SkImageEncoder.
 
 SkImageEncoder* SkImageEncoder::Create(Type t) {
-    return NULL;
+    return nullptr;
 }
 
 bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap&, Type, int quality) {
@@ -114,7 +114,7 @@
 }
 
 SkData* SkImageEncoder::EncodeData(const SkBitmap&, Type, int quality) {
-    return NULL;
+    return nullptr;
 }
 
 bool SkImageEncoder::encodeStream(SkWStream*, const SkBitmap&, int) {
@@ -122,7 +122,7 @@
 }
 
 SkData* SkImageEncoder::encodeData(const SkBitmap&, int) {
-    return NULL;
+    return nullptr;
 }
 
 bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm, int quality) {
diff --git a/src/ports/SkImageGenerator_none.cpp b/src/ports/SkImageGenerator_none.cpp
index c0126ca..2dce1c2 100644
--- a/src/ports/SkImageGenerator_none.cpp
+++ b/src/ports/SkImageGenerator_none.cpp
@@ -8,5 +8,5 @@
 #include "SkImageGenerator.h"
 
 SkImageGenerator* SkImageGenerator::NewFromEncodedImpl(SkData*) {
-    return NULL;
+    return nullptr;
 }
diff --git a/src/ports/SkImageGenerator_skia.cpp b/src/ports/SkImageGenerator_skia.cpp
index 2b11651..afcd4b4 100644
--- a/src/ports/SkImageGenerator_skia.cpp
+++ b/src/ports/SkImageGenerator_skia.cpp
@@ -28,7 +28,7 @@
         {
             return false;
         }
-        return bm->installPixels(bmi, fMemory, fRowBytes, ctable, NULL, NULL);
+        return bm->installPixels(bmi, fMemory, fRowBytes, ctable, nullptr, nullptr);
     }
 };
 
@@ -67,7 +67,7 @@
             SkASSERT(ctableEntries);
 
             SkColorTable* ctable = bm.getColorTable();
-            if (NULL == ctable) {
+            if (nullptr == ctable) {
                 return false;
             }
             const int count = ctable->count();
@@ -90,15 +90,15 @@
 SkImageGenerator* SkImageGenerator::NewFromEncodedImpl(SkData* data) {
     SkMemoryStream stream(data->data(), data->size(), false);
     SkImageDecoder* decoder = SkImageDecoder::Factory(&stream);
-    if (NULL == decoder) {
-        return NULL;
+    if (nullptr == decoder) {
+        return nullptr;
     }
 
     SkBitmap bm;
     stream.rewind();
     if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) {
         delete decoder;
-        return NULL;
+        return nullptr;
     }
 
     return new SkImageDecoderGenerator(bm.info(), decoder, data);
diff --git a/src/ports/SkMemory_malloc.cpp b/src/ports/SkMemory_malloc.cpp
index f9836c0..6ad01da 100644
--- a/src/ports/SkMemory_malloc.cpp
+++ b/src/ports/SkMemory_malloc.cpp
@@ -19,8 +19,8 @@
 }
 
 static inline void* throw_on_failure(size_t size, void* p) {
-    if (size > 0 && p == NULL) {
-        // If we've got a NULL here, the only reason we should have failed is running out of RAM.
+    if (size > 0 && p == nullptr) {
+        // If we've got a nullptr here, the only reason we should have failed is running out of RAM.
         sk_out_of_memory(size);
     }
     return p;
diff --git a/src/ports/SkOSFile_posix.cpp b/src/ports/SkOSFile_posix.cpp
index b604c21..58662f3 100644
--- a/src/ports/SkOSFile_posix.cpp
+++ b/src/ports/SkOSFile_posix.cpp
@@ -63,19 +63,19 @@
 void* sk_fdmmap(int fd, size_t* size) {
     struct stat status;
     if (0 != fstat(fd, &status)) {
-        return NULL;
+        return nullptr;
     }
     if (!S_ISREG(status.st_mode)) {
-        return NULL;
+        return nullptr;
     }
     if (!SkTFitsIn<size_t>(status.st_size)) {
-        return NULL;
+        return nullptr;
     }
     size_t fileSize = static_cast<size_t>(status.st_size);
 
-    void* addr = mmap(NULL, fileSize, PROT_READ, MAP_PRIVATE, fd, 0);
+    void* addr = mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0);
     if (MAP_FAILED == addr) {
-        return NULL;
+        return nullptr;
     }
 
     *size = fileSize;
@@ -89,7 +89,7 @@
 void* sk_fmmap(SkFILE* f, size_t* size) {
     int fd = sk_fileno(f);
     if (fd < 0) {
-        return NULL;
+        return nullptr;
     }
 
     return sk_fdmmap(fd, size);
@@ -149,7 +149,7 @@
     if (self.fDIR) {
         dirent* entry;
 
-        while ((entry = ::readdir(self.fDIR)) != NULL) {
+        while ((entry = ::readdir(self.fDIR)) != nullptr) {
             struct stat s;
             SkString str(self.fPath);
 
diff --git a/src/ports/SkOSFile_stdio.cpp b/src/ports/SkOSFile_stdio.cpp
index a7d776a..5b497d4 100644
--- a/src/ports/SkOSFile_stdio.cpp
+++ b/src/ports/SkOSFile_stdio.cpp
@@ -70,7 +70,7 @@
 
 size_t sk_fread(void* buffer, size_t byteCount, SkFILE* f) {
     SkASSERT(f);
-    if (buffer == NULL) {
+    if (buffer == nullptr) {
         size_t curr = ::ftell((FILE*)f);
         if ((long)curr == -1) {
             SkDEBUGF(("sk_fread: ftell(%p) returned -1 feof:%d ferror:%d\n", f, feof((FILE*)f), ferror((FILE*)f)));
diff --git a/src/ports/SkOSFile_win.cpp b/src/ports/SkOSFile_win.cpp
index 64bd516..14af458 100644
--- a/src/ports/SkOSFile_win.cpp
+++ b/src/ports/SkOSFile_win.cpp
@@ -79,29 +79,29 @@
 void* sk_fdmmap(int fileno, size_t* length) {
     HANDLE file = (HANDLE)_get_osfhandle(fileno);
     if (INVALID_HANDLE_VALUE == file) {
-        return NULL;
+        return nullptr;
     }
 
     LARGE_INTEGER fileSize;
     if (0 == GetFileSizeEx(file, &fileSize)) {
         //TODO: use SK_TRACEHR(GetLastError(), "Could not get file size.") to report.
-        return NULL;
+        return nullptr;
     }
     if (!SkTFitsIn<size_t>(fileSize.QuadPart)) {
-        return NULL;
+        return nullptr;
     }
 
-    SkAutoWinMMap mmap(CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL));
+    SkAutoWinMMap mmap(CreateFileMapping(file, nullptr, PAGE_READONLY, 0, 0, nullptr));
     if (!mmap.isValid()) {
         //TODO: use SK_TRACEHR(GetLastError(), "Could not create file mapping.") to report.
-        return NULL;
+        return nullptr;
     }
 
     // Eventually call UnmapViewOfFile
     void* addr = MapViewOfFile(mmap, FILE_MAP_READ, 0, 0, 0);
-    if (NULL == addr) {
+    if (nullptr == addr) {
         //TODO: use SK_TRACEHR(GetLastError(), "Could not map view of file.") to report.
-        return NULL;
+        return nullptr;
     }
 
     *length = static_cast<size_t>(fileSize.QuadPart);
@@ -115,7 +115,7 @@
 void* sk_fmmap(SkFILE* f, size_t* length) {
     int fileno = sk_fileno(f);
     if (fileno < 0) {
-        return NULL;
+        return nullptr;
     }
 
     return sk_fdmmap(fileno, length);
@@ -124,7 +124,7 @@
 ////////////////////////////////////////////////////////////////////////////
 
 struct SkOSFileIterData {
-    SkOSFileIterData() : fHandle(0), fPath16(NULL) { }
+    SkOSFileIterData() : fHandle(0), fPath16(nullptr) { }
     HANDLE fHandle;
     uint16_t* fPath16;
 };
@@ -177,7 +177,7 @@
         ::FindClose(self.fHandle);
         self.fHandle = 0;
     }
-    if (NULL == path) {
+    if (nullptr == path) {
         path = "";
     }
 
@@ -193,7 +193,7 @@
 static bool get_the_file(HANDLE handle, SkString* name, WIN32_FIND_DATAW* dataPtr, bool getDir) {
     WIN32_FIND_DATAW    data;
 
-    if (NULL == dataPtr) {
+    if (nullptr == dataPtr) {
         if (::FindNextFileW(handle, &data))
             dataPtr = &data;
         else
@@ -226,10 +226,10 @@
 bool SkOSFile::Iter::next(SkString* name, bool getDir) {
     SkOSFileIterData& self = *static_cast<SkOSFileIterData*>(fSelf.get());
     WIN32_FIND_DATAW    data;
-    WIN32_FIND_DATAW*   dataPtr = NULL;
+    WIN32_FIND_DATAW*   dataPtr = nullptr;
 
     if (self.fHandle == 0) {  // our first time
-        if (self.fPath16 == NULL || *self.fPath16 == 0) {  // check for no path
+        if (self.fPath16 == nullptr || *self.fPath16 == 0) {  // check for no path
             return false;
         }
 
diff --git a/src/ports/SkRemotableFontMgr_win_dw.cpp b/src/ports/SkRemotableFontMgr_win_dw.cpp
index 2d06255..aaef3a4 100644
--- a/src/ports/SkRemotableFontMgr_win_dw.cpp
+++ b/src/ports/SkRemotableFontMgr_win_dw.cpp
@@ -34,8 +34,8 @@
         explicit DataId(DataId& that)
             : fLoader(that.fLoader), fKey(that.fKey), fKeySize(that.fKeySize)
         {
-            that.fLoader = NULL;
-            that.fKey = NULL;
+            that.fLoader = nullptr;
+            that.fKey = nullptr;
             SkDEBUGCODE(that.fKeySize = 0xFFFFFFFF;)
         }
 
@@ -116,7 +116,7 @@
         HRM(font->CreateFontFace(&fontFace), "Could not create font face.");
 
         UINT32 numFiles;
-        HR(fontFace->GetFiles(&numFiles, NULL));
+        HR(fontFace->GetFiles(&numFiles, nullptr));
         if (numFiles > 1) {
             return E_FAIL;
         }
@@ -193,7 +193,7 @@
                    "Could not match font in family.",
                    identity);
 
-        HR_GENERAL(FontToIdentity(font.get(), &identity), NULL, identity);
+        HR_GENERAL(FontToIdentity(font.get(), &identity), nullptr, identity);
 
         return identity;
     }
@@ -218,12 +218,12 @@
 
     SkRemotableFontIdentitySet* matchName(const char familyName[]) const override {
         SkSMallocWCHAR dwFamilyName;
-        if (NULL == familyName) {
+        if (nullptr == familyName) {
             HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName),
-                       NULL, SkRemotableFontIdentitySet::NewEmpty());
+                       nullptr, SkRemotableFontIdentitySet::NewEmpty());
         } else {
             HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName),
-                       NULL, SkRemotableFontIdentitySet::NewEmpty());
+                       nullptr, SkRemotableFontIdentitySet::NewEmpty());
         }
 
         UINT32 index;
@@ -244,10 +244,10 @@
         SkFontIdentity identity = { SkFontIdentity::kInvalidDataId };
 
         SkSMallocWCHAR dwFamilyName;
-        if (NULL == familyName) {
-            HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), NULL, identity);
+        if (nullptr == familyName) {
+            HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), nullptr, identity);
         } else {
-            HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), NULL, identity);
+            HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), nullptr, identity);
         }
 
         UINT32 index;
@@ -374,7 +374,7 @@
                 this->AddRef();
                 return S_OK;
             }
-            *ppvObject = NULL;
+            *ppvObject = nullptr;
             return E_FAIL;
         }
 
@@ -395,7 +395,7 @@
         SkFontIdentity identity = { SkFontIdentity::kInvalidDataId };
 
         IDWriteFactory* dwFactory = sk_get_dwrite_factory();
-        if (NULL == dwFactory) {
+        if (nullptr == dwFactory) {
             return identity;
         }
 
@@ -404,10 +404,10 @@
         const DWriteStyle dwStyle(pattern);
 
         SkSMallocWCHAR dwFamilyName;
-        if (NULL == familyName) {
-            HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), NULL, identity);
+        if (nullptr == familyName) {
+            HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), nullptr, identity);
         } else {
-            HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), NULL, identity);
+            HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), nullptr, identity);
         }
 
         const SkSMallocWCHAR* dwBcp47;
@@ -416,7 +416,7 @@
             dwBcp47 = &fLocaleName;
         } else {
             //TODO: support fallback stack.
-            HR_GENERAL(sk_cstring_to_wchar(bcp47[bcp47Count-1], &dwBcp47Local), NULL, identity);
+            HR_GENERAL(sk_cstring_to_wchar(bcp47[bcp47Count-1], &dwBcp47Local), nullptr, identity);
             dwBcp47 = &dwBcp47Local;
         }
 
@@ -445,7 +445,7 @@
         SkTScopedComPtr<FontFallbackRenderer> fontFallbackRenderer(
             new FontFallbackRenderer(this, character));
 
-        HR_GENERAL(fallbackLayout->Draw(NULL, fontFallbackRenderer.get(), 50.0f, 50.0f),
+        HR_GENERAL(fallbackLayout->Draw(nullptr, fontFallbackRenderer.get(), 50.0f, 50.0f),
                    "Could not draw layout with renderer.",
                    identity);
 
@@ -455,7 +455,7 @@
     SkStreamAsset* getData(int dataId) const override {
         SkAutoMutexAcquire ama(fDataIdCacheMutex);
         if (dataId >= fDataIdCache.count()) {
-            return NULL;
+            return nullptr;
         }
         const DataId& id = fDataIdCache[dataId];
 
@@ -478,8 +478,8 @@
 
 SkRemotableFontMgr* SkRemotableFontMgr_New_DirectWrite() {
     IDWriteFactory* factory = sk_get_dwrite_factory();
-    if (NULL == factory) {
-        return NULL;
+    if (nullptr == factory) {
+        return nullptr;
     }
 
     SkTScopedComPtr<IDWriteFontCollection> sysFontCollection;
@@ -487,13 +487,13 @@
          "Could not get system font collection.");
 
     WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
-    WCHAR* localeName = NULL;
+    WCHAR* localeName = nullptr;
     int localeNameLen = 0;
 
     // Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
-    SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = NULL;
+    SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr;
     HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc);
-    if (NULL == getUserDefaultLocaleNameProc) {
+    if (nullptr == getUserDefaultLocaleNameProc) {
         SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
     } else {
         localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index 7bfa1d4..e259479 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -467,7 +467,7 @@
 }
 
 void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) {
-    if (NULL == metrics) {
+    if (nullptr == metrics) {
         return;
     }
 
@@ -734,8 +734,8 @@
     //It may not be needed, it appears that DirectWrite only hints at em size.
     HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSizeRender),
                                        &glyphId,
-                                       NULL, //advances
-                                       NULL, //offsets
+                                       nullptr, //advances
+                                       nullptr, //offsets
                                        1, //num glyphs
                                        FALSE, //sideways
                                        FALSE, //rtl
diff --git a/src/ports/SkTLS_none.cpp b/src/ports/SkTLS_none.cpp
index 95f6e37..d655560 100644
--- a/src/ports/SkTLS_none.cpp
+++ b/src/ports/SkTLS_none.cpp
@@ -7,7 +7,7 @@
 
 #include "SkTLS.h"
 
-static void* gSpecific = NULL;
+static void* gSpecific = nullptr;
 
 void* SkTLS::PlatformGetSpecific(bool) {
     return gSpecific;
diff --git a/src/ports/SkTLS_pthread.cpp b/src/ports/SkTLS_pthread.cpp
index 4264890..ac558a8 100644
--- a/src/ports/SkTLS_pthread.cpp
+++ b/src/ports/SkTLS_pthread.cpp
@@ -18,7 +18,7 @@
 
 void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
     // should we use forceCreateTheSlot to potentially skip calling pthread_once
-    // and just return NULL if we've never been called with
+    // and just return nullptr if we've never been called with
     // forceCreateTheSlot==true ?
 
     (void)pthread_once(&gSkTLSKey_Once, sk_tls_make_key);
diff --git a/src/ports/SkTLS_win.cpp b/src/ports/SkTLS_win.cpp
index c6f3dfc..cdfb465 100644
--- a/src/ports/SkTLS_win.cpp
+++ b/src/ports/SkTLS_win.cpp
@@ -14,7 +14,7 @@
 
 void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
     if (!forceCreateTheSlot && !gOnce) {
-        return NULL;
+        return nullptr;
     }
 
     if (!gOnce) {
@@ -49,9 +49,9 @@
 void NTAPI onTLSCallback(PVOID unused, DWORD reason, PVOID unused2) {
     if ((DLL_THREAD_DETACH == reason || DLL_PROCESS_DETACH == reason) && gOnce) {
         void* ptr = TlsGetValue(gTlsIndex);
-        if (ptr != NULL) {
+        if (ptr != nullptr) {
             SkTLS::Destructor(ptr);
-            TlsSetValue(gTlsIndex, NULL);
+            TlsSetValue(gTlsIndex, nullptr);
         }
     }
 }
diff --git a/src/ports/SkTime_Unix.cpp b/src/ports/SkTime_Unix.cpp
index 84f1a4e..ec96bb8 100644
--- a/src/ports/SkTime_Unix.cpp
+++ b/src/ports/SkTime_Unix.cpp
@@ -38,6 +38,6 @@
 SkMSec SkTime::GetMSecs()
 {
     struct timeval tv;
-    gettimeofday(&tv, NULL);
+    gettimeofday(&tv, nullptr);
     return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds
 }
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 3af4cca..144d4c7 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -30,7 +30,7 @@
     SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
     HRV(fDWriteFontFamily->GetFamilyNames(&familyNames));
 
-    sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, familyName);
+    sk_get_locale_string(familyNames.get(), nullptr/*fMgr->fLocaleName.get()*/, familyName);
 }
 
 void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
@@ -40,7 +40,7 @@
     HRV(fDWriteFontFamily->GetFamilyNames(&familyNames));
 
     SkString utf8FamilyName;
-    sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, &utf8FamilyName);
+    sk_get_locale_string(familyNames.get(), nullptr/*fMgr->fLocaleName.get()*/, &utf8FamilyName);
 
     desc->setFamilyName(utf8FamilyName.c_str());
     *isLocalStream = SkToBool(fDWriteFontFileLoader.get());
@@ -74,7 +74,7 @@
 int DWriteFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding,
                                         uint16_t glyphs[], int glyphCount) const
 {
-    if (NULL == glyphs) {
+    if (nullptr == glyphs) {
         EncodingProc next_ucs4_proc = find_encoding_proc(encoding);
         for (int i = 0; i < glyphCount; ++i) {
             const SkUnichar c = next_ucs4_proc(&chars);
@@ -172,7 +172,7 @@
 SkTypeface::LocalizedStrings* DWriteFontTypeface::onCreateFamilyNameIterator() const {
     SkTypeface::LocalizedStrings* nameIter =
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this);
-    if (NULL == nameIter) {
+    if (nullptr == nameIter) {
         SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
         HRNM(fDWriteFontFamily->GetFamilyNames(&familyNames), "Could not obtain family names.");
         nameIter = new LocalizedStrings_IDWriteLocalizedStrings(familyNames.release());
@@ -217,10 +217,10 @@
     *ttcIndex = fDWriteFontFace->GetIndex();
 
     UINT32 numFiles;
-    HRNM(fDWriteFontFace->GetFiles(&numFiles, NULL),
+    HRNM(fDWriteFontFace->GetFiles(&numFiles, nullptr),
          "Could not get number of font files.");
     if (numFiles != 1) {
-        return NULL;
+        return nullptr;
     }
 
     SkTScopedComPtr<IDWriteFontFile> fontFile;
@@ -265,7 +265,7 @@
 
 #if SK_FONT_HOST_USE_SYSTEM_SETTINGS
     IDWriteFactory* factory = get_dwrite_factory();
-    if (factory != NULL) {
+    if (factory != nullptr) {
         SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams;
         if (SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams))) {
             float gamma = defaultRenderingParams->GetGamma();
@@ -332,7 +332,7 @@
         const uint32_t* glyphIDs,
         uint32_t glyphIDsCount) const {
 
-    SkAdvancedTypefaceMetrics* info = NULL;
+    SkAdvancedTypefaceMetrics* info = nullptr;
 
     HRESULT hr = S_OK;
 
diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h
index 866e634..3d6fce0 100644
--- a/src/ports/SkTypeface_win_dw.h
+++ b/src/ports/SkTypeface_win_dw.h
@@ -41,8 +41,8 @@
                        IDWriteFontFace* fontFace,
                        IDWriteFont* font,
                        IDWriteFontFamily* fontFamily,
-                       IDWriteFontFileLoader* fontFileLoader = NULL,
-                       IDWriteFontCollectionLoader* fontCollectionLoader = NULL)
+                       IDWriteFontFileLoader* fontFileLoader = nullptr,
+                       IDWriteFontCollectionLoader* fontCollectionLoader = nullptr)
         : SkTypeface(style, fontID, false)
         , fFactory(SkRefComPtr(factory))
         , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader))
@@ -53,9 +53,9 @@
     {
 #if SK_HAS_DWRITE_1_H
         if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
-            // IUnknown::QueryInterface states that if it fails, punk will be set to NULL.
+            // IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
             // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
-            SK_ALWAYSBREAK(NULL == fDWriteFontFace1.get());
+            SK_ALWAYSBREAK(nullptr == fDWriteFontFace1.get());
         }
 #endif
     }
@@ -75,8 +75,8 @@
                                       IDWriteFontFace* fontFace,
                                       IDWriteFont* font,
                                       IDWriteFontFamily* fontFamily,
-                                      IDWriteFontFileLoader* fontFileLoader = NULL,
-                                      IDWriteFontCollectionLoader* fontCollectionLoader = NULL) {
+                                      IDWriteFontFileLoader* fontFileLoader = nullptr,
+                                      IDWriteFontCollectionLoader* fontCollectionLoader = nullptr) {
         SkFontID fontID = SkTypefaceCache::NewFontID();
         return new DWriteFontTypeface(get_style(font), fontID, factory, fontFace, font, fontFamily,
                                       fontFileLoader, fontCollectionLoader);