MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuTextFormatBlock

Function PiuTextFormatBlock

modules/piu/All/piuText.c:806–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804}
805
806void PiuTextFormatBlock(PiuText* self, PiuTextFormatContext ctx, PiuTextKind kind, PiuTextOffset length, PiuTextOffset textOffset)
807{
808 if (ctx->lineWidth + ctx->spaceWidth + ctx->wordWidth > ctx->blockWidth) {
809 if (ctx->lineWidth > 0)
810 PiuTextFormatLine(self, ctx, piuTextWord, 0);
811 ctx->spaceCount = 0;
812 ctx->spaceSum = 0;
813 ctx->lineOffset = ctx->wordOffset;
814 ctx->lineWidth = ctx->wordWidth;
815 ctx->lineAscent = ctx->wordAscent;
816 ctx->lineHeight = ctx->wordHeight;
817 }
818 else {
819 if (ctx->lineWidth > 0) {
820 ctx->spaceCount++;
821 ctx->spaceSum += ctx->spaceWidth;
822 }
823 ctx->lineWidth += ctx->spaceWidth + ctx->wordWidth;
824 if (ctx->lineAscent < ctx->wordAscent)
825 ctx->lineAscent = ctx->wordAscent;
826 if (ctx->lineHeight < ctx->wordHeight)
827 ctx->lineHeight = ctx->wordHeight;
828 }
829 if ((kind == piuTextReturn) || (ctx->lineWidth > ctx->blockWidth)) { // @@ no cesure
830 ctx->spaceCount = 0;
831 ctx->spaceSum = 0;
832 PiuTextFormatLine(self, ctx, kind, length);
833 ctx->lineOffset = textOffset;
834 ctx->lineWidth = 0;
835 ctx->lineAscent = 0;
836 ctx->lineHeight = 0;
837 }
838 ctx->spaceWidth = 0;
839 ctx->wordOffset = textOffset;
840 ctx->wordWidth = 0;
841 ctx->wordAscent = 0;
842 ctx->wordHeight = 0;
843}
844
845void PiuTextFormatLine(PiuText* self, PiuTextFormatContext ctx, PiuTextKind kind, PiuTextOffset length)
846{

Callers 1

PiuTextFormatFunction · 0.85

Calls 1

PiuTextFormatLineFunction · 0.85

Tested by

no test coverage detected