aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTypeface.h
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-05-12 06:22:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-12 06:22:30 -0700
commit9a9a7b29e5e5916a7b6453cd124ca437f14b9da4 (patch)
treead5b560f6ed5da12040e5665282fd2227c305ff8 /include/core/SkTypeface.h
parenta1b283345b27fef91908b104a30cb89e6fbdaade (diff)
Revert of Move SkTypeface to sk_sp. (patchset #5 id:80001 of https://codereview.chromium.org/1933393002/ )
Reason for revert: fontmgr_iterAndroid failing to draw emoji. E.g. 6296da736fbf40aae881650c239420f64e576c3f&unt=true&head=true&query=source_type%3Dgm">https://gold.skia.org/search2?blame=6296da736fbf40aae881650c239420f64e576c3f&unt=true&head=true&query=source_type%3Dgm Original issue's description: > Move SkTypeface to sk_sp. > > Committed: https://skia.googlesource.com/skia/+/6296da736fbf40aae881650c239420f64e576c3f TBR=reed@google.com,fmalita@chromium.org,tomhudson@google.com,bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1974783002
Diffstat (limited to 'include/core/SkTypeface.h')
-rw-r--r--include/core/SkTypeface.h87
1 files changed, 31 insertions, 56 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 3a47bd2bb3..f22d2bd14f 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -92,75 +92,51 @@ public:
*/
static bool Equal(const SkTypeface* facea, const SkTypeface* faceb);
- /** Returns the default typeface, which is never nullptr. */
- static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) {
- return MakeDefault(style).release();
- }
-#endif
+ /**
+ * Returns a ref() to the default typeface. The caller must call unref()
+ * when they are done referencing the object. Never returns NULL.
+ */
+ static SkTypeface* RefDefault(Style style = SkTypeface::kNormal);
- /** Return the typeface that most closely matches the requested familyName and style.
- Pass nullptr as the familyName to request the default font for the requested style.
- Will never return nullptr.
+ /** Return a new reference to the typeface that most closely matches the
+ requested familyName and style. Pass null as the familyName to return
+ the default font for the requested style. Will never return null
@param familyName May be NULL. The name of the font family.
@param style The style (normal, bold, italic) of the typeface.
- @return the closest-matching typeface.
+ @return reference to the closest-matching typeface. Call must call
+ unref() when they are done.
*/
- static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* CreateFromName(const char familyName[], Style style) {
- return MakeFromName(familyName, style).release();
- }
-#endif
+ static SkTypeface* CreateFromName(const char familyName[], Style style);
- /** Return the typeface that most closely matches the requested typeface and style.
- Use this to pick a new style from the same family of the existing typeface.
- If family is nullptr, this selects from the default font's family.
+ /** Return a new reference to the typeface that most closely matches the
+ requested typeface and specified Style. Use this call if you want to
+ pick a new style from the same family of the existing typeface.
+ If family is NULL, this selects from the default font's family.
@param family May be NULL. The name of the existing type face.
@param s The style (normal, bold, italic) of the type face.
- @return the closest-matching typeface.
+ @return reference to the closest-matching typeface. Call must call
+ unref() when they are done.
*/
- static sk_sp<SkTypeface> MakeFromTypeface(SkTypeface* family, Style);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* CreateFromTypeface(const SkTypeface* family, Style style) {
- return MakeFromTypeface(const_cast<SkTypeface*>(family), style).release();
- }
-#endif
+ static SkTypeface* CreateFromTypeface(const SkTypeface* family, Style s);
/** Return a new typeface given a file. If the file does not exist, or is
- not a valid font file, returns nullptr.
+ not a valid font file, returns null.
*/
- static sk_sp<SkTypeface> MakeFromFile(const char path[], int index = 0);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* CreateFromFile(const char path[], int index = 0) {
- return MakeFromFile(path, index).release();
- }
-#endif
+ static SkTypeface* CreateFromFile(const char path[], int index = 0);
/** Return a new typeface given a stream. If the stream is
- not a valid font file, returns nullptr. Ownership of the stream is
+ not a valid font file, returns null. Ownership of the stream is
transferred, so the caller must not reference it again.
*/
- static sk_sp<SkTypeface> MakeFromStream(SkStreamAsset* stream, int index = 0);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0) {
- return MakeFromStream(stream, index).release();
- }
-#endif
+ static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0);
/** Return a new typeface given font data and configuration. If the data
- is not valid font data, returns nullptr. Ownership of the font data is
+ is not valid font data, returns null. Ownership of the font data is
transferred, so the caller must not reference it again.
*/
- static sk_sp<SkTypeface> MakeFromFontData(SkFontData*);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* CreateFromFontData(SkFontData* fd) {
- return MakeFromFontData(fd).release();
- }
-#endif
+ static SkTypeface* CreateFromFontData(SkFontData*);
/** Write a unique signature to a stream, sufficient to reconstruct a
typeface referencing the same font when Deserialize is called.
@@ -168,16 +144,12 @@ public:
void serialize(SkWStream*) const;
/** Given the data previously written by serialize(), return a new instance
- of a typeface referring to the same font. If that font is not available,
- return nullptr.
+ to a typeface referring to the same font. If that font is not available,
+ return null. If an instance is returned, the caller is responsible for
+ calling unref() when they are done with it.
Does not affect ownership of SkStream.
*/
- static sk_sp<SkTypeface> MakeDeserialize(SkStream*);
-#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
- static SkTypeface* Deserialize(SkStream* stream) {
- return MakeDeserialize(stream).release();
- }
-#endif
+ static SkTypeface* Deserialize(SkStream*);
enum Encoding {
kUTF8_Encoding,
@@ -423,6 +395,9 @@ private:
uint32_t glyphIDsCount = 0) const;
private:
+ static SkTypeface* CreateDefault(int style); // SkLazyPtr requires an int, not a Style.
+ static void DeleteDefault(SkTypeface*);
+
SkFontID fUniqueID;
SkFontStyle fStyle;
mutable SkRect fBounds;