Flutter Engine
The Flutter Engine
SkFontMetricsPriv.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
12
13#include <optional>
14
16 buffer.writeUInt(metrics.fFlags);
17 buffer.writeScalar(metrics.fTop);
18 buffer.writeScalar(metrics.fAscent);
19 buffer.writeScalar(metrics.fDescent);
20 buffer.writeScalar(metrics.fBottom);
21 buffer.writeScalar(metrics.fLeading);
22 buffer.writeScalar(metrics.fAvgCharWidth);
23 buffer.writeScalar(metrics.fMaxCharWidth);
24 buffer.writeScalar(metrics.fXMin);
25 buffer.writeScalar(metrics.fXMax);
26 buffer.writeScalar(metrics.fXHeight);
27 buffer.writeScalar(metrics.fCapHeight);
28 buffer.writeScalar(metrics.fUnderlineThickness);
29 buffer.writeScalar(metrics.fUnderlinePosition);
30 buffer.writeScalar(metrics.fStrikeoutThickness);
31 buffer.writeScalar(metrics.fStrikeoutPosition);
32}
33
35 SkASSERT(buffer.isValid());
36
37 SkFontMetrics metrics;
38 metrics.fFlags = buffer.readUInt();
39 metrics.fTop = buffer.readScalar();
40 metrics.fAscent = buffer.readScalar();
41 metrics.fDescent = buffer.readScalar();
42 metrics.fBottom = buffer.readScalar();
43 metrics.fLeading = buffer.readScalar();
44 metrics.fAvgCharWidth = buffer.readScalar();
45 metrics.fMaxCharWidth = buffer.readScalar();
46 metrics.fXMin = buffer.readScalar();
47 metrics.fXMax = buffer.readScalar();
48 metrics.fXHeight = buffer.readScalar();
49 metrics.fCapHeight = buffer.readScalar();
50 metrics.fUnderlineThickness = buffer.readScalar();
51 metrics.fUnderlinePosition = buffer.readScalar();
52 metrics.fStrikeoutThickness = buffer.readScalar();
53 metrics.fStrikeoutPosition = buffer.readScalar();
54
55 // All the reads above were valid, so return the metrics.
56 if (buffer.isValid()) {
57 return metrics;
58 }
59
60 return std::nullopt;
61}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void Flatten(SkWriteBuffer &buffer, const SkFontMetrics &metrics)
static std::optional< SkFontMetrics > MakeFromBuffer(SkReadBuffer &buffer)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
Definition: SkFontMetrics.h:53
SkScalar fLeading
distance to add between lines, typically positive or zero
Definition: SkFontMetrics.h:57
SkScalar fAvgCharWidth
average character width, zero if unknown
Definition: SkFontMetrics.h:58
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
Definition: SkFontMetrics.h:67
SkScalar fStrikeoutThickness
strikeout thickness
Definition: SkFontMetrics.h:66
SkScalar fMaxCharWidth
maximum character width, zero if unknown
Definition: SkFontMetrics.h:59
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
Definition: SkFontMetrics.h:56
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
Definition: SkFontMetrics.h:52
SkScalar fAscent
distance to reserve above baseline, typically negative
Definition: SkFontMetrics.h:54
SkScalar fXHeight
height of lower-case 'x', zero if unknown, typically negative
Definition: SkFontMetrics.h:62
SkScalar fUnderlineThickness
underline thickness
Definition: SkFontMetrics.h:64
SkScalar fDescent
distance to reserve below baseline, typically positive
Definition: SkFontMetrics.h:55
SkScalar fCapHeight
height of an upper-case letter, zero if unknown, typically negative
Definition: SkFontMetrics.h:63
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
Definition: SkFontMetrics.h:60
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
Definition: SkFontMetrics.h:65
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
Definition: SkFontMetrics.h:61