Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: include/core/SkPaint.h

Issue 152073003: Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is us… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixing comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPaint.h
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index abb859950c5bb6a66aecccded690ca8cd6ae02a2..cc9c84af08f08f4b9d83fb0fd946f842fe86fc16 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -731,17 +731,57 @@ 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
+ 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;
+ }
+ *thickness = 0;
reed1 2014/02/24 18:30:09 don't change thickness if we return false.
+ 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* thickness) const {
+ if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag))
+ {
+ *thickness = fUnderlinePosition;
+ return true;
+ }
+ *thickness = 0;
reed1 2014/02/24 18:30:09 Skia protocol for this sort of getter is (generall
+ return false;
+ }
+
};
/** Return the recommend spacing between lines (which will be
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698