Novel texture character creation method and device, equipment and storage medium
By acquiring text and texture data, generating mask data using text shaping and font rendering engines, and combining this with a typesetting engine to generate colored textured text, the efficiency and adaptation issues of textured text creation in existing technologies are solved, achieving efficient textured text rendering.
Patent Information
- Application Number
- CN202511645487.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-11
- Publication Date
- 2026-02-10
AI Technical Summary
Existing methods for creating textured text struggle to balance visual effects, production efficiency, and batch adaptation capabilities. Traditional methods suffer from frequent calculations, resource waste, cumbersome operations, and high costs.
By acquiring text file data and texture image data, a text shaping engine and a font rendering engine are used to generate mask data and drawing areas. A typesetting engine is then used to lay out paragraphs, generate a set of colored mask glyphs, and configure the rendering method of the brush structure to finally output textured text.
It achieves rich text texture effects without creating a large number of colored fonts, improves rendering efficiency, saves time and labor costs, and adapts to diverse application needs.
Smart Images

Figure CN121505129A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a novel method, apparatus, device, and storage medium for creating textured text. Background Technology
[0002] With the rapid development of digital display technology, multimedia content creation, and smart terminal applications, text has gradually expanded from a traditional information transmission medium to diverse fields such as advertising design, game scenarios, UI interfaces, and digital publications. Users' demands for the visual expressiveness of text are increasing, giving rise to textured text that combines information delivery with aesthetic value. This type of text, by overlaying texture effects (such as wood grain, metallic texture, and gradient textures) on the surface of the letterforms, can significantly enhance visual impact, meet the personalized design needs of different scenarios, and has become an important development direction in current text visual design.
[0003] However, existing methods for implementing textured text still have significant limitations, making it difficult to efficiently adapt to large-scale, diverse application needs. Currently, the mainstream methods for drawing textured text fall into two main categories: One type is a text masking and texture scheme. For example... Figure 1 As shown, this method first obtains a mask glyph using conventional text generation, then draws a colorless text outline as a mask layer, and finally uses a texture map to outline the texture effect of the corresponding area on the mask layer, thus obtaining textured text. This method is simple and easy to understand, and is most commonly used to draw colored text with multiple color information, but its drawbacks are also prominent: in order to keep the texture content unchanged as the text moves, scales, or rotates, it is necessary to control the transformation of the texture image through a matrix to maintain its static state relative to the text, which leads to frequent matrix calculations; when the text exceeds the image range, it is necessary to fill the gaps by repeating commands, resulting in wasted rendering performance.
[0004] Another approach involves creating specific font schemes. This method utilizes mainstream font software such as FontCreator and Alphabix to create multi-colored fonts, applying these fonts to text to achieve texture effects. The core principle is to parse font data in the code to generate color glyphs, which are then passed to the rendering engine for drawing. This type of font software supports creating multi-colored glyphs and importing images to replace character outlines. FontCreator generates textured text by converting images into character outlines, while Alphabix directly replaces the glyphs with images and imports the correct alpha channel to achieve the effect. However, this approach has significant drawbacks: when the text has a multi-layered structure, it's often unnecessary to create textured text for each layer, and the one-text-one-font model cannot guarantee text style diversity; if a separate font file is configured for each layer, multiple font files need to be created, significantly increasing the workload.
[0005] In addition to the above, mainstream solutions also include a method of overlaying and compositing basic text and texture masks. This involves first generating a monochrome text outline, and then using a mask to confine the texture pattern within the text area. This method requires processing three independent elements: text, texture, and mask. When adjusting the text font, size, or texture style, outline matching and mask adaptation must be performed again, making the process cumbersome and prone to problems such as texture misalignment and blurred edges, resulting in low flexibility and efficiency. Some solutions achieve texture effects by customizing colored fonts, directly embedding texture-related color and layer information into the font file. However, the creation of such fonts requires professional font design tools and techniques, resulting in long development cycles and high costs. Furthermore, customized font files are difficult to adapt to different texture requirements in batches, and subsequent updates or modifications to the texture require regenerating the font file, which cannot meet the needs of rapid iteration and mass production scenarios. Summary of the Invention
[0006] The purpose of this invention is to provide a novel method, apparatus, device, and storage medium for creating textured text, aiming to solve the problems of existing technologies that make it difficult to balance the visual effect, production efficiency, and batch adaptation capability of textured text.
[0007] In a first aspect, embodiments of the present invention provide a novel method for creating textured text, comprising: Retrieve text file data and texture image data; The text file data and the texture image data are combined to form a data structure, and the data structure is then passed into the text rendering engine. In the text rendering engine, mask data is obtained from the text file data through the text shaping engine and the font rendering engine, and the text drawing area is determined. The mask data and the text drawing area are fed into the typesetting engine for paragraph layout to obtain the mask glyph set; Based on the mask glyph set, a color mask glyph set is generated by copying; Set the texture image data into the texture fill effect attribute of the brush structure, and configure the rendering method of the brush structure; A color atlas is generated based on the color mask glyph set and the configured brush structure; The color atlas is rendered and output to obtain textured text.
[0008] Secondly, embodiments of the present invention provide a novel textured text creation device, comprising: The acquisition unit is used to acquire text file data and texture image data; The component unit is used to combine the text file data and the texture image data into a data structure, and to pass the data structure into the text rendering engine; The determining unit is used in the text rendering engine to obtain mask data from the text file data through the text shaping engine and the font rendering engine, and to determine the text drawing area; A layout unit is used to input the mask data and the text drawing area into the typesetting engine for paragraph layout, and obtain a mask glyph set; The copying unit is used to generate a color mask glyph set by copying the mask glyph set. The configuration unit is used to set the texture image data into the texture fill effect attribute of the brush structure and configure the rendering method of the brush structure. A generation unit is used to generate a color atlas based on the color mask glyph set and the configured brush structure; The output unit is used to render and output the color atlas to obtain textured text.
[0009] Thirdly, embodiments of the present invention provide a computer device including 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 novel textured text creation method described in the first aspect.
[0010] Fourthly, embodiments of the present invention also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program that, when executed by a processor, implements the novel textured text creation method described in the first aspect.
[0011] This invention discloses a novel method, apparatus, device, and storage medium for creating textured text. The method includes: acquiring text file data and texture image data; forming a data structure from the text file data and the texture image data, and inputting the data structure into a text rendering engine; in the text rendering engine, obtaining mask data from the text file data through a text shaping engine and a font rendering engine, and determining the text drawing area; inputting the mask data and the text drawing area into a typesetting engine for paragraph layout to obtain a mask glyph set; generating a color mask glyph set by copying and constructing based on the mask glyph set; setting the texture image data into the texture fill effect attribute of a brush structure, and configuring the rendering mode of the brush structure; generating a color atlas based on the color mask glyph set and the configured brush structure; and rendering and outputting the color atlas to obtain textured text. This invention improves the traditional ordinary text rendering process, achieving textured text effects without the need to create a large number of color fonts. It not only enriches the ordinary text rendering effects and breaks down the barrier that texture effects can only be achieved through color fonts, but also saves more time and labor costs. The present invention also provides a novel textured text creation device, a computer-readable storage medium, and a computer device, which have the above-mentioned beneficial effects, and will not be described in detail here. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating the existing text masking and texture addition scheme; Figure 2 This is a schematic diagram of the first process of the novel textured text creation method in this embodiment; Figure 3 A schematic diagram of the second process for creating a new type of textured text; Figure 4 A schematic diagram of the third process for creating novel textured text; Figure 5 A schematic diagram of the first sub-process of the method for creating novel textured text; Figure 6 A schematic diagram of the second sub-process of the method for creating novel textured text; Figure 7 A schematic diagram of the third sub-process of the method for creating novel textured text; Figure 8A schematic diagram of the fourth sub-process of the new textured text creation method; Figure 9 A schematic diagram of the fifth sub-process of the new textured text creation method; Figure 10 A schematic diagram of the sixth sub-process of the new textured text creation method; Figure 11 A flowchart illustrating a novel textured text creation method according to a specific embodiment; Figure 12 A schematic diagram illustrating the effect of a novel textured text creation method according to a specific embodiment; Figure 13 A schematic diagram of a device for creating novel textured text. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] It should be understood that, when used in this specification and the appended claims, the terms “comprising” and “including” indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more of its features, integrals, steps, operations, elements, components and / or collections thereof.
[0016] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0017] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the relevant listed items and all possible combinations, and includes such combinations.
[0018] Please see Figures 2-4 This embodiment provides a novel method for creating textured text, including: S101: Obtain text file data and texture image data; Specifically, during the preparation phase, user input is received through a user interface or program interface. This input includes text file data and corresponding texture image data. Users can upload their own designed text files, which support various styles, including but not limited to single-layer plain text and multi-layer text with multiple effects (such as layered text with strokes and shadows). Secondly, corresponding texture image data needs to be configured. The texture image is used to give the text a specific texture (such as wood grain, metallic texture, gradient patterns, etc.).
[0019] S102: Combine the text file data and the texture image data to form structural data, and then pass the structural data into the text rendering engine; Specifically, the structured data composed of text file data and texture image data includes: The text file data is parsed and extracted to obtain glyph outline parameters, font size data, and character encoding information; Based on the character outline parameters and font size data, the texture image data is segmented to obtain sub-texture data that matches the outline of each character. The glyph outline parameters, font size data, character encoding information, and segmented sub-texture data are combined into a joint structure data containing a mapping index. The mapping index is used to associate the character encoding information with the corresponding sub-texture data.
[0020] This embodiment parses and extracts text file data, converting unstructured raw text into structured data containing explicit parameters such as glyph outlines, sizes, and encodings, laying a precise data foundation for subsequent processing. Simultaneously, based on the parsed glyph parameters, intelligent region segmentation is performed on the texture image, ensuring that the generated sub-texture data highly matches the specific glyphs in size and shape, avoiding waste of texture resources and improving the targeted and efficient use of resources. Next, the separated text parameters and image textures are integrated into a unified joint structure data, and a direct association between character encodings and sub-textures is established through a mapping index. This integrated structure simplifies the data management process and allows for rapid location and retrieval of corresponding resources during rendering, significantly improving the efficiency of data retrieval and access.
[0021] More specifically, the acquired text file data is parsed and extracted to obtain glyph outline parameters, font size data, and character encoding information. The glyph outline parameters include the keypoint coordinate sequence constituting each character outline and the outline path connection method; the font size data includes the font size value in pixels, the maximum value of the character width and height, and the baseline offset; the character encoding information is the Unicode encoding value sequence of the corresponding text content.
[0022] Next, based on the aforementioned character outline parameters and font size data, the texture image data is segmented into regions. Specifically, the width and height of the bounding rectangle of each character are calculated according to its character outline parameters. Combined with the scaling ratio in the font size data, the region range corresponding to that character in the texture image is determined. According to the region range of each character, the pixel matrix of the texture image is cut to obtain sub-texture data adapted to each character outline. The sub-texture data includes the pixel value matrix of the corresponding region, the region coordinate offset, and color channel information.
[0023] The extracted glyph contour parameters, font size data, character encoding information, and segmented sub-texture data are then integrated to form a joint structure data. This joint structure data contains four data fields, storing the glyph contour parameter set, font size dataset, character encoding information set, and sub-texture dataset, respectively. Simultaneously, a mapping index is set in the joint structure data. This mapping index is a relational table, where each record contains a character encoding information and the corresponding sub-texture data's storage index value in the sub-texture dataset. This mapping index enables direct association between character encoding information and corresponding sub-texture data.
[0024] The structure data is then passed as a parameter to the text rendering engine. After receiving the structure data, the text rendering engine reads the text content from its character information field, locates and binds the corresponding texture resource according to its texture resource field, and performs rendering operations to output textured text.
[0025] S103: In the text rendering engine, mask data is obtained from the text file data through the text shaping engine and the font rendering engine, and the text drawing area is determined; In this embodiment, please refer to Figures 5-7The core function of the text shaping engine (HarfBuzz) is to solve the problem of converting text strings into the correct glyph sequence and position, especially for complex texts (such as Arabic, Sanskrit, and vertical Chinese text). Its core tasks mainly include four aspects: ① Glyph selection: selecting the correct glyph based on the script (e.g., Latin, Arabic, Cyrillic), language, and font characteristics (e.g., italic, bold); ② Bidirectional text processing: calculating the correct display order for text that mixes left-to-right (e.g., English) and right-to-left (e.g., Arabic); ③ Ligature processing: merging multiple characters into a single ligature; ④ Kernel and baseline adjustment: calculating the positional offset of each glyph based on font metrics (e.g., ascent, descent, advancewidth) to ensure proper text alignment and spacing. After the glyph shaping vectorization, HarfBuzz generates a glyph buffer, which includes the ID of each glyph (GlyphID) and the position information of each glyph (x, y offset, used to determine the drawing coordinates on the screen).
[0026] The core function of the FreeType font rendering engine is to convert the vector glyph outlines in font files into pixel bitmaps that can be displayed on the screen. Its core tasks also include four parts: ① Font file parsing, supporting mainstream font formats such as TrueType, OpenType, and Type 1, and reading the glyph outline data (vector graphics composed of Bézier curves or straight lines) from the font; ② Glyph recording: loading the corresponding vector outline from the font file based on the glyph ID output by HarfBuzz; ③ Rasterization: converting the vector outline into a bitmap (pixel data), applying anti-aliasing technology to smooth the edges; ④ Font metrics extraction: obtaining basic font information (such as font size, ascent / descent baseline, character width, etc.) for layout calculations. After collaboration with HarfBuzz, it outputs glyph pixel bitmaps (containing color / transparency information for each pixel) and the physical properties of the glyphs (such as width, height, baseline position, etc.).
[0027] In some embodiments, obtaining mask data from the text file data and determining the text drawing area through a text shaping engine and a font rendering engine includes: Retrieve text file data, which includes font format information, character encoding sequence, and font size parameters; The text shaping engine performs stroke processing and character spacing adjustment on font format information and character encoding sequence to generate glyph ID and glyph coordinate offset; The font rendering engine parses the glyph IDs to obtain the vector outlines of the glyphs; The vector contour is rasterized to obtain mask data; The boundary coordinates of the text drawing area are determined by combining the character shape coordinate offset and the character size parameter.
[0028] Specifically, the text file data is obtained, which includes font format information, character encoding sequence, and font size parameters. Among them, the font format information indicates whether the font is in TrueType or OpenType format; the character encoding sequence is the Unicode encoding array corresponding to the text to be processed; and the font size parameter is in pixels and is set to 12px, 16px, or 24px.
[0029] The font format information and character encoding sequence are then input into the text shaping engine. The text shaping engine identifies the stroke rules of the font based on the font format information, performs stroke processing on characters with stroke relationships in the character encoding sequence (such as fi, ff, etc.), and generates continuous glyph combinations. At the same time, based on the inherent character spacing parameters of the font and the language characteristics of the character encoding sequence, the spacing between adjacent characters is adjusted, and the output includes a glyph ID containing a unique identifier for each glyph, as well as the glyph coordinate offset (including X-axis offset value and Y-axis offset value) of each glyph relative to the text baseline.
[0030] Next, the glyph ID and font format information are passed to the font rendering engine. The font rendering engine loads the corresponding font file according to the font format information, locates and parses the vector outline of the glyph through the glyph ID, and the vector outline is composed of the control point coordinates and curve connection methods of multiple Bézier curves.
[0031] Then, the vector outline is processed by the font rendering engine using an anti-aliasing rasterization algorithm to convert the vector graphics into pixel bitmaps and obtain mask data. The mask data is a two-dimensional array, and the value of each element in the array corresponds to the transparency of the pixel, ranging from 0 to 255, where 0 represents complete transparency and 255 represents complete opacity.
[0032] Then, the glyph coordinate offsets output by the text shaping engine are extracted, and the actual display position of each glyph is calculated in combination with the font size parameter. The leftmost X coordinate offset of all glyphs is taken as the starting X, the rightmost X coordinate offset and the sum of the character width in the font size parameter are taken as the ending X, the top Y coordinate offset is taken as the starting Y, and the bottom Y coordinate offset and the sum of the character height in the font size parameter are taken as the ending Y. The boundary coordinates of the text drawing area are determined, and the boundary coordinates are represented by the upper left corner (starting X, starting Y) and the lower right corner (ending X, ending Y).
[0033] The data acquisition process in this embodiment comprehensively covers font format information, character encoding sequences, and font size parameters, providing complete and crucial foundational data support for subsequent processing and avoiding processing deviations caused by missing data. The text shaping engine specifically handles cursive writing and character spacing adjustments, adhering to both inherent font rules and language characteristics, ensuring standardized character combinations and harmonious character spacing, thus improving the aesthetics and rationality of text layout. The font rendering engine accurately parses vector outlines using glyph IDs and generates mask data using an anti-aliasing rasterization algorithm. This ensures accurate restoration of glyph outlines while optimizing pixel rendering and reducing edge blurring. Simultaneously, by combining glyph coordinate offsets and font size parameters to determine the boundary coordinates of the drawing area, precise definition of the drawing range is achieved, effectively preventing glyph misalignment or exceeding the display range. The overall process is logically coherent and tightly connected, significantly improving the efficiency and accuracy of the initial data processing for textured text.
[0034] S104: Input the mask data and the text drawing area into the typesetting engine for paragraph layout to obtain the mask glyph set; In this embodiment, please refer to Figure 8 In the complete word processing workflow, typesetting is a crucial step between HarfBuzz's character shaping and final rendering. It's responsible for organizing the processed character sequences into a visually compliant page structure. The goal of typesetting is to transform fragmented character sequences into a structured page layout, solving the problem of rationally arranging lines, paragraphs, and pages of text within a limited space, ensuring both readability and aesthetics. It mainly includes the following steps: Line layout, including line breaks, line height alignment with baseline, and horizontal alignment; Paragraph layout, including paragraph spacing calculation and text direction (e.g., right-to-left Arabic text); and complex scenario handling, including word segmentation (e.g., English word splitting) and automatic line wrapping. The typesetting engine relies on the outputs of both the text shaping engine and the font rendering engine, and provides coordinate information for the final rendering: the glyph buffer output by the text shaping engine contains the ID and initial position of each glyph (based on the width of the font itself), and the typesetting engine will use this as a basis to calculate line breaks in combination with the container width; the typesetting engine will finally determine the absolute drawing coordinates for each glyph (e.g., (x=100, y=200)), and FreeType will draw the rendered glyph bitmap to the corresponding position based on these coordinates.
[0035] In some embodiments, the mask data and text drawing area are passed to the typesetting engine for paragraph layout, resulting in a mask glyph set including: The mask data is associated with the bounding box information of the text drawing area to generate character arrangement order and paragraph constraint parameters; Based on character arrangement order and paragraph constraint parameters, the typesetting engine is called to calculate the line height, alignment, and character spacing adjustment values for each line of text, generating a set of line-level typesetting parameters; By combining the set of row-level typesetting parameters with the transparency distribution characteristics of the mask data, the mask region of the mask data is spatially relocated to form a set of mask glyphs arranged by row.
[0036] Specifically, the mask data and the bounding box information of the text drawing area are used as input to first establish a character-level association. The mask data for each character includes a pixel-level transparency distribution matrix, and the bounding box information includes the coordinates of the character's minimum bounding rectangle (x_min, y_min, x_max, y_max) and the character encoding identifier. By traversing the bounding box coordinates of all characters, a character arrangement sequence is generated based on the text flow direction (left to right / right to left / vertical direction). Simultaneously, paragraph constraint parameters are extracted, including the maximum line width (max_line_width), alignment identifiers (left / center / right / justify), first-line indent flag (first_indent_flag), and line spacing coefficient (line_gap_ratio). The character arrangement sequence and paragraph constraint parameters together constitute the input parameter set of the typesetting engine.
[0037] Next, the paragraph layout interface of the typesetting engine is called, taking the character arrangement sequence and paragraph constraint parameters as input. The typesetting engine first uses a greedy algorithm to fill characters line by line based on the maximum line width parameter, calculating the actual width and number of characters for each line. For each line of text, the line height (line_height = baseline_height * (1 + line_gap_ratio)) is determined using the baseline height (baseline_height) and line spacing coefficient from the font size data. Then, based on the alignment identifier, the horizontal offset (horizontal_offset) and kerning_adjustment value for each line are calculated. Finally, a set of line-level typesetting parameters is generated, containing the starting coordinates (start_x, start_y), the in-line character index range (char_indices), the line height value, and the kerning_adjustment value for each line. This parameter set provides a coordinate reference for subsequent spatial relocation.
[0038] Next, the set of line-level layout parameters and the transparency distribution features of the mask data are fused. For each line of text, a subset of mask data for the corresponding character is extracted based on the line start coordinates and character index range. The horizontal position of each character is corrected by adjusting the character spacing, and the new bounding box coordinates (adjusted_x_min, adjusted_y_min, adjusted_x_max, adjusted_y_max) are calculated. The transparency distribution matrix of the original mask data is spatially mapped to the adjusted bounding box coordinates to generate a new mask region. Specifically, for the transparency value α(i,j) of each pixel (i,j), its new position (i',j') in the target coordinate system is calculated based on the line height value and the character spacing adjustment value, and the transparency value at this position is recorded. The repositioned mask regions of all lines are integrated in line order to form a mask glyph set arranged by line. This glyph set contains the coordinate range of the mask region for each line and the corresponding transparency distribution matrix, supporting subsequent texture mapping and rendering operations.
[0039] During the spatial repositioning of the mask area, a dynamic adjustment mechanism is introduced to handle complex typesetting requirements. When a character is detected to exceed the maximum line width, automatic line wrapping is triggered, and the line height and character arrangement order of the current line are recalculated. For justified alignment, the extra spacing between characters is evenly distributed by calculating the expansion coefficient of the in-line character spacing. In vertical typesetting scenarios, the calculation logic of the line start coordinates is adjusted to ensure that the baseline alignment is consistent with the character orientation. In addition, for high-resolution display requirements, a bilinear interpolation algorithm is used to optimize the transparency distribution of the mask area, avoiding the jagged effect caused by coordinate transformation.
[0040] The resulting row-arranged mask glyph set can be directly used in the graphics rendering pipeline. This glyph set supports efficient texture sampling and blending operations by binding the masked regions of each row to typographic parameters. In practical applications, the mask glyph set can be combined with pre-prepared texture image data to achieve high-quality textured text rendering effects through GPU-accelerated shader programs. Furthermore, this method is compatible with multiple font formats (TrueType / OpenType) and typographic rules (Arabic cursive / Chinese simplified / traditional switching), meeting cross-platform application requirements.
[0041] S105: Based on the mask glyph set, generate a color mask glyph set by copying; Usually, such as Figure 9As shown, glyphs, after being shaped by HarfBuzz, extracted by FreeType, and processed by the typesetting engine, are divided into two main categories: MaskGlyphs and ColorGlyphs. MaskGlyphs are a set of glyphs that define the visible area of a glyph using a mask. They are used to draw basic glyphs, control transparency, and act as masking layers. They are typically represented by monochrome / grayscale bitmaps or vector outlines to indicate whether the area is drawn. Visually, they have no color of their own and rely on external fill colors or grayscale to represent transparency. ColorGlyphs are a set of glyphs that define and draw an area using colors with color attributes. They require external fonts or graphics to define glyph attributes / font format. They typically include multi-color layers, color palettes, or embedded color graphics, and have their own color information, allowing for the direct creation of colorful effects with graphics.
[0042] However, since this embodiment follows the normal font rendering process rather than the font-specific rendering process, the generated Glyphs are only maskGlyphs. But in order to obtain a texture effect rather than a single-channel grayscale effect, it is necessary to construct a colorAtlas. Therefore, the maskGlyph data is copied to construct colorGlyphs.
[0043] Specifically, the generation of a color mask glyph set through copying, based on the mask glyph set, includes: Perform a channel expansion operation on the outline of each character in the mask glyph set to generate an expanded mask, and match each channel of the expanded mask with the distribution rules of the preset color channels one by one; Based on the distribution rules, the transparency data of the mask glyph set is copied to the corresponding color channels to form a multi-channel color mapping matrix; Transparency gradient adjustment is performed on each color channel in the multi-channel color mapping matrix, and the transparency value of the corresponding color channel is dynamically scaled according to the boundary blur parameter of the character outline to generate layered transparency data. Layered transparency data is overlaid with a preset color palette channel by channel to generate a set of color mask glyphs.
[0044] More specifically, for the single-channel transparency data of each character in the mask glyph set, a channel expansion operation is performed to generate a three-channel expanded mask. This expansion process is achieved through a preset color channel distribution rule: the left half of the character outline is mapped to the red channel, the middle half to the green channel, and the right half to the blue channel, forming an asymmetrical three-channel structure. The pixel position of each channel is determined by the geometric features of the character outline, for example, by calculating the median of the lateral coordinates of the outline points to delineate the region boundaries.
[0045] Based on the color channel distribution rules, the transparency values of the original mask glyph set are proportionally copied to the corresponding extended channels. Specifically, for each pixel in the red channel region, its transparency value α_red = α_base * 0.8, where α_base is the transparency value of the original mask; the green channel uses α_green = α_base * 1.0; and the blue channel uses α_blue = α_base * 0.6. Through pixel-by-pixel mapping, a multi-channel color mapping matrix containing the transparency distributions of the red, green, and blue channels is generated, with the matrix size consistent with the original mask.
[0046] Subsequently, independent transparency gradient adjustments are performed on each channel in the multi-channel color mapping matrix. Taking the red channel as an example, based on the boundary blurring parameter b of the character outline (ranging from 0 to 1), an exponential decay function α'=α_red*e is used. (-b·d) , where d is the Euclidean distance from the pixel to the contour boundary. When b=0, the original transparency distribution is preserved; when b=1, the transparency value at the boundary decays rapidly to zero. Similarly, different gradient functions (such as linear decay or hyperbolic decay) are applied to the green and blue channels respectively to create differentiated transparency transition effects between channels.
[0047] Next, the gradient-adjusted layered transparency data is overlaid channel-by-channel with a preset color palette. The color palette includes basic color schemes (such as warm and cool colors) and gradient modes (linear / radial). The overlay coefficient for each channel is dynamically adjusted by the character type: for vowel characters, the overlay coefficient for the red channel is set to 1.2, and for the green channel, it is 0.8; consonant characters use the opposite configuration. The overlay operation uses a maximum value fusion algorithm, meaning that each pixel value of the final color mask is the product of the original transparency value of the corresponding channel and the color value of the palette, ultimately generating a color mask glyph set containing positional information, color channel distribution, and transparency gradient.
[0048] This embodiment also introduces a real-time parameter adjustment interface, allowing dynamic modification of boundary ambiguity parameters, channel distribution rules, and color palette configuration during the generation process. For example, when a punctuation mark is detected, the system automatically switches to a high-contrast color palette and disables the transparency attenuation function of the red channel. Furthermore, an adaptive sampling strategy is adopted for display devices with different resolutions: in low-resolution scenes, 2x oversampling is performed on the green channel to enhance detail.
[0049] This embodiment significantly improves the generation efficiency and visual expressiveness of color masked glyphs through multi-channel color mapping and dynamic transparency adjustment. First, channel expansion operations combined with asymmetric distribution rules give the transparency distribution of different color channels differentiated spatial characteristics, overcoming the limitations of traditional single-channel mapping and enhancing the layering of character outlines. Second, transparency gradient adjustment introduces a boundary ambiguity parameter, achieving a gradual transparency transition through an exponential decay function. This preserves the clarity of character edges while avoiding abrupt hard boundaries, making it particularly suitable for high-resolution display scenarios. Furthermore, the channel-by-channel overlay mechanism of the preset color palette allows for flexible adaptation to different color styles. Simultaneously, by dynamically adjusting the overlay coefficients of each channel, differentiated processing can be performed for typological requirements such as vowel / consonant characters and punctuation marks, improving visual consistency. Finally, the introduction of a real-time parameter adjustment interface and adaptive sampling strategy enables the system to automatically optimize the processing flow based on character type, display resolution, and other conditions, reducing computational overhead while ensuring rendering quality and meeting the performance requirements of cross-platform applications.
[0050] S106: Set the texture image data into the texture fill effect attribute of the brush structure, and configure the rendering method of the brush structure; Please see Figure 10 After obtaining the mask glyph set or color mask glyph set, a brush structure is created. This structure tells the GPU what kind of text to draw in the current glyph set. It includes four attributes: paintStyle (fill / cutout), color (only supports a single color), stroke style (rounded stroke / right-angle stroke), and custom effect shader (shader data input to the underlying OpenGL).
[0051] In some embodiments, setting texture image data into the texture fill effect attribute of the brush structure and configuring the rendering method of the brush structure includes: Extract pixel arrangement information and color channel data from texture image data; Obtain the brush structure, which contains texture fill effect attributes, rendering method parameters, and attribute association identifiers; Set the pixel arrangement information and color channel data into the texture fill effect property of the brush structure accordingly; Establish a mapping relationship between pixel arrangement information and texture fill effect attributes, and set the mapping relationship in the attribute association identifier; Configure the rendering parameters of the brush structure based on the color channel data.
[0052] Specifically, pixel arrangement information and color channel data are extracted from the texture image data. The pixel arrangement information includes the number of rows and columns of the pixel matrix and the coordinate index of each pixel in the matrix; the color channel data includes the color value range (0-255) of each of the three RGB channels, the brightness correlation coefficient between channels, and the color transition threshold.
[0053] Then, the brush structure is obtained, which contains texture fill effect attributes, rendering mode parameters, and attribute association identifiers. Texture fill effect attributes cover texture size adaptation parameters, pixel sampling mode, and channel mapping range; rendering mode parameters include color blending mode (normal, overlay, multiply), edge anti-aliasing level, and texture repetition strategy; attribute association identifiers are a two-dimensional array used to store index information of data mapping relationships.
[0054] Next, the number of rows and columns in the pixel arrangement information are set to the texture size adaptation parameters of the texture fill effect attribute, and the pixel coordinate index is set to the sampling point coordinates of the pixel sampling mode. The RGB color value range in the color channel data is set to the upper and lower limits of the channel mapping interval, and the brightness correlation coefficient and color transition threshold are stored as supplementary parameters in the extended fields of the texture fill effect attribute.
[0055] Next, establish a mapping relationship between pixel arrangement information and texture fill effect attributes: using the coordinate index of pixel arrangement information as the key and the parameter ID of the corresponding sampling point in the texture fill effect attribute as the value, form a key-value pair set, and write the set into a two-dimensional array of attribute association identifiers in order to realize the direct association between the two.
[0056] Then, the rendering method parameters are configured according to the color channel data: if the overlap of the RGB color value range in the color channel data exceeds 60%, the color blending mode is set to overlay; if the brightness correlation coefficient is greater than 0.8, the edge anti-aliasing level is adjusted to the highest level; the texture continuity is judged according to the color transition threshold. When the threshold is less than 20, the texture repetition strategy is set to seamless stitching, otherwise it is set to edge clipping.
[0057] This embodiment provides complete and detailed basic data support for the precise setting of texture fill effects by extracting pixel arrangement information and color channel data from texture images, ensuring that subsequent processing accurately reflects the original characteristics of the texture. By mapping this data to the texture fill effect attributes of the brush structure, a direct association between texture data and fill attributes is achieved, avoiding fill deviations caused by data mismatch or omissions. The mapping relationship established in the attribute association identifier creates a clear correspondence between pixel arrangement information and texture fill effect attributes, facilitating quick querying and retrieval, and improving data processing efficiency. Simultaneously, dynamically configuring rendering method parameters based on color channel data can adapt to the color characteristics of the texture. For example, adjusting the blending mode and anti-aliasing level through color value overlap and brightness correlation coefficients makes the rendering effect more closely match the visual characteristics of the texture itself, enhancing the rationality and flexibility of texture application.
[0058] S107: Generate a color atlas based on the color mask glyph set and the configured brush structure; After setting the texture image data into the texture fill effect properties of the brush structure and configuring the rendering method of the brush structure, the corresponding textAtlas and glyph information table are generated using glyphs and textPaint. The textAtlas is a glyph atlas, a technique that merges multiple glyphs into a single texture image. Its core purpose is to reduce draw calls and improve rendering efficiency. The glyph information table contains information such as the size, baseline offset, and position of the glyphs. TextAtlas is very common in text rendering, and it mainly consists of three steps: ① merging the bitmaps (pixel data with alpha channels) of multiple commonly used glyphs (such as ASCII characters and common Chinese characters) into a large texture (Atlas texture); ② fixing each character into a finite-sized character atlas using a boxing algorithm. Bin packing algorithms are a type of optimization algorithm whose core objective is to minimize container usage, reduce space waste, or satisfy specific constraints (such as item priority). They are widely used in logistics, storage, graphics rendering, and other scenarios. ③ Record the position coordinates (x, y) and dimensions (width and height) of each glyph in the Atlas texture to form a "glyph information table" (containing UV coordinates, offsets, etc.). ④ When rendering text, only one drawing call is needed. By indexing the glyph information table, the UV coordinates of each character in the Atlas can be obtained, and samples can be taken from a single texture and drawn in batches.
[0059] TextAtlas can be further divided into maskAtlas and colorAtlas, with each glyph type generating a corresponding character atlas. It's worth noting that in common text rendering engines, maskAtlas only generates single-channel shape outlines with alpha, lacking color information. Therefore, when a color image is input as color data to the maskAtlas, the color information is automatically removed. The maskAtlas needs to be drawn first, and then the color can be set externally. However, at this point, color information can only be added to the maskAtlas using masking functions, and the added color information must also move with the text; otherwise, the text will have a constantly changing color position. ColorAtlas, on the other hand, supports color information in text rendering engines. When color information is input, the arranged glyphs are bound to the color, ensuring that the color does not change when the text moves. It's important to note that colorAtlas is generated from color glyphs, and color glyphs require the creation of a colored font to be parsed and obtained.
[0060] In some embodiments, generating a color atlas based on a color mask glyph set and a configured brush structure includes: Align the layered transparency data of the color mask glyph set with the texture fill effect attribute of the brush structure to generate a composite texture parameter set. The composite texture parameter set contains the color channel index and texture coordinate offset corresponding to each character outline. Based on the color channel index, the texture sub-image of the corresponding region is extracted from the texture fill effect attribute, and the texture sub-image is spatially transformed according to the texture coordinate offset to generate character-level texture slice data. The character-level texture slice data and layered transparency data are blended pixel by pixel. The blending algorithm is determined by the blending mode selection flag configured in the brush structure, and the character texture output is generated. The character texture outputs are integrated into a unified texture space according to a preset arrangement rule, and a color atlas is generated through a texture compression algorithm.
[0061] Specifically, the layered transparency data of the color mask glyph set is aligned with the texture fill effect attributes of the brush structure through channels to generate a composite texture parameter set. The color mask glyph set contains a multi-channel color pixel matrix, layered transparency data (including transparency gradient values of the four channels R, G, B, and Alpha), and position coordinates for each character; the configured texture fill effect attributes of the brush structure include texture pixel arrangement information, color channel mapping range, texture size adaptation parameters, and a channel index table.
[0062] Next, a channel alignment algorithm is used to map the R, G, B, and Alpha channels of the color mask glyph set to the corresponding channels of the brush structure texture fill effect attribute. Using the channel identifiers of the layered transparency data as a benchmark, the identifier values in the channel index table of the texture fill effect attribute are matched to ensure that channels of the same type (such as the R channels of both) correspond in position during data processing. After alignment, the color channel index corresponding to each character outline in the texture fill effect attribute is extracted (recording the position of the texture color channel that the character should use). Combined with the character position coordinates and texture size adaptation parameters, the texture coordinate offset (i.e., the position offset value of the character in texture space) is calculated and integrated to form a composite texture parameter set. This set contains the color channel index, texture coordinate offset, and channel alignment identifier of each character.
[0063] Then, based on the color channel index, the corresponding texture sub-image is extracted from the texture fill effect attribute, and the texture sub-image is spatially transformed according to the texture coordinate offset to generate character-level texture slice data. According to the color channel index in the composite texture parameter set, the pixel matrix region of the corresponding channel in the pixel arrangement information of the texture fill effect attribute is located, and the pixel data of this region is extracted as the initial texture sub-image. The initial texture sub-image contains the RGB color value matrix and size parameters (width and height in pixels) of this region.
[0064] Next, based on the texture coordinate offset, a spatial transformation is performed on the initial texture sub-image: if the offset is positive, the sub-image is translated by the corresponding number of pixels along the positive X-axis or Y-axis; if the offset includes a scaling factor, the sub-mesh is scaled proportionally according to the factor to ensure that the sub-image size matches the size of the bounding rectangle of the character outline; if a rotation angle parameter exists, the sub-image is rotated using an affine transformation algorithm. After the transformation, character-level texture slice data adapted to the size and position of the character outline is obtained. This data includes the transformed pixel matrix, slice boundary coordinates, and texture integrity check value.
[0065] The character-level texture slice data and the layered transparency data are then blended pixel by pixel. The blending algorithm is determined by the blending mode selection flag configured in the brush structure, generating the character texture output. Each pixel of the character-level texture slice data contains RGB color values (R1, G1, B1), and the corresponding pixel of the layered transparency data contains four-channel transparency values (Ra, Ga, Ba, Aa).
[0066] In the rendering parameters of the brush structure, the blending mode selection flag has three states: 0 (normal blending), 1 (overlay blending), and 2 (multiply blending). If the flag is 0, the "color value × transparency" algorithm is used to calculate the output color value of each pixel (R=R1×Ra, G=G1×Ga, B=B1×Ba). If the flag is 1, the "bottom color + top color - bottom color × top color" algorithm is used, combined with the character background color for overlay operation. If the flag is 2, the "bottom color × top color" algorithm is used to enhance the overlay depth of the texture. After the calculation is completed, the output color values and alpha channel data of all pixels are integrated to generate the character texture output of a single character, including the output pixel matrix and character boundary mask.
[0067] Next, the character texture outputs are integrated into a unified texture space according to a preset arrangement rule, and a color atlas is generated through a texture compression algorithm. The preset arrangement rule is a grid arrangement: based on the width of the unified texture space (e.g., 2048 pixels), the number of character texture outputs that can be accommodated in each row is calculated (number per row = texture space width ÷ width of a single character texture). According to the arrangement order of the characters in the color mask glyph set, the character texture outputs are placed in the corresponding positions of the grid in sequence, and a 2-pixel interval is maintained between adjacent characters to avoid edge confusion.
[0068] After integration, an original texture matrix containing all character textures is obtained. The ETC2 texture compression algorithm is then applied to this matrix: the original texture matrix is divided into 4×4 pixel sub-blocks, and the color value of each sub-block is quantized and encoded, preserving key color information while reducing data volume. After compression, a color atlas containing the overall texture matrix, a character position index table (recording the coordinates and size of each character in the atlas), and a compression format identifier is generated. This atlas can be directly used for subsequent text rendering.
[0069] This embodiment achieves precise matching between the layered transparency data of the color mask glyph set and the brush texture fill effect attributes through channel alignment, avoiding texture offset or color distortion caused by channel mismatch from the source, laying a precise foundation for subsequent processing. Extracting texture sub-images based on color channel indexes and performing spatial transformations using coordinate offsets allows the texture sub-images to adapt to the character outline size and position height, ensuring complete and fitting texture coverage for each character and improving the visual uniformity of the color atlas. Dynamically selecting the blending algorithm based on the brush configuration's blending mode allows for flexible adaptation to different texture styles and color requirements. Whether in normal blending, overlay, or multiply mode, it accurately presents the expected effect, enhancing application flexibility. Finally, integrating character textures according to grid rules and compressing them using the ETC2 algorithm avoids character edge confusion, significantly reduces the atlas data size, lowers storage and transmission costs, and facilitates rapid subsequent retrieval of the character position index table, balancing visual effects and usage efficiency.
[0070] S108: Render the color atlas to obtain textured text.
[0071] Specifically, the generated color atlas is uploaded as a texture resource to the texture memory of the graphics processor and bound thereon.
[0072] Then, obtain the shader program containing texture sampling and color blending logic, and pass the texture sampler handle of the color atlas, as well as unified variables such as the position and color of the text, to the shader program.
[0073] Next, activate and configure the blending state of the graphics rendering pipeline, setting the blending function applicable to textures with alpha channels.
[0074] Then, the rendering command is invoked, initiating a drawing command based on the text's mesh geometry data (usually consisting of a vertex array containing texture coordinates). The vertex data contains the position of each character on the screen and its corresponding texture coordinates in the color atlas.
[0075] Subsequently, the graphics processor processes the position information of each vertex during the vertex shading stage of the rendering pipeline, samples the bound color atlas during the fragment shading stage, and calculates the final color value of each fragment according to the preset blending logic.
[0076] After passing through pipeline stages such as rasterization and blending, the final textured text with correct texture mapping effect is obtained in the frame buffer.
[0077] In some embodiments, after the typesetting engine completes the text paragraph layout and generates the mask glyph set, it synchronously obtains the position coordinates of each character. These coordinates are calculated by the typesetting engine based on the character arrangement order, line-level typesetting parameters, and the boundaries of the text drawing area. They are in pixels of a unified texture space and include the X-axis and Y-axis coordinates of each character in the rendering canvas, with the coordinate order consistent with the text rendering order.
[0078] Retrieve the generated color atlas, which contains the original texture matrix, a character position index table, and an information table. The information table stores basic information such as the unique identifier of each character, the coordinates of the original texture slice, and size parameters. A new position coordinate field is added to store the corresponding position data after layout.
[0079] The position coordinates of each character output by the typesetting engine are matched one-to-one with the records in the information table according to the character's unique identifier. The corresponding X-axis and Y-axis coordinates are then written into the position coordinate field of the information table, completing the data update of the information table. The updated information table forms an association mapping between the character's unique identifier, the original texture slice coordinates, the size parameters, and the position coordinates.
[0080] During the subsequent rendering process, the rendering engine reads the information table of the color atlas, extracts the original texture slice data, size parameters and corresponding position coordinates of each character in the order of text rendering, determines the specific display position of each character in the rendering canvas based on the position coordinates, and loads the corresponding texture slice data for drawing. In the end, the text texture effect is arranged according to the preset rendering order, and the texture position is accurately adapted to the position coordinates, without any fixed situation.
[0081] In some embodiments, a non-uniform scaling factor is added to the vertex shader of the graphics rendering pipeline to calculate the character target rendering size and the original texture size. This calculation obtains the width and height values of the character in screen space and divides them by the corresponding width and height of the character in the color atlas texture, respectively, to obtain two independent scaling factors, one horizontal and one vertical.
[0082] The calculated non-uniform scaling factor is then passed as an additional variable to the fragment shader. In the fragment shader, this factor is used to dynamically control the detail level parameters of the texture sampler. Specifically, based on the maximum or average value of the scaling factor, an appropriate mipmap level selection bias is dynamically calculated and set, enabling the sampler to adapt to the scaling state of the current character and select a more suitable texture detail level.
[0083] Then, in the fragment shader, the difference between the width scaling factor and the height scaling factor of the character is further compared. Based on this difference, the anisotropic filtering parameters of the texture sampler are adaptively set. For example, when the width scaling factor of the character is detected to be significantly greater than the height scaling factor, the anisotropic filtering level is automatically increased to a higher setting; when the width and height scaling are similar, the default lower level setting is used.
[0084] Subsequently, the graphics processor samples the color atlas texture according to the dynamically set anisotropic filtering level, and optimizes the filtering of non-uniformly scaled characters during the fragment shading process, thereby completing the improved anti-aliasing processing in the rendering pipeline.
[0085] Please see Figure 11 and Figure 12In a specific implementation example, even if the position or orientation of the text is changed, there is no need to calculate extra matrix to set the texture position, which greatly saves computational performance.
[0086] Please see Figure 13 This embodiment provides a novel textured text creation device 200, comprising: Acquisition unit 201 is used to acquire text file data and texture image data; Composition unit 202 is used to combine the text file data and the texture image data into structural data, and to pass the structural data into the text rendering engine; The determining unit 203 is used to obtain mask data from the text file data through the text shaping engine and the font rendering engine in the text rendering engine, and to determine the text drawing area; The layout unit 204 is used to input the mask data and the text drawing area into the typesetting engine for paragraph layout to obtain the mask glyph set; Copying unit 205 is used to generate a color mask glyph set by copying based on the mask glyph set; Configuration unit 206 is used to set the texture image data into the texture fill effect attribute of the brush structure and configure the rendering method of the brush structure. The generation unit 207 is used to generate a color atlas based on the color mask glyph set and the configured brush structure; The output unit 208 is used to render and output the color atlas to obtain textured text.
[0087] Furthermore, the constituent unit 202 includes: The extraction subunit is used to parse and extract the text file data to obtain glyph outline parameters, font size data and character encoding information; The segmentation processing subunit is used to perform region segmentation processing on the texture image data based on the character outline parameters and the font size data to obtain sub-texture data that matches each character outline; The association subunit is used to combine the glyph contour parameters, font size data, character encoding information, and segmented sub-texture data into a joint structure data containing a mapping index, wherein the mapping index is used to associate the character encoding information with the corresponding sub-texture data.
[0088] Furthermore, the determining unit 203 includes: The data acquisition subunit is used to acquire text file data, which includes font format information, character encoding sequence and font size parameters. The character spacing adjustment subunit is used to perform stroke processing and character spacing adjustment on the font format information and the character encoding sequence through the text shaping engine, and generate character ID and character coordinate offset; The parsing subunit is used to parse the glyph ID through the font rendering engine to obtain the vector outline of the glyph; A rasterization subunit is used to rasterize the vector contour to obtain mask data; The coordinate determination subunit is used to determine the boundary coordinates of the text drawing area by combining the character shape coordinate offset and the character size parameter.
[0089] Furthermore, the layout unit 204 includes: The association processing subunit is used to associate the mask data with the bounding box information of the text drawing area to generate character arrangement order and paragraph constraint parameters; The calling sub-unit is used to call the typesetting engine to calculate the line height, alignment, and character spacing adjustment value of each line of text based on the character arrangement order and the paragraph constraint parameters, and generate a set of line-level typesetting parameters; The repositioning subunit is used to spatially reposition the mask region of the mask data by combining the set of row-level layout parameters with the transparency distribution characteristics of the mask data, so as to form a set of mask glyphs arranged in rows.
[0090] Furthermore, the replication unit 205 includes: The expansion operation subunit is used to perform channel expansion operation on each character outline in the mask glyph set, generate an expanded mask, and match each channel of the expanded mask with a preset color channel distribution rule; The data copying subunit is used to copy the transparency data of the mask glyph set to the corresponding color channel based on the distribution rules, forming a multi-channel color mapping matrix; The gradient adjustment subunit is used to perform transparency gradient adjustment on each color channel in the multi-channel color mapping matrix, dynamically scaling the transparency value of the corresponding color channel according to the boundary blur parameter of the character outline, and generating layered transparency data. The overlay subunit is used to overlay the layered transparency data with a preset color palette channel by channel to generate a color mask glyph set.
[0091] Furthermore, the configuration unit 206 includes: An information extraction subunit is used to extract pixel arrangement information and color channel data from the texture image data; The structure acquisition subunit is used to acquire the brush structure, which includes texture fill effect attributes, rendering method parameters and attribute association identifiers. The sub-unit is configured to set the pixel arrangement information and color channel data into the texture fill effect attribute of the brush structure. The relationship establishment subunit is used to establish a mapping relationship between pixel arrangement information and texture fill effect attributes and to set the mapping relationship in the attribute association identifier; The parameter configuration subunit is used to configure the rendering method parameters of the brush structure according to the color channel data.
[0092] Furthermore, the generation unit 207 includes: The channel alignment subunit is used to align the layered transparency data of the color mask glyph set with the texture fill effect attribute of the brush structure to generate a composite texture parameter set, which includes the color channel index and texture coordinate offset corresponding to each character outline. The spatial transformation subunit is used to extract the texture sub-image of the corresponding region from the texture fill effect attribute based on the color channel index, and perform spatial transformation on the texture sub-image according to the texture coordinate offset to generate character-level texture slice data. The blending operation subunit is used to perform pixel-by-pixel blending operations on the character-level texture slice data and the layered transparency data, determine the blending algorithm according to the blending mode selection flag configured in the brush structure, and generate character texture output. The integration subunit is used to integrate the character texture output into a unified texture space according to a preset arrangement rule, and generate a color atlas through a texture compression algorithm.
[0093] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0094] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed, can implement the methods provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0095] The present invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the methods provided in the above embodiments. Of course, the computer device may also include various network interfaces, power supplies, and other components.
[0096] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this invention.
[0097] It should also be noted that, in this specification, 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-exclusivity.
[0098] The term "comprises" implies that a process, method, article, or apparatus 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 apparatus. Unless otherwise specified, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A novel method for creating textured text, characterized in that, include: Retrieve text file data and texture image data; The text file data and the texture image data are combined to form structural data, and the structural data is then passed into the text rendering engine. In the text rendering engine, mask data is obtained from the text file data through the text shaping engine and the font rendering engine, and the text drawing area is determined. The mask data and the text drawing area are fed into the typesetting engine for paragraph layout to obtain the mask glyph set; Based on the mask glyph set, a color mask glyph set is generated by copying; Set the texture image data into the texture fill effect attribute of the brush structure, and configure the rendering method of the brush structure; A color atlas is generated based on the color mask glyph set and the configured brush structure; The color atlas is rendered and output to obtain textured text.
2. The novel textured text creation method according to claim 1, characterized in that, The step of combining the text file data and the texture image data to form structured data includes: The text file data is parsed and extracted to obtain glyph outline parameters, font size data, and character encoding information; Based on the character outline parameters and the font size data, the texture image data is segmented to obtain sub-texture data that matches the outline of each character. The glyph contour parameters, font size data, character encoding information, and segmented sub-texture data are combined into a joint structure data containing a mapping index, which is used to associate the character encoding information with the corresponding sub-texture data.
3. The novel textured text creation method according to claim 1, characterized in that, The step of obtaining mask data from the text file data through the text shaping engine and font rendering engine, and determining the text drawing area includes: Obtain text file data, wherein the text file data includes font format information, character encoding sequence and font size parameters; The text shaping engine performs stroke processing and character spacing adjustment on the font format information and the character encoding sequence to generate glyph ID and glyph coordinate offset. The font rendering engine parses the glyph ID to obtain the vector outline of the glyph; The vector contour is rasterized to obtain mask data; The boundary coordinates of the text drawing area are determined by combining the character shape coordinate offset and the character size parameter.
4. The novel textured text creation method according to claim 1, characterized in that, The step of inputting the mask data and the text drawing area into the typesetting engine for paragraph layout to obtain the mask glyph set includes: The mask data is associated with the bounding box information of the text drawing area to generate character arrangement order and paragraph constraint parameters; Based on the character arrangement order and the paragraph constraint parameters, the typesetting engine is called to calculate the line height, alignment, and character spacing adjustment values for each line of text, generating a set of line-level typesetting parameters; By combining the set of row-level layout parameters with the transparency distribution characteristics of the mask data, the mask region of the mask data is spatially repositioned to form a set of mask glyphs arranged in rows.
5. The novel textured text creation method according to claim 1, characterized in that, The step of generating a color mask glyph set by copying based on the mask glyph set includes: Perform a channel expansion operation on each character outline in the mask glyph set to generate an expanded mask, and match each channel of the expanded mask with a preset color channel distribution rule; Based on the distribution rules, the transparency data of the mask glyph set is copied to the corresponding color channels to form a multi-channel color mapping matrix; Transparency gradient adjustment is performed on each color channel in the multi-channel color mapping matrix, and the transparency value of the corresponding color channel is dynamically scaled according to the boundary blur parameter of the character outline to generate layered transparency data. The layered transparency data is superimposed on a preset color palette channel by channel to generate a color mask glyph set.
6. The novel textured text creation method according to claim 1, characterized in that, The step of setting the texture image data into the texture fill effect attribute of the brush structure and configuring the rendering method of the brush structure includes: Extract the pixel arrangement information and color channel data from the texture image data; Obtain the brush structure, which includes texture fill effect attributes, rendering method parameters, and attribute association identifiers; The pixel arrangement information and color channel data are set into the texture fill effect attribute of the brush structure accordingly; Establish a mapping relationship between pixel arrangement information and texture fill effect attributes, and set the mapping relationship in the attribute association identifier; Configure the rendering method parameters of the brush structure based on the color channel data.
7. The novel textured text creation method according to claim 1, characterized in that, The process of generating a color atlas based on the color mask glyph set and the configured brush structure includes: The layered transparency data of the color mask glyph set is aligned with the texture fill effect attribute of the brush structure to generate a composite texture parameter set, which includes the color channel index and texture coordinate offset corresponding to each character outline. Based on the color channel index, the texture sub-image of the corresponding region is extracted from the texture fill effect attribute, and the texture sub-image is spatially transformed according to the texture coordinate offset to generate character-level texture slice data. The character-level texture slice data and the layered transparency data are mixed pixel by pixel. The mixing algorithm is determined according to the mixing mode selection flag configured in the brush structure to generate character texture output. The character texture outputs are integrated into a unified texture space according to a preset arrangement rule, and a color atlas is generated by a texture compression algorithm.
8. A novel textured text creation device, characterized in that, include: The acquisition unit is used to acquire text file data and texture image data; The component unit is used to combine the text file data and the texture image data into structural data, and to pass the data structure into the text rendering engine; The determining unit is used in the text rendering engine to obtain mask data from the text file data through the text shaping engine and the font rendering engine, and to determine the text drawing area; A layout unit is used to input the mask data and the text drawing area into the typesetting engine for paragraph layout, and obtain a mask glyph set; The copying unit is used to generate a color mask glyph set by copying the mask glyph set. The configuration unit is used to set the texture image data into the texture fill effect attribute of the brush structure and configure the rendering method of the brush structure. A generation unit is used to generate a color atlas based on the color mask glyph set and the configured brush structure; The output unit is used to render and output the color atlas to obtain textured text.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the novel textured text creation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the novel textured text creation method as described in any one of claims 1 to 7.