OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 21 matching lines...) Expand all Loading... |
32 { | 32 { |
33 } | 33 } |
34 | 34 |
35 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) | 35 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) |
36 : m_width(0) | 36 : m_width(0) |
37 , m_height(0) | 37 , m_height(0) |
38 , m_length(1) | 38 , m_length(1) |
39 { | 39 { |
40 } | 40 } |
41 | 41 |
42 SVGTextMetrics::SVGTextMetrics(LineLayoutSVGInlineText textLayoutItem, const Tex
tRun& run) | |
43 { | |
44 ASSERT(textLayoutItem); | |
45 | |
46 float scalingFactor = textLayoutItem.scalingFactor(); | |
47 ASSERT(scalingFactor); | |
48 | |
49 const Font& scaledFont = textLayoutItem.scaledFont(); | |
50 | |
51 // Calculate width/height using the scaled font, divide this result by the s
calingFactor afterwards. | |
52 m_width = scaledFont.width(run) / scalingFactor; | |
53 m_height = scaledFont.getFontMetrics().floatHeight() / scalingFactor; | |
54 | |
55 ASSERT(run.length() >= 0); | |
56 m_length = static_cast<unsigned>(run.length()); | |
57 } | |
58 | |
59 TextRun SVGTextMetrics::constructTextRun(LineLayoutSVGInlineText textLayoutItem,
unsigned position, unsigned length, TextDirection textDirection) | 42 TextRun SVGTextMetrics::constructTextRun(LineLayoutSVGInlineText textLayoutItem,
unsigned position, unsigned length, TextDirection textDirection) |
60 { | 43 { |
61 const ComputedStyle& style = textLayoutItem.styleRef(); | 44 const ComputedStyle& style = textLayoutItem.styleRef(); |
62 | 45 |
63 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be
low if non-zero. | 46 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be
low if non-zero. |
64 , 0 // length, will be set below if non-zero. | 47 , 0 // length, will be set below if non-zero. |
65 , 0 // xPos, only relevant with allowTabs=true | 48 , 0 // xPos, only relevant with allowTabs=true |
66 , 0 // padding, only relevant for justified text, not relevant for SVG | 49 , 0 // padding, only relevant for justified text, not relevant for SVG |
67 , TextRun::AllowTrailingExpansion | 50 , TextRun::AllowTrailingExpansion |
68 , textDirection | 51 , textDirection |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return width(); | 88 return width(); |
106 case FontOrientation::VerticalUpright: | 89 case FontOrientation::VerticalUpright: |
107 return height(); | 90 return height(); |
108 default: | 91 default: |
109 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
110 return width(); | 93 return width(); |
111 } | 94 } |
112 } | 95 } |
113 | 96 |
114 } // namespace blink | 97 } // namespace blink |
OLD | NEW |