Reland "hide setTextAlign"
This reverts commitf10ea21088
. Reason for revert: flag added for google3 Original change's description: > Revert "hide setTextAlign" > > This reverts commit43c718302e
. > > Reason for revert: Google 3 roll. > > Original change's description: > > hide setTextAlign > > > > Bug: skia:8493 > > Change-Id: Ib3347f600300e90d5bcc47910fd75244039a016c > > Reviewed-on: https://skia-review.googlesource.com/c/164697 > > Commit-Queue: Mike Reed <reed@google.com> > > Reviewed-by: Ben Wagner <bungeman@google.com> > > TBR=djsollen@google.com,bungeman@google.com,herb@google.com,fmalita@chromium.org,reed@google.com > > Change-Id: I877bf993e71a6e81f1322c799c533bfea6c5813f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:8493 > Reviewed-on: https://skia-review.googlesource.com/c/165660 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> TBR=djsollen@google.com,bungeman@google.com,herb@google.com,brianosman@google.com,fmalita@chromium.org,reed@google.com Change-Id: I0f224cd560cea12ddac3cd48d244f85ccd943086 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8493 Reviewed-on: https://skia-review.googlesource.com/c/165681 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
f9e3a13090
commit
6e24cd3e28
@ -891,7 +891,9 @@ static void fuzz_paint_text(Fuzz* fuzz, SkPaint* paint) {
|
|||||||
paint->setDevKernText( make_fuzz_t<bool>(fuzz));
|
paint->setDevKernText( make_fuzz_t<bool>(fuzz));
|
||||||
paint->setHinting( make_fuzz_t_range<SkPaint::Hinting>(fuzz, 0,
|
paint->setHinting( make_fuzz_t_range<SkPaint::Hinting>(fuzz, 0,
|
||||||
SkPaint::kFull_Hinting));
|
SkPaint::kFull_Hinting));
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
paint->setTextAlign( make_fuzz_t_range<SkPaint::Align>(fuzz, 0, 2));
|
paint->setTextAlign( make_fuzz_t_range<SkPaint::Align>(fuzz, 0, 2));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fuzz_paint_text_encoding(Fuzz* fuzz, SkPaint* paint) {
|
static void fuzz_paint_text_encoding(Fuzz* fuzz, SkPaint* paint) {
|
||||||
|
@ -872,6 +872,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static constexpr int kAlignCount = 3;
|
static constexpr int kAlignCount = 3;
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
/** Returns SkPaint::Align.
|
/** Returns SkPaint::Align.
|
||||||
Returns kLeft_Align if SkPaint::Align has not been set.
|
Returns kLeft_Align if SkPaint::Align has not been set.
|
||||||
|
|
||||||
@ -885,6 +886,7 @@ public:
|
|||||||
@param align text placement relative to position
|
@param align text placement relative to position
|
||||||
*/
|
*/
|
||||||
void setTextAlign(Align align);
|
void setTextAlign(Align align);
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Returns text size in points.
|
/** Returns text size in points.
|
||||||
|
|
||||||
|
@ -164,7 +164,9 @@ void SkFont::LEGACY_applyToPaint(SkPaint* paint) const {
|
|||||||
|
|
||||||
paint->setHinting((SkPaint::Hinting)this->getHinting());
|
paint->setHinting((SkPaint::Hinting)this->getHinting());
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
paint->setTextAlign((SkPaint::Align)fAlign);
|
paint->setTextAlign((SkPaint::Align)fAlign);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFont SkFont::LEGACY_ExtractFromPaint(const SkPaint& paint) {
|
SkFont SkFont::LEGACY_ExtractFromPaint(const SkPaint& paint) {
|
||||||
@ -193,7 +195,11 @@ SkFont SkFont::LEGACY_ExtractFromPaint(const SkPaint& paint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkFont font(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(),
|
SkFont font(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(),
|
||||||
paint.getTextSkewX(), flags, (int)paint.getTextAlign());
|
paint.getTextSkewX(), flags
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
|
, (int)paint.getTextAlign()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
font.setHinting((Hinting)paint.getHinting());
|
font.setHinting((Hinting)paint.getHinting());
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
@ -387,6 +387,7 @@ void SkGlyphRunBuilder::simplifyDrawText(
|
|||||||
endOfLastGlyph += fScratchAdvances[i];
|
endOfLastGlyph += fScratchAdvances[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
|
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
|
||||||
SkVector len = endOfLastGlyph - origin;
|
SkVector len = endOfLastGlyph - origin;
|
||||||
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
|
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
|
||||||
@ -396,6 +397,7 @@ void SkGlyphRunBuilder::simplifyDrawText(
|
|||||||
pt -= len;
|
pt -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
this->makeGlyphRun(
|
this->makeGlyphRun(
|
||||||
paint,
|
paint,
|
||||||
|
@ -309,6 +309,7 @@ void SkPaint::setStrokeJoin(Join jt) {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
void SkPaint::setTextAlign(Align align) {
|
void SkPaint::setTextAlign(Align align) {
|
||||||
if ((unsigned)align < kAlignCount) {
|
if ((unsigned)align < kAlignCount) {
|
||||||
fBitfields.fTextAlign = SkToU8(align);
|
fBitfields.fTextAlign = SkToU8(align);
|
||||||
@ -318,6 +319,7 @@ void SkPaint::setTextAlign(Align align) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void SkPaint::setTextSize(SkScalar ts) {
|
void SkPaint::setTextSize(SkScalar ts) {
|
||||||
if (ts >= 0) {
|
if (ts >= 0) {
|
||||||
@ -422,7 +424,9 @@ static uint32_t pack_paint_flags(unsigned flags, unsigned hint, unsigned align,
|
|||||||
static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) {
|
static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) {
|
||||||
paint->setFlags(packed >> 16);
|
paint->setFlags(packed >> 16);
|
||||||
paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF)));
|
paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF)));
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF)));
|
paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF)));
|
||||||
|
#endif
|
||||||
paint->setFilterQuality((SkFilterQuality)((packed >> 10) & BPF_Mask(kFilter_BPF)));
|
paint->setFilterQuality((SkFilterQuality)((packed >> 10) & BPF_Mask(kFilter_BPF)));
|
||||||
return (FlatFlags)(packed & kFlatFlagMask);
|
return (FlatFlags)(packed & kFlatFlagMask);
|
||||||
}
|
}
|
||||||
@ -454,7 +458,12 @@ void SkPaintPriv::Flatten(const SkPaint& paint, SkWriteBuffer& buffer) {
|
|||||||
buffer.writeScalar(paint.getStrokeMiter());
|
buffer.writeScalar(paint.getStrokeMiter());
|
||||||
buffer.writeColor4f(paint.getColor4f());
|
buffer.writeColor4f(paint.getColor4f());
|
||||||
|
|
||||||
buffer.writeUInt(pack_paint_flags(paint.getFlags(), paint.getHinting(), paint.getTextAlign(),
|
buffer.writeUInt(pack_paint_flags(paint.getFlags(), paint.getHinting(),
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
|
paint.getTextAlign(),
|
||||||
|
#else
|
||||||
|
SkPaint::kLeft_Align,
|
||||||
|
#endif
|
||||||
paint.getFilterQuality(), flatFlags));
|
paint.getFilterQuality(), flatFlags));
|
||||||
buffer.writeUInt(pack_4(paint.getStrokeCap(), paint.getStrokeJoin(),
|
buffer.writeUInt(pack_4(paint.getStrokeCap(), paint.getStrokeJoin(),
|
||||||
(paint.getStyle() << 4) | paint.getTextEncoding(),
|
(paint.getStyle() << 4) | paint.getTextEncoding(),
|
||||||
|
@ -811,6 +811,7 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
|
|||||||
// now compute fXOffset if needed
|
// now compute fXOffset if needed
|
||||||
|
|
||||||
SkScalar xOffset = 0;
|
SkScalar xOffset = 0;
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
|
if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
|
||||||
int count;
|
int count;
|
||||||
SkScalar width = fPaint.measure_text(fCache.get(), text, length, &count, nullptr) * fScale;
|
SkScalar width = fPaint.measure_text(fCache.get(), text, length, &count, nullptr) * fScale;
|
||||||
@ -819,6 +820,7 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
|
|||||||
}
|
}
|
||||||
xOffset = -width;
|
xOffset = -width;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
fXPos = xOffset;
|
fXPos = xOffset;
|
||||||
fPrevAdvance = 0;
|
fPrevAdvance = 0;
|
||||||
|
|
||||||
|
@ -27,7 +27,11 @@ SkRunFont::SkRunFont(const SkPaint& paint)
|
|||||||
, fScaleX(paint.getTextScaleX())
|
, fScaleX(paint.getTextScaleX())
|
||||||
, fTypeface(SkPaintPriv::RefTypefaceOrDefault(paint))
|
, fTypeface(SkPaintPriv::RefTypefaceOrDefault(paint))
|
||||||
, fSkewX(paint.getTextSkewX())
|
, fSkewX(paint.getTextSkewX())
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
, fAlign(paint.getTextAlign())
|
, fAlign(paint.getTextAlign())
|
||||||
|
#else
|
||||||
|
, fAlign(SkPaint::kLeft_Align)
|
||||||
|
#endif
|
||||||
, fHinting(paint.getHinting())
|
, fHinting(paint.getHinting())
|
||||||
, fFlags(paint.getFlags() & kFlagsMask) { }
|
, fFlags(paint.getFlags() & kFlagsMask) { }
|
||||||
|
|
||||||
@ -37,7 +41,9 @@ void SkRunFont::applyToPaint(SkPaint* paint) const {
|
|||||||
paint->setTextSize(fSize);
|
paint->setTextSize(fSize);
|
||||||
paint->setTextScaleX(fScaleX);
|
paint->setTextScaleX(fScaleX);
|
||||||
paint->setTextSkewX(fSkewX);
|
paint->setTextSkewX(fSkewX);
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
paint->setTextAlign(static_cast<SkPaint::Align>(fAlign));
|
paint->setTextAlign(static_cast<SkPaint::Align>(fAlign));
|
||||||
|
#endif
|
||||||
paint->setHinting(static_cast<SkPaint::Hinting>(fHinting));
|
paint->setHinting(static_cast<SkPaint::Hinting>(fHinting));
|
||||||
|
|
||||||
paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags);
|
paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags);
|
||||||
|
@ -54,7 +54,10 @@ public:
|
|||||||
SkTextInterceptsIter(const char text[], size_t length, const SkPaint& paint,
|
SkTextInterceptsIter(const char text[], size_t length, const SkPaint& paint,
|
||||||
const SkScalar bounds[2], SkScalar x, SkScalar y, TextType textType)
|
const SkScalar bounds[2], SkScalar x, SkScalar y, TextType textType)
|
||||||
: SkTextBaseIter(text, length, paint, false)
|
: SkTextBaseIter(text, length, paint, false)
|
||||||
, fTextType(textType) {
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
|
, fTextType(textType)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
fBoundsBase[0] = bounds[0];
|
fBoundsBase[0] = bounds[0];
|
||||||
fBoundsBase[1] = bounds[1];
|
fBoundsBase[1] = bounds[1];
|
||||||
this->setPosition(x, y);
|
this->setPosition(x, y);
|
||||||
@ -67,6 +70,7 @@ public:
|
|||||||
|
|
||||||
void setPosition(SkScalar x, SkScalar y) {
|
void setPosition(SkScalar x, SkScalar y) {
|
||||||
SkScalar xOffset = 0;
|
SkScalar xOffset = 0;
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
if (TextType::kPosText == fTextType
|
if (TextType::kPosText == fTextType
|
||||||
&& fPaint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
|
&& fPaint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
|
||||||
const char* text = fText;
|
const char* text = fText;
|
||||||
@ -77,6 +81,7 @@ public:
|
|||||||
}
|
}
|
||||||
xOffset = width;
|
xOffset = width;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < (int) SK_ARRAY_COUNT(fBounds); ++i) {
|
for (int i = 0; i < (int) SK_ARRAY_COUNT(fBounds); ++i) {
|
||||||
SkScalar bound = fBoundsBase[i] - y;
|
SkScalar bound = fBoundsBase[i] - y;
|
||||||
@ -90,7 +95,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
SkScalar fBounds[2];
|
SkScalar fBounds[2];
|
||||||
SkScalar fBoundsBase[2];
|
SkScalar fBoundsBase[2];
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
TextType fTextType;
|
TextType fTextType;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1089,7 +1089,9 @@ void GrAAConvexTessellator::draw(SkCanvas* canvas) const {
|
|||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setTextSize(kPointTextSize);
|
paint.setTextSize(kPointTextSize);
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
paint.setTextAlign(SkPaint::kCenter_Align);
|
paint.setTextAlign(SkPaint::kCenter_Align);
|
||||||
|
#endif
|
||||||
if (this->depth(i) <= -kAntialiasingRadius) {
|
if (this->depth(i) <= -kAntialiasingRadius) {
|
||||||
paint.setColor(SK_ColorWHITE);
|
paint.setColor(SK_ColorWHITE);
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1034,6 @@ static bool contains(const SkRect& r, SkPoint p) {
|
|||||||
void SkPDFDevice::drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset) {
|
void SkPDFDevice::drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset) {
|
||||||
SkPaint paint{glyphRun.paint()};
|
SkPaint paint{glyphRun.paint()};
|
||||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||||
paint.setTextAlign(SkPaint::kLeft_Align);
|
|
||||||
SkPath path;
|
SkPath path;
|
||||||
SkASSERT(paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding);
|
SkASSERT(paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding);
|
||||||
|
|
||||||
@ -1053,7 +1052,9 @@ void SkPDFDevice::drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset)
|
|||||||
transparent.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
transparent.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||||
transparent.setColor(SK_ColorTRANSPARENT);
|
transparent.setColor(SK_ColorTRANSPARENT);
|
||||||
transparent.setTextSize(paint.getTextSize());
|
transparent.setTextSize(paint.getTextSize());
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
transparent.setTextAlign(paint.getTextAlign());
|
transparent.setTextAlign(paint.getTextAlign());
|
||||||
|
#endif
|
||||||
transparent.setTextScaleX(paint.getTextScaleX());
|
transparent.setTextScaleX(paint.getTextScaleX());
|
||||||
transparent.setTextSkewX(paint.getTextSkewX());
|
transparent.setTextSkewX(paint.getTextSkewX());
|
||||||
*tmp.mutablePaint() = std::move(transparent);
|
*tmp.mutablePaint() = std::move(transparent);
|
||||||
@ -1092,7 +1093,6 @@ void SkPDFDevice::internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offse
|
|||||||
uint32_t glyphCount = SkToU32(glyphRun.glyphsIDs().size());
|
uint32_t glyphCount = SkToU32(glyphRun.glyphsIDs().size());
|
||||||
SkPaint srcPaint{glyphRun.paint()};
|
SkPaint srcPaint{glyphRun.paint()};
|
||||||
srcPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
srcPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||||
srcPaint.setTextAlign(SkPaint::kLeft_Align);
|
|
||||||
|
|
||||||
if (!glyphCount || !glyphs || srcPaint.getTextSize() <= 0 || this->hasEmptyClip()) {
|
if (!glyphCount || !glyphs || srcPaint.getTextSize() <= 0 || this->hasEmptyClip()) {
|
||||||
return;
|
return;
|
||||||
@ -1138,7 +1138,6 @@ void SkPDFDevice::internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offse
|
|||||||
SkScalar textScaleY = textSize / emSize;
|
SkScalar textScaleY = textSize / emSize;
|
||||||
SkScalar textScaleX = advanceScale + paint.getTextSkewX() * textScaleY;
|
SkScalar textScaleX = advanceScale + paint.getTextSkewX() * textScaleY;
|
||||||
|
|
||||||
SkASSERT(paint.getTextAlign() == SkPaint::kLeft_Align);
|
|
||||||
SkRect clipStackBounds = this->cs().bounds(this->bounds());
|
SkRect clipStackBounds = this->cs().bounds(this->bounds());
|
||||||
{
|
{
|
||||||
ScopedContentEntry content(this, paint, true);
|
ScopedContentEntry content(this, paint, true);
|
||||||
|
@ -71,6 +71,7 @@ static const char* svg_join(SkPaint::Join join) {
|
|||||||
return join_map[join];
|
return join_map[join];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
// Keep in sync with SkPaint::Align
|
// Keep in sync with SkPaint::Align
|
||||||
static const char* text_align_map[] = {
|
static const char* text_align_map[] = {
|
||||||
nullptr, // kLeft_Align (default)
|
nullptr, // kLeft_Align (default)
|
||||||
@ -79,10 +80,12 @@ static const char* text_align_map[] = {
|
|||||||
};
|
};
|
||||||
static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
|
static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
|
||||||
"missing_text_align_map_entry");
|
"missing_text_align_map_entry");
|
||||||
|
|
||||||
static const char* svg_text_align(SkPaint::Align align) {
|
static const char* svg_text_align(SkPaint::Align align) {
|
||||||
SkASSERT(align < SK_ARRAY_COUNT(text_align_map));
|
SkASSERT(align < SK_ARRAY_COUNT(text_align_map));
|
||||||
return text_align_map[align];
|
return text_align_map[align];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static SkString svg_transform(const SkMatrix& t) {
|
static SkString svg_transform(const SkMatrix& t) {
|
||||||
SkASSERT(!t.isIdentity());
|
SkASSERT(!t.isIdentity());
|
||||||
@ -604,9 +607,11 @@ void SkSVGDevice::AutoElement::addPathAttributes(const SkPath& path) {
|
|||||||
void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
|
void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
|
||||||
this->addAttribute("font-size", paint.getTextSize());
|
this->addAttribute("font-size", paint.getTextSize());
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
|
if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
|
||||||
this->addAttribute("text-anchor", textAlign);
|
this->addAttribute("text-anchor", textAlign);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SkString familyName;
|
SkString familyName;
|
||||||
SkTHashSet<SkString> familySet;
|
SkTHashSet<SkString> familySet;
|
||||||
|
@ -846,41 +846,6 @@ static int lpaint_getFontID(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char* fLabel;
|
|
||||||
SkPaint::Align fAlign;
|
|
||||||
} gAlignRec[] = {
|
|
||||||
{ "left", SkPaint::kLeft_Align },
|
|
||||||
{ "center", SkPaint::kCenter_Align },
|
|
||||||
{ "right", SkPaint::kRight_Align },
|
|
||||||
};
|
|
||||||
|
|
||||||
static int lpaint_getTextAlign(lua_State* L) {
|
|
||||||
SkPaint::Align align = get_obj<SkPaint>(L, 1)->getTextAlign();
|
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gAlignRec); ++i) {
|
|
||||||
if (gAlignRec[i].fAlign == align) {
|
|
||||||
lua_pushstring(L, gAlignRec[i].fLabel);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lpaint_setTextAlign(lua_State* L) {
|
|
||||||
if (lua_isstring(L, 2)) {
|
|
||||||
size_t len;
|
|
||||||
const char* label = lua_tolstring(L, 2, &len);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gAlignRec); ++i) {
|
|
||||||
if (!strcmp(gAlignRec[i].fLabel, label)) {
|
|
||||||
get_obj<SkPaint>(L, 1)->setTextAlign(gAlignRec[i].fAlign);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lpaint_getStroke(lua_State* L) {
|
static int lpaint_getStroke(lua_State* L) {
|
||||||
lua_pushboolean(L, SkPaint::kStroke_Style == get_obj<SkPaint>(L, 1)->getStyle());
|
lua_pushboolean(L, SkPaint::kStroke_Style == get_obj<SkPaint>(L, 1)->getStyle());
|
||||||
return 1;
|
return 1;
|
||||||
@ -1081,8 +1046,6 @@ static const struct luaL_Reg gSkPaint_Methods[] = {
|
|||||||
{ "setTypeface", lpaint_setTypeface },
|
{ "setTypeface", lpaint_setTypeface },
|
||||||
{ "getHinting", lpaint_getHinting },
|
{ "getHinting", lpaint_getHinting },
|
||||||
{ "getFontID", lpaint_getFontID },
|
{ "getFontID", lpaint_getFontID },
|
||||||
{ "getTextAlign", lpaint_getTextAlign },
|
|
||||||
{ "setTextAlign", lpaint_setTextAlign },
|
|
||||||
{ "getStroke", lpaint_getStroke },
|
{ "getStroke", lpaint_getStroke },
|
||||||
{ "setStroke", lpaint_setStroke },
|
{ "setStroke", lpaint_setStroke },
|
||||||
{ "getStrokeCap", lpaint_getStrokeCap },
|
{ "getStrokeCap", lpaint_getStrokeCap },
|
||||||
|
@ -214,11 +214,6 @@ DEF_TEST(Paint_flattening, reporter) {
|
|||||||
SkPaint::kNormal_Hinting,
|
SkPaint::kNormal_Hinting,
|
||||||
SkPaint::kFull_Hinting,
|
SkPaint::kFull_Hinting,
|
||||||
};
|
};
|
||||||
const SkPaint::Align align[] = {
|
|
||||||
SkPaint::kLeft_Align,
|
|
||||||
SkPaint::kCenter_Align,
|
|
||||||
SkPaint::kRight_Align
|
|
||||||
};
|
|
||||||
const SkPaint::Cap caps[] = {
|
const SkPaint::Cap caps[] = {
|
||||||
SkPaint::kButt_Cap,
|
SkPaint::kButt_Cap,
|
||||||
SkPaint::kRound_Cap,
|
SkPaint::kRound_Cap,
|
||||||
@ -250,7 +245,6 @@ DEF_TEST(Paint_flattening, reporter) {
|
|||||||
|
|
||||||
FOR_SETUP(i, levels, setFilterQuality)
|
FOR_SETUP(i, levels, setFilterQuality)
|
||||||
FOR_SETUP(j, hinting, setHinting)
|
FOR_SETUP(j, hinting, setHinting)
|
||||||
FOR_SETUP(k, align, setTextAlign)
|
|
||||||
FOR_SETUP(l, caps, setStrokeCap)
|
FOR_SETUP(l, caps, setStrokeCap)
|
||||||
FOR_SETUP(m, joins, setStrokeJoin)
|
FOR_SETUP(m, joins, setStrokeJoin)
|
||||||
FOR_SETUP(n, encodings, setTextEncoding)
|
FOR_SETUP(n, encodings, setTextEncoding)
|
||||||
@ -267,7 +261,7 @@ DEF_TEST(Paint_flattening, reporter) {
|
|||||||
SkPaintPriv::Unflatten(&paint2, reader);
|
SkPaintPriv::Unflatten(&paint2, reader);
|
||||||
REPORTER_ASSERT(reporter, paint2 == paint);
|
REPORTER_ASSERT(reporter, paint2 == paint);
|
||||||
|
|
||||||
}}}}}}}
|
}}}}}}
|
||||||
#undef FOR_SETUP
|
#undef FOR_SETUP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,9 @@ public:
|
|||||||
font.setTextScaleX(4.2f);
|
font.setTextScaleX(4.2f);
|
||||||
font.setTypeface(SkTypeface::MakeDefault());
|
font.setTypeface(SkTypeface::MakeDefault());
|
||||||
font.setTextSkewX(0.42f);
|
font.setTextSkewX(0.42f);
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
font.setTextAlign(SkPaint::kCenter_Align);
|
font.setTextAlign(SkPaint::kCenter_Align);
|
||||||
|
#endif
|
||||||
font.setHinting(SkPaint::kFull_Hinting);
|
font.setHinting(SkPaint::kFull_Hinting);
|
||||||
font.setAntiAlias(true);
|
font.setAntiAlias(true);
|
||||||
font.setFakeBoldText(true);
|
font.setFakeBoldText(true);
|
||||||
@ -202,7 +204,9 @@ public:
|
|||||||
REPORTER_ASSERT(reporter, defaultPaint.getTextScaleX() != font.getTextScaleX());
|
REPORTER_ASSERT(reporter, defaultPaint.getTextScaleX() != font.getTextScaleX());
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.getTypeface() != font.getTypeface());
|
REPORTER_ASSERT(reporter, defaultPaint.getTypeface() != font.getTypeface());
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.getTextSkewX() != font.getTextSkewX());
|
REPORTER_ASSERT(reporter, defaultPaint.getTextSkewX() != font.getTextSkewX());
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.getTextAlign() != font.getTextAlign());
|
REPORTER_ASSERT(reporter, defaultPaint.getTextAlign() != font.getTextAlign());
|
||||||
|
#endif
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.getHinting() != font.getHinting());
|
REPORTER_ASSERT(reporter, defaultPaint.getHinting() != font.getHinting());
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.isAntiAlias() != font.isAntiAlias());
|
REPORTER_ASSERT(reporter, defaultPaint.isAntiAlias() != font.isAntiAlias());
|
||||||
REPORTER_ASSERT(reporter, defaultPaint.isFakeBoldText() != font.isFakeBoldText());
|
REPORTER_ASSERT(reporter, defaultPaint.isFakeBoldText() != font.isFakeBoldText());
|
||||||
@ -229,7 +233,9 @@ public:
|
|||||||
REPORTER_ASSERT(reporter, paint.getTextScaleX() == font.getTextScaleX());
|
REPORTER_ASSERT(reporter, paint.getTextScaleX() == font.getTextScaleX());
|
||||||
REPORTER_ASSERT(reporter, paint.getTypeface() == font.getTypeface());
|
REPORTER_ASSERT(reporter, paint.getTypeface() == font.getTypeface());
|
||||||
REPORTER_ASSERT(reporter, paint.getTextSkewX() == font.getTextSkewX());
|
REPORTER_ASSERT(reporter, paint.getTextSkewX() == font.getTextSkewX());
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
REPORTER_ASSERT(reporter, paint.getTextAlign() == font.getTextAlign());
|
REPORTER_ASSERT(reporter, paint.getTextAlign() == font.getTextAlign());
|
||||||
|
#endif
|
||||||
REPORTER_ASSERT(reporter, paint.getHinting() == font.getHinting());
|
REPORTER_ASSERT(reporter, paint.getHinting() == font.getHinting());
|
||||||
REPORTER_ASSERT(reporter, paint.isAntiAlias() == font.isAntiAlias());
|
REPORTER_ASSERT(reporter, paint.isAntiAlias() == font.isAntiAlias());
|
||||||
REPORTER_ASSERT(reporter, paint.isFakeBoldText() == font.isFakeBoldText());
|
REPORTER_ASSERT(reporter, paint.isFakeBoldText() == font.isFakeBoldText());
|
||||||
|
@ -968,6 +968,7 @@ static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) {
|
static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) {
|
||||||
SkPaint::Align textAlign = paint.getTextAlign();
|
SkPaint::Align textAlign = paint.getTextAlign();
|
||||||
if (textAlign != SkPaint::kLeft_Align) {
|
if (textAlign != SkPaint::kLeft_Align) {
|
||||||
@ -984,6 +985,7 @@ static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
|
static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
|
||||||
UrlDataManager& urlDataManager) {
|
UrlDataManager& urlDataManager) {
|
||||||
@ -1069,7 +1071,9 @@ Json::Value SkDrawCommand::MakeJsonPaint(const SkPaint& paint, UrlDataManager& u
|
|||||||
apply_paint_cap(paint, &result);
|
apply_paint_cap(paint, &result);
|
||||||
apply_paint_join(paint, &result);
|
apply_paint_join(paint, &result);
|
||||||
apply_paint_filterquality(paint, &result);
|
apply_paint_filterquality(paint, &result);
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_SETTEXTALIGN
|
||||||
apply_paint_textalign(paint, &result);
|
apply_paint_textalign(paint, &result);
|
||||||
|
#endif
|
||||||
apply_paint_patheffect(paint, &result, urlDataManager);
|
apply_paint_patheffect(paint, &result, urlDataManager);
|
||||||
apply_paint_maskfilter(paint, &result, urlDataManager);
|
apply_paint_maskfilter(paint, &result, urlDataManager);
|
||||||
apply_paint_shader(paint, &result, urlDataManager);
|
apply_paint_shader(paint, &result, urlDataManager);
|
||||||
|
@ -198,7 +198,6 @@ static void output_font(sk_sp<SkTypeface> face, const char* identifier, FILE* ou
|
|||||||
int emSize = face->getUnitsPerEm() * 2;
|
int emSize = face->getUnitsPerEm() * 2;
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setTextAlign(SkPaint::kLeft_Align);
|
|
||||||
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
|
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
|
||||||
paint.setTextSize(emSize);
|
paint.setTextSize(emSize);
|
||||||
paint.setTypeface(std::move(face));
|
paint.setTypeface(std::move(face));
|
||||||
|
Loading…
Reference in New Issue
Block a user