| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebFont_h | |
| 32 #define WebFont_h | |
| 33 | |
| 34 #include "../platform/WebCanvas.h" | |
| 35 #include "../platform/WebColor.h" | |
| 36 #include "../platform/WebCommon.h" | |
| 37 | |
| 38 namespace WebKit { | |
| 39 | |
| 40 struct WebFontDescription; | |
| 41 struct WebFloatPoint; | |
| 42 struct WebFloatRect; | |
| 43 struct WebPoint; | |
| 44 struct WebRect; | |
| 45 struct WebTextRun; | |
| 46 | |
| 47 class WebFont { | |
| 48 public: | |
| 49 virtual ~WebFont() { } | |
| 50 | |
| 51 WEBKIT_EXPORT static WebFont* create(const WebFontDescription&); | |
| 52 | |
| 53 virtual WebFontDescription fontDescription() const = 0; | |
| 54 | |
| 55 virtual int ascent() const = 0; | |
| 56 virtual int descent() const = 0; | |
| 57 virtual int height() const = 0; | |
| 58 virtual int lineSpacing() const = 0; | |
| 59 virtual float xHeight() const = 0; | |
| 60 | |
| 61 // Draws the text run to the given canvas. The text is positioned at the | |
| 62 // given left-hand point at the baseline. | |
| 63 // | |
| 64 // The text will be clipped to the given clip rect. |canvasIsOpaque| is | |
| 65 // used to control whether subpixel antialiasing is possible. If there is a | |
| 66 // possibility the area drawn could be semi-transparent, subpixel | |
| 67 // antialiasing will be disabled. | |
| 68 // | |
| 69 // |from| and |to| allow the caller to specify a subrange of the given text | |
| 70 // run to draw. If |to| is -1, the entire run will be drawn. | |
| 71 virtual void drawText(WebCanvas*, const WebTextRun&, const WebFloatPoint& le
ftBaseline, WebColor, | |
| 72 const WebRect& clip, bool canvasIsOpaque, | |
| 73 int from = 0, int to = -1) const = 0; | |
| 74 | |
| 75 // Measures the width in pixels of the given text run. | |
| 76 virtual int calculateWidth(const WebTextRun&) const = 0; | |
| 77 | |
| 78 // Returns the character offset corresponding to the given horizontal pixel | |
| 79 // position as measured from from the left of the run. | |
| 80 virtual int offsetForPosition(const WebTextRun&, float position) const = 0; | |
| 81 | |
| 82 // Returns the rectangle representing the selection rect for the subrange | |
| 83 // |from| -> |to| of the given text run. You can use -1 for |to| to specify | |
| 84 // the entire run (this will do something similar to calling width()). | |
| 85 // | |
| 86 // The rect will be positioned as if the text was drawn at the given | |
| 87 // |leftBaseline| position. |height| indicates the height of the selection | |
| 88 // rect you want, typically this will just be the height() of this font. | |
| 89 // | |
| 90 // To get the pixel offset of some character (the opposite of | |
| 91 // offsetForPosition()), pass in a |leftBaseline| = (0, 0), |from| = 0, and | |
| 92 // |to| = the character you want. The right edge of the resulting selection | |
| 93 // rect will tell you the right side of the character. | |
| 94 virtual WebFloatRect selectionRectForText(const WebTextRun&, const WebFloatP
oint& leftBaseline, | |
| 95 int height, int from = 0, int to =
-1) const = 0; | |
| 96 }; | |
| 97 | |
| 98 } // namespace WebKit | |
| 99 | |
| 100 #endif | |
| OLD | NEW |