| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "SymbolsIterator.h" | 5 #include "SymbolsIterator.h" |
| 6 | 6 |
| 7 #include "wtf/PtrUtil.h" | 7 #include "wtf/PtrUtil.h" |
| 8 #include <unicode/uchar.h> | 8 #include <unicode/uchar.h> |
| 9 #include <unicode/uniset.h> | 9 #include <unicode/uniset.h> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 return FontFallbackPriority::EmojiEmoji; | 34 return FontFallbackPriority::EmojiEmoji; |
| 35 | 35 |
| 36 if (Character::isEmojiEmojiDefault(codepoint) | 36 if (Character::isEmojiEmojiDefault(codepoint) |
| 37 || Character::isEmojiModifierBase(codepoint) | 37 || Character::isEmojiModifierBase(codepoint) |
| 38 || Character::isModifier(codepoint)) | 38 || Character::isModifier(codepoint)) |
| 39 return FontFallbackPriority::EmojiEmoji; | 39 return FontFallbackPriority::EmojiEmoji; |
| 40 | 40 |
| 41 if (Character::isEmojiTextDefault(codepoint)) | 41 if (Character::isEmojiTextDefault(codepoint)) |
| 42 return FontFallbackPriority::EmojiText; | 42 return FontFallbackPriority::EmojiText; |
| 43 | 43 |
| 44 UBlockCode block = ublock_getCode(codepoint); | 44 // Here we could segment into Symbols and Math categories as well, similar |
| 45 | 45 // to what the Windows font fallback does. Map the math Unicode and Symbols |
| 46 switch (block) { | 46 // blocks to Text for now since we don't have a good cross-platform way to |
| 47 case UBLOCK_PLAYING_CARDS: | 47 // select suitable math fonts. |
| 48 case UBLOCK_MISCELLANEOUS_SYMBOLS: | 48 return FontFallbackPriority::Text; |
| 49 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS: | |
| 50 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: | |
| 51 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: | |
| 52 case UBLOCK_ALCHEMICAL_SYMBOLS: | |
| 53 case UBLOCK_RUNIC: | |
| 54 case UBLOCK_DINGBATS: | |
| 55 case UBLOCK_GOTHIC: | |
| 56 return FontFallbackPriority::Symbols; | |
| 57 case UBLOCK_ARROWS: | |
| 58 case UBLOCK_MATHEMATICAL_OPERATORS: | |
| 59 case UBLOCK_MISCELLANEOUS_TECHNICAL: | |
| 60 case UBLOCK_GEOMETRIC_SHAPES: | |
| 61 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A: | |
| 62 case UBLOCK_SUPPLEMENTAL_ARROWS_A: | |
| 63 case UBLOCK_SUPPLEMENTAL_ARROWS_B: | |
| 64 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B: | |
| 65 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: | |
| 66 case UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS: | |
| 67 case UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS: | |
| 68 case UBLOCK_GEOMETRIC_SHAPES_EXTENDED: | |
| 69 return FontFallbackPriority::Math; | |
| 70 default: | |
| 71 return FontFallbackPriority::Text; | |
| 72 } | |
| 73 } | 49 } |
| 74 | 50 |
| 75 bool SymbolsIterator::consume(unsigned *symbolsLimit, FontFallbackPriority* font
FallbackPriority) | 51 bool SymbolsIterator::consume(unsigned *symbolsLimit, FontFallbackPriority* font
FallbackPriority) |
| 76 { | 52 { |
| 77 if (m_atEnd) | 53 if (m_atEnd) |
| 78 return false; | 54 return false; |
| 79 | 55 |
| 80 while (m_utf16Iterator->consume(m_nextChar)) { | 56 while (m_utf16Iterator->consume(m_nextChar)) { |
| 81 m_previousFontFallbackPriority = m_currentFontFallbackPriority; | 57 m_previousFontFallbackPriority = m_currentFontFallbackPriority; |
| 82 unsigned iteratorOffset = m_utf16Iterator->offset(); | 58 unsigned iteratorOffset = m_utf16Iterator->offset(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return true; | 127 return true; |
| 152 } | 128 } |
| 153 } | 129 } |
| 154 *symbolsLimit = m_bufferSize; | 130 *symbolsLimit = m_bufferSize; |
| 155 *fontFallbackPriority = m_currentFontFallbackPriority; | 131 *fontFallbackPriority = m_currentFontFallbackPriority; |
| 156 m_atEnd = true; | 132 m_atEnd = true; |
| 157 return true; | 133 return true; |
| 158 } | 134 } |
| 159 | 135 |
| 160 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |