29#if defined(SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE)
32#if defined(SK_FONTMGR_FONTATIONS_AVAILABLE)
43constexpr char kFontFile[] =
"fonts/sbix_uncompressed_flags.ttf";
45constexpr uint16_t kStrikeIndex = 2;
53static inline int16_t sk_float_saturate2int16(
float x) {
59struct ShortCoordinate {
bool negative; uint8_t
magnitude; };
60static inline ShortCoordinate sk_float_saturate2sm8(
float x) {
61 bool negative =
x < 0;
62 x =
x < 255 ?
x : 255;
63 x =
x > -255 ?
x : -255;
64 return ShortCoordinate{ negative, negative ? (uint8_t)-
x : (uint8_t)
x };
78 static constexpr const int kGlyfXYMin = 0;
79 static constexpr const int kGlyfXYMax = 1;
80 static constexpr const int kGlyfLSB = 2;
81 static constexpr const int kGlyfFirstPoint = 3;
82 static constexpr const int kOriginOffset = 4;
84 std::vector<sk_sp<SkFontMgr>> fFontMgr;
85 std::vector<SkFont> fFonts;
87 bool fInputChanged =
false;
91 SBIXSlide() {
fName =
"SBIX"; }
95#if defined(SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE)
98#if defined(SK_FONTMGR_FONTATIONS_AVAILABLE)
106 updateSBIXData(fSBIXData.
get(),
true);
121 for (
auto&& fontmgr : fFontMgr) {
126 for (
auto&&
font : fFonts) {
146 for (
auto&& pt :
fPts) {
147 paint.setColor(pt.color);
164 for (
auto&& pt = std::rbegin(
fPts); pt != std::rend(
fPts); ++pt) {
166 return new PtClick(&*pt);
172 bool onClick(Click* click)
override {
173 ((PtClick*)click)->fPt->location.set(click->fCurr.fX - DX, click->fCurr.fY - DY);
179 class PtClick :
public Click {
182 PtClick(
Point* pt) : fPt(pt) {}
195 SkTAfter<SkSFNTHeader::TableDirectoryEntry>(sfntHeader);
204 for (
int tableEntryIndex = 0; tableEntryIndex < numTables; ++tableEntryIndex) {
206 glyfTableEntry = tableEntry + tableEntryIndex;
209 headTableEntry = tableEntry + tableEntryIndex;
212 hheaTableEntry = tableEntry + tableEntryIndex;
215 hmtxTableEntry = tableEntry + tableEntryIndex;
218 locaTableEntry = tableEntry + tableEntryIndex;
221 maxpTableEntry = tableEntry + tableEntryIndex;
224 sbixTableEntry = tableEntry + tableEntryIndex;
236 SkTAddOffset<SkOTTableGlyph>(sfntHeader, glyfTableOffset);
240 SkTAddOffset<SkOTTableHead>(sfntHeader, headTableOffset);
244 SkTAddOffset<SkOTTableHorizontalHeader>(sfntHeader, hheaTableOffset);
248 SkTAddOffset<SkOTTableHorizontalMetrics>(sfntHeader, hmtxTableOffset);
252 SkTAddOffset<SkOTTableIndexToLocation>(sfntHeader, locaTableOffset);
256 SkTAddOffset<SkOTTableMaximumProfile>(sfntHeader, maxpTableOffset);
265 if (sbixTableEntry) {
268 SkTAddOffset<SkOTTableStandardBitmapGraphics>(sfntHeader, sbixTableOffset);
275 SkTAddOffset<SkOTTableStandardBitmapGraphics::Strike>(sbixTable, strikeOffset);
282 SkTAddOffset<SkOTTableStandardBitmapGraphics::GlyphData>(strike, glyphDataOffset);
309 if (contourCount > 0) {
310 SK_OT_USHORT* endPtsOfContours = SkTAfter<SK_OT_USHORT>(glyphData);
311 SK_OT_USHORT* numInstructions = SkTAfter<SK_OT_USHORT>(endPtsOfContours,
313 SK_OT_BYTE* instructions = SkTAfter<SK_OT_BYTE>(numInstructions);
315 SkTAfter<SkOTTableGlyphData::Simple::Flags>(
321 size_t offsetToXDelta;
323 size_t offsetToYDelta;
326 std::vector<Coordinate> coordinates(numResultPoints);
328 size_t offsetToXDelta = 0;
329 size_t offsetToYDelta = 0;
331 for (
int i = 0;
i < numResultPoints; ++
i) {
334 if (currentFlags->
field.Repeat) {
337 nextFlags = SkTAfter<SkOTTableGlyphData::Simple::Flags>(
repeat);
339 nextFlags = SkTAfter<SkOTTableGlyphData::Simple::Flags>(currentFlags);
345 coordinates[
i].flags = currentFlags;
346 coordinates[
i].offsetToXDelta = offsetToXDelta;
347 coordinates[
i].offsetToYDelta = offsetToYDelta;
349 if (currentFlags->
field.xShortVector) {
351 coordinates[
i].xDeltaSize = 1;
352 }
else if (currentFlags->
field.xIsSame_xShortVectorPositive) {
355 coordinates[
i].xDeltaSize = 0;
357 coordinates[
i].xDeltaSize = coordinates[
i-1].xDeltaSize;
361 coordinates[
i].xDeltaSize = 2;
364 if (currentFlags->
field.yShortVector) {
366 coordinates[
i].yDeltaSize = 1;
367 }
else if (currentFlags->
field.yIsSame_yShortVectorPositive) {
370 coordinates[
i].yDeltaSize = 0;
372 coordinates[
i].yDeltaSize = coordinates[
i-1].yDeltaSize;
376 coordinates[
i].yDeltaSize = 2;
379 currentFlags = nextFlags;
382 SK_OT_BYTE* yCoordinates = xCoordinates + offsetToXDelta;
385 if (coordinates[pointIndex].xDeltaSize == 0) {
387 SkDebugf(
"Failed to move point in X at all.\n");
388 }
else if (coordinates[pointIndex].xDeltaSize == 1) {
389 ShortCoordinate
x = sk_float_saturate2sm8(
fPts[kGlyfFirstPoint].location.
x()*toEm);
390 xCoordinates[coordinates[pointIndex].offsetToXDelta] =
x.magnitude;
391 coordinates[pointIndex].flags->field.xIsSame_xShortVectorPositive = !
x.negative;
393 *
reinterpret_cast<SK_OT_SHORT*
>(xCoordinates + coordinates[pointIndex].offsetToXDelta) =
397 if (coordinates[pointIndex].yDeltaSize == 0) {
399 SkDebugf(
"Failed to move point in Y at all.\n");
400 }
else if (coordinates[pointIndex].yDeltaSize == 1) {
401 ShortCoordinate
y = sk_float_saturate2sm8(-
fPts[kGlyfFirstPoint].location.
y()*toEm);
402 yCoordinates[coordinates[pointIndex].offsetToYDelta] =
y.magnitude;
403 coordinates[pointIndex].flags->field.yIsSame_yShortVectorPositive = !
y.negative;
405 *
reinterpret_cast<SK_OT_SHORT*
>(yCoordinates + coordinates[pointIndex].offsetToYDelta) =
414 if (
kGlyphID < numberOfFullMetrics) {
422 SkTAfter<SkOTTableHorizontalMetrics::ShortMetric>(fullMetrics, numberOfFullMetrics);
423 int shortMetricIndex =
kGlyphID - numberOfFullMetrics;
427 shortMetrics[shortMetricIndex].
lsb = lsb;
static SkISize times(const SkISize &size, float factor)
static bool hittest(const SkPoint &target, SkScalar x, SkScalar y)
sk_sp< SkData > GetResourceAsData(const char *resource)
#define SkASSERT_RELEASE(cond)
static unsigned repeat(SkFixed fx, int max)
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SkEndian_SwapBE32(n)
#define SkEndian_SwapBE16(n)
static double magnitude(double a)
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Fontations_Empty()
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
@ kGlyphID
uses two byte words to represent glyph indices
static constexpr int16_t SK_MaxS16
static constexpr int16_t SK_MinS16
virtual bool onClick(Click *)=0
virtual Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi)=0
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
void clear(SkColor color)
@ kPoints_PointMode
draw each point separately
const void * data() const
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
virtual void load(SkScalar winWidth, SkScalar winHeight)
virtual void draw(SkCanvas *canvas)=0
FlutterSemanticsFlag flags
sk_sp< SkBlender > blender SkRect rect
font
Font Metadata and Metrics.
static double time(int loops, Benchmark *bench, Target *target)
SK_OT_SHORT numberOfContours
static const SK_OT_ULONG TAG
struct SkOTTableHead::IndexToLocFormat indexToLocFormat
static const SK_OT_ULONG TAG
union SkOTTableHead::Flags flags
static const SK_OT_ULONG TAG
struct SkOTTableHorizontalMetrics::FullMetric longHorMetric[1/*hhea::numberOfHMetrics */]
static const SK_OT_ULONG TAG
union SkOTTableMaximumProfile::Version version
static const SK_OT_ULONG TAG
SK_OT_SHORT originOffsetY
SK_OT_SHORT originOffsetX
SK_OT_ULONG glyphDataOffset(int glyphId)
static const SK_OT_ULONG TAG
SK_OT_ULONG strikeOffset(int strikeIndex)
void set(float x, float y)
static float Length(float x, float y)
constexpr float y() const
constexpr float x() const
std::shared_ptr< const fml::Mapping > data
struct SkOTTableGlyphData::Simple::Flags::Field field
struct SkOTTableHead::Flags::Field field
SkOTTableMaximumProfile::Version::TT tt