OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "platform/fonts/FontFallbackList.h" | 29 #include "platform/fonts/FontFallbackList.h" |
30 #include "platform/fonts/GlyphBuffer.h" | 30 #include "platform/fonts/GlyphBuffer.h" |
31 #include "platform/fonts/SimpleFontData.h" | 31 #include "platform/fonts/SimpleFontData.h" |
32 #include "platform/fonts/harfbuzz/HarfBuzzShaper.h" | 32 #include "platform/fonts/harfbuzz/HarfBuzzShaper.h" |
33 #include "platform/fonts/mac/ComplexTextController.h" | 33 #include "platform/fonts/mac/ComplexTextController.h" |
34 #include "platform/geometry/IntRect.h" | 34 #include "platform/geometry/IntRect.h" |
35 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
36 #include "platform/text/TextRun.h" | 36 #include "platform/text/TextRun.h" |
37 #include "wtf/MathExtras.h" | 37 #include "wtf/MathExtras.h" |
38 | 38 |
39 using namespace std; | |
40 | |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 static bool preferHarfBuzz(const Font* font) | 41 static bool preferHarfBuzz(const Font* font) |
44 { | 42 { |
45 const FontDescription& description = font->fontDescription(); | 43 const FontDescription& description = font->fontDescription(); |
46 return description.featureSettings() && description.featureSettings()->size(
) > 0; | 44 return description.featureSettings() && description.featureSettings()->size(
) > 0; |
47 } | 45 } |
48 | 46 |
49 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint
& point, int h, | 47 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint
& point, int h, |
50 int from, int to) const | 48 int from, int to) const |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
tData*>* fallbackFonts, IntRectExtent* glyphBounds) const | 129 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
tData*>* fallbackFonts, IntRectExtent* glyphBounds) const |
132 { | 130 { |
133 if (preferHarfBuzz(this)) { | 131 if (preferHarfBuzz(this)) { |
134 HarfBuzzShaper shaper(this, run); | 132 HarfBuzzShaper shaper(this, run); |
135 if (shaper.shape()) | 133 if (shaper.shape()) |
136 return shaper.totalWidth(); | 134 return shaper.totalWidth(); |
137 } | 135 } |
138 ComplexTextController controller(this, run, true, fallbackFonts); | 136 ComplexTextController controller(this, run, true, fallbackFonts); |
139 glyphBounds->setTop(floorf(-controller.minGlyphBoundingBoxY())); | 137 glyphBounds->setTop(floorf(-controller.minGlyphBoundingBoxY())); |
140 glyphBounds->setBottom(ceilf(controller.maxGlyphBoundingBoxY())); | 138 glyphBounds->setBottom(ceilf(controller.maxGlyphBoundingBoxY())); |
141 glyphBounds->setLeft(max<int>(0, floorf(-controller.minGlyphBoundingBoxX()))
); | 139 glyphBounds->setLeft(std::max<int>(0, floorf(-controller.minGlyphBoundingBox
X()))); |
142 glyphBounds->setRight(max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() -
controller.totalWidth()))); | 140 glyphBounds->setRight(std::max<int>(0, ceilf(controller.maxGlyphBoundingBoxX
() - controller.totalWidth()))); |
143 | 141 |
144 return controller.totalWidth(); | 142 return controller.totalWidth(); |
145 } | 143 } |
146 | 144 |
147 int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool incl
udePartialGlyphs) const | 145 int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool incl
udePartialGlyphs) const |
148 { | 146 { |
149 if (preferHarfBuzz(this)) { | 147 if (preferHarfBuzz(this)) { |
150 HarfBuzzShaper shaper(this, run); | 148 HarfBuzzShaper shaper(this, run); |
151 if (shaper.shape()) | 149 if (shaper.shape()) |
152 return shaper.offsetForPosition(x); | 150 return shaper.offsetForPosition(x); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return simpleFontData; | 201 return simpleFontData; |
204 } | 202 } |
205 | 203 |
206 if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCh
aracterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, lengt
h)) | 204 if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCh
aracterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, lengt
h)) |
207 return baseCharacterGlyphData.fontData; | 205 return baseCharacterGlyphData.fontData; |
208 | 206 |
209 return SimpleFontData::systemFallback(); | 207 return SimpleFontData::systemFallback(); |
210 } | 208 } |
211 | 209 |
212 } // namespace blink | 210 } // namespace blink |
OLD | NEW |