| 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 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" | 
| 10 #include "SkBase64.h" | 10 #include "SkBase64.h" | 
| (...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1917                                              &numFonts); | 1917                                              &numFonts); | 
| 1918 | 1918 | 
| 1919     if (fontHandle != NULL && numFonts < 1) { | 1919     if (fontHandle != NULL && numFonts < 1) { | 
| 1920         RemoveFontMemResourceEx(fontHandle); | 1920         RemoveFontMemResourceEx(fontHandle); | 
| 1921         return NULL; | 1921         return NULL; | 
| 1922     } | 1922     } | 
| 1923 | 1923 | 
| 1924     return fontHandle; | 1924     return fontHandle; | 
| 1925 } | 1925 } | 
| 1926 | 1926 | 
|  | 1927 // Does not affect ownership of stream. | 
| 1927 static SkTypeface* create_from_stream(SkStream* stream) { | 1928 static SkTypeface* create_from_stream(SkStream* stream) { | 
| 1928     // Create a unique and unpredictable font name. | 1929     // Create a unique and unpredictable font name. | 
| 1929     // Avoids collisions and access from CSS. | 1930     // Avoids collisions and access from CSS. | 
| 1930     char familyName[BASE64_GUID_ID_LEN]; | 1931     char familyName[BASE64_GUID_ID_LEN]; | 
| 1931     const int familyNameSize = SK_ARRAY_COUNT(familyName); | 1932     const int familyNameSize = SK_ARRAY_COUNT(familyName); | 
| 1932     if (FAILED(create_unique_font_name(familyName, familyNameSize))) { | 1933     if (FAILED(create_unique_font_name(familyName, familyNameSize))) { | 
| 1933         return NULL; | 1934         return NULL; | 
| 1934     } | 1935     } | 
| 1935 | 1936 | 
| 1936     // Change the name of the font. | 1937     // Change the name of the font. | 
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2474 | 2475 | 
| 2475     virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 2476     virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 
| 2476                                          const SkFontStyle& fontstyle) const SK_
      OVERRIDE { | 2477                                          const SkFontStyle& fontstyle) const SK_
      OVERRIDE { | 
| 2477         // could be in base impl | 2478         // could be in base impl | 
| 2478         SkString familyName; | 2479         SkString familyName; | 
| 2479         ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); | 2480         ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); | 
| 2480         return this->matchFamilyStyle(familyName.c_str(), fontstyle); | 2481         return this->matchFamilyStyle(familyName.c_str(), fontstyle); | 
| 2481     } | 2482     } | 
| 2482 | 2483 | 
| 2483     SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER
      RIDE { | 2484     SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER
      RIDE { | 
|  | 2485         SkAutoTDelete<SkStream> streamDeleter(stream); | 
| 2484         return create_from_stream(stream); | 2486         return create_from_stream(stream); | 
| 2485     } | 2487     } | 
| 2486 | 2488 | 
| 2487     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE { | 2489     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE { | 
| 2488         // could be in base impl | 2490         // could be in base impl | 
| 2489         SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data))); | 2491         return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data))); | 
| 2490         return this->createFromStream(stream); |  | 
| 2491     } | 2492     } | 
| 2492 | 2493 | 
| 2493     SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR
      IDE { | 2494     SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR
      IDE { | 
| 2494         // could be in base impl | 2495         // could be in base impl | 
| 2495         SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 2496         return this->createFromStream(SkStream::NewFromFile(path)); | 
| 2496         return this->createFromStream(stream); |  | 
| 2497     } | 2497     } | 
| 2498 | 2498 | 
| 2499     virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 2499     virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 
| 2500                                                unsigned styleBits) const SK_OVER
      RIDE { | 2500                                                unsigned styleBits) const SK_OVER
      RIDE { | 
| 2501         LOGFONT lf; | 2501         LOGFONT lf; | 
| 2502         if (NULL == familyName) { | 2502         if (NULL == familyName) { | 
| 2503             lf = get_default_font(); | 2503             lf = get_default_font(); | 
| 2504         } else { | 2504         } else { | 
| 2505             logfont_for_name(familyName, &lf); | 2505             logfont_for_name(familyName, &lf); | 
| 2506         } | 2506         } | 
| 2507 | 2507 | 
| 2508         SkTypeface::Style style = (SkTypeface::Style)styleBits; | 2508         SkTypeface::Style style = (SkTypeface::Style)styleBits; | 
| 2509         lf.lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL; | 2509         lf.lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL; | 
| 2510         lf.lfItalic = ((style & SkTypeface::kItalic) != 0); | 2510         lf.lfItalic = ((style & SkTypeface::kItalic) != 0); | 
| 2511         return SkCreateTypefaceFromLOGFONT(lf); | 2511         return SkCreateTypefaceFromLOGFONT(lf); | 
| 2512     } | 2512     } | 
| 2513 | 2513 | 
| 2514 private: | 2514 private: | 
| 2515     SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2515     SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 
| 2516 }; | 2516 }; | 
| 2517 | 2517 | 
| 2518 /////////////////////////////////////////////////////////////////////////////// | 2518 /////////////////////////////////////////////////////////////////////////////// | 
| 2519 | 2519 | 
| 2520 SkFontMgr* SkFontMgr_New_GDI() { | 2520 SkFontMgr* SkFontMgr_New_GDI() { | 
| 2521     return SkNEW(SkFontMgrGDI); | 2521     return SkNEW(SkFontMgrGDI); | 
| 2522 } | 2522 } | 
| OLD | NEW | 
|---|