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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkRefCnt.h"
9 #include "SkScalar.h"
10
11 class SkPaint;
12 class SkTypeface;
13
14 enum SkTextEncoding {
15 kUTF8_SkTextEncoding,
16 kUTF16_SkTextEncoding,
17 kUTF32_SkTextEncoding,
18 kGlyphID_SkTextEncoding,
19 };
20
21 class SkFont : public SkRefCnt {
22 public:
23 enum Flags {
24 /**
25 * Use the system's automatic hinting mechanism to hint the typeface.
26 * If both bytecode and auto hints are specified, attempt to use the by tecodes first.
27 * If that fails (e.g. there are no codes), then attempt to autohint.
28 */
29 kEnableAutoHints_Flag = 1 << 0,
30
31 /**
32 * If the typeface contains explicit bytecodes for hinting, use them.
33 * If both bytecode and auto hints are specified, attempt to use the by tecodes first;
34 * if that fails (e.g. there are no codes), then attempt to autohint.
35 */
36 kEnableByteCodeHints_Flag = 1 << 1,
37
38 /**
39 * Use rounded metric values (e.g. advance).
40 * If either auto or bytecode hinting was used, apply those results to the metrics of the
41 * glyphs as well. If no hinting was applied, the metrics will just be rounded to the
42 * nearest integer.
43 *
44 * This applies to calls that return metrics (e.g. measureText) and to drawing the glyphs
45 * (see SkCanvas drawText and drawPosText).
46 */
47 kUseNonlinearMetrics_Flag = 1 << 2,
48
49 kVertical_Flag = 1 << 3,
50 kEmbeddedBitmaps_Flag = 1 << 4,
51 kGenA8FromLCD_Flag = 1 << 5,
52 kEmbolden_Flag = 1 << 6,
53 };
54
55 enum MaskType {
56 kBW_MaskType,
57 kA8_MaskType,
58 kLCD_MaskType,
59 };
60
61 SkTypeface* getTypeface() const { return fTypeface; }
62 SkScalar getSize() const { return fSize; }
63 SkScalar getScaleX() const { return fScaleX; }
64 SkScalar getSkewX() const { return fSkewX; }
65 uint32_t getFlags() const { return fFlags; }
66 MaskType getMaskType() const {
67 return (MaskType)fMaskType;
68 }
69
70 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding,
71 uint16_t glyphs[], int maxGlyphCount) const;
72
73 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co nst;
74
75 static SkFont* Create(SkTypeface*, SkScalar size, MaskType, uint32_t flags);
76 static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX,
77 MaskType, uint32_t flags);
78 static SkFont* Create(const SkFont&, SkScalar newSize);
79
80 static SkFont* Testing_CreateFromPaint(const SkPaint&);
81
82 private:
83 enum {
84 kAllFlags = 0x3F,
85 };
86
87 SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType , uint32_t flags);
88 virtual ~SkFont();
89
90 SkTypeface* fTypeface;
91 SkScalar fSize;
92 SkScalar fScaleX;
93 SkScalar fSkewX;
94 uint16_t fFlags;
95 uint8_t fMaskType;
96 uint8_t fPad;
97 };
98
OLDNEW
« 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