本文整理汇总了C++中SkPaint::getTextEncoding方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getTextEncoding方法的具体用法?C++ SkPaint::getTextEncoding怎么用?C++ SkPaint::getTextEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getTextEncoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawText
void SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {
SkString str;
toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(),
byteLength, SkScalarToFloat(x), SkScalarToFloat(y));
}
示例2: onDrawTextOnPath
void SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
const SkMatrix* matrix, const SkPaint& paint) {
SkString str;
toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])",
str.c_str(), byteLength);
}
示例3: onDrawTextRSXform
void SkOverdrawCanvas::onDrawTextRSXform(const void* text, size_t byteLength,
const SkRSXform xform[], const SkRect*,
const SkPaint& paint) {
CountTextProc proc = nullptr;
switch (paint.getTextEncoding()) {
case SkPaint::kUTF8_TextEncoding:
proc = SkUTF8_CountUTF8Bytes;
break;
case SkPaint::kUTF16_TextEncoding:
proc = count_utf16;
break;
case SkPaint::kUTF32_TextEncoding:
proc = return_4;
break;
case SkPaint::kGlyphID_TextEncoding:
proc = return_2;
break;
}
SkASSERT(proc);
SkMatrix matrix;
const void* stopText = (const char*)text + byteLength;
while ((const char*)text < (const char*)stopText) {
matrix.setRSXform(*xform++);
matrix.setConcat(this->getTotalMatrix(), matrix);
int subLen = proc((const char*)text);
this->save();
this->concat(matrix);
this->drawText(text, subLen, 0, 0, paint);
this->restore();
text = (const char*)text + subLen;
}
}
示例4: onDrawTextRSXform
void SkDumpCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
const SkRect* cull, const SkPaint& paint) {
SkString str;
toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawTextRSXform(%s [%d])",
str.c_str(), byteLength);
}
示例5: drawTextRSXform
void SkBaseDevice::drawTextRSXform(const SkDraw& draw, const void* text, size_t len,
const SkRSXform xform[], const SkPaint& paint) {
CountTextProc proc = nullptr;
switch (paint.getTextEncoding()) {
case SkPaint::kUTF8_TextEncoding:
proc = SkUTF8_CountUTF8Bytes;
break;
case SkPaint::kUTF16_TextEncoding:
proc = count_utf16;
break;
case SkPaint::kUTF32_TextEncoding:
proc = return_4;
break;
case SkPaint::kGlyphID_TextEncoding:
proc = return_2;
break;
}
SkDraw localD(draw);
SkMatrix localM, currM;
const void* stopText = (const char*)text + len;
while ((const char*)text < (const char*)stopText) {
localM.setRSXform(*xform++);
currM.setConcat(*draw.fMatrix, localM);
localD.fMatrix = &currM;
int subLen = proc((const char*)text);
this->drawText(localD, text, subLen, 0, 0, paint);
text = (const char*)text + subLen;
}
}
示例6: onDrawPosTextH
void SkDumpCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint) {
SkString str;
toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)",
str.c_str(), byteLength, SkScalarToFloat(xpos[0]),
SkScalarToFloat(constY));
}
示例7: onDrawText
void SkOverdrawCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {
ProcessOneGlyphBounds processBounds(this);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
this->getProps(&props);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
paint, &props, SkScalerContextFlags::kNone, &this->getTotalMatrix());
SkFindAndPlaceGlyph::ProcessText(paint.getTextEncoding(), (const char*) text, byteLength,
SkPoint::Make(x, y), SkMatrix(), paint.getTextAlign(),
cache.get(), processBounds);
}
示例8: getGlyphPositions
static void getGlyphPositions(const SkPaint& paint, const uint16_t glyphs[],
int count, SkScalar x, SkScalar y, SkPoint pos[]) {
SkASSERT(SkPaint::kGlyphID_TextEncoding == paint.getTextEncoding());
SkAutoSTMalloc<128, SkScalar> widthStorage(count);
SkScalar* widths = widthStorage.get();
paint.getTextWidths(glyphs, count * sizeof(uint16_t), widths);
for (int i = 0; i < count; ++i) {
pos[i].set(x, y);
x += widths[i];
}
}
示例9: INHERITED
SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint)
: INHERITED(DRAW_TEXT) {
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
fX = x;
fY = y;
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
fInfo.push(SkObjectParser::PaintToString(paint));
}
示例10: drawPosText
void SkPDFDevice::drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) {
SkASSERT(1 == scalarsPerPos || 2 == scalarsPerPos);
SkPaint textPaint = calculateTextPaint(paint);
updateGSFromPaint(textPaint, true);
// Make sure we have a glyph id encoding.
SkAutoFree glyphStorage;
uint16_t* glyphIDs;
size_t numGlyphs;
if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
numGlyphs = paint.textToGlyphs(text, len, NULL);
glyphIDs = (uint16_t*)sk_malloc_flags(numGlyphs * 2,
SK_MALLOC_TEMP | SK_MALLOC_THROW);
glyphStorage.set(glyphIDs);
paint.textToGlyphs(text, len, glyphIDs);
textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
} else {
SkASSERT((len & 1) == 0);
numGlyphs = len / 2;
glyphIDs = (uint16_t*)text;
}
SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
fContent.writeText("BT\n");
updateFont(textPaint, glyphIDs[0]);
for (size_t i = 0; i < numGlyphs; i++) {
SkPDFFont* font = fGraphicStack[fGraphicStackIndex].fFont;
uint16_t encodedValue = glyphIDs[i];
if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) {
updateFont(textPaint, glyphIDs[i]);
i--;
continue;
}
SkScalar x = pos[i * scalarsPerPos];
SkScalar y = scalarsPerPos == 1 ? constY : pos[i * scalarsPerPos + 1];
alignText(glyphCacheProc, textPaint, glyphIDs + i, 1, &x, &y, NULL);
setTextTransform(x, y, textPaint.getTextSkewX());
SkString encodedString =
SkPDFString::formatString(&encodedValue, 1,
font->multiByteGlyphs());
fContent.writeText(encodedString.c_str());
fContent.writeText(" Tj\n");
}
fContent.writeText("ET\n");
}
示例11: breakText
static int breakText(JNIEnv* env, const SkPaint& paint, const jchar text[],
int count, float maxWidth, jfloatArray jmeasured,
SkPaint::TextBufferDirection tbd) {
SkASSERT(paint.getTextEncoding() == SkPaint::kUTF16_TextEncoding);
SkScalar measured;
size_t bytes = paint.breakText(text, count << 1,
SkFloatToScalar(maxWidth), &measured, tbd);
SkASSERT((bytes & 1) == 0);
if (jmeasured && env->GetArrayLength(jmeasured) > 0) {
AutoJavaFloatArray autoMeasured(env, jmeasured, 1);
jfloat* array = autoMeasured.ptr();
array[0] = SkScalarToFloat(measured);
}
return bytes >> 1;
}
示例12: drawTextRSXform
void SkBaseDevice::drawTextRSXform(const void* text, size_t len,
const SkRSXform xform[], const SkPaint& paint) {
CountTextProc proc = nullptr;
switch (paint.getTextEncoding()) {
case SkPaint::kUTF8_TextEncoding:
proc = SkUTF8_CountUTF8Bytes;
break;
case SkPaint::kUTF16_TextEncoding:
proc = count_utf16;
break;
case SkPaint::kUTF32_TextEncoding:
proc = return_4;
break;
case SkPaint::kGlyphID_TextEncoding:
proc = return_2;
break;
}
SkPaint localPaint(paint);
SkShader* shader = paint.getShader();
SkMatrix localM, currM;
const void* stopText = (const char*)text + len;
while ((const char*)text < (const char*)stopText) {
localM.setRSXform(*xform++);
currM.setConcat(this->ctm(), localM);
SkAutoDeviceCTMRestore adc(this, currM);
// We want to rotate each glyph by the rsxform, but we don't want to rotate "space"
// (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick
// with a localmatrixshader so that the shader draws as if there was no change to the ctm.
if (shader) {
SkMatrix inverse;
if (localM.invert(&inverse)) {
localPaint.setShader(shader->makeWithLocalMatrix(inverse));
} else {
localPaint.setShader(nullptr); // can't handle this xform
}
}
int subLen = proc((const char*)text);
this->drawText(text, subLen, 0, 0, localPaint);
text = (const char*)text + subLen;
}
}
示例13: stringForText
String LoggingCanvas::stringForText(const void* text, size_t byteLength, const SkPaint& paint)
{
SkPaint::TextEncoding encoding = paint.getTextEncoding();
switch (encoding) {
case SkPaint::kUTF8_TextEncoding:
case SkPaint::kUTF16_TextEncoding:
case SkPaint::kUTF32_TextEncoding:
return stringForUTFText(text, byteLength, encoding);
case SkPaint::kGlyphID_TextEncoding: {
WTF::Vector<SkUnichar> dataVector(byteLength / 2);
SkUnichar* textData = dataVector.data();
paint.glyphsToUnichars(static_cast<const uint16_t*>(text), byteLength / 2, textData);
return WTF::UTF32LittleEndianEncoding().decode(reinterpret_cast<const char*>(textData), byteLength * 2);
}
default:
ASSERT_NOT_REACHED();
return "?";
}
}
示例14: drawText
void FindCanvas::drawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, const SkPaint& paint) {
SkPaint::TextEncoding encoding = paint.getTextEncoding();
//For complex text, transform utf16 to glyph
if (encoding == SkPaint::kUTF16_TextEncoding) {
int mCount = 0;
uint16_t *glyphBuf = NULL;
glyphBuf = new uint16_t[byteLength];
mCount = paint.textToGlyphs(text, byteLength, glyphBuf, byteLength);
SkPaint clonePaint(paint);
clonePaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
findHelper(glyphBuf, 2*mCount, clonePaint, &x, y, &FindCanvas::addMatchNormal);
delete glyphBuf;
return;
}
findHelper(text, byteLength, paint, &x, y, &FindCanvas::addMatchNormal);
}
示例15: DrawBmpPosText
void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
GrBatchFontCache* fontCache,
const SkSurfaceProps& props, const SkPaint& skPaint,
GrColor color,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != nullptr);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
// nothing to draw
if (text == nullptr || byteLength == 0) {
return;
}
// Ensure the blob is set for bitmaptext
blob->setHasBitmap();
GrBatchTextStrike* currStrike = nullptr;
// Get GrFontScaler from cache
SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma::On,
skPaint, &viewMatrix);
GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
SkFindAndPlaceGlyph::ProcessPosText(
skPaint.getTextEncoding(), text, byteLength,
offset, viewMatrix, pos, scalarsPerPosition,
skPaint.getTextAlign(), cache,
[&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
position += rounding;
BmpAppendGlyph(
blob, runIndex, fontCache, &currStrike, glyph,
SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY),
color, fontScaler);
}
);
SkGlyphCache::AttachCache(cache);
}