| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Computer, Inc. | 2 * Copyright (C) 2007 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "FontCustomPlatformData.h" | 22 #include "FontCustomPlatformData.h" |
| 23 | 23 |
| 24 #include <ApplicationServices/ApplicationServices.h> | 24 #include <ApplicationServices/ApplicationServices.h> |
| 25 #include "SharedBuffer.h" | 25 #include "SharedBuffer.h" |
| 26 #include "FontPlatformData.h" | 26 #include "FontPlatformData.h" |
| 27 #include "OpenTypeSanitizer.h" |
| 27 | 28 |
| 28 namespace WebCore { | 29 namespace WebCore { |
| 29 | 30 |
| 30 FontCustomPlatformData::~FontCustomPlatformData() | 31 FontCustomPlatformData::~FontCustomPlatformData() |
| 31 { | 32 { |
| 32 if (m_atsContainer) | 33 if (m_atsContainer) |
| 33 ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault); | 34 ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault); |
| 34 CGFontRelease(m_cgFont); | 35 CGFontRelease(m_cgFont); |
| 35 } | 36 } |
| 36 | 37 |
| 37 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
ool italic, FontRenderingMode) | 38 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
ool italic, FontRenderingMode) |
| 38 { | 39 { |
| 39 return FontPlatformData(m_cgFont, (ATSUFontID)m_atsFont, size, bold, italic)
; | 40 return FontPlatformData(m_cgFont, (ATSUFontID)m_atsFont, size, bold, italic)
; |
| 40 } | 41 } |
| 41 | 42 |
| 42 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) | 43 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) |
| 43 { | 44 { |
| 44 ASSERT_ARG(buffer, buffer); | 45 ASSERT_ARG(buffer, buffer); |
| 45 | 46 |
| 47 #if ENABLE(OPENTYPE_SANITIZER) |
| 48 OpenTypeSanitizer sanitizer(buffer); |
| 49 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize(); |
| 50 if (!transcodeBuffer) |
| 51 return 0; // validation failed. |
| 52 buffer = transcodeBuffer.get(); |
| 53 #endif |
| 54 |
| 46 ATSFontContainerRef containerRef = 0; | 55 ATSFontContainerRef containerRef = 0; |
| 47 ATSFontRef fontRef = 0; | 56 ATSFontRef fontRef = 0; |
| 48 | 57 |
| 49 RetainPtr<CGFontRef> cgFontRef; | 58 RetainPtr<CGFontRef> cgFontRef; |
| 50 | 59 |
| 51 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) | 60 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) |
| 52 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData()); | 61 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData()); |
| 53 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithC
FData(bufferData.get())); | 62 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithC
FData(bufferData.get())); |
| 54 | 63 |
| 55 cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get())); | 64 cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get())); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 if (!cgFontRef) { | 95 if (!cgFontRef) { |
| 87 ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault); | 96 ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault); |
| 88 return 0; | 97 return 0; |
| 89 } | 98 } |
| 90 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) | 99 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) |
| 91 | 100 |
| 92 return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRe
f()); | 101 return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRe
f()); |
| 93 } | 102 } |
| 94 | 103 |
| 95 } | 104 } |
| OLD | NEW |