From c47fab9603710b6ab003cfc8c4d9c9672be41df6 Mon Sep 17 00:00:00 2001
From: jhong <9123086@gmail.com>
Date: Wed, 1 Jan 2025 00:11:58 -0500
Subject: [PATCH] fallbackfont for content title display
---
components/ItemGrid/GridItem.xml | 4 +-
components/ItemGrid/ItemGrid.xml | 2 +-
components/JFOverhang.xml | 2 +-
components/home/HomeItem.xml | 4 +-
components/jflabel/jflabel.bs | 24 ++++++++++
components/jflabel/jflabel.xml | 6 +++
.../jfscrollinglabel/jfscrollinglabel.bs | 24 ++++++++++
.../jfscrollinglabel/jfscrollinglabel.xml | 6 +++
components/video/OSD.xml | 2 +-
components/video/VideoPlayerView.bs | 4 ++
source/Main.bs | 45 ++++++++++++-------
11 files changed, 99 insertions(+), 24 deletions(-)
create mode 100644 components/jflabel/jflabel.bs
create mode 100644 components/jflabel/jflabel.xml
create mode 100644 components/jfscrollinglabel/jfscrollinglabel.bs
create mode 100644 components/jfscrollinglabel/jfscrollinglabel.xml
diff --git a/components/ItemGrid/GridItem.xml b/components/ItemGrid/GridItem.xml
index 06575753a..096ab5e02 100644
--- a/components/ItemGrid/GridItem.xml
+++ b/components/ItemGrid/GridItem.xml
@@ -10,9 +10,9 @@
-
+
-
+
diff --git a/components/ItemGrid/ItemGrid.xml b/components/ItemGrid/ItemGrid.xml
index 74b8665c6..bf1bde4a7 100644
--- a/components/ItemGrid/ItemGrid.xml
+++ b/components/ItemGrid/ItemGrid.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/components/JFOverhang.xml b/components/JFOverhang.xml
index 26f1eacc2..29816050d 100644
--- a/components/JFOverhang.xml
+++ b/components/JFOverhang.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/components/home/HomeItem.xml b/components/home/HomeItem.xml
index 119671c69..4388b1724 100644
--- a/components/home/HomeItem.xml
+++ b/components/home/HomeItem.xml
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/components/jflabel/jflabel.bs b/components/jflabel/jflabel.bs
new file mode 100644
index 000000000..1ee9c2284
--- /dev/null
+++ b/components/jflabel/jflabel.bs
@@ -0,0 +1,24 @@
+sub init()
+ m.top.id = "jflabel"
+ m.top.observeField("text", "onText")
+ setFallbackfont()
+end sub
+
+sub onText()
+ setFallbackfont()
+end sub
+
+sub setFallbackfont()
+ if m.global.fallbackFont = invalid or m.top.font.id = "jffallbackfont" then return
+ fontSize = m.top.font.size
+
+ fallbackFontSize = m.top.fallbackFontSize
+ if getInterface(fallbackFontSize, "ifInteger") <> invalid and fallbackFontSize > 1 then fontSize = fallbackFontSize
+
+ m.top.font = m.global.fallbackFont.clone(true)
+ m.top.font.size = fontSize
+end sub
+
+sub onFallbackFontSize()
+ if m.top.font.size <> m.top.fallbackFontSize then m.top.font.size = m.top.fallbackFontSize
+end sub
diff --git a/components/jflabel/jflabel.xml b/components/jflabel/jflabel.xml
new file mode 100644
index 000000000..5c812696c
--- /dev/null
+++ b/components/jflabel/jflabel.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/jfscrollinglabel/jfscrollinglabel.bs b/components/jfscrollinglabel/jfscrollinglabel.bs
new file mode 100644
index 000000000..4dcf39f06
--- /dev/null
+++ b/components/jfscrollinglabel/jfscrollinglabel.bs
@@ -0,0 +1,24 @@
+sub init()
+ m.top.id = "jfscrollinglabel"
+ m.top.observeField("text", "onText")
+ setFallbackfont()
+end sub
+
+sub onText()
+ setFallbackfont()
+end sub
+
+sub setFallbackfont()
+ if m.global.fallbackFont = invalid or m.top.font.id = "jffallbackfont" then return
+ fontSize = m.top.font.size
+
+ fallbackFontSize = m.top.fallbackFontSize
+ if getInterface(fallbackFontSize, "ifInteger") <> invalid and fallbackFontSize > 1 then fontSize = fallbackFontSize
+
+ m.top.font = m.global.fallbackFont.clone(true)
+ m.top.font.size = fontSize
+end sub
+
+sub onFallbackFontSize()
+ if m.top.font.size <> m.top.fallbackFontSize then m.top.font.size = m.top.fallbackFontSize
+end sub
diff --git a/components/jfscrollinglabel/jfscrollinglabel.xml b/components/jfscrollinglabel/jfscrollinglabel.xml
new file mode 100644
index 000000000..ef48c2124
--- /dev/null
+++ b/components/jfscrollinglabel/jfscrollinglabel.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/video/OSD.xml b/components/video/OSD.xml
index e80eb64e6..79dd7fa99 100644
--- a/components/video/OSD.xml
+++ b/components/video/OSD.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs
index 6340cd9b0..3cb7b2af7 100644
--- a/components/video/VideoPlayerView.bs
+++ b/components/video/VideoPlayerView.bs
@@ -68,6 +68,9 @@ sub init()
m.top.retrievingBar.filledBarBlendColor = m.global.constants.colors.blue
m.top.bufferingBar.filledBarBlendColor = m.global.constants.colors.blue
m.top.trickPlayBar.filledBarBlendColor = m.global.constants.colors.blue
+
+ m.customTitle = createObject("roSgNode", "jflabel")
+ m.top.customTitle = m.customTitle
end sub
' handleChapterSkipAction: Handles user command to skip chapters in playing video
@@ -410,6 +413,7 @@ sub onVideoContentLoaded()
m.chapters = videoContent[0].chapters
m.top.showID = videoContent[0].showID
+ m.customTitle.text = m.top.content.title
m.osd.itemTitleText = m.top.content.title
' If video is an episode, attempt to add season and episode numbers to OSD
diff --git a/source/Main.bs b/source/Main.bs
index c70018199..04b8bd752 100644
--- a/source/Main.bs
+++ b/source/Main.bs
@@ -39,10 +39,12 @@ sub Main (args as dynamic) as void
m.global.addFields({ app_loaded: false, playstateTask: playstateTask, sceneManager: sceneManager, launchSource: "" })
m.global.addFields({ queueManager: CreateObject("roSGNode", "QueueManager") })
m.global.addFields({ audioPlayer: CreateObject("roSGNode", "AudioPlayer") })
+ m.global.addField("fallbackFont", "node", true)
app_start:
' First thing to do is validate the ability to use the API
if not LoginFlow() then return
+ loadFallbackFont() 'load custom font if enabled
' remove login scenes from the stack
sceneManager.callFunc("clearScenes")
@@ -55,23 +57,6 @@ sub Main (args as dynamic) as void
m.scene.observeField("exit", m.port)
- ' Downloads and stores a fallback font to tmp:/
- configEncoding = api.system.GetConfigurationByName("encoding")
-
- if isValid(configEncoding) and isValid(configEncoding.EnableFallbackFont)
- if configEncoding.EnableFallbackFont
- re = CreateObject("roRegex", "Name.:.(.*?).,.Size", "s")
- filename = APIRequest("FallbackFont/Fonts").GetToString()
- if isValid(filename)
- filename = re.match(filename)
- if isValid(filename) and filename.count() > 0
- filename = filename[1]
- APIRequest("FallbackFont/Fonts/" + filename).gettofile("tmp:/font")
- end if
- end if
- end if
- end if
-
' only show whats new popup and update lastRunVersion on prod
if not m.global.app.isDev
' has the current user ran this version before?
@@ -899,3 +884,29 @@ sub Main (args as dynamic) as void
end while
end sub
+
+sub loadFallbackFont()
+ configEncoding = api.system.GetConfigurationByName("encoding")
+ if not configEncoding.EnableFallbackFont then return
+
+ fontFiles = APIRequest("FallbackFont/Fonts").GetToString()
+ fontFilesList = parseJson(fontFiles)
+ isFirstFont = getInterface(fontFilesList, "ifArray") <> invalid and fontFilesList[0] <> invalid and fontFilesList[0].name <> invalid
+ if not isFirstFont then return
+
+ fontFilename = fontFilesList[0].name 'pickup the first font
+ if fontFilename = invalid then return
+
+ APIRequest("FallbackFont/Fonts/" + fontFilename).gettofile("tmp:/font")
+
+ fs = CreateObject("roFileSystem")
+ if fs.Exists("tmp:/font")
+ getFallbackFont = function() as object
+ font = CreateObject("roSGNode", "Font")
+ font.id = "jffallbackfont"
+ font.uri = "tmp:/font"
+ return font
+ end function
+ m.global.fallbackFont = getFallbackFont()
+ end if
+end sub