| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2008 Holger Hans Peter Freyther | 6 * Copyright (C) 2008 Holger Hans Peter Freyther |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return m_fontFallbackList ? m_fontFallbackList->getFontSelector() : 0; | 187 return m_fontFallbackList ? m_fontFallbackList->getFontSelector() : 0; |
| 188 } | 188 } |
| 189 | 189 |
| 190 inline float Font::tabWidth(const SimpleFontData& fontData, const TabSize& tabSi
ze, float position) const | 190 inline float Font::tabWidth(const SimpleFontData& fontData, const TabSize& tabSi
ze, float position) const |
| 191 { | 191 { |
| 192 float baseTabWidth = tabSize.getPixelSize(fontData.spaceWidth()); | 192 float baseTabWidth = tabSize.getPixelSize(fontData.spaceWidth()); |
| 193 if (!baseTabWidth) | 193 if (!baseTabWidth) |
| 194 return getFontDescription().letterSpacing(); | 194 return getFontDescription().letterSpacing(); |
| 195 float distanceToTabStop = baseTabWidth - fmodf(position, baseTabWidth); | 195 float distanceToTabStop = baseTabWidth - fmodf(position, baseTabWidth); |
| 196 | 196 |
| 197 // The smallest allowable tab space is letterSpacing() (but must be at least
one layout unit). | 197 // Let the minimum width be the half of the space width so that it's always
recognizable. |
| 198 // if the distance to the next tab stop is less than that, advance an additi
onal tab stop. | 198 // if the distance to the next tab stop is less than that, advance an additi
onal tab stop. |
| 199 if (distanceToTabStop < std::max(getFontDescription().letterSpacing(), Layou
tUnit::epsilon())) | 199 if (distanceToTabStop < fontData.spaceWidth() / 2) |
| 200 distanceToTabStop += baseTabWidth; | 200 distanceToTabStop += baseTabWidth; |
| 201 | 201 |
| 202 return distanceToTabStop; | 202 return distanceToTabStop; |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace blink | 205 } // namespace blink |
| 206 | 206 |
| 207 #endif | 207 #endif |
| OLD | NEW |