gfx/skia/trunk/include/ports/SkFontMgr.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2013 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkFontMgr_DEFINED
michael@0 9 #define SkFontMgr_DEFINED
michael@0 10
michael@0 11 #include "SkRefCnt.h"
michael@0 12 #include "SkFontStyle.h"
michael@0 13
michael@0 14 class SkData;
michael@0 15 class SkStream;
michael@0 16 class SkString;
michael@0 17 class SkTypeface;
michael@0 18
michael@0 19 class SK_API SkFontStyleSet : public SkRefCnt {
michael@0 20 public:
michael@0 21 SK_DECLARE_INST_COUNT(SkFontStyleSet)
michael@0 22
michael@0 23 virtual int count() = 0;
michael@0 24 virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0;
michael@0 25 virtual SkTypeface* createTypeface(int index) = 0;
michael@0 26 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) = 0;
michael@0 27
michael@0 28 static SkFontStyleSet* CreateEmpty();
michael@0 29
michael@0 30 private:
michael@0 31 typedef SkRefCnt INHERITED;
michael@0 32 };
michael@0 33
michael@0 34 class SkTypeface;
michael@0 35
michael@0 36 class SK_API SkFontMgr : public SkRefCnt {
michael@0 37 public:
michael@0 38 SK_DECLARE_INST_COUNT(SkFontMgr)
michael@0 39
michael@0 40 int countFamilies() const;
michael@0 41 void getFamilyName(int index, SkString* familyName) const;
michael@0 42 SkFontStyleSet* createStyleSet(int index) const;
michael@0 43
michael@0 44 /**
michael@0 45 * The caller must call unref() on the returned object.
michael@0 46 * Never returns NULL; will return an empty set if the name is not found.
michael@0 47 */
michael@0 48 SkFontStyleSet* matchFamily(const char familyName[]) const;
michael@0 49
michael@0 50 /**
michael@0 51 * Find the closest matching typeface to the specified familyName and style
michael@0 52 * and return a ref to it. The caller must call unref() on the returned
michael@0 53 * object. Will never return NULL, as it will return the default font if
michael@0 54 * no matching font is found.
michael@0 55 */
michael@0 56 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) const;
michael@0 57
michael@0 58 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&) const;
michael@0 59
michael@0 60 /**
michael@0 61 * Create a typeface for the specified data and TTC index (pass 0 for none)
michael@0 62 * or NULL if the data is not recognized. The caller must call unref() on
michael@0 63 * the returned object if it is not null.
michael@0 64 */
michael@0 65 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const;
michael@0 66
michael@0 67 /**
michael@0 68 * Create a typeface for the specified stream and TTC index
michael@0 69 * (pass 0 for none) or NULL if the stream is not recognized. The caller
michael@0 70 * must call unref() on the returned object if it is not null.
michael@0 71 */
michael@0 72 SkTypeface* createFromStream(SkStream*, int ttcIndex = 0) const;
michael@0 73
michael@0 74 /**
michael@0 75 * Create a typeface for the specified fileName and TTC index
michael@0 76 * (pass 0 for none) or NULL if the file is not found, or its contents are
michael@0 77 * not recognized. The caller must call unref() on the returned object
michael@0 78 * if it is not null.
michael@0 79 */
michael@0 80 SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const;
michael@0 81
michael@0 82 SkTypeface* legacyCreateTypeface(const char familyName[],
michael@0 83 unsigned typefaceStyleBits) const;
michael@0 84
michael@0 85 /**
michael@0 86 * Return a ref to the default fontmgr. The caller must call unref() on
michael@0 87 * the returned object.
michael@0 88 */
michael@0 89 static SkFontMgr* RefDefault();
michael@0 90
michael@0 91 protected:
michael@0 92 virtual int onCountFamilies() const = 0;
michael@0 93 virtual void onGetFamilyName(int index, SkString* familyName) const = 0;
michael@0 94 virtual SkFontStyleSet* onCreateStyleSet(int index)const = 0;
michael@0 95
michael@0 96 /** May return NULL if the name is not found. */
michael@0 97 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const = 0;
michael@0 98
michael@0 99 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
michael@0 100 const SkFontStyle&) const = 0;
michael@0 101 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
michael@0 102 const SkFontStyle&) const = 0;
michael@0 103
michael@0 104 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0;
michael@0 105 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) const = 0;
michael@0 106 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const = 0;
michael@0 107
michael@0 108 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
michael@0 109 unsigned styleBits) const = 0;
michael@0 110 private:
michael@0 111 static SkFontMgr* Factory(); // implemented by porting layer
michael@0 112 friend void set_up_default(SkFontMgr** singleton);
michael@0 113
michael@0 114 typedef SkRefCnt INHERITED;
michael@0 115 };
michael@0 116
michael@0 117 #endif

mercurial