| 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 26 matching lines...) Expand all Loading... |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/text/CharacterNames.h" | 40 #include "wtf/text/CharacterNames.h" |
| 41 | 41 |
| 42 #include <hb.h> | 42 #include <hb.h> |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 class FontPlatformData; | 46 class FontPlatformData; |
| 47 struct HarfBuzzFontData; | |
| 48 | 47 |
| 49 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { | 48 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { |
| 50 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); | 49 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); |
| 51 public: | 50 public: |
| 51 static const hb_tag_t vertTag; |
| 52 static const hb_tag_t vrt2Tag; |
| 52 | 53 |
| 53 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) | 54 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) |
| 54 { | 55 { |
| 55 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); | 56 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); |
| 56 } | 57 } |
| 57 ~HarfBuzzFace(); | 58 ~HarfBuzzFace(); |
| 58 | 59 |
| 59 // In order to support the restricting effect of unicode-range optionally a | 60 // In order to support the restricting effect of unicode-range optionally a |
| 60 // range restriction can be passed in, which will restrict which glyphs we | 61 // range restriction can be passed in, which will restrict which glyphs we |
| 61 // return in the harfBuzzGetGlyph function. | 62 // return in the harfBuzzGetGlyph function. |
| 62 hb_font_t* getScaledFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCode
point); | 63 hb_font_t* createFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCodepoi
nt) const; |
| 63 hb_face_t* face() const { return m_face; } | 64 hb_face_t* face() const { return m_face; } |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 HarfBuzzFace(FontPlatformData*, uint64_t); | 67 HarfBuzzFace(FontPlatformData*, uint64_t); |
| 67 | 68 |
| 68 hb_face_t* createFace(); | 69 hb_face_t* createFace(); |
| 69 void prepareHarfBuzzFontData(); | |
| 70 | 70 |
| 71 FontPlatformData* m_platformData; | 71 FontPlatformData* m_platformData; |
| 72 uint64_t m_uniqueID; | 72 uint64_t m_uniqueID; |
| 73 hb_face_t* m_face; | 73 hb_face_t* m_face; |
| 74 OwnPtr<hb_font_t> m_unscaledFont; | 74 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; |
| 75 OwnPtr<HarfBuzzFontData> m_harfBuzzFontData; | |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 } // namespace blink | 77 } // namespace blink |
| 79 | 78 |
| 80 namespace WTF { | 79 namespace WTF { |
| 81 | 80 |
| 82 template<typename T> struct OwnedPtrDeleter; | 81 template<typename T> struct OwnedPtrDeleter; |
| 83 template<> struct OwnedPtrDeleter<hb_font_t> { | 82 template<> struct OwnedPtrDeleter<hb_font_t> { |
| 84 STATIC_ONLY(OwnedPtrDeleter); | 83 STATIC_ONLY(OwnedPtrDeleter); |
| 85 static void deletePtr(hb_font_t* font) | 84 static void deletePtr(hb_font_t* font) |
| 86 { | 85 { |
| 87 if (font) | 86 if (font) |
| 88 hb_font_destroy(font); | 87 hb_font_destroy(font); |
| 89 } | 88 } |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 } // namespace WTF | 91 } // namespace WTF |
| 93 | 92 |
| 94 #endif // HarfBuzzFace_h | 93 #endif // HarfBuzzFace_h |
| OLD | NEW |