TAV: subtitle font handling

This commit is contained in:
minjaesong
2025-10-07 18:14:07 +09:00
parent da084c0074
commit e36d4041ce
2 changed files with 10 additions and 6 deletions

View File

@@ -76,6 +76,8 @@ let gui = require("playgui")
let seqread = undefined let seqread = undefined
let fullFilePathStr = fullFilePath.full let fullFilePathStr = fullFilePath.full
let fontUploaded = false
// Select seqread driver to use // Select seqread driver to use
if (fullFilePathStr.startsWith('$:/TAPE') || fullFilePathStr.startsWith('$:\\TAPE')) { if (fullFilePathStr.startsWith('$:/TAPE') || fullFilePathStr.startsWith('$:\\TAPE')) {
seqread = require("seqreadtape") seqread = require("seqreadtape")
@@ -133,7 +135,7 @@ function processSubtitlePacket(packetSize) {
sys.free(textBytes) sys.free(textBytes)
subtitleText = textStr subtitleText = textStr
subtitleVisible = true subtitleVisible = true
gui.displaySubtitle(subtitleText, subtitlePosition) gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition)
} }
break break
} }
@@ -156,7 +158,7 @@ function processSubtitlePacket(packetSize) {
// Re-display current subtitle at new position if visible // Re-display current subtitle at new position if visible
if (subtitleVisible && subtitleText.length > 0) { if (subtitleVisible && subtitleText.length > 0) {
gui.clearSubtitleArea() gui.clearSubtitleArea()
gui.displaySubtitle(subtitleText, subtitlePosition) gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition)
} }
} }
} }
@@ -180,6 +182,8 @@ function processSubtitlePacket(packetSize) {
sys.free(fontData) sys.free(fontData)
} }
fontUploaded = true
} }
break break
} }

View File

@@ -27,7 +27,7 @@ function getVisualLength(line) {
return unicode.visualStrlen(withoutTags) return unicode.visualStrlen(withoutTags)
} }
function displayFormattedLine(line) { function displayFormattedLine(line, useUnicode) {
// Parse line and handle <b> and <i> tags with colour changes // Parse line and handle <b> and <i> tags with colour changes
// Default subtitle colour: yellow (231), formatted text: white (254) // Default subtitle colour: yellow (231), formatted text: white (254)
@@ -38,7 +38,7 @@ function displayFormattedLine(line) {
// Helper function to flush the buffer // Helper function to flush the buffer
function flushBuffer() { function flushBuffer() {
if (buffer.length > 0) { if (buffer.length > 0) {
unicode.print(buffer) useUnicode ? unicode.print(buffer) : print(buffer)
buffer = "" buffer = ""
} }
} }
@@ -85,7 +85,7 @@ function displayFormattedLine(line) {
con.color_pair(231, 0) con.color_pair(231, 0)
} }
function displaySubtitle(text, position = 0) { function displaySubtitle(text, useUnicode = false, position = 0) {
if (!text || text.length === 0) { if (!text || text.length === 0) {
clearSubtitleArea() clearSubtitleArea()
return return
@@ -156,7 +156,7 @@ function displaySubtitle(text, position = 0) {
con.move(row, startCol) con.move(row, startCol)
// Parse and display line with formatting tag support // Parse and display line with formatting tag support
displayFormattedLine(line) displayFormattedLine(line, useUnicode)
} }
con.color_pair(oldFgColour, oldBgColour) con.color_pair(oldFgColour, oldBgColour)