| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkFontHost_DEFINED | 10 #ifndef SkFontHost_DEFINED |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 references the closest matching font available on the host system. | 41 references the closest matching font available on the host system. |
| 42 2) Given the data for a font (either in a stream or a file name), return | 42 2) Given the data for a font (either in a stream or a file name), return |
| 43 a typeface that allows access to that data. | 43 a typeface that allows access to that data. |
| 44 3) Each typeface instance carries a 32bit ID for its corresponding font. | 44 3) Each typeface instance carries a 32bit ID for its corresponding font. |
| 45 SkFontHost turns that ID into a stream to access the font's data. | 45 SkFontHost turns that ID into a stream to access the font's data. |
| 46 4) Given a font ID, return a subclass of SkScalerContext, which connects a | 46 4) Given a font ID, return a subclass of SkScalerContext, which connects a |
| 47 font scaler (e.g. freetype or other) to the font's data. | 47 font scaler (e.g. freetype or other) to the font's data. |
| 48 5) Utilites to manage the font cache (budgeting) and gamma correction | 48 5) Utilites to manage the font cache (budgeting) and gamma correction |
| 49 */ | 49 */ |
| 50 class SK_API SkFontHost { | 50 class SK_API SkFontHost { |
| 51 public: | 51 private: |
| 52 /** Return a new, closest matching typeface given either an existing family | 52 /** Return a new, closest matching typeface given either an existing family |
| 53 (specified by a typeface in that family) or by a familyName and a | 53 (specified by a typeface in that family) or by a familyName and a |
| 54 requested style. | 54 requested style. |
| 55 1) If familyFace is null, use familyName. | 55 1) If familyFace is null, use familyName. |
| 56 2) If familyName is null, use data (UTF-16 to cover). | 56 2) If familyName is null, use data (UTF-16 to cover). |
| 57 3) If all are null, return the default font that best matches style | 57 3) If all are null, return the default font that best matches style |
| 58 */ | 58 */ |
| 59 static SkTypeface* CreateTypeface(const SkTypeface* familyFace, | 59 static SkTypeface* CreateTypeface(const SkTypeface* familyFace, |
| 60 const char familyName[], | 60 const char familyName[], |
| 61 SkTypeface::Style style); | 61 SkTypeface::Style style); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 /** Given a stream created by Serialize(), return a new typeface (like | 129 /** Given a stream created by Serialize(), return a new typeface (like |
| 130 CreateTypeface) which is either an exact match to the one serialized | 130 CreateTypeface) which is either an exact match to the one serialized |
| 131 or the best available typeface based on the data in the deserialized | 131 or the best available typeface based on the data in the deserialized |
| 132 SkFontDescriptor. | 132 SkFontDescriptor. |
| 133 */ | 133 */ |
| 134 static SkTypeface* Deserialize(SkStream*); | 134 static SkTypeface* Deserialize(SkStream*); |
| 135 | 135 |
| 136 /////////////////////////////////////////////////////////////////////////// | 136 /////////////////////////////////////////////////////////////////////////// |
| 137 | 137 |
| 138 public: |
| 138 /** Return a subclass of SkScalarContext | 139 /** Return a subclass of SkScalarContext |
| 139 */ | 140 */ |
| 140 static SkScalerContext* CreateScalerContext(const SkDescriptor* desc); | 141 static SkScalerContext* CreateScalerContext(const SkDescriptor* desc); |
| 141 | 142 |
| 142 /** | 143 /** |
| 143 * Given a "current" fontID, return the next logical fontID to use | 144 * Given a "current" fontID, return the next logical fontID to use |
| 144 * when searching fonts for a given unicode value. Typically the caller | 145 * when searching fonts for a given unicode value. Typically the caller |
| 145 * will query a given font, and if a unicode value is not supported, they | 146 * will query a given font, and if a unicode value is not supported, they |
| 146 * will call this, and if 0 is not returned, will search that font, and so | 147 * will call this, and if 0 is not returned, will search that font, and so |
| 147 * on. This process must be finite, and when the fonthost sees a | 148 * on. This process must be finite, and when the fonthost sees a |
| 148 * font with no logical successor, it must return 0. | 149 * font with no logical successor, it must return 0. |
| 149 * | 150 * |
| 150 * The original fontID is also provided. This is the initial font that was | 151 * The original fontID is also provided. This is the initial font that was |
| 151 * stored in the typeface of the caller. It is provided as an aid to choose | 152 * stored in the typeface of the caller. It is provided as an aid to choose |
| 152 * the best next logical font. e.g. If the original font was bold or serif, | 153 * the best next logical font. e.g. If the original font was bold or serif, |
| 153 * but the 2nd in the logical chain was plain, then a subsequent call to | 154 * but the 2nd in the logical chain was plain, then a subsequent call to |
| 154 * get the 3rd can still inspect the original, and try to match its | 155 * get the 3rd can still inspect the original, and try to match its |
| 155 * stylistic attributes. | 156 * stylistic attributes. |
| 156 */ | 157 */ |
| 157 static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID); | 158 static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID); |
| 159 private: |
| 158 | 160 |
| 159 /////////////////////////////////////////////////////////////////////////// | 161 /////////////////////////////////////////////////////////////////////////// |
| 160 | 162 |
| 161 /** Given a filled-out rec, the fonthost may decide to modify it to reflect | 163 /** Given a filled-out rec, the fonthost may decide to modify it to reflect |
| 162 what the host is actually capable of fulfilling. For example, if the | 164 what the host is actually capable of fulfilling. For example, if the |
| 163 rec is requesting a level of hinting that, for this host, maps some | 165 rec is requesting a level of hinting that, for this host, maps some |
| 164 other level (e.g. kFull -> kNormal), it should update the rec to reflect | 166 other level (e.g. kFull -> kNormal), it should update the rec to reflect |
| 165 what will actually be done. This is an optimization so that the font | 167 what will actually be done. This is an optimization so that the font |
| 166 cache does not contain different recs (i.e. keys) that in reality map to | 168 cache does not contain different recs (i.e. keys) that in reality map to |
| 167 the same output. | 169 the same output. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 @return the number of bytes actually copied into data. If offset+length | 224 @return the number of bytes actually copied into data. If offset+length |
| 223 exceeds the table's size, then only the bytes up to the table's | 225 exceeds the table's size, then only the bytes up to the table's |
| 224 size are actually copied, and this is the value returned. If | 226 size are actually copied, and this is the value returned. If |
| 225 offset > the table's size, or tag is not a valid table, | 227 offset > the table's size, or tag is not a valid table, |
| 226 then 0 is returned. | 228 then 0 is returned. |
| 227 */ | 229 */ |
| 228 static size_t GetTableData(SkFontID fontID, SkFontTableTag tag, | 230 static size_t GetTableData(SkFontID fontID, SkFontTableTag tag, |
| 229 size_t offset, size_t length, void* data); | 231 size_t offset, size_t length, void* data); |
| 230 | 232 |
| 231 /////////////////////////////////////////////////////////////////////////// | 233 /////////////////////////////////////////////////////////////////////////// |
| 234 public: |
| 232 | 235 |
| 233 /** LCDs either have their color elements arranged horizontally or | 236 /** LCDs either have their color elements arranged horizontally or |
| 234 vertically. When rendering subpixel glyphs we need to know which way | 237 vertically. When rendering subpixel glyphs we need to know which way |
| 235 round they are. | 238 round they are. |
| 236 | 239 |
| 237 Note, if you change this after startup, you'll need to flush the glyph | 240 Note, if you change this after startup, you'll need to flush the glyph |
| 238 cache because it'll have the wrong type of masks cached. | 241 cache because it'll have the wrong type of masks cached. |
| 239 | 242 |
| 240 @deprecated use SkPixelGeometry instead. | 243 @deprecated use SkPixelGeometry instead. |
| 241 */ | 244 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 static uint32_t GetUnitsPerEm(SkFontID fontID); | 287 static uint32_t GetUnitsPerEm(SkFontID fontID); |
| 285 #endif | 288 #endif |
| 286 | 289 |
| 287 /** If Skia is running in a constrained environment and the typeface | 290 /** If Skia is running in a constrained environment and the typeface |
| 288 implementation is handle based, the typeface data may become | 291 implementation is handle based, the typeface data may become |
| 289 unavailable asynchronously. If a font host or scaler context method is | 292 unavailable asynchronously. If a font host or scaler context method is |
| 290 unable to access font data, it may call this function as a request to | 293 unable to access font data, it may call this function as a request to |
| 291 make the handle contained in the typeface useable. | 294 make the handle contained in the typeface useable. |
| 292 */ | 295 */ |
| 293 static void EnsureTypefaceAccessible(const SkTypeface& typeface); | 296 static void EnsureTypefaceAccessible(const SkTypeface& typeface); |
| 297 |
| 298 private: |
| 299 friend class SkTypeface; |
| 294 }; | 300 }; |
| 295 | 301 |
| 296 #endif | 302 #endif |
| OLD | NEW |