Character display method and display device, electronic equipment and storage medium
By generating intermediate font sequences, gradually transitioning from the initial font to the target font, the problem of visual jumping during font switching is solved, and the text display effect and visual continuity are improved.
Patent Information
- Application Number
- CN202411571682.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-25
AI Technical Summary
When the user switches fonts, instant changes lead to a sense of visual jumping, breaking the coherence of reading, causing visual fatigue to the user, and leading to poor text display effect.
By generating a font sequence containing one or more intermediate fonts, gradually transition from the initial font to the target font, using conditions to generate an adversarial network model and spherical linear interpolation algorithm, and generating personalized intermediate fonts based on user feature information.
Improves the visual continuity and font quality when switching fonts, improves the display effect of text when switching fonts, and reduces visual fatigue.
Smart Images

Figure CN119514491A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to a text display method and display device, an electronic device and a storage medium. Background Art
[0002] In the related art, when users read digital publications or other texts through electronic devices such as mobile phones, whether the text font conforms to the user's habits will directly affect the user's reading experience. Therefore, when the font does not conform to the user's habits, the user will tend to actively change the font.
[0003] When a user tries to switch from one font to another, the instantaneous change of fonts will cause a visual jump. This abrupt change not only breaks the continuity of reading, but also causes visual fatigue to the user, resulting in poor text display when switching fonts. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a text display method and display device, an electronic device and a storage medium, which can improve the display effect of text when switching fonts.
[0005] In a first aspect, an embodiment of the present application provides a text display method, the text display method comprising:
[0006] Receive font switching input;
[0007] In response to the font switching input, obtaining font switching data; wherein the font switching data includes an initial font and a target font;
[0008] Generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font;
[0009] After the initial font is displayed, each intermediate font in the intermediate font sequence is displayed in turn, and then the target font is switched to be displayed.
[0010] In a second aspect, an embodiment of the present application provides a method for training a font generation model, the training method comprising:
[0011] Obtain a conditional generative adversarial network model, which includes a generator network and a discriminator network;
[0012] Generate a training data set, the training data set includes a font sample set, user feature information and noise information;
[0013] Through the training data set, the generator network and the discriminator network are adversarially trained to obtain a font generation model; wherein the font generation model is used to generate intermediate fonts or personalized fonts according to font switching data, and the font switching data includes at least one of the following: initial font, target font, and user feature information.
[0014] In a third aspect, an embodiment of the present application provides a text display device, the text display device comprising:
[0015] A receiving module, used for receiving a font switching input;
[0016] A first acquisition module, configured to acquire font switching data in response to a font switching input; wherein the font switching data includes an initial font and a target font;
[0017] A first generating module, configured to generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font;
[0018] The font switching module is used to switch the display of the target font after the initial font is displayed and each intermediate font in the intermediate font sequence is displayed in sequence.
[0019] In a fourth aspect, an embodiment of the present application provides a training device for a font generation model, wherein the training device comprises:
[0020] A second acquisition module is used to acquire a conditional generative adversarial network model, where the conditional generative adversarial network model includes a generator network and a discriminator network;
[0021] A second generating module is used to generate a training data set, wherein the training data set includes a font sample set, user feature information and noise information;
[0022] The training module is used to perform adversarial training on the generator network and the discriminator network through the training data set to obtain a font generation model; wherein the font generation model is used to generate an intermediate font or a personalized font according to the font switching data, and the font switching data includes at least one of the following: an initial font, a target font, and user feature information.
[0023] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the methods of the first and second aspects are implemented.
[0024] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method of the first aspect and the second aspect are implemented.
[0025] In the seventh aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the methods of the first and second aspects.
[0026] In an eighth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the methods of the first and second aspects.
[0027] In an embodiment of the present application, when a user switches fonts, a font sequence including one or more intermediate fonts is generated based on the initial font of the currently displayed text and the target font to which the user wishes to switch. The style of the first font in the font sequence is close to the initial font, and the style of the last font is close to the target font. The switching process from the initial font to the target font is transitioned and smoothed through the font sequence, thereby improving the visual continuity and font quality when switching fonts, and ultimately improving the display effect of the text when switching fonts. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A flowchart showing a text display method in some embodiments of the present application is shown;
[0029] Figure 2 A schematic diagram of font switching in some embodiments of the present application is shown;
[0030] Figure 3 A schematic diagram showing a font selection interface of some embodiments of the present application;
[0031] Figure 4 A schematic diagram showing a font selection interface of some embodiments of the present application;
[0032] Figure 5 A flowchart showing a method for training a font generation model in some embodiments of the present application is shown;
[0033] Figure 6 A structural block diagram of a text display device according to some embodiments of the present application is shown;
[0034] Figure 7 A structural block diagram of a training device for a font generation model in some embodiments of the present application is shown;
[0035] Figure 8 A structural block diagram of an electronic device according to an embodiment of the present application is shown;
[0036] Fig. 9 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0038] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0039] The text display method and display device, electronic device and storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0040] In some embodiments of the present application, a text display method is proposed. Figure 1 A flowchart of a text display method in some embodiments of the present application is shown. Figure 1 As shown, the text display method includes:
[0041] Step 102: Receive font switching input.
[0042] In an embodiment of the present application, the text display method can be executed by an electronic device. By way of example, the electronic device includes but is not limited to mobile phones, tablet computers, laptop computers, personal computers, readers, watches, bracelets, head-mounted display devices and other electronic devices with text display functions.
[0043] The font switching input is an input used by the user to switch the font of the current electronic device when displaying text from the initial font to the target font. Exemplarily, the user can perform the font switching input by selecting the target font in the font selection interface.
[0044] Step 104, in response to the font switching input, obtaining font switching data; wherein the font switching data includes an initial font and a target font.
[0045] In an embodiment of the present application, when a font switching input is received from a user, data for generating an intermediate font sequence is obtained, including an initial font, a target font, and user feature information. The initial font is the font used when the current electronic device displays text, and the target font is the font that the user wishes to switch to. Exemplarily, the font used when the current electronic device displays text is "Songti", and the user selects "Kaiti" in the font selection interface, then the initial font is Songti, and the target font is Kaiti.
[0046] Step 106: Generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font.
[0047] In the embodiment of the present application, the intermediate font sequence includes one or more intermediate fonts, and the intermediate font is used as a transition font in the process of switching from the initial font to the target font. The intermediate font can make the font switching process continuous and smooth. It can be understood that when the intermediate font sequence includes multiple intermediate fonts, the intermediate font at the first position of the intermediate font sequence is more similar to the initial font, and the intermediate font at the last position of the intermediate font sequence is more similar to the target font.
[0048] Step 108, after the initial font is displayed, each intermediate font in the intermediate font sequence is displayed in turn, and then the target font is switched to be displayed.
[0049] In the embodiment of the present application, illustratively, it is assumed that the intermediate font sequence includes three intermediate fonts, which are respectively recorded as intermediate font 1, intermediate font 2 and intermediate font 3. Then, when switching from the initial font to the target font, the initial font is firstly transitioned to intermediate font 1, then from intermediate font 1 to intermediate font 2, then from intermediate font 2 to intermediate font 3, and finally from intermediate font 3 to the target font.
[0050] Exemplarily, in the process of transitioning from one font to another, a gradual transition animation can be used to fill the font switching process, making the font transition effect smoother.
[0051] The present application generates a font sequence including one or more intermediate fonts according to the initial font of the currently displayed text and the target font that the user wants to switch to. The style of the first font in the font sequence is close to the initial font, and the style of the last font is close to the target font. The switching process from the initial font to the target font is transitioned and smoothed through the font sequence, thereby improving the visual continuity and font quality when switching fonts, and ultimately improving the display effect of the text when switching fonts.
[0052] In some embodiments of the present application, the font switching data further includes user characteristic information, and the font style of the intermediate font is determined based on the font style of the initial font, the font style of the target font, and the user characteristic information.
[0053] In the embodiment of the present application, the user characteristic information is information that can reflect the personalized needs of the user who currently performs the font switching input. Exemplarily, in the process of the user using the electronic device, based on the analysis of the user's reading behavior data in the reading application, such as the user's commonly used font size selection, font delay selection, reading time, reading frequency and other information, the user characteristic information containing the user behavior feature vector is generated, and the user characteristic information can reflect the user's preference basis, and the font sequence is generated according to the user characteristic information, in which the intermediate font can better meet the user's personalized needs.
[0054] Exemplarily, the process of collecting user characteristic information may include the following steps:
[0055] 1. Data collection: Through the user's in-app operation records, such as click events, scrolling events, etc., record the user's font selection preferences, reading time, page dwell time, scrolling speed, etc.
[0056] Data collection methods include direct feedback, such as obtaining user preference information directly through questionnaires, user reviews, etc. It also includes indirect feedback, such as recording user behavior within the app, such as font selection, usage frequency, dwell time, etc., and generating contextual information, such as collecting environmental information when users use fonts, such as device type, screen resolution, operating system, etc.
[0057] 2. Data preprocessing. After obtaining the above data, clean and organize the data to remove invalid or abnormal data points. For example, use data cleaning technology to remove invalid or abnormal data points, such as outliers.
[0058] 3. Feature extraction: Use statistical methods, such as mean statistics, variance statistics, etc., and machine learning methods, such as principal component analysis (PCA) dimensionality reduction method, to extract user behavior feature vectors from the original data. For example, the method of extracting key behavior features using principal component analysis is as follows:
[0059] For example, the PCA formula is: X'=XW, where X is the original data matrix or feature vector, which can be the user's preference feature vector. For example, if the user prefers clear and easy-to-read fonts, the feature vector may be: [preferred clarity: 1, preferred artistry: 2, font size: 12pt, usage scenario: editing documents].
[0060] W is a weight matrix composed of principal components, which determines the importance of the input feature vector X in the model. The weight matrix can be optimized during the training process and used to adjust the importance of features. For example, in a simple linear model, the weight W may represent the influence of each preference feature on the final font recommendation. X' is the data after dimensionality reduction. PCA reduces the data dimension while retaining the maximum amount of information by finding the main direction of the data.
[0061] 4. Feature vectorization: Convert the extracted features into numerical vector form for easy subsequent processing.
[0062] For example, the eigenvector formula is: f = [f 1 , f 2 , ...f n ]. Among them, f n Represents the value of the nth feature.
[0063] By combining user feature information, the present application can make the generated intermediate font more in line with the user's personal preferences and improve the visual experience when switching fonts.
[0064] In some embodiments of the present application, generating an intermediate font sequence based on font switching data includes: inputting the font switching data into a font generation model to obtain an intermediate font; and generating an intermediate font sequence based on the intermediate font.
[0065] In an embodiment of the present application, an initial font, a target font and user feature information are input into a font generation model, and a series of high-quality intermediate fonts between the initial font and the target font are generated based on the font generation model. The input of the font generation model includes user feature information. For example, the user feature information includes user behavior feature vectors. These feature vectors enable the font generation model to generate personalized fonts that conform to user habits, and also help the font generation model understand what kind of intermediate fonts can best meet specific needs.
[0066] One or more intermediate fonts are generated through a trained font generation model, so that when switching from the initial font to the target font, a smooth transition can be achieved through the intermediate fonts. When the user selects a new target font, the font generation model can dynamically generate intermediate fonts in real time, so that the initial font can smoothly transition to the style of the new target font, rather than immediately jumping from the old font to the new font, avoiding visual abrupt changes and making the text display more coherent and comfortable when switching fonts.
[0067] In some embodiments of the present application, an intermediate font sequence is generated based on font switching data, including: inputting the font switching data into a font generation model to obtain an intermediate font; generating at least one transition font based on a spherical linear interpolation algorithm and the intermediate font; and generating an intermediate font sequence based on the intermediate font and the transition font.
[0068] In an embodiment of the present application, a smoothly transitioning font sequence, i.e., the above-mentioned intermediate font sequence, is generated based on the initial font, the target font, user feature information, and a high-quality intermediate font obtained based on a font generation model, thereby achieving a smooth switch from the initial font to the target font.
[0069] Spherical interpolation can generate a smooth transition from the initial font to the target font. Spherical interpolation can maintain the shortest path between the two endpoints, thus achieving a natural transition effect.
[0070] Generate one or more intermediate fonts through the trained font generation model. After the above-mentioned normalization process is performed on the feature vector of each intermediate font, the spherical linear interpolation formula is used to calculate the interpolation between any two adjacent fonts, such as the initial font and the first intermediate font in the intermediate font sequence, or any two points between any two adjacent intermediate fonts in the intermediate font sequence.
[0071] Exemplarily, the spherical linear interpolation formula is:
[0072]
[0073] Among them, slerp(θ,v 0 ,v 1 ) is the interpolation value, v 0 and v 1 are the feature vectors of two different fonts, α is the angle between the two feature vectors, and θ is the interpolation coefficient.
[0074] The calculation formula of the angle α is:
[0075]
[0076] Among them, v 0 and v 1 are the feature vectors of two different fonts, ||v 0 || is v 0 The norm of ||v 1 || is v 1 The norm of .
[0077] By adjusting the value of θ so that it gradually changes from 0 to 1, a series of transition fonts from the initial font to the target font, or from one intermediate font to another intermediate font can be generated. The intermediate fonts generated by the font generation model and the transition fonts obtained by spherical linear interpolation can obtain the above-mentioned intermediate font sequence. The intermediate font sequence can achieve a smooth transition from the initial font to the target font.
[0078] For example, Figure 2 Schematic diagrams of font switching in some embodiments of the present application are shown, such as Figure 2 As shown in the figure, the initial font and the target font are the font styles before and after the user selects the font switch, and the intermediate font is generated by the font generation model for smooth transition. The intermediate font is a smooth transition font from the initial font to the target font obtained by the spherical linear interpolation algorithm. Each intermediate font is interpolated based on the feature vectors of the previous font style and the next font style. This process starts when the user selects a new target font. The system will smoothly transition from the initial font to the target font instead of immediately jumping from the old font to the new font, thus avoiding visual abrupt changes. The user will see the font gradually change from the old style to the new style, making the entire reading experience more coherent and comfortable.
[0079] In some embodiments of the present application, before inputting the font switching data into the font generation model, the text display method further includes: performing standardization processing on the feature vector of the initial font and the feature vector of the target font.
[0080] In the embodiment of the present application, before the font switching data is input into the font generation model and the surface linear difference algorithm is used to generate the transition font, the feature vectors of the initial font and the target font are first standardized so that the feature vector of the initial font and the feature vector of the target font are on the same spatial scale. Exemplarily, the standardization formula is: Among them, v norm is the standardized eigenvector, v is the original eigenvector, and ||v|| is the norm of v.
[0081] By standardizing the feature vectors, it is possible to ensure that the feature vectors of different fonts remain at the same spatial scale, thereby improving the quality of generating intermediate fonts and transitional fonts.
[0082] Before receiving the font switching input, the text display method also includes: displaying a font selection interface corresponding to the font library; wherein the font selection interface includes a font identifier corresponding to the personalized font; or, the font selection interface includes a font identifier corresponding to the personalized font and a font identifier corresponding to the preset font, and the display priority of the font identifier corresponding to the personalized font is higher than the display priority of the font identifier corresponding to the preset font.
[0083] In an embodiment of the present application, the font generation model can generate a font that meets the user's preferences based on user feature information. The font can be used as an intermediate font for a smooth font switching process or as a personalized font for the user to select as a target font.
[0084] Exemplarily, the font output by the font generation model can be expressed as: F=G(z, c), where G is the generator network, z is the random noise extracted from the normal distribution, and c is the user behavior feature vector.
[0085] The personalized fonts generated by the font generation model are integrated into the system's font library. When the user requests to change the font, the generated personalized fonts can be displayed first.
[0086] For example, Figure 3 A schematic diagram of a font selection interface of some embodiments of the present application is shown. Figure 3 As shown, the font selection interface 300 displays a font identifier 302 of a personalized font generated by a font generation model.
[0087] For example, Figure 4 A schematic diagram of a font selection interface of some embodiments of the present application is shown. Figure 4 As shown, the font selection interface 400 displays a font identifier 402 of a personalized font generated by a font generation model and a font identifier 404 corresponding to a preset font. Among them, the font identifier 402 of the personalized font is displayed in a more forward order.
[0088] This application generates personalized fonts that meet user preferences based on user feature information, and gives priority to displaying these personalized fonts when users select fonts, so that users can personalize reading fonts and improve reading experience.
[0089] In some embodiments of the present application, after generating at least one personalized font based on user feature information and a font generation model, the text display method also includes: receiving feedback input; determining a feedback vector in response to the feedback input; and adjusting the personalized font based on at least one of the feedback vector and the historical feedback vector.
[0090] In an embodiment of the present application, a user feedback mechanism is proposed. Through the user feedback mechanism, the user is allowed to evaluate the personalized fonts generated by the font generation model, and the preference model is adjusted according to the user feedback, so that the personalized fonts generated by the font generation model can more accurately match the user's personalized needs.
[0091] Exemplarily, the feedback adjustment formula can be expressed as:
[0092] c new =cold +β·Δc;
[0093] Among them, c new For the adjusted personalized font, c old is the personalized font before adjustment, β is the preset learning rate parameter, and Δc is the feature vector increment adjusted according to user feedback.
[0094] By adding a user feedback mechanism, the generated personalized fonts can better meet the user's personalized needs.
[0095] In some embodiments of the present application, user feature information includes a user behavior feature vector and a user emotion feature vector; before receiving the font switching input, the text display method also includes: concatenating the user behavior feature vector and the user emotion feature vector to obtain the user feature information.
[0096] In an embodiment of the present application, the user characteristic information includes a user emotion characteristic vector, and a personalized font that is more in line with the current emotion is generated through emotion recognition.
[0097] For example, a user preference model is established based on the user behavior feature vector, and the user preference model generates a behavior feature vector according to the user's behavior attributes. Establish an emotion recognition module, which can extract emotion feature vectors from the user's voice or facial expressions
[0098] Among them, the sentiment feature vector It can be obtained by fusion of multimodal data, such as the emotional intensity of voice and the positivity and negativity of facial expressions. Assuming that the emotion recognition module can extract the emotional intensity h from the voice and the positivity l and negativity m from the facial expressions, the emotional feature vector can be expressed as:
[0099]
[0100] Exemplarily, the emotion recognition module applies emotion recognition technology, such as facial expression analysis or speech emotion recognition, to capture the user's current emotional state. For example, the user's facial expression is captured by a camera and analyzed using a convolutional neural network model, or the user's voice is collected by a microphone and the emotional color in the voice is recognized using a recurrent neural network model.
[0101] Define user feature information as The user feature information is obtained by weighted merging of the behavior feature vector and the emotion feature vector. In order to better reflect the influence of emotion on font selection, a nonlinear function can be used to fuse these two feature vectors. For example, the fusion formula is:
[0102]
[0103] in, is user feature information, Concat() represents vector concatenation operation, is a nonlinear transformation function used to adjust the dimension and expression of the entire emotional feature vector to make it more compatible with the behavioral feature vector. For example, It can be a vector mapped by multiple layers of neural network. is the user sentiment feature vector, is the user behavior feature vector.
[0104] After introducing the user emotion feature vector, the generator network G of the font generation model receives the user feature information and random noise As the model input, a personalized font F is generated. In order to improve the quality and diversity of the generated fonts, an attention mechanism can be introduced to enhance the generator's attention to important features. The generation process can be expressed as:
[0105]
[0106] Among them, F is a personalized font, G is a generator network, is user characteristic information, is random noise, and A is the attention mechanism.
[0107] The generated personalized fonts are integrated into the font library, and the comprehensive feature information including the user's emotional feature vector is used Assign different weights to different personalized fonts, and prioritize displaying personalized fonts that best match the user's current emotions.
[0108] By introducing a user emotion mechanism, this application can combine the user's current emotional state to improve the personalization level of font generation, ensure a smooth transition effect during the font switching process and ensure that font recommendations are more in line with the user's current situation.
[0109] In some embodiments of the present application, a method for training a font generation model is provided. Figure 5 A flowchart of a method for training a font generation model in some embodiments of the present application is shown. Figure 5 As shown, the training method includes:
[0110] Step 502, obtaining a conditional generative adversarial network model, where the conditional generative adversarial network model includes a generator network and a discriminator network;
[0111] Step 504, generating a training data set, the training data set including a font sample set, user feature information and noise information;
[0112] Step 506, using the training data set, adversarially train the generator network and the discriminator network to obtain a font generation model; wherein the font generation model is used to generate an intermediate font or a personalized font according to the font switching data, and the font switching data includes at least one of the following: an initial font, a target font, and user feature information.
[0113] In an embodiment of the present application, by constructing conditional generative adversarial networks (cGANs) and an optimized loss function, a font generation model capable of generating intermediate fonts that conform to the user's aesthetic habits is obtained.
[0114] Exemplarily, a conditional generative adversarial network is a specific type of generative adversarial network (GANs), that is, a specific type of generative adversarial network (GANs), which is special in that it allows both the generator and the discriminator to receive additional information, which helps to generate data with more specific properties.
[0115] The present application generates a series of high-quality intermediate fonts between the original font and the target font based on user feature information, an initial font, and a sample set of a target font. Exemplarily, the training process includes the following steps:
[0116] 1. Data preparation. Collect and annotate a large number of samples of initial fonts and target fonts. The initial font sample set includes the fonts currently used by the user, and the target font sample set includes the fonts that the user wants to switch to. Combine the user feature information, the initial font sample set, the target font sample set, and the randomly generated noise data to obtain the training data set.
[0117] 2. Model initialization. Define the generator network G and the discriminator network D, and initialize the weights. The generator network G and the discriminator network D respectively use convolutional neural network architectures and initialize the network parameters.
[0118] 3. Model training. The generator network G receives the data in the training data set, including user feature information and random noise as input, and generates intermediate fonts. The discriminator network D determines whether the generated intermediate font meets the requirements.
[0119] Among them, the loss function of the generator network is defined as:
[0120] L G =E z~P(z),c~P(c) [log(1-D(G(z,c)))];
[0121] Among them, L Gis the generator loss function value, z~P(z) means z is drawn from the probability distribution P(z), specifically, it means random noise z is randomly drawn from a certain distribution, usually standard normal distribution or uniform distribution. c~P(c) means user behavior feature vector c is randomly drawn from the probability distribution P(c), usually the distribution of user behavior feature vector. z is random noise drawn from normal distribution. Random noise is part of the input of the generator. It is a random vector used to introduce diversity so that the generated results are not exactly the same. Noise can be a set of values drawn from Gaussian distribution or uniform distribution. c is the user behavior feature vector. G is the generator network. D is the discriminator network. This formula encourages the generator to produce fonts that are difficult for the discriminator to distinguish between true and false.
[0122] The loss function of the discriminator network is defined as:
[0123] L D =E x~Pdata(x) [logD(x)]+E z~P(z),c~P(c) [log(1-D(G(z,c)))];
[0124] Among them, L D is the discriminator loss function value, x~Pdata(x) means x is extracted from the distribution of real data Pdata(x), and x is a real sample extracted from the real data set. D(x) is the output of the discriminator network, which is a probability value between 0 and 1, indicating the probability that the input sample x is real data. z~P(z) means Z is extracted from the probability distribution P(z). c~P(c) means that the user behavior feature vector c is randomly extracted from the probability distribution P(c). z is random noise extracted from the normal distribution, and c is the user behavior feature vector.
[0125] An additional quality loss term is introduced, defined as L Q , which is used to measure the quality of the generated font at a specific size. The final loss function is:
[0126] L=L G +L D +λL Q ;
[0127] Among them, L is the final loss function, L G is the generator loss function, L D is the discriminator loss function, L Q is the quality loss term, and λ is the weight adjustment factor.
[0128] 4. Iterative training. By alternating the update of the generator and the discriminator until convergence. By training cGANs and combining the quality loss term, it is possible to generate high-quality intermediate font styles that meet the user's preferences, which is the basis for achieving a smooth transition. Specifically, once the user's behavior feature vector is available, it can be used to guide the learning process of cGANs. The goal here is to enable cGANs to learn how to smoothly transition from one font style to another. In this process, the user behavior feature vector is input into the generator as a condition to help generate an intermediate font style that is more in line with the user's preferences.
[0129] This application obtains a font generation model that can generate intermediate fonts that meet user preferences through adversarial training.
[0130] The text display method provided in the embodiment of the present application can be executed by a text display device. In the embodiment of the present application, a text display device executing the text display method is taken as an example to illustrate the text display device provided in the embodiment of the present application.
[0131] In some embodiments of the present application, a text display device is provided. Figure 6 The structural block diagram of the text display device of some embodiments of the present application is shown as follows: Figure 6 As shown, the text display device 600 includes:
[0132] A receiving module 602, configured to receive a font switching input;
[0133] A first acquisition module 604 is used to acquire font switching data in response to a font switching input; wherein the font switching data includes an initial font and a target font;
[0134] A first generating module 606 is used to generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font;
[0135] The font switching module 608 is used to switch the display of the target font after the initial font is displayed and each intermediate font in the intermediate font sequence is displayed in sequence.
[0136] The present application generates a font sequence including one or more intermediate fonts according to the initial font of the currently displayed text and the target font that the user wants to switch to. The style of the first font in the font sequence is close to the initial font, and the style of the last font is close to the target font. The switching process from the initial font to the target font is transitioned and smoothed through the font sequence, thereby improving the visual continuity and font quality when switching fonts, and ultimately improving the display effect of the text when switching fonts.
[0137] In some embodiments of the present application, the font switching data further includes user characteristic information, and the font style of the intermediate font is determined based on the font style of the initial font, the font style of the target font, and the user characteristic information.
[0138] By combining user feature information, the present application can make the generated intermediate font more in line with the user's personal preferences and improve the visual experience when switching fonts.
[0139] In some embodiments of the present application, the text display device further includes:
[0140] A model control module, used for inputting font switching data into a font generation model to obtain an intermediate font;
[0141] The generation module is further used to generate an intermediate font sequence based on the intermediate font.
[0142] The present application generates one or more intermediate fonts through a trained font generation model, so that when switching from an initial font to a target font, a smooth transition when switching fonts can be achieved through the intermediate fonts. When a user selects a new target font, the font generation model can dynamically generate intermediate fonts in real time, so that the initial font can smoothly transition to the style of the new target font, rather than immediately jumping from the old font to the new font, avoiding abrupt visual changes and making the text display more coherent and comfortable when switching fonts.
[0143] In some embodiments of the present application, the text display device further includes:
[0144] A model control module, used for inputting font switching data into a font generation model to obtain an intermediate font;
[0145] The generating module is further used to generate at least one transitional font based on the spherical linear interpolation algorithm and the intermediate font; and to generate an intermediate font sequence based on the intermediate font and the transitional font.
[0146] This application obtains a smooth transition font from the initial font to the target font through a spherical linear interpolation algorithm. Each intermediate font is interpolated based on the feature vectors of the previous font style and the next font style. This process starts when the user selects a new target font. The system will smoothly transition from the initial font to the target font instead of immediately jumping from the old font to the new font, thereby avoiding visual abrupt changes. The user will see the font gradually change from the old style to the new style, making the entire reading experience more coherent and comfortable.
[0147] In some embodiments of the present application, the text display device further includes:
[0148] The processing module is used for standardizing the feature vector of the initial font and the feature vector of the target font.
[0149] The present application can ensure that the feature vectors of different fonts are kept at the same spatial scale by performing standardization processing on the feature vectors, thereby improving the quality of generating intermediate fonts and transitional fonts.
[0150] In some embodiments of the present application, the generating module is further used to generate at least one personalized font according to the user characteristic information and the font generating model;
[0151] The text display device also includes:
[0152] A font management module, used for adding personalized fonts to a font library, where the font library includes an initial font and a target font;
[0153] A display module is used to display a font selection interface corresponding to the font library; wherein the font selection interface includes a font identifier corresponding to the personalized font; or, the font selection interface includes a font identifier corresponding to the personalized font and a font identifier corresponding to the preset font, and the display priority of the font identifier corresponding to the personalized font is higher than the display priority of the font identifier corresponding to the preset font.
[0154] This application generates personalized fonts that meet user preferences based on user feature information, and gives priority to displaying these personalized fonts when users select fonts, so that users can personalize reading fonts and improve reading experience.
[0155] In some embodiments of the present application, the receiving module is further used to receive feedback input;
[0156] The text display device also includes:
[0157] a determination module, configured to determine a feedback vector in response to a feedback input;
[0158] The adjustment module is used to adjust the personalized font based on at least one of the feedback vector and the historical feedback vector.
[0159] This application adds a user feedback mechanism so that the generated personalized fonts can better meet the user's personalized needs.
[0160] In some embodiments of the present application, the user feature information includes a user behavior feature vector and a user emotion feature vector;
[0161] The text display device also includes:
[0162] The processing module is used to perform splicing processing on the user behavior feature vector and the user emotion feature vector to obtain user feature information.
[0163] By introducing a user emotion mechanism, this application can combine the user's current emotional state to improve the personalization level of font generation, ensure a smooth transition effect during the font switching process and ensure that font recommendations are more in line with the user's current situation.
[0164] In some embodiments of the present application, a training device for a font generation model is provided. Figure 7 The structural block diagram of the training device of the font generation model of some embodiments of the present application is shown as follows: Figure 7 As shown, the training device 700 includes:
[0165] A second acquisition module 702 is used to acquire a conditional generative adversarial network model, where the conditional generative adversarial network model includes a generator network and a discriminator network;
[0166] A second generating module 704 is used to generate a training data set, where the training data set includes a font sample set, user feature information, and noise information;
[0167] The training module 706 is used to perform adversarial training on the generator network and the discriminator network through the training data set to obtain a font generation model; wherein the font generation model is used to generate an intermediate font or a personalized font according to the font switching data, and the font switching data includes at least one of the following: an initial font, a target font, and user feature information.
[0168] This application obtains a font generation model that can generate intermediate fonts that meet user preferences through adversarial training.
[0169] The text display device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0170] The text display device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0171] The text display device provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.
[0172] Optionally, an embodiment of the present application further provides an electronic device, Figure 8 A structural block diagram of an electronic device according to an embodiment of the present application is shown. Figure 8 As shown, the electronic device 800 includes a processor 802, a memory 804, and a program or instruction stored in the memory 804 and executable on the processor 802. When the program or instruction is executed by the processor 802, each process of the above-mentioned method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0173] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0174] Fig. 9 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0175] The electronic device 900 includes but is not limited to: a radio frequency unit 901, a network module 902, an audio output unit 903, an input unit 904, a sensor 905, a display unit 906, a user input unit 907, an interface unit 908, a memory 909, a processor 910 and other components.
[0176] Those skilled in the art will appreciate that the electronic device 900 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 910 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0177] Wherein, the user input unit 907 is used to receive a font switching input;
[0178] Processor 910 is used to obtain font switching data in response to font switching input; wherein the font switching data includes an initial font and a target font; generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font; after displaying the initial font, sequentially transitioning to displaying each intermediate font in the intermediate font sequence, switching to display the target font.
[0179] The present application generates a font sequence including one or more intermediate fonts based on the initial font of the currently displayed text and the target font that the user wants to switch to, combined with the user's personal characteristic information. The style of the first font in the font sequence is close to the initial font, and the style of the last font is close to the target font. The switching process from the initial font to the target font is transitioned and smoothed through the font sequence, and the process conforms to the user's personal preferences, thereby improving the visual continuity and font quality when switching fonts, and ultimately improving the display effect of text when switching fonts.
[0180] Optionally, the font switching data further includes user characteristic information, and the font style of the intermediate font is determined based on the font style of the initial font, the font style of the target font and the user characteristic information.
[0181] By combining user feature information, the present application can make the generated intermediate font more in line with the user's personal preferences and improve the visual experience when switching fonts.
[0182] Optionally, the processor 910 is further configured to input the font switching data into a font generation model to obtain an intermediate font; and generate an intermediate font sequence based on the intermediate font.
[0183] The present application generates one or more intermediate fonts through a trained font generation model, so that when switching from an initial font to a target font, a smooth transition when switching fonts can be achieved through the intermediate fonts. When a user selects a new target font, the font generation model can dynamically generate intermediate fonts in real time, so that the initial font can smoothly transition to the style of the new target font, rather than immediately jumping from the old font to the new font, avoiding abrupt visual changes and making the text display more coherent and comfortable when switching fonts.
[0184] Optionally, the processor 910 is further configured to input the font switching data into a font generation model to obtain an intermediate font; generate at least one transitional font based on a spherical linear interpolation algorithm and the intermediate font; and generate an intermediate font sequence based on the intermediate font and the transitional font.
[0185] This application obtains a smooth transition font from the initial font to the target font through a spherical linear interpolation algorithm. Each intermediate font is interpolated based on the feature vectors of the previous font style and the next font style. This process starts when the user selects a new target font. The system will smoothly transition from the initial font to the target font instead of immediately jumping from the old font to the new font, thereby avoiding visual abrupt changes. The user will see the font gradually change from the old style to the new style, making the entire reading experience more coherent and comfortable.
[0186] Optionally, the processor 910 is further configured to perform standardization processing on the feature vector of the initial font and the feature vector of the target font.
[0187] The present application can ensure that the feature vectors of different fonts are kept at the same spatial scale by performing standardization processing on the feature vectors, thereby improving the quality of generating intermediate fonts and transitional fonts.
[0188] Optionally, the processor 910 is also used to obtain a conditional generative adversarial network model, which includes a generator network and a discriminator network; generate a training data set, which includes a font sample set, user feature information and noise information; and perform adversarial training on the generator network and the discriminator network through the training data set to obtain a font generation model.
[0189] This application obtains a font generation model that can generate intermediate fonts that meet user preferences through adversarial training.
[0190] Optionally, the processor 910 is further configured to generate at least one personalized font according to the user feature information and the font generation model; add the personalized font to a font library, where the font library includes an initial font and a target font;
[0191] Display unit 906 is used to display a font selection interface corresponding to the font library; wherein the font selection interface includes a font identifier corresponding to the personalized font; or, the font selection interface includes a font identifier corresponding to the personalized font and a font identifier corresponding to the preset font, and the display priority of the font identifier corresponding to the personalized font is higher than the display priority of the font identifier corresponding to the preset font.
[0192] This application generates personalized fonts that meet user preferences based on user feature information, and gives priority to displaying these personalized fonts when users select fonts, so that users can personalize reading fonts and improve reading experience.
[0193] Optionally, the user input unit 907 is further used to receive feedback input;
[0194] The processor 910 is further configured to determine a feedback vector in response to the feedback input; and adjust the personalized font based on at least one of the feedback vector and the historical feedback vector.
[0195] This application adds a user feedback mechanism so that the generated personalized fonts can better meet the user's personalized needs.
[0196] Optionally, the user feature information includes a user behavior feature vector and a user emotion feature vector;
[0197] The processor 910 is further used to perform concatenation processing on the user behavior feature vector and the user emotion feature vector to obtain user feature information.
[0198] By introducing a user emotion mechanism, this application can combine the user's current emotional state to improve the personalization level of font generation, ensure a smooth transition effect during the font switching process and ensure that font recommendations are more in line with the user's current situation.
[0199] It should be understood that in the embodiment of the present application, the input unit 904 may include a graphics processor (Graphics Processing Unit, GPU) 9041 and a microphone 9042, and the graphics processor 9041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 906 may include a display panel 9061, and the display panel 9061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 907 includes a touch panel 9071 and at least one of other input devices 9072. The touch panel 9071 is also called a touch screen. The touch panel 9071 may include two parts: a touch detection device and a touch controller. Other input devices 9072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0200] The memory 909 can be used to store software programs and various data. The memory 909 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 909 may include a volatile memory or a non-volatile memory, or the memory 909 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 909 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0201] The processor 910 may include one or more processing units; optionally, the processor 910 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 910.
[0202] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0203] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0204] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0205] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0206] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0207] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0208] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0209] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A text display method, characterized in that: The text display method comprises: Receive font switching input; In response to the font switching input, obtaining font switching data; wherein the font switching data includes an initial font and a target font; generating an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font; After the initial font is displayed, each intermediate font in the intermediate font sequence is displayed in sequence, and then the target font is displayed.
2. The text display method according to claim 1, characterized in that: The font switching data further includes user characteristic information, and the font style of the intermediate font is determined based on the font style of the initial font, the font style of the target font, and the user characteristic information.
3. The text display method according to claim 1 or 2, characterized in that: The step of generating an intermediate font sequence based on the font switching data comprises: Inputting the font switching data into a font generation model to obtain the intermediate font; The intermediate font sequence is generated based on the intermediate font.
4. The text display method according to claim 1 or 2, characterized in that: The step of generating an intermediate font sequence based on the font switching data comprises: Inputting the font switching data into a font generation model to obtain an intermediate font; Generate at least one transitional font based on the spherical linear interpolation algorithm and the intermediate font; The intermediate font sequence is generated based on the intermediate font and the transitional font.
5. The text display method according to claim 3, characterized in that: Before inputting the font switching data into the font generation model, the method further includes: The feature vector of the initial font and the feature vector of the target font are normalized.
6. The text display method according to claim 3, characterized in that: The font switching data also includes user feature information, and the method further includes: Generate at least one personalized font according to the user characteristic information and the font generation model; Adding the personalized font to the font library; Furthermore, before receiving the font switching input, the text display method further includes: A font selection interface corresponding to the font library is displayed; wherein the font selection interface includes a font identifier corresponding to the personalized font; or, the font selection interface includes a font identifier corresponding to the personalized font and a font identifier corresponding to a preset font, and a display priority of the font identifier corresponding to the personalized font is higher than a display priority of the font identifier corresponding to the preset font.
7. The text display method according to claim 6, characterized in that: After generating at least one personalized font according to the user characteristic information and the font generation model, the method further includes: Receive feedback input; determining a feedback vector in response to the feedback input; The personalized font is adjusted based on at least one of the feedback vector and the historical feedback vector.
8. The text display method according to claim 6, characterized in that: The font switching data also includes user feature information, and the user feature information includes a user behavior feature vector and a user emotion feature vector; Before receiving the font switching input, the method further includes: The user behavior feature vector and the user emotion feature vector are concatenated to obtain the user feature information.
9. A method for training a font generation model, characterized in that: The training method comprises: Acquire a conditional generative adversarial network model, wherein the conditional generative adversarial network model includes a generator network and a discriminator network; Generate a training data set, wherein the training data set includes a font sample set, user feature information, and noise information; The generator network and the discriminator network are adversarially trained through the training data set to obtain the font generation model; wherein the font generation model is used to generate an intermediate font or a personalized font according to font switching data, and the font switching data includes at least one of the following: an initial font, a target font, and user feature information.
10. A text display device, characterized in that: The text display device comprises: A receiving module, used for receiving a font switching input; A first acquisition module, configured to acquire font switching data in response to the font switching input; wherein the font switching data includes an initial font and a target font; A first generating module, configured to generate an intermediate font sequence based on the font switching data; wherein the intermediate font sequence includes at least one intermediate font; The font switching module is used to display the target font after sequentially transitioning from displaying the initial font to displaying each of the intermediate fonts in the intermediate font sequence.
11. A training device for a font generation model, characterized in that: The training device comprises: A second acquisition module is used to acquire a conditional generative adversarial network model, wherein the conditional generative adversarial network model includes a generator network and a discriminator network; A second generating module is used to generate a training data set, wherein the training data set includes a font sample set, user feature information and noise information; A training module is used to perform adversarial training on the generator network and the discriminator network through the training data set to obtain the font generation model; wherein the font generation model is used to generate an intermediate font or a personalized font according to font switching data, and the font switching data includes at least one of the following: an initial font, a target font, and user feature information.
12. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Image character morphing animation generating method
CN103810739A
Font setting method and device and device for setting fonts
CN112486362A
Dynamic differential evolution based control for typeface visual accessibility
US20230419568A1