diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-01 20:12:26 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-01 20:12:26 +0000 |
commit | 0bc406df48ac6f358ab8dcff08f71fe9c32b79de (patch) | |
tree | 605cbca3d7f3d1261a651d36ee02884846f22611 /include | |
parent | 370a89980b2d38a6d01903b484bf404d6c48b496 (diff) |
Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is used with Blink/Chrome. Blink changes are uploaded with code change in patch https://codereview.chromium.org/147703002/
BUG=skia:
R=reed@android.com, edisonn@google.com, reed@google.com, mtklein@google.com, mtklein@chromium.org, bungeman@google.com
Author: h.joshi@samsung.com
Review URL: https://codereview.chromium.org/152073003
git-svn-id: http://skia.googlecode.com/svn/trunk@13635 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkPaint.h | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 48cd573dc4..7d553ec8e0 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -731,17 +731,60 @@ public: void setTextEncoding(TextEncoding encoding); struct FontMetrics { + /** Flags which indicate the confidence level of various metrics. + A set flag indicates that the metric may be trusted. + */ + enum FontMetricsFlags { + kUnderlineThinknessIsValid_Flag = 1 << 0, + kUnderlinePositionIsValid_Flag = 1 << 1, + }; + + uint32_t fFlags; //!< Bit field to identify which values are unknown SkScalar fTop; //!< The greatest distance above the baseline for any glyph (will be <= 0) SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0) SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0) SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0) SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0) - SkScalar fAvgCharWidth; //!< the average charactor width (>= 0) - SkScalar fMaxCharWidth; //!< the max charactor width (>= 0) + SkScalar fAvgCharWidth; //!< the average character width (>= 0) + SkScalar fMaxCharWidth; //!< the max character width (>= 0) SkScalar fXMin; //!< The minimum bounding box x value for all glyphs SkScalar fXMax; //!< The maximum bounding box x value for all glyphs SkScalar fXHeight; //!< The height of an 'x' in px, or 0 if no 'x' in face SkScalar fCapHeight; //!< The cap height (> 0), or 0 if cannot be determined. + SkScalar fUnderlineThickness; //!< underline thickness, or 0 if cannot be determined + + /** Underline Position - position of the top of the Underline stroke + relative to the baseline, this can have following values + - Negative - means underline should be drawn above baseline. + - Positive - means below baseline. + - Zero - mean underline should be drawn on baseline. + */ + SkScalar fUnderlinePosition; //!< underline position, or 0 if cannot be determined + + /** If the fontmetrics has a valid underlinethickness, return true, and set the + thickness param to that value. If it doesn't return false and ignore the + thickness param. + */ + bool hasUnderlineThickness(SkScalar* thickness) const { + if (SkToBool(fFlags & kUnderlineThinknessIsValid_Flag)) { + *thickness = fUnderlineThickness; + return true; + } + return false; + } + + /** If the fontmetrics has a valid underlineposition, return true, and set the + thickness param to that value. If it doesn't return false and ignore the + thickness param. + */ + bool hasUnderlinePosition(SkScalar* position) const { + if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) { + *position = fUnderlinePosition; + return true; + } + return false; + } + }; /** Return the recommend spacing between lines (which will be |