| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/platform/graphics/GlyphPageTreeNode.h" | 30 #include "core/platform/graphics/GlyphPageTreeNode.h" |
| 31 | 31 |
| 32 #include <ApplicationServices/ApplicationServices.h> | 32 #include <ApplicationServices/ApplicationServices.h> |
| 33 #include "core/platform/graphics/Font.h" | 33 #include "core/platform/graphics/Font.h" |
| 34 #include "core/platform/graphics/SimpleFontData.h" | 34 #include "core/platform/graphics/SimpleFontData.h" |
| 35 #include "core/platform/mac/WebCoreSystemInterface.h" | 35 #include "core/platform/mac/WebCoreSystemInterface.h" |
| 36 | 36 |
| 37 // Forward declare Mac SPIs. |
| 38 // Request for public API: rdar://13787589 |
| 39 extern "C" { |
| 40 void CGFontGetGlyphsForUnichars(CGFontRef font, const UniChar chars[], CGGlyph g
lyphs[], size_t length); |
| 41 } |
| 42 |
| 37 namespace WebCore { | 43 namespace WebCore { |
| 38 | 44 |
| 39 static bool shouldUseCoreText(UChar* buffer, unsigned bufferLength, const Simple
FontData* fontData) | 45 static bool shouldUseCoreText(UChar* buffer, unsigned bufferLength, const Simple
FontData* fontData) |
| 40 { | 46 { |
| 41 if (fontData->platformData().isCompositeFontReference()) | 47 if (fontData->platformData().isCompositeFontReference()) |
| 42 return true; | 48 return true; |
| 43 if (fontData->platformData().widthVariant() != RegularWidth || fontData->has
VerticalGlyphs()) { | 49 if (fontData->platformData().widthVariant() != RegularWidth || fontData->has
VerticalGlyphs()) { |
| 44 // Ideographs don't have a vertical variant or width variants. | 50 // Ideographs don't have a vertical variant or width variants. |
| 45 for (unsigned i = 0; i < bufferLength; ++i) { | 51 for (unsigned i = 0; i < bufferLength; ++i) { |
| 46 if (!Font::isCJKIdeograph(buffer[i])) | 52 if (!Font::isCJKIdeograph(buffer[i])) |
| 47 return true; | 53 return true; |
| 48 } | 54 } |
| 49 } | 55 } |
| 50 | 56 |
| 51 return false; | 57 return false; |
| 52 } | 58 } |
| 53 | 59 |
| 54 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
ufferLength, const SimpleFontData* fontData) | 60 bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
ufferLength, const SimpleFontData* fontData) |
| 55 { | 61 { |
| 56 bool haveGlyphs = false; | 62 bool haveGlyphs = false; |
| 57 | 63 |
| 58 Vector<CGGlyph, 512> glyphs(bufferLength); | 64 Vector<CGGlyph, 512> glyphs(bufferLength); |
| 59 if (!shouldUseCoreText(buffer, bufferLength, fontData)) { | 65 if (!shouldUseCoreText(buffer, bufferLength, fontData)) { |
| 60 WKGetGlyphsForCharacters(fontData->platformData().cgFont(), buffer, glyp
hs.data(), bufferLength); | 66 CGFontGetGlyphsForUnichars(fontData->platformData().cgFont(), buffer, gl
yphs.data(), bufferLength); |
| 61 for (unsigned i = 0; i < length; ++i) { | 67 for (unsigned i = 0; i < length; ++i) { |
| 62 if (!glyphs[i]) | 68 if (!glyphs[i]) |
| 63 setGlyphDataForIndex(offset + i, 0, 0); | 69 setGlyphDataForIndex(offset + i, 0, 0); |
| 64 else { | 70 else { |
| 65 setGlyphDataForIndex(offset + i, glyphs[i], fontData); | 71 setGlyphDataForIndex(offset + i, glyphs[i], fontData); |
| 66 haveGlyphs = true; | 72 haveGlyphs = true; |
| 67 } | 73 } |
| 68 } | 74 } |
| 69 } else if (!fontData->platformData().isCompositeFontReference() && ((fontDat
a->platformData().widthVariant() == RegularWidth) ? WKGetVerticalGlyphsForCharac
ters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength) | 75 } else if (!fontData->platformData().isCompositeFontReference() && ((fontDat
a->platformData().widthVariant() == RegularWidth) ? WKGetVerticalGlyphsForCharac
ters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength) |
| 70 : CTFontGetGlyphsForCharacters(fontData->platformData().ctFont(),
buffer, glyphs.data(), bufferLength))) { | 76 : CTFontGetGlyphsForCharacters(fontData->platformData().ctFont(),
buffer, glyphs.data(), bufferLength))) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 160 } |
| 155 } | 161 } |
| 156 } | 162 } |
| 157 } | 163 } |
| 158 } | 164 } |
| 159 | 165 |
| 160 return haveGlyphs; | 166 return haveGlyphs; |
| 161 } | 167 } |
| 162 | 168 |
| 163 } // namespace WebCore | 169 } // namespace WebCore |
| OLD | NEW |