blob: 516da21777bbcde3f7aadfa5709856ac8bca671d [file] [log] [blame]
Cary Clarkcb6bef02018-11-29 12:05:25 -05001#Topic Font
2#Alias Font_Reference ##
3
Cary Clark3e73dcf2018-12-06 08:41:14 -05004#Code
5#Populate
6##
7
8#PhraseDef font_metrics
9Typeface, Font_Size, Font_Scale_X,
10Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting,
11Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear,
12and Font_Subpixel
13##
14
Cary Clarkcb6bef02018-11-29 12:05:25 -050015#Subtopic Advance
16# incomplete, should probably be in overview, not reference
17##
18#Subtopic Engine
19# incomplete, should probably be in overview, not reference
20##
21
Cary Clark3e73dcf2018-12-06 08:41:14 -050022#Subtopic Size
23#Line # overall height in points ##
24Font_Size adjusts the overall text size in points.
25Font_Size can be set to any positive value or zero.
26Font_Size defaults to 12.
27Font_Size
28##
29
30#Subtopic Scale_X
31#Line # text horizontal scale ##
32Font_Scale_X adjusts the text horizontal scale.
33Text scaling approximates condensed and expanded type faces when the actual face
34is not available.
35Font_Scale_X can be set to any value.
36Font_Scale_X defaults to 1.
37##
38
39#Subtopic Skew_X
40#Line # text horizontal slant ##
41Font_Skew_X adjusts the text horizontal slant.
42Text skewing approximates italic and oblique type faces when the actual face
43is not available.
44Font_Skew_X can be set to any value.
45Font_Skew_X defaults to 0.
46##
47
48#Subtopic Embolden
49#Line # approximate font styles ##
50
51Font_Embolden approximates the bold font style accompanying a normal font when a bold font face
52is not available. Skia does not provide font substitution; it is up to the client to find the
53bold font face using the platform Font_Manager.
54
55Use Font_Skew_X to approximate an italic font style when the italic font face
56is not available.
57
58A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to direct
59the font engine to create the bold Glyphs. Otherwise, the extra bold is computed
60by increasing the stroke width and setting the SkPaint::Style to
61SkPaint::kStrokeAndFill_Style as needed.
62
63Font_Embolden is disabled by default.
64#Subtopic Embolden ##
65
66#Subtopic Hinting_Spacing
67#Line # glyph spacing affected by hinting ##
68
69If Hinting is set to SkFontHinting::kFull, Hinting_Spacing adjusts the character
70spacing by the difference of the hinted and unhinted Left_Side_Bearing and
71Right_Side_Bearing. Hinting_Spacing only applies to platforms that use
72FreeType as their Font_Engine.
73
74Hinting_Spacing is not related to text kerning, where the space between
75a specific pair of characters is adjusted using data in the font kerning tables.
76#Subtopic Hinting_Spacing ##
77
78#Subtopic Linear
79#Line # selects text rendering as Glyph or Path ##
80Font_Linear selects whether text is rendered as a Glyph or as a Path.
81If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal.
82If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone.
83#Subtopic Linear ##
84
85#Subtopic Subpixel
86#Line # uses pixel transparency to represent fractional offset ##
87#Substitute sub-pixel
88Font_Subpixel uses the pixel transparency to represent a fractional offset.
89As the opaqueness of the color increases, the edge of the glyph appears to move
90towards the outside of the pixel.
91#Subtopic Subpixel ##
92
93#Subtopic Anti_Alias
94#Line # text relying on the order of RGB stripes ##
95When set, Anti_Alias positions glyphs within a pixel, using alpha and
96possibly RGB striping. It can take advantage of the organization of RGB stripes
97that create a color, and relies on the small size of the stripe and visual perception
98to make the color fringing imperceptible.
99
100Anti_Alias can be enabled on devices that orient stripes horizontally
101or vertically, and that order the color components as RGB or BGR. Internally, the
102glyph cache may store multiple copies of the same glyph with different sub-pixel
103positions, requiring more memory.
104#Subtopic Anti_Alias ##
105
106#Subtopic Force_Hinting
107#Line # always adjust glyph paths ##
108
109If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Force_Hinting
110instructs the Font_Manager to always hint Glyphs.
111Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or
112SkFontHinting::kSlight.
113
114Force_Hinting only affects platforms that use FreeType as the Font_Manager.
115#Subtopic Force_Hinting ##
116
117#Subtopic Embedded_Bitmaps
118#Line # custom sized bitmap Glyphs ##
119Embedded_Bitmaps allows selecting custom sized bitmap Glyphs.
120Embedded_Bitmaps when set chooses an embedded bitmap glyph over an outline contained
121in a font if the platform supports this option.
122
123FreeType selects the bitmap glyph if available when Embedded_Bitmaps is set, and selects
124the outline glyph if Embedded_Bitmaps is clear.
125Windows may select the bitmap glyph but is not required to do so.
126OS_X and iOS do not support this option.
Cary Clarkcb6bef02018-11-29 12:05:25 -0500127##
128
129# ------------------------------------------------------------------------------
130
131#Class SkFont
132
133SkFont controls options applied when drawing and measuring text.
134
135#Code
136#Populate
137##
138
139# ------------------------------------------------------------------------------
140
141#EnumClass Edging
142
143#Code
144#Populate
145##
146
147Whether edge pixels draw opaque or with partial transparency.
148
149#Const kAlias 0 # incomplete; replace '0' with member value
150#Line # no transparent pixels on glyph edges ##
151# incomplete; add description or delete
152##
153#Const kAntiAlias 0 # incomplete; replace '0' with member value
154#Line # may have transparent pixels on glyph edges ##
155# incomplete; add description or delete
156##
157#Const kSubpixelAntiAlias 0 # incomplete; replace '0' with member value
158#Line # glyph positioned in pixel using transparency ##
159# incomplete; add description or delete
160##
161
162# incomplete; add description or delete
163
164#Example
165// incomplete
166##
167
168#SeeAlso incomplete
169
170#EnumClass ##
171
172# ------------------------------------------------------------------------------
173
Cary Clarkcb6bef02018-11-29 12:05:25 -0500174#Method SkFont()
175#In Constructor
176#Line # incomplete ##
177
178#Populate
179
180#Example
181// incomplete
182##
183
184#SeeAlso incomplete
185
186#Method ##
187
188# ------------------------------------------------------------------------------
189
190#Method SkFont(sk_sp<SkTypeface> typeface, SkScalar size)
191#In Constructor
192#Line # incomplete ##
193
194#Populate
195
196#Example
197// incomplete
198##
199
200#SeeAlso incomplete
201
202#Method ##
203
204# ------------------------------------------------------------------------------
205
206#Method SkFont(sk_sp<SkTypeface> typeface, SkScalar size, SkScalar scaleX, SkScalar skewX)
207#In Constructor
208#Line # incomplete ##
209
210#Populate
211
212#Example
213// incomplete
214##
215
216#SeeAlso incomplete
217
218#Method ##
219
220# ------------------------------------------------------------------------------
221
Mike Reed42af4922018-11-30 08:54:46 -0500222#Method bool operator==(const SkFont& font) const
223#In Operator
224#Line # compares fonts for equality ##
225
226#Populate
227
228#Example
229// incomplete
230##
231
232#SeeAlso incomplete
233
234#Method ##
Cary Clarkcb6bef02018-11-29 12:05:25 -0500235
236# ------------------------------------------------------------------------------
237
238#Method bool isForceAutoHinting() const
239#In incomplete
240#Line # incomplete ##
241
242#Populate
243
244#Example
245// incomplete
246##
247
248#SeeAlso incomplete
249
250#Method ##
251
252# ------------------------------------------------------------------------------
253
254#Method bool isEmbeddedBitmaps() const
255#In incomplete
256#Line # incomplete ##
257
258#Populate
259
260#Example
261// incomplete
262##
263
264#SeeAlso incomplete
265
266#Method ##
267
268# ------------------------------------------------------------------------------
269
270#Method bool isSubpixel() const
271#In incomplete
272#Line # incomplete ##
273
274#Populate
275
276#Example
277// incomplete
278##
279
280#SeeAlso incomplete
281
282#Method ##
283
284# ------------------------------------------------------------------------------
285
286#Method bool isLinearMetrics() const
287#In incomplete
288#Line # incomplete ##
289
290#Populate
291
292#Example
293// incomplete
294##
295
296#SeeAlso incomplete
297
298#Method ##
299
300# ------------------------------------------------------------------------------
301
302#Method bool isEmbolden() const
303#In incomplete
304#Line # incomplete ##
305
306#Populate
307
308#Example
309// incomplete
310##
311
312#SeeAlso incomplete
313
314#Method ##
315
316# ------------------------------------------------------------------------------
317
318#Method void setForceAutoHinting(bool forceAutoHinting)
319#In incomplete
320#Line # incomplete ##
321
322#Populate
323
324#Example
325// incomplete
326##
327
328#SeeAlso incomplete
329
330#Method ##
331
332# ------------------------------------------------------------------------------
333
334#Method void setEmbeddedBitmaps(bool embeddedBitmaps)
335#In incomplete
336#Line # incomplete ##
337
338#Populate
339
340#Example
341// incomplete
342##
343
344#SeeAlso incomplete
345
346#Method ##
347
348# ------------------------------------------------------------------------------
349
350#Method void setSubpixel(bool subpixel)
351#In incomplete
352#Line # incomplete ##
353
354#Populate
355
356#Example
357// incomplete
358##
359
360#SeeAlso incomplete
361
362#Method ##
363
364# ------------------------------------------------------------------------------
365
366#Method void setLinearMetrics(bool linearMetrics)
367#In incomplete
368#Line # incomplete ##
369
370#Populate
371
372#Example
373// incomplete
374##
375
376#SeeAlso incomplete
377
378#Method ##
379
380# ------------------------------------------------------------------------------
381
382#Method void setEmbolden(bool embolden)
383#In incomplete
384#Line # incomplete ##
385
386#Populate
387
388#Example
389// incomplete
390##
391
392#SeeAlso incomplete
393
394#Method ##
395
396# ------------------------------------------------------------------------------
397
398#Method Edging getEdging() const
399#In incomplete
400#Line # incomplete ##
401
402#Populate
403
404#Example
405// incomplete
406##
407
408#SeeAlso incomplete
409
410#Method ##
411
412# ------------------------------------------------------------------------------
413
414#Method void setEdging(Edging edging)
415#In incomplete
416#Line # incomplete ##
417
418#Populate
419
420#Example
421// incomplete
422##
423
424#SeeAlso incomplete
425
426#Method ##
427
428# ------------------------------------------------------------------------------
429
430#Method void setHinting(SkFontHinting hintingLevel)
431#In incomplete
432#Line # incomplete ##
433
434#Populate
435
436#Example
437// incomplete
438##
439
440#SeeAlso incomplete
441
442#Method ##
443
444# ------------------------------------------------------------------------------
445
446#Method SkFontHinting getHinting() const
447#In incomplete
448#Line # incomplete ##
449
450#Populate
451
452#Example
453// incomplete
454##
455
456#SeeAlso incomplete
457
458#Method ##
459
460# ------------------------------------------------------------------------------
461
462#Method SkFont makeWithSize(SkScalar size) const
463#In incomplete
464#Line # incomplete ##
465
466#Populate
467
468#Example
469// incomplete
470##
471
472#SeeAlso incomplete
473
474#Method ##
475
476# ------------------------------------------------------------------------------
477
478#Method SkTypeface* getTypeface() const
479#In incomplete
480#Line # incomplete ##
481
482#Populate
483
484#Example
485// incomplete
486##
487
488#SeeAlso incomplete
489
490#Method ##
491
492# ------------------------------------------------------------------------------
493
494#Method SkScalar getSize() const
495#In incomplete
496#Line # incomplete ##
497
498#Populate
499
500#Example
501// incomplete
502##
503
504#SeeAlso incomplete
505
506#Method ##
507
508# ------------------------------------------------------------------------------
509
510#Method SkScalar getScaleX() const
511#In incomplete
512#Line # incomplete ##
513
514#Populate
515
516#Example
517// incomplete
518##
519
520#SeeAlso incomplete
521
522#Method ##
523
524# ------------------------------------------------------------------------------
525
526#Method SkScalar getSkewX() const
527#In incomplete
528#Line # incomplete ##
529
530#Populate
531
532#Example
533// incomplete
534##
535
536#SeeAlso incomplete
537
538#Method ##
539
540# ------------------------------------------------------------------------------
541
542#Method sk_sp<SkTypeface> refTypeface() const
543#In incomplete
544#Line # incomplete ##
545
546#Populate
547
548#Example
549// incomplete
550##
551
552#SeeAlso incomplete
553
554#Method ##
555
556# ------------------------------------------------------------------------------
557
558#Method void setTypeface(sk_sp<SkTypeface> tf)
559#In incomplete
560#Line # incomplete ##
561
562#Populate
563
564#Example
565// incomplete
566##
567
568#SeeAlso incomplete
569
570#Method ##
571
572# ------------------------------------------------------------------------------
573
574#Method void setSize(SkScalar textSize)
575#In incomplete
576#Line # incomplete ##
577
578#Populate
579
580#Example
581// incomplete
582##
583
584#SeeAlso incomplete
585
586#Method ##
587
588# ------------------------------------------------------------------------------
589
590#Method void setScaleX(SkScalar scaleX)
591#In incomplete
592#Line # incomplete ##
593
594#Populate
595
596#Example
597// incomplete
598##
599
600#SeeAlso incomplete
601
602#Method ##
603
604# ------------------------------------------------------------------------------
605
606#Method void setSkewX(SkScalar skewX)
607#In incomplete
608#Line # incomplete ##
609
610#Populate
611
612#Example
613// incomplete
614##
615
616#SeeAlso incomplete
617
618#Method ##
619
620# ------------------------------------------------------------------------------
621
622#Method int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding,
623 SkGlyphID glyphs[], int maxGlyphCount) const
624#In incomplete
625#Line # incomplete ##
626
627#Populate
628
629#Example
630// incomplete
631##
632
633#SeeAlso incomplete
634
635#Method ##
636
637# ------------------------------------------------------------------------------
638
639#Method uint16_t unicharToGlyph(SkUnichar uni) const
640#In incomplete
641#Line # incomplete ##
642
643#Populate
644
645#Example
646// incomplete
647##
648
649#SeeAlso incomplete
650
651#Method ##
652
653# ------------------------------------------------------------------------------
654
655#Method int countText(const void* text, size_t byteLength, SkTextEncoding encoding) const
656#In incomplete
657#Line # incomplete ##
658
659#Populate
660
661#Example
662// incomplete
663##
664
665#SeeAlso incomplete
666
667#Method ##
668
669# ------------------------------------------------------------------------------
670
Mike Reed42af4922018-11-30 08:54:46 -0500671#Method bool containsText(const void* text, size_t byteLength, SkTextEncoding encoding) const
672#In incomplete
673#Line # incomplete ##
674
675#Populate
676
677#Example
Cary Clarkcb6bef02018-11-29 12:05:25 -0500678// incomplete
Mike Reed42af4922018-11-30 08:54:46 -0500679##
680
681#SeeAlso incomplete
682
683#Method ##
Cary Clarkcb6bef02018-11-29 12:05:25 -0500684
685# ------------------------------------------------------------------------------
Cary Clark5b671c32018-12-03 04:53:21 -0500686
687#Method size_t breakText(const void* text, size_t length, SkTextEncoding encoding, SkScalar maxWidth,
688 SkScalar* measuredWidth = nullptr) const
689#In incomplete
690#Line # incomplete ##
691#Populate
692
693#Example
Cary Clarke954b9d2018-12-10 09:22:56 -0500694 #Description
695 Line under "Breakfast" shows desired width, shorter than available characters.
696 Line under "Bre" shows measured width after breaking text.
697 ##
698 #Height 128
699 #Width 280
700 void draw(SkCanvas* canvas) {
701 SkPaint paint;
702 paint.setAntiAlias(true);
703 paint.setTextSize(50);
704 const char str[] = "Breakfast";
705 const int count = sizeof(str) - 1;
706 canvas->drawText(str, count, 25, 50, paint);
707 SkScalar measuredWidth;
708 SkFont font;
709 font.setSize(50);
710 int partialBytes = font.breakText(str, count, kUTF8_SkTextEncoding,
711 100, &measuredWidth);
712 canvas->drawText(str, partialBytes, 25, 100, paint);
713 canvas->drawLine(25, 60, 25 + 100, 60, paint);
714 canvas->drawLine(25, 110, 25 + measuredWidth, 110, paint);
715 }
Cary Clark5b671c32018-12-03 04:53:21 -0500716##
717
718#SeeAlso incomplete
719
720#Method ##
721
722# ------------------------------------------------------------------------------
Cary Clarkcb6bef02018-11-29 12:05:25 -0500723
724#Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
725 SkRect* bounds = nullptr) const
726#In incomplete
727#Line # incomplete ##
728
729#Populate
730
731#Example
732// incomplete
733##
734
735#SeeAlso incomplete
736
737#Method ##
738
739# ------------------------------------------------------------------------------
740
741#Method bool getPath(uint16_t glyphID, SkPath* path) const
742#In incomplete
743#Line # incomplete ##
744
745#Populate
746
747#Example
748// incomplete
749##
750
751#SeeAlso incomplete
752
753#Method ##
754
755# ------------------------------------------------------------------------------
756
757#Method void getPaths(const uint16_t glyphIDs[], int count,
758 void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx),
759 void* ctx) const
760#In incomplete
761#Line # incomplete ##
762
763#Populate
764
765#Example
766// incomplete
767##
768
769#SeeAlso incomplete
770
771#Method ##
772
773# ------------------------------------------------------------------------------
774
775#Method SkScalar getMetrics(SkFontMetrics* metrics) const
776#In incomplete
777#Line # incomplete ##
778
779#Populate
780
781#Example
782// incomplete
783##
784
785#SeeAlso incomplete
786
787#Method ##
788
789# ------------------------------------------------------------------------------
790
791#Method SkScalar getSpacing() const
792#In incomplete
793#Line # incomplete ##
794
795#Populate
796
797#Example
798// incomplete
799##
800
801#SeeAlso incomplete
802
803#Method ##
804
805# ------------------------------------------------------------------------------
806
807#Class SkFont ##
808
809#Topic Font ##