ReadMark (FREE)

1. Core Purpose of the Component

ReadMark is a non-visible component for App Inventor and compatible builders (such as Kodular) that turns a standard container (like VerticalArrangement) into a rich-text reader. It supports advanced formatting, searching, rule-based text styling, and text-to-speech (TTS) playback with real-time word highlighting.

1. Properties (Get / Set)

Properties let you retrieve (get) current configuration values or modify (set) them.

  • Text
    • Purpose: Sets or gets the main text content for display and reading.
    • Value: Text string (String).
  • TextColor
    • Purpose: The default text color.
    • Value: Color integer (int, e.g., 0xFF1F2937).
  • PageColor
    • Purpose: Background color of the reading container.
    • Value: Color integer (int).
  • SearchColor
    • Purpose: Highlight color for search matches.
    • Value: Color integer (int).
  • ActiveMatchColor
    • Purpose: Highlight color for the currently selected search match.
    • Value: Color integer (int).
  • TextSize
    • Purpose: Font size of the text.
    • Value: float value in sp (minimum 6).
  • LineSpacing
    • Purpose: Line spacing multiplier.
    • Value: float value (e.g., 1.35, minimum 0.8).
  • PagePadding
    • Purpose: Inner padding around the text content.
    • Value: Integer in dp (e.g., 20).
  • Justify
    • Purpose: Enables or disables full text justification.
    • Value: Boolean (True / False).
  • Font
    • Purpose: System font family name.
    • Value: String (Default, Sans, SansLight, SansMedium, SansCondensed, SansBlack, Serif, SerifMono, Monospace, Casual, Cursive).
  • HighlightRadius
    • Purpose: Corner rounding radius for highlights (search, rules, text-to-speech). 0 for sharp corners, high values (e.g., 50) create pill-shaped highlights.
    • Value: float in dp.
  • HighlightPadding
    • Purpose: Extra horizontal spacing on the left and right of highlights.
    • Value: float in dp (e.g., 2 or 4).
  • MatchCount (Read-only)
    • Purpose: Returns the total number of search matches found.
    • Value: Integer (int).
  • CurrentMatch (Read-only)
    • Purpose: Index of the currently selected match (1-based), or 0 if none.
    • Value: Integer (int).
  • MatchLabel (Read-only)
    • Purpose: Formatted status string like β€œ3 of 12” or β€œNot found” for UI display.
    • Value: String (String).
  • HighlightRuleCount (Read-only)
    • Purpose: Total number of active user-defined styling rules.
    • Value: Integer (int).
  • ReadColor
    • Purpose: Highlight color for the word currently being read aloud.
    • Value: Color integer (int).
  • AutoScrollWhileReading
    • Purpose: Automatically scrolls text to follow the speech engine cursor.
    • Value: Boolean (True / False).
  • SpeechLanguage
    • Purpose: Language code for text-to-speech (e.g., "ru", "en-US"). Blank for default device language.
    • Value: String (String).
  • SpeechRate
    • Purpose: Speed of speech synthesis.
    • Value: Float from 0.1 to 4 (1 is normal speed).
  • SpeechPitch
    • Purpose: Voice pitch/tone.
    • Value: Float from 0.5 to 2 (1 is normal pitch).
  • IsSpeaking (Read-only)
    • Purpose: Checks if text-to-speech is currently active.
    • Value: Boolean (True / False).
  • IsPaused (Read-only)
    • Purpose: Checks if speech synthesis is paused.
    • Value: Boolean (True / False).

2. Methods (Functions / Commands)

Actions that can be invoked within blocks logic.

  • SetContainer(layout) β€” Binds the reader to a visual layout component (e.g., VerticalArrangement). Parameters: container component.
  • SetTheme(name) β€” Applies a built-in visual theme. Parameters: string name ("light", "paper", "sepia", "dark", "night", "forest", "ocean").
  • AvailableFonts() β€” Returns a comma-separated list of built-in font names.
  • SetFontFromAsset(fileName) β€” Loads a custom font from project assets. Parameters: file name string (e.g., "Lora.ttf").
  • HighlightWord(word, textColor, backColor, bold, italic, underline, strike) β€” Styles all occurrences of a word. Parameters: word (String), text color (int), background color (int), style flags (boolean).
  • HighlightPhrase(phrase, textColor, backColor, bold, italic, underline, strike) β€” Styles any arbitrary phrase or text fragment.
  • HighlightTextEx(textPart, caseSensitive, textColor, backColor, bold, italic, underline, strike, sizePercent, font) β€” Advanced text styling rule supporting case sensitivity, size percentage (100 = unchanged), and font name.
  • HighlightLine(lineNumber, textColor, backColor, bold, italic, underline, strike) β€” Styles a specific line by its line number (1-based).
  • HighlightRange(start, length, textColor, backColor, bold, italic, underline, strike) β€” Styles a character range by start index and length. Parameters: start (1-based), length.
  • RemoveHighlight(textPart) β€” Removes custom styling rules for a specific word or phrase.
  • ClearHighlights() β€” Clears all custom style rules.
  • Search(queryText, caseSensitive, wholeWord) β€” Performs a search, highlights matches, jumps to the first match, and returns match count (int).
  • NextMatch() β€” Jumps to the next search match.
  • PreviousMatch() β€” Jumps to the previous search match.
  • GoToMatch(index) β€” Jumps to a specific search match by index (1-based).
  • ClearSearch() β€” Clears search results and highlights.
  • Speak(language) β€” Starts reading text aloud. Parameters: language code ("ru", "en", or "" for auto).
  • SpeakFrom(language, start) β€” Reads text starting from character index start (1-based).
  • StopSpeaking() β€” Stops speech playback completely.
  • PauseSpeaking() β€” Pauses speech playback while preserving the current word highlight.
  • ResumeSpeaking() β€” Resumes speech playback from the paused position.
  • IsLanguageAvailable(language) β€” Checks if a speech language is supported. Returns boolean.
  • AvailableSpeechLanguages() β€” Returns a comma-separated list of device TTS languages (e.g., ru-RU,en-US).

3. Events

Triggered automatically when specific component actions occur.

  • FontError(fileName) β€” Triggered if a custom font fails to load from assets. Arguments: file name (String).
  • SearchFinished(queryText, count) β€” Search complete. Arguments: query (String), total count (int).
  • NotFound(queryText) β€” Search returned no matches. Arguments: query (String).
  • MatchChanged(index, total, matched) β€” Current search match changed. Arguments: current index (int), total (int), matched text fragment (String).
  • SpeechEngineReady() β€” TTS engine is fully initialized and ready.
  • SpeakStarted() β€” Speech playback has started.
  • WordSpoken(word, start, length) β€” Triggered in real-time as each word is spoken. Arguments: word (String), 1-based start index (int), length (int).
  • SpeakFinished() β€” Speech playback reached the end of the text.
  • SpeakError(message) β€” Speech error occurred (missing data, engine failure, etc.). Arguments: error message (String).





com.readmark.aix (40.0 KB)
The extension was created with the help of: :rocket: FAST

1 Like