Subtitle display method, electronic device and computer-readable storage medium
By generating an index table to quickly obtain the target font required for subtitle display, the problem of slow subtitle display speed in existing technologies is solved, and faster subtitle display is achieved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- SHENZHEN TCL DIGITAL TECH CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-07-30
AI Technical Summary
In existing technologies, in order to find the font required for subtitle display, it is necessary to open the font library files one by one for matching, which results in a slow subtitle display speed.
By generating an index table, the storage path of the target character of the target font can be quickly obtained, and the target character can be directly obtained to speed up the display of subtitles.
It shortens the time to obtain the target font and improves the speed and efficiency of subtitle display.
Smart Images

Figure CN2025148277_30072026_PF_FP_ABST
Abstract
Description
Subtitle display methods, electronic devices and computer-readable storage media
[0001] This application claims priority to Chinese patent application filed on January 23, 2025, with application number 2025101137739 and entitled "Method, Apparatus, Electronic Device and Computer-Readable Storage Medium for Displaying Subtitles", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of computer technology, specifically to a subtitle display method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0003] The player can display text subtitles, but the characters in different text subtitles may have different fonts. You need to find the characters in the corresponding fonts in order for the text subtitles to be displayed correctly. Technical issues
[0004] The font library contains multiple font files, each containing characters for a different font. To find the corresponding characters for the font and display the text subtitles correctly, the relevant technology needs to open each font file in the font library sequentially to match the characters for the corresponding font. This process is time-consuming and affects the overall display speed of the text subtitles. Technical solutions
[0005] This application provides a subtitle display method, apparatus, electronic device, and computer-readable storage medium, which can quickly obtain the target characters of the target font based on an index table, thereby speeding up the display speed of subtitles.
[0006] In a first aspect, embodiments of this application provide a subtitle display method, including:
[0007] Determine the target font for the target characters corresponding to the subtitle to be displayed;
[0008] The target font corresponding to the target character is queried in the index table, wherein the index table includes: multiple characters, multiple fonts corresponding to the multiple characters, and the storage path of the multiple characters for each font;
[0009] When the target font corresponding to the target character is found in the index table, the target storage path of the target character in the target font is obtained;
[0010] According to the target storage path, obtain the target character of the target font;
[0011] The subtitle is displayed based on the target character of the target font.
[0012] In one embodiment, before querying the target font corresponding to the target character in the index table, the method further includes:
[0013] Obtain the font set;
[0014] Iterate through each font file in the font set to obtain each character of each font;
[0015] Based on each character of each font, determine the font corresponding to each character;
[0016] Based on the storage paths of each character in each of the font files, determine the storage paths of each character in each font; based on each character, the corresponding font, and the storage paths of each character in each font, generate the index table.
[0017] In one embodiment, after querying the index table for the target font corresponding to the target character, the method further includes:
[0018] If the target font corresponding to the target character cannot be found in the index table, obtain the font library set;
[0019] The target character of the target font is queried in each font file of the font set;
[0020] When the target character of the target font is found in each font file of the font set, the target character of the target font is obtained;
[0021] The subtitle is displayed based on the target character of the target font.
[0022] In one embodiment, after querying the target character of the target font in each font file of the font set, the method further includes:
[0023] When the target character of the target font is found in each font file of the font set, the index table is deleted;
[0024] Generate a new index table.
[0025] In one embodiment, after querying the target character of the target font in each font file of the font set, the method further includes:
[0026] When the target character of the target font cannot be found in any of the font files in the font set, the target character of the target font is determined as a reference character;
[0027] The subtitle is displayed based on the reference characters.
[0028] In one embodiment, querying the target font corresponding to the target character in the index table includes:
[0029] The target character is retrieved from the index table;
[0030] When the target character is found in the index table, check whether each font corresponding to the target character contains the target font.
[0031] In one embodiment, determining the target font of the target character of the subtitle to be displayed includes:
[0032] When the playback process starts, the target character of the subtitle to be displayed is obtained;
[0033] Determine the target font required to display the target character.
[0034] Secondly, embodiments of this application provide a subtitle display device, including:
[0035] The font determination module is used to determine the target font for the target characters corresponding to the subtitles to be displayed;
[0036] A font query module is used to query the target font corresponding to the target character in an index table, wherein the index table includes: multiple characters, multiple fonts corresponding to the multiple characters, and storage paths of the multiple characters in each font; a path acquisition module is used to acquire the target storage path of the target character of the target font when the target font corresponding to the target character is found in the index table.
[0037] The character acquisition module is used to acquire the target characters of the target font according to the target storage path;
[0038] The subtitle display module is used to display the subtitles according to the target characters of the target font.
[0039] In one embodiment, the device further includes:
[0040] The font set acquisition module is used to acquire font sets;
[0041] The traversal module is used to traverse each font file in the font set to obtain each character of each font;
[0042] The corresponding font determination module is used to determine the font corresponding to each character based on each character of each font;
[0043] The path determination module is used to determine the storage path of each character in each font based on the storage path of each character in each font file.
[0044] The index table generation module is used to generate the index table based on each of the characters, the corresponding fonts of each character, and the storage paths of each character of each font.
[0045] In one embodiment, the device further includes:
[0046] The acquisition module is used to acquire a font set when the target font corresponding to the target character cannot be found in the index table;
[0047] A query module is used to query the target character of the target font in each font file of the font set;
[0048] The target character acquisition module is used to acquire the target character of the target font when the target character of the target font is found in each font file of the font set;
[0049] The display module is used to display the subtitles according to the target characters of the target font.
[0050] In one embodiment, the device further includes:
[0051] The deletion module is used to delete the index table when the target character of the target font is found in each font file of the font set;
[0052] The generation module is used to generate new index tables.
[0053] In one embodiment, the device further includes:
[0054] The reference character determination module is used to determine the target character of the target font as a reference character when the target character of the target font cannot be found in any of the font files in the font set.
[0055] A reference display module is used to display the subtitles based on the reference characters.
[0056] In one embodiment, the font query module includes:
[0057] A character query unit is used to query the target character in the index table;
[0058] The font query unit is used to query whether each font corresponding to the target character contains the target font when the target character is found in the index table.
[0059] In one embodiment, the font determination module includes:
[0060] The target character acquisition unit is used to acquire the target character of the subtitle to be displayed when the playback process starts; the target font determination unit is used to determine the target font required to display the target character.
[0061] Thirdly, embodiments of this application also provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps in the above-described subtitle display method.
[0062] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the above-described subtitle display method.
[0063] Fifthly, embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described in embodiments of this application. Beneficial effects
[0064] In this embodiment, the index table contains multiple characters, multiple fonts corresponding to these characters, and the storage paths of the characters for each font. Therefore, querying the index table allows for the quick retrieval of the target storage path of the target character for the target font. Consequently, it eliminates the need to sequentially open each font file to search for the target character; instead, the target character can be directly retrieved based on the target storage path, enabling rapid subtitle display. This significantly reduces the time required to obtain the target character, accelerates subtitle display speed, and improves subtitle display efficiency. Attached Figure Description
[0065] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0066] Figure 1 is a schematic diagram of the steps of a subtitle display method provided in an embodiment of this application;
[0067] Figure 2 is a schematic diagram of the steps of a subtitle display method provided in an embodiment of this application;
[0068] Figure 3 is a flowchart illustrating a subtitle display method provided in an embodiment of this application;
[0069] Figure 4 is a schematic diagram of the structure of a subtitle display device provided in an embodiment of this application;
[0070] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Embodiments of the present invention
[0071] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0072] In one embodiment, as shown in FIG1, a caption display method is provided. Although the logical order is shown in the step diagram, in some cases, the steps shown or described may be performed in a different order than that shown in the figures. Specifically, this caption display method can be applied to a terminal, wherein the terminal may include, but is not limited to, one or more of smartphones, tablets, laptops, desktop computers, and in-vehicle computers.
[0073] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the priority of the embodiments.
[0074] According to the subtitle display method shown in Figure 1, the method includes at least steps S110 to S160, which are described in detail below: In step S110, the target font of the target character corresponding to the subtitle to be displayed is determined.
[0075] The subtitle to be displayed can be any subtitle containing characters. Characters can be characters with multiple font options, characters from various languages, or other symbols. Font refers to the style and form of the characters; it is the external representation of the characters. The target character can be any character, and the target font can be any font. The fonts of the individual characters in the subtitle to be displayed can be the same or different.
[0076] Optionally, determining the target font of the target character of the subtitle to be displayed may include: acquiring the target character of the subtitle to be displayed when the playback process starts; and determining the target font required to display the target character.
[0077] It can retrieve the target characters from the subtitle file when the playback process corresponding to the subtitle starts, and determine the target font required to display the target characters.
[0078] In one embodiment, the target characters can be words such as "T" and "good", or various punctuation marks; each target character can have multiple fonts, such as regular script, Times New Roman, or boldface, etc. The shapes of the same character displayed in different fonts are different. When displaying the target characters of the subtitle, it is necessary to determine which font to display the target characters in specifically. Therefore, it is necessary to determine the target font required to display the target characters.
[0079] Adopting the technical solution of the embodiment of the present application can quickly display subtitles. Therefore, determining the target font of the target characters when the playback process starts, compared with determining the target font of the target characters in advance before the playback process starts, can avoid waste of resources caused by not playing subtitles subsequently without affecting subtitle display.
[0080] In step S120, query the target font corresponding to the target character in the index table.
[0081] Among them, the index table includes: multiple characters, multiple fonts corresponding to the multiple characters, and the storage paths of the multiple characters of each font.
[0082] The fast display of subtitles can be achieved by using the font configuration software tool (Fontconfig). The font set supported by the fonts file of the font configuration software tool is specified; the storage paths of each character of each font are specified in the cache file of the font configuration software tool.
[0083] The index table can be pre-generated and stored in the cache file. As shown in Table 1, the index table at least includes: multiple characters, multiple fonts corresponding to each character, and the storage paths of each character of each font. The font corresponding to a character refers to the font that the character has. Optionally, the index table can also include the font library files where the characters of each font are located, etc.
[0084] Table 1. Index Table
[0085] It can be seen from Table 1 that the character T has multiple fonts such as Courier, Tiresias, and Open Sans. Among them, the character T of the Courier font is stored in the font library file "cour.ttf", and the storage path of the character T of the Courier font is " / data / tcluniplayer / fontconfig / font / cour.ttf".
[0086] Optionally, the characters in the index table can be sorted in order, and the fonts corresponding to each character can also be sorted in order to speed up the query speed of the index table.
[0087] When the player process starts, it checks the availability of the font configuration software tool. If the software tool is available and the index table exists in the cache file, the pre-generated index table can be retrieved directly from the cache file. If the index table does not exist, it is rebuilt based on the set of font files in the fonts file.
[0088] The target font corresponding to the target character refers to the target font that the target character belongs to. As shown in Table 1, Courier, Tiresias, and Open Sans are the fonts corresponding to the character T.
[0089] Optionally, the step of querying the target font corresponding to the target character in the index table may include: querying the target character in the index table; and when the target character is found in the index table, querying whether each font corresponding to the target character contains the target font.
[0090] The system checks if the target character exists in the index table. If the target character does not exist in the index table, then the target font corresponding to the target character also does not exist.
[0091] If the target character exists in the index table, then you can query whether the target font corresponding to the target character exists among the multiple fonts corresponding to the target character.
[0092] Because the characters in the index table are sorted in order, and the fonts corresponding to each character are also sorted in order, when querying whether the target character exists in the index table, and whether the target font exists in the fonts corresponding to the target character, the search can be performed in order.
[0093] In this way, by querying the index table to see if the target font corresponding to the target character exists, it is possible to quickly determine whether the font file corresponding to the index table contains the target font corresponding to the target character.
[0094] In step S130, when the target font corresponding to the target character is found in the index table, the target storage path of the target character of the target font is obtained.
[0095] When the target font corresponding to the target character is found in the index table, the target storage path of the target character of the target font can be directly obtained from the index table.
[0096] In step S140, the target characters of the target font are obtained according to the target storage path.
[0097] The target characters of the target font can be obtained directly by following the target storage path.
[0098] In step S150, the subtitle is displayed according to the target character of the target font.
[0099] After obtaining the target characters for the target font, the target characters can be displayed. Similarly, after obtaining the target characters for each target font in the subtitle, the subtitle can be displayed.
[0100] The technical solution adopted in this application embodiment contains multiple characters, multiple fonts corresponding to the multiple characters, and the storage paths of the multiple characters in each font. Therefore, querying the index table can quickly obtain the target storage path of the target character of the target font; thus, it is not necessary to open each font file sequentially to find the target character of the target font, but can directly obtain the target character of the target font according to the target storage path, and quickly complete the display of subtitles. In this way, the time to obtain the target character of the target font can be greatly shortened, the display speed of subtitles can be accelerated, and the display efficiency of subtitles can be improved.
[0101] Based on the above technical solution, as an embodiment, as shown in Figure 2, before querying the target font corresponding to the target character in the index table, the method may further include steps S210 to S250.
[0102] In step S210, the character set is obtained.
[0103] In step S220, each font file in the font set is traversed to obtain each character of each font.
[0104] A font set consists of multiple font files, each containing characters from various fonts. By iterating through the font files in the font set, you can obtain the individual characters from each font.
[0105] In step S230, based on the individual characters of each font, the font corresponding to each character is determined. By organizing the individual characters of each font according to their order, the font corresponding to each character can be determined.
[0106] For example, if there are characters T in the Courier font, T in the Tiresias font, T in the Open Sans font, L in the Courier font, and L in the Tiresias font, then it can be determined that character T has the following three fonts: Courier, Tiresias, and Open Sans; and character L has the following two fonts: Courier and Tiresias.
[0107] In step S240, the storage path of each character in each font is determined according to the storage path of each character in each font file.
[0108] Each character in each font is obtained from a different font file. Therefore, the storage path of each character in each font can be determined based on the storage path of the font file containing each character.
[0109] In step S250, the index table is generated based on each character, the corresponding font, and the storage path of each character in each font.
[0110] The index table is generated based on each character, the corresponding font, and the storage path of each character in each font. This can be achieved by storing the characters, their corresponding fonts, and the storage paths of each character in each font in a corresponding manner, generating the index table as shown in Table 1.
[0111] Optionally, the characters in the index table can be sorted in order, and the fonts corresponding to each character can also be sorted in order to speed up the query of the index table.
[0112] The technical solution adopted in this application involves traversing each font file in the font library set to obtain each character of each font, and then redirecting each character of each font to generate an index table. Subsequently, the storage path of each character of each font can be directly determined from the index table, enabling fast lookup of each character of each font and thus accelerating the display speed of subtitles. Furthermore, the characters and fonts in the index table are sorted sequentially, which further speeds up the index table lookup.
[0113] Based on the above technical solution, as an embodiment, Figure 3 is a flowchart illustrating a subtitle display method provided in an embodiment of this application. As shown in Figure 3, after querying the target font corresponding to the target character in the index table, the method may further include: when the target font corresponding to the target character is not found in the index table, obtaining a font library set; querying the target character of the target font in each font file of the font library set; when the target character of the target font is found in each font file of the font library set, obtaining the target character of the target font; and displaying the subtitle according to the target character of the target font.
[0114] If the target font corresponding to the target character cannot be found in the index table, it is necessary to query each font file in the font set to see if it contains the target character of the target font. The font set is obtained, and each font file in the font set is traversed until the target character of the target font is found.
[0115] When the target character of the target font is found in the font file of the font set, the subtitle is displayed based on the target character of the target font in that font file.
[0116] Using the technical solution of this application embodiment, when the storage path of the target character of the target font does not exist in the index table, the target character of the target font can be found by traversing each font file in the font library set, so as to avoid affecting the display of subtitles. Based on the above technical solution, as an embodiment, as shown in Figure 3, after searching for the target character of the target font in each font file in the font library set, the method may further include: when the target character of the target font is found in each font file in the font library set, deleting the index table; and generating a new index table. If the target font corresponding to the target character cannot be found in the index table, but the target character of the target font is found in each font file in the font library set, it proves that the target character of the newly added target font exists in the font library set. Therefore, it is necessary to update the index table or generate a new index table.
[0117] In one embodiment, a thread can be created to delete the existing index table and generate a new index table. The method for generating the new index table can be referred to steps S210 to S250, and will not be described in detail here.
[0118] In another embodiment, the character set can be traversed to obtain the characters of the newly added fonts, and the original index table can be incrementally updated based on the characters of the newly added fonts.
[0119] By adopting the technical solution of this application embodiment, when there are newly added characters of a font in the font library set, the index table is updated or a new index table is generated so that when obtaining other characters of other fonts in the future, the storage path of the required font characters can be quickly obtained according to the new index table.
[0120] Based on the above technical solution, as an embodiment, as shown in Figure 3, after querying the target character of the target font in each font file of the font set, the method may further include: when the target character of the target font cannot be found in each font file of the font set, determining the target character of the target font as a reference character; and displaying the subtitle according to the reference character.
[0121] If the target font corresponding to the target character cannot be found in the index table, and the target character of the target font cannot be found in any of the font files in the font set, it proves that the target character of the target font does not exist in any of the current font files.
[0122] To prevent a single target character from affecting the display of the entire subtitle, the target character of the target font can be designated as a reference character. The reference character can be "□".
[0123] When displaying target characters in subtitles, reference characters can be used as a substitute. When users see the reference characters, they can determine that there are characters that are not displayed correctly at the location of the reference characters.
[0124] By using the technical solution of this application embodiment, a reference character is used to replace the target character for display. This can inform the user that there is a character that is not displayed correctly at the location of the reference character, so that the user can obtain the meaning of the target character by referring to the context, thereby reducing the impact on the viewing experience.
[0125] Optionally, as an embodiment, if the target font corresponding to the target character cannot be found in the index table, and the target character of the target font cannot be found in any of the font files in the font set, the target character of other fonts can be obtained. When displaying the target character of the subtitle, the target character of other fonts is displayed. Although the display effect of displaying the target character of other fonts is not as good as that of the target character of the target font, it still allows the user to obtain the semantics of the target character, thereby reducing the impact on the user's viewing experience.
[0126] Figure 3 is a flowchart illustrating a subtitle display method according to an embodiment of this application. As shown in Figure 3, in step S310, subtitle rendering begins. In step S320, the index table is checked to see if a target character of the target font exists. If the target character of the target font exists in the index table, the process jumps to step S330; if the target character of the target font does not exist in the index table, the process jumps to step S340.
[0127] In step S330, the storage path is obtained, and the target characters of the target font are retrieved based on the storage path. The storage path is the storage path of the target characters of the target font stored in the index table. Based on the storage path, the font file storing the target characters of the target font can be directly determined, and then the target characters of the target font can be directly retrieved from that font file. The subtitles are then displayed based on the retrieved target characters of the target font.
[0128] In step S340, the font set is traversed to check if the target character of the target font exists. If the target character of the target font exists in the font set, steps S350 and S360 are executed; if the target character of the target font does not exist in the font set, step S370 is executed.
[0129] In step S350, the target character of the target font is obtained from the font set. In step S360, a new index table is generated. If the target character of the target font exists in the font set, it is obtained from the font set to display the subtitles. If the target character of the target font exists in the font set but cannot be found in the index table, it indicates that the font set has been updated; therefore, a new index table is generated based on the current font set.
[0130] In step S370, the target character of the target font is displayed as a reference character. To avoid a single target character affecting the display of the entire subtitle, the target character of the target font can be designated as a reference character.
[0131] By adopting the technical solution of this application embodiment, the time to obtain the target character of the target font can be greatly shortened, the display speed of subtitles can be accelerated, and the display efficiency of subtitles can be improved.
[0132] To facilitate better implementation of the subtitle display method of this application, this application also provides a subtitle display device based on the above-described subtitle display method. The meanings of the terms used are the same as in the above-described subtitle display method, and specific implementation details can be found in the description of the method embodiments.
[0133] Please refer to Figure 4, which is a schematic diagram of the structure of the subtitle display device provided in an embodiment of this application. The subtitle display device includes:
[0134] The font determination module 401 is used to determine the target font of the target character corresponding to the subtitle to be displayed;
[0135] The font query module 402 is used to query the target font corresponding to the target character in the index table, wherein the index table includes: multiple characters, multiple fonts corresponding to the multiple characters, and storage paths of the multiple characters of each font; the path acquisition module 403 is used to acquire the target storage path of the target character of the target font when the target font corresponding to the target character is found in the index table.
[0136] The character acquisition module 404 is used to acquire the target characters of the target font according to the target storage path;
[0137] The subtitle display module 405 is used to display the subtitles according to the target characters of the target font.
[0138] In one embodiment, the device further includes:
[0139] The font set acquisition module is used to acquire font sets;
[0140] The traversal module is used to traverse each font file in the font set to obtain each character of each font;
[0141] The corresponding font determination module is used to determine the font corresponding to each character based on each character of each font;
[0142] The path determination module is used to determine the storage path of each character in each font based on the storage path of each character in each font file.
[0143] The index table generation module is used to generate the index table based on each of the characters, the corresponding fonts of each character, and the storage paths of each character of each font.
[0144] In one embodiment, the device further includes:
[0145] The acquisition module is used to acquire a font set when the target font corresponding to the target character cannot be found in the index table;
[0146] A query module is used to query the target character of the target font in each font file of the font set;
[0147] The target character acquisition module is used to acquire the target character of the target font when the target character of the target font is found in each font file of the font set;
[0148] The display module is used to display the subtitles according to the target characters of the target font.
[0149] In one embodiment, the device further includes:
[0150] The deletion module is used to delete the index table when the target character of the target font is found in each font file of the font set;
[0151] The generation module is used to generate new index tables.
[0152] In one embodiment, the device further includes:
[0153] The reference character determination module is used to determine the target character of the target font as a reference character when the target character of the target font cannot be found in any of the font files in the font set.
[0154] A reference display module is used to display the subtitles based on the reference characters.
[0155] In one embodiment, the font query module 402 includes:
[0156] A character query unit is used to query the target character in the index table;
[0157] The font query unit is used to query whether each font corresponding to the target character contains the target font when the target character is found in the index table.
[0158] In one embodiment, the font determination module 401 includes:
[0159] The target character acquisition unit is used to acquire the target character of the subtitle to be displayed when the playback process starts;
[0160] The target font determination unit is used to determine the target font required to display the target character.
[0161] The technical solution adopted in this application embodiment contains multiple characters, multiple fonts corresponding to the multiple characters, and the storage paths of the multiple characters in each font. Therefore, querying the index table can quickly obtain the target storage path of the target character of the target font; thus, it is not necessary to open each font file sequentially to find the target character of the target font, but can directly obtain the target character of the target font according to the target storage path, and quickly complete the display of subtitles. In this way, the time to obtain the target character of the target font can be greatly shortened, the display speed of subtitles can be accelerated, and the display efficiency of subtitles can be improved.
[0162] For specific limitations regarding the subtitle display device, please refer to the limitations on the subtitle display method above, which will not be repeated here. Each module in the aforementioned subtitle display device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0163] In addition, this application also provides an electronic device, as shown in Figure 5, which illustrates the structural schematic diagram of the electronic device involved in this application. Specifically:
[0164] The electronic device may include components such as a processor 501 with one or more processing cores and a memory 502 of one or more computer-readable storage media. Those skilled in the art will understand that the electronic device structure shown in FIG5 does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0165] The processor 501 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 502, and by calling data stored in the memory 502, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 501 may include one or more processing cores; preferably, the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 501.
[0166] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 502 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.
[0167] In one embodiment, the electronic device further includes a power supply 503 that supplies power to the various components. Preferably, the power supply 503 can be logically connected to the processor 501 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 503 may also include one or more DC or AC power supplies, recharging systems, power equipment debugging circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0168] In one embodiment, the electronic device may further include an input unit 504, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0169] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 501 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 502 according to the following instructions, and the processor 501 runs the applications stored in the memory 502, thereby implementing the steps in any of the subtitle display methods provided in the embodiments of this application.
[0170] Those skilled in the art will understand that the structure shown in Figure 5 is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0171] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the methods described in any embodiment of this application.
[0172] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of this application.
[0173] In some embodiments, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the methods described in any embodiment of this application.
[0174] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0175] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0176] Therefore, this application provides a computer-readable storage medium storing a computer program that can be loaded by a processor to execute the steps of any of the subtitle display methods provided in this application. Specific implementations of the above operations can be found in the preceding embodiments and will not be repeated here.
[0177] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0178] Since the instructions stored in the computer-readable storage medium can execute the steps in any of the subtitle display methods provided in this application, the beneficial effects that any of the subtitle display methods provided in this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0179] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0180] The above provides a detailed description of a subtitle display method, apparatus, electronic device, and computer-readable storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A subtitle display method, wherein, include: Determine the target font for the target characters corresponding to the subtitle to be displayed; The target font corresponding to the target character is queried in the index table, wherein the index table includes: multiple characters, multiple fonts corresponding to the multiple characters, and the storage path of the multiple characters for each font; When the target font corresponding to the target character is found in the index table, the target storage path of the target character in the target font is obtained; According to the target storage path, obtain the target character of the target font; The subtitle is displayed based on the target character of the target font.
2. The method of claim 1, wherein, Before querying the target font corresponding to the target character in the index table, the method further includes: Obtain the font set; Iterate through each font file in the font set to obtain each character of each font; Based on each character of each font, determine the font corresponding to each character; Based on the storage paths of each character in each of the aforementioned font files, determine the storage paths of each character in each font. The index table is generated based on each of the characters, the corresponding fonts, and the storage paths of each character in each font.
3. The method of claim 2, wherein, The step of generating the index table based on each of the characters, the corresponding fonts, and the storage paths of each character in each font includes: The character, the corresponding font, and the storage path of each character in each font are stored accordingly to generate the index table.
4. The method according to claim 1, wherein, After querying the target font corresponding to the target character in the index table, the method further includes: If the target font corresponding to the target character cannot be found in the index table, obtain the font library set; The target character of the target font is queried in each font file of the font set; When the target character of the target font is found in each font file of the font set, the target character of the target font is obtained; The subtitle is displayed based on the target character of the target font.
5. The method according to claim 4, wherein, After querying the target character of the target font in each font file of the font set, the method further includes: deleting the index table when the target character of the target font is found in each font file of the font set; Generate a new index table.
6. The method according to claim 4, wherein, After querying the target character of the target font in each font file of the font set, the method further includes: when the target character of the target font cannot be found in each font file of the font set, determining the target character of the target font as a reference character; The subtitle is displayed based on the reference characters.
7. The method according to claim 4, wherein, After querying the target font corresponding to the target character in the index table, the method further includes: When the target font corresponding to the target character cannot be found in the index table, and the target character of the target font cannot be found in any font file in the font set, the target character of other fonts is obtained; When displaying the target character of the subtitle, display the target character in another font.
8. The method according to claim 1, wherein, The step of querying the target font corresponding to the target character in the index table includes: The target character is retrieved from the index table; When the target character is found in the index table, check whether each font corresponding to the target character contains the target font.
9. The method according to claim 1, wherein, The determination of the target font for the target characters of the subtitle to be displayed includes: When the playback process starts, the target character of the subtitle to be displayed is obtained; Determine the target font required to display the target character.
10. The method according to claim 1, wherein, The determination of the target font for the target characters of the subtitle to be displayed includes: When the playback process corresponding to the subtitle is started, the target character in the subtitle to be displayed is obtained from the subtitle file, and the target font required to display the target character is determined.
11. The method according to claim 1, wherein, The display of the subtitles includes: using font configuration software tools to display the subtitles.
12. The method according to claim 11, wherein, The font configuration software tool specifies the set of fonts it can support in its font file; The cache file of the font configuration software tool specifies the storage path for each character of each font.
13. The method according to claim 12, wherein, The index table is pre-generated and stored in the cache file.
14. The method according to claim 13, wherein, The method further includes: When the player process starts, the availability of font configuration software tools is checked; When the font configuration software tool is available and the index table exists in the cache file, the pre-generated index table is obtained directly from the cache file.
15. The method according to claim 1, wherein, The characters in the index table can be sorted in order, and the fonts corresponding to each character can also be sorted in order.
16. The method according to claim 1, wherein, The characters are scripts or other symbols in various languages.
17. The method according to claim 1, wherein, The font refers to the style and form of the character, which is the external representation of the character.
18. The method according to claim 1, wherein, The method further includes: Iterate through the font library and retrieve the characters of the newly added fonts; The index table is incrementally updated based on the characters of the newly added fonts.
19. An electronic device, wherein, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the subtitle display method as described in any one of claims 1 to 18.
20. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the subtitle display method as described in any one of claims 1 to 18.