| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 Google Inc. All rights reserved. | 2 * Copyright (c) 2015 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "platform/fonts/shaping/Shaper.h" | 32 #include "platform/fonts/shaping/Shaper.h" |
| 33 | 33 |
| 34 #include "platform/fonts/GlyphBuffer.h" |
| 35 #include "platform/fonts/GlyphPage.h" |
| 34 #include "platform/text/TextRun.h" | 36 #include "platform/text/TextRun.h" |
| 35 | 37 |
| 36 namespace blink { | 38 namespace blink { |
| 37 | 39 |
| 38 Shaper::Shaper(const Font* font, const TextRun& run, ForTextEmphasisOrNot forTex
tEmphasis, | 40 Shaper::Shaper(const Font* font, const TextRun& run, const GlyphData* emphasisDa
ta, |
| 39 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) | 41 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) |
| 40 : m_font(font) | 42 : m_font(font) |
| 41 , m_run(run) | 43 , m_run(run) |
| 42 , m_fallbackFonts(fallbackFonts) | 44 , m_fallbackFonts(fallbackFonts) |
| 43 , m_glyphBoundingBox(bounds) | 45 , m_glyphBoundingBox(bounds) |
| 44 , m_expansion(0) | 46 , m_expansion(0) |
| 45 , m_expansionPerOpportunity(0) | 47 , m_expansionPerOpportunity(0) |
| 46 , m_isAfterExpansion(!run.allowsLeadingExpansion()) | 48 , m_isAfterExpansion(!run.allowsLeadingExpansion()) |
| 47 , m_forTextEmphasis(forTextEmphasis) | 49 , m_emphasisSubstitutionData(emphasisData) |
| 48 { | 50 { |
| 51 if (emphasisData) { |
| 52 ASSERT(emphasisData->fontData); |
| 53 m_emphasisGlyphCenter = emphasisData->fontData->boundsForGlyph(emphasisD
ata->glyph).center(); |
| 54 } |
| 55 } |
| 56 |
| 57 void Shaper::addEmphasisMark(GlyphBuffer* buffer, float midGlyphOffset) const |
| 58 { |
| 59 ASSERT(buffer); |
| 60 ASSERT(m_emphasisSubstitutionData); |
| 61 |
| 62 const SimpleFontData* emphasisFontData = m_emphasisSubstitutionData->fontDat
a; |
| 63 ASSERT(emphasisFontData); |
| 64 |
| 65 bool isVertical = emphasisFontData->platformData().orientation() == Vertical |
| 66 && emphasisFontData->verticalData(); |
| 67 |
| 68 if (!isVertical) { |
| 69 buffer->add(m_emphasisSubstitutionData->glyph, emphasisFontData, |
| 70 midGlyphOffset - m_emphasisGlyphCenter.x()); |
| 71 } else { |
| 72 buffer->add(m_emphasisSubstitutionData->glyph, emphasisFontData, |
| 73 FloatPoint(-m_emphasisGlyphCenter.x(), midGlyphOffset - m_emphasisGl
yphCenter.y())); |
| 74 } |
| 49 } | 75 } |
| 50 | 76 |
| 51 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |