Flutter Engine
The Flutter Engine
Classes | Macros | Functions | Variables
fontmgr.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontMetrics.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkFontStyle.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkGraphics.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkDashPathEffect.h"
#include "src/core/SkFontPriv.h"
#include "tools/SkMetaData.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"
#include <utility>

Go to the source code of this file.

Classes

class  FontMgrGM
 
class  FontMgrMatchGM
 
class  FontMgrBoundsGM
 

Macros

#define MAX_FAMILIES   30
 

Functions

static SkScalar drawString (SkCanvas *canvas, const SkString &text, SkScalar x, SkScalar y, const SkFont &font)
 
static SkScalar drawCharacter (SkCanvas *canvas, uint32_t character, SkScalar x, SkScalar y, const SkFont &origFont, SkFontMgr *fm, const char *fontName, const char *bcp47[], int bcp47Count, const SkFontStyle &fontStyle)
 

Variables

static const char * zh = "zh"
 
static const char * ja = "ja"
 

Macro Definition Documentation

◆ MAX_FAMILIES

#define MAX_FAMILIES   30

Definition at line 37 of file fontmgr.cpp.

Function Documentation

◆ drawCharacter()

static SkScalar drawCharacter ( SkCanvas canvas,
uint32_t  character,
SkScalar  x,
SkScalar  y,
const SkFont origFont,
SkFontMgr fm,
const char *  fontName,
const char *  bcp47[],
int  bcp47Count,
const SkFontStyle fontStyle 
)
static

Definition at line 45 of file fontmgr.cpp.

48 {
49 SkFont font = origFont;
50 // find typeface containing the requested character and draw it
51 SkString ch;
53 sk_sp<SkTypeface> typeface(fm->matchFamilyStyleCharacter(fontName, fontStyle,
54 bcp47, bcp47Count, character));
55 font.setTypeface(typeface);
56 x = drawString(canvas, ch, x, y, font) + 20;
57
58 if (nullptr == typeface) {
59 return x;
60 }
61
62 // repeat the process, but this time use the family name of the typeface
63 // from the first pass. This emulates the behavior in Blink where it
64 // it expects to get the same glyph when following this pattern.
65 SkString familyName;
66 typeface->getFamilyName(&familyName);
67 font.setTypeface(fm->legacyMakeTypeface(familyName.c_str(), typeface->fontStyle()));
68 return drawString(canvas, ch, x, y, font) + 20;
69}
sk_sp< SkTypeface > matchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const
Definition: SkFontMgr.cpp:114
sk_sp< SkTypeface > legacyMakeTypeface(const char familyName[], SkFontStyle style) const
Definition: SkFontMgr.cpp:150
Definition: SkFont.h:35
void appendUnichar(SkUnichar uni)
Definition: SkString.h:207
const char * c_str() const
Definition: SkString.h:133
static SkScalar drawString(SkCanvas *canvas, const SkString &text, SkScalar x, SkScalar y, const SkFont &font)
Definition: fontmgr.cpp:39
double y
double x
font
Font Metadata and Metrics.

◆ drawString()

static SkScalar drawString ( SkCanvas canvas,
const SkString text,
SkScalar  x,
SkScalar  y,
const SkFont font 
)
static

Definition at line 39 of file fontmgr.cpp.

40 {
41 canvas->drawString(text, x, y, font, SkPaint());
42 return x + font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8);
43}
@ kUTF8
uses bytes to represent UTF-8 or ASCII
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
std::u16string text

Variable Documentation

◆ ja

const char* ja = "ja"
static

Definition at line 72 of file fontmgr.cpp.

◆ zh

const char* zh = "zh"
static

Definition at line 71 of file fontmgr.cpp.