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

Unified Diff: include/core/SkFont.h

Issue 185293018: WIP -- SkFont (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: initial impl of Testing_CreateFromPaint Created 6 years, 9 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 | « gyp/core.gypi ('k') | src/core/SkFont.cpp » ('j') | src/core/SkFont.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFont.h
diff --git a/include/core/SkFont.h b/include/core/SkFont.h
new file mode 100644
index 0000000000000000000000000000000000000000..41e4fe8ad8b08a58b90aa85e548d375297c58462
--- /dev/null
+++ b/include/core/SkFont.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkRefCnt.h"
+#include "SkScalar.h"
+
+class SkPaint;
+class SkTypeface;
+
+enum SkTextEncoding {
+ kUTF8_SkTextEncoding,
+ kUTF16_SkTextEncoding,
+ kUTF32_SkTextEncoding,
+ kGlyphID_SkTextEncoding,
+};
+
+class SkFont : public SkRefCnt {
+public:
+ enum Flags {
+ /**
+ * Use the system's automatic hinting mechanism to hint the typeface.
+ * If both bytecode and auto hints are specified, attempt to use the bytecodes first.
+ * If that fails (e.g. there are no codes), then attempt to autohint.
+ */
+ kEnableAutoHints_Flag = 1 << 0,
+
+ /**
+ * If the typeface contains explicit bytecodes for hinting, use them.
+ * If both bytecode and auto hints are specified, attempt to use the bytecodes first;
+ * if that fails (e.g. there are no codes), then attempt to autohint.
+ */
+ kEnableByteCodeHints_Flag = 1 << 1,
+
+ /**
+ * Use rounded metric values (e.g. advance).
+ * If either auto or bytecode hinting was used, apply those results to the metrics of the
+ * glyphs as well. If no hinting was applied, the metrics will just be rounded to the
+ * nearest integer.
+ *
+ * This applies to calls that return metrics (e.g. measureText) and to drawing the glyphs
+ * (see SkCanvas drawText and drawPosText).
+ */
+ kUseNonlinearMetrics_Flag = 1 << 2,
+
+ kVertical_Flag = 1 << 3,
+ kEmbeddedBitmaps_Flag = 1 << 4,
+ kGenA8FromLCD_Flag = 1 << 5,
+ kEmbolden_Flag = 1 << 6,
+ };
+
+ enum MaskType {
+ kBW_MaskType,
+ kA8_MaskType,
+ kLCD_MaskType,
+ };
+
+ SkTypeface* getTypeface() const { return fTypeface; }
+ SkScalar getSize() const { return fSize; }
+ SkScalar getScaleX() const { return fScaleX; }
+ SkScalar getSkewX() const { return fSkewX; }
+ uint32_t getFlags() const { return fFlags; }
+ MaskType getMaskType() const {
+ return (MaskType)fMaskType;
+ }
+
+ int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding,
+ uint16_t glyphs[], int maxGlyphCount) const;
+
+ SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) const;
+
+ static SkFont* Create(SkTypeface*, SkScalar size, MaskType, uint32_t flags);
+ static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX,
+ MaskType, uint32_t flags);
+ static SkFont* Create(const SkFont&, SkScalar newSize);
+
+ static SkFont* Testing_CreateFromPaint(const SkPaint&);
+
+private:
+ enum {
+ kAllFlags = 0x3F,
+ };
+
+ SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType, uint32_t flags);
+ virtual ~SkFont();
+
+ SkTypeface* fTypeface;
+ SkScalar fSize;
+ SkScalar fScaleX;
+ SkScalar fSkewX;
+ uint16_t fFlags;
+ uint8_t fMaskType;
+ uint8_t fPad;
+};
+
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkFont.cpp » ('j') | src/core/SkFont.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698