private fun generateOps708( screenData: Array<CharArray>?, screenCellData: Array<LongArray>, clipRect: java.awt.geom.Rectangle2D.Float, alphaFactor: Float, xoff: Float, yoff: Float, rowHeight: Float, currY: Float, charWidth: Float, currX: Float
 ) { var currY = curry if (reality.isIntegerPixels()) currY = Math.floor(currY.toDouble()).toFloat() val sb = StringBuffer()
 printCCBuffer("708 CCData to render", screenData, sb, screenCellData, StringBuffer()) sb.setLength(0) var row = 0 while (row < sage.media.sub.CCSubtitleHandler.CC_ROWS && screenData != null) { var lastCellFormat = screenCellData[row][0] if (CellFormat.getBackgroundOpacity(lastCellFormat) === DTVCCOpacity.TRANSPARENT && screenData[row][0] == 0) { lastCellFormat = CellFormat.setForeground( lastCellFormat, CellFormat.getForeground(lastCellFormat) as Byte, DTVCCOpacity.TRANSPARENT ) } rowOffsets.get(row) = -1 val rowStartY = rowHeight * row var textOffset = charWidth val maxCols: Int = screenCellData[row].length – 1 var lastRenderedCol = -1 for (col in 0 until maxCols) { if (lastCellFormat != screenCellData[row][col]) { val windowID: Int = CellFormat.getWindowID(lastCellFormat) if (CellFormat.getForegroundOpacity(lastCellFormat) !== DTVCCOpacity.TRANSPARENT || CellFormat.getBackgroundOpacity( lastCellFormat ) !== DTVCCOpacity.TRANSPARENT ) { textOffset += render708ops( screenData, screenCellData, clipRect, alphaFactor, xoff, yoff, rowHeight, currY,
 charWidth, currX, sb, lastCellFormat, rowStartY, textOffset, lastRenderedCol, row, col ) lastRenderedCol = col – 1 } else { addTo708WindowRect( windowID, xoff + currX + textOffset, yoff + rowStartY, sb.length * charWidth, rowHeight ) textOffset += sb.length * charWidth } sb.setLength(0) } lastCellFormat = screenCellData[row][col] if (CellFormat.getBackgroundOpacity(lastCellFormat) === DTVCCOpacity.TRANSPARENT && screenData[row][col] == 0) { lastCellFormat = CellFormat.setForeground( lastCellFormat, CellFormat.getForeground(lastCellFormat) as Byte, DTVCCOpacity.TRANSPARENT ) } if (CellFormat.getBackgroundOpacity(lastCellFormat) === DTVCCOpacity.TRANSPARENT && (CellFormat.getForegroundOpacity( lastCellFormat ) === DTVCCOpacity.TRANSPARENT || screenData[row][col] == 0) ) { textOffset += charWidth } else if (screenData[row][col] != 0) { if (rowOffsets.get(row) === -1) { rowOffsets.get(row) = col } sb.append(screenData[row][col]) } else { sb.append(' ') } } if (sb.length > 0) { if (CellFormat.getForegroundOpacity(lastCellFormat) !== DTVCCOpacity.TRANSPARENT || CellFormat.getBackgroundOpacity( lastCellFormat ) !== DTVCCOpacity.TRANSPARENT ) { render708ops( screenData, screenCellData, clipRect, alphaFactor, xoff, yoff, rowHeight, currY, charWidth, currX, sb, lastCellFormat, rowStartY, textOffset, lastRenderedCol, row, maxCols ) } } sb.setLength(0) row++ } for (ops in cached708WindowOps) { cachedRenderOps.addAll(ops)} }
Render the 708 caption text to the screen . BIG NOTE ( codefu ) : This wont draw perfectly square boxes with text on it . e.g . : back-filled with black , 2 rows , 32 columns . Text on second row `` testing '' will produce and image that is stepped . If we want to draw squares , we need to track the widest character from any font/size that is used .