Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: Source/platform/fonts/FontPlatformData.h

Issue 879533003: Remove Mac native font type members from FontPlatformData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Canvas text metrics test does not need rebaselining after improvement landed, toNSFont in WebSubstringUtil.mm Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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); }
56 inline NSFont* toNSFont(CTFontRef ctFontRef) { return const_cast<NSFont*>(reinte rpret_cast<const NSFont*>(ctFontRef)); }
58 #endif // OS(MACOSX) 57 #endif // OS(MACOSX)
59 58
60 class SkTypeface; 59 class SkTypeface;
61 typedef uint32_t SkFontID; 60 typedef uint32_t SkFontID;
62 61
63 namespace blink { 62 namespace blink {
64 63
65 class Font; 64 class Font;
66 class GraphicsContext; 65 class GraphicsContext;
67 class HarfBuzzFace; 66 class HarfBuzzFace;
68 67
69 class PLATFORM_EXPORT FontPlatformData { 68 class PLATFORM_EXPORT FontPlatformData {
70 public: 69 public:
71 // Used for deleted values in the font cache's hash tables. The hash table 70 // 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 71 // 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 72 // 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 73 // from the 0 one (created with the empty constructor), so we can't just
75 // set everything to 0. 74 // set everything to 0.
76 FontPlatformData(WTF::HashTableDeletedValueType); 75 FontPlatformData(WTF::HashTableDeletedValueType);
77 FontPlatformData(); 76 FontPlatformData();
78 FontPlatformData(const FontPlatformData&); 77 FontPlatformData(const FontPlatformData&);
79 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO rientation = Horizontal); 78 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO rientation = Horizontal);
80 FontPlatformData(const FontPlatformData& src, float textSize); 79 FontPlatformData(const FontPlatformData& src, float textSize);
81 #if OS(MACOSX) 80 #if OS(MACOSX)
82 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth eticItalic = false, FontOrientation = Horizontal); 81 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); 82 #endif
84 #else
85 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp ixelTextPosition = defaultUseSubpixelPositioning()); 83 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp ixelTextPosition = defaultUseSubpixelPositioning());
86 #endif
87 ~FontPlatformData(); 84 ~FontPlatformData();
88 85
89 #if OS(MACOSX) 86 #if OS(MACOSX)
90 NSFont* font() const { return m_font; }
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
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
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontCustomPlatformData.cpp ('k') | Source/platform/fonts/FontPlatformData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698