| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef HarfBuzzFace_h | 31 #ifndef HarfBuzzFace_h |
| 32 #define HarfBuzzFace_h | 32 #define HarfBuzzFace_h |
| 33 | 33 |
| 34 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
| 35 #include "wtf/PassRefPtr.h" | 35 #include "wtf/PassRefPtr.h" |
| 36 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
| 37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
| 38 #include "wtf/text/CharacterNames.h" |
| 38 | 39 |
| 39 #include <hb.h> | 40 #include <hb.h> |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class FontPlatformData; | 44 class FontPlatformData; |
| 44 | 45 |
| 45 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { | 46 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { |
| 46 public: | 47 public: |
| 47 static const hb_tag_t vertTag; | 48 static const hb_tag_t vertTag; |
| 48 static const hb_tag_t vrt2Tag; | 49 static const hb_tag_t vrt2Tag; |
| 49 | 50 |
| 50 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) | 51 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) |
| 51 { | 52 { |
| 52 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); | 53 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); |
| 53 } | 54 } |
| 54 ~HarfBuzzFace(); | 55 ~HarfBuzzFace(); |
| 55 | 56 |
| 56 hb_font_t* createFont() const; | 57 // In order to support the restricting effect of unicode-range optionally a |
| 58 // range restriction can be passed in, which will restrict which glyphs we |
| 59 // return in the harfBuzzGetGlyph function. |
| 60 hb_font_t* createFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCodepoi
nt) const; |
| 57 hb_face_t* face() const { return m_face; } | 61 hb_face_t* face() const { return m_face; } |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 HarfBuzzFace(FontPlatformData*, uint64_t); | 64 HarfBuzzFace(FontPlatformData*, uint64_t); |
| 61 | 65 |
| 62 hb_face_t* createFace(); | 66 hb_face_t* createFace(); |
| 63 | 67 |
| 64 FontPlatformData* m_platformData; | 68 FontPlatformData* m_platformData; |
| 65 uint64_t m_uniqueID; | 69 uint64_t m_uniqueID; |
| 66 hb_face_t* m_face; | 70 hb_face_t* m_face; |
| 67 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; | 71 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 } // namespace blink | 74 } // namespace blink |
| 71 | 75 |
| 72 namespace WTF { | 76 namespace WTF { |
| 73 | 77 |
| 74 template<typename T> struct OwnedPtrDeleter; | 78 template<typename T> struct OwnedPtrDeleter; |
| 75 template<> struct OwnedPtrDeleter<hb_font_t> { | 79 template<> struct OwnedPtrDeleter<hb_font_t> { |
| 76 static void deletePtr(hb_font_t* font) | 80 static void deletePtr(hb_font_t* font) |
| 77 { | 81 { |
| 78 if (font) | 82 if (font) |
| 79 hb_font_destroy(font); | 83 hb_font_destroy(font); |
| 80 } | 84 } |
| 81 }; | 85 }; |
| 82 | 86 |
| 83 } // namespace WTF | 87 } // namespace WTF |
| 84 | 88 |
| 85 #endif // HarfBuzzFace_h | 89 #endif // HarfBuzzFace_h |
| OLD | NEW |