| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
| 44 #include "wtf/text/CString.h" | 44 #include "wtf/text/CString.h" |
| 45 #include "wtf/text/StringImpl.h" | 45 #include "wtf/text/StringImpl.h" |
| 46 | 46 |
| 47 #if OS(MACOSX) | 47 #if OS(MACOSX) |
| 48 OBJC_CLASS NSFont; | 48 OBJC_CLASS NSFont; |
| 49 | 49 |
| 50 typedef struct CGFont* CGFontRef; | 50 typedef struct CGFont* CGFontRef; |
| 51 typedef const struct __CTFont* CTFontRef; | 51 typedef const struct __CTFont* CTFontRef; |
| 52 | 52 |
| 53 #include "platform/fonts/mac/MemoryActivatedFont.h" | |
| 54 #include <CoreFoundation/CFBase.h> | |
| 55 #include <objc/objc-auto.h> | 53 #include <objc/objc-auto.h> |
| 56 | 54 |
| 57 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } | 55 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } |
| 58 #endif // OS(MACOSX) | 56 #endif // OS(MACOSX) |
| 59 | 57 |
| 60 class SkTypeface; | 58 class SkTypeface; |
| 61 typedef uint32_t SkFontID; | 59 typedef uint32_t SkFontID; |
| 62 | 60 |
| 63 namespace blink { | 61 namespace blink { |
| 64 | 62 |
| 65 class Font; | 63 class Font; |
| 66 class GraphicsContext; | 64 class GraphicsContext; |
| 67 class HarfBuzzFace; | 65 class HarfBuzzFace; |
| 68 | 66 |
| 69 class PLATFORM_EXPORT FontPlatformData { | 67 class PLATFORM_EXPORT FontPlatformData { |
| 70 public: | 68 public: |
| 71 // Used for deleted values in the font cache's hash tables. The hash table | 69 // Used for deleted values in the font cache's hash tables. The hash table |
| 72 // will create us with this structure, and it will compare other values | 70 // will create us with this structure, and it will compare other values |
| 73 // to this "Deleted" one. It expects the Deleted one to be differentiable | 71 // to this "Deleted" one. It expects the Deleted one to be differentiable |
| 74 // from the 0 one (created with the empty constructor), so we can't just | 72 // from the 0 one (created with the empty constructor), so we can't just |
| 75 // set everything to 0. | 73 // set everything to 0. |
| 76 FontPlatformData(WTF::HashTableDeletedValueType); | 74 FontPlatformData(WTF::HashTableDeletedValueType); |
| 77 FontPlatformData(); | 75 FontPlatformData(); |
| 78 FontPlatformData(const FontPlatformData&); | 76 FontPlatformData(const FontPlatformData&); |
| 79 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); | 77 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); |
| 80 FontPlatformData(const FontPlatformData& src, float textSize); | 78 FontPlatformData(const FontPlatformData& src, float textSize); |
| 81 #if OS(MACOSX) | 79 #if OS(MACOSX) |
| 82 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticItalic = false, FontOrientation = Horizontal); | 80 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticItalic = false, FontOrientation = Horizontal); |
| 83 FontPlatformData(CGFontRef, PassRefPtr<SkTypeface>, float size, bool synthet
icBold, bool syntheticOblique, FontOrientation); | 81 #endif |
| 84 #else | |
| 85 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); | 82 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); |
| 86 #endif | |
| 87 ~FontPlatformData(); | 83 ~FontPlatformData(); |
| 88 | 84 |
| 89 #if OS(MACOSX) | 85 #if OS(MACOSX) |
| 90 NSFont* font() const { return m_font; } | 86 const NSFont* font() const { return reinterpret_cast<const NSFont*>(ctFont()
); }; |
| 91 void setFont(NSFont*); | |
| 92 | |
| 93 CGFontRef cgFont() const { return m_cgFont.get(); } | |
| 94 CTFontRef ctFont() const; | 87 CTFontRef ctFont() const; |
| 95 | 88 CGFontRef cgFont() const; |
| 96 bool roundsGlyphAdvances() const; | |
| 97 bool allowsLigatures() const; | |
| 98 | |
| 99 bool isColorBitmapFont() const { return m_isColorBitmapFont; } | |
| 100 bool isCompositeFontReference() const { return m_isCompositeFontReference; } | |
| 101 #endif | 89 #endif |
| 102 | 90 |
| 103 String fontFamilyName() const; | 91 String fontFamilyName() const; |
| 104 float size() const { return m_textSize; } | 92 float size() const { return m_textSize; } |
| 105 bool isFixedPitch() const; | 93 bool isFixedPitch() const; |
| 106 bool syntheticBold() const { return m_syntheticBold; } | 94 bool syntheticBold() const { return m_syntheticBold; } |
| 107 bool syntheticItalic() const { return m_syntheticItalic; } | 95 bool syntheticItalic() const { return m_syntheticItalic; } |
| 108 | 96 |
| 109 SkTypeface* typeface() const; | 97 SkTypeface* typeface() const; |
| 110 HarfBuzzFace* harfBuzzFace() const; | 98 HarfBuzzFace* harfBuzzFace() const; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 int paintTextFlags() const { return m_paintTextFlags; } | 133 int paintTextFlags() const { return m_paintTextFlags; } |
| 146 #else | 134 #else |
| 147 static void setHinting(SkPaint::Hinting); | 135 static void setHinting(SkPaint::Hinting); |
| 148 static void setAutoHint(bool); | 136 static void setAutoHint(bool); |
| 149 static void setUseBitmaps(bool); | 137 static void setUseBitmaps(bool); |
| 150 static void setAntiAlias(bool); | 138 static void setAntiAlias(bool); |
| 151 static void setSubpixelRendering(bool); | 139 static void setSubpixelRendering(bool); |
| 152 #endif | 140 #endif |
| 153 | 141 |
| 154 private: | 142 private: |
| 143 bool static defaultUseSubpixelPositioning(); |
| 155 #if !OS(MACOSX) | 144 #if !OS(MACOSX) |
| 156 bool static defaultUseSubpixelPositioning(); | |
| 157 void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); | 145 void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); |
| 158 #else | |
| 159 // Load various data about the font specified by |nsFont| with the size font
Size into the following output paramters: | |
| 160 // Note: Callers should always take into account that for the Chromium port,
|outNSFont| isn't necessarily the same | |
| 161 // font as |nsFont|. This because the sandbox may block loading of the origi
nal font. | |
| 162 // * outNSFont - The font that was actually loaded, for the Chromium port th
is may be different than nsFont. | |
| 163 // The caller is responsible for calling CFRelease() on this parameter when
done with it. | |
| 164 // * cgFont - CGFontRef representing the input font at the specified point s
ize. | |
| 165 void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&); | |
| 166 void platformDataInit(const FontPlatformData&); | |
| 167 const FontPlatformData& platformDataAssign(const FontPlatformData&); | |
| 168 bool isAATFont(CTFontRef) const; | |
| 169 #endif | 146 #endif |
| 170 | 147 |
| 171 mutable RefPtr<SkTypeface> m_typeface; | 148 mutable RefPtr<SkTypeface> m_typeface; |
| 172 #if !OS(WIN) | 149 #if !OS(WIN) |
| 173 CString m_family; | 150 CString m_family; |
| 174 #endif | 151 #endif |
| 175 | 152 |
| 176 public: | 153 public: |
| 177 float m_textSize; | 154 float m_textSize; |
| 178 bool m_syntheticBold; | 155 bool m_syntheticBold; |
| 179 bool m_syntheticItalic; | 156 bool m_syntheticItalic; |
| 180 FontOrientation m_orientation; | 157 FontOrientation m_orientation; |
| 181 #if OS(MACOSX) | |
| 182 bool m_isColorBitmapFont; | |
| 183 bool m_isCompositeFontReference; | |
| 184 #endif | |
| 185 private: | 158 private: |
| 186 #if OS(MACOSX) | 159 #if !OS(MACOSX) |
| 187 NSFont* m_font; | |
| 188 RetainPtr<CGFontRef> m_cgFont; | |
| 189 mutable RetainPtr<CTFontRef> m_CTFont; | |
| 190 RefPtr<MemoryActivatedFont> m_inMemoryFont; | |
| 191 #else | |
| 192 FontRenderStyle m_style; | 160 FontRenderStyle m_style; |
| 193 #endif | 161 #endif |
| 194 | 162 |
| 195 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; | 163 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; |
| 196 bool m_isHashTableDeletedValue; | 164 bool m_isHashTableDeletedValue; |
| 197 #if OS(WIN) | 165 #if OS(WIN) |
| 198 int m_paintTextFlags; | 166 int m_paintTextFlags; |
| 199 bool m_useSubpixelPositioning; | 167 bool m_useSubpixelPositioning; |
| 200 unsigned m_minSizeForAntiAlias; | 168 unsigned m_minSizeForAntiAlias; |
| 201 float m_minSizeForSubpixel; | 169 float m_minSizeForSubpixel; |
| 202 #endif | 170 #endif |
| 203 }; | 171 }; |
| 204 | 172 |
| 205 } // namespace blink | 173 } // namespace blink |
| 206 | 174 |
| 207 #endif // ifdef FontPlatformData_h | 175 #endif // ifdef FontPlatformData_h |
| OLD | NEW |