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

Side by Side Diff: include/core/SkFont.h

Issue 185293018: WIP -- SkFont (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkFont.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkTypeface;
12
13 enum SkTextEncoding {
14 kUTF8_SkTextEncoding,
15 kUTF16_SkTextEncoding,
16 kUTF32_SkTextEncoding,
17 kGlyphID_SkTextEncoding,
18 };
19
20 class SkFont : public SkRefCnt {
21 public:
22 enum Flags {
23 /**
24 * Us the system's automatic hinting mechanism to hint the typeface.
bungeman-skia 2014/03/26 16:23:40 nit: s/Us/Use
reed1 2014/03/26 18:05:00 Done.
25 * If both bytecode and auto hints are specified, attempt to use the by tecodes first.
26 * If that fails (e.g. there are no codes), then attempt to autohint.
27 */
28 kEnableAutoHints_Flag = 1 << 0,
29
30 /**
31 * If the typeface contains explicit bytecodes for hinting, use them.
32 * If both bytecode and auto hints are specified, attempt to use the by tecodes first.
bungeman-skia 2014/03/26 16:23:40 nit: semicolon at the end of this to link to the n
reed1 2014/03/26 18:05:00 Done.
33 * If that fails (e.g. there are no codes), then attempt to autohint.
34 */
35 kEnableByteCodeHints_Flag = 1 << 1,
36
37 /**
38 * Use rounded metric values (e.g. advance).
39 * If either auto or bytecode hinting was used, apply those results to the metrics of the
40 * glyphs as well. If no hinting was applied, the metrics will just be rounded to the
41 * nearest integer.
42 *
43 * This applies to calls that return metrics (e.g. measureText) and to drawing the glyphs
44 * (see SkCanvas drawText and drawPosText).
45 */
46 kUseNonlinearMetrics_Flag = 1 << 2,
47
48 kVertical_Flag = 1 << 3,
49 kEmbeddedBitmaps_Flag = 1 << 4,
50 kGenA8FromLCD_Flag = 1 << 5,
51 kLCD_Mask_Flag = 1 << 6,
bungeman-skia 2014/03/26 16:23:40 Since we're changing up all of this anyway, I'd li
reed1 2014/03/26 18:05:00 Trying yet another way to organize mask types...
52 kEmbolden_Flag = 1 << 7,
53 };
54
55
56 SkTypeface* getTypeface() const { return fTypeface; }
57 SkScalar getSize() const { return fSize; }
58 SkScalar getScaleX() const { return fScaleX; }
59 SkScalar getSkewX() const { return fSkewX; }
60 uint32_t getFlags() const { return fFlags; }
61
62 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding,
63 uint16_t glyphs[], int maxGlyphCount) const;
64
65 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co nst;
66
67 static SkFont* Create(SkTypeface*, SkScalar size, uint32_t flags);
68 static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX,
69 uint32_t flags);
70 static SkFont* Create(const SkFont&, SkScalar newSize);
71
72 private:
73 enum {
74 kAllFlags = 0xFF,
75 };
76
77 SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, uint32_t flags);
78 virtual ~SkFont();
79
80 SkTypeface* fTypeface;
81 SkScalar fSize;
82 SkScalar fScaleX;
83 SkScalar fSkewX;
84 uint32_t fFlags;
85 };
86
OLDNEW
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698