| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 { | 43 { |
| 44 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) { | 44 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) { |
| 45 SkDebugf("%s last char is high-surrogate", __FUNCTION__); | 45 SkDebugf("%s last char is high-surrogate", __FUNCTION__); |
| 46 return false; | 46 return false; |
| 47 } | 47 } |
| 48 | 48 |
| 49 SkPaint paint; | 49 SkPaint paint; |
| 50 fontData->platformData().setupPaint(&paint); | 50 fontData->platformData().setupPaint(&paint); |
| 51 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 51 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); |
| 52 | 52 |
| 53 #if OS(WINDOWS) | 53 #if OS(WIN) |
| 54 // FIXME: For some reason SkAutoSTMalloc fails to link on Windows. | 54 // FIXME: For some reason SkAutoSTMalloc fails to link on Windows. |
| 55 // SkAutoSTArray works fine though... | 55 // SkAutoSTArray works fine though... |
| 56 SkAutoSTArray<GlyphPage::size, uint16_t> glyphStorage(length); | 56 SkAutoSTArray<GlyphPage::size, uint16_t> glyphStorage(length); |
| 57 #else | 57 #else |
| 58 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length); | 58 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length); |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 uint16_t* glyphs = glyphStorage.get(); | 61 uint16_t* glyphs = glyphStorage.get(); |
| 62 // textToGlyphs takes a byte count, not a glyph count so we multiply by two. | 62 // textToGlyphs takes a byte count, not a glyph count so we multiply by two. |
| 63 unsigned count = paint.textToGlyphs(buffer, bufferLength * 2, glyphs); | 63 unsigned count = paint.textToGlyphs(buffer, bufferLength * 2, glyphs); |
| 64 if (count != length) { | 64 if (count != length) { |
| 65 SkDebugf("%s count != length\n", __FUNCTION__); | 65 SkDebugf("%s count != length\n", __FUNCTION__); |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero | 69 unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero |
| 70 for (unsigned i = 0; i < length; i++) { | 70 for (unsigned i = 0; i < length; i++) { |
| 71 setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL)
; | 71 setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL)
; |
| 72 allGlyphs |= glyphs[i]; | 72 allGlyphs |= glyphs[i]; |
| 73 } | 73 } |
| 74 | 74 |
| 75 return allGlyphs != 0; | 75 return allGlyphs != 0; |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace WebCore | 78 } // namespace WebCore |
| OLD | NEW |