| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkFontConfigInterface_DEFINED | 8 #ifndef SkFontConfigInterface_DEFINED |
| 9 #define SkFontConfigInterface_DEFINED | 9 #define SkFontConfigInterface_DEFINED |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 static SkFontConfigInterface* RefGlobal(); | 27 static SkFontConfigInterface* RefGlobal(); |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Replace the current global instance with the specified one, safely | 30 * Replace the current global instance with the specified one, safely |
| 31 * ref'ing the new instance, and unref'ing the previous. Returns its | 31 * ref'ing the new instance, and unref'ing the previous. Returns its |
| 32 * parameter (the new global instance). | 32 * parameter (the new global instance). |
| 33 */ | 33 */ |
| 34 static SkFontConfigInterface* SetGlobal(SkFontConfigInterface*); | 34 static SkFontConfigInterface* SetGlobal(SkFontConfigInterface*); |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Given a familyName and style, find the best matching font and return | 37 * This should be treated as private to the impl of SkFontConfigInterface. |
| 38 * its fileFaceID and actual style (if outStyle is not null) and return | 38 * Callers should not change or expect any particular values. It is meant |
| 39 * true. If no matching font can be found, ignore fileFaceID and outStyle | 39 * to be a union of possible storage types to aid the impl. |
| 40 * and return false. | |
| 41 */ | 40 */ |
| 42 virtual bool match(const char familyName[], SkTypeface::Style requested, | 41 struct FontIdentity { |
| 43 unsigned* fileFaceID, SkTypeface::Style* outStyle) = 0; | 42 intptr_t fIntPtr; |
| 43 SkString fString; |
| 44 }; |
| 44 | 45 |
| 45 /** | 46 /** |
| 46 * Given a fileFaceID (returned by match), return the associated familyName | 47 * Given a familyName and style, find the best match. |
| 47 * and return true. If the associated name cannot be returned, ignore the | 48 * |
| 48 * name parameter, and return false. | 49 * If a match is found, return true and set its outFontIdentifier. |
| 50 * If outFamilyName is not null, assign the found familyName to it |
| 51 * (which may differ from the requested familyName). |
| 52 * If outStyle is not null, assign the found style to it |
| 53 * (which may differ from the requested style). |
| 54 * |
| 55 * If a match is not found, return false, and ignore all out parameters. |
| 49 */ | 56 */ |
| 50 virtual bool getFamilyName(unsigned fileFaceID, SkString* name) = 0; | 57 virtual bool matchFamilyName(const char familyName[], |
| 58 SkTypeface::Style requested, |
| 59 FontIdentity* outFontIdentifier, |
| 60 SkString* outFamilyName, |
| 61 SkTypeface::Style* outStyle) = 0; |
| 51 | 62 |
| 52 /** | 63 /** |
| 53 * Given a fileFaceID (returned by match), open a stream to access its | 64 * Given a FontRef, open a stream to access its data, or return null |
| 54 * data, which the caller while take ownership of (and will call unref() | 65 * if the FontRef's data is not available. The caller is responsible for |
| 55 * when they're through). On failure, return NULL. | 66 * calling stream->unref() when it is done accessing the data. |
| 56 */ | 67 */ |
| 57 virtual SkStream* openStream(unsigned fileFaceID) = 0; | 68 virtual SkStream* openStream(const FontIdentity&) = 0; |
| 58 }; | 69 }; |
| 59 | 70 |
| 60 #endif | 71 #endif |
| OLD | NEW |